hyperbook 0.5.4 → 0.5.5
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 +5 -2
package/dist/index.js
CHANGED
|
@@ -128,4 +128,4 @@ var o=i(4300);var a=o.Buffer;function copyProps(t,r){for(var i in t){r[i]=t[i]}}
|
|
|
128
128
|
* @license [MIT]{@link https://github.com/archiverjs/node-zip-stream/blob/master/LICENSE}
|
|
129
129
|
* @copyright (c) 2014 Chris Talkington, contributors.
|
|
130
130
|
*/
|
|
131
|
-
var o=i(3837).inherits;var a=i(2096).ZipArchiveOutputStream;var l=i(2096).ZipArchiveEntry;var c=i(1246);var u=t.exports=function(t){if(!(this instanceof u)){return new u(t)}t=this.options=t||{};t.zlib=t.zlib||{};a.call(this,t);if(typeof t.level==="number"&&t.level>=0){t.zlib.level=t.level;delete t.level}if(!t.forceZip64&&typeof t.zlib.level==="number"&&t.zlib.level===0){t.store=true}t.namePrependSlash=t.namePrependSlash||false;if(t.comment&&t.comment.length>0){this.setComment(t.comment)}};o(u,a);u.prototype._normalizeFileData=function(t){t=c.defaults(t,{type:"file",name:null,namePrependSlash:this.options.namePrependSlash,linkname:null,date:null,mode:null,store:this.options.store,comment:""});var r=t.type==="directory";var i=t.type==="symlink";if(t.name){t.name=c.sanitizePath(t.name);if(!i&&t.name.slice(-1)==="/"){r=true;t.type="directory"}else if(r){t.name+="/"}}if(r||i){t.store=true}t.date=c.dateify(t.date);return t};u.prototype.entry=function(t,r,i){if(typeof i!=="function"){i=this._emitErrorCallback.bind(this)}r=this._normalizeFileData(r);if(r.type!=="file"&&r.type!=="directory"&&r.type!=="symlink"){i(new Error(r.type+" entries not currently supported"));return}if(typeof r.name!=="string"||r.name.length===0){i(new Error("entry name must be a non-empty string value"));return}if(r.type==="symlink"&&typeof r.linkname!=="string"){i(new Error("entry linkname must be a non-empty string value when type equals symlink"));return}var o=new l(r.name);o.setTime(r.date,this.options.forceLocalTime);if(r.namePrependSlash){o.setName(r.name,true)}if(r.store){o.setMethod(0)}if(r.comment.length>0){o.setComment(r.comment)}if(r.type==="symlink"&&typeof r.mode!=="number"){r.mode=40960}if(typeof r.mode==="number"){if(r.type==="symlink"){r.mode|=40960}o.setUnixMode(r.mode)}if(r.type==="symlink"&&typeof r.linkname==="string"){t=Buffer.from(r.linkname)}return a.prototype.entry.call(this,o,t,i)};u.prototype.finalize=function(){this.finish()}},7666:(t,r,i)=>{"use strict";i.r(r);const o=10;const wrapAnsi16=(t=0)=>r=>`[${r+t}m`;const wrapAnsi256=(t=0)=>r=>`[${38+t};5;${r}m`;const wrapAnsi16m=(t=0)=>(r,i,o)=>`[${38+t};2;${r};${i};${o}m`;function assembleStyles(){const t=new Map;const r={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};r.color.gray=r.color.blackBright;r.bgColor.bgGray=r.bgColor.bgBlackBright;r.color.grey=r.color.blackBright;r.bgColor.bgGrey=r.bgColor.bgBlackBright;for(const[i,o]of Object.entries(r)){for(const[i,a]of Object.entries(o)){r[i]={open:`[${a[0]}m`,close:`[${a[1]}m`};o[i]=r[i];t.set(a[0],a[1])}Object.defineProperty(r,i,{value:o,enumerable:false})}Object.defineProperty(r,"codes",{value:t,enumerable:false});r.color.close="[39m";r.bgColor.close="[49m";r.color.ansi=wrapAnsi16();r.color.ansi256=wrapAnsi256();r.color.ansi16m=wrapAnsi16m();r.bgColor.ansi=wrapAnsi16(o);r.bgColor.ansi256=wrapAnsi256(o);r.bgColor.ansi16m=wrapAnsi16m(o);Object.defineProperties(r,{rgbToAnsi256:{value:(t,r,i)=>{if(t===r&&r===i){if(t<8){return 16}if(t>248){return 231}return Math.round((t-8)/247*24)+232}return 16+36*Math.round(t/255*5)+6*Math.round(r/255*5)+Math.round(i/255*5)},enumerable:false},hexToRgb:{value:t=>{const r=/(?<colorString>[a-f\d]{6}|[a-f\d]{3})/i.exec(t.toString(16));if(!r){return[0,0,0]}let{colorString:i}=r.groups;if(i.length===3){i=[...i].map((t=>t+t)).join("")}const o=Number.parseInt(i,16);return[o>>16&255,o>>8&255,o&255]},enumerable:false},hexToAnsi256:{value:t=>r.rgbToAnsi256(...r.hexToRgb(t)),enumerable:false},ansi256ToAnsi:{value:t=>{if(t<8){return 30+t}if(t<16){return 90+(t-8)}let r;let i;let o;if(t>=232){r=((t-232)*10+8)/255;i=r;o=r}else{t-=16;const a=t%36;r=Math.floor(t/36)/5;i=Math.floor(a/6)/5;o=a%6/5}const a=Math.max(r,i,o)*2;if(a===0){return 30}let l=30+(Math.round(o)<<2|Math.round(i)<<1|Math.round(r));if(a===2){l+=60}return l},enumerable:false},rgbToAnsi:{value:(t,i,o)=>r.ansi256ToAnsi(r.rgbToAnsi256(t,i,o)),enumerable:false},hexToAnsi:{value:t=>r.ansi256ToAnsi(r.hexToAnsi256(t)),enumerable:false}});return r}const a=assembleStyles();const l=a;const c=require("node:process");const u=require("node:os");const h=require("node:tty");function hasFlag(t,r=c.argv){const i=t.startsWith("-")?"":t.length===1?"-":"--";const o=r.indexOf(i+t);const a=r.indexOf("--");return o!==-1&&(a===-1||o<a)}const{env:d}=c;let p;if(hasFlag("no-color")||hasFlag("no-colors")||hasFlag("color=false")||hasFlag("color=never")){p=0}else if(hasFlag("color")||hasFlag("colors")||hasFlag("color=true")||hasFlag("color=always")){p=1}function envForceColor(){if("FORCE_COLOR"in d){if(d.FORCE_COLOR==="true"){return 1}if(d.FORCE_COLOR==="false"){return 0}return d.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(d.FORCE_COLOR,10),3)}}function translateLevel(t){if(t===0){return false}return{level:t,hasBasic:true,has256:t>=2,has16m:t>=3}}function _supportsColor(t,{streamIsTTY:r,sniffFlags:i=true}={}){const o=envForceColor();if(o!==undefined){p=o}const a=i?p:o;if(a===0){return 0}if(i){if(hasFlag("color=16m")||hasFlag("color=full")||hasFlag("color=truecolor")){return 3}if(hasFlag("color=256")){return 2}}if(t&&!r&&a===undefined){return 0}const l=a||0;if(d.TERM==="dumb"){return l}if(c.platform==="win32"){const t=u.release().split(".");if(Number(t[0])>=10&&Number(t[2])>=10586){return Number(t[2])>=14931?3:2}return 1}if("CI"in d){if(["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE","DRONE"].some((t=>t in d))||d.CI_NAME==="codeship"){return 1}return l}if("TEAMCITY_VERSION"in d){return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(d.TEAMCITY_VERSION)?1:0}if("TF_BUILD"in d&&"AGENT_NAME"in d){return 1}if(d.COLORTERM==="truecolor"){return 3}if("TERM_PROGRAM"in d){const t=Number.parseInt((d.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(d.TERM_PROGRAM){case"iTerm.app":return t>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(d.TERM)){return 2}if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(d.TERM)){return 1}if("COLORTERM"in d){return 1}return l}function createSupportsColor(t,r={}){const i=_supportsColor(t,{streamIsTTY:t&&t.isTTY,...r});return translateLevel(i)}const m={stdout:createSupportsColor({isTTY:h.isatty(1)}),stderr:createSupportsColor({isTTY:h.isatty(2)})};const y=m;function stringReplaceAll(t,r,i){let o=t.indexOf(r);if(o===-1){return t}const a=r.length;let l=0;let c="";do{c+=t.substr(l,o-l)+r+i;l=o+a;o=t.indexOf(r,l)}while(o!==-1);c+=t.slice(l);return c}function stringEncaseCRLFWithFirstIndex(t,r,i,o){let a=0;let l="";do{const c=t[o-1]==="\r";l+=t.substr(a,(c?o-1:o)-a)+r+(c?"\r\n":"\n")+i;a=o+1;o=t.indexOf("\n",a)}while(o!==-1);l+=t.slice(a);return l}const{stdout:g,stderr:b}=y;const v=Symbol("GENERATOR");const _=Symbol("STYLER");const w=Symbol("IS_EMPTY");const E=["ansi","ansi","ansi256","ansi16m"];const S=Object.create(null);const applyOptions=(t,r={})=>{if(r.level&&!(Number.isInteger(r.level)&&r.level>=0&&r.level<=3)){throw new Error("The `level` option should be an integer from 0 to 3")}const i=g?g.level:0;t.level=r.level===undefined?i:r.level};class Chalk{constructor(t){return chalkFactory(t)}}const chalkFactory=t=>{const chalk=(...t)=>t.join(" ");applyOptions(chalk,t);Object.setPrototypeOf(chalk,createChalk.prototype);return chalk};function createChalk(t){return chalkFactory(t)}Object.setPrototypeOf(createChalk.prototype,Function.prototype);for(const[t,r]of Object.entries(l)){S[t]={get(){const i=createBuilder(this,createStyler(r.open,r.close,this[_]),this[w]);Object.defineProperty(this,t,{value:i});return i}}}S.visible={get(){const t=createBuilder(this,this[_],true);Object.defineProperty(this,"visible",{value:t});return t}};const getModelAnsi=(t,r,i,...o)=>{if(t==="rgb"){if(r==="ansi16m"){return l[i].ansi16m(...o)}if(r==="ansi256"){return l[i].ansi256(l.rgbToAnsi256(...o))}return l[i].ansi(l.rgbToAnsi(...o))}if(t==="hex"){return getModelAnsi("rgb",r,i,...l.hexToRgb(...o))}return l[i][t](...o)};const O=["rgb","hex","ansi256"];for(const t of O){S[t]={get(){const{level:r}=this;return function(...i){const o=createStyler(getModelAnsi(t,E[r],"color",...i),l.color.close,this[_]);return createBuilder(this,o,this[w])}}};const r="bg"+t[0].toUpperCase()+t.slice(1);S[r]={get(){const{level:r}=this;return function(...i){const o=createStyler(getModelAnsi(t,E[r],"bgColor",...i),l.bgColor.close,this[_]);return createBuilder(this,o,this[w])}}}}const R=Object.defineProperties((()=>{}),{...S,level:{enumerable:true,get(){return this[v].level},set(t){this[v].level=t}}});const createStyler=(t,r,i)=>{let o;let a;if(i===undefined){o=t;a=r}else{o=i.openAll+t;a=r+i.closeAll}return{open:t,close:r,openAll:o,closeAll:a,parent:i}};const createBuilder=(t,r,i)=>{const builder=(...t)=>applyStyle(builder,t.length===1?""+t[0]:t.join(" "));Object.setPrototypeOf(builder,R);builder[v]=t;builder[_]=r;builder[w]=i;return builder};const applyStyle=(t,r)=>{if(t.level<=0||!r){return t[w]?"":r}let i=t[_];if(i===undefined){return r}const{openAll:o,closeAll:a}=i;if(r.includes("")){while(i!==undefined){r=stringReplaceAll(r,i.close,i.open);i=i.parent}}const l=r.indexOf("\n");if(l!==-1){r=stringEncaseCRLFWithFirstIndex(r,a,o,l)}return o+r+a};Object.defineProperties(createChalk.prototype,S);const x=createChalk();const k=createChalk({level:b?b.level:0});const T=x;var A=i(345);const{program:C,createCommand:P,createArgument:I,createOption:L,CommanderError:M,InvalidArgumentError:D,InvalidOptionArgumentError:N,Command:j,Argument:B,Option:$,Help:H}=A;var U=i(5656);var q=i.n(U);var z=i(1017);var G=i.n(z);var W=i(7147);var V=i.n(W);function isSetup(){try{const t=V().statSync(G().join(process.cwd(),".hyperbook"));if(!t.isDirectory()){throw Error()}}catch(t){console.log(T.red("Could not find .hyperbook folder. Be sure to run `hyperbook setup`."));return false}try{V().statSync(G().join(process.cwd(),".hyperbook","node_modules",".bin","next"))}catch(t){console.log(T.red("Could not find next binary in the .hyperbook folder. Be sure to run `hyperbook setup`."));return false}return true}var Y=i(2202);var Z=i.n(Y);var K=i(7282);var Q=i.n(K);async function archiveFolder(t){return new Promise(((r,i)=>{const o=G().join(Q().cwd(),"public","archives");if(!V().existsSync(o)){V().mkdirSync(o,{recursive:true})}const a=G().join(o,t+".zip");const l=V().createWriteStream(a);const c=Z()("zip",{zlib:{level:9}});c.on("finish",(()=>{console.log(T.green("Archive zipped: ")+t);r()}));c.on("error",(t=>{throw t}));c.pipe(l);c.directory(G().join(Q().cwd(),"archives",t),false);c.finalize()}))}async function runArchive(){const t=isSetup();if(!t){throw new Error("no setup")}return new Promise(((t,r)=>{if(!V().existsSync(G().join(Q().cwd(),"archives"))){console.log(T.blue("info ")+"- No Archives found");t()}const i=V().readdirSync(G().join(Q().cwd(),"archives"),{withFileTypes:true}).filter((t=>t.isDirectory()));Promise.all(i.map((t=>archiveFolder(t.name)))).then((()=>{t()})).catch((()=>{r()}))}))}var X=i(4488);var J=i.n(X);async function readHyperbook(){return new Promise(((t,r)=>{V().readFile(G().join(process.cwd(),"hyperbook.json"),((i,o)=>{if(i){console.log(T.red("Could not find 'hyperbook.json'. Make sure you are in the right directory."));r()}else{const r=JSON.parse(o.toString());t(r)}}))}))}async function runBuild(){const t=isSetup();if(!t){throw new Error("no setup")}const r=await readHyperbook();V().writeFileSync(G().join(process.cwd(),".hyperbook","next.config.js"),`\nmodule.exports = {\n ${(r===null||r===void 0?void 0:r.basePath)?`basePath: '${r.basePath}',`:""}\n typescript: {\n ignoreBuildErrors: true,\n }\n}\n `);return new Promise(((t,r)=>{const i="npm";const o=["run","build"];const a=J()(i,o,{stdio:"inherit",cwd:G().join(process.cwd(),".hyperbook"),env:{...process.env,ADBLOCK:"1",DISABLE_OPENCOLLECTIVE:"1"}});a.on("close",(a=>{if(a!==0){r({command:`${i} ${o.join(" ")}`});return}t()}))}))}async function runDev(){const t=isSetup();if(!t){throw new Error("no setup")}return new Promise(((t,r)=>{const i="npm";const o=["run","dev"];const a=J()(i,o,{stdio:"inherit",cwd:G().join(process.cwd(),".hyperbook"),env:{...process.env,ADBLOCK:"1",DISABLE_OPENCOLLECTIVE:"1"}});a.on("close",(a=>{if(a!==0){r({command:`${i} ${o.join(" ")}`});return}t()}))}))}var ee=i(2081);function getPkgManager(){try{const t=process.env.npm_config_user_agent;if(t){if(t.startsWith("yarn")){return"yarn"}else if(t.startsWith("pnpm")){return"pnpm"}}try{(0,ee.execSync)("yarn --version",{stdio:"ignore"});return"yarn"}catch{(0,ee.execSync)("pnpm --version",{stdio:"ignore"});return"pnpm"}}catch{return"npm"}}var te=i(2037);var re=i.n(te);const ie=require("node:events");const se=require("node:path");function indentString(t,r=1,i={}){const{indent:o=" ",includeEmptyLines:a=false}=i;if(typeof t!=="string"){throw new TypeError(`Expected \`input\` to be a \`string\`, got \`${typeof t}\``)}if(typeof r!=="number"){throw new TypeError(`Expected \`count\` to be a \`number\`, got \`${typeof r}\``)}if(r<0){throw new RangeError(`Expected \`count\` to be at least 0, got \`${r}\``)}if(typeof o!=="string"){throw new TypeError(`Expected \`options.indent\` to be a \`string\`, got \`${typeof o}\``)}if(r===0){return t}const l=a?/^/gm:/^(?!\s*$)/gm;return t.replace(l,o.repeat(r))}function escapeStringRegexp(t){if(typeof t!=="string"){throw new TypeError("Expected a string")}return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}const ne=/\s+at.*[(\s](.*)\)?/;const oe=/^(?:(?:(?:node|node:[\w/]+|(?:(?:node:)?internal\/[\w/]*|.*node_modules\/(?:babel-polyfill|pirates)\/.*)?\w+)(?:\.js)?:\d+:\d+)|native)/;const ae=typeof te.homedir==="undefined"?"":te.homedir().replace(/\\/g,"/");function cleanStack(t,{pretty:r=false,basePath:i}={}){const o=i&&new RegExp(`(at | \\()${escapeStringRegexp(i.replace(/\\/g,"/"))}`,"g");if(typeof t!=="string"){return undefined}return t.replace(/\\/g,"/").split("\n").filter((t=>{const r=t.match(ne);if(r===null||!r[1]){return true}const i=r[1];if(i.includes(".app/Contents/Resources/electron.asar")||i.includes(".app/Contents/Resources/default_app.asar")){return false}return!oe.test(i)})).filter((t=>t.trim()!=="")).map((t=>{if(o){t=t.replace(o,"$1")}if(r){t=t.replace(ne,((t,r)=>t.replace(r,r.replace(ae,"~"))))}return t})).join("\n")}const cleanInternalStack=t=>t.replace(/\s+at .*aggregate-error\/index.js:\d+:\d+\)?/g,"");class AggregateError extends Error{#e;name="AggregateError";constructor(t){if(!Array.isArray(t)){throw new TypeError(`Expected input to be an Array, got ${typeof t}`)}t=t.map((t=>{if(t instanceof Error){return t}if(t!==null&&typeof t==="object"){return Object.assign(new Error(t.message),t)}return new Error(t)}));let r=t.map((t=>typeof t.stack==="string"?cleanInternalStack(cleanStack(t.stack)):String(t))).join("\n");r="\n"+indentString(r,4);super(r);this.#e=t}get errors(){return this.#e.slice()}}async function pMap(t,r,{concurrency:i=Number.POSITIVE_INFINITY,stopOnError:o=true}={}){return new Promise(((a,l)=>{if(t[Symbol.iterator]===undefined&&t[Symbol.asyncIterator]===undefined){throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof t})`)}if(typeof r!=="function"){throw new TypeError("Mapper function is required")}if(!((Number.isSafeInteger(i)||i===Number.POSITIVE_INFINITY)&&i>=1)){throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${i}\` (${typeof i})`)}const c=[];const u=[];const h=new Map;let d=false;let p=false;let m=false;let y=0;let g=0;const b=t[Symbol.iterator]===undefined?t[Symbol.asyncIterator]():t[Symbol.iterator]();const reject=t=>{d=true;p=true;l(t)};const next=async()=>{if(p){return}const t=await b.next();const i=g;g++;if(t.done){m=true;if(y===0&&!p){if(!o&&u.length>0){reject(new AggregateError(u));return}p=true;if(!h.size){a(c);return}const t=[];for(const[r,i]of c.entries()){if(h.get(r)===le){continue}t.push(i)}a(t)}return}y++;(async()=>{try{const o=await t.value;if(p){return}const a=await r(o,i);if(a===le){h.set(i,a)}c[i]=a;y--;await next()}catch(t){if(o){reject(t)}else{u.push(t);y--;try{await next()}catch(t){reject(t)}}}})()};(async()=>{for(let t=0;t<i;t++){try{await next()}catch(t){reject(t);break}if(m||d){break}}})()}))}const le=Symbol("skip");function arrify(t){if(t===null||t===undefined){return[]}if(Array.isArray(t)){return t}if(typeof t==="string"){return[t]}if(typeof t[Symbol.iterator]==="function"){return[...t]}return[t]}var ce=i(8174);class AbortError extends Error{constructor(t){super();this.name="AbortError";this.message=t}}const getDOMException=t=>globalThis.DOMException===undefined?new AbortError(t):new DOMException(t);const getAbortedReason=t=>{const r=t.reason===undefined?getDOMException("This operation was aborted."):t.reason;return r instanceof Error?r:getDOMException(r)};async function p_map_pMap(t,r,{concurrency:i=Number.POSITIVE_INFINITY,stopOnError:o=true,signal:a}={}){return new Promise(((l,c)=>{if(t[Symbol.iterator]===undefined&&t[Symbol.asyncIterator]===undefined){throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof t})`)}if(typeof r!=="function"){throw new TypeError("Mapper function is required")}if(!((Number.isSafeInteger(i)||i===Number.POSITIVE_INFINITY)&&i>=1)){throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${i}\` (${typeof i})`)}const u=[];const h=[];const d=new Map;let p=false;let m=false;let y=false;let g=0;let b=0;const v=t[Symbol.iterator]===undefined?t[Symbol.asyncIterator]():t[Symbol.iterator]();const reject=t=>{p=true;m=true;c(t)};if(a){if(a.aborted){reject(getAbortedReason(a))}a.addEventListener("abort",(()=>{reject(getAbortedReason(a))}))}const next=async()=>{if(m){return}const t=await v.next();const i=b;b++;if(t.done){y=true;if(g===0&&!m){if(!o&&h.length>0){reject(new AggregateError(h));return}m=true;if(d.size===0){l(u);return}const t=[];for(const[r,i]of u.entries()){if(d.get(r)===ue){continue}t.push(i)}l(t)}return}g++;(async()=>{try{const o=await t.value;if(m){return}const a=await r(o,i);if(a===ue){d.set(i,a)}u[i]=a;g--;await next()}catch(t){if(o){reject(t)}else{h.push(t);g--;try{await next()}catch(t){reject(t)}}}})()};(async()=>{for(let t=0;t<i;t++){try{await next()}catch(t){reject(t);break}if(y||p){break}}})()}))}const ue=Symbol("skip");async function pFilter(t,r,i){const o=await p_map_pMap(t,((t,i)=>Promise.all([r(t,i),t])),i);return o.filter((t=>Boolean(t[0]))).map((t=>t[1]))}const he=require("node:fs");var fe=i(9117);var de=i(5342);var pe=i(3286);var me=i(7993);function slash(t){const r=/^\\\\\?\\/.test(t);const i=/[^\u0000-\u0080]+/.test(t);if(r||i){return t}return t.replace(/\\/g,"/")}const ye=require("node:url");const ge=require("node:stream");const toPath=t=>t instanceof URL?(0,ye.fileURLToPath)(t):t;class FilterStream extends ge.Transform{constructor(t){super({objectMode:true,transform(r,i,o){o(undefined,t(r)?r:undefined)}})}}const isNegativePattern=t=>t[0]==="!";const be={ignore:["**/node_modules","**/flow-typed","**/coverage","**/.git"],absolute:true,dot:true};const ve="**/.gitignore";const applyBaseToPattern=(t,r)=>isNegativePattern(t)?"!"+se.posix.join(r,t.slice(1)):se.posix.join(r,t);const parseIgnoreFile=(t,r)=>{const i=slash(se.relative(r,se.dirname(t.filePath)));return t.content.split(/\r?\n/).filter((t=>t&&!t.startsWith("#"))).map((t=>applyBaseToPattern(t,i)))};const toRelativePath=(t,r)=>{r=slash(r);if(se.isAbsolute(t)){if(slash(t).startsWith(r)){return se.relative(r,t)}throw new Error(`Path ${t} is not in cwd ${r}`)}return t};const getIsIgnoredPredicate=(t,r)=>{const i=t.flatMap((t=>parseIgnoreFile(t,r)));const o=me().add(i);return t=>{t=toPath(t);t=toRelativePath(t,r);return o.ignores(slash(t))}};const normalizeOptions=(t={})=>({cwd:toPath(t.cwd)||c.cwd()});const isIgnoredByIgnoreFiles=async(t,r)=>{const{cwd:i}=normalizeOptions(r);const o=await de(t,{cwd:i,...be});const a=await Promise.all(o.map((async t=>({filePath:t,content:await he.promises.readFile(t,"utf8")}))));return getIsIgnoredPredicate(a,i)};const isIgnoredByIgnoreFilesSync=(t,r)=>{const{cwd:i}=normalizeOptions(r);const o=de.sync(t,{cwd:i,...be});const a=o.map((t=>({filePath:t,content:he.readFileSync(t,"utf8")})));return getIsIgnoredPredicate(a,i)};const isGitIgnored=t=>isIgnoredByIgnoreFiles(ve,t);const isGitIgnoredSync=t=>isIgnoredByIgnoreFilesSync(ve,t);const assertPatternsInput=t=>{if(t.some((t=>typeof t!=="string"))){throw new TypeError("Patterns must be a string or an array of strings")}};const toPatternsArray=t=>{t=[...new Set([t].flat())];assertPatternsInput(t);return t};const checkCwdOption=t=>{if(!t.cwd){return}let r;try{r=he.statSync(t.cwd)}catch{return}if(!r.isDirectory()){throw new Error("The `cwd` option must be a path to a directory")}};const globby_normalizeOptions=(t={})=>{t={ignore:[],expandDirectories:true,...t,cwd:toPath(t.cwd)};checkCwdOption(t);return t};const normalizeArguments=t=>async(r,i)=>t(toPatternsArray(r),globby_normalizeOptions(i));const normalizeArgumentsSync=t=>(r,i)=>t(toPatternsArray(r),globby_normalizeOptions(i));const getIgnoreFilesPatterns=t=>{const{ignoreFiles:r,gitignore:i}=t;const o=r?toPatternsArray(r):[];if(i){o.push(ve)}return o};const getFilter=async t=>{const r=getIgnoreFilesPatterns(t);return createFilterFunction(r.length>0&&await isIgnoredByIgnoreFiles(r,{cwd:t.cwd}))};const getFilterSync=t=>{const r=getIgnoreFilesPatterns(t);return createFilterFunction(r.length>0&&isIgnoredByIgnoreFilesSync(r,{cwd:t.cwd}))};const createFilterFunction=t=>{const r=new Set;return i=>{const o=i.path||i;const a=se.normalize(o);const l=r.has(a)||t&&t(o);r.add(a);return!l}};const unionFastGlobResults=(t,r)=>t.flat().filter((t=>r(t)));const unionFastGlobStreams=(t,r)=>fe(t).pipe(new FilterStream((t=>r(t))));const convertNegativePatterns=(t,r)=>{const i=[];while(t.length>0){const o=t.findIndex((t=>isNegativePattern(t)));if(o===-1){i.push({patterns:t,options:r});break}const a=t[o].slice(1);for(const t of i){t.options.ignore.push(a)}if(o!==0){i.push({patterns:t.slice(0,o),options:{...r,ignore:[...r.ignore,a]}})}t=t.slice(o+1)}return i};const getDirGlobOptions=(t,r)=>({...r?{cwd:r}:{},...Array.isArray(t)?{files:t}:t});const generateTasks=async(t,r)=>{const i=convertNegativePatterns(t,r);const{cwd:o,expandDirectories:a}=r;if(!a){return i}const l=getDirGlobOptions(a,o);const c=o?{cwd:o}:undefined;return Promise.all(i.map((async t=>{let{patterns:r,options:i}=t;[r,i.ignore]=await Promise.all([pe(r,l),pe(i.ignore,c)]);return{patterns:r,options:i}})))};const generateTasksSync=(t,r)=>{const i=convertNegativePatterns(t,r);const{cwd:o,expandDirectories:a}=r;if(!a){return i}const l=getDirGlobOptions(a,o);const c=o?{cwd:o}:undefined;return i.map((t=>{let{patterns:r,options:i}=t;r=pe.sync(r,l);i.ignore=pe.sync(i.ignore,c);return{patterns:r,options:i}}))};const _e=normalizeArguments((async(t,r)=>{const[i,o]=await Promise.all([generateTasks(t,r),getFilter(r)]);const a=await Promise.all(i.map((t=>de(t.patterns,t.options))));return unionFastGlobResults(a,o)}));const we=normalizeArgumentsSync(((t,r)=>{const i=generateTasksSync(t,r);const o=getFilterSync(r);const a=i.map((t=>de.sync(t.patterns,t.options)));return unionFastGlobResults(a,o)}));const Ee=normalizeArgumentsSync(((t,r)=>{const i=generateTasksSync(t,r);const o=getFilterSync(r);const a=i.map((t=>de.stream(t.patterns,t.options)));return unionFastGlobStreams(a,o)}));const Se=normalizeArgumentsSync(((t,r)=>t.some((t=>de.isDynamicPattern(t,r)))));const Oe=normalizeArguments(generateTasks);const Re=normalizeArgumentsSync(generateTasksSync);var xe=i(7971);var ke=i(3134);class CpyError extends ke{constructor(t,r){super(t,r);Object.assign(this,r);this.name="CpyError"}}const Te=["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^Desktop\\.ini$","@eaDir$"];const Ae=new RegExp(Te.join("|"));function isJunk(t){return Ae.test(t)}function isNotJunk(t){return!isJunk(t)}class GlobPattern{constructor(t,r,i){this.path=t;this.originalPath=t;this.destination=r;this.options=i;this.isDirectory=false;if(!Se(t)&&he.existsSync(t)&&he.lstatSync(t).isDirectory()){this.path=[t,"**"].join("/");this.isDirectory=true}}get name(){return se.basename(this.originalPath)}get normalizedPath(){const t=this.originalPath.split("/");const r=t.findIndex((t=>t?Se(t):false));const i=t.slice(0,r).join("/");if(i){return se.isAbsolute(i)?i:se.join(this.options.cwd,i)}return this.destination}hasMagic(){return Se(this.options.flat?this.path:this.originalPath)}getMatches(){let t=we(this.path,{...this.options,dot:true,absolute:true,onlyFiles:true});if(this.options.ignoreJunk){t=t.filter((t=>isNotJunk(se.basename(t))))}return t}}const Ce=(u.cpus().length||1)*2;const Pe={ignoreJunk:true,flat:false,cwd:c.cwd()};class Entry{constructor(t,r,i){this.path=t.split("/").join(se.sep);this.relativePath=r.split("/").join(se.sep);this.pattern=i;Object.freeze(this)}get name(){return se.basename(this.path)}get nameWithoutExtension(){return se.basename(this.path,se.extname(this.path))}get extension(){return se.extname(this.path).slice(1)}}const expandPatternsWithBraceExpansion=t=>t.flatMap((t=>xe.braces(t,{expand:true,nodupes:true})));const preprocessDestinationPath=({entry:t,destination:r,options:i})=>{if(t.pattern.hasMagic()){if(i.flat){if(se.isAbsolute(r)){return se.join(r,t.name)}return se.join(i.cwd,r,t.name)}return se.join(r,se.relative(t.pattern.normalizedPath,t.path))}if(se.isAbsolute(r)){return se.join(r,t.name)}if(t.pattern.isDirectory&&se.relative(i.cwd,t.path).startsWith("..")){return se.join(i.cwd,r,se.basename(t.pattern.originalPath),se.relative(t.pattern.originalPath,t.path))}if(!t.pattern.isDirectory&&t.path===t.relativePath){return se.join(i.cwd,r,se.basename(t.pattern.originalPath),se.relative(t.pattern.originalPath,t.path))}if(!t.pattern.isDirectory&&i.flat){return se.join(i.cwd,r,se.basename(t.pattern.originalPath))}return se.join(i.cwd,r,se.relative(i.cwd,t.path))};const renameFile=(t,r)=>{const i=se.basename(t,se.extname(t));const o=se.extname(t);const a=se.dirname(t);if(typeof r==="string"){return se.join(a,r)}if(typeof r==="function"){return se.join(a,`${r(i)}${o}`)}return t};function cpy(t,r,{concurrency:i=Ce,...o}={}){const a=new Map;const l=new ie;o={...Pe,...o};const c=(async()=>{let c=[];let u=0;let h=0;let d=expandPatternsWithBraceExpansion(arrify(t)).map((t=>t.replace(/\\/g,"/")));const p=d.filter((t=>!t.startsWith("!")));const m=d.filter((t=>t.startsWith("!")));if(p.length===0||!r){throw new CpyError("`source` and `destination` required")}d=d.map((t=>new GlobPattern(t,r,{...o,ignore:m})));for(const t of d){let r=[];try{r=t.getMatches()}catch(r){throw new CpyError(`Cannot glob \`${t.originalPath}\`: ${r.message}`,r)}if(r.length===0&&!Se(t.originalPath)&&!Se(m)){throw new CpyError(`Cannot copy \`${t.originalPath}\`: the file doesn't exist`)}c=[...c,...r.map((r=>new Entry(r,se.relative(o.cwd,r),t)))]}if(o.filter!==undefined){c=await pFilter(c,o.filter,{concurrency:1024})}if(c.length===0){l.emit("progress",{totalFiles:0,percent:1,completedFiles:0,completedSize:0})}const fileProgressHandler=t=>{const r=a.get(t.sourcePath)||{writtenBytes:0,percent:0};if(r.writtenBytes!==t.writtenBytes||r.percent!==t.percent){h-=r.writtenBytes;h+=t.writtenBytes;if(t.percent===1&&r.percent!==1){u++}a.set(t.sourcePath,{writtenBytes:t.writtenBytes,percent:t.percent});l.emit("progress",{totalFiles:c.length,percent:u/c.length,completedFiles:u,completedSize:h})}};return pMap(c,(async t=>{const i=renameFile(preprocessDestinationPath({entry:t,destination:r,options:o}),o.rename);try{await ce(t.path,i,o).on("progress",fileProgressHandler)}catch(r){throw new CpyError(`Cannot copy from \`${t.relativePath}\` to \`${i}\`: ${r.message}`,r)}return i}),{concurrency:i})})();c.on=(...t)=>{l.on(...t);return c};return c}var Ie=i(5713);var Le=i.n(Ie);function isFolderEmpty(t,r){const i=[".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"];const o=V().readdirSync(t).filter((t=>!i.includes(t))).filter((t=>!/\.iml$/.test(t)));if(o.length>0){console.log(`The directory ${T.green(r)} contains files that could conflict:`);console.log();for(const r of o){try{const i=V().lstatSync(G().join(t,r));if(i.isDirectory()){console.log(` ${T.blue(r)}/`)}else{console.log(` ${r}`)}}catch{console.log(` ${r}`)}}console.log();console.log("Either try using a new directory name, or remove the files listed above.");console.log();return false}return true}async function isWriteable(t){try{await V().promises.access(t,(V().constants||V()).W_OK);return true}catch(t){return false}}async function makeDir(t,r={recursive:true}){await V().promises.mkdir(t,r)}var Me=i(4700);var De=i.n(Me);function isInGitRepository(){try{(0,ee.execSync)("git rev-parse --is-inside-work-tree",{stdio:"ignore"});return true}catch(t){}return false}function isInMercurialRepository(){try{(0,ee.execSync)("hg --cwd . root",{stdio:"ignore"});return true}catch(t){}return false}function tryGitInit(t){let r=false;try{(0,ee.execSync)("git --version",{stdio:"ignore"});if(isInGitRepository()||isInMercurialRepository()){return false}(0,ee.execSync)("git init",{stdio:"ignore"});r=true;(0,ee.execSync)("git checkout -b main",{stdio:"ignore"});(0,ee.execSync)("git add -A",{stdio:"ignore"});(0,ee.execSync)('git commit -m "Initial commit from Hyperbook"',{stdio:"ignore"});return true}catch(i){if(r){try{De().sync(G().join(t,".git"))}catch(t){}}return false}}const Ne=["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function isTypedArrayName(t){return Ne.includes(t)}const je=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Blob","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","WeakRef","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","FormData","URLSearchParams","HTMLElement","NaN",...Ne];function isObjectTypeName(t){return je.includes(t)}const Fe=["null","undefined","string","number","bigint","boolean","symbol"];function isPrimitiveTypeName(t){return Fe.includes(t)}function isOfType(t){return r=>typeof r===t}const{toString:Be}=Object.prototype;const getObjectType=t=>{const r=Be.call(t).slice(8,-1);if(/HTML\w+Element/.test(r)&&is.domElement(t)){return"HTMLElement"}if(isObjectTypeName(r)){return r}return undefined};const isObjectOfType=t=>r=>getObjectType(r)===t;function is(t){if(t===null){return"null"}switch(typeof t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(t)?"NaN":"number";case"boolean":return"boolean";case"function":return"Function";case"bigint":return"bigint";case"symbol":return"symbol";default:}if(is.observable(t)){return"Observable"}if(is.array(t)){return"Array"}if(is.buffer(t)){return"Buffer"}const r=getObjectType(t);if(r){return r}if(t instanceof String||t instanceof Boolean||t instanceof Number){throw new TypeError("Please don't use object wrappers for primitive types")}return"Object"}is.undefined=isOfType("undefined");is.string=isOfType("string");const $e=isOfType("number");is.number=t=>$e(t)&&!is.nan(t);is.bigint=isOfType("bigint");is.function_=isOfType("function");is.null_=t=>t===null;is.class_=t=>is.function_(t)&&t.toString().startsWith("class ");is.boolean=t=>t===true||t===false;is.symbol=isOfType("symbol");is.numericString=t=>is.string(t)&&!is.emptyStringOrWhitespace(t)&&!Number.isNaN(Number(t));is.array=(t,r)=>{if(!Array.isArray(t)){return false}if(!is.function_(r)){return true}return t.every((t=>r(t)))};is.buffer=t=>t?.constructor?.isBuffer?.(t)??false;is.blob=t=>isObjectOfType("Blob")(t);is.nullOrUndefined=t=>is.null_(t)||is.undefined(t);is.object=t=>!is.null_(t)&&(typeof t==="object"||is.function_(t));is.iterable=t=>is.function_(t?.[Symbol.iterator]);is.asyncIterable=t=>is.function_(t?.[Symbol.asyncIterator]);is.generator=t=>is.iterable(t)&&is.function_(t?.next)&&is.function_(t?.throw);is.asyncGenerator=t=>is.asyncIterable(t)&&is.function_(t.next)&&is.function_(t.throw);is.nativePromise=t=>isObjectOfType("Promise")(t);const hasPromiseApi=t=>is.function_(t?.then)&&is.function_(t?.catch);is.promise=t=>is.nativePromise(t)||hasPromiseApi(t);is.generatorFunction=isObjectOfType("GeneratorFunction");is.asyncGeneratorFunction=t=>getObjectType(t)==="AsyncGeneratorFunction";is.asyncFunction=t=>getObjectType(t)==="AsyncFunction";is.boundFunction=t=>is.function_(t)&&!t.hasOwnProperty("prototype");is.regExp=isObjectOfType("RegExp");is.date=isObjectOfType("Date");is.error=isObjectOfType("Error");is.map=t=>isObjectOfType("Map")(t);is.set=t=>isObjectOfType("Set")(t);is.weakMap=t=>isObjectOfType("WeakMap")(t);is.weakSet=t=>isObjectOfType("WeakSet")(t);is.weakRef=t=>isObjectOfType("WeakRef")(t);is.int8Array=isObjectOfType("Int8Array");is.uint8Array=isObjectOfType("Uint8Array");is.uint8ClampedArray=isObjectOfType("Uint8ClampedArray");is.int16Array=isObjectOfType("Int16Array");is.uint16Array=isObjectOfType("Uint16Array");is.int32Array=isObjectOfType("Int32Array");is.uint32Array=isObjectOfType("Uint32Array");is.float32Array=isObjectOfType("Float32Array");is.float64Array=isObjectOfType("Float64Array");is.bigInt64Array=isObjectOfType("BigInt64Array");is.bigUint64Array=isObjectOfType("BigUint64Array");is.arrayBuffer=isObjectOfType("ArrayBuffer");is.sharedArrayBuffer=isObjectOfType("SharedArrayBuffer");is.dataView=isObjectOfType("DataView");is.enumCase=(t,r)=>Object.values(r).includes(t);is.directInstanceOf=(t,r)=>Object.getPrototypeOf(t)===r.prototype;is.urlInstance=t=>isObjectOfType("URL")(t);is.urlString=t=>{if(!is.string(t)){return false}try{new URL(t);return true}catch{return false}};is.truthy=t=>Boolean(t);is.falsy=t=>!t;is.nan=t=>Number.isNaN(t);is.primitive=t=>is.null_(t)||isPrimitiveTypeName(typeof t);is.integer=t=>Number.isInteger(t);is.safeInteger=t=>Number.isSafeInteger(t);is.plainObject=t=>{if(typeof t!=="object"||t===null){return false}const r=Object.getPrototypeOf(t);return(r===null||r===Object.prototype||Object.getPrototypeOf(r)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)};is.typedArray=t=>isTypedArrayName(getObjectType(t));const isValidLength=t=>is.safeInteger(t)&&t>=0;is.arrayLike=t=>!is.nullOrUndefined(t)&&!is.function_(t)&&isValidLength(t.length);is.inRange=(t,r)=>{if(is.number(r)){return t>=Math.min(0,r)&&t<=Math.max(r,0)}if(is.array(r)&&r.length===2){return t>=Math.min(...r)&&t<=Math.max(...r)}throw new TypeError(`Invalid range: ${JSON.stringify(r)}`)};const He=1;const Ue=["innerHTML","ownerDocument","style","attributes","nodeValue"];is.domElement=t=>is.object(t)&&t.nodeType===He&&is.string(t.nodeName)&&!is.plainObject(t)&&Ue.every((r=>r in t));is.observable=t=>{if(!t){return false}if(t===t[Symbol.observable]?.()){return true}if(t===t["@@observable"]?.()){return true}return false};is.nodeStream=t=>is.object(t)&&is.function_(t.pipe)&&!is.observable(t);is.infinite=t=>t===Number.POSITIVE_INFINITY||t===Number.NEGATIVE_INFINITY;const isAbsoluteMod2=t=>r=>is.integer(r)&&Math.abs(r%2)===t;is.evenInteger=isAbsoluteMod2(0);is.oddInteger=isAbsoluteMod2(1);is.emptyArray=t=>is.array(t)&&t.length===0;is.nonEmptyArray=t=>is.array(t)&&t.length>0;is.emptyString=t=>is.string(t)&&t.length===0;const isWhiteSpaceString=t=>is.string(t)&&!/\S/.test(t);is.emptyStringOrWhitespace=t=>is.emptyString(t)||isWhiteSpaceString(t);is.nonEmptyString=t=>is.string(t)&&t.length>0;is.nonEmptyStringAndNotWhitespace=t=>is.string(t)&&!is.emptyStringOrWhitespace(t);is.emptyObject=t=>is.object(t)&&!is.map(t)&&!is.set(t)&&Object.keys(t).length===0;is.nonEmptyObject=t=>is.object(t)&&!is.map(t)&&!is.set(t)&&Object.keys(t).length>0;is.emptySet=t=>is.set(t)&&t.size===0;is.nonEmptySet=t=>is.set(t)&&t.size>0;is.emptyMap=t=>is.map(t)&&t.size===0;is.nonEmptyMap=t=>is.map(t)&&t.size>0;is.propertyKey=t=>is.any([is.string,is.number,is.symbol],t);is.formData=t=>isObjectOfType("FormData")(t);is.urlSearchParams=t=>isObjectOfType("URLSearchParams")(t);const predicateOnArray=(t,r,i)=>{if(!is.function_(r)){throw new TypeError(`Invalid predicate: ${JSON.stringify(r)}`)}if(i.length===0){throw new TypeError("Invalid number of values")}return t.call(i,r)};is.any=(t,...r)=>{const i=is.array(t)?t:[t];return i.some((t=>predicateOnArray(Array.prototype.some,t,r)))};is.all=(t,...r)=>predicateOnArray(Array.prototype.every,t,r);const assertType=(t,r,i,o={})=>{if(!t){const{multipleValues:t}=o;const a=t?`received values of types ${[...new Set(i.map((t=>`\`${is(t)}\``)))].join(", ")}`:`received value of type \`${is(i)}\``;throw new TypeError(`Expected value which is \`${r}\`, ${a}.`)}};const qe={undefined:t=>assertType(is.undefined(t),"undefined",t),string:t=>assertType(is.string(t),"string",t),number:t=>assertType(is.number(t),"number",t),bigint:t=>assertType(is.bigint(t),"bigint",t),function_:t=>assertType(is.function_(t),"Function",t),null_:t=>assertType(is.null_(t),"null",t),class_:t=>assertType(is.class_(t),"Class",t),boolean:t=>assertType(is.boolean(t),"boolean",t),symbol:t=>assertType(is.symbol(t),"symbol",t),numericString:t=>assertType(is.numericString(t),"string with a number",t),array:(t,r)=>{const i=assertType;i(is.array(t),"Array",t);if(r){t.forEach(r)}},buffer:t=>assertType(is.buffer(t),"Buffer",t),blob:t=>assertType(is.blob(t),"Blob",t),nullOrUndefined:t=>assertType(is.nullOrUndefined(t),"null or undefined",t),object:t=>assertType(is.object(t),"Object",t),iterable:t=>assertType(is.iterable(t),"Iterable",t),asyncIterable:t=>assertType(is.asyncIterable(t),"AsyncIterable",t),generator:t=>assertType(is.generator(t),"Generator",t),asyncGenerator:t=>assertType(is.asyncGenerator(t),"AsyncGenerator",t),nativePromise:t=>assertType(is.nativePromise(t),"native Promise",t),promise:t=>assertType(is.promise(t),"Promise",t),generatorFunction:t=>assertType(is.generatorFunction(t),"GeneratorFunction",t),asyncGeneratorFunction:t=>assertType(is.asyncGeneratorFunction(t),"AsyncGeneratorFunction",t),asyncFunction:t=>assertType(is.asyncFunction(t),"AsyncFunction",t),boundFunction:t=>assertType(is.boundFunction(t),"Function",t),regExp:t=>assertType(is.regExp(t),"RegExp",t),date:t=>assertType(is.date(t),"Date",t),error:t=>assertType(is.error(t),"Error",t),map:t=>assertType(is.map(t),"Map",t),set:t=>assertType(is.set(t),"Set",t),weakMap:t=>assertType(is.weakMap(t),"WeakMap",t),weakSet:t=>assertType(is.weakSet(t),"WeakSet",t),weakRef:t=>assertType(is.weakRef(t),"WeakRef",t),int8Array:t=>assertType(is.int8Array(t),"Int8Array",t),uint8Array:t=>assertType(is.uint8Array(t),"Uint8Array",t),uint8ClampedArray:t=>assertType(is.uint8ClampedArray(t),"Uint8ClampedArray",t),int16Array:t=>assertType(is.int16Array(t),"Int16Array",t),uint16Array:t=>assertType(is.uint16Array(t),"Uint16Array",t),int32Array:t=>assertType(is.int32Array(t),"Int32Array",t),uint32Array:t=>assertType(is.uint32Array(t),"Uint32Array",t),float32Array:t=>assertType(is.float32Array(t),"Float32Array",t),float64Array:t=>assertType(is.float64Array(t),"Float64Array",t),bigInt64Array:t=>assertType(is.bigInt64Array(t),"BigInt64Array",t),bigUint64Array:t=>assertType(is.bigUint64Array(t),"BigUint64Array",t),arrayBuffer:t=>assertType(is.arrayBuffer(t),"ArrayBuffer",t),sharedArrayBuffer:t=>assertType(is.sharedArrayBuffer(t),"SharedArrayBuffer",t),dataView:t=>assertType(is.dataView(t),"DataView",t),enumCase:(t,r)=>assertType(is.enumCase(t,r),"EnumCase",t),urlInstance:t=>assertType(is.urlInstance(t),"URL",t),urlString:t=>assertType(is.urlString(t),"string with a URL",t),truthy:t=>assertType(is.truthy(t),"truthy",t),falsy:t=>assertType(is.falsy(t),"falsy",t),nan:t=>assertType(is.nan(t),"NaN",t),primitive:t=>assertType(is.primitive(t),"primitive",t),integer:t=>assertType(is.integer(t),"integer",t),safeInteger:t=>assertType(is.safeInteger(t),"integer",t),plainObject:t=>assertType(is.plainObject(t),"plain object",t),typedArray:t=>assertType(is.typedArray(t),"TypedArray",t),arrayLike:t=>assertType(is.arrayLike(t),"array-like",t),domElement:t=>assertType(is.domElement(t),"HTMLElement",t),observable:t=>assertType(is.observable(t),"Observable",t),nodeStream:t=>assertType(is.nodeStream(t),"Node.js Stream",t),infinite:t=>assertType(is.infinite(t),"infinite number",t),emptyArray:t=>assertType(is.emptyArray(t),"empty array",t),nonEmptyArray:t=>assertType(is.nonEmptyArray(t),"non-empty array",t),emptyString:t=>assertType(is.emptyString(t),"empty string",t),emptyStringOrWhitespace:t=>assertType(is.emptyStringOrWhitespace(t),"empty string or whitespace",t),nonEmptyString:t=>assertType(is.nonEmptyString(t),"non-empty string",t),nonEmptyStringAndNotWhitespace:t=>assertType(is.nonEmptyStringAndNotWhitespace(t),"non-empty string and not whitespace",t),emptyObject:t=>assertType(is.emptyObject(t),"empty object",t),nonEmptyObject:t=>assertType(is.nonEmptyObject(t),"non-empty object",t),emptySet:t=>assertType(is.emptySet(t),"empty set",t),nonEmptySet:t=>assertType(is.nonEmptySet(t),"non-empty set",t),emptyMap:t=>assertType(is.emptyMap(t),"empty map",t),nonEmptyMap:t=>assertType(is.nonEmptyMap(t),"non-empty map",t),propertyKey:t=>assertType(is.propertyKey(t),"PropertyKey",t),formData:t=>assertType(is.formData(t),"FormData",t),urlSearchParams:t=>assertType(is.urlSearchParams(t),"URLSearchParams",t),evenInteger:t=>assertType(is.evenInteger(t),"even integer",t),oddInteger:t=>assertType(is.oddInteger(t),"odd integer",t),directInstanceOf:(t,r)=>assertType(is.directInstanceOf(t,r),"T",t),inRange:(t,r)=>assertType(is.inRange(t,r),"in range",t),any:(t,...r)=>assertType(is.any(t,...r),"predicate returns truthy for any value",r,{multipleValues:true}),all:(t,...r)=>assertType(is.all(t,...r),"predicate returns truthy for all values",r,{multipleValues:true})};Object.defineProperties(is,{class:{value:is.class_},function:{value:is.function_},null:{value:is.null_}});Object.defineProperties(qe,{class:{value:qe.class_},function:{value:qe.function_},null:{value:qe.null_}});const ze=is;class CancelError extends Error{constructor(t){super(t||"Promise was canceled");this.name="CancelError"}get isCanceled(){return true}}class PCancelable{static fn(t){return(...r)=>new PCancelable(((i,o,a)=>{r.push(a);t(...r).then(i,o)}))}constructor(t){this._cancelHandlers=[];this._isPending=true;this._isCanceled=false;this._rejectOnCancel=true;this._promise=new Promise(((r,i)=>{this._reject=i;const onResolve=t=>{if(!this._isCanceled||!onCancel.shouldReject){this._isPending=false;r(t)}};const onReject=t=>{this._isPending=false;i(t)};const onCancel=t=>{if(!this._isPending){throw new Error("The `onCancel` handler was attached after the promise settled.")}this._cancelHandlers.push(t)};Object.defineProperties(onCancel,{shouldReject:{get:()=>this._rejectOnCancel,set:t=>{this._rejectOnCancel=t}}});t(onResolve,onReject,onCancel)}))}then(t,r){return this._promise.then(t,r)}catch(t){return this._promise.catch(t)}finally(t){return this._promise.finally(t)}cancel(t){if(!this._isPending||this._isCanceled){return}this._isCanceled=true;if(this._cancelHandlers.length>0){try{for(const t of this._cancelHandlers){t()}}catch(t){this._reject(t);return}}if(this._rejectOnCancel){this._reject(new CancelError(t))}}get isCanceled(){return this._isCanceled}}Object.setPrototypeOf(PCancelable.prototype,Promise.prototype);function isRequest(t){return ze.object(t)&&"_onResponse"in t}class RequestError extends Error{constructor(t,r,i){super(t);Object.defineProperty(this,"input",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"code",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"stack",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"response",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"request",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"timings",{enumerable:true,configurable:true,writable:true,value:void 0});Error.captureStackTrace(this,this.constructor);this.name="RequestError";this.code=r.code??"ERR_GOT_REQUEST_ERROR";this.input=r.input;if(isRequest(i)){Object.defineProperty(this,"request",{enumerable:false,value:i});Object.defineProperty(this,"response",{enumerable:false,value:i.response});this.options=i.options}else{this.options=i}this.timings=this.request?.timings;if(ze.string(r.stack)&&ze.string(this.stack)){const t=this.stack.indexOf(this.message)+this.message.length;const i=this.stack.slice(t).split("\n").reverse();const o=r.stack.slice(r.stack.indexOf(r.message)+r.message.length).split("\n").reverse();while(o.length>0&&o[0]===i[0]){i.shift()}this.stack=`${this.stack.slice(0,t)}${i.reverse().join("\n")}${o.reverse().join("\n")}`}}}class MaxRedirectsError extends RequestError{constructor(t){super(`Redirected ${t.options.maxRedirects} times. Aborting.`,{},t);this.name="MaxRedirectsError";this.code="ERR_TOO_MANY_REDIRECTS"}}class HTTPError extends RequestError{constructor(t){super(`Response code ${t.statusCode} (${t.statusMessage})`,{},t.request);this.name="HTTPError";this.code="ERR_NON_2XX_3XX_RESPONSE"}}class CacheError extends RequestError{constructor(t,r){super(t.message,t,r);this.name="CacheError";this.code=this.code==="ERR_GOT_REQUEST_ERROR"?"ERR_CACHE_ACCESS":this.code}}class UploadError extends RequestError{constructor(t,r){super(t.message,t,r);this.name="UploadError";this.code=this.code==="ERR_GOT_REQUEST_ERROR"?"ERR_UPLOAD":this.code}}class TimeoutError extends RequestError{constructor(t,r,i){super(t.message,t,i);Object.defineProperty(this,"timings",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"event",{enumerable:true,configurable:true,writable:true,value:void 0});this.name="TimeoutError";this.event=t.event;this.timings=r}}class ReadError extends RequestError{constructor(t,r){super(t.message,t,r);this.name="ReadError";this.code=this.code==="ERR_GOT_REQUEST_ERROR"?"ERR_READING_RESPONSE_STREAM":this.code}}class RetryError extends RequestError{constructor(t){super("Retrying",{},t);this.name="RetryError";this.code="ERR_RETRYING"}}class errors_AbortError extends RequestError{constructor(t){super("This operation was aborted.",{},t);this.code="ERR_ABORTED";this.name="AbortError"}}const Ge=require("node:buffer");const We=require("node:http");var Ve=i(2361);var Ye=i(3837);var Ze=i(8985);const timer=t=>{if(t.timings){return t.timings}const r={start:Date.now(),socket:undefined,lookup:undefined,connect:undefined,secureConnect:undefined,upload:undefined,response:undefined,end:undefined,error:undefined,abort:undefined,phases:{wait:undefined,dns:undefined,tcp:undefined,tls:undefined,request:undefined,firstByte:undefined,download:undefined,total:undefined}};t.timings=r;const handleError=t=>{t.once(Ve.errorMonitor,(()=>{r.error=Date.now();r.phases.total=r.error-r.start}))};handleError(t);const onAbort=()=>{r.abort=Date.now();r.phases.total=r.abort-r.start};t.prependOnceListener("abort",onAbort);const onSocket=t=>{r.socket=Date.now();r.phases.wait=r.socket-r.start;if(Ye.types.isProxy(t)){return}const lookupListener=()=>{r.lookup=Date.now();r.phases.dns=r.lookup-r.socket};t.prependOnceListener("lookup",lookupListener);Ze(t,{connect:()=>{r.connect=Date.now();if(r.lookup===undefined){t.removeListener("lookup",lookupListener);r.lookup=r.connect;r.phases.dns=r.lookup-r.socket}r.phases.tcp=r.connect-r.lookup},secureConnect:()=>{r.secureConnect=Date.now();r.phases.tls=r.secureConnect-r.connect}})};if(t.socket){onSocket(t.socket)}else{t.prependOnceListener("socket",onSocket)}const onUpload=()=>{r.upload=Date.now();r.phases.request=r.upload-(r.secureConnect??r.connect)};if(t.writableFinished){onUpload()}else{t.prependOnceListener("finish",onUpload)}t.prependOnceListener("response",(i=>{r.response=Date.now();r.phases.firstByte=r.response-r.upload;i.timings=r;handleError(i);i.prependOnceListener("end",(()=>{t.off("abort",onAbort);i.off("aborted",onAbort);if(r.phases.total){return}r.end=Date.now();r.phases.download=r.end-r.response;r.phases.total=r.end-r.start}));i.prependOnceListener("aborted",onAbort)}));return r};const Ke=timer;const Qe=require("node:crypto");const Xe="text/plain";const Je="us-ascii";const testParameter=(t,r)=>r.some((r=>r instanceof RegExp?r.test(t):r===t));const normalizeDataURL=(t,{stripHash:r})=>{const i=/^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(t);if(!i){throw new Error(`Invalid URL: ${t}`)}let{type:o,data:a,hash:l}=i.groups;const c=o.split(";");l=r?"":l;let u=false;if(c[c.length-1]==="base64"){c.pop();u=true}const h=(c.shift()||"").toLowerCase();const d=c.map((t=>{let[r,i=""]=t.split("=").map((t=>t.trim()));if(r==="charset"){i=i.toLowerCase();if(i===Je){return""}}return`${r}${i?`=${i}`:""}`})).filter(Boolean);const p=[...d];if(u){p.push("base64")}if(p.length>0||h&&h!==Xe){p.unshift(h)}return`data:${p.join(";")},${u?a.trim():a}${l?`#${l}`:""}`};function normalizeUrl(t,r){r={defaultProtocol:"http:",normalizeProtocol:true,forceHttp:false,forceHttps:false,stripAuthentication:true,stripHash:false,stripTextFragment:true,stripWWW:true,removeQueryParameters:[/^utm_\w+/i],removeTrailingSlash:true,removeSingleSlash:true,removeDirectoryIndex:false,sortQueryParameters:true,...r};t=t.trim();if(/^data:/i.test(t)){return normalizeDataURL(t,r)}if(/^view-source:/i.test(t)){throw new Error("`view-source:` is not supported as it is a non-standard protocol")}const i=t.startsWith("//");const o=!i&&/^\.*\//.test(t);if(!o){t=t.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,r.defaultProtocol)}const a=new URL(t);if(r.forceHttp&&r.forceHttps){throw new Error("The `forceHttp` and `forceHttps` options cannot be used together")}if(r.forceHttp&&a.protocol==="https:"){a.protocol="http:"}if(r.forceHttps&&a.protocol==="http:"){a.protocol="https:"}if(r.stripAuthentication){a.username="";a.password=""}if(r.stripHash){a.hash=""}else if(r.stripTextFragment){a.hash=a.hash.replace(/#?:~:text.*?$/i,"")}if(a.pathname){const t=/\b[a-z][a-z\d+\-.]{1,50}:\/\//g;let r=0;let i="";for(;;){const o=t.exec(a.pathname);if(!o){break}const l=o[0];const c=o.index;const u=a.pathname.slice(r,c);i+=u.replace(/\/{2,}/g,"/");i+=l;r=c+l.length}const o=a.pathname.slice(r,a.pathname.length);i+=o.replace(/\/{2,}/g,"/");a.pathname=i}if(a.pathname){try{a.pathname=decodeURI(a.pathname)}catch{}}if(r.removeDirectoryIndex===true){r.removeDirectoryIndex=[/^index\.[a-z]+$/]}if(Array.isArray(r.removeDirectoryIndex)&&r.removeDirectoryIndex.length>0){let t=a.pathname.split("/");const i=t[t.length-1];if(testParameter(i,r.removeDirectoryIndex)){t=t.slice(0,-1);a.pathname=t.slice(1).join("/")+"/"}}if(a.hostname){a.hostname=a.hostname.replace(/\.$/,"");if(r.stripWWW&&/^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(a.hostname)){a.hostname=a.hostname.replace(/^www\./,"")}}if(Array.isArray(r.removeQueryParameters)){for(const t of[...a.searchParams.keys()]){if(testParameter(t,r.removeQueryParameters)){a.searchParams.delete(t)}}}if(!Array.isArray(r.keepQueryParameters)&&r.removeQueryParameters===true){a.search=""}if(Array.isArray(r.keepQueryParameters)&&r.keepQueryParameters.length>0){for(const t of[...a.searchParams.keys()]){if(!testParameter(t,r.keepQueryParameters)){a.searchParams.delete(t)}}}if(r.sortQueryParameters){a.searchParams.sort();try{a.search=decodeURIComponent(a.search)}catch{}}if(r.removeTrailingSlash){a.pathname=a.pathname.replace(/\/$/,"")}const l=t;t=a.toString();if(!r.removeSingleSlash&&a.pathname==="/"&&!l.endsWith("/")&&a.hash===""){t=t.replace(/\/$/,"")}if((r.removeTrailingSlash||a.pathname==="/")&&a.hash===""&&r.removeSingleSlash){t=t.replace(/\/$/,"")}if(i&&!r.normalizeProtocol){t=t.replace(/^http:\/\//,"//")}if(r.stripProtocol){t=t.replace(/^(?:https?:)?\/\//,"")}return t}var et=i(367);var tt=i(1454);function lowercaseKeys(t){return Object.fromEntries(Object.entries(t).map((([t,r])=>[t.toLowerCase(),r])))}class Response extends ge.Readable{statusCode;headers;body;url;constructor({statusCode:t,headers:r,body:i,url:o}){if(typeof t!=="number"){throw new TypeError("Argument `statusCode` should be a number")}if(typeof r!=="object"){throw new TypeError("Argument `headers` should be an object")}if(!(i instanceof Uint8Array)){throw new TypeError("Argument `body` should be a buffer")}if(typeof o!=="string"){throw new TypeError("Argument `url` should be a string")}super({read(){this.push(i);this.push(null)}});this.statusCode=t;this.headers=lowercaseKeys(r);this.body=i;this.url=o}}var rt=i(1187);const it=["aborted","complete","headers","httpVersion","httpVersionMinor","httpVersionMajor","method","rawHeaders","rawTrailers","setTimeout","socket","statusCode","statusMessage","trailers","url"];function mimicResponse(t,r){if(r._readableState.autoDestroy){throw new Error("The second stream must have the `autoDestroy` option set to `false`")}const i=new Set([...Object.keys(t),...it]);const o={};for(const a of i){if(a in r){continue}o[a]={get(){const r=t[a];const i=typeof r==="function";return i?r.bind(t):r},set(r){t[a]=r},enumerable:true,configurable:false}}Object.defineProperties(r,o);t.once("aborted",(()=>{r.destroy();r.emit("aborted")}));t.once("close",(()=>{if(t.complete){if(r.readable){r.once("end",(()=>{r.emit("close")}))}else{r.emit("close")}}else{r.emit("close")}}));return r}class types_RequestError extends Error{constructor(t){super(t.message);Object.assign(this,t)}}class types_CacheError extends Error{constructor(t){super(t.message);Object.assign(this,t)}}class CacheableRequest{constructor(t,r){this.hooks=new Map;this.request=()=>(t,r)=>{let i;if(typeof t==="string"){i=normalizeUrlObject(ye.parse(t));t={}}else if(t instanceof ye.URL){i=normalizeUrlObject(ye.parse(t.toString()));t={}}else{const[r,...o]=(t.path??"").split("?");const a=o.length>0?`?${o.join("?")}`:"";i=normalizeUrlObject({...t,pathname:r,search:a})}t={headers:{},method:"GET",cache:true,strictTtl:false,automaticFailover:false,...t,...urlObjectToRequestOptions(i)};t.headers=Object.fromEntries(st(t.headers).map((([t,r])=>[t.toLowerCase(),r])));const o=new ie;const a=normalizeUrl(ye.format(i),{stripWWW:false,removeTrailingSlash:false,stripAuthentication:false});let l=`${t.method}:${a}`;if(t.body&&t.method!==undefined&&["POST","PATCH","PUT"].includes(t.method)){if(t.body instanceof ge.Readable){t.cache=false}else{l+=`:${Qe.createHash("md5").update(t.body).digest("hex")}`}}let c=false;let u=false;const makeRequest=t=>{u=true;let i=false;let requestErrorCallback=()=>{};const a=new Promise((t=>{requestErrorCallback=()=>{if(!i){i=true;t()}}}));const handler=async i=>{if(c){i.status=i.statusCode;const r=tt.fromObject(c.cachePolicy).revalidatedPolicy(t,i);if(!r.modified){i.resume();await new Promise((t=>{i.once("end",t)}));const t=convertHeaders(r.policy.responseHeaders());i=new Response({statusCode:c.statusCode,headers:t,body:c.body,url:c.url});i.cachePolicy=r.policy;i.fromCache=true}}if(!i.fromCache){i.cachePolicy=new tt(t,i,t);i.fromCache=false}let u;if(t.cache&&i.cachePolicy.storable()){u=cloneResponse(i);(async()=>{try{const r=et.buffer(i);await Promise.race([a,new Promise((t=>i.once("end",t)))]);const o=await r;let u={url:i.url,statusCode:i.fromCache?c.statusCode:i.statusCode,body:o,cachePolicy:i.cachePolicy.toObject()};let h=t.strictTtl?i.cachePolicy.timeToLive():undefined;if(t.maxTtl){h=h?Math.min(h,t.maxTtl):t.maxTtl}if(this.hooks.size>0){for(const t of this.hooks.keys()){u=await this.runHook(t,u,i)}}await this.cache.set(l,u,h)}catch(t){o.emit("error",new types_CacheError(t))}})()}else if(t.cache&&c){(async()=>{try{await this.cache.delete(l)}catch(t){o.emit("error",new types_CacheError(t))}})()}o.emit("response",u??i);if(typeof r==="function"){r(u??i)}};try{const r=this.cacheRequest(t,handler);r.once("error",requestErrorCallback);r.once("abort",requestErrorCallback);o.emit("request",r)}catch(t){o.emit("error",new types_RequestError(t))}};(async()=>{const get=async t=>{await Promise.resolve();const i=t.cache?await this.cache.get(l):undefined;if(typeof i==="undefined"&&!t.forceRefresh){makeRequest(t);return}const a=tt.fromObject(i.cachePolicy);if(a.satisfiesWithoutRevalidation(t)&&!t.forceRefresh){const t=convertHeaders(a.responseHeaders());const l=new Response({statusCode:i.statusCode,headers:t,body:i.body,url:i.url});l.cachePolicy=a;l.fromCache=true;o.emit("response",l);if(typeof r==="function"){r(l)}}else if(a.satisfiesWithoutRevalidation(t)&&Date.now()>=a.timeToLive()&&t.forceRefresh){await this.cache.delete(l);t.headers=a.revalidationHeaders(t);makeRequest(t)}else{c=i;t.headers=a.revalidationHeaders(t);makeRequest(t)}};const errorHandler=t=>o.emit("error",new types_CacheError(t));if(this.cache instanceof rt){const t=this.cache;t.once("error",errorHandler);o.on("error",(()=>t.removeListener("error",errorHandler)))}try{await get(t)}catch(r){if(t.automaticFailover&&!u){makeRequest(t)}o.emit("error",new types_CacheError(r))}})();return o};this.addHook=(t,r)=>{if(!this.hooks.has(t)){this.hooks.set(t,r)}};this.removeHook=t=>this.hooks.delete(t);this.getHook=t=>this.hooks.get(t);this.runHook=async(t,...r)=>this.hooks.get(t)?.(...r);if(r instanceof rt){this.cache=r}else if(typeof r==="string"){this.cache=new rt({uri:r,namespace:"cacheable-request"})}else{this.cache=new rt({store:r,namespace:"cacheable-request"})}this.request=this.request.bind(this);this.cacheRequest=t}}const st=Object.entries;const cloneResponse=t=>{const r=new ge.PassThrough({autoDestroy:false});mimicResponse(t,r);return t.pipe(r)};const urlObjectToRequestOptions=t=>{const r={...t};r.path=`${t.pathname||"/"}${t.search||""}`;delete r.pathname;delete r.search;return r};const normalizeUrlObject=t=>({protocol:t.protocol,auth:t.auth,hostname:t.hostname||t.host||"localhost",port:t.port,pathname:t.pathname,search:t.search});const convertHeaders=t=>{const r=[];for(const i of Object.keys(t)){r[i.toLowerCase()]=t[i]}return r};const nt=CacheableRequest;const ot="onResponse";var at=i(2269);const isFunction=t=>typeof t==="function";const isFormData=t=>Boolean(t&&isFunction(t.constructor)&&t[Symbol.toStringTag]==="FormData"&&isFunction(t.append)&&isFunction(t.getAll)&&isFunction(t.entries)&&isFunction(t[Symbol.iterator]));const ct="abcdefghijklmnopqrstuvwxyz0123456789";function createBoundary(){let t=16;let r="";while(t--){r+=ct[Math.random()*ct.length<<0]}return r}const normalizeValue=t=>String(t).replace(/\r|\n/g,((t,r,i)=>{if(t==="\r"&&i[r+1]!=="\n"||t==="\n"&&i[r-1]!=="\r"){return"\r\n"}return t}));const getType=t=>Object.prototype.toString.call(t).slice(8,-1).toLowerCase();function isPlainObject(t){if(getType(t)!=="object"){return false}const r=Object.getPrototypeOf(t);if(r===null||r===undefined){return true}const i=r.constructor&&r.constructor.toString();return i===Object.toString()}function getProperty(t,r){if(typeof r!=="string"){return t[r]}for(const[i,o]of Object.entries(t)){if(r.toLowerCase()===i.toLowerCase()){return o}}return undefined}const proxyHeaders=t=>new Proxy(t,{get:(t,r)=>getProperty(t,r),has:(t,r)=>getProperty(t,r)!==undefined});const escapeName=t=>String(t).replace(/\r/g,"%0D").replace(/\n/g,"%0A").replace(/"/g,"%22");const isFile=t=>Boolean(t&&typeof t==="object"&&isFunction(t.constructor)&&t[Symbol.toStringTag]==="File"&&isFunction(t.stream)&&t.name!=null);const ut=null&&isFile;var ht=undefined&&undefined.__classPrivateFieldSet||function(t,r,i,o,a){if(o==="m")throw new TypeError("Private method is not writable");if(o==="a"&&!a)throw new TypeError("Private accessor was defined without a setter");if(typeof r==="function"?t!==r||!a:!r.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return o==="a"?a.call(t,i):a?a.value=i:r.set(t,i),i};var ft=undefined&&undefined.__classPrivateFieldGet||function(t,r,i,o){if(i==="a"&&!o)throw new TypeError("Private accessor was defined without a getter");if(typeof r==="function"?t!==r||!o:!r.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?o:i==="a"?o.call(t):o?o.value:r.get(t)};var dt,pt,mt,yt,bt,vt,_t,wt,Et,St,Ot;const Rt={enableAdditionalHeaders:false};const xt={writable:false,configurable:false};class FormDataEncoder{constructor(t,r,i){dt.add(this);pt.set(this,"\r\n");mt.set(this,void 0);yt.set(this,void 0);bt.set(this,"-".repeat(2));vt.set(this,new TextEncoder);_t.set(this,void 0);wt.set(this,void 0);Et.set(this,void 0);if(!isFormData(t)){throw new TypeError("Expected first argument to be a FormData instance.")}let o;if(isPlainObject(r)){i=r}else{o=r}if(!o){o=createBoundary()}if(typeof o!=="string"){throw new TypeError("Expected boundary argument to be a string.")}if(i&&!isPlainObject(i)){throw new TypeError("Expected options argument to be an object.")}ht(this,wt,Array.from(t.entries()),"f");ht(this,Et,{...Rt,...i},"f");ht(this,mt,ft(this,vt,"f").encode(ft(this,pt,"f")),"f");ht(this,yt,ft(this,mt,"f").byteLength,"f");this.boundary=`form-data-boundary-${o}`;this.contentType=`multipart/form-data; boundary=${this.boundary}`;ht(this,_t,ft(this,vt,"f").encode(`${ft(this,bt,"f")}${this.boundary}${ft(this,bt,"f")}${ft(this,pt,"f").repeat(2)}`),"f");const a={"Content-Type":this.contentType};const l=ft(this,dt,"m",Ot).call(this);if(l){this.contentLength=l;a["Content-Length"]=l}this.headers=proxyHeaders(Object.freeze(a));Object.defineProperties(this,{boundary:xt,contentType:xt,contentLength:xt,headers:xt})}getContentLength(){return this.contentLength==null?undefined:Number(this.contentLength)}*values(){for(const[t,r]of ft(this,wt,"f")){const i=isFile(r)?r:ft(this,vt,"f").encode(normalizeValue(r));yield ft(this,dt,"m",St).call(this,t,i);yield i;yield ft(this,mt,"f")}yield ft(this,_t,"f")}async*encode(){for(const t of this.values()){if(isFile(t)){yield*t.stream()}else{yield t}}}[(pt=new WeakMap,mt=new WeakMap,yt=new WeakMap,bt=new WeakMap,vt=new WeakMap,_t=new WeakMap,wt=new WeakMap,Et=new WeakMap,dt=new WeakSet,St=function _FormDataEncoder_getFieldHeader(t,r){let i="";i+=`${ft(this,bt,"f")}${this.boundary}${ft(this,pt,"f")}`;i+=`Content-Disposition: form-data; name="${escapeName(t)}"`;if(isFile(r)){i+=`; filename="${escapeName(r.name)}"${ft(this,pt,"f")}`;i+=`Content-Type: ${r.type||"application/octet-stream"}`}const o=isFile(r)?r.size:r.byteLength;if(ft(this,Et,"f").enableAdditionalHeaders===true&&o!=null&&!isNaN(o)){i+=`${ft(this,pt,"f")}Content-Length: ${isFile(r)?r.size:r.byteLength}`}return ft(this,vt,"f").encode(`${i}${ft(this,pt,"f").repeat(2)}`)},Ot=function _FormDataEncoder_getContentLength(){let t=0;for(const[r,i]of ft(this,wt,"f")){const o=isFile(i)?i:ft(this,vt,"f").encode(normalizeValue(i));const a=isFile(o)?o.size:o.byteLength;if(a==null||isNaN(a)){return undefined}t+=ft(this,dt,"m",St).call(this,r,o).byteLength;t+=a;t+=ft(this,yt,"f")}return String(t+ft(this,_t,"f").byteLength)},Symbol.iterator)](){return this.values()}[Symbol.asyncIterator](){return this.encode()}}const kt=require("node:util");function is_form_data_isFormData(t){return ze.nodeStream(t)&&ze.function_(t.getBoundary)}async function getBodySize(t,r){if(r&&"content-length"in r){return Number(r["content-length"])}if(!t){return 0}if(ze.string(t)){return Ge.Buffer.byteLength(t)}if(ze.buffer(t)){return t.length}if(is_form_data_isFormData(t)){return(0,kt.promisify)(t.getLength.bind(t))()}return undefined}function proxyEvents(t,r,i){const o={};for(const a of i){const eventFunction=(...t)=>{r.emit(a,...t)};o[a]=eventFunction;t.on(a,eventFunction)}return()=>{for(const[r,i]of Object.entries(o)){t.off(r,i)}}}const Tt=require("node:net");function unhandle(){const t=[];return{once(r,i,o){r.once(i,o);t.push({origin:r,event:i,fn:o})},unhandleAll(){for(const r of t){const{origin:t,event:i,fn:o}=r;t.removeListener(i,o)}t.length=0}}}const At=Symbol("reentry");const noop=()=>{};class timed_out_TimeoutError extends Error{constructor(t,r){super(`Timeout awaiting '${r}' for ${t}ms`);Object.defineProperty(this,"event",{enumerable:true,configurable:true,writable:true,value:r});Object.defineProperty(this,"code",{enumerable:true,configurable:true,writable:true,value:void 0});this.name="TimeoutError";this.code="ETIMEDOUT"}}function timedOut(t,r,i){if(At in t){return noop}t[At]=true;const o=[];const{once:a,unhandleAll:l}=unhandle();const addTimeout=(t,r,i)=>{const a=setTimeout(r,t,t,i);a.unref?.();const cancel=()=>{clearTimeout(a)};o.push(cancel);return cancel};const{host:c,hostname:u}=i;const timeoutHandler=(r,i)=>{t.destroy(new timed_out_TimeoutError(r,i))};const cancelTimeouts=()=>{for(const t of o){t()}l()};t.once("error",(r=>{cancelTimeouts();if(t.listenerCount("error")===0){throw r}}));if(typeof r.request!=="undefined"){const i=addTimeout(r.request,timeoutHandler,"request");a(t,"response",(t=>{a(t,"end",i)}))}if(typeof r.socket!=="undefined"){const{socket:i}=r;const socketTimeoutHandler=()=>{timeoutHandler(i,"socket")};t.setTimeout(i,socketTimeoutHandler);o.push((()=>{t.removeListener("timeout",socketTimeoutHandler)}))}const h=typeof r.lookup!=="undefined";const d=typeof r.connect!=="undefined";const p=typeof r.secureConnect!=="undefined";const m=typeof r.send!=="undefined";if(h||d||p||m){a(t,"socket",(o=>{const{socketPath:l}=t;if(o.connecting){const t=Boolean(l??Tt.isIP(u??c??"")!==0);if(h&&!t&&typeof o.address().address==="undefined"){const t=addTimeout(r.lookup,timeoutHandler,"lookup");a(o,"lookup",t)}if(d){const timeConnect=()=>addTimeout(r.connect,timeoutHandler,"connect");if(t){a(o,"connect",timeConnect())}else{a(o,"lookup",(t=>{if(t===null){a(o,"connect",timeConnect())}}))}}if(p&&i.protocol==="https:"){a(o,"connect",(()=>{const t=addTimeout(r.secureConnect,timeoutHandler,"secureConnect");a(o,"secureConnect",t)}))}}if(m){const timeRequest=()=>addTimeout(r.send,timeoutHandler,"send");if(o.connecting){a(o,"connect",(()=>{a(t,"upload-complete",timeRequest())}))}else{a(t,"upload-complete",timeRequest())}}}))}if(typeof r.response!=="undefined"){a(t,"upload-complete",(()=>{const i=addTimeout(r.response,timeoutHandler,"response");a(t,"response",i)}))}if(typeof r.read!=="undefined"){a(t,"response",(t=>{const i=addTimeout(r.read,timeoutHandler,"read");a(t,"end",i)}))}return cancelTimeouts}function urlToOptions(t){t=t;const r={protocol:t.protocol,hostname:ze.string(t.hostname)&&t.hostname.startsWith("[")?t.hostname.slice(1,-1):t.hostname,host:t.host,hash:t.hash,search:t.search,pathname:t.pathname,href:t.href,path:`${t.pathname||""}${t.search||""}`};if(ze.string(t.port)&&t.port.length>0){r.port=Number(t.port)}if(t.username||t.password){r.auth=`${t.username||""}:${t.password||""}`}return r}class WeakableMap{constructor(){Object.defineProperty(this,"weakMap",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"map",{enumerable:true,configurable:true,writable:true,value:void 0});this.weakMap=new WeakMap;this.map=new Map}set(t,r){if(typeof t==="object"){this.weakMap.set(t,r)}else{this.map.set(t,r)}}get(t){if(typeof t==="object"){return this.weakMap.get(t)}return this.map.get(t)}has(t){if(typeof t==="object"){return this.weakMap.has(t)}return this.map.has(t)}}const calculateRetryDelay=({attemptCount:t,retryOptions:r,error:i,retryAfter:o,computedValue:a})=>{if(i.name==="RetryError"){return 1}if(t>r.limit){return 0}const l=r.methods.includes(i.options.method);const c=r.errorCodes.includes(i.code);const u=i.response&&r.statusCodes.includes(i.response.statusCode);if(!l||!c&&!u){return 0}if(i.response){if(o){if(o>a){return 0}return o}if(i.response.statusCode===413){return 0}}const h=Math.random()*r.noise;return Math.min(2**(t-1)*1e3,r.backoffLimit)+h};const Ct=calculateRetryDelay;const Pt=require("node:tls");const It=require("node:https");const Lt=require("node:dns");const{Resolver:Mt}=Lt.promises;const Dt=Symbol("cacheableLookupCreateConnection");const Nt=Symbol("cacheableLookupInstance");const jt=Symbol("expires");const Ft=typeof Lt.ALL==="number";const verifyAgent=t=>{if(!(t&&typeof t.createConnection==="function")){throw new Error("Expected an Agent instance as the first argument")}};const map4to6=t=>{for(const r of t){if(r.family===6){continue}r.address=`::ffff:${r.address}`;r.family=6}};const getIfaceInfo=()=>{let t=false;let r=false;for(const i of Object.values(u.networkInterfaces())){for(const o of i){if(o.internal){continue}if(o.family==="IPv6"){r=true}else{t=true}if(t&&r){return{has4:t,has6:r}}}}return{has4:t,has6:r}};const isIterable=t=>Symbol.iterator in t;const ignoreNoResultErrors=t=>t.catch((t=>{if(t.code==="ENODATA"||t.code==="ENOTFOUND"||t.code==="ENOENT"){return[]}throw t}));const Bt={ttl:true};const $t={all:true};const Ht={all:true,family:4};const Ut={all:true,family:6};class CacheableLookup{constructor({cache:t=new Map,maxTtl:r=Infinity,fallbackDuration:i=3600,errorTtl:o=.15,resolver:a=new Mt,lookup:l=Lt.lookup}={}){this.maxTtl=r;this.errorTtl=o;this._cache=t;this._resolver=a;this._dnsLookup=l&&(0,kt.promisify)(l);this.stats={cache:0,query:0};if(this._resolver instanceof Mt){this._resolve4=this._resolver.resolve4.bind(this._resolver);this._resolve6=this._resolver.resolve6.bind(this._resolver)}else{this._resolve4=(0,kt.promisify)(this._resolver.resolve4.bind(this._resolver));this._resolve6=(0,kt.promisify)(this._resolver.resolve6.bind(this._resolver))}this._iface=getIfaceInfo();this._pending={};this._nextRemovalTime=false;this._hostnamesToFallback=new Set;this.fallbackDuration=i;if(i>0){const t=setInterval((()=>{this._hostnamesToFallback.clear()}),i*1e3);if(t.unref){t.unref()}this._fallbackInterval=t}this.lookup=this.lookup.bind(this);this.lookupAsync=this.lookupAsync.bind(this)}set servers(t){this.clear();this._resolver.setServers(t)}get servers(){return this._resolver.getServers()}lookup(t,r,i){if(typeof r==="function"){i=r;r={}}else if(typeof r==="number"){r={family:r}}if(!i){throw new Error("Callback must be a function.")}this.lookupAsync(t,r).then((t=>{if(r.all){i(null,t)}else{i(null,t.address,t.family,t.expires,t.ttl,t.source)}}),i)}async lookupAsync(t,r={}){if(typeof r==="number"){r={family:r}}let i=await this.query(t);if(r.family===6){const t=i.filter((t=>t.family===6));if(r.hints&Lt.V4MAPPED){if(Ft&&r.hints&Lt.ALL||t.length===0){map4to6(i)}else{i=t}}else{i=t}}else if(r.family===4){i=i.filter((t=>t.family===4))}if(r.hints&Lt.ADDRCONFIG){const{_iface:t}=this;i=i.filter((r=>r.family===6?t.has6:t.has4))}if(i.length===0){const r=new Error(`cacheableLookup ENOTFOUND ${t}`);r.code="ENOTFOUND";r.hostname=t;throw r}if(r.all){return i}return i[0]}async query(t){let r="cache";let i=await this._cache.get(t);if(i){this.stats.cache++}if(!i){const o=this._pending[t];if(o){this.stats.cache++;i=await o}else{r="query";const o=this.queryAndCache(t);this._pending[t]=o;this.stats.query++;try{i=await o}finally{delete this._pending[t]}}}i=i.map((t=>({...t,source:r})));return i}async _resolve(t){const[r,i]=await Promise.all([ignoreNoResultErrors(this._resolve4(t,Bt)),ignoreNoResultErrors(this._resolve6(t,Bt))]);let o=0;let a=0;let l=0;const c=Date.now();for(const t of r){t.family=4;t.expires=c+t.ttl*1e3;o=Math.max(o,t.ttl)}for(const t of i){t.family=6;t.expires=c+t.ttl*1e3;a=Math.max(a,t.ttl)}if(r.length>0){if(i.length>0){l=Math.min(o,a)}else{l=o}}else{l=a}return{entries:[...r,...i],cacheTtl:l}}async _lookup(t){try{const[r,i]=await Promise.all([ignoreNoResultErrors(this._dnsLookup(t,Ht)),ignoreNoResultErrors(this._dnsLookup(t,Ut))]);return{entries:[...r,...i],cacheTtl:0}}catch{return{entries:[],cacheTtl:0}}}async _set(t,r,i){if(this.maxTtl>0&&i>0){i=Math.min(i,this.maxTtl)*1e3;r[jt]=Date.now()+i;try{await this._cache.set(t,r,i)}catch(t){this.lookupAsync=async()=>{const r=new Error("Cache Error. Please recreate the CacheableLookup instance.");r.cause=t;throw r}}if(isIterable(this._cache)){this._tick(i)}}}async queryAndCache(t){if(this._hostnamesToFallback.has(t)){return this._dnsLookup(t,$t)}let r=await this._resolve(t);if(r.entries.length===0&&this._dnsLookup){r=await this._lookup(t);if(r.entries.length!==0&&this.fallbackDuration>0){this._hostnamesToFallback.add(t)}}const i=r.entries.length===0?this.errorTtl:r.cacheTtl;await this._set(t,r.entries,i);return r.entries}_tick(t){const r=this._nextRemovalTime;if(!r||t<r){clearTimeout(this._removalTimeout);this._nextRemovalTime=t;this._removalTimeout=setTimeout((()=>{this._nextRemovalTime=false;let t=Infinity;const r=Date.now();for(const[i,o]of this._cache){const a=o[jt];if(r>=a){this._cache.delete(i)}else if(a<t){t=a}}if(t!==Infinity){this._tick(t-r)}}),t);if(this._removalTimeout.unref){this._removalTimeout.unref()}}}install(t){verifyAgent(t);if(Dt in t){throw new Error("CacheableLookup has been already installed")}t[Dt]=t.createConnection;t[Nt]=this;t.createConnection=(r,i)=>{if(!("lookup"in r)){r.lookup=this.lookup}return t[Dt](r,i)}}uninstall(t){verifyAgent(t);if(t[Dt]){if(t[Nt]!==this){throw new Error("The agent is not owned by this CacheableLookup instance")}t.createConnection=t[Dt];delete t[Dt];delete t[Nt]}}updateInterfaceInfo(){const{_iface:t}=this;this._iface=getIfaceInfo();if(t.has4&&!this._iface.has4||t.has6&&!this._iface.has6){this._cache.clear()}}clear(t){if(t){this._cache.delete(t);return}this._cache.clear()}}var qt=i(5767);function parseLinkHeader(t){const r=[];const i=t.split(",");for(const o of i){const[i,...a]=o.split(";");const l=i.trim();if(l[0]!=="<"||l[l.length-1]!==">"){throw new Error(`Invalid format of the Link header reference: ${l}`)}const c=l.slice(1,-1);const u={};if(a.length===0){throw new Error(`Unexpected end of Link header parameters: ${a.join(";")}`)}for(const r of a){const i=r.trim();const o=i.indexOf("=");if(o===-1){throw new Error(`Failed to parse Link header: ${t}`)}const a=i.slice(0,o).trim();const l=i.slice(o+1).trim();u[a]=l}r.push({reference:c,parameters:u})}return r}const[zt,Gt]=c.versions.node.split(".").map(Number);function validateSearchParameters(t){for(const r in t){const i=t[r];qe.any([ze.string,ze.number,ze.boolean,ze.null_,ze.undefined],i)}}const Wt=new Map;let Vt;const getGlobalDnsCache=()=>{if(Vt){return Vt}Vt=new CacheableLookup;return Vt};const Yt={request:undefined,agent:{http:undefined,https:undefined,http2:undefined},h2session:undefined,decompress:true,timeout:{connect:undefined,lookup:undefined,read:undefined,request:undefined,response:undefined,secureConnect:undefined,send:undefined,socket:undefined},prefixUrl:"",body:undefined,form:undefined,json:undefined,cookieJar:undefined,ignoreInvalidCookies:false,searchParams:undefined,dnsLookup:undefined,dnsCache:undefined,context:{},hooks:{init:[],beforeRequest:[],beforeError:[],beforeRedirect:[],beforeRetry:[],afterResponse:[]},followRedirect:true,maxRedirects:10,cache:undefined,throwHttpErrors:true,username:"",password:"",http2:false,allowGetBody:false,headers:{"user-agent":"got (https://github.com/sindresorhus/got)"},methodRewriting:false,dnsLookupIpVersion:undefined,parseJson:JSON.parse,stringifyJson:JSON.stringify,retry:{limit:2,methods:["GET","PUT","HEAD","DELETE","OPTIONS","TRACE"],statusCodes:[408,413,429,500,502,503,504,521,522,524],errorCodes:["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN"],maxRetryAfter:undefined,calculateDelay:({computedValue:t})=>t,backoffLimit:Number.POSITIVE_INFINITY,noise:100},localAddress:undefined,method:"GET",createConnection:undefined,cacheOptions:{shared:undefined,cacheHeuristic:undefined,immutableMinTimeToLive:undefined,ignoreCargoCult:undefined},https:{alpnProtocols:undefined,rejectUnauthorized:undefined,checkServerIdentity:undefined,certificateAuthority:undefined,key:undefined,certificate:undefined,passphrase:undefined,pfx:undefined,ciphers:undefined,honorCipherOrder:undefined,minVersion:undefined,maxVersion:undefined,signatureAlgorithms:undefined,tlsSessionLifetime:undefined,dhparam:undefined,ecdhCurve:undefined,certificateRevocationLists:undefined},encoding:undefined,resolveBodyOnly:false,isStream:false,responseType:"text",url:undefined,pagination:{transform(t){if(t.request.options.responseType==="json"){return t.body}return JSON.parse(t.body)},paginate({response:t}){const r=t.headers.link;if(typeof r!=="string"||r.trim()===""){return false}const i=parseLinkHeader(r);const o=i.find((t=>t.parameters.rel==="next"||t.parameters.rel==='"next"'));if(o){return{url:new ye.URL(o.reference,t.url)}}return false},filter:()=>true,shouldContinue:()=>true,countLimit:Number.POSITIVE_INFINITY,backoff:0,requestLimit:1e4,stackAllItems:false},setHost:true,maxHeaderSize:undefined,signal:undefined,enableUnixSockets:true};const cloneInternals=t=>{const{hooks:r,retry:i}=t;const o={...t,context:{...t.context},cacheOptions:{...t.cacheOptions},https:{...t.https},agent:{...t.agent},headers:{...t.headers},retry:{...i,errorCodes:[...i.errorCodes],methods:[...i.methods],statusCodes:[...i.statusCodes]},timeout:{...t.timeout},hooks:{init:[...r.init],beforeRequest:[...r.beforeRequest],beforeError:[...r.beforeError],beforeRedirect:[...r.beforeRedirect],beforeRetry:[...r.beforeRetry],afterResponse:[...r.afterResponse]},searchParams:t.searchParams?new ye.URLSearchParams(t.searchParams):undefined,pagination:{...t.pagination}};if(o.url!==undefined){o.prefixUrl=""}return o};const cloneRaw=t=>{const{hooks:r,retry:i}=t;const o={...t};if(ze.object(t.context)){o.context={...t.context}}if(ze.object(t.cacheOptions)){o.cacheOptions={...t.cacheOptions}}if(ze.object(t.https)){o.https={...t.https}}if(ze.object(t.cacheOptions)){o.cacheOptions={...o.cacheOptions}}if(ze.object(t.agent)){o.agent={...t.agent}}if(ze.object(t.headers)){o.headers={...t.headers}}if(ze.object(i)){o.retry={...i};if(ze.array(i.errorCodes)){o.retry.errorCodes=[...i.errorCodes]}if(ze.array(i.methods)){o.retry.methods=[...i.methods]}if(ze.array(i.statusCodes)){o.retry.statusCodes=[...i.statusCodes]}}if(ze.object(t.timeout)){o.timeout={...t.timeout}}if(ze.object(r)){o.hooks={...r};if(ze.array(r.init)){o.hooks.init=[...r.init]}if(ze.array(r.beforeRequest)){o.hooks.beforeRequest=[...r.beforeRequest]}if(ze.array(r.beforeError)){o.hooks.beforeError=[...r.beforeError]}if(ze.array(r.beforeRedirect)){o.hooks.beforeRedirect=[...r.beforeRedirect]}if(ze.array(r.beforeRetry)){o.hooks.beforeRetry=[...r.beforeRetry]}if(ze.array(r.afterResponse)){o.hooks.afterResponse=[...r.afterResponse]}}if(ze.object(t.pagination)){o.pagination={...t.pagination}}return o};const getHttp2TimeoutOption=t=>{const r=[t.timeout.socket,t.timeout.connect,t.timeout.lookup,t.timeout.request,t.timeout.secureConnect].filter((t=>typeof t==="number"));if(r.length>0){return Math.min(...r)}return undefined};const init=(t,r,i)=>{const o=t.hooks?.init;if(o){for(const t of o){t(r,i)}}};class Options{constructor(t,r,i){Object.defineProperty(this,"_unixOptions",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"_internals",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"_merging",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"_init",{enumerable:true,configurable:true,writable:true,value:void 0});qe.any([ze.string,ze.urlInstance,ze.object,ze.undefined],t);qe.any([ze.object,ze.undefined],r);qe.any([ze.object,ze.undefined],i);if(t instanceof Options||r instanceof Options){throw new TypeError("The defaults must be passed as the third argument")}this._internals=cloneInternals(i?._internals??i??Yt);this._init=[...i?._init??[]];this._merging=false;this._unixOptions=undefined;try{if(ze.plainObject(t)){try{this.merge(t);this.merge(r)}finally{this.url=t.url}}else{try{this.merge(r)}finally{if(r?.url!==undefined){if(t===undefined){this.url=r.url}else{throw new TypeError("The `url` option is mutually exclusive with the `input` argument")}}else if(t!==undefined){this.url=t}}}}catch(t){t.options=this;throw t}}merge(t){if(!t){return}if(t instanceof Options){for(const r of t._init){this.merge(r)}return}t=cloneRaw(t);init(this,t,this);init(t,t,this);this._merging=true;if("isStream"in t){this.isStream=t.isStream}try{let r=false;for(const i in t){if(i==="mutableDefaults"||i==="handlers"){continue}if(i==="url"){continue}if(!(i in this)){throw new Error(`Unexpected option: ${i}`)}this[i]=t[i];r=true}if(r){this._init.push(t)}}finally{this._merging=false}}get request(){return this._internals.request}set request(t){qe.any([ze.function_,ze.undefined],t);this._internals.request=t}get agent(){return this._internals.agent}set agent(t){qe.plainObject(t);for(const r in t){if(!(r in this._internals.agent)){throw new TypeError(`Unexpected agent option: ${r}`)}qe.any([ze.object,ze.undefined],t[r])}if(this._merging){Object.assign(this._internals.agent,t)}else{this._internals.agent={...t}}}get h2session(){return this._internals.h2session}set h2session(t){this._internals.h2session=t}get decompress(){return this._internals.decompress}set decompress(t){qe.boolean(t);this._internals.decompress=t}get timeout(){return this._internals.timeout}set timeout(t){qe.plainObject(t);for(const r in t){if(!(r in this._internals.timeout)){throw new Error(`Unexpected timeout option: ${r}`)}qe.any([ze.number,ze.undefined],t[r])}if(this._merging){Object.assign(this._internals.timeout,t)}else{this._internals.timeout={...t}}}get prefixUrl(){return this._internals.prefixUrl}set prefixUrl(t){qe.any([ze.string,ze.urlInstance],t);if(t===""){this._internals.prefixUrl="";return}t=t.toString();if(!t.endsWith("/")){t+="/"}if(this._internals.prefixUrl&&this._internals.url){const{href:r}=this._internals.url;this._internals.url.href=t+r.slice(this._internals.prefixUrl.length)}this._internals.prefixUrl=t}get body(){return this._internals.body}set body(t){qe.any([ze.string,ze.buffer,ze.nodeStream,ze.generator,ze.asyncGenerator,isFormData,ze.undefined],t);if(ze.nodeStream(t)){qe.truthy(t.readable)}if(t!==undefined){qe.undefined(this._internals.form);qe.undefined(this._internals.json)}this._internals.body=t}get form(){return this._internals.form}set form(t){qe.any([ze.plainObject,ze.undefined],t);if(t!==undefined){qe.undefined(this._internals.body);qe.undefined(this._internals.json)}this._internals.form=t}get json(){return this._internals.json}set json(t){if(t!==undefined){qe.undefined(this._internals.body);qe.undefined(this._internals.form)}this._internals.json=t}get url(){return this._internals.url}set url(t){qe.any([ze.string,ze.urlInstance,ze.undefined],t);if(t===undefined){this._internals.url=undefined;return}if(ze.string(t)&&t.startsWith("/")){throw new Error("`url` must not start with a slash")}const r=`${this.prefixUrl}${t.toString()}`;const i=new ye.URL(r);this._internals.url=i;decodeURI(r);if(i.protocol==="unix:"){i.href=`http://unix${i.pathname}${i.search}`}if(i.protocol!=="http:"&&i.protocol!=="https:"){const t=new Error(`Unsupported protocol: ${i.protocol}`);t.code="ERR_UNSUPPORTED_PROTOCOL";throw t}if(this._internals.username){i.username=this._internals.username;this._internals.username=""}if(this._internals.password){i.password=this._internals.password;this._internals.password=""}if(this._internals.searchParams){i.search=this._internals.searchParams.toString();this._internals.searchParams=undefined}if(i.hostname==="unix"){if(!this._internals.enableUnixSockets){throw new Error("Using UNIX domain sockets but option `enableUnixSockets` is not enabled")}const t=/(?<socketPath>.+?):(?<path>.+)/.exec(`${i.pathname}${i.search}`);if(t?.groups){const{socketPath:r,path:i}=t.groups;this._unixOptions={socketPath:r,path:i,host:""}}else{this._unixOptions=undefined}return}this._unixOptions=undefined}get cookieJar(){return this._internals.cookieJar}set cookieJar(t){qe.any([ze.object,ze.undefined],t);if(t===undefined){this._internals.cookieJar=undefined;return}let{setCookie:r,getCookieString:i}=t;qe.function_(r);qe.function_(i);if(r.length===4&&i.length===0){r=(0,kt.promisify)(r.bind(t));i=(0,kt.promisify)(i.bind(t));this._internals.cookieJar={setCookie:r,getCookieString:i}}else{this._internals.cookieJar=t}}get signal(){return this._internals.signal}set signal(t){qe.object(t);this._internals.signal=t}get ignoreInvalidCookies(){return this._internals.ignoreInvalidCookies}set ignoreInvalidCookies(t){qe.boolean(t);this._internals.ignoreInvalidCookies=t}get searchParams(){if(this._internals.url){return this._internals.url.searchParams}if(this._internals.searchParams===undefined){this._internals.searchParams=new ye.URLSearchParams}return this._internals.searchParams}set searchParams(t){qe.any([ze.string,ze.object,ze.undefined],t);const r=this._internals.url;if(t===undefined){this._internals.searchParams=undefined;if(r){r.search=""}return}const i=this.searchParams;let o;if(ze.string(t)){o=new ye.URLSearchParams(t)}else if(t instanceof ye.URLSearchParams){o=t}else{validateSearchParameters(t);o=new ye.URLSearchParams;for(const r in t){const a=t[r];if(a===null){o.append(r,"")}else if(a===undefined){i.delete(r)}else{o.append(r,a)}}}if(this._merging){for(const t of o.keys()){i.delete(t)}for(const[t,r]of o){i.append(t,r)}}else if(r){r.search=i.toString()}else{this._internals.searchParams=i}}get searchParameters(){throw new Error("The `searchParameters` option does not exist. Use `searchParams` instead.")}set searchParameters(t){throw new Error("The `searchParameters` option does not exist. Use `searchParams` instead.")}get dnsLookup(){return this._internals.dnsLookup}set dnsLookup(t){qe.any([ze.function_,ze.undefined],t);this._internals.dnsLookup=t}get dnsCache(){return this._internals.dnsCache}set dnsCache(t){qe.any([ze.object,ze.boolean,ze.undefined],t);if(t===true){this._internals.dnsCache=getGlobalDnsCache()}else if(t===false){this._internals.dnsCache=undefined}else{this._internals.dnsCache=t}}get context(){return this._internals.context}set context(t){qe.object(t);if(this._merging){Object.assign(this._internals.context,t)}else{this._internals.context={...t}}}get hooks(){return this._internals.hooks}set hooks(t){qe.object(t);for(const r in t){if(!(r in this._internals.hooks)){throw new Error(`Unexpected hook event: ${r}`)}const i=r;const o=t[i];qe.any([ze.array,ze.undefined],o);if(o){for(const t of o){qe.function_(t)}}if(this._merging){if(o){this._internals.hooks[i].push(...o)}}else{if(!o){throw new Error(`Missing hook event: ${r}`)}this._internals.hooks[r]=[...o]}}}get followRedirect(){return this._internals.followRedirect}set followRedirect(t){qe.boolean(t);this._internals.followRedirect=t}get followRedirects(){throw new TypeError("The `followRedirects` option does not exist. Use `followRedirect` instead.")}set followRedirects(t){throw new TypeError("The `followRedirects` option does not exist. Use `followRedirect` instead.")}get maxRedirects(){return this._internals.maxRedirects}set maxRedirects(t){qe.number(t);this._internals.maxRedirects=t}get cache(){return this._internals.cache}set cache(t){qe.any([ze.object,ze.string,ze.boolean,ze.undefined],t);if(t===true){this._internals.cache=Wt}else if(t===false){this._internals.cache=undefined}else{this._internals.cache=t}}get throwHttpErrors(){return this._internals.throwHttpErrors}set throwHttpErrors(t){qe.boolean(t);this._internals.throwHttpErrors=t}get username(){const t=this._internals.url;const r=t?t.username:this._internals.username;return decodeURIComponent(r)}set username(t){qe.string(t);const r=this._internals.url;const i=encodeURIComponent(t);if(r){r.username=i}else{this._internals.username=i}}get password(){const t=this._internals.url;const r=t?t.password:this._internals.password;return decodeURIComponent(r)}set password(t){qe.string(t);const r=this._internals.url;const i=encodeURIComponent(t);if(r){r.password=i}else{this._internals.password=i}}get http2(){return this._internals.http2}set http2(t){qe.boolean(t);this._internals.http2=t}get allowGetBody(){return this._internals.allowGetBody}set allowGetBody(t){qe.boolean(t);this._internals.allowGetBody=t}get headers(){return this._internals.headers}set headers(t){qe.plainObject(t);if(this._merging){Object.assign(this._internals.headers,lowercaseKeys(t))}else{this._internals.headers=lowercaseKeys(t)}}get methodRewriting(){return this._internals.methodRewriting}set methodRewriting(t){qe.boolean(t);this._internals.methodRewriting=t}get dnsLookupIpVersion(){return this._internals.dnsLookupIpVersion}set dnsLookupIpVersion(t){if(t!==undefined&&t!==4&&t!==6){throw new TypeError(`Invalid DNS lookup IP version: ${t}`)}this._internals.dnsLookupIpVersion=t}get parseJson(){return this._internals.parseJson}set parseJson(t){qe.function_(t);this._internals.parseJson=t}get stringifyJson(){return this._internals.stringifyJson}set stringifyJson(t){qe.function_(t);this._internals.stringifyJson=t}get retry(){return this._internals.retry}set retry(t){qe.plainObject(t);qe.any([ze.function_,ze.undefined],t.calculateDelay);qe.any([ze.number,ze.undefined],t.maxRetryAfter);qe.any([ze.number,ze.undefined],t.limit);qe.any([ze.array,ze.undefined],t.methods);qe.any([ze.array,ze.undefined],t.statusCodes);qe.any([ze.array,ze.undefined],t.errorCodes);qe.any([ze.number,ze.undefined],t.noise);if(t.noise&&Math.abs(t.noise)>100){throw new Error(`The maximum acceptable retry noise is +/- 100ms, got ${t.noise}`)}for(const r in t){if(!(r in this._internals.retry)){throw new Error(`Unexpected retry option: ${r}`)}}if(this._merging){Object.assign(this._internals.retry,t)}else{this._internals.retry={...t}}const{retry:r}=this._internals;r.methods=[...new Set(r.methods.map((t=>t.toUpperCase())))];r.statusCodes=[...new Set(r.statusCodes)];r.errorCodes=[...new Set(r.errorCodes)]}get localAddress(){return this._internals.localAddress}set localAddress(t){qe.any([ze.string,ze.undefined],t);this._internals.localAddress=t}get method(){return this._internals.method}set method(t){qe.string(t);this._internals.method=t.toUpperCase()}get createConnection(){return this._internals.createConnection}set createConnection(t){qe.any([ze.function_,ze.undefined],t);this._internals.createConnection=t}get cacheOptions(){return this._internals.cacheOptions}set cacheOptions(t){qe.plainObject(t);qe.any([ze.boolean,ze.undefined],t.shared);qe.any([ze.number,ze.undefined],t.cacheHeuristic);qe.any([ze.number,ze.undefined],t.immutableMinTimeToLive);qe.any([ze.boolean,ze.undefined],t.ignoreCargoCult);for(const r in t){if(!(r in this._internals.cacheOptions)){throw new Error(`Cache option \`${r}\` does not exist`)}}if(this._merging){Object.assign(this._internals.cacheOptions,t)}else{this._internals.cacheOptions={...t}}}get https(){return this._internals.https}set https(t){qe.plainObject(t);qe.any([ze.boolean,ze.undefined],t.rejectUnauthorized);qe.any([ze.function_,ze.undefined],t.checkServerIdentity);qe.any([ze.string,ze.object,ze.array,ze.undefined],t.certificateAuthority);qe.any([ze.string,ze.object,ze.array,ze.undefined],t.key);qe.any([ze.string,ze.object,ze.array,ze.undefined],t.certificate);qe.any([ze.string,ze.undefined],t.passphrase);qe.any([ze.string,ze.buffer,ze.array,ze.undefined],t.pfx);qe.any([ze.array,ze.undefined],t.alpnProtocols);qe.any([ze.string,ze.undefined],t.ciphers);qe.any([ze.string,ze.buffer,ze.undefined],t.dhparam);qe.any([ze.string,ze.undefined],t.signatureAlgorithms);qe.any([ze.string,ze.undefined],t.minVersion);qe.any([ze.string,ze.undefined],t.maxVersion);qe.any([ze.boolean,ze.undefined],t.honorCipherOrder);qe.any([ze.number,ze.undefined],t.tlsSessionLifetime);qe.any([ze.string,ze.undefined],t.ecdhCurve);qe.any([ze.string,ze.buffer,ze.array,ze.undefined],t.certificateRevocationLists);for(const r in t){if(!(r in this._internals.https)){throw new Error(`HTTPS option \`${r}\` does not exist`)}}if(this._merging){Object.assign(this._internals.https,t)}else{this._internals.https={...t}}}get encoding(){return this._internals.encoding}set encoding(t){if(t===null){throw new TypeError("To get a Buffer, set `options.responseType` to `buffer` instead")}qe.any([ze.string,ze.undefined],t);this._internals.encoding=t}get resolveBodyOnly(){return this._internals.resolveBodyOnly}set resolveBodyOnly(t){qe.boolean(t);this._internals.resolveBodyOnly=t}get isStream(){return this._internals.isStream}set isStream(t){qe.boolean(t);this._internals.isStream=t}get responseType(){return this._internals.responseType}set responseType(t){if(t===undefined){this._internals.responseType="text";return}if(t!=="text"&&t!=="buffer"&&t!=="json"){throw new Error(`Invalid \`responseType\` option: ${t}`)}this._internals.responseType=t}get pagination(){return this._internals.pagination}set pagination(t){qe.object(t);if(this._merging){Object.assign(this._internals.pagination,t)}else{this._internals.pagination=t}}get auth(){throw new Error("Parameter `auth` is deprecated. Use `username` / `password` instead.")}set auth(t){throw new Error("Parameter `auth` is deprecated. Use `username` / `password` instead.")}get setHost(){return this._internals.setHost}set setHost(t){qe.boolean(t);this._internals.setHost=t}get maxHeaderSize(){return this._internals.maxHeaderSize}set maxHeaderSize(t){qe.any([ze.number,ze.undefined],t);this._internals.maxHeaderSize=t}get enableUnixSockets(){return this._internals.enableUnixSockets}set enableUnixSockets(t){qe.boolean(t);this._internals.enableUnixSockets=t}toJSON(){return{...this._internals}}[Symbol.for("nodejs.util.inspect.custom")](t,r){return(0,kt.inspect)(this._internals,r)}createNativeRequestOptions(){const t=this._internals;const r=t.url;let i;if(r.protocol==="https:"){i=t.http2?t.agent:t.agent.https}else{i=t.agent.http}const{https:o}=t;let{pfx:a}=o;if(ze.array(a)&&ze.plainObject(a[0])){a=a.map((t=>({buf:t.buffer,passphrase:t.passphrase})))}return{...t.cacheOptions,...this._unixOptions,ALPNProtocols:o.alpnProtocols,ca:o.certificateAuthority,cert:o.certificate,key:o.key,passphrase:o.passphrase,pfx:o.pfx,rejectUnauthorized:o.rejectUnauthorized,checkServerIdentity:o.checkServerIdentity??Pt.checkServerIdentity,ciphers:o.ciphers,honorCipherOrder:o.honorCipherOrder,minVersion:o.minVersion,maxVersion:o.maxVersion,sigalgs:o.signatureAlgorithms,sessionTimeout:o.tlsSessionLifetime,dhparam:o.dhparam,ecdhCurve:o.ecdhCurve,crl:o.certificateRevocationLists,lookup:t.dnsLookup??t.dnsCache?.lookup,family:t.dnsLookupIpVersion,agent:i,setHost:t.setHost,method:t.method,maxHeaderSize:t.maxHeaderSize,localAddress:t.localAddress,headers:t.headers,createConnection:t.createConnection,timeout:t.http2?getHttp2TimeoutOption(t):undefined,h2session:t.h2session}}getRequestFunction(){const t=this._internals.url;const{request:r}=this._internals;if(!r&&t){return this.getFallbackRequestFunction()}return r}getFallbackRequestFunction(){const t=this._internals.url;if(!t){return}if(t.protocol==="https:"){if(this._internals.http2){if(zt<15||zt===15&&Gt<10){const t=new Error("To use the `http2` option, install Node.js 15.10.0 or above");t.code="EUNSUPPORTED";throw t}return qt.auto}return It.request}return We.request}freeze(){const t=this._internals;Object.freeze(t);Object.freeze(t.hooks);Object.freeze(t.hooks.afterResponse);Object.freeze(t.hooks.beforeError);Object.freeze(t.hooks.beforeRedirect);Object.freeze(t.hooks.beforeRequest);Object.freeze(t.hooks.beforeRetry);Object.freeze(t.hooks.init);Object.freeze(t.https);Object.freeze(t.cacheOptions);Object.freeze(t.agent);Object.freeze(t.headers);Object.freeze(t.timeout);Object.freeze(t.retry);Object.freeze(t.retry.errorCodes);Object.freeze(t.retry.methods);Object.freeze(t.retry.statusCodes)}}const isResponseOk=t=>{const{statusCode:r}=t;const i=t.request.options.followRedirect?299:399;return r>=200&&r<=i||r===304};class ParseError extends RequestError{constructor(t,r){const{options:i}=r.request;super(`${t.message} in "${i.url.toString()}"`,t,r.request);this.name="ParseError";this.code="ERR_BODY_PARSE_FAILURE"}}const parseBody=(t,r,i,o)=>{const{rawBody:a}=t;try{if(r==="text"){return a.toString(o)}if(r==="json"){return a.length===0?"":i(a.toString(o))}if(r==="buffer"){return a}}catch(r){throw new ParseError(r,t)}throw new ParseError({message:`Unknown body type '${r}'`,name:"Error"},t)};function isClientRequest(t){return t.writable&&!t.writableEnded}const Zt=isClientRequest;function isUnixSocketURL(t){return t.protocol==="unix:"||t.hostname==="unix"}const Kt=ze.string(c.versions.brotli);const Qt=new Set(["GET","HEAD"]);const Xt=new WeakableMap;const Jt=new Set([300,301,302,303,304,307,308]);const er=["socket","connect","continue","information","upgrade"];const core_noop=()=>{};class Request extends ge.Duplex{constructor(t,r,i){super({autoDestroy:false,highWaterMark:0});Object.defineProperty(this,"constructor",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"_noPipe",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"options",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"response",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"requestUrl",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"redirectUrls",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"retryCount",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"_stopRetry",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"_downloadedSize",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"_uploadedSize",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"_stopReading",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"_pipedServerResponses",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"_request",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"_responseSize",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"_bodySize",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"_unproxyEvents",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"_isFromCache",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"_cannotHaveBody",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"_triggerRead",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"_cancelTimeouts",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"_nativeResponse",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"_flushed",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"_aborted",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"_requestInitialized",{enumerable:true,configurable:true,writable:true,value:void 0});this._downloadedSize=0;this._uploadedSize=0;this._stopReading=false;this._pipedServerResponses=new Set;this._cannotHaveBody=false;this._unproxyEvents=core_noop;this._triggerRead=false;this._cancelTimeouts=core_noop;this._jobs=[];this._flushed=false;this._requestInitialized=false;this._aborted=false;this.redirectUrls=[];this.retryCount=0;this._stopRetry=core_noop;this.on("pipe",(t=>{if(t.headers){Object.assign(this.options.headers,t.headers)}}));this.on("newListener",(t=>{if(t==="retry"&&this.listenerCount("retry")>0){throw new Error("A retry listener has been attached already.")}}));try{this.options=new Options(t,r,i);if(!this.options.url){if(this.options.prefixUrl===""){throw new TypeError("Missing `url` property")}this.options.url=""}this.requestUrl=this.options.url}catch(t){const{options:r}=t;if(r){this.options=r}this.flush=async()=>{this.flush=async()=>{};this.destroy(t)};return}if(this.options.signal?.aborted){this.destroy(new errors_AbortError(this))}this.options.signal?.addEventListener("abort",(()=>{this.destroy(new errors_AbortError(this))}));const{body:o}=this.options;if(ze.nodeStream(o)){o.once("error",(t=>{if(this._flushed){this._beforeError(new UploadError(t,this))}else{this.flush=async()=>{this.flush=async()=>{};this._beforeError(new UploadError(t,this))}}}))}}async flush(){if(this._flushed){return}this._flushed=true;try{await this._finalizeBody();if(this.destroyed){return}await this._makeRequest();if(this.destroyed){this._request?.destroy();return}for(const t of this._jobs){t()}this._jobs.length=0;this._requestInitialized=true}catch(t){this._beforeError(t)}}_beforeError(t){if(this._stopReading){return}const{response:r,options:i}=this;const o=this.retryCount+(t.name==="RetryError"?0:1);this._stopReading=true;if(!(t instanceof RequestError)){t=new RequestError(t.message,t,this)}const a=t;void(async()=>{if(r?.readable&&!r.rawBody&&!this._request?.socket?.destroyed){r.setEncoding(this.readableEncoding);const t=await this._setRawBody(r);if(t){r.body=r.rawBody.toString()}}if(this.listenerCount("retry")!==0){let l;try{let t;if(r&&"retry-after"in r.headers){t=Number(r.headers["retry-after"]);if(Number.isNaN(t)){t=Date.parse(r.headers["retry-after"])-Date.now();if(t<=0){t=1}}else{t*=1e3}}const c=i.retry;l=await c.calculateDelay({attemptCount:o,retryOptions:c,error:a,retryAfter:t,computedValue:Ct({attemptCount:o,retryOptions:c,error:a,retryAfter:t,computedValue:c.maxRetryAfter??i.timeout.request??Number.POSITIVE_INFINITY})})}catch(t){void this._error(new RequestError(t.message,t,this));return}if(l){await new Promise((t=>{const r=setTimeout(t,l);this._stopRetry=()=>{clearTimeout(r);t()}}));if(this.destroyed){return}try{for(const t of this.options.hooks.beforeRetry){await t(a,this.retryCount+1)}}catch(r){void this._error(new RequestError(r.message,t,this));return}if(this.destroyed){return}this.destroy();this.emit("retry",this.retryCount+1,t,(t=>{const r=new Request(i.url,t,i);r.retryCount=this.retryCount+1;c.nextTick((()=>{void r.flush()}));return r}));return}}void this._error(a)})()}_read(){this._triggerRead=true;const{response:t}=this;if(t&&!this._stopReading){if(t.readableLength){this._triggerRead=false}let r;while((r=t.read())!==null){this._downloadedSize+=r.length;const t=this.downloadProgress;if(t.percent<1){this.emit("downloadProgress",t)}this.push(r)}}}_write(t,r,i){const write=()=>{this._writeRequest(t,r,i)};if(this._requestInitialized){write()}else{this._jobs.push(write)}}_final(t){const endRequest=()=>{if(!this._request||this._request.destroyed){t();return}this._request.end((r=>{if(this._request._writableState?.errored){return}if(!r){this._bodySize=this._uploadedSize;this.emit("uploadProgress",this.uploadProgress);this._request.emit("upload-complete")}t(r)}))};if(this._requestInitialized){endRequest()}else{this._jobs.push(endRequest)}}_destroy(t,r){this._stopReading=true;this.flush=async()=>{};this._stopRetry();this._cancelTimeouts();if(this.options){const{body:t}=this.options;if(ze.nodeStream(t)){t.destroy()}}if(this._request){this._request.destroy()}if(t!==null&&!ze.undefined(t)&&!(t instanceof RequestError)){t=new RequestError(t.message,t,this)}r(t)}pipe(t,r){if(t instanceof We.ServerResponse){this._pipedServerResponses.add(t)}return super.pipe(t,r)}unpipe(t){if(t instanceof We.ServerResponse){this._pipedServerResponses.delete(t)}super.unpipe(t);return this}async _finalizeBody(){const{options:t}=this;const{headers:r}=t;const i=!ze.undefined(t.form);const o=!ze.undefined(t.json);const a=!ze.undefined(t.body);const l=Qt.has(t.method)&&!(t.method==="GET"&&t.allowGetBody);this._cannotHaveBody=l;if(i||o||a){if(l){throw new TypeError(`The \`${t.method}\` method cannot be used with a body`)}const o=!ze.string(r["content-type"]);if(a){if(isFormData(t.body)){const i=new FormDataEncoder(t.body);if(o){r["content-type"]=i.headers["Content-Type"]}if("Content-Length"in i.headers){r["content-length"]=i.headers["Content-Length"]}t.body=i.encode()}if(is_form_data_isFormData(t.body)&&o){r["content-type"]=`multipart/form-data; boundary=${t.body.getBoundary()}`}}else if(i){if(o){r["content-type"]="application/x-www-form-urlencoded"}const{form:i}=t;t.form=undefined;t.body=new ye.URLSearchParams(i).toString()}else{if(o){r["content-type"]="application/json"}const{json:i}=t;t.json=undefined;t.body=t.stringifyJson(i)}const c=await getBodySize(t.body,t.headers);if(ze.undefined(r["content-length"])&&ze.undefined(r["transfer-encoding"])&&!l&&!ze.undefined(c)){r["content-length"]=String(c)}}if(t.responseType==="json"&&!("accept"in t.headers)){t.headers.accept="application/json"}this._bodySize=Number(r["content-length"])||undefined}async _onResponseBase(t){if(this.isAborted){return}const{options:r}=this;const{url:i}=r;this._nativeResponse=t;if(r.decompress){t=at(t)}const o=t.statusCode;const a=t;a.statusMessage=a.statusMessage?a.statusMessage:We.STATUS_CODES[o];a.url=r.url.toString();a.requestUrl=this.requestUrl;a.redirectUrls=this.redirectUrls;a.request=this;a.isFromCache=this._nativeResponse.fromCache??false;a.ip=this.ip;a.retryCount=this.retryCount;a.ok=isResponseOk(a);this._isFromCache=a.isFromCache;this._responseSize=Number(t.headers["content-length"])||undefined;this.response=a;t.once("end",(()=>{this._responseSize=this._downloadedSize;this.emit("downloadProgress",this.downloadProgress)}));t.once("error",(r=>{this._aborted=true;t.destroy();this._beforeError(new ReadError(r,this))}));t.once("aborted",(()=>{this._aborted=true;this._beforeError(new ReadError({name:"Error",message:"The server aborted pending request",code:"ECONNRESET"},this))}));this.emit("downloadProgress",this.downloadProgress);const l=t.headers["set-cookie"];if(ze.object(r.cookieJar)&&l){let t=l.map((async t=>r.cookieJar.setCookie(t,i.toString())));if(r.ignoreInvalidCookies){t=t.map((async t=>{try{await t}catch{}}))}try{await Promise.all(t)}catch(t){this._beforeError(t);return}}if(this.isAborted){return}if(r.followRedirect&&t.headers.location&&Jt.has(o)){t.resume();this._cancelTimeouts();this._unproxyEvents();if(this.redirectUrls.length>=r.maxRedirects){this._beforeError(new MaxRedirectsError(this));return}this._request=undefined;const l=new Options(undefined,undefined,this.options);const c=o===303&&l.method!=="GET"&&l.method!=="HEAD";const u=o!==307&&o!==308;const h=l.methodRewriting&&u;if(c||h){l.method="GET";l.body=undefined;l.json=undefined;l.form=undefined;delete l.headers["content-length"]}try{const r=Ge.Buffer.from(t.headers.location,"binary").toString();const o=new ye.URL(r,i);if(!isUnixSocketURL(i)&&isUnixSocketURL(o)){this._beforeError(new RequestError("Cannot redirect to UNIX socket",{},this));return}if(o.hostname!==i.hostname||o.port!==i.port){if("host"in l.headers){delete l.headers.host}if("cookie"in l.headers){delete l.headers.cookie}if("authorization"in l.headers){delete l.headers.authorization}if(l.username||l.password){l.username="";l.password=""}}else{o.username=l.username;o.password=l.password}this.redirectUrls.push(o);l.prefixUrl="";l.url=o;for(const t of l.hooks.beforeRedirect){await t(l,a)}this.emit("redirect",l,a);this.options=l;await this._makeRequest()}catch(t){this._beforeError(t);return}return}if(r.isStream&&r.throwHttpErrors&&!isResponseOk(a)){this._beforeError(new HTTPError(a));return}t.on("readable",(()=>{if(this._triggerRead){this._read()}}));this.on("resume",(()=>{t.resume()}));this.on("pause",(()=>{t.pause()}));t.once("end",(()=>{this.push(null)}));if(this._noPipe){const r=await this._setRawBody();if(r){this.emit("response",t)}return}this.emit("response",t);for(const i of this._pipedServerResponses){if(i.headersSent){continue}for(const o in t.headers){const a=r.decompress?o!=="content-encoding":true;const l=t.headers[o];if(a){i.setHeader(o,l)}}i.statusCode=o}}async _setRawBody(t=this){if(t.readableEnded){return false}try{const r=await(0,et.buffer)(t);if(!this.isAborted){this.response.rawBody=r;return true}}catch{}return false}async _onResponse(t){try{await this._onResponseBase(t)}catch(t){this._beforeError(t)}}_onRequest(t){const{options:r}=this;const{timeout:i,url:o}=r;Ke(t);if(this.options.http2){t.setTimeout(0)}this._cancelTimeouts=timedOut(t,i,o);const a=r.cache?"cacheableResponse":"response";t.once(a,(t=>{void this._onResponse(t)}));t.once("error",(r=>{this._aborted=true;t.destroy();r=r instanceof timed_out_TimeoutError?new TimeoutError(r,this.timings,this):new RequestError(r.message,r,this);this._beforeError(r)}));this._unproxyEvents=proxyEvents(t,this,er);this._request=t;this.emit("uploadProgress",this.uploadProgress);this._sendBody();this.emit("request",t)}async _asyncWrite(t){return new Promise(((r,i)=>{super.write(t,(t=>{if(t){i(t);return}r()}))}))}_sendBody(){const{body:t}=this.options;const r=this.redirectUrls.length===0?this:this._request??this;if(ze.nodeStream(t)){t.pipe(r)}else if(ze.generator(t)||ze.asyncGenerator(t)){(async()=>{try{for await(const r of t){await this._asyncWrite(r)}super.end()}catch(t){this._beforeError(t)}})()}else if(!ze.undefined(t)){this._writeRequest(t,undefined,(()=>{}));r.end()}else if(this._cannotHaveBody||this._noPipe){r.end()}}_prepareCache(t){if(!Xt.has(t)){const r=new nt(((t,r)=>{const i=t._request(t,r);if(ze.promise(i)){i.once=(t,r)=>{if(t==="error"){(async()=>{try{await i}catch(t){r(t)}})()}else if(t==="abort"){(async()=>{try{const t=await i;t.once("abort",r)}catch{}})()}else{throw new Error(`Unknown HTTP2 promise event: ${t}`)}return i}}return i}),t);Xt.set(t,r.request())}}async _createCacheableRequest(t,r){return new Promise(((i,o)=>{Object.assign(r,urlToOptions(t));let a;const l=Xt.get(r.cache)(r,(async t=>{t._readableState.autoDestroy=false;if(a){const fix=()=>{if(t.req){t.complete=t.req.res.complete}};t.prependOnceListener("end",fix);fix();(await a).emit("cacheableResponse",t)}i(t)}));l.once("error",o);l.once("request",(async t=>{a=t;i(a)}))}))}async _makeRequest(){const{options:t}=this;const{headers:r,username:i,password:o}=t;const a=t.cookieJar;for(const t in r){if(ze.undefined(r[t])){delete r[t]}else if(ze.null_(r[t])){throw new TypeError(`Use \`undefined\` instead of \`null\` to delete the \`${t}\` header`)}}if(t.decompress&&ze.undefined(r["accept-encoding"])){r["accept-encoding"]=Kt?"gzip, deflate, br":"gzip, deflate"}if(i||o){const t=Ge.Buffer.from(`${i}:${o}`).toString("base64");r.authorization=`Basic ${t}`}if(a){const i=await a.getCookieString(t.url.toString());if(ze.nonEmptyString(i)){r.cookie=i}}t.prefixUrl="";let l;for(const r of t.hooks.beforeRequest){const i=await r(t);if(!ze.undefined(i)){l=()=>i;break}}if(!l){l=t.getRequestFunction()}const c=t.url;this._requestOptions=t.createNativeRequestOptions();if(t.cache){this._requestOptions._request=l;this._requestOptions.cache=t.cache;this._requestOptions.body=t.body;this._prepareCache(t.cache)}const u=t.cache?this._createCacheableRequest:l;try{let r=u(c,this._requestOptions);if(ze.promise(r)){r=await r}if(ze.undefined(r)){r=t.getFallbackRequestFunction()(c,this._requestOptions);if(ze.promise(r)){r=await r}}if(Zt(r)){this._onRequest(r)}else if(this.writable){this.once("finish",(()=>{void this._onResponse(r)}));this._sendBody()}else{void this._onResponse(r)}}catch(t){if(t instanceof types_CacheError){throw new CacheError(t,this)}throw t}}async _error(t){try{if(t instanceof HTTPError&&!this.options.throwHttpErrors){}else{for(const r of this.options.hooks.beforeError){t=await r(t)}}}catch(r){t=new RequestError(r.message,r,this)}this.destroy(t)}_writeRequest(t,r,i){if(!this._request||this._request.destroyed){return}this._request.write(t,r,(o=>{if(!o&&!this._request.destroyed){this._uploadedSize+=Ge.Buffer.byteLength(t,r);const i=this.uploadProgress;if(i.percent<1){this.emit("uploadProgress",i)}}i(o)}))}get ip(){return this.socket?.remoteAddress}get isAborted(){return this._aborted}get socket(){return this._request?.socket??undefined}get downloadProgress(){let t;if(this._responseSize){t=this._downloadedSize/this._responseSize}else if(this._responseSize===this._downloadedSize){t=1}else{t=0}return{percent:t,transferred:this._downloadedSize,total:this._responseSize}}get uploadProgress(){let t;if(this._bodySize){t=this._uploadedSize/this._bodySize}else if(this._bodySize===this._uploadedSize){t=1}else{t=0}return{percent:t,transferred:this._uploadedSize,total:this._bodySize}}get timings(){return this._request?.timings}get isFromCache(){return this._isFromCache}get reusedSocket(){return this._request?.reusedSocket}}class types_CancelError extends RequestError{constructor(t){super("Promise was canceled",{},t);this.name="CancelError";this.code="ERR_CANCELED"}get isCanceled(){return true}}const tr=["request","response","redirect","uploadProgress","downloadProgress"];function asPromise(t){let r;let i;let o;const a=new ie.EventEmitter;const l=new PCancelable(((c,u,h)=>{h((()=>{r.destroy()}));h.shouldReject=false;h((()=>{u(new types_CancelError(r))}));const makeRequest=d=>{h((()=>{}));const p=t??new Request(undefined,undefined,o);p.retryCount=d;p._noPipe=true;r=p;p.once("response",(async t=>{const r=(t.headers["content-encoding"]??"").toLowerCase();const o=r==="gzip"||r==="deflate"||r==="br";const{options:a}=p;if(o&&!a.decompress){t.body=t.rawBody}else{try{t.body=parseBody(t,a.responseType,a.parseJson,a.encoding)}catch(r){t.body=t.rawBody.toString();if(isResponseOk(t)){p._beforeError(r);return}}}try{const r=a.hooks.afterResponse;for(const[i,o]of r.entries()){t=await o(t,(async t=>{a.merge(t);a.prefixUrl="";if(t.url){a.url=t.url}a.hooks.afterResponse=a.hooks.afterResponse.slice(0,i);throw new RetryError(p)}));if(!(ze.object(t)&&ze.number(t.statusCode)&&!ze.nullOrUndefined(t.body))){throw new TypeError("The `afterResponse` hook returned an invalid value")}}}catch(t){p._beforeError(t);return}i=t;if(!isResponseOk(t)){p._beforeError(new HTTPError(t));return}p.destroy();c(p.options.resolveBodyOnly?t.body:t)}));const onError=t=>{if(l.isCanceled){return}const{options:r}=p;if(t instanceof HTTPError&&!r.throwHttpErrors){const{response:r}=t;p.destroy();c(p.options.resolveBodyOnly?r.body:r);return}u(t)};p.once("error",onError);const m=p.options?.body;p.once("retry",((r,i)=>{t=undefined;const a=p.options.body;if(m===a&&ze.nodeStream(a)){i.message="Cannot retry with consumed body stream";onError(i);return}o=p.options;makeRequest(r)}));proxyEvents(p,a,tr);if(ze.undefined(t)){void p.flush()}};makeRequest(0)}));l.on=(t,r)=>{a.on(t,r);return l};l.off=(t,r)=>{a.off(t,r);return l};const shortcut=t=>{const r=(async()=>{await l;const{options:r}=i.request;return parseBody(i,t,r.parseJson,r.encoding)})();Object.defineProperties(r,Object.getOwnPropertyDescriptors(l));return r};l.json=()=>{if(r.options){const{headers:t}=r.options;if(!r.writableFinished&&!("accept"in t)){t.accept="application/json"}}return shortcut("json")};l.buffer=()=>shortcut("buffer");l.text=()=>shortcut("text");return l}const delay=async t=>new Promise((r=>{setTimeout(r,t)}));const isGotInstance=t=>ze.function_(t);const rr=["get","post","put","patch","head","delete"];const create=t=>{t={options:new Options(undefined,undefined,t.options),handlers:[...t.handlers],mutableDefaults:t.mutableDefaults};Object.defineProperty(t,"mutableDefaults",{enumerable:true,configurable:false,writable:false});const got=(r,i,o=t.options)=>{const a=new Request(r,i,o);let l;const lastHandler=t=>{a.options=t;a._noPipe=!t.isStream;void a.flush();if(t.isStream){return a}if(!l){l=asPromise(a)}return l};let c=0;const iterateHandlers=r=>{const i=t.handlers[c++]??lastHandler;const o=i(r,iterateHandlers);if(ze.promise(o)&&!a.options.isStream){if(!l){l=asPromise(a)}if(o!==l){const t=Object.getOwnPropertyDescriptors(l);for(const r in t){if(r in o){delete t[r]}}Object.defineProperties(o,t);o.cancel=l.cancel}}return o};return iterateHandlers(a.options)};got.extend=(...r)=>{const i=new Options(undefined,undefined,t.options);const o=[...t.handlers];let a;for(const t of r){if(isGotInstance(t)){i.merge(t.defaults.options);o.push(...t.defaults.handlers);a=t.defaults.mutableDefaults}else{i.merge(t);if(t.handlers){o.push(...t.handlers)}a=t.mutableDefaults}}return create({options:i,handlers:o,mutableDefaults:Boolean(a)})};const paginateEach=async function*(r,i){let o=new Options(r,i,t.options);o.resolveBodyOnly=false;const{pagination:a}=o;qe.function_(a.transform);qe.function_(a.shouldContinue);qe.function_(a.filter);qe.function_(a.paginate);qe.number(a.countLimit);qe.number(a.requestLimit);qe.number(a.backoff);const l=[];let{countLimit:c}=a;let u=0;while(u<a.requestLimit){if(u!==0){await delay(a.backoff)}const t=await got(undefined,undefined,o);const r=await a.transform(t);const i=[];qe.array(r);for(const t of r){if(a.filter({item:t,currentItems:i,allItems:l})){if(!a.shouldContinue({item:t,currentItems:i,allItems:l})){return}yield t;if(a.stackAllItems){l.push(t)}i.push(t);if(--c<=0){return}}}const h=a.paginate({response:t,currentItems:i,allItems:l});if(h===false){return}if(h===t.request.options){o=t.request.options}else{o.merge(h);qe.any([ze.urlInstance,ze.undefined],h.url);if(h.url!==undefined){o.prefixUrl="";o.url=h.url}}u++}};got.paginate=paginateEach;got.paginate.all=async(t,r)=>{const i=[];for await(const o of paginateEach(t,r)){i.push(o)}return i};got.paginate.each=paginateEach;got.stream=(t,r)=>got(t,{...r,isStream:true});for(const t of rr){got[t]=(r,i)=>got(r,{...i,method:t});got.stream[t]=(r,i)=>got(r,{...i,method:t,isStream:true})}if(!t.mutableDefaults){Object.freeze(t.handlers);t.options.freeze()}Object.defineProperty(got,"defaults",{value:t,writable:false,configurable:false,enumerable:true});return got};const ir=create;const sr={options:new Options,handlers:[],mutableDefaults:false};const nr=ir(sr);const or=nr;var ar=i(5793);var lr=i(2781);const cr=(0,Ye.promisify)(lr.Stream.pipeline);async function isUrlOk(t){const r=await or.head(t).catch((t=>t));return r.statusCode===200}async function getRepoInfo(t,r){const[,i,o,a,l,...c]=t.pathname.split("/");const u=r?r.replace(/^\//,""):c.join("/");if(a===undefined){const t=await or(`https://api.github.com/repos/${i}/${o}`).catch((t=>t));if(t.statusCode!==200){return}const r=JSON.parse(t.body);return{username:i,name:o,branch:r["default_branch"],filePath:u}}const h=r?`${l}/${c.join("/")}`.replace(new RegExp(`/${u}|/$`),""):l;if(i&&o&&h&&a==="tree"){return{username:i,name:o,branch:h,filePath:u}}}function hasRepo({username:t,name:r,branch:i,filePath:o}){const a=`https://api.github.com/repos/${t}/${r}/contents`;const l=`${o?`/${o}`:""}/package.json`;return isUrlOk(a+l+`?ref=${i}`)}function hasTemplate(t){return isUrlOk(`https://api.github.com/repos/openpatch/hyperbook/contents/templates/${encodeURIComponent(t)}/package.json`)}function downloadAndExtractRepo(t,{username:r,name:i,branch:o,filePath:a}){return cr(or.stream(`https://codeload.github.com/${r}/${i}/tar.gz/${o}`),ar.extract({cwd:t,strip:a?a.split("/").length+1:1},[`${i}-${o}${a?`/${a}`:""}`]))}async function getTemplateInfo(t){let r;if(t){let i;try{i=new URL(t)}catch(t){if(t.code!=="ERR_INVALID_URL"){console.error(t);process.exit(1)}}if(i){if(i.origin!=="https://github.com"){console.error(`Invalid URL: ${T.red(`"${t}"`)}. Only GitHub repositories are supported. Please use a GitHub URL and try again.`);process.exit(1)}r=await getRepoInfo(i);if(!r){console.error(`Found invalid GitHub URL: ${T.red(`"${t}"`)}. Please fix the URL and try again.`);process.exit(1)}const o=await hasRepo(r);if(!o){console.error(`Could not locate the repository for ${T.red(`"${t}"`)}. Please check that the repository exists and try again.`);process.exit(1)}}else if(t!=="__internal-testing-retry"){const r=await hasTemplate(t);if(!r){console.error(`Could not locate an template named ${T.red(`"${t}"`)}. It could be due to the following:\n`,`1. Your spelling of template ${T.red(`"${t}"`)} might be incorrect.\n`,`2. You might not be connected to the internet.`);process.exit(1)}}}return r}var ur=i(3493);var hr=i.n(ur);function install(t,r,{packageManager:i,isOnline:o,devDependencies:a}){const l=[];const c=[];return new Promise(((u,h)=>{let d;let p=i;const m=i==="yarn";if(r&&r.length){if(m){d=["add","--exact"];if(!o)d.push("--offline");d.push("--cwd",t);if(a)d.push("--dev");d.push(...r)}else{d=["install","--save-exact"];d.push(a?"--save-dev":"--save");d.push(...r)}}else{d=["install"];if(!o){console.log(T.yellow("You appear to be offline."));if(m){console.log(T.yellow("Falling back to the local Yarn cache."));console.log();d.push("--offline")}else{console.log()}}}if(m){d.push(...c)}else{d.push(...l)}const y=J()(p,d,{stdio:"inherit",cwd:G().join(process.cwd(),".hyperbook"),env:{...process.env,ADBLOCK:"1",DISABLE_OPENCOLLECTIVE:"1"}});y.on("close",(t=>{if(t!==0){h({command:`${p} ${d.join(" ")}`});return}u()}))}))}const fr=require("dns");var dr=i.n(fr);var pr=i(7310);var mr=i.n(pr);function getProxy(){if(process.env.https_proxy){return process.env.https_proxy}try{const t=(0,ee.execSync)("npm config get https-proxy").toString().trim();return t!=="null"?t:undefined}catch(t){return}}function getOnline(){return new Promise((t=>{dr().lookup("registry.yarnpkg.com",(r=>{if(!r){return t(true)}const i=getProxy();if(!i){return t(false)}const{hostname:o}=mr().parse(i);if(!o){return t(false)}dr().lookup(o,(r=>{t(r==null)}))}))}))}async function makeSymlink(t,r){const i=re().platform()=="win32"?"junction":null;return new Promise(((o,a)=>{V().symlink(t,r,i,(t=>{if(t){a()}else{o()}}))}))}const yr=require("fs/promises");var gr=i.n(yr);async function preparePackages(t){var r,i;const o=await gr().readFile(G().join(t,"package.json")).then((t=>t.toString("utf8"))).then((t=>JSON.parse(t)));const{dependencies:a,devDependencies:l}=o;for(let t of Object.entries(a)){const[i,o]=t;if(o==="workspace:*"){const t=`https://registry.npmjs.org/${encodeURIComponent(i)}`;const o=await or.get(t).json();const l=(r=o===null||o===void 0?void 0:o["dist-tags"])===null||r===void 0?void 0:r["latest"];if(l){a[i]=l}}}for(let t of Object.entries(l)){const[r,o]=t;if(o==="workspace:*"){const t=`https://registry.npmjs.org/${encodeURIComponent(r)}`;const o=await or.get(t).json();const a=(i=o===null||o===void 0?void 0:o["dist-tags"])===null||i===void 0?void 0:i["latest"];if(a){l[r]=a}}}o["dependencies"]=a;o["devDependencies"]=l;await gr().writeFile(G().join(t,"package.json"),JSON.stringify(o,null,2))}class DownloadError extends Error{}async function runSetup(t,r,i){if(!i){i=process.cwd()}if(!t){const r=await readHyperbook();t=r.template}if(!t){t="https://github.com/openpatch/hyperbook/tree/main/templates/simple"}if(!r){r=await getTemplateInfo(t)}const o=G().join(i,".hyperbook");console.log("Removing old template");De().sync(o);await makeDir(o);const a=await getOnline();try{if(r){const i=r;console.log(`Downloading files from repo ${T.cyan(t)}. This might take a moment.`);console.log();await hr()((()=>downloadAndExtractRepo(o,i)),{retries:3})}}catch(t){function isErrorLike(t){return typeof t==="object"&&t!==null&&typeof t.message==="string"}throw new DownloadError(isErrorLike(t)?t.message:t+"")}console.log("Prepare packages. Use latest versions.");console.log();await preparePackages(o);console.log("Installing packages. This might take a couple of minutes.");console.log();await install(o,null,{packageManager:"npm",isOnline:a});console.log();De().sync(G().join(o,"book"));De().sync(G().join(o,"public"));De().sync(G().join(o,"glossary"));De().sync(G().join(o,"hyperbook.json"));await makeSymlink(G().join(i,"book"),G().join(o,"book"));await makeSymlink(G().join(i,"public"),G().join(o,"public"));await makeSymlink(G().join(i,"glossary"),G().join(o,"glossary"));await makeSymlink(G().join(i,"hyperbook.json"),G().join(o,"hyperbook.json"))}async function runNew({programName:t,bookPath:r,template:o}){if(typeof r==="string"){r=r.trim()}if(!r){const t=await Le()({type:"text",name:"path",message:"What is your book named?",initial:"my-book"});if(typeof t.path==="string"){r=t.path.trim()}}if(!r){console.log();console.log("Please specify the book directory:");console.log(` ${T.cyan(t)} ${T.green("<book-directory>")}`);console.log();console.log("For example:");console.log(` ${T.cyan(t)} ${T.green("my-new-book")}`);console.log();console.log(`Run ${T.cyan(`${t} --help`)} to see all options.`);process.exit(1)}let a=await getTemplateInfo(o);const l=G().resolve(r);if(!await isWriteable(G().dirname(l))){console.error("The book 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 c=G().basename(l);await makeDir(l);if(!isFolderEmpty(l,c)){process.exit(1)}const u=process.cwd();console.log(`Creating a new hyperbook in ${T.green(l)}.`);console.log();process.chdir(l);const{description:h}=await Le()({type:"text",name:"description",message:"What is your book about?",initial:""});const{author:d}=await Le()({type:"text",name:"author",message:"Who is the author of the book?",initial:""});const{authorUrl:p}=await Le()({type:"text",name:"authorUrl",message:"What is the link to the authors homepage?",initial:""});let{license:m}=await Le()({type:"select",name:"license",message:"Pick a license for your book!",choices:[{title:"Creative Commons Zero (CC0)",value:"cc0"},{title:"Creative Commons Attribution (CC BY)",value:"cc-by"},{title:"Creative Commons Attribution-ShareAlike (CC BY-SA)",value:"cc-by-sa"},{title:"Creative Commons Attribution-NoDerivs (CC BY-ND)",value:"cc-by-nd"},{title:"Creative Commons Attribution-NonCommercial (CC BY-NC)",value:"cc-by-nc"},{title:"Creative Commons Attribution-NonCommercial-ShareAlike (CC BY-NC-SA)",value:"cc-by-nc-sa"},{title:"Creative Commons Attribution-NonCommercial-NoDervis (CC BY-NC-ND)",value:"cc-by-nc-nd"},{title:"Custom",value:"custom"}]});if(m==="custom"){const t=await Le()({type:"text",name:"license",message:"Which custom license you want to use?"});m=t.license}const{language:y}=await Le()({type:"text",name:"language",message:"In which language is your book written? Provide a short code, e.g.: en or de",initial:"en"});const g={name:c,version:"0.0.0",description:h,license:m,author:{name:d,url:p},language:y};V().writeFileSync(G().join(l,"hyperbook.json"),JSON.stringify(g,null,2)+re().EOL);console.log();const b=i.ab+"templates";await cpy("default/**",l,{cwd:i.ab+"templates",rename:t=>{switch(t){case"gitignore":{return".".concat(t)}case"README-template.md":{return"README.md"}default:{return t}}}});await runSetup(o,a,l);if(tryGitInit(l)){console.log("Initialized a git repository.");console.log()}let v;if(G().join(u,c)===r){v=c}else{v=r}console.log(`${T.green("Success!")} Created ${c} at ${r}`);console.log("Inside that directory, you can run several commands:");console.log();console.log(T.cyan(` hyperbook dev`));console.log(" Starts the development server.");console.log();console.log(T.cyan(` hyperbook build`));console.log(" Builds the book for production.");console.log();console.log("We suggest that you begin by typing:");console.log();console.log(T.cyan(" cd"),v);console.log(` ${T.cyan(`hyperbook dev`)}`);console.log()}const br=JSON.parse('{"name":"hyperbook","version":"0.5.4","author":"Mike Barkmin","homepage":"https://github.com/openpatch/hyperbook#readme","license":"MIT","bin":{"hyperbook":"./dist/index.js"},"files":["dist"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/openpatch/hyperbook.git","directory":"packages/hyperbook"},"bugs":{"url":"https://github.com/openpatch/hyperbook/issues"},"engines":{"node":">=12.22.0"},"scripts":{"version":"pnpm build","lint":"tsc --noEmit","dev":"ncc build ./index.ts -w -o dist/","build":"rimraf dist && ncc build ./index.ts -o ./dist/ --minify --no-cache --no-source-map-register"},"devDependencies":{"@types/archiver":"5.3.1","@types/async-retry":"1.4.5","@types/cross-spawn":"6.0.2","@types/prompts":"2.0.14","@types/rimraf":"3.0.2","@types/tar":"6.1.3","@vercel/ncc":"0.34.0","archiver":"5.3.1","async-retry":"1.3.3","chalk":"5.0.1","commander":"9.4.1","cpy":"9.0.1","cross-spawn":"7.0.3","got":"12.5.1","prompts":"2.4.2","rimraf":"3.0.2","tar":"6.1.11","update-check":"1.5.4"}}');const vr=new j;vr.name(br.name).version(br.version).hook("preAction",(async()=>{await notifyUpdate()}));vr.command("new").description("create a new hyperbook").arguments("<book-directory>").usage(`${T.green("<book-directory>")} [options]`).option("-t, --template [name]|[github-url]",`\n A template for your hyperbook. You can use an template name\n from the official hyperbook repo or a GitHub URL. The URL can use\n any branch and/or subdirectory\n`).action((async(t,r)=>{const i=typeof r.template==="string"&&r.template.trim();await runNew({programName:vr.name(),bookPath:t,template:i}).catch((()=>process.exit(1)))}));vr.command("dev").description("start the development server for a hyperbook").action((async()=>{await runDev().catch((()=>process.exit(1)))}));vr.command("setup").description("downloads the latest version of the template of a hyperbook").action((async()=>{await runSetup().catch((()=>process.exit(1)))}));vr.command("build").description("build a hyperbook").action((async()=>{await runArchive().catch((()=>process.exit(1)));await runBuild().catch((()=>process.exit(1)))}));vr.command("archive").description("create archives from archives folder").action((async()=>{await runArchive().catch((()=>process.exit(1)))}));vr.parseAsync(process.argv);const _r=q()(br).catch((()=>null));async function notifyUpdate(){try{const t=await _r;if(t===null||t===void 0?void 0:t.latest){const t=getPkgManager();console.log();console.log(T.yellow.bold("A new version of `hyperbook` is available!"));console.log("You can update by running: "+T.cyan(t==="yarn"?"yarn global add hyperbook":`${t} install --global hyperbook`));console.log()}process.exit()}catch{}}},9491:t=>{"use strict";t.exports=require("assert")},4300:t=>{"use strict";t.exports=require("buffer")},2081:t=>{"use strict";t.exports=require("child_process")},2057:t=>{"use strict";t.exports=require("constants")},6113:t=>{"use strict";t.exports=require("crypto")},2361:t=>{"use strict";t.exports=require("events")},7147:t=>{"use strict";t.exports=require("fs")},3685:t=>{"use strict";t.exports=require("http")},5158:t=>{"use strict";t.exports=require("http2")},5687:t=>{"use strict";t.exports=require("https")},1808:t=>{"use strict";t.exports=require("net")},2037:t=>{"use strict";t.exports=require("os")},1017:t=>{"use strict";t.exports=require("path")},7282:t=>{"use strict";t.exports=require("process")},4521:t=>{"use strict";t.exports=require("readline")},2781:t=>{"use strict";t.exports=require("stream")},1576:t=>{"use strict";t.exports=require("string_decoder")},4404:t=>{"use strict";t.exports=require("tls")},7310:t=>{"use strict";t.exports=require("url")},3837:t=>{"use strict";t.exports=require("util")},9796:t=>{"use strict";t.exports=require("zlib")},345:(t,r,i)=>{const{Argument:o}=i(4079);const{Command:a}=i(6505);const{CommanderError:l,InvalidArgumentError:c}=i(9027);const{Help:u}=i(9164);const{Option:h}=i(5205);r=t.exports=new a;r.program=r;r.Argument=o;r.Command=a;r.CommanderError=l;r.Help=u;r.InvalidArgumentError=c;r.InvalidOptionArgumentError=c;r.Option=h},4079:(t,r,i)=>{const{InvalidArgumentError:o}=i(9027);class Argument{constructor(t,r){this.description=r||"";this.variadic=false;this.parseArg=undefined;this.defaultValue=undefined;this.defaultValueDescription=undefined;this.argChoices=undefined;switch(t[0]){case"<":this.required=true;this._name=t.slice(1,-1);break;case"[":this.required=false;this._name=t.slice(1,-1);break;default:this.required=true;this._name=t;break}if(this._name.length>3&&this._name.slice(-3)==="..."){this.variadic=true;this._name=this._name.slice(0,-3)}}name(){return this._name}_concatValue(t,r){if(r===this.defaultValue||!Array.isArray(r)){return[t]}return r.concat(t)}default(t,r){this.defaultValue=t;this.defaultValueDescription=r;return this}argParser(t){this.parseArg=t;return this}choices(t){this.argChoices=t.slice();this.parseArg=(t,r)=>{if(!this.argChoices.includes(t)){throw new o(`Allowed choices are ${this.argChoices.join(", ")}.`)}if(this.variadic){return this._concatValue(t,r)}return t};return this}argRequired(){this.required=true;return this}argOptional(){this.required=false;return this}}function humanReadableArgName(t){const r=t.name()+(t.variadic===true?"...":"");return t.required?"<"+r+">":"["+r+"]"}r.Argument=Argument;r.humanReadableArgName=humanReadableArgName},6505:(t,r,i)=>{const o=i(2361).EventEmitter;const a=i(2081);const l=i(1017);const c=i(7147);const u=i(7282);const{Argument:h,humanReadableArgName:d}=i(4079);const{CommanderError:p}=i(9027);const{Help:m}=i(9164);const{Option:y,splitOptionFlags:g,DualOptions:b}=i(5205);const{suggestSimilar:v}=i(211);class Command extends o{constructor(t){super();this.commands=[];this.options=[];this.parent=null;this._allowUnknownOption=false;this._allowExcessArguments=true;this._args=[];this.args=[];this.rawArgs=[];this.processedArgs=[];this._scriptPath=null;this._name=t||"";this._optionValues={};this._optionValueSources={};this._storeOptionsAsProperties=false;this._actionHandler=null;this._executableHandler=false;this._executableFile=null;this._executableDir=null;this._defaultCommandName=null;this._exitCallback=null;this._aliases=[];this._combineFlagAndOptionalValue=true;this._description="";this._summary="";this._argsDescription=undefined;this._enablePositionalOptions=false;this._passThroughOptions=false;this._lifeCycleHooks={};this._showHelpAfterError=false;this._showSuggestionAfterError=true;this._outputConfiguration={writeOut:t=>u.stdout.write(t),writeErr:t=>u.stderr.write(t),getOutHelpWidth:()=>u.stdout.isTTY?u.stdout.columns:undefined,getErrHelpWidth:()=>u.stderr.isTTY?u.stderr.columns:undefined,outputError:(t,r)=>r(t)};this._hidden=false;this._hasHelpOption=true;this._helpFlags="-h, --help";this._helpDescription="display help for command";this._helpShortFlag="-h";this._helpLongFlag="--help";this._addImplicitHelpCommand=undefined;this._helpCommandName="help";this._helpCommandnameAndArgs="help [command]";this._helpCommandDescription="display help for command";this._helpConfiguration={}}copyInheritedSettings(t){this._outputConfiguration=t._outputConfiguration;this._hasHelpOption=t._hasHelpOption;this._helpFlags=t._helpFlags;this._helpDescription=t._helpDescription;this._helpShortFlag=t._helpShortFlag;this._helpLongFlag=t._helpLongFlag;this._helpCommandName=t._helpCommandName;this._helpCommandnameAndArgs=t._helpCommandnameAndArgs;this._helpCommandDescription=t._helpCommandDescription;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}command(t,r,i){let o=r;let a=i;if(typeof o==="object"&&o!==null){a=o;o=null}a=a||{};const[,l,c]=t.match(/([^ ]+) *(.*)/);const u=this.createCommand(l);if(o){u.description(o);u._executableHandler=true}if(a.isDefault)this._defaultCommandName=u._name;u._hidden=!!(a.noHelp||a.hidden);u._executableFile=a.executableFile||null;if(c)u.arguments(c);this.commands.push(u);u.parent=this;u.copyInheritedSettings(this);if(o)return this;return u}createCommand(t){return new Command(t)}createHelp(){return Object.assign(new m,this.configureHelp())}configureHelp(t){if(t===undefined)return this._helpConfiguration;this._helpConfiguration=t;return this}configureOutput(t){if(t===undefined)return this._outputConfiguration;Object.assign(this._outputConfiguration,t);return this}showHelpAfterError(t=true){if(typeof t!=="string")t=!!t;this._showHelpAfterError=t;return this}showSuggestionAfterError(t=true){this._showSuggestionAfterError=!!t;return this}addCommand(t,r){if(!t._name){throw new Error(`Command passed to .addCommand() must have a name\n- specify the name in Command constructor or using .name()`)}r=r||{};if(r.isDefault)this._defaultCommandName=t._name;if(r.noHelp||r.hidden)t._hidden=true;this.commands.push(t);t.parent=this;return this}createArgument(t,r){return new h(t,r)}argument(t,r,i,o){const a=this.createArgument(t,r);if(typeof i==="function"){a.default(o).argParser(i)}else{a.default(i)}this.addArgument(a);return this}arguments(t){t.split(/ +/).forEach((t=>{this.argument(t)}));return this}addArgument(t){const r=this._args.slice(-1)[0];if(r&&r.variadic){throw new Error(`only the last argument can be variadic '${r.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._args.push(t);return this}addHelpCommand(t,r){if(t===false){this._addImplicitHelpCommand=false}else{this._addImplicitHelpCommand=true;if(typeof t==="string"){this._helpCommandName=t.split(" ")[0];this._helpCommandnameAndArgs=t}this._helpCommandDescription=r||this._helpCommandDescription}return this}_hasImplicitHelpCommand(){if(this._addImplicitHelpCommand===undefined){return this.commands.length&&!this._actionHandler&&!this._findCommand("help")}return this._addImplicitHelpCommand}hook(t,r){const i=["preSubcommand","preAction","postAction"];if(!i.includes(t)){throw new Error(`Unexpected value for event passed to hook : '${t}'.\nExpecting one of '${i.join("', '")}'`)}if(this._lifeCycleHooks[t]){this._lifeCycleHooks[t].push(r)}else{this._lifeCycleHooks[t]=[r]}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,r,i){if(this._exitCallback){this._exitCallback(new p(t,r,i))}u.exit(t)}action(t){const listener=r=>{const i=this._args.length;const o=r.slice(0,i);if(this._storeOptionsAsProperties){o[i]=this}else{o[i]=this.opts()}o.push(this);return t.apply(this,o)};this._actionHandler=listener;return this}createOption(t,r){return new y(t,r)}addOption(t){const r=t.name();const i=t.attributeName();if(t.negate){const r=t.long.replace(/^--no-/,"--");if(!this._findOption(r)){this.setOptionValueWithSource(i,t.defaultValue===undefined?true:t.defaultValue,"default")}}else if(t.defaultValue!==undefined){this.setOptionValueWithSource(i,t.defaultValue,"default")}this.options.push(t);const handleOptionValue=(r,o,a)=>{if(r==null&&t.presetArg!==undefined){r=t.presetArg}const l=this.getOptionValue(i);if(r!==null&&t.parseArg){try{r=t.parseArg(r,l)}catch(t){if(t.code==="commander.invalidArgument"){const r=`${o} ${t.message}`;this.error(r,{exitCode:t.exitCode,code:t.code})}throw t}}else if(r!==null&&t.variadic){r=t._concatValue(r,l)}if(r==null){if(t.negate){r=false}else if(t.isBoolean()||t.optional){r=true}else{r=""}}this.setOptionValueWithSource(i,r,a)};this.on("option:"+r,(r=>{const i=`error: option '${t.flags}' argument '${r}' is invalid.`;handleOptionValue(r,i,"cli")}));if(t.envVar){this.on("optionEnv:"+r,(r=>{const i=`error: option '${t.flags}' value '${r}' from env '${t.envVar}' is invalid.`;handleOptionValue(r,i,"env")}))}return this}_optionEx(t,r,i,o,a){if(typeof r==="object"&&r instanceof y){throw new Error("To add an Option object use addOption() instead of option() or requiredOption()")}const l=this.createOption(r,i);l.makeOptionMandatory(!!t.mandatory);if(typeof o==="function"){l.default(a).argParser(o)}else if(o instanceof RegExp){const t=o;o=(r,i)=>{const o=t.exec(r);return o?o[0]:i};l.default(a).argParser(o)}else{l.default(o)}return this.addOption(l)}option(t,r,i,o){return this._optionEx({},t,r,i,o)}requiredOption(t,r,i,o){return this._optionEx({mandatory:true},t,r,i,o)}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;if(!!this.parent&&t&&!this.parent._enablePositionalOptions){throw new Error("passThroughOptions can not be used without turning on enablePositionalOptions for parent command(s)")}return this}storeOptionsAsProperties(t=true){this._storeOptionsAsProperties=!!t;if(this.options.length){throw new Error("call .storeOptionsAsProperties() before adding options")}return this}getOptionValue(t){if(this._storeOptionsAsProperties){return this[t]}return this._optionValues[t]}setOptionValue(t,r){return this.setOptionValueWithSource(t,r,undefined)}setOptionValueWithSource(t,r,i){if(this._storeOptionsAsProperties){this[t]=r}else{this._optionValues[t]=r}this._optionValueSources[t]=i;return this}getOptionValueSource(t){return this._optionValueSources[t]}_prepareUserArgs(t,r){if(t!==undefined&&!Array.isArray(t)){throw new Error("first parameter to parse must be array or undefined")}r=r||{};if(t===undefined){t=u.argv;if(u.versions&&u.versions.electron){r.from="electron"}}this.rawArgs=t.slice();let i;switch(r.from){case undefined:case"node":this._scriptPath=t[1];i=t.slice(2);break;case"electron":if(u.defaultApp){this._scriptPath=t[1];i=t.slice(2)}else{i=t.slice(1)}break;case"user":i=t.slice(0);break;default:throw new Error(`unexpected parse option { from: '${r.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);this._name=this._name||"program";return i}parse(t,r){const i=this._prepareUserArgs(t,r);this._parseCommand([],i);return this}async parseAsync(t,r){const i=this._prepareUserArgs(t,r);await this._parseCommand([],i);return this}_executeSubCommand(t,r){r=r.slice();let i=false;const o=[".js",".ts",".tsx",".mjs",".cjs"];function findFile(t,r){const i=l.resolve(t,r);if(c.existsSync(i))return i;if(o.includes(l.extname(r)))return undefined;const a=o.find((t=>c.existsSync(`${i}${t}`)));if(a)return`${i}${a}`;return undefined}this._checkForMissingMandatoryOptions();this._checkForConflictingOptions();let h=t._executableFile||`${this._name}-${t._name}`;let d=this._executableDir||"";if(this._scriptPath){let t;try{t=c.realpathSync(this._scriptPath)}catch(r){t=this._scriptPath}d=l.resolve(l.dirname(t),d)}if(d){let r=findFile(d,h);if(!r&&!t._executableFile&&this._scriptPath){const i=l.basename(this._scriptPath,l.extname(this._scriptPath));if(i!==this._name){r=findFile(d,`${i}-${t._name}`)}}h=r||h}i=o.includes(l.extname(h));let m;if(u.platform!=="win32"){if(i){r.unshift(h);r=incrementNodeInspectorPort(u.execArgv).concat(r);m=a.spawn(u.argv[0],r,{stdio:"inherit"})}else{m=a.spawn(h,r,{stdio:"inherit"})}}else{r.unshift(h);r=incrementNodeInspectorPort(u.execArgv).concat(r);m=a.spawn(u.execPath,r,{stdio:"inherit"})}if(!m.killed){const t=["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"];t.forEach((t=>{u.on(t,(()=>{if(m.killed===false&&m.exitCode===null){m.kill(t)}}))}))}const y=this._exitCallback;if(!y){m.on("close",u.exit.bind(u))}else{m.on("close",(()=>{y(new p(u.exitCode||0,"commander.executeSubCommandAsync","(close)"))}))}m.on("error",(r=>{if(r.code==="ENOENT"){const r=d?`searched for local subcommand relative to directory '${d}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory";const i=`'${h}' does not exist\n - if '${t._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead\n - if the default executable name is not suitable, use the executableFile option to supply a custom name or path\n - ${r}`;throw new Error(i)}else if(r.code==="EACCES"){throw new Error(`'${h}' not executable`)}if(!y){u.exit(1)}else{const t=new p(1,"commander.executeSubCommandAsync","(error)");t.nestedError=r;y(t)}}));this.runningCommand=m}_dispatchSubcommand(t,r,i){const o=this._findCommand(t);if(!o)this.help({error:true});let a;a=this._chainOrCallSubCommandHook(a,o,"preSubcommand");a=this._chainOrCall(a,(()=>{if(o._executableHandler){this._executeSubCommand(o,r.concat(i))}else{return o._parseCommand(r,i)}}));return a}_checkNumberOfArguments(){this._args.forEach(((t,r)=>{if(t.required&&this.args[r]==null){this.missingArgument(t.name())}}));if(this._args.length>0&&this._args[this._args.length-1].variadic){return}if(this.args.length>this._args.length){this._excessArguments(this.args)}}_processArguments(){const myParseArg=(t,r,i)=>{let o=r;if(r!==null&&t.parseArg){try{o=t.parseArg(r,i)}catch(i){if(i.code==="commander.invalidArgument"){const o=`error: command-argument value '${r}' is invalid for argument '${t.name()}'. ${i.message}`;this.error(o,{exitCode:i.exitCode,code:i.code})}throw i}}return o};this._checkNumberOfArguments();const t=[];this._args.forEach(((r,i)=>{let o=r.defaultValue;if(r.variadic){if(i<this.args.length){o=this.args.slice(i);if(r.parseArg){o=o.reduce(((t,i)=>myParseArg(r,i,t)),r.defaultValue)}}else if(o===undefined){o=[]}}else if(i<this.args.length){o=this.args[i];if(r.parseArg){o=myParseArg(r,o,r.defaultValue)}}t[i]=o}));this.processedArgs=t}_chainOrCall(t,r){if(t&&t.then&&typeof t.then==="function"){return t.then((()=>r()))}return r()}_chainOrCallHooks(t,r){let i=t;const o=[];getCommandAndParents(this).reverse().filter((t=>t._lifeCycleHooks[r]!==undefined)).forEach((t=>{t._lifeCycleHooks[r].forEach((r=>{o.push({hookedCommand:t,callback:r})}))}));if(r==="postAction"){o.reverse()}o.forEach((t=>{i=this._chainOrCall(i,(()=>t.callback(t.hookedCommand,this)))}));return i}_chainOrCallSubCommandHook(t,r,i){let o=t;if(this._lifeCycleHooks[i]!==undefined){this._lifeCycleHooks[i].forEach((t=>{o=this._chainOrCall(o,(()=>t(this,r)))}))}return o}_parseCommand(t,r){const i=this.parseOptions(r);this._parseOptionsEnv();this._parseOptionsImplied();t=t.concat(i.operands);r=i.unknown;this.args=t.concat(r);if(t&&this._findCommand(t[0])){return this._dispatchSubcommand(t[0],t.slice(1),r)}if(this._hasImplicitHelpCommand()&&t[0]===this._helpCommandName){if(t.length===1){this.help()}return this._dispatchSubcommand(t[1],[],[this._helpLongFlag])}if(this._defaultCommandName){outputHelpIfRequested(this,r);return this._dispatchSubcommand(this._defaultCommandName,t,r)}if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName){this.help({error:true})}outputHelpIfRequested(this,i.unknown);this._checkForMissingMandatoryOptions();this._checkForConflictingOptions();const checkForUnknownOptions=()=>{if(i.unknown.length>0){this.unknownOption(i.unknown[0])}};const o=`command:${this.name()}`;if(this._actionHandler){checkForUnknownOptions();this._processArguments();let i;i=this._chainOrCallHooks(i,"preAction");i=this._chainOrCall(i,(()=>this._actionHandler(this.processedArgs)));if(this.parent){i=this._chainOrCall(i,(()=>{this.parent.emit(o,t,r)}))}i=this._chainOrCallHooks(i,"postAction");return i}if(this.parent&&this.parent.listenerCount(o)){checkForUnknownOptions();this._processArguments();this.parent.emit(o,t,r)}else if(t.length){if(this._findCommand("*")){return this._dispatchSubcommand("*",t,r)}if(this.listenerCount("command:*")){this.emit("command:*",t,r)}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((r=>r._name===t||r._aliases.includes(t)))}_findOption(t){return this.options.find((r=>r.is(t)))}_checkForMissingMandatoryOptions(){for(let t=this;t;t=t.parent){t.options.forEach((r=>{if(r.mandatory&&t.getOptionValue(r.attributeName())===undefined){t.missingMandatoryOptionValue(r)}}))}}_checkForConflictingLocalOptions(){const t=this.options.filter((t=>{const r=t.attributeName();if(this.getOptionValue(r)===undefined){return false}return this.getOptionValueSource(r)!=="default"}));const r=t.filter((t=>t.conflictsWith.length>0));r.forEach((r=>{const i=t.find((t=>r.conflictsWith.includes(t.attributeName())));if(i){this._conflictingOption(r,i)}}))}_checkForConflictingOptions(){for(let t=this;t;t=t.parent){t._checkForConflictingLocalOptions()}}parseOptions(t){const r=[];const i=[];let o=r;const a=t.slice();function maybeOption(t){return t.length>1&&t[0]==="-"}let l=null;while(a.length){const t=a.shift();if(t==="--"){if(o===i)o.push(t);o.push(...a);break}if(l&&!maybeOption(t)){this.emit(`option:${l.name()}`,t);continue}l=null;if(maybeOption(t)){const r=this._findOption(t);if(r){if(r.required){const t=a.shift();if(t===undefined)this.optionMissingArgument(r);this.emit(`option:${r.name()}`,t)}else if(r.optional){let t=null;if(a.length>0&&!maybeOption(a[0])){t=a.shift()}this.emit(`option:${r.name()}`,t)}else{this.emit(`option:${r.name()}`)}l=r.variadic?r:null;continue}}if(t.length>2&&t[0]==="-"&&t[1]!=="-"){const r=this._findOption(`-${t[1]}`);if(r){if(r.required||r.optional&&this._combineFlagAndOptionalValue){this.emit(`option:${r.name()}`,t.slice(2))}else{this.emit(`option:${r.name()}`);a.unshift(`-${t.slice(2)}`)}continue}}if(/^--[^=]+=/.test(t)){const r=t.indexOf("=");const i=this._findOption(t.slice(0,r));if(i&&(i.required||i.optional)){this.emit(`option:${i.name()}`,t.slice(r+1));continue}}if(maybeOption(t)){o=i}if((this._enablePositionalOptions||this._passThroughOptions)&&r.length===0&&i.length===0){if(this._findCommand(t)){r.push(t);if(a.length>0)i.push(...a);break}else if(t===this._helpCommandName&&this._hasImplicitHelpCommand()){r.push(t);if(a.length>0)r.push(...a);break}else if(this._defaultCommandName){i.push(t);if(a.length>0)i.push(...a);break}}if(this._passThroughOptions){o.push(t);if(a.length>0)o.push(...a);break}o.push(t)}return{operands:r,unknown:i}}opts(){if(this._storeOptionsAsProperties){const t={};const r=this.options.length;for(let i=0;i<r;i++){const r=this.options[i].attributeName();t[r]=r===this._versionOptionName?this._version:this[r]}return t}return this._optionValues}optsWithGlobals(){return getCommandAndParents(this).reduce(((t,r)=>Object.assign(t,r.opts())),{})}error(t,r){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 i=r||{};const o=i.exitCode||1;const a=i.code||"commander.error";this._exit(o,a,t)}_parseOptionsEnv(){this.options.forEach((t=>{if(t.envVar&&t.envVar in u.env){const r=t.attributeName();if(this.getOptionValue(r)===undefined||["default","config","env"].includes(this.getOptionValueSource(r))){if(t.required||t.optional){this.emit(`optionEnv:${t.name()}`,u.env[t.envVar])}else{this.emit(`optionEnv:${t.name()}`)}}}}))}_parseOptionsImplied(){const t=new b(this.options);const hasCustomOptionValue=t=>this.getOptionValue(t)!==undefined&&!["default","implied"].includes(this.getOptionValueSource(t));this.options.filter((r=>r.implied!==undefined&&hasCustomOptionValue(r.attributeName())&&t.valueFromOption(this.getOptionValue(r.attributeName()),r))).forEach((t=>{Object.keys(t.implied).filter((t=>!hasCustomOptionValue(t))).forEach((r=>{this.setOptionValueWithSource(r,t.implied[r],"implied")}))}))}missingArgument(t){const r=`error: missing required argument '${t}'`;this.error(r,{code:"commander.missingArgument"})}optionMissingArgument(t){const r=`error: option '${t.flags}' argument missing`;this.error(r,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(t){const r=`error: required option '${t.flags}' not specified`;this.error(r,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(t,r){const findBestOptionFromValue=t=>{const r=t.attributeName();const i=this.getOptionValue(r);const o=this.options.find((t=>t.negate&&r===t.attributeName()));const a=this.options.find((t=>!t.negate&&r===t.attributeName()));if(o&&(o.presetArg===undefined&&i===false||o.presetArg!==undefined&&i===o.presetArg)){return o}return a||t};const getErrorMessage=t=>{const r=findBestOptionFromValue(t);const i=r.attributeName();const o=this.getOptionValueSource(i);if(o==="env"){return`environment variable '${r.envVar}'`}return`option '${r.flags}'`};const i=`error: ${getErrorMessage(t)} cannot be used with ${getErrorMessage(r)}`;this.error(i,{code:"commander.conflictingOption"})}unknownOption(t){if(this._allowUnknownOption)return;let r="";if(t.startsWith("--")&&this._showSuggestionAfterError){let i=[];let o=this;do{const t=o.createHelp().visibleOptions(o).filter((t=>t.long)).map((t=>t.long));i=i.concat(t);o=o.parent}while(o&&!o._enablePositionalOptions);r=v(t,i)}const i=`error: unknown option '${t}'${r}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(t){if(this._allowExcessArguments)return;const r=this._args.length;const i=r===1?"":"s";const o=this.parent?` for '${this.name()}'`:"";const a=`error: too many arguments${o}. Expected ${r} argument${i} but got ${t.length}.`;this.error(a,{code:"commander.excessArguments"})}unknownCommand(){const t=this.args[0];let r="";if(this._showSuggestionAfterError){const i=[];this.createHelp().visibleCommands(this).forEach((t=>{i.push(t.name());if(t.alias())i.push(t.alias())}));r=v(t,i)}const i=`error: unknown command '${t}'${r}`;this.error(i,{code:"commander.unknownCommand"})}version(t,r,i){if(t===undefined)return this._version;this._version=t;r=r||"-V, --version";i=i||"output the version number";const o=this.createOption(r,i);this._versionOptionName=o.attributeName();this.options.push(o);this.on("option:"+o.name(),(()=>{this._outputConfiguration.writeOut(`${t}\n`);this._exit(0,"commander.version",t)}));return this}description(t,r){if(t===undefined&&r===undefined)return this._description;this._description=t;if(r){this._argsDescription=r}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 r=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler){r=this.commands[this.commands.length-1]}if(t===r._name)throw new Error("Command alias can't be the same as its name");r._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._args.map((t=>d(t)));return[].concat(this.options.length||this._hasHelpOption?"[options]":[],this.commands.length?"[command]":[],this._args.length?t:[]).join(" ")}this._usage=t;return this}name(t){if(t===undefined)return this._name;this._name=t;return this}nameFromFilename(t){this._name=l.basename(t,l.extname(t));return this}executableDir(t){if(t===undefined)return this._executableDir;this._executableDir=t;return this}helpInformation(t){const r=this.createHelp();if(r.helpWidth===undefined){r.helpWidth=t&&t.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()}return r.formatHelp(this,r)}_getHelpContext(t){t=t||{};const r={error:!!t.error};let i;if(r.error){i=t=>this._outputConfiguration.writeErr(t)}else{i=t=>this._outputConfiguration.writeOut(t)}r.write=t.write||i;r.command=this;return r}outputHelp(t){let r;if(typeof t==="function"){r=t;t=undefined}const i=this._getHelpContext(t);getCommandAndParents(this).reverse().forEach((t=>t.emit("beforeAllHelp",i)));this.emit("beforeHelp",i);let o=this.helpInformation(i);if(r){o=r(o);if(typeof o!=="string"&&!Buffer.isBuffer(o)){throw new Error("outputHelp callback must return a string or a Buffer")}}i.write(o);this.emit(this._helpLongFlag);this.emit("afterHelp",i);getCommandAndParents(this).forEach((t=>t.emit("afterAllHelp",i)))}helpOption(t,r){if(typeof t==="boolean"){this._hasHelpOption=t;return this}this._helpFlags=t||this._helpFlags;this._helpDescription=r||this._helpDescription;const i=g(this._helpFlags);this._helpShortFlag=i.shortFlag;this._helpLongFlag=i.longFlag;return this}help(t){this.outputHelp(t);let r=u.exitCode||0;if(r===0&&t&&typeof t!=="function"&&t.error){r=1}this._exit(r,"commander.help","(outputHelp)")}addHelpText(t,r){const i=["beforeAll","before","after","afterAll"];if(!i.includes(t)){throw new Error(`Unexpected value for position to addHelpText.\nExpecting one of '${i.join("', '")}'`)}const o=`${t}Help`;this.on(o,(t=>{let i;if(typeof r==="function"){i=r({error:t.error,command:t.command})}else{i=r}if(i){t.write(`${i}\n`)}}));return this}}function outputHelpIfRequested(t,r){const i=t._hasHelpOption&&r.find((r=>r===t._helpLongFlag||r===t._helpShortFlag));if(i){t.outputHelp();t._exit(0,"commander.helpDisplayed","(outputHelp)")}}function incrementNodeInspectorPort(t){return t.map((t=>{if(!t.startsWith("--inspect")){return t}let r;let i="127.0.0.1";let o="9229";let a;if((a=t.match(/^(--inspect(-brk)?)$/))!==null){r=a[1]}else if((a=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null){r=a[1];if(/^\d+$/.test(a[3])){o=a[3]}else{i=a[3]}}else if((a=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null){r=a[1];i=a[3];o=a[4]}if(r&&o!=="0"){return`${r}=${i}:${parseInt(o)+1}`}return t}))}function getCommandAndParents(t){const r=[];for(let i=t;i;i=i.parent){r.push(i)}return r}r.Command=Command},9027:(t,r)=>{class CommanderError extends Error{constructor(t,r,i){super(i);Error.captureStackTrace(this,this.constructor);this.name=this.constructor.name;this.code=r;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}}r.CommanderError=CommanderError;r.InvalidArgumentError=InvalidArgumentError},9164:(t,r,i)=>{const{humanReadableArgName:o}=i(4079);class Help{constructor(){this.helpWidth=undefined;this.sortSubcommands=false;this.sortOptions=false}visibleCommands(t){const r=t.commands.filter((t=>!t._hidden));if(t._hasImplicitHelpCommand()){const[,i,o]=t._helpCommandnameAndArgs.match(/([^ ]+) *(.*)/);const a=t.createCommand(i).helpOption(false);a.description(t._helpCommandDescription);if(o)a.arguments(o);r.push(a)}if(this.sortSubcommands){r.sort(((t,r)=>t.name().localeCompare(r.name())))}return r}visibleOptions(t){const r=t.options.filter((t=>!t.hidden));const i=t._hasHelpOption&&t._helpShortFlag&&!t._findOption(t._helpShortFlag);const o=t._hasHelpOption&&!t._findOption(t._helpLongFlag);if(i||o){let a;if(!i){a=t.createOption(t._helpLongFlag,t._helpDescription)}else if(!o){a=t.createOption(t._helpShortFlag,t._helpDescription)}else{a=t.createOption(t._helpFlags,t._helpDescription)}r.push(a)}if(this.sortOptions){const getSortKey=t=>t.short?t.short.replace(/^-/,""):t.long.replace(/^--/,"");r.sort(((t,r)=>getSortKey(t).localeCompare(getSortKey(r))))}return r}visibleArguments(t){if(t._argsDescription){t._args.forEach((r=>{r.description=r.description||t._argsDescription[r.name()]||""}))}if(t._args.find((t=>t.description))){return t._args}return[]}subcommandTerm(t){const r=t._args.map((t=>o(t))).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(r?" "+r:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,r){return r.visibleCommands(t).reduce(((t,i)=>Math.max(t,r.subcommandTerm(i).length)),0)}longestOptionTermLength(t,r){return r.visibleOptions(t).reduce(((t,i)=>Math.max(t,r.optionTerm(i).length)),0)}longestArgumentTermLength(t,r){return r.visibleArguments(t).reduce(((t,i)=>Math.max(t,r.argumentTerm(i).length)),0)}commandUsage(t){let r=t._name;if(t._aliases[0]){r=r+"|"+t._aliases[0]}let i="";for(let r=t.parent;r;r=r.parent){i=r.name()+" "+i}return i+r+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){const r=[];if(t.argChoices){r.push(`choices: ${t.argChoices.map((t=>JSON.stringify(t))).join(", ")}`)}if(t.defaultValue!==undefined){const i=t.required||t.optional||t.isBoolean()&&typeof t.defaultValue==="boolean";if(i){r.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`)}}if(t.presetArg!==undefined&&t.optional){r.push(`preset: ${JSON.stringify(t.presetArg)}`)}if(t.envVar!==undefined){r.push(`env: ${t.envVar}`)}if(r.length>0){return`${t.description} (${r.join(", ")})`}return t.description}argumentDescription(t){const r=[];if(t.argChoices){r.push(`choices: ${t.argChoices.map((t=>JSON.stringify(t))).join(", ")}`)}if(t.defaultValue!==undefined){r.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`)}if(r.length>0){const i=`(${r.join(", ")})`;if(t.description){return`${t.description} ${i}`}return i}return t.description}formatHelp(t,r){const i=r.padWidth(t,r);const o=r.helpWidth||80;const a=2;const l=2;function formatItem(t,c){if(c){const u=`${t.padEnd(i+l)}${c}`;return r.wrap(u,o-a,i+l)}return t}function formatList(t){return t.join("\n").replace(/^/gm," ".repeat(a))}let c=[`Usage: ${r.commandUsage(t)}`,""];const u=r.commandDescription(t);if(u.length>0){c=c.concat([u,""])}const h=r.visibleArguments(t).map((t=>formatItem(r.argumentTerm(t),r.argumentDescription(t))));if(h.length>0){c=c.concat(["Arguments:",formatList(h),""])}const d=r.visibleOptions(t).map((t=>formatItem(r.optionTerm(t),r.optionDescription(t))));if(d.length>0){c=c.concat(["Options:",formatList(d),""])}const p=r.visibleCommands(t).map((t=>formatItem(r.subcommandTerm(t),r.subcommandDescription(t))));if(p.length>0){c=c.concat(["Commands:",formatList(p),""])}return c.join("\n")}padWidth(t,r){return Math.max(r.longestOptionTermLength(t,r),r.longestSubcommandTermLength(t,r),r.longestArgumentTermLength(t,r))}wrap(t,r,i,o=40){if(t.match(/[\n]\s+/))return t;const a=r-i;if(a<o)return t;const l=t.slice(0,i);const c=t.slice(i);const u=" ".repeat(i);const h=new RegExp(".{1,"+(a-1)+"}([\\s]|$)|[^\\s]+?([\\s]|$)","g");const d=c.match(h)||[];return l+d.map(((t,r)=>{if(t.slice(-1)==="\n"){t=t.slice(0,t.length-1)}return(r>0?u:"")+t.trimRight()})).join("\n")}}r.Help=Help},5205:(t,r,i)=>{const{InvalidArgumentError:o}=i(9027);class Option{constructor(t,r){this.flags=t;this.description=r||"";this.required=t.includes("<");this.optional=t.includes("[");this.variadic=/\w\.\.\.[>\]]$/.test(t);this.mandatory=false;const i=splitOptionFlags(t);this.short=i.shortFlag;this.long=i.longFlag;this.negate=false;if(this.long){this.negate=this.long.startsWith("--no-")}this.defaultValue=undefined;this.defaultValueDescription=undefined;this.presetArg=undefined;this.envVar=undefined;this.parseArg=undefined;this.hidden=false;this.argChoices=undefined;this.conflictsWith=[];this.implied=undefined}default(t,r){this.defaultValue=t;this.defaultValueDescription=r;return this}preset(t){this.presetArg=t;return this}conflicts(t){this.conflictsWith=this.conflictsWith.concat(t);return this}implies(t){this.implied=Object.assign(this.implied||{},t);return this}env(t){this.envVar=t;return this}argParser(t){this.parseArg=t;return this}makeOptionMandatory(t=true){this.mandatory=!!t;return this}hideHelp(t=true){this.hidden=!!t;return this}_concatValue(t,r){if(r===this.defaultValue||!Array.isArray(r)){return[t]}return r.concat(t)}choices(t){this.argChoices=t.slice();this.parseArg=(t,r)=>{if(!this.argChoices.includes(t)){throw new o(`Allowed choices are ${this.argChoices.join(", ")}.`)}if(this.variadic){return this._concatValue(t,r)}return t};return this}name(){if(this.long){return this.long.replace(/^--/,"")}return this.short.replace(/^-/,"")}attributeName(){return camelcase(this.name().replace(/^no-/,""))}is(t){return this.short===t||this.long===t}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class DualOptions{constructor(t){this.positiveOptions=new Map;this.negativeOptions=new Map;this.dualOptions=new Set;t.forEach((t=>{if(t.negate){this.negativeOptions.set(t.attributeName(),t)}else{this.positiveOptions.set(t.attributeName(),t)}}));this.negativeOptions.forEach(((t,r)=>{if(this.positiveOptions.has(r)){this.dualOptions.add(r)}}))}valueFromOption(t,r){const i=r.attributeName();if(!this.dualOptions.has(i))return true;const o=this.negativeOptions.get(i).presetArg;const a=o!==undefined?o:false;return r.negate===(a===t)}}function camelcase(t){return t.split("-").reduce(((t,r)=>t+r[0].toUpperCase()+r.slice(1)))}function splitOptionFlags(t){let r;let i;const o=t.split(/[ |,]+/);if(o.length>1&&!/^[[<]/.test(o[1]))r=o.shift();i=o.shift();if(!r&&/^-[^-]$/.test(i)){r=i;i=undefined}return{shortFlag:r,longFlag:i}}r.Option=Option;r.splitOptionFlags=splitOptionFlags;r.DualOptions=DualOptions},211:(t,r)=>{const i=3;function editDistance(t,r){if(Math.abs(t.length-r.length)>i)return Math.max(t.length,r.length);const o=[];for(let r=0;r<=t.length;r++){o[r]=[r]}for(let t=0;t<=r.length;t++){o[0][t]=t}for(let i=1;i<=r.length;i++){for(let a=1;a<=t.length;a++){let l=1;if(t[a-1]===r[i-1]){l=0}else{l=1}o[a][i]=Math.min(o[a-1][i]+1,o[a][i-1]+1,o[a-1][i-1]+l);if(a>1&&i>1&&t[a-1]===r[i-2]&&t[a-2]===r[i-1]){o[a][i]=Math.min(o[a][i],o[a-2][i-2]+1)}}}return o[t.length][r.length]}function suggestSimilar(t,r){if(!r||r.length===0)return"";r=Array.from(new Set(r));const o=t.startsWith("--");if(o){t=t.slice(2);r=r.map((t=>t.slice(2)))}let a=[];let l=i;const c=.4;r.forEach((r=>{if(r.length<=1)return;const i=editDistance(t,r);const o=Math.max(t.length,r.length);const u=(o-i)/o;if(u>c){if(i<l){l=i;a=[r]}else if(i===l){a.push(r)}}}));a.sort(((t,r)=>t.localeCompare(r)));if(o){a=a.map((t=>`--${t}`))}if(a.length>1){return`\n(Did you mean one of ${a.join(", ")}?)`}if(a.length===1){return`\n(Did you mean ${a[0]}?)`}return""}r.suggestSimilar=suggestSimilar}};var r={};function __nccwpck_require__(i){var o=r[i];if(o!==undefined){return o.exports}var a=r[i]={exports:{}};var l=true;try{t[i].call(a.exports,a,a.exports,__nccwpck_require__);l=false}finally{if(l)delete r[i]}return a.exports}(()=>{__nccwpck_require__.n=t=>{var r=t&&t.__esModule?()=>t["default"]:()=>t;__nccwpck_require__.d(r,{a:r});return r}})();(()=>{__nccwpck_require__.d=(t,r)=>{for(var i in r){if(__nccwpck_require__.o(r,i)&&!__nccwpck_require__.o(t,i)){Object.defineProperty(t,i,{enumerable:true,get:r[i]})}}}})();(()=>{__nccwpck_require__.o=(t,r)=>Object.prototype.hasOwnProperty.call(t,r)})();(()=>{__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 i=__nccwpck_require__(7666);module.exports=i})();
|
|
131
|
+
var o=i(3837).inherits;var a=i(2096).ZipArchiveOutputStream;var l=i(2096).ZipArchiveEntry;var c=i(1246);var u=t.exports=function(t){if(!(this instanceof u)){return new u(t)}t=this.options=t||{};t.zlib=t.zlib||{};a.call(this,t);if(typeof t.level==="number"&&t.level>=0){t.zlib.level=t.level;delete t.level}if(!t.forceZip64&&typeof t.zlib.level==="number"&&t.zlib.level===0){t.store=true}t.namePrependSlash=t.namePrependSlash||false;if(t.comment&&t.comment.length>0){this.setComment(t.comment)}};o(u,a);u.prototype._normalizeFileData=function(t){t=c.defaults(t,{type:"file",name:null,namePrependSlash:this.options.namePrependSlash,linkname:null,date:null,mode:null,store:this.options.store,comment:""});var r=t.type==="directory";var i=t.type==="symlink";if(t.name){t.name=c.sanitizePath(t.name);if(!i&&t.name.slice(-1)==="/"){r=true;t.type="directory"}else if(r){t.name+="/"}}if(r||i){t.store=true}t.date=c.dateify(t.date);return t};u.prototype.entry=function(t,r,i){if(typeof i!=="function"){i=this._emitErrorCallback.bind(this)}r=this._normalizeFileData(r);if(r.type!=="file"&&r.type!=="directory"&&r.type!=="symlink"){i(new Error(r.type+" entries not currently supported"));return}if(typeof r.name!=="string"||r.name.length===0){i(new Error("entry name must be a non-empty string value"));return}if(r.type==="symlink"&&typeof r.linkname!=="string"){i(new Error("entry linkname must be a non-empty string value when type equals symlink"));return}var o=new l(r.name);o.setTime(r.date,this.options.forceLocalTime);if(r.namePrependSlash){o.setName(r.name,true)}if(r.store){o.setMethod(0)}if(r.comment.length>0){o.setComment(r.comment)}if(r.type==="symlink"&&typeof r.mode!=="number"){r.mode=40960}if(typeof r.mode==="number"){if(r.type==="symlink"){r.mode|=40960}o.setUnixMode(r.mode)}if(r.type==="symlink"&&typeof r.linkname==="string"){t=Buffer.from(r.linkname)}return a.prototype.entry.call(this,o,t,i)};u.prototype.finalize=function(){this.finish()}},7666:(t,r,i)=>{"use strict";i.r(r);const o=10;const wrapAnsi16=(t=0)=>r=>`[${r+t}m`;const wrapAnsi256=(t=0)=>r=>`[${38+t};5;${r}m`;const wrapAnsi16m=(t=0)=>(r,i,o)=>`[${38+t};2;${r};${i};${o}m`;function assembleStyles(){const t=new Map;const r={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};r.color.gray=r.color.blackBright;r.bgColor.bgGray=r.bgColor.bgBlackBright;r.color.grey=r.color.blackBright;r.bgColor.bgGrey=r.bgColor.bgBlackBright;for(const[i,o]of Object.entries(r)){for(const[i,a]of Object.entries(o)){r[i]={open:`[${a[0]}m`,close:`[${a[1]}m`};o[i]=r[i];t.set(a[0],a[1])}Object.defineProperty(r,i,{value:o,enumerable:false})}Object.defineProperty(r,"codes",{value:t,enumerable:false});r.color.close="[39m";r.bgColor.close="[49m";r.color.ansi=wrapAnsi16();r.color.ansi256=wrapAnsi256();r.color.ansi16m=wrapAnsi16m();r.bgColor.ansi=wrapAnsi16(o);r.bgColor.ansi256=wrapAnsi256(o);r.bgColor.ansi16m=wrapAnsi16m(o);Object.defineProperties(r,{rgbToAnsi256:{value:(t,r,i)=>{if(t===r&&r===i){if(t<8){return 16}if(t>248){return 231}return Math.round((t-8)/247*24)+232}return 16+36*Math.round(t/255*5)+6*Math.round(r/255*5)+Math.round(i/255*5)},enumerable:false},hexToRgb:{value:t=>{const r=/(?<colorString>[a-f\d]{6}|[a-f\d]{3})/i.exec(t.toString(16));if(!r){return[0,0,0]}let{colorString:i}=r.groups;if(i.length===3){i=[...i].map((t=>t+t)).join("")}const o=Number.parseInt(i,16);return[o>>16&255,o>>8&255,o&255]},enumerable:false},hexToAnsi256:{value:t=>r.rgbToAnsi256(...r.hexToRgb(t)),enumerable:false},ansi256ToAnsi:{value:t=>{if(t<8){return 30+t}if(t<16){return 90+(t-8)}let r;let i;let o;if(t>=232){r=((t-232)*10+8)/255;i=r;o=r}else{t-=16;const a=t%36;r=Math.floor(t/36)/5;i=Math.floor(a/6)/5;o=a%6/5}const a=Math.max(r,i,o)*2;if(a===0){return 30}let l=30+(Math.round(o)<<2|Math.round(i)<<1|Math.round(r));if(a===2){l+=60}return l},enumerable:false},rgbToAnsi:{value:(t,i,o)=>r.ansi256ToAnsi(r.rgbToAnsi256(t,i,o)),enumerable:false},hexToAnsi:{value:t=>r.ansi256ToAnsi(r.hexToAnsi256(t)),enumerable:false}});return r}const a=assembleStyles();const l=a;const c=require("node:process");const u=require("node:os");const h=require("node:tty");function hasFlag(t,r=c.argv){const i=t.startsWith("-")?"":t.length===1?"-":"--";const o=r.indexOf(i+t);const a=r.indexOf("--");return o!==-1&&(a===-1||o<a)}const{env:d}=c;let p;if(hasFlag("no-color")||hasFlag("no-colors")||hasFlag("color=false")||hasFlag("color=never")){p=0}else if(hasFlag("color")||hasFlag("colors")||hasFlag("color=true")||hasFlag("color=always")){p=1}function envForceColor(){if("FORCE_COLOR"in d){if(d.FORCE_COLOR==="true"){return 1}if(d.FORCE_COLOR==="false"){return 0}return d.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(d.FORCE_COLOR,10),3)}}function translateLevel(t){if(t===0){return false}return{level:t,hasBasic:true,has256:t>=2,has16m:t>=3}}function _supportsColor(t,{streamIsTTY:r,sniffFlags:i=true}={}){const o=envForceColor();if(o!==undefined){p=o}const a=i?p:o;if(a===0){return 0}if(i){if(hasFlag("color=16m")||hasFlag("color=full")||hasFlag("color=truecolor")){return 3}if(hasFlag("color=256")){return 2}}if(t&&!r&&a===undefined){return 0}const l=a||0;if(d.TERM==="dumb"){return l}if(c.platform==="win32"){const t=u.release().split(".");if(Number(t[0])>=10&&Number(t[2])>=10586){return Number(t[2])>=14931?3:2}return 1}if("CI"in d){if(["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE","DRONE"].some((t=>t in d))||d.CI_NAME==="codeship"){return 1}return l}if("TEAMCITY_VERSION"in d){return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(d.TEAMCITY_VERSION)?1:0}if("TF_BUILD"in d&&"AGENT_NAME"in d){return 1}if(d.COLORTERM==="truecolor"){return 3}if("TERM_PROGRAM"in d){const t=Number.parseInt((d.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(d.TERM_PROGRAM){case"iTerm.app":return t>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(d.TERM)){return 2}if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(d.TERM)){return 1}if("COLORTERM"in d){return 1}return l}function createSupportsColor(t,r={}){const i=_supportsColor(t,{streamIsTTY:t&&t.isTTY,...r});return translateLevel(i)}const m={stdout:createSupportsColor({isTTY:h.isatty(1)}),stderr:createSupportsColor({isTTY:h.isatty(2)})};const y=m;function stringReplaceAll(t,r,i){let o=t.indexOf(r);if(o===-1){return t}const a=r.length;let l=0;let c="";do{c+=t.substr(l,o-l)+r+i;l=o+a;o=t.indexOf(r,l)}while(o!==-1);c+=t.slice(l);return c}function stringEncaseCRLFWithFirstIndex(t,r,i,o){let a=0;let l="";do{const c=t[o-1]==="\r";l+=t.substr(a,(c?o-1:o)-a)+r+(c?"\r\n":"\n")+i;a=o+1;o=t.indexOf("\n",a)}while(o!==-1);l+=t.slice(a);return l}const{stdout:g,stderr:b}=y;const v=Symbol("GENERATOR");const _=Symbol("STYLER");const w=Symbol("IS_EMPTY");const E=["ansi","ansi","ansi256","ansi16m"];const S=Object.create(null);const applyOptions=(t,r={})=>{if(r.level&&!(Number.isInteger(r.level)&&r.level>=0&&r.level<=3)){throw new Error("The `level` option should be an integer from 0 to 3")}const i=g?g.level:0;t.level=r.level===undefined?i:r.level};class Chalk{constructor(t){return chalkFactory(t)}}const chalkFactory=t=>{const chalk=(...t)=>t.join(" ");applyOptions(chalk,t);Object.setPrototypeOf(chalk,createChalk.prototype);return chalk};function createChalk(t){return chalkFactory(t)}Object.setPrototypeOf(createChalk.prototype,Function.prototype);for(const[t,r]of Object.entries(l)){S[t]={get(){const i=createBuilder(this,createStyler(r.open,r.close,this[_]),this[w]);Object.defineProperty(this,t,{value:i});return i}}}S.visible={get(){const t=createBuilder(this,this[_],true);Object.defineProperty(this,"visible",{value:t});return t}};const getModelAnsi=(t,r,i,...o)=>{if(t==="rgb"){if(r==="ansi16m"){return l[i].ansi16m(...o)}if(r==="ansi256"){return l[i].ansi256(l.rgbToAnsi256(...o))}return l[i].ansi(l.rgbToAnsi(...o))}if(t==="hex"){return getModelAnsi("rgb",r,i,...l.hexToRgb(...o))}return l[i][t](...o)};const O=["rgb","hex","ansi256"];for(const t of O){S[t]={get(){const{level:r}=this;return function(...i){const o=createStyler(getModelAnsi(t,E[r],"color",...i),l.color.close,this[_]);return createBuilder(this,o,this[w])}}};const r="bg"+t[0].toUpperCase()+t.slice(1);S[r]={get(){const{level:r}=this;return function(...i){const o=createStyler(getModelAnsi(t,E[r],"bgColor",...i),l.bgColor.close,this[_]);return createBuilder(this,o,this[w])}}}}const R=Object.defineProperties((()=>{}),{...S,level:{enumerable:true,get(){return this[v].level},set(t){this[v].level=t}}});const createStyler=(t,r,i)=>{let o;let a;if(i===undefined){o=t;a=r}else{o=i.openAll+t;a=r+i.closeAll}return{open:t,close:r,openAll:o,closeAll:a,parent:i}};const createBuilder=(t,r,i)=>{const builder=(...t)=>applyStyle(builder,t.length===1?""+t[0]:t.join(" "));Object.setPrototypeOf(builder,R);builder[v]=t;builder[_]=r;builder[w]=i;return builder};const applyStyle=(t,r)=>{if(t.level<=0||!r){return t[w]?"":r}let i=t[_];if(i===undefined){return r}const{openAll:o,closeAll:a}=i;if(r.includes("")){while(i!==undefined){r=stringReplaceAll(r,i.close,i.open);i=i.parent}}const l=r.indexOf("\n");if(l!==-1){r=stringEncaseCRLFWithFirstIndex(r,a,o,l)}return o+r+a};Object.defineProperties(createChalk.prototype,S);const x=createChalk();const k=createChalk({level:b?b.level:0});const T=x;var A=i(345);const{program:C,createCommand:P,createArgument:I,createOption:L,CommanderError:M,InvalidArgumentError:D,InvalidOptionArgumentError:N,Command:j,Argument:B,Option:$,Help:H}=A;var U=i(5656);var q=i.n(U);var z=i(1017);var G=i.n(z);var W=i(7147);var V=i.n(W);function isSetup(){try{const t=V().statSync(G().join(process.cwd(),".hyperbook"));if(!t.isDirectory()){throw Error()}}catch(t){console.log(T.red("Could not find .hyperbook folder. Be sure to run `hyperbook setup`."));return false}try{V().statSync(G().join(process.cwd(),".hyperbook","node_modules",".bin","next"))}catch(t){console.log(T.red("Could not find next binary in the .hyperbook folder. Be sure to run `hyperbook setup`."));return false}return true}var Y=i(2202);var Z=i.n(Y);var K=i(7282);var Q=i.n(K);async function archiveFolder(t){return new Promise(((r,i)=>{const o=G().join(Q().cwd(),"public","archives");if(!V().existsSync(o)){V().mkdirSync(o,{recursive:true})}const a=G().join(o,t+".zip");const l=V().createWriteStream(a);const c=Z()("zip",{zlib:{level:9}});c.on("finish",(()=>{console.log(T.green("Archive zipped: ")+t);r()}));c.on("error",(t=>{throw t}));c.pipe(l);c.directory(G().join(Q().cwd(),"archives",t),false);c.finalize()}))}async function runArchive(){const t=isSetup();if(!t){throw new Error("no setup")}return new Promise(((t,r)=>{if(!V().existsSync(G().join(Q().cwd(),"archives"))){console.log(T.blue("info ")+"- No Archives found");t()}const i=V().readdirSync(G().join(Q().cwd(),"archives"),{withFileTypes:true}).filter((t=>t.isDirectory()));Promise.all(i.map((t=>archiveFolder(t.name)))).then((()=>{t()})).catch((()=>{r()}))}))}var X=i(4488);var J=i.n(X);async function readHyperbook(){return new Promise(((t,r)=>{V().readFile(G().join(process.cwd(),"hyperbook.json"),((i,o)=>{if(i){console.log(T.red("Could not find 'hyperbook.json'. Make sure you are in the right directory."));r()}else{const r=JSON.parse(o.toString());t(r)}}))}))}async function runBuild(){const t=isSetup();if(!t){throw new Error("no setup")}const r=await readHyperbook();V().writeFileSync(G().join(process.cwd(),".hyperbook","next.config.js"),`\nmodule.exports = {\n ${(r===null||r===void 0?void 0:r.basePath)?`basePath: '${r.basePath}',`:""}\n typescript: {\n ignoreBuildErrors: true,\n }\n}\n `);return new Promise(((t,r)=>{const i="npm";const o=["run","build"];const a=J()(i,o,{stdio:"inherit",cwd:G().join(process.cwd(),".hyperbook"),env:{...process.env,ADBLOCK:"1",DISABLE_OPENCOLLECTIVE:"1"}});a.on("close",(a=>{if(a!==0){r({command:`${i} ${o.join(" ")}`});return}t()}))}))}async function runDev(){const t=isSetup();if(!t){throw new Error("no setup")}return new Promise(((t,r)=>{const i="npm";const o=["run","dev"];const a=J()(i,o,{stdio:"inherit",cwd:G().join(process.cwd(),".hyperbook"),env:{...process.env,ADBLOCK:"1",DISABLE_OPENCOLLECTIVE:"1"}});a.on("close",(a=>{if(a!==0){r({command:`${i} ${o.join(" ")}`});return}t()}))}))}var ee=i(2081);function getPkgManager(){try{const t=process.env.npm_config_user_agent;if(t){if(t.startsWith("yarn")){return"yarn"}else if(t.startsWith("pnpm")){return"pnpm"}}try{(0,ee.execSync)("yarn --version",{stdio:"ignore"});return"yarn"}catch{(0,ee.execSync)("pnpm --version",{stdio:"ignore"});return"pnpm"}}catch{return"npm"}}var te=i(2037);var re=i.n(te);const ie=require("node:events");const se=require("node:path");function indentString(t,r=1,i={}){const{indent:o=" ",includeEmptyLines:a=false}=i;if(typeof t!=="string"){throw new TypeError(`Expected \`input\` to be a \`string\`, got \`${typeof t}\``)}if(typeof r!=="number"){throw new TypeError(`Expected \`count\` to be a \`number\`, got \`${typeof r}\``)}if(r<0){throw new RangeError(`Expected \`count\` to be at least 0, got \`${r}\``)}if(typeof o!=="string"){throw new TypeError(`Expected \`options.indent\` to be a \`string\`, got \`${typeof o}\``)}if(r===0){return t}const l=a?/^/gm:/^(?!\s*$)/gm;return t.replace(l,o.repeat(r))}function escapeStringRegexp(t){if(typeof t!=="string"){throw new TypeError("Expected a string")}return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}const ne=/\s+at.*[(\s](.*)\)?/;const oe=/^(?:(?:(?:node|node:[\w/]+|(?:(?:node:)?internal\/[\w/]*|.*node_modules\/(?:babel-polyfill|pirates)\/.*)?\w+)(?:\.js)?:\d+:\d+)|native)/;const ae=typeof te.homedir==="undefined"?"":te.homedir().replace(/\\/g,"/");function cleanStack(t,{pretty:r=false,basePath:i}={}){const o=i&&new RegExp(`(at | \\()${escapeStringRegexp(i.replace(/\\/g,"/"))}`,"g");if(typeof t!=="string"){return undefined}return t.replace(/\\/g,"/").split("\n").filter((t=>{const r=t.match(ne);if(r===null||!r[1]){return true}const i=r[1];if(i.includes(".app/Contents/Resources/electron.asar")||i.includes(".app/Contents/Resources/default_app.asar")){return false}return!oe.test(i)})).filter((t=>t.trim()!=="")).map((t=>{if(o){t=t.replace(o,"$1")}if(r){t=t.replace(ne,((t,r)=>t.replace(r,r.replace(ae,"~"))))}return t})).join("\n")}const cleanInternalStack=t=>t.replace(/\s+at .*aggregate-error\/index.js:\d+:\d+\)?/g,"");class AggregateError extends Error{#e;name="AggregateError";constructor(t){if(!Array.isArray(t)){throw new TypeError(`Expected input to be an Array, got ${typeof t}`)}t=t.map((t=>{if(t instanceof Error){return t}if(t!==null&&typeof t==="object"){return Object.assign(new Error(t.message),t)}return new Error(t)}));let r=t.map((t=>typeof t.stack==="string"?cleanInternalStack(cleanStack(t.stack)):String(t))).join("\n");r="\n"+indentString(r,4);super(r);this.#e=t}get errors(){return this.#e.slice()}}async function pMap(t,r,{concurrency:i=Number.POSITIVE_INFINITY,stopOnError:o=true}={}){return new Promise(((a,l)=>{if(t[Symbol.iterator]===undefined&&t[Symbol.asyncIterator]===undefined){throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof t})`)}if(typeof r!=="function"){throw new TypeError("Mapper function is required")}if(!((Number.isSafeInteger(i)||i===Number.POSITIVE_INFINITY)&&i>=1)){throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${i}\` (${typeof i})`)}const c=[];const u=[];const h=new Map;let d=false;let p=false;let m=false;let y=0;let g=0;const b=t[Symbol.iterator]===undefined?t[Symbol.asyncIterator]():t[Symbol.iterator]();const reject=t=>{d=true;p=true;l(t)};const next=async()=>{if(p){return}const t=await b.next();const i=g;g++;if(t.done){m=true;if(y===0&&!p){if(!o&&u.length>0){reject(new AggregateError(u));return}p=true;if(!h.size){a(c);return}const t=[];for(const[r,i]of c.entries()){if(h.get(r)===le){continue}t.push(i)}a(t)}return}y++;(async()=>{try{const o=await t.value;if(p){return}const a=await r(o,i);if(a===le){h.set(i,a)}c[i]=a;y--;await next()}catch(t){if(o){reject(t)}else{u.push(t);y--;try{await next()}catch(t){reject(t)}}}})()};(async()=>{for(let t=0;t<i;t++){try{await next()}catch(t){reject(t);break}if(m||d){break}}})()}))}const le=Symbol("skip");function arrify(t){if(t===null||t===undefined){return[]}if(Array.isArray(t)){return t}if(typeof t==="string"){return[t]}if(typeof t[Symbol.iterator]==="function"){return[...t]}return[t]}var ce=i(8174);class AbortError extends Error{constructor(t){super();this.name="AbortError";this.message=t}}const getDOMException=t=>globalThis.DOMException===undefined?new AbortError(t):new DOMException(t);const getAbortedReason=t=>{const r=t.reason===undefined?getDOMException("This operation was aborted."):t.reason;return r instanceof Error?r:getDOMException(r)};async function p_map_pMap(t,r,{concurrency:i=Number.POSITIVE_INFINITY,stopOnError:o=true,signal:a}={}){return new Promise(((l,c)=>{if(t[Symbol.iterator]===undefined&&t[Symbol.asyncIterator]===undefined){throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof t})`)}if(typeof r!=="function"){throw new TypeError("Mapper function is required")}if(!((Number.isSafeInteger(i)||i===Number.POSITIVE_INFINITY)&&i>=1)){throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${i}\` (${typeof i})`)}const u=[];const h=[];const d=new Map;let p=false;let m=false;let y=false;let g=0;let b=0;const v=t[Symbol.iterator]===undefined?t[Symbol.asyncIterator]():t[Symbol.iterator]();const reject=t=>{p=true;m=true;c(t)};if(a){if(a.aborted){reject(getAbortedReason(a))}a.addEventListener("abort",(()=>{reject(getAbortedReason(a))}))}const next=async()=>{if(m){return}const t=await v.next();const i=b;b++;if(t.done){y=true;if(g===0&&!m){if(!o&&h.length>0){reject(new AggregateError(h));return}m=true;if(d.size===0){l(u);return}const t=[];for(const[r,i]of u.entries()){if(d.get(r)===ue){continue}t.push(i)}l(t)}return}g++;(async()=>{try{const o=await t.value;if(m){return}const a=await r(o,i);if(a===ue){d.set(i,a)}u[i]=a;g--;await next()}catch(t){if(o){reject(t)}else{h.push(t);g--;try{await next()}catch(t){reject(t)}}}})()};(async()=>{for(let t=0;t<i;t++){try{await next()}catch(t){reject(t);break}if(y||p){break}}})()}))}const ue=Symbol("skip");async function pFilter(t,r,i){const o=await p_map_pMap(t,((t,i)=>Promise.all([r(t,i),t])),i);return o.filter((t=>Boolean(t[0]))).map((t=>t[1]))}const he=require("node:fs");var fe=i(9117);var de=i(5342);var pe=i(3286);var me=i(7993);function slash(t){const r=/^\\\\\?\\/.test(t);const i=/[^\u0000-\u0080]+/.test(t);if(r||i){return t}return t.replace(/\\/g,"/")}const ye=require("node:url");const ge=require("node:stream");const toPath=t=>t instanceof URL?(0,ye.fileURLToPath)(t):t;class FilterStream extends ge.Transform{constructor(t){super({objectMode:true,transform(r,i,o){o(undefined,t(r)?r:undefined)}})}}const isNegativePattern=t=>t[0]==="!";const be={ignore:["**/node_modules","**/flow-typed","**/coverage","**/.git"],absolute:true,dot:true};const ve="**/.gitignore";const applyBaseToPattern=(t,r)=>isNegativePattern(t)?"!"+se.posix.join(r,t.slice(1)):se.posix.join(r,t);const parseIgnoreFile=(t,r)=>{const i=slash(se.relative(r,se.dirname(t.filePath)));return t.content.split(/\r?\n/).filter((t=>t&&!t.startsWith("#"))).map((t=>applyBaseToPattern(t,i)))};const toRelativePath=(t,r)=>{r=slash(r);if(se.isAbsolute(t)){if(slash(t).startsWith(r)){return se.relative(r,t)}throw new Error(`Path ${t} is not in cwd ${r}`)}return t};const getIsIgnoredPredicate=(t,r)=>{const i=t.flatMap((t=>parseIgnoreFile(t,r)));const o=me().add(i);return t=>{t=toPath(t);t=toRelativePath(t,r);return o.ignores(slash(t))}};const normalizeOptions=(t={})=>({cwd:toPath(t.cwd)||c.cwd()});const isIgnoredByIgnoreFiles=async(t,r)=>{const{cwd:i}=normalizeOptions(r);const o=await de(t,{cwd:i,...be});const a=await Promise.all(o.map((async t=>({filePath:t,content:await he.promises.readFile(t,"utf8")}))));return getIsIgnoredPredicate(a,i)};const isIgnoredByIgnoreFilesSync=(t,r)=>{const{cwd:i}=normalizeOptions(r);const o=de.sync(t,{cwd:i,...be});const a=o.map((t=>({filePath:t,content:he.readFileSync(t,"utf8")})));return getIsIgnoredPredicate(a,i)};const isGitIgnored=t=>isIgnoredByIgnoreFiles(ve,t);const isGitIgnoredSync=t=>isIgnoredByIgnoreFilesSync(ve,t);const assertPatternsInput=t=>{if(t.some((t=>typeof t!=="string"))){throw new TypeError("Patterns must be a string or an array of strings")}};const toPatternsArray=t=>{t=[...new Set([t].flat())];assertPatternsInput(t);return t};const checkCwdOption=t=>{if(!t.cwd){return}let r;try{r=he.statSync(t.cwd)}catch{return}if(!r.isDirectory()){throw new Error("The `cwd` option must be a path to a directory")}};const globby_normalizeOptions=(t={})=>{t={ignore:[],expandDirectories:true,...t,cwd:toPath(t.cwd)};checkCwdOption(t);return t};const normalizeArguments=t=>async(r,i)=>t(toPatternsArray(r),globby_normalizeOptions(i));const normalizeArgumentsSync=t=>(r,i)=>t(toPatternsArray(r),globby_normalizeOptions(i));const getIgnoreFilesPatterns=t=>{const{ignoreFiles:r,gitignore:i}=t;const o=r?toPatternsArray(r):[];if(i){o.push(ve)}return o};const getFilter=async t=>{const r=getIgnoreFilesPatterns(t);return createFilterFunction(r.length>0&&await isIgnoredByIgnoreFiles(r,{cwd:t.cwd}))};const getFilterSync=t=>{const r=getIgnoreFilesPatterns(t);return createFilterFunction(r.length>0&&isIgnoredByIgnoreFilesSync(r,{cwd:t.cwd}))};const createFilterFunction=t=>{const r=new Set;return i=>{const o=i.path||i;const a=se.normalize(o);const l=r.has(a)||t&&t(o);r.add(a);return!l}};const unionFastGlobResults=(t,r)=>t.flat().filter((t=>r(t)));const unionFastGlobStreams=(t,r)=>fe(t).pipe(new FilterStream((t=>r(t))));const convertNegativePatterns=(t,r)=>{const i=[];while(t.length>0){const o=t.findIndex((t=>isNegativePattern(t)));if(o===-1){i.push({patterns:t,options:r});break}const a=t[o].slice(1);for(const t of i){t.options.ignore.push(a)}if(o!==0){i.push({patterns:t.slice(0,o),options:{...r,ignore:[...r.ignore,a]}})}t=t.slice(o+1)}return i};const getDirGlobOptions=(t,r)=>({...r?{cwd:r}:{},...Array.isArray(t)?{files:t}:t});const generateTasks=async(t,r)=>{const i=convertNegativePatterns(t,r);const{cwd:o,expandDirectories:a}=r;if(!a){return i}const l=getDirGlobOptions(a,o);const c=o?{cwd:o}:undefined;return Promise.all(i.map((async t=>{let{patterns:r,options:i}=t;[r,i.ignore]=await Promise.all([pe(r,l),pe(i.ignore,c)]);return{patterns:r,options:i}})))};const generateTasksSync=(t,r)=>{const i=convertNegativePatterns(t,r);const{cwd:o,expandDirectories:a}=r;if(!a){return i}const l=getDirGlobOptions(a,o);const c=o?{cwd:o}:undefined;return i.map((t=>{let{patterns:r,options:i}=t;r=pe.sync(r,l);i.ignore=pe.sync(i.ignore,c);return{patterns:r,options:i}}))};const _e=normalizeArguments((async(t,r)=>{const[i,o]=await Promise.all([generateTasks(t,r),getFilter(r)]);const a=await Promise.all(i.map((t=>de(t.patterns,t.options))));return unionFastGlobResults(a,o)}));const we=normalizeArgumentsSync(((t,r)=>{const i=generateTasksSync(t,r);const o=getFilterSync(r);const a=i.map((t=>de.sync(t.patterns,t.options)));return unionFastGlobResults(a,o)}));const Ee=normalizeArgumentsSync(((t,r)=>{const i=generateTasksSync(t,r);const o=getFilterSync(r);const a=i.map((t=>de.stream(t.patterns,t.options)));return unionFastGlobStreams(a,o)}));const Se=normalizeArgumentsSync(((t,r)=>t.some((t=>de.isDynamicPattern(t,r)))));const Oe=normalizeArguments(generateTasks);const Re=normalizeArgumentsSync(generateTasksSync);var xe=i(7971);var ke=i(3134);class CpyError extends ke{constructor(t,r){super(t,r);Object.assign(this,r);this.name="CpyError"}}const Te=["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^Desktop\\.ini$","@eaDir$"];const Ae=new RegExp(Te.join("|"));function isJunk(t){return Ae.test(t)}function isNotJunk(t){return!isJunk(t)}class GlobPattern{constructor(t,r,i){this.path=t;this.originalPath=t;this.destination=r;this.options=i;this.isDirectory=false;if(!Se(t)&&he.existsSync(t)&&he.lstatSync(t).isDirectory()){this.path=[t,"**"].join("/");this.isDirectory=true}}get name(){return se.basename(this.originalPath)}get normalizedPath(){const t=this.originalPath.split("/");const r=t.findIndex((t=>t?Se(t):false));const i=t.slice(0,r).join("/");if(i){return se.isAbsolute(i)?i:se.join(this.options.cwd,i)}return this.destination}hasMagic(){return Se(this.options.flat?this.path:this.originalPath)}getMatches(){let t=we(this.path,{...this.options,dot:true,absolute:true,onlyFiles:true});if(this.options.ignoreJunk){t=t.filter((t=>isNotJunk(se.basename(t))))}return t}}const Ce=(u.cpus().length||1)*2;const Pe={ignoreJunk:true,flat:false,cwd:c.cwd()};class Entry{constructor(t,r,i){this.path=t.split("/").join(se.sep);this.relativePath=r.split("/").join(se.sep);this.pattern=i;Object.freeze(this)}get name(){return se.basename(this.path)}get nameWithoutExtension(){return se.basename(this.path,se.extname(this.path))}get extension(){return se.extname(this.path).slice(1)}}const expandPatternsWithBraceExpansion=t=>t.flatMap((t=>xe.braces(t,{expand:true,nodupes:true})));const preprocessDestinationPath=({entry:t,destination:r,options:i})=>{if(t.pattern.hasMagic()){if(i.flat){if(se.isAbsolute(r)){return se.join(r,t.name)}return se.join(i.cwd,r,t.name)}return se.join(r,se.relative(t.pattern.normalizedPath,t.path))}if(se.isAbsolute(r)){return se.join(r,t.name)}if(t.pattern.isDirectory&&se.relative(i.cwd,t.path).startsWith("..")){return se.join(i.cwd,r,se.basename(t.pattern.originalPath),se.relative(t.pattern.originalPath,t.path))}if(!t.pattern.isDirectory&&t.path===t.relativePath){return se.join(i.cwd,r,se.basename(t.pattern.originalPath),se.relative(t.pattern.originalPath,t.path))}if(!t.pattern.isDirectory&&i.flat){return se.join(i.cwd,r,se.basename(t.pattern.originalPath))}return se.join(i.cwd,r,se.relative(i.cwd,t.path))};const renameFile=(t,r)=>{const i=se.basename(t,se.extname(t));const o=se.extname(t);const a=se.dirname(t);if(typeof r==="string"){return se.join(a,r)}if(typeof r==="function"){return se.join(a,`${r(i)}${o}`)}return t};function cpy(t,r,{concurrency:i=Ce,...o}={}){const a=new Map;const l=new ie;o={...Pe,...o};const c=(async()=>{let c=[];let u=0;let h=0;let d=expandPatternsWithBraceExpansion(arrify(t)).map((t=>t.replace(/\\/g,"/")));const p=d.filter((t=>!t.startsWith("!")));const m=d.filter((t=>t.startsWith("!")));if(p.length===0||!r){throw new CpyError("`source` and `destination` required")}d=d.map((t=>new GlobPattern(t,r,{...o,ignore:m})));for(const t of d){let r=[];try{r=t.getMatches()}catch(r){throw new CpyError(`Cannot glob \`${t.originalPath}\`: ${r.message}`,r)}if(r.length===0&&!Se(t.originalPath)&&!Se(m)){throw new CpyError(`Cannot copy \`${t.originalPath}\`: the file doesn't exist`)}c=[...c,...r.map((r=>new Entry(r,se.relative(o.cwd,r),t)))]}if(o.filter!==undefined){c=await pFilter(c,o.filter,{concurrency:1024})}if(c.length===0){l.emit("progress",{totalFiles:0,percent:1,completedFiles:0,completedSize:0})}const fileProgressHandler=t=>{const r=a.get(t.sourcePath)||{writtenBytes:0,percent:0};if(r.writtenBytes!==t.writtenBytes||r.percent!==t.percent){h-=r.writtenBytes;h+=t.writtenBytes;if(t.percent===1&&r.percent!==1){u++}a.set(t.sourcePath,{writtenBytes:t.writtenBytes,percent:t.percent});l.emit("progress",{totalFiles:c.length,percent:u/c.length,completedFiles:u,completedSize:h})}};return pMap(c,(async t=>{const i=renameFile(preprocessDestinationPath({entry:t,destination:r,options:o}),o.rename);try{await ce(t.path,i,o).on("progress",fileProgressHandler)}catch(r){throw new CpyError(`Cannot copy from \`${t.relativePath}\` to \`${i}\`: ${r.message}`,r)}return i}),{concurrency:i})})();c.on=(...t)=>{l.on(...t);return c};return c}var Ie=i(5713);var Le=i.n(Ie);function isFolderEmpty(t,r){const i=[".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"];const o=V().readdirSync(t).filter((t=>!i.includes(t))).filter((t=>!/\.iml$/.test(t)));if(o.length>0){console.log(`The directory ${T.green(r)} contains files that could conflict:`);console.log();for(const r of o){try{const i=V().lstatSync(G().join(t,r));if(i.isDirectory()){console.log(` ${T.blue(r)}/`)}else{console.log(` ${r}`)}}catch{console.log(` ${r}`)}}console.log();console.log("Either try using a new directory name, or remove the files listed above.");console.log();return false}return true}async function isWriteable(t){try{await V().promises.access(t,(V().constants||V()).W_OK);return true}catch(t){return false}}async function makeDir(t,r={recursive:true}){await V().promises.mkdir(t,r)}var Me=i(4700);var De=i.n(Me);function isInGitRepository(){try{(0,ee.execSync)("git rev-parse --is-inside-work-tree",{stdio:"ignore"});return true}catch(t){}return false}function isInMercurialRepository(){try{(0,ee.execSync)("hg --cwd . root",{stdio:"ignore"});return true}catch(t){}return false}function tryGitInit(t){let r=false;try{(0,ee.execSync)("git --version",{stdio:"ignore"});if(isInGitRepository()||isInMercurialRepository()){return false}(0,ee.execSync)("git init",{stdio:"ignore"});r=true;(0,ee.execSync)("git checkout -b main",{stdio:"ignore"});(0,ee.execSync)("git add -A",{stdio:"ignore"});(0,ee.execSync)('git commit -m "Initial commit from Hyperbook"',{stdio:"ignore"});return true}catch(i){if(r){try{De().sync(G().join(t,".git"))}catch(t){}}return false}}const Ne=["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function isTypedArrayName(t){return Ne.includes(t)}const je=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Blob","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","WeakRef","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","FormData","URLSearchParams","HTMLElement","NaN",...Ne];function isObjectTypeName(t){return je.includes(t)}const Fe=["null","undefined","string","number","bigint","boolean","symbol"];function isPrimitiveTypeName(t){return Fe.includes(t)}function isOfType(t){return r=>typeof r===t}const{toString:Be}=Object.prototype;const getObjectType=t=>{const r=Be.call(t).slice(8,-1);if(/HTML\w+Element/.test(r)&&is.domElement(t)){return"HTMLElement"}if(isObjectTypeName(r)){return r}return undefined};const isObjectOfType=t=>r=>getObjectType(r)===t;function is(t){if(t===null){return"null"}switch(typeof t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(t)?"NaN":"number";case"boolean":return"boolean";case"function":return"Function";case"bigint":return"bigint";case"symbol":return"symbol";default:}if(is.observable(t)){return"Observable"}if(is.array(t)){return"Array"}if(is.buffer(t)){return"Buffer"}const r=getObjectType(t);if(r){return r}if(t instanceof String||t instanceof Boolean||t instanceof Number){throw new TypeError("Please don't use object wrappers for primitive types")}return"Object"}is.undefined=isOfType("undefined");is.string=isOfType("string");const $e=isOfType("number");is.number=t=>$e(t)&&!is.nan(t);is.bigint=isOfType("bigint");is.function_=isOfType("function");is.null_=t=>t===null;is.class_=t=>is.function_(t)&&t.toString().startsWith("class ");is.boolean=t=>t===true||t===false;is.symbol=isOfType("symbol");is.numericString=t=>is.string(t)&&!is.emptyStringOrWhitespace(t)&&!Number.isNaN(Number(t));is.array=(t,r)=>{if(!Array.isArray(t)){return false}if(!is.function_(r)){return true}return t.every((t=>r(t)))};is.buffer=t=>t?.constructor?.isBuffer?.(t)??false;is.blob=t=>isObjectOfType("Blob")(t);is.nullOrUndefined=t=>is.null_(t)||is.undefined(t);is.object=t=>!is.null_(t)&&(typeof t==="object"||is.function_(t));is.iterable=t=>is.function_(t?.[Symbol.iterator]);is.asyncIterable=t=>is.function_(t?.[Symbol.asyncIterator]);is.generator=t=>is.iterable(t)&&is.function_(t?.next)&&is.function_(t?.throw);is.asyncGenerator=t=>is.asyncIterable(t)&&is.function_(t.next)&&is.function_(t.throw);is.nativePromise=t=>isObjectOfType("Promise")(t);const hasPromiseApi=t=>is.function_(t?.then)&&is.function_(t?.catch);is.promise=t=>is.nativePromise(t)||hasPromiseApi(t);is.generatorFunction=isObjectOfType("GeneratorFunction");is.asyncGeneratorFunction=t=>getObjectType(t)==="AsyncGeneratorFunction";is.asyncFunction=t=>getObjectType(t)==="AsyncFunction";is.boundFunction=t=>is.function_(t)&&!t.hasOwnProperty("prototype");is.regExp=isObjectOfType("RegExp");is.date=isObjectOfType("Date");is.error=isObjectOfType("Error");is.map=t=>isObjectOfType("Map")(t);is.set=t=>isObjectOfType("Set")(t);is.weakMap=t=>isObjectOfType("WeakMap")(t);is.weakSet=t=>isObjectOfType("WeakSet")(t);is.weakRef=t=>isObjectOfType("WeakRef")(t);is.int8Array=isObjectOfType("Int8Array");is.uint8Array=isObjectOfType("Uint8Array");is.uint8ClampedArray=isObjectOfType("Uint8ClampedArray");is.int16Array=isObjectOfType("Int16Array");is.uint16Array=isObjectOfType("Uint16Array");is.int32Array=isObjectOfType("Int32Array");is.uint32Array=isObjectOfType("Uint32Array");is.float32Array=isObjectOfType("Float32Array");is.float64Array=isObjectOfType("Float64Array");is.bigInt64Array=isObjectOfType("BigInt64Array");is.bigUint64Array=isObjectOfType("BigUint64Array");is.arrayBuffer=isObjectOfType("ArrayBuffer");is.sharedArrayBuffer=isObjectOfType("SharedArrayBuffer");is.dataView=isObjectOfType("DataView");is.enumCase=(t,r)=>Object.values(r).includes(t);is.directInstanceOf=(t,r)=>Object.getPrototypeOf(t)===r.prototype;is.urlInstance=t=>isObjectOfType("URL")(t);is.urlString=t=>{if(!is.string(t)){return false}try{new URL(t);return true}catch{return false}};is.truthy=t=>Boolean(t);is.falsy=t=>!t;is.nan=t=>Number.isNaN(t);is.primitive=t=>is.null_(t)||isPrimitiveTypeName(typeof t);is.integer=t=>Number.isInteger(t);is.safeInteger=t=>Number.isSafeInteger(t);is.plainObject=t=>{if(typeof t!=="object"||t===null){return false}const r=Object.getPrototypeOf(t);return(r===null||r===Object.prototype||Object.getPrototypeOf(r)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)};is.typedArray=t=>isTypedArrayName(getObjectType(t));const isValidLength=t=>is.safeInteger(t)&&t>=0;is.arrayLike=t=>!is.nullOrUndefined(t)&&!is.function_(t)&&isValidLength(t.length);is.inRange=(t,r)=>{if(is.number(r)){return t>=Math.min(0,r)&&t<=Math.max(r,0)}if(is.array(r)&&r.length===2){return t>=Math.min(...r)&&t<=Math.max(...r)}throw new TypeError(`Invalid range: ${JSON.stringify(r)}`)};const He=1;const Ue=["innerHTML","ownerDocument","style","attributes","nodeValue"];is.domElement=t=>is.object(t)&&t.nodeType===He&&is.string(t.nodeName)&&!is.plainObject(t)&&Ue.every((r=>r in t));is.observable=t=>{if(!t){return false}if(t===t[Symbol.observable]?.()){return true}if(t===t["@@observable"]?.()){return true}return false};is.nodeStream=t=>is.object(t)&&is.function_(t.pipe)&&!is.observable(t);is.infinite=t=>t===Number.POSITIVE_INFINITY||t===Number.NEGATIVE_INFINITY;const isAbsoluteMod2=t=>r=>is.integer(r)&&Math.abs(r%2)===t;is.evenInteger=isAbsoluteMod2(0);is.oddInteger=isAbsoluteMod2(1);is.emptyArray=t=>is.array(t)&&t.length===0;is.nonEmptyArray=t=>is.array(t)&&t.length>0;is.emptyString=t=>is.string(t)&&t.length===0;const isWhiteSpaceString=t=>is.string(t)&&!/\S/.test(t);is.emptyStringOrWhitespace=t=>is.emptyString(t)||isWhiteSpaceString(t);is.nonEmptyString=t=>is.string(t)&&t.length>0;is.nonEmptyStringAndNotWhitespace=t=>is.string(t)&&!is.emptyStringOrWhitespace(t);is.emptyObject=t=>is.object(t)&&!is.map(t)&&!is.set(t)&&Object.keys(t).length===0;is.nonEmptyObject=t=>is.object(t)&&!is.map(t)&&!is.set(t)&&Object.keys(t).length>0;is.emptySet=t=>is.set(t)&&t.size===0;is.nonEmptySet=t=>is.set(t)&&t.size>0;is.emptyMap=t=>is.map(t)&&t.size===0;is.nonEmptyMap=t=>is.map(t)&&t.size>0;is.propertyKey=t=>is.any([is.string,is.number,is.symbol],t);is.formData=t=>isObjectOfType("FormData")(t);is.urlSearchParams=t=>isObjectOfType("URLSearchParams")(t);const predicateOnArray=(t,r,i)=>{if(!is.function_(r)){throw new TypeError(`Invalid predicate: ${JSON.stringify(r)}`)}if(i.length===0){throw new TypeError("Invalid number of values")}return t.call(i,r)};is.any=(t,...r)=>{const i=is.array(t)?t:[t];return i.some((t=>predicateOnArray(Array.prototype.some,t,r)))};is.all=(t,...r)=>predicateOnArray(Array.prototype.every,t,r);const assertType=(t,r,i,o={})=>{if(!t){const{multipleValues:t}=o;const a=t?`received values of types ${[...new Set(i.map((t=>`\`${is(t)}\``)))].join(", ")}`:`received value of type \`${is(i)}\``;throw new TypeError(`Expected value which is \`${r}\`, ${a}.`)}};const qe={undefined:t=>assertType(is.undefined(t),"undefined",t),string:t=>assertType(is.string(t),"string",t),number:t=>assertType(is.number(t),"number",t),bigint:t=>assertType(is.bigint(t),"bigint",t),function_:t=>assertType(is.function_(t),"Function",t),null_:t=>assertType(is.null_(t),"null",t),class_:t=>assertType(is.class_(t),"Class",t),boolean:t=>assertType(is.boolean(t),"boolean",t),symbol:t=>assertType(is.symbol(t),"symbol",t),numericString:t=>assertType(is.numericString(t),"string with a number",t),array:(t,r)=>{const i=assertType;i(is.array(t),"Array",t);if(r){t.forEach(r)}},buffer:t=>assertType(is.buffer(t),"Buffer",t),blob:t=>assertType(is.blob(t),"Blob",t),nullOrUndefined:t=>assertType(is.nullOrUndefined(t),"null or undefined",t),object:t=>assertType(is.object(t),"Object",t),iterable:t=>assertType(is.iterable(t),"Iterable",t),asyncIterable:t=>assertType(is.asyncIterable(t),"AsyncIterable",t),generator:t=>assertType(is.generator(t),"Generator",t),asyncGenerator:t=>assertType(is.asyncGenerator(t),"AsyncGenerator",t),nativePromise:t=>assertType(is.nativePromise(t),"native Promise",t),promise:t=>assertType(is.promise(t),"Promise",t),generatorFunction:t=>assertType(is.generatorFunction(t),"GeneratorFunction",t),asyncGeneratorFunction:t=>assertType(is.asyncGeneratorFunction(t),"AsyncGeneratorFunction",t),asyncFunction:t=>assertType(is.asyncFunction(t),"AsyncFunction",t),boundFunction:t=>assertType(is.boundFunction(t),"Function",t),regExp:t=>assertType(is.regExp(t),"RegExp",t),date:t=>assertType(is.date(t),"Date",t),error:t=>assertType(is.error(t),"Error",t),map:t=>assertType(is.map(t),"Map",t),set:t=>assertType(is.set(t),"Set",t),weakMap:t=>assertType(is.weakMap(t),"WeakMap",t),weakSet:t=>assertType(is.weakSet(t),"WeakSet",t),weakRef:t=>assertType(is.weakRef(t),"WeakRef",t),int8Array:t=>assertType(is.int8Array(t),"Int8Array",t),uint8Array:t=>assertType(is.uint8Array(t),"Uint8Array",t),uint8ClampedArray:t=>assertType(is.uint8ClampedArray(t),"Uint8ClampedArray",t),int16Array:t=>assertType(is.int16Array(t),"Int16Array",t),uint16Array:t=>assertType(is.uint16Array(t),"Uint16Array",t),int32Array:t=>assertType(is.int32Array(t),"Int32Array",t),uint32Array:t=>assertType(is.uint32Array(t),"Uint32Array",t),float32Array:t=>assertType(is.float32Array(t),"Float32Array",t),float64Array:t=>assertType(is.float64Array(t),"Float64Array",t),bigInt64Array:t=>assertType(is.bigInt64Array(t),"BigInt64Array",t),bigUint64Array:t=>assertType(is.bigUint64Array(t),"BigUint64Array",t),arrayBuffer:t=>assertType(is.arrayBuffer(t),"ArrayBuffer",t),sharedArrayBuffer:t=>assertType(is.sharedArrayBuffer(t),"SharedArrayBuffer",t),dataView:t=>assertType(is.dataView(t),"DataView",t),enumCase:(t,r)=>assertType(is.enumCase(t,r),"EnumCase",t),urlInstance:t=>assertType(is.urlInstance(t),"URL",t),urlString:t=>assertType(is.urlString(t),"string with a URL",t),truthy:t=>assertType(is.truthy(t),"truthy",t),falsy:t=>assertType(is.falsy(t),"falsy",t),nan:t=>assertType(is.nan(t),"NaN",t),primitive:t=>assertType(is.primitive(t),"primitive",t),integer:t=>assertType(is.integer(t),"integer",t),safeInteger:t=>assertType(is.safeInteger(t),"integer",t),plainObject:t=>assertType(is.plainObject(t),"plain object",t),typedArray:t=>assertType(is.typedArray(t),"TypedArray",t),arrayLike:t=>assertType(is.arrayLike(t),"array-like",t),domElement:t=>assertType(is.domElement(t),"HTMLElement",t),observable:t=>assertType(is.observable(t),"Observable",t),nodeStream:t=>assertType(is.nodeStream(t),"Node.js Stream",t),infinite:t=>assertType(is.infinite(t),"infinite number",t),emptyArray:t=>assertType(is.emptyArray(t),"empty array",t),nonEmptyArray:t=>assertType(is.nonEmptyArray(t),"non-empty array",t),emptyString:t=>assertType(is.emptyString(t),"empty string",t),emptyStringOrWhitespace:t=>assertType(is.emptyStringOrWhitespace(t),"empty string or whitespace",t),nonEmptyString:t=>assertType(is.nonEmptyString(t),"non-empty string",t),nonEmptyStringAndNotWhitespace:t=>assertType(is.nonEmptyStringAndNotWhitespace(t),"non-empty string and not whitespace",t),emptyObject:t=>assertType(is.emptyObject(t),"empty object",t),nonEmptyObject:t=>assertType(is.nonEmptyObject(t),"non-empty object",t),emptySet:t=>assertType(is.emptySet(t),"empty set",t),nonEmptySet:t=>assertType(is.nonEmptySet(t),"non-empty set",t),emptyMap:t=>assertType(is.emptyMap(t),"empty map",t),nonEmptyMap:t=>assertType(is.nonEmptyMap(t),"non-empty map",t),propertyKey:t=>assertType(is.propertyKey(t),"PropertyKey",t),formData:t=>assertType(is.formData(t),"FormData",t),urlSearchParams:t=>assertType(is.urlSearchParams(t),"URLSearchParams",t),evenInteger:t=>assertType(is.evenInteger(t),"even integer",t),oddInteger:t=>assertType(is.oddInteger(t),"odd integer",t),directInstanceOf:(t,r)=>assertType(is.directInstanceOf(t,r),"T",t),inRange:(t,r)=>assertType(is.inRange(t,r),"in range",t),any:(t,...r)=>assertType(is.any(t,...r),"predicate returns truthy for any value",r,{multipleValues:true}),all:(t,...r)=>assertType(is.all(t,...r),"predicate returns truthy for all values",r,{multipleValues:true})};Object.defineProperties(is,{class:{value:is.class_},function:{value:is.function_},null:{value:is.null_}});Object.defineProperties(qe,{class:{value:qe.class_},function:{value:qe.function_},null:{value:qe.null_}});const ze=is;class CancelError extends Error{constructor(t){super(t||"Promise was canceled");this.name="CancelError"}get isCanceled(){return true}}class PCancelable{static fn(t){return(...r)=>new PCancelable(((i,o,a)=>{r.push(a);t(...r).then(i,o)}))}constructor(t){this._cancelHandlers=[];this._isPending=true;this._isCanceled=false;this._rejectOnCancel=true;this._promise=new Promise(((r,i)=>{this._reject=i;const onResolve=t=>{if(!this._isCanceled||!onCancel.shouldReject){this._isPending=false;r(t)}};const onReject=t=>{this._isPending=false;i(t)};const onCancel=t=>{if(!this._isPending){throw new Error("The `onCancel` handler was attached after the promise settled.")}this._cancelHandlers.push(t)};Object.defineProperties(onCancel,{shouldReject:{get:()=>this._rejectOnCancel,set:t=>{this._rejectOnCancel=t}}});t(onResolve,onReject,onCancel)}))}then(t,r){return this._promise.then(t,r)}catch(t){return this._promise.catch(t)}finally(t){return this._promise.finally(t)}cancel(t){if(!this._isPending||this._isCanceled){return}this._isCanceled=true;if(this._cancelHandlers.length>0){try{for(const t of this._cancelHandlers){t()}}catch(t){this._reject(t);return}}if(this._rejectOnCancel){this._reject(new CancelError(t))}}get isCanceled(){return this._isCanceled}}Object.setPrototypeOf(PCancelable.prototype,Promise.prototype);function isRequest(t){return ze.object(t)&&"_onResponse"in t}class RequestError extends Error{constructor(t,r,i){super(t);Object.defineProperty(this,"input",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"code",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"stack",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"response",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"request",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"timings",{enumerable:true,configurable:true,writable:true,value:void 0});Error.captureStackTrace(this,this.constructor);this.name="RequestError";this.code=r.code??"ERR_GOT_REQUEST_ERROR";this.input=r.input;if(isRequest(i)){Object.defineProperty(this,"request",{enumerable:false,value:i});Object.defineProperty(this,"response",{enumerable:false,value:i.response});this.options=i.options}else{this.options=i}this.timings=this.request?.timings;if(ze.string(r.stack)&&ze.string(this.stack)){const t=this.stack.indexOf(this.message)+this.message.length;const i=this.stack.slice(t).split("\n").reverse();const o=r.stack.slice(r.stack.indexOf(r.message)+r.message.length).split("\n").reverse();while(o.length>0&&o[0]===i[0]){i.shift()}this.stack=`${this.stack.slice(0,t)}${i.reverse().join("\n")}${o.reverse().join("\n")}`}}}class MaxRedirectsError extends RequestError{constructor(t){super(`Redirected ${t.options.maxRedirects} times. Aborting.`,{},t);this.name="MaxRedirectsError";this.code="ERR_TOO_MANY_REDIRECTS"}}class HTTPError extends RequestError{constructor(t){super(`Response code ${t.statusCode} (${t.statusMessage})`,{},t.request);this.name="HTTPError";this.code="ERR_NON_2XX_3XX_RESPONSE"}}class CacheError extends RequestError{constructor(t,r){super(t.message,t,r);this.name="CacheError";this.code=this.code==="ERR_GOT_REQUEST_ERROR"?"ERR_CACHE_ACCESS":this.code}}class UploadError extends RequestError{constructor(t,r){super(t.message,t,r);this.name="UploadError";this.code=this.code==="ERR_GOT_REQUEST_ERROR"?"ERR_UPLOAD":this.code}}class TimeoutError extends RequestError{constructor(t,r,i){super(t.message,t,i);Object.defineProperty(this,"timings",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"event",{enumerable:true,configurable:true,writable:true,value:void 0});this.name="TimeoutError";this.event=t.event;this.timings=r}}class ReadError extends RequestError{constructor(t,r){super(t.message,t,r);this.name="ReadError";this.code=this.code==="ERR_GOT_REQUEST_ERROR"?"ERR_READING_RESPONSE_STREAM":this.code}}class RetryError extends RequestError{constructor(t){super("Retrying",{},t);this.name="RetryError";this.code="ERR_RETRYING"}}class errors_AbortError extends RequestError{constructor(t){super("This operation was aborted.",{},t);this.code="ERR_ABORTED";this.name="AbortError"}}const Ge=require("node:buffer");const We=require("node:http");var Ve=i(2361);var Ye=i(3837);var Ze=i(8985);const timer=t=>{if(t.timings){return t.timings}const r={start:Date.now(),socket:undefined,lookup:undefined,connect:undefined,secureConnect:undefined,upload:undefined,response:undefined,end:undefined,error:undefined,abort:undefined,phases:{wait:undefined,dns:undefined,tcp:undefined,tls:undefined,request:undefined,firstByte:undefined,download:undefined,total:undefined}};t.timings=r;const handleError=t=>{t.once(Ve.errorMonitor,(()=>{r.error=Date.now();r.phases.total=r.error-r.start}))};handleError(t);const onAbort=()=>{r.abort=Date.now();r.phases.total=r.abort-r.start};t.prependOnceListener("abort",onAbort);const onSocket=t=>{r.socket=Date.now();r.phases.wait=r.socket-r.start;if(Ye.types.isProxy(t)){return}const lookupListener=()=>{r.lookup=Date.now();r.phases.dns=r.lookup-r.socket};t.prependOnceListener("lookup",lookupListener);Ze(t,{connect:()=>{r.connect=Date.now();if(r.lookup===undefined){t.removeListener("lookup",lookupListener);r.lookup=r.connect;r.phases.dns=r.lookup-r.socket}r.phases.tcp=r.connect-r.lookup},secureConnect:()=>{r.secureConnect=Date.now();r.phases.tls=r.secureConnect-r.connect}})};if(t.socket){onSocket(t.socket)}else{t.prependOnceListener("socket",onSocket)}const onUpload=()=>{r.upload=Date.now();r.phases.request=r.upload-(r.secureConnect??r.connect)};if(t.writableFinished){onUpload()}else{t.prependOnceListener("finish",onUpload)}t.prependOnceListener("response",(i=>{r.response=Date.now();r.phases.firstByte=r.response-r.upload;i.timings=r;handleError(i);i.prependOnceListener("end",(()=>{t.off("abort",onAbort);i.off("aborted",onAbort);if(r.phases.total){return}r.end=Date.now();r.phases.download=r.end-r.response;r.phases.total=r.end-r.start}));i.prependOnceListener("aborted",onAbort)}));return r};const Ke=timer;const Qe=require("node:crypto");const Xe="text/plain";const Je="us-ascii";const testParameter=(t,r)=>r.some((r=>r instanceof RegExp?r.test(t):r===t));const normalizeDataURL=(t,{stripHash:r})=>{const i=/^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(t);if(!i){throw new Error(`Invalid URL: ${t}`)}let{type:o,data:a,hash:l}=i.groups;const c=o.split(";");l=r?"":l;let u=false;if(c[c.length-1]==="base64"){c.pop();u=true}const h=(c.shift()||"").toLowerCase();const d=c.map((t=>{let[r,i=""]=t.split("=").map((t=>t.trim()));if(r==="charset"){i=i.toLowerCase();if(i===Je){return""}}return`${r}${i?`=${i}`:""}`})).filter(Boolean);const p=[...d];if(u){p.push("base64")}if(p.length>0||h&&h!==Xe){p.unshift(h)}return`data:${p.join(";")},${u?a.trim():a}${l?`#${l}`:""}`};function normalizeUrl(t,r){r={defaultProtocol:"http:",normalizeProtocol:true,forceHttp:false,forceHttps:false,stripAuthentication:true,stripHash:false,stripTextFragment:true,stripWWW:true,removeQueryParameters:[/^utm_\w+/i],removeTrailingSlash:true,removeSingleSlash:true,removeDirectoryIndex:false,sortQueryParameters:true,...r};t=t.trim();if(/^data:/i.test(t)){return normalizeDataURL(t,r)}if(/^view-source:/i.test(t)){throw new Error("`view-source:` is not supported as it is a non-standard protocol")}const i=t.startsWith("//");const o=!i&&/^\.*\//.test(t);if(!o){t=t.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,r.defaultProtocol)}const a=new URL(t);if(r.forceHttp&&r.forceHttps){throw new Error("The `forceHttp` and `forceHttps` options cannot be used together")}if(r.forceHttp&&a.protocol==="https:"){a.protocol="http:"}if(r.forceHttps&&a.protocol==="http:"){a.protocol="https:"}if(r.stripAuthentication){a.username="";a.password=""}if(r.stripHash){a.hash=""}else if(r.stripTextFragment){a.hash=a.hash.replace(/#?:~:text.*?$/i,"")}if(a.pathname){const t=/\b[a-z][a-z\d+\-.]{1,50}:\/\//g;let r=0;let i="";for(;;){const o=t.exec(a.pathname);if(!o){break}const l=o[0];const c=o.index;const u=a.pathname.slice(r,c);i+=u.replace(/\/{2,}/g,"/");i+=l;r=c+l.length}const o=a.pathname.slice(r,a.pathname.length);i+=o.replace(/\/{2,}/g,"/");a.pathname=i}if(a.pathname){try{a.pathname=decodeURI(a.pathname)}catch{}}if(r.removeDirectoryIndex===true){r.removeDirectoryIndex=[/^index\.[a-z]+$/]}if(Array.isArray(r.removeDirectoryIndex)&&r.removeDirectoryIndex.length>0){let t=a.pathname.split("/");const i=t[t.length-1];if(testParameter(i,r.removeDirectoryIndex)){t=t.slice(0,-1);a.pathname=t.slice(1).join("/")+"/"}}if(a.hostname){a.hostname=a.hostname.replace(/\.$/,"");if(r.stripWWW&&/^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(a.hostname)){a.hostname=a.hostname.replace(/^www\./,"")}}if(Array.isArray(r.removeQueryParameters)){for(const t of[...a.searchParams.keys()]){if(testParameter(t,r.removeQueryParameters)){a.searchParams.delete(t)}}}if(!Array.isArray(r.keepQueryParameters)&&r.removeQueryParameters===true){a.search=""}if(Array.isArray(r.keepQueryParameters)&&r.keepQueryParameters.length>0){for(const t of[...a.searchParams.keys()]){if(!testParameter(t,r.keepQueryParameters)){a.searchParams.delete(t)}}}if(r.sortQueryParameters){a.searchParams.sort();try{a.search=decodeURIComponent(a.search)}catch{}}if(r.removeTrailingSlash){a.pathname=a.pathname.replace(/\/$/,"")}const l=t;t=a.toString();if(!r.removeSingleSlash&&a.pathname==="/"&&!l.endsWith("/")&&a.hash===""){t=t.replace(/\/$/,"")}if((r.removeTrailingSlash||a.pathname==="/")&&a.hash===""&&r.removeSingleSlash){t=t.replace(/\/$/,"")}if(i&&!r.normalizeProtocol){t=t.replace(/^http:\/\//,"//")}if(r.stripProtocol){t=t.replace(/^(?:https?:)?\/\//,"")}return t}var et=i(367);var tt=i(1454);function lowercaseKeys(t){return Object.fromEntries(Object.entries(t).map((([t,r])=>[t.toLowerCase(),r])))}class Response extends ge.Readable{statusCode;headers;body;url;constructor({statusCode:t,headers:r,body:i,url:o}){if(typeof t!=="number"){throw new TypeError("Argument `statusCode` should be a number")}if(typeof r!=="object"){throw new TypeError("Argument `headers` should be an object")}if(!(i instanceof Uint8Array)){throw new TypeError("Argument `body` should be a buffer")}if(typeof o!=="string"){throw new TypeError("Argument `url` should be a string")}super({read(){this.push(i);this.push(null)}});this.statusCode=t;this.headers=lowercaseKeys(r);this.body=i;this.url=o}}var rt=i(1187);const it=["aborted","complete","headers","httpVersion","httpVersionMinor","httpVersionMajor","method","rawHeaders","rawTrailers","setTimeout","socket","statusCode","statusMessage","trailers","url"];function mimicResponse(t,r){if(r._readableState.autoDestroy){throw new Error("The second stream must have the `autoDestroy` option set to `false`")}const i=new Set([...Object.keys(t),...it]);const o={};for(const a of i){if(a in r){continue}o[a]={get(){const r=t[a];const i=typeof r==="function";return i?r.bind(t):r},set(r){t[a]=r},enumerable:true,configurable:false}}Object.defineProperties(r,o);t.once("aborted",(()=>{r.destroy();r.emit("aborted")}));t.once("close",(()=>{if(t.complete){if(r.readable){r.once("end",(()=>{r.emit("close")}))}else{r.emit("close")}}else{r.emit("close")}}));return r}class types_RequestError extends Error{constructor(t){super(t.message);Object.assign(this,t)}}class types_CacheError extends Error{constructor(t){super(t.message);Object.assign(this,t)}}class CacheableRequest{constructor(t,r){this.hooks=new Map;this.request=()=>(t,r)=>{let i;if(typeof t==="string"){i=normalizeUrlObject(ye.parse(t));t={}}else if(t instanceof ye.URL){i=normalizeUrlObject(ye.parse(t.toString()));t={}}else{const[r,...o]=(t.path??"").split("?");const a=o.length>0?`?${o.join("?")}`:"";i=normalizeUrlObject({...t,pathname:r,search:a})}t={headers:{},method:"GET",cache:true,strictTtl:false,automaticFailover:false,...t,...urlObjectToRequestOptions(i)};t.headers=Object.fromEntries(st(t.headers).map((([t,r])=>[t.toLowerCase(),r])));const o=new ie;const a=normalizeUrl(ye.format(i),{stripWWW:false,removeTrailingSlash:false,stripAuthentication:false});let l=`${t.method}:${a}`;if(t.body&&t.method!==undefined&&["POST","PATCH","PUT"].includes(t.method)){if(t.body instanceof ge.Readable){t.cache=false}else{l+=`:${Qe.createHash("md5").update(t.body).digest("hex")}`}}let c=false;let u=false;const makeRequest=t=>{u=true;let i=false;let requestErrorCallback=()=>{};const a=new Promise((t=>{requestErrorCallback=()=>{if(!i){i=true;t()}}}));const handler=async i=>{if(c){i.status=i.statusCode;const r=tt.fromObject(c.cachePolicy).revalidatedPolicy(t,i);if(!r.modified){i.resume();await new Promise((t=>{i.once("end",t)}));const t=convertHeaders(r.policy.responseHeaders());i=new Response({statusCode:c.statusCode,headers:t,body:c.body,url:c.url});i.cachePolicy=r.policy;i.fromCache=true}}if(!i.fromCache){i.cachePolicy=new tt(t,i,t);i.fromCache=false}let u;if(t.cache&&i.cachePolicy.storable()){u=cloneResponse(i);(async()=>{try{const r=et.buffer(i);await Promise.race([a,new Promise((t=>i.once("end",t)))]);const o=await r;let u={url:i.url,statusCode:i.fromCache?c.statusCode:i.statusCode,body:o,cachePolicy:i.cachePolicy.toObject()};let h=t.strictTtl?i.cachePolicy.timeToLive():undefined;if(t.maxTtl){h=h?Math.min(h,t.maxTtl):t.maxTtl}if(this.hooks.size>0){for(const t of this.hooks.keys()){u=await this.runHook(t,u,i)}}await this.cache.set(l,u,h)}catch(t){o.emit("error",new types_CacheError(t))}})()}else if(t.cache&&c){(async()=>{try{await this.cache.delete(l)}catch(t){o.emit("error",new types_CacheError(t))}})()}o.emit("response",u??i);if(typeof r==="function"){r(u??i)}};try{const r=this.cacheRequest(t,handler);r.once("error",requestErrorCallback);r.once("abort",requestErrorCallback);o.emit("request",r)}catch(t){o.emit("error",new types_RequestError(t))}};(async()=>{const get=async t=>{await Promise.resolve();const i=t.cache?await this.cache.get(l):undefined;if(typeof i==="undefined"&&!t.forceRefresh){makeRequest(t);return}const a=tt.fromObject(i.cachePolicy);if(a.satisfiesWithoutRevalidation(t)&&!t.forceRefresh){const t=convertHeaders(a.responseHeaders());const l=new Response({statusCode:i.statusCode,headers:t,body:i.body,url:i.url});l.cachePolicy=a;l.fromCache=true;o.emit("response",l);if(typeof r==="function"){r(l)}}else if(a.satisfiesWithoutRevalidation(t)&&Date.now()>=a.timeToLive()&&t.forceRefresh){await this.cache.delete(l);t.headers=a.revalidationHeaders(t);makeRequest(t)}else{c=i;t.headers=a.revalidationHeaders(t);makeRequest(t)}};const errorHandler=t=>o.emit("error",new types_CacheError(t));if(this.cache instanceof rt){const t=this.cache;t.once("error",errorHandler);o.on("error",(()=>t.removeListener("error",errorHandler)))}try{await get(t)}catch(r){if(t.automaticFailover&&!u){makeRequest(t)}o.emit("error",new types_CacheError(r))}})();return o};this.addHook=(t,r)=>{if(!this.hooks.has(t)){this.hooks.set(t,r)}};this.removeHook=t=>this.hooks.delete(t);this.getHook=t=>this.hooks.get(t);this.runHook=async(t,...r)=>this.hooks.get(t)?.(...r);if(r instanceof rt){this.cache=r}else if(typeof r==="string"){this.cache=new rt({uri:r,namespace:"cacheable-request"})}else{this.cache=new rt({store:r,namespace:"cacheable-request"})}this.request=this.request.bind(this);this.cacheRequest=t}}const st=Object.entries;const cloneResponse=t=>{const r=new ge.PassThrough({autoDestroy:false});mimicResponse(t,r);return t.pipe(r)};const urlObjectToRequestOptions=t=>{const r={...t};r.path=`${t.pathname||"/"}${t.search||""}`;delete r.pathname;delete r.search;return r};const normalizeUrlObject=t=>({protocol:t.protocol,auth:t.auth,hostname:t.hostname||t.host||"localhost",port:t.port,pathname:t.pathname,search:t.search});const convertHeaders=t=>{const r=[];for(const i of Object.keys(t)){r[i.toLowerCase()]=t[i]}return r};const nt=CacheableRequest;const ot="onResponse";var at=i(2269);const isFunction=t=>typeof t==="function";const isFormData=t=>Boolean(t&&isFunction(t.constructor)&&t[Symbol.toStringTag]==="FormData"&&isFunction(t.append)&&isFunction(t.getAll)&&isFunction(t.entries)&&isFunction(t[Symbol.iterator]));const ct="abcdefghijklmnopqrstuvwxyz0123456789";function createBoundary(){let t=16;let r="";while(t--){r+=ct[Math.random()*ct.length<<0]}return r}const normalizeValue=t=>String(t).replace(/\r|\n/g,((t,r,i)=>{if(t==="\r"&&i[r+1]!=="\n"||t==="\n"&&i[r-1]!=="\r"){return"\r\n"}return t}));const getType=t=>Object.prototype.toString.call(t).slice(8,-1).toLowerCase();function isPlainObject(t){if(getType(t)!=="object"){return false}const r=Object.getPrototypeOf(t);if(r===null||r===undefined){return true}const i=r.constructor&&r.constructor.toString();return i===Object.toString()}function getProperty(t,r){if(typeof r!=="string"){return t[r]}for(const[i,o]of Object.entries(t)){if(r.toLowerCase()===i.toLowerCase()){return o}}return undefined}const proxyHeaders=t=>new Proxy(t,{get:(t,r)=>getProperty(t,r),has:(t,r)=>getProperty(t,r)!==undefined});const escapeName=t=>String(t).replace(/\r/g,"%0D").replace(/\n/g,"%0A").replace(/"/g,"%22");const isFile=t=>Boolean(t&&typeof t==="object"&&isFunction(t.constructor)&&t[Symbol.toStringTag]==="File"&&isFunction(t.stream)&&t.name!=null);const ut=null&&isFile;var ht=undefined&&undefined.__classPrivateFieldSet||function(t,r,i,o,a){if(o==="m")throw new TypeError("Private method is not writable");if(o==="a"&&!a)throw new TypeError("Private accessor was defined without a setter");if(typeof r==="function"?t!==r||!a:!r.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return o==="a"?a.call(t,i):a?a.value=i:r.set(t,i),i};var ft=undefined&&undefined.__classPrivateFieldGet||function(t,r,i,o){if(i==="a"&&!o)throw new TypeError("Private accessor was defined without a getter");if(typeof r==="function"?t!==r||!o:!r.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?o:i==="a"?o.call(t):o?o.value:r.get(t)};var dt,pt,mt,yt,bt,vt,_t,wt,Et,St,Ot;const Rt={enableAdditionalHeaders:false};const xt={writable:false,configurable:false};class FormDataEncoder{constructor(t,r,i){dt.add(this);pt.set(this,"\r\n");mt.set(this,void 0);yt.set(this,void 0);bt.set(this,"-".repeat(2));vt.set(this,new TextEncoder);_t.set(this,void 0);wt.set(this,void 0);Et.set(this,void 0);if(!isFormData(t)){throw new TypeError("Expected first argument to be a FormData instance.")}let o;if(isPlainObject(r)){i=r}else{o=r}if(!o){o=createBoundary()}if(typeof o!=="string"){throw new TypeError("Expected boundary argument to be a string.")}if(i&&!isPlainObject(i)){throw new TypeError("Expected options argument to be an object.")}ht(this,wt,Array.from(t.entries()),"f");ht(this,Et,{...Rt,...i},"f");ht(this,mt,ft(this,vt,"f").encode(ft(this,pt,"f")),"f");ht(this,yt,ft(this,mt,"f").byteLength,"f");this.boundary=`form-data-boundary-${o}`;this.contentType=`multipart/form-data; boundary=${this.boundary}`;ht(this,_t,ft(this,vt,"f").encode(`${ft(this,bt,"f")}${this.boundary}${ft(this,bt,"f")}${ft(this,pt,"f").repeat(2)}`),"f");const a={"Content-Type":this.contentType};const l=ft(this,dt,"m",Ot).call(this);if(l){this.contentLength=l;a["Content-Length"]=l}this.headers=proxyHeaders(Object.freeze(a));Object.defineProperties(this,{boundary:xt,contentType:xt,contentLength:xt,headers:xt})}getContentLength(){return this.contentLength==null?undefined:Number(this.contentLength)}*values(){for(const[t,r]of ft(this,wt,"f")){const i=isFile(r)?r:ft(this,vt,"f").encode(normalizeValue(r));yield ft(this,dt,"m",St).call(this,t,i);yield i;yield ft(this,mt,"f")}yield ft(this,_t,"f")}async*encode(){for(const t of this.values()){if(isFile(t)){yield*t.stream()}else{yield t}}}[(pt=new WeakMap,mt=new WeakMap,yt=new WeakMap,bt=new WeakMap,vt=new WeakMap,_t=new WeakMap,wt=new WeakMap,Et=new WeakMap,dt=new WeakSet,St=function _FormDataEncoder_getFieldHeader(t,r){let i="";i+=`${ft(this,bt,"f")}${this.boundary}${ft(this,pt,"f")}`;i+=`Content-Disposition: form-data; name="${escapeName(t)}"`;if(isFile(r)){i+=`; filename="${escapeName(r.name)}"${ft(this,pt,"f")}`;i+=`Content-Type: ${r.type||"application/octet-stream"}`}const o=isFile(r)?r.size:r.byteLength;if(ft(this,Et,"f").enableAdditionalHeaders===true&&o!=null&&!isNaN(o)){i+=`${ft(this,pt,"f")}Content-Length: ${isFile(r)?r.size:r.byteLength}`}return ft(this,vt,"f").encode(`${i}${ft(this,pt,"f").repeat(2)}`)},Ot=function _FormDataEncoder_getContentLength(){let t=0;for(const[r,i]of ft(this,wt,"f")){const o=isFile(i)?i:ft(this,vt,"f").encode(normalizeValue(i));const a=isFile(o)?o.size:o.byteLength;if(a==null||isNaN(a)){return undefined}t+=ft(this,dt,"m",St).call(this,r,o).byteLength;t+=a;t+=ft(this,yt,"f")}return String(t+ft(this,_t,"f").byteLength)},Symbol.iterator)](){return this.values()}[Symbol.asyncIterator](){return this.encode()}}const kt=require("node:util");function is_form_data_isFormData(t){return ze.nodeStream(t)&&ze.function_(t.getBoundary)}async function getBodySize(t,r){if(r&&"content-length"in r){return Number(r["content-length"])}if(!t){return 0}if(ze.string(t)){return Ge.Buffer.byteLength(t)}if(ze.buffer(t)){return t.length}if(is_form_data_isFormData(t)){return(0,kt.promisify)(t.getLength.bind(t))()}return undefined}function proxyEvents(t,r,i){const o={};for(const a of i){const eventFunction=(...t)=>{r.emit(a,...t)};o[a]=eventFunction;t.on(a,eventFunction)}return()=>{for(const[r,i]of Object.entries(o)){t.off(r,i)}}}const Tt=require("node:net");function unhandle(){const t=[];return{once(r,i,o){r.once(i,o);t.push({origin:r,event:i,fn:o})},unhandleAll(){for(const r of t){const{origin:t,event:i,fn:o}=r;t.removeListener(i,o)}t.length=0}}}const At=Symbol("reentry");const noop=()=>{};class timed_out_TimeoutError extends Error{constructor(t,r){super(`Timeout awaiting '${r}' for ${t}ms`);Object.defineProperty(this,"event",{enumerable:true,configurable:true,writable:true,value:r});Object.defineProperty(this,"code",{enumerable:true,configurable:true,writable:true,value:void 0});this.name="TimeoutError";this.code="ETIMEDOUT"}}function timedOut(t,r,i){if(At in t){return noop}t[At]=true;const o=[];const{once:a,unhandleAll:l}=unhandle();const addTimeout=(t,r,i)=>{const a=setTimeout(r,t,t,i);a.unref?.();const cancel=()=>{clearTimeout(a)};o.push(cancel);return cancel};const{host:c,hostname:u}=i;const timeoutHandler=(r,i)=>{t.destroy(new timed_out_TimeoutError(r,i))};const cancelTimeouts=()=>{for(const t of o){t()}l()};t.once("error",(r=>{cancelTimeouts();if(t.listenerCount("error")===0){throw r}}));if(typeof r.request!=="undefined"){const i=addTimeout(r.request,timeoutHandler,"request");a(t,"response",(t=>{a(t,"end",i)}))}if(typeof r.socket!=="undefined"){const{socket:i}=r;const socketTimeoutHandler=()=>{timeoutHandler(i,"socket")};t.setTimeout(i,socketTimeoutHandler);o.push((()=>{t.removeListener("timeout",socketTimeoutHandler)}))}const h=typeof r.lookup!=="undefined";const d=typeof r.connect!=="undefined";const p=typeof r.secureConnect!=="undefined";const m=typeof r.send!=="undefined";if(h||d||p||m){a(t,"socket",(o=>{const{socketPath:l}=t;if(o.connecting){const t=Boolean(l??Tt.isIP(u??c??"")!==0);if(h&&!t&&typeof o.address().address==="undefined"){const t=addTimeout(r.lookup,timeoutHandler,"lookup");a(o,"lookup",t)}if(d){const timeConnect=()=>addTimeout(r.connect,timeoutHandler,"connect");if(t){a(o,"connect",timeConnect())}else{a(o,"lookup",(t=>{if(t===null){a(o,"connect",timeConnect())}}))}}if(p&&i.protocol==="https:"){a(o,"connect",(()=>{const t=addTimeout(r.secureConnect,timeoutHandler,"secureConnect");a(o,"secureConnect",t)}))}}if(m){const timeRequest=()=>addTimeout(r.send,timeoutHandler,"send");if(o.connecting){a(o,"connect",(()=>{a(t,"upload-complete",timeRequest())}))}else{a(t,"upload-complete",timeRequest())}}}))}if(typeof r.response!=="undefined"){a(t,"upload-complete",(()=>{const i=addTimeout(r.response,timeoutHandler,"response");a(t,"response",i)}))}if(typeof r.read!=="undefined"){a(t,"response",(t=>{const i=addTimeout(r.read,timeoutHandler,"read");a(t,"end",i)}))}return cancelTimeouts}function urlToOptions(t){t=t;const r={protocol:t.protocol,hostname:ze.string(t.hostname)&&t.hostname.startsWith("[")?t.hostname.slice(1,-1):t.hostname,host:t.host,hash:t.hash,search:t.search,pathname:t.pathname,href:t.href,path:`${t.pathname||""}${t.search||""}`};if(ze.string(t.port)&&t.port.length>0){r.port=Number(t.port)}if(t.username||t.password){r.auth=`${t.username||""}:${t.password||""}`}return r}class WeakableMap{constructor(){Object.defineProperty(this,"weakMap",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"map",{enumerable:true,configurable:true,writable:true,value:void 0});this.weakMap=new WeakMap;this.map=new Map}set(t,r){if(typeof t==="object"){this.weakMap.set(t,r)}else{this.map.set(t,r)}}get(t){if(typeof t==="object"){return this.weakMap.get(t)}return this.map.get(t)}has(t){if(typeof t==="object"){return this.weakMap.has(t)}return this.map.has(t)}}const calculateRetryDelay=({attemptCount:t,retryOptions:r,error:i,retryAfter:o,computedValue:a})=>{if(i.name==="RetryError"){return 1}if(t>r.limit){return 0}const l=r.methods.includes(i.options.method);const c=r.errorCodes.includes(i.code);const u=i.response&&r.statusCodes.includes(i.response.statusCode);if(!l||!c&&!u){return 0}if(i.response){if(o){if(o>a){return 0}return o}if(i.response.statusCode===413){return 0}}const h=Math.random()*r.noise;return Math.min(2**(t-1)*1e3,r.backoffLimit)+h};const Ct=calculateRetryDelay;const Pt=require("node:tls");const It=require("node:https");const Lt=require("node:dns");const{Resolver:Mt}=Lt.promises;const Dt=Symbol("cacheableLookupCreateConnection");const Nt=Symbol("cacheableLookupInstance");const jt=Symbol("expires");const Ft=typeof Lt.ALL==="number";const verifyAgent=t=>{if(!(t&&typeof t.createConnection==="function")){throw new Error("Expected an Agent instance as the first argument")}};const map4to6=t=>{for(const r of t){if(r.family===6){continue}r.address=`::ffff:${r.address}`;r.family=6}};const getIfaceInfo=()=>{let t=false;let r=false;for(const i of Object.values(u.networkInterfaces())){for(const o of i){if(o.internal){continue}if(o.family==="IPv6"){r=true}else{t=true}if(t&&r){return{has4:t,has6:r}}}}return{has4:t,has6:r}};const isIterable=t=>Symbol.iterator in t;const ignoreNoResultErrors=t=>t.catch((t=>{if(t.code==="ENODATA"||t.code==="ENOTFOUND"||t.code==="ENOENT"){return[]}throw t}));const Bt={ttl:true};const $t={all:true};const Ht={all:true,family:4};const Ut={all:true,family:6};class CacheableLookup{constructor({cache:t=new Map,maxTtl:r=Infinity,fallbackDuration:i=3600,errorTtl:o=.15,resolver:a=new Mt,lookup:l=Lt.lookup}={}){this.maxTtl=r;this.errorTtl=o;this._cache=t;this._resolver=a;this._dnsLookup=l&&(0,kt.promisify)(l);this.stats={cache:0,query:0};if(this._resolver instanceof Mt){this._resolve4=this._resolver.resolve4.bind(this._resolver);this._resolve6=this._resolver.resolve6.bind(this._resolver)}else{this._resolve4=(0,kt.promisify)(this._resolver.resolve4.bind(this._resolver));this._resolve6=(0,kt.promisify)(this._resolver.resolve6.bind(this._resolver))}this._iface=getIfaceInfo();this._pending={};this._nextRemovalTime=false;this._hostnamesToFallback=new Set;this.fallbackDuration=i;if(i>0){const t=setInterval((()=>{this._hostnamesToFallback.clear()}),i*1e3);if(t.unref){t.unref()}this._fallbackInterval=t}this.lookup=this.lookup.bind(this);this.lookupAsync=this.lookupAsync.bind(this)}set servers(t){this.clear();this._resolver.setServers(t)}get servers(){return this._resolver.getServers()}lookup(t,r,i){if(typeof r==="function"){i=r;r={}}else if(typeof r==="number"){r={family:r}}if(!i){throw new Error("Callback must be a function.")}this.lookupAsync(t,r).then((t=>{if(r.all){i(null,t)}else{i(null,t.address,t.family,t.expires,t.ttl,t.source)}}),i)}async lookupAsync(t,r={}){if(typeof r==="number"){r={family:r}}let i=await this.query(t);if(r.family===6){const t=i.filter((t=>t.family===6));if(r.hints&Lt.V4MAPPED){if(Ft&&r.hints&Lt.ALL||t.length===0){map4to6(i)}else{i=t}}else{i=t}}else if(r.family===4){i=i.filter((t=>t.family===4))}if(r.hints&Lt.ADDRCONFIG){const{_iface:t}=this;i=i.filter((r=>r.family===6?t.has6:t.has4))}if(i.length===0){const r=new Error(`cacheableLookup ENOTFOUND ${t}`);r.code="ENOTFOUND";r.hostname=t;throw r}if(r.all){return i}return i[0]}async query(t){let r="cache";let i=await this._cache.get(t);if(i){this.stats.cache++}if(!i){const o=this._pending[t];if(o){this.stats.cache++;i=await o}else{r="query";const o=this.queryAndCache(t);this._pending[t]=o;this.stats.query++;try{i=await o}finally{delete this._pending[t]}}}i=i.map((t=>({...t,source:r})));return i}async _resolve(t){const[r,i]=await Promise.all([ignoreNoResultErrors(this._resolve4(t,Bt)),ignoreNoResultErrors(this._resolve6(t,Bt))]);let o=0;let a=0;let l=0;const c=Date.now();for(const t of r){t.family=4;t.expires=c+t.ttl*1e3;o=Math.max(o,t.ttl)}for(const t of i){t.family=6;t.expires=c+t.ttl*1e3;a=Math.max(a,t.ttl)}if(r.length>0){if(i.length>0){l=Math.min(o,a)}else{l=o}}else{l=a}return{entries:[...r,...i],cacheTtl:l}}async _lookup(t){try{const[r,i]=await Promise.all([ignoreNoResultErrors(this._dnsLookup(t,Ht)),ignoreNoResultErrors(this._dnsLookup(t,Ut))]);return{entries:[...r,...i],cacheTtl:0}}catch{return{entries:[],cacheTtl:0}}}async _set(t,r,i){if(this.maxTtl>0&&i>0){i=Math.min(i,this.maxTtl)*1e3;r[jt]=Date.now()+i;try{await this._cache.set(t,r,i)}catch(t){this.lookupAsync=async()=>{const r=new Error("Cache Error. Please recreate the CacheableLookup instance.");r.cause=t;throw r}}if(isIterable(this._cache)){this._tick(i)}}}async queryAndCache(t){if(this._hostnamesToFallback.has(t)){return this._dnsLookup(t,$t)}let r=await this._resolve(t);if(r.entries.length===0&&this._dnsLookup){r=await this._lookup(t);if(r.entries.length!==0&&this.fallbackDuration>0){this._hostnamesToFallback.add(t)}}const i=r.entries.length===0?this.errorTtl:r.cacheTtl;await this._set(t,r.entries,i);return r.entries}_tick(t){const r=this._nextRemovalTime;if(!r||t<r){clearTimeout(this._removalTimeout);this._nextRemovalTime=t;this._removalTimeout=setTimeout((()=>{this._nextRemovalTime=false;let t=Infinity;const r=Date.now();for(const[i,o]of this._cache){const a=o[jt];if(r>=a){this._cache.delete(i)}else if(a<t){t=a}}if(t!==Infinity){this._tick(t-r)}}),t);if(this._removalTimeout.unref){this._removalTimeout.unref()}}}install(t){verifyAgent(t);if(Dt in t){throw new Error("CacheableLookup has been already installed")}t[Dt]=t.createConnection;t[Nt]=this;t.createConnection=(r,i)=>{if(!("lookup"in r)){r.lookup=this.lookup}return t[Dt](r,i)}}uninstall(t){verifyAgent(t);if(t[Dt]){if(t[Nt]!==this){throw new Error("The agent is not owned by this CacheableLookup instance")}t.createConnection=t[Dt];delete t[Dt];delete t[Nt]}}updateInterfaceInfo(){const{_iface:t}=this;this._iface=getIfaceInfo();if(t.has4&&!this._iface.has4||t.has6&&!this._iface.has6){this._cache.clear()}}clear(t){if(t){this._cache.delete(t);return}this._cache.clear()}}var qt=i(5767);function parseLinkHeader(t){const r=[];const i=t.split(",");for(const o of i){const[i,...a]=o.split(";");const l=i.trim();if(l[0]!=="<"||l[l.length-1]!==">"){throw new Error(`Invalid format of the Link header reference: ${l}`)}const c=l.slice(1,-1);const u={};if(a.length===0){throw new Error(`Unexpected end of Link header parameters: ${a.join(";")}`)}for(const r of a){const i=r.trim();const o=i.indexOf("=");if(o===-1){throw new Error(`Failed to parse Link header: ${t}`)}const a=i.slice(0,o).trim();const l=i.slice(o+1).trim();u[a]=l}r.push({reference:c,parameters:u})}return r}const[zt,Gt]=c.versions.node.split(".").map(Number);function validateSearchParameters(t){for(const r in t){const i=t[r];qe.any([ze.string,ze.number,ze.boolean,ze.null_,ze.undefined],i)}}const Wt=new Map;let Vt;const getGlobalDnsCache=()=>{if(Vt){return Vt}Vt=new CacheableLookup;return Vt};const Yt={request:undefined,agent:{http:undefined,https:undefined,http2:undefined},h2session:undefined,decompress:true,timeout:{connect:undefined,lookup:undefined,read:undefined,request:undefined,response:undefined,secureConnect:undefined,send:undefined,socket:undefined},prefixUrl:"",body:undefined,form:undefined,json:undefined,cookieJar:undefined,ignoreInvalidCookies:false,searchParams:undefined,dnsLookup:undefined,dnsCache:undefined,context:{},hooks:{init:[],beforeRequest:[],beforeError:[],beforeRedirect:[],beforeRetry:[],afterResponse:[]},followRedirect:true,maxRedirects:10,cache:undefined,throwHttpErrors:true,username:"",password:"",http2:false,allowGetBody:false,headers:{"user-agent":"got (https://github.com/sindresorhus/got)"},methodRewriting:false,dnsLookupIpVersion:undefined,parseJson:JSON.parse,stringifyJson:JSON.stringify,retry:{limit:2,methods:["GET","PUT","HEAD","DELETE","OPTIONS","TRACE"],statusCodes:[408,413,429,500,502,503,504,521,522,524],errorCodes:["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN"],maxRetryAfter:undefined,calculateDelay:({computedValue:t})=>t,backoffLimit:Number.POSITIVE_INFINITY,noise:100},localAddress:undefined,method:"GET",createConnection:undefined,cacheOptions:{shared:undefined,cacheHeuristic:undefined,immutableMinTimeToLive:undefined,ignoreCargoCult:undefined},https:{alpnProtocols:undefined,rejectUnauthorized:undefined,checkServerIdentity:undefined,certificateAuthority:undefined,key:undefined,certificate:undefined,passphrase:undefined,pfx:undefined,ciphers:undefined,honorCipherOrder:undefined,minVersion:undefined,maxVersion:undefined,signatureAlgorithms:undefined,tlsSessionLifetime:undefined,dhparam:undefined,ecdhCurve:undefined,certificateRevocationLists:undefined},encoding:undefined,resolveBodyOnly:false,isStream:false,responseType:"text",url:undefined,pagination:{transform(t){if(t.request.options.responseType==="json"){return t.body}return JSON.parse(t.body)},paginate({response:t}){const r=t.headers.link;if(typeof r!=="string"||r.trim()===""){return false}const i=parseLinkHeader(r);const o=i.find((t=>t.parameters.rel==="next"||t.parameters.rel==='"next"'));if(o){return{url:new ye.URL(o.reference,t.url)}}return false},filter:()=>true,shouldContinue:()=>true,countLimit:Number.POSITIVE_INFINITY,backoff:0,requestLimit:1e4,stackAllItems:false},setHost:true,maxHeaderSize:undefined,signal:undefined,enableUnixSockets:true};const cloneInternals=t=>{const{hooks:r,retry:i}=t;const o={...t,context:{...t.context},cacheOptions:{...t.cacheOptions},https:{...t.https},agent:{...t.agent},headers:{...t.headers},retry:{...i,errorCodes:[...i.errorCodes],methods:[...i.methods],statusCodes:[...i.statusCodes]},timeout:{...t.timeout},hooks:{init:[...r.init],beforeRequest:[...r.beforeRequest],beforeError:[...r.beforeError],beforeRedirect:[...r.beforeRedirect],beforeRetry:[...r.beforeRetry],afterResponse:[...r.afterResponse]},searchParams:t.searchParams?new ye.URLSearchParams(t.searchParams):undefined,pagination:{...t.pagination}};if(o.url!==undefined){o.prefixUrl=""}return o};const cloneRaw=t=>{const{hooks:r,retry:i}=t;const o={...t};if(ze.object(t.context)){o.context={...t.context}}if(ze.object(t.cacheOptions)){o.cacheOptions={...t.cacheOptions}}if(ze.object(t.https)){o.https={...t.https}}if(ze.object(t.cacheOptions)){o.cacheOptions={...o.cacheOptions}}if(ze.object(t.agent)){o.agent={...t.agent}}if(ze.object(t.headers)){o.headers={...t.headers}}if(ze.object(i)){o.retry={...i};if(ze.array(i.errorCodes)){o.retry.errorCodes=[...i.errorCodes]}if(ze.array(i.methods)){o.retry.methods=[...i.methods]}if(ze.array(i.statusCodes)){o.retry.statusCodes=[...i.statusCodes]}}if(ze.object(t.timeout)){o.timeout={...t.timeout}}if(ze.object(r)){o.hooks={...r};if(ze.array(r.init)){o.hooks.init=[...r.init]}if(ze.array(r.beforeRequest)){o.hooks.beforeRequest=[...r.beforeRequest]}if(ze.array(r.beforeError)){o.hooks.beforeError=[...r.beforeError]}if(ze.array(r.beforeRedirect)){o.hooks.beforeRedirect=[...r.beforeRedirect]}if(ze.array(r.beforeRetry)){o.hooks.beforeRetry=[...r.beforeRetry]}if(ze.array(r.afterResponse)){o.hooks.afterResponse=[...r.afterResponse]}}if(ze.object(t.pagination)){o.pagination={...t.pagination}}return o};const getHttp2TimeoutOption=t=>{const r=[t.timeout.socket,t.timeout.connect,t.timeout.lookup,t.timeout.request,t.timeout.secureConnect].filter((t=>typeof t==="number"));if(r.length>0){return Math.min(...r)}return undefined};const init=(t,r,i)=>{const o=t.hooks?.init;if(o){for(const t of o){t(r,i)}}};class Options{constructor(t,r,i){Object.defineProperty(this,"_unixOptions",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"_internals",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"_merging",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"_init",{enumerable:true,configurable:true,writable:true,value:void 0});qe.any([ze.string,ze.urlInstance,ze.object,ze.undefined],t);qe.any([ze.object,ze.undefined],r);qe.any([ze.object,ze.undefined],i);if(t instanceof Options||r instanceof Options){throw new TypeError("The defaults must be passed as the third argument")}this._internals=cloneInternals(i?._internals??i??Yt);this._init=[...i?._init??[]];this._merging=false;this._unixOptions=undefined;try{if(ze.plainObject(t)){try{this.merge(t);this.merge(r)}finally{this.url=t.url}}else{try{this.merge(r)}finally{if(r?.url!==undefined){if(t===undefined){this.url=r.url}else{throw new TypeError("The `url` option is mutually exclusive with the `input` argument")}}else if(t!==undefined){this.url=t}}}}catch(t){t.options=this;throw t}}merge(t){if(!t){return}if(t instanceof Options){for(const r of t._init){this.merge(r)}return}t=cloneRaw(t);init(this,t,this);init(t,t,this);this._merging=true;if("isStream"in t){this.isStream=t.isStream}try{let r=false;for(const i in t){if(i==="mutableDefaults"||i==="handlers"){continue}if(i==="url"){continue}if(!(i in this)){throw new Error(`Unexpected option: ${i}`)}this[i]=t[i];r=true}if(r){this._init.push(t)}}finally{this._merging=false}}get request(){return this._internals.request}set request(t){qe.any([ze.function_,ze.undefined],t);this._internals.request=t}get agent(){return this._internals.agent}set agent(t){qe.plainObject(t);for(const r in t){if(!(r in this._internals.agent)){throw new TypeError(`Unexpected agent option: ${r}`)}qe.any([ze.object,ze.undefined],t[r])}if(this._merging){Object.assign(this._internals.agent,t)}else{this._internals.agent={...t}}}get h2session(){return this._internals.h2session}set h2session(t){this._internals.h2session=t}get decompress(){return this._internals.decompress}set decompress(t){qe.boolean(t);this._internals.decompress=t}get timeout(){return this._internals.timeout}set timeout(t){qe.plainObject(t);for(const r in t){if(!(r in this._internals.timeout)){throw new Error(`Unexpected timeout option: ${r}`)}qe.any([ze.number,ze.undefined],t[r])}if(this._merging){Object.assign(this._internals.timeout,t)}else{this._internals.timeout={...t}}}get prefixUrl(){return this._internals.prefixUrl}set prefixUrl(t){qe.any([ze.string,ze.urlInstance],t);if(t===""){this._internals.prefixUrl="";return}t=t.toString();if(!t.endsWith("/")){t+="/"}if(this._internals.prefixUrl&&this._internals.url){const{href:r}=this._internals.url;this._internals.url.href=t+r.slice(this._internals.prefixUrl.length)}this._internals.prefixUrl=t}get body(){return this._internals.body}set body(t){qe.any([ze.string,ze.buffer,ze.nodeStream,ze.generator,ze.asyncGenerator,isFormData,ze.undefined],t);if(ze.nodeStream(t)){qe.truthy(t.readable)}if(t!==undefined){qe.undefined(this._internals.form);qe.undefined(this._internals.json)}this._internals.body=t}get form(){return this._internals.form}set form(t){qe.any([ze.plainObject,ze.undefined],t);if(t!==undefined){qe.undefined(this._internals.body);qe.undefined(this._internals.json)}this._internals.form=t}get json(){return this._internals.json}set json(t){if(t!==undefined){qe.undefined(this._internals.body);qe.undefined(this._internals.form)}this._internals.json=t}get url(){return this._internals.url}set url(t){qe.any([ze.string,ze.urlInstance,ze.undefined],t);if(t===undefined){this._internals.url=undefined;return}if(ze.string(t)&&t.startsWith("/")){throw new Error("`url` must not start with a slash")}const r=`${this.prefixUrl}${t.toString()}`;const i=new ye.URL(r);this._internals.url=i;decodeURI(r);if(i.protocol==="unix:"){i.href=`http://unix${i.pathname}${i.search}`}if(i.protocol!=="http:"&&i.protocol!=="https:"){const t=new Error(`Unsupported protocol: ${i.protocol}`);t.code="ERR_UNSUPPORTED_PROTOCOL";throw t}if(this._internals.username){i.username=this._internals.username;this._internals.username=""}if(this._internals.password){i.password=this._internals.password;this._internals.password=""}if(this._internals.searchParams){i.search=this._internals.searchParams.toString();this._internals.searchParams=undefined}if(i.hostname==="unix"){if(!this._internals.enableUnixSockets){throw new Error("Using UNIX domain sockets but option `enableUnixSockets` is not enabled")}const t=/(?<socketPath>.+?):(?<path>.+)/.exec(`${i.pathname}${i.search}`);if(t?.groups){const{socketPath:r,path:i}=t.groups;this._unixOptions={socketPath:r,path:i,host:""}}else{this._unixOptions=undefined}return}this._unixOptions=undefined}get cookieJar(){return this._internals.cookieJar}set cookieJar(t){qe.any([ze.object,ze.undefined],t);if(t===undefined){this._internals.cookieJar=undefined;return}let{setCookie:r,getCookieString:i}=t;qe.function_(r);qe.function_(i);if(r.length===4&&i.length===0){r=(0,kt.promisify)(r.bind(t));i=(0,kt.promisify)(i.bind(t));this._internals.cookieJar={setCookie:r,getCookieString:i}}else{this._internals.cookieJar=t}}get signal(){return this._internals.signal}set signal(t){qe.object(t);this._internals.signal=t}get ignoreInvalidCookies(){return this._internals.ignoreInvalidCookies}set ignoreInvalidCookies(t){qe.boolean(t);this._internals.ignoreInvalidCookies=t}get searchParams(){if(this._internals.url){return this._internals.url.searchParams}if(this._internals.searchParams===undefined){this._internals.searchParams=new ye.URLSearchParams}return this._internals.searchParams}set searchParams(t){qe.any([ze.string,ze.object,ze.undefined],t);const r=this._internals.url;if(t===undefined){this._internals.searchParams=undefined;if(r){r.search=""}return}const i=this.searchParams;let o;if(ze.string(t)){o=new ye.URLSearchParams(t)}else if(t instanceof ye.URLSearchParams){o=t}else{validateSearchParameters(t);o=new ye.URLSearchParams;for(const r in t){const a=t[r];if(a===null){o.append(r,"")}else if(a===undefined){i.delete(r)}else{o.append(r,a)}}}if(this._merging){for(const t of o.keys()){i.delete(t)}for(const[t,r]of o){i.append(t,r)}}else if(r){r.search=i.toString()}else{this._internals.searchParams=i}}get searchParameters(){throw new Error("The `searchParameters` option does not exist. Use `searchParams` instead.")}set searchParameters(t){throw new Error("The `searchParameters` option does not exist. Use `searchParams` instead.")}get dnsLookup(){return this._internals.dnsLookup}set dnsLookup(t){qe.any([ze.function_,ze.undefined],t);this._internals.dnsLookup=t}get dnsCache(){return this._internals.dnsCache}set dnsCache(t){qe.any([ze.object,ze.boolean,ze.undefined],t);if(t===true){this._internals.dnsCache=getGlobalDnsCache()}else if(t===false){this._internals.dnsCache=undefined}else{this._internals.dnsCache=t}}get context(){return this._internals.context}set context(t){qe.object(t);if(this._merging){Object.assign(this._internals.context,t)}else{this._internals.context={...t}}}get hooks(){return this._internals.hooks}set hooks(t){qe.object(t);for(const r in t){if(!(r in this._internals.hooks)){throw new Error(`Unexpected hook event: ${r}`)}const i=r;const o=t[i];qe.any([ze.array,ze.undefined],o);if(o){for(const t of o){qe.function_(t)}}if(this._merging){if(o){this._internals.hooks[i].push(...o)}}else{if(!o){throw new Error(`Missing hook event: ${r}`)}this._internals.hooks[r]=[...o]}}}get followRedirect(){return this._internals.followRedirect}set followRedirect(t){qe.boolean(t);this._internals.followRedirect=t}get followRedirects(){throw new TypeError("The `followRedirects` option does not exist. Use `followRedirect` instead.")}set followRedirects(t){throw new TypeError("The `followRedirects` option does not exist. Use `followRedirect` instead.")}get maxRedirects(){return this._internals.maxRedirects}set maxRedirects(t){qe.number(t);this._internals.maxRedirects=t}get cache(){return this._internals.cache}set cache(t){qe.any([ze.object,ze.string,ze.boolean,ze.undefined],t);if(t===true){this._internals.cache=Wt}else if(t===false){this._internals.cache=undefined}else{this._internals.cache=t}}get throwHttpErrors(){return this._internals.throwHttpErrors}set throwHttpErrors(t){qe.boolean(t);this._internals.throwHttpErrors=t}get username(){const t=this._internals.url;const r=t?t.username:this._internals.username;return decodeURIComponent(r)}set username(t){qe.string(t);const r=this._internals.url;const i=encodeURIComponent(t);if(r){r.username=i}else{this._internals.username=i}}get password(){const t=this._internals.url;const r=t?t.password:this._internals.password;return decodeURIComponent(r)}set password(t){qe.string(t);const r=this._internals.url;const i=encodeURIComponent(t);if(r){r.password=i}else{this._internals.password=i}}get http2(){return this._internals.http2}set http2(t){qe.boolean(t);this._internals.http2=t}get allowGetBody(){return this._internals.allowGetBody}set allowGetBody(t){qe.boolean(t);this._internals.allowGetBody=t}get headers(){return this._internals.headers}set headers(t){qe.plainObject(t);if(this._merging){Object.assign(this._internals.headers,lowercaseKeys(t))}else{this._internals.headers=lowercaseKeys(t)}}get methodRewriting(){return this._internals.methodRewriting}set methodRewriting(t){qe.boolean(t);this._internals.methodRewriting=t}get dnsLookupIpVersion(){return this._internals.dnsLookupIpVersion}set dnsLookupIpVersion(t){if(t!==undefined&&t!==4&&t!==6){throw new TypeError(`Invalid DNS lookup IP version: ${t}`)}this._internals.dnsLookupIpVersion=t}get parseJson(){return this._internals.parseJson}set parseJson(t){qe.function_(t);this._internals.parseJson=t}get stringifyJson(){return this._internals.stringifyJson}set stringifyJson(t){qe.function_(t);this._internals.stringifyJson=t}get retry(){return this._internals.retry}set retry(t){qe.plainObject(t);qe.any([ze.function_,ze.undefined],t.calculateDelay);qe.any([ze.number,ze.undefined],t.maxRetryAfter);qe.any([ze.number,ze.undefined],t.limit);qe.any([ze.array,ze.undefined],t.methods);qe.any([ze.array,ze.undefined],t.statusCodes);qe.any([ze.array,ze.undefined],t.errorCodes);qe.any([ze.number,ze.undefined],t.noise);if(t.noise&&Math.abs(t.noise)>100){throw new Error(`The maximum acceptable retry noise is +/- 100ms, got ${t.noise}`)}for(const r in t){if(!(r in this._internals.retry)){throw new Error(`Unexpected retry option: ${r}`)}}if(this._merging){Object.assign(this._internals.retry,t)}else{this._internals.retry={...t}}const{retry:r}=this._internals;r.methods=[...new Set(r.methods.map((t=>t.toUpperCase())))];r.statusCodes=[...new Set(r.statusCodes)];r.errorCodes=[...new Set(r.errorCodes)]}get localAddress(){return this._internals.localAddress}set localAddress(t){qe.any([ze.string,ze.undefined],t);this._internals.localAddress=t}get method(){return this._internals.method}set method(t){qe.string(t);this._internals.method=t.toUpperCase()}get createConnection(){return this._internals.createConnection}set createConnection(t){qe.any([ze.function_,ze.undefined],t);this._internals.createConnection=t}get cacheOptions(){return this._internals.cacheOptions}set cacheOptions(t){qe.plainObject(t);qe.any([ze.boolean,ze.undefined],t.shared);qe.any([ze.number,ze.undefined],t.cacheHeuristic);qe.any([ze.number,ze.undefined],t.immutableMinTimeToLive);qe.any([ze.boolean,ze.undefined],t.ignoreCargoCult);for(const r in t){if(!(r in this._internals.cacheOptions)){throw new Error(`Cache option \`${r}\` does not exist`)}}if(this._merging){Object.assign(this._internals.cacheOptions,t)}else{this._internals.cacheOptions={...t}}}get https(){return this._internals.https}set https(t){qe.plainObject(t);qe.any([ze.boolean,ze.undefined],t.rejectUnauthorized);qe.any([ze.function_,ze.undefined],t.checkServerIdentity);qe.any([ze.string,ze.object,ze.array,ze.undefined],t.certificateAuthority);qe.any([ze.string,ze.object,ze.array,ze.undefined],t.key);qe.any([ze.string,ze.object,ze.array,ze.undefined],t.certificate);qe.any([ze.string,ze.undefined],t.passphrase);qe.any([ze.string,ze.buffer,ze.array,ze.undefined],t.pfx);qe.any([ze.array,ze.undefined],t.alpnProtocols);qe.any([ze.string,ze.undefined],t.ciphers);qe.any([ze.string,ze.buffer,ze.undefined],t.dhparam);qe.any([ze.string,ze.undefined],t.signatureAlgorithms);qe.any([ze.string,ze.undefined],t.minVersion);qe.any([ze.string,ze.undefined],t.maxVersion);qe.any([ze.boolean,ze.undefined],t.honorCipherOrder);qe.any([ze.number,ze.undefined],t.tlsSessionLifetime);qe.any([ze.string,ze.undefined],t.ecdhCurve);qe.any([ze.string,ze.buffer,ze.array,ze.undefined],t.certificateRevocationLists);for(const r in t){if(!(r in this._internals.https)){throw new Error(`HTTPS option \`${r}\` does not exist`)}}if(this._merging){Object.assign(this._internals.https,t)}else{this._internals.https={...t}}}get encoding(){return this._internals.encoding}set encoding(t){if(t===null){throw new TypeError("To get a Buffer, set `options.responseType` to `buffer` instead")}qe.any([ze.string,ze.undefined],t);this._internals.encoding=t}get resolveBodyOnly(){return this._internals.resolveBodyOnly}set resolveBodyOnly(t){qe.boolean(t);this._internals.resolveBodyOnly=t}get isStream(){return this._internals.isStream}set isStream(t){qe.boolean(t);this._internals.isStream=t}get responseType(){return this._internals.responseType}set responseType(t){if(t===undefined){this._internals.responseType="text";return}if(t!=="text"&&t!=="buffer"&&t!=="json"){throw new Error(`Invalid \`responseType\` option: ${t}`)}this._internals.responseType=t}get pagination(){return this._internals.pagination}set pagination(t){qe.object(t);if(this._merging){Object.assign(this._internals.pagination,t)}else{this._internals.pagination=t}}get auth(){throw new Error("Parameter `auth` is deprecated. Use `username` / `password` instead.")}set auth(t){throw new Error("Parameter `auth` is deprecated. Use `username` / `password` instead.")}get setHost(){return this._internals.setHost}set setHost(t){qe.boolean(t);this._internals.setHost=t}get maxHeaderSize(){return this._internals.maxHeaderSize}set maxHeaderSize(t){qe.any([ze.number,ze.undefined],t);this._internals.maxHeaderSize=t}get enableUnixSockets(){return this._internals.enableUnixSockets}set enableUnixSockets(t){qe.boolean(t);this._internals.enableUnixSockets=t}toJSON(){return{...this._internals}}[Symbol.for("nodejs.util.inspect.custom")](t,r){return(0,kt.inspect)(this._internals,r)}createNativeRequestOptions(){const t=this._internals;const r=t.url;let i;if(r.protocol==="https:"){i=t.http2?t.agent:t.agent.https}else{i=t.agent.http}const{https:o}=t;let{pfx:a}=o;if(ze.array(a)&&ze.plainObject(a[0])){a=a.map((t=>({buf:t.buffer,passphrase:t.passphrase})))}return{...t.cacheOptions,...this._unixOptions,ALPNProtocols:o.alpnProtocols,ca:o.certificateAuthority,cert:o.certificate,key:o.key,passphrase:o.passphrase,pfx:o.pfx,rejectUnauthorized:o.rejectUnauthorized,checkServerIdentity:o.checkServerIdentity??Pt.checkServerIdentity,ciphers:o.ciphers,honorCipherOrder:o.honorCipherOrder,minVersion:o.minVersion,maxVersion:o.maxVersion,sigalgs:o.signatureAlgorithms,sessionTimeout:o.tlsSessionLifetime,dhparam:o.dhparam,ecdhCurve:o.ecdhCurve,crl:o.certificateRevocationLists,lookup:t.dnsLookup??t.dnsCache?.lookup,family:t.dnsLookupIpVersion,agent:i,setHost:t.setHost,method:t.method,maxHeaderSize:t.maxHeaderSize,localAddress:t.localAddress,headers:t.headers,createConnection:t.createConnection,timeout:t.http2?getHttp2TimeoutOption(t):undefined,h2session:t.h2session}}getRequestFunction(){const t=this._internals.url;const{request:r}=this._internals;if(!r&&t){return this.getFallbackRequestFunction()}return r}getFallbackRequestFunction(){const t=this._internals.url;if(!t){return}if(t.protocol==="https:"){if(this._internals.http2){if(zt<15||zt===15&&Gt<10){const t=new Error("To use the `http2` option, install Node.js 15.10.0 or above");t.code="EUNSUPPORTED";throw t}return qt.auto}return It.request}return We.request}freeze(){const t=this._internals;Object.freeze(t);Object.freeze(t.hooks);Object.freeze(t.hooks.afterResponse);Object.freeze(t.hooks.beforeError);Object.freeze(t.hooks.beforeRedirect);Object.freeze(t.hooks.beforeRequest);Object.freeze(t.hooks.beforeRetry);Object.freeze(t.hooks.init);Object.freeze(t.https);Object.freeze(t.cacheOptions);Object.freeze(t.agent);Object.freeze(t.headers);Object.freeze(t.timeout);Object.freeze(t.retry);Object.freeze(t.retry.errorCodes);Object.freeze(t.retry.methods);Object.freeze(t.retry.statusCodes)}}const isResponseOk=t=>{const{statusCode:r}=t;const i=t.request.options.followRedirect?299:399;return r>=200&&r<=i||r===304};class ParseError extends RequestError{constructor(t,r){const{options:i}=r.request;super(`${t.message} in "${i.url.toString()}"`,t,r.request);this.name="ParseError";this.code="ERR_BODY_PARSE_FAILURE"}}const parseBody=(t,r,i,o)=>{const{rawBody:a}=t;try{if(r==="text"){return a.toString(o)}if(r==="json"){return a.length===0?"":i(a.toString(o))}if(r==="buffer"){return a}}catch(r){throw new ParseError(r,t)}throw new ParseError({message:`Unknown body type '${r}'`,name:"Error"},t)};function isClientRequest(t){return t.writable&&!t.writableEnded}const Zt=isClientRequest;function isUnixSocketURL(t){return t.protocol==="unix:"||t.hostname==="unix"}const Kt=ze.string(c.versions.brotli);const Qt=new Set(["GET","HEAD"]);const Xt=new WeakableMap;const Jt=new Set([300,301,302,303,304,307,308]);const er=["socket","connect","continue","information","upgrade"];const core_noop=()=>{};class Request extends ge.Duplex{constructor(t,r,i){super({autoDestroy:false,highWaterMark:0});Object.defineProperty(this,"constructor",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"_noPipe",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"options",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"response",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"requestUrl",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"redirectUrls",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"retryCount",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"_stopRetry",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"_downloadedSize",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"_uploadedSize",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"_stopReading",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"_pipedServerResponses",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"_request",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"_responseSize",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"_bodySize",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"_unproxyEvents",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"_isFromCache",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"_cannotHaveBody",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"_triggerRead",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"_cancelTimeouts",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"_nativeResponse",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"_flushed",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"_aborted",{enumerable:true,configurable:true,writable:true,value:void 0});Object.defineProperty(this,"_requestInitialized",{enumerable:true,configurable:true,writable:true,value:void 0});this._downloadedSize=0;this._uploadedSize=0;this._stopReading=false;this._pipedServerResponses=new Set;this._cannotHaveBody=false;this._unproxyEvents=core_noop;this._triggerRead=false;this._cancelTimeouts=core_noop;this._jobs=[];this._flushed=false;this._requestInitialized=false;this._aborted=false;this.redirectUrls=[];this.retryCount=0;this._stopRetry=core_noop;this.on("pipe",(t=>{if(t.headers){Object.assign(this.options.headers,t.headers)}}));this.on("newListener",(t=>{if(t==="retry"&&this.listenerCount("retry")>0){throw new Error("A retry listener has been attached already.")}}));try{this.options=new Options(t,r,i);if(!this.options.url){if(this.options.prefixUrl===""){throw new TypeError("Missing `url` property")}this.options.url=""}this.requestUrl=this.options.url}catch(t){const{options:r}=t;if(r){this.options=r}this.flush=async()=>{this.flush=async()=>{};this.destroy(t)};return}if(this.options.signal?.aborted){this.destroy(new errors_AbortError(this))}this.options.signal?.addEventListener("abort",(()=>{this.destroy(new errors_AbortError(this))}));const{body:o}=this.options;if(ze.nodeStream(o)){o.once("error",(t=>{if(this._flushed){this._beforeError(new UploadError(t,this))}else{this.flush=async()=>{this.flush=async()=>{};this._beforeError(new UploadError(t,this))}}}))}}async flush(){if(this._flushed){return}this._flushed=true;try{await this._finalizeBody();if(this.destroyed){return}await this._makeRequest();if(this.destroyed){this._request?.destroy();return}for(const t of this._jobs){t()}this._jobs.length=0;this._requestInitialized=true}catch(t){this._beforeError(t)}}_beforeError(t){if(this._stopReading){return}const{response:r,options:i}=this;const o=this.retryCount+(t.name==="RetryError"?0:1);this._stopReading=true;if(!(t instanceof RequestError)){t=new RequestError(t.message,t,this)}const a=t;void(async()=>{if(r?.readable&&!r.rawBody&&!this._request?.socket?.destroyed){r.setEncoding(this.readableEncoding);const t=await this._setRawBody(r);if(t){r.body=r.rawBody.toString()}}if(this.listenerCount("retry")!==0){let l;try{let t;if(r&&"retry-after"in r.headers){t=Number(r.headers["retry-after"]);if(Number.isNaN(t)){t=Date.parse(r.headers["retry-after"])-Date.now();if(t<=0){t=1}}else{t*=1e3}}const c=i.retry;l=await c.calculateDelay({attemptCount:o,retryOptions:c,error:a,retryAfter:t,computedValue:Ct({attemptCount:o,retryOptions:c,error:a,retryAfter:t,computedValue:c.maxRetryAfter??i.timeout.request??Number.POSITIVE_INFINITY})})}catch(t){void this._error(new RequestError(t.message,t,this));return}if(l){await new Promise((t=>{const r=setTimeout(t,l);this._stopRetry=()=>{clearTimeout(r);t()}}));if(this.destroyed){return}try{for(const t of this.options.hooks.beforeRetry){await t(a,this.retryCount+1)}}catch(r){void this._error(new RequestError(r.message,t,this));return}if(this.destroyed){return}this.destroy();this.emit("retry",this.retryCount+1,t,(t=>{const r=new Request(i.url,t,i);r.retryCount=this.retryCount+1;c.nextTick((()=>{void r.flush()}));return r}));return}}void this._error(a)})()}_read(){this._triggerRead=true;const{response:t}=this;if(t&&!this._stopReading){if(t.readableLength){this._triggerRead=false}let r;while((r=t.read())!==null){this._downloadedSize+=r.length;const t=this.downloadProgress;if(t.percent<1){this.emit("downloadProgress",t)}this.push(r)}}}_write(t,r,i){const write=()=>{this._writeRequest(t,r,i)};if(this._requestInitialized){write()}else{this._jobs.push(write)}}_final(t){const endRequest=()=>{if(!this._request||this._request.destroyed){t();return}this._request.end((r=>{if(this._request._writableState?.errored){return}if(!r){this._bodySize=this._uploadedSize;this.emit("uploadProgress",this.uploadProgress);this._request.emit("upload-complete")}t(r)}))};if(this._requestInitialized){endRequest()}else{this._jobs.push(endRequest)}}_destroy(t,r){this._stopReading=true;this.flush=async()=>{};this._stopRetry();this._cancelTimeouts();if(this.options){const{body:t}=this.options;if(ze.nodeStream(t)){t.destroy()}}if(this._request){this._request.destroy()}if(t!==null&&!ze.undefined(t)&&!(t instanceof RequestError)){t=new RequestError(t.message,t,this)}r(t)}pipe(t,r){if(t instanceof We.ServerResponse){this._pipedServerResponses.add(t)}return super.pipe(t,r)}unpipe(t){if(t instanceof We.ServerResponse){this._pipedServerResponses.delete(t)}super.unpipe(t);return this}async _finalizeBody(){const{options:t}=this;const{headers:r}=t;const i=!ze.undefined(t.form);const o=!ze.undefined(t.json);const a=!ze.undefined(t.body);const l=Qt.has(t.method)&&!(t.method==="GET"&&t.allowGetBody);this._cannotHaveBody=l;if(i||o||a){if(l){throw new TypeError(`The \`${t.method}\` method cannot be used with a body`)}const o=!ze.string(r["content-type"]);if(a){if(isFormData(t.body)){const i=new FormDataEncoder(t.body);if(o){r["content-type"]=i.headers["Content-Type"]}if("Content-Length"in i.headers){r["content-length"]=i.headers["Content-Length"]}t.body=i.encode()}if(is_form_data_isFormData(t.body)&&o){r["content-type"]=`multipart/form-data; boundary=${t.body.getBoundary()}`}}else if(i){if(o){r["content-type"]="application/x-www-form-urlencoded"}const{form:i}=t;t.form=undefined;t.body=new ye.URLSearchParams(i).toString()}else{if(o){r["content-type"]="application/json"}const{json:i}=t;t.json=undefined;t.body=t.stringifyJson(i)}const c=await getBodySize(t.body,t.headers);if(ze.undefined(r["content-length"])&&ze.undefined(r["transfer-encoding"])&&!l&&!ze.undefined(c)){r["content-length"]=String(c)}}if(t.responseType==="json"&&!("accept"in t.headers)){t.headers.accept="application/json"}this._bodySize=Number(r["content-length"])||undefined}async _onResponseBase(t){if(this.isAborted){return}const{options:r}=this;const{url:i}=r;this._nativeResponse=t;if(r.decompress){t=at(t)}const o=t.statusCode;const a=t;a.statusMessage=a.statusMessage?a.statusMessage:We.STATUS_CODES[o];a.url=r.url.toString();a.requestUrl=this.requestUrl;a.redirectUrls=this.redirectUrls;a.request=this;a.isFromCache=this._nativeResponse.fromCache??false;a.ip=this.ip;a.retryCount=this.retryCount;a.ok=isResponseOk(a);this._isFromCache=a.isFromCache;this._responseSize=Number(t.headers["content-length"])||undefined;this.response=a;t.once("end",(()=>{this._responseSize=this._downloadedSize;this.emit("downloadProgress",this.downloadProgress)}));t.once("error",(r=>{this._aborted=true;t.destroy();this._beforeError(new ReadError(r,this))}));t.once("aborted",(()=>{this._aborted=true;this._beforeError(new ReadError({name:"Error",message:"The server aborted pending request",code:"ECONNRESET"},this))}));this.emit("downloadProgress",this.downloadProgress);const l=t.headers["set-cookie"];if(ze.object(r.cookieJar)&&l){let t=l.map((async t=>r.cookieJar.setCookie(t,i.toString())));if(r.ignoreInvalidCookies){t=t.map((async t=>{try{await t}catch{}}))}try{await Promise.all(t)}catch(t){this._beforeError(t);return}}if(this.isAborted){return}if(r.followRedirect&&t.headers.location&&Jt.has(o)){t.resume();this._cancelTimeouts();this._unproxyEvents();if(this.redirectUrls.length>=r.maxRedirects){this._beforeError(new MaxRedirectsError(this));return}this._request=undefined;const l=new Options(undefined,undefined,this.options);const c=o===303&&l.method!=="GET"&&l.method!=="HEAD";const u=o!==307&&o!==308;const h=l.methodRewriting&&u;if(c||h){l.method="GET";l.body=undefined;l.json=undefined;l.form=undefined;delete l.headers["content-length"]}try{const r=Ge.Buffer.from(t.headers.location,"binary").toString();const o=new ye.URL(r,i);if(!isUnixSocketURL(i)&&isUnixSocketURL(o)){this._beforeError(new RequestError("Cannot redirect to UNIX socket",{},this));return}if(o.hostname!==i.hostname||o.port!==i.port){if("host"in l.headers){delete l.headers.host}if("cookie"in l.headers){delete l.headers.cookie}if("authorization"in l.headers){delete l.headers.authorization}if(l.username||l.password){l.username="";l.password=""}}else{o.username=l.username;o.password=l.password}this.redirectUrls.push(o);l.prefixUrl="";l.url=o;for(const t of l.hooks.beforeRedirect){await t(l,a)}this.emit("redirect",l,a);this.options=l;await this._makeRequest()}catch(t){this._beforeError(t);return}return}if(r.isStream&&r.throwHttpErrors&&!isResponseOk(a)){this._beforeError(new HTTPError(a));return}t.on("readable",(()=>{if(this._triggerRead){this._read()}}));this.on("resume",(()=>{t.resume()}));this.on("pause",(()=>{t.pause()}));t.once("end",(()=>{this.push(null)}));if(this._noPipe){const r=await this._setRawBody();if(r){this.emit("response",t)}return}this.emit("response",t);for(const i of this._pipedServerResponses){if(i.headersSent){continue}for(const o in t.headers){const a=r.decompress?o!=="content-encoding":true;const l=t.headers[o];if(a){i.setHeader(o,l)}}i.statusCode=o}}async _setRawBody(t=this){if(t.readableEnded){return false}try{const r=await(0,et.buffer)(t);if(!this.isAborted){this.response.rawBody=r;return true}}catch{}return false}async _onResponse(t){try{await this._onResponseBase(t)}catch(t){this._beforeError(t)}}_onRequest(t){const{options:r}=this;const{timeout:i,url:o}=r;Ke(t);if(this.options.http2){t.setTimeout(0)}this._cancelTimeouts=timedOut(t,i,o);const a=r.cache?"cacheableResponse":"response";t.once(a,(t=>{void this._onResponse(t)}));t.once("error",(r=>{this._aborted=true;t.destroy();r=r instanceof timed_out_TimeoutError?new TimeoutError(r,this.timings,this):new RequestError(r.message,r,this);this._beforeError(r)}));this._unproxyEvents=proxyEvents(t,this,er);this._request=t;this.emit("uploadProgress",this.uploadProgress);this._sendBody();this.emit("request",t)}async _asyncWrite(t){return new Promise(((r,i)=>{super.write(t,(t=>{if(t){i(t);return}r()}))}))}_sendBody(){const{body:t}=this.options;const r=this.redirectUrls.length===0?this:this._request??this;if(ze.nodeStream(t)){t.pipe(r)}else if(ze.generator(t)||ze.asyncGenerator(t)){(async()=>{try{for await(const r of t){await this._asyncWrite(r)}super.end()}catch(t){this._beforeError(t)}})()}else if(!ze.undefined(t)){this._writeRequest(t,undefined,(()=>{}));r.end()}else if(this._cannotHaveBody||this._noPipe){r.end()}}_prepareCache(t){if(!Xt.has(t)){const r=new nt(((t,r)=>{const i=t._request(t,r);if(ze.promise(i)){i.once=(t,r)=>{if(t==="error"){(async()=>{try{await i}catch(t){r(t)}})()}else if(t==="abort"){(async()=>{try{const t=await i;t.once("abort",r)}catch{}})()}else{throw new Error(`Unknown HTTP2 promise event: ${t}`)}return i}}return i}),t);Xt.set(t,r.request())}}async _createCacheableRequest(t,r){return new Promise(((i,o)=>{Object.assign(r,urlToOptions(t));let a;const l=Xt.get(r.cache)(r,(async t=>{t._readableState.autoDestroy=false;if(a){const fix=()=>{if(t.req){t.complete=t.req.res.complete}};t.prependOnceListener("end",fix);fix();(await a).emit("cacheableResponse",t)}i(t)}));l.once("error",o);l.once("request",(async t=>{a=t;i(a)}))}))}async _makeRequest(){const{options:t}=this;const{headers:r,username:i,password:o}=t;const a=t.cookieJar;for(const t in r){if(ze.undefined(r[t])){delete r[t]}else if(ze.null_(r[t])){throw new TypeError(`Use \`undefined\` instead of \`null\` to delete the \`${t}\` header`)}}if(t.decompress&&ze.undefined(r["accept-encoding"])){r["accept-encoding"]=Kt?"gzip, deflate, br":"gzip, deflate"}if(i||o){const t=Ge.Buffer.from(`${i}:${o}`).toString("base64");r.authorization=`Basic ${t}`}if(a){const i=await a.getCookieString(t.url.toString());if(ze.nonEmptyString(i)){r.cookie=i}}t.prefixUrl="";let l;for(const r of t.hooks.beforeRequest){const i=await r(t);if(!ze.undefined(i)){l=()=>i;break}}if(!l){l=t.getRequestFunction()}const c=t.url;this._requestOptions=t.createNativeRequestOptions();if(t.cache){this._requestOptions._request=l;this._requestOptions.cache=t.cache;this._requestOptions.body=t.body;this._prepareCache(t.cache)}const u=t.cache?this._createCacheableRequest:l;try{let r=u(c,this._requestOptions);if(ze.promise(r)){r=await r}if(ze.undefined(r)){r=t.getFallbackRequestFunction()(c,this._requestOptions);if(ze.promise(r)){r=await r}}if(Zt(r)){this._onRequest(r)}else if(this.writable){this.once("finish",(()=>{void this._onResponse(r)}));this._sendBody()}else{void this._onResponse(r)}}catch(t){if(t instanceof types_CacheError){throw new CacheError(t,this)}throw t}}async _error(t){try{if(t instanceof HTTPError&&!this.options.throwHttpErrors){}else{for(const r of this.options.hooks.beforeError){t=await r(t)}}}catch(r){t=new RequestError(r.message,r,this)}this.destroy(t)}_writeRequest(t,r,i){if(!this._request||this._request.destroyed){return}this._request.write(t,r,(o=>{if(!o&&!this._request.destroyed){this._uploadedSize+=Ge.Buffer.byteLength(t,r);const i=this.uploadProgress;if(i.percent<1){this.emit("uploadProgress",i)}}i(o)}))}get ip(){return this.socket?.remoteAddress}get isAborted(){return this._aborted}get socket(){return this._request?.socket??undefined}get downloadProgress(){let t;if(this._responseSize){t=this._downloadedSize/this._responseSize}else if(this._responseSize===this._downloadedSize){t=1}else{t=0}return{percent:t,transferred:this._downloadedSize,total:this._responseSize}}get uploadProgress(){let t;if(this._bodySize){t=this._uploadedSize/this._bodySize}else if(this._bodySize===this._uploadedSize){t=1}else{t=0}return{percent:t,transferred:this._uploadedSize,total:this._bodySize}}get timings(){return this._request?.timings}get isFromCache(){return this._isFromCache}get reusedSocket(){return this._request?.reusedSocket}}class types_CancelError extends RequestError{constructor(t){super("Promise was canceled",{},t);this.name="CancelError";this.code="ERR_CANCELED"}get isCanceled(){return true}}const tr=["request","response","redirect","uploadProgress","downloadProgress"];function asPromise(t){let r;let i;let o;const a=new ie.EventEmitter;const l=new PCancelable(((c,u,h)=>{h((()=>{r.destroy()}));h.shouldReject=false;h((()=>{u(new types_CancelError(r))}));const makeRequest=d=>{h((()=>{}));const p=t??new Request(undefined,undefined,o);p.retryCount=d;p._noPipe=true;r=p;p.once("response",(async t=>{const r=(t.headers["content-encoding"]??"").toLowerCase();const o=r==="gzip"||r==="deflate"||r==="br";const{options:a}=p;if(o&&!a.decompress){t.body=t.rawBody}else{try{t.body=parseBody(t,a.responseType,a.parseJson,a.encoding)}catch(r){t.body=t.rawBody.toString();if(isResponseOk(t)){p._beforeError(r);return}}}try{const r=a.hooks.afterResponse;for(const[i,o]of r.entries()){t=await o(t,(async t=>{a.merge(t);a.prefixUrl="";if(t.url){a.url=t.url}a.hooks.afterResponse=a.hooks.afterResponse.slice(0,i);throw new RetryError(p)}));if(!(ze.object(t)&&ze.number(t.statusCode)&&!ze.nullOrUndefined(t.body))){throw new TypeError("The `afterResponse` hook returned an invalid value")}}}catch(t){p._beforeError(t);return}i=t;if(!isResponseOk(t)){p._beforeError(new HTTPError(t));return}p.destroy();c(p.options.resolveBodyOnly?t.body:t)}));const onError=t=>{if(l.isCanceled){return}const{options:r}=p;if(t instanceof HTTPError&&!r.throwHttpErrors){const{response:r}=t;p.destroy();c(p.options.resolveBodyOnly?r.body:r);return}u(t)};p.once("error",onError);const m=p.options?.body;p.once("retry",((r,i)=>{t=undefined;const a=p.options.body;if(m===a&&ze.nodeStream(a)){i.message="Cannot retry with consumed body stream";onError(i);return}o=p.options;makeRequest(r)}));proxyEvents(p,a,tr);if(ze.undefined(t)){void p.flush()}};makeRequest(0)}));l.on=(t,r)=>{a.on(t,r);return l};l.off=(t,r)=>{a.off(t,r);return l};const shortcut=t=>{const r=(async()=>{await l;const{options:r}=i.request;return parseBody(i,t,r.parseJson,r.encoding)})();Object.defineProperties(r,Object.getOwnPropertyDescriptors(l));return r};l.json=()=>{if(r.options){const{headers:t}=r.options;if(!r.writableFinished&&!("accept"in t)){t.accept="application/json"}}return shortcut("json")};l.buffer=()=>shortcut("buffer");l.text=()=>shortcut("text");return l}const delay=async t=>new Promise((r=>{setTimeout(r,t)}));const isGotInstance=t=>ze.function_(t);const rr=["get","post","put","patch","head","delete"];const create=t=>{t={options:new Options(undefined,undefined,t.options),handlers:[...t.handlers],mutableDefaults:t.mutableDefaults};Object.defineProperty(t,"mutableDefaults",{enumerable:true,configurable:false,writable:false});const got=(r,i,o=t.options)=>{const a=new Request(r,i,o);let l;const lastHandler=t=>{a.options=t;a._noPipe=!t.isStream;void a.flush();if(t.isStream){return a}if(!l){l=asPromise(a)}return l};let c=0;const iterateHandlers=r=>{const i=t.handlers[c++]??lastHandler;const o=i(r,iterateHandlers);if(ze.promise(o)&&!a.options.isStream){if(!l){l=asPromise(a)}if(o!==l){const t=Object.getOwnPropertyDescriptors(l);for(const r in t){if(r in o){delete t[r]}}Object.defineProperties(o,t);o.cancel=l.cancel}}return o};return iterateHandlers(a.options)};got.extend=(...r)=>{const i=new Options(undefined,undefined,t.options);const o=[...t.handlers];let a;for(const t of r){if(isGotInstance(t)){i.merge(t.defaults.options);o.push(...t.defaults.handlers);a=t.defaults.mutableDefaults}else{i.merge(t);if(t.handlers){o.push(...t.handlers)}a=t.mutableDefaults}}return create({options:i,handlers:o,mutableDefaults:Boolean(a)})};const paginateEach=async function*(r,i){let o=new Options(r,i,t.options);o.resolveBodyOnly=false;const{pagination:a}=o;qe.function_(a.transform);qe.function_(a.shouldContinue);qe.function_(a.filter);qe.function_(a.paginate);qe.number(a.countLimit);qe.number(a.requestLimit);qe.number(a.backoff);const l=[];let{countLimit:c}=a;let u=0;while(u<a.requestLimit){if(u!==0){await delay(a.backoff)}const t=await got(undefined,undefined,o);const r=await a.transform(t);const i=[];qe.array(r);for(const t of r){if(a.filter({item:t,currentItems:i,allItems:l})){if(!a.shouldContinue({item:t,currentItems:i,allItems:l})){return}yield t;if(a.stackAllItems){l.push(t)}i.push(t);if(--c<=0){return}}}const h=a.paginate({response:t,currentItems:i,allItems:l});if(h===false){return}if(h===t.request.options){o=t.request.options}else{o.merge(h);qe.any([ze.urlInstance,ze.undefined],h.url);if(h.url!==undefined){o.prefixUrl="";o.url=h.url}}u++}};got.paginate=paginateEach;got.paginate.all=async(t,r)=>{const i=[];for await(const o of paginateEach(t,r)){i.push(o)}return i};got.paginate.each=paginateEach;got.stream=(t,r)=>got(t,{...r,isStream:true});for(const t of rr){got[t]=(r,i)=>got(r,{...i,method:t});got.stream[t]=(r,i)=>got(r,{...i,method:t,isStream:true})}if(!t.mutableDefaults){Object.freeze(t.handlers);t.options.freeze()}Object.defineProperty(got,"defaults",{value:t,writable:false,configurable:false,enumerable:true});return got};const ir=create;const sr={options:new Options,handlers:[],mutableDefaults:false};const nr=ir(sr);const or=nr;var ar=i(5793);var lr=i(2781);const cr=(0,Ye.promisify)(lr.Stream.pipeline);async function isUrlOk(t){const r=await or.head(t).catch((t=>t));return r.statusCode===200}async function getRepoInfo(t,r){const[,i,o,a,l,...c]=t.pathname.split("/");const u=r?r.replace(/^\//,""):c.join("/");if(a===undefined){const t=await or(`https://api.github.com/repos/${i}/${o}`).catch((t=>t));if(t.statusCode!==200){return}const r=JSON.parse(t.body);return{username:i,name:o,branch:r["default_branch"],filePath:u}}const h=r?`${l}/${c.join("/")}`.replace(new RegExp(`/${u}|/$`),""):l;if(i&&o&&h&&a==="tree"){return{username:i,name:o,branch:h,filePath:u}}}function hasRepo({username:t,name:r,branch:i,filePath:o}){const a=`https://api.github.com/repos/${t}/${r}/contents`;const l=`${o?`/${o}`:""}/package.json`;return isUrlOk(a+l+`?ref=${i}`)}function hasTemplate(t){return isUrlOk(`https://api.github.com/repos/openpatch/hyperbook/contents/templates/${encodeURIComponent(t)}/package.json`)}function downloadAndExtractRepo(t,{username:r,name:i,branch:o,filePath:a}){return cr(or.stream(`https://codeload.github.com/${r}/${i}/tar.gz/${o}`),ar.extract({cwd:t,strip:a?a.split("/").length+1:1},[`${i}-${o}${a?`/${a}`:""}`]))}async function getTemplateInfo(t){let r;if(t){let i;try{i=new URL(t)}catch(t){if(t.code!=="ERR_INVALID_URL"){console.error(t);process.exit(1)}}if(i){if(i.origin!=="https://github.com"){console.error(`Invalid URL: ${T.red(`"${t}"`)}. Only GitHub repositories are supported. Please use a GitHub URL and try again.`);process.exit(1)}r=await getRepoInfo(i);if(!r){console.error(`Found invalid GitHub URL: ${T.red(`"${t}"`)}. Please fix the URL and try again.`);process.exit(1)}const o=await hasRepo(r);if(!o){console.error(`Could not locate the repository for ${T.red(`"${t}"`)}. Please check that the repository exists and try again.`);process.exit(1)}}else if(t!=="__internal-testing-retry"){const r=await hasTemplate(t);if(!r){console.error(`Could not locate an template named ${T.red(`"${t}"`)}. It could be due to the following:\n`,`1. Your spelling of template ${T.red(`"${t}"`)} might be incorrect.\n`,`2. You might not be connected to the internet.`);process.exit(1)}}}return r}var ur=i(3493);var hr=i.n(ur);function install(t,r,{packageManager:i,isOnline:o,devDependencies:a}){const l=[];const c=[];return new Promise(((u,h)=>{let d;let p=i;const m=i==="yarn";if(r&&r.length){if(m){d=["add","--exact"];if(!o)d.push("--offline");d.push("--cwd",t);if(a)d.push("--dev");d.push(...r)}else{d=["install","--save-exact"];d.push(a?"--save-dev":"--save");d.push(...r)}}else{d=["install"];if(!o){console.log(T.yellow("You appear to be offline."));if(m){console.log(T.yellow("Falling back to the local Yarn cache."));console.log();d.push("--offline")}else{console.log()}}}if(m){d.push(...c)}else{d.push(...l)}const y=J()(p,d,{stdio:"inherit",cwd:G().join(process.cwd(),".hyperbook"),env:{...process.env,ADBLOCK:"1",DISABLE_OPENCOLLECTIVE:"1"}});y.on("close",(t=>{if(t!==0){h({command:`${p} ${d.join(" ")}`});return}u()}))}))}const fr=require("dns");var dr=i.n(fr);var pr=i(7310);var mr=i.n(pr);function getProxy(){if(process.env.https_proxy){return process.env.https_proxy}try{const t=(0,ee.execSync)("npm config get https-proxy").toString().trim();return t!=="null"?t:undefined}catch(t){return}}function getOnline(){return new Promise((t=>{dr().lookup("registry.yarnpkg.com",(r=>{if(!r){return t(true)}const i=getProxy();if(!i){return t(false)}const{hostname:o}=mr().parse(i);if(!o){return t(false)}dr().lookup(o,(r=>{t(r==null)}))}))}))}async function makeSymlink(t,r){const i=re().platform()=="win32"?"junction":null;return new Promise(((o,a)=>{V().symlink(t,r,i,(t=>{if(t){a()}else{o()}}))}))}const yr=require("fs/promises");var gr=i.n(yr);async function preparePackages(t){var r,i;const o=await gr().readFile(G().join(t,"package.json")).then((t=>t.toString("utf8"))).then((t=>JSON.parse(t)));const{dependencies:a,devDependencies:l}=o;for(let t of Object.entries(a)){const[i,o]=t;if(o==="workspace:*"){const t=`https://registry.npmjs.org/${encodeURIComponent(i)}`;const o=await or.get(t).json();const l=(r=o===null||o===void 0?void 0:o["dist-tags"])===null||r===void 0?void 0:r["latest"];if(l){a[i]=l}}}for(let t of Object.entries(l)){const[r,o]=t;if(o==="workspace:*"){const t=`https://registry.npmjs.org/${encodeURIComponent(r)}`;const o=await or.get(t).json();const a=(i=o===null||o===void 0?void 0:o["dist-tags"])===null||i===void 0?void 0:i["latest"];if(a){l[r]=a}}}o["dependencies"]=a;o["devDependencies"]=l;await gr().writeFile(G().join(t,"package.json"),JSON.stringify(o,null,2))}class DownloadError extends Error{}async function runSetup(t,r,i){if(!i){i=process.cwd()}if(!t){const r=await readHyperbook();t=r.template}if(!t){t="https://github.com/openpatch/hyperbook/tree/main/templates/simple"}if(!r){r=await getTemplateInfo(t)}const o=G().join(i,".hyperbook");console.log("Removing old template");De().sync(o);await makeDir(o);const a=await getOnline();try{if(r){const i=r;console.log(`Downloading files from repo ${T.cyan(t)}. This might take a moment.`);console.log();await hr()((()=>downloadAndExtractRepo(o,i)),{retries:3})}}catch(t){function isErrorLike(t){return typeof t==="object"&&t!==null&&typeof t.message==="string"}throw new DownloadError(isErrorLike(t)?t.message:t+"")}console.log("Prepare packages. Use latest versions.");console.log();await preparePackages(o);console.log("Installing packages. This might take a couple of minutes.");console.log();await install(o,null,{packageManager:"npm",isOnline:a});console.log();De().sync(G().join(o,"book"));De().sync(G().join(o,"public"));De().sync(G().join(o,"glossary"));De().sync(G().join(o,"hyperbook.json"));await makeSymlink(G().join(i,"book"),G().join(o,"book"));await makeSymlink(G().join(i,"public"),G().join(o,"public"));await makeSymlink(G().join(i,"glossary"),G().join(o,"glossary"));await makeSymlink(G().join(i,"hyperbook.json"),G().join(o,"hyperbook.json"))}async function runNew({programName:t,bookPath:r,template:o}){if(typeof r==="string"){r=r.trim()}if(!r){const t=await Le()({type:"text",name:"path",message:"What is your book named?",initial:"my-book"});if(typeof t.path==="string"){r=t.path.trim()}}if(!r){console.log();console.log("Please specify the book directory:");console.log(` ${T.cyan(t)} ${T.green("<book-directory>")}`);console.log();console.log("For example:");console.log(` ${T.cyan(t)} ${T.green("my-new-book")}`);console.log();console.log(`Run ${T.cyan(`${t} --help`)} to see all options.`);process.exit(1)}let a=await getTemplateInfo(o);const l=G().resolve(r);if(!await isWriteable(G().dirname(l))){console.error("The book 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 c=G().basename(l);await makeDir(l);if(!isFolderEmpty(l,c)){process.exit(1)}const u=process.cwd();console.log(`Creating a new hyperbook in ${T.green(l)}.`);console.log();process.chdir(l);const{description:h}=await Le()({type:"text",name:"description",message:"What is your book about?",initial:""});const{author:d}=await Le()({type:"text",name:"author",message:"Who is the author of the book?",initial:""});const{authorUrl:p}=await Le()({type:"text",name:"authorUrl",message:"What is the link to the authors homepage?",initial:""});let{license:m}=await Le()({type:"select",name:"license",message:"Pick a license for your book!",choices:[{title:"Creative Commons Zero (CC0)",value:"cc0"},{title:"Creative Commons Attribution (CC BY)",value:"cc-by"},{title:"Creative Commons Attribution-ShareAlike (CC BY-SA)",value:"cc-by-sa"},{title:"Creative Commons Attribution-NoDerivs (CC BY-ND)",value:"cc-by-nd"},{title:"Creative Commons Attribution-NonCommercial (CC BY-NC)",value:"cc-by-nc"},{title:"Creative Commons Attribution-NonCommercial-ShareAlike (CC BY-NC-SA)",value:"cc-by-nc-sa"},{title:"Creative Commons Attribution-NonCommercial-NoDervis (CC BY-NC-ND)",value:"cc-by-nc-nd"},{title:"Custom",value:"custom"}]});if(m==="custom"){const t=await Le()({type:"text",name:"license",message:"Which custom license you want to use?"});m=t.license}const{language:y}=await Le()({type:"text",name:"language",message:"In which language is your book written? Provide a short code, e.g.: en or de",initial:"en"});const g={name:c,version:"0.0.0",description:h,license:m,author:{name:d,url:p},language:y};V().writeFileSync(G().join(l,"hyperbook.json"),JSON.stringify(g,null,2)+re().EOL);console.log();const b=i.ab+"templates";await cpy("default/**",l,{cwd:i.ab+"templates",rename:t=>{switch(t){case"gitignore":{return".".concat(t)}case"README-template.md":{return"README.md"}default:{return t}}}});await runSetup(o,a,l);if(tryGitInit(l)){console.log("Initialized a git repository.");console.log()}let v;if(G().join(u,c)===r){v=c}else{v=r}console.log(`${T.green("Success!")} Created ${c} at ${r}`);console.log("Inside that directory, you can run several commands:");console.log();console.log(T.cyan(` hyperbook dev`));console.log(" Starts the development server.");console.log();console.log(T.cyan(` hyperbook build`));console.log(" Builds the book for production.");console.log();console.log("We suggest that you begin by typing:");console.log();console.log(T.cyan(" cd"),v);console.log(` ${T.cyan(`hyperbook dev`)}`);console.log()}const br=JSON.parse('{"name":"hyperbook","version":"0.5.5","author":"Mike Barkmin","homepage":"https://github.com/openpatch/hyperbook#readme","license":"MIT","bin":{"hyperbook":"./dist/index.js"},"files":["dist"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/openpatch/hyperbook.git","directory":"packages/hyperbook"},"bugs":{"url":"https://github.com/openpatch/hyperbook/issues"},"engines":{"node":">=12.22.0"},"scripts":{"version":"pnpm build","lint":"tsc --noEmit","dev":"ncc build ./index.ts -w -o dist/","build":"rimraf dist && ncc build ./index.ts -o ./dist/ --minify --no-cache --no-source-map-register"},"devDependencies":{"@types/archiver":"5.3.1","@types/async-retry":"1.4.5","@types/cross-spawn":"6.0.2","@types/prompts":"2.4.1","@types/rimraf":"3.0.2","@types/tar":"6.1.3","@vercel/ncc":"0.34.0","archiver":"5.3.1","async-retry":"1.3.3","chalk":"5.0.1","commander":"9.4.1","cpy":"9.0.1","cross-spawn":"7.0.3","got":"12.5.1","prompts":"2.4.2","rimraf":"3.0.2","tar":"6.1.11","update-check":"1.5.4"},"dependencies":{"@hyperbook/types":"workspace:*"}}');const vr=new j;vr.name(br.name).version(br.version).hook("preAction",(async()=>{await notifyUpdate()}));vr.command("new").description("create a new hyperbook").arguments("<book-directory>").usage(`${T.green("<book-directory>")} [options]`).option("-t, --template [name]|[github-url]",`\n A template for your hyperbook. You can use an template name\n from the official hyperbook repo or a GitHub URL. The URL can use\n any branch and/or subdirectory\n`).action((async(t,r)=>{const i=typeof r.template==="string"&&r.template.trim();await runNew({programName:vr.name(),bookPath:t,template:i}).catch((()=>process.exit(1)))}));vr.command("dev").description("start the development server for a hyperbook").action((async()=>{await runDev().catch((()=>process.exit(1)))}));vr.command("setup").description("downloads the latest version of the template of a hyperbook").action((async()=>{await runSetup().catch((()=>process.exit(1)))}));vr.command("build").description("build a hyperbook").action((async()=>{await runArchive().catch((()=>process.exit(1)));await runBuild().catch((()=>process.exit(1)))}));vr.command("archive").description("create archives from archives folder").action((async()=>{await runArchive().catch((()=>process.exit(1)))}));vr.parseAsync(process.argv);const _r=q()(br).catch((()=>null));async function notifyUpdate(){try{const t=await _r;if(t===null||t===void 0?void 0:t.latest){const t=getPkgManager();console.log();console.log(T.yellow.bold("A new version of `hyperbook` is available!"));console.log("You can update by running: "+T.cyan(t==="yarn"?"yarn global add hyperbook":`${t} install --global hyperbook`));console.log()}process.exit()}catch{}}},9491:t=>{"use strict";t.exports=require("assert")},4300:t=>{"use strict";t.exports=require("buffer")},2081:t=>{"use strict";t.exports=require("child_process")},2057:t=>{"use strict";t.exports=require("constants")},6113:t=>{"use strict";t.exports=require("crypto")},2361:t=>{"use strict";t.exports=require("events")},7147:t=>{"use strict";t.exports=require("fs")},3685:t=>{"use strict";t.exports=require("http")},5158:t=>{"use strict";t.exports=require("http2")},5687:t=>{"use strict";t.exports=require("https")},1808:t=>{"use strict";t.exports=require("net")},2037:t=>{"use strict";t.exports=require("os")},1017:t=>{"use strict";t.exports=require("path")},7282:t=>{"use strict";t.exports=require("process")},4521:t=>{"use strict";t.exports=require("readline")},2781:t=>{"use strict";t.exports=require("stream")},1576:t=>{"use strict";t.exports=require("string_decoder")},4404:t=>{"use strict";t.exports=require("tls")},7310:t=>{"use strict";t.exports=require("url")},3837:t=>{"use strict";t.exports=require("util")},9796:t=>{"use strict";t.exports=require("zlib")},345:(t,r,i)=>{const{Argument:o}=i(4079);const{Command:a}=i(6505);const{CommanderError:l,InvalidArgumentError:c}=i(9027);const{Help:u}=i(9164);const{Option:h}=i(5205);r=t.exports=new a;r.program=r;r.Argument=o;r.Command=a;r.CommanderError=l;r.Help=u;r.InvalidArgumentError=c;r.InvalidOptionArgumentError=c;r.Option=h},4079:(t,r,i)=>{const{InvalidArgumentError:o}=i(9027);class Argument{constructor(t,r){this.description=r||"";this.variadic=false;this.parseArg=undefined;this.defaultValue=undefined;this.defaultValueDescription=undefined;this.argChoices=undefined;switch(t[0]){case"<":this.required=true;this._name=t.slice(1,-1);break;case"[":this.required=false;this._name=t.slice(1,-1);break;default:this.required=true;this._name=t;break}if(this._name.length>3&&this._name.slice(-3)==="..."){this.variadic=true;this._name=this._name.slice(0,-3)}}name(){return this._name}_concatValue(t,r){if(r===this.defaultValue||!Array.isArray(r)){return[t]}return r.concat(t)}default(t,r){this.defaultValue=t;this.defaultValueDescription=r;return this}argParser(t){this.parseArg=t;return this}choices(t){this.argChoices=t.slice();this.parseArg=(t,r)=>{if(!this.argChoices.includes(t)){throw new o(`Allowed choices are ${this.argChoices.join(", ")}.`)}if(this.variadic){return this._concatValue(t,r)}return t};return this}argRequired(){this.required=true;return this}argOptional(){this.required=false;return this}}function humanReadableArgName(t){const r=t.name()+(t.variadic===true?"...":"");return t.required?"<"+r+">":"["+r+"]"}r.Argument=Argument;r.humanReadableArgName=humanReadableArgName},6505:(t,r,i)=>{const o=i(2361).EventEmitter;const a=i(2081);const l=i(1017);const c=i(7147);const u=i(7282);const{Argument:h,humanReadableArgName:d}=i(4079);const{CommanderError:p}=i(9027);const{Help:m}=i(9164);const{Option:y,splitOptionFlags:g,DualOptions:b}=i(5205);const{suggestSimilar:v}=i(211);class Command extends o{constructor(t){super();this.commands=[];this.options=[];this.parent=null;this._allowUnknownOption=false;this._allowExcessArguments=true;this._args=[];this.args=[];this.rawArgs=[];this.processedArgs=[];this._scriptPath=null;this._name=t||"";this._optionValues={};this._optionValueSources={};this._storeOptionsAsProperties=false;this._actionHandler=null;this._executableHandler=false;this._executableFile=null;this._executableDir=null;this._defaultCommandName=null;this._exitCallback=null;this._aliases=[];this._combineFlagAndOptionalValue=true;this._description="";this._summary="";this._argsDescription=undefined;this._enablePositionalOptions=false;this._passThroughOptions=false;this._lifeCycleHooks={};this._showHelpAfterError=false;this._showSuggestionAfterError=true;this._outputConfiguration={writeOut:t=>u.stdout.write(t),writeErr:t=>u.stderr.write(t),getOutHelpWidth:()=>u.stdout.isTTY?u.stdout.columns:undefined,getErrHelpWidth:()=>u.stderr.isTTY?u.stderr.columns:undefined,outputError:(t,r)=>r(t)};this._hidden=false;this._hasHelpOption=true;this._helpFlags="-h, --help";this._helpDescription="display help for command";this._helpShortFlag="-h";this._helpLongFlag="--help";this._addImplicitHelpCommand=undefined;this._helpCommandName="help";this._helpCommandnameAndArgs="help [command]";this._helpCommandDescription="display help for command";this._helpConfiguration={}}copyInheritedSettings(t){this._outputConfiguration=t._outputConfiguration;this._hasHelpOption=t._hasHelpOption;this._helpFlags=t._helpFlags;this._helpDescription=t._helpDescription;this._helpShortFlag=t._helpShortFlag;this._helpLongFlag=t._helpLongFlag;this._helpCommandName=t._helpCommandName;this._helpCommandnameAndArgs=t._helpCommandnameAndArgs;this._helpCommandDescription=t._helpCommandDescription;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}command(t,r,i){let o=r;let a=i;if(typeof o==="object"&&o!==null){a=o;o=null}a=a||{};const[,l,c]=t.match(/([^ ]+) *(.*)/);const u=this.createCommand(l);if(o){u.description(o);u._executableHandler=true}if(a.isDefault)this._defaultCommandName=u._name;u._hidden=!!(a.noHelp||a.hidden);u._executableFile=a.executableFile||null;if(c)u.arguments(c);this.commands.push(u);u.parent=this;u.copyInheritedSettings(this);if(o)return this;return u}createCommand(t){return new Command(t)}createHelp(){return Object.assign(new m,this.configureHelp())}configureHelp(t){if(t===undefined)return this._helpConfiguration;this._helpConfiguration=t;return this}configureOutput(t){if(t===undefined)return this._outputConfiguration;Object.assign(this._outputConfiguration,t);return this}showHelpAfterError(t=true){if(typeof t!=="string")t=!!t;this._showHelpAfterError=t;return this}showSuggestionAfterError(t=true){this._showSuggestionAfterError=!!t;return this}addCommand(t,r){if(!t._name){throw new Error(`Command passed to .addCommand() must have a name\n- specify the name in Command constructor or using .name()`)}r=r||{};if(r.isDefault)this._defaultCommandName=t._name;if(r.noHelp||r.hidden)t._hidden=true;this.commands.push(t);t.parent=this;return this}createArgument(t,r){return new h(t,r)}argument(t,r,i,o){const a=this.createArgument(t,r);if(typeof i==="function"){a.default(o).argParser(i)}else{a.default(i)}this.addArgument(a);return this}arguments(t){t.split(/ +/).forEach((t=>{this.argument(t)}));return this}addArgument(t){const r=this._args.slice(-1)[0];if(r&&r.variadic){throw new Error(`only the last argument can be variadic '${r.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._args.push(t);return this}addHelpCommand(t,r){if(t===false){this._addImplicitHelpCommand=false}else{this._addImplicitHelpCommand=true;if(typeof t==="string"){this._helpCommandName=t.split(" ")[0];this._helpCommandnameAndArgs=t}this._helpCommandDescription=r||this._helpCommandDescription}return this}_hasImplicitHelpCommand(){if(this._addImplicitHelpCommand===undefined){return this.commands.length&&!this._actionHandler&&!this._findCommand("help")}return this._addImplicitHelpCommand}hook(t,r){const i=["preSubcommand","preAction","postAction"];if(!i.includes(t)){throw new Error(`Unexpected value for event passed to hook : '${t}'.\nExpecting one of '${i.join("', '")}'`)}if(this._lifeCycleHooks[t]){this._lifeCycleHooks[t].push(r)}else{this._lifeCycleHooks[t]=[r]}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,r,i){if(this._exitCallback){this._exitCallback(new p(t,r,i))}u.exit(t)}action(t){const listener=r=>{const i=this._args.length;const o=r.slice(0,i);if(this._storeOptionsAsProperties){o[i]=this}else{o[i]=this.opts()}o.push(this);return t.apply(this,o)};this._actionHandler=listener;return this}createOption(t,r){return new y(t,r)}addOption(t){const r=t.name();const i=t.attributeName();if(t.negate){const r=t.long.replace(/^--no-/,"--");if(!this._findOption(r)){this.setOptionValueWithSource(i,t.defaultValue===undefined?true:t.defaultValue,"default")}}else if(t.defaultValue!==undefined){this.setOptionValueWithSource(i,t.defaultValue,"default")}this.options.push(t);const handleOptionValue=(r,o,a)=>{if(r==null&&t.presetArg!==undefined){r=t.presetArg}const l=this.getOptionValue(i);if(r!==null&&t.parseArg){try{r=t.parseArg(r,l)}catch(t){if(t.code==="commander.invalidArgument"){const r=`${o} ${t.message}`;this.error(r,{exitCode:t.exitCode,code:t.code})}throw t}}else if(r!==null&&t.variadic){r=t._concatValue(r,l)}if(r==null){if(t.negate){r=false}else if(t.isBoolean()||t.optional){r=true}else{r=""}}this.setOptionValueWithSource(i,r,a)};this.on("option:"+r,(r=>{const i=`error: option '${t.flags}' argument '${r}' is invalid.`;handleOptionValue(r,i,"cli")}));if(t.envVar){this.on("optionEnv:"+r,(r=>{const i=`error: option '${t.flags}' value '${r}' from env '${t.envVar}' is invalid.`;handleOptionValue(r,i,"env")}))}return this}_optionEx(t,r,i,o,a){if(typeof r==="object"&&r instanceof y){throw new Error("To add an Option object use addOption() instead of option() or requiredOption()")}const l=this.createOption(r,i);l.makeOptionMandatory(!!t.mandatory);if(typeof o==="function"){l.default(a).argParser(o)}else if(o instanceof RegExp){const t=o;o=(r,i)=>{const o=t.exec(r);return o?o[0]:i};l.default(a).argParser(o)}else{l.default(o)}return this.addOption(l)}option(t,r,i,o){return this._optionEx({},t,r,i,o)}requiredOption(t,r,i,o){return this._optionEx({mandatory:true},t,r,i,o)}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;if(!!this.parent&&t&&!this.parent._enablePositionalOptions){throw new Error("passThroughOptions can not be used without turning on enablePositionalOptions for parent command(s)")}return this}storeOptionsAsProperties(t=true){this._storeOptionsAsProperties=!!t;if(this.options.length){throw new Error("call .storeOptionsAsProperties() before adding options")}return this}getOptionValue(t){if(this._storeOptionsAsProperties){return this[t]}return this._optionValues[t]}setOptionValue(t,r){return this.setOptionValueWithSource(t,r,undefined)}setOptionValueWithSource(t,r,i){if(this._storeOptionsAsProperties){this[t]=r}else{this._optionValues[t]=r}this._optionValueSources[t]=i;return this}getOptionValueSource(t){return this._optionValueSources[t]}_prepareUserArgs(t,r){if(t!==undefined&&!Array.isArray(t)){throw new Error("first parameter to parse must be array or undefined")}r=r||{};if(t===undefined){t=u.argv;if(u.versions&&u.versions.electron){r.from="electron"}}this.rawArgs=t.slice();let i;switch(r.from){case undefined:case"node":this._scriptPath=t[1];i=t.slice(2);break;case"electron":if(u.defaultApp){this._scriptPath=t[1];i=t.slice(2)}else{i=t.slice(1)}break;case"user":i=t.slice(0);break;default:throw new Error(`unexpected parse option { from: '${r.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);this._name=this._name||"program";return i}parse(t,r){const i=this._prepareUserArgs(t,r);this._parseCommand([],i);return this}async parseAsync(t,r){const i=this._prepareUserArgs(t,r);await this._parseCommand([],i);return this}_executeSubCommand(t,r){r=r.slice();let i=false;const o=[".js",".ts",".tsx",".mjs",".cjs"];function findFile(t,r){const i=l.resolve(t,r);if(c.existsSync(i))return i;if(o.includes(l.extname(r)))return undefined;const a=o.find((t=>c.existsSync(`${i}${t}`)));if(a)return`${i}${a}`;return undefined}this._checkForMissingMandatoryOptions();this._checkForConflictingOptions();let h=t._executableFile||`${this._name}-${t._name}`;let d=this._executableDir||"";if(this._scriptPath){let t;try{t=c.realpathSync(this._scriptPath)}catch(r){t=this._scriptPath}d=l.resolve(l.dirname(t),d)}if(d){let r=findFile(d,h);if(!r&&!t._executableFile&&this._scriptPath){const i=l.basename(this._scriptPath,l.extname(this._scriptPath));if(i!==this._name){r=findFile(d,`${i}-${t._name}`)}}h=r||h}i=o.includes(l.extname(h));let m;if(u.platform!=="win32"){if(i){r.unshift(h);r=incrementNodeInspectorPort(u.execArgv).concat(r);m=a.spawn(u.argv[0],r,{stdio:"inherit"})}else{m=a.spawn(h,r,{stdio:"inherit"})}}else{r.unshift(h);r=incrementNodeInspectorPort(u.execArgv).concat(r);m=a.spawn(u.execPath,r,{stdio:"inherit"})}if(!m.killed){const t=["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"];t.forEach((t=>{u.on(t,(()=>{if(m.killed===false&&m.exitCode===null){m.kill(t)}}))}))}const y=this._exitCallback;if(!y){m.on("close",u.exit.bind(u))}else{m.on("close",(()=>{y(new p(u.exitCode||0,"commander.executeSubCommandAsync","(close)"))}))}m.on("error",(r=>{if(r.code==="ENOENT"){const r=d?`searched for local subcommand relative to directory '${d}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory";const i=`'${h}' does not exist\n - if '${t._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead\n - if the default executable name is not suitable, use the executableFile option to supply a custom name or path\n - ${r}`;throw new Error(i)}else if(r.code==="EACCES"){throw new Error(`'${h}' not executable`)}if(!y){u.exit(1)}else{const t=new p(1,"commander.executeSubCommandAsync","(error)");t.nestedError=r;y(t)}}));this.runningCommand=m}_dispatchSubcommand(t,r,i){const o=this._findCommand(t);if(!o)this.help({error:true});let a;a=this._chainOrCallSubCommandHook(a,o,"preSubcommand");a=this._chainOrCall(a,(()=>{if(o._executableHandler){this._executeSubCommand(o,r.concat(i))}else{return o._parseCommand(r,i)}}));return a}_checkNumberOfArguments(){this._args.forEach(((t,r)=>{if(t.required&&this.args[r]==null){this.missingArgument(t.name())}}));if(this._args.length>0&&this._args[this._args.length-1].variadic){return}if(this.args.length>this._args.length){this._excessArguments(this.args)}}_processArguments(){const myParseArg=(t,r,i)=>{let o=r;if(r!==null&&t.parseArg){try{o=t.parseArg(r,i)}catch(i){if(i.code==="commander.invalidArgument"){const o=`error: command-argument value '${r}' is invalid for argument '${t.name()}'. ${i.message}`;this.error(o,{exitCode:i.exitCode,code:i.code})}throw i}}return o};this._checkNumberOfArguments();const t=[];this._args.forEach(((r,i)=>{let o=r.defaultValue;if(r.variadic){if(i<this.args.length){o=this.args.slice(i);if(r.parseArg){o=o.reduce(((t,i)=>myParseArg(r,i,t)),r.defaultValue)}}else if(o===undefined){o=[]}}else if(i<this.args.length){o=this.args[i];if(r.parseArg){o=myParseArg(r,o,r.defaultValue)}}t[i]=o}));this.processedArgs=t}_chainOrCall(t,r){if(t&&t.then&&typeof t.then==="function"){return t.then((()=>r()))}return r()}_chainOrCallHooks(t,r){let i=t;const o=[];getCommandAndParents(this).reverse().filter((t=>t._lifeCycleHooks[r]!==undefined)).forEach((t=>{t._lifeCycleHooks[r].forEach((r=>{o.push({hookedCommand:t,callback:r})}))}));if(r==="postAction"){o.reverse()}o.forEach((t=>{i=this._chainOrCall(i,(()=>t.callback(t.hookedCommand,this)))}));return i}_chainOrCallSubCommandHook(t,r,i){let o=t;if(this._lifeCycleHooks[i]!==undefined){this._lifeCycleHooks[i].forEach((t=>{o=this._chainOrCall(o,(()=>t(this,r)))}))}return o}_parseCommand(t,r){const i=this.parseOptions(r);this._parseOptionsEnv();this._parseOptionsImplied();t=t.concat(i.operands);r=i.unknown;this.args=t.concat(r);if(t&&this._findCommand(t[0])){return this._dispatchSubcommand(t[0],t.slice(1),r)}if(this._hasImplicitHelpCommand()&&t[0]===this._helpCommandName){if(t.length===1){this.help()}return this._dispatchSubcommand(t[1],[],[this._helpLongFlag])}if(this._defaultCommandName){outputHelpIfRequested(this,r);return this._dispatchSubcommand(this._defaultCommandName,t,r)}if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName){this.help({error:true})}outputHelpIfRequested(this,i.unknown);this._checkForMissingMandatoryOptions();this._checkForConflictingOptions();const checkForUnknownOptions=()=>{if(i.unknown.length>0){this.unknownOption(i.unknown[0])}};const o=`command:${this.name()}`;if(this._actionHandler){checkForUnknownOptions();this._processArguments();let i;i=this._chainOrCallHooks(i,"preAction");i=this._chainOrCall(i,(()=>this._actionHandler(this.processedArgs)));if(this.parent){i=this._chainOrCall(i,(()=>{this.parent.emit(o,t,r)}))}i=this._chainOrCallHooks(i,"postAction");return i}if(this.parent&&this.parent.listenerCount(o)){checkForUnknownOptions();this._processArguments();this.parent.emit(o,t,r)}else if(t.length){if(this._findCommand("*")){return this._dispatchSubcommand("*",t,r)}if(this.listenerCount("command:*")){this.emit("command:*",t,r)}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((r=>r._name===t||r._aliases.includes(t)))}_findOption(t){return this.options.find((r=>r.is(t)))}_checkForMissingMandatoryOptions(){for(let t=this;t;t=t.parent){t.options.forEach((r=>{if(r.mandatory&&t.getOptionValue(r.attributeName())===undefined){t.missingMandatoryOptionValue(r)}}))}}_checkForConflictingLocalOptions(){const t=this.options.filter((t=>{const r=t.attributeName();if(this.getOptionValue(r)===undefined){return false}return this.getOptionValueSource(r)!=="default"}));const r=t.filter((t=>t.conflictsWith.length>0));r.forEach((r=>{const i=t.find((t=>r.conflictsWith.includes(t.attributeName())));if(i){this._conflictingOption(r,i)}}))}_checkForConflictingOptions(){for(let t=this;t;t=t.parent){t._checkForConflictingLocalOptions()}}parseOptions(t){const r=[];const i=[];let o=r;const a=t.slice();function maybeOption(t){return t.length>1&&t[0]==="-"}let l=null;while(a.length){const t=a.shift();if(t==="--"){if(o===i)o.push(t);o.push(...a);break}if(l&&!maybeOption(t)){this.emit(`option:${l.name()}`,t);continue}l=null;if(maybeOption(t)){const r=this._findOption(t);if(r){if(r.required){const t=a.shift();if(t===undefined)this.optionMissingArgument(r);this.emit(`option:${r.name()}`,t)}else if(r.optional){let t=null;if(a.length>0&&!maybeOption(a[0])){t=a.shift()}this.emit(`option:${r.name()}`,t)}else{this.emit(`option:${r.name()}`)}l=r.variadic?r:null;continue}}if(t.length>2&&t[0]==="-"&&t[1]!=="-"){const r=this._findOption(`-${t[1]}`);if(r){if(r.required||r.optional&&this._combineFlagAndOptionalValue){this.emit(`option:${r.name()}`,t.slice(2))}else{this.emit(`option:${r.name()}`);a.unshift(`-${t.slice(2)}`)}continue}}if(/^--[^=]+=/.test(t)){const r=t.indexOf("=");const i=this._findOption(t.slice(0,r));if(i&&(i.required||i.optional)){this.emit(`option:${i.name()}`,t.slice(r+1));continue}}if(maybeOption(t)){o=i}if((this._enablePositionalOptions||this._passThroughOptions)&&r.length===0&&i.length===0){if(this._findCommand(t)){r.push(t);if(a.length>0)i.push(...a);break}else if(t===this._helpCommandName&&this._hasImplicitHelpCommand()){r.push(t);if(a.length>0)r.push(...a);break}else if(this._defaultCommandName){i.push(t);if(a.length>0)i.push(...a);break}}if(this._passThroughOptions){o.push(t);if(a.length>0)o.push(...a);break}o.push(t)}return{operands:r,unknown:i}}opts(){if(this._storeOptionsAsProperties){const t={};const r=this.options.length;for(let i=0;i<r;i++){const r=this.options[i].attributeName();t[r]=r===this._versionOptionName?this._version:this[r]}return t}return this._optionValues}optsWithGlobals(){return getCommandAndParents(this).reduce(((t,r)=>Object.assign(t,r.opts())),{})}error(t,r){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 i=r||{};const o=i.exitCode||1;const a=i.code||"commander.error";this._exit(o,a,t)}_parseOptionsEnv(){this.options.forEach((t=>{if(t.envVar&&t.envVar in u.env){const r=t.attributeName();if(this.getOptionValue(r)===undefined||["default","config","env"].includes(this.getOptionValueSource(r))){if(t.required||t.optional){this.emit(`optionEnv:${t.name()}`,u.env[t.envVar])}else{this.emit(`optionEnv:${t.name()}`)}}}}))}_parseOptionsImplied(){const t=new b(this.options);const hasCustomOptionValue=t=>this.getOptionValue(t)!==undefined&&!["default","implied"].includes(this.getOptionValueSource(t));this.options.filter((r=>r.implied!==undefined&&hasCustomOptionValue(r.attributeName())&&t.valueFromOption(this.getOptionValue(r.attributeName()),r))).forEach((t=>{Object.keys(t.implied).filter((t=>!hasCustomOptionValue(t))).forEach((r=>{this.setOptionValueWithSource(r,t.implied[r],"implied")}))}))}missingArgument(t){const r=`error: missing required argument '${t}'`;this.error(r,{code:"commander.missingArgument"})}optionMissingArgument(t){const r=`error: option '${t.flags}' argument missing`;this.error(r,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(t){const r=`error: required option '${t.flags}' not specified`;this.error(r,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(t,r){const findBestOptionFromValue=t=>{const r=t.attributeName();const i=this.getOptionValue(r);const o=this.options.find((t=>t.negate&&r===t.attributeName()));const a=this.options.find((t=>!t.negate&&r===t.attributeName()));if(o&&(o.presetArg===undefined&&i===false||o.presetArg!==undefined&&i===o.presetArg)){return o}return a||t};const getErrorMessage=t=>{const r=findBestOptionFromValue(t);const i=r.attributeName();const o=this.getOptionValueSource(i);if(o==="env"){return`environment variable '${r.envVar}'`}return`option '${r.flags}'`};const i=`error: ${getErrorMessage(t)} cannot be used with ${getErrorMessage(r)}`;this.error(i,{code:"commander.conflictingOption"})}unknownOption(t){if(this._allowUnknownOption)return;let r="";if(t.startsWith("--")&&this._showSuggestionAfterError){let i=[];let o=this;do{const t=o.createHelp().visibleOptions(o).filter((t=>t.long)).map((t=>t.long));i=i.concat(t);o=o.parent}while(o&&!o._enablePositionalOptions);r=v(t,i)}const i=`error: unknown option '${t}'${r}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(t){if(this._allowExcessArguments)return;const r=this._args.length;const i=r===1?"":"s";const o=this.parent?` for '${this.name()}'`:"";const a=`error: too many arguments${o}. Expected ${r} argument${i} but got ${t.length}.`;this.error(a,{code:"commander.excessArguments"})}unknownCommand(){const t=this.args[0];let r="";if(this._showSuggestionAfterError){const i=[];this.createHelp().visibleCommands(this).forEach((t=>{i.push(t.name());if(t.alias())i.push(t.alias())}));r=v(t,i)}const i=`error: unknown command '${t}'${r}`;this.error(i,{code:"commander.unknownCommand"})}version(t,r,i){if(t===undefined)return this._version;this._version=t;r=r||"-V, --version";i=i||"output the version number";const o=this.createOption(r,i);this._versionOptionName=o.attributeName();this.options.push(o);this.on("option:"+o.name(),(()=>{this._outputConfiguration.writeOut(`${t}\n`);this._exit(0,"commander.version",t)}));return this}description(t,r){if(t===undefined&&r===undefined)return this._description;this._description=t;if(r){this._argsDescription=r}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 r=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler){r=this.commands[this.commands.length-1]}if(t===r._name)throw new Error("Command alias can't be the same as its name");r._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._args.map((t=>d(t)));return[].concat(this.options.length||this._hasHelpOption?"[options]":[],this.commands.length?"[command]":[],this._args.length?t:[]).join(" ")}this._usage=t;return this}name(t){if(t===undefined)return this._name;this._name=t;return this}nameFromFilename(t){this._name=l.basename(t,l.extname(t));return this}executableDir(t){if(t===undefined)return this._executableDir;this._executableDir=t;return this}helpInformation(t){const r=this.createHelp();if(r.helpWidth===undefined){r.helpWidth=t&&t.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()}return r.formatHelp(this,r)}_getHelpContext(t){t=t||{};const r={error:!!t.error};let i;if(r.error){i=t=>this._outputConfiguration.writeErr(t)}else{i=t=>this._outputConfiguration.writeOut(t)}r.write=t.write||i;r.command=this;return r}outputHelp(t){let r;if(typeof t==="function"){r=t;t=undefined}const i=this._getHelpContext(t);getCommandAndParents(this).reverse().forEach((t=>t.emit("beforeAllHelp",i)));this.emit("beforeHelp",i);let o=this.helpInformation(i);if(r){o=r(o);if(typeof o!=="string"&&!Buffer.isBuffer(o)){throw new Error("outputHelp callback must return a string or a Buffer")}}i.write(o);this.emit(this._helpLongFlag);this.emit("afterHelp",i);getCommandAndParents(this).forEach((t=>t.emit("afterAllHelp",i)))}helpOption(t,r){if(typeof t==="boolean"){this._hasHelpOption=t;return this}this._helpFlags=t||this._helpFlags;this._helpDescription=r||this._helpDescription;const i=g(this._helpFlags);this._helpShortFlag=i.shortFlag;this._helpLongFlag=i.longFlag;return this}help(t){this.outputHelp(t);let r=u.exitCode||0;if(r===0&&t&&typeof t!=="function"&&t.error){r=1}this._exit(r,"commander.help","(outputHelp)")}addHelpText(t,r){const i=["beforeAll","before","after","afterAll"];if(!i.includes(t)){throw new Error(`Unexpected value for position to addHelpText.\nExpecting one of '${i.join("', '")}'`)}const o=`${t}Help`;this.on(o,(t=>{let i;if(typeof r==="function"){i=r({error:t.error,command:t.command})}else{i=r}if(i){t.write(`${i}\n`)}}));return this}}function outputHelpIfRequested(t,r){const i=t._hasHelpOption&&r.find((r=>r===t._helpLongFlag||r===t._helpShortFlag));if(i){t.outputHelp();t._exit(0,"commander.helpDisplayed","(outputHelp)")}}function incrementNodeInspectorPort(t){return t.map((t=>{if(!t.startsWith("--inspect")){return t}let r;let i="127.0.0.1";let o="9229";let a;if((a=t.match(/^(--inspect(-brk)?)$/))!==null){r=a[1]}else if((a=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null){r=a[1];if(/^\d+$/.test(a[3])){o=a[3]}else{i=a[3]}}else if((a=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null){r=a[1];i=a[3];o=a[4]}if(r&&o!=="0"){return`${r}=${i}:${parseInt(o)+1}`}return t}))}function getCommandAndParents(t){const r=[];for(let i=t;i;i=i.parent){r.push(i)}return r}r.Command=Command},9027:(t,r)=>{class CommanderError extends Error{constructor(t,r,i){super(i);Error.captureStackTrace(this,this.constructor);this.name=this.constructor.name;this.code=r;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}}r.CommanderError=CommanderError;r.InvalidArgumentError=InvalidArgumentError},9164:(t,r,i)=>{const{humanReadableArgName:o}=i(4079);class Help{constructor(){this.helpWidth=undefined;this.sortSubcommands=false;this.sortOptions=false}visibleCommands(t){const r=t.commands.filter((t=>!t._hidden));if(t._hasImplicitHelpCommand()){const[,i,o]=t._helpCommandnameAndArgs.match(/([^ ]+) *(.*)/);const a=t.createCommand(i).helpOption(false);a.description(t._helpCommandDescription);if(o)a.arguments(o);r.push(a)}if(this.sortSubcommands){r.sort(((t,r)=>t.name().localeCompare(r.name())))}return r}visibleOptions(t){const r=t.options.filter((t=>!t.hidden));const i=t._hasHelpOption&&t._helpShortFlag&&!t._findOption(t._helpShortFlag);const o=t._hasHelpOption&&!t._findOption(t._helpLongFlag);if(i||o){let a;if(!i){a=t.createOption(t._helpLongFlag,t._helpDescription)}else if(!o){a=t.createOption(t._helpShortFlag,t._helpDescription)}else{a=t.createOption(t._helpFlags,t._helpDescription)}r.push(a)}if(this.sortOptions){const getSortKey=t=>t.short?t.short.replace(/^-/,""):t.long.replace(/^--/,"");r.sort(((t,r)=>getSortKey(t).localeCompare(getSortKey(r))))}return r}visibleArguments(t){if(t._argsDescription){t._args.forEach((r=>{r.description=r.description||t._argsDescription[r.name()]||""}))}if(t._args.find((t=>t.description))){return t._args}return[]}subcommandTerm(t){const r=t._args.map((t=>o(t))).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(r?" "+r:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,r){return r.visibleCommands(t).reduce(((t,i)=>Math.max(t,r.subcommandTerm(i).length)),0)}longestOptionTermLength(t,r){return r.visibleOptions(t).reduce(((t,i)=>Math.max(t,r.optionTerm(i).length)),0)}longestArgumentTermLength(t,r){return r.visibleArguments(t).reduce(((t,i)=>Math.max(t,r.argumentTerm(i).length)),0)}commandUsage(t){let r=t._name;if(t._aliases[0]){r=r+"|"+t._aliases[0]}let i="";for(let r=t.parent;r;r=r.parent){i=r.name()+" "+i}return i+r+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){const r=[];if(t.argChoices){r.push(`choices: ${t.argChoices.map((t=>JSON.stringify(t))).join(", ")}`)}if(t.defaultValue!==undefined){const i=t.required||t.optional||t.isBoolean()&&typeof t.defaultValue==="boolean";if(i){r.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`)}}if(t.presetArg!==undefined&&t.optional){r.push(`preset: ${JSON.stringify(t.presetArg)}`)}if(t.envVar!==undefined){r.push(`env: ${t.envVar}`)}if(r.length>0){return`${t.description} (${r.join(", ")})`}return t.description}argumentDescription(t){const r=[];if(t.argChoices){r.push(`choices: ${t.argChoices.map((t=>JSON.stringify(t))).join(", ")}`)}if(t.defaultValue!==undefined){r.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`)}if(r.length>0){const i=`(${r.join(", ")})`;if(t.description){return`${t.description} ${i}`}return i}return t.description}formatHelp(t,r){const i=r.padWidth(t,r);const o=r.helpWidth||80;const a=2;const l=2;function formatItem(t,c){if(c){const u=`${t.padEnd(i+l)}${c}`;return r.wrap(u,o-a,i+l)}return t}function formatList(t){return t.join("\n").replace(/^/gm," ".repeat(a))}let c=[`Usage: ${r.commandUsage(t)}`,""];const u=r.commandDescription(t);if(u.length>0){c=c.concat([u,""])}const h=r.visibleArguments(t).map((t=>formatItem(r.argumentTerm(t),r.argumentDescription(t))));if(h.length>0){c=c.concat(["Arguments:",formatList(h),""])}const d=r.visibleOptions(t).map((t=>formatItem(r.optionTerm(t),r.optionDescription(t))));if(d.length>0){c=c.concat(["Options:",formatList(d),""])}const p=r.visibleCommands(t).map((t=>formatItem(r.subcommandTerm(t),r.subcommandDescription(t))));if(p.length>0){c=c.concat(["Commands:",formatList(p),""])}return c.join("\n")}padWidth(t,r){return Math.max(r.longestOptionTermLength(t,r),r.longestSubcommandTermLength(t,r),r.longestArgumentTermLength(t,r))}wrap(t,r,i,o=40){if(t.match(/[\n]\s+/))return t;const a=r-i;if(a<o)return t;const l=t.slice(0,i);const c=t.slice(i);const u=" ".repeat(i);const h=new RegExp(".{1,"+(a-1)+"}([\\s]|$)|[^\\s]+?([\\s]|$)","g");const d=c.match(h)||[];return l+d.map(((t,r)=>{if(t.slice(-1)==="\n"){t=t.slice(0,t.length-1)}return(r>0?u:"")+t.trimRight()})).join("\n")}}r.Help=Help},5205:(t,r,i)=>{const{InvalidArgumentError:o}=i(9027);class Option{constructor(t,r){this.flags=t;this.description=r||"";this.required=t.includes("<");this.optional=t.includes("[");this.variadic=/\w\.\.\.[>\]]$/.test(t);this.mandatory=false;const i=splitOptionFlags(t);this.short=i.shortFlag;this.long=i.longFlag;this.negate=false;if(this.long){this.negate=this.long.startsWith("--no-")}this.defaultValue=undefined;this.defaultValueDescription=undefined;this.presetArg=undefined;this.envVar=undefined;this.parseArg=undefined;this.hidden=false;this.argChoices=undefined;this.conflictsWith=[];this.implied=undefined}default(t,r){this.defaultValue=t;this.defaultValueDescription=r;return this}preset(t){this.presetArg=t;return this}conflicts(t){this.conflictsWith=this.conflictsWith.concat(t);return this}implies(t){this.implied=Object.assign(this.implied||{},t);return this}env(t){this.envVar=t;return this}argParser(t){this.parseArg=t;return this}makeOptionMandatory(t=true){this.mandatory=!!t;return this}hideHelp(t=true){this.hidden=!!t;return this}_concatValue(t,r){if(r===this.defaultValue||!Array.isArray(r)){return[t]}return r.concat(t)}choices(t){this.argChoices=t.slice();this.parseArg=(t,r)=>{if(!this.argChoices.includes(t)){throw new o(`Allowed choices are ${this.argChoices.join(", ")}.`)}if(this.variadic){return this._concatValue(t,r)}return t};return this}name(){if(this.long){return this.long.replace(/^--/,"")}return this.short.replace(/^-/,"")}attributeName(){return camelcase(this.name().replace(/^no-/,""))}is(t){return this.short===t||this.long===t}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class DualOptions{constructor(t){this.positiveOptions=new Map;this.negativeOptions=new Map;this.dualOptions=new Set;t.forEach((t=>{if(t.negate){this.negativeOptions.set(t.attributeName(),t)}else{this.positiveOptions.set(t.attributeName(),t)}}));this.negativeOptions.forEach(((t,r)=>{if(this.positiveOptions.has(r)){this.dualOptions.add(r)}}))}valueFromOption(t,r){const i=r.attributeName();if(!this.dualOptions.has(i))return true;const o=this.negativeOptions.get(i).presetArg;const a=o!==undefined?o:false;return r.negate===(a===t)}}function camelcase(t){return t.split("-").reduce(((t,r)=>t+r[0].toUpperCase()+r.slice(1)))}function splitOptionFlags(t){let r;let i;const o=t.split(/[ |,]+/);if(o.length>1&&!/^[[<]/.test(o[1]))r=o.shift();i=o.shift();if(!r&&/^-[^-]$/.test(i)){r=i;i=undefined}return{shortFlag:r,longFlag:i}}r.Option=Option;r.splitOptionFlags=splitOptionFlags;r.DualOptions=DualOptions},211:(t,r)=>{const i=3;function editDistance(t,r){if(Math.abs(t.length-r.length)>i)return Math.max(t.length,r.length);const o=[];for(let r=0;r<=t.length;r++){o[r]=[r]}for(let t=0;t<=r.length;t++){o[0][t]=t}for(let i=1;i<=r.length;i++){for(let a=1;a<=t.length;a++){let l=1;if(t[a-1]===r[i-1]){l=0}else{l=1}o[a][i]=Math.min(o[a-1][i]+1,o[a][i-1]+1,o[a-1][i-1]+l);if(a>1&&i>1&&t[a-1]===r[i-2]&&t[a-2]===r[i-1]){o[a][i]=Math.min(o[a][i],o[a-2][i-2]+1)}}}return o[t.length][r.length]}function suggestSimilar(t,r){if(!r||r.length===0)return"";r=Array.from(new Set(r));const o=t.startsWith("--");if(o){t=t.slice(2);r=r.map((t=>t.slice(2)))}let a=[];let l=i;const c=.4;r.forEach((r=>{if(r.length<=1)return;const i=editDistance(t,r);const o=Math.max(t.length,r.length);const u=(o-i)/o;if(u>c){if(i<l){l=i;a=[r]}else if(i===l){a.push(r)}}}));a.sort(((t,r)=>t.localeCompare(r)));if(o){a=a.map((t=>`--${t}`))}if(a.length>1){return`\n(Did you mean one of ${a.join(", ")}?)`}if(a.length===1){return`\n(Did you mean ${a[0]}?)`}return""}r.suggestSimilar=suggestSimilar}};var r={};function __nccwpck_require__(i){var o=r[i];if(o!==undefined){return o.exports}var a=r[i]={exports:{}};var l=true;try{t[i].call(a.exports,a,a.exports,__nccwpck_require__);l=false}finally{if(l)delete r[i]}return a.exports}(()=>{__nccwpck_require__.n=t=>{var r=t&&t.__esModule?()=>t["default"]:()=>t;__nccwpck_require__.d(r,{a:r});return r}})();(()=>{__nccwpck_require__.d=(t,r)=>{for(var i in r){if(__nccwpck_require__.o(r,i)&&!__nccwpck_require__.o(t,i)){Object.defineProperty(t,i,{enumerable:true,get:r[i]})}}}})();(()=>{__nccwpck_require__.o=(t,r)=>Object.prototype.hasOwnProperty.call(t,r)})();(()=>{__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 i=__nccwpck_require__(7666);module.exports=i})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hyperbook",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.5",
|
|
4
4
|
"author": "Mike Barkmin",
|
|
5
5
|
"homepage": "https://github.com/openpatch/hyperbook#readme",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@types/archiver": "5.3.1",
|
|
29
29
|
"@types/async-retry": "1.4.5",
|
|
30
30
|
"@types/cross-spawn": "6.0.2",
|
|
31
|
-
"@types/prompts": "2.
|
|
31
|
+
"@types/prompts": "2.4.1",
|
|
32
32
|
"@types/rimraf": "3.0.2",
|
|
33
33
|
"@types/tar": "6.1.3",
|
|
34
34
|
"@vercel/ncc": "0.34.0",
|
|
@@ -44,6 +44,9 @@
|
|
|
44
44
|
"tar": "6.1.11",
|
|
45
45
|
"update-check": "1.5.4"
|
|
46
46
|
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@hyperbook/types": "0.0.1"
|
|
49
|
+
},
|
|
47
50
|
"scripts": {
|
|
48
51
|
"version": "pnpm build",
|
|
49
52
|
"lint": "tsc --noEmit",
|