21 lines
128 KiB
JavaScript
21 lines
128 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
const originalEmit = process.emit;
|
|
process.emit = function (name, data, ...args) {
|
|
if (name === 'warning' && typeof data === 'object' && data.name === 'DeprecationWarning' && data.message.includes('punycode')) {
|
|
return false;
|
|
}
|
|
return originalEmit.apply(process, [name, data, ...args]);
|
|
};
|
|
|
|
var b=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var yt=b((Du,Ti)=>{Ti.exports={name:"@dp/tea-sdk-node",version:"3.0.10",description:"",main:"lib/index.js",keywords:[],author:"",license:"ISC",engines:{node:">=10.0.0"},types:"./lib/index.d.ts",dependencies:{"@types/node":"^12.12.50","@logsdk/node-utils":"^3.0.7"},scripts:{build:"npm run clean && tsc --build tsconfig.build.json",clean:"rm -rf ./lib",watch:"npm run build -- --watch",test:"jest"}}});var Ar=b(ge=>{var xi=ge&&ge.__rest||function(t,e){var r={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(r[s]=t[s]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,s=Object.getOwnPropertySymbols(t);n<s.length;n++)e.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(t,s[n])&&(r[s[n]]=t[s[n]]);return r};Object.defineProperty(ge,"__esModule",{value:!0});var Ai=yt(),qi=new Date().getTimezoneOffset(),ji=qi*60,Hi=new Proxy({darwin:"mac",win32:"windows"},{get(t,e){return t[e]||e}}),gt=class{get headerFields(){return Object.assign(Object.assign({},this.partialHeaderFields),{custom:JSON.stringify(this.customField)})}get logger(){return this.options.logger}get caller(){return this.options.caller}get appId(){return this.options.app_id}constructor(e){this.options=e,this.userFields={},this.customField={},this.partialHeaderFields={app_id:e.app_id},Object.assign(this.partialHeaderFields,{platform:"Node.js",os_name:Hi[process.platform],tz_offset:ji,sdk_version:Ai.version})}configure(e){var r;e.header&&this.logger.trace("Re-configure header with %o",e.header),e.user&&this.logger.trace("Re-configure user with %o",e.user),!((r=e.header)===null||r===void 0)&&r.custom&&this.logger.warn("Set custom params inside header is deprecated, use `config` instead. which looks like:",`
|
|
teaSDK.config({
|
|
header: { ... },
|
|
user: { ... },
|
|
custom: {/** custom content */},
|
|
})`);let s=e.header||{},{custom:n}=s,o=xi(s,["custom"]);this.customField=JSON.parse(n||"{}"),Object.assign(this.partialHeaderFields,o),Object.assign(this.userFields,e.user),Object.assign(this.customField,e.custom)}get(e){try{return e?Object.hasOwnProperty.call(this.userFields,e)?this.userFields[e]:Object.hasOwnProperty.call(this.partialHeaderFields,e)?this.partialHeaderFields[e]:this.customField[e]?this.customField[e]:void 0:{user:this.userFields,header:this.partialHeaderFields}}catch{this.logger.warn("applog node config get error");return}}compose(e,r){let s=Object.assign({},this.userFields,e.user);s.user_unique_id||(s.user_unique_id="anonymous",this.logger.warn("Composing events without specifying `user_unique_id` is strongly deprecated, use `sdk.config()` to add a global fallback value for anonymous users"));let n=Object.assign({},this.customField,e.customOfHeader);return this.partialHeaderFields&&this.partialHeaderFields.app_id&&this.logger.trace("report appid with %o",this.partialHeaderFields.app_id),{id:(r==null?void 0:r.id)||Math.random().toString(32).slice(2),originatedBy:(r==null?void 0:r.originatedBy)||"logsdk",createdAt:(r==null?void 0:r.createdAt)||Date.now(),event:{server_time:Math.ceil(Date.now()/1e3),caller:e.caller||this.caller||"",user:s,header:Object.assign({custom:JSON.stringify(n)},this.partialHeaderFields,e.header),events:e.events.map(o=>Object.assign(Object.assign({},o),{_staging_flag:this.options.isolated}))}}}};ge.default=gt});var qr=b(xe=>{"use strict";Object.defineProperty(xe,"__esModule",{value:!0});xe.format=void 0;var Ii=/%[sdjo%]/g;function Li(t){return typeof t=="object"&&t!==null}function Mi(t,...e){let r=1,s=arguments,n=s.length,o=String(t).replace(Ii,a=>{if(a==="%%")return"%";if(r>=n)return a;switch(a){case"%s":return String(s[r++]);case"%d":return Number(s[r++]).toString();case"%j":try{return JSON.stringify(s[r++])}catch{return"[Circular]"}default:return a}});for(var i=s[r];r<n;i=s[++r])i===null||!Li(i)?o+=" "+i:o+=" "+JSON.stringify(i);return o}function Di(t,...e){var r;return typeof process=="object"&&typeof((r=process==null?void 0:process.versions)===null||r===void 0?void 0:r.node)=="string"?require("util").format(t,...e):Mi(t,...e)}xe.format=Di});var jr=b(Ae=>{"use strict";Object.defineProperty(Ae,"__esModule",{value:!0});Ae.Logger=void 0;var Ui=qr(),Ni={silent:0,error:1,warn:2,verbose:3},Fi={write(t,e){switch(t){case"error":console.error(e);break;case"warn":console.warn(e);break;default:console.log(e)}}},_t=class t{constructor(e){this.product=e,this.levelIndex=1,this.consumer=Fi,this.getLevelIndex=()=>this.levelIndex,this.getConsumer=()=>this.consumer}propagate(e){let r=new t(`${this.product}.${e}`);return r.getLevelIndex=()=>this.levelIndex,r.getConsumer=()=>this.consumer,r}setLevel(e){this.levelIndex=Ni[e]||1}log(e,r,...s){let n=(0,Ui.format)(r,...s);this.getConsumer().write(e,`[${this.product}] [${e}] ${n}`)}error(e,...r){this.getLevelIndex()>=1&&this.log("error",e,...r)}warn(e,...r){this.getLevelIndex()>=2&&this.log("warn",e,...r)}trace(e,...r){this.getLevelIndex()>=3&&this.log("trace",e,...r)}};Ae.Logger=_t});var Hr=b(X=>{"use strict";var Bi=X&&X.__createBinding||(Object.create?(function(t,e,r,s){s===void 0&&(s=r);var n=Object.getOwnPropertyDescriptor(e,r);(!n||("get"in n?!e.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,s,n)}):(function(t,e,r,s){s===void 0&&(s=r),t[s]=e[r]})),zi=X&&X.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Bi(e,t,r)};Object.defineProperty(X,"__esModule",{value:!0});zi(jr(),X)});var Ir=b(W=>{Object.defineProperty(W,"__esModule",{value:!0});W.SDK_VERSION=W.useInspectOption=W.pathMap=void 0;W.pathMap={WEBID_PATH:"/v1/user/webid",SSID_PATH:"/v1/user/ssid",REPORT_PATH:"/v1/list",ET:"/v1/list_test"};W.useInspectOption={sorted:!0,depth:99};W.SDK_VERSION="3.0.10"});var Mr=b(V=>{var $i=V&&V.__rest||function(t,e){var r={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(r[s]=t[s]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,s=Object.getOwnPropertySymbols(t);n<s.length;n++)e.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(t,s[n])&&(r[s[n]]=t[s[n]]);return r},Lr=V&&V.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(V,"__esModule",{value:!0});V.TeaSDK=void 0;var Wi=Lr(require("assert")),Vi=Lr(Ar()),Gi=Hr(),Ji=yt(),Ki=Ir(),bt=class{get meta(){return{caller:this.configManager.caller,user:this.configManager.userFields,header:this.configManager.headerFields,appId:this.configManager.appId,version:Ji.version,instanceID:this.instanceID,installedPlugins:[]}}constructor(e){this.plugins=[],this.instanceID=Math.random().toString(32).slice(2),this.config=r=>{this.plugins.map(s=>{var n;(n=s.beforeConfig)===null||n===void 0||n.call(s,r)}),this.configManager.configure(r),this.plugins.map(s=>{var n;(n=s.afterConfig)===null||n===void 0||n.call(s,r)})},this.logger=new Gi.Logger("Logsdk"),this.logger.setLevel(e.logLevel||"silent"),e.isolated&&this.logger.warn("Global isolation is enabled"),(0,Wi.default)(typeof(e==null?void 0:e.app_id)=="number"),this.configManager=new Vi.default(Object.assign(Object.assign({},e),{logger:this.logger})),this.logger.trace("initialized success with options %o",e),this.logger.trace("initialized sdk version %o",Ki.SDK_VERSION)}composeHookContext(e){let r=this;return{get metaInfo(){return r.meta},logger:this.logger.propagate(e.name),collect:(s,n)=>{this.trigger(Object.assign({events:s.map(o=>Object.assign(Object.assign({},o.extra),{event:o.name,params:JSON.stringify(o.params),time:Math.ceil(Date.now()/1e3)}))},n),{originatedBy:e.name})}}}trigger(...e){let[r,s]=e,n=this.configManager.compose(r,s);this.logger.trace("Composed event %o",n),this.plugins.map(o=>{var i,a;(i=o.beforeSendEvent)===null||i===void 0||i.call(o,n),(a=o.onSendEvent)===null||a===void 0||a.call(o,n)})}use(...e){this.plugins.push(...e),e.map(r=>{var s;(s=r.install)===null||s===void 0||s.call(r,this.composeHookContext(r)),this.logger.trace("Plugin %s installed",r.name)})}collectEvents(e,r,s,n){this.trigger({events:s,user:e,header:r,caller:n||this.configManager.caller})}getConfig(e){return this.configManager.get(e)}collect(e,r,s){let n=Array.isArray(e)?e.map(({name:u,params:l})=>({event:u,params:JSON.stringify(l)})):[{event:e,params:JSON.stringify(r)}],o=(Array.isArray(e)?r:s)||{},{custom:i}=o,a=$i(o,["custom"]);this.plugins.length||this.logger.warn("Dry run since no plugin applied"),this.trigger(Object.assign({events:n.map(u=>Object.assign(Object.assign({},u),{time:Math.ceil(Date.now()/1e3)})),customOfHeader:i},a))}};V.TeaSDK=bt});var F=b((N,qe)=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});var Dr=["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function Qi(t){return Dr.includes(t)}var Xi=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Blob","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","FormData","URLSearchParams","HTMLElement",...Dr];function Yi(t){return Xi.includes(t)}var Zi=["null","undefined","string","number","bigint","boolean","symbol"];function eo(t){return Zi.includes(t)}function te(t){return e=>typeof e===t}var{toString:Ur}=Object.prototype,_e=t=>{let e=Ur.call(t).slice(8,-1);if(/HTML\w+Element/.test(e)&&c.domElement(t))return"HTMLElement";if(Yi(e))return e},S=t=>e=>_e(e)===t;function c(t){if(t===null)return"null";switch(typeof t){case"undefined":return"undefined";case"string":return"string";case"number":return"number";case"boolean":return"boolean";case"function":return"Function";case"bigint":return"bigint";case"symbol":return"symbol";default:}if(c.observable(t))return"Observable";if(c.array(t))return"Array";if(c.buffer(t))return"Buffer";let e=_e(t);if(e)return e;if(t instanceof String||t instanceof Boolean||t instanceof Number)throw new TypeError("Please don't use object wrappers for primitive types");return"Object"}c.undefined=te("undefined");c.string=te("string");var to=te("number");c.number=t=>to(t)&&!c.nan(t);c.bigint=te("bigint");c.function_=te("function");c.null_=t=>t===null;c.class_=t=>c.function_(t)&&t.toString().startsWith("class ");c.boolean=t=>t===!0||t===!1;c.symbol=te("symbol");c.numericString=t=>c.string(t)&&!c.emptyStringOrWhitespace(t)&&!Number.isNaN(Number(t));c.array=(t,e)=>Array.isArray(t)?c.function_(e)?t.every(e):!0:!1;c.buffer=t=>{var e,r,s,n;return(n=(s=(r=(e=t)===null||e===void 0?void 0:e.constructor)===null||r===void 0?void 0:r.isBuffer)===null||s===void 0?void 0:s.call(r,t))!==null&&n!==void 0?n:!1};c.blob=t=>S("Blob")(t);c.nullOrUndefined=t=>c.null_(t)||c.undefined(t);c.object=t=>!c.null_(t)&&(typeof t=="object"||c.function_(t));c.iterable=t=>{var e;return c.function_((e=t)===null||e===void 0?void 0:e[Symbol.iterator])};c.asyncIterable=t=>{var e;return c.function_((e=t)===null||e===void 0?void 0:e[Symbol.asyncIterator])};c.generator=t=>{var e,r;return c.iterable(t)&&c.function_((e=t)===null||e===void 0?void 0:e.next)&&c.function_((r=t)===null||r===void 0?void 0:r.throw)};c.asyncGenerator=t=>c.asyncIterable(t)&&c.function_(t.next)&&c.function_(t.throw);c.nativePromise=t=>S("Promise")(t);var ro=t=>{var e,r;return c.function_((e=t)===null||e===void 0?void 0:e.then)&&c.function_((r=t)===null||r===void 0?void 0:r.catch)};c.promise=t=>c.nativePromise(t)||ro(t);c.generatorFunction=S("GeneratorFunction");c.asyncGeneratorFunction=t=>_e(t)==="AsyncGeneratorFunction";c.asyncFunction=t=>_e(t)==="AsyncFunction";c.boundFunction=t=>c.function_(t)&&!t.hasOwnProperty("prototype");c.regExp=S("RegExp");c.date=S("Date");c.error=S("Error");c.map=t=>S("Map")(t);c.set=t=>S("Set")(t);c.weakMap=t=>S("WeakMap")(t);c.weakSet=t=>S("WeakSet")(t);c.int8Array=S("Int8Array");c.uint8Array=S("Uint8Array");c.uint8ClampedArray=S("Uint8ClampedArray");c.int16Array=S("Int16Array");c.uint16Array=S("Uint16Array");c.int32Array=S("Int32Array");c.uint32Array=S("Uint32Array");c.float32Array=S("Float32Array");c.float64Array=S("Float64Array");c.bigInt64Array=S("BigInt64Array");c.bigUint64Array=S("BigUint64Array");c.arrayBuffer=S("ArrayBuffer");c.sharedArrayBuffer=S("SharedArrayBuffer");c.dataView=S("DataView");c.enumCase=(t,e)=>Object.values(e).includes(t);c.directInstanceOf=(t,e)=>Object.getPrototypeOf(t)===e.prototype;c.urlInstance=t=>S("URL")(t);c.urlString=t=>{if(!c.string(t))return!1;try{return new URL(t),!0}catch{return!1}};c.truthy=t=>!!t;c.falsy=t=>!t;c.nan=t=>Number.isNaN(t);c.primitive=t=>c.null_(t)||eo(typeof t);c.integer=t=>Number.isInteger(t);c.safeInteger=t=>Number.isSafeInteger(t);c.plainObject=t=>{if(Ur.call(t)!=="[object Object]")return!1;let e=Object.getPrototypeOf(t);return e===null||e===Object.getPrototypeOf({})};c.typedArray=t=>Qi(_e(t));var so=t=>c.safeInteger(t)&&t>=0;c.arrayLike=t=>!c.nullOrUndefined(t)&&!c.function_(t)&&so(t.length);c.inRange=(t,e)=>{if(c.number(e))return t>=Math.min(0,e)&&t<=Math.max(e,0);if(c.array(e)&&e.length===2)return t>=Math.min(...e)&&t<=Math.max(...e);throw new TypeError(`Invalid range: ${JSON.stringify(e)}`)};var no=1,io=["innerHTML","ownerDocument","style","attributes","nodeValue"];c.domElement=t=>c.object(t)&&t.nodeType===no&&c.string(t.nodeName)&&!c.plainObject(t)&&io.every(e=>e in t);c.observable=t=>{var e,r,s,n;return t?t===((r=(e=t)[Symbol.observable])===null||r===void 0?void 0:r.call(e))||t===((n=(s=t)["@@observable"])===null||n===void 0?void 0:n.call(s)):!1};c.nodeStream=t=>c.object(t)&&c.function_(t.pipe)&&!c.observable(t);c.infinite=t=>t===1/0||t===-1/0;var Nr=t=>e=>c.integer(e)&&Math.abs(e%2)===t;c.evenInteger=Nr(0);c.oddInteger=Nr(1);c.emptyArray=t=>c.array(t)&&t.length===0;c.nonEmptyArray=t=>c.array(t)&&t.length>0;c.emptyString=t=>c.string(t)&&t.length===0;var oo=t=>c.string(t)&&!/\S/.test(t);c.emptyStringOrWhitespace=t=>c.emptyString(t)||oo(t);c.nonEmptyString=t=>c.string(t)&&t.length>0;c.nonEmptyStringAndNotWhitespace=t=>c.string(t)&&!c.emptyStringOrWhitespace(t);c.emptyObject=t=>c.object(t)&&!c.map(t)&&!c.set(t)&&Object.keys(t).length===0;c.nonEmptyObject=t=>c.object(t)&&!c.map(t)&&!c.set(t)&&Object.keys(t).length>0;c.emptySet=t=>c.set(t)&&t.size===0;c.nonEmptySet=t=>c.set(t)&&t.size>0;c.emptyMap=t=>c.map(t)&&t.size===0;c.nonEmptyMap=t=>c.map(t)&&t.size>0;c.propertyKey=t=>c.any([c.string,c.number,c.symbol],t);c.formData=t=>S("FormData")(t);c.urlSearchParams=t=>S("URLSearchParams")(t);var Fr=(t,e,r)=>{if(!c.function_(e))throw new TypeError(`Invalid predicate: ${JSON.stringify(e)}`);if(r.length===0)throw new TypeError("Invalid number of values");return t.call(r,e)};c.any=(t,...e)=>(c.array(t)?t:[t]).some(s=>Fr(Array.prototype.some,s,e));c.all=(t,...e)=>Fr(Array.prototype.every,t,e);var _=(t,e,r,s={})=>{if(!t){let{multipleValues:n}=s,o=n?`received values of types ${[...new Set(r.map(i=>`\`${c(i)}\``))].join(", ")}`:`received value of type \`${c(r)}\``;throw new TypeError(`Expected value which is \`${e}\`, ${o}.`)}};N.assert={undefined:t=>_(c.undefined(t),"undefined",t),string:t=>_(c.string(t),"string",t),number:t=>_(c.number(t),"number",t),bigint:t=>_(c.bigint(t),"bigint",t),function_:t=>_(c.function_(t),"Function",t),null_:t=>_(c.null_(t),"null",t),class_:t=>_(c.class_(t),"Class",t),boolean:t=>_(c.boolean(t),"boolean",t),symbol:t=>_(c.symbol(t),"symbol",t),numericString:t=>_(c.numericString(t),"string with a number",t),array:(t,e)=>{_(c.array(t),"Array",t),e&&t.forEach(e)},buffer:t=>_(c.buffer(t),"Buffer",t),blob:t=>_(c.blob(t),"Blob",t),nullOrUndefined:t=>_(c.nullOrUndefined(t),"null or undefined",t),object:t=>_(c.object(t),"Object",t),iterable:t=>_(c.iterable(t),"Iterable",t),asyncIterable:t=>_(c.asyncIterable(t),"AsyncIterable",t),generator:t=>_(c.generator(t),"Generator",t),asyncGenerator:t=>_(c.asyncGenerator(t),"AsyncGenerator",t),nativePromise:t=>_(c.nativePromise(t),"native Promise",t),promise:t=>_(c.promise(t),"Promise",t),generatorFunction:t=>_(c.generatorFunction(t),"GeneratorFunction",t),asyncGeneratorFunction:t=>_(c.asyncGeneratorFunction(t),"AsyncGeneratorFunction",t),asyncFunction:t=>_(c.asyncFunction(t),"AsyncFunction",t),boundFunction:t=>_(c.boundFunction(t),"Function",t),regExp:t=>_(c.regExp(t),"RegExp",t),date:t=>_(c.date(t),"Date",t),error:t=>_(c.error(t),"Error",t),map:t=>_(c.map(t),"Map",t),set:t=>_(c.set(t),"Set",t),weakMap:t=>_(c.weakMap(t),"WeakMap",t),weakSet:t=>_(c.weakSet(t),"WeakSet",t),int8Array:t=>_(c.int8Array(t),"Int8Array",t),uint8Array:t=>_(c.uint8Array(t),"Uint8Array",t),uint8ClampedArray:t=>_(c.uint8ClampedArray(t),"Uint8ClampedArray",t),int16Array:t=>_(c.int16Array(t),"Int16Array",t),uint16Array:t=>_(c.uint16Array(t),"Uint16Array",t),int32Array:t=>_(c.int32Array(t),"Int32Array",t),uint32Array:t=>_(c.uint32Array(t),"Uint32Array",t),float32Array:t=>_(c.float32Array(t),"Float32Array",t),float64Array:t=>_(c.float64Array(t),"Float64Array",t),bigInt64Array:t=>_(c.bigInt64Array(t),"BigInt64Array",t),bigUint64Array:t=>_(c.bigUint64Array(t),"BigUint64Array",t),arrayBuffer:t=>_(c.arrayBuffer(t),"ArrayBuffer",t),sharedArrayBuffer:t=>_(c.sharedArrayBuffer(t),"SharedArrayBuffer",t),dataView:t=>_(c.dataView(t),"DataView",t),enumCase:(t,e)=>_(c.enumCase(t,e),"EnumCase",t),urlInstance:t=>_(c.urlInstance(t),"URL",t),urlString:t=>_(c.urlString(t),"string with a URL",t),truthy:t=>_(c.truthy(t),"truthy",t),falsy:t=>_(c.falsy(t),"falsy",t),nan:t=>_(c.nan(t),"NaN",t),primitive:t=>_(c.primitive(t),"primitive",t),integer:t=>_(c.integer(t),"integer",t),safeInteger:t=>_(c.safeInteger(t),"integer",t),plainObject:t=>_(c.plainObject(t),"plain object",t),typedArray:t=>_(c.typedArray(t),"TypedArray",t),arrayLike:t=>_(c.arrayLike(t),"array-like",t),domElement:t=>_(c.domElement(t),"HTMLElement",t),observable:t=>_(c.observable(t),"Observable",t),nodeStream:t=>_(c.nodeStream(t),"Node.js Stream",t),infinite:t=>_(c.infinite(t),"infinite number",t),emptyArray:t=>_(c.emptyArray(t),"empty array",t),nonEmptyArray:t=>_(c.nonEmptyArray(t),"non-empty array",t),emptyString:t=>_(c.emptyString(t),"empty string",t),emptyStringOrWhitespace:t=>_(c.emptyStringOrWhitespace(t),"empty string or whitespace",t),nonEmptyString:t=>_(c.nonEmptyString(t),"non-empty string",t),nonEmptyStringAndNotWhitespace:t=>_(c.nonEmptyStringAndNotWhitespace(t),"non-empty string and not whitespace",t),emptyObject:t=>_(c.emptyObject(t),"empty object",t),nonEmptyObject:t=>_(c.nonEmptyObject(t),"non-empty object",t),emptySet:t=>_(c.emptySet(t),"empty set",t),nonEmptySet:t=>_(c.nonEmptySet(t),"non-empty set",t),emptyMap:t=>_(c.emptyMap(t),"empty map",t),nonEmptyMap:t=>_(c.nonEmptyMap(t),"non-empty map",t),propertyKey:t=>_(c.propertyKey(t),"PropertyKey",t),formData:t=>_(c.formData(t),"FormData",t),urlSearchParams:t=>_(c.urlSearchParams(t),"URLSearchParams",t),evenInteger:t=>_(c.evenInteger(t),"even integer",t),oddInteger:t=>_(c.oddInteger(t),"odd integer",t),directInstanceOf:(t,e)=>_(c.directInstanceOf(t,e),"T",t),inRange:(t,e)=>_(c.inRange(t,e),"in range",t),any:(t,...e)=>_(c.any(t,...e),"predicate returns truthy for any value",e,{multipleValues:!0}),all:(t,...e)=>_(c.all(t,...e),"predicate returns truthy for all values",e,{multipleValues:!0})};Object.defineProperties(c,{class:{value:c.class_},function:{value:c.function_},null:{value:c.null_}});Object.defineProperties(N.assert,{class:{value:N.assert.class_},function:{value:N.assert.function_},null:{value:N.assert.null_}});N.default=c;qe.exports=c;qe.exports.default=c;qe.exports.assert=N.assert});var Br=b((Wu,wt)=>{"use strict";var je=class extends Error{constructor(e){super(e||"Promise was canceled"),this.name="CancelError"}get isCanceled(){return!0}},He=class t{static fn(e){return(...r)=>new t((s,n,o)=>{r.push(o),e(...r).then(s,n)})}constructor(e){this._cancelHandlers=[],this._isPending=!0,this._isCanceled=!1,this._rejectOnCancel=!0,this._promise=new Promise((r,s)=>{this._reject=s;let n=a=>{(!this._isCanceled||!i.shouldReject)&&(this._isPending=!1,r(a))},o=a=>{this._isPending=!1,s(a)},i=a=>{if(!this._isPending)throw new Error("The `onCancel` handler was attached after the promise settled.");this._cancelHandlers.push(a)};return Object.defineProperties(i,{shouldReject:{get:()=>this._rejectOnCancel,set:a=>{this._rejectOnCancel=a}}}),e(n,o,i)})}then(e,r){return this._promise.then(e,r)}catch(e){return this._promise.catch(e)}finally(e){return this._promise.finally(e)}cancel(e){if(!(!this._isPending||this._isCanceled)){if(this._isCanceled=!0,this._cancelHandlers.length>0)try{for(let r of this._cancelHandlers)r()}catch(r){this._reject(r);return}this._rejectOnCancel&&this._reject(new je(e))}}get isCanceled(){return this._isCanceled}};Object.setPrototypeOf(He.prototype,Promise.prototype);wt.exports=He;wt.exports.CancelError=je});var zr=b((Et,St)=>{"use strict";Object.defineProperty(Et,"__esModule",{value:!0});function ao(t){return t.encrypted}var vt=(t,e)=>{let r;typeof e=="function"?r={connect:e}:r=e;let s=typeof r.connect=="function",n=typeof r.secureConnect=="function",o=typeof r.close=="function",i=()=>{s&&r.connect(),ao(t)&&n&&(t.authorized?r.secureConnect():t.authorizationError||t.once("secureConnect",r.secureConnect)),o&&t.once("close",r.close)};t.writable&&!t.connecting?i():t.connecting?t.once("connect",i):t.destroyed&&o&&r.close(t._hadError)};Et.default=vt;St.exports=vt;St.exports.default=vt});var $r=b((Ot,Rt)=>{"use strict";Object.defineProperty(Ot,"__esModule",{value:!0});var co=zr(),uo=require("util"),lo=Number(process.versions.node.split(".")[0]),Pt=t=>{if(t.timings)return t.timings;let e={start:Date.now(),socket:void 0,lookup:void 0,connect:void 0,secureConnect:void 0,upload:void 0,response:void 0,end:void 0,error:void 0,abort:void 0,phases:{wait:void 0,dns:void 0,tcp:void 0,tls:void 0,request:void 0,firstByte:void 0,download:void 0,total:void 0}};t.timings=e;let r=a=>{let u=a.emit.bind(a);a.emit=(l,...m)=>(l==="error"&&(e.error=Date.now(),e.phases.total=e.error-e.start,a.emit=u),u(l,...m))};r(t);let s=()=>{e.abort=Date.now(),(!e.response||lo>=13)&&(e.phases.total=Date.now()-e.start)};t.prependOnceListener("abort",s);let n=a=>{if(e.socket=Date.now(),e.phases.wait=e.socket-e.start,uo.types.isProxy(a))return;let u=()=>{e.lookup=Date.now(),e.phases.dns=e.lookup-e.socket};a.prependOnceListener("lookup",u),co.default(a,{connect:()=>{e.connect=Date.now(),e.lookup===void 0&&(a.removeListener("lookup",u),e.lookup=e.connect,e.phases.dns=e.lookup-e.socket),e.phases.tcp=e.connect-e.lookup},secureConnect:()=>{e.secureConnect=Date.now(),e.phases.tls=e.secureConnect-e.connect}})};t.socket?n(t.socket):t.prependOnceListener("socket",n);let o=()=>{var a;e.upload=Date.now(),e.phases.request=e.upload-((a=e.secureConnect)!==null&&a!==void 0?a:e.connect)};return(typeof t.writableFinished=="boolean"?t.writableFinished:t.finished&&t.outputSize===0&&(!t.socket||t.socket.writableLength===0))?o():t.prependOnceListener("finish",o),t.prependOnceListener("response",a=>{e.response=Date.now(),e.phases.firstByte=e.response-e.upload,a.timings=e,r(a),a.prependOnceListener("end",()=>{e.end=Date.now(),e.phases.download=e.end-e.response,e.phases.total=e.end-e.start}),a.prependOnceListener("aborted",s)}),e};Ot.default=Pt;Rt.exports=Pt;Rt.exports.default=Pt});var Xr=b((Vu,Tt)=>{"use strict";var{V4MAPPED:ho,ADDRCONFIG:fo,ALL:Qr,promises:{Resolver:Wr},lookup:po}=require("dns"),{promisify:kt}=require("util"),mo=require("os"),re=Symbol("cacheableLookupCreateConnection"),Ct=Symbol("cacheableLookupInstance"),Vr=Symbol("expires"),yo=typeof Qr=="number",Gr=t=>{if(!(t&&typeof t.createConnection=="function"))throw new Error("Expected an Agent instance as the first argument")},go=t=>{for(let e of t)e.family!==6&&(e.address=`::ffff:${e.address}`,e.family=6)},Jr=()=>{let t=!1,e=!1;for(let r of Object.values(mo.networkInterfaces()))for(let s of r)if(!s.internal&&(s.family==="IPv6"?e=!0:t=!0,t&&e))return{has4:t,has6:e};return{has4:t,has6:e}},_o=t=>Symbol.iterator in t,Kr={ttl:!0},bo={all:!0},Ie=class{constructor({cache:e=new Map,maxTtl:r=1/0,fallbackDuration:s=3600,errorTtl:n=.15,resolver:o=new Wr,lookup:i=po}={}){if(this.maxTtl=r,this.errorTtl=n,this._cache=e,this._resolver=o,this._dnsLookup=kt(i),this._resolver instanceof Wr?(this._resolve4=this._resolver.resolve4.bind(this._resolver),this._resolve6=this._resolver.resolve6.bind(this._resolver)):(this._resolve4=kt(this._resolver.resolve4.bind(this._resolver)),this._resolve6=kt(this._resolver.resolve6.bind(this._resolver))),this._iface=Jr(),this._pending={},this._nextRemovalTime=!1,this._hostnamesToFallback=new Set,s<1)this._fallback=!1;else{this._fallback=!0;let a=setInterval(()=>{this._hostnamesToFallback.clear()},s*1e3);a.unref&&a.unref()}this.lookup=this.lookup.bind(this),this.lookupAsync=this.lookupAsync.bind(this)}set servers(e){this.clear(),this._resolver.setServers(e)}get servers(){return this._resolver.getServers()}lookup(e,r,s){if(typeof r=="function"?(s=r,r={}):typeof r=="number"&&(r={family:r}),!s)throw new Error("Callback must be a function.");this.lookupAsync(e,r).then(n=>{r.all?s(null,n):s(null,n.address,n.family,n.expires,n.ttl)},s)}async lookupAsync(e,r={}){typeof r=="number"&&(r={family:r});let s=await this.query(e);if(r.family===6){let n=s.filter(o=>o.family===6);r.hints&ho&&(yo&&r.hints&Qr||n.length===0)?go(s):s=n}else r.family===4&&(s=s.filter(n=>n.family===4));if(r.hints&fo){let{_iface:n}=this;s=s.filter(o=>o.family===6?n.has6:n.has4)}if(s.length===0){let n=new Error(`cacheableLookup ENOTFOUND ${e}`);throw n.code="ENOTFOUND",n.hostname=e,n}return r.all?s:s[0]}async query(e){let r=await this._cache.get(e);if(!r){let s=this._pending[e];if(s)r=await s;else{let n=this.queryAndCache(e);this._pending[e]=n;try{r=await n}finally{delete this._pending[e]}}}return r=r.map(s=>({...s})),r}async _resolve(e){let r=async l=>{try{return await l}catch(m){if(m.code==="ENODATA"||m.code==="ENOTFOUND")return[];throw m}},[s,n]=await Promise.all([this._resolve4(e,Kr),this._resolve6(e,Kr)].map(l=>r(l))),o=0,i=0,a=0,u=Date.now();for(let l of s)l.family=4,l.expires=u+l.ttl*1e3,o=Math.max(o,l.ttl);for(let l of n)l.family=6,l.expires=u+l.ttl*1e3,i=Math.max(i,l.ttl);return s.length>0?n.length>0?a=Math.min(o,i):a=o:a=i,{entries:[...s,...n],cacheTtl:a}}async _lookup(e){try{return{entries:await this._dnsLookup(e,{all:!0}),cacheTtl:0}}catch{return{entries:[],cacheTtl:0}}}async _set(e,r,s){if(this.maxTtl>0&&s>0){s=Math.min(s,this.maxTtl)*1e3,r[Vr]=Date.now()+s;try{await this._cache.set(e,r,s)}catch(n){this.lookupAsync=async()=>{let o=new Error("Cache Error. Please recreate the CacheableLookup instance.");throw o.cause=n,o}}_o(this._cache)&&this._tick(s)}}async queryAndCache(e){if(this._hostnamesToFallback.has(e))return this._dnsLookup(e,bo);let r=await this._resolve(e);r.entries.length===0&&this._fallback&&(r=await this._lookup(e),r.entries.length!==0&&this._hostnamesToFallback.add(e));let s=r.entries.length===0?this.errorTtl:r.cacheTtl;return await this._set(e,r.entries,s),r.entries}_tick(e){let r=this._nextRemovalTime;(!r||e<r)&&(clearTimeout(this._removalTimeout),this._nextRemovalTime=e,this._removalTimeout=setTimeout(()=>{this._nextRemovalTime=!1;let s=1/0,n=Date.now();for(let[o,i]of this._cache){let a=i[Vr];n>=a?this._cache.delete(o):a<s&&(s=a)}s!==1/0&&this._tick(s-n)},e),this._removalTimeout.unref&&this._removalTimeout.unref())}install(e){if(Gr(e),re in e)throw new Error("CacheableLookup has been already installed");e[re]=e.createConnection,e[Ct]=this,e.createConnection=(r,s)=>("lookup"in r||(r.lookup=this.lookup),e[re](r,s))}uninstall(e){if(Gr(e),e[re]){if(e[Ct]!==this)throw new Error("The agent is not owned by this CacheableLookup instance");e.createConnection=e[re],delete e[re],delete e[Ct]}}updateInterfaceInfo(){let{_iface:e}=this;this._iface=Jr(),(e.has4&&!this._iface.has4||e.has6&&!this._iface.has6)&&this._cache.clear()}clear(e){if(e){this._cache.delete(e);return}this._cache.clear()}};Tt.exports=Ie;Tt.exports.default=Ie});var es=b((Gu,Zr)=>{"use strict";var wo="text/plain",vo="us-ascii",Yr=(t,e)=>e.some(r=>r instanceof RegExp?r.test(t):r===t),Eo=(t,{stripHash:e})=>{let r=/^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(t);if(!r)throw new Error(`Invalid URL: ${t}`);let{type:s,data:n,hash:o}=r.groups,i=s.split(";");o=e?"":o;let a=!1;i[i.length-1]==="base64"&&(i.pop(),a=!0);let u=(i.shift()||"").toLowerCase(),m=[...i.map(h=>{let[y,p=""]=h.split("=").map(g=>g.trim());return y==="charset"&&(p=p.toLowerCase(),p===vo)?"":`${y}${p?`=${p}`:""}`}).filter(Boolean)];return a&&m.push("base64"),(m.length!==0||u&&u!==wo)&&m.unshift(u),`data:${m.join(";")},${a?n.trim():n}${o?`#${o}`:""}`},So=(t,e)=>{if(e={defaultProtocol:"http:",normalizeProtocol:!0,forceHttp:!1,forceHttps:!1,stripAuthentication:!0,stripHash:!1,stripTextFragment:!0,stripWWW:!0,removeQueryParameters:[/^utm_\w+/i],removeTrailingSlash:!0,removeSingleSlash:!0,removeDirectoryIndex:!1,sortQueryParameters:!0,...e},t=t.trim(),/^data:/i.test(t))return Eo(t,e);if(/^view-source:/i.test(t))throw new Error("`view-source:` is not supported as it is a non-standard protocol");let r=t.startsWith("//");!r&&/^\.*\//.test(t)||(t=t.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,e.defaultProtocol));let n=new URL(t);if(e.forceHttp&&e.forceHttps)throw new Error("The `forceHttp` and `forceHttps` options cannot be used together");if(e.forceHttp&&n.protocol==="https:"&&(n.protocol="http:"),e.forceHttps&&n.protocol==="http:"&&(n.protocol="https:"),e.stripAuthentication&&(n.username="",n.password=""),e.stripHash?n.hash="":e.stripTextFragment&&(n.hash=n.hash.replace(/#?:~:text.*?$/i,"")),n.pathname&&(n.pathname=n.pathname.replace(/(?<!\b(?:[a-z][a-z\d+\-.]{1,50}:))\/{2,}/g,"/")),n.pathname)try{n.pathname=decodeURI(n.pathname)}catch{}if(e.removeDirectoryIndex===!0&&(e.removeDirectoryIndex=[/^index\.[a-z]+$/]),Array.isArray(e.removeDirectoryIndex)&&e.removeDirectoryIndex.length>0){let i=n.pathname.split("/"),a=i[i.length-1];Yr(a,e.removeDirectoryIndex)&&(i=i.slice(0,i.length-1),n.pathname=i.slice(1).join("/")+"/")}if(n.hostname&&(n.hostname=n.hostname.replace(/\.$/,""),e.stripWWW&&/^www\.(?!www\.)(?:[a-z\-\d]{1,63})\.(?:[a-z.\-\d]{2,63})$/.test(n.hostname)&&(n.hostname=n.hostname.replace(/^www\./,""))),Array.isArray(e.removeQueryParameters))for(let i of[...n.searchParams.keys()])Yr(i,e.removeQueryParameters)&&n.searchParams.delete(i);e.removeQueryParameters===!0&&(n.search=""),e.sortQueryParameters&&n.searchParams.sort(),e.removeTrailingSlash&&(n.pathname=n.pathname.replace(/\/$/,""));let o=t;return t=n.toString(),!e.removeSingleSlash&&n.pathname==="/"&&!o.endsWith("/")&&n.hash===""&&(t=t.replace(/\/$/,"")),(e.removeTrailingSlash||n.pathname==="/")&&n.hash===""&&e.removeSingleSlash&&(t=t.replace(/\/$/,"")),r&&!e.normalizeProtocol&&(t=t.replace(/^http:\/\//,"//")),e.stripProtocol&&(t=t.replace(/^(?:https?:)?\/\//,"")),t};Zr.exports=So});var ss=b((Ju,rs)=>{rs.exports=ts;function ts(t,e){if(t&&e)return ts(t)(e);if(typeof t!="function")throw new TypeError("need wrapper function");return Object.keys(t).forEach(function(s){r[s]=t[s]}),r;function r(){for(var s=new Array(arguments.length),n=0;n<s.length;n++)s[n]=arguments[n];var o=t.apply(this,s),i=s[s.length-1];return typeof o=="function"&&o!==i&&Object.keys(i).forEach(function(a){o[a]=i[a]}),o}}});var At=b((Ku,xt)=>{var ns=ss();xt.exports=ns(Le);xt.exports.strict=ns(is);Le.proto=Le(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return Le(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return is(this)},configurable:!0})});function Le(t){var e=function(){return e.called?e.value:(e.called=!0,e.value=t.apply(this,arguments))};return e.called=!1,e}function is(t){var e=function(){if(e.called)throw new Error(e.onceError);return e.called=!0,e.value=t.apply(this,arguments)},r=t.name||"Function wrapped with `once`";return e.onceError=r+" shouldn't be called more than once",e.called=!1,e}});var cs=b((Qu,as)=>{var Po=At(),Oo=function(){},Ro=global.Bare?queueMicrotask:process.nextTick.bind(process),ko=function(t){return t.setHeader&&typeof t.abort=="function"},Co=function(t){return t.stdio&&Array.isArray(t.stdio)&&t.stdio.length===3},os=function(t,e,r){if(typeof e=="function")return os(t,null,e);e||(e={}),r=Po(r||Oo);var s=t._writableState,n=t._readableState,o=e.readable||e.readable!==!1&&t.readable,i=e.writable||e.writable!==!1&&t.writable,a=!1,u=function(){t.writable||l()},l=function(){i=!1,o||r.call(t)},m=function(){o=!1,i||r.call(t)},h=function(f){r.call(t,f?new Error("exited with error code: "+f):null)},y=function(f){r.call(t,f)},p=function(){Ro(g)},g=function(){if(!a){if(o&&!(n&&n.ended&&!n.destroyed))return r.call(t,new Error("premature close"));if(i&&!(s&&s.ended&&!s.destroyed))return r.call(t,new Error("premature close"))}},w=function(){t.req.on("finish",l)};return ko(t)?(t.on("complete",l),t.on("abort",p),t.req?w():t.on("request",w)):i&&!s&&(t.on("end",u),t.on("close",u)),Co(t)&&t.on("exit",h),t.on("end",m),t.on("finish",l),e.error!==!1&&t.on("error",y),t.on("close",p),function(){a=!0,t.removeListener("complete",l),t.removeListener("abort",p),t.removeListener("request",w),t.req&&t.req.removeListener("finish",l),t.removeListener("end",u),t.removeListener("close",u),t.removeListener("finish",l),t.removeListener("exit",h),t.removeListener("end",m),t.removeListener("error",y),t.removeListener("close",p)}};as.exports=os});var ds=b((Xu,ls)=>{var To=At(),xo=cs(),Me;try{Me=require("fs")}catch{}var be=function(){},Ao=typeof process>"u"?!1:/^v?\.0/.test(process.version),De=function(t){return typeof t=="function"},qo=function(t){return!Ao||!Me?!1:(t instanceof(Me.ReadStream||be)||t instanceof(Me.WriteStream||be))&&De(t.close)},jo=function(t){return t.setHeader&&De(t.abort)},Ho=function(t,e,r,s){s=To(s);var n=!1;t.on("close",function(){n=!0}),xo(t,{readable:e,writable:r},function(i){if(i)return s(i);n=!0,s()});var o=!1;return function(i){if(!n&&!o){if(o=!0,qo(t))return t.close(be);if(jo(t))return t.abort();if(De(t.destroy))return t.destroy();s(i||new Error("stream was destroyed"))}}},us=function(t){t()},Io=function(t,e){return t.pipe(e)},Lo=function(){var t=Array.prototype.slice.call(arguments),e=De(t[t.length-1]||be)&&t.pop()||be;if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new Error("pump requires two streams per minimum");var r,s=t.map(function(n,o){var i=o<t.length-1,a=o>0;return Ho(n,i,a,function(u){r||(r=u),u&&s.forEach(us),!i&&(s.forEach(us),e(r))})});return t.reduce(Io)};ls.exports=Lo});var fs=b((Yu,hs)=>{"use strict";var{PassThrough:Mo}=require("stream");hs.exports=t=>{t={...t};let{array:e}=t,{encoding:r}=t,s=r==="buffer",n=!1;e?n=!(r||s):r=r||"utf8",s&&(r=null);let o=new Mo({objectMode:n});r&&o.setEncoding(r);let i=0,a=[];return o.on("data",u=>{a.push(u),n?i=a.length:i+=u.length}),o.getBufferedValue=()=>e?a:s?Buffer.concat(a,i):a.join(""),o.getBufferedLength=()=>i,o}});var ps=b((Zu,se)=>{"use strict";var{constants:Do}=require("buffer"),Uo=ds(),No=fs(),Ue=class extends Error{constructor(){super("maxBuffer exceeded"),this.name="MaxBufferError"}};async function Ne(t,e){if(!t)return Promise.reject(new Error("Expected a stream"));e={maxBuffer:1/0,...e};let{maxBuffer:r}=e,s;return await new Promise((n,o)=>{let i=a=>{a&&s.getBufferedLength()<=Do.MAX_LENGTH&&(a.bufferedData=s.getBufferedValue()),o(a)};s=Uo(t,No(e),a=>{if(a){i(a);return}n()}),s.on("data",()=>{s.getBufferedLength()>r&&i(new Ue)})}),s.getBufferedValue()}se.exports=Ne;se.exports.default=Ne;se.exports.buffer=(t,e)=>Ne(t,{...e,encoding:"buffer"});se.exports.array=(t,e)=>Ne(t,{...e,array:!0});se.exports.MaxBufferError=Ue});var ys=b((tl,ms)=>{"use strict";var Fo=new Set([200,203,204,206,300,301,308,404,405,410,414,501]),Bo=new Set([200,203,204,300,301,302,303,307,308,404,405,410,414,501]),zo=new Set([500,502,503,504]),$o={date:!0,connection:!0,"keep-alive":!0,"proxy-authenticate":!0,"proxy-authorization":!0,te:!0,trailer:!0,"transfer-encoding":!0,upgrade:!0},Wo={"content-length":!0,"content-encoding":!0,"transfer-encoding":!0,"content-range":!0};function B(t){let e=parseInt(t,10);return isFinite(e)?e:0}function Vo(t){return t?zo.has(t.status):!0}function qt(t){let e={};if(!t)return e;let r=t.trim().split(/,/);for(let s of r){let[n,o]=s.split(/=/,2);e[n.trim()]=o===void 0?!0:o.trim().replace(/^"|"$/g,"")}return e}function Go(t){let e=[];for(let r in t){let s=t[r];e.push(s===!0?r:r+"="+s)}if(e.length)return e.join(", ")}ms.exports=class{constructor(e,r,{shared:s,cacheHeuristic:n,immutableMinTimeToLive:o,ignoreCargoCult:i,_fromObject:a}={}){if(a){this._fromObject(a);return}if(!r||!r.headers)throw Error("Response headers missing");this._assertRequestHasHeaders(e),this._responseTime=this.now(),this._isShared=s!==!1,this._ignoreCargoCult=!!i,this._cacheHeuristic=n!==void 0?n:.1,this._immutableMinTtl=o!==void 0?o:24*3600*1e3,this._status="status"in r?r.status:200,this._resHeaders=r.headers,this._rescc=qt(r.headers["cache-control"]),this._method="method"in e?e.method:"GET",this._url=e.url,this._host=e.headers.host,this._noAuthorization=!e.headers.authorization,this._reqHeaders=r.headers.vary?e.headers:null,this._reqcc=qt(e.headers["cache-control"]),this._ignoreCargoCult&&"pre-check"in this._rescc&&"post-check"in this._rescc&&(delete this._rescc["pre-check"],delete this._rescc["post-check"],delete this._rescc["no-cache"],delete this._rescc["no-store"],delete this._rescc["must-revalidate"],this._resHeaders=Object.assign({},this._resHeaders,{"cache-control":Go(this._rescc)}),delete this._resHeaders.expires,delete this._resHeaders.pragma),r.headers["cache-control"]==null&&/no-cache/.test(r.headers.pragma)&&(this._rescc["no-cache"]=!0)}now(){return Date.now()}storable(){return!!(!this._reqcc["no-store"]&&(this._method==="GET"||this._method==="HEAD"||this._method==="POST"&&this._hasExplicitExpiration())&&Bo.has(this._status)&&!this._rescc["no-store"]&&(!this._isShared||!this._rescc.private)&&(!this._isShared||this._noAuthorization||this._allowsStoringAuthenticated())&&(this._resHeaders.expires||this._rescc["max-age"]||this._isShared&&this._rescc["s-maxage"]||this._rescc.public||Fo.has(this._status)))}_hasExplicitExpiration(){return!!(this._isShared&&this._rescc["s-maxage"]||this._rescc["max-age"]||this._resHeaders.expires)}_assertRequestHasHeaders(e){if(!e||!e.headers)throw Error("Request headers missing")}satisfiesWithoutRevalidation(e){return!this.evaluateRequest(e).revalidation}_evaluateRequestHitResult(e){return{response:{headers:this.responseHeaders()},revalidation:e}}_evaluateRequestRevalidation(e,r){return{synchronous:r,headers:this.revalidationHeaders(e)}}_evaluateRequestMissResult(e){return{response:void 0,revalidation:this._evaluateRequestRevalidation(e,!0)}}evaluateRequest(e){if(this._assertRequestHasHeaders(e),this._rescc["must-revalidate"])return this._evaluateRequestMissResult(e);if(!this._requestMatches(e,!1))return this._evaluateRequestMissResult(e);let r=qt(e.headers["cache-control"]);return r["no-cache"]||/no-cache/.test(e.headers.pragma)?this._evaluateRequestMissResult(e):r["max-age"]&&this.age()>B(r["max-age"])?this._evaluateRequestMissResult(e):r["min-fresh"]&&this.maxAge()-this.age()<B(r["min-fresh"])?this._evaluateRequestMissResult(e):this.stale()?"max-stale"in r&&(r["max-stale"]===!0||r["max-stale"]>this.age()-this.maxAge())?this._evaluateRequestHitResult(void 0):this.useStaleWhileRevalidate()?this._evaluateRequestHitResult(this._evaluateRequestRevalidation(e,!1)):this._evaluateRequestMissResult(e):this._evaluateRequestHitResult(void 0)}_requestMatches(e,r){return!!((!this._url||this._url===e.url)&&this._host===e.headers.host&&(!e.method||this._method===e.method||r&&e.method==="HEAD")&&this._varyMatches(e))}_allowsStoringAuthenticated(){return!!(this._rescc["must-revalidate"]||this._rescc.public||this._rescc["s-maxage"])}_varyMatches(e){if(!this._resHeaders.vary)return!0;if(this._resHeaders.vary==="*")return!1;let r=this._resHeaders.vary.trim().toLowerCase().split(/\s*,\s*/);for(let s of r)if(e.headers[s]!==this._reqHeaders[s])return!1;return!0}_copyWithoutHopByHopHeaders(e){let r={};for(let s in e)$o[s]||(r[s]=e[s]);if(e.connection){let s=e.connection.trim().split(/\s*,\s*/);for(let n of s)delete r[n]}if(r.warning){let s=r.warning.split(/,/).filter(n=>!/^\s*1[0-9][0-9]/.test(n));s.length?r.warning=s.join(",").trim():delete r.warning}return r}responseHeaders(){let e=this._copyWithoutHopByHopHeaders(this._resHeaders),r=this.age();return r>3600*24&&!this._hasExplicitExpiration()&&this.maxAge()>3600*24&&(e.warning=(e.warning?`${e.warning}, `:"")+'113 - "rfc7234 5.5.4"'),e.age=`${Math.round(r)}`,e.date=new Date(this.now()).toUTCString(),e}date(){let e=Date.parse(this._resHeaders.date);return isFinite(e)?e:this._responseTime}age(){let e=this._ageValue(),r=(this.now()-this._responseTime)/1e3;return e+r}_ageValue(){return B(this._resHeaders.age)}maxAge(){if(!this.storable()||this._rescc["no-cache"]||this._isShared&&this._resHeaders["set-cookie"]&&!this._rescc.public&&!this._rescc.immutable||this._resHeaders.vary==="*")return 0;if(this._isShared){if(this._rescc["proxy-revalidate"])return 0;if(this._rescc["s-maxage"])return B(this._rescc["s-maxage"])}if(this._rescc["max-age"])return B(this._rescc["max-age"]);let e=this._rescc.immutable?this._immutableMinTtl:0,r=this.date();if(this._resHeaders.expires){let s=Date.parse(this._resHeaders.expires);return Number.isNaN(s)||s<r?0:Math.max(e,(s-r)/1e3)}if(this._resHeaders["last-modified"]){let s=Date.parse(this._resHeaders["last-modified"]);if(isFinite(s)&&r>s)return Math.max(e,(r-s)/1e3*this._cacheHeuristic)}return e}timeToLive(){let e=this.maxAge()-this.age(),r=e+B(this._rescc["stale-if-error"]),s=e+B(this._rescc["stale-while-revalidate"]);return Math.round(Math.max(0,e,r,s)*1e3)}stale(){return this.maxAge()<=this.age()}_useStaleIfError(){return this.maxAge()+B(this._rescc["stale-if-error"])>this.age()}useStaleWhileRevalidate(){let e=B(this._rescc["stale-while-revalidate"]);return e>0&&this.maxAge()+e>this.age()}static fromObject(e){return new this(void 0,void 0,{_fromObject:e})}_fromObject(e){if(this._responseTime)throw Error("Reinitialized");if(!e||e.v!==1)throw Error("Invalid serialization");this._responseTime=e.t,this._isShared=e.sh,this._cacheHeuristic=e.ch,this._immutableMinTtl=e.imm!==void 0?e.imm:24*3600*1e3,this._ignoreCargoCult=!!e.icc,this._status=e.st,this._resHeaders=e.resh,this._rescc=e.rescc,this._method=e.m,this._url=e.u,this._host=e.h,this._noAuthorization=e.a,this._reqHeaders=e.reqh,this._reqcc=e.reqcc}toObject(){return{v:1,t:this._responseTime,sh:this._isShared,ch:this._cacheHeuristic,imm:this._immutableMinTtl,icc:this._ignoreCargoCult,st:this._status,resh:this._resHeaders,rescc:this._rescc,m:this._method,u:this._url,h:this._host,a:this._noAuthorization,reqh:this._reqHeaders,reqcc:this._reqcc}}revalidationHeaders(e){this._assertRequestHasHeaders(e);let r=this._copyWithoutHopByHopHeaders(e.headers);if(delete r["if-range"],!this._requestMatches(e,!0)||!this.storable())return delete r["if-none-match"],delete r["if-modified-since"],r;if(this._resHeaders.etag&&(r["if-none-match"]=r["if-none-match"]?`${r["if-none-match"]}, ${this._resHeaders.etag}`:this._resHeaders.etag),r["accept-ranges"]||r["if-match"]||r["if-unmodified-since"]||this._method&&this._method!="GET"){if(delete r["if-modified-since"],r["if-none-match"]){let n=r["if-none-match"].split(/,/).filter(o=>!/^\s*W\//.test(o));n.length?r["if-none-match"]=n.join(",").trim():delete r["if-none-match"]}}else this._resHeaders["last-modified"]&&!r["if-modified-since"]&&(r["if-modified-since"]=this._resHeaders["last-modified"]);return r}revalidatedPolicy(e,r){if(this._assertRequestHasHeaders(e),this._useStaleIfError()&&Vo(r))return{policy:this,modified:!1,matches:!0};if(!r||!r.headers)throw Error("Response headers missing");let s=!1;r.status!==void 0&&r.status!=304?s=!1:r.headers.etag&&!/^\s*W\//.test(r.headers.etag)?s=this._resHeaders.etag&&this._resHeaders.etag.replace(/^\s*W\//,"")===r.headers.etag:this._resHeaders.etag&&r.headers.etag?s=this._resHeaders.etag.replace(/^\s*W\//,"")===r.headers.etag.replace(/^\s*W\//,""):this._resHeaders["last-modified"]?s=this._resHeaders["last-modified"]===r.headers["last-modified"]:!this._resHeaders.etag&&!this._resHeaders["last-modified"]&&!r.headers.etag&&!r.headers["last-modified"]&&(s=!0);let n={shared:this._isShared,cacheHeuristic:this._cacheHeuristic,immutableMinTimeToLive:this._immutableMinTtl,ignoreCargoCult:this._ignoreCargoCult};if(!s)return{policy:new this.constructor(e,r,n),modified:r.status!=304,matches:!1};let o={};for(let a in this._resHeaders)o[a]=a in r.headers&&!Wo[a]?r.headers[a]:this._resHeaders[a];let i=Object.assign({},r,{status:this._status,method:this._method,headers:o});return{policy:new this.constructor(e,i,n),modified:!1,matches:!0}}}});var Fe=b((rl,gs)=>{"use strict";gs.exports=t=>{let e={};for(let[r,s]of Object.entries(t))e[r.toLowerCase()]=s;return e}});var bs=b((sl,_s)=>{"use strict";var Jo=require("stream").Readable,Ko=Fe(),jt=class extends Jo{constructor(e,r,s,n){if(typeof e!="number")throw new TypeError("Argument `statusCode` should be a number");if(typeof r!="object")throw new TypeError("Argument `headers` should be an object");if(!(s instanceof Buffer))throw new TypeError("Argument `body` should be a buffer");if(typeof n!="string")throw new TypeError("Argument `url` should be a string");super(),this.statusCode=e,this.headers=Ko(r),this.body=s,this.url=n}_read(){this.push(this.body),this.push(null)}};_s.exports=jt});var vs=b((nl,ws)=>{"use strict";var Qo=["destroy","setTimeout","socket","headers","trailers","rawHeaders","statusCode","httpVersion","httpVersionMinor","httpVersionMajor","rawTrailers","statusMessage"];ws.exports=(t,e)=>{let r=new Set(Object.keys(t).concat(Qo));for(let s of r)s in e||(e[s]=typeof t[s]=="function"?t[s].bind(t):t[s])}});var Ss=b((il,Es)=>{"use strict";var Xo=require("stream").PassThrough,Yo=vs(),Zo=t=>{if(!(t&&t.pipe))throw new TypeError("Parameter `response` must be a response stream.");let e=new Xo;return Yo(t,e),t.pipe(e)};Es.exports=Zo});var Ps=b(Ht=>{Ht.stringify=function t(e){if(typeof e>"u")return e;if(e&&Buffer.isBuffer(e))return JSON.stringify(":base64:"+e.toString("base64"));if(e&&e.toJSON&&(e=e.toJSON()),e&&typeof e=="object"){var r="",s=Array.isArray(e);r=s?"[":"{";var n=!0;for(var o in e){var i=typeof e[o]=="function"||!s&&typeof e[o]>"u";Object.hasOwnProperty.call(e,o)&&!i&&(n||(r+=","),n=!1,s?e[o]==null?r+="null":r+=t(e[o]):e[o]!==void 0&&(r+=t(o)+":"+t(e[o])))}return r+=s?"]":"}",r}else return typeof e=="string"?JSON.stringify(/^:/.test(e)?":"+e:e):typeof e>"u"?"null":JSON.stringify(e)};Ht.parse=function(t){return JSON.parse(t,function(e,r){return typeof r=="string"?/^:base64:/.test(r)?Buffer.from(r.substring(8),"base64"):/^:/.test(r)?r.substring(1):r:r})}});var Cs=b((al,ks)=>{"use strict";var ea=require("events"),Os=Ps(),ta=t=>{let e={redis:"@keyv/redis",rediss:"@keyv/redis",mongodb:"@keyv/mongo",mongo:"@keyv/mongo",sqlite:"@keyv/sqlite",postgresql:"@keyv/postgres",postgres:"@keyv/postgres",mysql:"@keyv/mysql",etcd:"@keyv/etcd",offline:"@keyv/offline",tiered:"@keyv/tiered"};if(t.adapter||t.uri){let r=t.adapter||/^[^:+]*/.exec(t.uri)[0];return new(require(e[r]))(t)}return new Map},Rs=["sqlite","postgres","mysql","mongo","redis","tiered"],It=class extends ea{constructor(e,{emitErrors:r=!0,...s}={}){if(super(),this.opts={namespace:"keyv",serialize:Os.stringify,deserialize:Os.parse,...typeof e=="string"?{uri:e}:e,...s},!this.opts.store){let o={...this.opts};this.opts.store=ta(o)}if(this.opts.compression){let o=this.opts.compression;this.opts.serialize=o.serialize.bind(o),this.opts.deserialize=o.deserialize.bind(o)}typeof this.opts.store.on=="function"&&r&&this.opts.store.on("error",o=>this.emit("error",o)),this.opts.store.namespace=this.opts.namespace;let n=o=>async function*(){for await(let[i,a]of typeof o=="function"?o(this.opts.store.namespace):o){let u=await this.opts.deserialize(a);if(!(this.opts.store.namespace&&!i.includes(this.opts.store.namespace))){if(typeof u.expires=="number"&&Date.now()>u.expires){this.delete(i);continue}yield[this._getKeyUnprefix(i),u.value]}}};typeof this.opts.store[Symbol.iterator]=="function"&&this.opts.store instanceof Map?this.iterator=n(this.opts.store):typeof this.opts.store.iterator=="function"&&this.opts.store.opts&&this._checkIterableAdaptar()&&(this.iterator=n(this.opts.store.iterator.bind(this.opts.store)))}_checkIterableAdaptar(){return Rs.includes(this.opts.store.opts.dialect)||Rs.findIndex(e=>this.opts.store.opts.url.includes(e))>=0}_getKeyPrefix(e){return`${this.opts.namespace}:${e}`}_getKeyPrefixArray(e){return e.map(r=>`${this.opts.namespace}:${r}`)}_getKeyUnprefix(e){return e.split(":").splice(1).join(":")}get(e,r){let{store:s}=this.opts,n=Array.isArray(e),o=n?this._getKeyPrefixArray(e):this._getKeyPrefix(e);if(n&&s.getMany===void 0){let i=[];for(let a of o)i.push(Promise.resolve().then(()=>s.get(a)).then(u=>typeof u=="string"?this.opts.deserialize(u):this.opts.compression?this.opts.deserialize(u):u).then(u=>{if(u!=null)return typeof u.expires=="number"&&Date.now()>u.expires?this.delete(a).then(()=>{}):r&&r.raw?u:u.value}));return Promise.allSettled(i).then(a=>{let u=[];for(let l of a)u.push(l.value);return u})}return Promise.resolve().then(()=>n?s.getMany(o):s.get(o)).then(i=>typeof i=="string"?this.opts.deserialize(i):this.opts.compression?this.opts.deserialize(i):i).then(i=>{if(i!=null)return n?i.map((a,u)=>{if(typeof a=="string"&&(a=this.opts.deserialize(a)),a!=null){if(typeof a.expires=="number"&&Date.now()>a.expires){this.delete(e[u]).then(()=>{});return}return r&&r.raw?a:a.value}}):typeof i.expires=="number"&&Date.now()>i.expires?this.delete(e).then(()=>{}):r&&r.raw?i:i.value})}set(e,r,s){let n=this._getKeyPrefix(e);typeof s>"u"&&(s=this.opts.ttl),s===0&&(s=void 0);let{store:o}=this.opts;return Promise.resolve().then(()=>{let i=typeof s=="number"?Date.now()+s:null;return typeof r=="symbol"&&this.emit("error","symbol cannot be serialized"),r={value:r,expires:i},this.opts.serialize(r)}).then(i=>o.set(n,i,s)).then(()=>!0)}delete(e){let{store:r}=this.opts;if(Array.isArray(e)){let n=this._getKeyPrefixArray(e);if(r.deleteMany===void 0){let o=[];for(let i of n)o.push(r.delete(i));return Promise.allSettled(o).then(i=>i.every(a=>a.value===!0))}return Promise.resolve().then(()=>r.deleteMany(n))}let s=this._getKeyPrefix(e);return Promise.resolve().then(()=>r.delete(s))}clear(){let{store:e}=this.opts;return Promise.resolve().then(()=>e.clear())}has(e){let r=this._getKeyPrefix(e),{store:s}=this.opts;return Promise.resolve().then(async()=>typeof s.has=="function"?s.has(r):await s.get(r)!==void 0)}disconnect(){let{store:e}=this.opts;if(typeof e.disconnect=="function")return e.disconnect()}};ks.exports=It});var As=b((cl,xs)=>{"use strict";var ra=require("events"),Be=require("url"),sa=es(),na=ps(),Lt=ys(),Ts=bs(),ia=Fe(),oa=Ss(),aa=Cs(),we=class t{constructor(e,r){if(typeof e!="function")throw new TypeError("Parameter `request` must be a function");return this.cache=new aa({uri:typeof r=="string"&&r,store:typeof r!="string"&&r,namespace:"cacheable-request"}),this.createCacheableRequest(e)}createCacheableRequest(e){return(r,s)=>{let n;if(typeof r=="string")n=Mt(Be.parse(r)),r={};else if(r instanceof Be.URL)n=Mt(Be.parse(r.toString())),r={};else{let[h,...y]=(r.path||"").split("?"),p=y.length>0?`?${y.join("?")}`:"";n=Mt({...r,pathname:h,search:p})}r={headers:{},method:"GET",cache:!0,strictTtl:!1,automaticFailover:!1,...r,...ca(n)},r.headers=ia(r.headers);let o=new ra,i=sa(Be.format(n),{stripWWW:!1,removeTrailingSlash:!1,stripAuthentication:!1}),a=`${r.method}:${i}`,u=!1,l=!1,m=h=>{l=!0;let y=!1,p,g=new Promise(f=>{p=()=>{y||(y=!0,f())}}),w=f=>{if(u&&!h.forceRefresh){f.status=f.statusCode;let P=Lt.fromObject(u.cachePolicy).revalidatedPolicy(h,f);if(!P.modified){let x=P.policy.responseHeaders();f=new Ts(u.statusCode,x,u.body,u.url),f.cachePolicy=P.policy,f.fromCache=!0}}f.fromCache||(f.cachePolicy=new Lt(h,f,h),f.fromCache=!1);let v;h.cache&&f.cachePolicy.storable()?(v=oa(f),(async()=>{try{let P=na.buffer(f);if(await Promise.race([g,new Promise(pt=>f.once("end",pt))]),y)return;let x=await P,U={cachePolicy:f.cachePolicy.toObject(),url:f.url,statusCode:f.fromCache?u.statusCode:f.statusCode,body:x},ee=h.strictTtl?f.cachePolicy.timeToLive():void 0;h.maxTtl&&(ee=ee?Math.min(ee,h.maxTtl):h.maxTtl),await this.cache.set(a,U,ee)}catch(P){o.emit("error",new t.CacheError(P))}})()):h.cache&&u&&(async()=>{try{await this.cache.delete(a)}catch(P){o.emit("error",new t.CacheError(P))}})(),o.emit("response",v||f),typeof s=="function"&&s(v||f)};try{let f=e(h,w);f.once("error",p),f.once("abort",p),o.emit("request",f)}catch(f){o.emit("error",new t.RequestError(f))}};return(async()=>{let h=async p=>{await Promise.resolve();let g=p.cache?await this.cache.get(a):void 0;if(typeof g>"u")return m(p);let w=Lt.fromObject(g.cachePolicy);if(w.satisfiesWithoutRevalidation(p)&&!p.forceRefresh){let f=w.responseHeaders(),v=new Ts(g.statusCode,f,g.body,g.url);v.cachePolicy=w,v.fromCache=!0,o.emit("response",v),typeof s=="function"&&s(v)}else u=g,p.headers=w.revalidationHeaders(p),m(p)},y=p=>o.emit("error",new t.CacheError(p));this.cache.once("error",y),o.on("response",()=>this.cache.removeListener("error",y));try{await h(r)}catch(p){r.automaticFailover&&!l&&m(r),o.emit("error",new t.CacheError(p))}})(),o}}};function ca(t){let e={...t};return e.path=`${t.pathname||"/"}${t.search||""}`,delete e.pathname,delete e.search,e}function Mt(t){return{protocol:t.protocol,auth:t.auth,hostname:t.hostname||t.host||"localhost",port:t.port,pathname:t.pathname,search:t.search}}we.RequestError=class extends Error{constructor(t){super(t.message),this.name="RequestError",Object.assign(this,t)}};we.CacheError=class extends Error{constructor(t){super(t.message),this.name="CacheError",Object.assign(this,t)}};xs.exports=we});var js=b((dl,qs)=>{"use strict";var ua=["aborted","complete","headers","httpVersion","httpVersionMinor","httpVersionMajor","method","rawHeaders","rawTrailers","setTimeout","socket","statusCode","statusMessage","trailers","url"];qs.exports=(t,e)=>{if(e._readableState.autoDestroy)throw new Error("The second stream must have the `autoDestroy` option set to `false`");let r=new Set(Object.keys(t).concat(ua)),s={};for(let n of r)n in e||(s[n]={get(){let o=t[n];return typeof o=="function"?o.bind(t):o},set(o){t[n]=o},enumerable:!0,configurable:!1});return Object.defineProperties(e,s),t.once("aborted",()=>{e.destroy(),e.emit("aborted")}),t.once("close",()=>{t.complete&&e.readable?e.once("end",()=>{e.emit("close")}):e.emit("close")}),e}});var Is=b((hl,Hs)=>{"use strict";var{Transform:la,PassThrough:da}=require("stream"),Dt=require("zlib"),ha=js();Hs.exports=t=>{let e=(t.headers["content-encoding"]||"").toLowerCase();if(!["gzip","deflate","br"].includes(e))return t;let r=e==="br";if(r&&typeof Dt.createBrotliDecompress!="function")return t.destroy(new Error("Brotli is not supported on Node.js < 12")),t;let s=!0,n=new la({transform(a,u,l){s=!1,l(null,a)},flush(a){a()}}),o=new da({autoDestroy:!1,destroy(a,u){t.destroy(),u(a)}}),i=r?Dt.createBrotliDecompress():Dt.createUnzip();return i.once("error",a=>{if(s&&!t.readable){o.end();return}o.destroy(a)}),ha(t,o),t.pipe(n).pipe(i).pipe(o),o}});var Nt=b((fl,Ls)=>{"use strict";var Ut=class{constructor(e={}){if(!(e.maxSize&&e.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");this.maxSize=e.maxSize,this.onEviction=e.onEviction,this.cache=new Map,this.oldCache=new Map,this._size=0}_set(e,r){if(this.cache.set(e,r),this._size++,this._size>=this.maxSize){if(this._size=0,typeof this.onEviction=="function")for(let[s,n]of this.oldCache.entries())this.onEviction(s,n);this.oldCache=this.cache,this.cache=new Map}}get(e){if(this.cache.has(e))return this.cache.get(e);if(this.oldCache.has(e)){let r=this.oldCache.get(e);return this.oldCache.delete(e),this._set(e,r),r}}set(e,r){return this.cache.has(e)?this.cache.set(e,r):this._set(e,r),this}has(e){return this.cache.has(e)||this.oldCache.has(e)}peek(e){if(this.cache.has(e))return this.cache.get(e);if(this.oldCache.has(e))return this.oldCache.get(e)}delete(e){let r=this.cache.delete(e);return r&&this._size--,this.oldCache.delete(e)||r}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}*keys(){for(let[e]of this)yield e}*values(){for(let[,e]of this)yield e}*[Symbol.iterator](){for(let e of this.cache)yield e;for(let e of this.oldCache){let[r]=e;this.cache.has(r)||(yield e)}}get size(){let e=0;for(let r of this.oldCache.keys())this.cache.has(r)||e++;return Math.min(this._size+e,this.maxSize)}};Ls.exports=Ut});var Bt=b((pl,Ns)=>{"use strict";var fa=require("events"),pa=require("tls"),ma=require("http2"),ya=Nt(),A=Symbol("currentStreamsCount"),Ms=Symbol("request"),j=Symbol("cachedOriginSet"),ne=Symbol("gracefullyClosing"),ga=["maxDeflateDynamicTableSize","maxSessionMemory","maxHeaderListPairs","maxOutstandingPings","maxReservedRemoteStreams","maxSendHeaderBlockLength","paddingStrategy","localAddress","path","rejectUnauthorized","minDHSize","ca","cert","clientCertEngine","ciphers","key","pfx","servername","minVersion","maxVersion","secureProtocol","crl","honorCipherOrder","ecdhCurve","dhparam","secureOptions","sessionIdContext"],_a=(t,e,r)=>{let s=0,n=t.length;for(;s<n;){let o=s+n>>>1;r(t[o],e)?s=o+1:n=o}return s},ba=(t,e)=>t.remoteSettings.maxConcurrentStreams>e.remoteSettings.maxConcurrentStreams,Ft=(t,e)=>{for(let r of t)r[j].length<e[j].length&&r[j].every(s=>e[j].includes(s))&&r[A]+e[A]<=e.remoteSettings.maxConcurrentStreams&&Us(r)},wa=(t,e)=>{for(let r of t)e[j].length<r[j].length&&e[j].every(s=>r[j].includes(s))&&e[A]+r[A]<=r.remoteSettings.maxConcurrentStreams&&Us(e)},Ds=({agent:t,isFree:e})=>{let r={};for(let s in t.sessions){let o=t.sessions[s].filter(i=>{let a=i[Y.kCurrentStreamsCount]<i.remoteSettings.maxConcurrentStreams;return e?a:!a});o.length!==0&&(r[s]=o)}return r},Us=t=>{t[ne]=!0,t[A]===0&&t.close()},Y=class t extends fa{constructor({timeout:e=6e4,maxSessions:r=1/0,maxFreeSessions:s=10,maxCachedTlsSessions:n=100}={}){super(),this.sessions={},this.queue={},this.timeout=e,this.maxSessions=r,this.maxFreeSessions=s,this._freeSessionsCount=0,this._sessionsCount=0,this.settings={enablePush:!1},this.tlsSessionCache=new ya({maxSize:n})}static normalizeOrigin(e,r){return typeof e=="string"&&(e=new URL(e)),r&&e.hostname!==r&&(e.hostname=r),e.origin}normalizeOptions(e){let r="";if(e)for(let s of ga)e[s]&&(r+=`:${e[s]}`);return r}_tryToCreateNewSession(e,r){if(!(e in this.queue)||!(r in this.queue[e]))return;let s=this.queue[e][r];this._sessionsCount<this.maxSessions&&!s.completed&&(s.completed=!0,s())}getSession(e,r,s){return new Promise((n,o)=>{Array.isArray(s)?(s=[...s],n()):s=[{resolve:n,reject:o}];let i=this.normalizeOptions(r),a=t.normalizeOrigin(e,r&&r.servername);if(a===void 0){for(let{reject:m}of s)m(new TypeError("The `origin` argument needs to be a string or an URL object"));return}if(i in this.sessions){let m=this.sessions[i],h=-1,y=-1,p;for(let g of m){let w=g.remoteSettings.maxConcurrentStreams;if(w<h)break;if(g[j].includes(a)){let f=g[A];if(f>=w||g[ne]||g.destroyed)continue;p||(h=w),f>y&&(p=g,y=f)}}if(p){if(s.length!==1){for(let{reject:g}of s){let w=new Error(`Expected the length of listeners to be 1, got ${s.length}.
|
|
Please report this to https://github.com/szmarczak/http2-wrapper/`);g(w)}return}s[0].resolve(p);return}}if(i in this.queue){if(a in this.queue[i]){this.queue[i][a].listeners.push(...s),this._tryToCreateNewSession(i,a);return}}else this.queue[i]={};let u=()=>{i in this.queue&&this.queue[i][a]===l&&(delete this.queue[i][a],Object.keys(this.queue[i]).length===0&&delete this.queue[i])},l=()=>{let m=`${a}:${i}`,h=!1;try{let y=ma.connect(e,{createConnection:this.createConnection,settings:this.settings,session:this.tlsSessionCache.get(m),...r});y[A]=0,y[ne]=!1;let p=()=>y[A]<y.remoteSettings.maxConcurrentStreams,g=!0;y.socket.once("session",f=>{this.tlsSessionCache.set(m,f)}),y.once("error",f=>{for(let{reject:v}of s)v(f);this.tlsSessionCache.delete(m)}),y.setTimeout(this.timeout,()=>{y.destroy()}),y.once("close",()=>{if(h){g&&this._freeSessionsCount--,this._sessionsCount--;let f=this.sessions[i];f.splice(f.indexOf(y),1),f.length===0&&delete this.sessions[i]}else{let f=new Error("Session closed without receiving a SETTINGS frame");f.code="HTTP2WRAPPER_NOSETTINGS";for(let{reject:v}of s)v(f);u()}this._tryToCreateNewSession(i,a)});let w=()=>{if(!(!(i in this.queue)||!p())){for(let f of y[j])if(f in this.queue[i]){let{listeners:v}=this.queue[i][f];for(;v.length!==0&&p();)v.shift().resolve(y);let P=this.queue[i];if(P[f].listeners.length===0&&(delete P[f],Object.keys(P).length===0)){delete this.queue[i];break}if(!p())break}}};y.on("origin",()=>{y[j]=y.originSet,p()&&(w(),Ft(this.sessions[i],y))}),y.once("remoteSettings",()=>{if(y.ref(),y.unref(),this._sessionsCount++,l.destroyed){let f=new Error("Agent has been destroyed");for(let v of s)v.reject(f);y.destroy();return}y[j]=y.originSet;{let f=this.sessions;if(i in f){let v=f[i];v.splice(_a(v,y,ba),0,y)}else f[i]=[y]}this._freeSessionsCount+=1,h=!0,this.emit("session",y),w(),u(),y[A]===0&&this._freeSessionsCount>this.maxFreeSessions&&y.close(),s.length!==0&&(this.getSession(a,r,s),s.length=0),y.on("remoteSettings",()=>{w(),Ft(this.sessions[i],y)})}),y[Ms]=y.request,y.request=(f,v)=>{if(y[ne])throw new Error("The session is gracefully closing. No new streams are allowed.");let P=y[Ms](f,v);return y.ref(),++y[A],y[A]===y.remoteSettings.maxConcurrentStreams&&this._freeSessionsCount--,P.once("close",()=>{if(g=p(),--y[A],!y.destroyed&&!y.closed&&(wa(this.sessions[i],y),p()&&!y.closed)){g||(this._freeSessionsCount++,g=!0);let x=y[A]===0;x&&y.unref(),x&&(this._freeSessionsCount>this.maxFreeSessions||y[ne])?y.close():(Ft(this.sessions[i],y),w())}}),P}}catch(y){for(let p of s)p.reject(y);u()}};l.listeners=s,l.completed=!1,l.destroyed=!1,this.queue[i][a]=l,this._tryToCreateNewSession(i,a)})}request(e,r,s,n){return new Promise((o,i)=>{this.getSession(e,r,[{reject:i,resolve:a=>{try{o(a.request(s,n))}catch(u){i(u)}}}])})}createConnection(e,r){return t.connect(e,r)}static connect(e,r){r.ALPNProtocols=["h2"];let s=e.port||443,n=e.hostname||e.host;return typeof r.servername>"u"&&(r.servername=n),pa.connect(s,n,r)}closeFreeSessions(){for(let e of Object.values(this.sessions))for(let r of e)r[A]===0&&r.close()}destroy(e){for(let r of Object.values(this.sessions))for(let s of r)s.destroy(e);for(let r of Object.values(this.queue))for(let s of Object.values(r))s.destroyed=!0;this.queue={}}get freeSessions(){return Ds({agent:this,isFree:!0})}get busySessions(){return Ds({agent:this,isFree:!1})}};Y.kCurrentStreamsCount=A;Y.kGracefullyClosing=ne;Ns.exports={Agent:Y,globalAgent:new Y}});var $t=b((ml,Fs)=>{"use strict";var{Readable:va}=require("stream"),zt=class extends va{constructor(e,r){super({highWaterMark:r,autoDestroy:!1}),this.statusCode=null,this.statusMessage="",this.httpVersion="2.0",this.httpVersionMajor=2,this.httpVersionMinor=0,this.headers={},this.trailers={},this.req=null,this.aborted=!1,this.complete=!1,this.upgrade=null,this.rawHeaders=[],this.rawTrailers=[],this.socket=e,this.connection=e,this._dumped=!1}_destroy(e){this.req._request.destroy(e)}setTimeout(e,r){return this.req.setTimeout(e,r),this}_dump(){this._dumped||(this._dumped=!0,this.removeAllListeners("data"),this.resume())}_read(){this.req&&this.req._request.resume()}};Fs.exports=zt});var Wt=b((yl,Bs)=>{"use strict";Bs.exports=t=>{let e={protocol:t.protocol,hostname:typeof t.hostname=="string"&&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||""}`};return typeof t.port=="string"&&t.port.length!==0&&(e.port=Number(t.port)),(t.username||t.password)&&(e.auth=`${t.username||""}:${t.password||""}`),e}});var $s=b((gl,zs)=>{"use strict";zs.exports=(t,e,r)=>{for(let s of r)t.on(s,(...n)=>e.emit(s,...n))}});var Vs=b((_l,Ws)=>{"use strict";Ws.exports=t=>{switch(t){case":method":case":scheme":case":authority":case":path":return!0;default:return!1}}});var Js=b((wl,Gs)=>{"use strict";var ie=(t,e,r)=>{Gs.exports[e]=class extends t{constructor(...n){super(typeof r=="string"?r:r(n)),this.name=`${super.name} [${e}]`,this.code=e}}};ie(TypeError,"ERR_INVALID_ARG_TYPE",t=>{let e=t[0].includes(".")?"property":"argument",r=t[1],s=Array.isArray(r);return s&&(r=`${r.slice(0,-1).join(", ")} or ${r.slice(-1)}`),`The "${t[0]}" ${e} must be ${s?"one of":"of"} type ${r}. Received ${typeof t[2]}`});ie(TypeError,"ERR_INVALID_PROTOCOL",t=>`Protocol "${t[0]}" not supported. Expected "${t[1]}"`);ie(Error,"ERR_HTTP_HEADERS_SENT",t=>`Cannot ${t[0]} headers after they are sent to the client`);ie(TypeError,"ERR_INVALID_HTTP_TOKEN",t=>`${t[0]} must be a valid HTTP token [${t[1]}]`);ie(TypeError,"ERR_HTTP_INVALID_HEADER_VALUE",t=>`Invalid value "${t[0]} for header "${t[1]}"`);ie(TypeError,"ERR_INVALID_CHAR",t=>`Invalid character in ${t[0]} [${t[1]}]`)});var Qt=b((vl,tn)=>{"use strict";var Ea=require("http2"),{Writable:Sa}=require("stream"),{Agent:Ks,globalAgent:Pa}=Bt(),Oa=$t(),Ra=Wt(),ka=$s(),Ca=Vs(),{ERR_INVALID_ARG_TYPE:Vt,ERR_INVALID_PROTOCOL:Ta,ERR_HTTP_HEADERS_SENT:Qs,ERR_INVALID_HTTP_TOKEN:xa,ERR_HTTP_INVALID_HEADER_VALUE:Aa,ERR_INVALID_CHAR:qa}=Js(),{HTTP2_HEADER_STATUS:Xs,HTTP2_HEADER_METHOD:Ys,HTTP2_HEADER_PATH:Zs,HTTP2_METHOD_CONNECT:ja}=Ea.constants,T=Symbol("headers"),Gt=Symbol("origin"),Jt=Symbol("session"),en=Symbol("options"),ze=Symbol("flushedHeaders"),ve=Symbol("jobs"),Ha=/^[\^`\-\w!#$%&*+.|~]+$/,Ia=/[^\t\u0020-\u007E\u0080-\u00FF]/,Kt=class extends Sa{constructor(e,r,s){super({autoDestroy:!1});let n=typeof e=="string"||e instanceof URL;if(n&&(e=Ra(e instanceof URL?e:new URL(e))),typeof r=="function"||r===void 0?(s=r,r=n?e:{...e}):r={...e,...r},r.h2session)this[Jt]=r.h2session;else if(r.agent===!1)this.agent=new Ks({maxFreeSessions:0});else if(typeof r.agent>"u"||r.agent===null)typeof r.createConnection=="function"?(this.agent=new Ks({maxFreeSessions:0}),this.agent.createConnection=r.createConnection):this.agent=Pa;else if(typeof r.agent.request=="function")this.agent=r.agent;else throw new Vt("options.agent",["Agent-like Object","undefined","false"],r.agent);if(r.protocol&&r.protocol!=="https:")throw new Ta(r.protocol,"https:");let o=r.port||r.defaultPort||this.agent&&this.agent.defaultPort||443,i=r.hostname||r.host||"localhost";delete r.hostname,delete r.host,delete r.port;let{timeout:a}=r;if(r.timeout=void 0,this[T]=Object.create(null),this[ve]=[],this.socket=null,this.connection=null,this.method=r.method||"GET",this.path=r.path,this.res=null,this.aborted=!1,this.reusedSocket=!1,r.headers)for(let[u,l]of Object.entries(r.headers))this.setHeader(u,l);r.auth&&!("authorization"in this[T])&&(this[T].authorization="Basic "+Buffer.from(r.auth).toString("base64")),r.session=r.tlsSession,r.path=r.socketPath,this[en]=r,o===443?(this[Gt]=`https://${i}`,":authority"in this[T]||(this[T][":authority"]=i)):(this[Gt]=`https://${i}:${o}`,":authority"in this[T]||(this[T][":authority"]=`${i}:${o}`)),a&&this.setTimeout(a),s&&this.once("response",s),this[ze]=!1}get method(){return this[T][Ys]}set method(e){e&&(this[T][Ys]=e.toUpperCase())}get path(){return this[T][Zs]}set path(e){e&&(this[T][Zs]=e)}get _mustNotHaveABody(){return this.method==="GET"||this.method==="HEAD"||this.method==="DELETE"}_write(e,r,s){if(this._mustNotHaveABody){s(new Error("The GET, HEAD and DELETE methods must NOT have a body"));return}this.flushHeaders();let n=()=>this._request.write(e,r,s);this._request?n():this[ve].push(n)}_final(e){if(this.destroyed)return;this.flushHeaders();let r=()=>{if(this._mustNotHaveABody){e();return}this._request.end(e)};this._request?r():this[ve].push(r)}abort(){this.res&&this.res.complete||(this.aborted||process.nextTick(()=>this.emit("abort")),this.aborted=!0,this.destroy())}_destroy(e,r){this.res&&this.res._dump(),this._request&&this._request.destroy(),r(e)}async flushHeaders(){if(this[ze]||this.destroyed)return;this[ze]=!0;let e=this.method===ja,r=s=>{if(this._request=s,this.destroyed){s.destroy();return}e||ka(s,this,["timeout","continue","close","error"]);let n=i=>(...a)=>{!this.writable&&!this.destroyed?i(...a):this.once("finish",()=>{i(...a)})};s.once("response",n((i,a,u)=>{let l=new Oa(this.socket,s.readableHighWaterMark);this.res=l,l.req=this,l.statusCode=i[Xs],l.headers=i,l.rawHeaders=u,l.once("end",()=>{this.aborted?(l.aborted=!0,l.emit("aborted")):(l.complete=!0,l.socket=null,l.connection=null)}),e?(l.upgrade=!0,this.emit("connect",l,s,Buffer.alloc(0))?this.emit("close"):s.destroy()):(s.on("data",m=>{!l._dumped&&!l.push(m)&&s.pause()}),s.once("end",()=>{l.push(null)}),this.emit("response",l)||l._dump())})),s.once("headers",n(i=>this.emit("information",{statusCode:i[Xs]}))),s.once("trailers",n((i,a,u)=>{let{res:l}=this;l.trailers=i,l.rawTrailers=u}));let{socket:o}=s.session;this.socket=o,this.connection=o;for(let i of this[ve])i();this.emit("socket",this.socket)};if(this[Jt])try{r(this[Jt].request(this[T]))}catch(s){this.emit("error",s)}else{this.reusedSocket=!0;try{r(await this.agent.request(this[Gt],this[en],this[T]))}catch(s){this.emit("error",s)}}}getHeader(e){if(typeof e!="string")throw new Vt("name","string",e);return this[T][e.toLowerCase()]}get headersSent(){return this[ze]}removeHeader(e){if(typeof e!="string")throw new Vt("name","string",e);if(this.headersSent)throw new Qs("remove");delete this[T][e.toLowerCase()]}setHeader(e,r){if(this.headersSent)throw new Qs("set");if(typeof e!="string"||!Ha.test(e)&&!Ca(e))throw new xa("Header name",e);if(typeof r>"u")throw new Aa(r,e);if(Ia.test(r))throw new qa("header content",e);this[T][e.toLowerCase()]=r}setNoDelay(){}setSocketKeepAlive(){}setTimeout(e,r){let s=()=>this._request.setTimeout(e,r);return this._request?s():this[ve].push(s),this}get maxHeadersCount(){if(!this.destroyed&&this._request)return this._request.session.localSettings.maxHeaderListSize}set maxHeadersCount(e){}};tn.exports=Kt});var sn=b((El,rn)=>{"use strict";var La=require("tls");rn.exports=(t={},e=La.connect)=>new Promise((r,s)=>{let n=!1,o,i=async()=>{await u,o.off("timeout",a),o.off("error",s),t.resolveSocket?(r({alpnProtocol:o.alpnProtocol,socket:o,timeout:n}),n&&(await Promise.resolve(),o.emit("timeout"))):(o.destroy(),r({alpnProtocol:o.alpnProtocol,timeout:n}))},a=async()=>{n=!0,i()},u=(async()=>{try{o=await e(t,i),o.on("error",s),o.once("timeout",a)}catch(l){s(l)}})()})});var on=b((Sl,nn)=>{"use strict";var Ma=require("net");nn.exports=t=>{let e=t.host,r=t.headers&&t.headers.host;return r&&(r.startsWith("[")?r.indexOf("]")===-1?e=r:e=r.slice(1,-1):e=r.split(":",1)[0]),Ma.isIP(e)?"":e}});var un=b((Pl,Yt)=>{"use strict";var an=require("http"),Xt=require("https"),Da=sn(),Ua=Nt(),Na=Qt(),Fa=on(),Ba=Wt(),$e=new Ua({maxSize:100}),Ee=new Map,cn=(t,e,r)=>{e._httpMessage={shouldKeepAlive:!0};let s=()=>{t.emit("free",e,r)};e.on("free",s);let n=()=>{t.removeSocket(e,r)};e.on("close",n);let o=()=>{t.removeSocket(e,r),e.off("close",n),e.off("free",s),e.off("agentRemove",o)};e.on("agentRemove",o),t.emit("free",e,r)},za=async t=>{let e=`${t.host}:${t.port}:${t.ALPNProtocols.sort()}`;if(!$e.has(e)){if(Ee.has(e))return(await Ee.get(e)).alpnProtocol;let{path:r,agent:s}=t;t.path=t.socketPath;let n=Da(t);Ee.set(e,n);try{let{socket:o,alpnProtocol:i}=await n;if($e.set(e,i),t.path=r,i==="h2")o.destroy();else{let{globalAgent:a}=Xt,u=Xt.Agent.prototype.createConnection;s?s.createConnection===u?cn(s,o,t):o.destroy():a.createConnection===u?cn(a,o,t):o.destroy()}return Ee.delete(e),i}catch(o){throw Ee.delete(e),o}}return $e.get(e)};Yt.exports=async(t,e,r)=>{if((typeof t=="string"||t instanceof URL)&&(t=Ba(new URL(t))),typeof e=="function"&&(r=e,e=void 0),e={ALPNProtocols:["h2","http/1.1"],...t,...e,resolveSocket:!0},!Array.isArray(e.ALPNProtocols)||e.ALPNProtocols.length===0)throw new Error("The `ALPNProtocols` option must be an Array with at least one entry");e.protocol=e.protocol||"https:";let s=e.protocol==="https:";e.host=e.hostname||e.host||"localhost",e.session=e.tlsSession,e.servername=e.servername||Fa(e),e.port=e.port||(s?443:80),e._defaultAgent=s?Xt.globalAgent:an.globalAgent;let n=e.agent;if(n){if(n.addRequest)throw new Error("The `options.agent` object can contain only `http`, `https` or `http2` properties");e.agent=n[s?"https":"http"]}return s&&await za(e)==="h2"?(n&&(e.agent=n.http2),new Na(e,r)):an.request(e,r)};Yt.exports.protocolCache=$e});var dn=b((Ol,ln)=>{"use strict";var $a=require("http2"),Wa=Bt(),Zt=Qt(),Va=$t(),Ga=un(),Ja=(t,e,r)=>new Zt(t,e,r),Ka=(t,e,r)=>{let s=new Zt(t,e,r);return s.end(),s};ln.exports={...$a,ClientRequest:Zt,IncomingMessage:Va,...Wa,request:Ja,get:Ka,auto:Ga}});var tr=b(er=>{"use strict";Object.defineProperty(er,"__esModule",{value:!0});var hn=F();er.default=t=>hn.default.nodeStream(t)&&hn.default.function_(t.getBoundary)});var yn=b(rr=>{"use strict";Object.defineProperty(rr,"__esModule",{value:!0});var pn=require("fs"),mn=require("util"),fn=F(),Qa=tr(),Xa=mn.promisify(pn.stat);rr.default=async(t,e)=>{if(e&&"content-length"in e)return Number(e["content-length"]);if(!t)return 0;if(fn.default.string(t))return Buffer.byteLength(t);if(fn.default.buffer(t))return t.length;if(Qa.default(t))return mn.promisify(t.getLength.bind(t))();if(t instanceof pn.ReadStream){let{size:r}=await Xa(t.path);return r===0?void 0:r}}});var nr=b(sr=>{"use strict";Object.defineProperty(sr,"__esModule",{value:!0});function Ya(t,e,r){let s={};for(let n of r)s[n]=(...o)=>{e.emit(n,...o)},t.on(n,s[n]);return()=>{for(let n of r)t.off(n,s[n])}}sr.default=Ya});var gn=b(ir=>{"use strict";Object.defineProperty(ir,"__esModule",{value:!0});ir.default=()=>{let t=[];return{once(e,r,s){e.once(r,s),t.push({origin:e,event:r,fn:s})},unhandleAll(){for(let e of t){let{origin:r,event:s,fn:n}=e;r.removeListener(s,n)}t.length=0}}}});var bn=b(Se=>{"use strict";Object.defineProperty(Se,"__esModule",{value:!0});Se.TimeoutError=void 0;var Za=require("net"),ec=gn(),_n=Symbol("reentry"),tc=()=>{},We=class extends Error{constructor(e,r){super(`Timeout awaiting '${r}' for ${e}ms`),this.event=r,this.name="TimeoutError",this.code="ETIMEDOUT"}};Se.TimeoutError=We;Se.default=(t,e,r)=>{if(_n in t)return tc;t[_n]=!0;let s=[],{once:n,unhandleAll:o}=ec.default(),i=(h,y,p)=>{var g;let w=setTimeout(y,h,h,p);(g=w.unref)===null||g===void 0||g.call(w);let f=()=>{clearTimeout(w)};return s.push(f),f},{host:a,hostname:u}=r,l=(h,y)=>{t.destroy(new We(h,y))},m=()=>{for(let h of s)h();o()};if(t.once("error",h=>{if(m(),t.listenerCount("error")===0)throw h}),t.once("close",m),n(t,"response",h=>{n(h,"end",m)}),typeof e.request<"u"&&i(e.request,l,"request"),typeof e.socket<"u"){let h=()=>{l(e.socket,"socket")};t.setTimeout(e.socket,h),s.push(()=>{t.removeListener("timeout",h)})}return n(t,"socket",h=>{var y;let{socketPath:p}=t;if(h.connecting){let g=!!(p??Za.isIP((y=u??a)!==null&&y!==void 0?y:"")!==0);if(typeof e.lookup<"u"&&!g&&typeof h.address().address>"u"){let w=i(e.lookup,l,"lookup");n(h,"lookup",w)}if(typeof e.connect<"u"){let w=()=>i(e.connect,l,"connect");g?n(h,"connect",w()):n(h,"lookup",f=>{f===null&&n(h,"connect",w())})}typeof e.secureConnect<"u"&&r.protocol==="https:"&&n(h,"connect",()=>{let w=i(e.secureConnect,l,"secureConnect");n(h,"secureConnect",w)})}if(typeof e.send<"u"){let g=()=>i(e.send,l,"send");h.connecting?n(h,"connect",()=>{n(t,"upload-complete",g())}):n(t,"upload-complete",g())}}),typeof e.response<"u"&&n(t,"upload-complete",()=>{let h=i(e.response,l,"response");n(t,"response",h)}),m}});var vn=b(or=>{"use strict";Object.defineProperty(or,"__esModule",{value:!0});var wn=F();or.default=t=>{t=t;let e={protocol:t.protocol,hostname:wn.default.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||""}`};return wn.default.string(t.port)&&t.port.length>0&&(e.port=Number(t.port)),(t.username||t.password)&&(e.auth=`${t.username||""}:${t.password||""}`),e}});var En=b(ar=>{"use strict";Object.defineProperty(ar,"__esModule",{value:!0});var rc=require("url"),sc=["protocol","host","hostname","port","pathname","search"];ar.default=(t,e)=>{var r,s;if(e.path){if(e.pathname)throw new TypeError("Parameters `path` and `pathname` are mutually exclusive.");if(e.search)throw new TypeError("Parameters `path` and `search` are mutually exclusive.");if(e.searchParams)throw new TypeError("Parameters `path` and `searchParams` are mutually exclusive.")}if(e.search&&e.searchParams)throw new TypeError("Parameters `search` and `searchParams` are mutually exclusive.");if(!t){if(!e.protocol)throw new TypeError("No URL protocol specified");t=`${e.protocol}//${(s=(r=e.hostname)!==null&&r!==void 0?r:e.host)!==null&&s!==void 0?s:""}`}let n=new rc.URL(t);if(e.path){let o=e.path.indexOf("?");o===-1?e.pathname=e.path:(e.pathname=e.path.slice(0,o),e.search=e.path.slice(o+1)),delete e.path}for(let o of sc)e[o]&&(n[o]=e[o].toString());return n}});var Sn=b(ur=>{"use strict";Object.defineProperty(ur,"__esModule",{value:!0});var cr=class{constructor(){this.weakMap=new WeakMap,this.map=new Map}set(e,r){typeof e=="object"?this.weakMap.set(e,r):this.map.set(e,r)}get(e){return typeof e=="object"?this.weakMap.get(e):this.map.get(e)}has(e){return typeof e=="object"?this.weakMap.has(e):this.map.has(e)}};ur.default=cr});var dr=b(lr=>{"use strict";Object.defineProperty(lr,"__esModule",{value:!0});var nc=async t=>{let e=[],r=0;for await(let s of t)e.push(s),r+=Buffer.byteLength(s);return Buffer.isBuffer(e[0])?Buffer.concat(e,r):Buffer.from(e.join(""))};lr.default=nc});var On=b(Z=>{"use strict";Object.defineProperty(Z,"__esModule",{value:!0});Z.dnsLookupIpVersionToFamily=Z.isDnsLookupIpVersion=void 0;var Pn={auto:0,ipv4:4,ipv6:6};Z.isDnsLookupIpVersion=t=>t in Pn;Z.dnsLookupIpVersionToFamily=t=>{if(Z.isDnsLookupIpVersion(t))return Pn[t];throw new Error("Invalid DNS lookup IP version")}});var hr=b(Ve=>{"use strict";Object.defineProperty(Ve,"__esModule",{value:!0});Ve.isResponseOk=void 0;Ve.isResponseOk=t=>{let{statusCode:e}=t,r=t.request.options.followRedirect?299:399;return e>=200&&e<=r||e===304}});var kn=b(fr=>{"use strict";Object.defineProperty(fr,"__esModule",{value:!0});var Rn=new Set;fr.default=t=>{Rn.has(t)||(Rn.add(t),process.emitWarning(`Got: ${t}`,{type:"DeprecationWarning"}))}});var Cn=b(pr=>{"use strict";Object.defineProperty(pr,"__esModule",{value:!0});var O=F(),ic=(t,e)=>{if(O.default.null_(t.encoding))throw new TypeError("To get a Buffer, set `options.responseType` to `buffer` instead");O.assert.any([O.default.string,O.default.undefined],t.encoding),O.assert.any([O.default.boolean,O.default.undefined],t.resolveBodyOnly),O.assert.any([O.default.boolean,O.default.undefined],t.methodRewriting),O.assert.any([O.default.boolean,O.default.undefined],t.isStream),O.assert.any([O.default.string,O.default.undefined],t.responseType),t.responseType===void 0&&(t.responseType="text");let{retry:r}=t;if(e?t.retry={...e.retry}:t.retry={calculateDelay:s=>s.computedValue,limit:0,methods:[],statusCodes:[],errorCodes:[],maxRetryAfter:void 0},O.default.object(r)?(t.retry={...t.retry,...r},t.retry.methods=[...new Set(t.retry.methods.map(s=>s.toUpperCase()))],t.retry.statusCodes=[...new Set(t.retry.statusCodes)],t.retry.errorCodes=[...new Set(t.retry.errorCodes)]):O.default.number(r)&&(t.retry.limit=r),O.default.undefined(t.retry.maxRetryAfter)&&(t.retry.maxRetryAfter=Math.min(...[t.timeout.request,t.timeout.connect].filter(O.default.number))),O.default.object(t.pagination)){e&&(t.pagination={...e.pagination,...t.pagination});let{pagination:s}=t;if(!O.default.function_(s.transform))throw new Error("`options.pagination.transform` must be implemented");if(!O.default.function_(s.shouldContinue))throw new Error("`options.pagination.shouldContinue` must be implemented");if(!O.default.function_(s.filter))throw new TypeError("`options.pagination.filter` must be implemented");if(!O.default.function_(s.paginate))throw new Error("`options.pagination.paginate` must be implemented")}return t.responseType==="json"&&t.headers.accept===void 0&&(t.headers.accept="application/json"),t};pr.default=ic});var Tn=b(Pe=>{"use strict";Object.defineProperty(Pe,"__esModule",{value:!0});Pe.retryAfterStatusCodes=void 0;Pe.retryAfterStatusCodes=new Set([413,429,503]);var oc=({attemptCount:t,retryOptions:e,error:r,retryAfter:s})=>{if(t>e.limit)return 0;let n=e.methods.includes(r.options.method),o=e.errorCodes.includes(r.code),i=r.response&&e.statusCodes.includes(r.response.statusCode);if(!n||!o&&!i)return 0;if(r.response){if(s)return e.maxRetryAfter===void 0||s>e.maxRetryAfter?0:s;if(r.response.statusCode===413)return 0}let a=Math.random()*100;return 2**(t-1)*1e3+a};Pe.default=oc});var ke=b(E=>{"use strict";Object.defineProperty(E,"__esModule",{value:!0});E.UnsupportedProtocolError=E.ReadError=E.TimeoutError=E.UploadError=E.CacheError=E.HTTPError=E.MaxRedirectsError=E.RequestError=E.setNonEnumerableProperties=E.knownHookEvents=E.withoutBody=E.kIsNormalizedAlready=void 0;var xn=require("util"),An=require("stream"),ac=require("fs"),G=require("url"),qn=require("http"),mr=require("http"),cc=require("https"),uc=$r(),lc=Xr(),jn=As(),dc=Is(),hc=dn(),fc=Fe(),d=F(),pc=yn(),Hn=tr(),mc=nr(),In=bn(),yc=vn(),Ln=En(),gc=Sn(),_c=dr(),Mn=On(),bc=hr(),J=kn(),wc=Cn(),vc=Tn(),yr,k=Symbol("request"),Ke=Symbol("response"),oe=Symbol("responseSize"),ae=Symbol("downloadedSize"),ce=Symbol("bodySize"),ue=Symbol("uploadedSize"),Ge=Symbol("serverResponsesPiped"),Dn=Symbol("unproxyEvents"),Un=Symbol("isFromCache"),gr=Symbol("cancelTimeouts"),Nn=Symbol("startedReading"),le=Symbol("stopReading"),Je=Symbol("triggerRead"),K=Symbol("body"),Oe=Symbol("jobs"),Fn=Symbol("originalResponse"),Bn=Symbol("retryTimeout");E.kIsNormalizedAlready=Symbol("isNormalizedAlready");var Ec=d.default.string(process.versions.brotli);E.withoutBody=new Set(["GET","HEAD"]);E.knownHookEvents=["init","beforeRequest","beforeRedirect","beforeError","beforeRetry","afterResponse"];function Sc(t){for(let e in t){let r=t[e];if(!d.default.string(r)&&!d.default.number(r)&&!d.default.boolean(r)&&!d.default.null_(r)&&!d.default.undefined(r))throw new TypeError(`The \`searchParams\` value '${String(r)}' must be a string, number, boolean or null`)}}function Pc(t){return d.default.object(t)&&!("statusCode"in t)}var _r=new gc.default,Oc=async t=>new Promise((e,r)=>{let s=n=>{r(n)};t.pending||e(),t.once("error",s),t.once("ready",()=>{t.off("error",s),e()})}),Rc=new Set([300,301,302,303,304,307,308]),kc=["context","body","json","form"];E.setNonEnumerableProperties=(t,e)=>{let r={};for(let s of t)if(s)for(let n of kc)n in s&&(r[n]={writable:!0,configurable:!0,enumerable:!1,value:s[n]});Object.defineProperties(e,r)};var R=class extends Error{constructor(e,r,s){var n,o;if(super(e),Error.captureStackTrace(this,this.constructor),this.name="RequestError",this.code=(n=r.code)!==null&&n!==void 0?n:"ERR_GOT_REQUEST_ERROR",s instanceof rt?(Object.defineProperty(this,"request",{enumerable:!1,value:s}),Object.defineProperty(this,"response",{enumerable:!1,value:s[Ke]}),Object.defineProperty(this,"options",{enumerable:!1,value:s.options})):Object.defineProperty(this,"options",{enumerable:!1,value:s}),this.timings=(o=this.request)===null||o===void 0?void 0:o.timings,d.default.string(r.stack)&&d.default.string(this.stack)){let i=this.stack.indexOf(this.message)+this.message.length,a=this.stack.slice(i).split(`
|
|
`).reverse(),u=r.stack.slice(r.stack.indexOf(r.message)+r.message.length).split(`
|
|
`).reverse();for(;u.length!==0&&u[0]===a[0];)a.shift();this.stack=`${this.stack.slice(0,i)}${a.reverse().join(`
|
|
`)}${u.reverse().join(`
|
|
`)}`}}};E.RequestError=R;var Qe=class extends R{constructor(e){super(`Redirected ${e.options.maxRedirects} times. Aborting.`,{},e),this.name="MaxRedirectsError",this.code="ERR_TOO_MANY_REDIRECTS"}};E.MaxRedirectsError=Qe;var Xe=class extends R{constructor(e){super(`Response code ${e.statusCode} (${e.statusMessage})`,{},e.request),this.name="HTTPError",this.code="ERR_NON_2XX_3XX_RESPONSE"}};E.HTTPError=Xe;var Ye=class extends R{constructor(e,r){super(e.message,e,r),this.name="CacheError",this.code=this.code==="ERR_GOT_REQUEST_ERROR"?"ERR_CACHE_ACCESS":this.code}};E.CacheError=Ye;var Ze=class extends R{constructor(e,r){super(e.message,e,r),this.name="UploadError",this.code=this.code==="ERR_GOT_REQUEST_ERROR"?"ERR_UPLOAD":this.code}};E.UploadError=Ze;var et=class extends R{constructor(e,r,s){super(e.message,e,s),this.name="TimeoutError",this.event=e.event,this.timings=r}};E.TimeoutError=et;var Re=class extends R{constructor(e,r){super(e.message,e,r),this.name="ReadError",this.code=this.code==="ERR_GOT_REQUEST_ERROR"?"ERR_READING_RESPONSE_STREAM":this.code}};E.ReadError=Re;var tt=class extends R{constructor(e){super(`Unsupported protocol "${e.url.protocol}"`,{},e),this.name="UnsupportedProtocolError",this.code="ERR_UNSUPPORTED_PROTOCOL"}};E.UnsupportedProtocolError=tt;var Cc=["socket","connect","continue","information","upgrade","timeout"],rt=class extends An.Duplex{constructor(e,r={},s){super({autoDestroy:!1,highWaterMark:0}),this[ae]=0,this[ue]=0,this.requestInitialized=!1,this[Ge]=new Set,this.redirects=[],this[le]=!1,this[Je]=!1,this[Oe]=[],this.retryCount=0,this._progressCallbacks=[];let n=()=>this._unlockWrite(),o=()=>this._lockWrite();this.on("pipe",l=>{l.prependListener("data",n),l.on("data",o),l.prependListener("end",n),l.on("end",o)}),this.on("unpipe",l=>{l.off("data",n),l.off("data",o),l.off("end",n),l.off("end",o)}),this.on("pipe",l=>{l instanceof mr.IncomingMessage&&(this.options.headers={...l.headers,...this.options.headers})});let{json:i,body:a,form:u}=r;if((i||a||u)&&this._lockWrite(),E.kIsNormalizedAlready in r)this.options=r;else try{this.options=this.constructor.normalizeArguments(e,r,s)}catch(l){d.default.nodeStream(r.body)&&r.body.destroy(),this.destroy(l);return}(async()=>{var l;try{this.options.body instanceof ac.ReadStream&&await Oc(this.options.body);let{url:m}=this.options;if(!m)throw new TypeError("Missing `url` property");if(this.requestUrl=m.toString(),decodeURI(this.requestUrl),await this._finalizeBody(),await this._makeRequest(),this.destroyed){(l=this[k])===null||l===void 0||l.destroy();return}for(let h of this[Oe])h();this[Oe].length=0,this.requestInitialized=!0}catch(m){if(m instanceof R){this._beforeError(m);return}this.destroyed||this.destroy(m)}})()}static normalizeArguments(e,r,s){var n,o,i,a,u;let l=r;if(d.default.object(e)&&!d.default.urlInstance(e))r={...s,...e,...r};else{if(e&&r&&r.url!==void 0)throw new TypeError("The `url` option is mutually exclusive with the `input` argument");r={...s,...r},e!==void 0&&(r.url=e),d.default.urlInstance(r.url)&&(r.url=new G.URL(r.url.toString()))}if(r.cache===!1&&(r.cache=void 0),r.dnsCache===!1&&(r.dnsCache=void 0),d.assert.any([d.default.string,d.default.undefined],r.method),d.assert.any([d.default.object,d.default.undefined],r.headers),d.assert.any([d.default.string,d.default.urlInstance,d.default.undefined],r.prefixUrl),d.assert.any([d.default.object,d.default.undefined],r.cookieJar),d.assert.any([d.default.object,d.default.string,d.default.undefined],r.searchParams),d.assert.any([d.default.object,d.default.string,d.default.undefined],r.cache),d.assert.any([d.default.object,d.default.number,d.default.undefined],r.timeout),d.assert.any([d.default.object,d.default.undefined],r.context),d.assert.any([d.default.object,d.default.undefined],r.hooks),d.assert.any([d.default.boolean,d.default.undefined],r.decompress),d.assert.any([d.default.boolean,d.default.undefined],r.ignoreInvalidCookies),d.assert.any([d.default.boolean,d.default.undefined],r.followRedirect),d.assert.any([d.default.number,d.default.undefined],r.maxRedirects),d.assert.any([d.default.boolean,d.default.undefined],r.throwHttpErrors),d.assert.any([d.default.boolean,d.default.undefined],r.http2),d.assert.any([d.default.boolean,d.default.undefined],r.allowGetBody),d.assert.any([d.default.string,d.default.undefined],r.localAddress),d.assert.any([Mn.isDnsLookupIpVersion,d.default.undefined],r.dnsLookupIpVersion),d.assert.any([d.default.object,d.default.undefined],r.https),d.assert.any([d.default.boolean,d.default.undefined],r.rejectUnauthorized),r.https&&(d.assert.any([d.default.boolean,d.default.undefined],r.https.rejectUnauthorized),d.assert.any([d.default.function_,d.default.undefined],r.https.checkServerIdentity),d.assert.any([d.default.string,d.default.object,d.default.array,d.default.undefined],r.https.certificateAuthority),d.assert.any([d.default.string,d.default.object,d.default.array,d.default.undefined],r.https.key),d.assert.any([d.default.string,d.default.object,d.default.array,d.default.undefined],r.https.certificate),d.assert.any([d.default.string,d.default.undefined],r.https.passphrase),d.assert.any([d.default.string,d.default.buffer,d.default.array,d.default.undefined],r.https.pfx)),d.assert.any([d.default.object,d.default.undefined],r.cacheOptions),d.default.string(r.method)?r.method=r.method.toUpperCase():r.method="GET",r.headers===(s==null?void 0:s.headers)?r.headers={...r.headers}:r.headers=fc({...s==null?void 0:s.headers,...r.headers}),"slashes"in r)throw new TypeError("The legacy `url.Url` has been deprecated. Use `URL` instead.");if("auth"in r)throw new TypeError("Parameter `auth` is deprecated. Use `username` / `password` instead.");if("searchParams"in r&&r.searchParams&&r.searchParams!==(s==null?void 0:s.searchParams)){let p;if(d.default.string(r.searchParams)||r.searchParams instanceof G.URLSearchParams)p=new G.URLSearchParams(r.searchParams);else{Sc(r.searchParams),p=new G.URLSearchParams;for(let g in r.searchParams){let w=r.searchParams[g];w===null?p.append(g,""):w!==void 0&&p.append(g,w)}}(n=s==null?void 0:s.searchParams)===null||n===void 0||n.forEach((g,w)=>{p.has(w)||p.append(w,g)}),r.searchParams=p}if(r.username=(o=r.username)!==null&&o!==void 0?o:"",r.password=(i=r.password)!==null&&i!==void 0?i:"",d.default.undefined(r.prefixUrl)?r.prefixUrl=(a=s==null?void 0:s.prefixUrl)!==null&&a!==void 0?a:"":(r.prefixUrl=r.prefixUrl.toString(),r.prefixUrl!==""&&!r.prefixUrl.endsWith("/")&&(r.prefixUrl+="/")),d.default.string(r.url)){if(r.url.startsWith("/"))throw new Error("`input` must not start with a slash when using `prefixUrl`");r.url=Ln.default(r.prefixUrl+r.url,r)}else(d.default.undefined(r.url)&&r.prefixUrl!==""||r.protocol)&&(r.url=Ln.default(r.prefixUrl,r));if(r.url){"port"in r&&delete r.port;let{prefixUrl:p}=r;Object.defineProperty(r,"prefixUrl",{set:w=>{let f=r.url;if(!f.href.startsWith(w))throw new Error(`Cannot change \`prefixUrl\` from ${p} to ${w}: ${f.href}`);r.url=new G.URL(w+f.href.slice(p.length)),p=w},get:()=>p});let{protocol:g}=r.url;if(g==="unix:"&&(g="http:",r.url=new G.URL(`http://unix${r.url.pathname}${r.url.search}`)),r.searchParams&&(r.url.search=r.searchParams.toString()),g!=="http:"&&g!=="https:")throw new tt(r);r.username===""?r.username=r.url.username:r.url.username=r.username,r.password===""?r.password=r.url.password:r.url.password=r.password}let{cookieJar:m}=r;if(m){let{setCookie:p,getCookieString:g}=m;d.assert.function_(p),d.assert.function_(g),p.length===4&&g.length===0&&(p=xn.promisify(p.bind(r.cookieJar)),g=xn.promisify(g.bind(r.cookieJar)),r.cookieJar={setCookie:p,getCookieString:g})}let{cache:h}=r;if(h&&(_r.has(h)||_r.set(h,new jn(((p,g)=>{let w=p[k](p,g);return d.default.promise(w)&&(w.once=(f,v)=>{if(f==="error")w.catch(v);else if(f==="abort")(async()=>{try{(await w).once("abort",v)}catch{}})();else throw new Error(`Unknown HTTP2 promise event: ${f}`);return w}),w}),h))),r.cacheOptions={...r.cacheOptions},r.dnsCache===!0)yr||(yr=new lc.default),r.dnsCache=yr;else if(!d.default.undefined(r.dnsCache)&&!r.dnsCache.lookup)throw new TypeError(`Parameter \`dnsCache\` must be a CacheableLookup instance or a boolean, got ${d.default(r.dnsCache)}`);d.default.number(r.timeout)?r.timeout={request:r.timeout}:s&&r.timeout!==s.timeout?r.timeout={...s.timeout,...r.timeout}:r.timeout={...r.timeout},r.context||(r.context={});let y=r.hooks===(s==null?void 0:s.hooks);r.hooks={...r.hooks};for(let p of E.knownHookEvents)if(p in r.hooks)if(d.default.array(r.hooks[p]))r.hooks[p]=[...r.hooks[p]];else throw new TypeError(`Parameter \`${p}\` must be an Array, got ${d.default(r.hooks[p])}`);else r.hooks[p]=[];if(s&&!y)for(let p of E.knownHookEvents)s.hooks[p].length>0&&(r.hooks[p]=[...s.hooks[p],...r.hooks[p]]);if("family"in r&&J.default('"options.family" was never documented, please use "options.dnsLookupIpVersion"'),s!=null&&s.https&&(r.https={...s.https,...r.https}),"rejectUnauthorized"in r&&J.default('"options.rejectUnauthorized" is now deprecated, please use "options.https.rejectUnauthorized"'),"checkServerIdentity"in r&&J.default('"options.checkServerIdentity" was never documented, please use "options.https.checkServerIdentity"'),"ca"in r&&J.default('"options.ca" was never documented, please use "options.https.certificateAuthority"'),"key"in r&&J.default('"options.key" was never documented, please use "options.https.key"'),"cert"in r&&J.default('"options.cert" was never documented, please use "options.https.certificate"'),"passphrase"in r&&J.default('"options.passphrase" was never documented, please use "options.https.passphrase"'),"pfx"in r&&J.default('"options.pfx" was never documented, please use "options.https.pfx"'),"followRedirects"in r)throw new TypeError("The `followRedirects` option does not exist. Use `followRedirect` instead.");if(r.agent){for(let p in r.agent)if(p!=="http"&&p!=="https"&&p!=="http2")throw new TypeError(`Expected the \`options.agent\` properties to be \`http\`, \`https\` or \`http2\`, got \`${p}\``)}return r.maxRedirects=(u=r.maxRedirects)!==null&&u!==void 0?u:0,E.setNonEnumerableProperties([s,l],r),wc.default(r,s)}_lockWrite(){let e=()=>{throw new TypeError("The payload has been already provided")};this.write=e,this.end=e}_unlockWrite(){this.write=super.write,this.end=super.end}async _finalizeBody(){let{options:e}=this,{headers:r}=e,s=!d.default.undefined(e.form),n=!d.default.undefined(e.json),o=!d.default.undefined(e.body),i=s||n||o,a=E.withoutBody.has(e.method)&&!(e.method==="GET"&&e.allowGetBody);if(this._cannotHaveBody=a,i){if(a)throw new TypeError(`The \`${e.method}\` method cannot be used with a body`);if([o,s,n].filter(u=>u).length>1)throw new TypeError("The `body`, `json` and `form` options are mutually exclusive");if(o&&!(e.body instanceof An.Readable)&&!d.default.string(e.body)&&!d.default.buffer(e.body)&&!Hn.default(e.body))throw new TypeError("The `body` option must be a stream.Readable, string or Buffer");if(s&&!d.default.object(e.form))throw new TypeError("The `form` option must be an Object");{let u=!d.default.string(r["content-type"]);o?(Hn.default(e.body)&&u&&(r["content-type"]=`multipart/form-data; boundary=${e.body.getBoundary()}`),this[K]=e.body):s?(u&&(r["content-type"]="application/x-www-form-urlencoded"),this[K]=new G.URLSearchParams(e.form).toString()):(u&&(r["content-type"]="application/json"),this[K]=e.stringifyJson(e.json));let l=await pc.default(this[K],e.headers);d.default.undefined(r["content-length"])&&d.default.undefined(r["transfer-encoding"])&&!a&&!d.default.undefined(l)&&(r["content-length"]=String(l))}}else a?this._lockWrite():this._unlockWrite();this[ce]=Number(r["content-length"])||void 0}async _onResponseBase(e){let{options:r}=this,{url:s}=r;this[Fn]=e,r.decompress&&(e=dc(e));let n=e.statusCode,o=e;o.statusMessage=o.statusMessage?o.statusMessage:qn.STATUS_CODES[n],o.url=r.url.toString(),o.requestUrl=this.requestUrl,o.redirectUrls=this.redirects,o.request=this,o.isFromCache=e.fromCache||!1,o.ip=this.ip,o.retryCount=this.retryCount,this[Un]=o.isFromCache,this[oe]=Number(e.headers["content-length"])||void 0,this[Ke]=e,e.once("end",()=>{this[oe]=this[ae],this.emit("downloadProgress",this.downloadProgress)}),e.once("error",a=>{e.destroy(),this._beforeError(new Re(a,this))}),e.once("aborted",()=>{this._beforeError(new Re({name:"Error",message:"The server aborted pending request",code:"ECONNRESET"},this))}),this.emit("downloadProgress",this.downloadProgress);let i=e.headers["set-cookie"];if(d.default.object(r.cookieJar)&&i){let a=i.map(async u=>r.cookieJar.setCookie(u,s.toString()));r.ignoreInvalidCookies&&(a=a.map(async u=>u.catch(()=>{})));try{await Promise.all(a)}catch(u){this._beforeError(u);return}}if(r.followRedirect&&e.headers.location&&Rc.has(n)){if(e.resume(),this[k]&&(this[gr](),delete this[k],this[Dn]()),(n===303&&r.method!=="GET"&&r.method!=="HEAD"||!r.methodRewriting)&&(r.method="GET","body"in r&&delete r.body,"json"in r&&delete r.json,"form"in r&&delete r.form,this[K]=void 0,delete r.headers["content-length"]),this.redirects.length>=r.maxRedirects){this._beforeError(new Qe(this));return}try{let h=function(y){return y.protocol==="unix:"||y.hostname==="unix"},u=Buffer.from(e.headers.location,"binary").toString(),l=new G.URL(u,s),m=l.toString();if(decodeURI(m),!h(s)&&h(l)){this._beforeError(new R("Cannot redirect to UNIX socket",{},this));return}l.hostname!==s.hostname||l.port!==s.port?("host"in r.headers&&delete r.headers.host,"cookie"in r.headers&&delete r.headers.cookie,"authorization"in r.headers&&delete r.headers.authorization,(r.username||r.password)&&(r.username="",r.password="")):(l.username=r.username,l.password=r.password),this.redirects.push(m),r.url=l;for(let y of r.hooks.beforeRedirect)await y(r,o);this.emit("redirect",o,r),await this._makeRequest()}catch(u){this._beforeError(u);return}return}if(r.isStream&&r.throwHttpErrors&&!bc.isResponseOk(o)){this._beforeError(new Xe(o));return}e.on("readable",()=>{this[Je]&&this._read()}),this.on("resume",()=>{e.resume()}),this.on("pause",()=>{e.pause()}),e.once("end",()=>{this.push(null)}),this.emit("response",e);for(let a of this[Ge])if(!a.headersSent){for(let u in e.headers){let l=r.decompress?u!=="content-encoding":!0,m=e.headers[u];l&&a.setHeader(u,m)}a.statusCode=n}}async _onResponse(e){try{await this._onResponseBase(e)}catch(r){this._beforeError(r)}} |