diff --git a/novastar-switcher/.build-info b/novastar-switcher/.build-info index c486cdb2..5767927e 100644 --- a/novastar-switcher/.build-info +++ b/novastar-switcher/.build-info @@ -1,4 +1,4 @@ MODULE_NAME=novastar-switcher -GIT_REF=v1.2.1 -RUN_URL=https://github.com/bitfocus/companion-bundled-modules/actions/runs/7413817596 -UPDATE_DATE=2024-01-04 +GIT_REF=v1.3.0 +RUN_URL=https://github.com/bitfocus/companion-bundled-modules/actions/runs/11002066440 +UPDATE_DATE=2024-09-23 diff --git a/novastar-switcher/companion/HELP.md b/novastar-switcher/companion/HELP.md index 2e219c5a..eadc6f0e 100644 --- a/novastar-switcher/companion/HELP.md +++ b/novastar-switcher/companion/HELP.md @@ -14,9 +14,19 @@ This module will allow you to control the following Nuowaxingyun products: N10, - Freeze - Preset - Preset Destination +- Screens +- Layers +- Sources +- SwapCopy +- MatchPgm +- Take Time- +- Take Time+ +- Mapping **Available Feedbacks:** - FTB Status Detection - Freeze Status Detection - PGM Status Detection +- SwapCopy Status Detection +- Mapping Status Detection \ No newline at end of file diff --git a/novastar-switcher/companion/manifest.json b/novastar-switcher/companion/manifest.json index d2c288ea..9b08717a 100644 --- a/novastar-switcher/companion/manifest.json +++ b/novastar-switcher/companion/manifest.json @@ -1 +1 @@ -{"id":"novastar-switcher","name":"novastar-switcher","shortname":"switcher","description":"Companion module for Nuowaxingyun Switcher Devices","version":"1.2.1","license":"MIT","repository":"git+https://github.com/bitfocus/companion-module-novastar-switcher.git","bugs":"https://github.com/bitfocus/companion-module-novastar-switcher/issues","maintainers":[{"name":"NovastarQQ","email":"qiqi@novastar.tech"}],"runtime":{"type":"node18","api":"nodejs-ipc","apiVersion":"1.5.1","entrypoint":"../main.js"},"legacyIds":["novastar-unico","novastar-d12"],"manufacturer":"Nuowaxingyun","products":["N10","N20","D12","D32"],"keywords":["Nuowaxingyun","Novastar"]} \ No newline at end of file +{"id":"novastar-switcher","name":"novastar-switcher","shortname":"switcher","description":"Companion module for Nuowaxingyun Switcher Devices","version":"1.3.0","license":"MIT","repository":"git+https://github.com/bitfocus/companion-module-novastar-switcher.git","bugs":"https://github.com/bitfocus/companion-module-novastar-switcher/issues","maintainers":[{"name":"NovaStar","email":"software@novastar.tech"}],"runtime":{"type":"node18","api":"nodejs-ipc","apiVersion":"1.5.1","entrypoint":"../main.js"},"legacyIds":["novastar-unico","novastar-d12"],"manufacturer":"NovaStar","products":["N10","N20","D12","D32"],"keywords":["Nuowaxingyun","NovaStar"]} \ No newline at end of file diff --git a/novastar-switcher/main.js b/novastar-switcher/main.js index a94f102e..88807d7e 100644 --- a/novastar-switcher/main.js +++ b/novastar-switcher/main.js @@ -1 +1,2 @@ -(()=>{var e={7056:(e,t,n)=>{"use strict";const s=n(4063);s.code='require("ajv/dist/runtime/equal").default',t.Z=s},7513:(e,t,n)=>{"use strict";n.d(t,{X:()=>s});const s="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__},758:(e,t,n)=>{"use strict";n.d(t,{r:()=>r});var s=n(5659),o=n(1283),i=n(2176);function r(){(0,o.T)(),(0,i.KV)()&&function(){const t=(0,s.cu)();if(!t.__SENTRY__)return;const n={mongodb:()=>new((0,i.l$)(e,"./node/integrations/mongo").Mongo),mongoose:()=>new((0,i.l$)(e,"./node/integrations/mongo").Mongo),mysql:()=>new((0,i.l$)(e,"./node/integrations/mysql").Mysql),pg:()=>new((0,i.l$)(e,"./node/integrations/postgres").Postgres)},o=Object.keys(n).filter((e=>!!(0,i.$y)(e))).map((e=>{try{return n[e]()}catch(e){return}})).filter((e=>e));o.length>0&&(t.__SENTRY__.integrations=[...t.__SENTRY__.integrations||[],...o])}()}e=n.hmd(e)},2716:(e,t,n)=>{"use strict";n.d(t,{_:()=>d});var s=n(4307),o=n(2176),i=n(2343),r=n(535),a=n(2844),c=n(7597),l=n(7513),g=n(7990);class d{static __initStatic(){this.id="Apollo"}constructor(e={useNestjs:!1}){this.name=d.id,this._useNest=!!e.useNestjs}loadDependency(){return this._useNest?this._module=this._module||(0,o.$y)("@nestjs/graphql"):this._module=this._module||(0,o.$y)("apollo-server-core"),this._module}setupOnce(e,t){if((0,g.K)(t))l.X&&i.kg.log("Apollo Integration is skipped because of instrumenter configuration.");else if(this._useNest){const e=this.loadDependency();if(!e)return void(l.X&&i.kg.error("Apollo-NestJS Integration was unable to require @nestjs/graphql package."));(0,r.hl)(e.GraphQLFactory.prototype,"mergeWithSchema",(function(e){return function(...n){return(0,r.hl)(this.resolversExplorerService,"explore",(function(e){return function(){return u((0,a.lE)(e.call(this)),t)}})),e.call(this,...n)}}))}else{const e=this.loadDependency();if(!e)return void(l.X&&i.kg.error("Apollo Integration was unable to require apollo-server-core package."));(0,r.hl)(e.ApolloServerBase.prototype,"constructSchema",(function(e){return function(){if(!this.config.resolvers)return l.X&&(this.config.schema?(i.kg.warn("Apollo integration is not able to trace `ApolloServer` instances constructed via `schema` property.If you are using NestJS with Apollo, please use `Sentry.Integrations.Apollo({ useNestjs: true })` instead."),i.kg.warn()):this.config.modules&&i.kg.warn("Apollo integration is not able to trace `ApolloServer` instances constructed via `modules` property."),i.kg.error("Skipping tracing as no resolvers found on the `ApolloServer` instance.")),e.call(this);const n=(0,a.lE)(this.config.resolvers);return this.config.resolvers=u(n,t),e.call(this)}}))}}}function u(e,t){return e.map((e=>(Object.keys(e).forEach((n=>{Object.keys(e[n]).forEach((o=>{"function"==typeof e[n][o]&&function(e,t,n,o){(0,r.hl)(e[t],n,(function(e){return function(...i){const r=o().getScope().getSpan(),a=(0,s.x)([r,"optionalAccess",e=>e.startChild,"call",e=>e({description:`${t}.${n}`,op:"graphql.resolve",origin:"auto.graphql.apollo"})]),l=e.call(this,...i);return(0,c.J8)(l)?l.then((e=>((0,s.x)([a,"optionalAccess",e=>e.end,"call",e=>e()]),e))):((0,s.x)([a,"optionalAccess",e=>e.end,"call",e=>e()]),l)}}))}(e,n,o,t)}))})),e)))}d.__initStatic()},8737:(e,t,n)=>{"use strict";n.d(t,{N1:()=>d});var s=n(4307),o=n(2343),i=n(6956),r=n(771),a=n(7597),c=n(1235),l=n(7513),g=n(7990);class d{static __initStatic(){this.id="Express"}constructor(e={}){this.name=d.id,this._router=e.router||e.app,this._methods=(Array.isArray(e.methods)?e.methods:[]).concat("use")}setupOnce(e,t){this._router?(0,g.K)(t)?l.X&&o.kg.log("Express Integration is skipped because of instrumenter configuration."):(function(e,t=[]){t.forEach((t=>function(e,t){const n=e[t];return e[t]=function(...e){return n.call(this,...function(e,t){return e.map((e=>"function"==typeof e?u(e,t):Array.isArray(e)?e.map((e=>"function"==typeof e?u(e,t):e)):e))}(e,t))},e}(e,t)))}(this._router,this._methods),function(e){const t="settings"in e;t&&void 0===e._router&&e.lazyrouter&&e.lazyrouter();const n=t?e._router:e;if(!n)return l.X&&o.kg.debug("Cannot instrument router for URL Parameterization (did not find a valid router)."),void(l.X&&o.kg.debug("Routing instrumentation is currently only supported in Express 4."));const g=Object.getPrototypeOf(n),d=g.process_params;g.process_params=function(e,t,n,o,l){n._reconstructedRoute||(n._reconstructedRoute="");const{layerRoutePath:g,isRegex:u,isArray:I,numExtraSegments:p}=function(e){let t=(0,s.x)([e,"access",e=>e.route,"optionalAccess",e=>e.path]);const n=(0,a.Kj)(t),o=Array.isArray(t);if(!t){const[n]=c.n2.process.versions.node.split(".").map(Number);n>=16&&(t=h(e.path,e.regexp,e.keys))}if(!t)return{isRegex:n,isArray:o,numExtraSegments:0};const r=o?Math.max(t.reduce(((e,t)=>e+(0,i.$A)(t.toString())),0)-(0,i.$A)(e.path||""),0):0,l=function(e,t){return e?t.map((e=>e.toString())).join(","):t&&t.toString()}(o,t);return{layerRoutePath:l,isRegex:n,isArray:o,numExtraSegments:r}}(e);let C;(g||u||I)&&(n._hasParameters=!0),C=g||function(e,t,n){const o=(0,i.rt)(e||""),r=(0,s.x)([o,"optionalAccess",e=>e.split,"call",e=>e("/"),"access",e=>e.filter,"call",e=>e((e=>!!e))]);let a=0;const c=(0,s.x)([t,"optionalAccess",e=>e.split,"call",e=>e("/"),"access",e=>e.filter,"call",e=>e((e=>!!e)),"access",e=>e.length])||0;return(0,s.x)([n,"optionalAccess",e=>e.split,"call",e=>e("/"),"access",e=>e.filter,"call",e=>e((e=>(0,s.x)([r,"optionalAccess",e=>e[c+a]])===e&&(a+=1,!0))),"access",e=>e.join,"call",e=>e("/")])}(n.originalUrl,n._reconstructedRoute,e.path)||"";const m=C.split("/").filter((e=>e.length>0&&(u||I||!e.includes("*")))).join("/");if(m&&m.length>0&&(n._reconstructedRoute+=`/${m}${u?"/":""}`),(0,i.$A)((0,i.rt)(n.originalUrl||""))+p===(0,i.$A)(n._reconstructedRoute)){n._hasParameters||n._reconstructedRoute!==n.originalUrl&&(n._reconstructedRoute=n.originalUrl?(0,i.rt)(n.originalUrl):n.originalUrl);const e=o.__sentry_transaction;if(e&&"custom"!==e.metadata.source){const t=n._reconstructedRoute||"/",[s,o]=(0,r.oA)(n,{path:!0,method:!0,customRoute:t});e.updateName(s),e.setMetadata({source:o})}}return d.call(this,e,t,n,o,l)}}(this._router)):l.X&&o.kg.error("ExpressIntegration is missing an Express instance")}}function u(e,t){const n=e.length;switch(n){case 2:return function(n,s){const o=s.__sentry_transaction;if(o){const n=o.startChild({description:e.name,op:`middleware.express.${t}`,origin:"auto.middleware.express"});s.once("finish",(()=>{n.end()}))}return e.call(this,n,s)};case 3:return function(n,o,i){const r=o.__sentry_transaction,a=(0,s.x)([r,"optionalAccess",e=>e.startChild,"call",n=>n({description:e.name,op:`middleware.express.${t}`,origin:"auto.middleware.express"})]);e.call(this,n,o,(function(...e){(0,s.x)([a,"optionalAccess",e=>e.end,"call",e=>e()]),i.call(this,...e)}))};case 4:return function(n,o,i,r){const a=i.__sentry_transaction,c=(0,s.x)([a,"optionalAccess",e=>e.startChild,"call",n=>n({description:e.name,op:`middleware.express.${t}`,origin:"auto.middleware.express"})]);e.call(this,n,o,i,(function(...e){(0,s.x)([c,"optionalAccess",e=>e.end,"call",e=>e()]),r.call(this,...e)}))};default:throw new Error(`Express middleware takes 2-4 arguments. Got: ${n}`)}}d.__initStatic();const h=(e,t,n)=>{if(!(e&&t&&n&&0!==Object.keys(n).length&&(0,s.x)([n,"access",e=>e[0],"optionalAccess",e=>e.offset])))return;const o=n.sort(((e,t)=>e.offset-t.offset)),i=new RegExp(t,`${t.flags}d`).exec(e);if(!i||!i.indices)return;const[,...r]=i.indices;if(r.length!==o.length)return;let a=e,c=0;return r.forEach(((e,t)=>{if(e){const[n,s]=e,i=a.substring(0,n-c),r=`:${o[t].name}`,l=a.substring(s-c);a=i+r+l,c+=s-n-r.length}})),a}},1791:(e,t,n)=>{"use strict";n.d(t,{k:()=>g});var s=n(4307),o=n(2176),i=n(2343),r=n(535),a=n(7597),c=n(7513),l=n(7990);class g{static __initStatic(){this.id="GraphQL"}constructor(){this.name=g.id}loadDependency(){return this._module=this._module||(0,o.$y)("graphql/execution/execute.js")}setupOnce(e,t){if((0,l.K)(t))return void(c.X&&i.kg.log("GraphQL Integration is skipped because of instrumenter configuration."));const n=this.loadDependency();n?(0,r.hl)(n,"execute",(function(e){return function(...n){const o=t().getScope(),i=o.getSpan(),r=(0,s.x)([i,"optionalAccess",e=>e.startChild,"call",e=>e({description:"execute",op:"graphql.execute",origin:"auto.graphql.graphql"})]);(0,s.x)([o,"optionalAccess",e=>e.setSpan,"call",e=>e(r)]);const c=e.call(this,...n);return(0,a.J8)(c)?c.then((e=>((0,s.x)([r,"optionalAccess",e=>e.end,"call",e=>e()]),(0,s.x)([o,"optionalAccess",e=>e.setSpan,"call",e=>e(i)]),e))):((0,s.x)([r,"optionalAccess",e=>e.end,"call",e=>e()]),(0,s.x)([o,"optionalAccess",e=>e.setSpan,"call",e=>e(i)]),c)}})):c.X&&i.kg.error("GraphQL Integration was unable to require graphql/execution package.")}}g.__initStatic()},6046:(e,t,n)=>{"use strict";n.d(t,{G:()=>o});var s=n(2176);e=n.hmd(e);const o=[()=>new((0,s.l$)(e,"./apollo").Apollo),()=>new((0,s.l$)(e,"./apollo").Apollo)({useNestjs:!0}),()=>new((0,s.l$)(e,"./graphql").GraphQL),()=>new((0,s.l$)(e,"./mongo").Mongo),()=>new((0,s.l$)(e,"./mongo").Mongo)({mongoose:!0}),()=>new((0,s.l$)(e,"./mysql").Mysql),()=>new((0,s.l$)(e,"./postgres").Postgres)]},6169:(e,t,n)=>{"use strict";n.d(t,{_:()=>u});var s=n(4307),o=n(2176),i=n(2343),r=n(535),a=n(7597),c=n(7513),l=n(7990);const g=["aggregate","bulkWrite","countDocuments","createIndex","createIndexes","deleteMany","deleteOne","distinct","drop","dropIndex","dropIndexes","estimatedDocumentCount","find","findOne","findOneAndDelete","findOneAndReplace","findOneAndUpdate","indexes","indexExists","indexInformation","initializeOrderedBulkOp","insertMany","insertOne","isCapped","mapReduce","options","parallelCollectionScan","rename","replaceOne","stats","updateMany","updateOne"],d={bulkWrite:["operations"],countDocuments:["query"],createIndex:["fieldOrSpec"],createIndexes:["indexSpecs"],deleteMany:["filter"],deleteOne:["filter"],distinct:["key","query"],dropIndex:["indexName"],find:["query"],findOne:["query"],findOneAndDelete:["filter"],findOneAndReplace:["filter","replacement"],findOneAndUpdate:["filter","update"],indexExists:["indexes"],insertMany:["docs"],insertOne:["doc"],mapReduce:["map","reduce"],rename:["newName"],replaceOne:["filter","doc"],updateMany:["filter","update"],updateOne:["filter","update"]};class u{static __initStatic(){this.id="Mongo"}constructor(e={}){this.name=u.id,this._operations=Array.isArray(e.operations)?e.operations:g,this._describeOperations=!("describeOperations"in e)||e.describeOperations,this._useMongoose=!!e.useMongoose}loadDependency(){const e=this._useMongoose?"mongoose":"mongodb";return this._module=this._module||(0,o.$y)(e)}setupOnce(e,t){if((0,l.K)(t))return void(c.X&&i.kg.log("Mongo Integration is skipped because of instrumenter configuration."));const n=this.loadDependency();if(n)this._instrumentOperations(n.Collection,this._operations,t);else{const e=this._useMongoose?"mongoose":"mongodb";c.X&&i.kg.error(`Mongo Integration was unable to require \`${e}\` package.`)}}_instrumentOperations(e,t,n){t.forEach((t=>this._patchOperation(e,t,n)))}_patchOperation(e,t,n){if(!(t in e.prototype))return;const o=this._getSpanContextFromOperationArguments.bind(this);(0,r.hl)(e.prototype,t,(function(e){return function(...i){const r=i[i.length-1],c=n().getScope().getSpan();if("function"!=typeof r||"mapReduce"===t&&2===i.length){const n=(0,s.x)([c,"optionalAccess",e=>e.startChild,"call",e=>e(o(this,t,i))]),r=e.call(this,...i);if((0,a.J8)(r))return r.then((e=>((0,s.x)([n,"optionalAccess",e=>e.end,"call",e=>e()]),e)));if((l=r)&&"object"==typeof l&&l.once&&"function"==typeof l.once){const e=r;try{e.once("close",(()=>{(0,s.x)([n,"optionalAccess",e=>e.end,"call",e=>e()])}))}catch(e){(0,s.x)([n,"optionalAccess",e=>e.end,"call",e=>e()])}return e}return(0,s.x)([n,"optionalAccess",e=>e.end,"call",e=>e()]),r}var l;const g=(0,s.x)([c,"optionalAccess",e=>e.startChild,"call",e=>e(o(this,t,i.slice(0,-1)))]);return e.call(this,...i.slice(0,-1),(function(e,t){(0,s.x)([g,"optionalAccess",e=>e.end,"call",e=>e()]),r(e,t)}))}}))}_getSpanContextFromOperationArguments(e,t,n){const s={"db.system":"mongodb","db.name":e.dbName,"db.operation":t,"db.mongodb.collection":e.collectionName},o={op:"db",origin:"auto.db.mongo",description:t,data:s},i=d[t],r=Array.isArray(this._describeOperations)?this._describeOperations.includes(t):this._describeOperations;if(!i||!r)return o;try{if("mapReduce"===t){const[e,t]=n;s[i[0]]="string"==typeof e?e:e.name||"",s[i[1]]="string"==typeof t?t:t.name||""}else for(let e=0;e{"use strict";n.d(t,{m:()=>l});var s=n(4307),o=n(2176),i=n(2343),r=n(535),a=n(7513),c=n(7990);class l{static __initStatic(){this.id="Mysql"}constructor(){this.name=l.id}loadDependency(){return this._module=this._module||(0,o.$y)("mysql/lib/Connection.js")}setupOnce(e,t){if((0,c.K)(t))return void(a.X&&i.kg.log("Mysql Integration is skipped because of instrumenter configuration."));const n=this.loadDependency();if(!n)return void(a.X&&i.kg.error("Mysql Integration was unable to require `mysql` package."));let o;try{n.prototype.connect=new Proxy(n.prototype.connect,{apply:(e,t,n)=>(o||(o=t.config),e.apply(t,n))})}catch(e){a.X&&i.kg.error("Mysql Integration was unable to instrument `mysql` config.")}function l(e){if(!e||e.endTimestamp)return;const t=o?{"server.address":o.host,"server.port":o.port,"db.user":o.user}:{};Object.keys(t).forEach((n=>{e.setData(n,t[n])})),e.end()}(0,r.hl)(n,"createQuery",(function(e){return function(n,o,i){const r=t().getScope().getSpan(),a=(0,s.x)([r,"optionalAccess",e=>e.startChild,"call",e=>e({description:"string"==typeof n?n:n.sql,op:"db",origin:"auto.db.mysql",data:{"db.system":"mysql"}})]);if("function"==typeof i)return e.call(this,n,o,(function(e,t,n){l(a),i(e,t,n)}));if("function"==typeof o)return e.call(this,n,(function(e,t,n){l(a),o(e,t,n)}));const c=e.call(this,n,o);return c.on("end",(()=>{l(a)})),c}}))}}l.__initStatic()},1370:(e,t,n)=>{"use strict";n.d(t,{E:()=>g});var s=n(4307),o=n(2176),i=n(2343),r=n(535),a=n(7597),c=n(7513),l=n(7990);class g{static __initStatic(){this.id="Postgres"}constructor(e={}){this.name=g.id,this._usePgNative=!!e.usePgNative,this._module=e.module}loadDependency(){return this._module=this._module||(0,o.$y)("pg")}setupOnce(e,t){if((0,l.K)(t))return void(c.X&&i.kg.log("Postgres Integration is skipped because of instrumenter configuration."));const n=this.loadDependency();if(!n)return void(c.X&&i.kg.error("Postgres Integration was unable to require `pg` package."));const o=this._usePgNative?(0,s.x)([n,"access",e=>e.native,"optionalAccess",e=>e.Client]):n.Client;o?(0,r.hl)(o.prototype,"query",(function(e){return function(n,o,i){const r=t().getScope().getSpan(),c={"db.system":"postgresql"};try{this.database&&(c["db.name"]=this.database),this.host&&(c["server.address"]=this.host),this.port&&(c["server.port"]=this.port),this.user&&(c["db.user"]=this.user)}catch(e){}const l=(0,s.x)([r,"optionalAccess",e=>e.startChild,"call",e=>e({description:"string"==typeof n?n:n.text,op:"db",origin:"auto.db.postgres",data:c})]);if("function"==typeof i)return e.call(this,n,o,(function(e,t){(0,s.x)([l,"optionalAccess",e=>e.end,"call",e=>e()]),i(e,t)}));if("function"==typeof o)return e.call(this,n,(function(e,t){(0,s.x)([l,"optionalAccess",e=>e.end,"call",e=>e()]),o(e,t)}));const g=void 0!==o?e.call(this,n,o):e.call(this,n);return(0,a.J8)(g)?g.then((e=>((0,s.x)([l,"optionalAccess",e=>e.end,"call",e=>e()]),e))):((0,s.x)([l,"optionalAccess",e=>e.end,"call",e=>e()]),g)}})):c.X&&i.kg.error("Postgres Integration was unable to access 'pg-native' bindings.")}}g.__initStatic()},9889:(e,t,n)=>{"use strict";n.d(t,{g:()=>l});var s=n(5659),o=n(4317),i=n(535),r=n(2343),a=n(7513),c=n(7990);class l{static __initStatic(){this.id="Prisma"}constructor(e={}){if(this.name=l.id,(t=e.client)&&t.$use&&!e.client._sentryInstrumented){(0,i.xp)(e.client,"_sentryInstrumented",!0);const t={};try{const n=e.client._engineConfig;if(n){const{activeProvider:e,clientVersion:s}=n;e&&(t["db.system"]=e),s&&(t["db.prisma.version"]=s)}}catch(e){}e.client.$use(((e,n)=>{if((0,c.K)(s.Gd))return n(e);const i=e.action,r=e.model;return(0,o.GK)({name:r?`${r} ${i}`:i,op:"db.prisma",origin:"auto.db.prisma",data:{...t,"db.operation":i}},(()=>n(e)))}))}else a.X&&r.kg.warn("Unsupported Prisma client provided to PrismaIntegration. Provided client:",e.client);var t}setupOnce(){}}l.__initStatic()},7990:(e,t,n)=>{"use strict";n.d(t,{K:()=>o});var s=n(4307);function o(e){const t=(0,s.x)([e,"call",e=>e(),"access",e=>e.getClient,"call",e=>e(),"optionalAccess",e=>e.getOptions,"call",e=>e()]);return"sentry"!==((0,s.x)([t,"optionalAccess",e=>e.instrumenter])||"sentry")}},1131:(e,t,n)=>{"use strict";n.d(t,{J:()=>s});const s="production"},1703:(e,t,n)=>{"use strict";n.d(t,{X:()=>s});const s="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__},1195:(e,t,n)=>{"use strict";n.d(t,{RP:()=>g,cc:()=>l,fH:()=>c});var s=n(1235),o=n(6893),i=n(2343),r=n(7597),a=n(1703);function c(){return(0,s.YO)("globalEventProcessors",(()=>[]))}function l(e){c().push(e)}function g(e,t,n,s=0){return new o.cW(((o,c)=>{const l=e[s];if(null===t||"function"!=typeof l)o(t);else{const d=l({...t},n);a.X&&l.id&&null===d&&i.kg.log(`Event processor "${l.id}" dropped event`),(0,r.J8)(d)?d.then((t=>g(e,t,n,s+1).then(o))).then(null,c):g(e,d,n,s+1).then(o).then(null,c)}}))}},4487:(e,t,n)=>{"use strict";n.d(t,{$e:()=>Z,Tb:()=>g,YA:()=>y,Yr:()=>A,av:()=>f,c:()=>G,e:()=>h,eN:()=>u,eW:()=>V,mG:()=>b,nZ:()=>S,n_:()=>I,rJ:()=>C,s3:()=>w,sU:()=>m,sV:()=>B,uT:()=>d,v:()=>p,xv:()=>W,yl:()=>v});var s=n(2343),o=n(2844),i=n(1170),r=n(7597),a=n(1703),c=n(5659),l=n(8942);function g(e,t){return(0,c.Gd)().captureException(e,(0,l.U0)(t))}function d(e,t){const n="string"==typeof t?t:void 0,s="string"!=typeof t?{captureContext:t}:void 0;return(0,c.Gd)().captureMessage(e,n,s)}function u(e,t){return(0,c.Gd)().captureEvent(e,t)}function h(e){(0,c.Gd)().configureScope(e)}function I(e,t){(0,c.Gd)().addBreadcrumb(e,t)}function p(e,t){(0,c.Gd)().setContext(e,t)}function C(e){(0,c.Gd)().setExtras(e)}function m(e,t){(0,c.Gd)().setExtra(e,t)}function b(e){(0,c.Gd)().setTags(e)}function y(e,t){(0,c.Gd)().setTag(e,t)}function f(e){(0,c.Gd)().setUser(e)}function Z(e){return(0,c.Gd)().withScope(e)}function A(e,t){return(0,c.Gd)().startTransaction({...e},t)}function G(e,t){const n=S(),i=w();if(i){if(i.captureCheckIn)return i.captureCheckIn(e,t,n);a.X&&s.kg.warn("Cannot capture check-in. Client does not support sending check-ins.")}else a.X&&s.kg.warn("Cannot capture check-in. No client defined.");return(0,o.DM)()}function B(e,t,n){const s=G({monitorSlug:e,status:"in_progress"},n),o=(0,i.ph)();function a(t){G({monitorSlug:e,status:t,checkInId:s,duration:(0,i.ph)()-o})}let c;try{c=t()}catch(e){throw a("error"),e}return(0,r.J8)(c)?Promise.resolve(c).then((()=>{a("ok")}),(()=>{a("error")})):a("ok"),c}async function v(e){const t=w();return t?t.flush(e):(a.X&&s.kg.warn("Cannot flush events. No client defined."),Promise.resolve(!1))}async function W(e){const t=w();return t?t.close(e):(a.X&&s.kg.warn("Cannot flush events and disable SDK. No client defined."),Promise.resolve(!1))}function V(){return(0,c.Gd)().lastEventId()}function w(){return(0,c.Gd)().getClient()}function S(){return(0,c.Gd)().getScope()}},5659:(e,t,n)=>{"use strict";n.d(t,{$b:()=>A,Gd:()=>b,Ok:()=>G,Xb:()=>p,aF:()=>y,cu:()=>C,j0:()=>W,pj:()=>m,uZ:()=>Z,vi:()=>v});var s=n(7597),o=n(2844),i=n(1170),r=n(2343),a=n(1235),c=n(1131),l=n(1703),g=n(350),d=n(9015),u=n(105);const h=parseFloat(u.J),I=100;class p{constructor(e,t,n,s=h){let o,i;this._version=s,t?o=t:(o=new g.sX,o.setClient(e)),n?i=n:(i=new g.sX,i.setClient(e)),this._stack=[{scope:o}],e&&this.bindClient(e),this._isolationScope=i}isOlderThan(e){return this._version(this.popScope(),e)),(e=>{throw this.popScope(),e})):(this.popScope(),n)}getClient(){return this.getStackTop().client}getScope(){return this.getStackTop().scope}getIsolationScope(){return this._isolationScope}getStack(){return this._stack}getStackTop(){return this._stack[this._stack.length-1]}captureException(e,t){const n=this._lastEventId=t&&t.event_id?t.event_id:(0,o.DM)(),s=new Error("Sentry syntheticException");return this._withClient(((o,i)=>{o.captureException(e,{originalException:e,syntheticException:s,...t,event_id:n},i)})),n}captureMessage(e,t,n){const s=this._lastEventId=n&&n.event_id?n.event_id:(0,o.DM)(),i=new Error(e);return this._withClient(((o,r)=>{o.captureMessage(e,t,{originalException:e,syntheticException:i,...n,event_id:s},r)})),s}captureEvent(e,t){const n=t&&t.event_id?t.event_id:(0,o.DM)();return e.type||(this._lastEventId=n),this._withClient(((s,o)=>{s.captureEvent(e,{...t,event_id:n},o)})),n}lastEventId(){return this._lastEventId}addBreadcrumb(e,t){const{scope:n,client:s}=this.getStackTop();if(!s)return;const{beforeBreadcrumb:o=null,maxBreadcrumbs:a=I}=s.getOptions&&s.getOptions()||{};if(a<=0)return;const c={timestamp:(0,i.yW)(),...e},l=o?(0,r.Cf)((()=>o(c,t))):c;null!==l&&(s.emit&&s.emit("beforeAddBreadcrumb",l,t),n.addBreadcrumb(l,a))}setUser(e){this.getScope().setUser(e)}setTags(e){this.getScope().setTags(e)}setExtras(e){this.getScope().setExtras(e)}setTag(e,t){this.getScope().setTag(e,t)}setExtra(e,t){this.getScope().setExtra(e,t)}setContext(e,t){this.getScope().setContext(e,t)}configureScope(e){const{scope:t,client:n}=this.getStackTop();n&&e(t)}run(e){const t=m(this);try{e(this)}finally{m(t)}}getIntegration(e){const t=this.getClient();if(!t)return null;try{return t.getIntegration(e)}catch(t){return l.X&&r.kg.warn(`Cannot retrieve integration ${e.id} from the current Hub`),null}}startTransaction(e,t){const n=this._callExtensionMethod("startTransaction",e,t);return l.X&&!n&&(this.getClient()?r.kg.warn("Tracing extension 'startTransaction' has not been added. Call 'addTracingExtensions' before calling 'init':\nSentry.addTracingExtensions();\nSentry.init({...});\n"):r.kg.warn("Tracing extension 'startTransaction' is missing. You should 'init' the SDK before calling 'startTransaction'")),n}traceHeaders(){return this._callExtensionMethod("traceHeaders")}captureSession(e=!1){if(e)return this.endSession();this._sendSessionUpdate()}endSession(){const e=this.getStackTop().scope,t=e.getSession();t&&(0,d.RJ)(t),this._sendSessionUpdate(),e.setSession()}startSession(e){const{scope:t,client:n}=this.getStackTop(),{release:s,environment:o=c.J}=n&&n.getOptions()||{},{userAgent:i}=a.n2.navigator||{},r=(0,d.Hv)({release:s,environment:o,user:t.getUser(),...i&&{userAgent:i},...e}),l=t.getSession&&t.getSession();return l&&"ok"===l.status&&(0,d.CT)(l,{status:"exited"}),this.endSession(),t.setSession(r),r}shouldSendDefaultPii(){const e=this.getClient(),t=e&&e.getOptions();return Boolean(t&&t.sendDefaultPii)}_sendSessionUpdate(){const{scope:e,client:t}=this.getStackTop(),n=e.getSession();n&&t&&t.captureSession&&t.captureSession(n)}_withClient(e){const{scope:t,client:n}=this.getStackTop();n&&e(n,t)}_callExtensionMethod(e,...t){const n=C().__SENTRY__;if(n&&n.extensions&&"function"==typeof n.extensions[e])return n.extensions[e].apply(this,t);l.X&&r.kg.warn(`Extension method ${e} couldn't be found, doing nothing.`)}}function C(){return a.n2.__SENTRY__=a.n2.__SENTRY__||{extensions:{},hub:void 0},a.n2}function m(e){const t=C(),n=v(t);return W(t,e),n}function b(){const e=C();if(e.__SENTRY__&&e.__SENTRY__.acs){const t=e.__SENTRY__.acs.getCurrentHub();if(t)return t}return f(e)}function y(){return b().getIsolationScope()}function f(e=C()){return B(e)&&!v(e).isOlderThan(h)||W(e,new p),v(e)}function Z(e,t=f()){if(!B(e)||v(e).isOlderThan(h)){const n=t.getClient(),s=t.getScope(),o=t.getIsolationScope();W(e,new p(n,s.clone(),o.clone()))}}function A(e){const t=C();t.__SENTRY__=t.__SENTRY__||{},t.__SENTRY__.acs=e}function G(e,t={}){const n=C();return n.__SENTRY__&&n.__SENTRY__.acs?n.__SENTRY__.acs.runWithAsyncContext(e,t):e()}function B(e){return!!(e&&e.__SENTRY__&&e.__SENTRY__.hub)}function v(e){return(0,a.YO)("hub",(()=>new p),e)}function W(e,t){return!!e&&((e.__SENTRY__=e.__SENTRY__||{}).hub=t,!0)}},2967:(e,t,n)=>{"use strict";n.d(t,{M5:()=>h,RN:()=>I,m7:()=>u,m8:()=>g,q4:()=>d});var s=n(2844),o=n(2343),i=n(1703),r=n(1195),a=n(4487),c=n(5659);const l=[];function g(e){const t=e.defaultIntegrations||[],n=e.integrations;let o;t.forEach((e=>{e.isDefaultInstance=!0})),o=Array.isArray(n)?[...t,...n]:"function"==typeof n?(0,s.lE)(n(t)):t;const i=function(e){const t={};return e.forEach((e=>{const{name:n}=e,s=t[n];s&&!s.isDefaultInstance&&e.isDefaultInstance||(t[n]=e)})),Object.keys(t).map((e=>t[e]))}(o),r=function(e,t){for(let t=0;t{t&&u(e,t,n)})),n}function u(e,t,n){if(n[t.name]=t,-1===l.indexOf(t.name)&&(t.setupOnce(r.cc,c.Gd),l.push(t.name)),t.setup&&"function"==typeof t.setup&&t.setup(e),e.on&&"function"==typeof t.preprocessEvent){const n=t.preprocessEvent.bind(t);e.on("preprocessEvent",((t,s)=>n(t,s,e)))}if(e.addEventProcessor&&"function"==typeof t.processEvent){const n=t.processEvent.bind(t),s=Object.assign(((t,s)=>n(t,s,e)),{id:t.name});e.addEventProcessor(s)}i.X&&o.kg.log(`Integration installed: ${t.name}`)}function h(e){const t=(0,a.s3)();t&&t.addIntegration?t.addIntegration(e):i.X&&o.kg.warn(`Cannot add integration "${e.name}" because no SDK Client is available.`)}function I(e,t){return Object.assign((function(...e){return{setupOnce:()=>{},...t(...e)}}),{id:e})}},350:(e,t,n)=>{"use strict";n.d(t,{lW:()=>d,sX:()=>g});var s=n(7597),o=n(1170),i=n(2844),r=n(1195),a=n(9015),c=n(3379);let l;class g{constructor(){this._notifyingListeners=!1,this._scopeListeners=[],this._eventProcessors=[],this._breadcrumbs=[],this._attachments=[],this._user={},this._tags={},this._extra={},this._contexts={},this._sdkProcessingMetadata={},this._propagationContext=u()}static clone(e){return e?e.clone():new g}clone(){const e=new g;return e._breadcrumbs=[...this._breadcrumbs],e._tags={...this._tags},e._extra={...this._extra},e._contexts={...this._contexts},e._user=this._user,e._level=this._level,e._span=this._span,e._session=this._session,e._transactionName=this._transactionName,e._fingerprint=this._fingerprint,e._eventProcessors=[...this._eventProcessors],e._requestSession=this._requestSession,e._attachments=[...this._attachments],e._sdkProcessingMetadata={...this._sdkProcessingMetadata},e._propagationContext={...this._propagationContext},e._client=this._client,e}setClient(e){this._client=e}getClient(){return this._client}addScopeListener(e){this._scopeListeners.push(e)}addEventProcessor(e){return this._eventProcessors.push(e),this}setUser(e){return this._user=e||{},this._session&&(0,a.CT)(this._session,{user:e}),this._notifyScopeListeners(),this}getUser(){return this._user}getRequestSession(){return this._requestSession}setRequestSession(e){return this._requestSession=e,this}setTags(e){return this._tags={...this._tags,...e},this._notifyScopeListeners(),this}setTag(e,t){return this._tags={...this._tags,[e]:t},this._notifyScopeListeners(),this}setExtras(e){return this._extra={...this._extra,...e},this._notifyScopeListeners(),this}setExtra(e,t){return this._extra={...this._extra,[e]:t},this._notifyScopeListeners(),this}setFingerprint(e){return this._fingerprint=e,this._notifyScopeListeners(),this}setLevel(e){return this._level=e,this._notifyScopeListeners(),this}setTransactionName(e){return this._transactionName=e,this._notifyScopeListeners(),this}setContext(e,t){return null===t?delete this._contexts[e]:this._contexts[e]=t,this._notifyScopeListeners(),this}setSpan(e){return this._span=e,this._notifyScopeListeners(),this}getSpan(){return this._span}getTransaction(){const e=this.getSpan();return e&&e.transaction}setSession(e){return e?this._session=e:delete this._session,this._notifyScopeListeners(),this}getSession(){return this._session}update(e){if(!e)return this;if("function"==typeof e){const t=e(this);return t instanceof g?t:this}return e instanceof g?(this._tags={...this._tags,...e._tags},this._extra={...this._extra,...e._extra},this._contexts={...this._contexts,...e._contexts},e._user&&Object.keys(e._user).length&&(this._user=e._user),e._level&&(this._level=e._level),e._fingerprint&&(this._fingerprint=e._fingerprint),e._requestSession&&(this._requestSession=e._requestSession),e._propagationContext&&(this._propagationContext=e._propagationContext)):(0,s.PO)(e)&&(this._tags={...this._tags,...e.tags},this._extra={...this._extra,...e.extra},this._contexts={...this._contexts,...e.contexts},e.user&&(this._user=e.user),e.level&&(this._level=e.level),e.fingerprint&&(this._fingerprint=e.fingerprint),e.requestSession&&(this._requestSession=e.requestSession),e.propagationContext&&(this._propagationContext=e.propagationContext)),this}clear(){return this._breadcrumbs=[],this._tags={},this._extra={},this._user={},this._contexts={},this._level=void 0,this._transactionName=void 0,this._fingerprint=void 0,this._requestSession=void 0,this._span=void 0,this._session=void 0,this._notifyScopeListeners(),this._attachments=[],this._propagationContext=u(),this}addBreadcrumb(e,t){const n="number"==typeof t?t:100;if(n<=0)return this;const s={timestamp:(0,o.yW)(),...e},i=this._breadcrumbs;return i.push(s),this._breadcrumbs=i.length>n?i.slice(-n):i,this._notifyScopeListeners(),this}getLastBreadcrumb(){return this._breadcrumbs[this._breadcrumbs.length-1]}clearBreadcrumbs(){return this._breadcrumbs=[],this._notifyScopeListeners(),this}addAttachment(e){return this._attachments.push(e),this}getAttachments(){return this.getScopeData().attachments}clearAttachments(){return this._attachments=[],this}getScopeData(){const{_breadcrumbs:e,_attachments:t,_contexts:n,_tags:s,_extra:o,_user:i,_level:r,_fingerprint:a,_eventProcessors:c,_propagationContext:l,_sdkProcessingMetadata:g,_transactionName:d,_span:u}=this;return{breadcrumbs:e,attachments:t,contexts:n,tags:s,extra:o,user:i,level:r,fingerprint:a||[],eventProcessors:c,propagationContext:l,sdkProcessingMetadata:g,transactionName:d,span:u}}applyToEvent(e,t={},n=[]){(0,c.gi)(e,this.getScopeData());const s=[...n,...(0,r.fH)(),...this._eventProcessors];return(0,r.RP)(s,e,t)}setSDKProcessingMetadata(e){return this._sdkProcessingMetadata={...this._sdkProcessingMetadata,...e},this}setPropagationContext(e){return this._propagationContext=e,this}getPropagationContext(){return this._propagationContext}_notifyScopeListeners(){this._notifyingListeners||(this._notifyingListeners=!0,this._scopeListeners.forEach((e=>{e(this)})),this._notifyingListeners=!1)}}function d(){return l||(l=new g),l}function u(){return{traceId:(0,i.DM)(),spanId:(0,i.DM)().substring(16)}}},9015:(e,t,n)=>{"use strict";n.d(t,{CT:()=>a,Hv:()=>r,RJ:()=>c});var s=n(1170),o=n(2844),i=n(535);function r(e){const t=(0,s.ph)(),n={sid:(0,o.DM)(),init:!0,timestamp:t,started:t,duration:0,status:"ok",errors:0,ignoreDuration:!1,toJSON:()=>function(e){return(0,i.Jr)({sid:`${e.sid}`,init:e.init,started:new Date(1e3*e.started).toISOString(),timestamp:new Date(1e3*e.timestamp).toISOString(),status:e.status,errors:e.errors,did:"number"==typeof e.did||"string"==typeof e.did?`${e.did}`:void 0,duration:e.duration,abnormal_mechanism:e.abnormal_mechanism,attrs:{release:e.release,environment:e.environment,ip_address:e.ipAddress,user_agent:e.userAgent}})}(n)};return e&&a(n,e),n}function a(e,t={}){if(t.user&&(!e.ipAddress&&t.user.ip_address&&(e.ipAddress=t.user.ip_address),e.did||t.did||(e.did=t.user.id||t.user.email||t.user.username)),e.timestamp=t.timestamp||(0,s.ph)(),t.abnormal_mechanism&&(e.abnormal_mechanism=t.abnormal_mechanism),t.ignoreDuration&&(e.ignoreDuration=t.ignoreDuration),t.sid&&(e.sid=32===t.sid.length?t.sid:(0,o.DM)()),void 0!==t.init&&(e.init=t.init),!e.did&&t.did&&(e.did=`${t.did}`),"number"==typeof t.started&&(e.started=t.started),e.ignoreDuration)e.duration=void 0;else if("number"==typeof t.duration)e.duration=t.duration;else{const t=e.timestamp-e.started;e.duration=t>=0?t:0}t.release&&(e.release=t.release),t.environment&&(e.environment=t.environment),!e.ipAddress&&t.ipAddress&&(e.ipAddress=t.ipAddress),!e.userAgent&&t.userAgent&&(e.userAgent=t.userAgent),"number"==typeof t.errors&&(e.errors=t.errors),t.status&&(e.status=t.status)}function c(e,t){let n={};t?n={status:t}:"ok"===e.status&&(n={status:"exited"}),a(e,n)}},454:(e,t,n)=>{"use strict";n.d(t,{_:()=>i});var s=n(535),o=n(1131);function i(e,t,n){const i=t.getOptions(),{publicKey:r}=t.getDsn()||{},{segment:a}=n&&n.getUser()||{},c=(0,s.Jr)({environment:i.environment||o.J,release:i.release,user_segment:a,public_key:r,trace_id:e});return t.emit&&t.emit("createDsc",c),c}},1283:(e,t,n)=>{"use strict";n.d(t,{T:()=>B,l:()=>G});var s=n(2343),o=n(1703),i=n(5659),r=n(3371),a=n(1235),c=n(9729);let l=null;function g(){l=a.n2.onerror,a.n2.onerror=function(e,t,n,s,o){const i={column:s,error:o,line:n,msg:e,url:t};return(0,c.rK)("error",i),!(!l||l.__SENTRY_LOADER__)&&l.apply(this,arguments)},a.n2.onerror.__SENTRY_INSTRUMENTED__=!0}let d=null;function u(){d=a.n2.onunhandledrejection,a.n2.onunhandledrejection=function(e){const t=e;return(0,c.rK)("unhandledrejection",t),!(d&&!d.__SENTRY_LOADER__)||d.apply(this,arguments)},a.n2.onunhandledrejection.__SENTRY_INSTRUMENTED__=!0}var h=n(9791);let I=!1;function p(){const e=(0,h.x1)();if(e){const t="internal_error";o.X&&s.kg.log(`[Tracing] Transaction: ${t} -> Global error occured`),e.setStatus(t)}}p.tag="sentry_tracingErrorCallback";var C=n(5544),m=n(7597),b=n(7522);function y(e,t,n){if(!(0,b.z)(t))return e.sampled=!1,e;if(void 0!==e.sampled)return e.setMetadata({sampleRate:Number(e.sampled)}),e;let i;return"function"==typeof t.tracesSampler?(i=t.tracesSampler(n),e.setMetadata({sampleRate:Number(i)})):void 0!==n.parentSampled?i=n.parentSampled:void 0!==t.tracesSampleRate?(i=t.tracesSampleRate,e.setMetadata({sampleRate:Number(i)})):(i=1,e.setMetadata({sampleRate:i})),r=i,((0,m.i2)(r)||"number"!=typeof r&&"boolean"!=typeof r?(o.X&&s.kg.warn(`[Tracing] Given sample rate is invalid. Sample rate must be a boolean or a number between 0 and 1. Got ${JSON.stringify(r)} of type ${JSON.stringify(typeof r)}.`),0):!(r<0||r>1)||(o.X&&s.kg.warn(`[Tracing] Given sample rate is invalid. Sample rate must be between 0 and 1. Got ${r}.`),0))?i?(e.sampled=Math.random(){"use strict";n.d(t,{AT:()=>l,io:()=>u});var s=n(2343),o=n(1170),i=n(1703),r=n(8903),a=n(8069),c=n(9791);const l={idleTimeout:1e3,finalTimeout:3e4,heartbeatInterval:5e3},g=["heartbeatFailed","idleTimeout","documentHidden","finalTimeout","externalFinish","cancelled"];class d extends r.gB{constructor(e,t,n,s){super(s),this._pushActivity=e,this._popActivity=t,this.transactionSpanId=n}add(e){if(e.spanId!==this.transactionSpanId){const t=e.end;e.end=(...n)=>(this._popActivity(e.spanId),t.apply(e,n)),void 0===e.endTimestamp&&this._pushActivity(e.spanId)}super.add(e)}}class u extends a.Y{constructor(e,t,n=l.idleTimeout,o=l.finalTimeout,r=l.heartbeatInterval,a=!1){super(e,t),this._idleHub=t,this._idleTimeout=n,this._finalTimeout=o,this._heartbeatInterval=r,this._onScope=a,this.activities={},this._heartbeatCounter=0,this._finished=!1,this._idleTimeoutCanceledPermanently=!1,this._beforeFinishCallbacks=[],this._finishReason=g[4],a&&(i.X&&s.kg.log(`Setting idle transaction on scope. Span ID: ${this.spanId}`),t.getScope().setSpan(this)),this._restartIdleTimeout(),setTimeout((()=>{this._finished||(this.setStatus("deadline_exceeded"),this._finishReason=g[3],this.end())}),this._finalTimeout)}end(e=(0,o.ph)()){const t=(0,c.oq)(e);if(this._finished=!0,this.activities={},"ui.action.click"===this.op&&this.setTag("finishReason",this._finishReason),this.spanRecorder){i.X&&s.kg.log("[Tracing] finishing IdleTransaction",new Date(1e3*t).toISOString(),this.op);for(const t of this._beforeFinishCallbacks)t(this,e);this.spanRecorder.spans=this.spanRecorder.spans.filter((e=>{if(e.spanId===this.spanId)return!0;e.endTimestamp||(e.endTimestamp=t,e.setStatus("cancelled"),i.X&&s.kg.log("[Tracing] cancelling span since transaction ended early",JSON.stringify(e,void 0,2)));const n=e.startTimestamp{this._finished||this._pushActivity(e)},n=e=>{this._finished||this._popActivity(e)};this.spanRecorder=new d(t,n,this.spanId,e),i.X&&s.kg.log("Starting heartbeat"),this._pingHeartbeat()}this.spanRecorder.add(this)}cancelIdleTimeout(e,{restartOnChildSpanChange:t}={restartOnChildSpanChange:!0}){this._idleTimeoutCanceledPermanently=!1===t,this._idleTimeoutID&&(clearTimeout(this._idleTimeoutID),this._idleTimeoutID=void 0,0===Object.keys(this.activities).length&&this._idleTimeoutCanceledPermanently&&(this._finishReason=g[5],this.end(e)))}setFinishReason(e){this._finishReason=e}_restartIdleTimeout(e){this.cancelIdleTimeout(),this._idleTimeoutID=setTimeout((()=>{this._finished||0!==Object.keys(this.activities).length||(this._finishReason=g[1],this.end(e))}),this._idleTimeout)}_pushActivity(e){this.cancelIdleTimeout(void 0,{restartOnChildSpanChange:!this._idleTimeoutCanceledPermanently}),i.X&&s.kg.log(`[Tracing] pushActivity: ${e}`),this.activities[e]=!0,i.X&&s.kg.log("[Tracing] new activities count",Object.keys(this.activities).length)}_popActivity(e){if(this.activities[e]&&(i.X&&s.kg.log(`[Tracing] popActivity ${e}`),delete this.activities[e],i.X&&s.kg.log("[Tracing] new activities count",Object.keys(this.activities).length)),0===Object.keys(this.activities).length){const e=(0,o.ph)();this._idleTimeoutCanceledPermanently?(this._finishReason=g[5],this.end(e)):this._restartIdleTimeout(e+this._idleTimeout/1e3)}}_beat(){if(this._finished)return;const e=Object.keys(this.activities).join("");e===this._prevHeartbeatString?this._heartbeatCounter++:this._heartbeatCounter=1,this._prevHeartbeatString=e,this._heartbeatCounter>=3?(i.X&&s.kg.log("[Tracing] Transaction finished because of no change for 3 heart beats"),this.setStatus("deadline_exceeded"),this._finishReason=g[0],this.end()):this._pingHeartbeat()}_pingHeartbeat(){i.X&&s.kg.log(`pinging Heartbeat -> current counter: ${this._heartbeatCounter}`),setTimeout((()=>{this._beat()}),this._heartbeatInterval)}}},8903:(e,t,n)=>{"use strict";n.d(t,{Dr:()=>d,Zd:()=>u,gB:()=>g});var s=n(2844),o=n(1170),i=n(2343),r=n(535),a=n(1703),c=n(3371),l=n(9791);class g{constructor(e=1e3){this._maxlen=e,this.spans=[]}add(e){this.spans.length>this._maxlen?e.spanRecorder=void 0:this.spans.push(e)}}class d{constructor(e={}){this.traceId=e.traceId||(0,s.DM)(),this.spanId=e.spanId||(0,s.DM)().substring(16),this.startTimestamp=e.startTimestamp||(0,o.ph)(),this.tags=e.tags||{},this.data=e.data||{},this.attributes=e.attributes||{},this.instrumenter=e.instrumenter||"sentry",this.origin=e.origin||"manual",e.parentSpanId&&(this.parentSpanId=e.parentSpanId),"sampled"in e&&(this.sampled=e.sampled),e.op&&(this.op=e.op),e.description&&(this.description=e.description),e.name&&(this.description=e.name),e.status&&(this.status=e.status),e.endTimestamp&&(this.endTimestamp=e.endTimestamp)}get name(){return this.description||""}set name(e){this.updateName(e)}startChild(e){const t=new d({...e,parentSpanId:this.spanId,sampled:this.sampled,traceId:this.traceId});if(t.spanRecorder=this.spanRecorder,t.spanRecorder&&t.spanRecorder.add(t),t.transaction=this.transaction,a.X&&t.transaction){const n=`[Tracing] Starting '${e&&e.op||"< unknown op >"}' span on transaction '${t.transaction.name||"< unknown name >"}' (${t.transaction.spanId}).`;t.transaction.metadata.spanMetadata[t.spanId]={logMessage:n},i.kg.log(n)}return t}setTag(e,t){return this.tags={...this.tags,[e]:t},this}setData(e,t){return this.data={...this.data,[e]:t},this}setAttribute(e,t){void 0===t?delete this.attributes[e]:this.attributes[e]=t}setAttributes(e){Object.keys(e).forEach((t=>this.setAttribute(t,e[t])))}setStatus(e){return this.status=e,this}setHttpStatus(e){this.setTag("http.status_code",String(e)),this.setData("http.response.status_code",e);const t=u(e);return"unknown_error"!==t&&this.setStatus(t),this}setName(e){this.updateName(e)}updateName(e){return this.description=e,this}isSuccess(){return"ok"===this.status}finish(e){return this.end(e)}end(e){if(a.X&&this.transaction&&this.transaction.spanId!==this.spanId){const{logMessage:e}=this.transaction.metadata.spanMetadata[this.spanId];e&&i.kg.log(e.replace("Starting","Finishing"))}this.endTimestamp="number"==typeof e?(0,l.oq)(e):(0,o.ph)()}toTraceparent(){return(0,c.H)(this)}toContext(){return(0,r.Jr)({data:this._getData(),description:this.description,endTimestamp:this.endTimestamp,op:this.op,parentSpanId:this.parentSpanId,sampled:this.sampled,spanId:this.spanId,startTimestamp:this.startTimestamp,status:this.status,tags:this.tags,traceId:this.traceId})}updateWithContext(e){return this.data=e.data||{},this.description=e.description,this.endTimestamp=e.endTimestamp,this.op=e.op,this.parentSpanId=e.parentSpanId,this.sampled=e.sampled,this.spanId=e.spanId||this.spanId,this.startTimestamp=e.startTimestamp||this.startTimestamp,this.status=e.status,this.tags=e.tags||{},this.traceId=e.traceId||this.traceId,this}getTraceContext(){return(0,c.w)(this)}toJSON(){return(0,r.Jr)({data:this._getData(),description:this.description,op:this.op,parent_span_id:this.parentSpanId,span_id:this.spanId,start_timestamp:this.startTimestamp,status:this.status,tags:Object.keys(this.tags).length>0?this.tags:void 0,timestamp:this.endTimestamp,trace_id:this.traceId,origin:this.origin})}_getData(){const{data:e,attributes:t}=this,n=Object.keys(e).length>0,s=Object.keys(t).length>0;if(n||s)return n&&s?{...e,...t}:n?e:t}}function u(e){if(e<400&&e>=100)return"ok";if(e>=400&&e<500)switch(e){case 401:return"unauthenticated";case 403:return"permission_denied";case 404:return"not_found";case 409:return"already_exists";case 413:return"failed_precondition";case 429:return"resource_exhausted";default:return"invalid_argument"}if(e>=500&&e<600)switch(e){case 501:return"unimplemented";case 503:return"unavailable";case 504:return"deadline_exceeded";default:return"internal_error"}return"unknown_error"}},4317:(e,t,n)=>{"use strict";n.d(t,{yn:()=>b,HN:()=>m,y_:()=>I,qp:()=>C,GK:()=>h,V0:()=>p,g4:()=>u});var s=n(7638),o=n(2343),i=n(535),r=n(1703),a=n(4487),c=n(5659),l=n(7597);function g(e,t,n=(()=>{})){let s;try{s=e()}catch(e){throw t(e),n(),e}return function(e,t,n){return(0,l.J8)(e)?e.then((e=>(n(),e)),(e=>{throw t(e),n(),e})):(n(),e)}(s,t,n)}var d=n(7522);function u(e,t,n=(()=>{}),s=(()=>{})){const o=f(e),i=(0,c.Gd)(),r=(0,a.nZ)(),l=r.getSpan(),d=y(i,l,o);return r.setSpan(d),g((()=>t(d)),(e=>{d&&d.setStatus("internal_error"),n(e,d)}),(()=>{d&&d.end(),r.setSpan(l),s()}))}function h(e,t){const n=f(e);return(0,a.$e)((e=>{const s=y((0,c.Gd)(),e.getSpan(),n);return e.setSpan(s),g((()=>t(s)),(()=>{!s||s.status&&"ok"!==s.status||s.setStatus("internal_error")}),(()=>s&&s.end()))}))}const I=h;function p(e,t){const n=f(e);return(0,a.$e)((e=>{const s=y((0,c.Gd)(),e.getSpan(),n);function o(){s&&s.end()}return e.setSpan(s),g((()=>t(s,o)),(()=>{!s||s.endTimestamp||s.status&&"ok"!==s.status||s.setStatus("internal_error")}))}))}function C(e){if(!(0,d.z)())return;const t={...e};void 0!==t.name&&void 0===t.description&&(t.description=t.name);const n=(0,c.Gd)(),s=m();return s?s.startChild(t):n.startTransaction(t)}function m(){return(0,a.nZ)().getSpan()}function b({sentryTrace:e,baggage:t},n){const c=(0,a.nZ)(),{traceparentData:l,dynamicSamplingContext:g,propagationContext:d}=(0,s.KA)(e,t);c.setPropagationContext(d),r.X&&l&&o.kg.log(`[Tracing] Continuing trace ${l.traceId}.`);const u={...l,metadata:(0,i.Jr)({dynamicSamplingContext:l&&!g?{}:g})};return n?n(u):u}function y(e,t,n){if((0,d.z)())return t?t.startChild(n):e.startTransaction(n)}function f(e){const t={...e};return void 0!==t.name&&void 0===t.description&&(t.description=t.name),t}},8069:(e,t,n)=>{"use strict";n.d(t,{Y:()=>u});var s=n(1170),o=n(535),i=n(2343),r=n(1703),a=n(5659),c=n(3371),l=n(454),g=n(8903),d=n(9791);class u extends g.Dr{constructor(e,t){super(e),delete this.description,this._measurements={},this._contexts={},this._hub=t||(0,a.Gd)(),this._name=e.name||"",this.metadata={source:"custom",...e.metadata,spanMetadata:{}},this._trimEnd=e.trimEnd,this.transaction=this;const n=this.metadata.dynamicSamplingContext;n&&(this._frozenDynamicSamplingContext={...n})}get name(){return this._name}set name(e){this.setName(e)}setName(e,t="custom"){this._name=e,this.metadata.source=t}updateName(e){return this._name=e,this}initSpanRecorder(e=1e3){this.spanRecorder||(this.spanRecorder=new g.gB(e)),this.spanRecorder.add(this)}setContext(e,t){null===t?delete this._contexts[e]:this._contexts[e]=t}setMeasurement(e,t,n=""){this._measurements[e]={value:t,unit:n}}setMetadata(e){this.metadata={...this.metadata,...e}}end(e){const t="number"==typeof e?(0,d.oq)(e):(0,s.ph)(),n=this._finishTransaction(t);if(n)return this._hub.captureEvent(n)}toContext(){const e=super.toContext();return(0,o.Jr)({...e,name:this.name,trimEnd:this._trimEnd})}updateWithContext(e){return super.updateWithContext(e),this.name=e.name||"",this._trimEnd=e.trimEnd,this}getDynamicSamplingContext(){if(this._frozenDynamicSamplingContext)return this._frozenDynamicSamplingContext;const e=this._hub||(0,a.Gd)(),t=e.getClient();if(!t)return{};const n=e.getScope(),s=(0,l._)(this.traceId,t,n),o=this.metadata.sampleRate;void 0!==o&&(s.sample_rate=`${o}`);const i=this.metadata.source;return i&&"url"!==i&&(s.transaction=this.name),void 0!==this.sampled&&(s.sampled=String(this.sampled)),s}setHub(e){this._hub=e}_finishTransaction(e){if(void 0!==this.endTimestamp)return;this.name||(r.X&&i.kg.warn("Transaction has no name, falling back to ``."),this.name=""),super.end(e);const t=this._hub.getClient();if(t&&t.emit&&t.emit("finishTransaction",this),!0!==this.sampled)return r.X&&i.kg.log("[Tracing] Discarding transaction because its trace was not chosen to be sampled."),void(t&&t.recordDroppedEvent("sample_rate","transaction"));const n=this.spanRecorder?this.spanRecorder.spans.filter((e=>e!==this&&e.endTimestamp)):[];this._trimEnd&&n.length>0&&(this.endTimestamp=n.reduce(((e,t)=>e.endTimestamp&&t.endTimestamp?e.endTimestamp>t.endTimestamp?e:t:e)).endTimestamp);const s=this.metadata,o={contexts:{...this._contexts,trace:(0,c.w)(this)},spans:n,start_timestamp:this.startTimestamp,tags:this.tags,timestamp:this.endTimestamp,transaction:this.name,type:"transaction",sdkProcessingMetadata:{...s,dynamicSamplingContext:this.getDynamicSamplingContext()},...s.source&&{transaction_info:{source:s.source}}};return Object.keys(this._measurements).length>0&&(r.X&&i.kg.log("[Measurements] Adding measurements to transaction",JSON.stringify(this._measurements,void 0,2)),o.measurements=this._measurements),r.X&&i.kg.log(`[Tracing] Finishing ${this.op} transaction: ${this.name}.`),o}}},9791:(e,t,n)=>{"use strict";n.d(t,{oq:()=>a,qG:()=>r,x1:()=>i});var s=n(7638),o=n(5659);function i(e){return(e||(0,o.Gd)()).getScope().getTransaction()}const r=s.qG;function a(e){return e>9999999999?e/1e3:e}},3379:(e,t,n)=>{"use strict";n.d(t,{gi:()=>i,yo:()=>r});var s=n(2844),o=n(3371);function i(e,t){const{fingerprint:n,span:i,breadcrumbs:r,sdkProcessingMetadata:a,propagationContext:c}=t;!function(e,t){const{extra:n,tags:s,user:o,contexts:i,level:r,transactionName:a}=t;n&&Object.keys(n).length&&(e.extra={...n,...e.extra}),s&&Object.keys(s).length&&(e.tags={...s,...e.tags}),o&&Object.keys(o).length&&(e.user={...o,...e.user}),i&&Object.keys(i).length&&(e.contexts={...i,...e.contexts}),r&&(e.level=r),a&&(e.transaction=a)}(e,t),i&&function(e,t){e.contexts={trace:(0,o.w)(t),...e.contexts};const n=t.transaction;if(n){e.sdkProcessingMetadata={dynamicSamplingContext:n.getDynamicSamplingContext(),...e.sdkProcessingMetadata};const t=n.name;t&&(e.tags={transaction:t,...e.tags})}}(e,i),function(e,t){e.fingerprint=e.fingerprint?(0,s.lE)(e.fingerprint):[],t&&(e.fingerprint=e.fingerprint.concat(t)),e.fingerprint&&!e.fingerprint.length&&delete e.fingerprint}(e,n),function(e,t){const n=[...e.breadcrumbs||[],...t];e.breadcrumbs=n.length?n:void 0}(e,r),function(e,t,n){e.sdkProcessingMetadata={...e.sdkProcessingMetadata,...t,propagationContext:n}}(e,a,c)}function r(e,t){const{extra:n,tags:s,user:o,contexts:i,level:r,sdkProcessingMetadata:c,breadcrumbs:l,fingerprint:g,eventProcessors:d,attachments:u,propagationContext:h,transactionName:I,span:p}=t;a(e,"extra",n),a(e,"tags",s),a(e,"user",o),a(e,"contexts",i),a(e,"sdkProcessingMetadata",c),r&&(e.level=r),I&&(e.transactionName=I),p&&(e.span=p),l.length&&(e.breadcrumbs=[...e.breadcrumbs,...l]),g.length&&(e.fingerprint=[...e.fingerprint,...g]),d.length&&(e.eventProcessors=[...e.eventProcessors,...d]),u.length&&(e.attachments=[...e.attachments,...u]),e.propagationContext={...e.propagationContext,...h}}function a(e,t,n){n&&Object.keys(n).length&&(e[t]={...e[t],...n})}},7522:(e,t,n)=>{"use strict";n.d(t,{z:()=>o});var s=n(4487);function o(e){if("boolean"==typeof __SENTRY_TRACING__&&!__SENTRY_TRACING__)return!1;const t=(0,s.s3)(),n=e||t&&t.getOptions();return!!n&&(n.enableTracing||"tracesSampleRate"in n||"tracesSampler"in n)}},766:(e,t,n)=>{"use strict";function s(e,t){const n=t&&function(e){return void 0!==e.getClient}(t)?t.getClient():t,s=n&&n.getDsn(),i=n&&n.getOptions().tunnel;return function(e,t){return!!t&&e.includes(t.host)}(e,s)||function(e,t){return!!t&&o(e)===o(t)}(e,i)}function o(e){return"/"===e[e.length-1]?e.slice(0,-1):e}n.d(t,{W:()=>s})},8942:(e,t,n)=>{"use strict";n.d(t,{R:()=>u,U0:()=>I});var s=n(2844),o=n(1170),i=n(7321),r=n(1235),a=n(8007),c=n(1131),l=n(1195),g=n(350),d=n(3379);function u(e,t,n,u,I,p){const{normalizeDepth:C=3,normalizeMaxBreadth:m=1e3}=e,b={...t,event_id:t.event_id||n.event_id||(0,s.DM)(),timestamp:t.timestamp||(0,o.yW)()},y=n.integrations||e.integrations.map((e=>e.name));!function(e,t){const{environment:n,release:s,dist:o,maxValueLength:r=250}=t;"environment"in e||(e.environment="environment"in t?n:c.J),void 0===e.release&&void 0!==s&&(e.release=s),void 0===e.dist&&void 0!==o&&(e.dist=o),e.message&&(e.message=(0,i.$G)(e.message,r));const a=e.exception&&e.exception.values&&e.exception.values[0];a&&a.value&&(a.value=(0,i.$G)(a.value,r));const l=e.request;l&&l.url&&(l.url=(0,i.$G)(l.url,r))}(b,e),function(e,t){t.length>0&&(e.sdk=e.sdk||{},e.sdk.integrations=[...e.sdk.integrations||[],...t])}(b,y),void 0===t.type&&function(e,t){const n=r.n2._sentryDebugIds;if(!n)return;let s;const o=h.get(t);o?s=o:(s=new Map,h.set(t,s));const i=Object.keys(n).reduce(((e,o)=>{let i;const r=s.get(o);r?i=r:(i=t(o),s.set(o,i));for(let t=i.length-1;t>=0;t--){const s=i[t];if(s.filename){e[s.filename]=n[o];break}}return e}),{});try{e.exception.values.forEach((e=>{e.stacktrace.frames.forEach((e=>{e.filename&&(e.debug_id=i[e.filename])}))}))}catch(e){}}(b,e.stackParser);const f=function(e,t){if(!t)return e;const n=e?e.clone():new g.sX;return n.update(t),n}(u,n.captureContext);n.mechanism&&(0,s.EG)(b,n.mechanism);const Z=I&&I.getEventProcessors?I.getEventProcessors():[],A=(0,g.lW)().getScopeData();if(p){const e=p.getScopeData();(0,d.yo)(A,e)}if(f){const e=f.getScopeData();(0,d.yo)(A,e)}const G=[...n.attachments||[],...A.attachments];G.length&&(n.attachments=G),(0,d.gi)(b,A);const B=[...Z,...(0,l.fH)(),...A.eventProcessors];return(0,l.RP)(B,b,n).then((e=>(e&&function(e){const t={};try{e.exception.values.forEach((e=>{e.stacktrace.frames.forEach((e=>{e.debug_id&&(e.abs_path?t[e.abs_path]=e.debug_id:e.filename&&(t[e.filename]=e.debug_id),delete e.debug_id)}))}))}catch(e){}if(0===Object.keys(t).length)return;e.debug_meta=e.debug_meta||{},e.debug_meta.images=e.debug_meta.images||[];const n=e.debug_meta.images;Object.keys(t).forEach((e=>{n.push({type:"sourcemap",code_file:e,debug_id:t[e]})}))}(e),"number"==typeof C&&C>0?function(e,t,n){if(!e)return null;const s={...e,...e.breadcrumbs&&{breadcrumbs:e.breadcrumbs.map((e=>({...e,...e.data&&{data:(0,a.Fv)(e.data,t,n)}})))},...e.user&&{user:(0,a.Fv)(e.user,t,n)},...e.contexts&&{contexts:(0,a.Fv)(e.contexts,t,n)},...e.extra&&{extra:(0,a.Fv)(e.extra,t,n)}};return e.contexts&&e.contexts.trace&&s.contexts&&(s.contexts.trace=e.contexts.trace,e.contexts.trace.data&&(s.contexts.trace.data=(0,a.Fv)(e.contexts.trace.data,t,n))),e.spans&&(s.spans=e.spans.map((e=>(e.data&&(e.data=(0,a.Fv)(e.data,t,n)),e)))),s}(e,C,m):e)))}const h=new WeakMap;function I(e){if(e)return function(e){return e instanceof g.sX||"function"==typeof e}(e)||function(e){return Object.keys(e).some((e=>p.includes(e)))}(e)?{captureContext:e}:e}const p=["user","level","extra","contexts","tags","fingerprint","requestSession","propagationContext"]},3371:(e,t,n)=>{"use strict";n.d(t,{H:()=>r,w:()=>i});var s=n(535),o=n(7638);function i(e){const{data:t,description:n,op:o,parent_span_id:i,span_id:r,status:a,tags:c,trace_id:l,origin:g}=e.toJSON();return(0,s.Jr)({data:t,description:n,op:o,parent_span_id:i,span_id:r,status:a,tags:c,trace_id:l,origin:g})}function r(e){return(0,o.$p)(e.traceId,e.spanId,e.sampled)}},105:(e,t,n)=>{"use strict";n.d(t,{J:()=>s});const s="7.92.0"},9816:(e,t,n)=>{"use strict";n.r(t),n.d(t,{DEFAULT_USER_INCLUDES:()=>Ee.rC,Handlers:()=>o,Hub:()=>O.Xb,Integrations:()=>zn,NodeClient:()=>Xe,SDK_VERSION:()=>be.J,Scope:()=>ye.sX,addBreadcrumb:()=>L.n_,addEventProcessor:()=>ie,addGlobalEventProcessor:()=>fe.cc,addIntegration:()=>c.M5,addRequestDataToEvent:()=>Ee.S6,autoDiscoverNodePerformanceMonitoringIntegrations:()=>Be,captureCheckIn:()=>L.c,captureEvent:()=>L.eN,captureException:()=>L.Tb,captureMessage:()=>L.uT,close:()=>L.xv,configureScope:()=>L.e,continueTrace:()=>Ze.yn,createTransport:()=>ce,cron:()=>Tn,deepReadDirSync:()=>In,defaultIntegrations:()=>ln,defaultStackParser:()=>hn,enableAnrDetection:()=>Cn,extractRequestData:()=>Ee.XQ,extractTraceparentData:()=>Ce.qG,flush:()=>L.yl,getActiveSpan:()=>Ze.HN,getActiveTransaction:()=>Ce.x1,getClient:()=>L.s3,getCurrentHub:()=>O.Gd,getCurrentScope:()=>L.nZ,getGlobalScope:()=>ye.lW,getHubFromCarrier:()=>O.vi,getIsolationScope:()=>O.aF,getModuleFromFilename:()=>cn,getSentryRelease:()=>un,hapiErrorPlugin:()=>Vn,init:()=>gn,lastEventId:()=>L.eW,makeMain:()=>O.pj,makeNodeTransport:()=>ze,metrics:()=>pe,runWithAsyncContext:()=>O.Ok,setContext:()=>L.v,setExtra:()=>L.sU,setExtras:()=>L.rJ,setMeasurement:()=>me,setTag:()=>L.YA,setTags:()=>L.mG,setUser:()=>L.av,spanStatusfromHttpCode:()=>Ae.Zd,startActiveSpan:()=>Ze.y_,startInactiveSpan:()=>Ze.qp,startSpan:()=>Ze.GK,startSpanManual:()=>Ze.V0,startTransaction:()=>L.Yr,trace:()=>Ze.g4,withMonitor:()=>L.sV,withScope:()=>L.$e});var s={};n.r(s),n.d(s,{FunctionToString:()=>d,InboundFilters:()=>y,LinkedErrors:()=>R});var o={};n.r(o),n.d(o,{errorHandler:()=>Gn,extractRequestData:()=>bn,parseRequest:()=>yn,requestHandler:()=>Zn,tracingHandler:()=>fn,trpcMiddleware:()=>Bn});var i={};n.r(i),n.d(i,{Anr:()=>pn.q,Console:()=>lt,Context:()=>zt,ContextLines:()=>Yt,Hapi:()=>Rn,Http:()=>bt,LocalVariables:()=>$t,Modules:()=>Ht,OnUncaughtException:()=>Gt,OnUnhandledRejection:()=>vt,RequestData:()=>Le,Spotlight:()=>nn,Undici:()=>en.Y});var r={};n.r(r),n.d(r,{Apollo:()=>Hn._,Express:()=>Xn.N1,GraphQL:()=>kn.k,Mongo:()=>Yn._,Mysql:()=>Nn.m,Postgres:()=>Jn.E,Prisma:()=>_n.g});var a=n(535),c=n(2967);let l;const g="FunctionToString",d=(0,c.RN)(g,(()=>({name:g,setupOnce(){l=Function.prototype.toString;try{Function.prototype.toString=function(...e){const t=(0,a.HK)(this)||this;return l.apply(t,e)}}catch(e){}}})));var u=n(2343),h=n(2844),I=n(7321),p=n(1703);const C=[/^Script error\.?$/,/^Javascript error: Script error\.? on line 0$/],m=[/^.*\/healthcheck$/,/^.*\/healthy$/,/^.*\/live$/,/^.*\/ready$/,/^.*\/heartbeat$/,/^.*\/health$/,/^.*\/healthz$/],b="InboundFilters",y=(0,c.RN)(b,(e=>({name:b,processEvent(t,n,s){const o=s.getOptions(),i=function(e={},t={}){return{allowUrls:[...e.allowUrls||[],...t.allowUrls||[]],denyUrls:[...e.denyUrls||[],...t.denyUrls||[]],ignoreErrors:[...e.ignoreErrors||[],...t.ignoreErrors||[],...e.disableErrorDefaults?[]:C],ignoreTransactions:[...e.ignoreTransactions||[],...t.ignoreTransactions||[],...e.disableTransactionDefaults?[]:m],ignoreInternal:void 0===e.ignoreInternal||e.ignoreInternal}}(e,o);return function(e,t){return t.ignoreInternal&&function(e){try{return"SentryError"===e.exception.values[0].type}catch(e){}return!1}(e)?(p.X&&u.kg.warn(`Event dropped due to being internal Sentry Error.\nEvent: ${(0,h.jH)(e)}`),!0):function(e,t){return!(e.type||!t||!t.length)&&function(e){const t=[];let n;e.message&&t.push(e.message);try{n=e.exception.values[e.exception.values.length-1]}catch(e){}return n&&n.value&&(t.push(n.value),n.type&&t.push(`${n.type}: ${n.value}`)),p.X&&0===t.length&&u.kg.error(`Could not extract message for event ${(0,h.jH)(e)}`),t}(e).some((e=>(0,I.U0)(e,t)))}(e,t.ignoreErrors)?(p.X&&u.kg.warn(`Event dropped due to being matched by \`ignoreErrors\` option.\nEvent: ${(0,h.jH)(e)}`),!0):function(e,t){if("transaction"!==e.type||!t||!t.length)return!1;const n=e.transaction;return!!n&&(0,I.U0)(n,t)}(e,t.ignoreTransactions)?(p.X&&u.kg.warn(`Event dropped due to being matched by \`ignoreTransactions\` option.\nEvent: ${(0,h.jH)(e)}`),!0):function(e,t){if(!t||!t.length)return!1;const n=f(e);return!!n&&(0,I.U0)(n,t)}(e,t.denyUrls)?(p.X&&u.kg.warn(`Event dropped due to being matched by \`denyUrls\` option.\nEvent: ${(0,h.jH)(e)}.\nUrl: ${f(e)}`),!0):!function(e,t){if(!t||!t.length)return!0;const n=f(e);return!n||(0,I.U0)(n,t)}(e,t.allowUrls)&&(p.X&&u.kg.warn(`Event dropped due to not being matched by \`allowUrls\` option.\nEvent: ${(0,h.jH)(e)}.\nUrl: ${f(e)}`),!0)}(t,i)?null:t}})));function f(e){try{let t;try{t=e.exception.values[0].stacktrace.frames}catch(e){}return t?function(e=[]){for(let t=e.length-1;t>=0;t--){const n=e[t];if(n&&""!==n.filename&&"[native code]"!==n.filename)return n.filename||null}return null}(t):null}catch(t){return p.X&&u.kg.error(`Cannot extract url for event ${(0,h.jH)(e)}`),null}}var Z=n(7597);function A(e,t,n=250,s,o,i,r){if(!(i.exception&&i.exception.values&&r&&(0,Z.V9)(r.originalException,Error)))return;const a=i.exception.values.length>0?i.exception.values[i.exception.values.length-1]:void 0;var c,l;a&&(i.exception.values=(c=G(e,t,o,r.originalException,s,i.exception.values,a,0),l=n,c.map((e=>(e.value&&(e.value=(0,I.$G)(e.value,l)),e)))))}function G(e,t,n,s,o,i,r,a){if(i.length>=n+1)return i;let c=[...i];if((0,Z.V9)(s[o],Error)){B(r,a);const i=e(t,s[o]),l=c.length;v(i,o,l,a),c=G(e,t,n,s[o],o,[i,...c],i,l)}return Array.isArray(s.errors)&&s.errors.forEach(((s,i)=>{if((0,Z.V9)(s,Error)){B(r,a);const l=e(t,s),g=c.length;v(l,`errors[${i}]`,g,a),c=G(e,t,n,s,o,[l,...c],l,g)}})),c}function B(e,t){e.mechanism=e.mechanism||{type:"generic",handled:!0},e.mechanism={...e.mechanism,is_exception_group:!0,exception_id:t}}function v(e,t,n,s){e.mechanism=e.mechanism||{type:"generic",handled:!0},e.mechanism={...e.mechanism,type:"chained",source:t,exception_id:n,parent_id:s}}var W=n(8007);function V(e,t){return e(t.stack||"",1)}function w(e,t){const n={type:t.name||t.constructor.name,value:t.message},s=V(e,t);return s.length&&(n.stacktrace={frames:s}),n}const S="LinkedErrors",R=(0,c.RN)(S,((e={})=>{const t=e.limit||5,n=e.key||"cause";return{name:S,preprocessEvent(e,s,o){const i=o.getOptions();A(w,i.stackParser,i.maxValueLength,n,t,e,s)}}}));var H=n(3897);const X=/^(?:(\w+):)\/\/(?:(\w+)(?::(\w+)?)?@)([\w.-]+)(?::(\d+))?\/(.+)/;function k(e,t=!1){const{host:n,path:s,pass:o,port:i,projectId:r,protocol:a,publicKey:c}=e;return`${a}://${c}${t&&o?`:${o}`:""}@${n}${i?`:${i}`:""}/${s?`${s}/`:s}${r}`}function Y(e){return{protocol:e.protocol,publicKey:e.publicKey||"",pass:e.pass||"",host:e.host,port:e.port||"",path:e.path||"",projectId:e.projectId}}var N=n(6893);function J(e,t=[]){return[e,t]}function _(e,t){const[n,s]=e;return[n,[...s,t]]}function K(e,t){const n=e[1];for(const e of n)if(t(e,e[0].type))return!0;return!1}function F(e,t){return(t||new TextEncoder).encode(e)}function x(e,t){const[n,s]=e;let o=JSON.stringify(n);function i(e){"string"==typeof o?o="string"==typeof e?o+e:[F(o,t),e]:o.push("string"==typeof e?F(e,t):e)}for(const e of s){const[t,n]=e;if(i(`\n${JSON.stringify(t)}\n`),"string"==typeof n||n instanceof Uint8Array)i(n);else{let e;try{e=JSON.stringify(n)}catch(t){e=JSON.stringify((0,W.Fv)(n))}i(e)}}return"string"==typeof o?o:function(e){const t=e.reduce(((e,t)=>e+t.length),0),n=new Uint8Array(t);let s=0;for(const t of e)n.set(t,s),s+=t.length;return n}(o)}function z(e,t){const n="string"==typeof e.data?F(e.data,t):e.data;return[(0,a.Jr)({type:"attachment",length:n.length,filename:e.filename,content_type:e.contentType,attachment_type:e.attachmentType}),n]}const T={session:"session",sessions:"session",attachment:"attachment",transaction:"transaction",event:"error",client_report:"internal",user_report:"default",profile:"profile",replay_event:"replay",replay_recording:"replay",check_in:"monitor",feedback:"feedback",statsd:"unknown"};function E(e){return T[e]}function U(e){if(!e||!e.sdk)return;const{name:t,version:n}=e.sdk;return{name:t,version:n}}class Q extends Error{constructor(e,t="warn"){super(e),this.message=e,this.name=new.target.prototype.constructor.name,Object.setPrototypeOf(this,new.target.prototype),this.logLevel=t}}var L=n(4487),O=n(5659);const j=/[^a-zA-Z0-9_/.-]+/g,M=/[^\w\d_:/@.{}[\]$-]+/g;function P(e,t,n,s){return`${e}${t}${n}${Object.entries((0,a.Jr)(s)).sort(((e,t)=>e[0].localeCompare(t[0])))}`}function D(e){const t={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n.replace(j,"_")]=String(e[n]).replace(M,"_"));return t}var q=n(9015),$=n(454),ee=n(8942);const te="Not capturing exception because it's already been captured.";class ne{constructor(e){if(this._options=e,this._integrations={},this._integrationsInitialized=!1,this._numProcessing=0,this._outcomes={},this._hooks={},this._eventProcessors=[],e.dsn?this._dsn=function(e){const t="string"==typeof e?function(e){const t=X.exec(e);if(!t)return void(0,u.Cf)((()=>{console.error(`Invalid Sentry Dsn: ${e}`)}));const[n,s,o="",i,r="",a]=t.slice(1);let c="",l=a;const g=l.split("/");if(g.length>1&&(c=g.slice(0,-1).join("/"),l=g.pop()),l){const e=l.match(/^\d+/);e&&(l=e[0])}return Y({host:i,pass:o,path:c,projectId:l,port:r,protocol:n,publicKey:s})}(e):Y(e);if(t&&function(e){if(!H.X)return!0;const{port:t,projectId:n,protocol:s}=e;return!(["protocol","publicKey","host","projectId"].find((t=>!e[t]&&(u.kg.error(`Invalid Sentry Dsn: ${t} missing`),!0)))||(n.match(/^\d+$/)?function(e){return"http"===e||"https"===e}(s)?t&&isNaN(parseInt(t,10))&&(u.kg.error(`Invalid Sentry Dsn: Invalid port ${t}`),1):(u.kg.error(`Invalid Sentry Dsn: Invalid protocol ${s}`),1):(u.kg.error(`Invalid Sentry Dsn: Invalid projectId ${n}`),1)))}(t))return t}(e.dsn):p.X&&u.kg.warn("No DSN provided, client will not send events."),this._dsn){const t=function(e,t={}){const n="string"==typeof t?t:t.tunnel,s="string"!=typeof t&&t._metadata?t._metadata.sdk:void 0;return n||`${function(e){return`${function(e){const t=e.protocol?`${e.protocol}:`:"",n=e.port?`:${e.port}`:"";return`${t}//${e.host}${n}${e.path?`/${e.path}`:""}/api/`}(e)}${e.projectId}/envelope/`}(e)}?${function(e,t){return(0,a._j)({sentry_key:e.publicKey,sentry_version:"7",...t&&{sentry_client:`${t.name}/${t.version}`}})}(e,s)}`}(this._dsn,e);this._transport=e.transport({recordDroppedEvent:this.recordDroppedEvent.bind(this),...e.transportOptions,url:t})}}captureException(e,t,n){if((0,h.YO)(e))return void(p.X&&u.kg.log(te));let s=t&&t.event_id;return this._process(this.eventFromException(e,t).then((e=>this._captureEvent(e,t,n))).then((e=>{s=e}))),s}captureMessage(e,t,n,s){let o=n&&n.event_id;const i=(0,Z.pt)(e)?this.eventFromMessage(String(e),t,n):this.eventFromException(e,n);return this._process(i.then((e=>this._captureEvent(e,n,s))).then((e=>{o=e}))),o}captureEvent(e,t,n){if(t&&t.originalException&&(0,h.YO)(t.originalException))return void(p.X&&u.kg.log(te));let s=t&&t.event_id;return this._process(this._captureEvent(e,t,n).then((e=>{s=e}))),s}captureSession(e){"string"!=typeof e.release?p.X&&u.kg.warn("Discarded session because of missing or non-string release"):(this.sendSession(e),(0,q.CT)(e,{init:!1}))}getDsn(){return this._dsn}getOptions(){return this._options}getSdkMetadata(){return this._options._metadata}getTransport(){return this._transport}flush(e){const t=this._transport;return t?(this.metricsAggregator&&this.metricsAggregator.flush(),this._isClientDoneProcessing(e).then((n=>t.flush(e).then((e=>n&&e))))):(0,N.WD)(!0)}close(e){return this.flush(e).then((e=>(this.getOptions().enabled=!1,this.metricsAggregator&&this.metricsAggregator.close(),e)))}getEventProcessors(){return this._eventProcessors}addEventProcessor(e){this._eventProcessors.push(e)}setupIntegrations(e){(e&&!this._integrationsInitialized||this._isEnabled()&&!this._integrationsInitialized)&&(this._integrations=(0,c.q4)(this,this._options.integrations),this._integrationsInitialized=!0)}getIntegrationById(e){return this._integrations[e]}getIntegration(e){try{return this._integrations[e.id]||null}catch(t){return p.X&&u.kg.warn(`Cannot retrieve integration ${e.id} from the current Client`),null}}addIntegration(e){(0,c.m7)(this,e,this._integrations)}sendEvent(e,t={}){this.emit("beforeSendEvent",e,t);let n=function(e,t,n,s){const o=U(n),i=e.type&&"replay_event"!==e.type?e.type:"event";!function(e,t){t&&(e.sdk=e.sdk||{},e.sdk.name=e.sdk.name||t.name,e.sdk.version=e.sdk.version||t.version,e.sdk.integrations=[...e.sdk.integrations||[],...t.integrations||[]],e.sdk.packages=[...e.sdk.packages||[],...t.packages||[]])}(e,n&&n.sdk);const r=function(e,t,n,s){const o=e.sdkProcessingMetadata&&e.sdkProcessingMetadata.dynamicSamplingContext;return{event_id:e.event_id,sent_at:(new Date).toISOString(),...t&&{sdk:t},...!!n&&s&&{dsn:k(s)},...o&&{trace:(0,a.Jr)({...o})}}}(e,o,s,t);return delete e.sdkProcessingMetadata,J(r,[[{type:i},e]])}(e,this._dsn,this._options._metadata,this._options.tunnel);for(const e of t.attachments||[])n=_(n,z(e,this._options.transportOptions&&this._options.transportOptions.textEncoder));const s=this._sendEnvelope(n);s&&s.then((t=>this.emit("afterSendEvent",e,t)),null)}sendSession(e){const t=function(e,t,n,s){const o=U(n);return J({sent_at:(new Date).toISOString(),...o&&{sdk:o},...!!s&&t&&{dsn:k(t)}},["aggregates"in e?[{type:"sessions"},e]:[{type:"session"},e.toJSON()]])}(e,this._dsn,this._options._metadata,this._options.tunnel);this._sendEnvelope(t)}recordDroppedEvent(e,t,n){if(this._options.sendClientReports){const n=`${e}:${t}`;p.X&&u.kg.log(`Adding outcome: "${n}"`),this._outcomes[n]=this._outcomes[n]+1||1}}captureAggregateMetrics(e){p.X&&u.kg.log(`Flushing aggregated metrics, number of metrics: ${e.length}`);const t=function(e,t,n,s){const o={sent_at:(new Date).toISOString()};n&&n.sdk&&(o.sdk={name:n.sdk.name,version:n.sdk.version}),s&&t&&(o.dsn=k(t));const i=function(e){const t=function(e){let t="";for(const n of e){const e=Object.entries(n.tags),s=e.length>0?`|#${e.map((([e,t])=>`${e}:${t}`)).join(",")}`:"";t+=`${n.name}@${n.unit}:${n.metric}|${n.metricType}${s}|T${n.timestamp}\n`}return t}(e);return[{type:"statsd",length:t.length},t]}(e);return J(o,[i])}(e,this._dsn,this._options._metadata,this._options.tunnel);this._sendEnvelope(t)}on(e,t){this._hooks[e]||(this._hooks[e]=[]),this._hooks[e].push(t)}emit(e,...t){this._hooks[e]&&this._hooks[e].forEach((e=>e(...t)))}_updateSessionFromEvent(e,t){let n=!1,s=!1;const o=t.exception&&t.exception.values;if(o){s=!0;for(const e of o){const t=e.mechanism;if(t&&!1===t.handled){n=!0;break}}}const i="ok"===e.status;(i&&0===e.errors||i&&n)&&((0,q.CT)(e,{...n&&{status:"crashed"},errors:e.errors||Number(s||n)}),this.captureSession(e))}_isClientDoneProcessing(e){return new N.cW((t=>{let n=0;const s=setInterval((()=>{0==this._numProcessing?(clearInterval(s),t(!0)):(n+=1,e&&n>=e&&(clearInterval(s),t(!1)))}),1)}))}_isEnabled(){return!1!==this.getOptions().enabled&&void 0!==this._transport}_prepareEvent(e,t,n,s=(0,O.aF)()){const o=this.getOptions(),i=Object.keys(this._integrations);return!t.integrations&&i.length>0&&(t.integrations=i),this.emit("preprocessEvent",e,t),(0,ee.R)(o,e,t,n,this,s).then((e=>{if(null===e)return e;const{propagationContext:t}=e.sdkProcessingMetadata||{};if((!e.contexts||!e.contexts.trace)&&t){const{traceId:s,spanId:o,parentSpanId:i,dsc:r}=t;e.contexts={trace:{trace_id:s,span_id:o,parent_span_id:i},...e.contexts};const a=r||(0,$._)(s,this,n);e.sdkProcessingMetadata={dynamicSamplingContext:a,...e.sdkProcessingMetadata}}return e}))}_captureEvent(e,t={},n){return this._processEvent(e,t,n).then((e=>e.event_id),(e=>{if(p.X){const t=e;"log"===t.logLevel?u.kg.log(t.message):u.kg.warn(t)}}))}_processEvent(e,t,n){const s=this.getOptions(),{sampleRate:o}=s,i=oe(e),r=se(e),a=e.type||"error",c=`before send for type \`${a}\``;if(r&&"number"==typeof o&&Math.random()>o)return this.recordDroppedEvent("sample_rate","error",e),(0,N.$2)(new Q(`Discarding event because it's not included in the random sample (sampling rate = ${o})`,"log"));const l="replay_event"===a?"replay":a;return this._prepareEvent(e,t,n).then((n=>{if(null===n)throw this.recordDroppedEvent("event_processor",l,e),new Q("An event processor returned `null`, will not send event.","log");if(t.data&&!0===t.data.__sentry__)return n;const o=function(e,t,n){const{beforeSend:s,beforeSendTransaction:o}=e;return se(t)&&s?s(t,n):oe(t)&&o?o(t,n):t}(s,n,t);return function(e,t){const n=`${t} must return \`null\` or a valid event.`;if((0,Z.J8)(e))return e.then((e=>{if(!(0,Z.PO)(e)&&null!==e)throw new Q(n);return e}),(e=>{throw new Q(`${t} rejected with ${e}`)}));if(!(0,Z.PO)(e)&&null!==e)throw new Q(n);return e}(o,c)})).then((s=>{if(null===s)throw this.recordDroppedEvent("before_send",l,e),new Q(`${c} returned \`null\`, will not send event.`,"log");const o=n&&n.getSession();!i&&o&&this._updateSessionFromEvent(o,s);const r=s.transaction_info;if(i&&r&&s.transaction!==e.transaction){const e="custom";s.transaction_info={...r,source:e}}return this.sendEvent(s,t),s})).then(null,(e=>{if(e instanceof Q)throw e;throw this.captureException(e,{data:{__sentry__:!0},originalException:e}),new Q(`Event processing pipeline threw an error, original event will not be sent. Details have been sent as a new event.\nReason: ${e}`)}))}_process(e){this._numProcessing++,e.then((e=>(this._numProcessing--,e)),(e=>(this._numProcessing--,e)))}_sendEnvelope(e){if(this.emit("beforeEnvelope",e),this._isEnabled()&&this._transport)return this._transport.send(e).then(null,(e=>{p.X&&u.kg.error("Error while sending event:",e)}));p.X&&u.kg.error("Transport disabled")}_clearOutcomes(){const e=this._outcomes;return this._outcomes={},Object.keys(e).map((t=>{const[n,s]=t.split(":");return{reason:n,category:s,quantity:e[t]}}))}}function se(e){return void 0===e.type}function oe(e){return"transaction"===e.type}function ie(e){const t=(0,L.s3)();t&&t.addEventProcessor&&t.addEventProcessor(e)}const re=6e4;const ae=30;function ce(e,t,n=function(e){const t=[];function n(e){return t.splice(t.indexOf(e),1)[0]}return{$:t,add:function(s){if(!(void 0===e||t.lengthn(o))).then(null,(()=>n(o).then(null,(()=>{})))),o},drain:function(e){return new N.cW(((n,s)=>{let o=t.length;if(!o)return n(!0);const i=setTimeout((()=>{e&&e>0&&n(!1)}),e);t.forEach((e=>{(0,N.WD)(e).then((()=>{--o||(clearTimeout(i),n(!0))}),s)}))}))}}}(e.bufferSize||ae)){let s={};function o(o){const i=[];if(K(o,((t,n)=>{const o=E(n);if(function(e,t,n=Date.now()){return function(e,t){return e[t]||e.all||0}(e,t)>n}(s,o)){const s=le(t,n);e.recordDroppedEvent("ratelimit_backoff",o,s)}else i.push(t)})),0===i.length)return(0,N.WD)();const r=J(o[0],i),a=t=>{K(r,((n,s)=>{const o=le(n,s);e.recordDroppedEvent(t,E(s),o)}))};return n.add((()=>t({body:x(r,e.textEncoder)}).then((e=>(void 0!==e.statusCode&&(e.statusCode<200||e.statusCode>=300)&&p.X&&u.kg.warn(`Sentry responded with status code ${e.statusCode} to sent event.`),s=function(e,{statusCode:t,headers:n},s=Date.now()){const o={...e},i=n&&n["x-sentry-rate-limits"],r=n&&n["retry-after"];if(i)for(const e of i.trim().split(",")){const[t,n]=e.split(":",2),i=parseInt(t,10),r=1e3*(isNaN(i)?60:i);if(n)for(const e of n.split(";"))o[e]=s+r;else o.all=s+r}else r?o.all=s+function(e,t=Date.now()){const n=parseInt(`${e}`,10);if(!isNaN(n))return 1e3*n;const s=Date.parse(`${e}`);return isNaN(s)?re:s-t}(r,s):429===t&&(o.all=s+6e4);return o}(s,e),e)),(e=>{throw a("network_error"),e})))).then((e=>e),(e=>{if(e instanceof Q)return p.X&&u.kg.error("Skipped sending event because buffer is full."),a("queue_overflow"),(0,N.WD)();throw e}))}return o.__sentry__baseTransport__=!0,{send:o,flush:e=>n.drain(e)}}function le(e,t){if("event"===t||"transaction"===t)return Array.isArray(e)?e[1]:void 0}var ge=n(1170);const de={c:class{constructor(e){this._value=e}get weight(){return 1}add(e){this._value+=e}toString(){return`${this._value}`}},g:class{constructor(e){this._last=e,this._min=e,this._max=e,this._sum=e,this._count=1}get weight(){return 5}add(e){this._last=e,ethis._max&&(this._max=e),this._sum+=e,this._count++}toString(){return`${this._last}:${this._min}:${this._max}:${this._sum}:${this._count}`}},d:class{constructor(e){this._value=[e]}get weight(){return this._value.length}add(e){this._value.push(e)}toString(){return this._value.join(":")}},s:class{constructor(e){this.first=e,this._value=new Set([e])}get weight(){return this._value.size}add(e){this._value.add(e)}toString(){return Array.from(this._value).map((e=>"string"==typeof e?function(e){let t=0;for(let n=0;n>>0}(e):e)).join(":")}}};class ue{constructor(e){this._client=e,this._buckets=new Map,this._interval=setInterval((()=>this.flush()),5e3)}add(e,t,n,s="none",o={},i=(0,ge.ph)()){const r=Math.floor(i),a=t.replace(j,"_"),c=D(o),l=P(e,a,s,c),g=this._buckets.get(l);g?(g.metric.add(n),g.timestampe));this._client.captureAggregateMetrics(e)}this._buckets.clear()}}close(){clearInterval(this._interval),this.flush()}}const he="MetricsAggregator";function Ie(e,t,n,s={}){const o=(0,L.s3)(),i=(0,L.nZ)();if(o){if(!o.metricsAggregator)return void(p.X&&u.kg.warn("No metrics aggregator enabled. Please add the MetricsAggregator integration to use metrics APIs"));const{unit:r,tags:a,timestamp:c}=s,{release:l,environment:g}=o.getOptions(),d=i.getTransaction(),h={};l&&(h.release=l),g&&(h.environment=g),d&&(h.transaction=d.name),p.X&&u.kg.log(`Adding value of ${n} to ${e} metric ${t}`),o.metricsAggregator.add(e,t,n,r,{...h,...a},c)}}const pe={increment:function(e,t=1,n){Ie("c",e,t,n)},distribution:function(e,t,n){Ie("d",e,t,n)},set:function(e,t,n){Ie("s",e,t,n)},gauge:function(e,t,n){Ie("g",e,t,n)},MetricsAggregator:(0,c.RN)(he,(()=>({name:he,setup(e){e.metricsAggregator=new ue(e)}})))};var Ce=n(9791);function me(e,t,n){const s=(0,Ce.x1)();s&&s.setMeasurement(e,t,n)}var be=n(105),ye=n(350),fe=n(1195),Ze=n(4317),Ae=n(8903),Ge=n(6046);function Be(){const e=Ge.G.map((e=>{try{return e()}catch(e){return}})).filter((e=>!!e));return 0===e.length&&u.kg.warn("Performance monitoring integrations could not be automatically loaded."),e.filter((e=>!!e.loadDependency()))}var ve=n(2037),We=n(3837);class Ve{constructor(e){this._client=e,this._buckets=new Map,this._bucketsTotalWeight=0,this._interval=setInterval((()=>this._flush()),1e4),this._flushShift=Math.floor(1e4*Math.random()/1e3),this._forceFlush=!1}add(e,t,n,s="none",o={},i=(0,ge.ph)()){const r=Math.floor(i),a=t.replace(j,"_"),c=D(o),l=P(e,a,s,c);let g=this._buckets.get(l);g?(g.metric.add(n),g.timestamp=1e4&&this.flush()}flush(){this._forceFlush=!0,this._flush()}close(){this._forceFlush=!0,clearInterval(this._interval),this._flush()}_flush(){if(this._forceFlush)return this._forceFlush=!1,this._bucketsTotalWeight=0,this._captureMetrics(this._buckets),void this._buckets.clear();const e=Math.floor((0,ge.ph)())-10-this._flushShift,t=new Map;for(const[n,s]of this._buckets)s.timestamp<=e&&(t.set(n,s),this._bucketsTotalWeight-=s.metric.weight);for(const[e]of t)this._buckets.delete(e);this._captureMetrics(t)}_captureMetrics(e){if(e.size>0&&this._client.captureAggregateMetrics){const t=Array.from(e).map((([,e])=>e));this._client.captureAggregateMetrics(t)}}}class we{constructor(e,t){this._client=e,this.flushTimeout=60,this._pendingAggregates={},this._isEnabled=!0,this._intervalId=setInterval((()=>this.flush()),1e3*this.flushTimeout),this._sessionAttrs=t}flush(){const e=this.getSessionAggregates();0!==e.aggregates.length&&(this._pendingAggregates={},this._client.sendSession(e))}getSessionAggregates(){const e=Object.keys(this._pendingAggregates).map((e=>this._pendingAggregates[parseInt(e)])),t={attrs:this._sessionAttrs,aggregates:e};return(0,a.Jr)(t)}close(){clearInterval(this._intervalId),this._isEnabled=!1,this.flush()}incrementSessionStatusCount(){if(!this._isEnabled)return;const e=(0,L.nZ)(),t=e.getRequestSession();t&&t.status&&(this._incrementSessionStatusCount(t.status,new Date),e.setRequestSession(void 0))}_incrementSessionStatusCount(e,t){const n=new Date(t).setSeconds(0,0);this._pendingAggregates[n]=this._pendingAggregates[n]||{};const s=this._pendingAggregates[n];switch(s.started||(s.started=new Date(n).toISOString()),e){case"errored":return s.errored=(s.errored||0)+1,s.errored;case"ok":return s.exited=(s.exited||0)+1,s.exited;default:return s.crashed=(s.crashed||0)+1,s.crashed}}}var Se=n(1283),Re=n(3371);class He extends ne{constructor(e){(0,Se.T)(),super(e),e._experiments&&e._experiments.metricsAggregator&&(this.metricsAggregator=new Ve(this))}eventFromException(e,t){return(0,N.WD)(function(e,t,n,s){const o="function"==typeof e?e().getClient():e;let i=n;const r=s&&s.data&&s.data.mechanism||{handled:!0,type:"generic"};let c;if(!(0,Z.VZ)(n)){if((0,Z.PO)(n)){const e=o&&o.getOptions().normalizeDepth;c={__serialized__:(0,W.Qy)(n,e)};const t=function(e){if("name"in e&&"string"==typeof e.name){let t=`'${e.name}' captured as exception`;return"message"in e&&"string"==typeof e.message&&(t+=` with message '${e.message}'`),t}return"message"in e&&"string"==typeof e.message?e.message:`Object captured as exception with keys: ${(0,a.zf)(e)}`}(n);i=s&&s.syntheticException||new Error(t),i.message=t}else i=s&&s.syntheticException||new Error(n),i.message=n;r.synthetic=!0}const l={exception:{values:[w(t,i)]}};return c&&(l.extra=c),(0,h.Db)(l,void 0,void 0),(0,h.EG)(l,r),{...l,event_id:s&&s.event_id}}((0,L.s3)(),this._options.stackParser,e,t))}eventFromMessage(e,t="info",n){return(0,N.WD)(function(e,t,n="info",s,o){const i={event_id:s&&s.event_id,level:n,message:t};if(o&&s&&s.syntheticException){const n=V(e,s.syntheticException);n.length&&(i.exception={values:[{value:t,stacktrace:{frames:n}}]})}return i}(this._options.stackParser,e,t,n,this._options.attachStacktrace))}captureException(e,t,n){if(this._options.autoSessionTracking&&this._sessionFlusher&&n){const e=n.getRequestSession();e&&"ok"===e.status&&(e.status="errored")}return super.captureException(e,t,n)}captureEvent(e,t,n){if(this._options.autoSessionTracking&&this._sessionFlusher&&n&&"exception"===(e.type||"exception")&&e.exception&&e.exception.values&&e.exception.values.length>0){const e=n.getRequestSession();e&&"ok"===e.status&&(e.status="errored")}return super.captureEvent(e,t,n)}close(e){return this._sessionFlusher&&this._sessionFlusher.close(),super.close(e)}initSessionFlusher(){const{release:e,environment:t}=this._options;e?this._sessionFlusher=new we(this,{release:e,environment:t}):p.X&&u.kg.warn("Cannot initialise an instance of SessionFlusher if no release is provided!")}captureCheckIn(e,t,n){const s="checkInId"in e&&e.checkInId?e.checkInId:(0,h.DM)();if(!this._isEnabled())return p.X&&u.kg.warn("SDK not enabled, will not capture checkin."),s;const o=this.getOptions(),{release:i,environment:r,tunnel:c}=o,l={check_in_id:s,monitor_slug:e.monitorSlug,status:e.status,release:i,environment:r};"duration"in e&&(l.duration=e.duration),t&&(l.monitor_config={schedule:t.schedule,checkin_margin:t.checkinMargin,max_runtime:t.maxRuntime,timezone:t.timezone});const[g,d]=this._getTraceInfoFromScope(n);d&&(l.contexts={trace:d});const I=function(e,t,n,s,o){const i={sent_at:(new Date).toISOString()};n&&n.sdk&&(i.sdk={name:n.sdk.name,version:n.sdk.version}),s&&o&&(i.dsn=k(o)),t&&(i.trace=(0,a.Jr)(t));const r=function(e){return[{type:"check_in"},e]}(e);return J(i,[r])}(l,g,this.getSdkMetadata(),c,this.getDsn());return p.X&&u.kg.info("Sending checkin:",e.monitorSlug,e.status),this._sendEnvelope(I),s}_captureRequestSession(){this._sessionFlusher?this._sessionFlusher.incrementSessionStatusCount():p.X&&u.kg.warn("Discarded request mode session because autoSessionTracking option was disabled")}_prepareEvent(e,t,n,s){return this._options.platform&&(e.platform=e.platform||this._options.platform),this._options.runtime&&(e.contexts={...e.contexts,runtime:(e.contexts||{}).runtime||this._options.runtime}),this._options.serverName&&(e.server_name=e.server_name||this._options.serverName),super._prepareEvent(e,t,n,s)}_getTraceInfoFromScope(e){if(!e)return[void 0,void 0];const t=e.getSpan();if(t)return[t.transaction?t.transaction.getDynamicSamplingContext():void 0,(0,Re.w)(t)];const{traceId:n,spanId:s,parentSpanId:o,dsc:i}=e.getPropagationContext(),r={trace_id:n,span_id:s,parent_span_id:o};return i?[i,r]:[(0,$._)(n,this,e),r]}}class Xe extends He{constructor(e){e._metadata=e._metadata||{},e._metadata.sdk=e._metadata.sdk||{name:"sentry.javascript.node",packages:[{name:"npm:@sentry/node",version:be.J}],version:be.J},e.transportOptions={textEncoder:new We.TextEncoder,...e.transportOptions},super({...e,platform:"node",runtime:{name:"node",version:global.process.version},serverName:e.serverName||global.process.env.SENTRY_NAME||ve.hostname()})}}function ke(e,t){return null!=e?e:t()}var Ye=n(3685),Ne=n(5687),Je=n(2781),_e=n(7310),Ke=n(9796),Fe=n(6018);const xe=32768;function ze(e){let t;try{t=new _e.URL(e.url)}catch(t){return(0,u.Cf)((()=>{console.warn("[@sentry/node]: Invalid dsn or tunnel option, will not send any events. The tunnel option must be a full URL when used.")})),ce(e,(()=>Promise.resolve({})))}const n="https:"===t.protocol,s=function(e,t){const{no_proxy:n}=process.env;return n&&n.split(",").some((t=>e.host.endsWith(t)||e.hostname.endsWith(t)))?void 0:t}(t,e.proxy||(n?process.env.https_proxy:void 0)||process.env.http_proxy),o=n?Ne:Ye,i=void 0!==e.keepAlive&&e.keepAlive,r=s?new Fe.HttpsProxyAgent(s):new o.Agent({keepAlive:i,maxSockets:30,timeout:2e3}),a=function(e,t,n){const{hostname:s,pathname:o,port:i,protocol:r,search:a}=new _e.URL(e.url);return function(c){return new Promise(((l,g)=>{let d=function(e){return new Je.Readable({read(){this.push(e),this.push(null)}})}(c.body);const u={...e.headers};c.body.length>xe&&(u["content-encoding"]="gzip",d=d.pipe((0,Ke.createGzip)()));const h=t.request({method:"POST",agent:n,headers:u,hostname:s,path:`${o}${a}`,port:i,protocol:r,ca:e.caCerts},(e=>{e.on("data",(()=>{})),e.on("end",(()=>{})),e.setEncoding("utf8");const t=ke(e.headers["retry-after"],(()=>null)),n=ke(e.headers["x-sentry-rate-limits"],(()=>null));l({statusCode:e.statusCode,headers:{"retry-after":t,"x-sentry-rate-limits":Array.isArray(n)?n[0]:n}})}));h.on("error",g),d.pipe(h)}))}}(e,ke(e.httpModule,(()=>o)),r);return ce(e,a)}var Te=n(4307),Ee=n(771);const Ue={include:{cookies:!0,data:!0,headers:!0,ip:!1,query_string:!0,url:!0,user:{id:!0,username:!0,email:!0}},transactionNamingScheme:"methodPath"},Qe="RequestData",Le=(0,c.RN)(Qe,((e={})=>{const t=Ee.S6,n={...Ue,...e,include:{method:!0,...Ue.include,...e.include,user:e.include&&"boolean"==typeof e.include.user?e.include.user:{...Ue.include.user,...(e.include||{}).user}}};return{name:Qe,processEvent(e,s,o){const{transactionNamingScheme:i}=n,{sdkProcessingMetadata:r={}}=e,a=r.request;if(!a)return e;const c=r.requestDataOptionsFromExpressHandler||r.requestDataOptionsFromGCPWrapper||function(e){const{transactionNamingScheme:t,include:{ip:n,user:s,...o}}=e,i=[];for(const[e,t]of Object.entries(o))t&&i.push(e);let r;if(void 0===s)r=!0;else if("boolean"==typeof s)r=s;else{const e=[];for(const[t,n]of Object.entries(s))n&&e.push(t);r=e}return{include:{ip:n,user:r,request:0!==i.length?i:void 0,transaction:t}}}(n),l=t(e,a,c);if("transaction"===e.type||"handler"===i)return l;const g=a._sentryTransaction;if(g){const e="sentry.javascript.nextjs"===function(e){try{return e.getOptions()._metadata.sdk.name}catch(e){return}}(o)?g.name.startsWith("/api"):"path"!==i,[t]=(0,Ee.oA)(a,{path:!0,method:e,customRoute:g.name});l.transaction=t}return l}}}));var Oe=n(6147),je=n(1235),Me=n(7638),Pe=n(9656);const De=require("domain");function qe(){return De.active}function $e(){const e=qe();if(e)return(0,O.uZ)(e),(0,O.vi)(e)}function et(e,t){const n=qe();if(n&&(0,Te.x)([t,"optionalAccess",e=>e.reuseExisting]))return e();const s=De.create(),o=function(e){const t={};return(0,O.uZ)(t,e),(0,O.vi)(t)}(n?(0,O.vi)(n):void 0);return(0,O.j0)(s,o),s.bind((()=>e()))()}const tt=require("async_hooks");let nt;function st(){Pe.V.major>=14?function(){function e(){return nt.getStore()}nt||(nt=new tt.AsyncLocalStorage),(0,O.$b)({getCurrentHub:e,runWithAsyncContext:function(t,n){const s=e();if(s&&(0,Te.x)([n,"optionalAccess",e=>e.reuseExisting]))return t();const o=function(e){const t={};return(0,O.uZ)(t,e),(0,O.vi)(t)}(s);return nt.run(o,(()=>t()))}})}():(0,O.$b)({getCurrentHub:$e,runWithAsyncContext:et})}var ot=n(9729);function it(){"console"in je.n2&&u.RU.forEach((function(e){e in je.n2.console&&(0,a.hl)(je.n2.console,e,(function(t){return u.LD[e]=t,function(...t){const n={args:t,level:e};(0,ot.rK)("console",n);const s=u.LD[e];s&&s.apply(je.n2.console,t)}}))}))}const rt=["fatal","error","warning","log","info","debug"];function at(e){return"warn"===e?"warning":rt.includes(e)?e:"log"}const ct="Console",lt=(0,c.RN)(ct,(()=>({name:ct,setup(e){!function(t){const n="console";(0,ot.Hj)(n,(({args:t,level:n})=>{(0,L.s3)()===e&&(0,L.n_)({category:"console",level:at(n),message:We.format.apply(void 0,t)},{input:[...t],level:n})})),(0,ot.D2)(n,it)}()}})));var gt=n(766),dt=n(3641),ut=n(9181);const ht="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__;function It(e){const{protocol:t,hostname:n,port:s}=mt(e),o=e.pathname||"/";return`${t}//${e.auth?function(e){const[t,n]=e.split(":");return`${t?"[Filtered]":""}:${n?"[Filtered]":""}@`}(e.auth):""}${n}${s}${o}`}function pt(e,t,n){if(!e)return e;let[s,o]=e.split(" ");return t.host&&!t.protocol&&(t.protocol=(0,Te.x)([n,"optionalAccess",e=>e.agent,"optionalAccess",e=>e.protocol]),o=It(t)),(0,Te.x)([o,"optionalAccess",e=>e.startsWith,"call",e=>e("///")])&&(o=o.slice(2)),`${s} ${o}`}function Ct(e){const t={protocol:e.protocol,hostname:"string"==typeof e.hostname&&e.hostname.startsWith("[")?e.hostname.slice(1,-1):e.hostname,hash:e.hash,search:e.search,pathname:e.pathname,path:`${e.pathname||""}${e.search||""}`,href:e.href};return""!==e.port&&(t.port=Number(e.port)),(e.username||e.password)&&(t.auth=`${e.username}:${e.password}`),t}function mt(e){const t=e.protocol||"",n=e.hostname||e.host||"";return{protocol:t,hostname:n,port:!e.port||80===e.port||443===e.port||/^(.*):(\d+)$/.test(n)?"":`:${e.port}`}}class bt{static __initStatic(){this.id="Http"}__init(){this.name=bt.id}constructor(e={}){bt.prototype.__init.call(this),this._breadcrumbs=void 0===e.breadcrumbs||e.breadcrumbs,this._tracing=e.tracing?!0===e.tracing?{}:e.tracing:void 0}setupOnce(e,t){if(!this._breadcrumbs&&!this._tracing)return;const s=(0,Te.x)([t,"call",e=>e(),"access",e=>e.getClient,"call",e=>e(),"optionalAccess",e=>e.getOptions,"call",e=>e()]);if(s&&"sentry"!==s.instrumenter)return void(ht&&u.kg.log("HTTP Integration is skipped because of instrumenter configuration."));const o=(0,Te.x)([this,"access",e=>e._tracing,"optionalAccess",e=>e.shouldCreateSpanForRequest])||(0,Te.x)([s,"optionalAccess",e=>e.shouldCreateSpanForRequest]),i=(0,Te.x)([s,"optionalAccess",e=>e.tracePropagationTargets])||(0,Te.x)([this,"access",e=>e._tracing,"optionalAccess",e=>e.tracePropagationTargets]),r=n(3685),c=yt(r,this._breadcrumbs,o,i);if((0,a.hl)(r,"get",c),(0,a.hl)(r,"request",c),Pe.V.major>8){const e=n(5687),t=yt(e,this._breadcrumbs,o,i);(0,a.hl)(e,"get",t),(0,a.hl)(e,"request",t)}}}function yt(e,t,n,s){const o=new dt.f(100),i=new dt.f(100);function r(e,t,n,s){(0,O.Gd)().getIntegration(bt)&&(0,L.n_)({category:"http",data:{status_code:s&&s.statusCode,...t},type:"http"},{event:e,request:n,response:s})}return function(a){return function(...c){const l=function(e,t){let n,s;if("function"==typeof t[t.length-1]&&(n=t.pop()),"string"==typeof t[0])s=Ct(new _e.URL(t[0]));else if(t[0]instanceof _e.URL)s=Ct(t[0]);else{s=t[0];try{const e=new _e.URL(s.path||"",`${s.protocol||"http:"}//${s.hostname}`);s={pathname:e.pathname,search:e.search,hash:e.hash,...s}}catch(e){}}return 2===t.length&&(s={...s,...t[1]}),void 0===s.protocol&&(Pe.V.major>8?s.protocol=(0,Te.x)([(0,Te.x)([e,"optionalAccess",e=>e.globalAgent]),"optionalAccess",e=>e.protocol])||(0,Te.x)([s.agent,"optionalAccess",e=>e.protocol])||(0,Te.x)([s._defaultAgent,"optionalAccess",e=>e.protocol]):s.protocol=(0,Te.x)([s.agent,"optionalAccess",e=>e.protocol])||(0,Te.x)([s._defaultAgent,"optionalAccess",e=>e.protocol])||(0,Te.x)([(0,Te.x)([e,"optionalAccess",e=>e.globalAgent]),"optionalAccess",e=>e.protocol])),n?[s,n]:[s]}(e,c),g=l[0],d=function(e){const{protocol:t,hostname:n,port:s}=mt(e);return`${t}//${n}${s}${e.path?e.path:"/"}`}(g),h=It(g);if((0,gt.W)(h,(0,L.s3)()))return a.apply(e,l);const p=(0,L.nZ)(),C=p.getSpan(),m=function(e,t){const n={url:e,"http.method":t.method||"GET"};return t.hash&&(n["http.fragment"]=t.hash.substring(1)),t.search&&(n["http.query"]=t.search.substring(1)),n}(h,g),b=(e=>{if(void 0===n)return!0;const t=o.get(e);if(void 0!==t)return t;const s=n(e);return o.set(e,s),s})(d)?(0,Te.x)([C,"optionalAccess",e=>e.startChild,"call",e=>e({op:"http.client",origin:"auto.http.node.http",description:`${m["http.method"]} ${m.url}`,data:m})]):void 0;if((e=>{if(void 0===s)return!0;const t=i.get(e);if(void 0!==t)return t;const n=(0,I.U0)(e,s);return i.set(e,n),n})(d))if(b){const e=(0,Re.H)(b),t=(0,Te.x)([b,"optionalAccess",e=>e.transaction,"optionalAccess",e=>e.getDynamicSamplingContext,"call",e=>e()]);ft(g,h,e,t)}else{const e=(0,L.s3)(),{traceId:t,sampled:n,dsc:s}=p.getPropagationContext(),o=(0,Me.$p)(t,void 0,n),i=s||(e?(0,$._)(t,e,p):void 0);ft(g,h,o,i)}else ht&&u.kg.log(`[Tracing] Not adding sentry-trace header to outgoing request (${h}) due to mismatching tracePropagationTargets option.`);return a.apply(e,l).once("response",(function(e){t&&r("response",m,this,e),b&&(e.statusCode&&b.setHttpStatus(e.statusCode),b.description=pt(b.description,g,this),b.end())})).once("error",(function(){t&&r("error",m,this),b&&(b.setHttpStatus(500),b.description=pt(b.description,g,this),b.end())}))}}}function ft(e,t,n,s){if((e.headers||{})["sentry-trace"])return;ht&&u.kg.log(`[Tracing] Adding sentry-trace header ${n} to outgoing request to "${t}": `);const o=(0,ut.IQ)(s),i=o&&o.length>0?function(e,t){return e.headers&&e.headers.baggage?t?Array.isArray(e.headers.baggage)?[...e.headers.baggage,t]:[e.headers.baggage,t]:e.headers.baggage:t}(e,o):void 0;e.headers={...e.headers,"sentry-trace":n,...i&&{baggage:i}}}bt.__initStatic();function Zt(e){(0,u.Cf)((()=>{console.error(e)}));const t=(0,L.s3)();void 0===t&&(ht&&u.kg.warn("No NodeClient was defined, we are exiting the process now."),global.process.exit(1));const n=t.getOptions(),s=n&&n.shutdownTimeout&&n.shutdownTimeout>0&&n.shutdownTimeout||2e3;t.close(s).then((e=>{e||ht&&u.kg.warn("We reached the timeout for emptying the request buffer, still exiting now!"),global.process.exit(1)}),(e=>{ht&&u.kg.error(e)}))}const At="OnUncaughtException",Gt=(0,c.RN)(At,((e={})=>{const t={exitEvenIfOtherHandlersAreRegistered:!0,...e};return{name:At,setup(e){global.process.on("uncaughtException",function(e,t){let n,s=!1,o=!1,i=!1;const r=e.getOptions();return Object.assign((a=>{let c=Zt;t.onFatalError?c=t.onFatalError:r.onFatalError&&(c=r.onFatalError);const l=0===global.process.listeners("uncaughtException").reduce(((e,t)=>"domainUncaughtExceptionClear"===t.name||t.tag&&"sentry_tracingErrorCallback"===t.tag||t._errorHandler?e:e+1),0),g=t.exitEvenIfOtherHandlersAreRegistered||l;s?g&&(i?(ht&&u.kg.warn("uncaught exception after calling fatal error shutdown callback - this is bad! forcing shutdown"),Zt(a)):o||(o=!0,setTimeout((()=>{i||(i=!0,c(n,a))}),2e3))):(n=a,s=!0,(0,L.s3)()===e&&(0,L.Tb)(a,{originalException:a,captureContext:{level:"fatal"},mechanism:{handled:!1,type:"onuncaughtexception"}}),!i&&g&&(i=!0,c(a)))}),{_errorHandler:!0})}(e,t))}}})),Bt="OnUnhandledRejection",vt=(0,c.RN)(Bt,((e={})=>{const t=e.mode||"warn";return{name:Bt,setup(e){global.process.on("unhandledRejection",function(e,t){return function(n,s){(0,L.s3)()===e&&((0,L.Tb)(n,{originalException:s,captureContext:{extra:{unhandledPromiseRejection:!0}},mechanism:{handled:!1,type:"onunhandledrejection"}}),function(e,t){const n="This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:";"warn"===t.mode?(0,u.Cf)((()=>{console.warn(n),console.error(e&&e.stack?e.stack:e)})):"strict"===t.mode&&((0,u.Cf)((()=>{console.warn(n)})),Zt(e))}(n,t))}}(e,{mode:t}))}}})),Wt=require("fs");var Vt=n(1017);let wt;const St="Modules";function Rt(){const e=n.c[n.s]&&n.c[n.s].paths||[],t=function(){try{return n.c?Object.keys(n.c):[]}catch(e){return[]}}(),s={},o={};return t.forEach((t=>{let n=t;const i=()=>{const t=n;if(n=(0,Vt.dirname)(t),!n||t===n||o[t])return;if(e.indexOf(n)<0)return i();const r=(0,Vt.join)(t,"package.json");if(o[t]=!0,!(0,Wt.existsSync)(r))return i();try{const e=JSON.parse((0,Wt.readFileSync)(r,"utf8"));s[e.name]=e.version}catch(e){}};i()})),s}const Ht=(0,c.RN)(St,(()=>({name:St,processEvent:e=>(e.modules={...e.modules,...(wt||(wt=Rt()),wt)},e)}))),Xt=new dt.f(100),kt="ContextLines",Yt=(0,c.RN)(kt,((e={})=>{const t=void 0!==e.frameContextLines?e.frameContextLines:7;return{name:kt,processEvent:e=>async function(e,t){const n={},s=[];if(t>0&&(0,Te.x)([e,"access",e=>e.exception,"optionalAccess",e=>e.values]))for(const t of e.exception.values)if((0,Te.x)([t,"access",e=>e.stacktrace,"optionalAccess",e=>e.frames]))for(let e=t.stacktrace.frames.length-1;e>=0;e--){const o=t.stacktrace.frames[e];!o.filename||n[o.filename]||Xt.get(o.filename)||(s.push(Jt(o.filename)),n[o.filename]=1)}if(s.length>0&&await Promise.all(s),t>0&&(0,Te.x)([e,"access",e=>e.exception,"optionalAccess",e=>e.values]))for(const n of e.exception.values)n.stacktrace&&n.stacktrace.frames&&await Nt(n.stacktrace.frames,t);return e}(e,t)}}));function Nt(e,t){for(const n of e)if(n.filename&&void 0===n.context_line){const e=Xt.get(n.filename);if(e)try{(0,h.go)(e,n,t)}catch(e){}}}async function Jt(e){const t=Xt.get(e);if(null===t)return null;if(void 0!==t)return t;let n=null;try{n=(await(s=e,new Promise(((e,t)=>{(0,Wt.readFile)(s,"utf8",((n,s)=>{n?t(n):e(s)}))})))).split("\n")}catch(e){}var s;return Xt.set(e,n),n}var _t=n(2081);const Kt=(0,We.promisify)(Wt.readFile),Ft=(0,We.promisify)(Wt.readdir),xt="Context",zt=(0,c.RN)(xt,((e={})=>{let t;const n={app:!0,os:!0,device:!0,culture:!0,cloudResource:!0,...e};return{name:xt,processEvent:e=>async function(e){void 0===t&&(t=async function(){const e={};if(n.os&&(e.os=await async function(){const e=ve.platform();switch(e){case"darwin":return async function(){const e={kernel_version:ve.release(),name:"Mac OS X",version:"10."+(Number(ve.release().split(".")[0])-4)};try{const t=await new Promise(((e,t)=>{(0,_t.execFile)("/usr/bin/sw_vers",((n,s)=>{n?t(n):e(s)}))}));e.name=Qt(/^ProductName:\s+(.*)$/m,t),e.version=Qt(/^ProductVersion:\s+(.*)$/m,t),e.build=Qt(/^BuildVersion:\s+(.*)$/m,t)}catch(e){}return e}();case"linux":return async function(){const e={kernel_version:ve.release(),name:"Linux"};try{const t=await Ft("/etc"),n=Et.find((e=>t.includes(e.name)));if(!n)return e;const s=(0,Vt.join)("/etc",n.name),o=(await Kt(s,{encoding:"utf-8"})).toLowerCase(),{distros:i}=n;e.name=i.find((e=>o.indexOf(Lt(e))>=0))||i[0];const r=Lt(e.name);e.version=Ut[r](o)}catch(e){}return e}();default:return{name:Tt[e]||e,version:ve.release()}}}()),n.app&&(e.app=function(){const e=process.memoryUsage().rss;return{app_start_time:new Date(Date.now()-1e3*process.uptime()).toISOString(),app_memory:e}}()),n.device&&(e.device=function(e){const t={};let n;try{n=ve.uptime&&ve.uptime()}catch(e){}if("number"==typeof n&&(t.boot_time=new Date(Date.now()-1e3*n).toISOString()),t.arch=ve.arch(),(!0===e||e.memory)&&(t.memory_size=ve.totalmem(),t.free_memory=ve.freemem()),!0===e||e.cpu){const e=ve.cpus();if(e&&e.length){const n=e[0];t.processor_count=e.length,t.cpu_description=n.model,t.processor_frequency=n.speed}}return t}(n.device)),n.culture){const t=function(){try{if("string"!=typeof process.versions.icu)return;const e=new Date(9e8);if("enero"===new Intl.DateTimeFormat("es",{month:"long"}).format(e)){const e=Intl.DateTimeFormat().resolvedOptions();return{locale:e.locale,timezone:e.timeZone}}}catch(e){}}();t&&(e.culture=t)}return n.cloudResource&&(e.cloud_resource=process.env.VERCEL?{"cloud.provider":"vercel","cloud.region":process.env.VERCEL_REGION}:process.env.AWS_REGION?{"cloud.provider":"aws","cloud.region":process.env.AWS_REGION,"cloud.platform":process.env.AWS_EXECUTION_ENV}:process.env.GCP_PROJECT?{"cloud.provider":"gcp"}:process.env.ALIYUN_REGION_ID?{"cloud.provider":"alibaba_cloud","cloud.region":process.env.ALIYUN_REGION_ID}:process.env.WEBSITE_SITE_NAME&&process.env.REGION_NAME?{"cloud.provider":"azure","cloud.region":process.env.REGION_NAME}:process.env.IBM_CLOUD_REGION?{"cloud.provider":"ibm_cloud","cloud.region":process.env.IBM_CLOUD_REGION}:process.env.TENCENTCLOUD_REGION?{"cloud.provider":"tencent_cloud","cloud.region":process.env.TENCENTCLOUD_REGION,"cloud.account.id":process.env.TENCENTCLOUD_APPID,"cloud.availability_zone":process.env.TENCENTCLOUD_ZONE}:process.env.NETLIFY?{"cloud.provider":"netlify"}:process.env.FLY_REGION?{"cloud.provider":"fly.io","cloud.region":process.env.FLY_REGION}:process.env.DYNO?{"cloud.provider":"heroku"}:void 0),e}());const s=(o=await t,(0,Te.x)([o,"optionalAccess",e=>e.app,"optionalAccess",e=>e.app_memory])&&(o.app.app_memory=process.memoryUsage().rss),(0,Te.x)([o,"optionalAccess",e=>e.device,"optionalAccess",e=>e.free_memory])&&(o.device.free_memory=ve.freemem()),o);var o;return e.contexts={...e.contexts,app:{...s.app,...(0,Te.x)([e,"access",e=>e.contexts,"optionalAccess",e=>e.app])},os:{...s.os,...(0,Te.x)([e,"access",e=>e.contexts,"optionalAccess",e=>e.os])},device:{...s.device,...(0,Te.x)([e,"access",e=>e.contexts,"optionalAccess",e=>e.device])},culture:{...s.culture,...(0,Te.x)([e,"access",e=>e.contexts,"optionalAccess",e=>e.culture])},cloud_resource:{...s.cloud_resource,...(0,Te.x)([e,"access",e=>e.contexts,"optionalAccess",e=>e.cloud_resource])}},e}(e)}})),Tt={aix:"IBM AIX",freebsd:"FreeBSD",openbsd:"OpenBSD",sunos:"SunOS",win32:"Windows"},Et=[{name:"fedora-release",distros:["Fedora"]},{name:"redhat-release",distros:["Red Hat Linux","Centos"]},{name:"redhat_version",distros:["Red Hat Linux"]},{name:"SuSE-release",distros:["SUSE Linux"]},{name:"lsb-release",distros:["Ubuntu Linux","Arch Linux"]},{name:"debian_version",distros:["Debian"]},{name:"debian_release",distros:["Debian"]},{name:"arch-release",distros:["Arch Linux"]},{name:"gentoo-release",distros:["Gentoo Linux"]},{name:"novell-release",distros:["SUSE Linux"]},{name:"alpine-release",distros:["Alpine Linux"]}],Ut={alpine:e=>e,arch:e=>Qt(/distrib_release=(.*)/,e),centos:e=>Qt(/release ([^ ]+)/,e),debian:e=>e,fedora:e=>Qt(/release (..)/,e),mint:e=>Qt(/distrib_release=(.*)/,e),red:e=>Qt(/release ([^ ]+)/,e),suse:e=>Qt(/VERSION = (.*)\n/,e),ubuntu:e=>Qt(/distrib_release=(.*)/,e)};function Qt(e,t){const n=e.exec(t);return n?n[1]:void 0}function Lt(e){return e.split(" ")[0].toLowerCase()}var Ot=n(8536),jt=n(750);function Mt(e){let t=[],n=!1;function s(s){t=[],n||(n=!0,e(s))}return t.push(s),{add:function(e){t.push(e)},next:function(e){const n=t.pop()||s;try{n(e)}catch(t){s(e)}}}}class Pt{constructor(){const{Session:e}=n(1405);this._session=new e}configureAndConnect(e,t){this._session.connect(),this._session.on("Debugger.paused",(t=>{e(t,(()=>{this._session.post("Debugger.resume")}))})),this._session.post("Debugger.enable"),this._session.post("Debugger.setPauseOnExceptions",{state:t?"all":"uncaught"})}setPauseOnExceptions(e){this._session.post("Debugger.setPauseOnExceptions",{state:e?"all":"uncaught"})}getLocalVariables(e,t){this._getProperties(e,(e=>{const{add:n,next:s}=Mt(t);for(const t of e)if((0,Te.x)([t,"optionalAccess",e=>e.value,"optionalAccess",e=>e.objectId])&&"Array"===(0,Te.x)([t,"optionalAccess",e=>e.value,"access",e=>e.className])){const e=t.value.objectId;n((n=>this._unrollArray(e,t.name,n,s)))}else if((0,Te.x)([t,"optionalAccess",e=>e.value,"optionalAccess",e=>e.objectId])&&"Object"===(0,Te.x)([t,"optionalAccess",e=>e.value,"optionalAccess",e=>e.className])){const e=t.value.objectId;n((n=>this._unrollObject(e,t.name,n,s)))}else((0,Te.x)([t,"optionalAccess",e=>e.value,"optionalAccess",e=>e.value])||(0,Te.x)([t,"optionalAccess",e=>e.value,"optionalAccess",e=>e.description]))&&n((e=>this._unrollOther(t,e,s)));s({})}))}_getProperties(e,t){this._session.post("Runtime.getProperties",{objectId:e,ownProperties:!0},((e,n)=>{t(e?[]:n.result)}))}_unrollArray(e,t,n,s){this._getProperties(e,(e=>{n[t]=e.filter((e=>"length"!==e.name&&!isNaN(parseInt(e.name,10)))).sort(((e,t)=>parseInt(e.name,10)-parseInt(t.name,10))).map((e=>(0,Te.x)([e,"optionalAccess",e=>e.value,"optionalAccess",e=>e.value]))),s(n)}))}_unrollObject(e,t,n,s){this._getProperties(e,(e=>{n[t]=e.map((e=>[e.name,(0,Te.x)([e,"optionalAccess",e=>e.value,"optionalAccess",e=>e.value])])).reduce(((e,[t,n])=>(e[t]=n,e)),{}),s(n)}))}_unrollOther(e,t,n){(0,Te.x)([e,"optionalAccess",e=>e.value,"optionalAccess",e=>e.value])?t[e.name]=e.value.value:(0,Te.x)([e,"optionalAccess",e=>e.value,"optionalAccess",e=>e.description])&&"function"!==(0,Te.x)([e,"optionalAccess",e=>e.value,"optionalAccess",e=>e.type])&&(t[e.name]=`<${e.value.description}>`),n(t)}}const Dt="LocalVariablesSync",qt=(e={},t=function(){try{return new Pt}catch(e){return}}())=>{const n=new dt.f(20);let s,o=!1;function i(e){const t=(0,jt.Q4)((0,Te.x)([e,"optionalAccess",e=>e.stacktrace,"optionalAccess",e=>e.frames]));if(void 0===t)return;const s=n.remove(t);if(void 0===s)return;const o=(0,Te.x)([e,"access",e=>e.stacktrace,"optionalAccess",e=>e.frames,"optionalAccess",e=>e.length])||0;for(let t=0;te.stacktrace,"optionalAccess",e=>e.frames,"optionalAccess",e=>e[n]])||!s[t])break;void 0!==s[t].vars&&!1!==e.stacktrace.frames[n].in_app&&(0,jt.MS)(e.stacktrace.frames[n].function,s[t].function)&&(e.stacktrace.frames[n].vars=s[t].vars)}}return{name:Dt,setup(i){const r=i.getOptions();if(t&&r.includeLocalVariables){if(Pe.V.major<18)return void u.kg.log("The `LocalVariables` integration is only supported on Node >= v18.");const i=!1!==e.captureAllExceptions;if(t.configureAndConnect(((e,o)=>function(e,{params:{reason:o,data:i,callFrames:r}},a){if("exception"!==o&&"promiseRejection"!==o)return void a();(0,Te.x)([s,"optionalCall",e=>e()]);const c=(0,jt.QY)(e,(0,Te.x)([i,"optionalAccess",e=>e.description]));if(null==c)return void a();const{add:l,next:g}=Mt((e=>{n.set(c,e),a()}));for(let e=0;e"local"===e.type)),a="global"!==o.className&&o.className?`${o.className}.${s}`:s;if(void 0===(0,Te.x)([i,"optionalAccess",e=>e.object,"access",e=>e.objectId]))l((t=>{t[e]={function:a},g(t)}));else{const n=i.object.objectId;l((s=>(0,Te.x)([t,"optionalAccess",e=>e.getLocalVariables,"call",t=>t(n,(t=>{s[e]={function:a,vars:t},g(s)}))])))}}g([])}(r.stackParser,e,o)),i),i){const n=e.maxExceptionsPerSecond||50;s=(0,jt.H2)(n,(()=>{u.kg.log("Local variables rate-limit lifted."),(0,Te.x)([t,"optionalAccess",e=>e.setPauseOnExceptions,"call",e=>e(!0)])}),(e=>{u.kg.log(`Local variables rate-limit exceeded. Disabling capturing of caught exceptions for ${e} seconds.`),(0,Te.x)([t,"optionalAccess",e=>e.setPauseOnExceptions,"call",e=>e(!1)])}))}o=!0}},processEvent:e=>o?function(e){for(const t of(0,Te.x)([e,"optionalAccess",e=>e.exception,"optionalAccess",e=>e.values])||[])i(t);return e}(e):e,_getCachedFramesCount:()=>n.size,_getFirstCachedFrame:()=>n.values()[0]}};(0,c.RN)(Dt,qt);const $t=(0,c.RN)("LocalVariables",((e={})=>Pe.V.major<19?qt(e):(0,Ot.f)(e)));var en=n(1249);const tn="Spotlight",nn=(0,c.RN)(tn,((e={})=>{const t={sidecarUrl:e.sidecarUrl||"http://localhost:8969/stream"};return{name:tn,setup(e){"object"==typeof process&&process.env&&u.kg.warn("[Spotlight] It seems you're not in dev mode. Do you really want to have Spotlight enabled?"),function(e,t){const n=function(e){try{return new _e.URL(`${e}`)}catch(t){return void u.kg.warn(`[Spotlight] Invalid sidecar URL: ${e}`)}}(t.sidecarUrl);if(!n)return;let s=0;"function"==typeof e.on?e.on("beforeEnvelope",(e=>{if(s>3)return void u.kg.warn("[Spotlight] Disabled Sentry -> Spotlight integration due to too many failed requests");const t=x(e),o=Ye.request({method:"POST",path:n.pathname,hostname:n.hostname,port:n.port,headers:{"Content-Type":"application/x-sentry-envelope"}},(e=>{e.on("data",(()=>{})),e.on("end",(()=>{})),e.setEncoding("utf8")}));o.on("error",(()=>{s++,u.kg.warn("[Spotlight] Failed to send envelope to Spotlight Sidecar")})),o.write(t),o.end()})):u.kg.warn("[Spotlight] Cannot connect to spotlight due to missing method on SDK client (`client.on`)")}(e,t)}}})),sn=/^(\S+:\\|\/?)([\s\S]*?)((?:\.{1,2}|[^/\\]+?|)(\.[^./\\]*|))(?:[/\\]*)$/;function on(e){return e.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}let rn;function an(){if(!rn){const e=n.c[n.s]&&n.c[n.s].filename?function(e){const t=function(e){const t=e.length>1024?`${e.slice(-1024)}`:e,n=sn.exec(t);return n?n.slice(1):[]}(e),n=t[0];let s=t[1];return n||s?(s&&(s=s.slice(0,s.length-1)),n+s):"."}(n.c[n.s].filename):global.process.cwd();rn=`${e}/`}return rn}function cn(e,t=an(),n="\\"===Vt.sep){if(!e)return;const s=n?on(t):t,o=n?on(e):e;let{dir:i,base:r,ext:a}=Vt.posix.parse(o);".js"!==a&&".mjs"!==a&&".cjs"!==a||(r=r.slice(0,-1*a.length)),i||(i=".");let c=i.lastIndexOf("/node_modules");if(c>-1)return`${i.slice(c+14).replace(/\//g,".")}:${r}`;if(c=`${i}/`.lastIndexOf(s,0),0===c){let e=i.slice(s.length).replace(/\//g,".");return e&&(e+=":"),e+=r,e}return r}const ln=[new y,new d,new R,new lt,new bt,new en.Y,new Gt,new vt,new Yt,new $t,new zt,new Ht,new Le];function gn(e={}){const t=(0,O.cu)();st();const n=(0,Te.x)([t,"access",e=>e.__SENTRY__,"optionalAccess",e=>e.integrations])||[];e.defaultIntegrations=!1===e.defaultIntegrations?[]:[...Array.isArray(e.defaultIntegrations)?e.defaultIntegrations:ln,...n],void 0===e.dsn&&process.env.SENTRY_DSN&&(e.dsn=process.env.SENTRY_DSN);const s=process.env.SENTRY_TRACES_SAMPLE_RATE;if(void 0===e.tracesSampleRate&&s){const t=parseFloat(s);isFinite(t)&&(e.tracesSampleRate=t)}if(void 0===e.release){const t=un();void 0!==t?e.release=t:e.autoSessionTracking=!1}void 0===e.environment&&process.env.SENTRY_ENVIRONMENT&&(e.environment=process.env.SENTRY_ENVIRONMENT),void 0===e.autoSessionTracking&&void 0!==e.dsn&&(e.autoSessionTracking=!0),void 0===e.instrumenter&&(e.instrumenter="sentry");const o={...e,stackParser:(0,Oe.Sq)(e.stackParser||hn),integrations:(0,c.m8)(e),transport:e.transport||ze};if(function(e,t){!0===t.debug&&(p.X?u.kg.enable():(0,u.Cf)((()=>{console.warn("[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.")})));const n=(0,O.Gd)();n.getScope().update(t.initialScope);const s=new e(t);n.bindClient(s)}(e.clientClass||Xe,o),e.autoSessionTracking&&function(){const e=(0,O.Gd)();e.startSession(),process.on("beforeExit",(()=>{const t=e.getScope().getSession();t&&!["exited","crashed"].includes(t.status)&&e.endSession()}))}(),function(){const e=(process.env.SENTRY_USE_ENVIRONMENT||"").toLowerCase();if(!["false","n","no","off","0"].includes(e)){const e=process.env.SENTRY_TRACE,t=process.env.SENTRY_BAGGAGE,{propagationContext:n}=(0,Me.KA)(e,t);(0,L.nZ)().setPropagationContext(n)}}(),e.spotlight){const t=(0,L.s3)();t&&t.addIntegration&&(t.setupIntegrations(!0),t.addIntegration(new nn({sidecarUrl:"string"==typeof e.spotlight?e.spotlight:void 0})))}}function dn(e){if(void 0===e)return!1;const t=e&&e.getOptions();return!(!t||void 0===t.autoSessionTracking)&&t.autoSessionTracking}function un(e){return process.env.SENTRY_RELEASE?process.env.SENTRY_RELEASE:je.n2.SENTRY_RELEASE&&je.n2.SENTRY_RELEASE.id?je.n2.SENTRY_RELEASE.id:process.env.GITHUB_SHA||process.env.COMMIT_REF||process.env.VERCEL_GIT_COMMIT_SHA||process.env.VERCEL_GITHUB_COMMIT_SHA||process.env.VERCEL_GITLAB_COMMIT_SHA||process.env.VERCEL_BITBUCKET_COMMIT_SHA||process.env.ZEIT_GITHUB_COMMIT_SHA||process.env.ZEIT_GITLAB_COMMIT_SHA||process.env.ZEIT_BITBUCKET_COMMIT_SHA||process.env.CF_PAGES_COMMIT_SHA||e}const hn=(0,Oe.pE)((0,Oe.Ep)(cn));function In(e){const t=Vt.resolve(e);if(!Wt.existsSync(t))throw new Error(`Cannot read contents of ${t}. Directory does not exist.`);if(!Wt.statSync(t).isDirectory())throw new Error(`Cannot read contents of ${t}, because it is not a directory.`);const n=e=>Wt.readdirSync(e).reduce(((t,s)=>{const o=Vt.join(e,s);return Wt.statSync(o).isDirectory()?t.concat(n(o)):(t.push(o),t)}),[]);return n(t).map((e=>Vt.relative(t,e)))}var pn=n(6751);function Cn(e){const t=(0,L.s3)();return new pn.q(e).setup(t),Promise.resolve()}var mn=n(7522);function bn(e,t){return(0,Ee.XQ)(e,{include:t})}function yn(e,t,n={}){return(0,Ee.S6)(e,t,{include:n})}function fn(){return function(e,t,n){const s=(0,Te.x)([L.s3,"call",e=>e(),"optionalAccess",e=>e.getOptions,"call",e=>e()]);if(!s||"sentry"!==s.instrumenter||"OPTIONS"===(0,Te.x)([e,"access",e=>e.method,"optionalAccess",e=>e.toUpperCase,"call",e=>e()])||"HEAD"===(0,Te.x)([e,"access",e=>e.method,"optionalAccess",e=>e.toUpperCase,"call",e=>e()]))return n();const o=e.headers&&(0,Z.HD)(e.headers["sentry-trace"])?e.headers["sentry-trace"]:void 0,i=(0,Te.x)([e,"access",e=>e.headers,"optionalAccess",e=>e.baggage]);if(!(0,mn.z)(s))return n();const[r,a]=(0,Ee.oA)(e,{path:!0,method:!0}),c=(0,Ze.yn)({sentryTrace:o,baggage:i},(t=>(0,L.Yr)({name:r,op:"http.server",origin:"auto.http.node.tracingHandler",...t,metadata:{...t.metadata,request:e,source:a}},{request:(0,Ee.XQ)(e)})));(0,L.nZ)().setSpan(c),t.__sentry_transaction=c,t.once("finish",(()=>{setImmediate((()=>{(0,Ee.dB)(c,e),c.setHttpStatus(t.statusCode),c.end()}))})),n()}}function Zn(e){const t=function(e={}){let t;if("include"in e)t={include:e.include};else{const{ip:n,request:s,transaction:o,user:i}=e;(n||s||o||i)&&(t={include:(0,a.Jr)({ip:n,request:s,transaction:o,user:i})})}return t}(e),n=(0,L.s3)();if(n&&dn(n)){n.initSessionFlusher();const e=(0,L.nZ)();e.getSession()&&e.setSession()}return function(n,s,o){if(e&&e.flushTimeout&&e.flushTimeout>0){const t=s.end;s.end=function(n,s,o){(0,L.yl)(e.flushTimeout).then((()=>{t.call(this,n,s,o)})).then(null,(e=>{ht&&u.kg.error(e),t.call(this,n,s,o)}))}}(0,O.Ok)((()=>{const e=(0,L.nZ)();e.setSDKProcessingMetadata({request:n,requestDataOptionsFromExpressHandler:t}),dn((0,L.s3)())&&e.setRequestSession({status:"ok"}),s.once("finish",(()=>{const e=(0,L.s3)();dn(e)&&setImmediate((()=>{e&&e._captureRequestSession&&e._captureRequestSession()}))})),o()}))}}function An(e){const t=function(e){const t=e.status||e.statusCode||e.status_code||e.output&&e.output.statusCode;return t?parseInt(t,10):500}(e);return t>=500}function Gn(e){return function(t,n,s,o){(e&&e.shouldHandleError||An)(t)?(0,L.$e)((e=>{e.setSDKProcessingMetadata({request:n});const i=s.__sentry_transaction;i&&void 0===e.getSpan()&&e.setSpan(i);const r=(0,L.s3)();if(r&&dn(r)&&void 0!==r._sessionFlusher){const t=e.getRequestSession();t&&void 0!==t.status&&(t.status="crashed")}const a=(0,L.Tb)(t,{mechanism:{type:"middleware",handled:!1}});s.sentry=a,o(t)})):o(t)}}function Bn(e={}){return function({path:t,type:n,next:s,rawInput:o}){const i=(0,Te.x)([L.s3,"call",e=>e(),"optionalAccess",e=>e.getOptions,"call",e=>e()]),r=(0,L.nZ)().getTransaction();if(r){r.updateName(`trpc/${t}`),r.setMetadata({source:"route"}),r.op="rpc.server";const s={procedure_type:n};(void 0!==e.attachRpcInput?e.attachRpcInput:(0,Te.x)([i,"optionalAccess",e=>e.sendDefaultPii]))&&(s.input=(0,W.Fv)(o)),r.setContext("trpc",s)}function a(e){e.ok||(0,L.Tb)(e.error,{mechanism:{handled:!1,data:{function:"trpcMiddleware"}}})}let c;try{c=s()}catch(e){throw(0,L.Tb)(e,{mechanism:{handled:!1,data:{function:"trpcMiddleware"}}}),e}return(0,Z.J8)(c)?Promise.resolve(c).then((e=>{a(e)}),(e=>{(0,L.Tb)(e,{mechanism:{handled:!1,data:{function:"trpcMiddleware"}}})})):a(c),c}}function vn(e){return e&&void 0!==e.statusCode}function Wn(e){(0,L.Tb)(e,{mechanism:{type:"hapi",handled:!1,data:{function:"hapiErrorPlugin"}}})}const Vn={name:"SentryHapiErrorPlugin",version:be.J,register:async function(e){e.events.on("request",((e,t)=>{const n=(0,Ce.x1)();var s;e.response&&(s=e.response)&&void 0!==s.isBoom?Wn(e.response):function(e){return e&&void 0!==e.error}(t)&&Wn(t.error),n&&(n.setStatus("internal_error"),n.end())}))}},wn={name:"SentryHapiTracingPlugin",version:be.J,register:async function(e){const t=e;t.ext("onPreHandler",((e,t)=>{const n=(0,Ze.yn)({sentryTrace:e.headers["sentry-trace"]||void 0,baggage:e.headers.baggage||void 0},(t=>(0,L.Yr)({...t,op:"hapi.request",name:e.route.path,description:`${e.route.method} ${e.path}`})));return(0,L.nZ)().setSpan(n),t.continue})),t.ext("onPreResponse",((e,t)=>{const n=(0,Ce.x1)();if(e.response&&vn(e.response)&&n){const t=e.response;t.header("sentry-trace",(0,Re.H)(n));const s=(0,ut.IQ)(n.getDynamicSamplingContext());s&&t.header("baggage",s)}return t.continue})),t.ext("onPostHandler",((e,t)=>{const n=(0,Ce.x1)();return e.response&&vn(e.response)&&n&&n.setHttpStatus(e.response.statusCode),n&&n.end(),t.continue}))}},Sn="Hapi",Rn=(0,c.RN)(Sn,((e={})=>{const t=e.server;return{name:Sn,setupOnce(){t&&(0,a.hl)(t,"start",(e=>async function(){return await this.register(wn),await this.register(Vn),e.apply(this)}))}}}));var Hn=n(2716),Xn=n(8737),kn=n(1791),Yn=n(6169),Nn=n(24),Jn=n(1370),_n=n(9889);const Kn=[["january","1"],["february","2"],["march","3"],["april","4"],["may","5"],["june","6"],["july","7"],["august","8"],["september","9"],["october","10"],["november","11"],["december","12"],["jan","1"],["feb","2"],["mar","3"],["apr","4"],["may","5"],["jun","6"],["jul","7"],["aug","8"],["sep","9"],["oct","10"],["nov","11"],["dec","12"],["sunday","0"],["monday","1"],["tuesday","2"],["wednesday","3"],["thursday","4"],["friday","5"],["saturday","6"],["sun","0"],["mon","1"],["tue","2"],["wed","3"],["thu","4"],["fri","5"],["sat","6"]];function Fn(e){return Kn.reduce(((e,[t,n])=>e.replace(new RegExp(t,"gi"),n)),e)}const xn="Automatic instrumentation of CronJob only supports crontab string",zn={...s,...i,...r},Tn={instrumentCron:function(e,t){return new Proxy(e,{construct(e,n){const[s,o,i,r,a,...c]=n;if("string"!=typeof s)throw new Error(xn);const l=Fn(s);return new e(s,(function(e,n){return(0,L.sV)(t,(()=>o(e,n)),{schedule:{type:"crontab",value:l},...a?{timeZone:a}:{}})}),i,r,a,...c)},get:(e,n)=>"from"===n?n=>{const{cronTime:s,onTick:o,timeZone:i}=n;if("string"!=typeof s)throw new Error(xn);const r=Fn(s);return n.onTick=(e,n)=>(0,L.sV)(t,(()=>o(e,n)),{schedule:{type:"crontab",value:r},...i?{timeZone:i}:{}}),e.from(n)}:e[n]})},instrumentNodeCron:function(e){return new Proxy(e,{get:(e,t)=>"schedule"===t&&e.schedule?new Proxy(e.schedule,{apply(e,t,n){const[s,,o]=n;if(!(0,Te.x)([o,"optionalAccess",e=>e.name]))throw new Error('Missing "name" for scheduled job. A name is required for Sentry check-in monitoring.');return(0,L.sV)(o.name,(()=>e.apply(t,n)),{schedule:{type:"crontab",value:Fn(s)},timezone:(0,Te.x)([o,"optionalAccess",e=>e.timezone])})}}):e[t]})}}},6751:(e,t,n)=>{"use strict";n.d(t,{q:()=>u});var s=n(4307);function o(e){const t=(0,s.x)(e);return null==t||t}var i=n(7310),r=n(2967),a=n(4487),c=n(2343),l=n(2176),g=n(9656);function d(e,...t){c.kg.log(`[ANR] ${e}`,...t)}e=n.hmd(e);const u=(0,r.RN)("Anr",((t={})=>({name:"Anr",setup(r){if(g.V.major<16)throw new Error("ANR detection requires Node 16 or later");setImmediate((()=>async function(t,r){const g=await async function(e){let t={message:"ANR"};const n={};for(const s of e.getEventProcessors()){if(null===t)break;t=await s(t,n)}return(0,s.x)([t,"optionalAccess",e=>e.contexts])||{}}(t),u=t.getDsn();if(!u)return;o([g,"access",e=>e.app,"optionalAccess",e=>delete e.app_memory]),o([g,"access",e=>e.device,"optionalAccess",e=>delete e.free_memory]);const h=t.getOptions(),I=t.getSdkMetadata()||{};I.sdk&&(I.sdk.integrations=h.integrations.map((e=>e.name)));const p={debug:c.kg.isEnabled(),dsn:u,environment:h.environment||"production",release:h.release,dist:h.dist,sdkMetadata:I,appRootPath:r.appRootPath,pollInterval:r.pollInterval||50,anrThreshold:r.anrThreshold||5e3,captureStackTrace:!!r.captureStackTrace,staticTags:r.staticTags||{},contexts:g};if(p.captureStackTrace){const e=n(1405);e.url()||e.open(0)}const{Worker:C}=(0,l.l$)(e,"worker_threads"),m=new C(new i.URL("data:application/javascript;base64,aW1wb3J0IHsgU2Vzc2lvbiB9IGZyb20gJ2luc3BlY3Rvcic7CmltcG9ydCB7IHdvcmtlckRhdGEsIHBhcmVudFBvcnQgfSBmcm9tICd3b3JrZXJfdGhyZWFkcyc7CmltcG9ydCAqIGFzIGh0dHAgZnJvbSAnaHR0cCc7CmltcG9ydCAqIGFzIGh0dHBzIGZyb20gJ2h0dHBzJzsKaW1wb3J0IHsgUmVhZGFibGUgfSBmcm9tICdzdHJlYW0nOwppbXBvcnQgcmVxdWlyZSQkMiwgeyBVUkwgfSBmcm9tICd1cmwnOwppbXBvcnQgeyBjcmVhdGVHemlwIH0gZnJvbSAnemx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ewogICAgICAgIHJldHVybiB0cnVlOwogICAgICB9CiAgICAgIGlubmVyLmFkZChvYmopOwogICAgICByZXR1cm4gZmFsc2U7CiAgICB9CiAgICAvLyBlc2xpbnQtZGlzYWJsZS1uZXh0LWxpbmUgQHR5cGVzY3JpcHQtZXNsaW50L3ByZWZlci1mb3Itb2YKICAgIGZvciAobGV0IGkgPSAwOyBpIDwgaW5uZXIubGVuZ3RoOyBpKyspIHsKICAgICAgY29uc3QgdmFsdWUgPSBpbm5lcltpXTsKICAgICAgaWYgKHZhbHVlID09PSBvYmopIHsKICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgfQogICAgfQogICAgaW5uZXIucHVzaChvYmopOwogICAgcmV0dXJuIGZhbHNlOwogIH0KCiAgZnVuY3Rpb24gdW5tZW1vaXplKG9iaikgewogICAgaWYgKGhhc1dlYWtTZXQpIHsKICAgICAgaW5uZXIuZGVsZXRlKG9iaik7CiAgICB9IGVsc2UgewogICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGlubmVyLmxlbmd0aDsgaSsrKSB7CiAgICAgICAgaWYgKGlubmVyW2ldID09PSBvYmopIHsKICAgICAgICAgIGlubmVyLnNwbGljZShpLCAxKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgfQogICAgfQogIH0KICByZXR1cm4gW21lbW9pemUsIHVubWVtb2l6ZV07Cn0KCi8qKgogKiBSZWN1cnNpdmVseSBub3JtYWxpemVzIHRoZSBnaXZlbiBvYmplY3QuCiAqCiAqIC0gQ3JlYXRlcyBhIGNvcHkgdG8gcHJldmVudCBvcmlnaW5hbCBpbnB1dCBtdXRhdGlvbgogKiAtIFNraXBzIG5vbi1lbnVtZXJhYmxlIHByb3BlcnRpZXMKICogLSBXaGVuIHN0cmluZ2lmeWluZywgY2FsbHMgYHRvSlNPTmAgaWYgaW1wbGVtZW50ZWQKICogLSBSZW1vdmVzIGNpcmN1bGFyIHJlZmVyZW5jZXMKICogLSBUcmFuc2xhdGVzIG5v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XNvbHZlLCB0aGlzLl9yZWplY3QpOwogICAgfSBjYXRjaCAoZSkgewogICAgICB0aGlzLl9yZWplY3QoZSk7CiAgICB9CiAgfQoKICAvKiogSlNEb2MgKi8KICAgdGhlbigKICAgIG9uZnVsZmlsbGVkLAogICAgb25yZWplY3RlZCwKICApIHsKICAgIHJldHVybiBuZXcgU3luY1Byb21pc2UoKHJlc29sdmUsIHJlamVjdCkgPT4gewogICAgICB0aGlzLl9oYW5kbGVycy5wdXNoKFsKICAgICAgICBmYWxzZSwKICAgICAgICByZXN1bHQgPT4gewogICAgICAgICAgaWYgKCFvbmZ1bGZpbGxlZCkgewogICAgICAgICAgICAvLyBUT0RPOiDCr1xfKOODhClfL8KvCiAgICAgICAgICAgIC8vIFRPRE86IEZJWE1FCiAgICAgICAgICAgIHJlc29sdmUocmVzdWx0ICk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgIHJlc29sdmUob25mdWxmaWxsZWQocmVzdWx0KSk7CiAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHsKICAgICAgICAgICAgICByZWplY3QoZSk7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9LAogICAgICAgIHJlYXNvbiA9PiB7CiAgICAgICAgICBpZiAoIW9ucmVqZWN0ZWQpIHsKICAgICAgICAgICAgcmVqZWN0KHJlYXNvbik7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgIHJlc29sdmUob25yZWplY3RlZChyZWFzb24pKTsKICAgICAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgICAgIHJlamVjdChlKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0sCiAgICAgIF0pOwogICAgICB0aGlzLl9leGVjdXRlSGFuZGxlcnMoKTsKICAgIH0pOwogIH0KCiAgLyoqIEpTRG9jICovCiAgIGNhdGNoKAogICAgb25yZWplY3RlZCwKICApIHsKICAgIHJldHVybiB0aGlzLnRoZW4odmFsID0+IHZhbCwgb25yZWplY3RlZCk7CiAgfQoKICAvKiogSlNEb2MgKi8KICAgZmluYWxseShvbmZpbmFsbHkpIHsKICAgIHJldHVybiBuZXcgU3luY1Byb21pc2UoKHJlc29sdmUsIHJlamVjdCkgPT4gewogICAgICBsZXQgdmFsOwogICAgICBsZXQgaXNSZWplY3RlZDsKCiAgICAgIHJldHVybiB0aGlzLnRoZW4oCiAgICAgICAgdmFsdWUgPT4gewogICAgICAgICAgaXNSZWplY3RlZCA9IGZhbHNlOwogICAgICAgICAgdmFsID0gdmFsdWU7CiAgICAgICAgICBpZiAob25maW5hbGx5KSB7CiAgICAgICAgICAgIG9uZmluYWxseSgpOwogICAgICAgICAgfQogICAgICAgIH0sCiAgICAgICAgcmVhc29uID0+IHsKICAgICAgICAgIGlzUmVqZWN0ZWQgPSB0cnVlOwogICAgICAgICAgdmFsID0gcmVhc29uOwogICAgICAgICAgaWYgKG9uZmluYWxseSkgewogICAgICAgICAgICBvbmZpbmFsbHkoKTsKICAgICAgICAgIH0KICAgICAgICB9LAogICAgICApLnRoZW4oKCkgPT4gewogICAgICAgIGlmIChpc1JlamVjdGVkKSB7CiAgICAgICAgICByZWplY3QodmFsKTsKICAgICAgICAgIHJldHVybjsKICAgICAgICB9CgogICAgICAgIHJlc29sdmUodmFsICk7CiAgICAgIH0pOwogICAgfSk7CiAgfQoKICAvKiogSlNEb2MgKi8KICAgIF9faW5pdCgpIHt0aGlzLl9yZXNvbHZlID0gKHZhbHVlKSA9PiB7CiAgICB0aGlzLl9zZXRSZXN1bHQoU3RhdGVzLlJFU09MVkVELCB2YWx1ZSk7CiAgfTt9CgogIC8qKiBKU0RvYyAqLwogICAgX19pbml0MigpIHt0aGlzLl9yZWplY3QgPSAocmVhc29uKSA9PiB7CiAgICB0aGlzLl9zZXRSZXN1bHQoU3RhdGVzLlJFSkVDVEVELCByZWFzb24pOwogIH07fQoKICAvKiogSlNEb2MgKi8KICAgIF9faW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MgPSBfb3B0czsKICAgICAgICAgICAgaWYgKHR5cGVvZiBjYWxsYmFjayA9PT0gJ2Z1bmN0aW9uJykgewogICAgICAgICAgICAgICAgdGhpcy5jYWxsYmFjayA9IGNhbGxiYWNrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVsc2UgaWYgKGNhbGxiYWNrKSB7CiAgICAgICAgICAgICAgICBvcHRzID0gY2FsbGJhY2s7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgLy8gdGltZW91dCBmb3IgdGhlIHNvY2tldCB0byBiZSByZXR1cm5lZCBmcm9tIHRoZSBjYWxsYmFjawogICAgICAgICAgICB0aGlzLnRpbWVvdXQgPSBudWxsOwogICAgICAgICAgICBpZiAob3B0cyAmJiB0eXBlb2Ygb3B0cy50aW1lb3V0ID09PSAnbnVtYmVyJykgewogICAgICAgICAgICAgICAgdGhpcy50aW1lb3V0ID0gb3B0cy50aW1lb3V0OwogICAgICAgICAgICB9CiAgICAgICAgICAgIHRoaXMub3B0aW9ucyA9IG9wdHMgfHwge307CiAgICAgICAgICAgIHRoaXMubWF4RnJlZVNvY2tldHMgPSAxOwogICAgICAgICAgICB0aGlzLm1heFNvY2tldHMgPSAxOwogICAgICAgICAgICB0aGlzLnNvY2tldHMgPSBbXTsKICAgICAgICAgICAgdGhpcy5yZXF1ZXN0cyA9IFtdOwogICAgICAgIH0KICAgICAgICBnZXQgZGVmYXVsdFBvcnQoKSB7CiAgICAgICAgICAgIGlmICh0eXBlb2YgdGhpcy5leHBsaWNpdERlZmF1bHRQb3J0ID09PSAnbnVtYmVyJykgewogICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuZXhwbGljaXREZWZhdWx0UG9ydDsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlIHsKICAgICAgICAgICAgICAgIHJldHVybiBpc1NlY3VyZUVuZHBvaW50KCkgPyA0NDMgOiA4MDsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBzZXQgZGVmYXVsdFBvcnQodikgewogICAgICAgICAgICB0aGlzLmV4cGxpY2l0RGVmYXVsdFBvcnQgPSB2OwogICAgICAgIH0KICAgICAgICBnZXQgcHJvdG9jb2woKSB7CiAgICAgICAgICAgIGlmICh0eXBlb2YgdGhpcy5leHBsaWNpdFByb3RvY29sID09PSAnc3RyaW5nJykgewogICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuZXhwbGljaXRQcm90b2NvbDsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlIHsKICAgICAgICAgICAgICAgIHJldHVybiBpc1NlY3VyZUVuZHBvaW50KCkgPyAnaHR0cHM6JyA6ICdodHRwOic7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgc2V0IHByb3RvY29sKHYpIHsKICAgICAgICAgICAgdGhpcy5leHBsaWNpdFByb3RvY29sID0gdjsKICAgICAgICB9CiAgICAgICAgY2FsbGJhY2socmVxLCBvcHRzLCBmbikgewogICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoJyJhZ2VudC1iYXNlIiBoYXMgbm8gZGVmYXVsdCBpbXBsZW1lbnRhdGlvbiwgeW91IG11c3Qgc3ViY2xhc3MgYW5kIG92ZXJyaWRlIGBjYWxsYmFjaygpYCcpOwogICAgICAgIH0KICAgICAgICAvKioKICAgICAgICAgKiBDYWxsZWQgYnkgbm9kZS1jb3JlJ3MgIl9odHRwX2NsaWVudC5qcyIgbW9kdWxlIHdoZW4gY3JlYXRpbmcKICAgICAgICAgKiBhIG5ldyBIVFRQIHJlcXVlc3Qgd2l0aCB0aGlzIEFnZW50IGluc3RhbmNlLgogICAgICAgICAqCiAgICAgICAgICogQGFwaSBwdWJsaWMKICAgICAgICAgKi8KICAgICAgICBhZGRSZXF1ZXN0KHJlcSwgX29wdHMpIHsKICAgICAgICAgICAgY29uc3Qgb3duT3B0cyA9IE9iamVjdC5hc3NpZ24oe30sIF9vcHRzKTsKICAgICAgICAgICAgaWYgKHR5cGVvZiBvd25PcHRzLnNlY3VyZUVuZHBvaW50ICE9PSAnYm9vbGVhbicpIHsKICAgICAgICAgICAgICAgIG93bk9wdHMuc2VjdXJlRW5kcG9pbnQgPSBpc1NlY3VyZUVuZHBvaW50KCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgLy8gU2V0IGRlZmF1bHQgYGhvc3RgIGZvciBIVFRQIHRvIGxvY2FsaG9zdAogICAgICAgICAgICBpZiAob3duT3B0cy5ob3N0ID09IG51bGwpIHsKICAgICAgICAgICAgICAgIG93bk9wdHMuaG9zdCA9ICdsb2NhbGhvc3QnOwogICAgICAgICAgICB9CiAgICAgICAgICAgIC8vIFNldCBkZWZhdWx0IGBwb3J0YCBmb3IgSFRUUCBpZiBub25lIHdhcyBleHBsaWNpdGx5IHNwZWNpZmllZAogICAgICAgICAgICBpZiAob3duT3B0cy5wb3J0ID09IG51bGwpIHsKICAgICAgICAgICAgICAgIG93bk9wdHMucG9ydCA9IG93bk9wdHMuc2VjdXJlRW5kcG9pbnQgPyA0NDMgOiA4MDsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb25zdCBvcHRzID0gT2JqZWN0LmFzc2lnbihPYmplY3QuYXNzaWduKHt9LCB0aGlzLm9wdGlvbnMpLCBvd25PcHRzKTsKICAgICAgICAgICAgaWYgKG9wdHMuaG9zdCAmJiBvcHRzLnBhdGgpIHsKICAgICAgICAgICAgICAgIC8vIElmIGJvdGggYSBgaG9zdGAgYW5kIGBwYXRoYCBhcmUgc3BlY2lmaWVkIHRoZW4gaXQncyBtb3N0IGxpa2VseSB0aGUKICAgICAgICAgICAgICAgIC8vIHJlc3VsdCBvZiBhIGB1cmwucGFyc2UoKWAgY2FsbC4uLiB3ZSBuZWVkIHRvIHJlbW92ZSB0aGUgYHBhdGhgIHBvcnRpb24gc28KICAgICAgICAgICAgICAgIC8vIHRoYXQgYG5ldC5jb25uZWN0KClgIGRvZXNuJ3QgYXR0ZW1wdCB0byBvcGVuIHRoYXQgYXMgYSB1bml4IHNvY2tldCBmaWxlLgogICAgICAgICAgICAgICAgZGVsZXRlIG9wdHMucGF0aDsKICAgICAgICAgICAgfQogICAgICAgICAgICBkZWxldGUgb3B0cy5hZ2VudDsKICAgICAgICAgICAgZGVsZXRlIG9wdHMuaG9zdG5hbWU7CiAgICAgICAgICAgIGRlbGV0ZSBvcHRzLl9kZWZhdWx0QWdlbnQ7CiAgICAgICAgICAgIGRlbGV0ZSBvcHRzLmRlZmF1bHRQb3J0OwogICAgICAgICAgICBkZWxldGUgb3B0cy5jcmVhdGVDb25uZWN0aW9uOwogICAgICAgICAgICAvLyBIaW50IHRvIHVzZSAiQ29ubmVjdGlvbjogY2xvc2UiCiAgICAgICAgICAgIC8vIFhYWDogbm9uLWRvY3VtZW50ZWQgYGh0dHBgIG1vZHVsZSBBUEkgOigKICAgICAgICAgICAgcmVxLl9sYXN0ID0gdHJ1ZTsKICAgICAgICAgICAgcmVxLnNob3VsZEtlZXBBbGl2ZSA9IGZhbHNlOwogICAgICAgICAgICAvLyBDcmVhdGUgdGhlIGBzdHJlYW0uRHVwbGV4YCBpbnN0YW5jZQogICAgICAgICAgICBsZXQgdGltZWRPdXQgPSBmYWxzZTsKICAgICAgICAgICAgbGV0IHRpbWVvdXQgPSBudWxsOwogICAgICAgICAgICBjb25zdCB0aW1lb3V0TXMgPSB0aGlzLnRpbWVvdXQ7CiAgICAgICAgICAgIGNvbnN0IGZyZWVTb2NrZXQgPSB0aGlzLmZyZWVTb2NrZXQ7CiAgICAgICAgICAgIGZ1bmN0aW9uIG9uZXJyb3IoZXJyKSB7CiAgICAgICAgICAgICAgICBpZiAocmVxLl9oYWRFcnJvcikKICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICByZXEuZW1pdCgnZXJyb3InLCBlcnIpOwogICAgICAgICAgICAgICAgLy8gRm9yIFNhZmV0eS4gU29tZSBhZGRpdGlvbmFsIGVycm9ycyBtaWdodCBmaXJlIGxhdGVyIG9uCiAgICAgICAgICAgICAgICAvLyBhbmQgd2UgbmVlZCB0byBtYWtlIHN1cmUgd2UgZG9uJ3QgZG91YmxlLWZpcmUgdGhlIGVycm9yIGV2ZW50LgogICAgICAgICAgICAgICAgcmVxLl9oYWRFcnJvciA9IHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZnVuY3Rpb24gb250aW1lb3V0KCkgewogICAgICAgICAgICAgICAgdGltZW91dCA9IG51bGw7CiAgICAgICAgICAgICAgICB0aW1lZE91dCA9IHRydWU7CiAgICAgICAgICAgICAgICBjb25zdCBlcnIgPSBuZXcgRXJyb3IoYEEgInNvY2tldCIgd2FzIG5vdCBjcmVhdGVkIGZvciBIVFRQIHJlcXVlc3QgYmVmb3JlICR7dGltZW91dE1zfW1zYCk7CiAgICAgICAgICAgICAgICBlcnIuY29kZSA9ICdFVElNRU9VVCc7CiAgICAgICAgICAgICAgICBvbmVycm9yKGVycik7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZnVuY3Rpb24gY2FsbGJhY2tFcnJvcihlcnIpIHsKICAgICAgICAgICAgICAgIGlmICh0aW1lZE91dCkKICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICBpZiAodGltZW91dCAhPT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgIGNsZWFyVGltZW91dCh0aW1lb3V0KTsKICAgICAgICAgICAgICAgICAgICB0aW1lb3V0ID0gbnVsbDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIG9uZXJyb3IoZXJyKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBmdW5jdGlvbiBvbnNvY2tldChzb2NrZXQpIHsKICAgICAgICAgICAgICAgIGxldCBzb2NrOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gb25mcmVlKCkgewogICAgICAgICAgICAgICAgICAgIGZyZWVTb2NrZXQoc29jaywgb3B0cyk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAodGltZWRPdXQpCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgaWYgKHRpbWVvdXQgIT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgIGNsZWFyVGltZW91dCh0aW1lb3V0KTsKICAgICAgICAgICAgICAgICAgICB0aW1lb3V0ID0gbnVsbDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmIChpc0FnZW50QmFzZShzb2NrZXQpIHx8IGlzSHR0cEFnZW50KHNvY2tldCkpIHsKICAgICAgICAgICAgICAgICAgICAvLyBgc29ja2V0YCBpcyBhY3R1YWxseSBhbiBgaHR0cC5BZ2VudGAgaW5zdGFuY2UsIHNvCiAgICAgICAgICAgICAgICAgICAgLy8gcmVsaW5xdWlzaCByZXNwb25zaWJpbGl0eSBmb3IgdGhpcyBgcmVxYCB0byB0aGUgQWdlbnQKICAgICAgICAgICAgICAgICAgICAvLyBmcm9tIGhlcmUgb24KICAgICAgICAgICAgICAgICAgICBzb2NrZXQuYWRkUmVxdWVzdChyZXEsIG9wdHMpOwogICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmIChzb2NrZXQpIHsKICAgICAgICAgICAgICAgICAgICBzb2NrID0gc29ja2V0OwogICAgICAgICAgICAgICAgICAgIHNvY2sub24oJ2ZyZWUnLCBvbmZyZWUpOwogICAgICAgICAgICAgICAgICAgIHJlcS5vblNvY2tldChzb2NrKTsKICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjb25zdCBlcnIgPSBuZXcgRXJyb3IoYG5vIER1cGxleCBzdHJlYW0gd2FzIHJldHVybmVkIHRvIGFnZW50LWJhc2UgZm9yIFxgJHtyZXEubWV0aG9kfSAke3JlcS5wYXRofVxgYCk7CiAgICAgICAgICAgICAgICBvbmVycm9yKGVycik7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKHR5cGVvZiB0aGlzLmNhbGxiYWNrICE9PSAnZnVuY3Rpb24nKSB7CiAgICAgICAgICAgICAgICBvbmVycm9yKG5ldyBFcnJvcignYGNhbGxiYWNrYCBpcyBub3QgZGVmaW5lZCcpKTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoIXRoaXMucHJvbWlzaWZpZWRDYWxsYmFjaykgewogICAgICAgICAgICAgICAgaWYgKHRoaXMuY2FsbGJhY2subGVuZ3RoID49IDMpIHsKICAgICAgICAgICAgICAgICAgICAvLyBMZWdhY3kgY2FsbGJhY2sgZnVuY3Rpb24gLSBjb252ZXJ0IHRvIGEgUHJvbWlzZQogICAgICAgICAgICAgICAgICAgIHRoaXMucHJvbWlzaWZpZWRDYWxsYmFjayA9IHByb21pc2lmeV8xLmRlZmF1bHQodGhpcy5jYWxsYmFjayk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBlbHNlIHsKICAgICAgICAgICAgICAgICAgICB0aGlzLnByb21pc2lmaWVkQ2FsbGJhY2sgPSB0aGlzLmNhbGxiYWNrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmICh0eXBlb2YgdGltZW91dE1zID09PSAnbnVtYmVyJyAmJiB0aW1lb3V0TXMgPiAwKSB7CiAgICAgICAgICAgICAgICB0aW1lb3V0ID0gc2V0VGltZW91dChvbnRpbWVvdXQsIHRpbWVvdXRNcyk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKCdwb3J0JyBpbiBvcHRzICYmIHR5cGVvZiBvcHRzLnBvcnQgIT09ICdudW1iZXInKSB7CiAgICAgICAgICAgICAgICBvcHRzLnBvcnQgPSBOdW1iZXIob3B0cy5wb3J0KTsKICAgICAgICAgICAgfQogICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgUHJvbWlzZS5yZXNvbHZlKHRoaXMucHJvbWlzaWZpZWRDYWxsYmFjayhyZXEsIG9wdHMpKS50aGVuKG9uc29ja2V0LCBjYWxsYmF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G9zZSk7CiAgICAgICAgICAgIHNvY2tldC5yZW1vdmVMaXN0ZW5lcigncmVhZGFibGUnLCByZWFkKTsKICAgICAgICB9CiAgICAgICAgZnVuY3Rpb24gb25jbG9zZShlcnIpIHsKICAgICAgICAgICAgZGVidWckMSgnb25jbG9zZSBoYWQgZXJyb3IgJW8nLCBlcnIpOwogICAgICAgIH0KICAgICAgICBmdW5jdGlvbiBvbmVuZCgpIHsKICAgICAgICAgICAgZGVidWckMSgnb25lbmQnKTsKICAgICAgICB9CiAgICAgICAgZnVuY3Rpb24gb25lcnJvcihlcnIpIHsKICAgICAgICAgICAgY2xlYW51cCgpOwogICAgICAgICAgICBkZWJ1ZyQxKCdvbmVycm9yICVvJywgZXJyKTsKICAgICAgICAgICAgcmVqZWN0KGVycik7CiAgICAgICAgfQogICAgICAgIGZ1bmN0aW9uIG9uZGF0YShiKSB7CiAgICAgICAgICAgIGJ1ZmZlcnMucHVzaChiKTsKICAgICAgICAgICAgYnVmZmVyc0xlbmd0aCArPSBiLmxlbmd0aDsKICAgICAgICAgICAgY29uc3QgYnVmZmVyZWQgPSBCdWZmZXIuY29uY2F0KGJ1ZmZlcnMsIGJ1ZmZlcnNMZW5ndGgpOwogICAgICAgICAgICBjb25zdCBlbmRPZkhlYWRlcnMgPSBidWZmZXJlZC5pbmRleE9mKCdcclxuXHJcbicpOwogICAgICAgICAgICBpZiAoZW5kT2ZIZWFkZXJzID09PSAtMSkgewogICAgICAgICAgICAgICAgLy8ga2VlcCBidWZmZXJpbmcKICAgICAgICAgICAgICAgIGRlYnVnJDEoJ2hhdmUgbm90IHJlY2VpdmVkIGVuZCBvZiBIVFRQIGhlYWRlcnMgeWV0Li4uJyk7CiAgICAgICAgICAgICAgICByZWFkKCk7CiAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY29uc3QgZmlyc3RMaW5lID0gYnVmZmVyZWQudG9TdHJpbmcoJ2FzY2lpJywgMCwgYnVmZmVyZW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AodHlwZW9mIF9vcHRzID09PSAnc3RyaW5nJykgewogICAgICAgICAgICBvcHRzID0gdXJsXzEuZGVmYXVsdC5wYXJzZShfb3B0cyk7CiAgICAgICAgfQogICAgICAgIGVsc2UgewogICAgICAgICAgICBvcHRzID0gX29wdHM7CiAgICAgICAgfQogICAgICAgIGlmICghb3B0cykgewogICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoJ2FuIEhUVFAoUykgcHJveHkgc2VydmVyIGBob3N0YCBhbmQgYHBvcnRgIG11c3QgYmUgc3BlY2lmaWVkIScpOwogICAgICAgIH0KICAgICAgICBkZWJ1ZygnY3JlYXRpbmcgbmV3IEh0dHBzUHJveHlBZ2VudCBpbnN0YW5jZTogJW8nLCBvcHRzKTsKICAgICAgICBzdXBlcihvcHRzKTsKICAgICAgICBjb25zdCBwcm94eSA9IE9iamVjdC5hc3NpZ24oe30sIG9wdHMpOwogICAgICAgIC8vIElmIGB0cnVlYCwgdGhlbiBjb25uZWN0IHRvIHRoZSBwcm94eSBzZXJ2ZXIgb3ZlciBUTFMuCiAgICAgICAgLy8gRGVmYXVsdHMgdG8gYGZhbHNlYC4KICAgICAgICB0aGlzLnNlY3VyZVByb3h5ID0gb3B0cy5zZWN1cmVQcm94eSB8fCBpc0hUVFBTKHByb3h5LnByb3RvY29sKTsKICAgICAgICAvLyBQcmVmZXIgYGhvc3RuYW1lYCBvdmVyIGBob3N0YCwgYW5kIHNldCB0aGUgYHBvcnRgIGlmIG5lZWRlZC4KICAgICAgICBwcm94eS5ob3N0ID0gcHJveHkuaG9zdG5hbWUgfHwgcHJveHkuaG9zdDsKICAgICAgICBpZiAodHlwZW9mIHByb3h5LnBvcnQgPT09ICdzdHJpbmcnKSB7CiAgICAgICAgICAgIHByb3h5LnBvcnQgPSBwYXJzZUludChwcm94eS5wb3J0LCAxMCk7CiAgICAgICAgfQogICAgICAgIGlmICghcHJveHkucG9ydCAmJiBwcm94eS5ob3N0KSB7CiAgICAgICAgICAgIHByb3h5L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IHByb3RlY3RlZAogICAgICovCiAgICBjYWxsYmFjayhyZXEsIG9wdHMpIHsKICAgICAgICByZXR1cm4gX19hd2FpdGVyKHRoaXMsIHZvaWQgMCwgdm9pZCAwLCBmdW5jdGlvbiogKCkgewogICAgICAgICAgICBjb25zdCB7IHByb3h5LCBzZWN1cmVQcm94eSB9ID0gdGhpczsKICAgICAgICAgICAgLy8gQ3JlYXRlIGEgc29ja2V0IGNvbm5lY3Rpb24gdG8gdGhlIHByb3h5IHNlcnZlci4KICAgICAgICAgICAgbGV0IHNvY2tldDsKICAgICAgICAgICAgaWYgKHNlY3VyZVByb3h5KSB7CiAgICAgICAgICAgICAgICBkZWJ1ZygnQ3JlYXRpbmcgYHRscy5Tb2NrZXRgOiAlbycsIHByb3h5KTsKICAgICAgICAgICAgICAgIHNvY2tldCA9IHRsc18xLmRlZmF1bHQuY29ubmVjdChwcm94eSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZSB7CiAgICAgICAgICAgICAgICBkZWJ1ZygnQ3JlYXRpbmcgYG5ldC5Tb2NrZXRgOiAlbycsIHByb3h5KTsKICAgICAgICAgICAgICAgIHNvY2tldCA9IG5ldF8xLmRlZmF1bHQuY29ubmVjdChwcm94eSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY29uc3QgaGVhZGVycyA9IE9iamVjdC5hc3NpZ24oe30sIHByb3h5LmhlYWRlcnMpOwogICAgICAgICAgICBjb25zdCBob3N0bmFtZSA9IGAke29wdHMuaG9zdH06JHtvcHRzLnBvcnR9YDsKICAgICAgICAgICAgbGV0IHBheWxvYWQgPSBgQ09OTkVDVCAke2hvc3RuYW1lfSBIVFRQLzEuMVxyXG5gOwogICAgICAgICAgICAvLyBJbmplY3QgdGhlIGBQcm94eS1BdXRob3JpemF0aW9uYCBoZWFkZXIgaWYgbmVjZXNzYXJ5LgogICAgICAgICAgICBpZiAocHJveHkuYXV0aCkgewogICAgICAgICAgICAgICAgaGVhZGVyc1snUHJveHktQXV0aG9yaXphdGlvbiddID0gYEJhc2ljICR7QnVmZmVyLmZyb20ocHJveHkuYXV0aCkudG9TdHJpbmcoJ2Jhc2U2NCcpfWA7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgLy8gVGhlIGBIb3N0YCBoZWFkZXIgc2hvdWxkIG9ubHkgaW5jbHVkZSB0aGUgcG9ydAogICAgICAgICAgICAvLyBudW1iZXIgd2hlbiBpdCBpcyBub3QgdGhlIGRlZmF1bHQgcG9ydC4KICAgICAgICAgICAgbGV0IHsgaG9zdCwgcG9ydCwgc2VjdXJlRW5kcG9pbnQgfSA9IG9wdHM7CiAgICAgICAgICAgIGlmICghaXNEZWZhdWx0UG9ydChwb3J0LCBzZWN1cmVFbmRwb2ludCkpIHsKICAgICAgICAgICAgICAgIGhvc3QgKz0gYDoke3BvcnR9YDsKICAgICAgICAgICAgfQogICAgICAgICAgICBoZWFkZXJzLkhvc3QgPSBob3N0OwogICAgICAgICAgICBoZWFkZXJzLkNvbm5lY3Rpb24gPSAnY2xvc2UnOwogICAgICAgICAgICBmb3IgKGNvbnN0IG5hbWUgb2YgT2JqZWN0LmtleXMoaGVhZGVycykpIHsKICAgICAgICAgICAgICAgIHBheWxvYWQgKz0gYCR7bmFtZX06ICR7aGVhZGVyc1tuYW1lXX1cclxuYDsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb25zdCBwcm94eVJlc3BvbnNlUHJvbWlzZSA9IHBhcnNlX3Byb3h5X3Jlc3BvbnNlXzEuZGVmYXVsdChzb2NrZXQpOwogICAgICAgICAgICBzb2NrZXQud3JpdGUoYCR7cGF5bG9hZH1cclxuYCk7CiAgICAgICAgICAgIGNvbnN0IHsgc3RhdHVzQ29kZSwgYnVmZmVyZWQgfSA9IHlpZWxkIHByb3h5UmVzcG9uc2VQcm9taXNlOwogICAgICAgICAgICBpZiAoc3RhdHVzQ29kZSA9PT0gMjAwKSB7CiAgICAgICAgICAgICAgICByZXEub25jZSgnc29ja2V0JywgcmVzdW1lKTsKICAgICAgICAgICAgICAgIGlmIChvcHRzLnNlY3VyZUVuZHBvaW50KSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2VydmVybmFtZSA9IG9wdHMuc2VydmVybmFtZSB8fCBvcHRzLmhvc3Q7CiAgICAgICAgICAgICAgICAgICAgaWYgKCFzZXJ2ZXJuYW1lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcignQ291bGQgbm90IGRldGVybWluZSAic2VydmVybmFtZSInKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgLy8gVGhlIHByb3h5IGlzIGNvbm5lY3RpbmcgdG8gYSBUTFMgc2VydmVyLCBzbyB1cGdyYWRlCiAgICAgICAgICAgICAgICAgICAgLy8gdGhpcyBzb2NrZXQgY29ubmVjdGlvbiB0byBhIFRMUyBjb25uZWN0aW9uLgogICAgICAgICAgICAgICAgICAgIGRlYnVnKCdVcGdyYWRpbmcgc29ja2V0IGNvbm5lY3Rpb24gdG8gVExTJyk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRsc18xLmRlZmF1bHQuY29ubmVjdChPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sIG9taXQob3B0cywgJ2hvc3QnLCAnaG9zdG5hbWUnLCAncGF0aCcsICdwb3J0JykpLCB7IHNvY2tldCwKICAgICAgICAgICAgICAgICAgICAgICAgc2VydmVybmFtZSB9KSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICByZXR1cm4gc29ja2V0OwogICAgICAgICAgICB9CiAgICAgICAgICAgIC8vIFNvbWUgb3RoZXIgc3RhdHVzIGNvZGUgdGhhdCdzIG5vdCAyMDAuLi4gbmVlZCB0byByZS1wbGF5IHRoZSBIVFRQCiAgICAgICAgICAgIC8vIGhlYWRlciAiZGF0YSIgZXZlbnRzIG9udG8gdGhlIHNvY2tldCBvbmNlIHRoZSBIVFRQIG1hY2hpbmVyeSBpcwogICAgICAgIC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nNwb3J0YC4KICovCmZ1bmN0aW9uIGNyZWF0ZVJlcXVlc3RFeGVjdXRvcigKICBvcHRpb25zLAogIGh0dHBNb2R1bGUsCiAgYWdlbnQsCikgewogIGNvbnN0IHsgaG9zdG5hbWUsIHBhdGhuYW1lLCBwb3J0LCBwcm90b2NvbCwgc2VhcmNoIH0gPSBuZXcgVVJMKG9wdGlvbnMudXJsKTsKICByZXR1cm4gZnVuY3Rpb24gbWFrZVJlcXVlc3QocmVxdWVzdCkgewogICAgcmV0dXJuIG5ldyBQcm9taXNlKChyZXNvbHZlLCByZWplY3QpID0+IHsKICAgICAgbGV0IGJvZHkgPSBzdHJlYW1Gcm9tQm9keShyZXF1ZXN0LmJvZHkpOwoKICAgICAgY29uc3QgaGVhZGVycyA9IHsgLi4ub3B0aW9ucy5oZWFkZXJzIH07CgogICAgICBpZiAocmVxdWVzdC5ib2R5Lmxlbmd0aCA+IEdaSVBfVEhSRVNIT0xEKSB7CiAgICAgICAgaGVhZGVyc1snY29udGVudC1lbmNvZGluZyddID0gJ2d6aXAnOwogICAgICAgIGJvZHkgPSBib2R5LnBpcGUoY3JlYXRlR3ppcCgpKTsKICAgICAgfQoKICAgICAgY29uc3QgcmVxID0gaHR0cE1vZHVsZS5yZXF1ZXN0KAogICAgICAgIHsKICAgICAgICAgIG1ldGhvZDogJ1BPU1QnLAogICAgICAgICAgYWdlbnQsCiAgICAgICAgICBoZWFkZXJzLAogICAgICAgICAgaG9zdG5hbWUsCiAgICAgICAgICBwYXRoOiBgJHtwYXRobmFtZX0ke3NlYXJjaH1gLAogICAgICAgICAgcG9ydCwKICAgICAgICAgIHByb3RvY29sLAogICAgICAgICAgY2E6IG9wdGlvbnMuY2FDZXJ0cywKICAgICAgICB9LAogICAgICAgIHJlcyA9PiB7CiAgICAgICAgICByZXMub24oJ2RhdGEnLCAoKSA9PiB7CiAgICAgICAgICAgIC8vIERyYWluIHNvY2tldAogICAgICAgICAgfSk7CgogICAgICAgICAgcmVzLm9uKCdlbmQnLCAoKSA9PiB7CiAgICAgICAgICAgIC8vIERyYWluIHNvY2tldAogICAgICAgICAgfSk7CgogICAgICAgICAgcmVzLnNldEVuY29kaW5nKCd1dGY4Jyk7CgogICAgICAgICAgLy8gIktleS12YWx1ZSBwYWlycyBvZiBoZWFkZXIgbmFtZXMgYW5kIHZhbHVlcy4gSGVhZGVyIG5hbWVzIGFyZSBsb3dlci1jYXNlZC4iCiAgICAgICAgICAvLyBodHRwczovL25vZGVqcy5vcmcvYXBpL2h0dHAuaHRtbCNodHRwX21lc3NhZ2VfaGVhZGVycwogICAgICAgICAgY29uc3QgcmV0cnlBZnRlckhlYWRlciA9IF9udWxsaXNoQ29hbGVzY2UocmVzLmhlYWRlcnNbJ3JldHJ5LWFmdGVyJ10sICgpID0+ICggbnVsbCkpOwogICAgICAgICAgY29uc3QgcmF0ZUxpbWl0c0hlYWRlciA9IF9udWxsaXNoQ29hbGVzY2UocmVzLmhlYWRlcnNbJ3gtc2VudHJ5LXJhdGUtbGltaXRzJ10sICgpID0+ICggbnVsbCkpOwoKICAgICAgICAgIHJlc29sdmUoewogICAgICAgICAgICBzdGF0dXNDb2RlOiByZXMuc3RhdHVzQ29kZSwKICAgICAgICAgICAgaGVhZGVyczogewogICAgICAgICAgICAgICdyZXRyeS1hZnRlcic6IHJldHJ5QWZ0ZXJIZWFkZXIsCiAgICAgICAgICAgICAgJ3gtc2VudHJ5LXJhdGUtbGltaXRzJzogQXJyYXkuaXNBcnJheShyYXRlTGltaXRzSGVhZGVyKSA/IHJhdGVMaW1pdHNIZWFkZXJbMF0gOiByYXRlTGltaXRzSGVhZGVyLAogICAgICAgICAgICB9LAogICAgICAgICAgfSk7CiAgICAgICAgfSwKICAgICAgKTsKCiAgICAgIHJlcS5vbignZXJyb3InLCByZWplY3QpOwogICAgICBib2R5LnBpcGUocmVxKTsKICAgIH0pOwogIH07Cn0KCmZ1bmN0aW9uIF9vcHRpb25hbENoYWluKG9wcykgeyBsZXQgbGFzdEFjY2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BNYXRoLmZsb29yKHNlY29uZHMgKiAxZTMgKyBuYW5vU2Vjb25kcyAvIDFlNik7CiAgICB9LAogICAgcmVzZXQ6ICgpID0+IHsKICAgICAgbGFzdFBvbGwgPSBwcm9jZXNzLmhydGltZSgpOwogICAgfSwKICB9Owp9CgpmdW5jdGlvbiB3YXRjaGRvZ1RpbWVvdXQoKSB7CiAgbG9nKCdXYXRjaGRvZyB0aW1lb3V0Jyk7CgogIGlmIChkZWJ1Z2dlclBhdXNlKSB7CiAgICBsb2coJ1BhdXNpbmcgZGVidWdnZXIgdG8gY2FwdHVyZSBzdGFjayB0cmFjZScpOwogICAgZGVidWdnZXJQYXVzZSgpOwogIH0gZWxzZSB7CiAgICBsb2coJ0NhcHR1cmluZyBldmVudCB3aXRob3V0IGEgc3RhY2sgdHJhY2UnKTsKICAgIHNlbmRBbnJFdmVudCgpLnRoZW4obnVsbCwgKCkgPT4gewogICAgICBsb2coJ1NlbmRpbmcgQU5SIGV2ZW50IGZhaWxlZCBvbiB3YXRjaGRvZyB0aW1lb3V0LicpOwogICAgfSk7CiAgfQp9Cgpjb25zdCB7IHBvbGwgfSA9IHdhdGNoZG9nVGltZXIoY3JlYXRlSHJUaW1lciwgb3B0aW9ucy5wb2xsSW50ZXJ2YWwsIG9wdGlvbnMuYW5yVGhyZXNob2xkLCB3YXRjaGRvZ1RpbWVvdXQpOwoKX29wdGlvbmFsQ2hhaW4oW3BhcmVudFBvcnQsICdvcHRpb25hbEFjY2VzcycsIF82ID0+IF82Lm9uLCAnY2FsbCcsIF83ID0+IF83KCdtZXNzYWdlJywgKG1zZykgPT4gewogIGlmIChtc2cuc2Vzc2lvbikgewogICAgc2Vzc2lvbiA9IG1ha2VTZXNzaW9uKG1zZy5zZXNzaW9uKTsKICB9CgogIHBvbGwoKTsKfSldKTs="),{workerData:p});process.on("exit",(()=>{m.terminate()}));const b=setInterval((()=>{try{const e=(0,a.nZ)().getSession(),t=e?{...e,toJSON:void 0}:void 0;m.postMessage({session:t})}catch(e){}}),p.pollInterval);b.unref(),m.on("message",(e=>{"session-ended"===e&&(d("ANR event sent from ANR worker. Clearing session in this thread."),(0,a.nZ)().setSession(void 0))})),m.once("error",(e=>{clearInterval(b),d("ANR worker error",e)})),m.once("exit",(e=>{clearInterval(b),d("ANR worker exit",e)})),m.unref()}(r,t)))}})))},750:(e,t,n)=>{"use strict";function s(e,t,n){let s=0,o=5,i=0;return setInterval((()=>{0===i?s>e&&(o*=2,n(o),o>86400&&(o=86400),i=o):(i-=1,0===i&&t()),s=0}),1e3).unref(),()=>{s+=1}}function o(e){return void 0!==e&&(0===e.length||"?"===e||""===e)}function i(e,t){return e===t||o(e)&&o(t)}function r(e){if(void 0!==e)return e.slice(-10).reduce(((e,t)=>`${e},${t.function},${t.lineno},${t.colno}`),"")}function a(e,t){if(void 0!==t)return r(e(t,1))}n.d(t,{H2:()=>s,MS:()=>i,Q4:()=>r,QY:()=>a})},8536:(e,t,n)=>{"use strict";n.d(t,{f:()=>I});var s=n(4307),o=n(2967),i=n(3641),r=n(2343),a=n(2176),c=n(750);async function l(e,t,n,o){const i=await e.post("Runtime.getProperties",{objectId:t,ownProperties:!0});o[n]=i.result.filter((e=>"length"!==e.name&&!isNaN(parseInt(e.name,10)))).sort(((e,t)=>parseInt(e.name,10)-parseInt(t.name,10))).map((e=>(0,s.x)([e,"access",e=>e.value,"optionalAccess",e=>e.value])))}async function g(e,t,n,o){const i=await e.post("Runtime.getProperties",{objectId:t,ownProperties:!0});o[n]=i.result.map((e=>[e.name,(0,s.x)([e,"access",e=>e.value,"optionalAccess",e=>e.value])])).reduce(((e,[t,n])=>(e[t]=n,e)),{})}function d(e,t){(0,s.x)([e,"optionalAccess",e=>e.value,"optionalAccess",e=>e.value])?t[e.name]=e.value.value:(0,s.x)([e,"optionalAccess",e=>e.value,"optionalAccess",e=>e.description])&&"function"!==(0,s.x)([e,"optionalAccess",e=>e.value,"optionalAccess",e=>e.type])&&(t[e.name]=`<${e.value.description}>`)}async function u(e,t){const n=await e.post("Runtime.getProperties",{objectId:t,ownProperties:!0}),o={};for(const t of n.result)if((0,s.x)([t,"optionalAccess",e=>e.value,"optionalAccess",e=>e.objectId])&&"Array"===(0,s.x)([t,"optionalAccess",e=>e.value,"access",e=>e.className])){const n=t.value.objectId;await l(e,n,t.name,o)}else if((0,s.x)([t,"optionalAccess",e=>e.value,"optionalAccess",e=>e.objectId])&&"Object"===(0,s.x)([t,"optionalAccess",e=>e.value,"optionalAccess",e=>e.className])){const n=t.value.objectId;await g(e,n,t.name,o)}else((0,s.x)([t,"optionalAccess",e=>e.value,"optionalAccess",e=>e.value])||(0,s.x)([t,"optionalAccess",e=>e.value,"optionalAccess",e=>e.description]))&&d(t,o);return o}e=n.hmd(e);const h="LocalVariablesAsync",I=(t={})=>{const n=new i.f(20);let o,l=!1;function g(e){const t=(0,c.Q4)((0,s.x)([e,"access",e=>e.stacktrace,"optionalAccess",e=>e.frames]));if(void 0===t)return;const o=n.remove(t);if(void 0===o)return;const i=(0,s.x)([e,"access",e=>e.stacktrace,"optionalAccess",e=>e.frames,"optionalAccess",e=>e.length])||0;for(let t=0;te.stacktrace,"optionalAccess",e=>e.frames,"optionalAccess",e=>e[n]])||!o[t])break;void 0!==o[t].vars&&!1!==e.stacktrace.frames[n].in_app&&(0,c.MS)(e.stacktrace.frames[n].function,o[t].function)&&(e.stacktrace.frames[n].vars=o[t].vars)}}return{name:h,setup(i){const g=i.getOptions();if(g.includeLocalVariables)try{const{Session:i}=(0,a.l$)(e,"node:inspector/promises");(async function(e,i){e.connect();let a=!1;e.on("Debugger.resumed",(()=>{a=!1})),e.on("Debugger.paused",(t=>{a=!0,async function(e,t,{reason:i,data:r,callFrames:a}){if("exception"!==i&&"promiseRejection"!==i)return;(0,s.x)([o,"optionalCall",e=>e()]);const l=(0,c.QY)(t,(0,s.x)([r,"optionalAccess",e=>e.description]));if(null==l)return;const g=[];for(let t=0;t"local"===e.type)),c="global"!==i.className&&i.className?`${i.className}.${o}`:o;if(void 0===(0,s.x)([r,"optionalAccess",e=>e.object,"access",e=>e.objectId]))g[t]={function:c};else{const n=await u(e,r.object.objectId);g[t]={function:c,vars:n}}}n.set(l,g)}(e,i.stackParser,t.params).then((()=>a?e.post("Debugger.resume"):Promise.resolve()),(e=>{}))})),await e.post("Debugger.enable");const g=!1!==t.captureAllExceptions;if(await e.post("Debugger.setPauseOnExceptions",{state:g?"all":"uncaught"}),g){const n=t.maxExceptionsPerSecond||50;o=(0,c.H2)(n,(()=>(r.kg.log("Local variables rate-limit lifted."),e.post("Debugger.setPauseOnExceptions",{state:"all"}))),(t=>(r.kg.log(`Local variables rate-limit exceeded. Disabling capturing of caught exceptions for ${t} seconds.`),e.post("Debugger.setPauseOnExceptions",{state:"uncaught"}))))}l=!0})(new i,g).catch((e=>{r.kg.error("Failed to start inspector session",e)}))}catch(e){return void r.kg.error("Failed to load inspector API",e)}},processEvent:e=>l?function(e){for(const t of(0,s.x)([e,"access",e=>e.exception,"optionalAccess",e=>e.values])||[])g(t);return e}(e):e}};(0,o.RN)(h,I)},1249:(e,t,n)=>{"use strict";n.d(t,{Y:()=>m});var s,o=n(4307),i=n(5659),r=n(4487),a=n(766),c=n(3371),l=n(454),g=n(3641),d=n(2176),u=n(7321),h=n(9181),I=n(7638),p=n(6956),C=n(9656);e=n.hmd(e),function(e){e.RequestCreate="undici:request:create",e.RequestEnd="undici:request:headers",e.RequestError="undici:request:error"}(s||(s={}));class m{static __initStatic(){this.id="Undici"}__init(){this.name=m.id}__init2(){this._createSpanUrlMap=new g.f(100)}__init3(){this._headersUrlMap=new g.f(100)}constructor(e={}){m.prototype.__init.call(this),m.prototype.__init2.call(this),m.prototype.__init3.call(this),m.prototype.__init4.call(this),m.prototype.__init5.call(this),m.prototype.__init6.call(this),this._options={breadcrumbs:void 0===e.breadcrumbs||e.breadcrumbs,shouldCreateSpanForRequest:e.shouldCreateSpanForRequest}}setupOnce(t){if(C.V.major<16)return;let n;try{n=(0,d.l$)(e,"diagnostics_channel")}catch(e){}n&&n.subscribe&&(n.subscribe(s.RequestCreate,this._onRequestCreate),n.subscribe(s.RequestEnd,this._onRequestEnd),n.subscribe(s.RequestError,this._onRequestError))}_shouldCreateSpan(e){if(void 0===this._options.shouldCreateSpanForRequest)return!0;const t=this._createSpanUrlMap.get(e);if(void 0!==t)return t;const n=this._options.shouldCreateSpanForRequest(e);return this._createSpanUrlMap.set(e,n),n}__init4(){this._onRequestCreate=e=>{if(!(0,i.Gd)().getIntegration(m))return;const{request:t}=e,n=t.origin?t.origin.toString()+t.path:t.path,s=(0,r.s3)();if(!s)return;if((0,a.W)(n,s)||void 0!==t.__sentry_span__)return;const g=s.getOptions(),d=(0,r.nZ)(),C=d.getSpan(),y=this._shouldCreateSpan(n)?function(e,t,n){const s=(0,p.en)(n),i=t.method||"GET",r={"http.method":i};return s.search&&(r["http.query"]=s.search),s.hash&&(r["http.fragment"]=s.hash),(0,o.x)([e,"optionalAccess",e=>e.startChild,"call",e=>e({op:"http.client",origin:"auto.http.node.undici",description:`${i} ${(0,p.tF)(s)}`,data:r})])}(C,t,n):void 0;if(y&&(t.__sentry_span__=y),(e=>{if(void 0===g.tracePropagationTargets)return!0;const t=this._headersUrlMap.get(e);if(void 0!==t)return t;const n=(0,u.U0)(e,g.tracePropagationTargets);return this._headersUrlMap.set(e,n),n})(n))if(y){const e=(0,o.x)([y,"optionalAccess",e=>e.transaction,"optionalAccess",e=>e.getDynamicSamplingContext,"call",e=>e()]),n=(0,h.IQ)(e);b(t,(0,c.H)(y),n)}else{const{traceId:e,sampled:n,dsc:o}=d.getPropagationContext(),i=(0,I.$p)(e,void 0,n),r=o||(0,l._)(e,s,d);b(t,i,(0,h.IQ)(r))}}}__init5(){this._onRequestEnd=e=>{if(!(0,i.Gd)().getIntegration(m))return;const{request:t,response:n}=e,s=t.origin?t.origin.toString()+t.path:t.path;if((0,a.W)(s,(0,r.s3)()))return;const o=t.__sentry_span__;o&&(o.setHttpStatus(n.statusCode),o.end()),this._options.breadcrumbs&&(0,r.n_)({category:"http",data:{method:t.method,status_code:n.statusCode,url:s},type:"http"},{event:"response",request:t,response:n})}}__init6(){this._onRequestError=e=>{if(!(0,i.Gd)().getIntegration(m))return;const{request:t}=e,n=t.origin?t.origin.toString()+t.path:t.path;if((0,a.W)(n,(0,r.s3)()))return;const s=t.__sentry_span__;s&&(s.setStatus("internal_error"),s.end()),this._options.breadcrumbs&&(0,r.n_)({category:"http",data:{method:t.method,url:n},level:"error",type:"http"},{event:"error",request:t})}}}function b(e,t,n){e.headers.split("\r\n").some((e=>e.startsWith("sentry-trace:")))||(e.addHeader("sentry-trace",t),n&&e.addHeader("baggage",n))}m.__initStatic()},9656:(e,t,n)=>{"use strict";n.d(t,{V:()=>s});const s=(0,n(2844).J4)(process.versions.node)},2421:(e,t,n)=>{"use strict";n.r(t),n.d(t,{BROWSER_TRACING_INTEGRATION_ID:()=>Oe,BrowserTracing:()=>xe,IdleTransaction:()=>qe,Integrations:()=>nt,Span:()=>Le,SpanStatus:()=>tt,TRACEPARENT_REGEXP:()=>De,Transaction:()=>Qe,addExtensionMethods:()=>ze,defaultRequestInstrumentationOptions:()=>je,extractTraceparentData:()=>Ee,getActiveTransaction:()=>Te,hasTracingEnabled:()=>Me,instrumentOutgoingRequests:()=>$e,spanStatusfromHttpCode:()=>Ue,startIdleTransaction:()=>et,stripUrlQueryAndFragment:()=>Pe});var s=n(5544),o=n(1283),i=n(9791),r=n(2343),a=n(7638),c=n(8464),l=n(7513),g=n(1235);const d=g.n2;var u=n(1170),h=n(6147);const I=(e,t,n)=>{let s,o;return i=>{t.value>=0&&(i||n)&&(o=t.value-(s||0),(o||void 0===s)&&(s=t.value,t.delta=o,e(t)))}},p=()=>d.__WEB_VITALS_POLYFILL__?d.performance&&(performance.getEntriesByType&&performance.getEntriesByType("navigation")[0]||(()=>{const e=d.performance.timing,t=d.performance.navigation.type,n={entryType:"navigation",startTime:0,type:2==t?"back_forward":1===t?"reload":"navigate"};for(const t in e)"navigationStart"!==t&&"toJSON"!==t&&(n[t]=Math.max(e[t]-e.navigationStart,0));return n})()):d.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0],C=()=>{const e=p();return e&&e.activationStart||0},m=(e,t)=>{const n=p();let s="navigate";return n&&(s=d.document.prerendering||C()>0?"prerender":n.type.replace(/_/g,"-")),{name:e,value:void 0===t?-1:t,rating:"good",delta:0,entries:[],id:`v3-${Date.now()}-${Math.floor(8999999999999*Math.random())+1e12}`,navigationType:s}},b=(e,t,n)=>{try{if(PerformanceObserver.supportedEntryTypes.includes(e)){const s=new PerformanceObserver((e=>{t(e.getEntries())}));return s.observe(Object.assign({type:e,buffered:!0},n||{})),s}}catch(e){}},y=(e,t)=>{const n=s=>{"pagehide"!==s.type&&"hidden"!==d.document.visibilityState||(e(s),t&&(removeEventListener("visibilitychange",n,!0),removeEventListener("pagehide",n,!0)))};addEventListener("visibilitychange",n,!0),addEventListener("pagehide",n,!0)},f=e=>{const t=m("CLS",0);let n,s=0,o=[];const i=e=>{e.forEach((e=>{if(!e.hadRecentInput){const i=o[0],r=o[o.length-1];s&&0!==o.length&&e.startTime-r.startTime<1e3&&e.startTime-i.startTime<5e3?(s+=e.value,o.push(e)):(s=e.value,o=[e]),s>t.value&&(t.value=s,t.entries=o,n&&n())}}))},r=b("layout-shift",i);if(r){n=I(e,t);const s=()=>{i(r.takeRecords()),n(!0)};return y(s),s}};let Z=-1;const A=()=>(Z<0&&(Z="hidden"!==d.document.visibilityState||d.document.prerendering?1/0:0,y((({timeStamp:e})=>{Z=e}),!0)),{get firstHiddenTime(){return Z}}),G=e=>{const t=A(),n=m("FID");let s;const o=e=>{e.startTime{e.forEach(o)},r=b("first-input",i);s=I(e,n),r&&y((()=>{i(r.takeRecords()),r.disconnect()}),!0)},B={},v=e=>{const t=A(),n=m("LCP");let s;const o=e=>{const o=e[e.length-1];if(o){const e=Math.max(o.startTime-C(),0);e{B[n.id]||(o(i.takeRecords()),i.disconnect(),B[n.id]=!0,s(!0))};return["keydown","click"].forEach((e=>{addEventListener(e,t,{once:!0,capture:!0})})),y(t,!0),t}},W={},V={};let w,S,R;function H(e,t){return _(e,t),V[e]||(function(e){const t={};"event"===e&&(t.durationThreshold=0),b(e,(t=>{X(e,{entries:t})}),t)}(e),V[e]=!0),K(e,t)}function X(e,t){const n=W[e];if(n&&n.length)for(const s of n)try{s(t)}catch(t){l.X&&r.kg.error(`Error while triggering instrumentation handler.\nType: ${e}\nName: ${(0,h.$P)(s)}\nError:`,t)}}function k(){f((e=>{X("cls",{metric:e}),w=e}))}function Y(){G((e=>{X("fid",{metric:e}),S=e}))}function N(){v((e=>{X("lcp",{metric:e}),R=e}))}function J(e,t,n,s){return _(e,t),V[e]||(n(),V[e]=!0),s&&t({metric:s}),K(e,t)}function _(e,t){W[e]=W[e]||[],W[e].push(t)}function K(e,t){return()=>{const n=W[e];if(!n)return;const s=n.indexOf(t);-1!==s&&n.splice(s,1)}}function F(e){return"number"==typeof e&&isFinite(e)}function x(e,{startTimestamp:t,...n}){return t&&e.startTimestamp>t&&(e.startTimestamp=t),e.startChild({startTimestamp:t,...n})}const z=2147483647;function T(e){return e/1e3}function E(){return d&&d.addEventListener&&d.performance}let U,Q,L=0,O={};function j(){const e=E();if(e&&u.Z1){e.mark&&d.performance.mark("sentry-tracing-init");const t=J("fid",(({metric:e})=>{const t=e.entries.pop();if(!t)return;const n=T(u.Z1),s=T(t.startTime);l.X&&r.kg.log("[Measurements] Adding FID"),O.fid={value:e.value,unit:"millisecond"},O["mark.fid"]={value:n+s,unit:"second"}}),Y,S),n=J("cls",(({metric:e})=>{const t=e.entries.pop();t&&(l.X&&r.kg.log("[Measurements] Adding CLS"),O.cls={value:e.value,unit:""},Q=t)}),k,w),s=J("lcp",(({metric:e})=>{const t=e.entries.pop();t&&(l.X&&r.kg.log("[Measurements] Adding LCP"),O.lcp={value:e.value,unit:"millisecond"},U=t)}),N,R);return()=>{t(),n(),s()}}return()=>{}}function M(e,t,n,s,o,i){const r=i?t[i]:t[`${n}End`],a=t[`${n}Start`];a&&r&&x(e,{op:"browser",origin:"auto.browser.browser.metrics",description:o||n,startTimestamp:s+T(a),endTimestamp:s+T(r)})}function P(e,t,n,s){const o=t[n];null!=o&&o{const t={...o,endTimestamp:Date.now(),response:e};return(0,ie.rK)("fetch",t),e}),(e=>{const t={...o,endTimestamp:Date.now(),error:e};throw(0,ie.rK)("fetch",t),e}))}}))}function ae(e,t){return!!e&&"object"==typeof e&&!!e[t]}function ce(e){return"string"==typeof e?e:e?ae(e,"url")?e.url:e.toString?e.toString():"":""}var le=n(7597);const ge=g.n2,de="__sentry_xhr_v3__";function ue(){if(!ge.XMLHttpRequest)return;const e=XMLHttpRequest.prototype;(0,te.hl)(e,"open",(function(e){return function(...t){const n=Date.now(),s=(0,le.HD)(t[0])?t[0].toUpperCase():void 0,o=function(e){if((0,le.HD)(e))return e;try{return e.toString()}catch(e){}}(t[1]);if(!s||!o)return e.apply(this,t);this[de]={method:s,url:o,request_headers:{}},"POST"===s&&o.match(/sentry_key/)&&(this.__sentry_own_request__=!0);const i=()=>{const e=this[de];if(e&&4===this.readyState){try{e.status_code=this.status}catch(e){}const t={args:[s,o],endTimestamp:Date.now(),startTimestamp:n,xhr:this};(0,ie.rK)("xhr",t)}};return"onreadystatechange"in this&&"function"==typeof this.onreadystatechange?(0,te.hl)(this,"onreadystatechange",(function(e){return function(...t){return i(),e.apply(this,t)}})):this.addEventListener("readystatechange",i),(0,te.hl)(this,"setRequestHeader",(function(e){return function(...t){const[n,s]=t,o=this[de];return o&&(0,le.HD)(n)&&(0,le.HD)(s)&&(o.request_headers[n.toLowerCase()]=s),e.apply(this,t)}})),e.apply(this,t)}})),(0,te.hl)(e,"send",(function(e){return function(...t){const n=this[de];if(!n)return e.apply(this,t);void 0!==t[0]&&(n.body=t[0]);const s={args:[n.method,n.url],startTimestamp:Date.now(),xhr:this};return(0,ie.rK)("xhr",s),e.apply(this,t)}}))}var he=n(7321),Ie=n(9181);const pe=["localhost",/^\/(?!\/)/],Ce={traceFetch:!0,traceXHR:!0,enableHTTPTimings:!0,tracingOrigins:pe,tracePropagationTargets:pe};function me(e){const{traceFetch:t,traceXHR:n,tracePropagationTargets:s,tracingOrigins:o,shouldCreateSpanForRequest:i,enableHTTPTimings:r}={traceFetch:Ce.traceFetch,traceXHR:Ce.traceXHR,...e},c="function"==typeof i?i:e=>!0,l=e=>function(e,t){return(0,he.U0)(e,t||pe)}(e,s||o),g={};var d;t&&function(e){const t="fetch";(0,ie.Hj)(t,(e=>{const t=function(e,t,n,s,o="auto.http.browser"){if(!(0,D.z)()||!e.fetchData)return;const i=t(e.fetchData.url);if(e.endTimestamp&&i){const t=e.fetchData.__span;if(!t)return;const n=s[t];if(n){if(e.response){n.setHttpStatus(e.response.status);const t=e.response&&e.response.headers&&e.response.headers.get("content-length");if(t){const e=parseInt(t);e>0&&n.setData("http.response_content_length",e)}}else e.error&&n.setStatus("internal_error");n.end(),delete s[t]}return}const r=(0,q.nZ)(),c=(0,q.s3)(),l=r.getSpan(),{method:g,url:d}=e.fetchData,u=i&&l?l.startChild({data:{url:d,type:"fetch","http.method":g},description:`${g} ${d}`,op:"http.client",origin:o}):void 0;if(u&&(e.fetchData.__span=u.spanId,s[u.spanId]=u),n(e.fetchData.url)&&c){const t=e.args[0];e.args[1]=e.args[1]||{};const n=e.args[1];n.headers=function(e,t,n,s,o){const i=o||n.getSpan(),r=i&&i.transaction,{traceId:c,sampled:l,dsc:g}=n.getPropagationContext(),d=i?(0,$.H)(i):(0,a.$p)(c,void 0,l),u=r?r.getDynamicSamplingContext():g||(0,ee._)(c,t,n),h=(0,Ie.IQ)(u),I="undefined"!=typeof Request&&(0,le.V9)(e,Request)?e.headers:s.headers;if(I){if("undefined"!=typeof Headers&&(0,le.V9)(I,Headers)){const e=new Headers(I);return e.append("sentry-trace",d),h&&e.append(Ie.bU,h),e}if(Array.isArray(I)){const e=[...I,["sentry-trace",d]];return h&&e.push([Ie.bU,h]),e}{const e="baggage"in I?I.baggage:void 0,t=[];return Array.isArray(e)?t.push(...e):e&&t.push(e),h&&t.push(h),{...I,"sentry-trace":d,baggage:t.length>0?t.join(","):void 0}}}return{"sentry-trace":d,baggage:h}}(t,c,r,n,u)}return u}(e,c,l,g);r&&t&&be(t)})),(0,ie.D2)(t,re)}(),n&&(d=e=>{const t=function(e,t,n,s){const o=e.xhr,i=o&&o[de];if(!(0,D.z)()||!o||o.__sentry_own_request__||!i)return;const r=t(i.url);if(e.endTimestamp&&r){const e=o.__sentry_xhr_span_id__;if(!e)return;const t=s[e];return void(t&&void 0!==i.status_code&&(t.setHttpStatus(i.status_code),t.end(),delete s[e]))}const c=(0,q.nZ)(),l=c.getSpan(),g=r&&l?l.startChild({data:{type:"xhr","http.method":i.method,url:i.url},description:`${i.method} ${i.url}`,op:"http.client",origin:"auto.http.browser"}):void 0;if(g&&(o.__sentry_xhr_span_id__=g.spanId,s[o.__sentry_xhr_span_id__]=g),o.setRequestHeader&&n(i.url))if(g){const e=g&&g.transaction,t=e&&e.getDynamicSamplingContext(),n=(0,Ie.IQ)(t);fe(o,(0,$.H)(g),n)}else{const e=(0,q.s3)(),{traceId:t,sampled:n,dsc:s}=c.getPropagationContext(),i=(0,a.$p)(t,void 0,n),r=s||(e?(0,ee._)(t,e,c):void 0);fe(o,i,(0,Ie.IQ)(r))}return g}(e,c,l,g);r&&t&&be(t)},(0,ie.Hj)("xhr",d),(0,ie.D2)("xhr",ue))}function be(e){const t=e.data.url;if(!t)return;const n=H("resource",(({entries:s})=>{s.forEach((s=>{(function(e){return"resource"===e.entryType&&"initiatorType"in e&&"string"==typeof e.nextHopProtocol&&("fetch"===e.initiatorType||"xmlhttprequest"===e.initiatorType)})(s)&&s.name.endsWith(t)&&(function(e){const{name:t,version:n}=function(e){let t="unknown",n="unknown",s="";for(const o of e){if("/"===o){[t,n]=e.split("/");break}if(!isNaN(Number(o))){t="h"===s?"http":s,n=e.split(s)[1];break}s+=o}return s===e&&(t=s),{name:t,version:n}}(e.nextHopProtocol),s=[];return s.push(["network.protocol.version",n],["network.protocol.name",t]),u.Z1?[...s,["http.request.redirect_start",ye(e.redirectStart)],["http.request.fetch_start",ye(e.fetchStart)],["http.request.domain_lookup_start",ye(e.domainLookupStart)],["http.request.domain_lookup_end",ye(e.domainLookupEnd)],["http.request.connect_start",ye(e.connectStart)],["http.request.secure_connection_start",ye(e.secureConnectionStart)],["http.request.connection_end",ye(e.connectEnd)],["http.request.request_start",ye(e.requestStart)],["http.request.response_start",ye(e.responseStart)],["http.request.response_end",ye(e.responseEnd)]]:s}(s).forEach((t=>e.setData(...t))),setTimeout(n))}))}))}function ye(e=0){return((u.Z1||performance.timeOrigin)+e)/1e3}function fe(e,t,n){try{e.setRequestHeader("sentry-trace",t),n&&e.setRequestHeader(Ie.bU,n)}catch(e){}}const Ze=(0,g.Rf)(),Ae=g.n2;let Ge;function Be(){if(!function(){const e=Ze.chrome,t=e&&e.app&&e.app.runtime,n="history"in Ze&&!!Ze.history.pushState&&!!Ze.history.replaceState;return!t&&n}())return;const e=Ae.onpopstate;function t(e){return function(...t){const n=t.length>2?t[2]:void 0;if(n){const e=Ge,t=String(n);Ge=t;const s={from:e,to:t};(0,ie.rK)("history",s)}return e.apply(this,t)}}Ae.onpopstate=function(...t){const n=Ae.location.href,s=Ge;Ge=n;const o={from:s,to:n};if((0,ie.rK)("history",o),e)try{return e.apply(this,t)}catch(e){}},(0,te.hl)(Ae.history,"pushState",t),(0,te.hl)(Ae.history,"replaceState",t)}const ve="BrowserTracing",We={...s.AT,markBackgroundTransactions:!0,routingInstrumentation:function(e,t=!0,n=!0){if(!d||!d.location)return void(l.X&&r.kg.warn("Could not initialize routing instrumentation due to invalid location"));let s,o=d.location.href;t&&(s=e({name:d.location.pathname,startTimestamp:u.Z1?u.Z1/1e3:void 0,op:"pageload",origin:"auto.pageload.browser",metadata:{source:"url"}})),n&&function(t){const n="history";(0,ie.Hj)(n,(({to:t,from:n})=>{void 0===n&&o&&-1!==o.indexOf(t)?o=void 0:n!==t&&(o=void 0,s&&(l.X&&r.kg.log(`[Tracing] Finishing current transaction with op: ${s.op}`),s.end()),s=e({name:d.location.pathname,op:"navigation",origin:"auto.navigation.browser",metadata:{source:"url"}}))})),(0,ie.D2)(n,Be)}()},startTransactionOnLocationChange:!0,startTransactionOnPageLoad:!0,enableLongTask:!0,_experiments:{},...Ce};function Ve(e){const t=(0,c.qT)(`meta[name=${e}]`);return t?t.getAttribute("content"):void 0}var we,Se=n(758),Re=n(8903),He=n(8069),Xe=n(6956);!function(e){e.Ok="ok",e.DeadlineExceeded="deadline_exceeded",e.Unauthenticated="unauthenticated",e.PermissionDenied="permission_denied",e.NotFound="not_found",e.ResourceExhausted="resource_exhausted",e.InvalidArgument="invalid_argument",e.Unimplemented="unimplemented",e.Unavailable="unavailable",e.InternalError="internal_error",e.UnknownError="unknown_error",e.Cancelled="cancelled",e.AlreadyExists="already_exists",e.FailedPrecondition="failed_precondition",e.Aborted="aborted",e.OutOfRange="out_of_range",e.DataLoss="data_loss"}(we||(we={}));var ke=n(2716),Ye=n(8737),Ne=n(1791),Je=n(6169),_e=n(24),Ke=n(1370),Fe=n(9889);const xe=class{constructor(e){this.name=ve,this._hasSetTracePropagationTargets=!1,(0,o.T)(),l.X&&(this._hasSetTracePropagationTargets=!(!e||!e.tracePropagationTargets&&!e.tracingOrigins)),this.options={...We,...e},void 0!==this.options._experiments.enableLongTask&&(this.options.enableLongTask=this.options._experiments.enableLongTask),e&&!e.tracePropagationTargets&&e.tracingOrigins&&(this.options.tracePropagationTargets=e.tracingOrigins),this._collectWebVitals=j(),this.options.enableLongTask&&H("longtask",(({entries:e})=>{for(const t of e){const e=(0,i.x1)();if(!e)return;const n=T(u.Z1+t.startTime),s=T(t.duration);e.startChild({description:"Main UI thread blocked",op:"ui.long-task",origin:"auto.ui.browser.metrics",startTimestamp:n,endTimestamp:n+s})}})),this.options._experiments.enableInteractions&&H("event",(({entries:e})=>{for(const t of e){const e=(0,i.x1)();if(!e)return;if("click"===t.name){const n=T(u.Z1+t.startTime),s=T(t.duration),o={description:(0,c.Rt)(t.target),op:`ui.interaction.${t.name}`,origin:"auto.ui.browser.metrics",startTimestamp:n,endTimestamp:n+s},i=(0,c.iY)(t.target);i&&(o.data={"ui.component_name":i}),e.startChild(o)}}}))}setupOnce(e,t){this._getCurrentHub=t;const n=t().getClient(),s=n&&n.getOptions(),{routingInstrumentation:o,startTransactionOnLocationChange:a,startTransactionOnPageLoad:c,markBackgroundTransactions:g,traceFetch:u,traceXHR:h,shouldCreateSpanForRequest:I,enableHTTPTimings:p,_experiments:C}=this.options,m=s&&s.tracePropagationTargets,b=m||this.options.tracePropagationTargets;l.X&&this._hasSetTracePropagationTargets&&m&&r.kg.warn("[Tracing] The `tracePropagationTargets` option was set in the BrowserTracing integration and top level `Sentry.init`. The top level `Sentry.init` value is being used."),o((e=>{const n=this._createRouteTransaction(e);return this.options._experiments.onStartRouteTransaction&&this.options._experiments.onStartRouteTransaction(n,e,t),n}),c,a),g&&(d&&d.document?d.document.addEventListener("visibilitychange",(()=>{const e=(0,i.x1)();if(d.document.hidden&&e){const t="cancelled";l.X&&r.kg.log(`[Tracing] Transaction: ${t} -> since tab moved to the background, op: ${e.op}`),e.status||e.setStatus(t),e.setTag("visibilitychange","document.hidden"),e.end()}})):l.X&&r.kg.warn("[Tracing] Could not set up background tab detection due to lack of global document")),C.enableInteractions&&this._registerInteractionListener(),me({traceFetch:u,traceXHR:h,tracePropagationTargets:b,shouldCreateSpanForRequest:I,enableHTTPTimings:p})}_createRouteTransaction(e){if(!this._getCurrentHub)return void(l.X&&r.kg.warn(`[Tracing] Did not create ${e.op} transaction because _getCurrentHub is invalid.`));const t=this._getCurrentHub(),{beforeNavigate:n,idleTimeout:s,finalTimeout:i,heartbeatInterval:g}=this.options,h="pageload"===e.op,I=h?Ve("sentry-trace"):"",p=h?Ve("baggage"):"",{traceparentData:C,dynamicSamplingContext:m,propagationContext:b}=(0,a.KA)(I,p),y={...e,...C,metadata:{...e.metadata,dynamicSamplingContext:C&&!m?{}:m},trimEnd:!0},f="function"==typeof n?n(y):y,Z=void 0===f?{...y,sampled:!1}:f;Z.metadata=Z.name!==y.name?{...Z.metadata,source:"custom"}:Z.metadata,this._latestRouteName=Z.name,this._latestRouteSource=Z.metadata&&Z.metadata.source,!1===Z.sampled&&l.X&&r.kg.log(`[Tracing] Will not send ${Z.op} transaction because of beforeNavigate.`),l.X&&r.kg.log(`[Tracing] Starting ${Z.op} transaction on scope`);const{location:G}=d,B=(0,o.l)(t,Z,s,i,!0,{location:G},g),v=t.getScope();return h&&C?v.setPropagationContext(b):v.setPropagationContext({traceId:B.traceId,spanId:B.spanId,parentSpanId:B.parentSpanId,sampled:B.sampled}),B.registerBeforeFinishCallback((e=>{this._collectWebVitals(),function(e){const t=E();if(!t||!d.performance.getEntries||!u.Z1)return;l.X&&r.kg.log("[Tracing] Adding & adjusting spans using Performance API");const n=T(u.Z1),s=t.getEntries();let o,i;if(s.slice(L).forEach((t=>{const s=T(t.startTime),a=T(t.duration);if(!("navigation"===e.op&&n+s{M(e,t,s,n)})),M(e,t,"secureConnection",n,"TLS/SSL","connectEnd"),M(e,t,"fetch",n,"cache","domainLookupStart"),M(e,t,"domainLookup",n,"DNS"),function(e,t,n){x(e,{op:"browser",origin:"auto.browser.browser.metrics",description:"request",startTimestamp:n+T(t.requestStart),endTimestamp:n+T(t.responseEnd)}),x(e,{op:"browser",origin:"auto.browser.browser.metrics",description:"response",startTimestamp:n+T(t.responseStart),endTimestamp:n+T(t.responseEnd)})}(e,t,n)}(e,t,n),o=n+T(t.responseStart),i=n+T(t.requestStart);break;case"mark":case"paint":case"measure":{!function(e,t,n,s,o){const i=o+n,r=i+s;x(e,{description:t.name,endTimestamp:r,op:t.entryType,origin:"auto.resource.browser.metrics",startTimestamp:i})}(e,t,s,a,n);const o=A(),i=t.startTime{if(!O[t]||n>=e.startTimestamp)return;const s=O[t].value,o=n+T(s),i=Math.abs(1e3*(o-e.startTimestamp)),a=i-s;l.X&&r.kg.log(`[Measurements] Normalized ${t} from ${s} to ${i} (${a})`),O[t].value=i}));const t=O["mark.fid"];t&&O.fid&&(x(e,{description:"first input delay",endTimestamp:t.value+T(O.fid.value),op:"ui.action",origin:"auto.ui.browser.metrics",startTimestamp:t.value}),delete O["mark.fid"]),"fcp"in O||delete O.cls,Object.keys(O).forEach((t=>{e.setMeasurement(t,O[t].value,O[t].unit)})),function(e){U&&(l.X&&r.kg.log("[Measurements] Adding LCP Data"),U.element&&e.setTag("lcp.element",(0,c.Rt)(U.element)),U.id&&e.setTag("lcp.id",U.id),U.url&&e.setTag("lcp.url",U.url.trim().slice(0,200)),e.setTag("lcp.size",U.size)),Q&&Q.sources&&(l.X&&r.kg.log("[Measurements] Adding CLS Data"),Q.sources.forEach(((t,n)=>e.setTag(`cls.source.${n+1}`,(0,c.Rt)(t.node)))))}(e)}U=void 0,Q=void 0,O={}}(e)})),B}_registerInteractionListener(){let e;const t=()=>{const{idleTimeout:t,finalTimeout:n,heartbeatInterval:s}=this.options,a="ui.action.click",c=(0,i.x1)();if(c&&c.op&&["navigation","pageload"].includes(c.op))return void(l.X&&r.kg.warn(`[Tracing] Did not create ${a} transaction because a pageload or navigation transaction is in progress.`));if(e&&(e.setFinishReason("interactionInterrupted"),e.end(),e=void 0),!this._getCurrentHub)return void(l.X&&r.kg.warn(`[Tracing] Did not create ${a} transaction because _getCurrentHub is invalid.`));if(!this._latestRouteName)return void(l.X&&r.kg.warn(`[Tracing] Did not create ${a} transaction because _latestRouteName is missing.`));const g=this._getCurrentHub(),{location:u}=d,h={name:this._latestRouteName,op:a,trimEnd:!0,metadata:{source:this._latestRouteSource||"url"}};e=(0,o.l)(g,h,t,n,!0,{location:u},s)};["click"].forEach((e=>{addEventListener(e,t,{once:!1,capture:!0})}))}},ze=Se.r,Te=i.x1,Ee=i.qG,Ue=Re.Zd,Qe=He.Y,Le=Re.Dr,Oe=ve,je=Ce,Me=D.z,Pe=Xe.rt,De=a.Ke,qe=s.io,$e=me,et=o.l,tt=we,nt={BrowserTracing:xe,Apollo:ke._,Express:Ye.N1,GraphQL:Ne.k,Mongo:Je._,Mysql:_e.m,Postgres:Ke.E,Prisma:Fe.g};("undefined"==typeof __SENTRY_TRACING__||__SENTRY_TRACING__)&&(0,Se.r)()},9181:(e,t,n)=>{"use strict";n.d(t,{EN:()=>g,IQ:()=>d,bU:()=>r});var s=n(3897),o=n(7597),i=n(2343);const r="baggage",a="sentry-",c=/^sentry-/,l=8192;function g(e){if(!(0,o.HD)(e)&&!Array.isArray(e))return;let t={};if(Array.isArray(e))t=e.reduce(((e,t)=>{const n=u(t);for(const t of Object.keys(n))e[t]=n[t];return e}),{});else{if(!e)return;t=u(e)}const n=Object.entries(t).reduce(((e,[t,n])=>(t.match(c)&&(e[t.slice(a.length)]=n),e)),{});return Object.keys(n).length>0?n:void 0}function d(e){if(e)return function(e){if(0!==Object.keys(e).length)return Object.entries(e).reduce(((e,[t,n],o)=>{const r=`${encodeURIComponent(t)}=${encodeURIComponent(n)}`,a=0===o?r:`${e},${r}`;return a.length>l?(s.X&&i.kg.warn(`Not adding key: ${t} with val: ${n} to baggage header due to exceeding baggage size limits.`),e):a}),"")}(Object.entries(e).reduce(((e,[t,n])=>(n&&(e[`${a}${t}`]=n),e)),{}))}function u(e){return e.split(",").map((e=>e.split("=").map((e=>decodeURIComponent(e.trim()))))).reduce(((e,[t,n])=>(e[t]=n,e)),{})}},8464:(e,t,n)=>{"use strict";n.d(t,{Rt:()=>r,iY:()=>l,qT:()=>c});var s=n(7597);const o=(0,n(1235).Rf)(),i=80;function r(e,t={}){if(!e)return"";try{let n=e;const s=5,o=[];let r=0,c=0;const l=" > ",g=l.length;let d;const u=Array.isArray(t)?t:t.keyAttrs,h=!Array.isArray(t)&&t.maxStringLength||i;for(;n&&r++1&&c+o.length*g+d.length>=h));)o.push(d),c+=d.length,n=n.parentNode;return o.reverse().join(l)}catch(e){return""}}function a(e,t){const n=e,i=[];let r,a,c,l,g;if(!n||!n.tagName)return"";if(o.HTMLElement&&n instanceof HTMLElement&&n.dataset&&n.dataset.sentryComponent)return n.dataset.sentryComponent;i.push(n.tagName.toLowerCase());const d=t&&t.length?t.filter((e=>n.getAttribute(e))).map((e=>[e,n.getAttribute(e)])):null;if(d&&d.length)d.forEach((e=>{i.push(`[${e[0]}="${e[1]}"]`)}));else if(n.id&&i.push(`#${n.id}`),r=n.className,r&&(0,s.HD)(r))for(a=r.split(/\s+/),g=0;g{"use strict";function s(e){let t,n=e[0],s=1;for(;sn.call(t,...e))),t=void 0)}return n}n.d(t,{x:()=>s})},3897:(e,t,n)=>{"use strict";n.d(t,{X:()=>s});const s="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__},9729:(e,t,n)=>{"use strict";n.d(t,{D2:()=>l,Hj:()=>c,rK:()=>g});var s=n(3897),o=n(2343),i=n(6147);const r={},a={};function c(e,t){r[e]=r[e]||[],r[e].push(t)}function l(e,t){a[e]||(t(),a[e]=!0)}function g(e,t){const n=e&&r[e];if(n)for(const r of n)try{r(t)}catch(t){s.X&&o.kg.error(`Error while triggering instrumentation handler.\nType: ${e}\nName: ${(0,i.$P)(r)}\nError:`,t)}}},7597:(e,t,n)=>{"use strict";n.d(t,{Cy:()=>h,HD:()=>r,J8:()=>u,Kj:()=>d,PO:()=>c,V9:()=>p,VZ:()=>o,cO:()=>l,i2:()=>I,kK:()=>g,pt:()=>a,y1:()=>C});const s=Object.prototype.toString;function o(e){switch(s.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return!0;default:return p(e,Error)}}function i(e,t){return s.call(e)===`[object ${t}]`}function r(e){return i(e,"String")}function a(e){return null===e||"object"!=typeof e&&"function"!=typeof e}function c(e){return i(e,"Object")}function l(e){return"undefined"!=typeof Event&&p(e,Event)}function g(e){return"undefined"!=typeof Element&&p(e,Element)}function d(e){return i(e,"RegExp")}function u(e){return Boolean(e&&e.then&&"function"==typeof e.then)}function h(e){return c(e)&&"nativeEvent"in e&&"preventDefault"in e&&"stopPropagation"in e}function I(e){return"number"==typeof e&&e!=e}function p(e,t){try{return e instanceof t}catch(e){return!1}}function C(e){return!("object"!=typeof e||null===e||!e.__isVue&&!e._isVue)}},2343:(e,t,n)=>{"use strict";n.d(t,{Cf:()=>a,LD:()=>r,RU:()=>i,kg:()=>c});var s=n(3897),o=n(1235);const i=["debug","info","warn","error","log","assert","trace"],r={};function a(e){if(!("console"in o.n2))return e();const t=o.n2.console,n={},s=Object.keys(r);s.forEach((e=>{const s=r[e];n[e]=t[e],t[e]=s}));try{return e()}finally{s.forEach((e=>{t[e]=n[e]}))}}const c=function(){let e=!1;const t={enable:()=>{e=!0},disable:()=>{e=!1},isEnabled:()=>e};return s.X?i.forEach((n=>{t[n]=(...t)=>{e&&a((()=>{o.n2.console[n](`Sentry Logger [${n}]:`,...t)}))}})):i.forEach((e=>{t[e]=()=>{}})),t}()},3641:(e,t,n)=>{"use strict";n.d(t,{f:()=>s});class s{constructor(e){this._maxSize=e,this._cache=new Map}get size(){return this._cache.size}get(e){const t=this._cache.get(e);if(void 0!==t)return this._cache.delete(e),this._cache.set(e,t),t}set(e,t){this._cache.size>=this._maxSize&&this._cache.delete(this._cache.keys().next().value),this._cache.set(e,t)}remove(e){const t=this._cache.get(e);return t&&this._cache.delete(e),t}clear(){this._cache.clear()}keys(){return Array.from(this._cache.keys())}values(){const e=[];return this._cache.forEach((t=>e.push(t))),e}}},2844:(e,t,n)=>{"use strict";n.d(t,{DM:()=>r,Db:()=>l,EG:()=>g,J4:()=>u,YO:()=>I,go:()=>h,jH:()=>c,lE:()=>p});var s=n(535),o=n(7321),i=n(1235);function r(){const e=i.n2,t=e.crypto||e.msCrypto;let n=()=>16*Math.random();try{if(t&&t.randomUUID)return t.randomUUID().replace(/-/g,"");t&&t.getRandomValues&&(n=()=>{const e=new Uint8Array(1);return t.getRandomValues(e),e[0]})}catch(e){}return([1e7]+1e3+4e3+8e3+1e11).replace(/[018]/g,(e=>(e^(15&n())>>e/4).toString(16)))}function a(e){return e.exception&&e.exception.values?e.exception.values[0]:void 0}function c(e){const{message:t,event_id:n}=e;if(t)return t;const s=a(e);return s?s.type&&s.value?`${s.type}: ${s.value}`:s.type||s.value||n||"":n||""}function l(e,t,n){const s=e.exception=e.exception||{},o=s.values=s.values||[],i=o[0]=o[0]||{};i.value||(i.value=t||""),i.type||(i.type=n||"Error")}function g(e,t){const n=a(e);if(!n)return;const s=n.mechanism;if(n.mechanism={type:"generic",handled:!0,...s,...t},t&&"data"in t){const e={...s&&s.data,...t.data};n.mechanism.data=e}}const d=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;function u(e){const t=e.match(d)||[],n=parseInt(t[1],10),s=parseInt(t[2],10),o=parseInt(t[3],10);return{buildmetadata:t[5],major:isNaN(n)?void 0:n,minor:isNaN(s)?void 0:s,patch:isNaN(o)?void 0:o,prerelease:t[4]}}function h(e,t,n=5){if(void 0===t.lineno)return;const s=e.length,i=Math.max(Math.min(s-1,t.lineno-1),0);t.pre_context=e.slice(Math.max(0,i-n),i).map((e=>(0,o.JM)(e,0))),t.context_line=(0,o.JM)(e[Math.min(s-1,i)],t.colno||0),t.post_context=e.slice(Math.min(i+1,s),i+1+n).map((e=>(0,o.JM)(e,0)))}function I(e){if(e&&e.__sentry_captured__)return!0;try{(0,s.xp)(e,"__sentry_captured__",!0)}catch(e){}return!1}function p(e){return Array.isArray(e)?e:[e]}},2176:(e,t,n)=>{"use strict";function s(){return!("undefined"!=typeof __SENTRY_BROWSER_BUNDLE__&&__SENTRY_BROWSER_BUNDLE__)&&"[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0)}function o(e,t){return e.require(t)}function i(t){let n;try{n=o(e,t)}catch(e){}try{const{cwd:s}=o(e,"process");n=o(e,`${s()}/node_modules/${t}`)}catch(e){}return n}n.d(t,{l$:()=>o,KV:()=>s,$y:()=>i}),e=n.hmd(e)},8007:(e,t,n)=>{"use strict";n.d(t,{Fv:()=>r,Qy:()=>a});var s=n(7597),o=n(535),i=n(6147);function r(e,t=100,n=1/0){try{return c("",e,t,n)}catch(e){return{ERROR:`**non-serializable** (${e})`}}}function a(e,t=3,n=102400){const s=r(e,t);return o=s,function(e){return~-encodeURI(e).split(/%..|./).length}(JSON.stringify(o))>n?a(e,t-1,n):s;var o}function c(e,t,n=1/0,r=1/0,a=function(){const e="function"==typeof WeakSet,t=e?new WeakSet:[];return[function(n){if(e)return!!t.has(n)||(t.add(n),!1);for(let e=0;e=r){I[e]="[MaxProperties ~]";break}const t=C[e];I[e]=c(e,t,u-1,r,a),p++}return g(t),I}},535:(e,t,n)=>{"use strict";n.d(t,{HK:()=>g,Jr:()=>C,Sh:()=>u,_j:()=>d,hl:()=>c,xp:()=>l,zf:()=>p});var s=n(8464),o=n(3897),i=n(7597),r=n(2343),a=n(7321);function c(e,t,n){if(!(t in e))return;const s=e[t],o=n(s);"function"==typeof o&&function(e,t){try{const n=t.prototype||{};e.prototype=t.prototype=n,l(e,"__sentry_original__",t)}catch(e){}}(o,s),e[t]=o}function l(e,t,n){try{Object.defineProperty(e,t,{value:n,writable:!0,configurable:!0})}catch(n){o.X&&r.kg.log(`Failed to add non-enumerable property "${t}" to object`,e)}}function g(e){return e.__sentry_original__}function d(e){return Object.keys(e).map((t=>`${encodeURIComponent(t)}=${encodeURIComponent(e[t])}`)).join("&")}function u(e){if((0,i.VZ)(e))return{message:e.message,name:e.name,stack:e.stack,...I(e)};if((0,i.cO)(e)){const t={type:e.type,target:h(e.target),currentTarget:h(e.currentTarget),...I(e)};return"undefined"!=typeof CustomEvent&&(0,i.V9)(e,CustomEvent)&&(t.detail=e.detail),t}return e}function h(e){try{return(0,i.kK)(e)?(0,s.Rt)(e):Object.prototype.toString.call(e)}catch(e){return""}}function I(e){if("object"==typeof e&&null!==e){const t={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}return{}}function p(e,t=40){const n=Object.keys(u(e));if(n.sort(),!n.length)return"[object has no keys]";if(n[0].length>=t)return(0,a.$G)(n[0],t);for(let e=n.length;e>0;e--){const s=n.slice(0,e).join(", ");if(!(s.length>t))return e===n.length?s:(0,a.$G)(s,t)}return""}function C(e){return m(e,new Map)}function m(e,t){if((0,i.PO)(e)){const n=t.get(e);if(void 0!==n)return n;const s={};t.set(e,s);for(const n of Object.keys(e))void 0!==e[n]&&(s[n]=m(e[n],t));return s}if(Array.isArray(e)){const n=t.get(e);if(void 0!==n)return n;const s=[];return t.set(e,s),e.forEach((e=>{s.push(m(e,t))})),s}return e}},771:(e,t,n)=>{"use strict";n.d(t,{rC:()=>c,S6:()=>u,dB:()=>l,oA:()=>g,XQ:()=>d});var s=n(7597),o=n(8007),i=n(6956);const r={ip:!1,request:!0,transaction:!0,user:!0},a=["cookies","data","headers","method","query_string","url"],c=["id","username","email"];function l(e,t,n){if(e){if(!e.metadata.source||"url"===e.metadata.source){const[n,s]=g(t,{path:!0,method:!0});e.updateName(n),e.setMetadata({source:s})}e.setData("url",t.originalUrl||t.url),t.baseUrl&&e.setData("baseUrl",t.baseUrl),e.setData("query",h(t,n))}}function g(e,t={}){const n=e.method&&e.method.toUpperCase();let s="",o="url";t.customRoute||e.route?(s=t.customRoute||`${e.baseUrl||""}${e.route&&e.route.path}`,o="route"):(e.originalUrl||e.url)&&(s=(0,i.rt)(e.originalUrl||e.url||""));let r="";return t.method&&n&&(r+=n),t.method&&t.path&&(r+=" "),t.path&&s&&(r+=s),[r,o]}function d(e,t){const{include:n=a,deps:i}=t||{},r={},c=e.headers||{},l=e.method,g=c.host||e.hostname||e.host||"",d="https"===e.protocol||e.socket&&e.socket.encrypted?"https":"http",u=e.originalUrl||e.url||"",I=u.startsWith(d)?u:`${d}://${g}${u}`;return n.forEach((t=>{switch(t){case"headers":r.headers=c,n.includes("cookies")||delete r.headers.cookie;break;case"method":r.method=l;break;case"url":r.url=I;break;case"cookies":r.cookies=e.cookies||c.cookie&&function(e){const t={};let n=0;for(;n{e&&t in e&&(n[t]=e[t])})),n}(t.user,o.user):{};Object.keys(n).length&&(e.user={...e.user,...n})}if(o.ip){const n=t.ip||t.socket&&t.socket.remoteAddress;n&&(e.user={...e.user,ip_address:n})}return o.transaction&&!e.transaction&&(e.transaction=function(e,t){switch(t){case"path":return g(e,{path:!0})[0];case"handler":return e.route&&e.route.stack&&e.route.stack[0]&&e.route.stack[0].name||"";default:return g(e,{path:!0,method:!0,customRoute:e._reconstructedRoute?e._reconstructedRoute:void 0})[0]}}(t,o.transaction)),e}function h(e,t){let n=e.originalUrl||e.url||"";if(n){n.startsWith("/")&&(n=`http://dogs.are.great${n}`);try{return e.query||"undefined"!=typeof URL&&new URL(n).search.slice(1)||t&&t.url&&t.url.parse(n).query||void 0}catch(e){return}}}},6147:(e,t,n)=>{"use strict";function s(e,t=!1){return!(t||e&&!e.startsWith("/")&&!e.includes(":\\")&&!e.startsWith(".")&&!e.match(/^[a-zA-Z]([a-zA-Z0-9.\-+])*:\/\//)||void 0===e||e.includes("node_modules/"))}function o(e){const t=/^\s*[-]{4,}$/,n=/at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/;return o=>{const i=o.match(n);if(i){let t,n,o,r,a;if(i[1]){o=i[1];let e=o.lastIndexOf(".");if("."===o[e-1]&&e--,e>0){t=o.slice(0,e),n=o.slice(e+1);const s=t.indexOf(".Module");s>0&&(o=o.slice(s+1),t=t.slice(0,s))}r=void 0}n&&(r=t,a=n),""===n&&(a=void 0,o=void 0),void 0===o&&(a=a||"",o=r?`${r}.${a}`:a);let c=i[2]&&i[2].startsWith("file://")?i[2].slice(7):i[2];const l="native"===i[5];return c||!i[5]||l||(c=i[5]),{filename:c,module:e?e(c):void 0,function:o,lineno:parseInt(i[3],10)||void 0,colno:parseInt(i[4],10)||void 0,in_app:s(c,l)}}if(o.match(t))return{filename:o}}}n.d(t,{pE:()=>c,$P:()=>d,Ep:()=>u,Sq:()=>l});const i=50,r=/\(error: (.*)\)/,a=/captureMessage|captureException/;function c(...e){const t=e.sort(((e,t)=>e[0]-t[0])).map((e=>e[1]));return(e,n=0)=>{const s=[],o=e.split("\n");for(let e=n;e1024)continue;const a=r.test(n)?n.replace(r,"$1"):n;if(!a.match(/\S*Error: /)){for(const e of t){const t=e(a);if(t){s.push(t);break}}if(s.length>=i)break}}return function(e){if(!e.length)return[];const t=Array.from(e);return/sentryWrapped/.test(t[t.length-1].function||"")&&t.pop(),t.reverse(),a.test(t[t.length-1].function||"")&&(t.pop(),a.test(t[t.length-1].function||"")&&t.pop()),t.slice(0,i).map((e=>({...e,filename:e.filename||t[t.length-1].filename,function:e.function||"?"})))}(s)}}function l(e){return Array.isArray(e)?c(...e):e}const g="";function d(e){try{return e&&"function"==typeof e&&e.name||g}catch(e){return g}}function u(e){return[90,o(e)]}},7321:(e,t,n)=>{"use strict";n.d(t,{$G:()=>o,JM:()=>i,U0:()=>r});var s=n(7597);function o(e,t=0){return"string"!=typeof e||0===t||e.length<=t?e:`${e.slice(0,t)}...`}function i(e,t){let n=e;const s=n.length;if(s<=150)return n;t>s&&(t=s);let o=Math.max(t-60,0);o<5&&(o=0);let i=Math.min(o+140,s);return i>s-5&&(i=s),i===s&&(o=Math.max(i-140,0)),n=n.slice(o,i),o>0&&(n=`'{snip} ${n}`),ifunction(e,t,n=!1){return!!(0,s.HD)(e)&&((0,s.Kj)(t)?t.test(e):!!(0,s.HD)(t)&&(n?e===t:e.includes(t)))}(e,t,n)))}},6893:(e,t,n)=>{"use strict";n.d(t,{$2:()=>r,WD:()=>i,cW:()=>a});var s,o=n(7597);function i(e){return new a((t=>{t(e)}))}function r(e){return new a(((t,n)=>{n(e)}))}!function(e){e[e.PENDING=0]="PENDING",e[e.RESOLVED=1]="RESOLVED",e[e.REJECTED=2]="REJECTED"}(s||(s={}));class a{constructor(e){a.prototype.__init.call(this),a.prototype.__init2.call(this),a.prototype.__init3.call(this),a.prototype.__init4.call(this),this._state=s.PENDING,this._handlers=[];try{e(this._resolve,this._reject)}catch(e){this._reject(e)}}then(e,t){return new a(((n,s)=>{this._handlers.push([!1,t=>{if(e)try{n(e(t))}catch(e){s(e)}else n(t)},e=>{if(t)try{n(t(e))}catch(e){s(e)}else s(e)}]),this._executeHandlers()}))}catch(e){return this.then((e=>e),e)}finally(e){return new a(((t,n)=>{let s,o;return this.then((t=>{o=!1,s=t,e&&e()}),(t=>{o=!0,s=t,e&&e()})).then((()=>{o?n(s):t(s)}))}))}__init(){this._resolve=e=>{this._setResult(s.RESOLVED,e)}}__init2(){this._reject=e=>{this._setResult(s.REJECTED,e)}}__init3(){this._setResult=(e,t)=>{this._state===s.PENDING&&((0,o.J8)(t)?t.then(this._resolve,this._reject):(this._state=e,this._value=t,this._executeHandlers()))}}__init4(){this._executeHandlers=()=>{if(this._state===s.PENDING)return;const e=this._handlers.slice();this._handlers=[],e.forEach((e=>{e[0]||(this._state===s.RESOLVED&&e[1](this._value),this._state===s.REJECTED&&e[2](this._value),e[0]=!0)}))}}}},1170:(e,t,n)=>{"use strict";n.d(t,{Z1:()=>u,ph:()=>g,yW:()=>l});var s=n(2176),o=n(1235);e=n.hmd(e);const i=(0,o.Rf)(),r={nowSeconds:()=>Date.now()/1e3},a=(0,s.KV)()?function(){try{return(0,s.l$)(e,"perf_hooks").performance}catch(e){return}}():function(){const{performance:e}=i;if(e&&e.now)return{now:()=>e.now(),timeOrigin:Date.now()-e.now()}}(),c=void 0===a?r:{nowSeconds:()=>(a.timeOrigin+a.now())/1e3},l=r.nowSeconds.bind(r),g=c.nowSeconds.bind(c);let d;const u=(()=>{const{performance:e}=i;if(!e||!e.now)return void(d="none");const t=36e5,n=e.now(),s=Date.now(),o=e.timeOrigin?Math.abs(e.timeOrigin+n-s):t,r=o{"use strict";n.d(t,{$p:()=>c,KA:()=>a,Ke:()=>i,qG:()=>r});var s=n(9181),o=n(2844);const i=new RegExp("^[ \\t]*([0-9a-f]{32})?-?([0-9a-f]{16})?-?([01])?[ \\t]*$");function r(e){if(!e)return;const t=e.match(i);if(!t)return;let n;return"1"===t[3]?n=!0:"0"===t[3]&&(n=!1),{traceId:t[1],parentSampled:n,parentSpanId:t[2]}}function a(e,t){const n=r(e),i=(0,s.EN)(t),{traceId:a,parentSpanId:c,parentSampled:l}=n||{},g={traceId:a||(0,o.DM)(),spanId:(0,o.DM)().substring(16),sampled:l};return c&&(g.parentSpanId=c),i&&(g.dsc=i),{traceparentData:n,dynamicSamplingContext:i,propagationContext:g}}function c(e=(0,o.DM)(),t=(0,o.DM)().substring(16),n){let s="";return void 0!==n&&(s=n?"-1":"-0"),`${e}-${t}${s}`}},6956:(e,t,n)=>{"use strict";function s(e){if(!e)return{};const t=e.match(/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!t)return{};const n=t[6]||"",s=t[8]||"";return{host:t[4],path:t[5],protocol:t[2],search:n,hash:s,relative:t[5]+n+s}}function o(e){return e.split(/[\?#]/,1)[0]}function i(e){return e.split(/\\?\//).filter((e=>e.length>0&&","!==e)).length}function r(e){const{protocol:t,host:n,path:s}=e;return`${t?`${t}://`:""}${n&&n.replace(/^.*@/,"[filtered]:[filtered]@").replace(/(:80)$/,"").replace(/(:443)$/,"")||""}${s}`}n.d(t,{$A:()=>i,en:()=>s,rt:()=>o,tF:()=>r})},1235:(e,t,n)=>{"use strict";function s(e){return e&&e.Math==Math?e:void 0}n.d(t,{Rf:()=>i,YO:()=>r,n2:()=>o});const o="object"==typeof globalThis&&s(globalThis)||"object"==typeof window&&s(window)||"object"==typeof self&&s(self)||"object"==typeof global&&s(global)||function(){return this}()||{};function i(){return o}function r(e,t,n){const s=n||o,i=s.__SENTRY__=s.__SENTRY__||{};return i[e]||(i[e]=t())}},8054:function(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const o=n(2361),i=s(n(5158)),r=s(n(6304)),a=i.default("agent-base");function c(){const{stack:e}=new Error;return"string"==typeof e&&e.split("\n").some((e=>-1!==e.indexOf("(https.js:")||-1!==e.indexOf("node:https:")))}function l(e,t){return new l.Agent(e,t)}!function(e){class t extends o.EventEmitter{constructor(e,t){super();let n=t;"function"==typeof e?this.callback=e:e&&(n=e),this.timeout=null,n&&"number"==typeof n.timeout&&(this.timeout=n.timeout),this.maxFreeSockets=1,this.maxSockets=1,this.maxTotalSockets=1/0,this.sockets={},this.freeSockets={},this.requests={},this.options={}}get defaultPort(){return"number"==typeof this.explicitDefaultPort?this.explicitDefaultPort:c()?443:80}set defaultPort(e){this.explicitDefaultPort=e}get protocol(){return"string"==typeof this.explicitProtocol?this.explicitProtocol:c()?"https:":"http:"}set protocol(e){this.explicitProtocol=e}callback(e,t,n){throw new Error('"agent-base" has no default implementation, you must subclass and override `callback()`')}addRequest(e,t){const n=Object.assign({},t);"boolean"!=typeof n.secureEndpoint&&(n.secureEndpoint=c()),null==n.host&&(n.host="localhost"),null==n.port&&(n.port=n.secureEndpoint?443:80),null==n.protocol&&(n.protocol=n.secureEndpoint?"https:":"http:"),n.host&&n.path&&delete n.path,delete n.agent,delete n.hostname,delete n._defaultAgent,delete n.defaultPort,delete n.createConnection,e._last=!0,e.shouldKeepAlive=!1;let s=!1,o=null;const i=n.timeout||this.timeout,l=t=>{e._hadError||(e.emit("error",t),e._hadError=!0)},g=()=>{o=null,s=!0;const e=new Error(`A "socket" was not created for HTTP request before ${i}ms`);e.code="ETIMEOUT",l(e)},d=e=>{s||(null!==o&&(clearTimeout(o),o=null),l(e))},u=t=>{if(s)return;if(null!=o&&(clearTimeout(o),o=null),i=t,Boolean(i)&&"function"==typeof i.addRequest)return a("Callback returned another Agent instance %o",t.constructor.name),void t.addRequest(e,n);var i;if(t)return t.once("free",(()=>{this.freeSocket(t,n)})),void e.onSocket(t);const r=new Error(`no Duplex stream was returned to agent-base for \`${e.method} ${e.path}\``);l(r)};if("function"==typeof this.callback){this.promisifiedCallback||(this.callback.length>=3?(a("Converting legacy callback function to promise"),this.promisifiedCallback=r.default(this.callback)):this.promisifiedCallback=this.callback),"number"==typeof i&&i>0&&(o=setTimeout(g,i)),"port"in n&&"number"!=typeof n.port&&(n.port=Number(n.port));try{a("Resolving socket for %o request: %o",n.protocol,`${e.method} ${e.path}`),Promise.resolve(this.promisifiedCallback(e,n)).then(u,d)}catch(e){Promise.reject(e).catch(d)}}else l(new Error("`callback` is not defined"))}freeSocket(e,t){a("Freeing socket %o %o",e.constructor.name,t),e.destroy()}destroy(){a("Destroying agent %o",this.constructor.name)}}e.Agent=t,e.prototype=e.Agent.prototype}(l||(l={})),e.exports=l},6304:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return function(t,n){return new Promise(((s,o)=>{e.call(this,t,n,((e,t)=>{e?o(e):s(t)}))}))}}},1227:(e,t,n)=>{t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let s=0,o=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(s++,"%c"===e&&(o=s))})),t.splice(o,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=n(2447)(t);const{formatters:s}=e.exports;s.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},2447:(e,t,n)=>{e.exports=function(e){function t(e){let n,o,i,r=null;function a(...e){if(!a.enabled)return;const s=a,o=Number(new Date),i=o-(n||o);s.diff=i,s.prev=n,s.curr=o,n=o,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let r=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,o)=>{if("%%"===n)return"%";r++;const i=t.formatters[o];if("function"==typeof i){const t=e[r];n=i.call(s,t),e.splice(r,1),r--}return n})),t.formatArgs.call(s,e),(s.log||t.log).apply(s,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=s,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==r?r:(o!==t.namespaces&&(o=t.namespaces,i=t.enabled(e)),i),set:e=>{r=e}}),"function"==typeof t.init&&t.init(a),a}function s(e,n){const s=t(this.namespace+(void 0===n?":":n)+e);return s.log=this.log,s}function o(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names.map(o),...t.skips.map(o).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const s=("string"==typeof e?e:"").split(/[\s,]+/),o=s.length;for(n=0;n{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t{"undefined"==typeof process||"renderer"===process.type||!0===process.browser||process.__nwjs?e.exports=n(1227):e.exports=n(39)},39:(e,t,n)=>{const s=n(6224),o=n(3837);t.init=function(e){e.inspectOpts={};const n=Object.keys(t.inspectOpts);for(let s=0;s{}),"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),t.colors=[6,2,3,4,5,1];try{const e=n(2130);e&&(e.stderr||e).level>=2&&(t.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(e){}t.inspectOpts=Object.keys(process.env).filter((e=>/^debug_/i.test(e))).reduce(((e,t)=>{const n=t.substring(6).toLowerCase().replace(/_([a-z])/g,((e,t)=>t.toUpperCase()));let s=process.env[t];return s=!!/^(yes|on|true|enabled)$/i.test(s)||!/^(no|off|false|disabled)$/i.test(s)&&("null"===s?null:Number(s)),e[n]=s,e}),{}),e.exports=n(2447)(t);const{formatters:i}=e.exports;i.o=function(e){return this.inspectOpts.colors=this.useColors,o.inspect(e,this.inspectOpts).split("\n").map((e=>e.trim())).join(" ")},i.O=function(e){return this.inspectOpts.colors=this.useColors,o.inspect(e,this.inspectOpts)}},346:(e,t,n)=>{"use strict";const{Transform:s,PassThrough:o}=n(2781),i=n(9796),r=n(6344);e.exports=e=>{const t=(e.headers["content-encoding"]||"").toLowerCase();if(!["gzip","deflate","br"].includes(t))return e;const n="br"===t;if(n&&"function"!=typeof i.createBrotliDecompress)return e.destroy(new Error("Brotli is not supported on Node.js < 12")),e;let a=!0;const c=new s({transform(e,t,n){a=!1,n(null,e)},flush(e){e()}}),l=new o({autoDestroy:!1,destroy(t,n){e.destroy(),n(t)}}),g=n?i.createBrotliDecompress():i.createUnzip();return g.once("error",(t=>{!a||e.readable?l.destroy(t):l.end()})),r(e,l),e.pipe(c).pipe(g).pipe(l),l}},1313:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=(e,t)=>{let n;n="function"==typeof t?{connect:t}:t;const s="function"==typeof n.connect,o="function"==typeof n.secureConnect,i="function"==typeof n.close,r=()=>{s&&n.connect(),function(e){return e.encrypted}(e)&&o&&(e.authorized?n.secureConnect():e.authorizationError||e.once("secureConnect",n.secureConnect)),i&&e.once("close",n.close)};e.writable&&!e.connecting?r():e.connecting?e.once("connect",r):e.destroyed&&i&&n.close(e._hadError)};t.default=n,e.exports=n,e.exports.default=n},2559:e=>{!function(){"use strict";var t=[,function(e,t){function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,s=new Array(t);n255)throw new Error("Not ascii. Base64.encode can only take ascii strings.");e[n]=o}}for(var r=[],a=null,c=null,l=null,g=null,d=0;d>2&63,c=(3&e[d])<<4;break;case 1:c|=e[d]>>4&15,l=(15&e[d])<<2;break;case 2:l|=e[d]>>6&3,g=63&e[d],r.push(s(a)),r.push(s(c)),r.push(s(l)),r.push(s(g)),a=null,c=null,l=null,g=null}return null!=a&&(r.push(s(a)),r.push(s(c)),null==l?r.push("="):r.push(s(l)),null==g&&r.push("=")),r.join("")},decode:function(e){var t=Math.floor(3*e.length/4);"="==e.charAt(e.length-1)&&(t--,"="==e.charAt(e.length-2)&&t--);for(var s,o=i(t),r=null,a=null,c=null,l=0,g=0;g>4,o[l++]=r,a=(15&d)<<4;break;case 2:d>=0&&(a|=d>>2,o[l++]=a,c=(3&d)<<6);break;case 3:d>=0&&(o[l++]=c|d)}}return o},newBinary:i};t.Base64=r},function(e){e.exports={_noYieldsAllowed:function(e){return e()}}},function(e,t){function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function s(e){return JSON.stringify(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=function e(t,o,i,r,a){var c=o[t];switch(n(c)){case"string":return s(c);case"number":return isFinite(c)?String(c):"null";case"boolean":return String(c);case"object":if(!c)return"null";var l,g=r+i,d=[];if(Array.isArray(c)||{}.hasOwnProperty.call(c,"callee")){for(var u=c.length,h=0;h0&&void 0!==arguments[0]&&arguments[0]?a:(0,i.convertMapToObject)(a)},r._getConverters=function(){return c};var l=function(e){for(var t=0;t=d.length||o!==d[s]||!r.equals(e[o],t[d[s]],n)||(s++,0))}))):(s=0,a=g.every((function(o){return!!(0,i.hasOwn)(t,o)&&!!r.equals(e[o],t[o],n)&&(s++,!0)}))),a&&s===d.length},r.clone=function(e){var t;if(!(0,i.isObject)(e))return e;if(null===e)return null;if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp)return e;if(r.isBinary(e)){t=r.newBinary(e.length);for(var n=0;n{"use strict";var t=Object.prototype.hasOwnProperty,n="~";function s(){}function o(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function i(e,t,s,i,r){if("function"!=typeof s)throw new TypeError("The listener must be a function");var a=new o(s,i||e,r),c=n?n+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],a]:e._events[c].push(a):(e._events[c]=a,e._eventsCount++),e}function r(e,t){0==--e._eventsCount?e._events=new s:delete e._events[t]}function a(){this._events=new s,this._eventsCount=0}Object.create&&(s.prototype=Object.create(null),(new s).__proto__||(n=!1)),a.prototype.eventNames=function(){var e,s,o=[];if(0===this._eventsCount)return o;for(s in e=this._events)t.call(e,s)&&o.push(n?s.slice(1):s);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},a.prototype.listeners=function(e){var t=n?n+e:e,s=this._events[t];if(!s)return[];if(s.fn)return[s.fn];for(var o=0,i=s.length,r=new Array(i);o{"use strict";e.exports=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){if(t.constructor!==n.constructor)return!1;var s,o,i;if(Array.isArray(t)){if((s=t.length)!=n.length)return!1;for(o=s;0!=o--;)if(!e(t[o],n[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if((s=(i=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(o=s;0!=o--;)if(!Object.prototype.hasOwnProperty.call(n,i[o]))return!1;for(o=s;0!=o--;){var r=i[o];if(!e(t[r],n[r]))return!1}return!0}return t!=t&&n!=n}},5105:(e,t,n)=>{"use strict";const{PassThrough:s}=n(2781);e.exports=e=>{e={...e};const{array:t}=e;let{encoding:n}=e;const o="buffer"===n;let i=!1;t?i=!(n||o):n=n||"utf8",o&&(n=null);const r=new s({objectMode:i});n&&r.setEncoding(n);let a=0;const c=[];return r.on("data",(e=>{c.push(e),i?a=c.length:a+=e.length})),r.getBufferedValue=()=>t?c:o?Buffer.concat(c,a):c.join(""),r.getBufferedLength=()=>a,r}},31:(e,t,n)=>{"use strict";const{constants:s}=n(4300),o=n(2781),{promisify:i}=n(3837),r=n(5105),a=i(o.pipeline);class c extends Error{constructor(){super("maxBuffer exceeded"),this.name="MaxBufferError"}}async function l(e,t){if(!e)throw new Error("Expected a stream");t={maxBuffer:1/0,...t};const{maxBuffer:n}=t,o=r(t);return await new Promise(((t,i)=>{const r=e=>{e&&o.getBufferedLength()<=s.MAX_LENGTH&&(e.bufferedData=o.getBufferedValue()),i(e)};(async()=>{try{await a(e,o),t()}catch(e){r(e)}})(),o.on("data",(()=>{o.getBufferedLength()>n&&r(new c)}))})),o.getBufferedValue()}e.exports=l,e.exports.buffer=(e,t)=>l(e,{...t,encoding:"buffer"}),e.exports.array=(e,t)=>l(e,{...t,array:!0}),e.exports.MaxBufferError=c},6560:e=>{"use strict";e.exports=(e,t=process.argv)=>{const n=e.startsWith("-")?"":1===e.length?"-":"--",s=t.indexOf(n+e),o=t.indexOf("--");return-1!==s&&(-1===o||s{"use strict";const t=new Set([200,203,204,206,300,301,308,404,405,410,414,501]),n=new Set([200,203,204,300,301,302,303,307,308,404,405,410,414,501]),s=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},i={"content-length":!0,"content-encoding":!0,"transfer-encoding":!0,"content-range":!0};function r(e){const t=parseInt(e,10);return isFinite(t)?t:0}function a(e){const t={};if(!e)return t;const n=e.trim().split(/,/);for(const e of n){const[n,s]=e.split(/=/,2);t[n.trim()]=void 0===s||s.trim().replace(/^"|"$/g,"")}return t}function c(e){let t=[];for(const n in e){const s=e[n];t.push(!0===s?n:n+"="+s)}if(t.length)return t.join(", ")}e.exports=class{constructor(e,t,{shared:n,cacheHeuristic:s,immutableMinTimeToLive:o,ignoreCargoCult:i,_fromObject:r}={}){if(r)this._fromObject(r);else{if(!t||!t.headers)throw Error("Response headers missing");this._assertRequestHasHeaders(e),this._responseTime=this.now(),this._isShared=!1!==n,this._cacheHeuristic=void 0!==s?s:.1,this._immutableMinTtl=void 0!==o?o:864e5,this._status="status"in t?t.status:200,this._resHeaders=t.headers,this._rescc=a(t.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=t.headers.vary?e.headers:null,this._reqcc=a(e.headers["cache-control"]),i&&"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":c(this._rescc)}),delete this._resHeaders.expires,delete this._resHeaders.pragma),null==t.headers["cache-control"]&&/no-cache/.test(t.headers.pragma)&&(this._rescc["no-cache"]=!0)}}now(){return Date.now()}storable(){return!(this._reqcc["no-store"]||!("GET"===this._method||"HEAD"===this._method||"POST"===this._method&&this._hasExplicitExpiration())||!n.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||t.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){this._assertRequestHasHeaders(e);const t=a(e.headers["cache-control"]);return!t["no-cache"]&&!/no-cache/.test(e.headers.pragma)&&(!(t["max-age"]&&this.age()>t["max-age"])&&(!(t["min-fresh"]&&this.timeToLive()<1e3*t["min-fresh"])&&(!(this.stale()&&(!t["max-stale"]||this._rescc["must-revalidate"]||!(!0===t["max-stale"]||t["max-stale"]>this.age()-this.maxAge())))&&this._requestMatches(e,!1))))}_requestMatches(e,t){return(!this._url||this._url===e.url)&&this._host===e.headers.host&&(!e.method||this._method===e.method||t&&"HEAD"===e.method)&&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;const t=this._resHeaders.vary.trim().toLowerCase().split(/\s*,\s*/);for(const n of t)if(e.headers[n]!==this._reqHeaders[n])return!1;return!0}_copyWithoutHopByHopHeaders(e){const t={};for(const n in e)o[n]||(t[n]=e[n]);if(e.connection){const n=e.connection.trim().split(/\s*,\s*/);for(const e of n)delete t[e]}if(t.warning){const e=t.warning.split(/,/).filter((e=>!/^\s*1[0-9][0-9]/.test(e)));e.length?t.warning=e.join(",").trim():delete t.warning}return t}responseHeaders(){const e=this._copyWithoutHopByHopHeaders(this._resHeaders),t=this.age();return t>86400&&!this._hasExplicitExpiration()&&this.maxAge()>86400&&(e.warning=(e.warning?`${e.warning}, `:"")+'113 - "rfc7234 5.5.4"'),e.age=`${Math.round(t)}`,e.date=new Date(this.now()).toUTCString(),e}date(){const e=Date.parse(this._resHeaders.date);return isFinite(e)?e:this._responseTime}age(){return this._ageValue()+(this.now()-this._responseTime)/1e3}_ageValue(){return r(this._resHeaders.age)}maxAge(){if(!this.storable()||this._rescc["no-cache"])return 0;if(this._isShared&&this._resHeaders["set-cookie"]&&!this._rescc.public&&!this._rescc.immutable)return 0;if("*"===this._resHeaders.vary)return 0;if(this._isShared){if(this._rescc["proxy-revalidate"])return 0;if(this._rescc["s-maxage"])return r(this._rescc["s-maxage"])}if(this._rescc["max-age"])return r(this._rescc["max-age"]);const e=this._rescc.immutable?this._immutableMinTtl:0,t=this.date();if(this._resHeaders.expires){const n=Date.parse(this._resHeaders.expires);return Number.isNaN(n)||nn)return Math.max(e,(t-n)/1e3*this._cacheHeuristic)}return e}timeToLive(){const e=this.maxAge()-this.age(),t=e+r(this._rescc["stale-if-error"]),n=e+r(this._rescc["stale-while-revalidate"]);return 1e3*Math.max(0,e,t,n)}stale(){return this.maxAge()<=this.age()}_useStaleIfError(){return this.maxAge()+r(this._rescc["stale-if-error"])>this.age()}useStaleWhileRevalidate(){return this.maxAge()+r(this._rescc["stale-while-revalidate"])>this.age()}static fromObject(e){return new this(void 0,void 0,{_fromObject:e})}_fromObject(e){if(this._responseTime)throw Error("Reinitialized");if(!e||1!==e.v)throw Error("Invalid serialization");this._responseTime=e.t,this._isShared=e.sh,this._cacheHeuristic=e.ch,this._immutableMinTtl=void 0!==e.imm?e.imm:864e5,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,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);const t=this._copyWithoutHopByHopHeaders(e.headers);if(delete t["if-range"],!this._requestMatches(e,!0)||!this.storable())return delete t["if-none-match"],delete t["if-modified-since"],t;if(this._resHeaders.etag&&(t["if-none-match"]=t["if-none-match"]?`${t["if-none-match"]}, ${this._resHeaders.etag}`:this._resHeaders.etag),t["accept-ranges"]||t["if-match"]||t["if-unmodified-since"]||this._method&&"GET"!=this._method){if(delete t["if-modified-since"],t["if-none-match"]){const e=t["if-none-match"].split(/,/).filter((e=>!/^\s*W\//.test(e)));e.length?t["if-none-match"]=e.join(",").trim():delete t["if-none-match"]}}else this._resHeaders["last-modified"]&&!t["if-modified-since"]&&(t["if-modified-since"]=this._resHeaders["last-modified"]);return t}revalidatedPolicy(e,t){if(this._assertRequestHasHeaders(e),this._useStaleIfError()&&function(e){return!e||s.has(e.status)}(t))return{modified:!1,matches:!1,policy:this};if(!t||!t.headers)throw Error("Response headers missing");let n=!1;if(void 0!==t.status&&304!=t.status?n=!1:t.headers.etag&&!/^\s*W\//.test(t.headers.etag)?n=this._resHeaders.etag&&this._resHeaders.etag.replace(/^\s*W\//,"")===t.headers.etag:this._resHeaders.etag&&t.headers.etag?n=this._resHeaders.etag.replace(/^\s*W\//,"")===t.headers.etag.replace(/^\s*W\//,""):this._resHeaders["last-modified"]?n=this._resHeaders["last-modified"]===t.headers["last-modified"]:this._resHeaders.etag||this._resHeaders["last-modified"]||t.headers.etag||t.headers["last-modified"]||(n=!0),!n)return{policy:new this.constructor(e,t),modified:304!=t.status,matches:!1};const o={};for(const e in this._resHeaders)o[e]=e in t.headers&&!i[e]?t.headers[e]:this._resHeaders[e];const r=Object.assign({},t,{status:this._status,method:this._method,headers:o});return{policy:new this.constructor(e,r,{shared:this._isShared,cacheHeuristic:this._cacheHeuristic,immutableMinTimeToLive:this._immutableMinTtl}),modified:!1,matches:!0}}}},4685:(e,t,n)=>{"use strict";const{URL:s}=n(7310),o=n(2361),i=n(4404),r=n(6281),a=n(1269),c=n(8120),l=Symbol("currentStreamCount"),g=Symbol("request"),d=Symbol("cachedOriginSet"),u=Symbol("gracefullyClosing"),h=Symbol("length"),I=["createConnection","maxDeflateDynamicTableSize","maxSettings","maxSessionMemory","maxHeaderListPairs","maxOutstandingPings","maxReservedRemoteStreams","maxSendHeaderBlockLength","paddingStrategy","peerMaxConcurrentStreams","settings","family","localAddress","rejectUnauthorized","pskCallback","minDHSize","path","socket","ca","cert","sigalgs","ciphers","clientCertEngine","crl","dhparam","ecdhCurve","honorCipherOrder","key","privateKeyEngine","privateKeyIdentifier","maxVersion","minVersion","pfx","secureOptions","secureProtocol","sessionIdContext","ticketKeys"],p=(e,t)=>e.remoteSettings.maxConcurrentStreams>t.remoteSettings.maxConcurrentStreams,C=(e,t)=>{for(let n=0;n0&&s[d].lengtht[d].includes(e)))&&s[l]+t[l]<=t.remoteSettings.maxConcurrentStreams&&b(s)}},m=(e,t)=>{for(let n=0;n0&&t[d].lengths[d].includes(e)))&&t[l]+s[l]<=s.remoteSettings.maxConcurrentStreams)return b(t),!0}return!1},b=e=>{e[u]=!0,0===e[l]&&e.close()};class y extends o{constructor({timeout:e=0,maxSessions:t=Number.POSITIVE_INFINITY,maxEmptySessions:n=10,maxCachedTlsSessions:s=100}={}){super(),this.sessions={},this.queue={},this.timeout=e,this.maxSessions=t,this.maxEmptySessions=n,this._emptySessionCount=0,this._sessionCount=0,this.settings={enablePush:!1,initialWindowSize:33554432},this.tlsSessionCache=new a({maxSize:s})}get protocol(){return"https:"}normalizeOptions(e){let t="";for(let n=0;n=this.maxSessions)this.closeEmptySessions(this.maxSessions-this._sessionCount+1);else for(const e in this.queue)for(const t in this.queue[e]){const n=this.queue[e][t];n.completed||(n.completed=!0,n())}}_isBetterSession(e,t){return e>t}_accept(e,t,n,s){let o=0;for(;o0&&(this.getSession(n,s,t),t.length=0)}getSession(e,t,n){return new Promise(((o,i)=>{Array.isArray(n)&&n.length>0?(n=[...n],o()):n=[{resolve:o,reject:i}];try{if("string"==typeof e)e=new s(e);else if(!(e instanceof s))throw new TypeError("The `origin` argument needs to be a string or an URL object");if(t){const{servername:n}=t,{hostname:s}=e;if(n&&s!==n)throw new Error(`Origin ${s} differs from servername ${n}`)}}catch(e){for(let t=0;t=r||n[u]||n.destroyed||(s||(o=r),this._isBetterSession(a,i)&&(s=n,i=a))}if(s)return void this._accept(s,n,c,t)}if(a in this.queue){if(c in this.queue[a])return void this.queue[a][c].listeners.push(...n)}else this.queue[a]={[h]:0};const I=()=>{a in this.queue&&this.queue[a][c]===b&&(delete this.queue[a][c],0==--this.queue[a][h]&&delete this.queue[a])},b=async()=>{this._sessionCount++;const s=`${c}:${a}`;let o,i=!1;try{const y={...t};void 0===y.settings&&(y.settings=this.settings),void 0===y.session&&(y.session=this.tlsSessionCache.get(s));const f=y.createConnection||this.createConnection;o=await f.call(this,e,y),y.createConnection=()=>o;const Z=r.connect(e,y);Z[l]=0,Z[u]=!1;const A=()=>{const{socket:e}=Z;let t;return!1===e.servername?(e.servername=e.remoteAddress,t=Z.originSet,e.servername=!1):t=Z.originSet,t},G=()=>Z[l]{this.tlsSessionCache.set(s,e)})),Z.once("error",(e=>{for(let t=0;t{Z.destroy()})),Z.once("close",(()=>{if(this._sessionCount--,i){this._emptySessionCount--;const e=this.sessions[a];1===e.length?delete this.sessions[a]:e.splice(e.indexOf(Z),1)}else{I();const e=new Error("Session closed without receiving a SETTINGS frame");e.code="HTTP2WRAPPER_NOSETTINGS";for(let t=0;t{const e=this.queue[a];if(!e)return;const t=Z[d];for(let n=0;n{Z[d]=A()||[],Z[u]=!1,m(this.sessions[a],Z),!Z[u]&&G()&&(B(),G()&&C(this.sessions[a],Z))})),Z.once("remoteSettings",(()=>{if(b.destroyed){const e=new Error("Agent has been destroyed");for(let t=0;t{let s=0,o=e.length;for(;s>>1;n(e[i],t)?s=i+1:o=i}return s})(t,Z,p),0,Z)}else e[a]=[Z]}i=!0,this._emptySessionCount++,this.emit("session",Z),this._accept(Z,n,c,t),0===Z[l]&&this._emptySessionCount>this.maxEmptySessions&&this.closeEmptySessions(this._emptySessionCount-this.maxEmptySessions),Z.on("remoteSettings",(()=>{G()&&(B(),G()&&C(this.sessions[a],Z))}))}})),Z[g]=Z.request,Z.request=(e,t)=>{if(Z[u])throw new Error("The session is gracefully closing. No new streams are allowed.");const n=Z[g](e,t);return Z.ref(),0==Z[l]++&&this._emptySessionCount--,n.once("close",(()=>{0==--Z[l]&&(this._emptySessionCount++,Z.unref(),this._emptySessionCount>this.maxEmptySessions||Z[u])?Z.close():Z.destroyed||Z.closed||G()&&!m(this.sessions[a],Z)&&(C(this.sessions[a],Z),B(),0===Z[l]&&this._processQueue())})),n}}catch(e){I(),this._sessionCount--;for(let t=0;t{this.getSession(e,t,[{reject:i,resolve:e=>{try{const t=e.request(n,s);c(t),o(t)}catch(e){i(e)}}}])}))}async createConnection(e,t){return y.connect(e,t)}static connect(e,t){t.ALPNProtocols=["h2"];const n=e.port||443,s=e.hostname;void 0===t.servername&&(t.servername=s);const o=i.connect(n,s,t);return t.socket&&(o._peername={family:void 0,address:void 0,port:n}),o}closeEmptySessions(e=Number.POSITIVE_INFINITY){let t=0;const{sessions:n}=this;for(const s in n){const o=n[s];for(let n=0;n=e))return t}}return t}destroy(e){const{sessions:t,queue:n}=this;for(const n in t){const s=t[n];for(let t=0;t{"use strict";const{URL:s,urlToHttpOptions:o}=n(7310),i=n(3685),r=n(5687),a=n(5322),c=n(1269),{Agent:l,globalAgent:g}=n(4685),d=n(2287),u=n(4017),h=n(8120),I=new c({maxSize:100}),p=(e,t=new Map,n=void 0)=>async s=>{const o=`${s.host}:${s.port}:${s.ALPNProtocols.sort()}`;if(!e.has(o)){if(t.has(o))return{alpnProtocol:(await t.get(o)).alpnProtocol};const{path:i}=s;s.path=s.socketPath;const r=a(s,n);t.set(o,r);try{const n=await r;return e.set(o,n.alpnProtocol),t.delete(o),s.path=i,n}catch(e){throw t.delete(o),s.path=i,e}}return{alpnProtocol:e.get(o)}},C=p(I,new Map);e.exports=async(e,t,n)=>{if(e="string"==typeof e?o(new s(e)):e instanceof s?o(e):{...e},"function"==typeof t||void 0===t?(n=t,t=e):t=Object.assign(e,t),t.ALPNProtocols=t.ALPNProtocols||["h2","http/1.1"],!Array.isArray(t.ALPNProtocols)||0===t.ALPNProtocols.length)throw new Error("The `ALPNProtocols` option must be an Array with at least one entry");t.protocol=t.protocol||"https:";const a="https:"===t.protocol;t.host=t.hostname||t.host||"localhost",t.session=t.tlsSession,t.servername=t.servername||u(t.headers&&t.headers.host||t.host),t.port=t.port||(a?443:80),t._defaultAgent=a?r.globalAgent:i.globalAgent;const c=t.resolveProtocol||C;let{agent:I}=t;if(void 0!==I&&!1!==I&&"Object"!==I.constructor.name)throw new Error("The `options.agent` can be only an object `http`, `https` or `http2` properties");if(a){t.resolveSocket=!0;let{socket:e,alpnProtocol:s,timeout:o}=await c(t);if(o){e&&e.destroy();const n=new Error(`Timed out resolving ALPN: ${t.timeout} ms`);throw n.code="ETIMEDOUT",n.ms=t.timeout,n}e&&t.createConnection&&(e.destroy(),e=void 0),delete t.resolveSocket;const i="h2"===s;if(I&&(I=i?I.http2:I.https,t.agent=I),void 0===I&&(I=i?g:r.globalAgent),e)if(!1===I)e.destroy();else{const n=(i?l:r.Agent).prototype.createConnection;I.createConnection===n?i?t._reuseSocket=e:((e,t,n)=>{t._httpMessage={shouldKeepAlive:!0};const s=()=>{e.emit("free",t,n)};t.on("free",s);const o=()=>{e.removeSocket(t,n)};t.on("close",o);const i=()=>{const{freeSockets:n}=e;for(const e of Object.values(n))if(e.includes(t))return void t.destroy()};t.on("timeout",i);const r=()=>{e.removeSocket(t,n),t.off("close",o),t.off("free",s),t.off("timeout",i),t.off("agentRemove",r)};t.on("agentRemove",r),e.emit("free",t,n)})(I,e,t):e.destroy()}if(i)return h(new d(t,n))}else I&&(t.agent=I.http);return t.headers&&(t.headers={...t.headers},t.headers[":authority"]&&(t.headers.host||(t.headers.host=t.headers[":authority"]),delete t.headers[":authority"]),delete t.headers[":method"],delete t.headers[":scheme"],delete t.headers[":path"]),h(i.request(t,n))},e.exports.protocolCache=I,e.exports.resolveProtocol=C,e.exports.createResolveProtocol=p},2287:(e,t,n)=>{"use strict";const{URL:s,urlToHttpOptions:o}=n(7310),i=n(6281),{Writable:r}=n(2781),{Agent:a,globalAgent:c}=n(4685),l=n(7138),g=n(7306),{ERR_INVALID_ARG_TYPE:d,ERR_INVALID_PROTOCOL:u,ERR_HTTP_HEADERS_SENT:h}=n(3190),I=n(7460),p=n(9154),C=n(7709),{HTTP2_HEADER_STATUS:m,HTTP2_HEADER_METHOD:b,HTTP2_HEADER_PATH:y,HTTP2_HEADER_AUTHORITY:f,HTTP2_METHOD_CONNECT:Z}=i.constants,A=Symbol("headers"),G=Symbol("origin"),B=Symbol("session"),v=Symbol("options"),W=Symbol("flushedHeaders"),V=Symbol("jobs"),w=Symbol("pendingAgentPromise");e.exports=class extends r{constructor(e,t,n){if(super({autoDestroy:!1,emitClose:!1}),e="string"==typeof e?o(new s(e)):e instanceof s?o(e):{...e},"function"==typeof t||void 0===t?(n=t,t=e):t=Object.assign(e,t),t.h2session){if(this[B]=t.h2session,this[B].destroyed)throw new Error("The session has been closed already");this.protocol=this[B].socket.encrypted?"https:":"http:"}else if(!1===t.agent)this.agent=new a({maxEmptySessions:0});else if(void 0===t.agent||null===t.agent)this.agent=c;else{if("function"!=typeof t.agent.request)throw new d("options.agent",["http2wrapper.Agent-like Object","undefined","false"],t.agent);this.agent=t.agent}if(this.agent&&(this.protocol=this.agent.protocol),t.protocol&&t.protocol!==this.protocol)throw new u(t.protocol,this.protocol);t.port||(t.port=t.defaultPort||this.agent&&this.agent.defaultPort||443),t.host=t.hostname||t.host||"localhost",delete t.hostname;const{timeout:i}=t;t.timeout=void 0,this[A]=Object.create(null),this[V]=[],this[w]=void 0,this.socket=null,this.connection=null,this.method=t.method||"GET",("CONNECT"!==this.method||"/"!==t.path&&void 0!==t.path)&&(this.path=t.path),this.res=null,this.aborted=!1,this.reusedSocket=!1;const{headers:r}=t;if(r)for(const e in r)this.setHeader(e,r[e]);t.auth&&!("authorization"in this[A])&&(this[A].authorization="Basic "+Buffer.from(t.auth).toString("base64")),t.session=t.tlsSession,t.path=t.socketPath,this[v]=t,this[G]=new s(`${this.protocol}//${t.servername||t.host}:${t.port}`);const l=t._reuseSocket;l&&(t.createConnection=(...e)=>l.destroyed?this.agent.createConnection(...e):l,this.agent.getSession(this[G],this[v]).catch((()=>{}))),i&&this.setTimeout(i),n&&this.once("response",n),this[W]=!1}get method(){return this[A][b]}set method(e){e&&(this[A][b]=e.toUpperCase())}get path(){const e="CONNECT"===this.method?f:y;return this[A][e]}set path(e){if(e){const t="CONNECT"===this.method?f:y;this[A][t]=e}}get host(){return this[G].hostname}set host(e){}get _mustNotHaveABody(){return"GET"===this.method||"HEAD"===this.method||"DELETE"===this.method}_write(e,t,n){if(this._mustNotHaveABody)return void n(new Error("The GET, HEAD and DELETE methods must NOT have a body"));this.flushHeaders();const s=()=>this._request.write(e,t,n);this._request?s():this[V].push(s)}_final(e){this.flushHeaders();const t=()=>{this._mustNotHaveABody||"CONNECT"===this.method?e():this._request.end(e)};this._request?t():this[V].push(t)}abort(){this.res&&this.res.complete||(this.aborted||process.nextTick((()=>this.emit("abort"))),this.aborted=!0,this.destroy())}async _destroy(e,t){this.res&&this.res._dump(),this._request?this._request.destroy():process.nextTick((()=>{this.emit("close")}));try{await this[w]}catch(t){this.aborted&&(e=t)}t(e)}async flushHeaders(){if(this[W]||this.destroyed)return;this[W]=!0;const e=this.method===Z,t=t=>{if(this._request=t,this.destroyed)return void t.destroy();e||g(t,this,["timeout","continue"]),t.once("error",(e=>{this.destroy(e)})),t.once("aborted",(()=>{const{res:e}=this;e?(e.aborted=!0,e.emit("aborted"),e.destroy()):this.destroy(new Error("The server aborted the HTTP/2 stream"))}));const n=(n,s,o)=>{const i=new l(this.socket,t.readableHighWaterMark);this.res=i,i.url=`${this[G].origin}${this.path}`,i.req=this,i.statusCode=n[m],i.headers=n,i.rawHeaders=o,i.once("end",(()=>{i.complete=!0,i.socket=null,i.connection=null})),e?(i.upgrade=!0,this.emit("connect",i,t,Buffer.alloc(0))?this.emit("close"):t.destroy()):(t.on("data",(e=>{i._dumped||i.push(e)||t.pause()})),t.once("end",(()=>{this.aborted||i.push(null)})),this.emit("response",i)||i._dump())};t.once("response",n),t.once("headers",(e=>this.emit("information",{statusCode:e[m]}))),t.once("trailers",((e,t,s)=>{const{res:o}=this;null!==o?(o.trailers=e,o.rawTrailers=s):n(e,0,s)})),t.once("close",(()=>{const{aborted:e,res:t}=this;if(t){e&&(t.aborted=!0,t.emit("aborted"),t.destroy());const n=()=>{t.emit("close"),this.destroy(),this.emit("close")};t.readable?t.once("end",n):n()}else{if(!this.destroyed)return this.destroy(new Error("The HTTP/2 stream has been early terminated")),void this.emit("close");this.destroy(),this.emit("close")}})),this.socket=new Proxy(t,C);for(const e of this[V])e();this[V].length=0,this.emit("socket",this.socket)};if(f in this[A]||e||(this[A][f]=this[G].host),this[B])try{t(this[B].request(this[A]))}catch(e){this.destroy(e)}else{this.reusedSocket=!0;try{const e=this.agent.request(this[G],this[v],this[A]);this[w]=e,t(await e),this[w]=!1}catch(e){this[w]=!1,this.destroy(e)}}}get connection(){return this.socket}set connection(e){this.socket=e}getHeaderNames(){return Object.keys(this[A])}hasHeader(e){if("string"!=typeof e)throw new d("name","string",e);return Boolean(this[A][e.toLowerCase()])}getHeader(e){if("string"!=typeof e)throw new d("name","string",e);return this[A][e.toLowerCase()]}get headersSent(){return this[W]}removeHeader(e){if("string"!=typeof e)throw new d("name","string",e);if(this.headersSent)throw new h("remove");delete this[A][e.toLowerCase()]}setHeader(e,t){if(this.headersSent)throw new h("set");I(e),p(e,t);const n=e.toLowerCase();if("connection"===n){if("keep-alive"===t.toLowerCase())return;throw new Error(`Invalid 'connection' header: ${t}`)}"host"===n&&"CONNECT"===this.method?this[A][f]=t:this[A][n]=t}setNoDelay(){}setSocketKeepAlive(){}setTimeout(e,t){const n=()=>this._request.setTimeout(e,t);return this._request?n():this[V].push(n),this}get maxHeadersCount(){if(!this.destroyed&&this._request)return this._request.session.localSettings.maxHeaderListSize}set maxHeadersCount(e){}}},7138:(e,t,n)=>{"use strict";const{Readable:s}=n(2781);e.exports=class extends s{constructor(e,t){super({emitClose:!1,autoDestroy:!0,highWaterMark:t}),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._dumped=!1}get connection(){return this.socket}set connection(e){this.socket=e}_destroy(e,t){this.readableEnded||(this.aborted=!0),t(),this.req._request.destroy(e)}setTimeout(e,t){return this.req.setTimeout(e,t),this}_dump(){this._dumped||(this._dumped=!0,this.removeAllListeners("data"),this.resume())}_read(){this.req&&this.req._request.resume()}}},9758:(e,t,n)=>{"use strict";const s=n(6281),{Agent:o,globalAgent:i}=n(4685),r=n(2287),a=n(7138),c=n(6673),{HttpOverHttp2:l,HttpsOverHttp2:g}=n(7072),d=n(3672),{Http2OverHttp:u,Http2OverHttps:h}=n(148),I=n(7460),p=n(9154);e.exports={...s,ClientRequest:r,IncomingMessage:a,Agent:o,globalAgent:i,request:(e,t,n)=>new r(e,t,n),get:(e,t,n)=>{const s=new r(e,t,n);return s.end(),s},auto:c,proxies:{HttpOverHttp2:l,HttpsOverHttp2:g,Http2OverHttp2:d,Http2OverHttp:u,Http2OverHttps:h},validateHeaderName:I,validateHeaderValue:p}},6476:e=>{"use strict";e.exports=e=>{const{username:t,password:n}=e.proxyOptions.url;if(t||n){const e=`${t}:${n}`,s=`Basic ${Buffer.from(e).toString("base64")}`;return{"proxy-authorization":s,authorization:s}}return{}}},7072:(e,t,n)=>{"use strict";const s=n(4404),o=n(3685),i=n(5687),r=n(5583),{globalAgent:a}=n(4685),c=n(4906),l=n(9645),g=n(6476),d=(e,t,n)=>{(async()=>{try{const{proxyOptions:o}=e,{url:l,headers:d,raw:u}=o,h=await a.request(l,o,{...g(e),...d,":method":"CONNECT",":authority":`${t.host}:${t.port}`});h.once("error",n),h.once("response",(o=>{const a=o[":status"];if(200!==a)return void n(new c(a,""));const l=e instanceof i.Agent;if(u&&l){t.socket=h;const e=s.connect(t);return e.once("close",(()=>{h.destroy()})),void n(null,e)}const g=new r(h);g.encrypted=!1,g._handle.getpeername=e=>{e.family=void 0,e.address=void 0,e.port=void 0},n(null,g)}))}catch(e){n(e)}})()};class u extends o.Agent{constructor(e){super(e),l(this,e.proxyOptions)}createConnection(e,t){d(this,e,t)}}class h extends i.Agent{constructor(e){super(e),l(this,e.proxyOptions)}createConnection(e,t){d(this,e,t)}}e.exports={HttpOverHttp2:u,HttpsOverHttp2:h}},148:(e,t,n)=>{"use strict";const s=n(3685),o=n(5687),i=n(8193),r=n(6476);class a extends i{async _getProxyStream(e){const{proxyOptions:t}=this,{url:n,headers:i}=this.proxyOptions;return a=("https:"===n.protocol?o:s).request({...t,hostname:n.hostname,port:n.port,path:e,headers:{...r(this),...i,host:e},method:"CONNECT"}).end(),new Promise(((e,t)=>{a.once("error",t),a.once("connect",((n,s,o)=>{s.unshift(o),a.off("error",t),e([s,n.statusCode,n.statusMessage])}))}));var a}}e.exports={Http2OverHttp:a,Http2OverHttps:a}},3672:(e,t,n)=>{"use strict";const{globalAgent:s}=n(4685),o=n(8193),i=n(6476);e.exports=class extends o{async _getProxyStream(e){const{proxyOptions:t}=this,n={...i(this),...t.headers,":method":"CONNECT",":authority":e},o=await s.request(t.url,t,n),r=await(e=>new Promise(((t,n)=>{e.once("error",n),e.once("response",(s=>{e.off("error",n),t(s[":status"])}))})))(o);return[o,r,""]}}},8193:(e,t,n)=>{"use strict";const{Agent:s}=n(4685),o=n(5583),i=n(4906),r=n(9645);e.exports=class extends s{constructor(e){super(e),r(this,e.proxyOptions)}async createConnection(e,t){const n=`${e.hostname}:${e.port||443}`,[s,r,a]=await this._getProxyStream(n);if(200!==r)throw new i(r,a);if(!this.proxyOptions.raw){const e=new o(s);return e.encrypted=!1,e._handle.getpeername=e=>{e.family=void 0,e.address=void 0,e.port=void 0},e}return t.socket=s,super.createConnection(e,t)}}},9645:(e,t,n)=>{"use strict";const{URL:s}=n(7310),o=n(2058);e.exports=(e,t)=>{o("proxyOptions",t,["object"]),o("proxyOptions.headers",t.headers,["object","undefined"]),o("proxyOptions.raw",t.raw,["boolean","undefined"]),o("proxyOptions.url",t.url,[s,"string"]);const n=new s(t.url);e.proxyOptions={raw:!0,...t,headers:{...t.headers},url:n}}},4906:e=>{"use strict";class t extends Error{constructor(e,t=""){super(`The proxy server rejected the request with status code ${e} (${t||"empty status message"})`),this.statusCode=e,this.statusMessage=t}}e.exports=t},4017:(e,t,n)=>{"use strict";const{isIP:s}=n(1808),o=n(9491);e.exports=e=>{const t=(e=>{if("["===e[0]){const t=e.indexOf("]");return o(-1!==t),e.slice(1,t)}const t=e.indexOf(":");return-1===t?e:e.slice(0,t)})(e);return s(t)?"":t}},2058:e=>{"use strict";e.exports=(e,t,n)=>{if(!n.some((e=>"string"==typeof e?typeof t===e:t instanceof e))){const s=n.map((e=>"string"==typeof e?e:e.name));throw new TypeError(`Expected '${e}' to be a type of ${s.join(" or ")}, got ${typeof t}`)}}},8120:e=>{"use strict";e.exports=e=>{if(0!==e.listenerCount("error"))return e;e.__destroy=e._destroy,e._destroy=(...t)=>{const n=t.pop();e.__destroy(...t,(async e=>{await Promise.resolve(),n(e)}))};const t=t=>{Promise.resolve().then((()=>{e.emit("error",t)}))};return e.once("error",t),Promise.resolve().then((()=>{e.off("error",t)})),e}},3190:e=>{"use strict";const t=(t,n,s)=>{e.exports[n]=class extends t{constructor(...e){super("string"==typeof s?s:s(e)),this.name=`${super.name} [${n}]`,this.code=n}}};t(TypeError,"ERR_INVALID_ARG_TYPE",(e=>{const t=e[0].includes(".")?"property":"argument";let n=e[1];const s=Array.isArray(n);return s&&(n=`${n.slice(0,-1).join(", ")} or ${n.slice(-1)}`),`The "${e[0]}" ${t} must be ${s?"one of":"of"} type ${n}. Received ${typeof e[2]}`})),t(TypeError,"ERR_INVALID_PROTOCOL",(e=>`Protocol "${e[0]}" not supported. Expected "${e[1]}"`)),t(Error,"ERR_HTTP_HEADERS_SENT",(e=>`Cannot ${e[0]} headers after they are sent to the client`)),t(TypeError,"ERR_INVALID_HTTP_TOKEN",(e=>`${e[0]} must be a valid HTTP token [${e[1]}]`)),t(TypeError,"ERR_HTTP_INVALID_HEADER_VALUE",(e=>`Invalid value "${e[0]} for header "${e[1]}"`)),t(TypeError,"ERR_INVALID_CHAR",(e=>`Invalid character in ${e[0]} [${e[1]}]`)),t(Error,"ERR_HTTP2_NO_SOCKET_MANIPULATION","HTTP/2 sockets should not be directly manipulated (e.g. read and written)")},8202:e=>{"use strict";e.exports=e=>{switch(e){case":method":case":scheme":case":authority":case":path":return!0;default:return!1}}},5583:(e,t,n)=>{"use strict";const s=n(2781),o=new(n(4404).TLSSocket)(new s.PassThrough)._handle._parentWrap.constructor;e.exports=o},7306:e=>{"use strict";e.exports=(e,t,n)=>{for(const s of n)e.on(s,((...e)=>t.emit(s,...e)))}},7709:(e,t,n)=>{"use strict";const{ERR_HTTP2_NO_SOCKET_MANIPULATION:s}=n(3190),o={has(e,t){const n=void 0===e.session?e:e.session.socket;return t in e||t in n},get(e,t){switch(t){case"on":case"once":case"end":case"emit":case"destroy":return e[t].bind(e);case"writable":case"destroyed":return e[t];case"readable":return!e.destroyed&&e.readable;case"setTimeout":{const{session:t}=e;return void 0!==t?t.setTimeout.bind(t):e.setTimeout.bind(e)}case"write":case"read":case"pause":case"resume":throw new s;default:{const n=void 0===e.session?e:e.session.socket,s=n[t];return"function"==typeof s?s.bind(n):s}}},getPrototypeOf:e=>void 0!==e.session?Reflect.getPrototypeOf(e.session.socket):Reflect.getPrototypeOf(e),set(e,t,n){switch(t){case"writable":case"readable":case"destroyed":case"on":case"once":case"end":case"emit":case"destroy":return e[t]=n,!0;case"setTimeout":{const{session:t}=e;return void 0===t?e.setTimeout=n:t.setTimeout=n,!0}case"write":case"read":case"pause":case"resume":throw new s;default:return(void 0===e.session?e:e.session.socket)[t]=n,!0}}};e.exports=o},7460:(e,t,n)=>{"use strict";const{ERR_INVALID_HTTP_TOKEN:s}=n(3190),o=n(8202),i=/^[\^`\-\w!#$%&*+.|~]+$/;e.exports=e=>{if("string"!=typeof e||!i.test(e)&&!o(e))throw new s("Header name",e)}},9154:(e,t,n)=>{"use strict";const{ERR_HTTP_INVALID_HEADER_VALUE:s,ERR_INVALID_CHAR:o}=n(3190),i=/[^\t\u0020-\u007E\u0080-\u00FF]/;e.exports=(e,t)=>{if(void 0===t)throw new s(t,e);if(i.test(t))throw new o("header content",e)}},9146:function(e,t,n){"use strict";var s=this&&this.__awaiter||function(e,t,n,s){return new(n||(n=Promise))((function(o,i){function r(e){try{c(s.next(e))}catch(e){i(e)}}function a(e){try{c(s.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,a)}c((s=s.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=o(n(1808)),r=o(n(4404)),a=o(n(7310)),c=o(n(9491)),l=o(n(5158)),g=n(8054),d=o(n(9829)),u=l.default("https-proxy-agent:agent");class h extends g.Agent{constructor(e){let t;if(t="string"==typeof e?a.default.parse(e):e,!t)throw new Error("an HTTP(S) proxy server `host` and `port` must be specified!");u("creating new HttpsProxyAgent instance: %o",t),super(t);const n=Object.assign({},t);var s;this.secureProxy=t.secureProxy||"string"==typeof(s=n.protocol)&&/^https:?$/i.test(s),n.host=n.hostname||n.host,"string"==typeof n.port&&(n.port=parseInt(n.port,10)),!n.port&&n.host&&(n.port=this.secureProxy?443:80),this.secureProxy&&!("ALPNProtocols"in n)&&(n.ALPNProtocols=["http 1.1"]),n.host&&n.path&&(delete n.path,delete n.pathname),this.proxy=n}callback(e,t){return s(this,void 0,void 0,(function*(){const{proxy:n,secureProxy:s}=this;let o;s?(u("Creating `tls.Socket`: %o",n),o=r.default.connect(n)):(u("Creating `net.Socket`: %o",n),o=i.default.connect(n));const a=Object.assign({},n.headers);let l=`CONNECT ${t.host}:${t.port} HTTP/1.1\r\n`;n.auth&&(a["Proxy-Authorization"]=`Basic ${Buffer.from(n.auth).toString("base64")}`);let{host:g,port:h,secureEndpoint:p}=t;(function(e,t){return Boolean(!t&&80===e||t&&443===e)})(h,p)||(g+=`:${h}`),a.Host=g,a.Connection="close";for(const e of Object.keys(a))l+=`${e}: ${a[e]}\r\n`;const C=d.default(o);o.write(`${l}\r\n`);const{statusCode:m,buffered:b}=yield C;if(200===m){if(e.once("socket",I),t.secureEndpoint){u("Upgrading socket connection to TLS");const e=t.servername||t.host;return r.default.connect(Object.assign(Object.assign({},function(e,...t){const n={};let s;for(s in e)t.includes(s)||(n[s]=e[s]);return n}(t,"host","hostname","path","port")),{socket:o,servername:e}))}return o}o.destroy();const y=new i.default.Socket({writable:!1});return y.readable=!0,e.once("socket",(e=>{u("replaying proxy buffer for failed request"),c.default(e.listenerCount("data")>0),e.push(b),e.push(null)})),y}))}}function I(e){e.resume()}t.default=h},6018:function(e,t,n){"use strict";const s=(this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(n(9146));function o(e){return new s.default(e)}!function(e){e.HttpsProxyAgent=s.default,e.prototype=s.default.prototype}(o||(o={})),e.exports=o},9829:function(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=s(n(5158)).default("https-proxy-agent:parse-proxy-response");t.default=function(e){return new Promise(((t,n)=>{let s=0;const i=[];function r(){const n=e.read();n?function(e){i.push(e),s+=e.length;const n=Buffer.concat(i,s);if(-1===n.indexOf("\r\n\r\n"))return o("have not received end of HTTP headers yet..."),void r();const a=n.toString("ascii",0,n.indexOf("\r\n")),c=+a.split(" ")[1];o("got proxy server response: %o",a),t({statusCode:c,buffered:n})}(n):e.once("readable",r)}function a(e){o("onclose had error %o",e)}function c(){o("onend")}e.on("error",(function t(s){e.removeListener("end",c),e.removeListener("error",t),e.removeListener("close",a),e.removeListener("readable",r),o("onerror %o",s),n(s)})),e.on("close",a),e.on("end",c),r()}))}},1085:(e,t)=>{t.stringify=function e(t){if(void 0===t)return t;if(t&&Buffer.isBuffer(t))return JSON.stringify(":base64:"+t.toString("base64"));if(t&&t.toJSON&&(t=t.toJSON()),t&&"object"==typeof t){var n="",s=Array.isArray(t);n=s?"[":"{";var o=!0;for(var i in t){var r="function"==typeof t[i]||!s&&void 0===t[i];Object.hasOwnProperty.call(t,i)&&!r&&(o||(n+=","),o=!1,s?null==t[i]?n+="null":n+=e(t[i]):void 0!==t[i]&&(n+=e(i)+":"+e(t[i])))}return n+(s?"]":"}")}return"string"==typeof t?JSON.stringify(/^:/.test(t)?":"+t:t):void 0===t?"null":JSON.stringify(t)},t.parse=function(e){return JSON.parse(e,(function(e,t){return"string"==typeof t?/^:base64:/.test(t)?Buffer.from(t.substring(8),"base64"):/^:/.test(t)?t.substring(1):t:t}))}},4958:(e,t,n)=>{"use strict";const s=n(2361),o=n(1085),i=["sqlite","postgres","mysql","mongo","redis","tiered"];e.exports=class extends s{constructor(e,{emitErrors:t=!0,...s}={}){if(super(),this.opts={namespace:"keyv",serialize:o.stringify,deserialize:o.parse,..."string"==typeof e?{uri:e}:e,...s},!this.opts.store){const e={...this.opts};this.opts.store=(e=>{const t={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(e.adapter||e.uri){const s=e.adapter||/^[^:+]*/.exec(e.uri)[0];return new(n(3196)(t[s]))(e)}return new Map})(e)}if(this.opts.compression){const e=this.opts.compression;this.opts.serialize=e.serialize.bind(e),this.opts.deserialize=e.deserialize.bind(e)}"function"==typeof this.opts.store.on&&t&&this.opts.store.on("error",(e=>this.emit("error",e))),this.opts.store.namespace=this.opts.namespace;const i=e=>async function*(){for await(const[t,n]of"function"==typeof e?e(this.opts.store.namespace):e){const e=await this.opts.deserialize(n);this.opts.store.namespace&&!t.includes(this.opts.store.namespace)||("number"==typeof e.expires&&Date.now()>e.expires?this.delete(t):yield[this._getKeyUnprefix(t),e.value])}};"function"==typeof this.opts.store[Symbol.iterator]&&this.opts.store instanceof Map?this.iterator=i(this.opts.store):"function"==typeof this.opts.store.iterator&&this.opts.store.opts&&this._checkIterableAdaptar()&&(this.iterator=i(this.opts.store.iterator.bind(this.opts.store)))}_checkIterableAdaptar(){return i.includes(this.opts.store.opts.dialect)||i.findIndex((e=>this.opts.store.opts.url.includes(e)))>=0}_getKeyPrefix(e){return`${this.opts.namespace}:${e}`}_getKeyPrefixArray(e){return e.map((e=>`${this.opts.namespace}:${e}`))}_getKeyUnprefix(e){return e.split(":").splice(1).join(":")}get(e,t){const{store:n}=this.opts,s=Array.isArray(e),o=s?this._getKeyPrefixArray(e):this._getKeyPrefix(e);if(s&&void 0===n.getMany){const e=[];for(const s of o)e.push(Promise.resolve().then((()=>n.get(s))).then((e=>"string"==typeof e||this.opts.compression?this.opts.deserialize(e):e)).then((e=>{if(null!=e)return"number"==typeof e.expires&&Date.now()>e.expires?this.delete(s).then((()=>{})):t&&t.raw?e:e.value})));return Promise.allSettled(e).then((e=>{const t=[];for(const n of e)t.push(n.value);return t}))}return Promise.resolve().then((()=>s?n.getMany(o):n.get(o))).then((e=>"string"==typeof e||this.opts.compression?this.opts.deserialize(e):e)).then((n=>{if(null!=n)return s?n.map(((n,s)=>{if("string"==typeof n&&(n=this.opts.deserialize(n)),null!=n){if(!("number"==typeof n.expires&&Date.now()>n.expires))return t&&t.raw?n:n.value;this.delete(e[s]).then((()=>{}))}})):"number"==typeof n.expires&&Date.now()>n.expires?this.delete(e).then((()=>{})):t&&t.raw?n:n.value}))}set(e,t,n){const s=this._getKeyPrefix(e);void 0===n&&(n=this.opts.ttl),0===n&&(n=void 0);const{store:o}=this.opts;return Promise.resolve().then((()=>{const e="number"==typeof n?Date.now()+n:null;return"symbol"==typeof t&&this.emit("error","symbol cannot be serialized"),t={value:t,expires:e},this.opts.serialize(t)})).then((e=>o.set(s,e,n))).then((()=>!0))}delete(e){const{store:t}=this.opts;if(Array.isArray(e)){const n=this._getKeyPrefixArray(e);if(void 0===t.deleteMany){const e=[];for(const s of n)e.push(t.delete(s));return Promise.allSettled(e).then((e=>e.every((e=>!0===e.value))))}return Promise.resolve().then((()=>t.deleteMany(n)))}const n=this._getKeyPrefix(e);return Promise.resolve().then((()=>t.delete(n)))}clear(){const{store:e}=this.opts;return Promise.resolve().then((()=>e.clear()))}has(e){const t=this._getKeyPrefix(e),{store:n}=this.opts;return Promise.resolve().then((async()=>"function"==typeof n.has?n.has(t):void 0!==await n.get(t)))}disconnect(){const{store:e}=this.opts;if("function"==typeof e.disconnect)return e.disconnect()}}},3196:e=>{function t(e){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}t.keys=()=>[],t.resolve=t,t.id=3196,e.exports=t},4341:e=>{"use strict";const t=(e,t,s,o)=>{if("length"===s||"prototype"===s)return;if("arguments"===s||"caller"===s)return;const i=Object.getOwnPropertyDescriptor(e,s),r=Object.getOwnPropertyDescriptor(t,s);!n(i,r)&&o||Object.defineProperty(e,s,r)},n=function(e,t){return void 0===e||e.configurable||e.writable===t.writable&&e.enumerable===t.enumerable&&e.configurable===t.configurable&&(e.writable||e.value===t.value)},s=(e,t)=>`/* Wrapped ${e}*/\n${t}`,o=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),i=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name");e.exports=(e,n,{ignoreNonConfigurable:r=!1}={})=>{const{name:a}=e;for(const s of Reflect.ownKeys(n))t(e,n,s,r);return((e,t)=>{const n=Object.getPrototypeOf(t);n!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,n)})(e,n),((e,t,n)=>{const r=""===n?"":`with ${n.trim()}() `,a=s.bind(null,r,t.toString());Object.defineProperty(a,"name",i),Object.defineProperty(e,"toString",{...o,value:a})})(e,n,a),e}},6344:e=>{"use strict";const t=["aborted","complete","headers","httpVersion","httpVersionMinor","httpVersionMajor","method","rawHeaders","rawTrailers","setTimeout","socket","statusCode","statusMessage","trailers","url"];e.exports=(e,n)=>{if(n._readableState.autoDestroy)throw new Error("The second stream must have the `autoDestroy` option set to `false`");const s=new Set(Object.keys(e).concat(t)),o={};for(const t of s)t in n||(o[t]={get(){const n=e[t];return"function"==typeof n?n.bind(e):n},set(n){e[t]=n},enumerable:!0,configurable:!1});return Object.defineProperties(n,o),e.once("aborted",(()=>{n.destroy(),n.emit("aborted")})),e.once("close",(()=>{e.complete&&n.readable?n.once("end",(()=>{n.emit("close")})):n.emit("close")})),n}},7824:e=>{var t=1e3,n=60*t,s=60*n,o=24*s;function i(e,t,n,s){var o=t>=1.5*n;return Math.round(e/n)+" "+s+(o?"s":"")}e.exports=function(e,r){r=r||{};var a,c,l=typeof e;if("string"===l&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var i=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(i){var r=parseFloat(i[1]);switch((i[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*r;case"weeks":case"week":case"w":return 6048e5*r;case"days":case"day":case"d":return r*o;case"hours":case"hour":case"hrs":case"hr":case"h":return r*s;case"minutes":case"minute":case"mins":case"min":case"m":return r*n;case"seconds":case"second":case"secs":case"sec":case"s":return r*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}(e);if("number"===l&&isFinite(e))return r.long?(a=e,(c=Math.abs(a))>=o?i(a,c,o,"day"):c>=s?i(a,c,s,"hour"):c>=n?i(a,c,n,"minute"):c>=t?i(a,c,t,"second"):a+" ms"):function(e){var i=Math.abs(e);return i>=o?Math.round(e/o)+"d":i>=s?Math.round(e/s)+"h":i>=n?Math.round(e/n)+"m":i>=t?Math.round(e/t)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},7345:e=>{"use strict";e.exports=(e,t)=>(t=t||(()=>{}),e.then((e=>new Promise((e=>{e(t())})).then((()=>e))),(e=>new Promise((e=>{e(t())})).then((()=>{throw e})))))},5860:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const s=n(6729),o=n(6512),i=n(6506),r=()=>{},a=new o.TimeoutError;t.default=class extends s{constructor(e){var t,n,s,o;if(super(),this._intervalCount=0,this._intervalEnd=0,this._pendingCount=0,this._resolveEmpty=r,this._resolveIdle=r,!("number"==typeof(e=Object.assign({carryoverConcurrencyCount:!1,intervalCap:1/0,interval:0,concurrency:1/0,autoStart:!0,queueClass:i.default},e)).intervalCap&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${null!==(n=null===(t=e.intervalCap)||void 0===t?void 0:t.toString())&&void 0!==n?n:""}\` (${typeof e.intervalCap})`);if(void 0===e.interval||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${null!==(o=null===(s=e.interval)||void 0===s?void 0:s.toString())&&void 0!==o?o:""}\` (${typeof e.interval})`);this._carryoverConcurrencyCount=e.carryoverConcurrencyCount,this._isIntervalIgnored=e.intervalCap===1/0||0===e.interval,this._intervalCap=e.intervalCap,this._interval=e.interval,this._queue=new e.queueClass,this._queueClass=e.queueClass,this.concurrency=e.concurrency,this._timeout=e.timeout,this._throwOnTimeout=!0===e.throwOnTimeout,this._isPaused=!1===e.autoStart}get _doesIntervalAllowAnother(){return this._isIntervalIgnored||this._intervalCount{this._onResumeInterval()}),t)),!0;this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0}return!1}_tryToStartAnother(){if(0===this._queue.size)return this._intervalId&&clearInterval(this._intervalId),this._intervalId=void 0,this._resolvePromises(),!1;if(!this._isPaused){const e=!this._isIntervalPaused();if(this._doesIntervalAllowAnother&&this._doesConcurrentAllowAnother){const t=this._queue.dequeue();return!!t&&(this.emit("active"),t(),e&&this._initializeIntervalIfNeeded(),!0)}}return!1}_initializeIntervalIfNeeded(){this._isIntervalIgnored||void 0!==this._intervalId||(this._intervalId=setInterval((()=>{this._onInterval()}),this._interval),this._intervalEnd=Date.now()+this._interval)}_onInterval(){0===this._intervalCount&&0===this._pendingCount&&this._intervalId&&(clearInterval(this._intervalId),this._intervalId=void 0),this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0,this._processQueue()}_processQueue(){for(;this._tryToStartAnother(););}get concurrency(){return this._concurrency}set concurrency(e){if(!("number"==typeof e&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);this._concurrency=e,this._processQueue()}async add(e,t={}){return new Promise(((n,s)=>{this._queue.enqueue((async()=>{this._pendingCount++,this._intervalCount++;try{const i=void 0===this._timeout&&void 0===t.timeout?e():o.default(Promise.resolve(e()),void 0===t.timeout?this._timeout:t.timeout,(()=>{(void 0===t.throwOnTimeout?this._throwOnTimeout:t.throwOnTimeout)&&s(a)}));n(await i)}catch(e){s(e)}this._next()}),t),this._tryToStartAnother(),this.emit("add")}))}async addAll(e,t){return Promise.all(e.map((async e=>this.add(e,t))))}start(){return this._isPaused?(this._isPaused=!1,this._processQueue(),this):this}pause(){this._isPaused=!0}clear(){this._queue=new this._queueClass}async onEmpty(){if(0!==this._queue.size)return new Promise((e=>{const t=this._resolveEmpty;this._resolveEmpty=()=>{t(),e()}}))}async onIdle(){if(0!==this._pendingCount||0!==this._queue.size)return new Promise((e=>{const t=this._resolveIdle;this._resolveIdle=()=>{t(),e()}}))}get size(){return this._queue.size}sizeBy(e){return this._queue.filter(e).length}get pending(){return this._pendingCount}get isPaused(){return this._isPaused}get timeout(){return this._timeout}set timeout(e){this._timeout=e}}},7489:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,n){let s=0,o=e.length;for(;o>0;){const i=o/2|0;let r=s+i;n(e[r],t)<=0?(s=++r,o-=i+1):o=i}return s}},6506:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const s=n(7489);t.default=class{constructor(){this._queue=[]}enqueue(e,t){const n={priority:(t=Object.assign({priority:0},t)).priority,run:e};if(this.size&&this._queue[this.size-1].priority>=t.priority)return void this._queue.push(n);const o=s.default(this._queue,n,((e,t)=>t.priority-e.priority));this._queue.splice(o,0,n)}dequeue(){const e=this._queue.shift();return null==e?void 0:e.run}filter(e){return this._queue.filter((t=>t.priority===e.priority)).map((e=>e.run))}get size(){return this._queue.length}}},6512:(e,t,n)=>{"use strict";const s=n(7345);class o extends Error{constructor(e){super(e),this.name="TimeoutError"}}const i=(e,t,n)=>new Promise(((i,r)=>{if("number"!=typeof t||t<0)throw new TypeError("Expected `milliseconds` to be a positive number");if(t===1/0)return void i(e);const a=setTimeout((()=>{if("function"==typeof n){try{i(n())}catch(e){r(e)}return}const s=n instanceof Error?n:new o("string"==typeof n?n:`Promise timed out after ${t} milliseconds`);"function"==typeof e.cancel&&e.cancel(),r(s)}),t);s(e.then(i,r),(()=>{clearTimeout(a)}))}));e.exports=i,e.exports.default=i,e.exports.TimeoutError=o},2773:(e,t,n)=>{var s={};s.sys=n(3583),s.promise=n(8835),e.exports=s},8371:(e,t,n)=>{"use strict";var s=n(3837),o=n(4344),i=n(3078),r=n(9674);function a(){}a.isLinux=function(e){return["aix","android","linux"].indexOf(e)>=0},a.isMacOS=function(e){return["darwin","freebsd"].indexOf(e)>=0},a.isWindow=function(e){return e&&null!==e.match(/^win/)},a.isPlatformSupport=function(e){return this.isWindow(e)||this.isLinux(e)||this.isMacOS(e)},a.getExecutablePath=function(e,t){if(!this.isPlatformSupport(e))throw new Error(s.format("Platform |%s| is not support",e));var n=null;return"aix"===e?n="/usr/sbin/ping":a.isLinux(e)?n=t?"ping6":"ping":a.isWindow(e)?n=process.env.SystemRoot+"/system32/ping.exe":a.isMacOS(e)&&(n=t?"/sbin/ping6":"/sbin/ping"),n},a.createBuilder=function(e){if(!this.isPlatformSupport(e))throw new Error(s.format("Platform |%s| is not support",e));var t=null;return a.isLinux(e)?t=o:a.isWindow(e)?t=r:a.isMacOS(e)&&(t=i),t},e.exports=a},4344:(e,t,n)=>{"use strict";var s=n(3837),o={},i={numeric:!0,timeout:2,deadline:!1,min_reply:1,v6:!1,sourceAddr:"",packetSize:56,extra:[]};o.getCommandArguments=function(e,t){var n=t||{},o=[];return["numeric","timeout","deadline","min_reply","v6","sourceAddr","extra","packetSize"].forEach((function(e){"boolean"!=typeof n[e]&&(n[e]=n[e]||i[e])})),n.numeric&&o.push("-n"),n.timeout&&(o=o.concat(["-W",s.format("%d",n.timeout)])),n.deadline&&(o=o.concat(["-w",s.format("%d",n.deadline)])),n.min_reply&&(o=o.concat(["-c",s.format("%d",n.min_reply)])),n.sourceAddr&&(o=o.concat(["-I",s.format("%s",n.sourceAddr)])),n.packetSize&&(o=o.concat(["-s",s.format("%d",n.packetSize)])),n.extra&&(o=o.concat(n.extra)),o.push(e),o},o.getSpawnOptions=function(){return{shell:!1,env:Object.assign(process.env,{LANG:"C"})}},e.exports=o},3078:(e,t,n)=>{"use strict";var s=n(3837),o={},i={numeric:!0,timeout:2,deadline:!1,min_reply:1,v6:!1,sourceAddr:"",packetSize:56,extra:[]};o.getCommandArguments=function(e,t){var n=t||{},o=[];if(["numeric","timeout","deadline","min_reply","v6","sourceAddr","extra","packetSize"].forEach((function(e){"boolean"!=typeof n[e]&&(n[e]=n[e]||i[e])})),n.numeric&&o.push("-n"),n.timeout){if(t.v6)throw new Error("There is no timeout option on ping6");o=o.concat(["-W",s.format("%d",1e3*n.timeout)])}return n.deadline&&(o=o.concat(["-t",s.format("%d",n.deadline)])),n.min_reply&&(o=o.concat(["-c",s.format("%d",n.min_reply)])),n.sourceAddr&&(o=o.concat(["-S",s.format("%s",n.sourceAddr)])),n.packetSize&&(o=o.concat(["-s",s.format("%d",n.packetSize)])),n.extra&&(o=o.concat(n.extra)),o.push(e),o},o.getSpawnOptions=function(){return{}},e.exports=o},9674:(e,t,n)=>{"use strict";var s=n(3837),o={},i={numeric:!0,timeout:5,min_reply:1,v6:!1,sourceAddr:"",packetSize:32,extra:[]};o.getCommandArguments=function(e,t){var n=t||{},o=[];if(["numeric","timeout","min_reply","v6","sourceAddr","extra","packetSize"].forEach((function(e){"boolean"!=typeof n[e]&&(n[e]=n[e]||i[e])})),o.push(n.v6?"-6":"-4"),n.numeric||o.push("-a"),n.timeout&&(o=o.concat(["-w",s.format("%d",1e3*n.timeout)])),n.deadline)throw new Error("There is no deadline option on windows");return n.min_reply&&(o=o.concat(["-n",s.format("%d",n.min_reply)])),n.sourceAddr&&(o=o.concat(["-S",s.format("%s",n.sourceAddr)])),n.packetSize&&(o=o.concat(["-l",s.format("%d",n.packetSize)])),n.extra&&(o=o.concat(n.extra)),o.push(e),o},o.getSpawnOptions=function(){return{windowsHide:!0}},e.exports=o},5347:e=>{"use strict";function t(e,t){this._state=0,this._response={inputHost:e,host:"unknown",alive:!1,output:"unknown",time:"unknown",times:[],min:"unknown",max:"unknown",avg:"unknown",stddev:"unknown",packetLoss:"unknown"},this._times=[],this._lines=[],this._stripRegex=/[ ]*\r?\n?$/g,this._pingConfig=t||{}}t.prototype.STATES={INIT:0,HEADER:1,BODY:2,FOOTER:3,END:4},t.prototype._changeState=function(e){if(Object.keys(this.STATES).map((function(e){return this.STATES[e]}),this).indexOf(e)<0)throw new Error("Unknown state");return this._state=e,this},t.prototype._processHeader=function(e){throw new Error("Subclass should implement this method")},t.prototype._processBody=function(e){throw new Error("Subclass should implement this method")},t.prototype._processFooter=function(e){throw new Error("Subclass should implement this method")},t.prototype.eat=function(e){var t=[this.STATES.INIT,this.STATES.HEADER];this._lines.push(e);var n=e.replace(this._stripRegex,"");if(0===n.length);else if(t.indexOf(this._state)>=0)this._processHeader(n);else if(this._state===this.STATES.BODY)this._processBody(n);else if(this._state===this.STATES.FOOTER)this._processFooter(n);else if(this._state!==this.STATES.END)throw new Error("Unknown state");return this},t.prototype.getResult=function(){var e=Object.assign({},this._response);if(e.output=this._lines.join("\n"),e.alive=this._times.length>0,e.alive&&(this._response.time=this._times[0],e.time=this._response.time,this._response.times=this._times,e.times=this._response.times),"unknown"===e.stddev&&e.alive){var t=this._times.length,n=this._times.reduce((function(t,n){var s=n-e.avg;return t+s*s}),0)/t;e.stddev=Math.round(1e3*Math.sqrt(n))/1e3}return["min","avg","max","stddev","packetLoss"].forEach((function(t){var n=e[t];"number"==typeof n&&(e[t]=n.toFixed(3))})),e},e.exports=t},6394:(e,t,n)=>{"use strict";var s=n(3837),o=n(8371),i=n(5839),r=n(5096),a=n(7749);function c(){}c.createParser=function(e,t,n){var c=n||{};if(!o.isPlatformSupport(t))throw new Error(s.format("Platform |%s| is not support",t));var l=null;return o.isWindow(t)?l=new i(e,c):o.isMacOS(t)?l=new r(e,c):o.isLinux(t)&&(l=new a(e,c)),l},e.exports=c},7749:(e,t,n)=>{"use strict";var s=n(3837),o=n(5347),i=n(5096);function r(e,t){o.call(this,e,t)}s.inherits(r,o),r.prototype._processHeader=function(e){var t=e.split(" ");if(-1===t[1].indexOf("("))this._response.host=t[1],this._response.numeric_host=t[2].slice(1,-1);else{var n=t.slice(1,-3).join("").match(/([^\s()]+)/g);this._response.host=n.shift(),this._response.numeric_host=n.pop()}this._changeState(this.STATES.BODY)},r.prototype._processBody=function(e){i.prototype._processBody.call(this,e)},r.prototype._processFooter=function(e){i.prototype._processFooter.call(this,e)},e.exports=r},5096:(e,t,n)=>{"use strict";var s=n(3837),o=n(5347);function i(e,t){o.call(this,e,t)}s.inherits(i,o),i.prototype._processHeader=function(e){var t=e.split(" ");this._response.host=t[1],this._response.numeric_host=t[2].slice(1,-2),this._changeState(this.STATES.BODY)},i.prototype._processBody=function(e){if((e.match(/=/g)||[]).length>=3){var t=/([0-9.]+)[ ]*ms/.exec(e);this._times.push(parseFloat(t[1],10))}e.indexOf("---")>=0&&this._changeState(this.STATES.FOOTER)},i.prototype._processFooter=function(e){var t=e.match(/ ([\d.]+)%/);if(t&&(this._response.packetLoss=parseFloat(t[1],10)),(e.match(/[/]/g)||[]).length>=3){var n=/([0-9.]+)/g,s=n.exec(e),o=n.exec(e),i=n.exec(e),r=n.exec(e);s&&o&&i&&r&&(this._response.min=parseFloat(s[1],10),this._response.avg=parseFloat(o[1],10),this._response.max=parseFloat(i[1],10),this._response.stddev=parseFloat(r[1],10),this._changeState(this.STATES.END)),this._changeState(this.STATES.END)}},e.exports=i},5839:(e,t,n)=>{"use strict";var s=n(3837),o=n(5347);function i(e,t){o.call(this,e,t),this._ipv4Regex=/^([0-9]{1,3}\.){3}[0-9]{1,3}$/}s.inherits(i,o),i.prototype._processHeader=function(e){var t=-1===e.indexOf("["),n=e.split(" ");if(t)this._response.host=n.find((function(e){return this._ipv4Regex.test(e)}),this),this._response.numeric_host=this._response.host;else{var s=n.find((function(e){return-1!==e.indexOf("[")}),this),o=n.indexOf(s),i=/\[(.*)\]/.exec(s);this._response.numeric_host=i?i[1]:"NA",this._response.host=n[o-1]}this._changeState(this.STATES.BODY)},i.prototype._processIPV6Body=function(e){var t=e.split(" "),n=t.filter((function(e){return e.indexOf("=")>=0||e.indexOf("<")>=0}));if((n=n.map((function(e){var n=e,s=t.indexOf(e)+1;return s=1){var s=n.find((function(e){return e.search(/(ms|мс)/i)>=0})),o=/([0-9.]+)/.exec(s);this._times.push(parseFloat(o[1],10))}},i.prototype._processIPV4Body=function(e){var t=e.split(" ").filter((function(e){return e.indexOf("=")>=0||e.indexOf("<")>=0}));if(t.length>=3){var n=this._pingConfig.packetSize,o=t.find((function(e){var t=s.format("=%d",n);return e.indexOf(t)>=0})),i=t.indexOf(o),r=t[i+1],a=/([0-9.]+)/.exec(r);this._times.push(parseFloat(a[1],10))}},i.prototype._processBody=function(e){":"===e.slice(-1)?this._changeState(this.STATES.FOOTER):this._pingConfig.v6?this._processIPV6Body(e):this._processIPV4Body(e)},i.prototype._processFooter=function(e){var t=e.match(/([\d.]+)%/);if(t&&(this._response.packetLoss=parseFloat(t[1],10)),e.search(/(ms|мсек)/i)>=0){var n=/([0-9.]+)/g,s=n.exec(e),o=n.exec(e),i=n.exec(e);s&&o&&i&&(this._response.min=parseFloat(s[1],10),this._response.max=parseFloat(o[1],10),this._response.avg=parseFloat(i[1],10),this._changeState(this.STATES.END))}},e.exports=i},8835:(e,t,n)=>{"use strict";var s=n(3837),o=n(1808),i=n(2081),r=n(2037),a=n(8371),c=n(6394);t.probe=function(e,t){try{var n=function(e,t){var n=t||{};return void 0===n.v6&&(n.v6=o.isIPv6(e)),new Promise((function(t,o){var l=null,g=r.platform();try{var d=a.createBuilder(g),u=a.getExecutablePath(g,n.v6),h=d.getCommandArguments(e,n),I=d.getSpawnOptions();l=i.spawn(u,h,I)}catch(e){return void o(e)}var p=c.createParser(e,g,n);l.once("error",(function(){var e=new Error(s.format("ping.probe: %s. %s","there was an error while executing the ping program. ","Check the path or permissions..."));o(e)}));var C=[];l.stdout.on("data",(function(e){C.push(String(e))})),l.stderr.on("data",(function(e){C.push(String(e))})),l.once("close",(function(){C.join("").split("\n").forEach(p.eat,p);var e=p.getResult();t(e)}))}))}(e,t);return n}catch(e){return Promise.reject(e)}}},3583:(e,t,n)=>{"use strict";var s=n(8835);t.probe=function(e,t,n){var o=n||{};return s.probe(e,o).then((function(e){t(e.alive,null)})).catch((function(e){t(null,e)}))}},1269:e=>{"use strict";class t{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,t){if(this.cache.set(e,t),this._size++,this._size>=this.maxSize){if(this._size=0,"function"==typeof this.onEviction)for(const[e,t]of this.oldCache.entries())this.onEviction(e,t);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)){const t=this.oldCache.get(e);return this.oldCache.delete(e),this._set(e,t),t}}set(e,t){return this.cache.has(e)?this.cache.set(e,t):this._set(e,t),this}has(e){return this.cache.has(e)||this.oldCache.has(e)}peek(e){return this.cache.has(e)?this.cache.get(e):this.oldCache.has(e)?this.oldCache.get(e):void 0}delete(e){const t=this.cache.delete(e);return t&&this._size--,this.oldCache.delete(e)||t}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}*keys(){for(const[e]of this)yield e}*values(){for(const[,e]of this)yield e}*[Symbol.iterator](){for(const e of this.cache)yield e;for(const e of this.oldCache){const[t]=e;this.cache.has(t)||(yield e)}}get size(){let e=0;for(const t of this.oldCache.keys())this.cache.has(t)||e++;return Math.min(this._size+e,this.maxSize)}}e.exports=t},5322:(e,t,n)=>{"use strict";const s=n(4404);e.exports=(e={},t=s.connect)=>new Promise(((n,s)=>{let o,i=!1;const r=async()=>{await c,o.off("timeout",a),o.off("error",s),e.resolveSocket?(n({alpnProtocol:o.alpnProtocol,socket:o,timeout:i}),i&&(await Promise.resolve(),o.emit("timeout"))):(o.destroy(),n({alpnProtocol:o.alpnProtocol,timeout:i}))},a=async()=>{i=!0,r()},c=(async()=>{try{o=await t(e,r),o.on("error",s),o.once("timeout",a)}catch(e){s(e)}})()}))},2130:(e,t,n)=>{"use strict";const s=n(2037),o=n(6224),i=n(6560),{env:r}=process;let a;function c(e){return 0!==e&&{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function l(e,t){if(0===a)return 0;if(i("color=16m")||i("color=full")||i("color=truecolor"))return 3;if(i("color=256"))return 2;if(e&&!t&&void 0===a)return 0;const n=a||0;if("dumb"===r.TERM)return n;if("win32"===process.platform){const e=s.release().split(".");return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if("CI"in r)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some((e=>e in r))||"codeship"===r.CI_NAME?1:n;if("TEAMCITY_VERSION"in r)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(r.TEAMCITY_VERSION)?1:0;if("truecolor"===r.COLORTERM)return 3;if("TERM_PROGRAM"in r){const e=parseInt((r.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(r.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(r.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(r.TERM)||"COLORTERM"in r?1:n}i("no-color")||i("no-colors")||i("color=false")||i("color=never")?a=0:(i("color")||i("colors")||i("color=true")||i("color=always"))&&(a=1),"FORCE_COLOR"in r&&(a="true"===r.FORCE_COLOR?1:"false"===r.FORCE_COLOR?0:0===r.FORCE_COLOR.length?1:Math.min(parseInt(r.FORCE_COLOR,10),3)),e.exports={supportsColor:function(e){return c(l(e,e&&e.isTTY))},stdout:c(l(!0,o.isatty(1))),stderr:c(l(!0,o.isatty(2)))}},9491:e=>{"use strict";e.exports=require("assert")},4300:e=>{"use strict";e.exports=require("buffer")},2081:e=>{"use strict";e.exports=require("child_process")},1891:e=>{"use strict";e.exports=require("dgram")},2361:e=>{"use strict";e.exports=require("events")},3292:e=>{"use strict";e.exports=require("fs/promises")},3685:e=>{"use strict";e.exports=require("http")},6281:e=>{"use strict";e.exports=require("http2")},5687:e=>{"use strict";e.exports=require("https")},1405:e=>{"use strict";e.exports=require("inspector")},1808:e=>{"use strict";e.exports=require("net")},2037:e=>{"use strict";e.exports=require("os")},1017:e=>{"use strict";e.exports=require("path")},2781:e=>{"use strict";e.exports=require("stream")},4404:e=>{"use strict";e.exports=require("tls")},6224:e=>{"use strict";e.exports=require("tty")},7310:e=>{"use strict";e.exports=require("url")},3837:e=>{"use strict";e.exports=require("util")},9796:e=>{"use strict";e.exports=require("zlib")},2764:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},7359:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.runEntrypoint=void 0;const s=n(7582),o=n(9913),i=s.__importDefault(n(3292)),r=n(2068),a=n(9816);n(2421);const c=n(8221),l=s.__importDefault(n(1017));let g,d=!1;t.runEntrypoint=function(e,t){Promise.resolve().then((async()=>{if(d)throw new Error("runEntrypoint can only be called once");d=!0;const n=process.env.MODULE_MANIFEST;if(!n)throw new Error("Module initialise is missing MODULE_MANIFEST");const s=await i.default.readFile(n),u=JSON.parse(s.toString());if(u.runtime?.api!==o.HostApiNodeJsIpc)throw new Error("Module manifest 'api' mismatch");if(!u.runtime.apiVersion)throw new Error("Module manifest 'apiVersion' missing");let h=u.runtime.apiVersion;if("0.0.0"===h)try{const e=await i.default.readFile(l.default.join(__dirname,"../package.json")),t=JSON.parse(e.toString());"@companion-module/base"===t.name&&(h=t.version)}catch(e){throw new Error("Failed to determine module api version")}if(!process.send)throw new Error("Module is not being run with ipc");console.log(`Starting up module class: ${e.name}`);const I=process.env.CONNECTION_ID;if("string"!=typeof I||!I)throw new Error("Module initialise is missing CONNECTION_ID");const p=process.env.VERIFICATION_TOKEN;if("string"!=typeof p||!p)throw new Error("Module initialise is missing VERIFICATION_TOKEN");const C=process.env.SENTRY_DSN,m=process.env.SENTRY_USERID,b=process.env.SENTRY_COMPANION_VERSION;C&&m&&"https://"==C.substring(0,8)?(console.log("Sentry enabled"),(0,a.init)({dsn:C,release:`${u.name}@${u.version}`,beforeSend:e=>(e.exception&&console.log("sentry","error",e.exception),e)}),(0,a.configureScope)((e=>{e.setUser({id:m}),e.setTag("companion",b)}))):console.log("Sentry disabled");const y=new c.IpcWrapper({},(e=>{process.send(e)}),5e3);process.once("message",(e=>{y.receivedMessage(e)})),g=new e((0,r.literal)({id:I,upgradeScripts:t,_isInstanceBaseProps:!0})),y.sendWithCb("register",{apiVersion:h,connectionId:I,verificationToken:p}).then((()=>{console.log("Module-host accepted registration")}),(e=>{console.error("Module registration failed",e),process.exit(11)}))})).catch((e=>{console.error("Failed to startup module:"),console.error(e.stack||e.message),process.exit(1)}))}},1972:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UDPHelper=t.TelnetHelper=t.TCPHelper=void 0;var s=n(9159);Object.defineProperty(t,"TCPHelper",{enumerable:!0,get:function(){return s.TCPHelper}});var o=n(6226);Object.defineProperty(t,"TelnetHelper",{enumerable:!0,get:function(){return o.TelnetHelper}});var i=n(8473);Object.defineProperty(t,"UDPHelper",{enumerable:!0,get:function(){return i.UDPHelper}})},9159:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TCPHelper=void 0;const s=n(7582).__importDefault(n(1808)),o=n(6729),i=n(609);class r extends o.EventEmitter{#e;#t;_socket;#n;#s=!1;#o=!1;#i=!1;#r;#a;get isConnected(){return this.#s}get isConnecting(){return this.#o}get isDestroyed(){return this.#i}constructor(e,t,n){super(),this.#e=e,this.#t=t,this.#n={reconnect_interval:2e3,reconnect:!0,...n},this._socket=new s.default.Socket,this._socket.setKeepAlive(!0),this._socket.setNoDelay(!0),this._socket.on("error",(e=>{this.#o=!1,this.#s=!1,this.#n.reconnect&&this.#c(),this.#l(i.InstanceStatus.UnknownError,e.message),this.emit("error",e)})),this._socket.on("ready",(()=>{this.#s=!0,this.#o=!1,this.#l(i.InstanceStatus.Ok),this.emit("connect")})),this._socket.on("end",(()=>{this.#s=!1,this.#l(i.InstanceStatus.Disconnected),!this.#o&&this.#n.reconnect&&this.#c(),this.emit("end")})),this._socket.on("data",(e=>this.emit("data",e))),this._socket.on("drain",(()=>this.emit("drain"))),setImmediate((()=>this.connect())),setTimeout((()=>{this.#i||this.listenerCount("error")||console.error(`Danger: TCP client for ${this.#e}:${this.#t} is missing an error handler!`)}),5e3)}connect(){if(this.#i)throw new Error("Cannot connect destroyed socket");return!this.#o&&(this.#o=!0,this._socket.connect(this.#t,this.#e),!0)}async send(e){if(this.#i||this._socket.destroyed)throw new Error("Cannot write to destroyed socket");if(!e||!e.length)throw new Error("No message to send");if(!this.#s)return!1;try{return new Promise(((t,n)=>{this._socket.write(e,(e=>{e?n(e):t(!0)}))}))}catch(e){this.#s=!1;const t=e instanceof Error?e:new Error(`${e}`);throw this.#l(i.InstanceStatus.UnknownError,t.message),this.emit("error",t),t}}destroy(){this.#i=!0,void 0!==this.#a&&clearTimeout(this.#a),this._socket.removeAllListeners(),this.removeAllListeners(),this._socket.destroy()}#c(){void 0!==this.#a&&clearTimeout(this.#a),this.#a=setTimeout((()=>{this.#a=void 0,this.#l(i.InstanceStatus.Connecting),this.connect()}),this.#n.reconnect_interval)}#l(e,t){this.#r!=e&&(this.#r=e,this.emit("status_change",e,t))}}t.TCPHelper=r},6226:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TelnetHelper=void 0;const s=n(7582).__importDefault(n(6729)),o=n(2781),i=n(9159);class r extends s.default{#g;#d;get isConnected(){return this.#g.isConnected}get isConnecting(){return this.#g.isConnecting}get isDestroyed(){return this.#g.isDestroyed}constructor(e,t,n){super(),this.#g=new i.TCPHelper(e,t,n),this.#d=new a,this.#g._socket.pipe(this.#d),this.#g.on("connect",(()=>this.emit("connect"))),this.#g.on("end",(()=>this.emit("end"))),this.#g.on("error",(e=>this.emit("error",e))),this.#g.on("status_change",((e,t)=>this.emit("status_change",e,t))),this.#d.on("iac",((e,t)=>this.emit("iac",e,t))),this.#d.on("sb",(e=>this.emit("sb",e))),this.#d.on("data",(e=>this.emit("data",e))),this.#d.on("drain",(()=>this.emit("drain"))),setTimeout((()=>{this.isDestroyed||this.listenerCount("error")||console.error(`Danger: Telnet client for ${e}:${t} is missing an error handler!`)}),5e3)}connect(){return this.#g.connect()}async send(e){return this.#g.send(e)}destroy(){this.#g.destroy(),this.#d.removeAllListeners(),this.#d.destroy()}}t.TelnetHelper=r;class a extends o.Transform{#u;#h;#I;constructor(e){super(e),this.#u=Buffer.alloc(0),this.#h=Buffer.alloc(0),this.#I=0}_transform(e,t,n){for(let t=0;t=251&&this.#I<=254){let t;switch(this.#I){case 251:t="WILL";break;case 252:t="WONT";break;case 253:t="DO";break;case 254:t="DONT";break;default:return}return this.emit("iac",t,e),void(this.#I=0)}if(250===this.#I){if(240===e)return this.emit("sb",this.#h),this.#I=0,void(this.#h=Buffer.alloc(0));this.#h=Buffer.concat([this.#h,Buffer.from([e])])}}}#C(){const e=this.#u;return this.#u=Buffer.alloc(0),e}}},8473:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UDPHelper=void 0;const s=n(7582).__importDefault(n(1891)),o=n(6729),i=n(609);class r extends o.EventEmitter{#e;#t;#m;#n;#i=!1;#r;get isDestroyed(){return this.#i}constructor(e,t,n){super(),this.#e=e,this.#t=t,this.#n={...n},this.#m=s.default.createSocket("udp4");try{this.#m.bind(this.#n.bind_port||0,this.#n.bind_ip)}catch(e){throw new Error(`Unable to bind to ip/port: ${this.#n.bind_ip}:${this.#n.bind_port}`)}this.#n.broadcast&&this.#m.setBroadcast(!0),void 0!==this.#n.ttl&&this.#m.setTTL(this.#n.ttl),void 0!==this.#n.multicast_ttl&&this.#m.setMulticastTTL(this.#n.multicast_ttl),this.#m.on("error",(e=>{this.#l(i.InstanceStatus.UnknownError,e.message),this.emit("error",e)})),this.#m.on("listening",(()=>{this.#n.multicast_interface&&this.#m.setMulticastInterface(this.#n.multicast_interface),this.#l(i.InstanceStatus.Ok),this.emit("listening")})),this.#m.on("message",(e=>this.emit("data",e))),setTimeout((()=>{this.#i||this.listenerCount("error")||console.error(`Danger: UDP socket for ${this.#e}:${this.#t} is missing an error handler!`)}),5e3)}async send(e){if(this.#i)throw new Error("Cannot write to destroyed socket");if(!e||!e.length)throw new Error("No message to send");return new Promise(((t,n)=>{this.#m.send(e,this.#t,this.#e,(e=>{e?n(e):t()}))}))}destroy(){this.#i=!0,this.#m.removeAllListeners(),this.#m.close(),this.removeAllListeners()}#l(e,t){this.#r!=e&&(this.#r=e,this.emit("status_change",e,t))}}t.UDPHelper=r},8221:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IpcWrapper=void 0;const s=n(7582),o=n(2068),i=s.__importDefault(n(2559));t.IpcWrapper=class{#b;#y;#f;#Z=1;#A=new Map;constructor(e,t,n){this.#b=e,this.#y=t,this.#f=n}async sendWithCb(e,t,n,s=0){s<=0&&(s=this.#f);const o={timeout:void 0,resolve:()=>null,reject:()=>null},r=new Promise(((e,t)=>{o.resolve=e,o.reject=t}));this.#Z>268435456&&(this.#Z=1);const a=this.#Z++;this.#A.set(a,o),this.#y({direction:"call",name:String(e),payload:i.default.stringify(t),callbackId:a});const c=new Error("Call timed out");return o.timeout=setTimeout((()=>{o.reject(n?n():c),this.#A.delete(a)}),s),r}sendWithNoCb(e,t){this.#y({direction:"call",name:String(e),payload:i.default.stringify(t),callbackId:void 0})}receivedMessage(e){const t=e;switch(e.direction){case"call":{const t=this.#b[e.name];if(!t)return void(e.callbackId&&this.#y({direction:"response",callbackId:e.callbackId,success:!1,payload:i.default.stringify({message:`Unknown command "${e.name}"`})}));t(e.payload?i.default.parse(e.payload):void 0).then((t=>{e.callbackId&&this.#y({direction:"response",callbackId:e.callbackId,success:!0,payload:i.default.stringify(t)})}),(t=>{e.callbackId&&this.#y({direction:"response",callbackId:e.callbackId,success:!1,payload:t instanceof Error?JSON.stringify(t,Object.getOwnPropertyNames(t)):i.default.stringify(t)})}));break}case"response":{if(!e.callbackId)return void console.error("Ipc: Response message has no callbackId");const t=this.#A.get(e.callbackId);if(this.#A.delete(e.callbackId),!t)return;clearTimeout(t.timeout);const n=e.payload?i.default.parse(e.payload):void 0;if(e.success)t.resolve(n);else{let e=n;n&&"message"in n&&(e=new Error(n.message),n.stack&&(e.stack=n.stack)),t.reject(e)}break}default:(0,o.assertNever)(e),console.error(`Ipc: Message of unknown direction "${t.direction}"`)}}}},9913:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HostApiNodeJsIpc=void 0,t.HostApiNodeJsIpc="nodejs-ipc"},8049:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.runEntrypoint=t.assertNever=t.splitRgb=t.combineRgb=t.literal=void 0;const s=n(7582);s.__exportStar(n(7517),t),s.__exportStar(n(4911),t),s.__exportStar(n(2764),t);var o=n(2068);Object.defineProperty(t,"literal",{enumerable:!0,get:function(){return o.literal}}),Object.defineProperty(t,"combineRgb",{enumerable:!0,get:function(){return o.combineRgb}}),Object.defineProperty(t,"splitRgb",{enumerable:!0,get:function(){return o.splitRgb}}),Object.defineProperty(t,"assertNever",{enumerable:!0,get:function(){return o.assertNever}}),s.__exportStar(n(1972),t);var i=n(7359);Object.defineProperty(t,"runEntrypoint",{enumerable:!0,get:function(){return i.runEntrypoint}})},4391:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ActionManager=void 0;const s=n(2557);function o(e){return{id:e.id,actionId:e.actionId,controlId:e.controlId,options:e.options}}t.ActionManager=class{#G;#B;#v;#W=new Map;#V=new Map;constructor(e,t,n){this.#G=e,this.#B=t,this.#v=n}async handleExecuteAction(e){const t=this.#W.get(e.action.actionId);if(!t)throw new Error(`Unknown action: ${e.action.actionId}`);const n={parseVariablesInString:async t=>(await this.#G({text:t,controlId:e.action.controlId,actionInstanceId:e.action.id,feedbackInstanceId:void 0})).text};await t.callback({id:e.action.id,actionId:e.action.actionId,controlId:e.action.controlId,options:e.action.options,surfaceId:e.surfaceId??e.deviceId,_deviceId:e.surfaceId??e.deviceId,_page:e.action.page,_bank:e.action.bank},n)}handleUpdateActions(e){for(const[t,n]of Object.entries(e)){const e=this.#V.get(t);if(e){const t=this.#W.get(e.actionId);if(t?.unsubscribe){const n={parseVariablesInString:async t=>(await this.#G({text:t,controlId:e.controlId,actionInstanceId:e.id,feedbackInstanceId:void 0})).text};Promise.resolve(t.unsubscribe(o(e),n)).catch((t=>{this.#v("error",`Action unsubscribe failed: ${JSON.stringify(e)} - ${t?.message??t} ${t?.stack}`)}))}}if(!n||n.disabled)this.#V.delete(t);else{this.#V.set(t,n);const e=this.#W.get(n.actionId);if(e?.subscribe){const t={parseVariablesInString:async e=>(await this.#G({text:e,controlId:n.controlId,actionInstanceId:n.id,feedbackInstanceId:void 0})).text};Promise.resolve(e.subscribe(o(n),t)).catch((e=>{this.#v("error",`Action subscribe failed: ${JSON.stringify(n)} - ${e?.message??e} ${e?.stack}`)}))}}}}async handleLearnAction(e){const t=this.#W.get(e.action.actionId);if(t&&t.learn){const n={parseVariablesInString:async t=>(await this.#G({text:t,controlId:e.action.controlId,actionInstanceId:e.action.id,feedbackInstanceId:void 0})).text};return{options:await t.learn({id:e.action.id,actionId:e.action.actionId,controlId:e.action.controlId,options:e.action.options,surfaceId:void 0,_deviceId:void 0,_page:e.action.page,_bank:e.action.bank},n)}}return{options:void 0}}setActionDefinitions(e){const t=[];this.#W.clear();for(const[n,o]of Object.entries(e))o&&(t.push({id:n,name:o.name,description:o.description,options:(0,s.serializeIsVisibleFn)(o.options),hasLearn:!!o.learn}),this.#W.set(n,o));this.#B({actions:t})}_getAllActions(){return Array.from(this.#V.values()).map((e=>({id:e.id,actionId:e.actionId,controlId:e.controlId,options:e.options})))}subscribeActions(e){let t=Array.from(this.#V.values());const n=new Set(e);n.size&&(t=t.filter((e=>n.has(e.actionId))));for(const e of t){const t=this.#W.get(e.actionId);if(t?.subscribe){const n={parseVariablesInString:async t=>(await this.#G({text:t,controlId:e.controlId,actionInstanceId:e.id,feedbackInstanceId:void 0})).text};Promise.resolve(t.subscribe(o(e),n)).catch((t=>{this.#v("error",`Action subscribe failed: ${JSON.stringify(e)} - ${t?.message??t} ${t?.stack}`)}))}}}unsubscribeActions(e){let t=Array.from(this.#V.values());const n=new Set(e);n.size&&(t=t.filter((e=>n.has(e.actionId))));for(const e of t){const t=this.#W.get(e.actionId);if(t&&t.unsubscribe){const n={parseVariablesInString:async t=>(await this.#G({text:t,controlId:e.controlId,actionInstanceId:e.id,feedbackInstanceId:void 0})).text};Promise.resolve(t.unsubscribe(o(e),n)).catch((t=>{this.#v("error",`Action unsubscribe failed: ${JSON.stringify(e)} - ${t?.message??t} ${t?.stack}`)}))}}}}},2557:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isInstanceBaseProps=t.serializeIsVisibleFn=void 0,t.serializeIsVisibleFn=function(e){return(e??[]).map((e=>"isVisible"in e&&"function"==typeof e.isVisible?{...e,isVisibleFn:e.isVisible.toString(),isVisible:void 0}:{...e,isVisibleFn:void 0}))},t.isInstanceBaseProps=function(e){const t=e;return"object"==typeof t&&"string"==typeof t.id&&!0===t._isInstanceBaseProps}},7550:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FeedbackManager=void 0;const s=n(7582),o=n(2557),i=s.__importDefault(n(3453));function r(e,t){return{type:e,id:t.id,feedbackId:t.feedbackId,controlId:t.controlId,options:t.options}}t.FeedbackManager=class{#G;#w;#S;#v;#R=new Map;#H=new Map;#X=new Map;#k=new Map;#Y;get parseVariablesContext(){return this.#Y}constructor(e,t,n,s){this.#G=e,this.#w=t,this.#S=n,this.#v=s}getDefinitionIds(){return Array.from(this.#R.keys())}getInstanceIds(){return Array.from(this.#H.keys())}handleUpdateFeedbacks(e){for(const[t,n]of Object.entries(e)){const e=this.#H.get(t);if(e){const t=this.#R.get(e.feedbackId);if(t?.unsubscribe){const n={parseVariablesInString:async t=>(await this.#G({text:t,controlId:e.controlId,actionInstanceId:void 0,feedbackInstanceId:e.id})).text};Promise.resolve(t.unsubscribe(r(t.type,e),n)).catch((t=>{this.#v("error",`Feedback unsubscribe failed: ${JSON.stringify(e)} - ${t?.message??t} ${t?.stack}`)}))}}if(!n||n.disabled)this.#H.delete(t);else{this.#H.set(t,{...n,referencedVariables:null});const e=this.#R.get(n.feedbackId);if(e?.subscribe){const t={parseVariablesInString:async e=>(await this.#G({text:e,controlId:n.controlId,actionInstanceId:void 0,feedbackInstanceId:n.id})).text};Promise.resolve(e.subscribe(r(e.type,n),t)).catch((e=>{this.#v("error",`Feedback subscribe failed: ${JSON.stringify(n)} - ${e?.message??e} ${e?.stack}`)}))}this.#N(t)}}}async handleLearnFeedback(e){const t=this.#R.get(e.feedback.feedbackId);if(t&&t.learn){const n={parseVariablesInString:async t=>(await this.#G({text:t,controlId:e.feedback.controlId,actionInstanceId:void 0,feedbackInstanceId:e.feedback.id})).text};return{options:await t.learn({id:e.feedback.id,feedbackId:e.feedback.feedbackId,controlId:e.feedback.controlId,options:e.feedback.options,type:t.type},n)}}return{options:void 0}}handleVariablesChanged(e){if(!e.variablesIds.length)return;const t=new Set(e.variablesIds);for(const t of this.#k.values())for(const n of e.variablesIds)t.changedVariables.add(n);const n=new Set;for(const e of this.#H.values())if(!this.#k.has(e.id)&&e.referencedVariables)for(const s of e.referencedVariables)if(t.has(s)){n.add(e.id);break}for(const e of n)setImmediate((()=>{this.#N(e)}))}#N(e){const t=this.#k.get(e);if(t)return void(t.needsRecheck=!0);const n=this.#H.get(e);if(!n)return;const s=n,o={needsRecheck:!1,changedVariables:new Set};this.#k.set(e,o),Promise.resolve().then((async()=>{const t=this.#R.get(s.feedbackId);let n;const o=new Set;if(t){this.#Y=`Feedback ${s.feedbackId} (${e})`;const i={parseVariablesInString:async t=>{const n=await this.#G({text:t,controlId:s.controlId,actionInstanceId:void 0,feedbackInstanceId:e});if(n.variableIds&&n.variableIds.length)for(const e of n.variableIds)o.add(e);return n.text}};n="boolean"===t.type?t.callback({...r("boolean",s),type:"boolean",_rawBank:s.rawBank},i):t.callback({...r("advanced",s),type:"advanced",image:s.image,_page:s.page,_bank:s.bank,_rawBank:s.rawBank},i),this.#Y=void 0}const i=await n;this.#X.set(e,{id:e,controlId:s.controlId,value:i}),this.#J(),s.referencedVariables=o.size>0?Array.from(o):null})).catch((e=>{console.error(`Feedback check failed: ${JSON.stringify(s)} - ${e?.message??e} ${e?.stack}`)})).finally((()=>{this.#Y=void 0,this.#k.delete(e);let t=!1;if(s.referencedVariables)for(const e of s.referencedVariables)if(o.changedVariables.has(e)){t=!0;break}(t||o.needsRecheck)&&setImmediate((()=>{this.#N(e)}))}))}#J=(0,i.default)((()=>{const e=this.#X;this.#X=new Map,e.size>0&&this.#w({values:Array.from(e.values())})}),{wait:5,maxWait:25});setFeedbackDefinitions(e){const t=[];this.#R.clear();for(const[n,s]of Object.entries(e))s&&(t.push({id:n,name:s.name,description:s.description,options:(0,o.serializeIsVisibleFn)(s.options),type:s.type,defaultStyle:"boolean"===s.type?s.defaultStyle:void 0,hasLearn:!!s.learn,showInvert:"boolean"===s.type&&s.showInvert}),this.#R.set(n,s));this.#S({feedbacks:t})}checkFeedbacks(e){const t=new Set(e);for(const[e,n]of this.#H.entries())this.#R.get(n.feedbackId)&&(0===t.size||t.has(n.feedbackId))&&this.#N(e)}checkFeedbacksById(e){for(const t of e)this.#N(t)}_getAllFeedbacks(){return Array.from(this.#H.values()).map((e=>({id:e.id,feedbackId:e.feedbackId,controlId:e.controlId,options:e.options})))}subscribeFeedbacks(e){let t=Array.from(this.#H.values());const n=new Set(e);n.size&&(t=t.filter((e=>n.has(e.feedbackId))));for(const e of t){const t=this.#R.get(e.feedbackId);if(t?.subscribe){const n={parseVariablesInString:async t=>(await this.#G({text:t,controlId:e.controlId,actionInstanceId:void 0,feedbackInstanceId:e.id})).text};Promise.resolve(t.subscribe(r(t.type,e),n)).catch((t=>{this.#v("error",`Feedback subscribe failed: ${JSON.stringify(e)} - ${t?.message??t} ${t?.stack}`)}))}}}unsubscribeFeedbacks(e){let t=Array.from(this.#H.values());const n=new Set(e);n.size&&(t=t.filter((e=>n.has(e.feedbackId))));for(const e of t){const t=this.#R.get(e.feedbackId);if(t&&t.unsubscribe){const n={parseVariablesInString:async t=>(await this.#G({text:t,controlId:e.controlId,actionInstanceId:void 0,feedbackInstanceId:e.id})).text};Promise.resolve(t.unsubscribe(r(t.type,e),n)).catch((t=>{this.#v("error",`Feedback unsubscribe failed: ${JSON.stringify(e)} - ${t?.message??t} ${t?.stack}`)}))}}}}},1806:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.runThroughUpgradeScripts=void 0;const s=n(2068);function o(e){return JSON.parse(JSON.stringify(e))}t.runThroughUpgradeScripts=function(e,t,n,i,r,a){const c=new Map,l=e=>{let t=c.get(e);return t||(t={actions:[],feedbacks:[],config:!1},c.set(e,t)),t};for(const t of Object.values(e)){const e=t?.upgradeIndex??n;t&&"number"==typeof e&&l(e).actions.push(t.id)}for(const e of Object.values(t)){const t=e?.upgradeIndex??n;e&&"number"==typeof t&&l(t).feedbacks.push(e.id)}if(!a)for(let e=n??-1;e0){const a=Array.from(c.keys()).sort(),l=Math.min(...a,n??-1)+1,h=[],I=[],p=i.length;for(let n=l;n{const n=e[t];if(n)return(0,s.literal)({id:n.id,controlId:n.controlId,actionId:n.actionId,options:void 0!==n.options?o(n.options):{}})})).filter((e=>!!e)),feedbacks:I.map((e=>{const n=t[e];if(n)return(0,s.literal)({id:n.id,controlId:n.controlId,feedbackId:n.feedbackId,options:void 0!==n.options?o(n.options):{},isInverted:n.isInverted})})).filter((e=>!!e))});l&&C.updatedConfig&&(u=C.updatedConfig);for(const t of C.updatedActions)if(t){const n=e[t.id];n&&(n.actionId=t.actionId,n.options=t.options,d[t.id]=n)}for(const e of C.updatedFeedbacks)if(e){const n=t[e.id];n&&(n.feedbackId=e.feedbackId,n.options=e.options,g[e.id]={...n,style:g[e.id]?.style??e.style,isInverted:e.isInverted??!1})}}for(const[t,n]of Object.entries(e))d[t]||"number"!=typeof n?.upgradeIndex||(d[t]=n);for(const[e,n]of Object.entries(t))g[e]||"number"!=typeof n?.upgradeIndex||(g[e]=n)}return{updatedActions:d,updatedFeedbacks:g,updatedConfig:u}}},7517:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validateManifest=void 0;const s=n(7582).__importDefault(n(4618));t.validateManifest=function(e){if(!(0,s.default)(e)){const e=s.default.errors;if(!e)throw new Error("Manifest failed validation with unknown reason");throw new Error(`Manifest validation failed: ${JSON.stringify(e)}`)}}},8322:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},5203:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InstanceBase=void 0;const s=n(7582),o=n(2068),i=s.__importDefault(n(5860)),r=n(2557),a=n(1806),c=n(7550),l=n(8221),g=n(4391);t.InstanceBase=class{#_;#K;id;#F=new i.default({concurrency:1});#x=!1;#z=!1;#T={};#E;#U;#Q=new Map;#L=new Map;#n;#O;get instanceOptions(){return this.#n}get label(){return this.#O}constructor(e){if(!(0,r.isInstanceBaseProps)(e)||!e._isInstanceBaseProps)throw new Error("Module instance is being constructed incorrectly. Make sure you aren't trying to do this manually");this.#n={disableVariableValidation:!1},this.#_=new l.IpcWrapper({init:this._handleInit.bind(this),destroy:this._handleDestroy.bind(this),updateConfigAndLabel:this._handleConfigUpdateAndLabel.bind(this),updateConfig:async()=>{},executeAction:this._handleExecuteAction.bind(this),updateFeedbacks:this._handleUpdateFeedbacks.bind(this),updateActions:this._handleUpdateActions.bind(this),getConfigFields:this._handleGetConfigFields.bind(this),handleHttpRequest:this._handleHttpRequest.bind(this),learnAction:this._handleLearnAction.bind(this),learnFeedback:this._handleLearnFeedback.bind(this),startStopRecordActions:this._handleStartStopRecordActions.bind(this),variablesChanged:this._handleVariablesChanged.bind(this)},(e=>{process.send(e)}),5e3),process.on("message",(e=>{this.#_.receivedMessage(e)})),this.#E=new g.ActionManager((async e=>this.#_.sendWithCb("parseVariablesInString",e)),(e=>this.#_.sendWithNoCb("setActionDefinitions",e)),this.log.bind(this)),this.#U=new c.FeedbackManager((async e=>this.#_.sendWithCb("parseVariablesInString",e)),(e=>this.#_.sendWithNoCb("updateFeedbackValues",e)),(e=>this.#_.sendWithNoCb("setFeedbackDefinitions",e)),this.log.bind(this)),this.#K=e.upgradeScripts,this.id=e.id,this.#O=e.id,this.log("debug","Initializing")}async _handleInit(e){return this.#F.add((async()=>{if(this.#x)throw new Error("Already initialized");const t=e.actions,n=e.feedbacks;if(this.#T=e.config,this.#O=e.label,e.isFirstInit){const t={},n=this.getConfigFields();for(const e of n)"default"in e&&(t[e.id]=e.default);this.#T=t,this.saveConfig(this.#T),e.lastUpgradeIndex=this.#K.length-1}const{updatedActions:s,updatedFeedbacks:o,updatedConfig:i}=(0,a.runThroughUpgradeScripts)(t,n,e.lastUpgradeIndex,this.#K,this.#T,!1);this.#T=i??this.#T;const r=this.#_.sendWithCb("upgradedItems",{updatedActions:s,updatedFeedbacks:o});try{await this.init(this.#T,!!e.isFirstInit),this.#x=!0}catch(e){throw console.trace(`Init failed: ${e}`),e}finally{await r}return setImmediate((()=>{this._handleUpdateActions({actions:t},!0).catch((e=>{this.log("error",`Receive actions failed: ${e}`)})),this._handleUpdateFeedbacks({feedbacks:n},!0).catch((e=>{this.log("error",`Receive feedbacks failed: ${e}`)}))})),{hasHttpHandler:"function"==typeof this.handleHttpRequest,hasRecordActionsHandler:"function"==typeof this.handleStartStopRecordActions,newUpgradeIndex:this.#K.length-1,updatedConfig:this.#T}}))}async _handleDestroy(){await this.#F.add((async()=>{if(!this.#x)throw new Error("Not initialized");await this.destroy(),this.#x=!1}))}async _handleConfigUpdateAndLabel(e){await this.#F.add((async()=>{if(!this.#x)throw new Error("Not initialized");this.#O=e.label,this.#T=e.config,await this.configUpdated(this.#T)}))}async _handleExecuteAction(e){return this.#E.handleExecuteAction(e)}async _handleUpdateFeedbacks(e,t){if(!t){const t=(0,a.runThroughUpgradeScripts)({},e.feedbacks,null,this.#K,this.#T,!0);this.#_.sendWithCb("upgradedItems",{updatedActions:t.updatedActions,updatedFeedbacks:t.updatedFeedbacks}).catch((e=>{this.log("error",`Failed to save upgraded feedbacks: ${e}`)}))}this.#U.handleUpdateFeedbacks(e.feedbacks)}async _handleUpdateActions(e,t){if(!t){const t=(0,a.runThroughUpgradeScripts)(e.actions,{},null,this.#K,this.#T,!0);this.#_.sendWithCb("upgradedItems",{updatedActions:t.updatedActions,updatedFeedbacks:t.updatedFeedbacks}).catch((e=>{this.log("error",`Failed to save upgraded actions: ${e}`)}))}this.#E.handleUpdateActions(e.actions)}async _handleGetConfigFields(e){return{fields:(0,r.serializeIsVisibleFn)(this.getConfigFields())}}async _handleHttpRequest(e){if(!this.handleHttpRequest)throw new Error("handleHttpRequest is not supported!");return{response:await this.handleHttpRequest(e.request)}}async _handleLearnAction(e){return this.#E.handleLearnAction(e)}async _handleLearnFeedback(e){return this.#U.handleLearnFeedback(e)}async _handleStartStopRecordActions(e){if(e.recording){if(this.#z)return}else if(!this.#z)return;if(!this.handleStartStopRecordActions)throw this.#z=!1,new Error("Recording actions is not supported by this module!");this.#z=e.recording,this.handleStartStopRecordActions(this.#z)}async _handleVariablesChanged(e){this.#U.handleVariablesChanged(e)}saveConfig(e){this.#T=e,this.#_.sendWithNoCb("saveConfig",{config:e})}setActionDefinitions(e){this.#E.setActionDefinitions(e)}setFeedbackDefinitions(e){this.#U.setFeedbackDefinitions(e)}setPresetDefinitions(e){const t=[];for(const[n,s]of Object.entries(e))s&&t.push({...s,id:n});this.#_.sendWithNoCb("setPresetDefinitions",{presets:t})}setVariableDefinitions(e){const t=[];this.#Q.clear();for(const n of e)t.push({id:n.variableId,name:n.name}),this.#Q.set(n.variableId,n),this.#L.has(n.variableId)||this.#L.set(n.variableId,"");if(!this.#n.disableVariableValidation){const e=new Set(this.#Q.keys());for(const t of this.#L.keys())e.has(t)||this.#L.delete(t)}this.#_.sendWithNoCb("setVariableDefinitions",{variables:t})}setVariableValues(e){const t=[];for(const[n,s]of Object.entries(e))this.#n.disableVariableValidation?(void 0===s?this.#L.delete(n):this.#L.set(n,s),t.push({id:n,value:s})):this.#Q.has(n)?(this.#L.set(n,s??""),t.push({id:n,value:s??""})):t.push({id:n,value:void 0});this.#_.sendWithNoCb("setVariableValues",{newValues:t})}getVariableValue(e){return this.#L.get(e)}async parseVariablesInString(e){const t=this.#U.parseVariablesContext;return t&&this.log("debug",`parseVariablesInString called while in: ${t}. You should use the parseVariablesInString provided to the callback instead`),(await this.#_.sendWithCb("parseVariablesInString",{text:e,controlId:void 0,actionInstanceId:void 0,feedbackInstanceId:void 0})).text}checkFeedbacks(...e){this.#U.checkFeedbacks(e)}checkFeedbacksById(...e){this.#U.checkFeedbacksById(e)}_getAllActions(){return this.#E._getAllActions()}subscribeActions(...e){this.#E.subscribeActions(e)}unsubscribeActions(...e){this.#E.unsubscribeActions(e)}_getAllFeedbacks(){return this.#U._getAllFeedbacks()}subscribeFeedbacks(...e){this.#U.subscribeFeedbacks(e)}unsubscribeFeedbacks(...e){this.#U.unsubscribeFeedbacks(e)}recordAction(e,t){if(!this.#z)throw new Error("Not currently recording actions");this.#_.sendWithNoCb("recordAction",{uniquenessId:t??null,actionId:e.actionId,options:e.options})}setCustomVariableValue(e,t){this.#_.sendWithNoCb("setCustomVariable",{customVariableId:e,value:t})}oscSend(e,t,n,s){this.#_.sendWithNoCb("send-osc",(0,o.literal)({host:e,port:t,path:n,args:s}))}updateStatus(e,t){this.#_.sendWithNoCb("set-status",(0,o.literal)({status:e,message:t??null}))}log(e,t){this.#_.sendWithNoCb("log-message",(0,o.literal)({level:e,message:t}))}}},9051:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},609:(e,t)=>{"use strict";var n,s;Object.defineProperty(t,"__esModule",{value:!0}),t.Regex=t.InstanceStatus=void 0,(s=t.InstanceStatus||(t.InstanceStatus={})).Ok="ok",s.Connecting="connecting",s.Disconnected="disconnected",s.ConnectionFailure="connection_failure",s.BadConfig="bad_config",s.UnknownError="unknown_error",s.UnknownWarning="unknown_warning",(n=t.Regex||(t.Regex={})).IP="/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/",n.HOSTNAME="/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9])$/",n.BOOLEAN="/^(true|false|0|1)$/i",n.PORT="/^([1-9]|[1-8][0-9]|9[0-9]|[1-8][0-9]{2}|9[0-8][0-9]|99[0-9]|[1-8][0-9]{3}|9[0-8][0-9]{2}|99[0-8][0-9]|999[0-9]|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-4])$/",n.PERCENT="/^(100|[0-9]|[0-9][0-9])$/",n.FLOAT="/^([0-9]*\\.)?[0-9]+$/",n.SIGNED_FLOAT="/^[+-]?([0-9]*\\.)?[0-9]+$/",n.FLOAT_OR_INT="/^([0-9]+)(\\.[0-9]+)?$/",n.NUMBER="/^\\d+$/",n.SIGNED_NUMBER="/^[+-]?\\d+$/",n.SOMETHING="/^.+$/",n.TIMECODE="/^(0*[0-9]|1[0-9]|2[0-4]):(0*[0-9]|[1-5][0-9]|60):(0*[0-9]|[1-5][0-9]|60):(0*[0-9]|[12][0-9]|30)$/"},4334:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},2490:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},4911:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const s=n(7582);s.__exportStar(n(8322),t),s.__exportStar(n(5203),t),s.__exportStar(n(9051),t),s.__exportStar(n(609),t),s.__exportStar(n(4334),t),s.__exportStar(n(2490),t),s.__exportStar(n(3646),t),s.__exportStar(n(3558),t),s.__exportStar(n(4788),t),s.__exportStar(n(521),t),s.__exportStar(n(6870),t)},3646:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},3558:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},4788:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},521:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CreateUseBuiltinInvertForFeedbacksUpgradeScript=t.CreateConvertToBooleanFeedbackUpgradeScript=t.EmptyUpgradeScript=void 0,t.EmptyUpgradeScript=()=>({updatedConfig:null,updatedActions:[],updatedFeedbacks:[]}),t.CreateConvertToBooleanFeedbackUpgradeScript=function(e){return(t,n)=>{const s=[];for(const t of n.feedbacks){let n=e[t.feedbackId];if(!0===n&&(n={bg:"bgcolor",bgcolor:"bgcolor",fg:"color",color:"color",png64:"png64",png:"png64"}),n){t.style||(t.style={});for(const[e,o]of Object.entries(n))void 0!==t.options[e]&&(t.style[o]=t.options[e],delete t.options[e],s.push(t))}}return{updatedConfig:null,updatedActions:[],updatedFeedbacks:s}}},t.CreateUseBuiltinInvertForFeedbacksUpgradeScript=function(e){return(t,n)=>{const s=[];for(const t of n.feedbacks){let n=e[t.feedbackId];if("string"!=typeof n)continue;const o=t.options[n];void 0!==o&&(delete t.options[n],t.isInverted="true"===o||!0===o||Number(o)>0,s.push(t))}return{updatedConfig:null,updatedActions:[],updatedFeedbacks:s}}}},6870:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},2068:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.splitRgb=t.combineRgb=t.assertNever=t.literal=void 0,t.literal=function(e){return e},t.assertNever=function(e){},t.combineRgb=function(e,t,n){return(255&e)<<16|(255&t)<<8|255&n},t.splitRgb=function(e){return{r:(16711680&e)>>16,g:(65280&e)>>8,b:255&e}}},4618:(e,t,n)=>{"use strict";e.exports=i,e.exports.default=i;const s={$schema:"http://json-schema.org/draft-07/schema#",type:"object",title:"ModuleManifest",properties:{id:{type:"string",description:"Unique identifier for the module"},name:{type:"string",description:"Name of the module"},shortname:{type:"string"},description:{type:"string",description:"Description of the module "},version:{type:"string",description:"Current version of the module"},license:{type:"string",description:"SPDX identifier for license of the module"},repository:{type:"string",description:"URL to the source repository"},bugs:{type:"string",description:"URL to bug tracker"},maintainers:{type:"array",description:"List of active maintiners",uniqueItems:!0,items:{type:"object",title:"ModuleManifestMaintainer",properties:{name:{type:"string"},email:{type:"string"},github:{type:"string"}},required:["name"]}},legacyIds:{type:"array",description:"If the module had a different unique identifier previously, then specify it here",uniqueItems:!0,items:{type:"string"}},runtime:{type:"object",title:"ModuleManifestRuntime",description:"Information on how to execute the module",properties:{type:{type:"string",description:"Type of the module. Must be: node18"},api:{type:"string",description:"Which host-api does it use. In the future alternate options will be allowed",enum:["nodejs-ipc"]},apiVersion:{type:"string",description:"The version of the host-api used"},entrypoint:{type:"string",description:"Entrypoint to pass to the runtime. eg index.js"}},required:["type","api","apiVersion","entrypoint"]},manufacturer:{type:"string"},products:{type:"array",uniqueItems:!0,items:{type:"string"}},keywords:{type:"array",uniqueItems:!0,items:{type:"string"}}},required:["id","name","shortname","description","version","license","repository","bugs","maintainers","legacyIds","runtime","manufacturer","products","keywords"]},o=n(7056).Z;function i(e,{instancePath:t="",parentData:n,parentDataProperty:r,rootData:a=e}={}){if(!e||"object"!=typeof e||Array.isArray(e))return i.errors=[{instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;{let n;if(void 0===e.id&&(n="id")||void 0===e.name&&(n="name")||void 0===e.shortname&&(n="shortname")||void 0===e.description&&(n="description")||void 0===e.version&&(n="version")||void 0===e.license&&(n="license")||void 0===e.repository&&(n="repository")||void 0===e.bugs&&(n="bugs")||void 0===e.maintainers&&(n="maintainers")||void 0===e.legacyIds&&(n="legacyIds")||void 0===e.runtime&&(n="runtime")||void 0===e.manufacturer&&(n="manufacturer")||void 0===e.products&&(n="products")||void 0===e.keywords&&(n="keywords"))return i.errors=[{instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:n},message:"must have required property '"+n+"'"}],!1;if(void 0!==e.id){const n=0;if("string"!=typeof e.id)return i.errors=[{instancePath:t+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var c=0===n}else c=!0;if(c){if(void 0!==e.name){const n=0;if("string"!=typeof e.name)return i.errors=[{instancePath:t+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;c=0===n}else c=!0;if(c){if(void 0!==e.shortname){const n=0;if("string"!=typeof e.shortname)return i.errors=[{instancePath:t+"/shortname",schemaPath:"#/properties/shortname/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;c=0===n}else c=!0;if(c){if(void 0!==e.description){const n=0;if("string"!=typeof e.description)return i.errors=[{instancePath:t+"/description",schemaPath:"#/properties/description/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;c=0===n}else c=!0;if(c){if(void 0!==e.version){const n=0;if("string"!=typeof e.version)return i.errors=[{instancePath:t+"/version",schemaPath:"#/properties/version/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;c=0===n}else c=!0;if(c){if(void 0!==e.license){const n=0;if("string"!=typeof e.license)return i.errors=[{instancePath:t+"/license",schemaPath:"#/properties/license/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;c=0===n}else c=!0;if(c){if(void 0!==e.repository){const n=0;if("string"!=typeof e.repository)return i.errors=[{instancePath:t+"/repository",schemaPath:"#/properties/repository/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;c=0===n}else c=!0;if(c){if(void 0!==e.bugs){const n=0;if("string"!=typeof e.bugs)return i.errors=[{instancePath:t+"/bugs",schemaPath:"#/properties/bugs/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;c=0===n}else c=!0;if(c){if(void 0!==e.maintainers){let n=e.maintainers;const s=0;if(0===s){if(!Array.isArray(n))return i.errors=[{instancePath:t+"/maintainers",schemaPath:"#/properties/maintainers/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;{var l=!0;const e=n.length;for(let s=0;s1)for(;s--;)for(e=s;e--;)if(o(n[s],n[e]))return i.errors=[{instancePath:t+"/maintainers",schemaPath:"#/properties/maintainers/uniqueItems",keyword:"uniqueItems",params:{i:s,j:e},message:"must NOT have duplicate items (items ## "+e+" and "+s+" are identical)"}],!1}}}c=0===s}else c=!0;if(c){if(void 0!==e.legacyIds){let n=e.legacyIds;const s=0;if(0===s){if(!Array.isArray(n))return i.errors=[{instancePath:t+"/legacyIds",schemaPath:"#/properties/legacyIds/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;{var d=!0;const e=n.length;for(let s=0;s1){const o={};for(;s--;){let r=n[s];if("string"==typeof r){if("number"==typeof o[r])return e=o[r],i.errors=[{instancePath:t+"/legacyIds",schemaPath:"#/properties/legacyIds/uniqueItems",keyword:"uniqueItems",params:{i:s,j:e},message:"must NOT have duplicate items (items ## "+e+" and "+s+" are identical)"}],!1;o[r]=s}}}}}}c=0===s}else c=!0;if(c){if(void 0!==e.runtime){let n=e.runtime;const o=0;if(0===o){if(!n||"object"!=typeof n||Array.isArray(n))return i.errors=[{instancePath:t+"/runtime",schemaPath:"#/properties/runtime/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;{let e;if(void 0===n.type&&(e="type")||void 0===n.api&&(e="api")||void 0===n.apiVersion&&(e="apiVersion")||void 0===n.entrypoint&&(e="entrypoint"))return i.errors=[{instancePath:t+"/runtime",schemaPath:"#/properties/runtime/required",keyword:"required",params:{missingProperty:e},message:"must have required property '"+e+"'"}],!1;if(void 0!==n.type){const e=0;if("string"!=typeof n.type)return i.errors=[{instancePath:t+"/runtime/type",schemaPath:"#/properties/runtime/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=0===e}else u=!0;if(u){if(void 0!==n.api){let e=n.api;const o=0;if("string"!=typeof e)return i.errors=[{instancePath:t+"/runtime/api",schemaPath:"#/properties/runtime/properties/api/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if("nodejs-ipc"!==e)return i.errors=[{instancePath:t+"/runtime/api",schemaPath:"#/properties/runtime/properties/api/enum",keyword:"enum",params:{allowedValues:s.properties.runtime.properties.api.enum},message:"must be equal to one of the allowed values"}],!1;u=0===o}else u=!0;if(u){if(void 0!==n.apiVersion){const e=0;if("string"!=typeof n.apiVersion)return i.errors=[{instancePath:t+"/runtime/apiVersion",schemaPath:"#/properties/runtime/properties/apiVersion/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;u=0===e}else u=!0;if(u)if(void 0!==n.entrypoint){const e=0;if("string"!=typeof n.entrypoint)return i.errors=[{instancePath:t+"/runtime/entrypoint",schemaPath:"#/properties/runtime/properties/entrypoint/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;u=0===e}else u=!0}}}}c=0===o}else c=!0;if(c){if(void 0!==e.manufacturer){const n=0;if("string"!=typeof e.manufacturer)return i.errors=[{instancePath:t+"/manufacturer",schemaPath:"#/properties/manufacturer/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;c=0===n}else c=!0;if(c){if(void 0!==e.products){let n=e.products;const s=0;if(0===s){if(!Array.isArray(n))return i.errors=[{instancePath:t+"/products",schemaPath:"#/properties/products/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;{var h=!0;const e=n.length;for(let s=0;s1){const o={};for(;s--;){let r=n[s];if("string"==typeof r){if("number"==typeof o[r])return e=o[r],i.errors=[{instancePath:t+"/products",schemaPath:"#/properties/products/uniqueItems",keyword:"uniqueItems",params:{i:s,j:e},message:"must NOT have duplicate items (items ## "+e+" and "+s+" are identical)"}],!1;o[r]=s}}}}}}c=0===s}else c=!0;if(c)if(void 0!==e.keywords){let n=e.keywords;const s=0;if(0===s){if(!Array.isArray(n))return i.errors=[{instancePath:t+"/keywords",schemaPath:"#/properties/keywords/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;{var I=!0;const e=n.length;for(let s=0;s1){const o={};for(;s--;){let r=n[s];if("string"==typeof r){if("number"==typeof o[r])return e=o[r],i.errors=[{instancePath:t+"/keywords",schemaPath:"#/properties/keywords/uniqueItems",keyword:"uniqueItems",params:{i:s,j:e},message:"must NOT have duplicate items (items ## "+e+" and "+s+" are identical)"}],!1;o[r]=s}}}}}}c=0===s}else c=!0}}}}}}}}}}}}}return i.errors=null,!0}},3453:(e,t,n)=>{"use strict";const s=n(4341);e.exports=(e,t={})=>{if("function"!=typeof e)throw new TypeError(`Expected the first argument to be a function, got \`${typeof e}\``);const{wait:n=0,maxWait:o=0,before:i=!1,after:r=!0}=t;if(!i&&!r)throw new Error("Both `before` and `after` are false, function wouldn't be called.");let a,c,l;const g=function(...t){const s=this,g=i&&!a;return clearTimeout(a),a=setTimeout((()=>{a=void 0,c&&(clearTimeout(c),c=void 0),r&&(l=e.apply(s,t))}),n),o>0&&!c&&r&&(c=setTimeout((()=>{c=void 0,a&&(clearTimeout(a),a=void 0),l=e.apply(s,t)}),o)),g&&(l=e.apply(s,t)),l};return s(g,e),g.cancel=()=>{a&&(clearTimeout(a),a=void 0),c&&(clearTimeout(c),c=void 0)},g}},7582:(e,t,n)=>{"use strict";n.r(t),n.d(t,{__addDisposableResource:()=>Y,__assign:()=>i,__asyncDelegator:()=>v,__asyncGenerator:()=>B,__asyncValues:()=>W,__await:()=>G,__awaiter:()=>I,__classPrivateFieldGet:()=>H,__classPrivateFieldIn:()=>k,__classPrivateFieldSet:()=>X,__createBinding:()=>C,__decorate:()=>a,__disposeResources:()=>J,__esDecorate:()=>l,__exportStar:()=>m,__extends:()=>o,__generator:()=>p,__importDefault:()=>R,__importStar:()=>S,__makeTemplateObject:()=>V,__metadata:()=>h,__param:()=>c,__propKey:()=>d,__read:()=>y,__rest:()=>r,__runInitializers:()=>g,__setFunctionName:()=>u,__spread:()=>f,__spreadArray:()=>A,__spreadArrays:()=>Z,__values:()=>b,default:()=>_});var s=function(e,t){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},s(e,t)};function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}s(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var i=function(){return i=Object.assign||function(e){for(var t,n=1,s=arguments.length;n=0;a--)(o=e[a])&&(r=(i<3?o(r):i>3?o(t,n,r):o(t,n))||r);return i>3&&r&&Object.defineProperty(t,n,r),r}function c(e,t){return function(n,s){t(n,s,e)}}function l(e,t,n,s,o,i){function r(e){if(void 0!==e&&"function"!=typeof e)throw new TypeError("Function expected");return e}for(var a,c=s.kind,l="getter"===c?"get":"setter"===c?"set":"value",g=!t&&e?s.static?e:e.prototype:null,d=t||(g?Object.getOwnPropertyDescriptor(g,s.name):{}),u=!1,h=n.length-1;h>=0;h--){var I={};for(var p in s)I[p]="access"===p?{}:s[p];for(var p in s.access)I.access[p]=s.access[p];I.addInitializer=function(e){if(u)throw new TypeError("Cannot add initializers after decoration has completed");i.push(r(e||null))};var C=(0,n[h])("accessor"===c?{get:d.get,set:d.set}:d[l],I);if("accessor"===c){if(void 0===C)continue;if(null===C||"object"!=typeof C)throw new TypeError("Object expected");(a=r(C.get))&&(d.get=a),(a=r(C.set))&&(d.set=a),(a=r(C.init))&&o.unshift(a)}else(a=r(C))&&("field"===c?o.unshift(a):d[l]=a)}g&&Object.defineProperty(g,s.name,d),u=!0}function g(e,t,n){for(var s=arguments.length>2,o=0;o0&&o[o.length-1])||6!==a[0]&&2!==a[0])){r=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]=e.length&&(e=void 0),{value:e&&e[s++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function y(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var s,o,i=n.call(e),r=[];try{for(;(void 0===t||t-- >0)&&!(s=i.next()).done;)r.push(s.value)}catch(e){o={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return r}function f(){for(var e=[],t=0;t1||a(e,t)}))})}function a(e,t){try{(n=o[e](t)).value instanceof G?Promise.resolve(n.value.v).then(c,l):g(i[0][2],n)}catch(e){g(i[0][3],e)}var n}function c(e){a("next",e)}function l(e){a("throw",e)}function g(e,t){e(t),i.shift(),i.length&&a(i[0][0],i[0][1])}}function v(e){var t,n;return t={},s("next"),s("throw",(function(e){throw e})),s("return"),t[Symbol.iterator]=function(){return this},t;function s(s,o){t[s]=e[s]?function(t){return(n=!n)?{value:G(e[s](t)),done:!1}:o?o(t):t}:o}}function W(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=b(e),t={},s("next"),s("throw"),s("return"),t[Symbol.asyncIterator]=function(){return this},t);function s(n){t[n]=e[n]&&function(t){return new Promise((function(s,o){!function(e,t,n,s){Promise.resolve(s).then((function(t){e({value:t,done:n})}),t)}(s,o,(t=e[n](t)).done,t.value)}))}}}function V(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var w=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t};function S(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&C(t,e,n);return w(t,e),t}function R(e){return e&&e.__esModule?e:{default:e}}function H(e,t,n,s){if("a"===n&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?s:"a"===n?s.call(e):s?s.value:t.get(e)}function X(e,t,n,s,o){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?o.call(e,n):o?o.value=n:t.set(e,n),n}function k(e,t){if(null===t||"object"!=typeof t&&"function"!=typeof t)throw new TypeError("Cannot use 'in' operator on non-object");return"function"==typeof e?t===e:e.has(t)}function Y(e,t,n){if(null!=t){if("object"!=typeof t&&"function"!=typeof t)throw new TypeError("Object expected.");var s;if(n){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");s=t[Symbol.asyncDispose]}if(void 0===s){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");s=t[Symbol.dispose]}if("function"!=typeof s)throw new TypeError("Object not disposable.");e.stack.push({value:t,dispose:s,async:n})}else n&&e.stack.push({async:!0});return t}var N="function"==typeof SuppressedError?SuppressedError:function(e,t,n){var s=new Error(n);return s.name="SuppressedError",s.error=e,s.suppressed=t,s};function J(e){function t(t){e.error=e.hasError?new N(t,e.error,"An error was suppressed during disposal."):t,e.hasError=!0}return function n(){for(;e.stack.length;){var s=e.stack.pop();try{var o=s.dispose&&s.dispose.call(s.value);if(s.async)return Promise.resolve(o).then(n,(function(e){return t(e),n()}))}catch(e){t(e)}}if(e.hasError)throw e.error}()}const _={__extends:o,__assign:i,__rest:r,__decorate:a,__param:c,__metadata:h,__awaiter:I,__generator:p,__createBinding:C,__exportStar:m,__values:b,__read:y,__spread:f,__spreadArrays:Z,__spreadArray:A,__await:G,__asyncGenerator:B,__asyncDelegator:v,__asyncValues:W,__makeTemplateObject:V,__importStar:S,__importDefault:R,__classPrivateFieldGet:H,__classPrivateFieldSet:X,__classPrivateFieldIn:k,__addDisposableResource:Y,__disposeResources:J}},8106:(e,t,n)=>{"use strict";var s=n(8049),o=n(2773);const i=[{id:"0",label:"No fade to black",cmd:Buffer.from([85,170,0,175,254,0,4,0,0,0,1,48,0,0,0,0,139,0,0,0,2,1,0,0,0,0,0,0,0,10,19,0,0,0,0,0,91,123,34,115,99,114,101,101,110,73,100,34,58,50,53,53,44,34,115,99,114,101,101,110,84,121,112,101,34,58,50,44,34,70,84,66,34,58,123,34,101,110,97,98,108,101,34,58,48,44,34,116,105,109,101,34,58,48,125,125,44,123,34,115,99,114,101,101,110,73,100,34,58,50,53,53,44,34,115,99,114,101,101,110,84,121,112,101,34,58,52,44,34,70,84,66,34,58,123,34,101,110,97,98,108,101,34,58,48,44,34,116,105,109,101,34,58,48,125,125,93,122,125])},{id:"1",label:"Fade to black",cmd:Buffer.from([85,170,0,146,254,0,4,0,0,0,1,48,0,0,0,0,139,0,0,0,2,1,0,0,0,0,0,0,0,10,19,0,0,0,0,0,91,123,34,115,99,114,101,101,110,73,100,34,58,50,53,53,44,34,115,99,114,101,101,110,84,121,112,101,34,58,50,44,34,70,84,66,34,58,123,34,101,110,97,98,108,101,34,58,49,44,34,116,105,109,101,34,58,48,125,125,44,123,34,115,99,114,101,101,110,73,100,34,58,50,53,53,44,34,115,99,114,101,101,110,84,121,112,101,34,58,52,44,34,70,84,66,34,58,123,34,101,110,97,98,108,101,34,58,49,44,34,116,105,109,101,34,58,48,125,125,93,95,125])}],r=[{id:"0",label:"Unfreeze",cmd:Buffer.from([85,170,0,229,254,0,4,0,0,0,1,48,0,0,0,0,105,0,0,0,2,1,0,0,0,0,0,0,0,9,19,0,0,0,0,0,91,123,34,115,99,114,101,101,110,73,100,34,58,50,53,53,44,34,115,99,114,101,101,110,84,121,112,101,34,58,50,44,34,102,114,101,101,122,101,34,58,48,125,44,123,34,115,99,114,101,101,110,73,100,34,58,50,53,53,44,34,115,99,114,101,101,110,84,121,112,101,34,58,52,44,34,102,114,101,101,122,101,34,58,48,125,93,174,115])},{id:"1",label:"Freeze",cmd:Buffer.from([85,170,0,202,254,0,4,0,0,0,1,48,0,0,0,0,105,0,0,0,2,1,0,0,0,0,0,0,0,9,19,0,0,0,0,0,91,123,34,115,99,114,101,101,110,73,100,34,58,50,53,53,44,34,115,99,114,101,101,110,84,121,112,101,34,58,50,44,34,102,114,101,101,122,101,34,58,49,125,44,123,34,115,99,114,101,101,110,73,100,34,58,50,53,53,44,34,115,99,114,101,101,110,84,121,112,101,34,58,52,44,34,102,114,101,101,122,101,34,58,49,125,93,242,115])}],a=[85,170,0,106,254,0,4,0,0,0,1,48,0,0,0,0,181,0,0,0,2,1,0,0,0,0,0,0,0,14,19,0,0,0,0,0,91,123,34,115,99,114,101,101,110,73,100,34,58,50,53,53,44,34,115,99,114,101,101,110,84,121,112,101,34,58,50,44,34,115,119,105,116,99,104,69,102,102,101,99,116,34,58,123,34,116,105,109,101,34,58,49,44,34,100,105,114,101,99,116,105,111,110,34,58,48,44,34,116,121,112,101,34,58,49,125,125,44,123,34,115,99,114,101,101,110,73,100,34,58,50,53,53,44,34,115,99,114,101,101,110,84,121,112,101,34,58,52,44,34,115,119,105,116,99,104,69,102,102,101,99,116,34,58,123,34,116,105,109,101,34,58,49,44,34,100,105,114,101,99,116,105,111,110,34,58,48,44,34,116,121,112,101,34,58,49,125,125,93,89,141],c=[85,170,0,113,254,0,4,0,0,0,1,48,0,0,0,0,181,0,0,0,2,1,0,0,0,0,0,0,0,14,19,0,0,0,0,0,91,123,34,115,99,114,101,101,110,73,100,34,58,50,53,53,44,34,115,99,114,101,101,110,84,121,112,101,34,58,50,44,34,115,119,105,116,99,104,69,102,102,101,99,116,34,58,123,34,116,105,109,101,34,58,49,44,34,100,105,114,101,99,116,105,111,110,34,58,48,44,34,116,121,112,101,34,58,48,125,125,44,123,34,115,99,114,101,101,110,73,100,34,58,50,53,53,44,34,115,99,114,101,101,110,84,121,112,101,34,58,52,44,34,115,119,105,116,99,104,69,102,102,101,99,116,34,58,123,34,116,105,109,101,34,58,49,44,34,100,105,114,101,99,116,105,111,110,34,58,48,44,34,116,121,112,101,34,58,48,125,125,93,94,141],l={pvw:[85,170,0,82,254,0,4,0,0,0,1,48,0,0,0,0,39,0,0,0,2,1,0,0,0,0,0,0,0,14,17,0,0,0,0,0,123,34,112,114,101,115,101,116,65,112,112,108,121,84,121,112,101,34,58,48,125,4,95],pgm:[85,170,0,33,254,0,4,0,0,0,1,48,0,0,0,0,39,0,0,0,2,1,0,0,0,0,0,0,0,14,17,0,0,0,0,0,123,34,112,114,101,115,101,116,65,112,112,108,121,84,121,112,101,34,58,49,125,212,94]},g=[{id:"0",label:"No fade to black",default:"0"},{id:"1",label:"Fade to black",default:"1"}],d=[{id:"0",label:"Unfreeze",default:"0"},{id:"1",label:"Freeze",default:"1"}],u=[{id:"pvw",label:"Load to\nPVW",default:"pvw"},{id:"pgm",label:"Load to\nPGM",default:"pgm"}],h={http:{id:"http",label:"http"},https:{id:"https",label:"https"}},I={pvw:48,pgm:49},p={undefined:0,pvw:4,pgm:2},C=["n10","n20","d32"],m=["d12"],b=["n10","n20","d12","d32"],y={n10:128,n20:128,d12:240,d32:1024},f=["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"],Z=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Blob","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","WeakRef","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","FormData","URLSearchParams","HTMLElement","NaN",...f],A=["null","undefined","string","number","bigint","boolean","symbol"];function G(e){return t=>typeof t===e}const{toString:B}=Object.prototype,v=e=>{const t=B.call(e).slice(8,-1);return/HTML\w+Element/.test(t)&&V.domElement(e)?"HTMLElement":(n=t,Z.includes(n)?t:void 0);var n},W=e=>t=>v(t)===e;function V(e){if(null===e)return"null";switch(typeof e){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"NaN":"number";case"boolean":return"boolean";case"function":return"Function";case"bigint":return"bigint";case"symbol":return"symbol"}if(V.observable(e))return"Observable";if(V.array(e))return"Array";if(V.buffer(e))return"Buffer";const t=v(e);if(t)return t;if(e instanceof String||e instanceof Boolean||e instanceof Number)throw new TypeError("Please don't use object wrappers for primitive types");return"Object"}V.undefined=G("undefined"),V.string=G("string");const w=G("number");V.number=e=>w(e)&&!V.nan(e),V.positiveNumber=e=>V.number(e)&&e>0,V.negativeNumber=e=>V.number(e)&&e<0,V.bigint=G("bigint"),V.function_=G("function"),V.null_=e=>null===e,V.class_=e=>V.function_(e)&&e.toString().startsWith("class "),V.boolean=e=>!0===e||!1===e,V.symbol=G("symbol"),V.numericString=e=>V.string(e)&&!V.emptyStringOrWhitespace(e)&&!Number.isNaN(Number(e)),V.array=(e,t)=>!!Array.isArray(e)&&(!V.function_(t)||e.every((e=>t(e)))),V.buffer=e=>e?.constructor?.isBuffer?.(e)??!1,V.blob=e=>W("Blob")(e),V.nullOrUndefined=e=>V.null_(e)||V.undefined(e),V.object=e=>!V.null_(e)&&("object"==typeof e||V.function_(e)),V.iterable=e=>V.function_(e?.[Symbol.iterator]),V.asyncIterable=e=>V.function_(e?.[Symbol.asyncIterator]),V.generator=e=>V.iterable(e)&&V.function_(e?.next)&&V.function_(e?.throw),V.asyncGenerator=e=>V.asyncIterable(e)&&V.function_(e.next)&&V.function_(e.throw),V.nativePromise=e=>W("Promise")(e),V.promise=e=>V.nativePromise(e)||(e=>V.function_(e?.then)&&V.function_(e?.catch))(e),V.generatorFunction=W("GeneratorFunction"),V.asyncGeneratorFunction=e=>"AsyncGeneratorFunction"===v(e),V.asyncFunction=e=>"AsyncFunction"===v(e),V.boundFunction=e=>V.function_(e)&&!e.hasOwnProperty("prototype"),V.regExp=W("RegExp"),V.date=W("Date"),V.error=W("Error"),V.map=e=>W("Map")(e),V.set=e=>W("Set")(e),V.weakMap=e=>W("WeakMap")(e),V.weakSet=e=>W("WeakSet")(e),V.weakRef=e=>W("WeakRef")(e),V.int8Array=W("Int8Array"),V.uint8Array=W("Uint8Array"),V.uint8ClampedArray=W("Uint8ClampedArray"),V.int16Array=W("Int16Array"),V.uint16Array=W("Uint16Array"),V.int32Array=W("Int32Array"),V.uint32Array=W("Uint32Array"),V.float32Array=W("Float32Array"),V.float64Array=W("Float64Array"),V.bigInt64Array=W("BigInt64Array"),V.bigUint64Array=W("BigUint64Array"),V.arrayBuffer=W("ArrayBuffer"),V.sharedArrayBuffer=W("SharedArrayBuffer"),V.dataView=W("DataView"),V.enumCase=(e,t)=>Object.values(t).includes(e),V.directInstanceOf=(e,t)=>Object.getPrototypeOf(e)===t.prototype,V.urlInstance=e=>W("URL")(e),V.urlString=e=>{if(!V.string(e))return!1;try{return new URL(e),!0}catch{return!1}},V.truthy=e=>Boolean(e),V.falsy=e=>!e,V.nan=e=>Number.isNaN(e),V.primitive=e=>{return V.null_(e)||(t=typeof e,A.includes(t));var t},V.integer=e=>Number.isInteger(e),V.safeInteger=e=>Number.isSafeInteger(e),V.plainObject=e=>{if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)},V.typedArray=e=>{return t=v(e),f.includes(t);var t},V.arrayLike=e=>!V.nullOrUndefined(e)&&!V.function_(e)&&(e=>V.safeInteger(e)&&e>=0)(e.length),V.tupleLike=(e,t)=>!(!V.array(t)||!V.array(e)||t.length!==e.length)&&t.every(((t,n)=>t(e[n]))),V.inRange=(e,t)=>{if(V.number(t))return e>=Math.min(0,t)&&e<=Math.max(t,0);if(V.array(t)&&2===t.length)return e>=Math.min(...t)&&e<=Math.max(...t);throw new TypeError(`Invalid range: ${JSON.stringify(t)}`)};const S=["innerHTML","ownerDocument","style","attributes","nodeValue"];V.domElement=e=>V.object(e)&&1===e.nodeType&&V.string(e.nodeName)&&!V.plainObject(e)&&S.every((t=>t in e)),V.observable=e=>!!e&&(e===e[Symbol.observable]?.()||e===e["@@observable"]?.()),V.nodeStream=e=>V.object(e)&&V.function_(e.pipe)&&!V.observable(e),V.infinite=e=>e===Number.POSITIVE_INFINITY||e===Number.NEGATIVE_INFINITY;const R=e=>t=>V.integer(t)&&Math.abs(t%2)===e;V.evenInteger=R(0),V.oddInteger=R(1),V.emptyArray=e=>V.array(e)&&0===e.length,V.nonEmptyArray=e=>V.array(e)&&e.length>0,V.emptyString=e=>V.string(e)&&0===e.length,V.emptyStringOrWhitespace=e=>V.emptyString(e)||(e=>V.string(e)&&!/\S/.test(e))(e),V.nonEmptyString=e=>V.string(e)&&e.length>0,V.nonEmptyStringAndNotWhitespace=e=>V.string(e)&&!V.emptyStringOrWhitespace(e),V.emptyObject=e=>V.object(e)&&!V.map(e)&&!V.set(e)&&0===Object.keys(e).length,V.nonEmptyObject=e=>V.object(e)&&!V.map(e)&&!V.set(e)&&Object.keys(e).length>0,V.emptySet=e=>V.set(e)&&0===e.size,V.nonEmptySet=e=>V.set(e)&&e.size>0,V.emptyMap=e=>V.map(e)&&0===e.size,V.nonEmptyMap=e=>V.map(e)&&e.size>0,V.propertyKey=e=>V.any([V.string,V.number,V.symbol],e),V.formData=e=>W("FormData")(e),V.urlSearchParams=e=>W("URLSearchParams")(e);const H=(e,t,n)=>{if(!V.function_(t))throw new TypeError(`Invalid predicate: ${JSON.stringify(t)}`);if(0===n.length)throw new TypeError("Invalid number of values");return e.call(n,t)};V.any=(e,...t)=>(V.array(e)?e:[e]).some((e=>H(Array.prototype.some,e,t))),V.all=(e,...t)=>H(Array.prototype.every,e,t);const X=(e,t,n,s={})=>{if(!e){const{multipleValues:e}=s,o=e?`received values of types ${[...new Set(n.map((e=>`\`${V(e)}\``)))].join(", ")}`:`received value of type \`${V(n)}\``;throw new TypeError(`Expected value which is \`${t}\`, ${o}.`)}},k={undefined:e=>X(V.undefined(e),"undefined",e),string:e=>X(V.string(e),"string",e),number:e=>X(V.number(e),"number",e),positiveNumber:e=>X(V.positiveNumber(e),"positive number",e),negativeNumber:e=>X(V.negativeNumber(e),"negative number",e),bigint:e=>X(V.bigint(e),"bigint",e),function_:e=>X(V.function_(e),"Function",e),null_:e=>X(V.null_(e),"null",e),class_:e=>X(V.class_(e),"Class",e),boolean:e=>X(V.boolean(e),"boolean",e),symbol:e=>X(V.symbol(e),"symbol",e),numericString:e=>X(V.numericString(e),"string with a number",e),array:(e,t)=>{X(V.array(e),"Array",e),t&&e.forEach(t)},buffer:e=>X(V.buffer(e),"Buffer",e),blob:e=>X(V.blob(e),"Blob",e),nullOrUndefined:e=>X(V.nullOrUndefined(e),"null or undefined",e),object:e=>X(V.object(e),"Object",e),iterable:e=>X(V.iterable(e),"Iterable",e),asyncIterable:e=>X(V.asyncIterable(e),"AsyncIterable",e),generator:e=>X(V.generator(e),"Generator",e),asyncGenerator:e=>X(V.asyncGenerator(e),"AsyncGenerator",e),nativePromise:e=>X(V.nativePromise(e),"native Promise",e),promise:e=>X(V.promise(e),"Promise",e),generatorFunction:e=>X(V.generatorFunction(e),"GeneratorFunction",e),asyncGeneratorFunction:e=>X(V.asyncGeneratorFunction(e),"AsyncGeneratorFunction",e),asyncFunction:e=>X(V.asyncFunction(e),"AsyncFunction",e),boundFunction:e=>X(V.boundFunction(e),"Function",e),regExp:e=>X(V.regExp(e),"RegExp",e),date:e=>X(V.date(e),"Date",e),error:e=>X(V.error(e),"Error",e),map:e=>X(V.map(e),"Map",e),set:e=>X(V.set(e),"Set",e),weakMap:e=>X(V.weakMap(e),"WeakMap",e),weakSet:e=>X(V.weakSet(e),"WeakSet",e),weakRef:e=>X(V.weakRef(e),"WeakRef",e),int8Array:e=>X(V.int8Array(e),"Int8Array",e),uint8Array:e=>X(V.uint8Array(e),"Uint8Array",e),uint8ClampedArray:e=>X(V.uint8ClampedArray(e),"Uint8ClampedArray",e),int16Array:e=>X(V.int16Array(e),"Int16Array",e),uint16Array:e=>X(V.uint16Array(e),"Uint16Array",e),int32Array:e=>X(V.int32Array(e),"Int32Array",e),uint32Array:e=>X(V.uint32Array(e),"Uint32Array",e),float32Array:e=>X(V.float32Array(e),"Float32Array",e),float64Array:e=>X(V.float64Array(e),"Float64Array",e),bigInt64Array:e=>X(V.bigInt64Array(e),"BigInt64Array",e),bigUint64Array:e=>X(V.bigUint64Array(e),"BigUint64Array",e),arrayBuffer:e=>X(V.arrayBuffer(e),"ArrayBuffer",e),sharedArrayBuffer:e=>X(V.sharedArrayBuffer(e),"SharedArrayBuffer",e),dataView:e=>X(V.dataView(e),"DataView",e),enumCase:(e,t)=>X(V.enumCase(e,t),"EnumCase",e),urlInstance:e=>X(V.urlInstance(e),"URL",e),urlString:e=>X(V.urlString(e),"string with a URL",e),truthy:e=>X(V.truthy(e),"truthy",e),falsy:e=>X(V.falsy(e),"falsy",e),nan:e=>X(V.nan(e),"NaN",e),primitive:e=>X(V.primitive(e),"primitive",e),integer:e=>X(V.integer(e),"integer",e),safeInteger:e=>X(V.safeInteger(e),"integer",e),plainObject:e=>X(V.plainObject(e),"plain object",e),typedArray:e=>X(V.typedArray(e),"TypedArray",e),arrayLike:e=>X(V.arrayLike(e),"array-like",e),tupleLike:(e,t)=>X(V.tupleLike(e,t),"tuple-like",e),domElement:e=>X(V.domElement(e),"HTMLElement",e),observable:e=>X(V.observable(e),"Observable",e),nodeStream:e=>X(V.nodeStream(e),"Node.js Stream",e),infinite:e=>X(V.infinite(e),"infinite number",e),emptyArray:e=>X(V.emptyArray(e),"empty array",e),nonEmptyArray:e=>X(V.nonEmptyArray(e),"non-empty array",e),emptyString:e=>X(V.emptyString(e),"empty string",e),emptyStringOrWhitespace:e=>X(V.emptyStringOrWhitespace(e),"empty string or whitespace",e),nonEmptyString:e=>X(V.nonEmptyString(e),"non-empty string",e),nonEmptyStringAndNotWhitespace:e=>X(V.nonEmptyStringAndNotWhitespace(e),"non-empty string and not whitespace",e),emptyObject:e=>X(V.emptyObject(e),"empty object",e),nonEmptyObject:e=>X(V.nonEmptyObject(e),"non-empty object",e),emptySet:e=>X(V.emptySet(e),"empty set",e),nonEmptySet:e=>X(V.nonEmptySet(e),"non-empty set",e),emptyMap:e=>X(V.emptyMap(e),"empty map",e),nonEmptyMap:e=>X(V.nonEmptyMap(e),"non-empty map",e),propertyKey:e=>X(V.propertyKey(e),"PropertyKey",e),formData:e=>X(V.formData(e),"FormData",e),urlSearchParams:e=>X(V.urlSearchParams(e),"URLSearchParams",e),evenInteger:e=>X(V.evenInteger(e),"even integer",e),oddInteger:e=>X(V.oddInteger(e),"odd integer",e),directInstanceOf:(e,t)=>X(V.directInstanceOf(e,t),"T",e),inRange:(e,t)=>X(V.inRange(e,t),"in range",e),any:(e,...t)=>X(V.any(e,...t),"predicate returns truthy for any value",t,{multipleValues:!0}),all:(e,...t)=>X(V.all(e,...t),"predicate returns truthy for all values",t,{multipleValues:!0})};Object.defineProperties(V,{class:{value:V.class_},function:{value:V.function_},null:{value:V.null_}}),Object.defineProperties(k,{class:{value:k.class_},function:{value:k.function_},null:{value:k.null_}});const Y=V,N=require("node:events");class J extends Error{constructor(e){super(e||"Promise was canceled"),this.name="CancelError"}get isCanceled(){return!0}}class _{static fn(e){return(...t)=>new _(((n,s,o)=>{t.push(o),e(...t).then(n,s)}))}constructor(e){this._cancelHandlers=[],this._isPending=!0,this._isCanceled=!1,this._rejectOnCancel=!0,this._promise=new Promise(((t,n)=>{this._reject=n;const s=e=>{if(!this._isPending)throw new Error("The `onCancel` handler was attached after the promise settled.");this._cancelHandlers.push(e)};Object.defineProperties(s,{shouldReject:{get:()=>this._rejectOnCancel,set:e=>{this._rejectOnCancel=e}}}),e((e=>{this._isCanceled&&s.shouldReject||(this._isPending=!1,t(e))}),(e=>{this._isPending=!1,n(e)}),s)}))}then(e,t){return this._promise.then(e,t)}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(const e of this._cancelHandlers)e()}catch(e){return void this._reject(e)}this._rejectOnCancel&&this._reject(new J(e))}}get isCanceled(){return this._isCanceled}}Object.setPrototypeOf(_.prototype,Promise.prototype);class K extends Error{constructor(e,t,n){var s;if(super(e),Object.defineProperty(this,"input",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"stack",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"response",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"request",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"timings",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Error.captureStackTrace(this,this.constructor),this.name="RequestError",this.code=t.code??"ERR_GOT_REQUEST_ERROR",this.input=t.input,s=n,Y.object(s)&&"_onResponse"in s?(Object.defineProperty(this,"request",{enumerable:!1,value:n}),Object.defineProperty(this,"response",{enumerable:!1,value:n.response}),this.options=n.options):this.options=n,this.timings=this.request?.timings,Y.string(t.stack)&&Y.string(this.stack)){const e=this.stack.indexOf(this.message)+this.message.length,n=this.stack.slice(e).split("\n").reverse(),s=t.stack.slice(t.stack.indexOf(t.message)+t.message.length).split("\n").reverse();for(;s.length>0&&s[0]===n[0];)n.shift();this.stack=`${this.stack.slice(0,e)}${n.reverse().join("\n")}${s.reverse().join("\n")}`}}}class F extends K{constructor(e){super(`Redirected ${e.options.maxRedirects} times. Aborting.`,{},e),this.name="MaxRedirectsError",this.code="ERR_TOO_MANY_REDIRECTS"}}class x extends K{constructor(e){super(`Response code ${e.statusCode} (${e.statusMessage})`,{},e.request),this.name="HTTPError",this.code="ERR_NON_2XX_3XX_RESPONSE"}}class z extends K{constructor(e,t){super(e.message,e,t),this.name="CacheError",this.code="ERR_GOT_REQUEST_ERROR"===this.code?"ERR_CACHE_ACCESS":this.code}}class T extends K{constructor(e,t){super(e.message,e,t),this.name="UploadError",this.code="ERR_GOT_REQUEST_ERROR"===this.code?"ERR_UPLOAD":this.code}}class E extends K{constructor(e,t,n){super(e.message,e,n),Object.defineProperty(this,"timings",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"event",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name="TimeoutError",this.event=e.event,this.timings=t}}class U extends K{constructor(e,t){super(e.message,e,t),this.name="ReadError",this.code="ERR_GOT_REQUEST_ERROR"===this.code?"ERR_READING_RESPONSE_STREAM":this.code}}class Q extends K{constructor(e){super("Retrying",{},e),this.name="RetryError",this.code="ERR_RETRYING"}}class L extends K{constructor(e){super("This operation was aborted.",{},e),this.code="ERR_ABORTED",this.name="AbortError"}}const O=require("node:process"),j=require("node:buffer"),M=require("node:stream"),P=require("node:http");var D=n(2361),q=n(3837),$=n(1313);const ee=require("node:url"),te=require("node:crypto"),ne=(e,t)=>t.some((t=>t instanceof RegExp?t.test(e):t===e)),se=new Set(["https:","http:","file:"]);var oe=n(31),ie=n(6214);function re(e){return Object.fromEntries(Object.entries(e).map((([e,t])=>[e.toLowerCase(),t])))}class ae extends M.Readable{statusCode;headers;body;url;constructor({statusCode:e,headers:t,body:n,url:s}){if("number"!=typeof e)throw new TypeError("Argument `statusCode` should be a number");if("object"!=typeof t)throw new TypeError("Argument `headers` should be an object");if(!(n instanceof Uint8Array))throw new TypeError("Argument `body` should be a buffer");if("string"!=typeof s)throw new TypeError("Argument `url` should be a string");super({read(){this.push(n),this.push(null)}}),this.statusCode=e,this.headers=re(t),this.body=n,this.url=s}}var ce=n(4958);const le=["aborted","complete","headers","httpVersion","httpVersionMinor","httpVersionMajor","method","rawHeaders","rawTrailers","setTimeout","socket","statusCode","statusMessage","trailers","url"];class ge extends Error{constructor(e){super(e.message),Object.assign(this,e)}}class de extends Error{constructor(e){super(e.message),Object.assign(this,e)}}const ue=Object.entries,he=e=>{const t={...e};return t.path=`${e.pathname||"/"}${e.search||""}`,delete t.pathname,delete t.search,t},Ie=e=>({protocol:e.protocol,auth:e.auth,hostname:e.hostname||e.host||"localhost",port:e.port,pathname:e.pathname,search:e.search}),pe=e=>{const t=[];for(const n of Object.keys(e))t[n.toLowerCase()]=e[n];return t},Ce=class{constructor(e,t){this.hooks=new Map,this.request=()=>(e,t)=>{let n;if("string"==typeof e)n=Ie(ee.parse(e)),e={};else if(e instanceof ee.URL)n=Ie(ee.parse(e.toString())),e={};else{const[t,...s]=(e.path??"").split("?"),o=s.length>0?`?${s.join("?")}`:"";n=Ie({...e,pathname:t,search:o})}(e={headers:{},method:"GET",cache:!0,strictTtl:!1,automaticFailover:!1,...e,...he(n)}).headers=Object.fromEntries(ue(e.headers).map((([e,t])=>[e.toLowerCase(),t])));const s=new N,o=function(e,t){if("string"!=typeof(t={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,removeExplicitPort:!1,sortQueryParameters:!0,...t}).defaultProtocol||t.defaultProtocol.endsWith(":")||(t.defaultProtocol=`${t.defaultProtocol}:`),e=e.trim(),/^data:/i.test(e))return((e,{stripHash:t})=>{const n=/^data:(?[^,]*?),(?[^#]*?)(?:#(?.*))?$/.exec(e);if(!n)throw new Error(`Invalid URL: ${e}`);let{type:s,data:o,hash:i}=n.groups;const r=s.split(";");i=t?"":i;let a=!1;"base64"===r[r.length-1]&&(r.pop(),a=!0);const c=r.shift()?.toLowerCase()??"",l=[...r.map((e=>{let[t,n=""]=e.split("=").map((e=>e.trim()));return"charset"===t&&(n=n.toLowerCase(),"us-ascii"===n)?"":`${t}${n?`=${n}`:""}`})).filter(Boolean)];return a&&l.push("base64"),(l.length>0||c&&"text/plain"!==c)&&l.unshift(c),`data:${l.join(";")},${a?o.trim():o}${i?`#${i}`:""}`})(e,t);if((e=>{try{const{protocol:t}=new URL(e);return t.endsWith(":")&&!se.has(t)}catch{return!1}})(e))return e;const n=e.startsWith("//");!n&&/^\.*\//.test(e)||(e=e.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,t.defaultProtocol));const s=new URL(e);if(t.forceHttp&&t.forceHttps)throw new Error("The `forceHttp` and `forceHttps` options cannot be used together");if(t.forceHttp&&"https:"===s.protocol&&(s.protocol="http:"),t.forceHttps&&"http:"===s.protocol&&(s.protocol="https:"),t.stripAuthentication&&(s.username="",s.password=""),t.stripHash?s.hash="":t.stripTextFragment&&(s.hash=s.hash.replace(/#?:~:text.*?$/i,"")),s.pathname){const e=/\b[a-z][a-z\d+\-.]{1,50}:\/\//g;let t=0,n="";for(;;){const o=e.exec(s.pathname);if(!o)break;const i=o[0],r=o.index;n+=s.pathname.slice(t,r).replace(/\/{2,}/g,"/"),n+=i,t=r+i.length}n+=s.pathname.slice(t,s.pathname.length).replace(/\/{2,}/g,"/"),s.pathname=n}if(s.pathname)try{s.pathname=decodeURI(s.pathname)}catch{}if(!0===t.removeDirectoryIndex&&(t.removeDirectoryIndex=[/^index\.[a-z]+$/]),Array.isArray(t.removeDirectoryIndex)&&t.removeDirectoryIndex.length>0){let e=s.pathname.split("/");const n=e[e.length-1];ne(n,t.removeDirectoryIndex)&&(e=e.slice(0,-1),s.pathname=e.slice(1).join("/")+"/")}if(s.hostname&&(s.hostname=s.hostname.replace(/\.$/,""),t.stripWWW&&/^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(s.hostname)&&(s.hostname=s.hostname.replace(/^www\./,""))),Array.isArray(t.removeQueryParameters))for(const e of[...s.searchParams.keys()])ne(e,t.removeQueryParameters)&&s.searchParams.delete(e);if(Array.isArray(t.keepQueryParameters)||!0!==t.removeQueryParameters||(s.search=""),Array.isArray(t.keepQueryParameters)&&t.keepQueryParameters.length>0)for(const e of[...s.searchParams.keys()])ne(e,t.keepQueryParameters)||s.searchParams.delete(e);if(t.sortQueryParameters){s.searchParams.sort();try{s.search=decodeURIComponent(s.search)}catch{}}t.removeTrailingSlash&&(s.pathname=s.pathname.replace(/\/$/,"")),t.removeExplicitPort&&s.port&&(s.port="");const o=e;return e=s.toString(),t.removeSingleSlash||"/"!==s.pathname||o.endsWith("/")||""!==s.hash||(e=e.replace(/\/$/,"")),(t.removeTrailingSlash||"/"===s.pathname)&&""===s.hash&&t.removeSingleSlash&&(e=e.replace(/\/$/,"")),n&&!t.normalizeProtocol&&(e=e.replace(/^http:\/\//,"//")),t.stripProtocol&&(e=e.replace(/^(?:https?:)?\/\//,"")),e}(ee.format(n),{stripWWW:!1,removeTrailingSlash:!1,stripAuthentication:!1});let i=`${e.method}:${o}`;e.body&&void 0!==e.method&&["POST","PATCH","PUT"].includes(e.method)&&(e.body instanceof M.Readable?e.cache=!1:i+=`:${te.createHash("md5").update(e.body).digest("hex")}`);let r=!1,a=!1;const c=e=>{a=!0;let n=!1,o=()=>{};const c=new Promise((e=>{o=()=>{n||(n=!0,e())}})),l=async n=>{if(r){n.status=n.statusCode;const t=ie.fromObject(r.cachePolicy).revalidatedPolicy(e,n);if(!t.modified){n.resume(),await new Promise((e=>{n.once("end",e)}));const e=pe(t.policy.responseHeaders());(n=new ae({statusCode:r.statusCode,headers:e,body:r.body,url:r.url})).cachePolicy=t.policy,n.fromCache=!0}}let o;n.fromCache||(n.cachePolicy=new ie(e,n,e),n.fromCache=!1),e.cache&&n.cachePolicy.storable()?(o=(e=>{const t=new M.PassThrough({autoDestroy:!1});return function(e,t){if(t._readableState.autoDestroy)throw new Error("The second stream must have the `autoDestroy` option set to `false`");const n=new Set([...Object.keys(e),...le]),s={};for(const o of n)o in t||(s[o]={get(){const t=e[o];return"function"==typeof t?t.bind(e):t},set(t){e[o]=t},enumerable:!0,configurable:!1});Object.defineProperties(t,s),e.once("aborted",(()=>{t.destroy(),t.emit("aborted")})),e.once("close",(()=>{e.complete&&t.readable?t.once("end",(()=>{t.emit("close")})):t.emit("close")}))}(e,t),e.pipe(t)})(n),(async()=>{try{const t=oe.buffer(n);await Promise.race([c,new Promise((e=>n.once("end",e))),new Promise((e=>n.once("close",e)))]);const s=await t;let o={url:n.url,statusCode:n.fromCache?r.statusCode:n.statusCode,body:s,cachePolicy:n.cachePolicy.toObject()},a=e.strictTtl?n.cachePolicy.timeToLive():void 0;if(e.maxTtl&&(a=a?Math.min(a,e.maxTtl):e.maxTtl),this.hooks.size>0)for(const e of this.hooks.keys())o=await this.runHook(e,o,n);await this.cache.set(i,o,a)}catch(e){s.emit("error",new de(e))}})()):e.cache&&r&&(async()=>{try{await this.cache.delete(i)}catch(e){s.emit("error",new de(e))}})(),s.emit("response",o??n),"function"==typeof t&&t(o??n)};try{const t=this.cacheRequest(e,l);t.once("error",o),t.once("abort",o),t.once("destroy",o),s.emit("request",t)}catch(e){s.emit("error",new ge(e))}};return(async()=>{const n=async e=>{await Promise.resolve();const n=e.cache?await this.cache.get(i):void 0;if(void 0===n&&!e.forceRefresh)return void c(e);const o=ie.fromObject(n.cachePolicy);if(o.satisfiesWithoutRevalidation(e)&&!e.forceRefresh){const e=pe(o.responseHeaders()),i=new ae({statusCode:n.statusCode,headers:e,body:n.body,url:n.url});i.cachePolicy=o,i.fromCache=!0,s.emit("response",i),"function"==typeof t&&t(i)}else o.satisfiesWithoutRevalidation(e)&&Date.now()>=o.timeToLive()&&e.forceRefresh?(await this.cache.delete(i),e.headers=o.revalidationHeaders(e),c(e)):(r=n,e.headers=o.revalidationHeaders(e),c(e))},o=e=>s.emit("error",new de(e));if(this.cache instanceof ce){const e=this.cache;e.once("error",o),s.on("error",(()=>e.removeListener("error",o))),s.on("response",(()=>e.removeListener("error",o)))}try{await n(e)}catch(t){e.automaticFailover&&!a&&c(e),s.emit("error",new de(t))}})(),s},this.addHook=(e,t)=>{this.hooks.has(e)||this.hooks.set(e,t)},this.removeHook=e=>this.hooks.delete(e),this.getHook=e=>this.hooks.get(e),this.runHook=async(e,...t)=>this.hooks.get(e)?.(...t),this.cache=t instanceof ce?t:new ce("string"==typeof t?{uri:t,namespace:"cacheable-request"}:{store:t,namespace:"cacheable-request"}),this.request=this.request.bind(this),this.cacheRequest=e}};var me=n(346);const be=e=>"function"==typeof e,ye=e=>Boolean(e&&be(e.constructor)&&"FormData"===e[Symbol.toStringTag]&&be(e.append)&&be(e.getAll)&&be(e.entries)&&be(e[Symbol.iterator])),fe=e=>{if(be(e[Symbol.asyncIterator]))return e;if(be(e.getReader))return async function*(e){const t=e.getReader();for(;;){const{done:e,value:n}=await t.read();if(e)break;yield n}}(e);throw new TypeError("Unsupported data source: Expected either ReadableStream or async iterable.")},Ze=e=>String(e).replace(/\r|\n/g,((e,t,n)=>"\r"===e&&"\n"!==n[t+1]||"\n"===e&&"\r"!==n[t-1]?"\r\n":e));function Ae(e){if("object"!==(e=>Object.prototype.toString.call(e).slice(8,-1).toLowerCase())(e))return!1;const t=Object.getPrototypeOf(e);return null==t||(t.constructor&&t.constructor.toString())===Object.toString()}function Ge(e,t){if("string"==typeof t)for(const[n,s]of Object.entries(e))if(t.toLowerCase()===n.toLowerCase())return s}const Be=e=>String(e).replace(/\r/g,"%0D").replace(/\n/g,"%0A").replace(/"/g,"%22"),ve=e=>Boolean(e&&"object"==typeof e&&be(e.constructor)&&"File"===e[Symbol.toStringTag]&&be(e.stream)&&null!=e.name);var We,Ve,we,Se,Re,He,Xe,ke,Ye,Ne,Je,_e=function(e,t,n,s,o){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?o.call(e,n):o?o.value=n:t.set(e,n),n},Ke=function(e,t,n,s){if("a"===n&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?s:"a"===n?s.call(e):s?s.value:t.get(e)};const Fe={enableAdditionalHeaders:!1},xe={writable:!1,configurable:!1};class ze{constructor(e,t,n){if(We.add(this),Ve.set(this,"\r\n"),we.set(this,void 0),Se.set(this,void 0),Re.set(this,"-".repeat(2)),He.set(this,new TextEncoder),Xe.set(this,void 0),ke.set(this,void 0),Ye.set(this,void 0),!ye(e))throw new TypeError("Expected first argument to be a FormData instance.");let s;if(Ae(t)?n=t:s=t,s||(s=function(){let e=16,t="";for(;e--;)t+="abcdefghijklmnopqrstuvwxyz0123456789"[36*Math.random()<<0];return t}()),"string"!=typeof s)throw new TypeError("Expected boundary argument to be a string.");if(n&&!Ae(n))throw new TypeError("Expected options argument to be an object.");_e(this,ke,Array.from(e.entries()),"f"),_e(this,Ye,{...Fe,...n},"f"),_e(this,we,Ke(this,He,"f").encode(Ke(this,Ve,"f")),"f"),_e(this,Se,Ke(this,we,"f").byteLength,"f"),this.boundary=`form-data-boundary-${s}`,this.contentType=`multipart/form-data; boundary=${this.boundary}`,_e(this,Xe,Ke(this,He,"f").encode(`${Ke(this,Re,"f")}${this.boundary}${Ke(this,Re,"f")}${Ke(this,Ve,"f").repeat(2)}`),"f");const o={"Content-Type":this.contentType},i=Ke(this,We,"m",Je).call(this);var r;i&&(this.contentLength=i,o["Content-Length"]=i),this.headers=(r=Object.freeze(o),new Proxy(r,{get:(e,t)=>Ge(e,t),has:(e,t)=>void 0!==Ge(e,t)})),Object.defineProperties(this,{boundary:xe,contentType:xe,contentLength:xe,headers:xe})}getContentLength(){return null==this.contentLength?void 0:Number(this.contentLength)}*values(){for(const[e,t]of Ke(this,ke,"f")){const n=ve(t)?t:Ke(this,He,"f").encode(Ze(t));yield Ke(this,We,"m",Ne).call(this,e,n),yield n,yield Ke(this,we,"f")}yield Ke(this,Xe,"f")}async*encode(){for(const e of this.values())ve(e)?yield*fe(e.stream()):yield e}[(Ve=new WeakMap,we=new WeakMap,Se=new WeakMap,Re=new WeakMap,He=new WeakMap,Xe=new WeakMap,ke=new WeakMap,Ye=new WeakMap,We=new WeakSet,Ne=function(e,t){let n="";n+=`${Ke(this,Re,"f")}${this.boundary}${Ke(this,Ve,"f")}`,n+=`Content-Disposition: form-data; name="${Be(e)}"`,ve(t)&&(n+=`; filename="${Be(t.name)}"${Ke(this,Ve,"f")}`,n+=`Content-Type: ${t.type||"application/octet-stream"}`);const s=ve(t)?t.size:t.byteLength;return!0!==Ke(this,Ye,"f").enableAdditionalHeaders||null==s||isNaN(s)||(n+=`${Ke(this,Ve,"f")}Content-Length: ${ve(t)?t.size:t.byteLength}`),Ke(this,He,"f").encode(`${n}${Ke(this,Ve,"f").repeat(2)}`)},Je=function(){let e=0;for(const[t,n]of Ke(this,ke,"f")){const s=ve(n)?n:Ke(this,He,"f").encode(Ze(n)),o=ve(s)?s.size:s.byteLength;if(null==o||isNaN(o))return;e+=Ke(this,We,"m",Ne).call(this,t,s).byteLength,e+=o,e+=Ke(this,Se,"f")}return String(e+Ke(this,Xe,"f").byteLength)},Symbol.iterator)](){return this.values()}[Symbol.asyncIterator](){return this.encode()}}const Te=require("node:util");function Ee(e){return Y.nodeStream(e)&&Y.function_(e.getBoundary)}function Ue(e,t,n){const s={};for(const o of n){const n=(...e)=>{t.emit(o,...e)};s[o]=n,e.on(o,n)}return()=>{for(const[t,n]of Object.entries(s))e.off(t,n)}}const Qe=require("node:net"),Le=Symbol("reentry"),Oe=()=>{};class je extends Error{constructor(e,t){super(`Timeout awaiting '${t}' for ${e}ms`),Object.defineProperty(this,"event",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name="TimeoutError",this.code="ETIMEDOUT"}}const Me=({attemptCount:e,retryOptions:t,error:n,retryAfter:s,computedValue:o})=>{if("RetryError"===n.name)return 1;if(e>t.limit)return 0;const i=t.methods.includes(n.options.method),r=t.errorCodes.includes(n.code),a=n.response&&t.statusCodes.includes(n.response.statusCode);if(!i||!r&&!a)return 0;if(n.response){if(s)return s>o?0:s;if(413===n.response.statusCode)return 0}const c=Math.random()*t.noise;return Math.min(2**(e-1)*1e3,t.backoffLimit)+c},Pe=require("node:tls"),De=require("node:https"),qe=require("node:dns"),$e=require("node:os"),{Resolver:et}=qe.promises,tt=Symbol("cacheableLookupCreateConnection"),nt=Symbol("cacheableLookupInstance"),st=Symbol("expires"),ot="number"==typeof qe.ALL,it=e=>{if(!e||"function"!=typeof e.createConnection)throw new Error("Expected an Agent instance as the first argument")},rt=()=>{let e=!1,t=!1;for(const n of Object.values($e.networkInterfaces()))for(const s of n)if(!s.internal&&("IPv6"===s.family?t=!0:e=!0,e&&t))return{has4:e,has6:t};return{has4:e,has6:t}},at=e=>e.catch((e=>{if("ENODATA"===e.code||"ENOTFOUND"===e.code||"ENOENT"===e.code)return[];throw e})),ct={ttl:!0},lt={all:!0},gt={all:!0,family:4},dt={all:!0,family:6};class ut{constructor({cache:e=new Map,maxTtl:t=1/0,fallbackDuration:n=3600,errorTtl:s=.15,resolver:o=new et,lookup:i=qe.lookup}={}){if(this.maxTtl=t,this.errorTtl=s,this._cache=e,this._resolver=o,this._dnsLookup=i&&(0,Te.promisify)(i),this.stats={cache:0,query:0},this._resolver instanceof et?(this._resolve4=this._resolver.resolve4.bind(this._resolver),this._resolve6=this._resolver.resolve6.bind(this._resolver)):(this._resolve4=(0,Te.promisify)(this._resolver.resolve4.bind(this._resolver)),this._resolve6=(0,Te.promisify)(this._resolver.resolve6.bind(this._resolver))),this._iface=rt(),this._pending={},this._nextRemovalTime=!1,this._hostnamesToFallback=new Set,this.fallbackDuration=n,n>0){const e=setInterval((()=>{this._hostnamesToFallback.clear()}),1e3*n);e.unref&&e.unref(),this._fallbackInterval=e}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,t,n){if("function"==typeof t?(n=t,t={}):"number"==typeof t&&(t={family:t}),!n)throw new Error("Callback must be a function.");this.lookupAsync(e,t).then((e=>{t.all?n(null,e):n(null,e.address,e.family,e.expires,e.ttl,e.source)}),n)}async lookupAsync(e,t={}){"number"==typeof t&&(t={family:t});let n=await this.query(e);if(6===t.family){const e=n.filter((e=>6===e.family));t.hints&qe.V4MAPPED&&(ot&&t.hints&qe.ALL||0===e.length)?(e=>{for(const t of e)6!==t.family&&(t.address=`::ffff:${t.address}`,t.family=6)})(n):n=e}else 4===t.family&&(n=n.filter((e=>4===e.family)));if(t.hints&qe.ADDRCONFIG){const{_iface:e}=this;n=n.filter((t=>6===t.family?e.has6:e.has4))}if(0===n.length){const t=new Error(`cacheableLookup ENOTFOUND ${e}`);throw t.code="ENOTFOUND",t.hostname=e,t}return t.all?n:n[0]}async query(e){let t="cache",n=await this._cache.get(e);if(n&&this.stats.cache++,!n){const s=this._pending[e];if(s)this.stats.cache++,n=await s;else{t="query";const s=this.queryAndCache(e);this._pending[e]=s,this.stats.query++;try{n=await s}finally{delete this._pending[e]}}}return n=n.map((e=>({...e,source:t}))),n}async _resolve(e){const[t,n]=await Promise.all([at(this._resolve4(e,ct)),at(this._resolve6(e,ct))]);let s=0,o=0,i=0;const r=Date.now();for(const e of t)e.family=4,e.expires=r+1e3*e.ttl,s=Math.max(s,e.ttl);for(const e of n)e.family=6,e.expires=r+1e3*e.ttl,o=Math.max(o,e.ttl);return i=t.length>0?n.length>0?Math.min(s,o):s:o,{entries:[...t,...n],cacheTtl:i}}async _lookup(e){try{const[t,n]=await Promise.all([at(this._dnsLookup(e,gt)),at(this._dnsLookup(e,dt))]);return{entries:[...t,...n],cacheTtl:0}}catch{return{entries:[],cacheTtl:0}}}async _set(e,t,n){if(this.maxTtl>0&&n>0){n=1e3*Math.min(n,this.maxTtl),t[st]=Date.now()+n;try{await this._cache.set(e,t,n)}catch(e){this.lookupAsync=async()=>{const t=new Error("Cache Error. Please recreate the CacheableLookup instance.");throw t.cause=e,t}}s=this._cache,Symbol.iterator in s&&this._tick(n)}var s}async queryAndCache(e){if(this._hostnamesToFallback.has(e))return this._dnsLookup(e,lt);let t=await this._resolve(e);0===t.entries.length&&this._dnsLookup&&(t=await this._lookup(e),0!==t.entries.length&&this.fallbackDuration>0&&this._hostnamesToFallback.add(e));const n=0===t.entries.length?this.errorTtl:t.cacheTtl;return await this._set(e,t.entries,n),t.entries}_tick(e){const t=this._nextRemovalTime;(!t||e{this._nextRemovalTime=!1;let e=1/0;const t=Date.now();for(const[n,s]of this._cache){const o=s[st];t>=o?this._cache.delete(n):o("lookup"in t||(t.lookup=this.lookup),e[tt](t,n))}uninstall(e){if(it(e),e[tt]){if(e[nt]!==this)throw new Error("The agent is not owned by this CacheableLookup instance");e.createConnection=e[tt],delete e[tt],delete e[nt]}}updateInterfaceInfo(){const{_iface:e}=this;this._iface=rt(),(e.has4&&!this._iface.has4||e.has6&&!this._iface.has6)&&this._cache.clear()}clear(e){e?this._cache.delete(e):this._cache.clear()}}var ht=n(9758);const[It,pt]=O.versions.node.split(".").map(Number),Ct=new Map;let mt;const bt={request:void 0,agent:{http:void 0,https:void 0,http2:void 0},h2session:void 0,decompress:!0,timeout:{connect:void 0,lookup:void 0,read:void 0,request:void 0,response:void 0,secureConnect:void 0,send:void 0,socket:void 0},prefixUrl:"",body:void 0,form:void 0,json:void 0,cookieJar:void 0,ignoreInvalidCookies:!1,searchParams:void 0,dnsLookup:void 0,dnsCache:void 0,context:{},hooks:{init:[],beforeRequest:[],beforeError:[],beforeRedirect:[],beforeRetry:[],afterResponse:[]},followRedirect:!0,maxRedirects:10,cache:void 0,throwHttpErrors:!0,username:"",password:"",http2:!1,allowGetBody:!1,headers:{"user-agent":"got (https://github.com/sindresorhus/got)"},methodRewriting:!1,dnsLookupIpVersion:void 0,parseJson:JSON.parse,stringifyJson:JSON.stringify,retry:{limit:2,methods:["GET","PUT","HEAD","DELETE","OPTIONS","TRACE"],statusCodes:[408,413,429,500,502,503,504,521,522,524],errorCodes:["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN"],maxRetryAfter:void 0,calculateDelay:({computedValue:e})=>e,backoffLimit:Number.POSITIVE_INFINITY,noise:100},localAddress:void 0,method:"GET",createConnection:void 0,cacheOptions:{shared:void 0,cacheHeuristic:void 0,immutableMinTimeToLive:void 0,ignoreCargoCult:void 0},https:{alpnProtocols:void 0,rejectUnauthorized:void 0,checkServerIdentity:void 0,certificateAuthority:void 0,key:void 0,certificate:void 0,passphrase:void 0,pfx:void 0,ciphers:void 0,honorCipherOrder:void 0,minVersion:void 0,maxVersion:void 0,signatureAlgorithms:void 0,tlsSessionLifetime:void 0,dhparam:void 0,ecdhCurve:void 0,certificateRevocationLists:void 0},encoding:void 0,resolveBodyOnly:!1,isStream:!1,responseType:"text",url:void 0,pagination:{transform:e=>"json"===e.request.options.responseType?e.body:JSON.parse(e.body),paginate({response:e}){const t=e.headers.link;if("string"!=typeof t||""===t.trim())return!1;const n=function(e){const t=[],n=e.split(",");for(const s of n){const[n,...o]=s.split(";"),i=n.trim();if("<"!==i[0]||">"!==i[i.length-1])throw new Error(`Invalid format of the Link header reference: ${i}`);const r=i.slice(1,-1),a={};if(0===o.length)throw new Error(`Unexpected end of Link header parameters: ${o.join(";")}`);for(const t of o){const n=t.trim(),s=n.indexOf("=");if(-1===s)throw new Error(`Failed to parse Link header: ${e}`);const o=n.slice(0,s).trim(),i=n.slice(s+1).trim();a[o]=i}t.push({reference:r,parameters:a})}return t}(t).find((e=>"next"===e.parameters.rel||'"next"'===e.parameters.rel));return!!n&&{url:new URL(n.reference,e.url)}},filter:()=>!0,shouldContinue:()=>!0,countLimit:Number.POSITIVE_INFINITY,backoff:0,requestLimit:1e4,stackAllItems:!1},setHost:!0,maxHeaderSize:void 0,signal:void 0,enableUnixSockets:!1},yt=e=>{const t=[e.timeout.socket,e.timeout.connect,e.timeout.lookup,e.timeout.request,e.timeout.secureConnect].filter((e=>"number"==typeof e));if(t.length>0)return Math.min(...t)},ft=(e,t,n)=>{const s=e.hooks?.init;if(s)for(const e of s)e(t,n)};class Zt{constructor(e,t,n){if(Object.defineProperty(this,"_unixOptions",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_internals",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_merging",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_init",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),k.any([Y.string,Y.urlInstance,Y.object,Y.undefined],e),k.any([Y.object,Y.undefined],t),k.any([Y.object,Y.undefined],n),e instanceof Zt||t instanceof Zt)throw new TypeError("The defaults must be passed as the third argument");this._internals=(e=>{const{hooks:t,retry:n}=e,s={...e,context:{...e.context},cacheOptions:{...e.cacheOptions},https:{...e.https},agent:{...e.agent},headers:{...e.headers},retry:{...n,errorCodes:[...n.errorCodes],methods:[...n.methods],statusCodes:[...n.statusCodes]},timeout:{...e.timeout},hooks:{init:[...t.init],beforeRequest:[...t.beforeRequest],beforeError:[...t.beforeError],beforeRedirect:[...t.beforeRedirect],beforeRetry:[...t.beforeRetry],afterResponse:[...t.afterResponse]},searchParams:e.searchParams?new URLSearchParams(e.searchParams):void 0,pagination:{...e.pagination}};return void 0!==s.url&&(s.prefixUrl=""),s})(n?._internals??n??bt),this._init=[...n?._init??[]],this._merging=!1,this._unixOptions=void 0;try{if(Y.plainObject(e))try{this.merge(e),this.merge(t)}finally{this.url=e.url}else try{this.merge(t)}finally{if(void 0!==t?.url){if(void 0!==e)throw new TypeError("The `url` option is mutually exclusive with the `input` argument");this.url=t.url}else void 0!==e&&(this.url=e)}}catch(e){throw e.options=this,e}}merge(e){if(e)if(e instanceof Zt)for(const t of e._init)this.merge(t);else{e=(e=>{const{hooks:t,retry:n}=e,s={...e};return Y.object(e.context)&&(s.context={...e.context}),Y.object(e.cacheOptions)&&(s.cacheOptions={...e.cacheOptions}),Y.object(e.https)&&(s.https={...e.https}),Y.object(e.cacheOptions)&&(s.cacheOptions={...s.cacheOptions}),Y.object(e.agent)&&(s.agent={...e.agent}),Y.object(e.headers)&&(s.headers={...e.headers}),Y.object(n)&&(s.retry={...n},Y.array(n.errorCodes)&&(s.retry.errorCodes=[...n.errorCodes]),Y.array(n.methods)&&(s.retry.methods=[...n.methods]),Y.array(n.statusCodes)&&(s.retry.statusCodes=[...n.statusCodes])),Y.object(e.timeout)&&(s.timeout={...e.timeout}),Y.object(t)&&(s.hooks={...t},Y.array(t.init)&&(s.hooks.init=[...t.init]),Y.array(t.beforeRequest)&&(s.hooks.beforeRequest=[...t.beforeRequest]),Y.array(t.beforeError)&&(s.hooks.beforeError=[...t.beforeError]),Y.array(t.beforeRedirect)&&(s.hooks.beforeRedirect=[...t.beforeRedirect]),Y.array(t.beforeRetry)&&(s.hooks.beforeRetry=[...t.beforeRetry]),Y.array(t.afterResponse)&&(s.hooks.afterResponse=[...t.afterResponse])),Y.object(e.pagination)&&(s.pagination={...e.pagination}),s})(e),ft(this,e,this),ft(e,e,this),this._merging=!0,"isStream"in e&&(this.isStream=e.isStream);try{let t=!1;for(const n in e){if("mutableDefaults"===n||"handlers"===n)continue;if("url"===n)continue;if(!(n in this))throw new Error(`Unexpected option: ${n}`);const s=e[n];void 0!==s&&(this[n]=s,t=!0)}t&&this._init.push(e)}finally{this._merging=!1}}}get request(){return this._internals.request}set request(e){k.any([Y.function_,Y.undefined],e),this._internals.request=e}get agent(){return this._internals.agent}set agent(e){k.plainObject(e);for(const t in e){if(!(t in this._internals.agent))throw new TypeError(`Unexpected agent option: ${t}`);k.any([Y.object,Y.undefined],e[t])}this._merging?Object.assign(this._internals.agent,e):this._internals.agent={...e}}get h2session(){return this._internals.h2session}set h2session(e){this._internals.h2session=e}get decompress(){return this._internals.decompress}set decompress(e){k.boolean(e),this._internals.decompress=e}get timeout(){return this._internals.timeout}set timeout(e){k.plainObject(e);for(const t in e){if(!(t in this._internals.timeout))throw new Error(`Unexpected timeout option: ${t}`);k.any([Y.number,Y.undefined],e[t])}this._merging?Object.assign(this._internals.timeout,e):this._internals.timeout={...e}}get prefixUrl(){return this._internals.prefixUrl}set prefixUrl(e){if(k.any([Y.string,Y.urlInstance],e),""!==e){if((e=e.toString()).endsWith("/")||(e+="/"),this._internals.prefixUrl&&this._internals.url){const{href:t}=this._internals.url;this._internals.url.href=e+t.slice(this._internals.prefixUrl.length)}this._internals.prefixUrl=e}else this._internals.prefixUrl=""}get body(){return this._internals.body}set body(e){k.any([Y.string,Y.buffer,Y.nodeStream,Y.generator,Y.asyncGenerator,ye,Y.undefined],e),Y.nodeStream(e)&&k.truthy(e.readable),void 0!==e&&(k.undefined(this._internals.form),k.undefined(this._internals.json)),this._internals.body=e}get form(){return this._internals.form}set form(e){k.any([Y.plainObject,Y.undefined],e),void 0!==e&&(k.undefined(this._internals.body),k.undefined(this._internals.json)),this._internals.form=e}get json(){return this._internals.json}set json(e){void 0!==e&&(k.undefined(this._internals.body),k.undefined(this._internals.form)),this._internals.json=e}get url(){return this._internals.url}set url(e){if(k.any([Y.string,Y.urlInstance,Y.undefined],e),void 0===e)return void(this._internals.url=void 0);if(Y.string(e)&&e.startsWith("/"))throw new Error("`url` must not start with a slash");const t=`${this.prefixUrl}${e.toString()}`,n=new URL(t);if(this._internals.url=n,"unix:"===n.protocol&&(n.href=`http://unix${n.pathname}${n.search}`),"http:"!==n.protocol&&"https:"!==n.protocol){const e=new Error(`Unsupported protocol: ${n.protocol}`);throw e.code="ERR_UNSUPPORTED_PROTOCOL",e}if(this._internals.username&&(n.username=this._internals.username,this._internals.username=""),this._internals.password&&(n.password=this._internals.password,this._internals.password=""),this._internals.searchParams&&(n.search=this._internals.searchParams.toString(),this._internals.searchParams=void 0),"unix"!==n.hostname)this._unixOptions=void 0;else{if(!this._internals.enableUnixSockets)throw new Error("Using UNIX domain sockets but option `enableUnixSockets` is not enabled");const e=/(?.+?):(?.+)/.exec(`${n.pathname}${n.search}`);if(e?.groups){const{socketPath:t,path:n}=e.groups;this._unixOptions={socketPath:t,path:n,host:""}}else this._unixOptions=void 0}}get cookieJar(){return this._internals.cookieJar}set cookieJar(e){if(k.any([Y.object,Y.undefined],e),void 0===e)return void(this._internals.cookieJar=void 0);let{setCookie:t,getCookieString:n}=e;k.function_(t),k.function_(n),4===t.length&&0===n.length?(t=(0,Te.promisify)(t.bind(e)),n=(0,Te.promisify)(n.bind(e)),this._internals.cookieJar={setCookie:t,getCookieString:n}):this._internals.cookieJar=e}get signal(){return this._internals.signal}set signal(e){k.object(e),this._internals.signal=e}get ignoreInvalidCookies(){return this._internals.ignoreInvalidCookies}set ignoreInvalidCookies(e){k.boolean(e),this._internals.ignoreInvalidCookies=e}get searchParams(){return this._internals.url?this._internals.url.searchParams:(void 0===this._internals.searchParams&&(this._internals.searchParams=new URLSearchParams),this._internals.searchParams)}set searchParams(e){k.any([Y.string,Y.object,Y.undefined],e);const t=this._internals.url;if(void 0===e)return this._internals.searchParams=void 0,void(t&&(t.search=""));const n=this.searchParams;let s;if(Y.string(e))s=new URLSearchParams(e);else if(e instanceof URLSearchParams)s=e;else{!function(e){for(const t in e){const n=e[t];k.any([Y.string,Y.number,Y.boolean,Y.null_,Y.undefined],n)}}(e),s=new URLSearchParams;for(const t in e){const o=e[t];null===o?s.append(t,""):void 0===o?n.delete(t):s.append(t,o)}}if(this._merging){for(const e of s.keys())n.delete(e);for(const[e,t]of s)n.append(e,t)}else t?t.search=n.toString():this._internals.searchParams=n}get searchParameters(){throw new Error("The `searchParameters` option does not exist. Use `searchParams` instead.")}set searchParameters(e){throw new Error("The `searchParameters` option does not exist. Use `searchParams` instead.")}get dnsLookup(){return this._internals.dnsLookup}set dnsLookup(e){k.any([Y.function_,Y.undefined],e),this._internals.dnsLookup=e}get dnsCache(){return this._internals.dnsCache}set dnsCache(e){k.any([Y.object,Y.boolean,Y.undefined],e),this._internals.dnsCache=!0===e?mt||(mt=new ut,mt):!1===e?void 0:e}get context(){return this._internals.context}set context(e){k.object(e),this._merging?Object.assign(this._internals.context,e):this._internals.context={...e}}get hooks(){return this._internals.hooks}set hooks(e){k.object(e);for(const t in e){if(!(t in this._internals.hooks))throw new Error(`Unexpected hook event: ${t}`);const n=t,s=e[n];if(k.any([Y.array,Y.undefined],s),s)for(const e of s)k.function_(e);if(this._merging)s&&this._internals.hooks[n].push(...s);else{if(!s)throw new Error(`Missing hook event: ${t}`);this._internals.hooks[t]=[...s]}}}get followRedirect(){return this._internals.followRedirect}set followRedirect(e){k.boolean(e),this._internals.followRedirect=e}get followRedirects(){throw new TypeError("The `followRedirects` option does not exist. Use `followRedirect` instead.")}set followRedirects(e){throw new TypeError("The `followRedirects` option does not exist. Use `followRedirect` instead.")}get maxRedirects(){return this._internals.maxRedirects}set maxRedirects(e){k.number(e),this._internals.maxRedirects=e}get cache(){return this._internals.cache}set cache(e){k.any([Y.object,Y.string,Y.boolean,Y.undefined],e),this._internals.cache=!0===e?Ct:!1===e?void 0:e}get throwHttpErrors(){return this._internals.throwHttpErrors}set throwHttpErrors(e){k.boolean(e),this._internals.throwHttpErrors=e}get username(){const e=this._internals.url,t=e?e.username:this._internals.username;return decodeURIComponent(t)}set username(e){k.string(e);const t=this._internals.url,n=encodeURIComponent(e);t?t.username=n:this._internals.username=n}get password(){const e=this._internals.url,t=e?e.password:this._internals.password;return decodeURIComponent(t)}set password(e){k.string(e);const t=this._internals.url,n=encodeURIComponent(e);t?t.password=n:this._internals.password=n}get http2(){return this._internals.http2}set http2(e){k.boolean(e),this._internals.http2=e}get allowGetBody(){return this._internals.allowGetBody}set allowGetBody(e){k.boolean(e),this._internals.allowGetBody=e}get headers(){return this._internals.headers}set headers(e){k.plainObject(e),this._merging?Object.assign(this._internals.headers,re(e)):this._internals.headers=re(e)}get methodRewriting(){return this._internals.methodRewriting}set methodRewriting(e){k.boolean(e),this._internals.methodRewriting=e}get dnsLookupIpVersion(){return this._internals.dnsLookupIpVersion}set dnsLookupIpVersion(e){if(void 0!==e&&4!==e&&6!==e)throw new TypeError(`Invalid DNS lookup IP version: ${e}`);this._internals.dnsLookupIpVersion=e}get parseJson(){return this._internals.parseJson}set parseJson(e){k.function_(e),this._internals.parseJson=e}get stringifyJson(){return this._internals.stringifyJson}set stringifyJson(e){k.function_(e),this._internals.stringifyJson=e}get retry(){return this._internals.retry}set retry(e){if(k.plainObject(e),k.any([Y.function_,Y.undefined],e.calculateDelay),k.any([Y.number,Y.undefined],e.maxRetryAfter),k.any([Y.number,Y.undefined],e.limit),k.any([Y.array,Y.undefined],e.methods),k.any([Y.array,Y.undefined],e.statusCodes),k.any([Y.array,Y.undefined],e.errorCodes),k.any([Y.number,Y.undefined],e.noise),e.noise&&Math.abs(e.noise)>100)throw new Error(`The maximum acceptable retry noise is +/- 100ms, got ${e.noise}`);for(const t in e)if(!(t in this._internals.retry))throw new Error(`Unexpected retry option: ${t}`);this._merging?Object.assign(this._internals.retry,e):this._internals.retry={...e};const{retry:t}=this._internals;t.methods=[...new Set(t.methods.map((e=>e.toUpperCase())))],t.statusCodes=[...new Set(t.statusCodes)],t.errorCodes=[...new Set(t.errorCodes)]}get localAddress(){return this._internals.localAddress}set localAddress(e){k.any([Y.string,Y.undefined],e),this._internals.localAddress=e}get method(){return this._internals.method}set method(e){k.string(e),this._internals.method=e.toUpperCase()}get createConnection(){return this._internals.createConnection}set createConnection(e){k.any([Y.function_,Y.undefined],e),this._internals.createConnection=e}get cacheOptions(){return this._internals.cacheOptions}set cacheOptions(e){k.plainObject(e),k.any([Y.boolean,Y.undefined],e.shared),k.any([Y.number,Y.undefined],e.cacheHeuristic),k.any([Y.number,Y.undefined],e.immutableMinTimeToLive),k.any([Y.boolean,Y.undefined],e.ignoreCargoCult);for(const t in e)if(!(t in this._internals.cacheOptions))throw new Error(`Cache option \`${t}\` does not exist`);this._merging?Object.assign(this._internals.cacheOptions,e):this._internals.cacheOptions={...e}}get https(){return this._internals.https}set https(e){k.plainObject(e),k.any([Y.boolean,Y.undefined],e.rejectUnauthorized),k.any([Y.function_,Y.undefined],e.checkServerIdentity),k.any([Y.string,Y.object,Y.array,Y.undefined],e.certificateAuthority),k.any([Y.string,Y.object,Y.array,Y.undefined],e.key),k.any([Y.string,Y.object,Y.array,Y.undefined],e.certificate),k.any([Y.string,Y.undefined],e.passphrase),k.any([Y.string,Y.buffer,Y.array,Y.undefined],e.pfx),k.any([Y.array,Y.undefined],e.alpnProtocols),k.any([Y.string,Y.undefined],e.ciphers),k.any([Y.string,Y.buffer,Y.undefined],e.dhparam),k.any([Y.string,Y.undefined],e.signatureAlgorithms),k.any([Y.string,Y.undefined],e.minVersion),k.any([Y.string,Y.undefined],e.maxVersion),k.any([Y.boolean,Y.undefined],e.honorCipherOrder),k.any([Y.number,Y.undefined],e.tlsSessionLifetime),k.any([Y.string,Y.undefined],e.ecdhCurve),k.any([Y.string,Y.buffer,Y.array,Y.undefined],e.certificateRevocationLists);for(const t in e)if(!(t in this._internals.https))throw new Error(`HTTPS option \`${t}\` does not exist`);this._merging?Object.assign(this._internals.https,e):this._internals.https={...e}}get encoding(){return this._internals.encoding}set encoding(e){if(null===e)throw new TypeError("To get a Buffer, set `options.responseType` to `buffer` instead");k.any([Y.string,Y.undefined],e),this._internals.encoding=e}get resolveBodyOnly(){return this._internals.resolveBodyOnly}set resolveBodyOnly(e){k.boolean(e),this._internals.resolveBodyOnly=e}get isStream(){return this._internals.isStream}set isStream(e){k.boolean(e),this._internals.isStream=e}get responseType(){return this._internals.responseType}set responseType(e){if(void 0!==e){if("text"!==e&&"buffer"!==e&&"json"!==e)throw new Error(`Invalid \`responseType\` option: ${e}`);this._internals.responseType=e}else this._internals.responseType="text"}get pagination(){return this._internals.pagination}set pagination(e){k.object(e),this._merging?Object.assign(this._internals.pagination,e):this._internals.pagination=e}get auth(){throw new Error("Parameter `auth` is deprecated. Use `username` / `password` instead.")}set auth(e){throw new Error("Parameter `auth` is deprecated. Use `username` / `password` instead.")}get setHost(){return this._internals.setHost}set setHost(e){k.boolean(e),this._internals.setHost=e}get maxHeaderSize(){return this._internals.maxHeaderSize}set maxHeaderSize(e){k.any([Y.number,Y.undefined],e),this._internals.maxHeaderSize=e}get enableUnixSockets(){return this._internals.enableUnixSockets}set enableUnixSockets(e){k.boolean(e),this._internals.enableUnixSockets=e}toJSON(){return{...this._internals}}[Symbol.for("nodejs.util.inspect.custom")](e,t){return(0,Te.inspect)(this._internals,t)}createNativeRequestOptions(){const e=this._internals;let t;t="https:"===e.url.protocol?e.http2?e.agent:e.agent.https:e.agent.http;const{https:n}=e;let{pfx:s}=n;return Y.array(s)&&Y.plainObject(s[0])&&(s=s.map((e=>({buf:e.buffer,passphrase:e.passphrase})))),{...e.cacheOptions,...this._unixOptions,ALPNProtocols:n.alpnProtocols,ca:n.certificateAuthority,cert:n.certificate,key:n.key,passphrase:n.passphrase,pfx:n.pfx,rejectUnauthorized:n.rejectUnauthorized,checkServerIdentity:n.checkServerIdentity??Pe.checkServerIdentity,ciphers:n.ciphers,honorCipherOrder:n.honorCipherOrder,minVersion:n.minVersion,maxVersion:n.maxVersion,sigalgs:n.signatureAlgorithms,sessionTimeout:n.tlsSessionLifetime,dhparam:n.dhparam,ecdhCurve:n.ecdhCurve,crl:n.certificateRevocationLists,lookup:e.dnsLookup??e.dnsCache?.lookup,family:e.dnsLookupIpVersion,agent:t,setHost:e.setHost,method:e.method,maxHeaderSize:e.maxHeaderSize,localAddress:e.localAddress,headers:e.headers,createConnection:e.createConnection,timeout:e.http2?yt(e):void 0,h2session:e.h2session}}getRequestFunction(){const e=this._internals.url,{request:t}=this._internals;return!t&&e?this.getFallbackRequestFunction():t}getFallbackRequestFunction(){const e=this._internals.url;if(e){if("https:"===e.protocol){if(this._internals.http2){if(It<15||15===It&&pt<10){const e=new Error("To use the `http2` option, install Node.js 15.10.0 or above");throw e.code="EUNSUPPORTED",e}return ht.auto}return De.request}return P.request}}freeze(){const e=this._internals;Object.freeze(e),Object.freeze(e.hooks),Object.freeze(e.hooks.afterResponse),Object.freeze(e.hooks.beforeError),Object.freeze(e.hooks.beforeRedirect),Object.freeze(e.hooks.beforeRequest),Object.freeze(e.hooks.beforeRetry),Object.freeze(e.hooks.init),Object.freeze(e.https),Object.freeze(e.cacheOptions),Object.freeze(e.agent),Object.freeze(e.headers),Object.freeze(e.timeout),Object.freeze(e.retry),Object.freeze(e.retry.errorCodes),Object.freeze(e.retry.methods),Object.freeze(e.retry.statusCodes)}}const At=e=>{const{statusCode:t}=e,n=e.request.options.followRedirect?299:399;return t>=200&&t<=n||304===t};class Gt extends K{constructor(e,t){const{options:n}=t.request;super(`${e.message} in "${n.url.toString()}"`,e,t.request),this.name="ParseError",this.code="ERR_BODY_PARSE_FAILURE"}}const Bt=(e,t,n,s)=>{const{rawBody:o}=e;try{if("text"===t)return o.toString(s);if("json"===t)return 0===o.length?"":n(o.toString(s));if("buffer"===t)return o}catch(t){throw new Gt(t,e)}throw new Gt({message:`Unknown body type '${t}'`,name:"Error"},e)};function vt(e){return"unix:"===e.protocol||"unix"===e.hostname}const{buffer:Wt}=oe,Vt=Y.string(O.versions.brotli),wt=new Set(["GET","HEAD"]),St=new class{constructor(){Object.defineProperty(this,"weakMap",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"map",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.weakMap=new WeakMap,this.map=new Map}set(e,t){"object"==typeof e?this.weakMap.set(e,t):this.map.set(e,t)}get(e){return"object"==typeof e?this.weakMap.get(e):this.map.get(e)}has(e){return"object"==typeof e?this.weakMap.has(e):this.map.has(e)}},Rt=new Set([300,301,302,303,304,307,308]),Ht=["socket","connect","continue","information","upgrade"],Xt=()=>{};class kt extends M.Duplex{constructor(e,t,n){super({autoDestroy:!1,highWaterMark:0}),Object.defineProperty(this,"constructor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_noPipe",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"response",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"requestUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"redirectUrls",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"retryCount",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_stopRetry",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_downloadedSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_uploadedSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_stopReading",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_pipedServerResponses",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_request",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_responseSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_bodySize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_unproxyEvents",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_isFromCache",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_cannotHaveBody",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_triggerRead",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_cancelTimeouts",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_removeListeners",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_nativeResponse",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_flushed",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_aborted",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_requestInitialized",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._downloadedSize=0,this._uploadedSize=0,this._stopReading=!1,this._pipedServerResponses=new Set,this._cannotHaveBody=!1,this._unproxyEvents=Xt,this._triggerRead=!1,this._cancelTimeouts=Xt,this._removeListeners=Xt,this._jobs=[],this._flushed=!1,this._requestInitialized=!1,this._aborted=!1,this.redirectUrls=[],this.retryCount=0,this._stopRetry=Xt,this.on("pipe",(e=>{e?.headers&&Object.assign(this.options.headers,e.headers)})),this.on("newListener",(e=>{if("retry"===e&&this.listenerCount("retry")>0)throw new Error("A retry listener has been attached already.")}));try{if(this.options=new Zt(e,t,n),!this.options.url){if(""===this.options.prefixUrl)throw new TypeError("Missing `url` property");this.options.url=""}this.requestUrl=this.options.url}catch(e){const{options:t}=e;return t&&(this.options=t),void(this.flush=async()=>{this.flush=async()=>{},this.destroy(e)})}const{body:s}=this.options;if(Y.nodeStream(s)&&s.once("error",(e=>{this._flushed?this._beforeError(new T(e,this)):this.flush=async()=>{this.flush=async()=>{},this._beforeError(new T(e,this))}})),this.options.signal){const e=()=>{this.destroy(new L(this))};this.options.signal.aborted?e():(this.options.signal.addEventListener("abort",e),this._removeListeners=()=>{this.options.signal?.removeEventListener("abort",e)})}}async flush(){if(!this._flushed){this._flushed=!0;try{if(await this._finalizeBody(),this.destroyed)return;if(await this._makeRequest(),this.destroyed)return void this._request?.destroy();for(const e of this._jobs)e();this._jobs.length=0,this._requestInitialized=!0}catch(e){this._beforeError(e)}}}_beforeError(e){if(this._stopReading)return;const{response:t,options:n}=this,s=this.retryCount+("RetryError"===e.name?0:1);this._stopReading=!0,e instanceof K||(e=new K(e.message,e,this));const o=e;(async()=>{if(!t?.readable||t.rawBody||this._request?.socket?.destroyed||(t.setEncoding(this.readableEncoding),await this._setRawBody(t)&&(t.body=t.rawBody.toString())),0!==this.listenerCount("retry")){let i;try{let e;t&&"retry-after"in t.headers&&(e=Number(t.headers["retry-after"]),Number.isNaN(e)?(e=Date.parse(t.headers["retry-after"])-Date.now(),e<=0&&(e=1)):e*=1e3);const r=n.retry;i=await r.calculateDelay({attemptCount:s,retryOptions:r,error:o,retryAfter:e,computedValue:Me({attemptCount:s,retryOptions:r,error:o,retryAfter:e,computedValue:r.maxRetryAfter??n.timeout.request??Number.POSITIVE_INFINITY})})}catch(e){return void this._error(new K(e.message,e,this))}if(i){if(await new Promise((e=>{const t=setTimeout(e,i);this._stopRetry=()=>{clearTimeout(t),e()}})),this.destroyed)return;try{for(const e of this.options.hooks.beforeRetry)await e(o,this.retryCount+1)}catch(t){return void this._error(new K(t.message,e,this))}if(this.destroyed)return;return this.destroy(),void this.emit("retry",this.retryCount+1,e,(e=>{const t=new kt(n.url,e,n);return t.retryCount=this.retryCount+1,O.nextTick((()=>{t.flush()})),t}))}}this._error(o)})()}_read(){this._triggerRead=!0;const{response:e}=this;if(e&&!this._stopReading){let t;for(e.readableLength&&(this._triggerRead=!1);null!==(t=e.read());){this._downloadedSize+=t.length;const e=this.downloadProgress;e.percent<1&&this.emit("downloadProgress",e),this.push(t)}}}_write(e,t,n){const s=()=>{this._writeRequest(e,t,n)};this._requestInitialized?s():this._jobs.push(s)}_final(e){const t=()=>{this._request&&!this._request.destroyed?this._request.end((t=>{this._request._writableState?.errored||(t||(this._bodySize=this._uploadedSize,this.emit("uploadProgress",this.uploadProgress),this._request.emit("upload-complete")),e(t))})):e()};this._requestInitialized?t():this._jobs.push(t)}_destroy(e,t){if(this._stopReading=!0,this.flush=async()=>{},this._stopRetry(),this._cancelTimeouts(),this._removeListeners(),this.options){const{body:e}=this.options;Y.nodeStream(e)&&e.destroy()}this._request&&this._request.destroy(),null===e||Y.undefined(e)||e instanceof K||(e=new K(e.message,e,this)),t(e)}pipe(e,t){return e instanceof P.ServerResponse&&this._pipedServerResponses.add(e),super.pipe(e,t)}unpipe(e){return e instanceof P.ServerResponse&&this._pipedServerResponses.delete(e),super.unpipe(e),this}async _finalizeBody(){const{options:e}=this,{headers:t}=e,n=!Y.undefined(e.form),s=!Y.undefined(e.json),o=!Y.undefined(e.body),i=wt.has(e.method)&&!("GET"===e.method&&e.allowGetBody);if(this._cannotHaveBody=i,n||s||o){if(i)throw new TypeError(`The \`${e.method}\` method cannot be used with a body`);const s=!Y.string(t["content-type"]);if(o){if(ye(e.body)){const n=new ze(e.body);s&&(t["content-type"]=n.headers["Content-Type"]),"Content-Length"in n.headers&&(t["content-length"]=n.headers["Content-Length"]),e.body=n.encode()}Ee(e.body)&&s&&(t["content-type"]=`multipart/form-data; boundary=${e.body.getBoundary()}`)}else if(n){s&&(t["content-type"]="application/x-www-form-urlencoded");const{form:n}=e;e.form=void 0,e.body=new URLSearchParams(n).toString()}else{s&&(t["content-type"]="application/json");const{json:n}=e;e.json=void 0,e.body=e.stringifyJson(n)}const r=await async function(e,t){return t&&"content-length"in t?Number(t["content-length"]):e?Y.string(e)?j.Buffer.byteLength(e):Y.buffer(e)?e.length:Ee(e)?(0,Te.promisify)(e.getLength.bind(e))():void 0:0}(e.body,e.headers);Y.undefined(t["content-length"])&&Y.undefined(t["transfer-encoding"])&&!i&&!Y.undefined(r)&&(t["content-length"]=String(r))}"json"!==e.responseType||"accept"in e.headers||(e.headers.accept="application/json"),this._bodySize=Number(t["content-length"])||void 0}async _onResponseBase(e){if(this.isAborted)return;const{options:t}=this,{url:n}=t;this._nativeResponse=e,t.decompress&&(e=me(e));const s=e.statusCode,o=e;o.statusMessage=o.statusMessage??P.STATUS_CODES[s],o.url=t.url.toString(),o.requestUrl=this.requestUrl,o.redirectUrls=this.redirectUrls,o.request=this,o.isFromCache=this._nativeResponse.fromCache??!1,o.ip=this.ip,o.retryCount=this.retryCount,o.ok=At(o),this._isFromCache=o.isFromCache,this._responseSize=Number(e.headers["content-length"])||void 0,this.response=o,e.once("end",(()=>{this._responseSize=this._downloadedSize,this.emit("downloadProgress",this.downloadProgress)})),e.once("error",(t=>{this._aborted=!0,e.destroy(),this._beforeError(new U(t,this))})),e.once("aborted",(()=>{this._aborted=!0,this._beforeError(new U({name:"Error",message:"The server aborted pending request",code:"ECONNRESET"},this))})),this.emit("downloadProgress",this.downloadProgress);const i=e.headers["set-cookie"];if(Y.object(t.cookieJar)&&i){let e=i.map((async e=>t.cookieJar.setCookie(e,n.toString())));t.ignoreInvalidCookies&&(e=e.map((async e=>{try{await e}catch{}})));try{await Promise.all(e)}catch(e){return void this._beforeError(e)}}if(!this.isAborted)if(t.followRedirect&&e.headers.location&&Rt.has(s)){if(e.resume(),this._cancelTimeouts(),this._unproxyEvents(),this.redirectUrls.length>=t.maxRedirects)return void this._beforeError(new F(this));this._request=void 0;const i=new Zt(void 0,void 0,this.options),r=303===s&&"GET"!==i.method&&"HEAD"!==i.method,a=307!==s&&308!==s,c=i.methodRewriting&&a;(r||c)&&(i.method="GET",i.body=void 0,i.json=void 0,i.form=void 0,delete i.headers["content-length"]);try{const t=j.Buffer.from(e.headers.location,"binary").toString(),s=new URL(t,n);if(!vt(n)&&vt(s))return void this._beforeError(new K("Cannot redirect to UNIX socket",{},this));s.hostname!==n.hostname||s.port!==n.port?("host"in i.headers&&delete i.headers.host,"cookie"in i.headers&&delete i.headers.cookie,"authorization"in i.headers&&delete i.headers.authorization,(i.username||i.password)&&(i.username="",i.password="")):(s.username=i.username,s.password=i.password),this.redirectUrls.push(s),i.prefixUrl="",i.url=s;for(const e of i.hooks.beforeRedirect)await e(i,o);this.emit("redirect",i,o),this.options=i,await this._makeRequest()}catch(e){return void this._beforeError(e)}}else if(t.isStream&&t.throwHttpErrors&&!At(o))this._beforeError(new x(o));else if(e.on("readable",(()=>{this._triggerRead&&this._read()})),this.on("resume",(()=>{e.resume()})),this.on("pause",(()=>{e.pause()})),e.once("end",(()=>{this.push(null)})),this._noPipe)await this._setRawBody()&&this.emit("response",e);else{this.emit("response",e);for(const n of this._pipedServerResponses)if(!n.headersSent){for(const s in e.headers){const o=!t.decompress||"content-encoding"!==s,i=e.headers[s];o&&n.setHeader(s,i)}n.statusCode=s}}}async _setRawBody(e=this){if(e.readableEnded)return!1;try{const t=await Wt(e);if(!this.isAborted)return this.response.rawBody=t,!0}catch{}return!1}async _onResponse(e){try{await this._onResponseBase(e)}catch(e){this._beforeError(e)}}_onRequest(e){const{options:t}=this,{timeout:n,url:s}=t;(e=>{if(e.timings)return e.timings;const t={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}};e.timings=t;const n=e=>{e.once(D.errorMonitor,(()=>{t.error=Date.now(),t.phases.total=t.error-t.start}))};n(e);const s=()=>{t.abort=Date.now(),t.phases.total=t.abort-t.start};e.prependOnceListener("abort",s);const o=e=>{if(t.socket=Date.now(),t.phases.wait=t.socket-t.start,q.types.isProxy(e))return;const n=()=>{t.lookup=Date.now(),t.phases.dns=t.lookup-t.socket};e.prependOnceListener("lookup",n),$(e,{connect:()=>{t.connect=Date.now(),void 0===t.lookup&&(e.removeListener("lookup",n),t.lookup=t.connect,t.phases.dns=t.lookup-t.socket),t.phases.tcp=t.connect-t.lookup},secureConnect:()=>{t.secureConnect=Date.now(),t.phases.tls=t.secureConnect-t.connect}})};e.socket?o(e.socket):e.prependOnceListener("socket",o);const i=()=>{t.upload=Date.now(),t.phases.request=t.upload-(t.secureConnect??t.connect)};e.writableFinished?i():e.prependOnceListener("finish",i),e.prependOnceListener("response",(o=>{t.response=Date.now(),t.phases.firstByte=t.response-t.upload,o.timings=t,n(o),o.prependOnceListener("end",(()=>{e.off("abort",s),o.off("aborted",s),t.phases.total||(t.end=Date.now(),t.phases.download=t.end-t.response,t.phases.total=t.end-t.start)})),o.prependOnceListener("aborted",s)}))})(e),this.options.http2&&e.setTimeout(0),this._cancelTimeouts=function(e,t,n){if(Le in e)return Oe;e[Le]=!0;const s=[],{once:o,unhandleAll:i}=function(){const e=[];return{once(t,n,s){t.once(n,s),e.push({origin:t,event:n,fn:s})},unhandleAll(){for(const t of e){const{origin:e,event:n,fn:s}=t;e.removeListener(n,s)}e.length=0}}}(),r=(e,t,n)=>{const o=setTimeout(t,e,e,n);o.unref?.();const i=()=>{clearTimeout(o)};return s.push(i),i},{host:a,hostname:c}=n,l=(t,n)=>{e.destroy(new je(t,n))},g=()=>{for(const e of s)e();i()};if(e.once("error",(t=>{if(g(),0===e.listenerCount("error"))throw t})),void 0!==t.request){const n=r(t.request,l,"request");o(e,"response",(e=>{o(e,"end",n)}))}if(void 0!==t.socket){const{socket:n}=t,o=()=>{l(n,"socket")};e.setTimeout(n,o),s.push((()=>{e.removeListener("timeout",o)}))}const d=void 0!==t.lookup,u=void 0!==t.connect,h=void 0!==t.secureConnect,I=void 0!==t.send;return(d||u||h||I)&&o(e,"socket",(s=>{const{socketPath:i}=e;if(s.connecting){const e=Boolean(i??0!==Qe.isIP(c??a??""));if(d&&!e&&void 0===s.address().address){const e=r(t.lookup,l,"lookup");o(s,"lookup",e)}if(u){const n=()=>r(t.connect,l,"connect");e?o(s,"connect",n()):o(s,"lookup",(e=>{null===e&&o(s,"connect",n())}))}h&&"https:"===n.protocol&&o(s,"connect",(()=>{const e=r(t.secureConnect,l,"secureConnect");o(s,"secureConnect",e)}))}if(I){const n=()=>r(t.send,l,"send");s.connecting?o(s,"connect",(()=>{o(e,"upload-complete",n())})):o(e,"upload-complete",n())}})),void 0!==t.response&&o(e,"upload-complete",(()=>{const n=r(t.response,l,"response");o(e,"response",n)})),void 0!==t.read&&o(e,"response",(e=>{const n=r(t.read,l,"read");o(e,"end",n)})),g}(e,n,s);const o=t.cache?"cacheableResponse":"response";e.once(o,(e=>{this._onResponse(e)})),e.once("error",(t=>{this._aborted=!0,e.destroy(),t=t instanceof je?new E(t,this.timings,this):new K(t.message,t,this),this._beforeError(t)})),this._unproxyEvents=Ue(e,this,Ht),this._request=e,this.emit("uploadProgress",this.uploadProgress),this._sendBody(),this.emit("request",e)}async _asyncWrite(e){return new Promise(((t,n)=>{super.write(e,(e=>{e?n(e):t()}))}))}_sendBody(){const{body:e}=this.options,t=0===this.redirectUrls.length?this:this._request??this;Y.nodeStream(e)?e.pipe(t):Y.generator(e)||Y.asyncGenerator(e)?(async()=>{try{for await(const t of e)await this._asyncWrite(t);super.end()}catch(e){this._beforeError(e)}})():Y.undefined(e)?(this._cannotHaveBody||this._noPipe)&&t.end():(this._writeRequest(e,void 0,(()=>{})),t.end())}_prepareCache(e){if(!St.has(e)){const t=new Ce(((e,t)=>{const n=e._request(e,t);return Y.promise(n)&&(n.once=(e,t)=>{if("error"===e)(async()=>{try{await n}catch(e){t(e)}})();else{if("abort"!==e)throw new Error(`Unknown HTTP2 promise event: ${e}`);(async()=>{try{(await n).once("abort",t)}catch{}})()}return n}),n}),e);St.set(e,t.request())}}async _createCacheableRequest(e,t){return new Promise(((n,s)=>{let o;Object.assign(t,function(e){const t={protocol:e.protocol,hostname:Y.string(e.hostname)&&e.hostname.startsWith("[")?e.hostname.slice(1,-1):e.hostname,host:e.host,hash:e.hash,search:e.search,pathname:e.pathname,href:e.href,path:`${e.pathname||""}${e.search||""}`};return Y.string(e.port)&&e.port.length>0&&(t.port=Number(e.port)),(e.username||e.password)&&(t.auth=`${e.username||""}:${e.password||""}`),t}(e));const i=St.get(t.cache)(t,(async e=>{if(e._readableState.autoDestroy=!1,o){const t=()=>{e.req&&(e.complete=e.req.res.complete)};e.prependOnceListener("end",t),t(),(await o).emit("cacheableResponse",e)}n(e)}));i.once("error",s),i.once("request",(async e=>{o=e,n(o)}))}))}async _makeRequest(){const{options:e}=this,{headers:t,username:n,password:s}=e,o=e.cookieJar;for(const e in t)if(Y.undefined(t[e]))delete t[e];else if(Y.null_(t[e]))throw new TypeError(`Use \`undefined\` instead of \`null\` to delete the \`${e}\` header`);if(e.decompress&&Y.undefined(t["accept-encoding"])&&(t["accept-encoding"]=Vt?"gzip, deflate, br":"gzip, deflate"),n||s){const e=j.Buffer.from(`${n}:${s}`).toString("base64");t.authorization=`Basic ${e}`}if(o){const n=await o.getCookieString(e.url.toString());Y.nonEmptyString(n)&&(t.cookie=n)}let i;e.prefixUrl="";for(const t of e.hooks.beforeRequest){const n=await t(e);if(!Y.undefined(n)){i=()=>n;break}}i||(i=e.getRequestFunction());const r=e.url;this._requestOptions=e.createNativeRequestOptions(),e.cache&&(this._requestOptions._request=i,this._requestOptions.cache=e.cache,this._requestOptions.body=e.body,this._prepareCache(e.cache));const a=e.cache?this._createCacheableRequest:i;try{let t=a(r,this._requestOptions);Y.promise(t)&&(t=await t),Y.undefined(t)&&(t=e.getFallbackRequestFunction()(r,this._requestOptions),Y.promise(t)&&(t=await t)),(c=t).writable&&!c.writableEnded?this._onRequest(t):this.writable?(this.once("finish",(()=>{this._onResponse(t)})),this._sendBody()):this._onResponse(t)}catch(e){if(e instanceof de)throw new z(e,this);throw e}var c}async _error(e){try{if(e instanceof x&&!this.options.throwHttpErrors);else for(const t of this.options.hooks.beforeError)e=await t(e)}catch(t){e=new K(t.message,t,this)}this.destroy(e)}_writeRequest(e,t,n){this._request&&!this._request.destroyed&&this._request.write(e,t,(s=>{if(!s&&!this._request.destroyed){this._uploadedSize+=j.Buffer.byteLength(e,t);const n=this.uploadProgress;n.percent<1&&this.emit("uploadProgress",n)}n(s)}))}get ip(){return this.socket?.remoteAddress}get isAborted(){return this._aborted}get socket(){return this._request?.socket??void 0}get downloadProgress(){let e;return e=this._responseSize?this._downloadedSize/this._responseSize:this._responseSize===this._downloadedSize?1:0,{percent:e,transferred:this._downloadedSize,total:this._responseSize}}get uploadProgress(){let e;return e=this._bodySize?this._uploadedSize/this._bodySize:this._bodySize===this._uploadedSize?1:0,{percent:e,transferred:this._uploadedSize,total:this._bodySize}}get timings(){return this._request?.timings}get isFromCache(){return this._isFromCache}get reusedSocket(){return this._request?.reusedSocket}}class Yt extends K{constructor(e){super("Promise was canceled",{},e),this.name="CancelError",this.code="ERR_CANCELED"}get isCanceled(){return!0}}const Nt=["request","response","redirect","uploadProgress","downloadProgress"];function Jt(e){let t,n,s;const o=new N.EventEmitter,i=new _(((r,a,c)=>{c((()=>{t.destroy()})),c.shouldReject=!1,c((()=>{a(new Yt(t))}));const l=g=>{c((()=>{}));const d=e??new kt(void 0,void 0,s);d.retryCount=g,d._noPipe=!0,t=d,d.once("response",(async e=>{const t=(e.headers["content-encoding"]??"").toLowerCase(),s="gzip"===t||"deflate"===t||"br"===t,{options:o}=d;if(s&&!o.decompress)e.body=e.rawBody;else try{e.body=Bt(e,o.responseType,o.parseJson,o.encoding)}catch(t){if(e.body=e.rawBody.toString(),At(e))return void d._beforeError(t)}try{const t=o.hooks.afterResponse;for(const[n,s]of t.entries())if(e=await s(e,(async e=>{throw o.merge(e),o.prefixUrl="",e.url&&(o.url=e.url),o.hooks.afterResponse=o.hooks.afterResponse.slice(0,n),new Q(d)})),!Y.object(e)||!Y.number(e.statusCode)||Y.nullOrUndefined(e.body))throw new TypeError("The `afterResponse` hook returned an invalid value")}catch(e){return void d._beforeError(e)}n=e,At(e)?(d.destroy(),r(d.options.resolveBodyOnly?e.body:e)):d._beforeError(new x(e))}));const u=e=>{if(i.isCanceled)return;const{options:t}=d;if(e instanceof x&&!t.throwHttpErrors){const{response:t}=e;return d.destroy(),void r(d.options.resolveBodyOnly?t.body:t)}a(e)};d.once("error",u);const h=d.options?.body;d.once("retry",((t,n)=>{e=void 0;const o=d.options.body;if(h===o&&Y.nodeStream(o))return n.message="Cannot retry with consumed body stream",void u(n);s=d.options,l(t)})),Ue(d,o,Nt),Y.undefined(e)&&d.flush()};l(0)}));i.on=(e,t)=>(o.on(e,t),i),i.off=(e,t)=>(o.off(e,t),i);const r=e=>{const t=(async()=>{await i;const{options:t}=n.request;return Bt(n,e,t.parseJson,t.encoding)})();return Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)),t};return i.json=()=>{if(t.options){const{headers:e}=t.options;t.writableFinished||"accept"in e||(e.accept="application/json")}return r("json")},i.buffer=()=>r("buffer"),i.text=()=>r("text"),i}const _t=async e=>new Promise((t=>{setTimeout(t,e)})),Kt=e=>Y.function_(e),Ft=["get","post","put","patch","head","delete"],xt=e=>{e={options:new Zt(void 0,void 0,e.options),handlers:[...e.handlers],mutableDefaults:e.mutableDefaults},Object.defineProperty(e,"mutableDefaults",{enumerable:!0,configurable:!1,writable:!1});const t=(t,n,s=e.options)=>{const o=new kt(t,n,s);let i;const r=e=>(o.options=e,o._noPipe=!e.isStream,o.flush(),e.isStream?o:(i||(i=Jt(o)),i));let a=0;const c=t=>{const n=(e.handlers[a++]??r)(t,c);if(Y.promise(n)&&!o.options.isStream&&(i||(i=Jt(o)),n!==i)){const e=Object.getOwnPropertyDescriptors(i);for(const t in e)t in n&&delete e[t];Object.defineProperties(n,e),n.cancel=i.cancel}return n};return c(o.options)};t.extend=(...t)=>{const n=new Zt(void 0,void 0,e.options),s=[...e.handlers];let o;for(const e of t)Kt(e)?(n.merge(e.defaults.options),s.push(...e.defaults.handlers),o=e.defaults.mutableDefaults):(n.merge(e),e.handlers&&s.push(...e.handlers),o=e.mutableDefaults);return xt({options:n,handlers:s,mutableDefaults:Boolean(o)})};const n=async function*(n,s){let o=new Zt(n,s,e.options);o.resolveBodyOnly=!1;const{pagination:i}=o;k.function_(i.transform),k.function_(i.shouldContinue),k.function_(i.filter),k.function_(i.paginate),k.number(i.countLimit),k.number(i.requestLimit),k.number(i.backoff);const r=[];let{countLimit:a}=i,c=0;for(;c{const s=[];for await(const o of n(e,t))s.push(o);return s},t.paginate.each=n,t.stream=(e,n)=>t(e,{...n,isStream:!0});for(const e of Ft)t[e]=(n,s)=>t(n,{...s,method:e}),t.stream[e]=(n,s)=>t(n,{...s,method:e,isStream:!0});return e.mutableDefaults||(Object.freeze(e.handlers),e.options.freeze()),Object.defineProperty(t,"defaults",{value:e,writable:!1,configurable:!1,enumerable:!0}),t},zt=xt({options:new Zt,handlers:[],mutableDefaults:!1}),Tt=async(e,t)=>{const n=await zt.post(`${e}/v1/system/auth/login`,{https:{rejectUnauthorized:!1},json:t,timeout:{request:1e3}});return JSON.parse(n.body)};async function Et(e,...t){if(8273===(await e.bind(this)(this.config.token,...t)).code){const t=await Tt(this.config.baseURL,{username:this.config.username,password:this.config.password});0===t.code&&(this.config.token=t.data.token,await e.bind(this)(this.config.token))}}const Ut={take:function(){let e=Buffer.from(a);this.socket.send(e)},cut:function(){let e=Buffer.from(c);this.socket.send(e)},ftb:function(e){let t=i.find((t=>t.id===e.options.ftb));this.config.ftb=e.options.ftb,this.checkFeedbacks("ftb"),this.socket.send(t.cmd)},freeze:function(e){this.config.freeze=e.options.freeze,this.checkFeedbacks("freeze");let t=r.find((t=>t.id===e.options.freeze));this.socket.send(t.cmd)},presetType:function(e){this.config.presetType=e.options.presetType,this.checkFeedbacks("pgm")},preset:function(e){let t=Buffer.from(l[this.config.presetType??"pvw"]);this.socket.send(t);let n=((e,t)=>{let n=[],s=0,o=e,i=25693;for((o<1||o>240)&&(console.log("error","Invalid temp_index, value="+o+", use default value 1"),o=1);o>0;)n[s]=Math.floor(o%10)+48,i+=n[s],o=Math.floor(o/10),s+=1;let r,a,c,l=[],g=[],d=[],u=[],h=[];switch(l=Buffer.from([85,170,0,125,254,0,4,0,0,0,1,48,0,0,0,0]),g=Buffer.from([0,0,2,1,0,0,0,0,0,0,0,1,21,0,0,0,0,0,91,123,34,102,105,108,101,73,100,34,58]),d=Buffer.from([44,34,102,105,108,101,84,121,112,101,34,58,54,44,34,97,112,112,108,121,84,121,112,101,34,58]),u=Buffer.from([t]),h=Buffer.from([125,93]),s){case 1:i+=59,r=Buffer.from([59,0]),a=Buffer.from([n[0]]);break;case 2:i+=60,r=Buffer.from([60,0]),a=Buffer.from([n[1],n[0]]);break;case 3:i+=61,r=Buffer.from([61,0]),a=Buffer.from([n[2],n[1],n[0]]);break;default:console.log("error","Invalid preset buf len!")}c=Buffer.from([255&i,i>>8&255]);let I=l.length+g.length+d.length+u.length+h.length+r.length+a.length+c.length;return Buffer.concat([l,r,g,a,d,u,h,c],I)})(e.options.preset,I[this.config.presetType]??I.pvw);this.socket.send(n)}};async function Qt(e){return await zt.put(`${this.config.baseURL}/v1/screen/selected/take`,{headers:{Authorization:e},https:{rejectUnauthorized:!1},json:{direction:0,effectSelect:0,switchEffect:{time:500,type:1}}})}async function Lt(e){return await zt.put(`${this.config.baseURL}/v1/screen/selected/cut`,{headers:{Authorization:e},https:{rejectUnauthorized:!1},json:{direction:0}})}async function Ot(e,t){this.config.ftb=t.options.ftb,this.checkFeedbacks("ftb");const n={ftb:{enable:Number(t.options.ftb),time:700}};return await zt.put(`${this.config.baseURL}/v1/screen/selected/ftb`,{headers:{Authorization:e},https:{rejectUnauthorized:!1},json:n})}async function jt(e,t){this.config.freeze=t.options.freeze,this.checkFeedbacks("freeze");const n={freeze:Number(t.options.freeze)};return await zt.put(`${this.config.baseURL}/v1/screen/selected/freeze`,{headers:{Authorization:e},https:{rejectUnauthorized:!1},json:n})}async function Mt(e,t){const n={sceneType:p[this.config.presetType],id:Number(t.options.preset-1),presetId:0};return this.log("info",JSON.stringify(n)),await zt.put(`${this.config.baseURL}/v1/preset/play`,{headers:{Authorization:e},https:{rejectUnauthorized:!1},json:n})}const Pt={take:function(e){Et.bind(this)(Qt,e)},cut:function(e){Et.bind(this)(Lt,e)},ftb:function(e){Et.bind(this)(Ot,e)},freeze:function(e){Et.bind(this)(jt,e)},presetType:function(e){this.config.presetType=e.options.presetType,this.checkFeedbacks("pgm")},preset:function(e){Et.bind(this)(Mt,e)}};let Dt=128;const qt={take:{type:"button",category:"Basics",name:"TAKE",style:{text:"TAKE",size:"24",color:(0,s.combineRgb)(255,255,255),bgcolor:(0,s.combineRgb)(255,0,0)},steps:[{down:[{actionId:"take",options:{}}]}],feedbacks:[]},cut:{type:"button",category:"Basics",name:"CUT",style:{text:"CUT",size:"24",color:(0,s.combineRgb)(255,255,255),bgcolor:(0,s.combineRgb)(255,0,0)},steps:[{down:[{actionId:"cut",options:{}}]}],feedbacks:[]}},$t={ftb:{type:"button",category:"Display",name:"FTB",style:{text:"FTB",size:"18",color:(0,s.combineRgb)(255,255,255),bgcolor:(0,s.combineRgb)(0,0,0)},steps:[{down:[{actionId:"ftb",options:{ftb:"1"}}]},{down:[{actionId:"ftb",options:{ftb:"0"}}]}],feedbacks:[{feedbackId:"ftb",style:{bgcolor:(0,s.combineRgb)(255,0,0)},options:{}}]},freeze:{type:"button",category:"Display",name:"Freeze",style:{text:"Freeze",size:"18",color:(0,s.combineRgb)(255,255,255),bgcolor:(0,s.combineRgb)(0,0,0)},steps:[{down:[{actionId:"freeze",options:{freeze:"1"}}]},{down:[{actionId:"freeze",options:{freeze:"0"}}]}],feedbacks:[{feedbackId:"freeze",style:{bgcolor:(0,s.combineRgb)(255,0,0)},options:{}}]},presetType:{type:"button",category:"Display",name:"presetType",style:{text:"Load to\nPVW",size:"18",color:(0,s.combineRgb)(255,255,255),bgcolor:(0,s.combineRgb)(0,0,0)},steps:[{down:[{actionId:"presetType",options:{presetType:"pgm"}}]},{down:[{actionId:"presetType",options:{presetType:"pvw"}}]}],feedbacks:[{feedbackId:"pgm",style:{bgcolor:(0,s.combineRgb)(255,0,0),text:"Load to\nPGM"},options:{}}]}},en={"preset-play":{type:"button",category:"Presets",name:"Preset",style:{text:"Preset",size:"18",color:(0,s.combineRgb)(0,0,0),bgcolor:(0,s.combineRgb)(255,0,255)},steps:[{down:[{actionId:"preset",options:{preset:0}}]}],feedbacks:[]}},tn=async(e,t)=>{let n=t;try{await e()}catch(t){if(n-=1,!(n>0))throw Error;await tn(e,n)}},nn=["ftb","freeze","presetType"];class sn extends s.InstanceBase{constructor(e){super(e),this.PROTOCOL_TYPE=Object.values(h),this.DEVICES_INFO=function(){const e={};return b.forEach((t=>{var n;e[t]={id:t,label:(n=t,n.split(" ").map((e=>e.charAt(0).toUpperCase()+e.slice(1))).join(" ")),ftb:C.includes(t)?g:i,freeze:C.includes(t)?d:r}})),e}(),this.DEVICES=Object.values(this.DEVICES_INFO),this.DEVICES.sort((function(e,t){var n=e.label.toLowerCase(),s=t.label.toLowerCase();return ns?1:0}))}updateActions(){this.log("debug","update actions...."),this.setActionDefinitions((e=>{const t=e.config.modelId,n=C.includes(t),s=n?Pt:Ut;let o={};return o.take={name:"TAKE",options:[],callback:async t=>{try{s.take.bind(e)(t)}catch(t){e.log("error","take send error")}}},o.cut={name:"CUT",options:[],callback:async t=>{try{s.cut.bind(e)(t)}catch(t){e.log("error","cut send error")}}},o.ftb={name:"Make the screen fade to black or return to normal",options:[{type:"dropdown",name:"FTB",id:"ftb",default:"1",choices:n?g:i}],callback:async t=>{try{s.ftb.bind(e)(t)}catch(t){e.log("error","FTB send error")}}},o.freeze={name:"Freeze/Unfreeze the screen",options:[{type:"dropdown",name:"FRZ",id:"freeze",default:"1",choices:n?d:r}],callback:async t=>{try{s.freeze.bind(e)(t)}catch(t){e.log("error","FTB send error")}}},o.presetType={name:"Choose a destination to load the preset",options:[{type:"dropdown",name:"PVW/PGM",id:"presetType",default:"pvw",choices:u}],callback:async t=>{try{s.presetType.bind(e)(t)}catch(t){e.log("error","presetType set error")}}},o.preset={name:"Select a preset to load",options:[{type:"dropdown",name:"Preset",id:"preset",default:1,choices:[...Array(parseInt(y[e.config.modelId])??128)].map(((e,t)=>({id:t+1,label:`Preset ${t+1}`})))}],callback:async t=>{try{s.preset.bind(e)(t)}catch(t){e.log("error","load_preset send error")}}},o})(this))}updateFeedbacks(){this.setFeedbackDefinitions((e=>{let t={};return t.ftb={type:"boolean",name:"FTB Status Detection",description:"Change the style when FTB is pressed.",defaultStyle:{bgcolor:(0,s.combineRgb)(255,0,0)},options:[],callback:()=>"1"===e.config.ftb},t.freeze={type:"boolean",name:"Freeze Status Detection",description:"Change the style when Freeze is pressed.",defaultStyle:{bgcolor:(0,s.combineRgb)(255,0,0)},options:[],callback:()=>"1"===e.config.freeze},t.pgm={type:"boolean",name:"PGM Status Detection",description:"Change the style when Load preset to PGM.",defaultStyle:{bgcolor:(0,s.combineRgb)(255,0,0),text:"Load to\nPGM"},options:[],callback:()=>"pgm"===e.config.presetType},t})(this))}getConfigFields(){return this.log("getting the fields...."),[{type:"static-text",id:"info",width:12,label:"Information",value:"This module will allow you to control the following Nuowaxingyun products: N10, N20, D12 and D32."},{type:"textinput",id:"host",label:"IP Address",width:6,default:"192.168.0.10",regex:s.Regex.IP},{type:"dropdown",id:"modelId",label:"Model",width:6,choices:this.DEVICES,default:this.DEVICES[0].id},{type:"textinput",id:"username",label:"Username",width:6,default:"",isVisibleData:C,isVisible:(e,t)=>t.includes(e.modelId)},{type:"textinput",id:"password",label:"Password",width:6,default:"",isVisibleData:C,isVisible:(e,t)=>t.includes(e.modelId)}]}async destroy(){this.log("info","destroy:"+this.id),void 0!==this.socket&&this.socket.destroy(),void 0!==this.udp&&this.udp.destroy(),this.heartbeat&&(clearInterval(this.heartbeat),delete this.heartbeat)}async getDeviceStatus(){this.config.baseURL=`${this.config.protocol}://${this.config.host}:${this.config.port}/unico`,this.log("info",`tokenUrl:${this.config.baseURL}`),this.log("info",`tokenInfo:${this.config.username}/${this.config.password}`);const e=await Tt(this.config.baseURL,{username:this.config.username,password:this.config.password});this.log("info","tokenRes:"),this.log("info",JSON.stringify(e)),0===e.code?(this.config.token=e.data.token,this.updateStatus(s.InstanceStatus.Ok)):8274===e.code?this.updateStatus(s.InstanceStatus.BadConfig):this.updateStatus(s.InstanceStatus.ConnectionFailure)}async getProtocol(){this.log("info","getProtocol"),this.config.port=8088;try{try{this.config.protocol="http",await tn(this.getDeviceStatus.bind(this),3)}catch(e){this.config.protocol="https",await tn(this.getDeviceStatus.bind(this),3)}}catch(e){this.log("info",`getProtocol-${this.config.protocol}-cache-${e.code}`),this.updateStatus(s.InstanceStatus.ConnectionFailure)}}updateDeviceStatus(e){this.log("debug","ping test:"+e+", lastState:"+this.lastState),1==e?(this.log("debug","ping check ok."),0!==this.lastState&&(this.log("info","connection recover, try to reconnect device."),this.updateStatus(s.InstanceStatus.Connecting),this.initUDP(),this.initTCP(),this.lastState=0)):0==e&&0===this.lastState&&(this.updateStatus(s.InstanceStatus.ConnectionFailure),this.log("info","ping check failure."),this.lastState=1)}pingTest(){o.sys.probe(this.config.host,(e=>this.updateDeviceStatus(e)),{timeout:1})}initTCP(){void 0!==this.socket&&(this.socket.destroy(),delete this.socket),this.config.port=5400,this.config.host?(this.socket=new s.TCPHelper(this.config.host,this.config.port),this.socket.on("status_change",((e,t)=>{this.updateStatus(e,t)})),this.socket.on("error",(e=>{if(this.updateStatus(s.InstanceStatus.ConnectionFailure),this.log("error","Network error: "+e.message),console.log("TCP Connection error, Try to reconnect."),this.updateStatus(s.InstanceStatus.Connecting),void 0!==this.udp){let e=Buffer.from([114,101,113,78,79,86,65,83,84,65,82,95,76,73,78,75,58,0,0,3,254,255]);this.udp.send(e)}else this.initUDP()})),this.socket.on("connect",(()=>{let e=Buffer.from([85,170,0,0,254,0,0,0,0,0,0,0,2,0,0,0,2,0,87,86]);this.socket.send(e),this.log("debug","Connected"),this.updateStatus(s.InstanceStatus.Ok)})),this.socket.on("data",(e=>{}))):(this.log("error","No host configured"),this.updateStatus(s.InstanceStatus.BadConfig))}initUDP(){if(void 0!==this.udp&&(this.udp.destroy(),delete this.udp),void 0!==this.config.host?(this.udp=new s.UDPHelper(this.config.host,3800),this.udp.on("error",(e=>{this.debug("Network error",e),this.log("error","Network error: "+e.message),this.updateStatus(s.InstanceStatus.ConnectionFailure)})),this.udp.on("data",(()=>{})),this.udp.on("status_change",((e,t)=>{this.log("debug","UDP status_change: "+e)})),this.log("debug","initUDP finish")):(this.log("error","No host configured"),this.updateStatus(s.InstanceStatus.BadConfig)),void 0!==this.udp){let e=Buffer.from([114,101,113,78,79,86,65,83,84,65,82,95,76,73,78,75,58,0,0,3,254,255]);this.udp.send(e),this.log("info","UDP registration.")}}updateDefaultInfo(){nn.map((e=>{delete this.config[e]})),this.updateActions(),this.updateFeedbacks(),this.setPresetDefinitions(function(e){e.log("info","preset-instance-config:"),e.log("info",JSON.stringify(e.config)),Dt=parseInt(y[e.config.modelId])??128;const t=(e=>{const t={};for(let n=1;n<=e;n++){const e={type:"button",category:"Presets",name:"Preset "+n,style:{text:"Preset \n"+n,size:"18",color:(0,s.combineRgb)(0,0,0),bgcolor:(0,s.combineRgb)(0,255,0)},steps:[{down:[{actionId:"preset",options:{preset:n}}]}],feedbacks:[]};t["preset-play"+n]=e}return t})(Dt);return{...qt,...$t,...en,...t}}(this))}async configUpdated(e){this.log("info","configUpdated modules...");let t=!1;if(this.config.host===e.host&&this.config.port===e.port&&this.config.modelId===e.modelId||(t=!0),delete this.config.token,this.config={...this.config,...e,model:this.DEVICES_INFO[e.modelId]},C.includes(this.config.modelId))void 0!==this.socket&&this.socket.destroy(),this.heartbeat&&(clearInterval(this.heartbeat),delete this.heartbeat),await this.getProtocol(),this.updateDefaultInfo.bind(this)();else{if(!0!==t&&void 0!==this.socket)return;this.heartbeat&&(clearInterval(this.heartbeat),delete this.heartbeat),this.initUDP(),this.initTCP(),this.heartbeat=setInterval((()=>this.pingTest()),1e4),this.updateDefaultInfo.bind(this)()}}async init(e){this.config=Object.assign({},e),void 0!==this.config.modelId?this.config.model=this.DEVICES_INFO[this.config.modelId]:(this.config.modelId=this.DEVICES[0].id,this.config.model=this.DEVICES[0]),m.includes(this.config.modelId)?(this.initUDP(),this.initTCP(),this.heartbeat=setInterval((()=>this.pingTest()),1e4)):C.includes(this.config.modelId)&&await this.getProtocol(),this.updateDefaultInfo.bind(this)()}}(0,s.runEntrypoint)(sn,[function(e,t){let n={updatedConfig:null,updatedActions:[],updatedFeedbacks:[]};t.config&&(n.updatedConfig=t.config,t.config.modelID&&!t.config.modelId&&(n.updatedConfig.modelId=t.config.modelID),t.config.presetType||(n.updatedConfig.presetType="pvw"));for(const e of t.actions)switch(e.actionId){case"change_black":e.actionId="ftb",e.options={ftb:"1"},n.updatedActions.push(e);break;case"change_freeze":e.actionId="freeze",e.options={freeze:"1"},n.updatedActions.push(e);break;case"load_preset":e.actionId="preset",e.options={preset:"1"},n.updatedActions.push(e)}return n}])}},t={};function n(s){var o=t[s];if(void 0!==o)return o.exports;var i=t[s]={id:s,loaded:!1,exports:{}};return e[s].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}n.c=t,n.d=(e,t)=>{for(var s in t)n.o(t,s)&&!n.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},n.hmd=e=>((e=Object.create(e)).children||(e.children=[]),Object.defineProperty(e,"exports",{enumerable:!0,set:()=>{throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+e.id)}}),e),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n(n.s=8106)})(); \ No newline at end of file +/*! For license information please see main.js.LICENSE.txt */ +(()=>{var e={7169:(e,t,n)=>{"use strict";const s=n(2017);s.code='require("ajv/dist/runtime/equal").default',t.A=s},2719:(e,t,n)=>{"use strict";n.d(t,{T:()=>s});const s="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__},2581:(e,t,n)=>{"use strict";n.d(t,{l:()=>r});var s=n(6641),o=n(8444),i=n(258);function r(){(0,o.U)(),(0,i.wD)()&&function(){const t=(0,s.EU)();if(!t.__SENTRY__)return;const n={mongodb:()=>new((0,i.fj)(e,"./node/integrations/mongo").Mongo),mongoose:()=>new((0,i.fj)(e,"./node/integrations/mongo").Mongo),mysql:()=>new((0,i.fj)(e,"./node/integrations/mysql").Mysql),pg:()=>new((0,i.fj)(e,"./node/integrations/postgres").Postgres)},o=Object.keys(n).filter((e=>!!(0,i.Vw)(e))).map((e=>{try{return n[e]()}catch(e){return}})).filter((e=>e));o.length>0&&(t.__SENTRY__.integrations=[...t.__SENTRY__.integrations||[],...o])}()}e=n.hmd(e)},2543:(e,t,n)=>{"use strict";n.d(t,{I:()=>d});var s=n(853),o=n(258),i=n(7412),r=n(8411),a=n(6936),c=n(3816),l=n(2719),g=n(6354);class d{static __initStatic(){this.id="Apollo"}constructor(e={useNestjs:!1}){this.name=d.id,this._useNest=!!e.useNestjs}loadDependency(){return this._useNest?this._module=this._module||(0,o.Vw)("@nestjs/graphql"):this._module=this._module||(0,o.Vw)("apollo-server-core"),this._module}setupOnce(e,t){if((0,g.H)(t))l.T&&i.vF.log("Apollo Integration is skipped because of instrumenter configuration.");else if(this._useNest){const e=this.loadDependency();if(!e)return void(l.T&&i.vF.error("Apollo-NestJS Integration was unable to require @nestjs/graphql package."));(0,r.GS)(e.GraphQLFactory.prototype,"mergeWithSchema",(function(e){return function(...n){return(0,r.GS)(this.resolversExplorerService,"explore",(function(e){return function(){return u((0,a.k9)(e.call(this)),t)}})),e.call(this,...n)}}))}else{const e=this.loadDependency();if(!e)return void(l.T&&i.vF.error("Apollo Integration was unable to require apollo-server-core package."));(0,r.GS)(e.ApolloServerBase.prototype,"constructSchema",(function(e){return function(){if(!this.config.resolvers)return l.T&&(this.config.schema?(i.vF.warn("Apollo integration is not able to trace `ApolloServer` instances constructed via `schema` property.If you are using NestJS with Apollo, please use `Sentry.Integrations.Apollo({ useNestjs: true })` instead."),i.vF.warn()):this.config.modules&&i.vF.warn("Apollo integration is not able to trace `ApolloServer` instances constructed via `modules` property."),i.vF.error("Skipping tracing as no resolvers found on the `ApolloServer` instance.")),e.call(this);const n=(0,a.k9)(this.config.resolvers);return this.config.resolvers=u(n,t),e.call(this)}}))}}}function u(e,t){return e.map((e=>(Object.keys(e).forEach((n=>{Object.keys(e[n]).forEach((o=>{"function"==typeof e[n][o]&&function(e,t,n,o){(0,r.GS)(e[t],n,(function(e){return function(...i){const r=o().getScope().getSpan(),a=(0,s.z)([r,"optionalAccess",e=>e.startChild,"call",e=>e({description:`${t}.${n}`,op:"graphql.resolve",origin:"auto.graphql.apollo"})]),l=e.call(this,...i);return(0,c.Qg)(l)?l.then((e=>((0,s.z)([a,"optionalAccess",e=>e.end,"call",e=>e()]),e))):((0,s.z)([a,"optionalAccess",e=>e.end,"call",e=>e()]),l)}}))}(e,n,o,t)}))})),e)))}d.__initStatic()},5838:(e,t,n)=>{"use strict";n.d(t,{JF:()=>d});var s=n(853),o=n(7412),i=n(2879),r=n(1040),a=n(3816),c=n(6341),l=n(2719),g=n(6354);class d{static __initStatic(){this.id="Express"}constructor(e={}){this.name=d.id,this._router=e.router||e.app,this._methods=(Array.isArray(e.methods)?e.methods:[]).concat("use")}setupOnce(e,t){this._router?(0,g.H)(t)?l.T&&o.vF.log("Express Integration is skipped because of instrumenter configuration."):(function(e,t=[]){t.forEach((t=>function(e,t){const n=e[t];return e[t]=function(...e){return n.call(this,...function(e,t){return e.map((e=>"function"==typeof e?u(e,t):Array.isArray(e)?e.map((e=>"function"==typeof e?u(e,t):e)):e))}(e,t))},e}(e,t)))}(this._router,this._methods),function(e){const t="settings"in e;t&&void 0===e._router&&e.lazyrouter&&e.lazyrouter();const n=t?e._router:e;if(!n)return l.T&&o.vF.debug("Cannot instrument router for URL Parameterization (did not find a valid router)."),void(l.T&&o.vF.debug("Routing instrumentation is currently only supported in Express 4."));const g=Object.getPrototypeOf(n),d=g.process_params;g.process_params=function(e,t,n,o,l){n._reconstructedRoute||(n._reconstructedRoute="");const{layerRoutePath:g,isRegex:u,isArray:p,numExtraSegments:I}=function(e){let t=(0,s.z)([e,"access",e=>e.route,"optionalAccess",e=>e.path]);const n=(0,a.gd)(t),o=Array.isArray(t);if(!t){const[n]=c.OW.process.versions.node.split(".").map(Number);n>=16&&(t=h(e.path,e.regexp,e.keys))}if(!t)return{isRegex:n,isArray:o,numExtraSegments:0};const r=o?Math.max(t.reduce(((e,t)=>e+(0,i.c4)(t.toString())),0)-(0,i.c4)(e.path||""),0):0,l=function(e,t){return e?t.map((e=>e.toString())).join(","):t&&t.toString()}(o,t);return{layerRoutePath:l,isRegex:n,isArray:o,numExtraSegments:r}}(e);let m;(g||u||p)&&(n._hasParameters=!0),m=g||function(e,t,n){const o=(0,i.f)(e||""),r=(0,s.z)([o,"optionalAccess",e=>e.split,"call",e=>e("/"),"access",e=>e.filter,"call",e=>e((e=>!!e))]);let a=0;const c=(0,s.z)([t,"optionalAccess",e=>e.split,"call",e=>e("/"),"access",e=>e.filter,"call",e=>e((e=>!!e)),"access",e=>e.length])||0;return(0,s.z)([n,"optionalAccess",e=>e.split,"call",e=>e("/"),"access",e=>e.filter,"call",e=>e((e=>(0,s.z)([r,"optionalAccess",e=>e[c+a]])===e&&(a+=1,!0))),"access",e=>e.join,"call",e=>e("/")])}(n.originalUrl,n._reconstructedRoute,e.path)||"";const C=m.split("/").filter((e=>e.length>0&&(u||p||!e.includes("*")))).join("/");if(C&&C.length>0&&(n._reconstructedRoute+=`/${C}${u?"/":""}`),(0,i.c4)((0,i.f)(n.originalUrl||""))+I===(0,i.c4)(n._reconstructedRoute)){n._hasParameters||n._reconstructedRoute!==n.originalUrl&&(n._reconstructedRoute=n.originalUrl?(0,i.f)(n.originalUrl):n.originalUrl);const e=o.__sentry_transaction;if(e&&"custom"!==e.metadata.source){const t=n._reconstructedRoute||"/";e.setName(...(0,r.Up)(n,{path:!0,method:!0,customRoute:t}))}}return d.call(this,e,t,n,o,l)}}(this._router)):l.T&&o.vF.error("ExpressIntegration is missing an Express instance")}}function u(e,t){const n=e.length;switch(n){case 2:return function(n,s){const o=s.__sentry_transaction;if(o){const n=o.startChild({description:e.name,op:`middleware.express.${t}`,origin:"auto.middleware.express"});s.once("finish",(()=>{n.end()}))}return e.call(this,n,s)};case 3:return function(n,o,i){const r=o.__sentry_transaction,a=(0,s.z)([r,"optionalAccess",e=>e.startChild,"call",n=>n({description:e.name,op:`middleware.express.${t}`,origin:"auto.middleware.express"})]);e.call(this,n,o,(function(...e){(0,s.z)([a,"optionalAccess",e=>e.end,"call",e=>e()]),i.call(this,...e)}))};case 4:return function(n,o,i,r){const a=i.__sentry_transaction,c=(0,s.z)([a,"optionalAccess",e=>e.startChild,"call",n=>n({description:e.name,op:`middleware.express.${t}`,origin:"auto.middleware.express"})]);e.call(this,n,o,i,(function(...e){(0,s.z)([c,"optionalAccess",e=>e.end,"call",e=>e()]),r.call(this,...e)}))};default:throw new Error(`Express middleware takes 2-4 arguments. Got: ${n}`)}}d.__initStatic();const h=(e,t,n)=>{if(!(e&&t&&n&&0!==Object.keys(n).length&&(0,s.z)([n,"access",e=>e[0],"optionalAccess",e=>e.offset])))return;const o=n.sort(((e,t)=>e.offset-t.offset)),i=new RegExp(t,`${t.flags}d`).exec(e);if(!i||!i.indices)return;const[,...r]=i.indices;if(r.length!==o.length)return;let a=e,c=0;return r.forEach(((e,t)=>{if(e){const[n,s]=e,i=a.substring(0,n-c),r=`:${o[t].name}`,l=a.substring(s-c);a=i+r+l,c+=s-n-r.length}})),a}},875:(e,t,n)=>{"use strict";n.d(t,{c:()=>g});var s=n(853),o=n(258),i=n(7412),r=n(8411),a=n(3816),c=n(2719),l=n(6354);class g{static __initStatic(){this.id="GraphQL"}constructor(){this.name=g.id}loadDependency(){return this._module=this._module||(0,o.Vw)("graphql/execution/execute.js")}setupOnce(e,t){if((0,l.H)(t))return void(c.T&&i.vF.log("GraphQL Integration is skipped because of instrumenter configuration."));const n=this.loadDependency();n?(0,r.GS)(n,"execute",(function(e){return function(...n){const o=t().getScope(),i=o.getSpan(),r=(0,s.z)([i,"optionalAccess",e=>e.startChild,"call",e=>e({description:"execute",op:"graphql.execute",origin:"auto.graphql.graphql"})]);(0,s.z)([o,"optionalAccess",e=>e.setSpan,"call",e=>e(r)]);const c=e.call(this,...n);return(0,a.Qg)(c)?c.then((e=>((0,s.z)([r,"optionalAccess",e=>e.end,"call",e=>e()]),(0,s.z)([o,"optionalAccess",e=>e.setSpan,"call",e=>e(i)]),e))):((0,s.z)([r,"optionalAccess",e=>e.end,"call",e=>e()]),(0,s.z)([o,"optionalAccess",e=>e.setSpan,"call",e=>e(i)]),c)}})):c.T&&i.vF.error("GraphQL Integration was unable to require graphql/execution package.")}}g.__initStatic()},8402:(e,t,n)=>{"use strict";n.d(t,{j:()=>o});var s=n(258);e=n.hmd(e);const o=[()=>new((0,s.fj)(e,"./apollo").Apollo),()=>new((0,s.fj)(e,"./apollo").Apollo)({useNestjs:!0}),()=>new((0,s.fj)(e,"./graphql").GraphQL),()=>new((0,s.fj)(e,"./mongo").Mongo),()=>new((0,s.fj)(e,"./mongo").Mongo)({mongoose:!0}),()=>new((0,s.fj)(e,"./mysql").Mysql),()=>new((0,s.fj)(e,"./postgres").Postgres)]},3114:(e,t,n)=>{"use strict";n.d(t,{N:()=>u});var s=n(853),o=n(258),i=n(7412),r=n(8411),a=n(3816),c=n(2719),l=n(6354);const g=["aggregate","bulkWrite","countDocuments","createIndex","createIndexes","deleteMany","deleteOne","distinct","drop","dropIndex","dropIndexes","estimatedDocumentCount","find","findOne","findOneAndDelete","findOneAndReplace","findOneAndUpdate","indexes","indexExists","indexInformation","initializeOrderedBulkOp","insertMany","insertOne","isCapped","mapReduce","options","parallelCollectionScan","rename","replaceOne","stats","updateMany","updateOne"],d={bulkWrite:["operations"],countDocuments:["query"],createIndex:["fieldOrSpec"],createIndexes:["indexSpecs"],deleteMany:["filter"],deleteOne:["filter"],distinct:["key","query"],dropIndex:["indexName"],find:["query"],findOne:["query"],findOneAndDelete:["filter"],findOneAndReplace:["filter","replacement"],findOneAndUpdate:["filter","update"],indexExists:["indexes"],insertMany:["docs"],insertOne:["doc"],mapReduce:["map","reduce"],rename:["newName"],replaceOne:["filter","doc"],updateMany:["filter","update"],updateOne:["filter","update"]};class u{static __initStatic(){this.id="Mongo"}constructor(e={}){this.name=u.id,this._operations=Array.isArray(e.operations)?e.operations:g,this._describeOperations=!("describeOperations"in e)||e.describeOperations,this._useMongoose=!!e.useMongoose}loadDependency(){const e=this._useMongoose?"mongoose":"mongodb";return this._module=this._module||(0,o.Vw)(e)}setupOnce(e,t){if((0,l.H)(t))return void(c.T&&i.vF.log("Mongo Integration is skipped because of instrumenter configuration."));const n=this.loadDependency();if(n)this._instrumentOperations(n.Collection,this._operations,t);else{const e=this._useMongoose?"mongoose":"mongodb";c.T&&i.vF.error(`Mongo Integration was unable to require \`${e}\` package.`)}}_instrumentOperations(e,t,n){t.forEach((t=>this._patchOperation(e,t,n)))}_patchOperation(e,t,n){if(!(t in e.prototype))return;const o=this._getSpanContextFromOperationArguments.bind(this);(0,r.GS)(e.prototype,t,(function(e){return function(...i){const r=i[i.length-1],c=n().getScope().getSpan();if("function"!=typeof r||"mapReduce"===t&&2===i.length){const n=(0,s.z)([c,"optionalAccess",e=>e.startChild,"call",e=>e(o(this,t,i))]),r=e.call(this,...i);if((0,a.Qg)(r))return r.then((e=>((0,s.z)([n,"optionalAccess",e=>e.end,"call",e=>e()]),e)));if((l=r)&&"object"==typeof l&&l.once&&"function"==typeof l.once){const e=r;try{e.once("close",(()=>{(0,s.z)([n,"optionalAccess",e=>e.end,"call",e=>e()])}))}catch(e){(0,s.z)([n,"optionalAccess",e=>e.end,"call",e=>e()])}return e}return(0,s.z)([n,"optionalAccess",e=>e.end,"call",e=>e()]),r}var l;const g=(0,s.z)([c,"optionalAccess",e=>e.startChild,"call",e=>e(o(this,t,i.slice(0,-1)))]);return e.call(this,...i.slice(0,-1),(function(e,t){(0,s.z)([g,"optionalAccess",e=>e.end,"call",e=>e()]),r(e,t)}))}}))}_getSpanContextFromOperationArguments(e,t,n){const s={"db.system":"mongodb","db.name":e.dbName,"db.operation":t,"db.mongodb.collection":e.collectionName},o={op:"db",origin:"auto.db.mongo",description:t,data:s},i=d[t],r=Array.isArray(this._describeOperations)?this._describeOperations.includes(t):this._describeOperations;if(!i||!r)return o;try{if("mapReduce"===t){const[e,t]=n;s[i[0]]="string"==typeof e?e:e.name||"",s[i[1]]="string"==typeof t?t:t.name||""}else for(let e=0;e{"use strict";n.d(t,{d:()=>l});var s=n(853),o=n(258),i=n(7412),r=n(8411),a=n(2719),c=n(6354);class l{static __initStatic(){this.id="Mysql"}constructor(){this.name=l.id}loadDependency(){return this._module=this._module||(0,o.Vw)("mysql/lib/Connection.js")}setupOnce(e,t){if((0,c.H)(t))return void(a.T&&i.vF.log("Mysql Integration is skipped because of instrumenter configuration."));const n=this.loadDependency();if(!n)return void(a.T&&i.vF.error("Mysql Integration was unable to require `mysql` package."));let o;try{n.prototype.connect=new Proxy(n.prototype.connect,{apply:(e,t,n)=>(o||(o=t.config),e.apply(t,n))})}catch(e){a.T&&i.vF.error("Mysql Integration was unable to instrument `mysql` config.")}function l(e){if(!e||e.endTimestamp)return;const t=o?{"server.address":o.host,"server.port":o.port,"db.user":o.user}:{};Object.keys(t).forEach((n=>{e.setData(n,t[n])})),e.end()}(0,r.GS)(n,"createQuery",(function(e){return function(n,o,i){const r=t().getScope().getSpan(),a=(0,s.z)([r,"optionalAccess",e=>e.startChild,"call",e=>e({description:"string"==typeof n?n:n.sql,op:"db",origin:"auto.db.mysql",data:{"db.system":"mysql"}})]);if("function"==typeof i)return e.call(this,n,o,(function(e,t,n){l(a),i(e,t,n)}));if("function"==typeof o)return e.call(this,n,(function(e,t,n){l(a),o(e,t,n)}));const c=e.call(this,n,o);return c.on("end",(()=>{l(a)})),c}}))}}l.__initStatic()},5455:(e,t,n)=>{"use strict";n.d(t,{E:()=>g});var s=n(853),o=n(258),i=n(7412),r=n(8411),a=n(3816),c=n(2719),l=n(6354);class g{static __initStatic(){this.id="Postgres"}constructor(e={}){this.name=g.id,this._usePgNative=!!e.usePgNative,this._module=e.module}loadDependency(){return this._module=this._module||(0,o.Vw)("pg")}setupOnce(e,t){if((0,l.H)(t))return void(c.T&&i.vF.log("Postgres Integration is skipped because of instrumenter configuration."));const n=this.loadDependency();if(!n)return void(c.T&&i.vF.error("Postgres Integration was unable to require `pg` package."));const o=this._usePgNative?(0,s.z)([n,"access",e=>e.native,"optionalAccess",e=>e.Client]):n.Client;o?(0,r.GS)(o.prototype,"query",(function(e){return function(n,o,i){const r=t().getScope().getSpan(),c={"db.system":"postgresql"};try{this.database&&(c["db.name"]=this.database),this.host&&(c["server.address"]=this.host),this.port&&(c["server.port"]=this.port),this.user&&(c["db.user"]=this.user)}catch(e){}const l=(0,s.z)([r,"optionalAccess",e=>e.startChild,"call",e=>e({description:"string"==typeof n?n:n.text,op:"db",origin:"auto.db.postgres",data:c})]);if("function"==typeof i)return e.call(this,n,o,(function(e,t){(0,s.z)([l,"optionalAccess",e=>e.end,"call",e=>e()]),i(e,t)}));if("function"==typeof o)return e.call(this,n,(function(e,t){(0,s.z)([l,"optionalAccess",e=>e.end,"call",e=>e()]),o(e,t)}));const g=void 0!==o?e.call(this,n,o):e.call(this,n);return(0,a.Qg)(g)?g.then((e=>((0,s.z)([l,"optionalAccess",e=>e.end,"call",e=>e()]),e))):((0,s.z)([l,"optionalAccess",e=>e.end,"call",e=>e()]),g)}})):c.T&&i.vF.error("Postgres Integration was unable to access 'pg-native' bindings.")}}g.__initStatic()},9932:(e,t,n)=>{"use strict";n.d(t,{D:()=>l});var s=n(6641),o=n(6954),i=n(8411),r=n(7412),a=n(2719),c=n(6354);class l{static __initStatic(){this.id="Prisma"}constructor(e={}){if(this.name=l.id,(t=e.client)&&t.$use&&!e.client._sentryInstrumented){(0,i.my)(e.client,"_sentryInstrumented",!0);const t={};try{const n=e.client._engineConfig;if(n){const{activeProvider:e,clientVersion:s}=n;e&&(t["db.system"]=e),s&&(t["db.prisma.version"]=s)}}catch(e){}e.client.$use(((e,n)=>{if((0,c.H)(s.BF))return n(e);const i=e.action,r=e.model;return(0,o.uP)({name:r?`${r} ${i}`:i,op:"db.prisma",origin:"auto.db.prisma",data:{...t,"db.operation":i}},(()=>n(e)))}))}else a.T&&r.vF.warn("Unsupported Prisma client provided to PrismaIntegration. Provided client:",e.client);var t}setupOnce(){}}l.__initStatic()},6354:(e,t,n)=>{"use strict";n.d(t,{H:()=>o});var s=n(853);function o(e){const t=(0,s.z)([e,"call",e=>e(),"access",e=>e.getClient,"call",e=>e(),"optionalAccess",e=>e.getOptions,"call",e=>e()]);return"sentry"!==((0,s.z)([t,"optionalAccess",e=>e.instrumenter])||"sentry")}},2967:(e,t,n)=>{"use strict";n.d(t,{U:()=>s});const s="production"},2220:(e,t,n)=>{"use strict";n.d(t,{T:()=>s});const s="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__},2531:(e,t,n)=>{"use strict";n.d(t,{jB:()=>g,lG:()=>c,lb:()=>l});var s=n(6341),o=n(690),i=n(7412),r=n(3816),a=n(2220);function c(){return(0,s.BY)("globalEventProcessors",(()=>[]))}function l(e){c().push(e)}function g(e,t,n,s=0){return new o.T2(((o,c)=>{const l=e[s];if(null===t||"function"!=typeof l)o(t);else{const d=l({...t},n);a.T&&l.id&&null===d&&i.vF.log(`Event processor "${l.id}" dropped event`),(0,r.Qg)(d)?d.then((t=>g(e,t,n,s+1).then(o))).then(null,c):g(e,d,n,s+1).then(o).then(null,c)}}))}},3741:(e,t,n)=>{"use strict";n.d(t,{Cp:()=>g,KU:()=>V,NA:()=>y,PN:()=>h,Q:()=>S,SE:()=>G,T$:()=>v,VN:()=>W,Wt:()=>b,ZQ:()=>p,bX:()=>B,cx:()=>m,gV:()=>f,l7:()=>C,nb:()=>Z,o:()=>I,o5:()=>w,r:()=>u,v4:()=>A,wd:()=>d});var s=n(7412),o=n(6936),i=n(9297),r=n(3816),a=n(2220),c=n(6641),l=n(9475);function g(e,t){return(0,c.BF)().captureException(e,(0,l.li)(t))}function d(e,t){const n="string"==typeof t?t:void 0,s="string"!=typeof t?{captureContext:t}:void 0;return(0,c.BF)().captureMessage(e,n,s)}function u(e,t){return(0,c.BF)().captureEvent(e,t)}function h(e){(0,c.BF)().configureScope(e)}function p(e,t){(0,c.BF)().addBreadcrumb(e,t)}function I(e,t){(0,c.BF)().setContext(e,t)}function m(e){(0,c.BF)().setExtras(e)}function C(e,t){(0,c.BF)().setExtra(e,t)}function b(e){(0,c.BF)().setTags(e)}function y(e,t){(0,c.BF)().setTag(e,t)}function f(e){(0,c.BF)().setUser(e)}function A(e){return(0,c.BF)().withScope(e)}function Z(e,t){return(0,c.BF)().startTransaction({...e},t)}function G(e,t){const n=w(),i=V();if(i){if(i.captureCheckIn)return i.captureCheckIn(e,t,n);a.T&&s.vF.warn("Cannot capture check-in. Client does not support sending check-ins.")}else a.T&&s.vF.warn("Cannot capture check-in. No client defined.");return(0,o.eJ)()}function v(e,t,n){const s=G({monitorSlug:e,status:"in_progress"},n),o=(0,i.zf)();function a(t){G({monitorSlug:e,status:t,checkInId:s,duration:(0,i.zf)()-o})}let c;try{c=t()}catch(e){throw a("error"),e}return(0,r.Qg)(c)?Promise.resolve(c).then((()=>{a("ok")}),(()=>{a("error")})):a("ok"),c}async function B(e){const t=V();return t?t.flush(e):(a.T&&s.vF.warn("Cannot flush events. No client defined."),Promise.resolve(!1))}async function W(e){const t=V();return t?t.close(e):(a.T&&s.vF.warn("Cannot flush events and disable SDK. No client defined."),Promise.resolve(!1))}function S(){return(0,c.BF)().lastEventId()}function V(){return(0,c.BF)().getClient()}function w(){return(0,c.BF)().getScope()}},6641:(e,t,n)=>{"use strict";n.d(t,{BF:()=>C,EU:()=>I,Me:()=>v,TF:()=>f,YZ:()=>p,fx:()=>Z,gM:()=>m,lq:()=>B,nX:()=>A,rm:()=>b});var s=n(6936),o=n(9297),i=n(7412),r=n(6341),a=n(2967),c=n(2220),l=n(2486),g=n(7058),d=n(7986);const u=parseFloat(d.M),h=100;class p{constructor(e,t=new l.HG,n=new l.HG,s=u){this._version=s,this._stack=[{scope:t}],e&&this.bindClient(e),this._isolationScope=n}isOlderThan(e){return this._version{s.captureException(e,{originalException:e,syntheticException:o,...t,event_id:n},i)})),n}captureMessage(e,t,n){const o=this._lastEventId=n&&n.event_id?n.event_id:(0,s.eJ)(),i=new Error(e);return this._withClient(((s,r)=>{s.captureMessage(e,t,{originalException:e,syntheticException:i,...n,event_id:o},r)})),o}captureEvent(e,t){const n=t&&t.event_id?t.event_id:(0,s.eJ)();return e.type||(this._lastEventId=n),this._withClient(((s,o)=>{s.captureEvent(e,{...t,event_id:n},o)})),n}lastEventId(){return this._lastEventId}addBreadcrumb(e,t){const{scope:n,client:s}=this.getStackTop();if(!s)return;const{beforeBreadcrumb:r=null,maxBreadcrumbs:a=h}=s.getOptions&&s.getOptions()||{};if(a<=0)return;const c={timestamp:(0,o.lu)(),...e},l=r?(0,i.pq)((()=>r(c,t))):c;null!==l&&(s.emit&&s.emit("beforeAddBreadcrumb",l,t),n.addBreadcrumb(l,a))}setUser(e){this.getScope().setUser(e)}setTags(e){this.getScope().setTags(e)}setExtras(e){this.getScope().setExtras(e)}setTag(e,t){this.getScope().setTag(e,t)}setExtra(e,t){this.getScope().setExtra(e,t)}setContext(e,t){this.getScope().setContext(e,t)}configureScope(e){const{scope:t,client:n}=this.getStackTop();n&&e(t)}run(e){const t=m(this);try{e(this)}finally{m(t)}}getIntegration(e){const t=this.getClient();if(!t)return null;try{return t.getIntegration(e)}catch(t){return c.T&&i.vF.warn(`Cannot retrieve integration ${e.id} from the current Hub`),null}}startTransaction(e,t){const n=this._callExtensionMethod("startTransaction",e,t);return c.T&&!n&&(this.getClient()?i.vF.warn("Tracing extension 'startTransaction' has not been added. Call 'addTracingExtensions' before calling 'init':\nSentry.addTracingExtensions();\nSentry.init({...});\n"):i.vF.warn("Tracing extension 'startTransaction' is missing. You should 'init' the SDK before calling 'startTransaction'")),n}traceHeaders(){return this._callExtensionMethod("traceHeaders")}captureSession(e=!1){if(e)return this.endSession();this._sendSessionUpdate()}endSession(){const e=this.getStackTop().scope,t=e.getSession();t&&(0,g.Vu)(t),this._sendSessionUpdate(),e.setSession()}startSession(e){const{scope:t,client:n}=this.getStackTop(),{release:s,environment:o=a.U}=n&&n.getOptions()||{},{userAgent:i}=r.OW.navigator||{},c=(0,g.fj)({release:s,environment:o,user:t.getUser(),...i&&{userAgent:i},...e}),l=t.getSession&&t.getSession();return l&&"ok"===l.status&&(0,g.qO)(l,{status:"exited"}),this.endSession(),t.setSession(c),c}shouldSendDefaultPii(){const e=this.getClient(),t=e&&e.getOptions();return Boolean(t&&t.sendDefaultPii)}_sendSessionUpdate(){const{scope:e,client:t}=this.getStackTop(),n=e.getSession();n&&t&&t.captureSession&&t.captureSession(n)}_withClient(e){const{scope:t,client:n}=this.getStackTop();n&&e(n,t)}_callExtensionMethod(e,...t){const n=I().__SENTRY__;if(n&&n.extensions&&"function"==typeof n.extensions[e])return n.extensions[e].apply(this,t);c.T&&i.vF.warn(`Extension method ${e} couldn't be found, doing nothing.`)}}function I(){return r.OW.__SENTRY__=r.OW.__SENTRY__||{extensions:{},hub:void 0},r.OW}function m(e){const t=I(),n=v(t);return B(t,e),n}function C(){const e=I();if(e.__SENTRY__&&e.__SENTRY__.acs){const t=e.__SENTRY__.acs.getCurrentHub();if(t)return t}return y(e)}function b(){return C().getIsolationScope()}function y(e=I()){return G(e)&&!v(e).isOlderThan(u)||B(e,new p),v(e)}function f(e,t=y()){if(!G(e)||v(e).isOlderThan(u)){const n=t.getClient(),s=t.getScope(),o=t.getIsolationScope();B(e,new p(n,s.clone(),o.clone()))}}function A(e){const t=I();t.__SENTRY__=t.__SENTRY__||{},t.__SENTRY__.acs=e}function Z(e,t={}){const n=I();return n.__SENTRY__&&n.__SENTRY__.acs?n.__SENTRY__.acs.runWithAsyncContext(e,t):e()}function G(e){return!!(e&&e.__SENTRY__&&e.__SENTRY__.hub)}function v(e){return(0,r.BY)("hub",(()=>new p),e)}function B(e,t){return!!e&&((e.__SENTRY__=e.__SENTRY__||{}).hub=t,!0)}},2486:(e,t,n)=>{"use strict";n.d(t,{HG:()=>g,m6:()=>d});var s=n(3816),o=n(9297),i=n(6936),r=n(2531),a=n(7058),c=n(1535);let l;class g{constructor(){this._notifyingListeners=!1,this._scopeListeners=[],this._eventProcessors=[],this._breadcrumbs=[],this._attachments=[],this._user={},this._tags={},this._extra={},this._contexts={},this._sdkProcessingMetadata={},this._propagationContext=u()}static clone(e){return e?e.clone():new g}clone(){const e=new g;return e._breadcrumbs=[...this._breadcrumbs],e._tags={...this._tags},e._extra={...this._extra},e._contexts={...this._contexts},e._user=this._user,e._level=this._level,e._span=this._span,e._session=this._session,e._transactionName=this._transactionName,e._fingerprint=this._fingerprint,e._eventProcessors=[...this._eventProcessors],e._requestSession=this._requestSession,e._attachments=[...this._attachments],e._sdkProcessingMetadata={...this._sdkProcessingMetadata},e._propagationContext={...this._propagationContext},e}addScopeListener(e){this._scopeListeners.push(e)}addEventProcessor(e){return this._eventProcessors.push(e),this}setUser(e){return this._user=e||{},this._session&&(0,a.qO)(this._session,{user:e}),this._notifyScopeListeners(),this}getUser(){return this._user}getRequestSession(){return this._requestSession}setRequestSession(e){return this._requestSession=e,this}setTags(e){return this._tags={...this._tags,...e},this._notifyScopeListeners(),this}setTag(e,t){return this._tags={...this._tags,[e]:t},this._notifyScopeListeners(),this}setExtras(e){return this._extra={...this._extra,...e},this._notifyScopeListeners(),this}setExtra(e,t){return this._extra={...this._extra,[e]:t},this._notifyScopeListeners(),this}setFingerprint(e){return this._fingerprint=e,this._notifyScopeListeners(),this}setLevel(e){return this._level=e,this._notifyScopeListeners(),this}setTransactionName(e){return this._transactionName=e,this._notifyScopeListeners(),this}setContext(e,t){return null===t?delete this._contexts[e]:this._contexts[e]=t,this._notifyScopeListeners(),this}setSpan(e){return this._span=e,this._notifyScopeListeners(),this}getSpan(){return this._span}getTransaction(){const e=this.getSpan();return e&&e.transaction}setSession(e){return e?this._session=e:delete this._session,this._notifyScopeListeners(),this}getSession(){return this._session}update(e){if(!e)return this;if("function"==typeof e){const t=e(this);return t instanceof g?t:this}return e instanceof g?(this._tags={...this._tags,...e._tags},this._extra={...this._extra,...e._extra},this._contexts={...this._contexts,...e._contexts},e._user&&Object.keys(e._user).length&&(this._user=e._user),e._level&&(this._level=e._level),e._fingerprint&&(this._fingerprint=e._fingerprint),e._requestSession&&(this._requestSession=e._requestSession),e._propagationContext&&(this._propagationContext=e._propagationContext)):(0,s.Qd)(e)&&(this._tags={...this._tags,...e.tags},this._extra={...this._extra,...e.extra},this._contexts={...this._contexts,...e.contexts},e.user&&(this._user=e.user),e.level&&(this._level=e.level),e.fingerprint&&(this._fingerprint=e.fingerprint),e.requestSession&&(this._requestSession=e.requestSession),e.propagationContext&&(this._propagationContext=e.propagationContext)),this}clear(){return this._breadcrumbs=[],this._tags={},this._extra={},this._user={},this._contexts={},this._level=void 0,this._transactionName=void 0,this._fingerprint=void 0,this._requestSession=void 0,this._span=void 0,this._session=void 0,this._notifyScopeListeners(),this._attachments=[],this._propagationContext=u(),this}addBreadcrumb(e,t){const n="number"==typeof t?t:100;if(n<=0)return this;const s={timestamp:(0,o.lu)(),...e},i=this._breadcrumbs;return i.push(s),this._breadcrumbs=i.length>n?i.slice(-n):i,this._notifyScopeListeners(),this}getLastBreadcrumb(){return this._breadcrumbs[this._breadcrumbs.length-1]}clearBreadcrumbs(){return this._breadcrumbs=[],this._notifyScopeListeners(),this}addAttachment(e){return this._attachments.push(e),this}getAttachments(){return this.getScopeData().attachments}clearAttachments(){return this._attachments=[],this}getScopeData(){const{_breadcrumbs:e,_attachments:t,_contexts:n,_tags:s,_extra:o,_user:i,_level:r,_fingerprint:a,_eventProcessors:c,_propagationContext:l,_sdkProcessingMetadata:g,_transactionName:d,_span:u}=this;return{breadcrumbs:e,attachments:t,contexts:n,tags:s,extra:o,user:i,level:r,fingerprint:a||[],eventProcessors:c,propagationContext:l,sdkProcessingMetadata:g,transactionName:d,span:u}}applyToEvent(e,t={},n=[]){(0,c.e2)(e,this.getScopeData());const s=[...n,...(0,r.lG)(),...this._eventProcessors];return(0,r.jB)(s,e,t)}setSDKProcessingMetadata(e){return this._sdkProcessingMetadata={...this._sdkProcessingMetadata,...e},this}setPropagationContext(e){return this._propagationContext=e,this}getPropagationContext(){return this._propagationContext}_notifyScopeListeners(){this._notifyingListeners||(this._notifyingListeners=!0,this._scopeListeners.forEach((e=>{e(this)})),this._notifyingListeners=!1)}}function d(){return l||(l=new g),l}function u(){return{traceId:(0,i.eJ)(),spanId:(0,i.eJ)().substring(16)}}},7058:(e,t,n)=>{"use strict";n.d(t,{Vu:()=>c,fj:()=>r,qO:()=>a});var s=n(9297),o=n(6936),i=n(8411);function r(e){const t=(0,s.zf)(),n={sid:(0,o.eJ)(),init:!0,timestamp:t,started:t,duration:0,status:"ok",errors:0,ignoreDuration:!1,toJSON:()=>function(e){return(0,i.Ce)({sid:`${e.sid}`,init:e.init,started:new Date(1e3*e.started).toISOString(),timestamp:new Date(1e3*e.timestamp).toISOString(),status:e.status,errors:e.errors,did:"number"==typeof e.did||"string"==typeof e.did?`${e.did}`:void 0,duration:e.duration,abnormal_mechanism:e.abnormal_mechanism,attrs:{release:e.release,environment:e.environment,ip_address:e.ipAddress,user_agent:e.userAgent}})}(n)};return e&&a(n,e),n}function a(e,t={}){if(t.user&&(!e.ipAddress&&t.user.ip_address&&(e.ipAddress=t.user.ip_address),e.did||t.did||(e.did=t.user.id||t.user.email||t.user.username)),e.timestamp=t.timestamp||(0,s.zf)(),t.abnormal_mechanism&&(e.abnormal_mechanism=t.abnormal_mechanism),t.ignoreDuration&&(e.ignoreDuration=t.ignoreDuration),t.sid&&(e.sid=32===t.sid.length?t.sid:(0,o.eJ)()),void 0!==t.init&&(e.init=t.init),!e.did&&t.did&&(e.did=`${t.did}`),"number"==typeof t.started&&(e.started=t.started),e.ignoreDuration)e.duration=void 0;else if("number"==typeof t.duration)e.duration=t.duration;else{const t=e.timestamp-e.started;e.duration=t>=0?t:0}t.release&&(e.release=t.release),t.environment&&(e.environment=t.environment),!e.ipAddress&&t.ipAddress&&(e.ipAddress=t.ipAddress),!e.userAgent&&t.userAgent&&(e.userAgent=t.userAgent),"number"==typeof t.errors&&(e.errors=t.errors),t.status&&(e.status=t.status)}function c(e,t){let n={};t?n={status:t}:"ok"===e.status&&(n={status:"exited"}),a(e,n)}},5452:(e,t,n)=>{"use strict";n.d(t,{l:()=>i});var s=n(8411),o=n(2967);function i(e,t,n){const i=t.getOptions(),{publicKey:r}=t.getDsn()||{},{segment:a}=n&&n.getUser()||{},c=(0,s.Ce)({environment:i.environment||o.U,release:i.release,user_segment:a,public_key:r,trace_id:e});return t.emit&&t.emit("createDsc",c),c}},8444:(e,t,n)=>{"use strict";n.d(t,{U:()=>G,p:()=>Z});var s=n(7412),o=n(2220),i=n(6641),r=n(6341),a=n(718);let c=null;function l(){c=r.OW.onerror,r.OW.onerror=function(e,t,n,s,o){const i={column:s,error:o,line:n,msg:e,url:t};return(0,a.aj)("error",i),!(!c||c.__SENTRY_LOADER__)&&c.apply(this,arguments)},r.OW.onerror.__SENTRY_INSTRUMENTED__=!0}let g=null;function d(){g=r.OW.onunhandledrejection,r.OW.onunhandledrejection=function(e){const t=e;return(0,a.aj)("unhandledrejection",t),!(g&&!g.__SENTRY_LOADER__)||g.apply(this,arguments)},r.OW.onunhandledrejection.__SENTRY_INSTRUMENTED__=!0}var u=n(7998);let h=!1;function p(){const e=(0,u.Z7)();if(e){const t="internal_error";o.T&&s.vF.log(`[Tracing] Transaction: ${t} -> Global error occured`),e.setStatus(t)}}p.tag="sentry_tracingErrorCallback";var I=n(6849),m=n(3816),C=n(3551);function b(e,t,n){if(!(0,C.w)(t))return e.sampled=!1,e;if(void 0!==e.sampled)return e.setMetadata({sampleRate:Number(e.sampled)}),e;let i;return"function"==typeof t.tracesSampler?(i=t.tracesSampler(n),e.setMetadata({sampleRate:Number(i)})):void 0!==n.parentSampled?i=n.parentSampled:void 0!==t.tracesSampleRate?(i=t.tracesSampleRate,e.setMetadata({sampleRate:Number(i)})):(i=1,e.setMetadata({sampleRate:i})),r=i,((0,m.yr)(r)||"number"!=typeof r&&"boolean"!=typeof r?(o.T&&s.vF.warn(`[Tracing] Given sample rate is invalid. Sample rate must be a boolean or a number between 0 and 1. Got ${JSON.stringify(r)} of type ${JSON.stringify(typeof r)}.`),0):!(r<0||r>1)||(o.T&&s.vF.warn(`[Tracing] Given sample rate is invalid. Sample rate must be between 0 and 1. Got ${r}.`),0))?i?(e.sampled=Math.random(){"use strict";n.d(t,{Cq:()=>l,zX:()=>u});var s=n(7412),o=n(9297),i=n(2220),r=n(5527),a=n(7927),c=n(7998);const l={idleTimeout:1e3,finalTimeout:3e4,heartbeatInterval:5e3},g=["heartbeatFailed","idleTimeout","documentHidden","finalTimeout","externalFinish","cancelled"];class d extends r.lh{constructor(e,t,n,s){super(s),this._pushActivity=e,this._popActivity=t,this.transactionSpanId=n}add(e){if(e.spanId!==this.transactionSpanId){const t=e.end;e.end=(...n)=>(this._popActivity(e.spanId),t.apply(e,n)),void 0===e.endTimestamp&&this._pushActivity(e.spanId)}super.add(e)}}class u extends a.Z{constructor(e,t,n=l.idleTimeout,o=l.finalTimeout,r=l.heartbeatInterval,a=!1){super(e,t),this._idleHub=t,this._idleTimeout=n,this._finalTimeout=o,this._heartbeatInterval=r,this._onScope=a,this.activities={},this._heartbeatCounter=0,this._finished=!1,this._idleTimeoutCanceledPermanently=!1,this._beforeFinishCallbacks=[],this._finishReason=g[4],a&&(i.T&&s.vF.log(`Setting idle transaction on scope. Span ID: ${this.spanId}`),t.getScope().setSpan(this)),this._restartIdleTimeout(),setTimeout((()=>{this._finished||(this.setStatus("deadline_exceeded"),this._finishReason=g[3],this.end())}),this._finalTimeout)}end(e=(0,o.zf)()){const t=(0,c.JL)(e);if(this._finished=!0,this.activities={},"ui.action.click"===this.op&&this.setTag("finishReason",this._finishReason),this.spanRecorder){i.T&&s.vF.log("[Tracing] finishing IdleTransaction",new Date(1e3*t).toISOString(),this.op);for(const t of this._beforeFinishCallbacks)t(this,e);this.spanRecorder.spans=this.spanRecorder.spans.filter((e=>{if(e.spanId===this.spanId)return!0;e.endTimestamp||(e.endTimestamp=t,e.setStatus("cancelled"),i.T&&s.vF.log("[Tracing] cancelling span since transaction ended early",JSON.stringify(e,void 0,2)));const n=e.startTimestamp{this._finished||this._pushActivity(e)},n=e=>{this._finished||this._popActivity(e)};this.spanRecorder=new d(t,n,this.spanId,e),i.T&&s.vF.log("Starting heartbeat"),this._pingHeartbeat()}this.spanRecorder.add(this)}cancelIdleTimeout(e,{restartOnChildSpanChange:t}={restartOnChildSpanChange:!0}){this._idleTimeoutCanceledPermanently=!1===t,this._idleTimeoutID&&(clearTimeout(this._idleTimeoutID),this._idleTimeoutID=void 0,0===Object.keys(this.activities).length&&this._idleTimeoutCanceledPermanently&&(this._finishReason=g[5],this.end(e)))}setFinishReason(e){this._finishReason=e}_restartIdleTimeout(e){this.cancelIdleTimeout(),this._idleTimeoutID=setTimeout((()=>{this._finished||0!==Object.keys(this.activities).length||(this._finishReason=g[1],this.end(e))}),this._idleTimeout)}_pushActivity(e){this.cancelIdleTimeout(void 0,{restartOnChildSpanChange:!this._idleTimeoutCanceledPermanently}),i.T&&s.vF.log(`[Tracing] pushActivity: ${e}`),this.activities[e]=!0,i.T&&s.vF.log("[Tracing] new activities count",Object.keys(this.activities).length)}_popActivity(e){if(this.activities[e]&&(i.T&&s.vF.log(`[Tracing] popActivity ${e}`),delete this.activities[e],i.T&&s.vF.log("[Tracing] new activities count",Object.keys(this.activities).length)),0===Object.keys(this.activities).length){const e=(0,o.zf)();this._idleTimeoutCanceledPermanently?(this._finishReason=g[5],this.end(e)):this._restartIdleTimeout(e+this._idleTimeout/1e3)}}_beat(){if(this._finished)return;const e=Object.keys(this.activities).join("");e===this._prevHeartbeatString?this._heartbeatCounter++:this._heartbeatCounter=1,this._prevHeartbeatString=e,this._heartbeatCounter>=3?(i.T&&s.vF.log("[Tracing] Transaction finished because of no change for 3 heart beats"),this.setStatus("deadline_exceeded"),this._finishReason=g[0],this.end()):this._pingHeartbeat()}_pingHeartbeat(){i.T&&s.vF.log(`pinging Heartbeat -> current counter: ${this._heartbeatCounter}`),setTimeout((()=>{this._beat()}),this._heartbeatInterval)}}},5527:(e,t,n)=>{"use strict";n.d(t,{L9:()=>d,lh:()=>g,o6:()=>u});var s=n(6936),o=n(9297),i=n(7412),r=n(6524),a=n(8411),c=n(2220),l=n(7998);class g{constructor(e=1e3){this._maxlen=e,this.spans=[]}add(e){this.spans.length>this._maxlen?e.spanRecorder=void 0:this.spans.push(e)}}class d{constructor(e={}){this.traceId=e.traceId||(0,s.eJ)(),this.spanId=e.spanId||(0,s.eJ)().substring(16),this.startTimestamp=e.startTimestamp||(0,o.zf)(),this.tags=e.tags||{},this.data=e.data||{},this.instrumenter=e.instrumenter||"sentry",this.origin=e.origin||"manual",e.parentSpanId&&(this.parentSpanId=e.parentSpanId),"sampled"in e&&(this.sampled=e.sampled),e.op&&(this.op=e.op),e.description&&(this.description=e.description),e.name&&(this.description=e.name),e.status&&(this.status=e.status),e.endTimestamp&&(this.endTimestamp=e.endTimestamp)}get name(){return this.description||""}set name(e){this.setName(e)}startChild(e){const t=new d({...e,parentSpanId:this.spanId,sampled:this.sampled,traceId:this.traceId});if(t.spanRecorder=this.spanRecorder,t.spanRecorder&&t.spanRecorder.add(t),t.transaction=this.transaction,c.T&&t.transaction){const n=`[Tracing] Starting '${e&&e.op||"< unknown op >"}' span on transaction '${t.transaction.name||"< unknown name >"}' (${t.transaction.spanId}).`;t.transaction.metadata.spanMetadata[t.spanId]={logMessage:n},i.vF.log(n)}return t}setTag(e,t){return this.tags={...this.tags,[e]:t},this}setData(e,t){return this.data={...this.data,[e]:t},this}setStatus(e){return this.status=e,this}setHttpStatus(e){this.setTag("http.status_code",String(e)),this.setData("http.response.status_code",e);const t=u(e);return"unknown_error"!==t&&this.setStatus(t),this}setName(e){this.description=e}isSuccess(){return"ok"===this.status}finish(e){return this.end(e)}end(e){if(c.T&&this.transaction&&this.transaction.spanId!==this.spanId){const{logMessage:e}=this.transaction.metadata.spanMetadata[this.spanId];e&&i.vF.log(e.replace("Starting","Finishing"))}this.endTimestamp="number"==typeof e?(0,l.JL)(e):(0,o.zf)()}toTraceparent(){return(0,r.TC)(this.traceId,this.spanId,this.sampled)}toContext(){return(0,a.Ce)({data:this.data,description:this.description,endTimestamp:this.endTimestamp,op:this.op,parentSpanId:this.parentSpanId,sampled:this.sampled,spanId:this.spanId,startTimestamp:this.startTimestamp,status:this.status,tags:this.tags,traceId:this.traceId})}updateWithContext(e){return this.data=e.data||{},this.description=e.description,this.endTimestamp=e.endTimestamp,this.op=e.op,this.parentSpanId=e.parentSpanId,this.sampled=e.sampled,this.spanId=e.spanId||this.spanId,this.startTimestamp=e.startTimestamp||this.startTimestamp,this.status=e.status,this.tags=e.tags||{},this.traceId=e.traceId||this.traceId,this}getTraceContext(){return(0,a.Ce)({data:Object.keys(this.data).length>0?this.data:void 0,description:this.description,op:this.op,parent_span_id:this.parentSpanId,span_id:this.spanId,status:this.status,tags:Object.keys(this.tags).length>0?this.tags:void 0,trace_id:this.traceId,origin:this.origin})}toJSON(){return(0,a.Ce)({data:Object.keys(this.data).length>0?this.data:void 0,description:this.description,op:this.op,parent_span_id:this.parentSpanId,span_id:this.spanId,start_timestamp:this.startTimestamp,status:this.status,tags:Object.keys(this.tags).length>0?this.tags:void 0,timestamp:this.endTimestamp,trace_id:this.traceId,origin:this.origin})}}function u(e){if(e<400&&e>=100)return"ok";if(e>=400&&e<500)switch(e){case 401:return"unauthenticated";case 403:return"permission_denied";case 404:return"not_found";case 409:return"already_exists";case 413:return"failed_precondition";case 429:return"resource_exhausted";default:return"invalid_argument"}if(e>=500&&e<600)switch(e){case 501:return"unimplemented";case 503:return"unavailable";case 504:return"deadline_exceeded";default:return"internal_error"}return"unknown_error"}},6954:(e,t,n)=>{"use strict";n.d(t,{Bk:()=>m,D7:()=>h,Lk:()=>u,Uk:()=>I,V4:()=>C,nV:()=>p,uP:()=>d});var s=n(3816),o=n(6524),i=n(7412),r=n(8411),a=n(2220),c=n(3741),l=n(6641),g=n(3551);function d(e,t,n=(()=>{}),o=(()=>{})){const i=y(e),r=(0,l.BF)(),a=(0,c.o5)(),g=a.getSpan(),d=b(r,g,i);function u(){d&&d.end(),a.setSpan(g)}let h;a.setSpan(d);try{h=t(d)}catch(e){throw d&&d.setStatus("internal_error"),n(e,d),u(),o(),e}return(0,s.Qg)(h)?h.then((e=>(u(),o(),e)),(e=>{throw d&&d.setStatus("internal_error"),n(e,d),u(),o(),e})):(u(),o(),h)}function u(e,t){const n=y(e);return(0,c.v4)((e=>{const o=b((0,l.BF)(),e.getSpan(),n);function i(){o&&o.end()}let r;e.setSpan(o);try{r=t(o)}catch(e){throw o&&o.setStatus("internal_error"),i(),e}return(0,s.Qg)(r)?r.then((e=>(i(),e)),(e=>{throw o&&o.setStatus("internal_error"),i(),e})):(i(),r)}))}const h=u;function p(e,t){const n=y(e);return(0,c.v4)((e=>{const o=b((0,l.BF)(),e.getSpan(),n);let i;e.setSpan(o);try{i=t(o,(function(){o&&o.end()}))}catch(e){throw o&&o.setStatus("internal_error"),e}return(0,s.Qg)(i)?i.then((e=>e),(e=>{throw o&&o.setStatus("internal_error"),e})):i}))}function I(e){if(!(0,g.w)())return;const t={...e};void 0!==t.name&&void 0===t.description&&(t.description=t.name);const n=(0,l.BF)(),s=m();return s?s.startChild(t):n.startTransaction(t)}function m(){return(0,c.o5)().getSpan()}function C({sentryTrace:e,baggage:t},n){const s=(0,c.o5)(),{traceparentData:l,dynamicSamplingContext:g,propagationContext:d}=(0,o.E0)(e,t);s.setPropagationContext(d),a.T&&l&&i.vF.log(`[Tracing] Continuing trace ${l.traceId}.`);const u={...l,metadata:(0,r.Ce)({dynamicSamplingContext:l&&!g?{}:g})};return n?n(u):u}function b(e,t,n){if((0,g.w)())return t?t.startChild(n):e.startTransaction(n)}function y(e){const t={...e};return void 0!==t.name&&void 0===t.description&&(t.description=t.name),t}},7927:(e,t,n)=>{"use strict";n.d(t,{Z:()=>d});var s=n(9297),o=n(8411),i=n(7412),r=n(2220),a=n(6641),c=n(5452),l=n(5527),g=n(7998);class d extends l.L9{constructor(e,t){super(e),delete this.description,this._measurements={},this._contexts={},this._hub=t||(0,a.BF)(),this._name=e.name||"",this.metadata={source:"custom",...e.metadata,spanMetadata:{}},this._trimEnd=e.trimEnd,this.transaction=this;const n=this.metadata.dynamicSamplingContext;n&&(this._frozenDynamicSamplingContext={...n})}get name(){return this._name}set name(e){this.setName(e)}setName(e,t="custom"){this._name=e,this.metadata.source=t}initSpanRecorder(e=1e3){this.spanRecorder||(this.spanRecorder=new l.lh(e)),this.spanRecorder.add(this)}setContext(e,t){null===t?delete this._contexts[e]:this._contexts[e]=t}setMeasurement(e,t,n=""){this._measurements[e]={value:t,unit:n}}setMetadata(e){this.metadata={...this.metadata,...e}}end(e){const t="number"==typeof e?(0,g.JL)(e):(0,s.zf)(),n=this._finishTransaction(t);if(n)return this._hub.captureEvent(n)}toContext(){const e=super.toContext();return(0,o.Ce)({...e,name:this.name,trimEnd:this._trimEnd})}updateWithContext(e){return super.updateWithContext(e),this.name=e.name||"",this._trimEnd=e.trimEnd,this}getDynamicSamplingContext(){if(this._frozenDynamicSamplingContext)return this._frozenDynamicSamplingContext;const e=this._hub||(0,a.BF)(),t=e.getClient();if(!t)return{};const n=e.getScope(),s=(0,c.l)(this.traceId,t,n),o=this.metadata.sampleRate;void 0!==o&&(s.sample_rate=`${o}`);const i=this.metadata.source;return i&&"url"!==i&&(s.transaction=this.name),void 0!==this.sampled&&(s.sampled=String(this.sampled)),s}setHub(e){this._hub=e}_finishTransaction(e){if(void 0!==this.endTimestamp)return;this.name||(r.T&&i.vF.warn("Transaction has no name, falling back to ``."),this.name=""),super.end(e);const t=this._hub.getClient();if(t&&t.emit&&t.emit("finishTransaction",this),!0!==this.sampled)return r.T&&i.vF.log("[Tracing] Discarding transaction because its trace was not chosen to be sampled."),void(t&&t.recordDroppedEvent("sample_rate","transaction"));const n=this.spanRecorder?this.spanRecorder.spans.filter((e=>e!==this&&e.endTimestamp)):[];this._trimEnd&&n.length>0&&(this.endTimestamp=n.reduce(((e,t)=>e.endTimestamp&&t.endTimestamp?e.endTimestamp>t.endTimestamp?e:t:e)).endTimestamp);const s=this.metadata,o={contexts:{...this._contexts,trace:this.getTraceContext()},spans:n,start_timestamp:this.startTimestamp,tags:this.tags,timestamp:this.endTimestamp,transaction:this.name,type:"transaction",sdkProcessingMetadata:{...s,dynamicSamplingContext:this.getDynamicSamplingContext()},...s.source&&{transaction_info:{source:s.source}}};return Object.keys(this._measurements).length>0&&(r.T&&i.vF.log("[Measurements] Adding measurements to transaction",JSON.stringify(this._measurements,void 0,2)),o.measurements=this._measurements),r.T&&i.vF.log(`[Tracing] Finishing ${this.op} transaction: ${this.name}.`),o}}},7998:(e,t,n)=>{"use strict";n.d(t,{JL:()=>a,Z7:()=>i,nc:()=>r});var s=n(6524),o=n(6641);function i(e){return(e||(0,o.BF)()).getScope().getTransaction()}const r=s.nc;function a(e){return e>9999999999?e/1e3:e}},1535:(e,t,n)=>{"use strict";n.d(t,{Rg:()=>i,e2:()=>o});var s=n(6936);function o(e,t){const{fingerprint:n,span:o,breadcrumbs:i,sdkProcessingMetadata:r,propagationContext:a}=t;!function(e,t){const{extra:n,tags:s,user:o,contexts:i,level:r,transactionName:a}=t;n&&Object.keys(n).length&&(e.extra={...n,...e.extra}),s&&Object.keys(s).length&&(e.tags={...s,...e.tags}),o&&Object.keys(o).length&&(e.user={...o,...e.user}),i&&Object.keys(i).length&&(e.contexts={...i,...e.contexts}),r&&(e.level=r),a&&(e.transaction=a)}(e,t),o&&function(e,t){e.contexts={trace:t.getTraceContext(),...e.contexts};const n=t.transaction;if(n){e.sdkProcessingMetadata={dynamicSamplingContext:n.getDynamicSamplingContext(),...e.sdkProcessingMetadata};const t=n.name;t&&(e.tags={transaction:t,...e.tags})}}(e,o),function(e,t){e.fingerprint=e.fingerprint?(0,s.k9)(e.fingerprint):[],t&&(e.fingerprint=e.fingerprint.concat(t)),e.fingerprint&&!e.fingerprint.length&&delete e.fingerprint}(e,n),function(e,t){const n=[...e.breadcrumbs||[],...t];e.breadcrumbs=n.length?n:void 0}(e,i),function(e,t,n){e.sdkProcessingMetadata={...e.sdkProcessingMetadata,...t,propagationContext:n}}(e,r,a)}function i(e,t){const{extra:n,tags:s,user:o,contexts:i,level:a,sdkProcessingMetadata:c,breadcrumbs:l,fingerprint:g,eventProcessors:d,attachments:u,propagationContext:h,transactionName:p,span:I}=t;r(e,"extra",n),r(e,"tags",s),r(e,"user",o),r(e,"contexts",i),r(e,"sdkProcessingMetadata",c),a&&(e.level=a),p&&(e.transactionName=p),I&&(e.span=I),l.length&&(e.breadcrumbs=[...e.breadcrumbs,...l]),g.length&&(e.fingerprint=[...e.fingerprint,...g]),d.length&&(e.eventProcessors=[...e.eventProcessors,...d]),u.length&&(e.attachments=[...e.attachments,...u]),e.propagationContext={...e.propagationContext,...h}}function r(e,t,n){n&&Object.keys(n).length&&(e[t]={...e[t],...n})}},3551:(e,t,n)=>{"use strict";n.d(t,{w:()=>o});var s=n(3741);function o(e){if("boolean"==typeof __SENTRY_TRACING__&&!__SENTRY_TRACING__)return!1;const t=(0,s.KU)(),n=e||t&&t.getOptions();return!!n&&(n.enableTracing||"tracesSampleRate"in n||"tracesSampler"in n)}},1351:(e,t,n)=>{"use strict";function s(e,t){const n=t&&function(e){return void 0!==e.getClient}(t)?t.getClient():t,s=n&&n.getDsn(),i=n&&n.getOptions().tunnel;return function(e,t){return!!t&&e.includes(t.host)}(e,s)||function(e,t){return!!t&&o(e)===o(t)}(e,i)}function o(e){return"/"===e[e.length-1]?e.slice(0,-1):e}n.d(t,{A:()=>s})},9475:(e,t,n)=>{"use strict";n.d(t,{li:()=>p,mG:()=>u});var s=n(6936),o=n(9297),i=n(9653),r=n(6341),a=n(2181),c=n(2967),l=n(2531),g=n(2486),d=n(1535);function u(e,t,n,u,p,I){const{normalizeDepth:m=3,normalizeMaxBreadth:C=1e3}=e,b={...t,event_id:t.event_id||n.event_id||(0,s.eJ)(),timestamp:t.timestamp||(0,o.lu)()},y=n.integrations||e.integrations.map((e=>e.name));!function(e,t){const{environment:n,release:s,dist:o,maxValueLength:r=250}=t;"environment"in e||(e.environment="environment"in t?n:c.U),void 0===e.release&&void 0!==s&&(e.release=s),void 0===e.dist&&void 0!==o&&(e.dist=o),e.message&&(e.message=(0,i.xv)(e.message,r));const a=e.exception&&e.exception.values&&e.exception.values[0];a&&a.value&&(a.value=(0,i.xv)(a.value,r));const l=e.request;l&&l.url&&(l.url=(0,i.xv)(l.url,r))}(b,e),function(e,t){t.length>0&&(e.sdk=e.sdk||{},e.sdk.integrations=[...e.sdk.integrations||[],...t])}(b,y),void 0===t.type&&function(e,t){const n=r.OW._sentryDebugIds;if(!n)return;let s;const o=h.get(t);o?s=o:(s=new Map,h.set(t,s));const i=Object.keys(n).reduce(((e,o)=>{let i;const r=s.get(o);r?i=r:(i=t(o),s.set(o,i));for(let t=i.length-1;t>=0;t--){const s=i[t];if(s.filename){e[s.filename]=n[o];break}}return e}),{});try{e.exception.values.forEach((e=>{e.stacktrace.frames.forEach((e=>{e.filename&&(e.debug_id=i[e.filename])}))}))}catch(e){}}(b,e.stackParser);const f=function(e,t){if(!t)return e;const n=e?e.clone():new g.HG;return n.update(t),n}(u,n.captureContext);n.mechanism&&(0,s.M6)(b,n.mechanism);const A=p&&p.getEventProcessors?p.getEventProcessors():[],Z=(0,g.m6)().getScopeData();if(I){const e=I.getScopeData();(0,d.Rg)(Z,e)}if(f){const e=f.getScopeData();(0,d.Rg)(Z,e)}const G=[...n.attachments||[],...Z.attachments];G.length&&(n.attachments=G),(0,d.e2)(b,Z);const v=[...A,...(0,l.lG)(),...Z.eventProcessors];return(0,l.jB)(v,b,n).then((e=>(e&&function(e){const t={};try{e.exception.values.forEach((e=>{e.stacktrace.frames.forEach((e=>{e.debug_id&&(e.abs_path?t[e.abs_path]=e.debug_id:e.filename&&(t[e.filename]=e.debug_id),delete e.debug_id)}))}))}catch(e){}if(0===Object.keys(t).length)return;e.debug_meta=e.debug_meta||{},e.debug_meta.images=e.debug_meta.images||[];const n=e.debug_meta.images;Object.keys(t).forEach((e=>{n.push({type:"sourcemap",code_file:e,debug_id:t[e]})}))}(e),"number"==typeof m&&m>0?function(e,t,n){if(!e)return null;const s={...e,...e.breadcrumbs&&{breadcrumbs:e.breadcrumbs.map((e=>({...e,...e.data&&{data:(0,a.S8)(e.data,t,n)}})))},...e.user&&{user:(0,a.S8)(e.user,t,n)},...e.contexts&&{contexts:(0,a.S8)(e.contexts,t,n)},...e.extra&&{extra:(0,a.S8)(e.extra,t,n)}};return e.contexts&&e.contexts.trace&&s.contexts&&(s.contexts.trace=e.contexts.trace,e.contexts.trace.data&&(s.contexts.trace.data=(0,a.S8)(e.contexts.trace.data,t,n))),e.spans&&(s.spans=e.spans.map((e=>(e.data&&(e.data=(0,a.S8)(e.data,t,n)),e)))),s}(e,m,C):e)))}const h=new WeakMap;function p(e){if(e)return function(e){return e instanceof g.HG||"function"==typeof e}(e)||function(e){return Object.keys(e).some((e=>I.includes(e)))}(e)?{captureContext:e}:e}const I=["user","level","extra","contexts","tags","fingerprint","requestSession","propagationContext"]},7986:(e,t,n)=>{"use strict";n.d(t,{M:()=>s});const s="7.91.0"},1138:(e,t,n)=>{"use strict";n.r(t),n.d(t,{DEFAULT_USER_INCLUDES:()=>Le.cx,Handlers:()=>o,Hub:()=>h.YZ,Integrations:()=>Sn,NodeClient:()=>Ne,SDK_VERSION:()=>Ge.M,Scope:()=>ve.HG,addBreadcrumb:()=>u.ZQ,addEventProcessor:()=>ge,addGlobalEventProcessor:()=>d.lb,addIntegration:()=>C,addRequestDataToEvent:()=>Le.GY,autoDiscoverNodePerformanceMonitoringIntegrations:()=>Ve,captureCheckIn:()=>u.SE,captureEvent:()=>u.r,captureException:()=>u.Cp,captureMessage:()=>u.wd,close:()=>u.VN,configureScope:()=>u.PN,continueTrace:()=>Be.V4,createTransport:()=>he,deepReadDirSync:()=>sn,defaultIntegrations:()=>qt,defaultStackParser:()=>nn,enableAnrDetection:()=>rn,extractRequestData:()=>Le.Rj,extractTraceparentData:()=>Ae.nc,flush:()=>u.bX,getActiveSpan:()=>Be.Bk,getActiveTransaction:()=>Ae.Z7,getClient:()=>u.KU,getCurrentHub:()=>h.BF,getCurrentScope:()=>u.o5,getGlobalScope:()=>ve.m6,getHubFromCarrier:()=>h.Me,getIsolationScope:()=>h.rm,getModuleFromFilename:()=>Dt,getSentryRelease:()=>tn,hapiErrorPlugin:()=>Cn,init:()=>$t,lastEventId:()=>u.Q,makeMain:()=>h.gM,makeNodeTransport:()=>Ue,metrics:()=>fe,runWithAsyncContext:()=>h.fx,setContext:()=>u.o,setExtra:()=>u.l7,setExtras:()=>u.cx,setMeasurement:()=>Ze,setTag:()=>u.NA,setTags:()=>u.Wt,setUser:()=>u.gV,spanStatusfromHttpCode:()=>We.o6,startActiveSpan:()=>Be.D7,startInactiveSpan:()=>Be.Uk,startSpan:()=>Be.Lk,startSpanManual:()=>Be.nV,startTransaction:()=>u.nb,trace:()=>Be.uP,withMonitor:()=>u.T$,withScope:()=>u.v4});var s={};n.r(s),n.d(s,{FunctionToString:()=>A,InboundFilters:()=>W,LinkedErrors:()=>J});var o={};n.r(o),n.d(o,{errorHandler:()=>hn,extractRequestData:()=>cn,parseRequest:()=>ln,requestHandler:()=>dn,tracingHandler:()=>gn,trpcMiddleware:()=>pn});var i={};n.r(i),n.d(i,{Anr:()=>on.M,Console:()=>dt,Context:()=>Jt,ContextLines:()=>kt,Hapi:()=>yn,Http:()=>ft,LocalVariables:()=>jt,Modules:()=>Rt,OnUncaughtException:()=>vt,OnUnhandledRejection:()=>Bt,RequestData:()=>Me,Spotlight:()=>Mt,Undici:()=>Qt.h});var r={};n.r(r),n.d(r,{Apollo:()=>fn.I,Express:()=>An.JF,GraphQL:()=>Zn.c,Mongo:()=>Gn.N,Mysql:()=>vn.d,Postgres:()=>Bn.E,Prisma:()=>Wn.D});var a=n(8411),c=n(6936),l=n(7412),g=n(2220),d=n(2531),u=n(3741),h=n(6641);const p=[];function I(e){const t=e.defaultIntegrations||[],n=e.integrations;let s;t.forEach((e=>{e.isDefaultInstance=!0})),s=Array.isArray(n)?[...t,...n]:"function"==typeof n?(0,c.k9)(n(t)):t;const o=function(e){const t={};return e.forEach((e=>{const{name:n}=e,s=t[n];s&&!s.isDefaultInstance&&e.isDefaultInstance||(t[n]=e)})),Object.keys(t).map((e=>t[e]))}(s),i=function(e,t){for(let t=0;tn(t,s,e)))}if(e.addEventProcessor&&"function"==typeof t.processEvent){const n=t.processEvent.bind(t),s=Object.assign(((t,s)=>n(t,s,e)),{id:t.name});e.addEventProcessor(s)}g.T&&l.vF.log(`Integration installed: ${t.name}`)}function C(e){const t=(0,u.KU)();t&&t.addIntegration?t.addIntegration(e):g.T&&l.vF.warn(`Cannot add integration "${e.name}" because no SDK Client is available.`)}function b(e,t){return Object.assign((function(...e){return{setupOnce:()=>{},...t(...e)}}),{id:e})}let y;const f="FunctionToString",A=b(f,(()=>({name:f,setupOnce(){y=Function.prototype.toString;try{Function.prototype.toString=function(...e){const t=(0,a.sp)(this)||this;return y.apply(t,e)}}catch(e){}}})));var Z=n(9653);const G=[/^Script error\.?$/,/^Javascript error: Script error\.? on line 0$/],v=[/^.*\/healthcheck$/,/^.*\/healthy$/,/^.*\/live$/,/^.*\/ready$/,/^.*\/heartbeat$/,/^.*\/health$/,/^.*\/healthz$/],B="InboundFilters",W=b(B,(e=>({name:B,processEvent(t,n,s){const o=s.getOptions(),i=function(e={},t={}){return{allowUrls:[...e.allowUrls||[],...t.allowUrls||[]],denyUrls:[...e.denyUrls||[],...t.denyUrls||[]],ignoreErrors:[...e.ignoreErrors||[],...t.ignoreErrors||[],...e.disableErrorDefaults?[]:G],ignoreTransactions:[...e.ignoreTransactions||[],...t.ignoreTransactions||[],...e.disableTransactionDefaults?[]:v],ignoreInternal:void 0===e.ignoreInternal||e.ignoreInternal}}(e,o);return function(e,t){return t.ignoreInternal&&function(e){try{return"SentryError"===e.exception.values[0].type}catch(e){}return!1}(e)?(g.T&&l.vF.warn(`Event dropped due to being internal Sentry Error.\nEvent: ${(0,c.$X)(e)}`),!0):function(e,t){return!(e.type||!t||!t.length)&&function(e){const t=[];let n;e.message&&t.push(e.message);try{n=e.exception.values[e.exception.values.length-1]}catch(e){}return n&&n.value&&(t.push(n.value),n.type&&t.push(`${n.type}: ${n.value}`)),g.T&&0===t.length&&l.vF.error(`Could not extract message for event ${(0,c.$X)(e)}`),t}(e).some((e=>(0,Z.Xr)(e,t)))}(e,t.ignoreErrors)?(g.T&&l.vF.warn(`Event dropped due to being matched by \`ignoreErrors\` option.\nEvent: ${(0,c.$X)(e)}`),!0):function(e,t){if("transaction"!==e.type||!t||!t.length)return!1;const n=e.transaction;return!!n&&(0,Z.Xr)(n,t)}(e,t.ignoreTransactions)?(g.T&&l.vF.warn(`Event dropped due to being matched by \`ignoreTransactions\` option.\nEvent: ${(0,c.$X)(e)}`),!0):function(e,t){if(!t||!t.length)return!1;const n=S(e);return!!n&&(0,Z.Xr)(n,t)}(e,t.denyUrls)?(g.T&&l.vF.warn(`Event dropped due to being matched by \`denyUrls\` option.\nEvent: ${(0,c.$X)(e)}.\nUrl: ${S(e)}`),!0):!function(e,t){if(!t||!t.length)return!0;const n=S(e);return!n||(0,Z.Xr)(n,t)}(e,t.allowUrls)&&(g.T&&l.vF.warn(`Event dropped due to not being matched by \`allowUrls\` option.\nEvent: ${(0,c.$X)(e)}.\nUrl: ${S(e)}`),!0)}(t,i)?null:t}})));function S(e){try{let t;try{t=e.exception.values[0].stacktrace.frames}catch(e){}return t?function(e=[]){for(let t=e.length-1;t>=0;t--){const n=e[t];if(n&&""!==n.filename&&"[native code]"!==n.filename)return n.filename||null}return null}(t):null}catch(t){return g.T&&l.vF.error(`Cannot extract url for event ${(0,c.$X)(e)}`),null}}var V=n(3816);function w(e,t,n=250,s,o,i,r){if(!(i.exception&&i.exception.values&&r&&(0,V.tH)(r.originalException,Error)))return;const a=i.exception.values.length>0?i.exception.values[i.exception.values.length-1]:void 0;var c,l;a&&(i.exception.values=(c=R(e,t,o,r.originalException,s,i.exception.values,a,0),l=n,c.map((e=>(e.value&&(e.value=(0,Z.xv)(e.value,l)),e)))))}function R(e,t,n,s,o,i,r,a){if(i.length>=n+1)return i;let c=[...i];if((0,V.tH)(s[o],Error)){H(r,a);const i=e(t,s[o]),l=c.length;k(i,o,l,a),c=R(e,t,n,s[o],o,[i,...c],i,l)}return Array.isArray(s.errors)&&s.errors.forEach(((s,i)=>{if((0,V.tH)(s,Error)){H(r,a);const l=e(t,s),g=c.length;k(l,`errors[${i}]`,g,a),c=R(e,t,n,s,o,[l,...c],l,g)}})),c}function H(e,t){e.mechanism=e.mechanism||{type:"generic",handled:!0},e.mechanism={...e.mechanism,is_exception_group:!0,exception_id:t}}function k(e,t,n,s){e.mechanism=e.mechanism||{type:"generic",handled:!0},e.mechanism={...e.mechanism,type:"chained",source:t,exception_id:n,parent_id:s}}var Y=n(2181);function X(e,t){return e(t.stack||"",1)}function N(e,t){const n={type:t.name||t.constructor.name,value:t.message},s=X(e,t);return s.length&&(n.stacktrace={frames:s}),n}const _="LinkedErrors",J=b(_,((e={})=>{const t=e.limit||5,n=e.key||"cause";return{name:_,preprocessEvent(e,s,o){const i=o.getOptions();w(N,i.stackParser,i.maxValueLength,n,t,e,s)}}}));var F=n(5644);const K=/^(?:(\w+):)\/\/(?:(\w+)(?::(\w+)?)?@)([\w.-]+)(?::(\d+))?\/(.+)/;function x(e,t=!1){const{host:n,path:s,pass:o,port:i,projectId:r,protocol:a,publicKey:c}=e;return`${a}://${c}${t&&o?`:${o}`:""}@${n}${i?`:${i}`:""}/${s?`${s}/`:s}${r}`}function E(e){return{protocol:e.protocol,publicKey:e.publicKey||"",pass:e.pass||"",host:e.host,port:e.port||"",path:e.path||"",projectId:e.projectId}}var T=n(690);function z(e,t=[]){return[e,t]}function U(e,t){const[n,s]=e;return[n,[...s,t]]}function O(e,t){const n=e[1];for(const e of n)if(t(e,e[0].type))return!0;return!1}function L(e,t){return(t||new TextEncoder).encode(e)}function j(e,t){const[n,s]=e;let o=JSON.stringify(n);function i(e){"string"==typeof o?o="string"==typeof e?o+e:[L(o,t),e]:o.push("string"==typeof e?L(e,t):e)}for(const e of s){const[t,n]=e;if(i(`\n${JSON.stringify(t)}\n`),"string"==typeof n||n instanceof Uint8Array)i(n);else{let e;try{e=JSON.stringify(n)}catch(t){e=JSON.stringify((0,Y.S8)(n))}i(e)}}return"string"==typeof o?o:function(e){const t=e.reduce(((e,t)=>e+t.length),0),n=new Uint8Array(t);let s=0;for(const t of e)n.set(t,s),s+=t.length;return n}(o)}function Q(e,t){const n="string"==typeof e.data?L(e.data,t):e.data;return[(0,a.Ce)({type:"attachment",length:n.length,filename:e.filename,content_type:e.contentType,attachment_type:e.attachmentType}),n]}const M={session:"session",sessions:"session",attachment:"attachment",transaction:"transaction",event:"error",client_report:"internal",user_report:"default",profile:"profile",replay_event:"replay",replay_recording:"replay",check_in:"monitor",feedback:"feedback",statsd:"unknown"};function P(e){return M[e]}function D(e){if(!e||!e.sdk)return;const{name:t,version:n}=e.sdk;return{name:t,version:n}}class q extends Error{constructor(e,t="warn"){super(e),this.message=e,this.name=new.target.prototype.constructor.name,Object.setPrototypeOf(this,new.target.prototype),this.logLevel=t}}const $=/[^a-zA-Z0-9_/.-]+/g,ee=/[^\w\d_:/@.{}[\]$-]+/g;function te(e,t,n,s){return`${e}${t}${n}${Object.entries((0,a.Ce)(s)).sort(((e,t)=>e[0].localeCompare(t[0])))}`}function ne(e){const t={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n.replace($,"_")]=String(e[n]).replace(ee,"_"));return t}var se=n(7058),oe=n(5452),ie=n(9475);const re="Not capturing exception because it's already been captured.";class ae{constructor(e){if(this._options=e,this._integrations={},this._integrationsInitialized=!1,this._numProcessing=0,this._outcomes={},this._hooks={},this._eventProcessors=[],e.dsn?this._dsn=function(e){const t="string"==typeof e?function(e){const t=K.exec(e);if(!t)return void(0,l.pq)((()=>{console.error(`Invalid Sentry Dsn: ${e}`)}));const[n,s,o="",i,r="",a]=t.slice(1);let c="",g=a;const d=g.split("/");if(d.length>1&&(c=d.slice(0,-1).join("/"),g=d.pop()),g){const e=g.match(/^\d+/);e&&(g=e[0])}return E({host:i,pass:o,path:c,projectId:g,port:r,protocol:n,publicKey:s})}(e):E(e);if(t&&function(e){if(!F.T)return!0;const{port:t,projectId:n,protocol:s}=e;return!(["protocol","publicKey","host","projectId"].find((t=>!e[t]&&(l.vF.error(`Invalid Sentry Dsn: ${t} missing`),!0)))||(n.match(/^\d+$/)?function(e){return"http"===e||"https"===e}(s)?t&&isNaN(parseInt(t,10))&&(l.vF.error(`Invalid Sentry Dsn: Invalid port ${t}`),1):(l.vF.error(`Invalid Sentry Dsn: Invalid protocol ${s}`),1):(l.vF.error(`Invalid Sentry Dsn: Invalid projectId ${n}`),1)))}(t))return t}(e.dsn):g.T&&l.vF.warn("No DSN provided, client will not send events."),this._dsn){const t=function(e,t={}){const n="string"==typeof t?t:t.tunnel,s="string"!=typeof t&&t._metadata?t._metadata.sdk:void 0;return n||`${function(e){return`${function(e){const t=e.protocol?`${e.protocol}:`:"",n=e.port?`:${e.port}`:"";return`${t}//${e.host}${n}${e.path?`/${e.path}`:""}/api/`}(e)}${e.projectId}/envelope/`}(e)}?${function(e,t){return(0,a.u4)({sentry_key:e.publicKey,sentry_version:"7",...t&&{sentry_client:`${t.name}/${t.version}`}})}(e,s)}`}(this._dsn,e);this._transport=e.transport({recordDroppedEvent:this.recordDroppedEvent.bind(this),...e.transportOptions,url:t})}}captureException(e,t,n){if((0,c.GR)(e))return void(g.T&&l.vF.log(re));let s=t&&t.event_id;return this._process(this.eventFromException(e,t).then((e=>this._captureEvent(e,t,n))).then((e=>{s=e}))),s}captureMessage(e,t,n,s){let o=n&&n.event_id;const i=(0,V.sO)(e)?this.eventFromMessage(String(e),t,n):this.eventFromException(e,n);return this._process(i.then((e=>this._captureEvent(e,n,s))).then((e=>{o=e}))),o}captureEvent(e,t,n){if(t&&t.originalException&&(0,c.GR)(t.originalException))return void(g.T&&l.vF.log(re));let s=t&&t.event_id;return this._process(this._captureEvent(e,t,n).then((e=>{s=e}))),s}captureSession(e){"string"!=typeof e.release?g.T&&l.vF.warn("Discarded session because of missing or non-string release"):(this.sendSession(e),(0,se.qO)(e,{init:!1}))}getDsn(){return this._dsn}getOptions(){return this._options}getSdkMetadata(){return this._options._metadata}getTransport(){return this._transport}flush(e){const t=this._transport;return t?(this.metricsAggregator&&this.metricsAggregator.flush(),this._isClientDoneProcessing(e).then((n=>t.flush(e).then((e=>n&&e))))):(0,T.XW)(!0)}close(e){return this.flush(e).then((e=>(this.getOptions().enabled=!1,this.metricsAggregator&&this.metricsAggregator.close(),e)))}getEventProcessors(){return this._eventProcessors}addEventProcessor(e){this._eventProcessors.push(e)}setupIntegrations(e){(e&&!this._integrationsInitialized||this._isEnabled()&&!this._integrationsInitialized)&&(this._integrations=function(e,t){const n={};return t.forEach((t=>{t&&m(e,t,n)})),n}(this,this._options.integrations),this._integrationsInitialized=!0)}getIntegrationById(e){return this._integrations[e]}getIntegration(e){try{return this._integrations[e.id]||null}catch(t){return g.T&&l.vF.warn(`Cannot retrieve integration ${e.id} from the current Client`),null}}addIntegration(e){m(this,e,this._integrations)}sendEvent(e,t={}){this.emit("beforeSendEvent",e,t);let n=function(e,t,n,s){const o=D(n),i=e.type&&"replay_event"!==e.type?e.type:"event";!function(e,t){t&&(e.sdk=e.sdk||{},e.sdk.name=e.sdk.name||t.name,e.sdk.version=e.sdk.version||t.version,e.sdk.integrations=[...e.sdk.integrations||[],...t.integrations||[]],e.sdk.packages=[...e.sdk.packages||[],...t.packages||[]])}(e,n&&n.sdk);const r=function(e,t,n,s){const o=e.sdkProcessingMetadata&&e.sdkProcessingMetadata.dynamicSamplingContext;return{event_id:e.event_id,sent_at:(new Date).toISOString(),...t&&{sdk:t},...!!n&&s&&{dsn:x(s)},...o&&{trace:(0,a.Ce)({...o})}}}(e,o,s,t);return delete e.sdkProcessingMetadata,z(r,[[{type:i},e]])}(e,this._dsn,this._options._metadata,this._options.tunnel);for(const e of t.attachments||[])n=U(n,Q(e,this._options.transportOptions&&this._options.transportOptions.textEncoder));const s=this._sendEnvelope(n);s&&s.then((t=>this.emit("afterSendEvent",e,t)),null)}sendSession(e){const t=function(e,t,n,s){const o=D(n);return z({sent_at:(new Date).toISOString(),...o&&{sdk:o},...!!s&&t&&{dsn:x(t)}},["aggregates"in e?[{type:"sessions"},e]:[{type:"session"},e.toJSON()]])}(e,this._dsn,this._options._metadata,this._options.tunnel);this._sendEnvelope(t)}recordDroppedEvent(e,t,n){if(this._options.sendClientReports){const n=`${e}:${t}`;g.T&&l.vF.log(`Adding outcome: "${n}"`),this._outcomes[n]=this._outcomes[n]+1||1}}captureAggregateMetrics(e){g.T&&l.vF.log(`Flushing aggregated metrics, number of metrics: ${e.length}`);const t=function(e,t,n,s){const o={sent_at:(new Date).toISOString()};n&&n.sdk&&(o.sdk={name:n.sdk.name,version:n.sdk.version}),s&&t&&(o.dsn=x(t));const i=function(e){const t=function(e){let t="";for(const n of e){const e=Object.entries(n.tags),s=e.length>0?`|#${e.map((([e,t])=>`${e}:${t}`)).join(",")}`:"";t+=`${n.name}@${n.unit}:${n.metric}|${n.metricType}${s}|T${n.timestamp}\n`}return t}(e);return[{type:"statsd",length:t.length},t]}(e);return z(o,[i])}(e,this._dsn,this._options._metadata,this._options.tunnel);this._sendEnvelope(t)}on(e,t){this._hooks[e]||(this._hooks[e]=[]),this._hooks[e].push(t)}emit(e,...t){this._hooks[e]&&this._hooks[e].forEach((e=>e(...t)))}_updateSessionFromEvent(e,t){let n=!1,s=!1;const o=t.exception&&t.exception.values;if(o){s=!0;for(const e of o){const t=e.mechanism;if(t&&!1===t.handled){n=!0;break}}}const i="ok"===e.status;(i&&0===e.errors||i&&n)&&((0,se.qO)(e,{...n&&{status:"crashed"},errors:e.errors||Number(s||n)}),this.captureSession(e))}_isClientDoneProcessing(e){return new T.T2((t=>{let n=0;const s=setInterval((()=>{0==this._numProcessing?(clearInterval(s),t(!0)):(n+=1,e&&n>=e&&(clearInterval(s),t(!1)))}),1)}))}_isEnabled(){return!1!==this.getOptions().enabled&&void 0!==this._transport}_prepareEvent(e,t,n,s=(0,h.rm)()){const o=this.getOptions(),i=Object.keys(this._integrations);return!t.integrations&&i.length>0&&(t.integrations=i),this.emit("preprocessEvent",e,t),(0,ie.mG)(o,e,t,n,this,s).then((e=>{if(null===e)return e;const{propagationContext:t}=e.sdkProcessingMetadata||{};if((!e.contexts||!e.contexts.trace)&&t){const{traceId:s,spanId:o,parentSpanId:i,dsc:r}=t;e.contexts={trace:{trace_id:s,span_id:o,parent_span_id:i},...e.contexts};const a=r||(0,oe.l)(s,this,n);e.sdkProcessingMetadata={dynamicSamplingContext:a,...e.sdkProcessingMetadata}}return e}))}_captureEvent(e,t={},n){return this._processEvent(e,t,n).then((e=>e.event_id),(e=>{if(g.T){const t=e;"log"===t.logLevel?l.vF.log(t.message):l.vF.warn(t)}}))}_processEvent(e,t,n){const s=this.getOptions(),{sampleRate:o}=s,i=le(e),r=ce(e),a=e.type||"error",c=`before send for type \`${a}\``;if(r&&"number"==typeof o&&Math.random()>o)return this.recordDroppedEvent("sample_rate","error",e),(0,T.xg)(new q(`Discarding event because it's not included in the random sample (sampling rate = ${o})`,"log"));const l="replay_event"===a?"replay":a;return this._prepareEvent(e,t,n).then((n=>{if(null===n)throw this.recordDroppedEvent("event_processor",l,e),new q("An event processor returned `null`, will not send event.","log");if(t.data&&!0===t.data.__sentry__)return n;const o=function(e,t,n){const{beforeSend:s,beforeSendTransaction:o}=e;return ce(t)&&s?s(t,n):le(t)&&o?o(t,n):t}(s,n,t);return function(e,t){const n=`${t} must return \`null\` or a valid event.`;if((0,V.Qg)(e))return e.then((e=>{if(!(0,V.Qd)(e)&&null!==e)throw new q(n);return e}),(e=>{throw new q(`${t} rejected with ${e}`)}));if(!(0,V.Qd)(e)&&null!==e)throw new q(n);return e}(o,c)})).then((s=>{if(null===s)throw this.recordDroppedEvent("before_send",l,e),new q(`${c} returned \`null\`, will not send event.`,"log");const o=n&&n.getSession();!i&&o&&this._updateSessionFromEvent(o,s);const r=s.transaction_info;if(i&&r&&s.transaction!==e.transaction){const e="custom";s.transaction_info={...r,source:e}}return this.sendEvent(s,t),s})).then(null,(e=>{if(e instanceof q)throw e;throw this.captureException(e,{data:{__sentry__:!0},originalException:e}),new q(`Event processing pipeline threw an error, original event will not be sent. Details have been sent as a new event.\nReason: ${e}`)}))}_process(e){this._numProcessing++,e.then((e=>(this._numProcessing--,e)),(e=>(this._numProcessing--,e)))}_sendEnvelope(e){if(this.emit("beforeEnvelope",e),this._isEnabled()&&this._transport)return this._transport.send(e).then(null,(e=>{g.T&&l.vF.error("Error while sending event:",e)}));g.T&&l.vF.error("Transport disabled")}_clearOutcomes(){const e=this._outcomes;return this._outcomes={},Object.keys(e).map((t=>{const[n,s]=t.split(":");return{reason:n,category:s,quantity:e[t]}}))}}function ce(e){return void 0===e.type}function le(e){return"transaction"===e.type}function ge(e){const t=(0,u.KU)();t&&t.addEventProcessor&&t.addEventProcessor(e)}const de=6e4;const ue=30;function he(e,t,n=function(e){const t=[];function n(e){return t.splice(t.indexOf(e),1)[0]}return{$:t,add:function(s){if(!(void 0===e||t.lengthn(o))).then(null,(()=>n(o).then(null,(()=>{})))),o},drain:function(e){return new T.T2(((n,s)=>{let o=t.length;if(!o)return n(!0);const i=setTimeout((()=>{e&&e>0&&n(!1)}),e);t.forEach((e=>{(0,T.XW)(e).then((()=>{--o||(clearTimeout(i),n(!0))}),s)}))}))}}}(e.bufferSize||ue)){let s={};function o(o){const i=[];if(O(o,((t,n)=>{const o=P(n);if(function(e,t,n=Date.now()){return function(e,t){return e[t]||e.all||0}(e,t)>n}(s,o)){const s=pe(t,n);e.recordDroppedEvent("ratelimit_backoff",o,s)}else i.push(t)})),0===i.length)return(0,T.XW)();const r=z(o[0],i),a=t=>{O(r,((n,s)=>{const o=pe(n,s);e.recordDroppedEvent(t,P(s),o)}))};return n.add((()=>t({body:j(r,e.textEncoder)}).then((e=>(void 0!==e.statusCode&&(e.statusCode<200||e.statusCode>=300)&&g.T&&l.vF.warn(`Sentry responded with status code ${e.statusCode} to sent event.`),s=function(e,{statusCode:t,headers:n},s=Date.now()){const o={...e},i=n&&n["x-sentry-rate-limits"],r=n&&n["retry-after"];if(i)for(const e of i.trim().split(",")){const[t,n]=e.split(":",2),i=parseInt(t,10),r=1e3*(isNaN(i)?60:i);if(n)for(const e of n.split(";"))o[e]=s+r;else o.all=s+r}else r?o.all=s+function(e,t=Date.now()){const n=parseInt(`${e}`,10);if(!isNaN(n))return 1e3*n;const s=Date.parse(`${e}`);return isNaN(s)?de:s-t}(r,s):429===t&&(o.all=s+6e4);return o}(s,e),e)),(e=>{throw a("network_error"),e})))).then((e=>e),(e=>{if(e instanceof q)return g.T&&l.vF.error("Skipped sending event because buffer is full."),a("queue_overflow"),(0,T.XW)();throw e}))}return o.__sentry__baseTransport__=!0,{send:o,flush:e=>n.drain(e)}}function pe(e,t){if("event"===t||"transaction"===t)return Array.isArray(e)?e[1]:void 0}var Ie=n(9297);const me={c:class{constructor(e){this._value=e}get weight(){return 1}add(e){this._value+=e}toString(){return`${this._value}`}},g:class{constructor(e){this._last=e,this._min=e,this._max=e,this._sum=e,this._count=1}get weight(){return 5}add(e){this._last=e,ethis._max&&(this._max=e),this._sum+=e,this._count++}toString(){return`${this._last}:${this._min}:${this._max}:${this._sum}:${this._count}`}},d:class{constructor(e){this._value=[e]}get weight(){return this._value.length}add(e){this._value.push(e)}toString(){return this._value.join(":")}},s:class{constructor(e){this.first=e,this._value=new Set([e])}get weight(){return this._value.size}add(e){this._value.add(e)}toString(){return Array.from(this._value).map((e=>"string"==typeof e?function(e){let t=0;for(let n=0;n>>0}(e):e)).join(":")}}};class Ce{constructor(e){this._client=e,this._buckets=new Map,this._interval=setInterval((()=>this.flush()),5e3)}add(e,t,n,s="none",o={},i=(0,Ie.zf)()){const r=Math.floor(i),a=t.replace($,"_"),c=ne(o),l=te(e,a,s,c),g=this._buckets.get(l);g?(g.metric.add(n),g.timestampe));this._client.captureAggregateMetrics(e)}this._buckets.clear()}}close(){clearInterval(this._interval),this.flush()}}const be="MetricsAggregator";function ye(e,t,n,s={}){const o=(0,u.KU)(),i=(0,u.o5)();if(o){if(!o.metricsAggregator)return void(g.T&&l.vF.warn("No metrics aggregator enabled. Please add the MetricsAggregator integration to use metrics APIs"));const{unit:r,tags:a,timestamp:c}=s,{release:d,environment:u}=o.getOptions(),h=i.getTransaction(),p={};d&&(p.release=d),u&&(p.environment=u),h&&(p.transaction=h.name),g.T&&l.vF.log(`Adding value of ${n} to ${e} metric ${t}`),o.metricsAggregator.add(e,t,n,r,{...p,...a},c)}}const fe={increment:function(e,t=1,n){ye("c",e,t,n)},distribution:function(e,t,n){ye("d",e,t,n)},set:function(e,t,n){ye("s",e,t,n)},gauge:function(e,t,n){ye("g",e,t,n)},MetricsAggregator:b(be,(()=>({name:be,setup(e){e.metricsAggregator=new Ce(e)}})))};var Ae=n(7998);function Ze(e,t,n){const s=(0,Ae.Z7)();s&&s.setMeasurement(e,t,n)}var Ge=n(7986),ve=n(2486),Be=n(6954),We=n(5527),Se=n(8402);function Ve(){const e=Se.j.map((e=>{try{return e()}catch(e){return}})).filter((e=>!!e));return 0===e.length&&l.vF.warn("Performance monitoring integrations could not be automatically loaded."),e.filter((e=>!!e.loadDependency()))}var we=n(857),Re=n(9023);class He{constructor(e){this._client=e,this._buckets=new Map,this._bucketsTotalWeight=0,this._interval=setInterval((()=>this._flush()),1e4),this._flushShift=Math.floor(1e4*Math.random()/1e3),this._forceFlush=!1}add(e,t,n,s="none",o={},i=(0,Ie.zf)()){const r=Math.floor(i),a=t.replace($,"_"),c=ne(o),l=te(e,a,s,c);let g=this._buckets.get(l);g?(g.metric.add(n),g.timestamp=1e4&&this.flush()}flush(){this._forceFlush=!0,this._flush()}close(){this._forceFlush=!0,clearInterval(this._interval),this._flush()}_flush(){if(this._forceFlush)return this._forceFlush=!1,this._bucketsTotalWeight=0,this._captureMetrics(this._buckets),void this._buckets.clear();const e=Math.floor((0,Ie.zf)())-10-this._flushShift,t=new Map;for(const[n,s]of this._buckets)s.timestamp<=e&&(t.set(n,s),this._bucketsTotalWeight-=s.metric.weight);for(const[e]of t)this._buckets.delete(e);this._captureMetrics(t)}_captureMetrics(e){if(e.size>0&&this._client.captureAggregateMetrics){const t=Array.from(e).map((([,e])=>e));this._client.captureAggregateMetrics(t)}}}class ke{constructor(e,t){this._client=e,this.flushTimeout=60,this._pendingAggregates={},this._isEnabled=!0,this._intervalId=setInterval((()=>this.flush()),1e3*this.flushTimeout),this._sessionAttrs=t}flush(){const e=this.getSessionAggregates();0!==e.aggregates.length&&(this._pendingAggregates={},this._client.sendSession(e))}getSessionAggregates(){const e=Object.keys(this._pendingAggregates).map((e=>this._pendingAggregates[parseInt(e)])),t={attrs:this._sessionAttrs,aggregates:e};return(0,a.Ce)(t)}close(){clearInterval(this._intervalId),this._isEnabled=!1,this.flush()}incrementSessionStatusCount(){if(!this._isEnabled)return;const e=(0,u.o5)(),t=e.getRequestSession();t&&t.status&&(this._incrementSessionStatusCount(t.status,new Date),e.setRequestSession(void 0))}_incrementSessionStatusCount(e,t){const n=new Date(t).setSeconds(0,0);this._pendingAggregates[n]=this._pendingAggregates[n]||{};const s=this._pendingAggregates[n];switch(s.started||(s.started=new Date(n).toISOString()),e){case"errored":return s.errored=(s.errored||0)+1,s.errored;case"ok":return s.exited=(s.exited||0)+1,s.exited;default:return s.crashed=(s.crashed||0)+1,s.crashed}}}var Ye=n(8444);class Xe extends ae{constructor(e){(0,Ye.U)(),super(e),e._experiments&&e._experiments.metricsAggregator&&(this.metricsAggregator=new He(this))}eventFromException(e,t){return(0,T.XW)(function(e,t,n,s){const o="function"==typeof e?e().getClient():e;let i=n;const r=s&&s.data&&s.data.mechanism||{handled:!0,type:"generic"};let l;if(!(0,V.bJ)(n)){if((0,V.Qd)(n)){const e=o&&o.getOptions().normalizeDepth;l={__serialized__:(0,Y.cd)(n,e)};const t=function(e){if("name"in e&&"string"==typeof e.name){let t=`'${e.name}' captured as exception`;return"message"in e&&"string"==typeof e.message&&(t+=` with message '${e.message}'`),t}return"message"in e&&"string"==typeof e.message?e.message:`Object captured as exception with keys: ${(0,a.HF)(e)}`}(n);i=s&&s.syntheticException||new Error(t),i.message=t}else i=s&&s.syntheticException||new Error(n),i.message=n;r.synthetic=!0}const g={exception:{values:[N(t,i)]}};return l&&(g.extra=l),(0,c.gO)(g,void 0,void 0),(0,c.M6)(g,r),{...g,event_id:s&&s.event_id}}((0,u.KU)(),this._options.stackParser,e,t))}eventFromMessage(e,t="info",n){return(0,T.XW)(function(e,t,n="info",s,o){const i={event_id:s&&s.event_id,level:n,message:t};if(o&&s&&s.syntheticException){const n=X(e,s.syntheticException);n.length&&(i.exception={values:[{value:t,stacktrace:{frames:n}}]})}return i}(this._options.stackParser,e,t,n,this._options.attachStacktrace))}captureException(e,t,n){if(this._options.autoSessionTracking&&this._sessionFlusher&&n){const e=n.getRequestSession();e&&"ok"===e.status&&(e.status="errored")}return super.captureException(e,t,n)}captureEvent(e,t,n){if(this._options.autoSessionTracking&&this._sessionFlusher&&n&&"exception"===(e.type||"exception")&&e.exception&&e.exception.values&&e.exception.values.length>0){const e=n.getRequestSession();e&&"ok"===e.status&&(e.status="errored")}return super.captureEvent(e,t,n)}close(e){return this._sessionFlusher&&this._sessionFlusher.close(),super.close(e)}initSessionFlusher(){const{release:e,environment:t}=this._options;e?this._sessionFlusher=new ke(this,{release:e,environment:t}):g.T&&l.vF.warn("Cannot initialise an instance of SessionFlusher if no release is provided!")}captureCheckIn(e,t,n){const s="checkInId"in e&&e.checkInId?e.checkInId:(0,c.eJ)();if(!this._isEnabled())return g.T&&l.vF.warn("SDK not enabled, will not capture checkin."),s;const o=this.getOptions(),{release:i,environment:r,tunnel:d}=o,u={check_in_id:s,monitor_slug:e.monitorSlug,status:e.status,release:i,environment:r};"duration"in e&&(u.duration=e.duration),t&&(u.monitor_config={schedule:t.schedule,checkin_margin:t.checkinMargin,max_runtime:t.maxRuntime,timezone:t.timezone});const[h,p]=this._getTraceInfoFromScope(n);p&&(u.contexts={trace:p});const I=function(e,t,n,s,o){const i={sent_at:(new Date).toISOString()};n&&n.sdk&&(i.sdk={name:n.sdk.name,version:n.sdk.version}),s&&o&&(i.dsn=x(o)),t&&(i.trace=(0,a.Ce)(t));const r=function(e){return[{type:"check_in"},e]}(e);return z(i,[r])}(u,h,this.getSdkMetadata(),d,this.getDsn());return g.T&&l.vF.info("Sending checkin:",e.monitorSlug,e.status),this._sendEnvelope(I),s}_captureRequestSession(){this._sessionFlusher?this._sessionFlusher.incrementSessionStatusCount():g.T&&l.vF.warn("Discarded request mode session because autoSessionTracking option was disabled")}_prepareEvent(e,t,n,s){return this._options.platform&&(e.platform=e.platform||this._options.platform),this._options.runtime&&(e.contexts={...e.contexts,runtime:(e.contexts||{}).runtime||this._options.runtime}),this._options.serverName&&(e.server_name=e.server_name||this._options.serverName),super._prepareEvent(e,t,n,s)}_getTraceInfoFromScope(e){if(!e)return[void 0,void 0];const t=e.getSpan();if(t)return[t.transaction?t.transaction.getDynamicSamplingContext():void 0,t.getTraceContext()];const{traceId:n,spanId:s,parentSpanId:o,dsc:i}=e.getPropagationContext(),r={trace_id:n,span_id:s,parent_span_id:o};return i?[i,r]:[(0,oe.l)(n,this,e),r]}}class Ne extends Xe{constructor(e){e._metadata=e._metadata||{},e._metadata.sdk=e._metadata.sdk||{name:"sentry.javascript.node",packages:[{name:"npm:@sentry/node",version:Ge.M}],version:Ge.M},e.transportOptions={textEncoder:new Re.TextEncoder,...e.transportOptions},super({...e,platform:"node",runtime:{name:"node",version:global.process.version},serverName:e.serverName||global.process.env.SENTRY_NAME||we.hostname()})}}function _e(e,t){return null!=e?e:t()}var Je=n(8611),Fe=n(5692),Ke=n(2203),xe=n(7016),Ee=n(3106),Te=n(2288);const ze=32768;function Ue(e){let t;try{t=new xe.URL(e.url)}catch(t){return(0,l.pq)((()=>{console.warn("[@sentry/node]: Invalid dsn or tunnel option, will not send any events. The tunnel option must be a full URL when used.")})),he(e,(()=>Promise.resolve({})))}const n="https:"===t.protocol,s=function(e,t){const{no_proxy:n}=process.env;return n&&n.split(",").some((t=>e.host.endsWith(t)||e.hostname.endsWith(t)))?void 0:t}(t,e.proxy||(n?process.env.https_proxy:void 0)||process.env.http_proxy),o=n?Fe:Je,i=void 0!==e.keepAlive&&e.keepAlive,r=s?new Te.HttpsProxyAgent(s):new o.Agent({keepAlive:i,maxSockets:30,timeout:2e3}),a=function(e,t,n){const{hostname:s,pathname:o,port:i,protocol:r,search:a}=new xe.URL(e.url);return function(c){return new Promise(((l,g)=>{let d=function(e){return new Ke.Readable({read(){this.push(e),this.push(null)}})}(c.body);const u={...e.headers};c.body.length>ze&&(u["content-encoding"]="gzip",d=d.pipe((0,Ee.createGzip)()));const h=t.request({method:"POST",agent:n,headers:u,hostname:s,path:`${o}${a}`,port:i,protocol:r,ca:e.caCerts},(e=>{e.on("data",(()=>{})),e.on("end",(()=>{})),e.setEncoding("utf8");const t=_e(e.headers["retry-after"],(()=>null)),n=_e(e.headers["x-sentry-rate-limits"],(()=>null));l({statusCode:e.statusCode,headers:{"retry-after":t,"x-sentry-rate-limits":Array.isArray(n)?n[0]:n}})}));h.on("error",g),d.pipe(h)}))}}(e,_e(e.httpModule,(()=>o)),r);return he(e,a)}var Oe=n(853),Le=n(1040);const je={include:{cookies:!0,data:!0,headers:!0,ip:!1,query_string:!0,url:!0,user:{id:!0,username:!0,email:!0}},transactionNamingScheme:"methodPath"},Qe="RequestData",Me=b(Qe,((e={})=>{const t=Le.GY,n={...je,...e,include:{method:!0,...je.include,...e.include,user:e.include&&"boolean"==typeof e.include.user?e.include.user:{...je.include.user,...(e.include||{}).user}}};return{name:Qe,processEvent(e,s,o){const{transactionNamingScheme:i}=n,{sdkProcessingMetadata:r={}}=e,a=r.request;if(!a)return e;const c=r.requestDataOptionsFromExpressHandler||r.requestDataOptionsFromGCPWrapper||function(e){const{transactionNamingScheme:t,include:{ip:n,user:s,...o}}=e,i=[];for(const[e,t]of Object.entries(o))t&&i.push(e);let r;if(void 0===s)r=!0;else if("boolean"==typeof s)r=s;else{const e=[];for(const[t,n]of Object.entries(s))n&&e.push(t);r=e}return{include:{ip:n,user:r,request:0!==i.length?i:void 0,transaction:t}}}(n),l=t(e,a,c);if("transaction"===e.type||"handler"===i)return l;const g=a._sentryTransaction;if(g){const e="sentry.javascript.nextjs"===function(e){try{return e.getOptions()._metadata.sdk.name}catch(e){return}}(o)?g.name.startsWith("/api"):"path"!==i,[t]=(0,Le.Up)(a,{path:!0,method:e,customRoute:g.name});l.transaction=t}return l}}}));var Pe=n(7930),De=n(6341),qe=n(6524),$e=n(3245);const et=require("domain");function tt(){return et.active}function nt(){const e=tt();if(e)return(0,h.TF)(e),(0,h.Me)(e)}function st(e,t){const n=tt();if(n&&(0,Oe.z)([t,"optionalAccess",e=>e.reuseExisting]))return e();const s=et.create(),o=function(e){const t={};return(0,h.TF)(t,e),(0,h.Me)(t)}(n?(0,h.Me)(n):void 0);return(0,h.lq)(s,o),s.bind((()=>e()))()}const ot=require("async_hooks");let it;function rt(){$e.S.major&&$e.S.major>=14?function(){function e(){return it.getStore()}it||(it=new ot.AsyncLocalStorage),(0,h.nX)({getCurrentHub:e,runWithAsyncContext:function(t,n){const s=e();if(s&&(0,Oe.z)([n,"optionalAccess",e=>e.reuseExisting]))return t();const o=function(e){const t={};return(0,h.TF)(t,e),(0,h.Me)(t)}(s);return it.run(o,(()=>t()))}})}():(0,h.nX)({getCurrentHub:nt,runWithAsyncContext:st})}var at=n(718);function ct(){"console"in De.OW&&l.Ow.forEach((function(e){e in De.OW.console&&(0,a.GS)(De.OW.console,e,(function(t){return l.Z9[e]=t,function(...t){const n={args:t,level:e};(0,at.aj)("console",n);const s=l.Z9[e];s&&s.apply(De.OW.console,t)}}))}))}const lt=["fatal","error","warning","log","info","debug"];function gt(e){return"warn"===e?"warning":lt.includes(e)?e:"log"}class dt{constructor(){dt.prototype.__init.call(this)}static __initStatic(){this.id="Console"}__init(){this.name=dt.id}setupOnce(){}setup(e){!function(t){const n="console";(0,at.s5)(n,(({args:t,level:n})=>{(0,u.KU)()===e&&(0,u.ZQ)({category:"console",level:gt(n),message:Re.format.apply(void 0,t)},{input:[...t],level:n})})),(0,at.AS)(n,ct)}()}}dt.__initStatic();var ut=n(1351),ht=n(5019),pt=n(5584);const It="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__;function mt(e){const{protocol:t,hostname:n,port:s}=yt(e),o=e.pathname||"/";return`${t}//${e.auth?function(e){const[t,n]=e.split(":");return`${t?"[Filtered]":""}:${n?"[Filtered]":""}@`}(e.auth):""}${n}${s}${o}`}function Ct(e,t,n){if(!e)return e;let[s,o]=e.split(" ");return t.host&&!t.protocol&&(t.protocol=(0,Oe.z)([n,"optionalAccess",e=>e.agent,"optionalAccess",e=>e.protocol]),o=mt(t)),(0,Oe.z)([o,"optionalAccess",e=>e.startsWith,"call",e=>e("///")])&&(o=o.slice(2)),`${s} ${o}`}function bt(e){const t={protocol:e.protocol,hostname:"string"==typeof e.hostname&&e.hostname.startsWith("[")?e.hostname.slice(1,-1):e.hostname,hash:e.hash,search:e.search,pathname:e.pathname,path:`${e.pathname||""}${e.search||""}`,href:e.href};return""!==e.port&&(t.port=Number(e.port)),(e.username||e.password)&&(t.auth=`${e.username}:${e.password}`),t}function yt(e){const t=e.protocol||"",n=e.hostname||e.host||"";return{protocol:t,hostname:n,port:!e.port||80===e.port||443===e.port||/^(.*):(\d+)$/.test(n)?"":`:${e.port}`}}class ft{static __initStatic(){this.id="Http"}__init(){this.name=ft.id}constructor(e={}){ft.prototype.__init.call(this),this._breadcrumbs=void 0===e.breadcrumbs||e.breadcrumbs,this._tracing=e.tracing?!0===e.tracing?{}:e.tracing:void 0}setupOnce(e,t){if(!this._breadcrumbs&&!this._tracing)return;const s=(0,Oe.z)([t,"call",e=>e(),"access",e=>e.getClient,"call",e=>e(),"optionalAccess",e=>e.getOptions,"call",e=>e()]);if(s&&"sentry"!==s.instrumenter)return void(It&&l.vF.log("HTTP Integration is skipped because of instrumenter configuration."));const o=(0,Oe.z)([this,"access",e=>e._tracing,"optionalAccess",e=>e.shouldCreateSpanForRequest])||(0,Oe.z)([s,"optionalAccess",e=>e.shouldCreateSpanForRequest]),i=(0,Oe.z)([s,"optionalAccess",e=>e.tracePropagationTargets])||(0,Oe.z)([this,"access",e=>e._tracing,"optionalAccess",e=>e.tracePropagationTargets]),r=n(8611),c=At(r,this._breadcrumbs,o,i);if((0,a.GS)(r,"get",c),(0,a.GS)(r,"request",c),$e.S.major&&$e.S.major>8){const e=n(5692),t=At(e,this._breadcrumbs,o,i);(0,a.GS)(e,"get",t),(0,a.GS)(e,"request",t)}}}function At(e,t,n,s){const o=new ht.G(100),i=new ht.G(100);function r(e,t,n,s){(0,h.BF)().getIntegration(ft)&&(0,u.ZQ)({category:"http",data:{status_code:s&&s.statusCode,...t},type:"http"},{event:e,request:n,response:s})}return function(a){return function(...c){const g=function(e,t){let n,s;if("function"==typeof t[t.length-1]&&(n=t.pop()),"string"==typeof t[0])s=bt(new xe.URL(t[0]));else if(t[0]instanceof xe.URL)s=bt(t[0]);else{s=t[0];try{const e=new xe.URL(s.path||"",`${s.protocol||"http:"}//${s.hostname}`);s={pathname:e.pathname,search:e.search,hash:e.hash,...s}}catch(e){}}return 2===t.length&&(s={...s,...t[1]}),void 0===s.protocol&&($e.S.major&&$e.S.major>8?s.protocol=(0,Oe.z)([(0,Oe.z)([e,"optionalAccess",e=>e.globalAgent]),"optionalAccess",e=>e.protocol])||(0,Oe.z)([s.agent,"optionalAccess",e=>e.protocol])||(0,Oe.z)([s._defaultAgent,"optionalAccess",e=>e.protocol]):s.protocol=(0,Oe.z)([s.agent,"optionalAccess",e=>e.protocol])||(0,Oe.z)([s._defaultAgent,"optionalAccess",e=>e.protocol])||(0,Oe.z)([(0,Oe.z)([e,"optionalAccess",e=>e.globalAgent]),"optionalAccess",e=>e.protocol])),n?[s,n]:[s]}(e,c),d=g[0],h=function(e){const{protocol:t,hostname:n,port:s}=yt(e);return`${t}//${n}${s}${e.path?e.path:"/"}`}(d),p=mt(d);if((0,ut.A)(p,(0,u.KU)()))return a.apply(e,g);const I=(0,u.o5)(),m=I.getSpan(),C=function(e,t){const n={url:e,"http.method":t.method||"GET"};return t.hash&&(n["http.fragment"]=t.hash.substring(1)),t.search&&(n["http.query"]=t.search.substring(1)),n}(p,d),b=(e=>{if(void 0===n)return!0;const t=o.get(e);if(void 0!==t)return t;const s=n(e);return o.set(e,s),s})(h)?(0,Oe.z)([m,"optionalAccess",e=>e.startChild,"call",e=>e({op:"http.client",origin:"auto.http.node.http",description:`${C["http.method"]} ${C.url}`,data:C})]):void 0;if((e=>{if(void 0===s)return!0;const t=i.get(e);if(void 0!==t)return t;const n=(0,Z.Xr)(e,s);return i.set(e,n),n})(h))if(b){const e=b.toTraceparent(),t=(0,Oe.z)([b,"optionalAccess",e=>e.transaction,"optionalAccess",e=>e.getDynamicSamplingContext,"call",e=>e()]);Zt(d,p,e,t)}else{const e=(0,u.KU)(),{traceId:t,sampled:n,dsc:s}=I.getPropagationContext(),o=(0,qe.TC)(t,void 0,n),i=s||(e?(0,oe.l)(t,e,I):void 0);Zt(d,p,o,i)}else It&&l.vF.log(`[Tracing] Not adding sentry-trace header to outgoing request (${p}) due to mismatching tracePropagationTargets option.`);return a.apply(e,g).once("response",(function(e){t&&r("response",C,this,e),b&&(e.statusCode&&b.setHttpStatus(e.statusCode),b.description=Ct(b.description,d,this),b.end())})).once("error",(function(){t&&r("error",C,this),b&&(b.setHttpStatus(500),b.description=Ct(b.description,d,this),b.end())}))}}}function Zt(e,t,n,s){if((e.headers||{})["sentry-trace"])return;It&&l.vF.log(`[Tracing] Adding sentry-trace header ${n} to outgoing request to "${t}": `);const o=(0,pt.De)(s),i=o&&o.length>0?function(e,t){return e.headers&&e.headers.baggage?t?Array.isArray(e.headers.baggage)?[...e.headers.baggage,t]:[e.headers.baggage,t]:e.headers.baggage:t}(e,o):void 0;e.headers={...e.headers,"sentry-trace":n,...i&&{baggage:i}}}ft.__initStatic();function Gt(e){(0,l.pq)((()=>{console.error(e)}));const t=(0,u.KU)();void 0===t&&(It&&l.vF.warn("No NodeClient was defined, we are exiting the process now."),global.process.exit(1));const n=t.getOptions(),s=n&&n.shutdownTimeout&&n.shutdownTimeout>0&&n.shutdownTimeout||2e3;t.close(s).then((e=>{e||It&&l.vF.warn("We reached the timeout for emptying the request buffer, still exiting now!"),global.process.exit(1)}),(e=>{It&&l.vF.error(e)}))}class vt{static __initStatic(){this.id="OnUncaughtException"}__init(){this.name=vt.id}constructor(e={}){vt.prototype.__init.call(this),vt.prototype.__init2.call(this),this._options={exitEvenIfOtherHandlersAreRegistered:!0,...e}}__init2(){this.handler=()=>{}}setupOnce(){}setup(e){global.process.on("uncaughtException",function(e,t){let n,s=!1,o=!1,i=!1;const r=e.getOptions();return Object.assign((a=>{let c=Gt;t.onFatalError?c=t.onFatalError:r.onFatalError&&(c=r.onFatalError);const g=0===global.process.listeners("uncaughtException").reduce(((e,t)=>"domainUncaughtExceptionClear"===t.name||t.tag&&"sentry_tracingErrorCallback"===t.tag||t._errorHandler?e:e+1),0),d=t.exitEvenIfOtherHandlersAreRegistered||g;s?d&&(i?(It&&l.vF.warn("uncaught exception after calling fatal error shutdown callback - this is bad! forcing shutdown"),Gt(a)):o||(o=!0,setTimeout((()=>{i||(i=!0,c(n,a))}),2e3))):(n=a,s=!0,(0,u.KU)()===e&&(0,u.Cp)(a,{originalException:a,captureContext:{level:"fatal"},mechanism:{handled:!1,type:"onuncaughtexception"}}),!i&&d&&(i=!0,c(a)))}),{_errorHandler:!0})}(e,this._options))}}vt.__initStatic();class Bt{static __initStatic(){this.id="OnUnhandledRejection"}__init(){this.name=Bt.id}constructor(e={mode:"warn"}){this._options=e,Bt.prototype.__init.call(this)}setupOnce(){}setup(e){global.process.on("unhandledRejection",function(e,t){return function(n,s){(0,u.KU)()===e&&((0,u.Cp)(n,{originalException:s,captureContext:{extra:{unhandledPromiseRejection:!0}},mechanism:{handled:!1,type:"onunhandledrejection"}}),function(e,t){const n="This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:";"warn"===t.mode?(0,l.pq)((()=>{console.warn(n),console.error(e&&e.stack?e.stack:e)})):"strict"===t.mode&&((0,l.pq)((()=>{console.warn(n)})),Gt(e))}(n,t))}}(e,this._options))}}Bt.__initStatic();const Wt=require("fs");var St=n(6928);let Vt;function wt(){const e=n.c[n.s]&&n.c[n.s].paths||[],t=function(){try{return n.c?Object.keys(n.c):[]}catch(e){return[]}}(),s={},o={};return t.forEach((t=>{let n=t;const i=()=>{const t=n;if(n=(0,St.dirname)(t),!n||t===n||o[t])return;if(e.indexOf(n)<0)return i();const r=(0,St.join)(t,"package.json");if(o[t]=!0,!(0,Wt.existsSync)(r))return i();try{const e=JSON.parse((0,Wt.readFileSync)(r,"utf8"));s[e.name]=e.version}catch(e){}};i()})),s}class Rt{constructor(){Rt.prototype.__init.call(this)}static __initStatic(){this.id="Modules"}__init(){this.name=Rt.id}setupOnce(e,t){}processEvent(e){return{...e,modules:{...e.modules,...(Vt||(Vt=wt()),Vt)}}}}Rt.__initStatic();const Ht=new ht.G(100);class kt{static __initStatic(){this.id="ContextLines"}__init(){this.name=kt.id}constructor(e={}){this._options=e,kt.prototype.__init.call(this)}get _contextLines(){return void 0!==this._options.frameContextLines?this._options.frameContextLines:7}setupOnce(e,t){}processEvent(e){return this.addSourceContext(e)}async addSourceContext(e){const t={},n=[];if(this._contextLines>0&&(0,Oe.z)([e,"access",e=>e.exception,"optionalAccess",e=>e.values]))for(const s of e.exception.values)if((0,Oe.z)([s,"access",e=>e.stacktrace,"optionalAccess",e=>e.frames]))for(let e=s.stacktrace.frames.length-1;e>=0;e--){const o=s.stacktrace.frames[e];!o.filename||t[o.filename]||Ht.get(o.filename)||(n.push(Yt(o.filename)),t[o.filename]=1)}if(n.length>0&&await Promise.all(n),this._contextLines>0&&(0,Oe.z)([e,"access",e=>e.exception,"optionalAccess",e=>e.values]))for(const t of e.exception.values)t.stacktrace&&t.stacktrace.frames&&await this.addSourceContextToFrames(t.stacktrace.frames);return e}addSourceContextToFrames(e){for(const t of e)if(t.filename&&void 0===t.context_line){const e=Ht.get(t.filename);if(e)try{(0,c.db)(e,t,this._contextLines)}catch(e){}}}}async function Yt(e){const t=Ht.get(e);if(null===t)return null;if(void 0!==t)return t;let n=null;try{n=(await(s=e,new Promise(((e,t)=>{(0,Wt.readFile)(s,"utf8",((n,s)=>{n?t(n):e(s)}))})))).split("\n")}catch(e){}var s;return Ht.set(e,n),n}kt.__initStatic();var Xt=n(5317);const Nt=(0,Re.promisify)(Wt.readFile),_t=(0,Re.promisify)(Wt.readdir);class Jt{static __initStatic(){this.id="Context"}__init(){this.name=Jt.id}constructor(e={app:!0,os:!0,device:!0,culture:!0,cloudResource:!0}){this._options=e,Jt.prototype.__init.call(this)}setupOnce(e,t){}processEvent(e){return this.addContext(e)}async addContext(e){void 0===this._cachedContext&&(this._cachedContext=this._getContexts());const t=(n=await this._cachedContext,(0,Oe.z)([n,"optionalAccess",e=>e.app,"optionalAccess",e=>e.app_memory])&&(n.app.app_memory=process.memoryUsage().rss),(0,Oe.z)([n,"optionalAccess",e=>e.device,"optionalAccess",e=>e.free_memory])&&(n.device.free_memory=we.freemem()),n);var n;return e.contexts={...e.contexts,app:{...t.app,...(0,Oe.z)([e,"access",e=>e.contexts,"optionalAccess",e=>e.app])},os:{...t.os,...(0,Oe.z)([e,"access",e=>e.contexts,"optionalAccess",e=>e.os])},device:{...t.device,...(0,Oe.z)([e,"access",e=>e.contexts,"optionalAccess",e=>e.device])},culture:{...t.culture,...(0,Oe.z)([e,"access",e=>e.contexts,"optionalAccess",e=>e.culture])},cloud_resource:{...t.cloud_resource,...(0,Oe.z)([e,"access",e=>e.contexts,"optionalAccess",e=>e.cloud_resource])}},e}async _getContexts(){const e={};if(this._options.os&&(e.os=await async function(){const e=we.platform();switch(e){case"darwin":return async function(){const e={kernel_version:we.release(),name:"Mac OS X",version:"10."+(Number(we.release().split(".")[0])-4)};try{const t=await new Promise(((e,t)=>{(0,Xt.execFile)("/usr/bin/sw_vers",((n,s)=>{n?t(n):e(s)}))}));e.name=Et(/^ProductName:\s+(.*)$/m,t),e.version=Et(/^ProductVersion:\s+(.*)$/m,t),e.build=Et(/^BuildVersion:\s+(.*)$/m,t)}catch(e){}return e}();case"linux":return async function(){const e={kernel_version:we.release(),name:"Linux"};try{const t=await _t("/etc"),n=Kt.find((e=>t.includes(e.name)));if(!n)return e;const s=(0,St.join)("/etc",n.name),o=(await Nt(s,{encoding:"utf-8"})).toLowerCase(),{distros:i}=n;e.name=i.find((e=>o.indexOf(Tt(e))>=0))||i[0];const r=Tt(e.name);e.version=xt[r](o)}catch(e){}return e}();default:return{name:Ft[e]||e,version:we.release()}}}()),this._options.app&&(e.app=function(){const e=process.memoryUsage().rss;return{app_start_time:new Date(Date.now()-1e3*process.uptime()).toISOString(),app_memory:e}}()),this._options.device&&(e.device=function(e){const t={};let n;try{n=we.uptime&&we.uptime()}catch(e){}if("number"==typeof n&&(t.boot_time=new Date(Date.now()-1e3*n).toISOString()),t.arch=we.arch(),(!0===e||e.memory)&&(t.memory_size=we.totalmem(),t.free_memory=we.freemem()),!0===e||e.cpu){const e=we.cpus();if(e&&e.length){const n=e[0];t.processor_count=e.length,t.cpu_description=n.model,t.processor_frequency=n.speed}}return t}(this._options.device)),this._options.culture){const t=function(){try{if("string"!=typeof process.versions.icu)return;const e=new Date(9e8);if("enero"===new Intl.DateTimeFormat("es",{month:"long"}).format(e)){const e=Intl.DateTimeFormat().resolvedOptions();return{locale:e.locale,timezone:e.timeZone}}}catch(e){}}();t&&(e.culture=t)}return this._options.cloudResource&&(e.cloud_resource=process.env.VERCEL?{"cloud.provider":"vercel","cloud.region":process.env.VERCEL_REGION}:process.env.AWS_REGION?{"cloud.provider":"aws","cloud.region":process.env.AWS_REGION,"cloud.platform":process.env.AWS_EXECUTION_ENV}:process.env.GCP_PROJECT?{"cloud.provider":"gcp"}:process.env.ALIYUN_REGION_ID?{"cloud.provider":"alibaba_cloud","cloud.region":process.env.ALIYUN_REGION_ID}:process.env.WEBSITE_SITE_NAME&&process.env.REGION_NAME?{"cloud.provider":"azure","cloud.region":process.env.REGION_NAME}:process.env.IBM_CLOUD_REGION?{"cloud.provider":"ibm_cloud","cloud.region":process.env.IBM_CLOUD_REGION}:process.env.TENCENTCLOUD_REGION?{"cloud.provider":"tencent_cloud","cloud.region":process.env.TENCENTCLOUD_REGION,"cloud.account.id":process.env.TENCENTCLOUD_APPID,"cloud.availability_zone":process.env.TENCENTCLOUD_ZONE}:process.env.NETLIFY?{"cloud.provider":"netlify"}:process.env.FLY_REGION?{"cloud.provider":"fly.io","cloud.region":process.env.FLY_REGION}:process.env.DYNO?{"cloud.provider":"heroku"}:void 0),e}}Jt.__initStatic();const Ft={aix:"IBM AIX",freebsd:"FreeBSD",openbsd:"OpenBSD",sunos:"SunOS",win32:"Windows"},Kt=[{name:"fedora-release",distros:["Fedora"]},{name:"redhat-release",distros:["Red Hat Linux","Centos"]},{name:"redhat_version",distros:["Red Hat Linux"]},{name:"SuSE-release",distros:["SUSE Linux"]},{name:"lsb-release",distros:["Ubuntu Linux","Arch Linux"]},{name:"debian_version",distros:["Debian"]},{name:"debian_release",distros:["Debian"]},{name:"arch-release",distros:["Arch Linux"]},{name:"gentoo-release",distros:["Gentoo Linux"]},{name:"novell-release",distros:["SUSE Linux"]},{name:"alpine-release",distros:["Alpine Linux"]}],xt={alpine:e=>e,arch:e=>Et(/distrib_release=(.*)/,e),centos:e=>Et(/release ([^ ]+)/,e),debian:e=>e,fedora:e=>Et(/release (..)/,e),mint:e=>Et(/distrib_release=(.*)/,e),red:e=>Et(/release ([^ ]+)/,e),suse:e=>Et(/VERSION = (.*)\n/,e),ubuntu:e=>Et(/distrib_release=(.*)/,e)};function Et(e,t){const n=e.exec(t);return n?n[1]:void 0}function Tt(e){return e.split(" ")[0].toLowerCase()}function zt(e){let t=[],n=!1;function s(s){t=[],n||(n=!0,e(s))}return t.push(s),{add:function(e){t.push(e)},next:function(e){const n=t.pop()||s;try{n(e)}catch(t){s(e)}}}}class Ut{constructor(){const{Session:e}=n(264);this._session=new e}configureAndConnect(e,t){this._session.connect(),this._session.on("Debugger.paused",(t=>{e(t,(()=>{this._session.post("Debugger.resume")}))})),this._session.post("Debugger.enable"),this._session.post("Debugger.setPauseOnExceptions",{state:t?"all":"uncaught"})}setPauseOnExceptions(e){this._session.post("Debugger.setPauseOnExceptions",{state:e?"all":"uncaught"})}getLocalVariables(e,t){this._getProperties(e,(e=>{const{add:n,next:s}=zt(t);for(const t of e)if((0,Oe.z)([t,"optionalAccess",e=>e.value,"optionalAccess",e=>e.objectId])&&"Array"===(0,Oe.z)([t,"optionalAccess",e=>e.value,"access",e=>e.className])){const e=t.value.objectId;n((n=>this._unrollArray(e,t.name,n,s)))}else if((0,Oe.z)([t,"optionalAccess",e=>e.value,"optionalAccess",e=>e.objectId])&&"Object"===(0,Oe.z)([t,"optionalAccess",e=>e.value,"optionalAccess",e=>e.className])){const e=t.value.objectId;n((n=>this._unrollObject(e,t.name,n,s)))}else((0,Oe.z)([t,"optionalAccess",e=>e.value,"optionalAccess",e=>e.value])||(0,Oe.z)([t,"optionalAccess",e=>e.value,"optionalAccess",e=>e.description]))&&n((e=>this._unrollOther(t,e,s)));s({})}))}_getProperties(e,t){this._session.post("Runtime.getProperties",{objectId:e,ownProperties:!0},((e,n)=>{t(e?[]:n.result)}))}_unrollArray(e,t,n,s){this._getProperties(e,(e=>{n[t]=e.filter((e=>"length"!==e.name&&!isNaN(parseInt(e.name,10)))).sort(((e,t)=>parseInt(e.name,10)-parseInt(t.name,10))).map((e=>(0,Oe.z)([e,"optionalAccess",e=>e.value,"optionalAccess",e=>e.value]))),s(n)}))}_unrollObject(e,t,n,s){this._getProperties(e,(e=>{n[t]=e.map((e=>[e.name,(0,Oe.z)([e,"optionalAccess",e=>e.value,"optionalAccess",e=>e.value])])).reduce(((e,[t,n])=>(e[t]=n,e)),{}),s(n)}))}_unrollOther(e,t,n){(0,Oe.z)([e,"optionalAccess",e=>e.value,"optionalAccess",e=>e.value])?t[e.name]=e.value.value:(0,Oe.z)([e,"optionalAccess",e=>e.value,"optionalAccess",e=>e.description])&&"function"!==(0,Oe.z)([e,"optionalAccess",e=>e.value,"optionalAccess",e=>e.type])&&(t[e.name]=`<${e.value.description}>`),n(t)}}function Ot(e){return void 0!==e&&["","?",""].includes(e)}function Lt(e){if(void 0!==e)return e.slice(-10).reduce(((e,t)=>`${e},${t.function},${t.lineno},${t.colno}`),"")}class jt{static __initStatic(){this.id="LocalVariables"}__init(){this.name=jt.id}__init2(){this._cachedFrames=new ht.G(20)}__init3(){this._shouldProcessEvent=!1}constructor(e={},t=function(){try{return new Ut}catch(e){return}}()){this._options=e,this._session=t,jt.prototype.__init.call(this),jt.prototype.__init2.call(this),jt.prototype.__init3.call(this)}setupOnce(e,t){}setup(e){const t=e.getOptions();if(this._session&&t.includeLocalVariables){if(($e.S.major||0)<18)return void l.vF.log("The `LocalVariables` integration is only supported on Node >= v18.");const e=!1!==this._options.captureAllExceptions;if(this._session.configureAndConnect(((e,n)=>this._handlePaused(t.stackParser,e,n)),e),e){const e=this._options.maxExceptionsPerSecond||50;this._rateLimiter=function(e,t,n){let s=0,o=5,i=0;return setInterval((()=>{0===i?s>e&&(o*=2,n(o),o>86400&&(o=86400),i=o):(i-=1,0===i&&t()),s=0}),1e3).unref(),()=>{s+=1}}(e,(()=>{l.vF.log("Local variables rate-limit lifted."),(0,Oe.z)([this,"access",e=>e._session,"optionalAccess",e=>e.setPauseOnExceptions,"call",e=>e(!0)])}),(e=>{l.vF.log(`Local variables rate-limit exceeded. Disabling capturing of caught exceptions for ${e} seconds.`),(0,Oe.z)([this,"access",e=>e._session,"optionalAccess",e=>e.setPauseOnExceptions,"call",e=>e(!1)])}))}this._shouldProcessEvent=!0}}processEvent(e){return this._shouldProcessEvent?this._addLocalVariables(e):e}_handlePaused(e,{params:{reason:t,data:n,callFrames:s}},o){if("exception"!==t&&"promiseRejection"!==t)return void o();(0,Oe.z)([this,"access",e=>e._rateLimiter,"optionalCall",e=>e()]);const i=function(e,t){if(void 0!==t)return Lt(e(t,1))}(e,(0,Oe.z)([n,"optionalAccess",e=>e.description]));if(null==i)return void o();const{add:r,next:a}=zt((e=>{this._cachedFrames.set(i,e),o()}));for(let e=0;e"local"===e.type)),c="global"!==o.className&&o.className?`${o.className}.${n}`:n;if(void 0===(0,Oe.z)([i,"optionalAccess",e=>e.object,"access",e=>e.objectId]))r((t=>{t[e]={function:c},a(t)}));else{const t=i.object.objectId;r((n=>(0,Oe.z)([this,"access",e=>e._session,"optionalAccess",e=>e.getLocalVariables,"call",s=>s(t,(t=>{n[e]={function:c,vars:t},a(n)}))])))}}a([])}_addLocalVariables(e){for(const t of(0,Oe.z)([e,"optionalAccess",e=>e.exception,"optionalAccess",e=>e.values])||[])this._addLocalVariablesToException(t);return e}_addLocalVariablesToException(e){const t=Lt((0,Oe.z)([e,"optionalAccess",e=>e.stacktrace,"optionalAccess",e=>e.frames]));if(void 0===t)return;const n=this._cachedFrames.remove(t);if(void 0===n)return;const s=(0,Oe.z)([e,"access",e=>e.stacktrace,"optionalAccess",e=>e.frames,"optionalAccess",e=>e.length])||0;for(let t=0;te.stacktrace,"optionalAccess",e=>e.frames,"optionalAccess",e=>e[r]])||!n[t])break;void 0!==n[t].vars&&!1!==e.stacktrace.frames[r].in_app&&((o=e.stacktrace.frames[r].function)===(i=n[t].function)||Ot(o)&&Ot(i))&&(e.stacktrace.frames[r].vars=n[t].vars)}var o,i}}jt.__initStatic();var Qt=n(3278);class Mt{static __initStatic(){this.id="Spotlight"}__init(){this.name=Mt.id}constructor(e){Mt.prototype.__init.call(this),this._options={sidecarUrl:(0,Oe.z)([e,"optionalAccess",e=>e.sidecarUrl])||"http://localhost:8969/stream"}}setupOnce(){}setup(e){"object"==typeof process&&process.env&&l.vF.warn("[Spotlight] It seems you're not in dev mode. Do you really want to have Spotlight enabled?"),function(e,t){const n=function(e){try{return new xe.URL(`${e}`)}catch(t){return void l.vF.warn(`[Spotlight] Invalid sidecar URL: ${e}`)}}(t.sidecarUrl);if(!n)return;let s=0;"function"==typeof e.on?e.on("beforeEnvelope",(e=>{if(s>3)return void l.vF.warn("[Spotlight] Disabled Sentry -> Spotlight integration due to too many failed requests");const t=j(e),o=Je.request({method:"POST",path:n.pathname,hostname:n.hostname,port:n.port,headers:{"Content-Type":"application/x-sentry-envelope"}},(e=>{e.on("data",(()=>{})),e.on("end",(()=>{})),e.setEncoding("utf8")}));o.on("error",(()=>{s++,l.vF.warn("[Spotlight] Failed to send envelope to Spotlight Sidecar")})),o.write(t),o.end()})):l.vF.warn("[Spotlight] Cannot connect to spotlight due to missing method on SDK client (`client.on`)")}(e,this._options)}}Mt.__initStatic();const Pt="\\"===St.sep;function Dt(e,t=Pt){if(!e)return;const s=t?e.replace(/^[A-Z]:/,"").replace(/\\/g,"/"):e;let{root:o,dir:i,base:r,ext:a}=St.posix.parse(s);const c=`${n.c[n.s]&&n.c[n.s].filename&&i||global.process.cwd()}/`;let l=r;".js"!==a&&".mjs"!==a&&".cjs"!==a||(l=l.slice(0,-1*a.length)),o||i||(i=".");let g=i.lastIndexOf("/node_modules/");if(g>-1)return`${i.slice(g+14).replace(/\//g,".")}:${l}`;if(g=`${i}/`.lastIndexOf(c,0),0===g){let e=i.slice(c.length).replace(/\//g,".");return e&&(e+=":"),e+=l,e}return l}const qt=[new W,new A,new J,new dt,new ft,new Qt.h,new vt,new Bt,new kt,new jt,new Jt,new Rt,new Me];function $t(e={}){const t=(0,h.EU)();rt();const n=(0,Oe.z)([t,"access",e=>e.__SENTRY__,"optionalAccess",e=>e.integrations])||[];e.defaultIntegrations=!1===e.defaultIntegrations?[]:[...Array.isArray(e.defaultIntegrations)?e.defaultIntegrations:qt,...n],void 0===e.dsn&&process.env.SENTRY_DSN&&(e.dsn=process.env.SENTRY_DSN);const s=process.env.SENTRY_TRACES_SAMPLE_RATE;if(void 0===e.tracesSampleRate&&s){const t=parseFloat(s);isFinite(t)&&(e.tracesSampleRate=t)}if(void 0===e.release){const t=tn();void 0!==t?e.release=t:e.autoSessionTracking=!1}void 0===e.environment&&process.env.SENTRY_ENVIRONMENT&&(e.environment=process.env.SENTRY_ENVIRONMENT),void 0===e.autoSessionTracking&&void 0!==e.dsn&&(e.autoSessionTracking=!0),void 0===e.instrumenter&&(e.instrumenter="sentry");const o={...e,stackParser:(0,Pe.vk)(e.stackParser||nn),integrations:I(e),transport:e.transport||Ue};if(function(e,t){!0===t.debug&&(g.T?l.vF.enable():(0,l.pq)((()=>{console.warn("[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.")})));const n=(0,h.BF)();n.getScope().update(t.initialScope);const s=new e(t);n.bindClient(s)}(e.clientClass||Ne,o),e.autoSessionTracking&&function(){const e=(0,h.BF)();e.startSession(),process.on("beforeExit",(()=>{const t=e.getScope().getSession();t&&!["exited","crashed"].includes(t.status)&&e.endSession()}))}(),function(){const e=(process.env.SENTRY_USE_ENVIRONMENT||"").toLowerCase();if(!["false","n","no","off","0"].includes(e)){const e=process.env.SENTRY_TRACE,t=process.env.SENTRY_BAGGAGE,{propagationContext:n}=(0,qe.E0)(e,t);(0,u.o5)().setPropagationContext(n)}}(),e.spotlight){const t=(0,u.KU)();t&&t.addIntegration&&(t.setupIntegrations(!0),t.addIntegration(new Mt({sidecarUrl:"string"==typeof e.spotlight?e.spotlight:void 0})))}}function en(e){if(void 0===e)return!1;const t=e&&e.getOptions();return!(!t||void 0===t.autoSessionTracking)&&t.autoSessionTracking}function tn(e){return process.env.SENTRY_RELEASE?process.env.SENTRY_RELEASE:De.OW.SENTRY_RELEASE&&De.OW.SENTRY_RELEASE.id?De.OW.SENTRY_RELEASE.id:process.env.GITHUB_SHA||process.env.COMMIT_REF||process.env.VERCEL_GIT_COMMIT_SHA||process.env.VERCEL_GITHUB_COMMIT_SHA||process.env.VERCEL_GITLAB_COMMIT_SHA||process.env.VERCEL_BITBUCKET_COMMIT_SHA||process.env.ZEIT_GITHUB_COMMIT_SHA||process.env.ZEIT_GITLAB_COMMIT_SHA||process.env.ZEIT_BITBUCKET_COMMIT_SHA||process.env.CF_PAGES_COMMIT_SHA||e}const nn=(0,Pe.gd)((0,Pe.o)(Dt));function sn(e){const t=St.resolve(e);if(!Wt.existsSync(t))throw new Error(`Cannot read contents of ${t}. Directory does not exist.`);if(!Wt.statSync(t).isDirectory())throw new Error(`Cannot read contents of ${t}, because it is not a directory.`);const n=e=>Wt.readdirSync(e).reduce(((t,s)=>{const o=St.join(e,s);return Wt.statSync(o).isDirectory()?t.concat(n(o)):(t.push(o),t)}),[]);return n(t).map((e=>St.relative(t,e)))}var on=n(1615);function rn(e){const t=(0,u.KU)();return new on.M(e).setup(t),Promise.resolve()}var an=n(3551);function cn(e,t){return(0,Le.Rj)(e,{include:t})}function ln(e,t,n={}){return(0,Le.GY)(e,t,{include:n})}function gn(){return function(e,t,n){const s=(0,Oe.z)([u.KU,"call",e=>e(),"optionalAccess",e=>e.getOptions,"call",e=>e()]);if(!s||"sentry"!==s.instrumenter||"OPTIONS"===(0,Oe.z)([e,"access",e=>e.method,"optionalAccess",e=>e.toUpperCase,"call",e=>e()])||"HEAD"===(0,Oe.z)([e,"access",e=>e.method,"optionalAccess",e=>e.toUpperCase,"call",e=>e()]))return n();const o=e.headers&&(0,V.Kg)(e.headers["sentry-trace"])?e.headers["sentry-trace"]:void 0,i=(0,Oe.z)([e,"access",e=>e.headers,"optionalAccess",e=>e.baggage]);if(!(0,an.w)(s))return n();const[r,a]=(0,Le.Up)(e,{path:!0,method:!0}),c=(0,Be.V4)({sentryTrace:o,baggage:i},(t=>(0,u.nb)({name:r,op:"http.server",origin:"auto.http.node.tracingHandler",...t,metadata:{...t.metadata,request:e,source:a}},{request:(0,Le.Rj)(e)})));(0,u.o5)().setSpan(c),t.__sentry_transaction=c,t.once("finish",(()=>{setImmediate((()=>{(0,Le.em)(c,e),c.setHttpStatus(t.statusCode),c.end()}))})),n()}}function dn(e){const t=function(e={}){let t;if("include"in e)t={include:e.include};else{const{ip:n,request:s,transaction:o,user:i}=e;(n||s||o||i)&&(t={include:(0,a.Ce)({ip:n,request:s,transaction:o,user:i})})}return t}(e),n=(0,u.KU)();if(n&&en(n)){n.initSessionFlusher();const e=(0,u.o5)();e.getSession()&&e.setSession()}return function(n,s,o){if(e&&e.flushTimeout&&e.flushTimeout>0){const t=s.end;s.end=function(n,s,o){(0,u.bX)(e.flushTimeout).then((()=>{t.call(this,n,s,o)})).then(null,(e=>{It&&l.vF.error(e),t.call(this,n,s,o)}))}}(0,h.fx)((()=>{const e=(0,u.o5)();e.setSDKProcessingMetadata({request:n,requestDataOptionsFromExpressHandler:t}),en((0,u.KU)())&&e.setRequestSession({status:"ok"}),s.once("finish",(()=>{const e=(0,u.KU)();en(e)&&setImmediate((()=>{e&&e._captureRequestSession&&e._captureRequestSession()}))})),o()}))}}function un(e){const t=function(e){const t=e.status||e.statusCode||e.status_code||e.output&&e.output.statusCode;return t?parseInt(t,10):500}(e);return t>=500}function hn(e){return function(t,n,s,o){(e&&e.shouldHandleError||un)(t)?(0,u.v4)((e=>{e.setSDKProcessingMetadata({request:n});const i=s.__sentry_transaction;i&&void 0===e.getSpan()&&e.setSpan(i);const r=(0,u.KU)();if(r&&en(r)&&void 0!==r._sessionFlusher){const t=e.getRequestSession();t&&void 0!==t.status&&(t.status="crashed")}const a=(0,u.Cp)(t,{mechanism:{type:"middleware",handled:!1}});s.sentry=a,o(t)})):o(t)}}function pn(e={}){return function({path:t,type:n,next:s,rawInput:o}){const i=(0,Oe.z)([u.KU,"call",e=>e(),"optionalAccess",e=>e.getOptions,"call",e=>e()]),r=(0,u.o5)().getTransaction();if(r){r.setName(`trpc/${t}`,"route"),r.op="rpc.server";const s={procedure_type:n};(void 0!==e.attachRpcInput?e.attachRpcInput:(0,Oe.z)([i,"optionalAccess",e=>e.sendDefaultPii]))&&(s.input=(0,Y.S8)(o)),r.setContext("trpc",s)}function a(e){e.ok||(0,u.Cp)(e.error,{mechanism:{handled:!1,data:{function:"trpcMiddleware"}}})}let c;try{c=s()}catch(e){throw(0,u.Cp)(e,{mechanism:{handled:!1,data:{function:"trpcMiddleware"}}}),e}return(0,V.Qg)(c)?Promise.resolve(c).then((e=>{a(e)}),(e=>{(0,u.Cp)(e,{mechanism:{handled:!1,data:{function:"trpcMiddleware"}}})})):a(c),c}}function In(e){return e&&void 0!==e.statusCode}function mn(e){(0,u.Cp)(e,{mechanism:{type:"hapi",handled:!1,data:{function:"hapiErrorPlugin"}}})}const Cn={name:"SentryHapiErrorPlugin",version:Ge.M,register:async function(e){e.events.on("request",((e,t)=>{const n=(0,Ae.Z7)();var s;e.response&&(s=e.response)&&void 0!==s.isBoom?mn(e.response):function(e){return e&&void 0!==e.error}(t)&&mn(t.error),n&&(n.setStatus("internal_error"),n.end())}))}},bn={name:"SentryHapiTracingPlugin",version:Ge.M,register:async function(e){const t=e;t.ext("onPreHandler",((e,t)=>{const n=(0,Be.V4)({sentryTrace:e.headers["sentry-trace"]||void 0,baggage:e.headers.baggage||void 0},(t=>(0,u.nb)({...t,op:"hapi.request",name:e.route.path,description:`${e.route.method} ${e.path}`})));return(0,u.o5)().setSpan(n),t.continue})),t.ext("onPreResponse",((e,t)=>{const n=(0,Ae.Z7)();if(e.response&&In(e.response)&&n){const t=e.response;t.header("sentry-trace",n.toTraceparent());const s=(0,pt.De)(n.getDynamicSamplingContext());s&&t.header("baggage",s)}return t.continue})),t.ext("onPostHandler",((e,t)=>{const n=(0,Ae.Z7)();return e.response&&In(e.response)&&n&&n.setHttpStatus(e.response.statusCode),n&&n.end(),t.continue}))}};class yn{static __initStatic(){this.id="Hapi"}constructor(e){if((0,Oe.z)([e,"optionalAccess",e=>e.server])){const t=e.server;this._hapiServer=t}this.name=yn.id}setupOnce(){this._hapiServer&&(0,a.GS)(this._hapiServer,"start",(e=>async function(){return await this.register(bn),await this.register(Cn),e.apply(this)}))}}yn.__initStatic();var fn=n(2543),An=n(5838),Zn=n(875),Gn=n(3114),vn=n(9336),Bn=n(5455),Wn=n(9932);const Sn={...s,...i,...r}},1615:(e,t,n)=>{"use strict";n.d(t,{M:()=>d});var s=n(853);function o(e){const t=(0,s.z)(e);return null==t||t}var i=n(7016),r=n(3741),a=n(7412),c=n(258),l=n(3245);function g(e,...t){a.vF.log(`[ANR] ${e}`,...t)}e=n.hmd(e);class d{__init(){this.name="Anr"}constructor(e={}){this._options=e,d.prototype.__init.call(this)}setupOnce(){}setup(e){if((l.S.major||0)<16)throw new Error("ANR detection requires Node 16 or later");setImmediate((()=>this._startWorker(e)))}async _startWorker(t){const l=await async function(e){let t={message:"ANR"};const n={};for(const s of e.getEventProcessors()){if(null===t)break;t=await s(t,n)}return(0,s.z)([t,"optionalAccess",e=>e.contexts])||{}}(t),d=t.getDsn();if(!d)return;o([l,"access",e=>e.app,"optionalAccess",e=>delete e.app_memory]),o([l,"access",e=>e.device,"optionalAccess",e=>delete e.free_memory]);const u=t.getOptions(),h=t.getSdkMetadata()||{};h.sdk&&(h.sdk.integrations=u.integrations.map((e=>e.name)));const p={debug:a.vF.isEnabled(),dsn:d,environment:u.environment||"production",release:u.release,dist:u.dist,sdkMetadata:h,pollInterval:this._options.pollInterval||50,anrThreshold:this._options.anrThreshold||5e3,captureStackTrace:!!this._options.captureStackTrace,contexts:l};p.captureStackTrace&&n(264).open(0);const{Worker:I}=(0,c.fj)(e,"worker_threads"),m=new I(new i.URL("data:application/javascript;base64,aW1wb3J0IHsgU2Vzc2lvbiB9IGZyb20gJ2luc3BlY3Rvcic7CmltcG9ydCB7IHdvcmtlckRhdGEsIHBhcmVudFBvcnQgfSBmcm9tICd3b3JrZXJfdGhyZWFkcyc7CmltcG9ydCAqIGFzIGh0dHAgZnJvbSAnaHR0cCc7CmltcG9ydCAqIGFzIGh0dHBzIGZyb20gJ2h0dHBzJzsKaW1wb3J0IHsgUmVhZGFibGUgfSBmcm9tICdzdHJlYW0n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gZnVuY3Rpb24gbWVtb2l6ZShvYmopIHsKICAgIGlmIChoYXNXZWFrU2V0KSB7CiAgICAgIGlmIChpbm5lci5oYXMob2JqKSkgewogICAgICAgIHJldHVybiB0cnVlOwogICAgICB9CiAgICAgIGlubmVyLmFkZChvYmopOwogICAgICByZXR1cm4gZmFsc2U7CiAgICB9CiAgICAvLyBlc2xpbnQtZGlzYWJsZS1uZXh0LWxpbmUgQHR5cGVzY3JpcHQtZXNsaW50L3ByZWZlci1mb3Itb2YKICAgIGZvciAobGV0IGkgPSAwOyBpIDwgaW5uZXIubGVuZ3RoOyBpKyspIHsKICAgICAgY29uc3QgdmFsdWUgPSBpbm5lcltpXTsKICAgICAgaWYgKHZhbHVlID09PSBvYmopIHsKICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgfQogICAgfQogICAgaW5uZXIucHVzaChvYmopOwogICAgcmV0dXJuIGZhbHNlOwogIH0KCiAgZnVuY3Rpb24gdW5tZW1vaXplKG9iaikgewogICAgaWYgKGhhc1dlYWtTZXQpIHsKICAgICAgaW5uZXIuZGVsZXRlKG9iaik7CiAgICB9IGVsc2UgewogICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGlubmVyLmxlbmd0aDsgaSsrKSB7CiAgICAgICAgaWYgKGlubmVyW2ldID09PSBvYmopIHsKICAgICAgICAgIGlubmVyLnNwbGljZShpLCAxKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgfQogICAgfQogIH0KICByZXR1cm4gW21lbW9pemUsIHVubWVtb2l6ZV07Cn0KCi8qKgogKiBSZWN1cnNpdmVseSBub3JtYWxpemVzIHRoZSBnaXZlbiBvYmplY3QuCiAqCiAqIC0gQ3JlYXRlcyBhIGNvcHkgdG8gcHJldmVudCBvcmlnaW5hbCBpbnB1dCBtdXRhdGlvbgogKiAtIFNraXBzIG5vbi1lbnVtZXJhYmxlIHByb3BlcnRpZXMKICogLSBXaGVuIHN0cmluZ2lmeWluZywgY2FsbHMgYHRvSl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ICAgIGV4ZWN1dG9yKHRoaXMuX3Jlc29sdmUsIHRoaXMuX3JlamVjdCk7CiAgICB9IGNhdGNoIChlKSB7CiAgICAgIHRoaXMuX3JlamVjdChlKTsKICAgIH0KICB9CgogIC8qKiBKU0RvYyAqLwogICB0aGVuKAogICAgb25mdWxmaWxsZWQsCiAgICBvbnJlamVjdGVkLAogICkgewogICAgcmV0dXJuIG5ldyBTeW5jUHJvbWlzZSgocmVzb2x2ZSwgcmVqZWN0KSA9PiB7CiAgICAgIHRoaXMuX2hhbmRsZXJzLnB1c2goWwogICAgICAgIGZhbHNlLAogICAgICAgIHJlc3VsdCA9PiB7CiAgICAgICAgICBpZiAoIW9uZnVsZmlsbGVkKSB7CiAgICAgICAgICAgIC8vIFRPRE86IMKvXF8o44OEKV8vwq8KICAgICAgICAgICAgLy8gVE9ETzogRklYTUUKICAgICAgICAgICAgcmVzb2x2ZShyZXN1bHQgKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgcmVzb2x2ZShvbmZ1bGZpbGxlZChyZXN1bHQpKTsKICAgICAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgICAgIHJlamVjdChlKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0sCiAgICAgICAgcmVhc29uID0+IHsKICAgICAgICAgIGlmICghb25yZWplY3RlZCkgewogICAgICAgICAgICByZWplY3QocmVhc29uKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgcmVzb2x2ZShvbnJlamVjdGVkKHJlYXNvbikpOwogICAgICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICAgICAgcmVqZWN0KGUpOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfSwKICAgICAgXSk7CiAgICAgIHRoaXMuX2V4ZWN1dGVIYW5kbGVycygpOwogICAgfSk7CiAgfQoKICAvKiogSlNEb2MgKi8KICAgY2F0Y2goCiAgICBvbnJlamVjdGVkLAogICkgewogICAgcmV0dXJuIHRoaXMudGhlbih2YWwgPT4gdmFsLCBvbnJlamVjdGVkKTsKICB9CgogIC8qKiBKU0RvYyAqLwogICBmaW5hbGx5KG9uZmluYWxseSkgewogICAgcmV0dXJuIG5ldyBTeW5jUHJvbWlzZSgocmVzb2x2ZSwgcmVqZWN0KSA9PiB7CiAgICAgIGxldCB2YWw7CiAgICAgIGxldCBpc1JlamVjdGVkOwoKICAgICAgcmV0dXJuIHRoaXMudGhlbigKICAgICAgICB2YWx1ZSA9PiB7CiAgICAgICAgICBpc1JlamVjdGVkID0gZmFsc2U7CiAgICAgICAgICB2YWwgPSB2YWx1ZTsKICAgICAgICAgIGlmIChvbmZpbmFsbHkpIHsKICAgICAgICAgICAgb25maW5hbGx5KCk7CiAgICAgICAgICB9CiAgICAgICAgfSwKICAgICAgICByZWFzb24gPT4gewogICAgICAgICAgaXNSZWplY3RlZCA9IHRydWU7CiAgICAgICAgICB2YWwgPSByZWFzb247CiAgICAgICAgICBpZiAob25maW5hbGx5KSB7CiAgICAgICAgICAgIG9uZmluYWxseSgpOwogICAgICAgICAgfQogICAgICAgIH0sCiAgICAgICkudGhlbigoKSA9PiB7CiAgICAgICAgaWYgKGlzUmVqZWN0ZWQpIHsKICAgICAgICAgIHJlamVjdCh2YWwpOwogICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KCiAgICAgICAgcmVzb2x2ZSh2YWwgKTsKICAgICAgfSk7CiAgICB9KTsKICB9CgogIC8qKiBKU0RvYyAqLwogICAgX19pbml0KCkge3RoaXMuX3Jlc29sdmUgPSAodmFsdWUpID0+IHsKICAgIHRoaXMuX3NldFJlc3VsdChTdGF0ZXMuUkVTT0xWRUQsIHZhbHVlKTsKICB9O30KCiAgLyoqIEpTRG9jICovCiAgICBfX2luaXQyKCkge3RoaXMuX3JlamVjdCA9IChyZWFzb24pID0+IHsKICAgIHRoaXMuX3NldFJlc3VsdChTdGF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MnOgogICAgICByZXR1cm4gbjsKICAgIGRlZmF1bHQ6CiAgICAgIHJldHVybiB1bmRlZmluZWQ7CiAgfQp9CgovKioKICogU2hvcnQgZm9ybWF0IGZvciBgbXNgLgogKgogKiBAcGFyYW0ge051bWJlcn0gbXMKICogQHJldHVybiB7U3RyaW5nfQogKiBAYXBpIHByaXZhdGUKICovCgpmdW5jdGlvbiBmbXRTaG9ydChtcykgewogIHZhciBtc0FicyA9IE1hdGguYWJzKG1zKTsKICBpZiAobXNBYnMgPj0gZCkgewogICAgcmV0dXJuIE1hdGgucm91bmQobXMgLyBkKSArICdkJzsKICB9CiAgaWYgKG1zQWJzID49IGgpIHsKICAgIHJldHVybiBNYXRoLnJvdW5kKG1zIC8gaCkgKyAnaCc7CiAgfQogIGlmIChtc0FicyA+PSBtKSB7CiAgICByZXR1cm4gTWF0aC5yb3VuZChtcyAvIG0pICsgJ20nOwogIH0KICBpZiAobXNBYnMgPj0gcykgewogICAgcmV0dXJuIE1hdGgucm91bmQobXMgLyBzKSArICdzJzsKICB9CiAgcmV0dXJuIG1zICsgJ21zJzsKfQoKLyoqCiAqIExvbmcgZm9ybWF0IGZvciBgbXNgLgogKgogKiBAcGFyYW0ge051bWJlcn0gbXMKICogQHJldHVybiB7U3RyaW5nfQogKiBAYXBpIHByaXZhdGUKICovCgpmdW5jdGlvbiBmbXRMb25nKG1zKSB7CiAgdmFyIG1zQWJzID0gTWF0aC5hYnMobXMpOwogIGlmIChtc0FicyA+PSBkKSB7CiAgICByZXR1cm4gcGx1cmFsKG1zLCBtc0FicywgZCwgJ2RheScpOwogIH0KICBpZiAobXNBYnMgPj0gaCkgewogICAgcmV0dXJuIHBsdXJhbChtcywgbXNBYnMsIGgsICdob3VyJyk7CiAgfQogIGlmIChtc0FicyA+PSBtKSB7CiAgICByZXR1cm4gcGx1cmFsKG1zLCBtc0FicywgbSwgJ21pbnV0ZScpOwogIH0KICBpZiAobXNBYnMgPj0gcykgewogICAgcmV0dXJuIHBsdXJ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jMDA5OUNDJywKCScjMDA5OUZGJywKCScjMDBDQzAwJywKCScjMDBDQzMzJywKCScjMDBDQzY2JywKCScjMDBDQzk5JywKCScjMDBDQ0NDJywKCScjMDBDQ0ZGJywKCScjMzMwMENDJywKCScjMzMwMEZGJywKCScjMzMzM0NDJywKCScjMzMzM0ZGJywKCScjMzM2NkNDJywKCScjMzM2NkZGJywKCScjMzM5OUNDJywKCScjMzM5OUZGJywKCScjMzNDQzAwJywKCScjMzNDQzMzJywKCScjMzNDQzY2JywKCScjMzNDQzk5JywKCScjMzNDQ0NDJywKCScjMzNDQ0ZGJywKCScjNjYwMENDJywKCScjNjYwMEZGJywKCScjNjYzM0NDJywKCScjNjYzM0ZGJywKCScjNjZDQzAwJywKCScjNjZDQzMzJywKCScjOTkwMENDJywKCScjOTkwMEZGJywKCScjOTkzM0NDJywKCScjOTkzM0ZGJywKCScjOTlDQzAwJywKCScjOTlDQzMzJywKCScjQ0MwMDAwJywKCScjQ0MwMDMzJywKCScjQ0MwMDY2JywKCScjQ0MwMDk5JywKCScjQ0MwMENDJywKCScjQ0MwMEZGJywKCScjQ0MzMzAwJywKCScjQ0MzMzMzJywKCScjQ0MzMzY2JywKCScjQ0MzMzk5JywKCScjQ0MzM0NDJywKCScjQ0MzM0ZGJywKCScjQ0M2NjAwJywKCScjQ0M2NjMzJywKCScjQ0M5OTAwJywKCScjQ0M5OTMzJywKCScjQ0NDQzAwJywKCScjQ0NDQzMzJywKCScjRkYwMDAwJywKCScjRkYwMDMzJywKCScjRkYwMDY2JywKCScjRkYwMDk5JywKCScjRkYwMENDJywKCScjRkYwMEZGJywKCScjRkYzMzAwJywKCScjRkYzMzMzJywKCScjRkYzMzY2JywKCScjRkYzMzk5JywKCScjRkYzM0NDJywKCScjRkYzM0ZGJywKCScjRkY2NjAwJywKCScjRkY2NjMzJywKCScjRkY5OTAwJywKCScjRkY5OTMzJywKCScjRkZDQzAwJywKCScjRkZDQzMzJwpdOwoKLyoqCiAqIEN1cnJlb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SB7CiAgICAgICAgICAgICAgICB0aGlzLmNhbGxiYWNrID0gY2FsbGJhY2s7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZSBpZiAoY2FsbGJhY2spIHsKICAgICAgICAgICAgICAgIG9wdHMgPSBjYWxsYmFjazsKICAgICAgICAgICAgfQogICAgICAgICAgICAvLyB0aW1lb3V0IGZvciB0aGUgc29ja2V0IHRvIGJlIHJldHVybmVkIGZyb20gdGhlIGNhbGxiYWNrCiAgICAgICAgICAgIHRoaXMudGltZW91dCA9IG51bGw7CiAgICAgICAgICAgIGlmIChvcHRzICYmIHR5cGVvZiBvcHRzLnRpbWVvdXQgPT09ICdudW1iZXInKSB7CiAgICAgICAgICAgICAgICB0aGlzLnRpbWVvdXQgPSBvcHRzLnRpbWVvdXQ7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdGhpcy5vcHRpb25zID0gb3B0cyB8fCB7fTsKICAgICAgICAgICAgdGhpcy5tYXhGcmVlU29ja2V0cyA9IDE7CiAgICAgICAgICAgIHRoaXMubWF4U29ja2V0cyA9IDE7CiAgICAgICAgICAgIHRoaXMuc29ja2V0cyA9IFtdOwogICAgICAgICAgICB0aGlzLnJlcXVlc3RzID0gW107CiAgICAgICAgfQogICAgICAgIGdldCBkZWZhdWx0UG9ydCgpIHsKICAgICAgICAgICAgaWYgKHR5cGVvZiB0aGlzLmV4cGxpY2l0RGVmYXVsdFBvcnQgPT09ICdudW1iZXInKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5leHBsaWNpdERlZmF1bHRQb3J0OwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVsc2UgewogICAgICAgICAgICAgICAgcmV0dXJuIGlzU2VjdXJlRW5kcG9pbnQoKSA/IDQ0MyA6IDgwOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHNldCBkZWZhdWx0UG9ydCh2KSB7CiAgICAgICAgICAgIHRoaXMuZXhwbGljaXREZWZhdWx0UG9ydCA9IHY7CiAgICAgICAgfQogICAgICAgIGdldCBwcm90b2NvbCgpIHsKICAgICAgICAgICAgaWYgKHR5cGVvZiB0aGlzLmV4cGxpY2l0UHJvdG9jb2wgPT09ICdzdHJpbmcnKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5leHBsaWNpdFByb3RvY29sOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVsc2UgewogICAgICAgICAgICAgICAgcmV0dXJuIGlzU2VjdXJlRW5kcG9pbnQoKSA/ICdodHRwczonIDogJ2h0dHA6JzsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBzZXQgcHJvdG9jb2wodikgewogICAgICAgICAgICB0aGlzLmV4cGxpY2l0UHJvdG9jb2wgPSB2OwogICAgICAgIH0KICAgICAgICBjYWxsYmFjayhyZXEsIG9wdHMsIGZuKSB7CiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcignImFnZW50LWJhc2UiIGhhcyBubyBkZWZhdWx0IGltcGxlbWVudGF0aW9uLCB5b3UgbXVzdCBzdWJjbGFzcyBhbmQgb3ZlcnJpZGUgYGNhbGxiYWNrKClgJyk7CiAgICAgICAgfQogICAgICAgIC8qKgogICAgICAgICAqIENhbGxlZCBieSBub2RlLWNvcmUncyAiX2h0dHBfY2xpZW50LmpzIiBtb2R1bGUgd2hlbiBjcmVhdGluZwogICAgICAgICAqIGEgbmV3IEhUVFAgcmVxdWVzdCB3aXRoIHRoaXMgQWdlbnQgaW5zdGFuY2UuCiAgICAgICAgICoKICAgICAgICAgKiBAYXBpIHB1YmxpYwogICAgICAgICAqLwogICAgICAgIGFkZFJlcXVlc3QocmVxLCBfb3B0cykgewogICAgICAgICAgICBjb25zdCBvd25PcHRzID0gT2JqZWN0LmFzc2lnbih7fSwgX29wdHMpOwogICAgICAgICAgICBpZiAodHlwZW9mIG93bk9wdHMuc2VjdXJlRW5kcG9pbnQgIT09ICdib29sZWFuJykgewogICAgICAgICAgICAgICAgb3duT3B0cy5zZWN1cmVFbmRwb2ludCA9IGlzU2VjdXJlRW5kcG9pbnQoKTsKICAgICAgICAgICAgfQogICAgICAgICAgICAvLyBTZXQgZGVmYXVsdCBgaG9zdGAgZm9yIEhUVFAgdG8gbG9jYWxob3N0CiAgICAgICAgICAgIGlmIChvd25PcHRzLmhvc3QgPT0gbnVsbCkgewogICAgICAgICAgICAgICAgb3duT3B0cy5ob3N0ID0gJ2xvY2FsaG9zdCc7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgLy8gU2V0IGRlZmF1bHQgYHBvcnRgIGZvciBIVFRQIGlmIG5vbmUgd2FzIGV4cGxpY2l0bHkgc3BlY2lmaWVkCiAgICAgICAgICAgIGlmIChvd25PcHRzLnBvcnQgPT0gbnVsbCkgewogICAgICAgICAgICAgICAgb3duT3B0cy5wb3J0ID0gb3duT3B0cy5zZWN1cmVFbmRwb2ludCA/IDQ0MyA6IDgwOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvbnN0IG9wdHMgPSBPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sIHRoaXMub3B0aW9ucyksIG93bk9wdHMpOwogICAgICAgICAgICBpZiAob3B0cy5ob3N0ICYmIG9wdHMucGF0aCkgewogICAgICAgICAgICAgICAgLy8gSWYgYm90aCBhIGBob3N0YCBhbmQgYHBhdGhgIGFyZSBzcGVjaWZpZWQgdGhlbiBpdCdzIG1vc3QgbGlrZWx5IHRoZQogICAgICAgICAgICAgICAgLy8gcmVzdWx0IG9mIGEgYHVybC5wYXJzZSgpYCBjYWxsLi4uIHdlIG5lZWQgdG8gcmVtb3ZlIHRoZSBgcGF0aGAgcG9ydGlvbiBzbwogICAgICAgICAgICAgICAgLy8gdGhhdCBgbmV0LmNvbm5lY3QoKWAgZG9lc24ndCBhdHRlbXB0IHRvIG9wZW4gdGhhdCBhcyBhIHVuaXggc29ja2V0IGZpbGUuCiAgICAgICAgICAgICAgICBkZWxldGUgb3B0cy5wYXRoOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGRlbGV0ZSBvcHRzLmFnZW50OwogICAgICAgICAgICBkZWxldGUgb3B0cy5ob3N0bmFtZTsKICAgICAgICAgICAgZGVsZXRlIG9wdHMuX2RlZmF1bHRBZ2VudDsKICAgICAgICAgICAgZGVsZXRlIG9wdHMuZGVmYXVsdFBvcnQ7CiAgICAgICAgICAgIGRlbGV0ZSBvcHRzLmNyZWF0ZUNvbm5lY3Rpb247CiAgICAgICAgICAgIC8vIEhpbnQgdG8gdXNlICJDb25uZWN0aW9uOiBjbG9zZSIKICAgICAgICAgICAgLy8gWFhYOiBub24tZG9jdW1lbnRlZCBgaHR0cGAgbW9kdWxlIEFQSSA6KAogICAgICAgICAgICByZXEuX2xhc3QgPSB0cnVlOwogICAgICAgICAgICByZXEuc2hvdWxkS2VlcEFsaXZlID0gZmFsc2U7CiAgICAgICAgICAgIC8vIENyZWF0ZSB0aGUgYHN0cmVhbS5EdXBsZXhgIGluc3RhbmNlCiAgICAgICAgICAgIGxldCB0aW1lZE91dCA9IGZhbHNlOwogICAgICAgICAgICBsZXQgdGltZW91dCA9IG51bGw7CiAgICAgICAgICAgIGNvbnN0IHRpbWVvdXRNcyA9IHRoaXMudGltZW91dDsKICAgICAgICAgICAgY29uc3QgZnJlZVNvY2tldCA9IHRoaXMuZnJlZVNvY2tldDsKICAgICAgICAgICAgZnVuY3Rpb24gb25lcnJvcihlcnIpIHsKICAgICAgICAgICAgICAgIGlmIChyZXEuX2hhZEVycm9yKQogICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgIHJlcS5lbWl0KCdlcnJvcicsIGVycik7CiAgICAgICAgICAgICAgICAvLyBGb3IgU2FmZXR5LiBTb21lIGFkZGl0aW9uYWwgZXJyb3JzIG1pZ2h0IGZpcmUgbGF0ZXIgb24KICAgICAgICAgICAgICAgIC8vIGFuZCB3ZSBuZWVkIHRvIG1ha2Ugc3VyZSB3ZSBkb24ndCBkb3VibGUtZmlyZSB0aGUgZXJyb3IgZXZlbnQuCiAgICAgICAgICAgICAgICByZXEuX2hhZEVycm9yID0gdHJ1ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBmdW5jdGlvbiBvbnRpbWVvdXQoKSB7CiAgICAgICAgICAgICAgICB0aW1lb3V0ID0gbnVsbDsKICAgICAgICAgICAgICAgIHRpbWVkT3V0ID0gdHJ1ZTsKICAgICAgICAgICAgICAgIGNvbnN0IGVyciA9IG5ldyBFcnJvcihgQSAic29ja2V0IiB3YXMgbm90IGNyZWF0ZWQgZm9yIEhUVFAgcmVxdWVzdCBiZWZvcmUgJHt0aW1lb3V0TXN9bXNgKTsKICAgICAgICAgICAgICAgIGVyci5jb2RlID0gJ0VUSU1FT1VUJzsKICAgICAgICAgICAgICAgIG9uZXJyb3IoZXJyKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBmdW5jdGlvbiBjYWxsYmFja0Vycm9yKGVycikgewogICAgICAgICAgICAgICAgaWYgKHRpbWVkT3V0KQogICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgIGlmICh0aW1lb3V0ICE9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgY2xlYXJUaW1lb3V0KHRpbWVvdXQpOwogICAgICAgICAgICAgICAgICAgIHRpbWVvdXQgPSBudWxsOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgb25lcnJvcihlcnIpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGZ1bmN0aW9uIG9uc29ja2V0KHNvY2tldCkgewogICAgICAgICAgICAgICAgbGV0IHNvY2s7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBvbmZyZWUoKSB7CiAgICAgICAgICAgICAgICAgICAgZnJlZVNvY2tldChzb2NrLCBvcHRzKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmICh0aW1lZE91dCkKICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICBpZiAodGltZW91dCAhPSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgY2xlYXJUaW1lb3V0KHRpbWVvdXQpOwogICAgICAgICAgICAgICAgICAgIHRpbWVvdXQgPSBudWxsOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKGlzQWdlbnRCYXNlKHNvY2tldCkgfHwgaXNIdHRwQWdlbnQoc29ja2V0KSkgewogICAgICAgICAgICAgICAgICAgIC8vIGBzb2NrZXRgIGlzIGFjdHVhbGx5IGFuIGBodHRwLkFnZW50YCBpbnN0YW5jZSwgc28KICAgICAgICAgICAgICAgICAgICAvLyByZWxpbnF1aXNoIHJlc3BvbnNpYmlsaXR5IGZvciB0aGlzIGByZXFgIHRvIHRoZSBBZ2VudAogICAgICAgICAgICAgICAgICAgIC8vIGZyb20gaGVyZSBvbgogICAgICAgICAgICAgICAgICAgIHNvY2tldC5hZGRSZXF1ZXN0KHJlcSwgb3B0cyk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKHNvY2tldCkgewogICAgICAgICAgICAgICAgICAgIHNvY2sgPSBzb2NrZXQ7CiAgICAgICAgICAgICAgICAgICAgc29jay5vbignZnJlZScsIG9uZnJlZSk7CiAgICAgICAgICAgICAgICAgICAgcmVxLm9uU29ja2V0KHNvY2spOwogICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNvbnN0IGVyciA9IG5ldyBFcnJvcihgbm8gRHVwbGV4IHN0cmVhbSB3YXMgcmV0dXJuZWQgdG8gYWdlbnQtYmFzZSBmb3IgXGAke3JlcS5tZXRob2R9ICR7cmVxLnBhdGh9XGBgKTsKICAgICAgICAgICAgICAgIG9uZXJyb3IoZXJyKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAodHlwZW9mIHRoaXMuY2FsbGJhY2sgIT09ICdmdW5jdGlvbicpIHsKICAgICAgICAgICAgICAgIG9uZXJyb3IobmV3IEVycm9yKCdgY2FsbGJhY2tgIGlzIG5vdCBkZWZpbmVkJykpOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmICghdGhpcy5wcm9taXNpZmllZENhbGxiYWNrKSB7CiAgICAgICAgICAgICAgICBpZiAodGhpcy5jYWxsYmFjay5sZW5ndGggPj0gMykgewogICAgICAgICAgICAgICAgICAgIC8vIExlZ2FjeSBjYWxsYmFjayBmdW5jdGlvbiAtIGNvbnZlcnQgdG8gYSBQcm9taXNlCiAgICAgICAgICAgICAgICAgICAgdGhpcy5wcm9taXNpZmllZENhbGxiYWNrID0gcHJvbWlzaWZ5XzEuZGVmYXVsdCh0aGlzLmNhbGxiYWNrKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGVsc2UgewogICAgICAgICAgICAgICAgICAgIHRoaXMucHJvbWlzaWZpZWRDYWxsYmFjayA9IHRoaXMuY2FsbGJhY2s7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKHR5cGVvZiB0aW1lb3V0TXMgPT09ICdudW1iZXInICYmIHRpbWVvdXRNcyA+IDApIHsKICAgICAgICAgICAgICAgIHRpbWVvdXQgPSBzZXRUaW1lb3V0KG9udGltZW91dCwgdGltZW91dE1zKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoJ3BvcnQnIGluIG9wdHMgJiYgdHlwZW9mIG9wdHMucG9ydCAhPT0gJ251bWJlcicpIHsKICAgICAgICAgICAgICAgIG9wdHMucG9ydCA9IE51bWJlcihvcHRzLnBvcnQpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICBQcm9taXNlLnJlc29sdmUodGhpcy5wcm9taXNpZmllZENhbGxiYWNrKHJlcSwgb3B0cykpLnRoZW4ob25zb2NrZXQsIGNhbGxiYWNrRXJyb3IpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNhdGNoIChlcnIpIHs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ZWFkYWJsZScsIHJlYWQpOwogICAgICAgIH0KICAgICAgICBmdW5jdGlvbiBvbmNsb3NlKGVycikgewogICAgICAgICAgICBkZWJ1ZyQxKCdvbmNsb3NlIGhhZCBlcnJvciAlbycsIGVycik7CiAgICAgICAgfQogICAgICAgIGZ1bmN0aW9uIG9uZW5kKCkgewogICAgICAgICAgICBkZWJ1ZyQxKCdvbmVuZCcpOwogICAgICAgIH0KICAgICAgICBmdW5jdGlvbiBvbmVycm9yKGVycikgewogICAgICAgICAgICBjbGVhbnVwKCk7CiAgICAgICAgICAgIGRlYnVnJDEoJ29uZXJyb3IgJW8nLCBlcnIpOwogICAgICAgICAgICByZWplY3QoZXJyKTsKICAgICAgICB9CiAgICAgICAgZnVuY3Rpb24gb25kYXRhKGIpIHsKICAgICAgICAgICAgYnVmZmVycy5wdXNoKGIpOwogICAgICAgICAgICBidWZmZXJzTGVuZ3RoICs9IGIubGVuZ3RoOwogICAgICAgICAgICBjb25zdCBidWZmZXJlZCA9IEJ1ZmZlci5jb25jYXQoYnVmZmVycywgYnVmZmVyc0xlbmd0aCk7CiAgICAgICAgICAgIGNvbnN0IGVuZE9mSGVhZGVycyA9IGJ1ZmZlcmVkLmluZGV4T2YoJ1xyXG5cclxuJyk7CiAgICAgICAgICAgIGlmIChlbmRPZkhlYWRlcnMgPT09IC0xKSB7CiAgICAgICAgICAgICAgICAvLyBrZWVwIGJ1ZmZlcmluZwogICAgICAgICAgICAgICAgZGVidWckMSgnaGF2ZSBub3QgcmVjZWl2ZWQgZW5kIG9mIEhUVFAgaGVhZGVycyB5ZXQuLi4nKTsKICAgICAgICAgICAgICAgIHJlYWQoKTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb25zdCBmaXJzdExpbmUgPSBidWZmZXJlZC50b1N0cmluZygnYXNjaWknLCAwLCBidWZmZXJlZC5pbmRleE9mKCdcclxuJykpOwogICAgICAgICAgICBjb25zdCBzdGF0dXNDb2RlID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ykgewogICAgICAgIHJldHVybiBfX2F3YWl0ZXIodGhpcywgdm9pZCAwLCB2b2lkIDAsIGZ1bmN0aW9uKiAoKSB7CiAgICAgICAgICAgIGNvbnN0IHsgcHJveHksIHNlY3VyZVByb3h5IH0gPSB0aGlzOwogICAgICAgICAgICAvLyBDcmVhdGUgYSBzb2NrZXQgY29ubmVjdGlvbiB0byB0aGUgcHJveHkgc2VydmVyLgogICAgICAgICAgICBsZXQgc29ja2V0OwogICAgICAgICAgICBpZiAoc2VjdXJlUHJveHkpIHsKICAgICAgICAgICAgICAgIGRlYnVnKCdDcmVhdGluZyBgdGxzLlNvY2tldGA6ICVvJywgcHJveHkpOwogICAgICAgICAgICAgICAgc29ja2V0ID0gdGxzXzEuZGVmYXVsdC5jb25uZWN0KHByb3h5KTsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlIHsKICAgICAgICAgICAgICAgIGRlYnVnKCdDcmVhdGluZyBgbmV0LlNvY2tldGA6ICVvJywgcHJveHkpOwogICAgICAgICAgICAgICAgc29ja2V0ID0gbmV0XzEuZGVmYXVsdC5jb25uZWN0KHByb3h5KTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb25zdCBoZWFkZXJzID0gT2JqZWN0LmFzc2lnbih7fSwgcHJveHkuaGVhZGVycyk7CiAgICAgICAgICAgIGNvbnN0IGhvc3RuYW1lID0gYCR7b3B0cy5ob3N0fToke29wdHMucG9ydH1gOwogICAgICAgICAgICBsZXQgcGF5bG9hZCA9IGBDT05ORUNUICR7aG9zdG5hbWV9IEhUVFAvMS4xXHJcbmA7CiAgICAgICAgICAgIC8vIEluamVjdCB0aGUgYFByb3h5LUF1dGhvcml6YXRpb25gIGhlYWRlciBpZiBuZWNlc3NhcnkuCiAgICAgICAgICAgIGlmIChwcm94eS5hdXRoKSB7CiAgICAgICAgICAgICAgICBoZWFkZXJzWydQcm94eS1BdXRob3JpemF0aW9uJ10gPSBgQmFzaWMgJHtCdWZmZXIuZnJvbShwcm94eS5hdXRoKS50b1N0cmluZygnYmFzZTY0Jyl9YDsKICAgICAgICAgICAgfQogICAgICAgICAgICAvLyBUaGUgYEhvc3RgIGhlYWRlciBzaG91bGQgb25seSBpbmNsdWRlIHRoZSBwb3J0CiAgICAgICAgICAgIC8vIG51bWJlciB3aGVuIGl0IGlzIG5vdCB0aGUgZGVmYXVsdCBwb3J0LgogICAgICAgICAgICBsZXQgeyBob3N0LCBwb3J0LCBzZWN1cmVFbmRwb2ludCB9ID0gb3B0czsKICAgICAgICAgICAgaWYgKCFpc0RlZmF1bHRQb3J0KHBvcnQsIHNlY3VyZUVuZHBvaW50KSkgewogICAgICAgICAgICAgICAgaG9zdCArPSBgOiR7cG9ydH1gOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGhlYWRlcnMuSG9zdCA9IGhvc3Q7CiAgICAgICAgICAgIGhlYWRlcnMuQ29ubmVjdGlvbiA9ICdjbG9zZSc7CiAgICAgICAgICAgIGZvciAoY29uc3QgbmFtZSBvZiBPYmplY3Qua2V5cyhoZWFkZXJzKSkgewogICAgICAgICAgICAgICAgcGF5bG9hZCArPSBgJHtuYW1lfTogJHtoZWFkZXJzW25hbWVdfVxyXG5gOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvbnN0IHByb3h5UmVzcG9uc2VQcm9taXNlID0gcGFyc2VfcHJveHlfcmVzcG9uc2VfMS5kZWZhdWx0KHNvY2tldCk7CiAgICAgICAgICAgIHNvY2tldC53cml0ZShgJHtwYXlsb2FkfVxyXG5gKTsKICAgICAgICAgICAgY29uc3QgeyBzdGF0dXNDb2RlLCBidWZmZXJlZCB9ID0geWllbGQgcHJveHlSZXNwb25zZVByb21pc2U7CiAgICAgICAgICAgIGlmIChzdGF0dXNDb2RlID09PSAyMDApIHsKICAgICAgICAgICAgICAgIHJlcS5vbmNlKCdzb2NrZXQnLCByZXN1bWUpOwogICAgICAgICAgICAgICAgaWYgKG9wdHMuc2VjdXJlRW5kcG9pbnQpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBzZXJ2ZXJuYW1lID0gb3B0cy5zZXJ2ZXJuYW1lIHx8IG9wdHMuaG9zdDsKICAgICAgICAgICAgICAgICAgICBpZiAoIXNlcnZlcm5hbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCdDb3VsZCBub3QgZGV0ZXJtaW5lICJzZXJ2ZXJuYW1lIicpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAvLyBUaGUgcHJveHkgaXMgY29ubmVjdGluZyB0byBhIFRMUyBzZXJ2ZXIsIHNvIHVwZ3JhZGUKICAgICAgICAgICAgICAgICAgICAvLyB0aGlzIHNvY2tldCBjb25uZWN0aW9uIHRvIGEgVExTIGNvbm5lY3Rpb24uCiAgICAgICAgICAgICAgICAgICAgZGVidWcoJ1VwZ3JhZGluZyBzb2NrZXQgY29ubmVjdGlvbiB0byBUTFMnKTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGxzXzEuZGVmYXVsdC5jb25uZWN0KE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSwgb21pdChvcHRzLCAnaG9zdCcsICdob3N0bmFtZScsICdwYXRoJywgJ3BvcnQnKSksIHsgc29ja2V0LAogICAgICAgICAgICAgICAgICAgICAgICBzZXJ2ZXJuYW1lIH0pKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHJldHVybiBzb2NrZXQ7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgLy8gU29tZSBvdGhlciBzdGF0dXMgY29kZSB0aGF0J3Mgbm90IDIwMC4uLiBuZWVkIHRvIHJlLXBsYXkgdGhlIEhUVFAKICAgICAgICAgICAgLy8gaGVhZGVyICJkYXRhIiBldmVudHMgb250byB0aGUgc29ja2V0IG9uY2UgdGhlIEhUVFAgbWFjaGluZXJ5IGlzCiAgICAgICAgICAgIC8vIGF0dGFjaGVkIHNvIHRoYXQgdGhlIG5vZGUgY29yZSBgaHR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ja2V0YCwgc2luY2UgYXQKICAgICAgICAgICAgICAgIC8vIHRoaXMgcG9pbnQgdGhlIEhUVFAgbW9kdWxlIG1hY2hpbmVyeSBoYXMgYmVlbiBob29rZWQgdXAgZm9yCiAgICAgICAgICAgICAgICAvLyB0aGUgdXNlci4KICAgICAgICAgICAgICAgIHMucHVzaChidWZmZXJlZCk7CiAgICAgICAgICAgICAgICBzLnB1c2gobnVsbCk7CiAgICAgICAgICAgIH0pOwogICAgICAgICAgICByZXR1cm4gZmFrZVNvY2tldDsKICAgICAgICB9KTsKICAgIH0KfQphZ2VudC5kZWZhdWx0ID0gSHR0cHNQcm94eUFnZW50OwpmdW5jdGlvbiByZXN1bWUoc29ja2V0KSB7CiAgICBzb2NrZXQucmVzdW1lKCk7Cn0KZnVuY3Rpb24gaXNEZWZhdWx0UG9ydChwb3J0LCBzZWN1cmUpIHsKICAgIHJldHVybiBCb29sZWFuKCghc2VjdXJlICYmIHBvcnQgPT09IDgwKSB8fCAoc2VjdXJlICYmIHBvcnQgPT09IDQ0MykpOwp9CmZ1bmN0aW9uIGlzSFRUUFMocHJvdG9jb2wpIHsKICAgIHJldHVybiB0eXBlb2YgcHJvdG9jb2wgPT09ICdzdHJpbmcnID8gL15odHRwczo/JC9pLnRlc3QocHJvdG9jb2wpIDogZmFsc2U7Cn0KZnVuY3Rpb24gb21pdChvYmosIC4uLmtleXMpIHsKICAgIGNvbnN0IHJldCA9IHt9OwogICAgbGV0IGtleTsKICAgIGZvciAoa2V5IGluIG9iaikgewogICAgICAgIGlmICgha2V5cy5pbmNsdWRlcyhrZXkpKSB7CiAgICAgICAgICAgIHJldFtrZXldID0gb2JqW2tleV07CiAgICAgICAgfQogICAgfQogICAgcmV0dXJuIHJldDsKfQoKdmFyIF9faW1wb3J0RGVmYXVsdCA9IChjb21tb25qc0dsb2JhbCAmJiBjb21tb25qc0dsb2JhbC5fX2ltcG9ydERlZmF1bHQpIHx8IGZ1bmN0aW9uIChtb2QpIHsKICAgIHJld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SwKICBhZ2VudCwKKSB7CiAgY29uc3QgeyBob3N0bmFtZSwgcGF0aG5hbWUsIHBvcnQsIHByb3RvY29sLCBzZWFyY2ggfSA9IG5ldyBVUkwob3B0aW9ucy51cmwpOwogIHJldHVybiBmdW5jdGlvbiBtYWtlUmVxdWVzdChyZXF1ZXN0KSB7CiAgICByZXR1cm4gbmV3IFByb21pc2UoKHJlc29sdmUsIHJlamVjdCkgPT4gewogICAgICBsZXQgYm9keSA9IHN0cmVhbUZyb21Cb2R5KHJlcXVlc3QuYm9keSk7CgogICAgICBjb25zdCBoZWFkZXJzID0geyAuLi5vcHRpb25zLmhlYWRlcnMgfTsKCiAgICAgIGlmIChyZXF1ZXN0LmJvZHkubGVuZ3RoID4gR1pJUF9USFJFU0hPTEQpIHsKICAgICAgICBoZWFkZXJzWydjb250ZW50LWVuY29kaW5nJ10gPSAnZ3ppcCc7CiAgICAgICAgYm9keSA9IGJvZHkucGlwZShjcmVhdGVHemlwKCkpOwogICAgICB9CgogICAgICBjb25zdCByZXEgPSBodHRwTW9kdWxlLnJlcXVlc3QoCiAgICAgICAgewogICAgICAgICAgbWV0aG9kOiAnUE9TVCcsCiAgICAgICAgICBhZ2VudCwKICAgICAgICAgIGhlYWRlcnMsCiAgICAgICAgICBob3N0bmFtZSwKICAgICAgICAgIHBhdGg6IGAke3BhdGhuYW1lfSR7c2VhcmNofWAsCiAgICAgICAgICBwb3J0LAogICAgICAgICAgcHJvdG9jb2wsCiAgICAgICAgICBjYTogb3B0aW9ucy5jYUNlcnRzLAogICAgICAgIH0sCiAgICAgICAgcmVzID0+IHsKICAgICAgICAgIHJlcy5vbignZGF0YScsICgpID0+IHsKICAgICAgICAgICAgLy8gRHJhaW4gc29ja2V0CiAgICAgICAgICB9KTsKCiAgICAgICAgICByZXMub24oJ2VuZCcsICgpID0+IHsKICAgICAgICAgICAgLy8gRHJhaW4gc29ja2V0CiAgICAgICAgICB9KTsKCiAgICAgICAgICByZXMuc2V0RW5jb2Rpbmco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GlvbmFsQWNjZXNzJywgXzYgPT4gXzYub24sICdjYWxsJywgXzcgPT4gXzcoJ21lc3NhZ2UnLCAobXNnKSA9PiB7CiAgaWYgKG1zZy5zZXNzaW9uKSB7CiAgICBzZXNzaW9uID0gbWFrZVNlc3Npb24obXNnLnNlc3Npb24pOwogIH0KCiAgcG9sbCgpOwp9KV0pOw=="),{workerData:p});m.unref();const C=setInterval((()=>{try{const e=(0,r.o5)().getSession(),t=e?{...e,toJSON:void 0}:void 0;m.postMessage({session:t})}catch(e){}}),p.pollInterval);m.on("message",(e=>{"session-ended"===e&&(g("ANR event sent from ANR worker. Clearing session in this thread."),(0,r.o5)().setSession(void 0))})),m.once("error",(e=>{clearInterval(C),g("ANR worker error",e)})),m.once("exit",(e=>{clearInterval(C),g("ANR worker exit",e)}))}}},3278:(e,t,n)=>{"use strict";n.d(t,{h:()=>m});var s,o=n(853),i=n(6641),r=n(3741),a=n(1351),c=n(5452),l=n(5019),g=n(258),d=n(9653),u=n(5584),h=n(6524),p=n(2879),I=n(3245);e=n.hmd(e),function(e){e.RequestCreate="undici:request:create",e.RequestEnd="undici:request:headers",e.RequestError="undici:request:error"}(s||(s={}));class m{static __initStatic(){this.id="Undici"}__init(){this.name=m.id}__init2(){this._createSpanUrlMap=new l.G(100)}__init3(){this._headersUrlMap=new l.G(100)}constructor(e={}){m.prototype.__init.call(this),m.prototype.__init2.call(this),m.prototype.__init3.call(this),m.prototype.__init4.call(this),m.prototype.__init5.call(this),m.prototype.__init6.call(this),this._options={breadcrumbs:void 0===e.breadcrumbs||e.breadcrumbs,shouldCreateSpanForRequest:e.shouldCreateSpanForRequest}}setupOnce(t){if(I.S.major&&I.S.major<16)return;let n;try{n=(0,g.fj)(e,"diagnostics_channel")}catch(e){}n&&n.subscribe&&(n.subscribe(s.RequestCreate,this._onRequestCreate),n.subscribe(s.RequestEnd,this._onRequestEnd),n.subscribe(s.RequestError,this._onRequestError))}_shouldCreateSpan(e){if(void 0===this._options.shouldCreateSpanForRequest)return!0;const t=this._createSpanUrlMap.get(e);if(void 0!==t)return t;const n=this._options.shouldCreateSpanForRequest(e);return this._createSpanUrlMap.set(e,n),n}__init4(){this._onRequestCreate=e=>{if(!(0,i.BF)().getIntegration(m))return;const{request:t}=e,n=t.origin?t.origin.toString()+t.path:t.path,s=(0,r.KU)();if(!s)return;if((0,a.A)(n,s)||void 0!==t.__sentry_span__)return;const l=s.getOptions(),g=(0,r.o5)(),I=g.getSpan(),b=this._shouldCreateSpan(n)?function(e,t,n){const s=(0,p.Dl)(n),i=t.method||"GET",r={"http.method":i};return s.search&&(r["http.query"]=s.search),s.hash&&(r["http.fragment"]=s.hash),(0,o.z)([e,"optionalAccess",e=>e.startChild,"call",e=>e({op:"http.client",origin:"auto.http.node.undici",description:`${i} ${(0,p.e_)(s)}`,data:r})])}(I,t,n):void 0;if(b&&(t.__sentry_span__=b),(e=>{if(void 0===l.tracePropagationTargets)return!0;const t=this._headersUrlMap.get(e);if(void 0!==t)return t;const n=(0,d.Xr)(e,l.tracePropagationTargets);return this._headersUrlMap.set(e,n),n})(n))if(b){const e=(0,o.z)([b,"optionalAccess",e=>e.transaction,"optionalAccess",e=>e.getDynamicSamplingContext,"call",e=>e()]),n=(0,u.De)(e);C(t,b.toTraceparent(),n)}else{const{traceId:e,sampled:n,dsc:o}=g.getPropagationContext(),i=(0,h.TC)(e,void 0,n),r=o||(0,c.l)(e,s,g);C(t,i,(0,u.De)(r))}}}__init5(){this._onRequestEnd=e=>{if(!(0,i.BF)().getIntegration(m))return;const{request:t,response:n}=e,s=t.origin?t.origin.toString()+t.path:t.path;if((0,a.A)(s,(0,r.KU)()))return;const o=t.__sentry_span__;o&&(o.setHttpStatus(n.statusCode),o.end()),this._options.breadcrumbs&&(0,r.ZQ)({category:"http",data:{method:t.method,status_code:n.statusCode,url:s},type:"http"},{event:"response",request:t,response:n})}}__init6(){this._onRequestError=e=>{if(!(0,i.BF)().getIntegration(m))return;const{request:t}=e,n=t.origin?t.origin.toString()+t.path:t.path;if((0,a.A)(n,(0,r.KU)()))return;const s=t.__sentry_span__;s&&(s.setStatus("internal_error"),s.end()),this._options.breadcrumbs&&(0,r.ZQ)({category:"http",data:{method:t.method,url:n},level:"error",type:"http"},{event:"error",request:t})}}}function C(e,t,n){e.headers.split("\r\n").some((e=>e.startsWith("sentry-trace:")))||(e.addHeader("sentry-trace",t),n&&e.addHeader("baggage",n))}m.__initStatic()},3245:(e,t,n)=>{"use strict";n.d(t,{S:()=>s});const s=(0,n(6936).kf)(process.versions.node)},9921:(e,t,n)=>{"use strict";n.r(t),n.d(t,{BROWSER_TRACING_INTEGRATION_ID:()=>Le,BrowserTracing:()=>Ke,IdleTransaction:()=>De,Integrations:()=>tt,Span:()=>Oe,SpanStatus:()=>et,TRACEPARENT_REGEXP:()=>Pe,Transaction:()=>Ue,addExtensionMethods:()=>xe,defaultRequestInstrumentationOptions:()=>je,extractTraceparentData:()=>Te,getActiveTransaction:()=>Ee,hasTracingEnabled:()=>Qe,instrumentOutgoingRequests:()=>qe,spanStatusfromHttpCode:()=>ze,startIdleTransaction:()=>$e,stripUrlQueryAndFragment:()=>Me});var s=n(6849),o=n(8444),i=n(7998),r=n(7412),a=n(6524),c=n(9766),l=n(2719),g=n(6341);const d=g.OW;var u=n(9297),h=n(7930);const p=(e,t,n)=>{let s,o;return i=>{t.value>=0&&(i||n)&&(o=t.value-(s||0),(o||void 0===s)&&(s=t.value,t.delta=o,e(t)))}},I=()=>d.__WEB_VITALS_POLYFILL__?d.performance&&(performance.getEntriesByType&&performance.getEntriesByType("navigation")[0]||(()=>{const e=d.performance.timing,t=d.performance.navigation.type,n={entryType:"navigation",startTime:0,type:2==t?"back_forward":1===t?"reload":"navigate"};for(const t in e)"navigationStart"!==t&&"toJSON"!==t&&(n[t]=Math.max(e[t]-e.navigationStart,0));return n})()):d.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0],m=()=>{const e=I();return e&&e.activationStart||0},C=(e,t)=>{const n=I();let s="navigate";return n&&(s=d.document.prerendering||m()>0?"prerender":n.type.replace(/_/g,"-")),{name:e,value:void 0===t?-1:t,rating:"good",delta:0,entries:[],id:`v3-${Date.now()}-${Math.floor(8999999999999*Math.random())+1e12}`,navigationType:s}},b=(e,t,n)=>{try{if(PerformanceObserver.supportedEntryTypes.includes(e)){const s=new PerformanceObserver((e=>{t(e.getEntries())}));return s.observe(Object.assign({type:e,buffered:!0},n||{})),s}}catch(e){}},y=(e,t)=>{const n=s=>{"pagehide"!==s.type&&"hidden"!==d.document.visibilityState||(e(s),t&&(removeEventListener("visibilitychange",n,!0),removeEventListener("pagehide",n,!0)))};addEventListener("visibilitychange",n,!0),addEventListener("pagehide",n,!0)},f=e=>{const t=C("CLS",0);let n,s=0,o=[];const i=e=>{e.forEach((e=>{if(!e.hadRecentInput){const i=o[0],r=o[o.length-1];s&&0!==o.length&&e.startTime-r.startTime<1e3&&e.startTime-i.startTime<5e3?(s+=e.value,o.push(e)):(s=e.value,o=[e]),s>t.value&&(t.value=s,t.entries=o,n&&n())}}))},r=b("layout-shift",i);if(r){n=p(e,t);const s=()=>{i(r.takeRecords()),n(!0)};return y(s),s}};let A=-1;const Z=()=>(A<0&&(A="hidden"!==d.document.visibilityState||d.document.prerendering?1/0:0,y((({timeStamp:e})=>{A=e}),!0)),{get firstHiddenTime(){return A}}),G=e=>{const t=Z(),n=C("FID");let s;const o=e=>{e.startTime{e.forEach(o)},r=b("first-input",i);s=p(e,n),r&&y((()=>{i(r.takeRecords()),r.disconnect()}),!0)},v={},B=e=>{const t=Z(),n=C("LCP");let s;const o=e=>{const o=e[e.length-1];if(o){const e=Math.max(o.startTime-m(),0);e{v[n.id]||(o(i.takeRecords()),i.disconnect(),v[n.id]=!0,s(!0))};return["keydown","click"].forEach((e=>{addEventListener(e,t,{once:!0,capture:!0})})),y(t,!0),t}},W={},S={};let V,w,R;function H(e,t){return J(e,t),S[e]||(function(e){const t={};"event"===e&&(t.durationThreshold=0),b(e,(t=>{k(e,{entries:t})}),t)}(e),S[e]=!0),F(e,t)}function k(e,t){const n=W[e];if(n&&n.length)for(const s of n)try{s(t)}catch(t){l.T&&r.vF.error(`Error while triggering instrumentation handler.\nType: ${e}\nName: ${(0,h.qQ)(s)}\nError:`,t)}}function Y(){f((e=>{k("cls",{metric:e}),V=e}))}function X(){G((e=>{k("fid",{metric:e}),w=e}))}function N(){B((e=>{k("lcp",{metric:e}),R=e}))}function _(e,t,n,s){return J(e,t),S[e]||(n(),S[e]=!0),s&&t({metric:s}),F(e,t)}function J(e,t){W[e]=W[e]||[],W[e].push(t)}function F(e,t){return()=>{const n=W[e];if(!n)return;const s=n.indexOf(t);-1!==s&&n.splice(s,1)}}function K(e){return"number"==typeof e&&isFinite(e)}function x(e,{startTimestamp:t,...n}){return t&&e.startTimestamp>t&&(e.startTimestamp=t),e.startChild({startTimestamp:t,...n})}const E=2147483647;function T(e){return e/1e3}function z(){return d&&d.addEventListener&&d.performance}let U,O,L=0,j={};function Q(){const e=z();if(e&&u.k3){e.mark&&d.performance.mark("sentry-tracing-init");const t=_("fid",(({metric:e})=>{const t=e.entries.pop();if(!t)return;const n=T(u.k3),s=T(t.startTime);l.T&&r.vF.log("[Measurements] Adding FID"),j.fid={value:e.value,unit:"millisecond"},j["mark.fid"]={value:n+s,unit:"second"}}),X,w),n=_("cls",(({metric:e})=>{const t=e.entries.pop();t&&(l.T&&r.vF.log("[Measurements] Adding CLS"),j.cls={value:e.value,unit:""},O=t)}),Y,V),s=_("lcp",(({metric:e})=>{const t=e.entries.pop();t&&(l.T&&r.vF.log("[Measurements] Adding LCP"),j.lcp={value:e.value,unit:"millisecond"},U=t)}),N,R);return()=>{t(),n(),s()}}return()=>{}}function M(e,t,n,s,o,i){const r=i?t[i]:t[`${n}End`],a=t[`${n}Start`];a&&r&&x(e,{op:"browser",origin:"auto.browser.browser.metrics",description:o||n,startTimestamp:s+T(a),endTimestamp:s+T(r)})}function P(e,t,n,s){const o=t[n];null!=o&&o{const t={...o,endTimestamp:Date.now(),response:e};return(0,oe.aj)("fetch",t),e}),(e=>{const t={...o,endTimestamp:Date.now(),error:e};throw(0,oe.aj)("fetch",t),e}))}}))}function re(e,t){return!!e&&"object"==typeof e&&!!e[t]}function ae(e){return"string"==typeof e?e:e?re(e,"url")?e.url:e.toString?e.toString():"":""}var ce=n(3816);const le=g.OW,ge="__sentry_xhr_v3__";function de(){if(!le.XMLHttpRequest)return;const e=XMLHttpRequest.prototype;(0,ee.GS)(e,"open",(function(e){return function(...t){const n=Date.now(),s=(0,ce.Kg)(t[0])?t[0].toUpperCase():void 0,o=function(e){if((0,ce.Kg)(e))return e;try{return e.toString()}catch(e){}}(t[1]);if(!s||!o)return e.apply(this,t);this[ge]={method:s,url:o,request_headers:{}},"POST"===s&&o.match(/sentry_key/)&&(this.__sentry_own_request__=!0);const i=()=>{const e=this[ge];if(e&&4===this.readyState){try{e.status_code=this.status}catch(e){}const t={args:[s,o],endTimestamp:Date.now(),startTimestamp:n,xhr:this};(0,oe.aj)("xhr",t)}};return"onreadystatechange"in this&&"function"==typeof this.onreadystatechange?(0,ee.GS)(this,"onreadystatechange",(function(e){return function(...t){return i(),e.apply(this,t)}})):this.addEventListener("readystatechange",i),(0,ee.GS)(this,"setRequestHeader",(function(e){return function(...t){const[n,s]=t,o=this[ge];return o&&(0,ce.Kg)(n)&&(0,ce.Kg)(s)&&(o.request_headers[n.toLowerCase()]=s),e.apply(this,t)}})),e.apply(this,t)}})),(0,ee.GS)(e,"send",(function(e){return function(...t){const n=this[ge];if(!n)return e.apply(this,t);void 0!==t[0]&&(n.body=t[0]);const s={args:[n.method,n.url],startTimestamp:Date.now(),xhr:this};return(0,oe.aj)("xhr",s),e.apply(this,t)}}))}var ue=n(9653),he=n(5584);const pe=["localhost",/^\/(?!\/)/],Ie={traceFetch:!0,traceXHR:!0,enableHTTPTimings:!0,tracingOrigins:pe,tracePropagationTargets:pe};function me(e){const{traceFetch:t,traceXHR:n,tracePropagationTargets:s,tracingOrigins:o,shouldCreateSpanForRequest:i,enableHTTPTimings:r}={traceFetch:Ie.traceFetch,traceXHR:Ie.traceXHR,...e},c="function"==typeof i?i:e=>!0,l=e=>function(e,t){return(0,ue.Xr)(e,t||pe)}(e,s||o),g={};var d;t&&function(e){const t="fetch";(0,oe.s5)(t,(e=>{const t=function(e,t,n,s,o="auto.http.browser"){if(!(0,D.w)()||!e.fetchData)return;const i=t(e.fetchData.url);if(e.endTimestamp&&i){const t=e.fetchData.__span;if(!t)return;const n=s[t];if(n){if(e.response){n.setHttpStatus(e.response.status);const t=e.response&&e.response.headers&&e.response.headers.get("content-length");if(t){const e=parseInt(t);e>0&&n.setData("http.response_content_length",e)}}else e.error&&n.setStatus("internal_error");n.end(),delete s[t]}return}const r=(0,q.o5)(),c=(0,q.KU)(),l=r.getSpan(),{method:g,url:d}=e.fetchData,u=i&&l?l.startChild({data:{url:d,type:"fetch","http.method":g},description:`${g} ${d}`,op:"http.client",origin:o}):void 0;if(u&&(e.fetchData.__span=u.spanId,s[u.spanId]=u),n(e.fetchData.url)&&c){const t=e.args[0];e.args[1]=e.args[1]||{};const n=e.args[1];n.headers=function(e,t,n,s,o){const i=o||n.getSpan(),r=i&&i.transaction,{traceId:c,sampled:l,dsc:g}=n.getPropagationContext(),d=i?i.toTraceparent():(0,a.TC)(c,void 0,l),u=r?r.getDynamicSamplingContext():g||(0,$.l)(c,t,n),h=(0,he.De)(u),p="undefined"!=typeof Request&&(0,ce.tH)(e,Request)?e.headers:s.headers;if(p){if("undefined"!=typeof Headers&&(0,ce.tH)(p,Headers)){const e=new Headers(p);return e.append("sentry-trace",d),h&&e.append(he.hF,h),e}if(Array.isArray(p)){const e=[...p,["sentry-trace",d]];return h&&e.push([he.hF,h]),e}{const e="baggage"in p?p.baggage:void 0,t=[];return Array.isArray(e)?t.push(...e):e&&t.push(e),h&&t.push(h),{...p,"sentry-trace":d,baggage:t.length>0?t.join(","):void 0}}}return{"sentry-trace":d,baggage:h}}(t,c,r,n,u)}return u}(e,c,l,g);r&&t&&Ce(t)})),(0,oe.AS)(t,ie)}(),n&&(d=e=>{const t=function(e,t,n,s){const o=e.xhr,i=o&&o[ge];if(!(0,D.w)()||!o||o.__sentry_own_request__||!i)return;const r=t(i.url);if(e.endTimestamp&&r){const e=o.__sentry_xhr_span_id__;if(!e)return;const t=s[e];return void(t&&void 0!==i.status_code&&(t.setHttpStatus(i.status_code),t.end(),delete s[e]))}const c=(0,q.o5)(),l=c.getSpan(),g=r&&l?l.startChild({data:{type:"xhr","http.method":i.method,url:i.url},description:`${i.method} ${i.url}`,op:"http.client",origin:"auto.http.browser"}):void 0;if(g&&(o.__sentry_xhr_span_id__=g.spanId,s[o.__sentry_xhr_span_id__]=g),o.setRequestHeader&&n(i.url))if(g){const e=g&&g.transaction,t=e&&e.getDynamicSamplingContext(),n=(0,he.De)(t);ye(o,g.toTraceparent(),n)}else{const e=(0,q.KU)(),{traceId:t,sampled:n,dsc:s}=c.getPropagationContext(),i=(0,a.TC)(t,void 0,n),r=s||(e?(0,$.l)(t,e,c):void 0);ye(o,i,(0,he.De)(r))}return g}(e,c,l,g);r&&t&&Ce(t)},(0,oe.s5)("xhr",d),(0,oe.AS)("xhr",de))}function Ce(e){const t=e.data.url;if(!t)return;const n=H("resource",(({entries:s})=>{s.forEach((s=>{(function(e){return"resource"===e.entryType&&"initiatorType"in e&&"string"==typeof e.nextHopProtocol&&("fetch"===e.initiatorType||"xmlhttprequest"===e.initiatorType)})(s)&&s.name.endsWith(t)&&(function(e){const{name:t,version:n}=function(e){let t="unknown",n="unknown",s="";for(const o of e){if("/"===o){[t,n]=e.split("/");break}if(!isNaN(Number(o))){t="h"===s?"http":s,n=e.split(s)[1];break}s+=o}return s===e&&(t=s),{name:t,version:n}}(e.nextHopProtocol),s=[];return s.push(["network.protocol.version",n],["network.protocol.name",t]),u.k3?[...s,["http.request.redirect_start",be(e.redirectStart)],["http.request.fetch_start",be(e.fetchStart)],["http.request.domain_lookup_start",be(e.domainLookupStart)],["http.request.domain_lookup_end",be(e.domainLookupEnd)],["http.request.connect_start",be(e.connectStart)],["http.request.secure_connection_start",be(e.secureConnectionStart)],["http.request.connection_end",be(e.connectEnd)],["http.request.request_start",be(e.requestStart)],["http.request.response_start",be(e.responseStart)],["http.request.response_end",be(e.responseEnd)]]:s}(s).forEach((t=>e.setData(...t))),setTimeout(n))}))}))}function be(e=0){return((u.k3||performance.timeOrigin)+e)/1e3}function ye(e,t,n){try{e.setRequestHeader("sentry-trace",t),n&&e.setRequestHeader(he.hF,n)}catch(e){}}const fe=(0,g.VZ)(),Ae=g.OW;let Ze;function Ge(){if(!function(){const e=fe.chrome,t=e&&e.app&&e.app.runtime,n="history"in fe&&!!fe.history.pushState&&!!fe.history.replaceState;return!t&&n}())return;const e=Ae.onpopstate;function t(e){return function(...t){const n=t.length>2?t[2]:void 0;if(n){const e=Ze,t=String(n);Ze=t;const s={from:e,to:t};(0,oe.aj)("history",s)}return e.apply(this,t)}}Ae.onpopstate=function(...t){const n=Ae.location.href,s=Ze;Ze=n;const o={from:s,to:n};if((0,oe.aj)("history",o),e)try{return e.apply(this,t)}catch(e){}},(0,ee.GS)(Ae.history,"pushState",t),(0,ee.GS)(Ae.history,"replaceState",t)}const ve="BrowserTracing",Be={...s.Cq,markBackgroundTransactions:!0,routingInstrumentation:function(e,t=!0,n=!0){if(!d||!d.location)return void(l.T&&r.vF.warn("Could not initialize routing instrumentation due to invalid location"));let s,o=d.location.href;t&&(s=e({name:d.location.pathname,startTimestamp:u.k3?u.k3/1e3:void 0,op:"pageload",origin:"auto.pageload.browser",metadata:{source:"url"}})),n&&function(t){const n="history";(0,oe.s5)(n,(({to:t,from:n})=>{void 0===n&&o&&-1!==o.indexOf(t)?o=void 0:n!==t&&(o=void 0,s&&(l.T&&r.vF.log(`[Tracing] Finishing current transaction with op: ${s.op}`),s.end()),s=e({name:d.location.pathname,op:"navigation",origin:"auto.navigation.browser",metadata:{source:"url"}}))})),(0,oe.AS)(n,Ge)}()},startTransactionOnLocationChange:!0,startTransactionOnPageLoad:!0,enableLongTask:!0,_experiments:{},...Ie};function We(e){const t=(0,c.NX)(`meta[name=${e}]`);return t?t.getAttribute("content"):void 0}var Se,Ve=n(2581),we=n(5527),Re=n(7927),He=n(2879);!function(e){e.Ok="ok",e.DeadlineExceeded="deadline_exceeded",e.Unauthenticated="unauthenticated",e.PermissionDenied="permission_denied",e.NotFound="not_found",e.ResourceExhausted="resource_exhausted",e.InvalidArgument="invalid_argument",e.Unimplemented="unimplemented",e.Unavailable="unavailable",e.InternalError="internal_error",e.UnknownError="unknown_error",e.Cancelled="cancelled",e.AlreadyExists="already_exists",e.FailedPrecondition="failed_precondition",e.Aborted="aborted",e.OutOfRange="out_of_range",e.DataLoss="data_loss"}(Se||(Se={}));var ke=n(2543),Ye=n(5838),Xe=n(875),Ne=n(3114),_e=n(9336),Je=n(5455),Fe=n(9932);const Ke=class{constructor(e){this.name=ve,this._hasSetTracePropagationTargets=!1,(0,o.U)(),l.T&&(this._hasSetTracePropagationTargets=!(!e||!e.tracePropagationTargets&&!e.tracingOrigins)),this.options={...Be,...e},void 0!==this.options._experiments.enableLongTask&&(this.options.enableLongTask=this.options._experiments.enableLongTask),e&&!e.tracePropagationTargets&&e.tracingOrigins&&(this.options.tracePropagationTargets=e.tracingOrigins),this._collectWebVitals=Q(),this.options.enableLongTask&&H("longtask",(({entries:e})=>{for(const t of e){const e=(0,i.Z7)();if(!e)return;const n=T(u.k3+t.startTime),s=T(t.duration);e.startChild({description:"Main UI thread blocked",op:"ui.long-task",origin:"auto.ui.browser.metrics",startTimestamp:n,endTimestamp:n+s})}})),this.options._experiments.enableInteractions&&H("event",(({entries:e})=>{for(const t of e){const e=(0,i.Z7)();if(!e)return;if("click"===t.name){const n=T(u.k3+t.startTime),s=T(t.duration),o={description:(0,c.Hd)(t.target),op:`ui.interaction.${t.name}`,origin:"auto.ui.browser.metrics",startTimestamp:n,endTimestamp:n+s},i=(0,c.xE)(t.target);i&&(o.data={"ui.component_name":i}),e.startChild(o)}}}))}setupOnce(e,t){this._getCurrentHub=t;const n=t().getClient(),s=n&&n.getOptions(),{routingInstrumentation:o,startTransactionOnLocationChange:a,startTransactionOnPageLoad:c,markBackgroundTransactions:g,traceFetch:u,traceXHR:h,shouldCreateSpanForRequest:p,enableHTTPTimings:I,_experiments:m}=this.options,C=s&&s.tracePropagationTargets,b=C||this.options.tracePropagationTargets;l.T&&this._hasSetTracePropagationTargets&&C&&r.vF.warn("[Tracing] The `tracePropagationTargets` option was set in the BrowserTracing integration and top level `Sentry.init`. The top level `Sentry.init` value is being used."),o((e=>{const n=this._createRouteTransaction(e);return this.options._experiments.onStartRouteTransaction&&this.options._experiments.onStartRouteTransaction(n,e,t),n}),c,a),g&&(d&&d.document?d.document.addEventListener("visibilitychange",(()=>{const e=(0,i.Z7)();if(d.document.hidden&&e){const t="cancelled";l.T&&r.vF.log(`[Tracing] Transaction: ${t} -> since tab moved to the background, op: ${e.op}`),e.status||e.setStatus(t),e.setTag("visibilitychange","document.hidden"),e.end()}})):l.T&&r.vF.warn("[Tracing] Could not set up background tab detection due to lack of global document")),m.enableInteractions&&this._registerInteractionListener(),me({traceFetch:u,traceXHR:h,tracePropagationTargets:b,shouldCreateSpanForRequest:p,enableHTTPTimings:I})}_createRouteTransaction(e){if(!this._getCurrentHub)return void(l.T&&r.vF.warn(`[Tracing] Did not create ${e.op} transaction because _getCurrentHub is invalid.`));const t=this._getCurrentHub(),{beforeNavigate:n,idleTimeout:s,finalTimeout:i,heartbeatInterval:g}=this.options,h="pageload"===e.op,p=h?We("sentry-trace"):"",I=h?We("baggage"):"",{traceparentData:m,dynamicSamplingContext:C,propagationContext:b}=(0,a.E0)(p,I),y={...e,...m,metadata:{...e.metadata,dynamicSamplingContext:m&&!C?{}:C},trimEnd:!0},f="function"==typeof n?n(y):y,A=void 0===f?{...y,sampled:!1}:f;A.metadata=A.name!==y.name?{...A.metadata,source:"custom"}:A.metadata,this._latestRouteName=A.name,this._latestRouteSource=A.metadata&&A.metadata.source,!1===A.sampled&&l.T&&r.vF.log(`[Tracing] Will not send ${A.op} transaction because of beforeNavigate.`),l.T&&r.vF.log(`[Tracing] Starting ${A.op} transaction on scope`);const{location:G}=d,v=(0,o.p)(t,A,s,i,!0,{location:G},g),B=t.getScope();return h&&m?B.setPropagationContext(b):B.setPropagationContext({traceId:v.traceId,spanId:v.spanId,parentSpanId:v.parentSpanId,sampled:v.sampled}),v.registerBeforeFinishCallback((e=>{this._collectWebVitals(),function(e){const t=z();if(!t||!d.performance.getEntries||!u.k3)return;l.T&&r.vF.log("[Tracing] Adding & adjusting spans using Performance API");const n=T(u.k3),s=t.getEntries();let o,i;if(s.slice(L).forEach((t=>{const s=T(t.startTime),a=T(t.duration);if(!("navigation"===e.op&&n+s{M(e,t,s,n)})),M(e,t,"secureConnection",n,"TLS/SSL","connectEnd"),M(e,t,"fetch",n,"cache","domainLookupStart"),M(e,t,"domainLookup",n,"DNS"),function(e,t,n){x(e,{op:"browser",origin:"auto.browser.browser.metrics",description:"request",startTimestamp:n+T(t.requestStart),endTimestamp:n+T(t.responseEnd)}),x(e,{op:"browser",origin:"auto.browser.browser.metrics",description:"response",startTimestamp:n+T(t.responseStart),endTimestamp:n+T(t.responseEnd)})}(e,t,n)}(e,t,n),o=n+T(t.responseStart),i=n+T(t.requestStart);break;case"mark":case"paint":case"measure":{!function(e,t,n,s,o){const i=o+n,r=i+s;x(e,{description:t.name,endTimestamp:r,op:t.entryType,origin:"auto.resource.browser.metrics",startTimestamp:i})}(e,t,s,a,n);const o=Z(),i=t.startTime{if(!j[t]||n>=e.startTimestamp)return;const s=j[t].value,o=n+T(s),i=Math.abs(1e3*(o-e.startTimestamp)),a=i-s;l.T&&r.vF.log(`[Measurements] Normalized ${t} from ${s} to ${i} (${a})`),j[t].value=i}));const t=j["mark.fid"];t&&j.fid&&(x(e,{description:"first input delay",endTimestamp:t.value+T(j.fid.value),op:"ui.action",origin:"auto.ui.browser.metrics",startTimestamp:t.value}),delete j["mark.fid"]),"fcp"in j||delete j.cls,Object.keys(j).forEach((t=>{e.setMeasurement(t,j[t].value,j[t].unit)})),function(e){U&&(l.T&&r.vF.log("[Measurements] Adding LCP Data"),U.element&&e.setTag("lcp.element",(0,c.Hd)(U.element)),U.id&&e.setTag("lcp.id",U.id),U.url&&e.setTag("lcp.url",U.url.trim().slice(0,200)),e.setTag("lcp.size",U.size)),O&&O.sources&&(l.T&&r.vF.log("[Measurements] Adding CLS Data"),O.sources.forEach(((t,n)=>e.setTag(`cls.source.${n+1}`,(0,c.Hd)(t.node)))))}(e)}U=void 0,O=void 0,j={}}(e)})),v}_registerInteractionListener(){let e;const t=()=>{const{idleTimeout:t,finalTimeout:n,heartbeatInterval:s}=this.options,a="ui.action.click",c=(0,i.Z7)();if(c&&c.op&&["navigation","pageload"].includes(c.op))return void(l.T&&r.vF.warn(`[Tracing] Did not create ${a} transaction because a pageload or navigation transaction is in progress.`));if(e&&(e.setFinishReason("interactionInterrupted"),e.end(),e=void 0),!this._getCurrentHub)return void(l.T&&r.vF.warn(`[Tracing] Did not create ${a} transaction because _getCurrentHub is invalid.`));if(!this._latestRouteName)return void(l.T&&r.vF.warn(`[Tracing] Did not create ${a} transaction because _latestRouteName is missing.`));const g=this._getCurrentHub(),{location:u}=d,h={name:this._latestRouteName,op:a,trimEnd:!0,metadata:{source:this._latestRouteSource||"url"}};e=(0,o.p)(g,h,t,n,!0,{location:u},s)};["click"].forEach((e=>{addEventListener(e,t,{once:!1,capture:!0})}))}},xe=Ve.l,Ee=i.Z7,Te=i.nc,ze=we.o6,Ue=Re.Z,Oe=we.L9,Le=ve,je=Ie,Qe=D.w,Me=He.f,Pe=a.MI,De=s.zX,qe=me,$e=o.p,et=Se,tt={BrowserTracing:Ke,Apollo:ke.I,Express:Ye.JF,GraphQL:Xe.c,Mongo:Ne.N,Mysql:_e.d,Postgres:Je.E,Prisma:Fe.D};("undefined"==typeof __SENTRY_TRACING__||__SENTRY_TRACING__)&&(0,Ve.l)()},5584:(e,t,n)=>{"use strict";n.d(t,{De:()=>d,hF:()=>r,yD:()=>g});var s=n(5644),o=n(3816),i=n(7412);const r="baggage",a="sentry-",c=/^sentry-/,l=8192;function g(e){if(!(0,o.Kg)(e)&&!Array.isArray(e))return;let t={};if(Array.isArray(e))t=e.reduce(((e,t)=>({...e,...u(t)})),{});else{if(!e)return;t=u(e)}const n=Object.entries(t).reduce(((e,[t,n])=>(t.match(c)&&(e[t.slice(a.length)]=n),e)),{});return Object.keys(n).length>0?n:void 0}function d(e){if(e)return function(e){if(0!==Object.keys(e).length)return Object.entries(e).reduce(((e,[t,n],o)=>{const r=`${encodeURIComponent(t)}=${encodeURIComponent(n)}`,a=0===o?r:`${e},${r}`;return a.length>l?(s.T&&i.vF.warn(`Not adding key: ${t} with val: ${n} to baggage header due to exceeding baggage size limits.`),e):a}),"")}(Object.entries(e).reduce(((e,[t,n])=>(n&&(e[`${a}${t}`]=n),e)),{}))}function u(e){return e.split(",").map((e=>e.split("=").map((e=>decodeURIComponent(e.trim()))))).reduce(((e,[t,n])=>(e[t]=n,e)),{})}},9766:(e,t,n)=>{"use strict";n.d(t,{Hd:()=>r,NX:()=>c,xE:()=>l});var s=n(3816);const o=(0,n(6341).VZ)(),i=80;function r(e,t={}){if(!e)return"";try{let n=e;const s=5,o=[];let r=0,c=0;const l=" > ",g=l.length;let d;const u=Array.isArray(t)?t:t.keyAttrs,h=!Array.isArray(t)&&t.maxStringLength||i;for(;n&&r++1&&c+o.length*g+d.length>=h));)o.push(d),c+=d.length,n=n.parentNode;return o.reverse().join(l)}catch(e){return""}}function a(e,t){const n=e,i=[];let r,a,c,l,g;if(!n||!n.tagName)return"";if(o.HTMLElement&&n instanceof HTMLElement&&n.dataset&&n.dataset.sentryComponent)return n.dataset.sentryComponent;i.push(n.tagName.toLowerCase());const d=t&&t.length?t.filter((e=>n.getAttribute(e))).map((e=>[e,n.getAttribute(e)])):null;if(d&&d.length)d.forEach((e=>{i.push(`[${e[0]}="${e[1]}"]`)}));else if(n.id&&i.push(`#${n.id}`),r=n.className,r&&(0,s.Kg)(r))for(a=r.split(/\s+/),g=0;g{"use strict";function s(e){let t,n=e[0],s=1;for(;sn.call(t,...e))),t=void 0)}return n}n.d(t,{z:()=>s})},5644:(e,t,n)=>{"use strict";n.d(t,{T:()=>s});const s="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__},718:(e,t,n)=>{"use strict";n.d(t,{AS:()=>l,aj:()=>g,s5:()=>c});var s=n(5644),o=n(7412),i=n(7930);const r={},a={};function c(e,t){r[e]=r[e]||[],r[e].push(t)}function l(e,t){a[e]||(t(),a[e]=!0)}function g(e,t){const n=e&&r[e];if(n)for(const r of n)try{r(t)}catch(t){s.T&&o.vF.error(`Error while triggering instrumentation handler.\nType: ${e}\nName: ${(0,i.qQ)(r)}\nError:`,t)}}},3816:(e,t,n)=>{"use strict";n.d(t,{Kg:()=>r,L2:()=>m,Qd:()=>c,Qg:()=>u,bJ:()=>o,gd:()=>d,mE:()=>h,sO:()=>a,tH:()=>I,vq:()=>g,xH:()=>l,yr:()=>p});const s=Object.prototype.toString;function o(e){switch(s.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return!0;default:return I(e,Error)}}function i(e,t){return s.call(e)===`[object ${t}]`}function r(e){return i(e,"String")}function a(e){return null===e||"object"!=typeof e&&"function"!=typeof e}function c(e){return i(e,"Object")}function l(e){return"undefined"!=typeof Event&&I(e,Event)}function g(e){return"undefined"!=typeof Element&&I(e,Element)}function d(e){return i(e,"RegExp")}function u(e){return Boolean(e&&e.then&&"function"==typeof e.then)}function h(e){return c(e)&&"nativeEvent"in e&&"preventDefault"in e&&"stopPropagation"in e}function p(e){return"number"==typeof e&&e!=e}function I(e,t){try{return e instanceof t}catch(e){return!1}}function m(e){return!("object"!=typeof e||null===e||!e.__isVue&&!e._isVue)}},7412:(e,t,n)=>{"use strict";n.d(t,{Ow:()=>i,Z9:()=>r,pq:()=>a,vF:()=>c});var s=n(5644),o=n(6341);const i=["debug","info","warn","error","log","assert","trace"],r={};function a(e){if(!("console"in o.OW))return e();const t=o.OW.console,n={},s=Object.keys(r);s.forEach((e=>{const s=r[e];n[e]=t[e],t[e]=s}));try{return e()}finally{s.forEach((e=>{t[e]=n[e]}))}}const c=function(){let e=!1;const t={enable:()=>{e=!0},disable:()=>{e=!1},isEnabled:()=>e};return s.T?i.forEach((n=>{t[n]=(...t)=>{e&&a((()=>{o.OW.console[n](`Sentry Logger [${n}]:`,...t)}))}})):i.forEach((e=>{t[e]=()=>{}})),t}()},5019:(e,t,n)=>{"use strict";n.d(t,{G:()=>s});class s{constructor(e){this._maxSize=e,this._cache=new Map}get size(){return this._cache.size}get(e){const t=this._cache.get(e);if(void 0!==t)return this._cache.delete(e),this._cache.set(e,t),t}set(e,t){this._cache.size>=this._maxSize&&this._cache.delete(this._cache.keys().next().value),this._cache.set(e,t)}remove(e){const t=this._cache.get(e);return t&&this._cache.delete(e),t}clear(){this._cache.clear()}keys(){return Array.from(this._cache.keys())}values(){const e=[];return this._cache.forEach((t=>e.push(t))),e}}},6936:(e,t,n)=>{"use strict";n.d(t,{$X:()=>c,GR:()=>p,M6:()=>g,db:()=>h,eJ:()=>r,gO:()=>l,k9:()=>I,kf:()=>u});var s=n(8411),o=n(9653),i=n(6341);function r(){const e=i.OW,t=e.crypto||e.msCrypto;let n=()=>16*Math.random();try{if(t&&t.randomUUID)return t.randomUUID().replace(/-/g,"");t&&t.getRandomValues&&(n=()=>{const e=new Uint8Array(1);return t.getRandomValues(e),e[0]})}catch(e){}return([1e7]+1e3+4e3+8e3+1e11).replace(/[018]/g,(e=>(e^(15&n())>>e/4).toString(16)))}function a(e){return e.exception&&e.exception.values?e.exception.values[0]:void 0}function c(e){const{message:t,event_id:n}=e;if(t)return t;const s=a(e);return s?s.type&&s.value?`${s.type}: ${s.value}`:s.type||s.value||n||"":n||""}function l(e,t,n){const s=e.exception=e.exception||{},o=s.values=s.values||[],i=o[0]=o[0]||{};i.value||(i.value=t||""),i.type||(i.type=n||"Error")}function g(e,t){const n=a(e);if(!n)return;const s=n.mechanism;if(n.mechanism={type:"generic",handled:!0,...s,...t},t&&"data"in t){const e={...s&&s.data,...t.data};n.mechanism.data=e}}const d=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;function u(e){const t=e.match(d)||[],n=parseInt(t[1],10),s=parseInt(t[2],10),o=parseInt(t[3],10);return{buildmetadata:t[5],major:isNaN(n)?void 0:n,minor:isNaN(s)?void 0:s,patch:isNaN(o)?void 0:o,prerelease:t[4]}}function h(e,t,n=5){if(void 0===t.lineno)return;const s=e.length,i=Math.max(Math.min(s-1,t.lineno-1),0);t.pre_context=e.slice(Math.max(0,i-n),i).map((e=>(0,o.nC)(e,0))),t.context_line=(0,o.nC)(e[Math.min(s-1,i)],t.colno||0),t.post_context=e.slice(Math.min(i+1,s),i+1+n).map((e=>(0,o.nC)(e,0)))}function p(e){if(e&&e.__sentry_captured__)return!0;try{(0,s.my)(e,"__sentry_captured__",!0)}catch(e){}return!1}function I(e){return Array.isArray(e)?e:[e]}},258:(e,t,n)=>{"use strict";function s(){return!("undefined"!=typeof __SENTRY_BROWSER_BUNDLE__&&__SENTRY_BROWSER_BUNDLE__)&&"[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0)}function o(e,t){return e.require(t)}function i(t){let n;try{n=o(e,t)}catch(e){}try{const{cwd:s}=o(e,"process");n=o(e,`${s()}/node_modules/${t}`)}catch(e){}return n}n.d(t,{fj:()=>o,wD:()=>s,Vw:()=>i}),e=n.hmd(e)},2181:(e,t,n)=>{"use strict";n.d(t,{S8:()=>r,cd:()=>a});var s=n(3816),o=n(8411),i=n(7930);function r(e,t=100,n=1/0){try{return c("",e,t,n)}catch(e){return{ERROR:`**non-serializable** (${e})`}}}function a(e,t=3,n=102400){const s=r(e,t);return o=s,function(e){return~-encodeURI(e).split(/%..|./).length}(JSON.stringify(o))>n?a(e,t-1,n):s;var o}function c(e,t,n=1/0,r=1/0,a=function(){const e="function"==typeof WeakSet,t=e?new WeakSet:[];return[function(n){if(e)return!!t.has(n)||(t.add(n),!1);for(let e=0;e=r){p[e]="[MaxProperties ~]";break}const t=m[e];p[e]=c(e,t,u-1,r,a),I++}return g(t),p}},8411:(e,t,n)=>{"use strict";n.d(t,{Ce:()=>m,GS:()=>c,HF:()=>I,W4:()=>u,my:()=>l,sp:()=>g,u4:()=>d});var s=n(9766),o=n(5644),i=n(3816),r=n(7412),a=n(9653);function c(e,t,n){if(!(t in e))return;const s=e[t],o=n(s);"function"==typeof o&&function(e,t){try{const n=t.prototype||{};e.prototype=t.prototype=n,l(e,"__sentry_original__",t)}catch(e){}}(o,s),e[t]=o}function l(e,t,n){try{Object.defineProperty(e,t,{value:n,writable:!0,configurable:!0})}catch(n){o.T&&r.vF.log(`Failed to add non-enumerable property "${t}" to object`,e)}}function g(e){return e.__sentry_original__}function d(e){return Object.keys(e).map((t=>`${encodeURIComponent(t)}=${encodeURIComponent(e[t])}`)).join("&")}function u(e){if((0,i.bJ)(e))return{message:e.message,name:e.name,stack:e.stack,...p(e)};if((0,i.xH)(e)){const t={type:e.type,target:h(e.target),currentTarget:h(e.currentTarget),...p(e)};return"undefined"!=typeof CustomEvent&&(0,i.tH)(e,CustomEvent)&&(t.detail=e.detail),t}return e}function h(e){try{return(0,i.vq)(e)?(0,s.Hd)(e):Object.prototype.toString.call(e)}catch(e){return""}}function p(e){if("object"==typeof e&&null!==e){const t={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}return{}}function I(e,t=40){const n=Object.keys(u(e));if(n.sort(),!n.length)return"[object has no keys]";if(n[0].length>=t)return(0,a.xv)(n[0],t);for(let e=n.length;e>0;e--){const s=n.slice(0,e).join(", ");if(!(s.length>t))return e===n.length?s:(0,a.xv)(s,t)}return""}function m(e){return C(e,new Map)}function C(e,t){if((0,i.Qd)(e)){const n=t.get(e);if(void 0!==n)return n;const s={};t.set(e,s);for(const n of Object.keys(e))void 0!==e[n]&&(s[n]=C(e[n],t));return s}if(Array.isArray(e)){const n=t.get(e);if(void 0!==n)return n;const s=[];return t.set(e,s),e.forEach((e=>{s.push(C(e,t))})),s}return e}},1040:(e,t,n)=>{"use strict";n.d(t,{cx:()=>c,GY:()=>u,em:()=>l,Up:()=>g,Rj:()=>d});var s=n(3816),o=n(2181),i=n(2879);const r={ip:!1,request:!0,transaction:!0,user:!0},a=["cookies","data","headers","method","query_string","url"],c=["id","username","email"];function l(e,t,n){e&&(e.metadata.source&&"url"!==e.metadata.source||e.setName(...g(t,{path:!0,method:!0})),e.setData("url",t.originalUrl||t.url),t.baseUrl&&e.setData("baseUrl",t.baseUrl),e.setData("query",h(t,n)))}function g(e,t={}){const n=e.method&&e.method.toUpperCase();let s="",o="url";t.customRoute||e.route?(s=t.customRoute||`${e.baseUrl||""}${e.route&&e.route.path}`,o="route"):(e.originalUrl||e.url)&&(s=(0,i.f)(e.originalUrl||e.url||""));let r="";return t.method&&n&&(r+=n),t.method&&t.path&&(r+=" "),t.path&&s&&(r+=s),[r,o]}function d(e,t){const{include:n=a,deps:i}=t||{},r={},c=e.headers||{},l=e.method,g=e.hostname||e.host||c.host||"",d="https"===e.protocol||e.socket&&e.socket.encrypted?"https":"http",u=e.originalUrl||e.url||"",p=u.startsWith(d)?u:`${d}://${g}${u}`;return n.forEach((t=>{switch(t){case"headers":r.headers=c,n.includes("cookies")||delete r.headers.cookie;break;case"method":r.method=l;break;case"url":r.url=p;break;case"cookies":r.cookies=e.cookies||c.cookie&&function(e){const t={};let n=0;for(;n{e&&t in e&&(n[t]=e[t])})),n}(t.user,o.user):{};Object.keys(n).length&&(e.user={...e.user,...n})}if(o.ip){const n=t.ip||t.socket&&t.socket.remoteAddress;n&&(e.user={...e.user,ip_address:n})}return o.transaction&&!e.transaction&&(e.transaction=function(e,t){switch(t){case"path":return g(e,{path:!0})[0];case"handler":return e.route&&e.route.stack&&e.route.stack[0]&&e.route.stack[0].name||"";default:return g(e,{path:!0,method:!0,customRoute:e._reconstructedRoute?e._reconstructedRoute:void 0})[0]}}(t,o.transaction)),e}function h(e,t){let n=e.originalUrl||e.url||"";if(n){n.startsWith("/")&&(n=`http://dogs.are.great${n}`);try{return e.query||void 0!==typeof URL&&new URL(n).search.slice(1)||t&&t.url&&t.url.parse(n).query||void 0}catch(e){return}}}},7930:(e,t,n)=>{"use strict";function s(e,t=!1){return!(t||e&&!e.startsWith("/")&&!e.includes(":\\")&&!e.startsWith(".")&&!e.match(/^[a-zA-Z]([a-zA-Z0-9.\-+])*:\/\//)||void 0===e||e.includes("node_modules/"))}function o(e){const t=/^\s*[-]{4,}$/,n=/at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/;return o=>{const i=o.match(n);if(i){let t,n,o,r,a;if(i[1]){o=i[1];let e=o.lastIndexOf(".");if("."===o[e-1]&&e--,e>0){t=o.slice(0,e),n=o.slice(e+1);const s=t.indexOf(".Module");s>0&&(o=o.slice(s+1),t=t.slice(0,s))}r=void 0}n&&(r=t,a=n),""===n&&(a=void 0,o=void 0),void 0===o&&(a=a||"",o=r?`${r}.${a}`:a);let c=i[2]&&i[2].startsWith("file://")?i[2].slice(7):i[2];const l="native"===i[5];return c||!i[5]||l||(c=i[5]),{filename:c,module:e?e(c):void 0,function:o,lineno:parseInt(i[3],10)||void 0,colno:parseInt(i[4],10)||void 0,in_app:s(c,l)}}if(o.match(t))return{filename:o}}}n.d(t,{gd:()=>c,qQ:()=>d,o:()=>u,vk:()=>l});const i=50,r=/\(error: (.*)\)/,a=/captureMessage|captureException/;function c(...e){const t=e.sort(((e,t)=>e[0]-t[0])).map((e=>e[1]));return(e,n=0)=>{const s=[],o=e.split("\n");for(let e=n;e1024)continue;const a=r.test(n)?n.replace(r,"$1"):n;if(!a.match(/\S*Error: /)){for(const e of t){const t=e(a);if(t){s.push(t);break}}if(s.length>=i)break}}return function(e){if(!e.length)return[];const t=Array.from(e);return/sentryWrapped/.test(t[t.length-1].function||"")&&t.pop(),t.reverse(),a.test(t[t.length-1].function||"")&&(t.pop(),a.test(t[t.length-1].function||"")&&t.pop()),t.slice(0,i).map((e=>({...e,filename:e.filename||t[t.length-1].filename,function:e.function||"?"})))}(s)}}function l(e){return Array.isArray(e)?c(...e):e}const g="";function d(e){try{return e&&"function"==typeof e&&e.name||g}catch(e){return g}}function u(e){return[90,o(e)]}},9653:(e,t,n)=>{"use strict";n.d(t,{Xr:()=>r,nC:()=>i,xv:()=>o});var s=n(3816);function o(e,t=0){return"string"!=typeof e||0===t||e.length<=t?e:`${e.slice(0,t)}...`}function i(e,t){let n=e;const s=n.length;if(s<=150)return n;t>s&&(t=s);let o=Math.max(t-60,0);o<5&&(o=0);let i=Math.min(o+140,s);return i>s-5&&(i=s),i===s&&(o=Math.max(i-140,0)),n=n.slice(o,i),o>0&&(n=`'{snip} ${n}`),ifunction(e,t,n=!1){return!!(0,s.Kg)(e)&&((0,s.gd)(t)?t.test(e):!!(0,s.Kg)(t)&&(n?e===t:e.includes(t)))}(e,t,n)))}},690:(e,t,n)=>{"use strict";n.d(t,{T2:()=>a,XW:()=>i,xg:()=>r});var s,o=n(3816);function i(e){return new a((t=>{t(e)}))}function r(e){return new a(((t,n)=>{n(e)}))}!function(e){e[e.PENDING=0]="PENDING",e[e.RESOLVED=1]="RESOLVED",e[e.REJECTED=2]="REJECTED"}(s||(s={}));class a{constructor(e){a.prototype.__init.call(this),a.prototype.__init2.call(this),a.prototype.__init3.call(this),a.prototype.__init4.call(this),this._state=s.PENDING,this._handlers=[];try{e(this._resolve,this._reject)}catch(e){this._reject(e)}}then(e,t){return new a(((n,s)=>{this._handlers.push([!1,t=>{if(e)try{n(e(t))}catch(e){s(e)}else n(t)},e=>{if(t)try{n(t(e))}catch(e){s(e)}else s(e)}]),this._executeHandlers()}))}catch(e){return this.then((e=>e),e)}finally(e){return new a(((t,n)=>{let s,o;return this.then((t=>{o=!1,s=t,e&&e()}),(t=>{o=!0,s=t,e&&e()})).then((()=>{o?n(s):t(s)}))}))}__init(){this._resolve=e=>{this._setResult(s.RESOLVED,e)}}__init2(){this._reject=e=>{this._setResult(s.REJECTED,e)}}__init3(){this._setResult=(e,t)=>{this._state===s.PENDING&&((0,o.Qg)(t)?t.then(this._resolve,this._reject):(this._state=e,this._value=t,this._executeHandlers()))}}__init4(){this._executeHandlers=()=>{if(this._state===s.PENDING)return;const e=this._handlers.slice();this._handlers=[],e.forEach((e=>{e[0]||(this._state===s.RESOLVED&&e[1](this._value),this._state===s.REJECTED&&e[2](this._value),e[0]=!0)}))}}}},9297:(e,t,n)=>{"use strict";n.d(t,{k3:()=>u,lu:()=>l,zf:()=>g});var s=n(258),o=n(6341);e=n.hmd(e);const i=(0,o.VZ)(),r={nowSeconds:()=>Date.now()/1e3},a=(0,s.wD)()?function(){try{return(0,s.fj)(e,"perf_hooks").performance}catch(e){return}}():function(){const{performance:e}=i;if(e&&e.now)return{now:()=>e.now(),timeOrigin:Date.now()-e.now()}}(),c=void 0===a?r:{nowSeconds:()=>(a.timeOrigin+a.now())/1e3},l=r.nowSeconds.bind(r),g=c.nowSeconds.bind(c);let d;const u=(()=>{const{performance:e}=i;if(!e||!e.now)return void(d="none");const t=36e5,n=e.now(),s=Date.now(),o=e.timeOrigin?Math.abs(e.timeOrigin+n-s):t,r=o{"use strict";n.d(t,{E0:()=>a,MI:()=>i,TC:()=>c,nc:()=>r});var s=n(5584),o=n(6936);const i=new RegExp("^[ \\t]*([0-9a-f]{32})?-?([0-9a-f]{16})?-?([01])?[ \\t]*$");function r(e){if(!e)return;const t=e.match(i);if(!t)return;let n;return"1"===t[3]?n=!0:"0"===t[3]&&(n=!1),{traceId:t[1],parentSampled:n,parentSpanId:t[2]}}function a(e,t){const n=r(e),i=(0,s.yD)(t),{traceId:a,parentSpanId:c,parentSampled:l}=n||{},g={traceId:a||(0,o.eJ)(),spanId:(0,o.eJ)().substring(16),sampled:l};return c&&(g.parentSpanId=c),i&&(g.dsc=i),{traceparentData:n,dynamicSamplingContext:i,propagationContext:g}}function c(e=(0,o.eJ)(),t=(0,o.eJ)().substring(16),n){let s="";return void 0!==n&&(s=n?"-1":"-0"),`${e}-${t}${s}`}},2879:(e,t,n)=>{"use strict";function s(e){if(!e)return{};const t=e.match(/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!t)return{};const n=t[6]||"",s=t[8]||"";return{host:t[4],path:t[5],protocol:t[2],search:n,hash:s,relative:t[5]+n+s}}function o(e){return e.split(/[\?#]/,1)[0]}function i(e){return e.split(/\\?\//).filter((e=>e.length>0&&","!==e)).length}function r(e){const{protocol:t,host:n,path:s}=e;return`${t?`${t}://`:""}${n&&n.replace(/^.*@/,"[filtered]:[filtered]@").replace(/(:80)$/,"").replace(/(:443)$/,"")||""}${s}`}n.d(t,{Dl:()=>s,c4:()=>i,e_:()=>r,f:()=>o})},6341:(e,t,n)=>{"use strict";function s(e){return e&&e.Math==Math?e:void 0}n.d(t,{BY:()=>r,OW:()=>o,VZ:()=>i});const o="object"==typeof globalThis&&s(globalThis)||"object"==typeof window&&s(window)||"object"==typeof self&&s(self)||"object"==typeof global&&s(global)||function(){return this}()||{};function i(){return o}function r(e,t,n){const s=n||o,i=s.__SENTRY__=s.__SENTRY__||{};return i[e]||(i[e]=t())}},9724:function(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const o=n(4434),i=s(n(5753)),r=s(n(1956)),a=i.default("agent-base");function c(){const{stack:e}=new Error;return"string"==typeof e&&e.split("\n").some((e=>-1!==e.indexOf("(https.js:")||-1!==e.indexOf("node:https:")))}function l(e,t){return new l.Agent(e,t)}!function(e){class t extends o.EventEmitter{constructor(e,t){super();let n=t;"function"==typeof e?this.callback=e:e&&(n=e),this.timeout=null,n&&"number"==typeof n.timeout&&(this.timeout=n.timeout),this.maxFreeSockets=1,this.maxSockets=1,this.maxTotalSockets=1/0,this.sockets={},this.freeSockets={},this.requests={},this.options={}}get defaultPort(){return"number"==typeof this.explicitDefaultPort?this.explicitDefaultPort:c()?443:80}set defaultPort(e){this.explicitDefaultPort=e}get protocol(){return"string"==typeof this.explicitProtocol?this.explicitProtocol:c()?"https:":"http:"}set protocol(e){this.explicitProtocol=e}callback(e,t,n){throw new Error('"agent-base" has no default implementation, you must subclass and override `callback()`')}addRequest(e,t){const n=Object.assign({},t);"boolean"!=typeof n.secureEndpoint&&(n.secureEndpoint=c()),null==n.host&&(n.host="localhost"),null==n.port&&(n.port=n.secureEndpoint?443:80),null==n.protocol&&(n.protocol=n.secureEndpoint?"https:":"http:"),n.host&&n.path&&delete n.path,delete n.agent,delete n.hostname,delete n._defaultAgent,delete n.defaultPort,delete n.createConnection,e._last=!0,e.shouldKeepAlive=!1;let s=!1,o=null;const i=n.timeout||this.timeout,l=t=>{e._hadError||(e.emit("error",t),e._hadError=!0)},g=()=>{o=null,s=!0;const e=new Error(`A "socket" was not created for HTTP request before ${i}ms`);e.code="ETIMEOUT",l(e)},d=e=>{s||(null!==o&&(clearTimeout(o),o=null),l(e))},u=t=>{if(s)return;if(null!=o&&(clearTimeout(o),o=null),i=t,Boolean(i)&&"function"==typeof i.addRequest)return a("Callback returned another Agent instance %o",t.constructor.name),void t.addRequest(e,n);var i;if(t)return t.once("free",(()=>{this.freeSocket(t,n)})),void e.onSocket(t);const r=new Error(`no Duplex stream was returned to agent-base for \`${e.method} ${e.path}\``);l(r)};if("function"==typeof this.callback){this.promisifiedCallback||(this.callback.length>=3?(a("Converting legacy callback function to promise"),this.promisifiedCallback=r.default(this.callback)):this.promisifiedCallback=this.callback),"number"==typeof i&&i>0&&(o=setTimeout(g,i)),"port"in n&&"number"!=typeof n.port&&(n.port=Number(n.port));try{a("Resolving socket for %o request: %o",n.protocol,`${e.method} ${e.path}`),Promise.resolve(this.promisifiedCallback(e,n)).then(u,d)}catch(e){Promise.reject(e).catch(d)}}else l(new Error("`callback` is not defined"))}freeSocket(e,t){a("Freeing socket %o %o",e.constructor.name,t),e.destroy()}destroy(){a("Destroying agent %o",this.constructor.name)}}e.Agent=t,e.prototype=e.Agent.prototype}(l||(l={})),e.exports=l},1956:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return function(t,n){return new Promise(((s,o)=>{e.call(this,t,n,((e,t)=>{e?o(e):s(t)}))}))}}},1045:(e,t,n)=>{"use strict";var s=n(181).Buffer,o=n(181).SlowBuffer;function i(e,t){if(!s.isBuffer(e)||!s.isBuffer(t))return!1;if(e.length!==t.length)return!1;for(var n=0,o=0;o{var t=1e3,n=60*t,s=60*n,o=24*s;function i(e,t,n,s){var o=t>=1.5*n;return Math.round(e/n)+" "+s+(o?"s":"")}e.exports=function(e,r){r=r||{};var a,c,l=typeof e;if("string"===l&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var i=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(i){var r=parseFloat(i[1]);switch((i[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*r;case"weeks":case"week":case"w":return 6048e5*r;case"days":case"day":case"d":return r*o;case"hours":case"hour":case"hrs":case"hr":case"h":return r*s;case"minutes":case"minute":case"mins":case"min":case"m":return r*n;case"seconds":case"second":case"secs":case"sec":case"s":return r*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}(e);if("number"===l&&isFinite(e))return r.long?(a=e,(c=Math.abs(a))>=o?i(a,c,o,"day"):c>=s?i(a,c,s,"hour"):c>=n?i(a,c,n,"minute"):c>=t?i(a,c,t,"second"):a+" ms"):function(e){var i=Math.abs(e);return i>=o?Math.round(e/o)+"d":i>=s?Math.round(e/s)+"h":i>=n?Math.round(e/n)+"m":i>=t?Math.round(e/t)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},7833:(e,t,n)=>{t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let s=0,o=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(s++,"%c"===e&&(o=s))})),t.splice(o,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=n(736)(t);const{formatters:s}=e.exports;s.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},736:(e,t,n)=>{e.exports=function(e){function t(e){let n,o,i,r=null;function a(...e){if(!a.enabled)return;const s=a,o=Number(new Date),i=o-(n||o);s.diff=i,s.prev=n,s.curr=o,n=o,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let r=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,o)=>{if("%%"===n)return"%";r++;const i=t.formatters[o];if("function"==typeof i){const t=e[r];n=i.call(s,t),e.splice(r,1),r--}return n})),t.formatArgs.call(s,e),(s.log||t.log).apply(s,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=s,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==r?r:(o!==t.namespaces&&(o=t.namespaces,i=t.enabled(e)),i),set:e=>{r=e}}),"function"==typeof t.init&&t.init(a),a}function s(e,n){const s=t(this.namespace+(void 0===n?":":n)+e);return s.log=this.log,s}function o(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names.map(o),...t.skips.map(o).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const s=("string"==typeof e?e:"").split(/[\s,]+/),o=s.length;for(n=0;n{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t{"undefined"==typeof process||"renderer"===process.type||!0===process.browser||process.__nwjs?e.exports=n(7833):e.exports=n(6033)},6033:(e,t,n)=>{const s=n(9637),o=n(9023);t.init=function(e){e.inspectOpts={};const n=Object.keys(t.inspectOpts);for(let s=0;s{}),"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),t.colors=[6,2,3,4,5,1];try{const e=n(7687);e&&(e.stderr||e).level>=2&&(t.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(e){}t.inspectOpts=Object.keys(process.env).filter((e=>/^debug_/i.test(e))).reduce(((e,t)=>{const n=t.substring(6).toLowerCase().replace(/_([a-z])/g,((e,t)=>t.toUpperCase()));let s=process.env[t];return s=!!/^(yes|on|true|enabled)$/i.test(s)||!/^(no|off|false|disabled)$/i.test(s)&&("null"===s?null:Number(s)),e[n]=s,e}),{}),e.exports=n(736)(t);const{formatters:i}=e.exports;i.o=function(e){return this.inspectOpts.colors=this.useColors,o.inspect(e,this.inspectOpts).split("\n").map((e=>e.trim())).join(" ")},i.O=function(e){return this.inspectOpts.colors=this.useColors,o.inspect(e,this.inspectOpts)}},602:(e,t,n)=>{"use strict";const{Transform:s,PassThrough:o}=n(2203),i=n(3106),r=n(5022);e.exports=e=>{const t=(e.headers["content-encoding"]||"").toLowerCase();if(!["gzip","deflate","br"].includes(t))return e;const n="br"===t;if(n&&"function"!=typeof i.createBrotliDecompress)return e.destroy(new Error("Brotli is not supported on Node.js < 12")),e;let a=!0;const c=new s({transform(e,t,n){a=!1,n(null,e)},flush(e){e()}}),l=new o({autoDestroy:!1,destroy(t,n){e.destroy(),n(t)}}),g=n?i.createBrotliDecompress():i.createUnzip();return g.once("error",(t=>{!a||e.readable?l.destroy(t):l.end()})),r(e,l),e.pipe(c).pipe(g).pipe(l),l}},687:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=(e,t)=>{let n;n="function"==typeof t?{connect:t}:t;const s="function"==typeof n.connect,o="function"==typeof n.secureConnect,i="function"==typeof n.close,r=()=>{s&&n.connect(),function(e){return e.encrypted}(e)&&o&&(e.authorized?n.secureConnect():e.authorizationError||e.once("secureConnect",n.secureConnect)),i&&e.once("close",n.close)};e.writable&&!e.connecting?r():e.connecting?e.once("connect",r):e.destroyed&&i&&n.close(e._hadError)};t.default=n,e.exports=n,e.exports.default=n},2010:(e,t,n)=>{"use strict";var s=n(2861).Buffer,o=n(3527),i=128;function r(e){if(s.isBuffer(e))return e;if("string"==typeof e)return s.from(e,"base64");throw new TypeError("ECDSA signature must be a Base64 string or a Buffer")}function a(e,t,n){for(var s=0;t+s=i&&--s,s}e.exports={derToJose:function(e,t){e=r(e);var n=o(t),i=n+1,a=e.length,c=0;if(48!==e[c++])throw new Error('Could not find expected "seq"');var l=e[c++];if(129===l&&(l=e[c++]),a-c{"use strict";function t(e){return(e/8|0)+(e%8==0?0:1)}var n={ES256:t(256),ES384:t(384),ES512:t(521)};e.exports=function(e){var t=n[e];if(t)return t;throw new Error('Unknown algorithm "'+e+'"')}},6022:e=>{!function(){"use strict";var t=[,function(e,t){function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,s=new Array(t);n255)throw new Error("Not ascii. Base64.encode can only take ascii strings.");e[n]=o}}for(var r=[],a=null,c=null,l=null,g=null,d=0;d>2&63,c=(3&e[d])<<4;break;case 1:c|=e[d]>>4&15,l=(15&e[d])<<2;break;case 2:l|=e[d]>>6&3,g=63&e[d],r.push(s(a)),r.push(s(c)),r.push(s(l)),r.push(s(g)),a=null,c=null,l=null,g=null}return null!=a&&(r.push(s(a)),r.push(s(c)),null==l?r.push("="):r.push(s(l)),null==g&&r.push("=")),r.join("")},decode:function(e){var t=Math.floor(3*e.length/4);"="==e.charAt(e.length-1)&&(t--,"="==e.charAt(e.length-2)&&t--);for(var s,o=i(t),r=null,a=null,c=null,l=0,g=0;g>4,o[l++]=r,a=(15&d)<<4;break;case 2:d>=0&&(a|=d>>2,o[l++]=a,c=(3&d)<<6);break;case 3:d>=0&&(o[l++]=c|d)}}return o},newBinary:i};t.Base64=r},function(e){e.exports={_noYieldsAllowed:function(e){return e()}}},function(e,t){function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function s(e){return JSON.stringify(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=function e(t,o,i,r,a){var c=o[t];switch(n(c)){case"string":return s(c);case"number":return isFinite(c)?String(c):"null";case"boolean":return String(c);case"object":if(!c)return"null";var l,g=r+i,d=[];if(Array.isArray(c)||{}.hasOwnProperty.call(c,"callee")){for(var u=c.length,h=0;h0&&void 0!==arguments[0]&&arguments[0]?a:(0,i.convertMapToObject)(a)},r._getConverters=function(){return c};var l=function(e){for(var t=0;t=d.length||o!==d[s]||!r.equals(e[o],t[d[s]],n)||(s++,0))}))):(s=0,a=g.every((function(o){return!!(0,i.hasOwn)(t,o)&&!!r.equals(e[o],t[o],n)&&(s++,!0)}))),a&&s===d.length},r.clone=function(e){var t;if(!(0,i.isObject)(e))return e;if(null===e)return null;if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp)return e;if(r.isBinary(e)){t=r.newBinary(e.length);for(var n=0;n{"use strict";var t=Object.prototype.hasOwnProperty,n="~";function s(){}function o(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function i(e,t,s,i,r){if("function"!=typeof s)throw new TypeError("The listener must be a function");var a=new o(s,i||e,r),c=n?n+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],a]:e._events[c].push(a):(e._events[c]=a,e._eventsCount++),e}function r(e,t){0==--e._eventsCount?e._events=new s:delete e._events[t]}function a(){this._events=new s,this._eventsCount=0}Object.create&&(s.prototype=Object.create(null),(new s).__proto__||(n=!1)),a.prototype.eventNames=function(){var e,s,o=[];if(0===this._eventsCount)return o;for(s in e=this._events)t.call(e,s)&&o.push(n?s.slice(1):s);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},a.prototype.listeners=function(e){var t=n?n+e:e,s=this._events[t];if(!s)return[];if(s.fn)return[s.fn];for(var o=0,i=s.length,r=new Array(i);o{"use strict";e.exports=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){if(t.constructor!==n.constructor)return!1;var s,o,i;if(Array.isArray(t)){if((s=t.length)!=n.length)return!1;for(o=s;0!=o--;)if(!e(t[o],n[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if((s=(i=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(o=s;0!=o--;)if(!Object.prototype.hasOwnProperty.call(n,i[o]))return!1;for(o=s;0!=o--;){var r=i[o];if(!e(t[r],n[r]))return!1}return!0}return t!=t&&n!=n}},5635:(e,t,n)=>{"use strict";const{PassThrough:s}=n(2203);e.exports=e=>{e={...e};const{array:t}=e;let{encoding:n}=e;const o="buffer"===n;let i=!1;t?i=!(n||o):n=n||"utf8",o&&(n=null);const r=new s({objectMode:i});n&&r.setEncoding(n);let a=0;const c=[];return r.on("data",(e=>{c.push(e),i?a=c.length:a+=e.length})),r.getBufferedValue=()=>t?c:o?Buffer.concat(c,a):c.join(""),r.getBufferedLength=()=>a,r}},4594:(e,t,n)=>{"use strict";const{constants:s}=n(181),o=n(2203),{promisify:i}=n(9023),r=n(5635),a=i(o.pipeline);class c extends Error{constructor(){super("maxBuffer exceeded"),this.name="MaxBufferError"}}async function l(e,t){if(!e)throw new Error("Expected a stream");t={maxBuffer:1/0,...t};const{maxBuffer:n}=t,o=r(t);return await new Promise(((t,i)=>{const r=e=>{e&&o.getBufferedLength()<=s.MAX_LENGTH&&(e.bufferedData=o.getBufferedValue()),i(e)};(async()=>{try{await a(e,o),t()}catch(e){r(e)}})(),o.on("data",(()=>{o.getBufferedLength()>n&&r(new c)}))})),o.getBufferedValue()}e.exports=l,e.exports.buffer=(e,t)=>l(e,{...t,encoding:"buffer"}),e.exports.array=(e,t)=>l(e,{...t,array:!0}),e.exports.MaxBufferError=c},5884:e=>{"use strict";e.exports=(e,t=process.argv)=>{const n=e.startsWith("-")?"":1===e.length?"-":"--",s=t.indexOf(n+e),o=t.indexOf("--");return-1!==s&&(-1===o||s{"use strict";const t=new Set([200,203,204,206,300,301,308,404,405,410,414,501]),n=new Set([200,203,204,300,301,302,303,307,308,404,405,410,414,501]),s=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},i={"content-length":!0,"content-encoding":!0,"transfer-encoding":!0,"content-range":!0};function r(e){const t=parseInt(e,10);return isFinite(t)?t:0}function a(e){const t={};if(!e)return t;const n=e.trim().split(/,/);for(const e of n){const[n,s]=e.split(/=/,2);t[n.trim()]=void 0===s||s.trim().replace(/^"|"$/g,"")}return t}function c(e){let t=[];for(const n in e){const s=e[n];t.push(!0===s?n:n+"="+s)}if(t.length)return t.join(", ")}e.exports=class{constructor(e,t,{shared:n,cacheHeuristic:s,immutableMinTimeToLive:o,ignoreCargoCult:i,_fromObject:r}={}){if(r)this._fromObject(r);else{if(!t||!t.headers)throw Error("Response headers missing");this._assertRequestHasHeaders(e),this._responseTime=this.now(),this._isShared=!1!==n,this._cacheHeuristic=void 0!==s?s:.1,this._immutableMinTtl=void 0!==o?o:864e5,this._status="status"in t?t.status:200,this._resHeaders=t.headers,this._rescc=a(t.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=t.headers.vary?e.headers:null,this._reqcc=a(e.headers["cache-control"]),i&&"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":c(this._rescc)}),delete this._resHeaders.expires,delete this._resHeaders.pragma),null==t.headers["cache-control"]&&/no-cache/.test(t.headers.pragma)&&(this._rescc["no-cache"]=!0)}}now(){return Date.now()}storable(){return!(this._reqcc["no-store"]||!("GET"===this._method||"HEAD"===this._method||"POST"===this._method&&this._hasExplicitExpiration())||!n.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||t.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){this._assertRequestHasHeaders(e);const t=a(e.headers["cache-control"]);return!t["no-cache"]&&!/no-cache/.test(e.headers.pragma)&&(!(t["max-age"]&&this.age()>t["max-age"])&&(!(t["min-fresh"]&&this.timeToLive()<1e3*t["min-fresh"])&&(!(this.stale()&&(!t["max-stale"]||this._rescc["must-revalidate"]||!(!0===t["max-stale"]||t["max-stale"]>this.age()-this.maxAge())))&&this._requestMatches(e,!1))))}_requestMatches(e,t){return(!this._url||this._url===e.url)&&this._host===e.headers.host&&(!e.method||this._method===e.method||t&&"HEAD"===e.method)&&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;const t=this._resHeaders.vary.trim().toLowerCase().split(/\s*,\s*/);for(const n of t)if(e.headers[n]!==this._reqHeaders[n])return!1;return!0}_copyWithoutHopByHopHeaders(e){const t={};for(const n in e)o[n]||(t[n]=e[n]);if(e.connection){const n=e.connection.trim().split(/\s*,\s*/);for(const e of n)delete t[e]}if(t.warning){const e=t.warning.split(/,/).filter((e=>!/^\s*1[0-9][0-9]/.test(e)));e.length?t.warning=e.join(",").trim():delete t.warning}return t}responseHeaders(){const e=this._copyWithoutHopByHopHeaders(this._resHeaders),t=this.age();return t>86400&&!this._hasExplicitExpiration()&&this.maxAge()>86400&&(e.warning=(e.warning?`${e.warning}, `:"")+'113 - "rfc7234 5.5.4"'),e.age=`${Math.round(t)}`,e.date=new Date(this.now()).toUTCString(),e}date(){const e=Date.parse(this._resHeaders.date);return isFinite(e)?e:this._responseTime}age(){return this._ageValue()+(this.now()-this._responseTime)/1e3}_ageValue(){return r(this._resHeaders.age)}maxAge(){if(!this.storable()||this._rescc["no-cache"])return 0;if(this._isShared&&this._resHeaders["set-cookie"]&&!this._rescc.public&&!this._rescc.immutable)return 0;if("*"===this._resHeaders.vary)return 0;if(this._isShared){if(this._rescc["proxy-revalidate"])return 0;if(this._rescc["s-maxage"])return r(this._rescc["s-maxage"])}if(this._rescc["max-age"])return r(this._rescc["max-age"]);const e=this._rescc.immutable?this._immutableMinTtl:0,t=this.date();if(this._resHeaders.expires){const n=Date.parse(this._resHeaders.expires);return Number.isNaN(n)||nn)return Math.max(e,(t-n)/1e3*this._cacheHeuristic)}return e}timeToLive(){const e=this.maxAge()-this.age(),t=e+r(this._rescc["stale-if-error"]),n=e+r(this._rescc["stale-while-revalidate"]);return 1e3*Math.max(0,e,t,n)}stale(){return this.maxAge()<=this.age()}_useStaleIfError(){return this.maxAge()+r(this._rescc["stale-if-error"])>this.age()}useStaleWhileRevalidate(){return this.maxAge()+r(this._rescc["stale-while-revalidate"])>this.age()}static fromObject(e){return new this(void 0,void 0,{_fromObject:e})}_fromObject(e){if(this._responseTime)throw Error("Reinitialized");if(!e||1!==e.v)throw Error("Invalid serialization");this._responseTime=e.t,this._isShared=e.sh,this._cacheHeuristic=e.ch,this._immutableMinTtl=void 0!==e.imm?e.imm:864e5,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,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);const t=this._copyWithoutHopByHopHeaders(e.headers);if(delete t["if-range"],!this._requestMatches(e,!0)||!this.storable())return delete t["if-none-match"],delete t["if-modified-since"],t;if(this._resHeaders.etag&&(t["if-none-match"]=t["if-none-match"]?`${t["if-none-match"]}, ${this._resHeaders.etag}`:this._resHeaders.etag),t["accept-ranges"]||t["if-match"]||t["if-unmodified-since"]||this._method&&"GET"!=this._method){if(delete t["if-modified-since"],t["if-none-match"]){const e=t["if-none-match"].split(/,/).filter((e=>!/^\s*W\//.test(e)));e.length?t["if-none-match"]=e.join(",").trim():delete t["if-none-match"]}}else this._resHeaders["last-modified"]&&!t["if-modified-since"]&&(t["if-modified-since"]=this._resHeaders["last-modified"]);return t}revalidatedPolicy(e,t){if(this._assertRequestHasHeaders(e),this._useStaleIfError()&&function(e){return!e||s.has(e.status)}(t))return{modified:!1,matches:!1,policy:this};if(!t||!t.headers)throw Error("Response headers missing");let n=!1;if(void 0!==t.status&&304!=t.status?n=!1:t.headers.etag&&!/^\s*W\//.test(t.headers.etag)?n=this._resHeaders.etag&&this._resHeaders.etag.replace(/^\s*W\//,"")===t.headers.etag:this._resHeaders.etag&&t.headers.etag?n=this._resHeaders.etag.replace(/^\s*W\//,"")===t.headers.etag.replace(/^\s*W\//,""):this._resHeaders["last-modified"]?n=this._resHeaders["last-modified"]===t.headers["last-modified"]:this._resHeaders.etag||this._resHeaders["last-modified"]||t.headers.etag||t.headers["last-modified"]||(n=!0),!n)return{policy:new this.constructor(e,t),modified:304!=t.status,matches:!1};const o={};for(const e in this._resHeaders)o[e]=e in t.headers&&!i[e]?t.headers[e]:this._resHeaders[e];const r=Object.assign({},t,{status:this._status,method:this._method,headers:o});return{policy:new this.constructor(e,r,{shared:this._isShared,cacheHeuristic:this._cacheHeuristic,immutableMinTimeToLive:this._immutableMinTtl}),modified:!1,matches:!0}}}},7444:(e,t,n)=>{"use strict";const{URL:s}=n(7016),o=n(4434),i=n(4756),r=n(5675),a=n(7392),c=n(2822),l=Symbol("currentStreamCount"),g=Symbol("request"),d=Symbol("cachedOriginSet"),u=Symbol("gracefullyClosing"),h=Symbol("length"),p=["createConnection","maxDeflateDynamicTableSize","maxSettings","maxSessionMemory","maxHeaderListPairs","maxOutstandingPings","maxReservedRemoteStreams","maxSendHeaderBlockLength","paddingStrategy","peerMaxConcurrentStreams","settings","family","localAddress","rejectUnauthorized","pskCallback","minDHSize","path","socket","ca","cert","sigalgs","ciphers","clientCertEngine","crl","dhparam","ecdhCurve","honorCipherOrder","key","privateKeyEngine","privateKeyIdentifier","maxVersion","minVersion","pfx","secureOptions","secureProtocol","sessionIdContext","ticketKeys"],I=(e,t)=>e.remoteSettings.maxConcurrentStreams>t.remoteSettings.maxConcurrentStreams,m=(e,t)=>{for(let n=0;n0&&s[d].lengtht[d].includes(e)))&&s[l]+t[l]<=t.remoteSettings.maxConcurrentStreams&&b(s)}},C=(e,t)=>{for(let n=0;n0&&t[d].lengths[d].includes(e)))&&t[l]+s[l]<=s.remoteSettings.maxConcurrentStreams)return b(t),!0}return!1},b=e=>{e[u]=!0,0===e[l]&&e.close()};class y extends o{constructor({timeout:e=0,maxSessions:t=Number.POSITIVE_INFINITY,maxEmptySessions:n=10,maxCachedTlsSessions:s=100}={}){super(),this.sessions={},this.queue={},this.timeout=e,this.maxSessions=t,this.maxEmptySessions=n,this._emptySessionCount=0,this._sessionCount=0,this.settings={enablePush:!1,initialWindowSize:33554432},this.tlsSessionCache=new a({maxSize:s})}get protocol(){return"https:"}normalizeOptions(e){let t="";for(let n=0;n=this.maxSessions)this.closeEmptySessions(this.maxSessions-this._sessionCount+1);else for(const e in this.queue)for(const t in this.queue[e]){const n=this.queue[e][t];n.completed||(n.completed=!0,n())}}_isBetterSession(e,t){return e>t}_accept(e,t,n,s){let o=0;for(;o0&&(this.getSession(n,s,t),t.length=0)}getSession(e,t,n){return new Promise(((o,i)=>{Array.isArray(n)&&n.length>0?(n=[...n],o()):n=[{resolve:o,reject:i}];try{if("string"==typeof e)e=new s(e);else if(!(e instanceof s))throw new TypeError("The `origin` argument needs to be a string or an URL object");if(t){const{servername:n}=t,{hostname:s}=e;if(n&&s!==n)throw new Error(`Origin ${s} differs from servername ${n}`)}}catch(e){for(let t=0;t=r||n[u]||n.destroyed||(s||(o=r),this._isBetterSession(a,i)&&(s=n,i=a))}if(s)return void this._accept(s,n,c,t)}if(a in this.queue){if(c in this.queue[a])return void this.queue[a][c].listeners.push(...n)}else this.queue[a]={[h]:0};const p=()=>{a in this.queue&&this.queue[a][c]===b&&(delete this.queue[a][c],0==--this.queue[a][h]&&delete this.queue[a])},b=async()=>{this._sessionCount++;const s=`${c}:${a}`;let o,i=!1;try{const y={...t};void 0===y.settings&&(y.settings=this.settings),void 0===y.session&&(y.session=this.tlsSessionCache.get(s));const f=y.createConnection||this.createConnection;o=await f.call(this,e,y),y.createConnection=()=>o;const A=r.connect(e,y);A[l]=0,A[u]=!1;const Z=()=>{const{socket:e}=A;let t;return!1===e.servername?(e.servername=e.remoteAddress,t=A.originSet,e.servername=!1):t=A.originSet,t},G=()=>A[l]{this.tlsSessionCache.set(s,e)})),A.once("error",(e=>{for(let t=0;t{A.destroy()})),A.once("close",(()=>{if(this._sessionCount--,i){this._emptySessionCount--;const e=this.sessions[a];1===e.length?delete this.sessions[a]:e.splice(e.indexOf(A),1)}else{p();const e=new Error("Session closed without receiving a SETTINGS frame");e.code="HTTP2WRAPPER_NOSETTINGS";for(let t=0;t{const e=this.queue[a];if(!e)return;const t=A[d];for(let n=0;n{A[d]=Z()||[],A[u]=!1,C(this.sessions[a],A),!A[u]&&G()&&(v(),G()&&m(this.sessions[a],A))})),A.once("remoteSettings",(()=>{if(b.destroyed){const e=new Error("Agent has been destroyed");for(let t=0;t{let s=0,o=e.length;for(;s>>1;n(e[i],t)?s=i+1:o=i}return s})(t,A,I),0,A)}else e[a]=[A]}i=!0,this._emptySessionCount++,this.emit("session",A),this._accept(A,n,c,t),0===A[l]&&this._emptySessionCount>this.maxEmptySessions&&this.closeEmptySessions(this._emptySessionCount-this.maxEmptySessions),A.on("remoteSettings",(()=>{G()&&(v(),G()&&m(this.sessions[a],A))}))}})),A[g]=A.request,A.request=(e,t)=>{if(A[u])throw new Error("The session is gracefully closing. No new streams are allowed.");const n=A[g](e,t);return A.ref(),0==A[l]++&&this._emptySessionCount--,n.once("close",(()=>{0==--A[l]&&(this._emptySessionCount++,A.unref(),this._emptySessionCount>this.maxEmptySessions||A[u])?A.close():A.destroyed||A.closed||G()&&!C(this.sessions[a],A)&&(m(this.sessions[a],A),v(),0===A[l]&&this._processQueue())})),n}}catch(e){p(),this._sessionCount--;for(let t=0;t{this.getSession(e,t,[{reject:i,resolve:e=>{try{const t=e.request(n,s);c(t),o(t)}catch(e){i(e)}}}])}))}async createConnection(e,t){return y.connect(e,t)}static connect(e,t){t.ALPNProtocols=["h2"];const n=e.port||443,s=e.hostname;void 0===t.servername&&(t.servername=s);const o=i.connect(n,s,t);return t.socket&&(o._peername={family:void 0,address:void 0,port:n}),o}closeEmptySessions(e=Number.POSITIVE_INFINITY){let t=0;const{sessions:n}=this;for(const s in n){const o=n[s];for(let n=0;n=e))return t}}return t}destroy(e){const{sessions:t,queue:n}=this;for(const n in t){const s=t[n];for(let t=0;t{"use strict";const{URL:s,urlToHttpOptions:o}=n(7016),i=n(8611),r=n(5692),a=n(1169),c=n(7392),{Agent:l,globalAgent:g}=n(7444),d=n(2734),u=n(491),h=n(2822),p=new c({maxSize:100}),I=(e,t=new Map,n=void 0)=>async s=>{const o=`${s.host}:${s.port}:${s.ALPNProtocols.sort()}`;if(!e.has(o)){if(t.has(o))return{alpnProtocol:(await t.get(o)).alpnProtocol};const{path:i}=s;s.path=s.socketPath;const r=a(s,n);t.set(o,r);try{const n=await r;return e.set(o,n.alpnProtocol),t.delete(o),s.path=i,n}catch(e){throw t.delete(o),s.path=i,e}}return{alpnProtocol:e.get(o)}},m=I(p,new Map);e.exports=async(e,t,n)=>{if(e="string"==typeof e?o(new s(e)):e instanceof s?o(e):{...e},"function"==typeof t||void 0===t?(n=t,t=e):t=Object.assign(e,t),t.ALPNProtocols=t.ALPNProtocols||["h2","http/1.1"],!Array.isArray(t.ALPNProtocols)||0===t.ALPNProtocols.length)throw new Error("The `ALPNProtocols` option must be an Array with at least one entry");t.protocol=t.protocol||"https:";const a="https:"===t.protocol;t.host=t.hostname||t.host||"localhost",t.session=t.tlsSession,t.servername=t.servername||u(t.headers&&t.headers.host||t.host),t.port=t.port||(a?443:80),t._defaultAgent=a?r.globalAgent:i.globalAgent;const c=t.resolveProtocol||m;let{agent:p}=t;if(void 0!==p&&!1!==p&&"Object"!==p.constructor.name)throw new Error("The `options.agent` can be only an object `http`, `https` or `http2` properties");if(a){t.resolveSocket=!0;let{socket:e,alpnProtocol:s,timeout:o}=await c(t);if(o){e&&e.destroy();const n=new Error(`Timed out resolving ALPN: ${t.timeout} ms`);throw n.code="ETIMEDOUT",n.ms=t.timeout,n}e&&t.createConnection&&(e.destroy(),e=void 0),delete t.resolveSocket;const i="h2"===s;if(p&&(p=i?p.http2:p.https,t.agent=p),void 0===p&&(p=i?g:r.globalAgent),e)if(!1===p)e.destroy();else{const n=(i?l:r.Agent).prototype.createConnection;p.createConnection===n?i?t._reuseSocket=e:((e,t,n)=>{t._httpMessage={shouldKeepAlive:!0};const s=()=>{e.emit("free",t,n)};t.on("free",s);const o=()=>{e.removeSocket(t,n)};t.on("close",o);const i=()=>{const{freeSockets:n}=e;for(const e of Object.values(n))if(e.includes(t))return void t.destroy()};t.on("timeout",i);const r=()=>{e.removeSocket(t,n),t.off("close",o),t.off("free",s),t.off("timeout",i),t.off("agentRemove",r)};t.on("agentRemove",r),e.emit("free",t,n)})(p,e,t):e.destroy()}if(i)return h(new d(t,n))}else p&&(t.agent=p.http);return t.headers&&(t.headers={...t.headers},t.headers[":authority"]&&(t.headers.host||(t.headers.host=t.headers[":authority"]),delete t.headers[":authority"]),delete t.headers[":method"],delete t.headers[":scheme"],delete t.headers[":path"]),h(i.request(t,n))},e.exports.protocolCache=p,e.exports.resolveProtocol=m,e.exports.createResolveProtocol=I},2734:(e,t,n)=>{"use strict";const{URL:s,urlToHttpOptions:o}=n(7016),i=n(5675),{Writable:r}=n(2203),{Agent:a,globalAgent:c}=n(7444),l=n(7235),g=n(1125),{ERR_INVALID_ARG_TYPE:d,ERR_INVALID_PROTOCOL:u,ERR_HTTP_HEADERS_SENT:h}=n(3876),p=n(5711),I=n(9879),m=n(5332),{HTTP2_HEADER_STATUS:C,HTTP2_HEADER_METHOD:b,HTTP2_HEADER_PATH:y,HTTP2_HEADER_AUTHORITY:f,HTTP2_METHOD_CONNECT:A}=i.constants,Z=Symbol("headers"),G=Symbol("origin"),v=Symbol("session"),B=Symbol("options"),W=Symbol("flushedHeaders"),S=Symbol("jobs"),V=Symbol("pendingAgentPromise");e.exports=class extends r{constructor(e,t,n){if(super({autoDestroy:!1,emitClose:!1}),e="string"==typeof e?o(new s(e)):e instanceof s?o(e):{...e},"function"==typeof t||void 0===t?(n=t,t=e):t=Object.assign(e,t),t.h2session){if(this[v]=t.h2session,this[v].destroyed)throw new Error("The session has been closed already");this.protocol=this[v].socket.encrypted?"https:":"http:"}else if(!1===t.agent)this.agent=new a({maxEmptySessions:0});else if(void 0===t.agent||null===t.agent)this.agent=c;else{if("function"!=typeof t.agent.request)throw new d("options.agent",["http2wrapper.Agent-like Object","undefined","false"],t.agent);this.agent=t.agent}if(this.agent&&(this.protocol=this.agent.protocol),t.protocol&&t.protocol!==this.protocol)throw new u(t.protocol,this.protocol);t.port||(t.port=t.defaultPort||this.agent&&this.agent.defaultPort||443),t.host=t.hostname||t.host||"localhost",delete t.hostname;const{timeout:i}=t;t.timeout=void 0,this[Z]=Object.create(null),this[S]=[],this[V]=void 0,this.socket=null,this.connection=null,this.method=t.method||"GET",("CONNECT"!==this.method||"/"!==t.path&&void 0!==t.path)&&(this.path=t.path),this.res=null,this.aborted=!1,this.reusedSocket=!1;const{headers:r}=t;if(r)for(const e in r)this.setHeader(e,r[e]);t.auth&&!("authorization"in this[Z])&&(this[Z].authorization="Basic "+Buffer.from(t.auth).toString("base64")),t.session=t.tlsSession,t.path=t.socketPath,this[B]=t,this[G]=new s(`${this.protocol}//${t.servername||t.host}:${t.port}`);const l=t._reuseSocket;l&&(t.createConnection=(...e)=>l.destroyed?this.agent.createConnection(...e):l,this.agent.getSession(this[G],this[B]).catch((()=>{}))),i&&this.setTimeout(i),n&&this.once("response",n),this[W]=!1}get method(){return this[Z][b]}set method(e){e&&(this[Z][b]=e.toUpperCase())}get path(){const e="CONNECT"===this.method?f:y;return this[Z][e]}set path(e){if(e){const t="CONNECT"===this.method?f:y;this[Z][t]=e}}get host(){return this[G].hostname}set host(e){}get _mustNotHaveABody(){return"GET"===this.method||"HEAD"===this.method||"DELETE"===this.method}_write(e,t,n){if(this._mustNotHaveABody)return void n(new Error("The GET, HEAD and DELETE methods must NOT have a body"));this.flushHeaders();const s=()=>this._request.write(e,t,n);this._request?s():this[S].push(s)}_final(e){this.flushHeaders();const t=()=>{this._mustNotHaveABody||"CONNECT"===this.method?e():this._request.end(e)};this._request?t():this[S].push(t)}abort(){this.res&&this.res.complete||(this.aborted||process.nextTick((()=>this.emit("abort"))),this.aborted=!0,this.destroy())}async _destroy(e,t){this.res&&this.res._dump(),this._request?this._request.destroy():process.nextTick((()=>{this.emit("close")}));try{await this[V]}catch(t){this.aborted&&(e=t)}t(e)}async flushHeaders(){if(this[W]||this.destroyed)return;this[W]=!0;const e=this.method===A,t=t=>{if(this._request=t,this.destroyed)return void t.destroy();e||g(t,this,["timeout","continue"]),t.once("error",(e=>{this.destroy(e)})),t.once("aborted",(()=>{const{res:e}=this;e?(e.aborted=!0,e.emit("aborted"),e.destroy()):this.destroy(new Error("The server aborted the HTTP/2 stream"))}));const n=(n,s,o)=>{const i=new l(this.socket,t.readableHighWaterMark);this.res=i,i.url=`${this[G].origin}${this.path}`,i.req=this,i.statusCode=n[C],i.headers=n,i.rawHeaders=o,i.once("end",(()=>{i.complete=!0,i.socket=null,i.connection=null})),e?(i.upgrade=!0,this.emit("connect",i,t,Buffer.alloc(0))?this.emit("close"):t.destroy()):(t.on("data",(e=>{i._dumped||i.push(e)||t.pause()})),t.once("end",(()=>{this.aborted||i.push(null)})),this.emit("response",i)||i._dump())};t.once("response",n),t.once("headers",(e=>this.emit("information",{statusCode:e[C]}))),t.once("trailers",((e,t,s)=>{const{res:o}=this;null!==o?(o.trailers=e,o.rawTrailers=s):n(e,0,s)})),t.once("close",(()=>{const{aborted:e,res:t}=this;if(t){e&&(t.aborted=!0,t.emit("aborted"),t.destroy());const n=()=>{t.emit("close"),this.destroy(),this.emit("close")};t.readable?t.once("end",n):n()}else{if(!this.destroyed)return this.destroy(new Error("The HTTP/2 stream has been early terminated")),void this.emit("close");this.destroy(),this.emit("close")}})),this.socket=new Proxy(t,m);for(const e of this[S])e();this[S].length=0,this.emit("socket",this.socket)};if(f in this[Z]||e||(this[Z][f]=this[G].host),this[v])try{t(this[v].request(this[Z]))}catch(e){this.destroy(e)}else{this.reusedSocket=!0;try{const e=this.agent.request(this[G],this[B],this[Z]);this[V]=e,t(await e),this[V]=!1}catch(e){this[V]=!1,this.destroy(e)}}}get connection(){return this.socket}set connection(e){this.socket=e}getHeaderNames(){return Object.keys(this[Z])}hasHeader(e){if("string"!=typeof e)throw new d("name","string",e);return Boolean(this[Z][e.toLowerCase()])}getHeader(e){if("string"!=typeof e)throw new d("name","string",e);return this[Z][e.toLowerCase()]}get headersSent(){return this[W]}removeHeader(e){if("string"!=typeof e)throw new d("name","string",e);if(this.headersSent)throw new h("remove");delete this[Z][e.toLowerCase()]}setHeader(e,t){if(this.headersSent)throw new h("set");p(e),I(e,t);const n=e.toLowerCase();if("connection"===n){if("keep-alive"===t.toLowerCase())return;throw new Error(`Invalid 'connection' header: ${t}`)}"host"===n&&"CONNECT"===this.method?this[Z][f]=t:this[Z][n]=t}setNoDelay(){}setSocketKeepAlive(){}setTimeout(e,t){const n=()=>this._request.setTimeout(e,t);return this._request?n():this[S].push(n),this}get maxHeadersCount(){if(!this.destroyed&&this._request)return this._request.session.localSettings.maxHeaderListSize}set maxHeadersCount(e){}}},7235:(e,t,n)=>{"use strict";const{Readable:s}=n(2203);e.exports=class extends s{constructor(e,t){super({emitClose:!1,autoDestroy:!0,highWaterMark:t}),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._dumped=!1}get connection(){return this.socket}set connection(e){this.socket=e}_destroy(e,t){this.readableEnded||(this.aborted=!0),t(),this.req._request.destroy(e)}setTimeout(e,t){return this.req.setTimeout(e,t),this}_dump(){this._dumped||(this._dumped=!0,this.removeAllListeners("data"),this.resume())}_read(){this.req&&this.req._request.resume()}}},5769:(e,t,n)=>{"use strict";const s=n(5675),{Agent:o,globalAgent:i}=n(7444),r=n(2734),a=n(7235),c=n(2094),{HttpOverHttp2:l,HttpsOverHttp2:g}=n(201),d=n(312),{Http2OverHttp:u,Http2OverHttps:h}=n(449),p=n(5711),I=n(9879);e.exports={...s,ClientRequest:r,IncomingMessage:a,Agent:o,globalAgent:i,request:(e,t,n)=>new r(e,t,n),get:(e,t,n)=>{const s=new r(e,t,n);return s.end(),s},auto:c,proxies:{HttpOverHttp2:l,HttpsOverHttp2:g,Http2OverHttp2:d,Http2OverHttp:u,Http2OverHttps:h},validateHeaderName:p,validateHeaderValue:I}},9350:e=>{"use strict";e.exports=e=>{const{username:t,password:n}=e.proxyOptions.url;if(t||n){const e=`${t}:${n}`,s=`Basic ${Buffer.from(e).toString("base64")}`;return{"proxy-authorization":s,authorization:s}}return{}}},201:(e,t,n)=>{"use strict";const s=n(4756),o=n(8611),i=n(5692),r=n(6559),{globalAgent:a}=n(7444),c=n(3305),l=n(4394),g=n(9350),d=(e,t,n)=>{(async()=>{try{const{proxyOptions:o}=e,{url:l,headers:d,raw:u}=o,h=await a.request(l,o,{...g(e),...d,":method":"CONNECT",":authority":`${t.host}:${t.port}`});h.once("error",n),h.once("response",(o=>{const a=o[":status"];if(200!==a)return void n(new c(a,""));const l=e instanceof i.Agent;if(u&&l){t.socket=h;const e=s.connect(t);return e.once("close",(()=>{h.destroy()})),void n(null,e)}const g=new r(h);g.encrypted=!1,g._handle.getpeername=e=>{e.family=void 0,e.address=void 0,e.port=void 0},n(null,g)}))}catch(e){n(e)}})()};class u extends o.Agent{constructor(e){super(e),l(this,e.proxyOptions)}createConnection(e,t){d(this,e,t)}}class h extends i.Agent{constructor(e){super(e),l(this,e.proxyOptions)}createConnection(e,t){d(this,e,t)}}e.exports={HttpOverHttp2:u,HttpsOverHttp2:h}},449:(e,t,n)=>{"use strict";const s=n(8611),o=n(5692),i=n(6538),r=n(9350);class a extends i{async _getProxyStream(e){const{proxyOptions:t}=this,{url:n,headers:i}=this.proxyOptions;return a=("https:"===n.protocol?o:s).request({...t,hostname:n.hostname,port:n.port,path:e,headers:{...r(this),...i,host:e},method:"CONNECT"}).end(),new Promise(((e,t)=>{a.once("error",t),a.once("connect",((n,s,o)=>{s.unshift(o),a.off("error",t),e([s,n.statusCode,n.statusMessage])}))}));var a}}e.exports={Http2OverHttp:a,Http2OverHttps:a}},312:(e,t,n)=>{"use strict";const{globalAgent:s}=n(7444),o=n(6538),i=n(9350);e.exports=class extends o{async _getProxyStream(e){const{proxyOptions:t}=this,n={...i(this),...t.headers,":method":"CONNECT",":authority":e},o=await s.request(t.url,t,n),r=await(e=>new Promise(((t,n)=>{e.once("error",n),e.once("response",(s=>{e.off("error",n),t(s[":status"])}))})))(o);return[o,r,""]}}},6538:(e,t,n)=>{"use strict";const{Agent:s}=n(7444),o=n(6559),i=n(3305),r=n(4394);e.exports=class extends s{constructor(e){super(e),r(this,e.proxyOptions)}async createConnection(e,t){const n=`${e.hostname}:${e.port||443}`,[s,r,a]=await this._getProxyStream(n);if(200!==r)throw new i(r,a);if(!this.proxyOptions.raw){const e=new o(s);return e.encrypted=!1,e._handle.getpeername=e=>{e.family=void 0,e.address=void 0,e.port=void 0},e}return t.socket=s,super.createConnection(e,t)}}},4394:(e,t,n)=>{"use strict";const{URL:s}=n(7016),o=n(9420);e.exports=(e,t)=>{o("proxyOptions",t,["object"]),o("proxyOptions.headers",t.headers,["object","undefined"]),o("proxyOptions.raw",t.raw,["boolean","undefined"]),o("proxyOptions.url",t.url,[s,"string"]);const n=new s(t.url);e.proxyOptions={raw:!0,...t,headers:{...t.headers},url:n}}},3305:e=>{"use strict";class t extends Error{constructor(e,t=""){super(`The proxy server rejected the request with status code ${e} (${t||"empty status message"})`),this.statusCode=e,this.statusMessage=t}}e.exports=t},491:(e,t,n)=>{"use strict";const{isIP:s}=n(9278),o=n(2613);e.exports=e=>{const t=(e=>{if("["===e[0]){const t=e.indexOf("]");return o(-1!==t),e.slice(1,t)}const t=e.indexOf(":");return-1===t?e:e.slice(0,t)})(e);return s(t)?"":t}},9420:e=>{"use strict";e.exports=(e,t,n)=>{if(!n.some((e=>"string"==typeof e?typeof t===e:t instanceof e))){const s=n.map((e=>"string"==typeof e?e:e.name));throw new TypeError(`Expected '${e}' to be a type of ${s.join(" or ")}, got ${typeof t}`)}}},2822:e=>{"use strict";e.exports=e=>{if(0!==e.listenerCount("error"))return e;e.__destroy=e._destroy,e._destroy=(...t)=>{const n=t.pop();e.__destroy(...t,(async e=>{await Promise.resolve(),n(e)}))};const t=t=>{Promise.resolve().then((()=>{e.emit("error",t)}))};return e.once("error",t),Promise.resolve().then((()=>{e.off("error",t)})),e}},3876:e=>{"use strict";const t=(t,n,s)=>{e.exports[n]=class extends t{constructor(...e){super("string"==typeof s?s:s(e)),this.name=`${super.name} [${n}]`,this.code=n}}};t(TypeError,"ERR_INVALID_ARG_TYPE",(e=>{const t=e[0].includes(".")?"property":"argument";let n=e[1];const s=Array.isArray(n);return s&&(n=`${n.slice(0,-1).join(", ")} or ${n.slice(-1)}`),`The "${e[0]}" ${t} must be ${s?"one of":"of"} type ${n}. Received ${typeof e[2]}`})),t(TypeError,"ERR_INVALID_PROTOCOL",(e=>`Protocol "${e[0]}" not supported. Expected "${e[1]}"`)),t(Error,"ERR_HTTP_HEADERS_SENT",(e=>`Cannot ${e[0]} headers after they are sent to the client`)),t(TypeError,"ERR_INVALID_HTTP_TOKEN",(e=>`${e[0]} must be a valid HTTP token [${e[1]}]`)),t(TypeError,"ERR_HTTP_INVALID_HEADER_VALUE",(e=>`Invalid value "${e[0]} for header "${e[1]}"`)),t(TypeError,"ERR_INVALID_CHAR",(e=>`Invalid character in ${e[0]} [${e[1]}]`)),t(Error,"ERR_HTTP2_NO_SOCKET_MANIPULATION","HTTP/2 sockets should not be directly manipulated (e.g. read and written)")},3610:e=>{"use strict";e.exports=e=>{switch(e){case":method":case":scheme":case":authority":case":path":return!0;default:return!1}}},6559:(e,t,n)=>{"use strict";const s=n(2203),o=new(n(4756).TLSSocket)(new s.PassThrough)._handle._parentWrap.constructor;e.exports=o},1125:e=>{"use strict";e.exports=(e,t,n)=>{for(const s of n)e.on(s,((...e)=>t.emit(s,...e)))}},5332:(e,t,n)=>{"use strict";const{ERR_HTTP2_NO_SOCKET_MANIPULATION:s}=n(3876),o={has(e,t){const n=void 0===e.session?e:e.session.socket;return t in e||t in n},get(e,t){switch(t){case"on":case"once":case"end":case"emit":case"destroy":return e[t].bind(e);case"writable":case"destroyed":return e[t];case"readable":return!e.destroyed&&e.readable;case"setTimeout":{const{session:t}=e;return void 0!==t?t.setTimeout.bind(t):e.setTimeout.bind(e)}case"write":case"read":case"pause":case"resume":throw new s;default:{const n=void 0===e.session?e:e.session.socket,s=n[t];return"function"==typeof s?s.bind(n):s}}},getPrototypeOf:e=>void 0!==e.session?Reflect.getPrototypeOf(e.session.socket):Reflect.getPrototypeOf(e),set(e,t,n){switch(t){case"writable":case"readable":case"destroyed":case"on":case"once":case"end":case"emit":case"destroy":return e[t]=n,!0;case"setTimeout":{const{session:t}=e;return void 0===t?e.setTimeout=n:t.setTimeout=n,!0}case"write":case"read":case"pause":case"resume":throw new s;default:return(void 0===e.session?e:e.session.socket)[t]=n,!0}}};e.exports=o},5711:(e,t,n)=>{"use strict";const{ERR_INVALID_HTTP_TOKEN:s}=n(3876),o=n(3610),i=/^[\^`\-\w!#$%&*+.|~]+$/;e.exports=e=>{if("string"!=typeof e||!i.test(e)&&!o(e))throw new s("Header name",e)}},9879:(e,t,n)=>{"use strict";const{ERR_HTTP_INVALID_HEADER_VALUE:s,ERR_INVALID_CHAR:o}=n(3876),i=/[^\t\u0020-\u007E\u0080-\u00FF]/;e.exports=(e,t)=>{if(void 0===t)throw new s(t,e);if(i.test(t))throw new o("header content",e)}},6329:function(e,t,n){"use strict";var s=this&&this.__awaiter||function(e,t,n,s){return new(n||(n=Promise))((function(o,i){function r(e){try{c(s.next(e))}catch(e){i(e)}}function a(e){try{c(s.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,a)}c((s=s.apply(e,t||[])).next())}))},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=o(n(9278)),r=o(n(4756)),a=o(n(7016)),c=o(n(2613)),l=o(n(5753)),g=n(9724),d=o(n(3868)),u=l.default("https-proxy-agent:agent");class h extends g.Agent{constructor(e){let t;if(t="string"==typeof e?a.default.parse(e):e,!t)throw new Error("an HTTP(S) proxy server `host` and `port` must be specified!");u("creating new HttpsProxyAgent instance: %o",t),super(t);const n=Object.assign({},t);var s;this.secureProxy=t.secureProxy||"string"==typeof(s=n.protocol)&&/^https:?$/i.test(s),n.host=n.hostname||n.host,"string"==typeof n.port&&(n.port=parseInt(n.port,10)),!n.port&&n.host&&(n.port=this.secureProxy?443:80),this.secureProxy&&!("ALPNProtocols"in n)&&(n.ALPNProtocols=["http 1.1"]),n.host&&n.path&&(delete n.path,delete n.pathname),this.proxy=n}callback(e,t){return s(this,void 0,void 0,(function*(){const{proxy:n,secureProxy:s}=this;let o;s?(u("Creating `tls.Socket`: %o",n),o=r.default.connect(n)):(u("Creating `net.Socket`: %o",n),o=i.default.connect(n));const a=Object.assign({},n.headers);let l=`CONNECT ${t.host}:${t.port} HTTP/1.1\r\n`;n.auth&&(a["Proxy-Authorization"]=`Basic ${Buffer.from(n.auth).toString("base64")}`);let{host:g,port:h,secureEndpoint:I}=t;(function(e,t){return Boolean(!t&&80===e||t&&443===e)})(h,I)||(g+=`:${h}`),a.Host=g,a.Connection="close";for(const e of Object.keys(a))l+=`${e}: ${a[e]}\r\n`;const m=d.default(o);o.write(`${l}\r\n`);const{statusCode:C,buffered:b}=yield m;if(200===C){if(e.once("socket",p),t.secureEndpoint){u("Upgrading socket connection to TLS");const e=t.servername||t.host;return r.default.connect(Object.assign(Object.assign({},function(e,...t){const n={};let s;for(s in e)t.includes(s)||(n[s]=e[s]);return n}(t,"host","hostname","path","port")),{socket:o,servername:e}))}return o}o.destroy();const y=new i.default.Socket({writable:!1});return y.readable=!0,e.once("socket",(e=>{u("replaying proxy buffer for failed request"),c.default(e.listenerCount("data")>0),e.push(b),e.push(null)})),y}))}}function p(e){e.resume()}t.default=h},2288:function(e,t,n){"use strict";const s=(this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(n(6329));function o(e){return new s.default(e)}!function(e){e.HttpsProxyAgent=s.default,e.prototype=s.default.prototype}(o||(o={})),e.exports=o},3868:function(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=s(n(5753)).default("https-proxy-agent:parse-proxy-response");t.default=function(e){return new Promise(((t,n)=>{let s=0;const i=[];function r(){const n=e.read();n?function(e){i.push(e),s+=e.length;const n=Buffer.concat(i,s);if(-1===n.indexOf("\r\n\r\n"))return o("have not received end of HTTP headers yet..."),void r();const a=n.toString("ascii",0,n.indexOf("\r\n")),c=+a.split(" ")[1];o("got proxy server response: %o",a),t({statusCode:c,buffered:n})}(n):e.once("readable",r)}function a(e){o("onclose had error %o",e)}function c(){o("onend")}e.on("error",(function t(s){e.removeListener("end",c),e.removeListener("error",t),e.removeListener("close",a),e.removeListener("readable",r),o("onerror %o",s),n(s)})),e.on("close",a),e.on("end",c),r()}))}},5516:(e,t)=>{t.stringify=function e(t){if(void 0===t)return t;if(t&&Buffer.isBuffer(t))return JSON.stringify(":base64:"+t.toString("base64"));if(t&&t.toJSON&&(t=t.toJSON()),t&&"object"==typeof t){var n="",s=Array.isArray(t);n=s?"[":"{";var o=!0;for(var i in t){var r="function"==typeof t[i]||!s&&void 0===t[i];Object.hasOwnProperty.call(t,i)&&!r&&(o||(n+=","),o=!1,s?null==t[i]?n+="null":n+=e(t[i]):void 0!==t[i]&&(n+=e(i)+":"+e(t[i])))}return n+(s?"]":"}")}return"string"==typeof t?JSON.stringify(/^:/.test(t)?":"+t:t):void 0===t?"null":JSON.stringify(t)},t.parse=function(e){return JSON.parse(e,(function(e,t){return"string"==typeof t?/^:base64:/.test(t)?Buffer.from(t.substring(8),"base64"):/^:/.test(t)?t.substring(1):t:t}))}},7260:(e,t,n)=>{var s=n(5747);e.exports=function(e,t){t=t||{};var n=s.decode(e,t);if(!n)return null;var o=n.payload;if("string"==typeof o)try{var i=JSON.parse(o);null!==i&&"object"==typeof i&&(o=i)}catch(e){}return!0===t.complete?{header:n.header,payload:o,signature:n.signature}:o}},4040:(e,t,n)=>{e.exports={decode:n(7260),verify:n(1691),sign:n(7651),JsonWebTokenError:n(1741),NotBeforeError:n(3726),TokenExpiredError:n(8980)}},1741:e=>{var t=function(e,t){Error.call(this,e),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name="JsonWebTokenError",this.message=e,t&&(this.inner=t)};(t.prototype=Object.create(Error.prototype)).constructor=t,e.exports=t},3726:(e,t,n)=>{var s=n(1741),o=function(e,t){s.call(this,e),this.name="NotBeforeError",this.date=t};(o.prototype=Object.create(s.prototype)).constructor=o,e.exports=o},8980:(e,t,n)=>{var s=n(1741),o=function(e,t){s.call(this,e),this.name="TokenExpiredError",this.expiredAt=t};(o.prototype=Object.create(s.prototype)).constructor=o,e.exports=o},1977:(e,t,n)=>{const s=n(5864);e.exports=s.satisfies(process.version,">=15.7.0")},4977:(e,t,n)=>{var s=n(5864);e.exports=s.satisfies(process.version,"^6.12.0 || >=8.0.0")},4623:(e,t,n)=>{const s=n(5864);e.exports=s.satisfies(process.version,">=16.9.0")},855:(e,t,n)=>{var s=n(6585);e.exports=function(e,t){var n=t||Math.floor(Date.now()/1e3);if("string"==typeof e){var o=s(e);if(void 0===o)return;return Math.floor(n+o/1e3)}return"number"==typeof e?n+e:void 0}},7019:(e,t,n)=>{const s=n(1977),o=n(4623),i={ec:["ES256","ES384","ES512"],rsa:["RS256","PS256","RS384","PS384","RS512","PS512"],"rsa-pss":["PS256","PS384","PS512"]},r={ES256:"prime256v1",ES384:"secp384r1",ES512:"secp521r1"};e.exports=function(e,t){if(!e||!t)return;const n=t.asymmetricKeyType;if(!n)return;const a=i[n];if(!a)throw new Error(`Unknown key type "${n}".`);if(!a.includes(e))throw new Error(`"alg" parameter for "${n}" key type must be one of: ${a.join(", ")}.`);if(s)switch(n){case"ec":const n=t.asymmetricKeyDetails.namedCurve,s=r[e];if(n!==s)throw new Error(`"alg" parameter "${e}" requires curve "${s}".`);break;case"rsa-pss":if(o){const n=parseInt(e.slice(-3),10),{hashAlgorithm:s,mgf1HashAlgorithm:o,saltLength:i}=t.asymmetricKeyDetails;if(s!==`sha${n}`||o!==s)throw new Error(`Invalid key for this operation, its RSA-PSS parameters do not meet the requirements of "alg" ${e}.`);if(void 0!==i&&i>n>>3)throw new Error(`Invalid key for this operation, its RSA-PSS parameter saltLength does not meet the requirements of "alg" ${e}.`)}}}},2659:(e,t,n)=>{const s=Symbol("SemVer ANY");class o{static get ANY(){return s}constructor(e,t){if(t=i(t),e instanceof o){if(e.loose===!!t.loose)return e;e=e.value}e=e.trim().split(/\s+/).join(" "),l("comparator",e,t),this.options=t,this.loose=!!t.loose,this.parse(e),this.semver===s?this.value="":this.value=this.operator+this.semver.version,l("comp",this)}parse(e){const t=this.options.loose?r[a.COMPARATORLOOSE]:r[a.COMPARATOR],n=e.match(t);if(!n)throw new TypeError(`Invalid comparator: ${e}`);this.operator=void 0!==n[1]?n[1]:"","="===this.operator&&(this.operator=""),n[2]?this.semver=new g(n[2],this.options.loose):this.semver=s}toString(){return this.value}test(e){if(l("Comparator.test",e,this.options.loose),this.semver===s||e===s)return!0;if("string"==typeof e)try{e=new g(e,this.options)}catch(e){return!1}return c(e,this.operator,this.semver,this.options)}intersects(e,t){if(!(e instanceof o))throw new TypeError("a Comparator is required");return""===this.operator?""===this.value||new d(e.value,t).test(this.value):""===e.operator?""===e.value||new d(this.value,t).test(e.semver):!((t=i(t)).includePrerelease&&("<0.0.0-0"===this.value||"<0.0.0-0"===e.value)||!t.includePrerelease&&(this.value.startsWith("<0.0.0")||e.value.startsWith("<0.0.0"))||(!this.operator.startsWith(">")||!e.operator.startsWith(">"))&&(!this.operator.startsWith("<")||!e.operator.startsWith("<"))&&(this.semver.version!==e.semver.version||!this.operator.includes("=")||!e.operator.includes("="))&&!(c(this.semver,"<",e.semver,t)&&this.operator.startsWith(">")&&e.operator.startsWith("<"))&&!(c(this.semver,">",e.semver,t)&&this.operator.startsWith("<")&&e.operator.startsWith(">")))}}e.exports=o;const i=n(9284),{safeRe:r,t:a}=n(2351),c=n(630),l=n(6839),g=n(6315),d=n(5006)},5006:(e,t,n)=>{const s=/\s+/g;class o{constructor(e,t){if(t=r(t),e instanceof o)return e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease?e:new o(e.raw,t);if(e instanceof a)return this.raw=e.value,this.set=[[e]],this.formatted=void 0,this;if(this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease,this.raw=e.trim().replace(s," "),this.set=this.raw.split("||").map((e=>this.parseRange(e.trim()))).filter((e=>e.length)),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const e=this.set[0];if(this.set=this.set.filter((e=>!C(e[0]))),0===this.set.length)this.set=[e];else if(this.set.length>1)for(const e of this.set)if(1===e.length&&b(e[0])){this.set=[e];break}}this.formatted=void 0}get range(){if(void 0===this.formatted){this.formatted="";for(let e=0;e0&&(this.formatted+="||");const t=this.set[e];for(let e=0;e0&&(this.formatted+=" "),this.formatted+=t[e].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(e){const t=((this.options.includePrerelease&&I)|(this.options.loose&&m))+":"+e,n=i.get(t);if(n)return n;const s=this.options.loose,o=s?g[d.HYPHENRANGELOOSE]:g[d.HYPHENRANGE];e=e.replace(o,R(this.options.includePrerelease)),c("hyphen replace",e),e=e.replace(g[d.COMPARATORTRIM],u),c("comparator trim",e),e=e.replace(g[d.TILDETRIM],h),c("tilde trim",e),e=e.replace(g[d.CARETTRIM],p),c("caret trim",e);let r=e.split(" ").map((e=>f(e,this.options))).join(" ").split(/\s+/).map((e=>w(e,this.options)));s&&(r=r.filter((e=>(c("loose invalid filter",e,this.options),!!e.match(g[d.COMPARATORLOOSE]))))),c("range list",r);const l=new Map,b=r.map((e=>new a(e,this.options)));for(const e of b){if(C(e))return[e];l.set(e.value,e)}l.size>1&&l.has("")&&l.delete("");const y=[...l.values()];return i.set(t,y),y}intersects(e,t){if(!(e instanceof o))throw new TypeError("a Range is required");return this.set.some((n=>y(n,t)&&e.set.some((e=>y(e,t)&&n.every((n=>e.every((e=>n.intersects(e,t)))))))))}test(e){if(!e)return!1;if("string"==typeof e)try{e=new l(e,this.options)}catch(e){return!1}for(let t=0;t"<0.0.0-0"===e.value,b=e=>""===e.value,y=(e,t)=>{let n=!0;const s=e.slice();let o=s.pop();for(;n&&s.length;)n=s.every((e=>o.intersects(e,t))),o=s.pop();return n},f=(e,t)=>(c("comp",e,t),e=v(e,t),c("caret",e),e=Z(e,t),c("tildes",e),e=W(e,t),c("xrange",e),e=V(e,t),c("stars",e),e),A=e=>!e||"x"===e.toLowerCase()||"*"===e,Z=(e,t)=>e.trim().split(/\s+/).map((e=>G(e,t))).join(" "),G=(e,t)=>{const n=t.loose?g[d.TILDELOOSE]:g[d.TILDE];return e.replace(n,((t,n,s,o,i)=>{let r;return c("tilde",e,t,n,s,o,i),A(n)?r="":A(s)?r=`>=${n}.0.0 <${+n+1}.0.0-0`:A(o)?r=`>=${n}.${s}.0 <${n}.${+s+1}.0-0`:i?(c("replaceTilde pr",i),r=`>=${n}.${s}.${o}-${i} <${n}.${+s+1}.0-0`):r=`>=${n}.${s}.${o} <${n}.${+s+1}.0-0`,c("tilde return",r),r}))},v=(e,t)=>e.trim().split(/\s+/).map((e=>B(e,t))).join(" "),B=(e,t)=>{c("caret",e,t);const n=t.loose?g[d.CARETLOOSE]:g[d.CARET],s=t.includePrerelease?"-0":"";return e.replace(n,((t,n,o,i,r)=>{let a;return c("caret",e,t,n,o,i,r),A(n)?a="":A(o)?a=`>=${n}.0.0${s} <${+n+1}.0.0-0`:A(i)?a="0"===n?`>=${n}.${o}.0${s} <${n}.${+o+1}.0-0`:`>=${n}.${o}.0${s} <${+n+1}.0.0-0`:r?(c("replaceCaret pr",r),a="0"===n?"0"===o?`>=${n}.${o}.${i}-${r} <${n}.${o}.${+i+1}-0`:`>=${n}.${o}.${i}-${r} <${n}.${+o+1}.0-0`:`>=${n}.${o}.${i}-${r} <${+n+1}.0.0-0`):(c("no pr"),a="0"===n?"0"===o?`>=${n}.${o}.${i}${s} <${n}.${o}.${+i+1}-0`:`>=${n}.${o}.${i}${s} <${n}.${+o+1}.0-0`:`>=${n}.${o}.${i} <${+n+1}.0.0-0`),c("caret return",a),a}))},W=(e,t)=>(c("replaceXRanges",e,t),e.split(/\s+/).map((e=>S(e,t))).join(" ")),S=(e,t)=>{e=e.trim();const n=t.loose?g[d.XRANGELOOSE]:g[d.XRANGE];return e.replace(n,((n,s,o,i,r,a)=>{c("xRange",e,n,s,o,i,r,a);const l=A(o),g=l||A(i),d=g||A(r),u=d;return"="===s&&u&&(s=""),a=t.includePrerelease?"-0":"",l?n=">"===s||"<"===s?"<0.0.0-0":"*":s&&u?(g&&(i=0),r=0,">"===s?(s=">=",g?(o=+o+1,i=0,r=0):(i=+i+1,r=0)):"<="===s&&(s="<",g?o=+o+1:i=+i+1),"<"===s&&(a="-0"),n=`${s+o}.${i}.${r}${a}`):g?n=`>=${o}.0.0${a} <${+o+1}.0.0-0`:d&&(n=`>=${o}.${i}.0${a} <${o}.${+i+1}.0-0`),c("xRange return",n),n}))},V=(e,t)=>(c("replaceStars",e,t),e.trim().replace(g[d.STAR],"")),w=(e,t)=>(c("replaceGTE0",e,t),e.trim().replace(g[t.includePrerelease?d.GTE0PRE:d.GTE0],"")),R=e=>(t,n,s,o,i,r,a,c,l,g,d,u)=>`${n=A(s)?"":A(o)?`>=${s}.0.0${e?"-0":""}`:A(i)?`>=${s}.${o}.0${e?"-0":""}`:r?`>=${n}`:`>=${n}${e?"-0":""}`} ${c=A(l)?"":A(g)?`<${+l+1}.0.0-0`:A(d)?`<${l}.${+g+1}.0-0`:u?`<=${l}.${g}.${d}-${u}`:e?`<${l}.${g}.${+d+1}-0`:`<=${c}`}`.trim(),H=(e,t,n)=>{for(let n=0;n0){const s=e[n].semver;if(s.major===t.major&&s.minor===t.minor&&s.patch===t.patch)return!0}return!1}return!0}},6315:(e,t,n)=>{const s=n(6839),{MAX_LENGTH:o,MAX_SAFE_INTEGER:i}=n(5501),{safeRe:r,t:a}=n(2351),c=n(9284),{compareIdentifiers:l}=n(9716);class g{constructor(e,t){if(t=c(t),e instanceof g){if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease)return e;e=e.version}else if("string"!=typeof e)throw new TypeError(`Invalid version. Must be a string. Got type "${typeof e}".`);if(e.length>o)throw new TypeError(`version is longer than ${o} characters`);s("SemVer",e,t),this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease;const n=e.trim().match(t.loose?r[a.LOOSE]:r[a.FULL]);if(!n)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+n[1],this.minor=+n[2],this.patch=+n[3],this.major>i||this.major<0)throw new TypeError("Invalid major version");if(this.minor>i||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>i||this.patch<0)throw new TypeError("Invalid patch version");n[4]?this.prerelease=n[4].split(".").map((e=>{if(/^[0-9]+$/.test(e)){const t=+e;if(t>=0&&t=0;)"number"==typeof this.prerelease[s]&&(this.prerelease[s]++,s=-2);if(-1===s){if(t===this.prerelease.join(".")&&!1===n)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(e)}}if(t){let s=[t,e];!1===n&&(s=[t]),0===l(this.prerelease[0],t)?isNaN(this.prerelease[1])&&(this.prerelease=s):this.prerelease=s}break}default:throw new Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}}e.exports=g},871:(e,t,n)=>{const s=n(7153);e.exports=(e,t)=>{const n=s(e.trim().replace(/^[=v]+/,""),t);return n?n.version:null}},630:(e,t,n)=>{const s=n(4506),o=n(4654),i=n(9671),r=n(9540),a=n(6912),c=n(8445);e.exports=(e,t,n,l)=>{switch(t){case"===":return"object"==typeof e&&(e=e.version),"object"==typeof n&&(n=n.version),e===n;case"!==":return"object"==typeof e&&(e=e.version),"object"==typeof n&&(n=n.version),e!==n;case"":case"=":case"==":return s(e,n,l);case"!=":return o(e,n,l);case">":return i(e,n,l);case">=":return r(e,n,l);case"<":return a(e,n,l);case"<=":return c(e,n,l);default:throw new TypeError(`Invalid operator: ${t}`)}}},2393:(e,t,n)=>{const s=n(6315),o=n(7153),{safeRe:i,t:r}=n(2351);e.exports=(e,t)=>{if(e instanceof s)return e;if("number"==typeof e&&(e=String(e)),"string"!=typeof e)return null;let n=null;if((t=t||{}).rtl){const s=t.includePrerelease?i[r.COERCERTLFULL]:i[r.COERCERTL];let o;for(;(o=s.exec(e))&&(!n||n.index+n[0].length!==e.length);)n&&o.index+o[0].length===n.index+n[0].length||(n=o),s.lastIndex=o.index+o[1].length+o[2].length;s.lastIndex=-1}else n=e.match(t.includePrerelease?i[r.COERCEFULL]:i[r.COERCE]);if(null===n)return null;const a=n[2],c=n[3]||"0",l=n[4]||"0",g=t.includePrerelease&&n[5]?`-${n[5]}`:"",d=t.includePrerelease&&n[6]?`+${n[6]}`:"";return o(`${a}.${c}.${l}${g}${d}`,t)}},4848:(e,t,n)=>{const s=n(6315);e.exports=(e,t,n)=>{const o=new s(e,n),i=new s(t,n);return o.compare(i)||o.compareBuild(i)}},8474:(e,t,n)=>{const s=n(3701);e.exports=(e,t)=>s(e,t,!0)},3701:(e,t,n)=>{const s=n(6315);e.exports=(e,t,n)=>new s(e,n).compare(new s(t,n))},3719:(e,t,n)=>{const s=n(7153);e.exports=(e,t)=>{const n=s(e,null,!0),o=s(t,null,!0),i=n.compare(o);if(0===i)return null;const r=i>0,a=r?n:o,c=r?o:n,l=!!a.prerelease.length;if(c.prerelease.length&&!l)return c.patch||c.minor?a.patch?"patch":a.minor?"minor":"major":"major";const g=l?"pre":"";return n.major!==o.major?g+"major":n.minor!==o.minor?g+"minor":n.patch!==o.patch?g+"patch":"prerelease"}},4506:(e,t,n)=>{const s=n(3701);e.exports=(e,t,n)=>0===s(e,t,n)},9671:(e,t,n)=>{const s=n(3701);e.exports=(e,t,n)=>s(e,t,n)>0},9540:(e,t,n)=>{const s=n(3701);e.exports=(e,t,n)=>s(e,t,n)>=0},9746:(e,t,n)=>{const s=n(6315);e.exports=(e,t,n,o,i)=>{"string"==typeof n&&(i=o,o=n,n=void 0);try{return new s(e instanceof s?e.version:e,n).inc(t,o,i).version}catch(e){return null}}},6912:(e,t,n)=>{const s=n(3701);e.exports=(e,t,n)=>s(e,t,n)<0},8445:(e,t,n)=>{const s=n(3701);e.exports=(e,t,n)=>s(e,t,n)<=0},7887:(e,t,n)=>{const s=n(6315);e.exports=(e,t)=>new s(e,t).major},6651:(e,t,n)=>{const s=n(6315);e.exports=(e,t)=>new s(e,t).minor},4654:(e,t,n)=>{const s=n(3701);e.exports=(e,t,n)=>0!==s(e,t,n)},7153:(e,t,n)=>{const s=n(6315);e.exports=(e,t,n=!1)=>{if(e instanceof s)return e;try{return new s(e,t)}catch(e){if(!n)return null;throw e}}},180:(e,t,n)=>{const s=n(6315);e.exports=(e,t)=>new s(e,t).patch},818:(e,t,n)=>{const s=n(7153);e.exports=(e,t)=>{const n=s(e,t);return n&&n.prerelease.length?n.prerelease:null}},6813:(e,t,n)=>{const s=n(3701);e.exports=(e,t,n)=>s(t,e,n)},9544:(e,t,n)=>{const s=n(4848);e.exports=(e,t)=>e.sort(((e,n)=>s(n,e,t)))},1995:(e,t,n)=>{const s=n(5006);e.exports=(e,t,n)=>{try{t=new s(t,n)}catch(e){return!1}return t.test(e)}},8080:(e,t,n)=>{const s=n(4848);e.exports=(e,t)=>e.sort(((e,n)=>s(e,n,t)))},8300:(e,t,n)=>{const s=n(7153);e.exports=(e,t)=>{const n=s(e,t);return n?n.version:null}},5864:(e,t,n)=>{const s=n(2351),o=n(5501),i=n(6315),r=n(9716),a=n(7153),c=n(8300),l=n(871),g=n(9746),d=n(3719),u=n(7887),h=n(6651),p=n(180),I=n(818),m=n(3701),C=n(6813),b=n(8474),y=n(4848),f=n(8080),A=n(9544),Z=n(9671),G=n(6912),v=n(4506),B=n(4654),W=n(9540),S=n(8445),V=n(630),w=n(2393),R=n(2659),H=n(5006),k=n(1995),Y=n(6897),X=n(1017),N=n(3811),_=n(3514),J=n(6561),F=n(5368),K=n(9924),x=n(4173),E=n(153),T=n(9388),z=n(6529);e.exports={parse:a,valid:c,clean:l,inc:g,diff:d,major:u,minor:h,patch:p,prerelease:I,compare:m,rcompare:C,compareLoose:b,compareBuild:y,sort:f,rsort:A,gt:Z,lt:G,eq:v,neq:B,gte:W,lte:S,cmp:V,coerce:w,Comparator:R,Range:H,satisfies:k,toComparators:Y,maxSatisfying:X,minSatisfying:N,minVersion:_,validRange:J,outside:F,gtr:K,ltr:x,intersects:E,simplifyRange:T,subset:z,SemVer:i,re:s.re,src:s.src,tokens:s.t,SEMVER_SPEC_VERSION:o.SEMVER_SPEC_VERSION,RELEASE_TYPES:o.RELEASE_TYPES,compareIdentifiers:r.compareIdentifiers,rcompareIdentifiers:r.rcompareIdentifiers}},5501:e=>{const t=Number.MAX_SAFE_INTEGER||9007199254740991;e.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:t,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}},6839:e=>{const t="object"==typeof process&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};e.exports=t},9716:e=>{const t=/^[0-9]+$/,n=(e,n)=>{const s=t.test(e),o=t.test(n);return s&&o&&(e=+e,n=+n),e===n?0:s&&!o?-1:o&&!s?1:en(t,e)}},7207:e=>{e.exports=class{constructor(){this.max=1e3,this.map=new Map}get(e){const t=this.map.get(e);return void 0===t?void 0:(this.map.delete(e),this.map.set(e,t),t)}delete(e){return this.map.delete(e)}set(e,t){if(!this.delete(e)&&void 0!==t){if(this.map.size>=this.max){const e=this.map.keys().next().value;this.delete(e)}this.map.set(e,t)}return this}}},9284:e=>{const t=Object.freeze({loose:!0}),n=Object.freeze({});e.exports=e=>e?"object"!=typeof e?t:e:n},2351:(e,t,n)=>{const{MAX_SAFE_COMPONENT_LENGTH:s,MAX_SAFE_BUILD_LENGTH:o,MAX_LENGTH:i}=n(5501),r=n(6839),a=(t=e.exports={}).re=[],c=t.safeRe=[],l=t.src=[],g=t.t={};let d=0;const u="[a-zA-Z0-9-]",h=[["\\s",1],["\\d",i],[u,o]],p=(e,t,n)=>{const s=(e=>{for(const[t,n]of h)e=e.split(`${t}*`).join(`${t}{0,${n}}`).split(`${t}+`).join(`${t}{1,${n}}`);return e})(t),o=d++;r(e,o,t),g[e]=o,l[o]=t,a[o]=new RegExp(t,n?"g":void 0),c[o]=new RegExp(s,n?"g":void 0)};p("NUMERICIDENTIFIER","0|[1-9]\\d*"),p("NUMERICIDENTIFIERLOOSE","\\d+"),p("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${u}*`),p("MAINVERSION",`(${l[g.NUMERICIDENTIFIER]})\\.(${l[g.NUMERICIDENTIFIER]})\\.(${l[g.NUMERICIDENTIFIER]})`),p("MAINVERSIONLOOSE",`(${l[g.NUMERICIDENTIFIERLOOSE]})\\.(${l[g.NUMERICIDENTIFIERLOOSE]})\\.(${l[g.NUMERICIDENTIFIERLOOSE]})`),p("PRERELEASEIDENTIFIER",`(?:${l[g.NUMERICIDENTIFIER]}|${l[g.NONNUMERICIDENTIFIER]})`),p("PRERELEASEIDENTIFIERLOOSE",`(?:${l[g.NUMERICIDENTIFIERLOOSE]}|${l[g.NONNUMERICIDENTIFIER]})`),p("PRERELEASE",`(?:-(${l[g.PRERELEASEIDENTIFIER]}(?:\\.${l[g.PRERELEASEIDENTIFIER]})*))`),p("PRERELEASELOOSE",`(?:-?(${l[g.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${l[g.PRERELEASEIDENTIFIERLOOSE]})*))`),p("BUILDIDENTIFIER",`${u}+`),p("BUILD",`(?:\\+(${l[g.BUILDIDENTIFIER]}(?:\\.${l[g.BUILDIDENTIFIER]})*))`),p("FULLPLAIN",`v?${l[g.MAINVERSION]}${l[g.PRERELEASE]}?${l[g.BUILD]}?`),p("FULL",`^${l[g.FULLPLAIN]}$`),p("LOOSEPLAIN",`[v=\\s]*${l[g.MAINVERSIONLOOSE]}${l[g.PRERELEASELOOSE]}?${l[g.BUILD]}?`),p("LOOSE",`^${l[g.LOOSEPLAIN]}$`),p("GTLT","((?:<|>)?=?)"),p("XRANGEIDENTIFIERLOOSE",`${l[g.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),p("XRANGEIDENTIFIER",`${l[g.NUMERICIDENTIFIER]}|x|X|\\*`),p("XRANGEPLAIN",`[v=\\s]*(${l[g.XRANGEIDENTIFIER]})(?:\\.(${l[g.XRANGEIDENTIFIER]})(?:\\.(${l[g.XRANGEIDENTIFIER]})(?:${l[g.PRERELEASE]})?${l[g.BUILD]}?)?)?`),p("XRANGEPLAINLOOSE",`[v=\\s]*(${l[g.XRANGEIDENTIFIERLOOSE]})(?:\\.(${l[g.XRANGEIDENTIFIERLOOSE]})(?:\\.(${l[g.XRANGEIDENTIFIERLOOSE]})(?:${l[g.PRERELEASELOOSE]})?${l[g.BUILD]}?)?)?`),p("XRANGE",`^${l[g.GTLT]}\\s*${l[g.XRANGEPLAIN]}$`),p("XRANGELOOSE",`^${l[g.GTLT]}\\s*${l[g.XRANGEPLAINLOOSE]}$`),p("COERCEPLAIN",`(^|[^\\d])(\\d{1,${s}})(?:\\.(\\d{1,${s}}))?(?:\\.(\\d{1,${s}}))?`),p("COERCE",`${l[g.COERCEPLAIN]}(?:$|[^\\d])`),p("COERCEFULL",l[g.COERCEPLAIN]+`(?:${l[g.PRERELEASE]})?`+`(?:${l[g.BUILD]})?(?:$|[^\\d])`),p("COERCERTL",l[g.COERCE],!0),p("COERCERTLFULL",l[g.COERCEFULL],!0),p("LONETILDE","(?:~>?)"),p("TILDETRIM",`(\\s*)${l[g.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",p("TILDE",`^${l[g.LONETILDE]}${l[g.XRANGEPLAIN]}$`),p("TILDELOOSE",`^${l[g.LONETILDE]}${l[g.XRANGEPLAINLOOSE]}$`),p("LONECARET","(?:\\^)"),p("CARETTRIM",`(\\s*)${l[g.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",p("CARET",`^${l[g.LONECARET]}${l[g.XRANGEPLAIN]}$`),p("CARETLOOSE",`^${l[g.LONECARET]}${l[g.XRANGEPLAINLOOSE]}$`),p("COMPARATORLOOSE",`^${l[g.GTLT]}\\s*(${l[g.LOOSEPLAIN]})$|^$`),p("COMPARATOR",`^${l[g.GTLT]}\\s*(${l[g.FULLPLAIN]})$|^$`),p("COMPARATORTRIM",`(\\s*)${l[g.GTLT]}\\s*(${l[g.LOOSEPLAIN]}|${l[g.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",p("HYPHENRANGE",`^\\s*(${l[g.XRANGEPLAIN]})\\s+-\\s+(${l[g.XRANGEPLAIN]})\\s*$`),p("HYPHENRANGELOOSE",`^\\s*(${l[g.XRANGEPLAINLOOSE]})\\s+-\\s+(${l[g.XRANGEPLAINLOOSE]})\\s*$`),p("STAR","(<|>)?=?\\s*\\*"),p("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),p("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")},9924:(e,t,n)=>{const s=n(5368);e.exports=(e,t,n)=>s(e,t,">",n)},153:(e,t,n)=>{const s=n(5006);e.exports=(e,t,n)=>(e=new s(e,n),t=new s(t,n),e.intersects(t,n))},4173:(e,t,n)=>{const s=n(5368);e.exports=(e,t,n)=>s(e,t,"<",n)},1017:(e,t,n)=>{const s=n(6315),o=n(5006);e.exports=(e,t,n)=>{let i=null,r=null,a=null;try{a=new o(t,n)}catch(e){return null}return e.forEach((e=>{a.test(e)&&(i&&-1!==r.compare(e)||(i=e,r=new s(i,n)))})),i}},3811:(e,t,n)=>{const s=n(6315),o=n(5006);e.exports=(e,t,n)=>{let i=null,r=null,a=null;try{a=new o(t,n)}catch(e){return null}return e.forEach((e=>{a.test(e)&&(i&&1!==r.compare(e)||(i=e,r=new s(i,n)))})),i}},3514:(e,t,n)=>{const s=n(6315),o=n(5006),i=n(9671);e.exports=(e,t)=>{e=new o(e,t);let n=new s("0.0.0");if(e.test(n))return n;if(n=new s("0.0.0-0"),e.test(n))return n;n=null;for(let t=0;t{const t=new s(e.semver.version);switch(e.operator){case">":0===t.prerelease.length?t.patch++:t.prerelease.push(0),t.raw=t.format();case"":case">=":r&&!i(t,r)||(r=t);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${e.operator}`)}})),!r||n&&!i(n,r)||(n=r)}return n&&e.test(n)?n:null}},5368:(e,t,n)=>{const s=n(6315),o=n(2659),{ANY:i}=o,r=n(5006),a=n(1995),c=n(9671),l=n(6912),g=n(8445),d=n(9540);e.exports=(e,t,n,u)=>{let h,p,I,m,C;switch(e=new s(e,u),t=new r(t,u),n){case">":h=c,p=g,I=l,m=">",C=">=";break;case"<":h=l,p=d,I=c,m="<",C="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(a(e,t,u))return!1;for(let n=0;n{e.semver===i&&(e=new o(">=0.0.0")),r=r||e,a=a||e,h(e.semver,r.semver,u)?r=e:I(e.semver,a.semver,u)&&(a=e)})),r.operator===m||r.operator===C)return!1;if((!a.operator||a.operator===m)&&p(e,a.semver))return!1;if(a.operator===C&&I(e,a.semver))return!1}return!0}},9388:(e,t,n)=>{const s=n(1995),o=n(3701);e.exports=(e,t,n)=>{const i=[];let r=null,a=null;const c=e.sort(((e,t)=>o(e,t,n)));for(const e of c)s(e,t,n)?(a=e,r||(r=e)):(a&&i.push([r,a]),a=null,r=null);r&&i.push([r,null]);const l=[];for(const[e,t]of i)e===t?l.push(e):t||e!==c[0]?t?e===c[0]?l.push(`<=${t}`):l.push(`${e} - ${t}`):l.push(`>=${e}`):l.push("*");const g=l.join(" || "),d="string"==typeof t.raw?t.raw:String(t);return g.length{const s=n(5006),o=n(2659),{ANY:i}=o,r=n(1995),a=n(3701),c=[new o(">=0.0.0-0")],l=[new o(">=0.0.0")],g=(e,t,n)=>{if(e===t)return!0;if(1===e.length&&e[0].semver===i){if(1===t.length&&t[0].semver===i)return!0;e=n.includePrerelease?c:l}if(1===t.length&&t[0].semver===i){if(n.includePrerelease)return!0;t=l}const s=new Set;let o,g,h,p,I,m,C;for(const t of e)">"===t.operator||">="===t.operator?o=d(o,t,n):"<"===t.operator||"<="===t.operator?g=u(g,t,n):s.add(t.semver);if(s.size>1)return null;if(o&&g){if(h=a(o.semver,g.semver,n),h>0)return null;if(0===h&&(">="!==o.operator||"<="!==g.operator))return null}for(const e of s){if(o&&!r(e,String(o),n))return null;if(g&&!r(e,String(g),n))return null;for(const s of t)if(!r(e,String(s),n))return!1;return!0}let b=!(!g||n.includePrerelease||!g.semver.prerelease.length)&&g.semver,y=!(!o||n.includePrerelease||!o.semver.prerelease.length)&&o.semver;b&&1===b.prerelease.length&&"<"===g.operator&&0===b.prerelease[0]&&(b=!1);for(const e of t){if(C=C||">"===e.operator||">="===e.operator,m=m||"<"===e.operator||"<="===e.operator,o)if(y&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===y.major&&e.semver.minor===y.minor&&e.semver.patch===y.patch&&(y=!1),">"===e.operator||">="===e.operator){if(p=d(o,e,n),p===e&&p!==o)return!1}else if(">="===o.operator&&!r(o.semver,String(e),n))return!1;if(g)if(b&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===b.major&&e.semver.minor===b.minor&&e.semver.patch===b.patch&&(b=!1),"<"===e.operator||"<="===e.operator){if(I=u(g,e,n),I===e&&I!==g)return!1}else if("<="===g.operator&&!r(g.semver,String(e),n))return!1;if(!e.operator&&(g||o)&&0!==h)return!1}return!(o&&m&&!g&&0!==h||g&&C&&!o&&0!==h||y||b)},d=(e,t,n)=>{if(!e)return t;const s=a(e.semver,t.semver,n);return s>0?e:s<0||">"===t.operator&&">="===e.operator?t:e},u=(e,t,n)=>{if(!e)return t;const s=a(e.semver,t.semver,n);return s<0?e:s>0||"<"===t.operator&&"<="===e.operator?t:e};e.exports=(e,t,n={})=>{if(e===t)return!0;e=new s(e,n),t=new s(t,n);let o=!1;e:for(const s of e.set){for(const e of t.set){const t=g(s,e,n);if(o=o||null!==t,t)continue e}if(o)return!1}return!0}},6897:(e,t,n)=>{const s=n(5006);e.exports=(e,t)=>new s(e,t).set.map((e=>e.map((e=>e.value)).join(" ").trim().split(" ")))},6561:(e,t,n)=>{const s=n(5006);e.exports=(e,t)=>{try{return new s(e,t).range||"*"}catch(e){return null}}},7651:(e,t,n)=>{const s=n(855),o=n(4977),i=n(7019),r=n(5747),a=n(6111),c=n(7914),l=n(8928),g=n(3639),d=n(9001),u=n(5931),h=n(7083),{KeyObject:p,createSecretKey:I,createPrivateKey:m}=n(6982),C=["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512","none"];o&&C.splice(3,0,"PS256","PS384","PS512");const b={expiresIn:{isValid:function(e){return l(e)||u(e)&&e},message:'"expiresIn" should be a number of seconds or string representing a timespan'},notBefore:{isValid:function(e){return l(e)||u(e)&&e},message:'"notBefore" should be a number of seconds or string representing a timespan'},audience:{isValid:function(e){return u(e)||Array.isArray(e)},message:'"audience" must be a string or array'},algorithm:{isValid:a.bind(null,C),message:'"algorithm" must be a valid string enum value'},header:{isValid:d,message:'"header" must be an object'},encoding:{isValid:u,message:'"encoding" must be a string'},issuer:{isValid:u,message:'"issuer" must be a string'},subject:{isValid:u,message:'"subject" must be a string'},jwtid:{isValid:u,message:'"jwtid" must be a string'},noTimestamp:{isValid:c,message:'"noTimestamp" must be a boolean'},keyid:{isValid:u,message:'"keyid" must be a string'},mutatePayload:{isValid:c,message:'"mutatePayload" must be a boolean'},allowInsecureKeySizes:{isValid:c,message:'"allowInsecureKeySizes" must be a boolean'},allowInvalidAsymmetricKeyTypes:{isValid:c,message:'"allowInvalidAsymmetricKeyTypes" must be a boolean'}},y={iat:{isValid:g,message:'"iat" should be a number of seconds'},exp:{isValid:g,message:'"exp" should be a number of seconds'},nbf:{isValid:g,message:'"nbf" should be a number of seconds'}};function f(e,t,n,s){if(!d(n))throw new Error('Expected "'+s+'" to be a plain object.');Object.keys(n).forEach((function(o){const i=e[o];if(i){if(!i.isValid(n[o]))throw new Error(i.message)}else if(!t)throw new Error('"'+o+'" is not allowed in "'+s+'"')}))}const A={audience:"aud",issuer:"iss",subject:"sub",jwtid:"jti"},Z=["expiresIn","notBefore","noTimestamp","audience","issuer","subject","jwtid"];e.exports=function(e,t,n,o){"function"==typeof n?(o=n,n={}):n=n||{};const a="object"==typeof e&&!Buffer.isBuffer(e),c=Object.assign({alg:n.algorithm||"HS256",typ:a?"JWT":void 0,kid:n.keyid},n.header);function l(e){if(o)return o(e);throw e}if(!t&&"none"!==n.algorithm)return l(new Error("secretOrPrivateKey must have a value"));if(null!=t&&!(t instanceof p))try{t=m(t)}catch(e){try{t=I("string"==typeof t?Buffer.from(t):t)}catch(e){return l(new Error("secretOrPrivateKey is not valid key material"))}}if(c.alg.startsWith("HS")&&"secret"!==t.type)return l(new Error(`secretOrPrivateKey must be a symmetric key when using ${c.alg}`));if(/^(?:RS|PS|ES)/.test(c.alg)){if("private"!==t.type)return l(new Error(`secretOrPrivateKey must be an asymmetric key when using ${c.alg}`));if(!n.allowInsecureKeySizes&&!c.alg.startsWith("ES")&&void 0!==t.asymmetricKeyDetails&&t.asymmetricKeyDetails.modulusLength<2048)return l(new Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${c.alg}`))}if(void 0===e)return l(new Error("payload is required"));if(a){try{!function(e){f(y,!0,e,"payload")}(e)}catch(e){return l(e)}n.mutatePayload||(e=Object.assign({},e))}else{const t=Z.filter((function(e){return void 0!==n[e]}));if(t.length>0)return l(new Error("invalid "+t.join(",")+" option for "+typeof e+" payload"))}if(void 0!==e.exp&&void 0!==n.expiresIn)return l(new Error('Bad "options.expiresIn" option the payload already has an "exp" property.'));if(void 0!==e.nbf&&void 0!==n.notBefore)return l(new Error('Bad "options.notBefore" option the payload already has an "nbf" property.'));try{!function(e){f(b,!1,e,"options")}(n)}catch(e){return l(e)}if(!n.allowInvalidAsymmetricKeyTypes)try{i(c.alg,t)}catch(e){return l(e)}const g=e.iat||Math.floor(Date.now()/1e3);if(n.noTimestamp?delete e.iat:a&&(e.iat=g),void 0!==n.notBefore){try{e.nbf=s(n.notBefore,g)}catch(e){return l(e)}if(void 0===e.nbf)return l(new Error('"notBefore" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'))}if(void 0!==n.expiresIn&&"object"==typeof e){try{e.exp=s(n.expiresIn,g)}catch(e){return l(e)}if(void 0===e.exp)return l(new Error('"expiresIn" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'))}Object.keys(A).forEach((function(t){const s=A[t];if(void 0!==n[t]){if(void 0!==e[s])return l(new Error('Bad "options.'+t+'" option. The payload already has an "'+s+'" property.'));e[s]=n[t]}}));const d=n.encoding||"utf8";if("function"!=typeof o){let s=r.sign({header:c,payload:e,secret:t,encoding:d});if(!n.allowInsecureKeySizes&&/^(?:RS|PS)/.test(c.alg)&&s.length<256)throw new Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${c.alg}`);return s}o=o&&h(o),r.createSign({header:c,privateKey:t,payload:e,encoding:d}).once("error",o).once("done",(function(e){if(!n.allowInsecureKeySizes&&/^(?:RS|PS)/.test(c.alg)&&e.length<256)return o(new Error(`secretOrPrivateKey has a minimum key size of 2048 bits for ${c.alg}`));o(null,e)}))}},1691:(e,t,n)=>{const s=n(1741),o=n(3726),i=n(8980),r=n(7260),a=n(855),c=n(7019),l=n(4977),g=n(5747),{KeyObject:d,createSecretKey:u,createPublicKey:h}=n(6982),p=["RS256","RS384","RS512"],I=["ES256","ES384","ES512"],m=["RS256","RS384","RS512"],C=["HS256","HS384","HS512"];l&&(p.splice(p.length,0,"PS256","PS384","PS512"),m.splice(m.length,0,"PS256","PS384","PS512")),e.exports=function(e,t,n,l){let b;if("function"!=typeof n||l||(l=n,n={}),n||(n={}),n=Object.assign({},n),b=l||function(e,t){if(e)throw e;return t},n.clockTimestamp&&"number"!=typeof n.clockTimestamp)return b(new s("clockTimestamp must be a number"));if(void 0!==n.nonce&&("string"!=typeof n.nonce||""===n.nonce.trim()))return b(new s("nonce must be a non-empty string"));if(void 0!==n.allowInvalidAsymmetricKeyTypes&&"boolean"!=typeof n.allowInvalidAsymmetricKeyTypes)return b(new s("allowInvalidAsymmetricKeyTypes must be a boolean"));const y=n.clockTimestamp||Math.floor(Date.now()/1e3);if(!e)return b(new s("jwt must be provided"));if("string"!=typeof e)return b(new s("jwt must be a string"));const f=e.split(".");if(3!==f.length)return b(new s("jwt malformed"));let A;try{A=r(e,{complete:!0})}catch(e){return b(e)}if(!A)return b(new s("invalid token"));const Z=A.header;let G;if("function"==typeof t){if(!l)return b(new s("verify must be called asynchronous if secret or public key is provided as a callback"));G=t}else G=function(e,n){return n(null,t)};return G(Z,(function(t,r){if(t)return b(new s("error in secret or public key callback: "+t.message));const l=""!==f[2].trim();if(!l&&r)return b(new s("jwt signature is required"));if(l&&!r)return b(new s("secret or public key must be provided"));if(!l&&!n.algorithms)return b(new s('please specify "none" in "algorithms" to verify unsigned tokens'));if(null!=r&&!(r instanceof d))try{r=h(r)}catch(e){try{r=u("string"==typeof r?Buffer.from(r):r)}catch(e){return b(new s("secretOrPublicKey is not valid key material"))}}if(n.algorithms||("secret"===r.type?n.algorithms=C:["rsa","rsa-pss"].includes(r.asymmetricKeyType)?n.algorithms=m:"ec"===r.asymmetricKeyType?n.algorithms=I:n.algorithms=p),-1===n.algorithms.indexOf(A.header.alg))return b(new s("invalid algorithm"));if(Z.alg.startsWith("HS")&&"secret"!==r.type)return b(new s(`secretOrPublicKey must be a symmetric key when using ${Z.alg}`));if(/^(?:RS|PS|ES)/.test(Z.alg)&&"public"!==r.type)return b(new s(`secretOrPublicKey must be an asymmetric key when using ${Z.alg}`));if(!n.allowInvalidAsymmetricKeyTypes)try{c(Z.alg,r)}catch(e){return b(e)}let G;try{G=g.verify(e,A.header.alg,r)}catch(e){return b(e)}if(!G)return b(new s("invalid signature"));const v=A.payload;if(void 0!==v.nbf&&!n.ignoreNotBefore){if("number"!=typeof v.nbf)return b(new s("invalid nbf value"));if(v.nbf>y+(n.clockTolerance||0))return b(new o("jwt not active",new Date(1e3*v.nbf)))}if(void 0!==v.exp&&!n.ignoreExpiration){if("number"!=typeof v.exp)return b(new s("invalid exp value"));if(y>=v.exp+(n.clockTolerance||0))return b(new i("jwt expired",new Date(1e3*v.exp)))}if(n.audience){const e=Array.isArray(n.audience)?n.audience:[n.audience];if(!(Array.isArray(v.aud)?v.aud:[v.aud]).some((function(t){return e.some((function(e){return e instanceof RegExp?e.test(t):e===t}))})))return b(new s("jwt audience invalid. expected: "+e.join(" or ")))}if(n.issuer&&("string"==typeof n.issuer&&v.iss!==n.issuer||Array.isArray(n.issuer)&&-1===n.issuer.indexOf(v.iss)))return b(new s("jwt issuer invalid. expected: "+n.issuer));if(n.subject&&v.sub!==n.subject)return b(new s("jwt subject invalid. expected: "+n.subject));if(n.jwtid&&v.jti!==n.jwtid)return b(new s("jwt jwtid invalid. expected: "+n.jwtid));if(n.nonce&&v.nonce!==n.nonce)return b(new s("jwt nonce invalid. expected: "+n.nonce));if(n.maxAge){if("number"!=typeof v.iat)return b(new s("iat required when maxAge is specified"));const e=a(n.maxAge,v.iat);if(void 0===e)return b(new s('"maxAge" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'));if(y>=e+(n.clockTolerance||0))return b(new i("maxAge exceeded",new Date(1e3*e)))}if(!0===n.complete){const e=A.signature;return b(null,{header:Z,payload:v,signature:e})}return b(null,v)}))}},8789:(e,t,n)=>{var s=n(1045),o=n(2861).Buffer,i=n(6982),r=n(2010),a=n(9023),c="secret must be a string or buffer",l="key must be a string or a buffer",g="key must be a string, a buffer or an object",d="function"==typeof i.createPublicKey;function u(e){if(!o.isBuffer(e)&&"string"!=typeof e){if(!d)throw m(l);if("object"!=typeof e)throw m(l);if("string"!=typeof e.type)throw m(l);if("string"!=typeof e.asymmetricKeyType)throw m(l);if("function"!=typeof e.export)throw m(l)}}function h(e){if(!o.isBuffer(e)&&"string"!=typeof e&&"object"!=typeof e)throw m(g)}function p(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function I(e){var t=4-(e=e.toString()).length%4;if(4!==t)for(var n=0;n{var s=n(3387),o=n(7599);t.ALGORITHMS=["HS256","HS384","HS512","RS256","RS384","RS512","PS256","PS384","PS512","ES256","ES384","ES512"],t.sign=s.sign,t.verify=o.verify,t.decode=o.decode,t.isValid=o.isValid,t.createSign=function(e){return new s(e)},t.createVerify=function(e){return new o(e)}},8948:(e,t,n)=>{var s=n(2861).Buffer,o=n(2203);function i(e){if(this.buffer=null,this.writable=!0,this.readable=!0,!e)return this.buffer=s.alloc(0),this;if("function"==typeof e.pipe)return this.buffer=s.alloc(0),e.pipe(this),this;if(e.length||"object"==typeof e)return this.buffer=e,this.writable=!1,process.nextTick(function(){this.emit("end",e),this.readable=!1,this.emit("close")}.bind(this)),this;throw new TypeError("Unexpected data type ("+typeof e+")")}n(9023).inherits(i,o),i.prototype.write=function(e){this.buffer=s.concat([this.buffer,s.from(e)]),this.emit("data",e)},i.prototype.end=function(e){e&&this.write(e),this.emit("end",e),this.emit("close"),this.writable=!1,this.readable=!1},e.exports=i},3387:(e,t,n)=>{var s=n(2861).Buffer,o=n(8948),i=n(8789),r=n(2203),a=n(2851),c=n(9023);function l(e,t){return s.from(e,t).toString("base64").replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function g(e){var t=e.header,n=e.payload,s=e.secret||e.privateKey,o=e.encoding,r=i(t.alg),g=function(e,t,n){n=n||"utf8";var s=l(a(e),"binary"),o=l(a(t),n);return c.format("%s.%s",s,o)}(t,n,o),d=r.sign(g,s);return c.format("%s.%s",g,d)}function d(e){var t=e.secret||e.privateKey||e.key,n=new o(t);this.readable=!0,this.header=e.header,this.encoding=e.encoding,this.secret=this.privateKey=this.key=n,this.payload=new o(e.payload),this.secret.once("close",function(){!this.payload.writable&&this.readable&&this.sign()}.bind(this)),this.payload.once("close",function(){!this.secret.writable&&this.readable&&this.sign()}.bind(this))}c.inherits(d,r),d.prototype.sign=function(){try{var e=g({header:this.header,payload:this.payload.buffer,secret:this.secret.buffer,encoding:this.encoding});return this.emit("done",e),this.emit("data",e),this.emit("end"),this.readable=!1,e}catch(e){this.readable=!1,this.emit("error",e),this.emit("close")}},d.sign=g,e.exports=d},2851:(e,t,n)=>{var s=n(181).Buffer;e.exports=function(e){return"string"==typeof e?e:"number"==typeof e||s.isBuffer(e)?e.toString():JSON.stringify(e)}},7599:(e,t,n)=>{var s=n(2861).Buffer,o=n(8948),i=n(8789),r=n(2203),a=n(2851),c=n(9023),l=/^[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)?$/;function g(e){var t=e.split(".",1)[0];return function(e){if(function(e){return"[object Object]"===Object.prototype.toString.call(e)}(e))return e;try{return JSON.parse(e)}catch(e){return}}(s.from(t,"base64").toString("binary"))}function d(e){return e.split(".")[2]}function u(e){return l.test(e)&&!!g(e)}function h(e,t,n){if(!t){var s=new Error("Missing algorithm parameter for jws.verify");throw s.code="MISSING_ALGORITHM",s}var o=d(e=a(e)),r=function(e){return e.split(".",2).join(".")}(e);return i(t).verify(r,o,n)}function p(e,t){if(t=t||{},!u(e=a(e)))return null;var n=g(e);if(!n)return null;var o=function(e,t){t=t||"utf8";var n=e.split(".")[1];return s.from(n,"base64").toString(t)}(e);return("JWT"===n.typ||t.json)&&(o=JSON.parse(o,t.encoding)),{header:n,payload:o,signature:d(e)}}function I(e){var t=(e=e||{}).secret||e.publicKey||e.key,n=new o(t);this.readable=!0,this.algorithm=e.algorithm,this.encoding=e.encoding,this.secret=this.publicKey=this.key=n,this.signature=new o(e.signature),this.secret.once("close",function(){!this.signature.writable&&this.readable&&this.verify()}.bind(this)),this.signature.once("close",function(){!this.secret.writable&&this.readable&&this.verify()}.bind(this))}c.inherits(I,r),I.prototype.verify=function(){try{var e=h(this.signature.buffer,this.algorithm,this.key.buffer),t=p(this.signature.buffer,this.encoding);return this.emit("done",e,t),this.emit("data",e),this.emit("end"),this.readable=!1,e}catch(e){this.readable=!1,this.emit("error",e),this.emit("close")}},I.decode=p,I.isValid=u,I.verify=h,e.exports=I},8387:(e,t,n)=>{"use strict";const s=n(4434),o=n(5516),i=["sqlite","postgres","mysql","mongo","redis","tiered"];e.exports=class extends s{constructor(e,{emitErrors:t=!0,...s}={}){if(super(),this.opts={namespace:"keyv",serialize:o.stringify,deserialize:o.parse,..."string"==typeof e?{uri:e}:e,...s},!this.opts.store){const e={...this.opts};this.opts.store=(e=>{const t={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(e.adapter||e.uri){const s=e.adapter||/^[^:+]*/.exec(e.uri)[0];return new(n(6478)(t[s]))(e)}return new Map})(e)}if(this.opts.compression){const e=this.opts.compression;this.opts.serialize=e.serialize.bind(e),this.opts.deserialize=e.deserialize.bind(e)}"function"==typeof this.opts.store.on&&t&&this.opts.store.on("error",(e=>this.emit("error",e))),this.opts.store.namespace=this.opts.namespace;const i=e=>async function*(){for await(const[t,n]of"function"==typeof e?e(this.opts.store.namespace):e){const e=await this.opts.deserialize(n);this.opts.store.namespace&&!t.includes(this.opts.store.namespace)||("number"==typeof e.expires&&Date.now()>e.expires?this.delete(t):yield[this._getKeyUnprefix(t),e.value])}};"function"==typeof this.opts.store[Symbol.iterator]&&this.opts.store instanceof Map?this.iterator=i(this.opts.store):"function"==typeof this.opts.store.iterator&&this.opts.store.opts&&this._checkIterableAdaptar()&&(this.iterator=i(this.opts.store.iterator.bind(this.opts.store)))}_checkIterableAdaptar(){return i.includes(this.opts.store.opts.dialect)||i.findIndex((e=>this.opts.store.opts.url.includes(e)))>=0}_getKeyPrefix(e){return`${this.opts.namespace}:${e}`}_getKeyPrefixArray(e){return e.map((e=>`${this.opts.namespace}:${e}`))}_getKeyUnprefix(e){return e.split(":").splice(1).join(":")}get(e,t){const{store:n}=this.opts,s=Array.isArray(e),o=s?this._getKeyPrefixArray(e):this._getKeyPrefix(e);if(s&&void 0===n.getMany){const e=[];for(const s of o)e.push(Promise.resolve().then((()=>n.get(s))).then((e=>"string"==typeof e||this.opts.compression?this.opts.deserialize(e):e)).then((e=>{if(null!=e)return"number"==typeof e.expires&&Date.now()>e.expires?this.delete(s).then((()=>{})):t&&t.raw?e:e.value})));return Promise.allSettled(e).then((e=>{const t=[];for(const n of e)t.push(n.value);return t}))}return Promise.resolve().then((()=>s?n.getMany(o):n.get(o))).then((e=>"string"==typeof e||this.opts.compression?this.opts.deserialize(e):e)).then((n=>{if(null!=n)return s?n.map(((n,s)=>{if("string"==typeof n&&(n=this.opts.deserialize(n)),null!=n){if(!("number"==typeof n.expires&&Date.now()>n.expires))return t&&t.raw?n:n.value;this.delete(e[s]).then((()=>{}))}})):"number"==typeof n.expires&&Date.now()>n.expires?this.delete(e).then((()=>{})):t&&t.raw?n:n.value}))}set(e,t,n){const s=this._getKeyPrefix(e);void 0===n&&(n=this.opts.ttl),0===n&&(n=void 0);const{store:o}=this.opts;return Promise.resolve().then((()=>{const e="number"==typeof n?Date.now()+n:null;return"symbol"==typeof t&&this.emit("error","symbol cannot be serialized"),t={value:t,expires:e},this.opts.serialize(t)})).then((e=>o.set(s,e,n))).then((()=>!0))}delete(e){const{store:t}=this.opts;if(Array.isArray(e)){const n=this._getKeyPrefixArray(e);if(void 0===t.deleteMany){const e=[];for(const s of n)e.push(t.delete(s));return Promise.allSettled(e).then((e=>e.every((e=>!0===e.value))))}return Promise.resolve().then((()=>t.deleteMany(n)))}const n=this._getKeyPrefix(e);return Promise.resolve().then((()=>t.delete(n)))}clear(){const{store:e}=this.opts;return Promise.resolve().then((()=>e.clear()))}has(e){const t=this._getKeyPrefix(e),{store:n}=this.opts;return Promise.resolve().then((async()=>"function"==typeof n.has?n.has(t):void 0!==await n.get(t)))}disconnect(){const{store:e}=this.opts;if("function"==typeof e.disconnect)return e.disconnect()}}},6478:e=>{function t(e){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}t.keys=()=>[],t.resolve=t,t.id=6478,e.exports=t},6111:e=>{var t=1/0,n=9007199254740991,s="[object Function]",o="[object GeneratorFunction]",i=/^\s+|\s+$/g,r=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,c=/^0o[0-7]+$/i,l=/^(?:0|[1-9]\d*)$/,g=parseInt;function d(e){return e!=e}var u,h,p=Object.prototype,I=p.hasOwnProperty,m=p.toString,C=p.propertyIsEnumerable,b=(u=Object.keys,h=Object,function(e){return u(h(e))}),y=Math.max;function f(e,t){return!!(t=null==t?n:t)&&("number"==typeof e||l.test(e))&&e>-1&&e%1==0&&e-1&&e%1==0&&e<=n}(e.length)&&!function(e){var t=G(e)?m.call(e):"";return t==s||t==o}(e)}function G(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function v(e){return!!e&&"object"==typeof e}e.exports=function(e,n,s,o){var l;e=Z(e)?e:(l=e)?function(e,t){return function(t,n){for(var s=-1,o=t?t.length:0,i=Array(o);++s-1:!!u&&function(e,t,n){if(t!=t)return function(e,t,n,s){for(var o=e.length,i=n+-1;++i-1}},7914:e=>{var t=Object.prototype.toString;e.exports=function(e){return!0===e||!1===e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Boolean]"==t.call(e)}},8928:e=>{var t=1/0,n=/^\s+|\s+$/g,s=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,i=/^0o[0-7]+$/i,r=parseInt,a=Object.prototype.toString;function c(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}e.exports=function(e){return"number"==typeof e&&e==function(e){var l=function(e){return e?(e=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==a.call(e)}(e))return NaN;if(c(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=c(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(n,"");var l=o.test(e);return l||i.test(e)?r(e.slice(2),l?2:8):s.test(e)?NaN:+e}(e))===t||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}(e),g=l%1;return l==l?g?l-g:l:0}(e)}},3639:e=>{var t=Object.prototype.toString;e.exports=function(e){return"number"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Number]"==t.call(e)}},9001:e=>{var t,n,s=Function.prototype,o=Object.prototype,i=s.toString,r=o.hasOwnProperty,a=i.call(Object),c=o.toString,l=(t=Object.getPrototypeOf,n=Object,function(e){return t(n(e))});e.exports=function(e){if(!function(e){return!!e&&"object"==typeof e}(e)||"[object Object]"!=c.call(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e))return!1;var t=l(e);if(null===t)return!0;var n=r.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&i.call(n)==a}},5931:e=>{var t=Object.prototype.toString,n=Array.isArray;e.exports=function(e){return"string"==typeof e||!n(e)&&function(e){return!!e&&"object"==typeof e}(e)&&"[object String]"==t.call(e)}},7083:e=>{var t=1/0,n=/^\s+|\s+$/g,s=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,i=/^0o[0-7]+$/i,r=parseInt,a=Object.prototype.toString;function c(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}e.exports=function(e){return function(e,l){var g;if("function"!=typeof l)throw new TypeError("Expected a function");return e=function(e){var l=function(e){return e?(e=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==a.call(e)}(e))return NaN;if(c(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=c(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(n,"");var l=o.test(e);return l||i.test(e)?r(e.slice(2),l?2:8):s.test(e)?NaN:+e}(e))===t||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}(e),g=l%1;return l==l?g?l-g:l:0}(e),function(){return--e>0&&(g=l.apply(this,arguments)),e<=1&&(l=void 0),g}}(2,e)}},4865:e=>{"use strict";const t=(e,t,s,o)=>{if("length"===s||"prototype"===s)return;if("arguments"===s||"caller"===s)return;const i=Object.getOwnPropertyDescriptor(e,s),r=Object.getOwnPropertyDescriptor(t,s);!n(i,r)&&o||Object.defineProperty(e,s,r)},n=function(e,t){return void 0===e||e.configurable||e.writable===t.writable&&e.enumerable===t.enumerable&&e.configurable===t.configurable&&(e.writable||e.value===t.value)},s=(e,t)=>`/* Wrapped ${e}*/\n${t}`,o=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),i=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name");e.exports=(e,n,{ignoreNonConfigurable:r=!1}={})=>{const{name:a}=e;for(const s of Reflect.ownKeys(n))t(e,n,s,r);return((e,t)=>{const n=Object.getPrototypeOf(t);n!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,n)})(e,n),((e,t,n)=>{const r=""===n?"":`with ${n.trim()}() `,a=s.bind(null,r,t.toString());Object.defineProperty(a,"name",i),Object.defineProperty(e,"toString",{...o,value:a})})(e,n,a),e}},5022:e=>{"use strict";const t=["aborted","complete","headers","httpVersion","httpVersionMinor","httpVersionMajor","method","rawHeaders","rawTrailers","setTimeout","socket","statusCode","statusMessage","trailers","url"];e.exports=(e,n)=>{if(n._readableState.autoDestroy)throw new Error("The second stream must have the `autoDestroy` option set to `false`");const s=new Set(Object.keys(e).concat(t)),o={};for(const t of s)t in n||(o[t]={get(){const n=e[t];return"function"==typeof n?n.bind(e):n},set(n){e[t]=n},enumerable:!0,configurable:!1});return Object.defineProperties(n,o),e.once("aborted",(()=>{n.destroy(),n.emit("aborted")})),e.once("close",(()=>{e.complete&&n.readable?n.once("end",(()=>{n.emit("close")})):n.emit("close")})),n}},6585:e=>{var t=1e3,n=60*t,s=60*n,o=24*s;function i(e,t,n,s){var o=t>=1.5*n;return Math.round(e/n)+" "+s+(o?"s":"")}e.exports=function(e,r){r=r||{};var a,c,l=typeof e;if("string"===l&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var i=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(i){var r=parseFloat(i[1]);switch((i[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*r;case"weeks":case"week":case"w":return 6048e5*r;case"days":case"day":case"d":return r*o;case"hours":case"hour":case"hrs":case"hr":case"h":return r*s;case"minutes":case"minute":case"mins":case"min":case"m":return r*n;case"seconds":case"second":case"secs":case"sec":case"s":return r*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}(e);if("number"===l&&isFinite(e))return r.long?(a=e,(c=Math.abs(a))>=o?i(a,c,o,"day"):c>=s?i(a,c,s,"hour"):c>=n?i(a,c,n,"minute"):c>=t?i(a,c,t,"second"):a+" ms"):function(e){var i=Math.abs(e);return i>=o?Math.round(e/o)+"d":i>=s?Math.round(e/s)+"h":i>=n?Math.round(e/n)+"m":i>=t?Math.round(e/t)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},4617:e=>{"use strict";e.exports=(e,t)=>(t=t||(()=>{}),e.then((e=>new Promise((e=>{e(t())})).then((()=>e))),(e=>new Promise((e=>{e(t())})).then((()=>{throw e})))))},3290:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const s=n(228),o=n(7685),i=n(4774),r=()=>{},a=new o.TimeoutError;t.default=class extends s{constructor(e){var t,n,s,o;if(super(),this._intervalCount=0,this._intervalEnd=0,this._pendingCount=0,this._resolveEmpty=r,this._resolveIdle=r,!("number"==typeof(e=Object.assign({carryoverConcurrencyCount:!1,intervalCap:1/0,interval:0,concurrency:1/0,autoStart:!0,queueClass:i.default},e)).intervalCap&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${null!==(n=null===(t=e.intervalCap)||void 0===t?void 0:t.toString())&&void 0!==n?n:""}\` (${typeof e.intervalCap})`);if(void 0===e.interval||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${null!==(o=null===(s=e.interval)||void 0===s?void 0:s.toString())&&void 0!==o?o:""}\` (${typeof e.interval})`);this._carryoverConcurrencyCount=e.carryoverConcurrencyCount,this._isIntervalIgnored=e.intervalCap===1/0||0===e.interval,this._intervalCap=e.intervalCap,this._interval=e.interval,this._queue=new e.queueClass,this._queueClass=e.queueClass,this.concurrency=e.concurrency,this._timeout=e.timeout,this._throwOnTimeout=!0===e.throwOnTimeout,this._isPaused=!1===e.autoStart}get _doesIntervalAllowAnother(){return this._isIntervalIgnored||this._intervalCount{this._onResumeInterval()}),t)),!0;this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0}return!1}_tryToStartAnother(){if(0===this._queue.size)return this._intervalId&&clearInterval(this._intervalId),this._intervalId=void 0,this._resolvePromises(),!1;if(!this._isPaused){const e=!this._isIntervalPaused();if(this._doesIntervalAllowAnother&&this._doesConcurrentAllowAnother){const t=this._queue.dequeue();return!!t&&(this.emit("active"),t(),e&&this._initializeIntervalIfNeeded(),!0)}}return!1}_initializeIntervalIfNeeded(){this._isIntervalIgnored||void 0!==this._intervalId||(this._intervalId=setInterval((()=>{this._onInterval()}),this._interval),this._intervalEnd=Date.now()+this._interval)}_onInterval(){0===this._intervalCount&&0===this._pendingCount&&this._intervalId&&(clearInterval(this._intervalId),this._intervalId=void 0),this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0,this._processQueue()}_processQueue(){for(;this._tryToStartAnother(););}get concurrency(){return this._concurrency}set concurrency(e){if(!("number"==typeof e&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);this._concurrency=e,this._processQueue()}async add(e,t={}){return new Promise(((n,s)=>{this._queue.enqueue((async()=>{this._pendingCount++,this._intervalCount++;try{const i=void 0===this._timeout&&void 0===t.timeout?e():o.default(Promise.resolve(e()),void 0===t.timeout?this._timeout:t.timeout,(()=>{(void 0===t.throwOnTimeout?this._throwOnTimeout:t.throwOnTimeout)&&s(a)}));n(await i)}catch(e){s(e)}this._next()}),t),this._tryToStartAnother(),this.emit("add")}))}async addAll(e,t){return Promise.all(e.map((async e=>this.add(e,t))))}start(){return this._isPaused?(this._isPaused=!1,this._processQueue(),this):this}pause(){this._isPaused=!0}clear(){this._queue=new this._queueClass}async onEmpty(){if(0!==this._queue.size)return new Promise((e=>{const t=this._resolveEmpty;this._resolveEmpty=()=>{t(),e()}}))}async onIdle(){if(0!==this._pendingCount||0!==this._queue.size)return new Promise((e=>{const t=this._resolveIdle;this._resolveIdle=()=>{t(),e()}}))}get size(){return this._queue.size}sizeBy(e){return this._queue.filter(e).length}get pending(){return this._pendingCount}get isPaused(){return this._isPaused}get timeout(){return this._timeout}set timeout(e){this._timeout=e}}},9998:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,n){let s=0,o=e.length;for(;o>0;){const i=o/2|0;let r=s+i;n(e[r],t)<=0?(s=++r,o-=i+1):o=i}return s}},4774:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const s=n(9998);t.default=class{constructor(){this._queue=[]}enqueue(e,t){const n={priority:(t=Object.assign({priority:0},t)).priority,run:e};if(this.size&&this._queue[this.size-1].priority>=t.priority)return void this._queue.push(n);const o=s.default(this._queue,n,((e,t)=>t.priority-e.priority));this._queue.splice(o,0,n)}dequeue(){const e=this._queue.shift();return null==e?void 0:e.run}filter(e){return this._queue.filter((t=>t.priority===e.priority)).map((e=>e.run))}get size(){return this._queue.length}}},7685:(e,t,n)=>{"use strict";const s=n(4617);class o extends Error{constructor(e){super(e),this.name="TimeoutError"}}const i=(e,t,n)=>new Promise(((i,r)=>{if("number"!=typeof t||t<0)throw new TypeError("Expected `milliseconds` to be a positive number");if(t===1/0)return void i(e);const a=setTimeout((()=>{if("function"==typeof n){try{i(n())}catch(e){r(e)}return}const s=n instanceof Error?n:new o("string"==typeof n?n:`Promise timed out after ${t} milliseconds`);"function"==typeof e.cancel&&e.cancel(),r(s)}),t);s(e.then(i,r),(()=>{clearTimeout(a)}))}));e.exports=i,e.exports.default=i,e.exports.TimeoutError=o},7113:(e,t,n)=>{var s={};s.sys=n(6009),s.promise=n(7973),e.exports=s},9055:(e,t,n)=>{"use strict";var s=n(9023),o=n(4459),i=n(2394),r=n(4447);function a(){}a.isLinux=function(e){return["aix","android","linux"].indexOf(e)>=0},a.isMacOS=function(e){return["darwin","freebsd"].indexOf(e)>=0},a.isWindow=function(e){return e&&null!==e.match(/^win/)},a.isPlatformSupport=function(e){return this.isWindow(e)||this.isLinux(e)||this.isMacOS(e)},a.getExecutablePath=function(e,t){if(!this.isPlatformSupport(e))throw new Error(s.format("Platform |%s| is not support",e));var n=null;return"aix"===e?n="/usr/sbin/ping":a.isLinux(e)?n=t?"ping6":"ping":a.isWindow(e)?n=process.env.SystemRoot+"/system32/ping.exe":a.isMacOS(e)&&(n=t?"/sbin/ping6":"/sbin/ping"),n},a.createBuilder=function(e){if(!this.isPlatformSupport(e))throw new Error(s.format("Platform |%s| is not support",e));var t=null;return a.isLinux(e)?t=o:a.isWindow(e)?t=r:a.isMacOS(e)&&(t=i),t},e.exports=a},4459:(e,t,n)=>{"use strict";var s=n(9023),o={},i={numeric:!0,timeout:2,deadline:!1,min_reply:1,v6:!1,sourceAddr:"",packetSize:56,extra:[]};o.getCommandArguments=function(e,t){var n=t||{},o=[];return["numeric","timeout","deadline","min_reply","v6","sourceAddr","extra","packetSize"].forEach((function(e){"boolean"!=typeof n[e]&&(n[e]=n[e]||i[e])})),n.numeric&&o.push("-n"),n.timeout&&(o=o.concat(["-W",s.format("%d",n.timeout)])),n.deadline&&(o=o.concat(["-w",s.format("%d",n.deadline)])),n.min_reply&&(o=o.concat(["-c",s.format("%d",n.min_reply)])),n.sourceAddr&&(o=o.concat(["-I",s.format("%s",n.sourceAddr)])),n.packetSize&&(o=o.concat(["-s",s.format("%d",n.packetSize)])),n.extra&&(o=o.concat(n.extra)),o.push(e),o},o.getSpawnOptions=function(){return{shell:!1,env:Object.assign(process.env,{LANG:"C"})}},e.exports=o},2394:(e,t,n)=>{"use strict";var s=n(9023),o={},i={numeric:!0,timeout:2,deadline:!1,min_reply:1,v6:!1,sourceAddr:"",packetSize:56,extra:[]};o.getCommandArguments=function(e,t){var n=t||{},o=[];if(["numeric","timeout","deadline","min_reply","v6","sourceAddr","extra","packetSize"].forEach((function(e){"boolean"!=typeof n[e]&&(n[e]=n[e]||i[e])})),n.numeric&&o.push("-n"),n.timeout){if(t.v6)throw new Error("There is no timeout option on ping6");o=o.concat(["-W",s.format("%d",1e3*n.timeout)])}return n.deadline&&(o=o.concat(["-t",s.format("%d",n.deadline)])),n.min_reply&&(o=o.concat(["-c",s.format("%d",n.min_reply)])),n.sourceAddr&&(o=o.concat(["-S",s.format("%s",n.sourceAddr)])),n.packetSize&&(o=o.concat(["-s",s.format("%d",n.packetSize)])),n.extra&&(o=o.concat(n.extra)),o.push(e),o},o.getSpawnOptions=function(){return{}},e.exports=o},4447:(e,t,n)=>{"use strict";var s=n(9023),o={},i={numeric:!0,timeout:5,min_reply:1,v6:!1,sourceAddr:"",packetSize:32,extra:[]};o.getCommandArguments=function(e,t){var n=t||{},o=[];if(["numeric","timeout","min_reply","v6","sourceAddr","extra","packetSize"].forEach((function(e){"boolean"!=typeof n[e]&&(n[e]=n[e]||i[e])})),o.push(n.v6?"-6":"-4"),n.numeric||o.push("-a"),n.timeout&&(o=o.concat(["-w",s.format("%d",1e3*n.timeout)])),n.deadline)throw new Error("There is no deadline option on windows");return n.min_reply&&(o=o.concat(["-n",s.format("%d",n.min_reply)])),n.sourceAddr&&(o=o.concat(["-S",s.format("%s",n.sourceAddr)])),n.packetSize&&(o=o.concat(["-l",s.format("%d",n.packetSize)])),n.extra&&(o=o.concat(n.extra)),o.push(e),o},o.getSpawnOptions=function(){return{windowsHide:!0}},e.exports=o},424:e=>{"use strict";function t(e,t){this._state=0,this._response={inputHost:e,host:"unknown",alive:!1,output:"unknown",time:"unknown",times:[],min:"unknown",max:"unknown",avg:"unknown",stddev:"unknown",packetLoss:"unknown"},this._times=[],this._lines=[],this._stripRegex=/[ ]*\r?\n?$/g,this._pingConfig=t||{}}t.prototype.STATES={INIT:0,HEADER:1,BODY:2,FOOTER:3,END:4},t.prototype._changeState=function(e){if(Object.keys(this.STATES).map((function(e){return this.STATES[e]}),this).indexOf(e)<0)throw new Error("Unknown state");return this._state=e,this},t.prototype._processHeader=function(e){throw new Error("Subclass should implement this method")},t.prototype._processBody=function(e){throw new Error("Subclass should implement this method")},t.prototype._processFooter=function(e){throw new Error("Subclass should implement this method")},t.prototype.eat=function(e){var t=[this.STATES.INIT,this.STATES.HEADER];this._lines.push(e);var n=e.replace(this._stripRegex,"");if(0===n.length);else if(t.indexOf(this._state)>=0)this._processHeader(n);else if(this._state===this.STATES.BODY)this._processBody(n);else if(this._state===this.STATES.FOOTER)this._processFooter(n);else if(this._state!==this.STATES.END)throw new Error("Unknown state");return this},t.prototype.getResult=function(){var e=Object.assign({},this._response);if(e.output=this._lines.join("\n"),e.alive=this._times.length>0,e.alive&&(this._response.time=this._times[0],e.time=this._response.time,this._response.times=this._times,e.times=this._response.times),"unknown"===e.stddev&&e.alive){var t=this._times.length,n=this._times.reduce((function(t,n){var s=n-e.avg;return t+s*s}),0)/t;e.stddev=Math.round(1e3*Math.sqrt(n))/1e3}return["min","avg","max","stddev","packetLoss"].forEach((function(t){var n=e[t];"number"==typeof n&&(e[t]=n.toFixed(3))})),e},e.exports=t},3975:(e,t,n)=>{"use strict";var s=n(9023),o=n(9055),i=n(599),r=n(786),a=n(7395);function c(){}c.createParser=function(e,t,n){var c=n||{};if(!o.isPlatformSupport(t))throw new Error(s.format("Platform |%s| is not support",t));var l=null;return o.isWindow(t)?l=new i(e,c):o.isMacOS(t)?l=new r(e,c):o.isLinux(t)&&(l=new a(e,c)),l},e.exports=c},7395:(e,t,n)=>{"use strict";var s=n(9023),o=n(424),i=n(786);function r(e,t){o.call(this,e,t)}s.inherits(r,o),r.prototype._processHeader=function(e){var t=e.split(" ");if(-1===t[1].indexOf("("))this._response.host=t[1],this._response.numeric_host=t[2].slice(1,-1);else{var n=t.slice(1,-3).join("").match(/([^\s()]+)/g);this._response.host=n.shift(),this._response.numeric_host=n.pop()}this._changeState(this.STATES.BODY)},r.prototype._processBody=function(e){i.prototype._processBody.call(this,e)},r.prototype._processFooter=function(e){i.prototype._processFooter.call(this,e)},e.exports=r},786:(e,t,n)=>{"use strict";var s=n(9023),o=n(424);function i(e,t){o.call(this,e,t)}s.inherits(i,o),i.prototype._processHeader=function(e){var t=e.split(" ");this._response.host=t[1],this._response.numeric_host=t[2].slice(1,-2),this._changeState(this.STATES.BODY)},i.prototype._processBody=function(e){if((e.match(/=/g)||[]).length>=3){var t=/([0-9.]+)[ ]*ms/.exec(e);this._times.push(parseFloat(t[1],10))}e.indexOf("---")>=0&&this._changeState(this.STATES.FOOTER)},i.prototype._processFooter=function(e){var t=e.match(/ ([\d.]+)%/);if(t&&(this._response.packetLoss=parseFloat(t[1],10)),(e.match(/[/]/g)||[]).length>=3){var n=/([0-9.]+)/g,s=n.exec(e),o=n.exec(e),i=n.exec(e),r=n.exec(e);s&&o&&i&&r&&(this._response.min=parseFloat(s[1],10),this._response.avg=parseFloat(o[1],10),this._response.max=parseFloat(i[1],10),this._response.stddev=parseFloat(r[1],10),this._changeState(this.STATES.END)),this._changeState(this.STATES.END)}},e.exports=i},599:(e,t,n)=>{"use strict";var s=n(9023),o=n(424);function i(e,t){o.call(this,e,t),this._ipv4Regex=/^([0-9]{1,3}\.){3}[0-9]{1,3}$/}s.inherits(i,o),i.prototype._processHeader=function(e){var t=-1===e.indexOf("["),n=e.split(" ");if(t)this._response.host=n.find((function(e){return this._ipv4Regex.test(e)}),this),this._response.numeric_host=this._response.host;else{var s=n.find((function(e){return-1!==e.indexOf("[")}),this),o=n.indexOf(s),i=/\[(.*)\]/.exec(s);this._response.numeric_host=i?i[1]:"NA",this._response.host=n[o-1]}this._changeState(this.STATES.BODY)},i.prototype._processIPV6Body=function(e){var t=e.split(" "),n=t.filter((function(e){return e.indexOf("=")>=0||e.indexOf("<")>=0}));if((n=n.map((function(e){var n=e,s=t.indexOf(e)+1;return s=1){var s=n.find((function(e){return e.search(/(ms|мс)/i)>=0})),o=/([0-9.]+)/.exec(s);this._times.push(parseFloat(o[1],10))}},i.prototype._processIPV4Body=function(e){var t=e.split(" ").filter((function(e){return e.indexOf("=")>=0||e.indexOf("<")>=0}));if(t.length>=3){var n=this._pingConfig.packetSize,o=t.find((function(e){var t=s.format("=%d",n);return e.indexOf(t)>=0})),i=t.indexOf(o),r=t[i+1],a=/([0-9.]+)/.exec(r);this._times.push(parseFloat(a[1],10))}},i.prototype._processBody=function(e){":"===e.slice(-1)?this._changeState(this.STATES.FOOTER):this._pingConfig.v6?this._processIPV6Body(e):this._processIPV4Body(e)},i.prototype._processFooter=function(e){var t=e.match(/([\d.]+)%/);if(t&&(this._response.packetLoss=parseFloat(t[1],10)),e.search(/(ms|мсек)/i)>=0){var n=/([0-9.]+)/g,s=n.exec(e),o=n.exec(e),i=n.exec(e);s&&o&&i&&(this._response.min=parseFloat(s[1],10),this._response.max=parseFloat(o[1],10),this._response.avg=parseFloat(i[1],10),this._changeState(this.STATES.END))}},e.exports=i},7973:(e,t,n)=>{"use strict";var s=n(9023),o=n(9278),i=n(5317),r=n(857),a=n(9055),c=n(3975);t.probe=function(e,t){try{var n=function(e,t){var n=t||{};return void 0===n.v6&&(n.v6=o.isIPv6(e)),new Promise((function(t,o){var l=null,g=r.platform();try{var d=a.createBuilder(g),u=a.getExecutablePath(g,n.v6),h=d.getCommandArguments(e,n),p=d.getSpawnOptions();l=i.spawn(u,h,p)}catch(e){return void o(e)}var I=c.createParser(e,g,n);l.once("error",(function(){var e=new Error(s.format("ping.probe: %s. %s","there was an error while executing the ping program. ","Check the path or permissions..."));o(e)}));var m=[];l.stdout.on("data",(function(e){m.push(String(e))})),l.stderr.on("data",(function(e){m.push(String(e))})),l.once("close",(function(){m.join("").split("\n").forEach(I.eat,I);var e=I.getResult();t(e)}))}))}(e,t);return n}catch(e){return Promise.reject(e)}}},6009:(e,t,n)=>{"use strict";var s=n(7973);t.probe=function(e,t,n){var o=n||{};return s.probe(e,o).then((function(e){t(e.alive,null)})).catch((function(e){t(null,e)}))}},7392:e=>{"use strict";class t{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,t){if(this.cache.set(e,t),this._size++,this._size>=this.maxSize){if(this._size=0,"function"==typeof this.onEviction)for(const[e,t]of this.oldCache.entries())this.onEviction(e,t);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)){const t=this.oldCache.get(e);return this.oldCache.delete(e),this._set(e,t),t}}set(e,t){return this.cache.has(e)?this.cache.set(e,t):this._set(e,t),this}has(e){return this.cache.has(e)||this.oldCache.has(e)}peek(e){return this.cache.has(e)?this.cache.get(e):this.oldCache.has(e)?this.oldCache.get(e):void 0}delete(e){const t=this.cache.delete(e);return t&&this._size--,this.oldCache.delete(e)||t}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}*keys(){for(const[e]of this)yield e}*values(){for(const[,e]of this)yield e}*[Symbol.iterator](){for(const e of this.cache)yield e;for(const e of this.oldCache){const[t]=e;this.cache.has(t)||(yield e)}}get size(){let e=0;for(const t of this.oldCache.keys())this.cache.has(t)||e++;return Math.min(this._size+e,this.maxSize)}}e.exports=t},1169:(e,t,n)=>{"use strict";const s=n(4756);e.exports=(e={},t=s.connect)=>new Promise(((n,s)=>{let o,i=!1;const r=async()=>{await c,o.off("timeout",a),o.off("error",s),e.resolveSocket?(n({alpnProtocol:o.alpnProtocol,socket:o,timeout:i}),i&&(await Promise.resolve(),o.emit("timeout"))):(o.destroy(),n({alpnProtocol:o.alpnProtocol,timeout:i}))},a=async()=>{i=!0,r()},c=(async()=>{try{o=await t(e,r),o.on("error",s),o.once("timeout",a)}catch(e){s(e)}})()}))},2861:(e,t,n)=>{var s=n(181),o=s.Buffer;function i(e,t){for(var n in e)t[n]=e[n]}function r(e,t,n){return o(e,t,n)}o.from&&o.alloc&&o.allocUnsafe&&o.allocUnsafeSlow?e.exports=s:(i(s,t),t.Buffer=r),r.prototype=Object.create(o.prototype),i(o,r),r.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return o(e,t,n)},r.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var s=o(e);return void 0!==t?"string"==typeof n?s.fill(t,n):s.fill(t):s.fill(0),s},r.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return o(e)},r.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return s.SlowBuffer(e)}},7687:(e,t,n)=>{"use strict";const s=n(857),o=n(9637),i=n(5884),{env:r}=process;let a;function c(e){return 0!==e&&{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function l(e,t){if(0===a)return 0;if(i("color=16m")||i("color=full")||i("color=truecolor"))return 3;if(i("color=256"))return 2;if(e&&!t&&void 0===a)return 0;const n=a||0;if("dumb"===r.TERM)return n;if("win32"===process.platform){const e=s.release().split(".");return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if("CI"in r)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some((e=>e in r))||"codeship"===r.CI_NAME?1:n;if("TEAMCITY_VERSION"in r)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(r.TEAMCITY_VERSION)?1:0;if("truecolor"===r.COLORTERM)return 3;if("TERM_PROGRAM"in r){const e=parseInt((r.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(r.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(r.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(r.TERM)||"COLORTERM"in r?1:n}i("no-color")||i("no-colors")||i("color=false")||i("color=never")?a=0:(i("color")||i("colors")||i("color=true")||i("color=always"))&&(a=1),"FORCE_COLOR"in r&&(a="true"===r.FORCE_COLOR?1:"false"===r.FORCE_COLOR?0:0===r.FORCE_COLOR.length?1:Math.min(parseInt(r.FORCE_COLOR,10),3)),e.exports={supportsColor:function(e){return c(l(e,e&&e.isTTY))},stdout:c(l(!0,o.isatty(1))),stderr:c(l(!0,o.isatty(2)))}},2613:e=>{"use strict";e.exports=require("assert")},181:e=>{"use strict";e.exports=require("buffer")},5317:e=>{"use strict";e.exports=require("child_process")},6982:e=>{"use strict";e.exports=require("crypto")},7194:e=>{"use strict";e.exports=require("dgram")},4434:e=>{"use strict";e.exports=require("events")},1943:e=>{"use strict";e.exports=require("fs/promises")},8611:e=>{"use strict";e.exports=require("http")},5675:e=>{"use strict";e.exports=require("http2")},5692:e=>{"use strict";e.exports=require("https")},264:e=>{"use strict";e.exports=require("inspector")},9278:e=>{"use strict";e.exports=require("net")},857:e=>{"use strict";e.exports=require("os")},6928:e=>{"use strict";e.exports=require("path")},2203:e=>{"use strict";e.exports=require("stream")},4756:e=>{"use strict";e.exports=require("tls")},9637:e=>{"use strict";e.exports=require("tty")},7016:e=>{"use strict";e.exports=require("url")},9023:e=>{"use strict";e.exports=require("util")},3106:e=>{"use strict";e.exports=require("zlib")},4581:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},4326:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.runEntrypoint=void 0;const s=n(1635),o=n(9967),i=s.__importDefault(n(1943)),r=n(360),a=n(1138);n(9921);const c=n(4044),l=s.__importDefault(n(6928));let g,d=!1;t.runEntrypoint=function(e,t){Promise.resolve().then((async()=>{if(d)throw new Error("runEntrypoint can only be called once");d=!0;const n=process.env.MODULE_MANIFEST;if(!n)throw new Error("Module initialise is missing MODULE_MANIFEST");const s=await i.default.readFile(n),u=JSON.parse(s.toString());if(u.runtime?.api!==o.HostApiNodeJsIpc)throw new Error("Module manifest 'api' mismatch");if(!u.runtime.apiVersion)throw new Error("Module manifest 'apiVersion' missing");let h=u.runtime.apiVersion;if("0.0.0"===h)try{const e=await i.default.readFile(l.default.join(__dirname,"../package.json")),t=JSON.parse(e.toString());"@companion-module/base"===t.name&&(h=t.version)}catch(e){throw new Error("Failed to determine module api version")}if(!process.send)throw new Error("Module is not being run with ipc");console.log(`Starting up module class: ${e.name}`);const p=process.env.CONNECTION_ID;if("string"!=typeof p||!p)throw new Error("Module initialise is missing CONNECTION_ID");const I=process.env.VERIFICATION_TOKEN;if("string"!=typeof I||!I)throw new Error("Module initialise is missing VERIFICATION_TOKEN");const m=process.env.SENTRY_DSN,C=process.env.SENTRY_USERID,b=process.env.SENTRY_COMPANION_VERSION;m&&C&&"https://"==m.substring(0,8)?(console.log("Sentry enabled"),(0,a.init)({dsn:m,release:`${u.name}@${u.version}`,beforeSend:e=>(e.exception&&console.log("sentry","error",e.exception),e)}),(0,a.configureScope)((e=>{e.setUser({id:C}),e.setTag("companion",b)}))):console.log("Sentry disabled");const y=new c.IpcWrapper({},(e=>{process.send(e)}),5e3);process.once("message",(e=>{y.receivedMessage(e)})),g=new e((0,r.literal)({id:p,upgradeScripts:t,_isInstanceBaseProps:!0})),y.sendWithCb("register",{apiVersion:h,connectionId:p,verificationToken:I}).then((()=>{console.log("Module-host accepted registration")}),(e=>{console.error("Module registration failed",e),process.exit(11)}))})).catch((e=>{console.error("Failed to startup module:"),console.error(e.stack||e.message),process.exit(1)}))}},6160:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UDPHelper=t.TelnetHelper=t.TCPHelper=void 0;var s=n(8895);Object.defineProperty(t,"TCPHelper",{enumerable:!0,get:function(){return s.TCPHelper}});var o=n(1118);Object.defineProperty(t,"TelnetHelper",{enumerable:!0,get:function(){return o.TelnetHelper}});var i=n(6259);Object.defineProperty(t,"UDPHelper",{enumerable:!0,get:function(){return i.UDPHelper}})},8895:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TCPHelper=void 0;const s=n(1635).__importDefault(n(9278)),o=n(228),i=n(1400);class r extends o.EventEmitter{#e;#t;_socket;#n;#s=!1;#o=!1;#i=!1;#r;#a;get isConnected(){return this.#s}get isConnecting(){return this.#o}get isDestroyed(){return this.#i}constructor(e,t,n){super(),this.#e=e,this.#t=t,this.#n={reconnect_interval:2e3,reconnect:!0,...n},this._socket=new s.default.Socket,this._socket.setKeepAlive(!0),this._socket.setNoDelay(!0),this._socket.on("error",(e=>{this.#o=!1,this.#s=!1,this.#n.reconnect&&this.#c(),this.#l(i.InstanceStatus.UnknownError,e.message),this.emit("error",e)})),this._socket.on("ready",(()=>{this.#s=!0,this.#o=!1,this.#l(i.InstanceStatus.Ok),this.emit("connect")})),this._socket.on("end",(()=>{this.#s=!1,this.#l(i.InstanceStatus.Disconnected),!this.#o&&this.#n.reconnect&&this.#c(),this.emit("end")})),this._socket.on("data",(e=>this.emit("data",e))),this._socket.on("drain",(()=>this.emit("drain"))),setImmediate((()=>this.connect())),setTimeout((()=>{this.#i||this.listenerCount("error")||console.error(`Danger: TCP client for ${this.#e}:${this.#t} is missing an error handler!`)}),5e3)}connect(){if(this.#i)throw new Error("Cannot connect destroyed socket");return!this.#o&&(this.#o=!0,this._socket.connect(this.#t,this.#e),!0)}async send(e){if(this.#i||this._socket.destroyed)throw new Error("Cannot write to destroyed socket");if(!e||!e.length)throw new Error("No message to send");if(!this.#s)return!1;try{return new Promise(((t,n)=>{this._socket.write(e,(e=>{e?n(e):t(!0)}))}))}catch(e){this.#s=!1;const t=e instanceof Error?e:new Error(`${e}`);throw this.#l(i.InstanceStatus.UnknownError,t.message),this.emit("error",t),t}}destroy(){this.#i=!0,void 0!==this.#a&&clearTimeout(this.#a),this._socket.removeAllListeners(),this.removeAllListeners(),this._socket.destroy()}#c(){void 0!==this.#a&&clearTimeout(this.#a),this.#a=setTimeout((()=>{this.#a=void 0,this.#l(i.InstanceStatus.Connecting),this.connect()}),this.#n.reconnect_interval)}#l(e,t){this.#r!=e&&(this.#r=e,this.emit("status_change",e,t))}}t.TCPHelper=r},1118:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TelnetHelper=void 0;const s=n(1635).__importDefault(n(228)),o=n(2203),i=n(8895);class r extends s.default{#g;#d;get isConnected(){return this.#g.isConnected}get isConnecting(){return this.#g.isConnecting}get isDestroyed(){return this.#g.isDestroyed}constructor(e,t,n){super(),this.#g=new i.TCPHelper(e,t,n),this.#d=new a,this.#g._socket.pipe(this.#d),this.#g.on("connect",(()=>this.emit("connect"))),this.#g.on("end",(()=>this.emit("end"))),this.#g.on("error",(e=>this.emit("error",e))),this.#g.on("status_change",((e,t)=>this.emit("status_change",e,t))),this.#d.on("iac",((e,t)=>this.emit("iac",e,t))),this.#d.on("sb",(e=>this.emit("sb",e))),this.#d.on("data",(e=>this.emit("data",e))),this.#d.on("drain",(()=>this.emit("drain"))),setTimeout((()=>{this.isDestroyed||this.listenerCount("error")||console.error(`Danger: Telnet client for ${e}:${t} is missing an error handler!`)}),5e3)}connect(){return this.#g.connect()}async send(e){return this.#g.send(e)}destroy(){this.#g.destroy(),this.#d.removeAllListeners(),this.#d.destroy()}}t.TelnetHelper=r;class a extends o.Transform{#u;#h;#p;constructor(e){super(e),this.#u=Buffer.alloc(0),this.#h=Buffer.alloc(0),this.#p=0}_transform(e,t,n){for(let t=0;t=251&&this.#p<=254){let t;switch(this.#p){case 251:t="WILL";break;case 252:t="WONT";break;case 253:t="DO";break;case 254:t="DONT";break;default:return}return this.emit("iac",t,e),void(this.#p=0)}if(250===this.#p){if(240===e)return this.emit("sb",this.#h),this.#p=0,void(this.#h=Buffer.alloc(0));this.#h=Buffer.concat([this.#h,Buffer.from([e])])}}}#m(){const e=this.#u;return this.#u=Buffer.alloc(0),e}}},6259:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UDPHelper=void 0;const s=n(1635).__importDefault(n(7194)),o=n(228),i=n(1400);class r extends o.EventEmitter{#e;#t;#C;#n;#i=!1;#r;get isDestroyed(){return this.#i}constructor(e,t,n){super(),this.#e=e,this.#t=t,this.#n={...n},this.#C=s.default.createSocket("udp4");try{this.#C.bind(this.#n.bind_port||0,this.#n.bind_ip)}catch(e){throw new Error(`Unable to bind to ip/port: ${this.#n.bind_ip}:${this.#n.bind_port}`)}this.#n.broadcast&&this.#C.setBroadcast(!0),void 0!==this.#n.ttl&&this.#C.setTTL(this.#n.ttl),void 0!==this.#n.multicast_ttl&&this.#C.setMulticastTTL(this.#n.multicast_ttl),this.#C.on("error",(e=>{this.#l(i.InstanceStatus.UnknownError,e.message),this.emit("error",e)})),this.#C.on("listening",(()=>{this.#n.multicast_interface&&this.#C.setMulticastInterface(this.#n.multicast_interface),this.#l(i.InstanceStatus.Ok),this.emit("listening")})),this.#C.on("message",(e=>this.emit("data",e))),setTimeout((()=>{this.#i||this.listenerCount("error")||console.error(`Danger: UDP socket for ${this.#e}:${this.#t} is missing an error handler!`)}),5e3)}async send(e){if(this.#i)throw new Error("Cannot write to destroyed socket");if(!e||!e.length)throw new Error("No message to send");return new Promise(((t,n)=>{this.#C.send(e,this.#t,this.#e,(e=>{e?n(e):t()}))}))}destroy(){this.#i=!0,this.#C.removeAllListeners(),this.#C.close(),this.removeAllListeners()}#l(e,t){this.#r!=e&&(this.#r=e,this.emit("status_change",e,t))}}t.UDPHelper=r},4044:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IpcWrapper=void 0;const s=n(1635),o=n(360),i=s.__importDefault(n(6022));t.IpcWrapper=class{#b;#y;#f;#A=1;#Z=new Map;constructor(e,t,n){this.#b=e,this.#y=t,this.#f=n}async sendWithCb(e,t,n,s=0){s<=0&&(s=this.#f);const o={timeout:void 0,resolve:()=>null,reject:()=>null},r=new Promise(((e,t)=>{o.resolve=e,o.reject=t}));this.#A>268435456&&(this.#A=1);const a=this.#A++;this.#Z.set(a,o),this.#y({direction:"call",name:String(e),payload:i.default.stringify(t),callbackId:a});const c=new Error("Call timed out");return o.timeout=setTimeout((()=>{o.reject(n?n():c),this.#Z.delete(a)}),s),r}sendWithNoCb(e,t){this.#y({direction:"call",name:String(e),payload:i.default.stringify(t),callbackId:void 0})}receivedMessage(e){const t=e;switch(e.direction){case"call":{const t=this.#b[e.name];if(!t)return void(e.callbackId&&this.#y({direction:"response",callbackId:e.callbackId,success:!1,payload:i.default.stringify({message:`Unknown command "${e.name}"`})}));t(e.payload?i.default.parse(e.payload):void 0).then((t=>{e.callbackId&&this.#y({direction:"response",callbackId:e.callbackId,success:!0,payload:i.default.stringify(t)})}),(t=>{e.callbackId&&this.#y({direction:"response",callbackId:e.callbackId,success:!1,payload:t instanceof Error?JSON.stringify(t,Object.getOwnPropertyNames(t)):i.default.stringify(t)})}));break}case"response":{if(!e.callbackId)return void console.error("Ipc: Response message has no callbackId");const t=this.#Z.get(e.callbackId);if(this.#Z.delete(e.callbackId),!t)return;clearTimeout(t.timeout);const n=e.payload?i.default.parse(e.payload):void 0;if(e.success)t.resolve(n);else{let e=n;n&&"message"in n&&(e=new Error(n.message),n.stack&&(e.stack=n.stack)),t.reject(e)}break}default:(0,o.assertNever)(e),console.error(`Ipc: Message of unknown direction "${t.direction}"`)}}}},9967:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HostApiNodeJsIpc=void 0,t.HostApiNodeJsIpc="nodejs-ipc"},6278:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.runEntrypoint=t.assertNever=t.splitRgb=t.combineRgb=t.literal=void 0;const s=n(1635);s.__exportStar(n(9077),t),s.__exportStar(n(2018),t),s.__exportStar(n(4581),t);var o=n(360);Object.defineProperty(t,"literal",{enumerable:!0,get:function(){return o.literal}}),Object.defineProperty(t,"combineRgb",{enumerable:!0,get:function(){return o.combineRgb}}),Object.defineProperty(t,"splitRgb",{enumerable:!0,get:function(){return o.splitRgb}}),Object.defineProperty(t,"assertNever",{enumerable:!0,get:function(){return o.assertNever}}),s.__exportStar(n(6160),t);var i=n(4326);Object.defineProperty(t,"runEntrypoint",{enumerable:!0,get:function(){return i.runEntrypoint}})},4289:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ActionManager=void 0;const s=n(2593);function o(e){return{id:e.id,actionId:e.actionId,controlId:e.controlId,options:e.options}}t.ActionManager=class{#G;#v;#B;#W=new Map;#S=new Map;constructor(e,t,n){this.#G=e,this.#v=t,this.#B=n}async handleExecuteAction(e){const t=this.#W.get(e.action.actionId);if(!t)throw new Error(`Unknown action: ${e.action.actionId}`);const n={parseVariablesInString:async t=>(await this.#G({text:t,controlId:e.action.controlId,actionInstanceId:e.action.id,feedbackInstanceId:void 0})).text};await t.callback({id:e.action.id,actionId:e.action.actionId,controlId:e.action.controlId,options:e.action.options,surfaceId:e.surfaceId??e.deviceId,_deviceId:e.surfaceId??e.deviceId,_page:e.action.page,_bank:e.action.bank},n)}handleUpdateActions(e){for(const[t,n]of Object.entries(e)){const e=this.#S.get(t);if(e){const t=this.#W.get(e.actionId);if(t?.unsubscribe){const n={parseVariablesInString:async t=>(await this.#G({text:t,controlId:e.controlId,actionInstanceId:e.id,feedbackInstanceId:void 0})).text};Promise.resolve(t.unsubscribe(o(e),n)).catch((t=>{this.#B("error",`Action unsubscribe failed: ${JSON.stringify(e)} - ${t?.message??t} ${t?.stack}`)}))}}if(!n||n.disabled)this.#S.delete(t);else{this.#S.set(t,n);const e=this.#W.get(n.actionId);if(e?.subscribe){const t={parseVariablesInString:async e=>(await this.#G({text:e,controlId:n.controlId,actionInstanceId:n.id,feedbackInstanceId:void 0})).text};Promise.resolve(e.subscribe(o(n),t)).catch((e=>{this.#B("error",`Action subscribe failed: ${JSON.stringify(n)} - ${e?.message??e} ${e?.stack}`)}))}}}}async handleLearnAction(e){const t=this.#W.get(e.action.actionId);if(t&&t.learn){const n={parseVariablesInString:async t=>(await this.#G({text:t,controlId:e.action.controlId,actionInstanceId:e.action.id,feedbackInstanceId:void 0})).text};return{options:await t.learn({id:e.action.id,actionId:e.action.actionId,controlId:e.action.controlId,options:e.action.options,surfaceId:void 0,_deviceId:void 0,_page:e.action.page,_bank:e.action.bank},n)}}return{options:void 0}}setActionDefinitions(e){const t=[];this.#W.clear();for(const[n,o]of Object.entries(e))o&&(t.push({id:n,name:o.name,description:o.description,options:(0,s.serializeIsVisibleFn)(o.options),hasLearn:!!o.learn}),this.#W.set(n,o));this.#v({actions:t})}_getAllActions(){return Array.from(this.#S.values()).map((e=>({id:e.id,actionId:e.actionId,controlId:e.controlId,options:e.options})))}subscribeActions(e){let t=Array.from(this.#S.values());const n=new Set(e);n.size&&(t=t.filter((e=>n.has(e.actionId))));for(const e of t){const t=this.#W.get(e.actionId);if(t?.subscribe){const n={parseVariablesInString:async t=>(await this.#G({text:t,controlId:e.controlId,actionInstanceId:e.id,feedbackInstanceId:void 0})).text};Promise.resolve(t.subscribe(o(e),n)).catch((t=>{this.#B("error",`Action subscribe failed: ${JSON.stringify(e)} - ${t?.message??t} ${t?.stack}`)}))}}}unsubscribeActions(e){let t=Array.from(this.#S.values());const n=new Set(e);n.size&&(t=t.filter((e=>n.has(e.actionId))));for(const e of t){const t=this.#W.get(e.actionId);if(t&&t.unsubscribe){const n={parseVariablesInString:async t=>(await this.#G({text:t,controlId:e.controlId,actionInstanceId:e.id,feedbackInstanceId:void 0})).text};Promise.resolve(t.unsubscribe(o(e),n)).catch((t=>{this.#B("error",`Action unsubscribe failed: ${JSON.stringify(e)} - ${t?.message??t} ${t?.stack}`)}))}}}}},2593:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isInstanceBaseProps=t.serializeIsVisibleFn=void 0,t.serializeIsVisibleFn=function(e){return(e??[]).map((e=>"isVisible"in e&&"function"==typeof e.isVisible?{...e,isVisibleFn:e.isVisible.toString(),isVisible:void 0}:{...e,isVisibleFn:void 0}))},t.isInstanceBaseProps=function(e){const t=e;return"object"==typeof t&&"string"==typeof t.id&&!0===t._isInstanceBaseProps}},8039:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FeedbackManager=void 0;const s=n(1635),o=n(2593),i=s.__importDefault(n(7e3));function r(e,t){return{type:e,id:t.id,feedbackId:t.feedbackId,controlId:t.controlId,options:t.options}}t.FeedbackManager=class{#G;#V;#w;#B;#R=new Map;#H=new Map;#k=new Map;#Y=new Map;#X;get parseVariablesContext(){return this.#X}constructor(e,t,n,s){this.#G=e,this.#V=t,this.#w=n,this.#B=s}getDefinitionIds(){return Array.from(this.#R.keys())}getInstanceIds(){return Array.from(this.#H.keys())}handleUpdateFeedbacks(e){for(const[t,n]of Object.entries(e)){const e=this.#H.get(t);if(e){const t=this.#R.get(e.feedbackId);if(t?.unsubscribe){const n={parseVariablesInString:async t=>(await this.#G({text:t,controlId:e.controlId,actionInstanceId:void 0,feedbackInstanceId:e.id})).text};Promise.resolve(t.unsubscribe(r(t.type,e),n)).catch((t=>{this.#B("error",`Feedback unsubscribe failed: ${JSON.stringify(e)} - ${t?.message??t} ${t?.stack}`)}))}}if(!n||n.disabled)this.#H.delete(t);else{this.#H.set(t,{...n,referencedVariables:null});const e=this.#R.get(n.feedbackId);if(e?.subscribe){const t={parseVariablesInString:async e=>(await this.#G({text:e,controlId:n.controlId,actionInstanceId:void 0,feedbackInstanceId:n.id})).text};Promise.resolve(e.subscribe(r(e.type,n),t)).catch((e=>{this.#B("error",`Feedback subscribe failed: ${JSON.stringify(n)} - ${e?.message??e} ${e?.stack}`)}))}this.#N(t)}}}async handleLearnFeedback(e){const t=this.#R.get(e.feedback.feedbackId);if(t&&t.learn){const n={parseVariablesInString:async t=>(await this.#G({text:t,controlId:e.feedback.controlId,actionInstanceId:void 0,feedbackInstanceId:e.feedback.id})).text};return{options:await t.learn({id:e.feedback.id,feedbackId:e.feedback.feedbackId,controlId:e.feedback.controlId,options:e.feedback.options,type:t.type},n)}}return{options:void 0}}handleVariablesChanged(e){if(!e.variablesIds.length)return;const t=new Set(e.variablesIds);for(const t of this.#Y.values())for(const n of e.variablesIds)t.changedVariables.add(n);const n=new Set;for(const e of this.#H.values())if(!this.#Y.has(e.id)&&e.referencedVariables)for(const s of e.referencedVariables)if(t.has(s)){n.add(e.id);break}for(const e of n)setImmediate((()=>{this.#N(e)}))}#N(e){const t=this.#Y.get(e);if(t)return void(t.needsRecheck=!0);const n=this.#H.get(e);if(!n)return;const s=n,o={needsRecheck:!1,changedVariables:new Set};this.#Y.set(e,o),Promise.resolve().then((async()=>{const t=this.#R.get(s.feedbackId);let n;const o=new Set;if(t){this.#X=`Feedback ${s.feedbackId} (${e})`;const i={parseVariablesInString:async t=>{const n=await this.#G({text:t,controlId:s.controlId,actionInstanceId:void 0,feedbackInstanceId:e});if(n.variableIds&&n.variableIds.length)for(const e of n.variableIds)o.add(e);return n.text}};n="boolean"===t.type?t.callback({...r("boolean",s),type:"boolean",_rawBank:s.rawBank},i):t.callback({...r("advanced",s),type:"advanced",image:s.image,_page:s.page,_bank:s.bank,_rawBank:s.rawBank},i),this.#X=void 0}const i=await n;this.#k.set(e,{id:e,controlId:s.controlId,value:i}),this.#_(),s.referencedVariables=o.size>0?Array.from(o):null})).catch((e=>{console.error(`Feedback check failed: ${JSON.stringify(s)} - ${e?.message??e} ${e?.stack}`)})).finally((()=>{this.#X=void 0,this.#Y.delete(e);let t=!1;if(s.referencedVariables)for(const e of s.referencedVariables)if(o.changedVariables.has(e)){t=!0;break}(t||o.needsRecheck)&&setImmediate((()=>{this.#N(e)}))}))}#_=(0,i.default)((()=>{const e=this.#k;this.#k=new Map,e.size>0&&this.#V({values:Array.from(e.values())})}),{wait:5,maxWait:25});setFeedbackDefinitions(e){const t=[];this.#R.clear();for(const[n,s]of Object.entries(e))s&&(t.push({id:n,name:s.name,description:s.description,options:(0,o.serializeIsVisibleFn)(s.options),type:s.type,defaultStyle:"boolean"===s.type?s.defaultStyle:void 0,hasLearn:!!s.learn,showInvert:"boolean"===s.type&&s.showInvert}),this.#R.set(n,s));this.#w({feedbacks:t})}checkFeedbacks(e){const t=new Set(e);for(const[e,n]of this.#H.entries())this.#R.get(n.feedbackId)&&(0===t.size||t.has(n.feedbackId))&&this.#N(e)}checkFeedbacksById(e){for(const t of e)this.#N(t)}_getAllFeedbacks(){return Array.from(this.#H.values()).map((e=>({id:e.id,feedbackId:e.feedbackId,controlId:e.controlId,options:e.options})))}subscribeFeedbacks(e){let t=Array.from(this.#H.values());const n=new Set(e);n.size&&(t=t.filter((e=>n.has(e.feedbackId))));for(const e of t){const t=this.#R.get(e.feedbackId);if(t?.subscribe){const n={parseVariablesInString:async t=>(await this.#G({text:t,controlId:e.controlId,actionInstanceId:void 0,feedbackInstanceId:e.id})).text};Promise.resolve(t.subscribe(r(t.type,e),n)).catch((t=>{this.#B("error",`Feedback subscribe failed: ${JSON.stringify(e)} - ${t?.message??t} ${t?.stack}`)}))}}}unsubscribeFeedbacks(e){let t=Array.from(this.#H.values());const n=new Set(e);n.size&&(t=t.filter((e=>n.has(e.feedbackId))));for(const e of t){const t=this.#R.get(e.feedbackId);if(t&&t.unsubscribe){const n={parseVariablesInString:async t=>(await this.#G({text:t,controlId:e.controlId,actionInstanceId:void 0,feedbackInstanceId:e.id})).text};Promise.resolve(t.unsubscribe(r(t.type,e),n)).catch((t=>{this.#B("error",`Feedback unsubscribe failed: ${JSON.stringify(e)} - ${t?.message??t} ${t?.stack}`)}))}}}}},1706:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.runThroughUpgradeScripts=void 0;const s=n(360);function o(e){return JSON.parse(JSON.stringify(e))}t.runThroughUpgradeScripts=function(e,t,n,i,r,a){const c=new Map,l=e=>{let t=c.get(e);return t||(t={actions:[],feedbacks:[],config:!1},c.set(e,t)),t};for(const t of Object.values(e)){const e=t?.upgradeIndex??n;t&&"number"==typeof e&&l(e).actions.push(t.id)}for(const e of Object.values(t)){const t=e?.upgradeIndex??n;e&&"number"==typeof t&&l(t).feedbacks.push(e.id)}if(!a)for(let e=n??-1;e0){const a=Array.from(c.keys()).sort(),l=Math.min(...a,n??-1)+1,h=[],p=[],I=i.length;for(let n=l;n{const n=e[t];if(n)return(0,s.literal)({id:n.id,controlId:n.controlId,actionId:n.actionId,options:void 0!==n.options?o(n.options):{}})})).filter((e=>!!e)),feedbacks:p.map((e=>{const n=t[e];if(n)return(0,s.literal)({id:n.id,controlId:n.controlId,feedbackId:n.feedbackId,options:void 0!==n.options?o(n.options):{},isInverted:n.isInverted})})).filter((e=>!!e))});l&&m.updatedConfig&&(u=m.updatedConfig);for(const t of m.updatedActions)if(t){const n=e[t.id];n&&(n.actionId=t.actionId,n.options=t.options,d[t.id]=n)}for(const e of m.updatedFeedbacks)if(e){const n=t[e.id];n&&(n.feedbackId=e.feedbackId,n.options=e.options,g[e.id]={...n,style:g[e.id]?.style??e.style,isInverted:e.isInverted??!1})}}for(const[t,n]of Object.entries(e))d[t]||"number"!=typeof n?.upgradeIndex||(d[t]=n);for(const[e,n]of Object.entries(t))g[e]||"number"!=typeof n?.upgradeIndex||(g[e]=n)}return{updatedActions:d,updatedFeedbacks:g,updatedConfig:u}}},9077:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validateManifest=void 0;const s=n(1635).__importDefault(n(7281));t.validateManifest=function(e){if(!(0,s.default)(e)){const e=s.default.errors;if(!e)throw new Error("Manifest failed validation with unknown reason");throw new Error(`Manifest validation failed: ${JSON.stringify(e)}`)}}},3730:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},1649:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InstanceBase=void 0;const s=n(1635),o=n(360),i=s.__importDefault(n(3290)),r=n(2593),a=n(1706),c=n(8039),l=n(4044),g=n(4289);t.InstanceBase=class{#J;#F;id;#K=new i.default({concurrency:1});#x=!1;#E=!1;#T={};#z;#U;#O=new Map;#L=new Map;#n;#j;get instanceOptions(){return this.#n}get label(){return this.#j}constructor(e){if(!(0,r.isInstanceBaseProps)(e)||!e._isInstanceBaseProps)throw new Error("Module instance is being constructed incorrectly. Make sure you aren't trying to do this manually");this.#n={disableVariableValidation:!1},this.#J=new l.IpcWrapper({init:this._handleInit.bind(this),destroy:this._handleDestroy.bind(this),updateConfigAndLabel:this._handleConfigUpdateAndLabel.bind(this),updateConfig:async()=>{},executeAction:this._handleExecuteAction.bind(this),updateFeedbacks:this._handleUpdateFeedbacks.bind(this),updateActions:this._handleUpdateActions.bind(this),getConfigFields:this._handleGetConfigFields.bind(this),handleHttpRequest:this._handleHttpRequest.bind(this),learnAction:this._handleLearnAction.bind(this),learnFeedback:this._handleLearnFeedback.bind(this),startStopRecordActions:this._handleStartStopRecordActions.bind(this),variablesChanged:this._handleVariablesChanged.bind(this)},(e=>{process.send(e)}),5e3),process.on("message",(e=>{this.#J.receivedMessage(e)})),this.#z=new g.ActionManager((async e=>this.#J.sendWithCb("parseVariablesInString",e)),(e=>this.#J.sendWithNoCb("setActionDefinitions",e)),this.log.bind(this)),this.#U=new c.FeedbackManager((async e=>this.#J.sendWithCb("parseVariablesInString",e)),(e=>this.#J.sendWithNoCb("updateFeedbackValues",e)),(e=>this.#J.sendWithNoCb("setFeedbackDefinitions",e)),this.log.bind(this)),this.#F=e.upgradeScripts,this.id=e.id,this.#j=e.id,this.log("debug","Initializing")}async _handleInit(e){return this.#K.add((async()=>{if(this.#x)throw new Error("Already initialized");const t=e.actions,n=e.feedbacks;if(this.#T=e.config,this.#j=e.label,e.isFirstInit){const t={},n=this.getConfigFields();for(const e of n)"default"in e&&(t[e.id]=e.default);this.#T=t,this.saveConfig(this.#T),e.lastUpgradeIndex=this.#F.length-1}const{updatedActions:s,updatedFeedbacks:o,updatedConfig:i}=(0,a.runThroughUpgradeScripts)(t,n,e.lastUpgradeIndex,this.#F,this.#T,!1);this.#T=i??this.#T;const r=this.#J.sendWithCb("upgradedItems",{updatedActions:s,updatedFeedbacks:o});try{await this.init(this.#T,!!e.isFirstInit),this.#x=!0}catch(e){throw console.trace(`Init failed: ${e}`),e}finally{await r}return setImmediate((()=>{this._handleUpdateActions({actions:t},!0).catch((e=>{this.log("error",`Receive actions failed: ${e}`)})),this._handleUpdateFeedbacks({feedbacks:n},!0).catch((e=>{this.log("error",`Receive feedbacks failed: ${e}`)}))})),{hasHttpHandler:"function"==typeof this.handleHttpRequest,hasRecordActionsHandler:"function"==typeof this.handleStartStopRecordActions,newUpgradeIndex:this.#F.length-1,updatedConfig:this.#T}}))}async _handleDestroy(){await this.#K.add((async()=>{if(!this.#x)throw new Error("Not initialized");await this.destroy(),this.#x=!1}))}async _handleConfigUpdateAndLabel(e){await this.#K.add((async()=>{if(!this.#x)throw new Error("Not initialized");this.#j=e.label,this.#T=e.config,await this.configUpdated(this.#T)}))}async _handleExecuteAction(e){return this.#z.handleExecuteAction(e)}async _handleUpdateFeedbacks(e,t){if(!t){const t=(0,a.runThroughUpgradeScripts)({},e.feedbacks,null,this.#F,this.#T,!0);this.#J.sendWithCb("upgradedItems",{updatedActions:t.updatedActions,updatedFeedbacks:t.updatedFeedbacks}).catch((e=>{this.log("error",`Failed to save upgraded feedbacks: ${e}`)}))}this.#U.handleUpdateFeedbacks(e.feedbacks)}async _handleUpdateActions(e,t){if(!t){const t=(0,a.runThroughUpgradeScripts)(e.actions,{},null,this.#F,this.#T,!0);this.#J.sendWithCb("upgradedItems",{updatedActions:t.updatedActions,updatedFeedbacks:t.updatedFeedbacks}).catch((e=>{this.log("error",`Failed to save upgraded actions: ${e}`)}))}this.#z.handleUpdateActions(e.actions)}async _handleGetConfigFields(e){return{fields:(0,r.serializeIsVisibleFn)(this.getConfigFields())}}async _handleHttpRequest(e){if(!this.handleHttpRequest)throw new Error("handleHttpRequest is not supported!");return{response:await this.handleHttpRequest(e.request)}}async _handleLearnAction(e){return this.#z.handleLearnAction(e)}async _handleLearnFeedback(e){return this.#U.handleLearnFeedback(e)}async _handleStartStopRecordActions(e){if(e.recording){if(this.#E)return}else if(!this.#E)return;if(!this.handleStartStopRecordActions)throw this.#E=!1,new Error("Recording actions is not supported by this module!");this.#E=e.recording,this.handleStartStopRecordActions(this.#E)}async _handleVariablesChanged(e){this.#U.handleVariablesChanged(e)}saveConfig(e){this.#T=e,this.#J.sendWithNoCb("saveConfig",{config:e})}setActionDefinitions(e){this.#z.setActionDefinitions(e)}setFeedbackDefinitions(e){this.#U.setFeedbackDefinitions(e)}setPresetDefinitions(e){const t=[];for(const[n,s]of Object.entries(e))s&&t.push({...s,id:n});this.#J.sendWithNoCb("setPresetDefinitions",{presets:t})}setVariableDefinitions(e){const t=[];this.#O.clear();for(const n of e)t.push({id:n.variableId,name:n.name}),this.#O.set(n.variableId,n),this.#L.has(n.variableId)||this.#L.set(n.variableId,"");if(!this.#n.disableVariableValidation){const e=new Set(this.#O.keys());for(const t of this.#L.keys())e.has(t)||this.#L.delete(t)}this.#J.sendWithNoCb("setVariableDefinitions",{variables:t})}setVariableValues(e){const t=[];for(const[n,s]of Object.entries(e))this.#n.disableVariableValidation?(void 0===s?this.#L.delete(n):this.#L.set(n,s),t.push({id:n,value:s})):this.#O.has(n)?(this.#L.set(n,s??""),t.push({id:n,value:s??""})):t.push({id:n,value:void 0});this.#J.sendWithNoCb("setVariableValues",{newValues:t})}getVariableValue(e){return this.#L.get(e)}async parseVariablesInString(e){const t=this.#U.parseVariablesContext;return t&&this.log("debug",`parseVariablesInString called while in: ${t}. You should use the parseVariablesInString provided to the callback instead`),(await this.#J.sendWithCb("parseVariablesInString",{text:e,controlId:void 0,actionInstanceId:void 0,feedbackInstanceId:void 0})).text}checkFeedbacks(...e){this.#U.checkFeedbacks(e)}checkFeedbacksById(...e){this.#U.checkFeedbacksById(e)}_getAllActions(){return this.#z._getAllActions()}subscribeActions(...e){this.#z.subscribeActions(e)}unsubscribeActions(...e){this.#z.unsubscribeActions(e)}_getAllFeedbacks(){return this.#U._getAllFeedbacks()}subscribeFeedbacks(...e){this.#U.subscribeFeedbacks(e)}unsubscribeFeedbacks(...e){this.#U.unsubscribeFeedbacks(e)}recordAction(e,t){if(!this.#E)throw new Error("Not currently recording actions");this.#J.sendWithNoCb("recordAction",{uniquenessId:t??null,actionId:e.actionId,options:e.options})}setCustomVariableValue(e,t){this.#J.sendWithNoCb("setCustomVariable",{customVariableId:e,value:t})}oscSend(e,t,n,s){this.#J.sendWithNoCb("send-osc",(0,o.literal)({host:e,port:t,path:n,args:s}))}updateStatus(e,t){this.#J.sendWithNoCb("set-status",(0,o.literal)({status:e,message:t??null}))}log(e,t){this.#J.sendWithNoCb("log-message",(0,o.literal)({level:e,message:t}))}}},7386:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},1400:(e,t)=>{"use strict";var n,s;Object.defineProperty(t,"__esModule",{value:!0}),t.Regex=t.InstanceStatus=void 0,(s=t.InstanceStatus||(t.InstanceStatus={})).Ok="ok",s.Connecting="connecting",s.Disconnected="disconnected",s.ConnectionFailure="connection_failure",s.BadConfig="bad_config",s.UnknownError="unknown_error",s.UnknownWarning="unknown_warning",(n=t.Regex||(t.Regex={})).IP="/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/",n.HOSTNAME="/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9])$/",n.BOOLEAN="/^(true|false|0|1)$/i",n.PORT="/^([1-9]|[1-8][0-9]|9[0-9]|[1-8][0-9]{2}|9[0-8][0-9]|99[0-9]|[1-8][0-9]{3}|9[0-8][0-9]{2}|99[0-8][0-9]|999[0-9]|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-4])$/",n.PERCENT="/^(100|[0-9]|[0-9][0-9])$/",n.FLOAT="/^([0-9]*\\.)?[0-9]+$/",n.SIGNED_FLOAT="/^[+-]?([0-9]*\\.)?[0-9]+$/",n.FLOAT_OR_INT="/^([0-9]+)(\\.[0-9]+)?$/",n.NUMBER="/^\\d+$/",n.SIGNED_NUMBER="/^[+-]?\\d+$/",n.SOMETHING="/^.+$/",n.TIMECODE="/^(0*[0-9]|1[0-9]|2[0-4]):(0*[0-9]|[1-5][0-9]|60):(0*[0-9]|[1-5][0-9]|60):(0*[0-9]|[12][0-9]|30)$/"},8983:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},8104:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},2018:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const s=n(1635);s.__exportStar(n(3730),t),s.__exportStar(n(1649),t),s.__exportStar(n(7386),t),s.__exportStar(n(1400),t),s.__exportStar(n(8983),t),s.__exportStar(n(8104),t),s.__exportStar(n(3258),t),s.__exportStar(n(131),t),s.__exportStar(n(3371),t),s.__exportStar(n(9786),t),s.__exportStar(n(6132),t)},3258:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},131:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},3371:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},9786:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CreateUseBuiltinInvertForFeedbacksUpgradeScript=t.CreateConvertToBooleanFeedbackUpgradeScript=t.EmptyUpgradeScript=void 0,t.EmptyUpgradeScript=()=>({updatedConfig:null,updatedActions:[],updatedFeedbacks:[]}),t.CreateConvertToBooleanFeedbackUpgradeScript=function(e){return(t,n)=>{const s=[];for(const t of n.feedbacks){let n=e[t.feedbackId];if(!0===n&&(n={bg:"bgcolor",bgcolor:"bgcolor",fg:"color",color:"color",png64:"png64",png:"png64"}),n){t.style||(t.style={});for(const[e,o]of Object.entries(n))void 0!==t.options[e]&&(t.style[o]=t.options[e],delete t.options[e],s.push(t))}}return{updatedConfig:null,updatedActions:[],updatedFeedbacks:s}}},t.CreateUseBuiltinInvertForFeedbacksUpgradeScript=function(e){return(t,n)=>{const s=[];for(const t of n.feedbacks){let n=e[t.feedbackId];if("string"!=typeof n)continue;const o=t.options[n];void 0!==o&&(delete t.options[n],t.isInverted="true"===o||!0===o||Number(o)>0,s.push(t))}return{updatedConfig:null,updatedActions:[],updatedFeedbacks:s}}}},6132:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},360:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.splitRgb=t.combineRgb=t.assertNever=t.literal=void 0,t.literal=function(e){return e},t.assertNever=function(e){},t.combineRgb=function(e,t,n){return(255&e)<<16|(255&t)<<8|255&n},t.splitRgb=function(e){return{r:(16711680&e)>>16,g:(65280&e)>>8,b:255&e}}},7281:(e,t,n)=>{"use strict";e.exports=i,e.exports.default=i;const s={$schema:"http://json-schema.org/draft-07/schema#",type:"object",title:"ModuleManifest",properties:{id:{type:"string",description:"Unique identifier for the module"},name:{type:"string",description:"Name of the module"},shortname:{type:"string"},description:{type:"string",description:"Description of the module "},version:{type:"string",description:"Current version of the module"},license:{type:"string",description:"SPDX identifier for license of the module"},repository:{type:"string",description:"URL to the source repository"},bugs:{type:"string",description:"URL to bug tracker"},maintainers:{type:"array",description:"List of active maintiners",uniqueItems:!0,items:{type:"object",title:"ModuleManifestMaintainer",properties:{name:{type:"string"},email:{type:"string"},github:{type:"string"}},required:["name"]}},legacyIds:{type:"array",description:"If the module had a different unique identifier previously, then specify it here",uniqueItems:!0,items:{type:"string"}},runtime:{type:"object",title:"ModuleManifestRuntime",description:"Information on how to execute the module",properties:{type:{type:"string",description:"Type of the module. Must be: node18"},api:{type:"string",description:"Which host-api does it use. In the future alternate options will be allowed",enum:["nodejs-ipc"]},apiVersion:{type:"string",description:"The version of the host-api used"},entrypoint:{type:"string",description:"Entrypoint to pass to the runtime. eg index.js"}},required:["type","api","apiVersion","entrypoint"]},manufacturer:{type:"string"},products:{type:"array",uniqueItems:!0,items:{type:"string"}},keywords:{type:"array",uniqueItems:!0,items:{type:"string"}}},required:["id","name","shortname","description","version","license","repository","bugs","maintainers","legacyIds","runtime","manufacturer","products","keywords"]},o=n(7169).A;function i(e,{instancePath:t="",parentData:n,parentDataProperty:r,rootData:a=e}={}){if(!e||"object"!=typeof e||Array.isArray(e))return i.errors=[{instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;{let n;if(void 0===e.id&&(n="id")||void 0===e.name&&(n="name")||void 0===e.shortname&&(n="shortname")||void 0===e.description&&(n="description")||void 0===e.version&&(n="version")||void 0===e.license&&(n="license")||void 0===e.repository&&(n="repository")||void 0===e.bugs&&(n="bugs")||void 0===e.maintainers&&(n="maintainers")||void 0===e.legacyIds&&(n="legacyIds")||void 0===e.runtime&&(n="runtime")||void 0===e.manufacturer&&(n="manufacturer")||void 0===e.products&&(n="products")||void 0===e.keywords&&(n="keywords"))return i.errors=[{instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:n},message:"must have required property '"+n+"'"}],!1;if(void 0!==e.id){const n=0;if("string"!=typeof e.id)return i.errors=[{instancePath:t+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var c=0===n}else c=!0;if(c){if(void 0!==e.name){const n=0;if("string"!=typeof e.name)return i.errors=[{instancePath:t+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;c=0===n}else c=!0;if(c){if(void 0!==e.shortname){const n=0;if("string"!=typeof e.shortname)return i.errors=[{instancePath:t+"/shortname",schemaPath:"#/properties/shortname/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;c=0===n}else c=!0;if(c){if(void 0!==e.description){const n=0;if("string"!=typeof e.description)return i.errors=[{instancePath:t+"/description",schemaPath:"#/properties/description/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;c=0===n}else c=!0;if(c){if(void 0!==e.version){const n=0;if("string"!=typeof e.version)return i.errors=[{instancePath:t+"/version",schemaPath:"#/properties/version/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;c=0===n}else c=!0;if(c){if(void 0!==e.license){const n=0;if("string"!=typeof e.license)return i.errors=[{instancePath:t+"/license",schemaPath:"#/properties/license/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;c=0===n}else c=!0;if(c){if(void 0!==e.repository){const n=0;if("string"!=typeof e.repository)return i.errors=[{instancePath:t+"/repository",schemaPath:"#/properties/repository/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;c=0===n}else c=!0;if(c){if(void 0!==e.bugs){const n=0;if("string"!=typeof e.bugs)return i.errors=[{instancePath:t+"/bugs",schemaPath:"#/properties/bugs/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;c=0===n}else c=!0;if(c){if(void 0!==e.maintainers){let n=e.maintainers;const s=0;if(0===s){if(!Array.isArray(n))return i.errors=[{instancePath:t+"/maintainers",schemaPath:"#/properties/maintainers/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;{var l=!0;const e=n.length;for(let s=0;s1)for(;s--;)for(e=s;e--;)if(o(n[s],n[e]))return i.errors=[{instancePath:t+"/maintainers",schemaPath:"#/properties/maintainers/uniqueItems",keyword:"uniqueItems",params:{i:s,j:e},message:"must NOT have duplicate items (items ## "+e+" and "+s+" are identical)"}],!1}}}c=0===s}else c=!0;if(c){if(void 0!==e.legacyIds){let n=e.legacyIds;const s=0;if(0===s){if(!Array.isArray(n))return i.errors=[{instancePath:t+"/legacyIds",schemaPath:"#/properties/legacyIds/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;{var d=!0;const e=n.length;for(let s=0;s1){const o={};for(;s--;){let r=n[s];if("string"==typeof r){if("number"==typeof o[r])return e=o[r],i.errors=[{instancePath:t+"/legacyIds",schemaPath:"#/properties/legacyIds/uniqueItems",keyword:"uniqueItems",params:{i:s,j:e},message:"must NOT have duplicate items (items ## "+e+" and "+s+" are identical)"}],!1;o[r]=s}}}}}}c=0===s}else c=!0;if(c){if(void 0!==e.runtime){let n=e.runtime;const o=0;if(0===o){if(!n||"object"!=typeof n||Array.isArray(n))return i.errors=[{instancePath:t+"/runtime",schemaPath:"#/properties/runtime/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;{let e;if(void 0===n.type&&(e="type")||void 0===n.api&&(e="api")||void 0===n.apiVersion&&(e="apiVersion")||void 0===n.entrypoint&&(e="entrypoint"))return i.errors=[{instancePath:t+"/runtime",schemaPath:"#/properties/runtime/required",keyword:"required",params:{missingProperty:e},message:"must have required property '"+e+"'"}],!1;if(void 0!==n.type){const e=0;if("string"!=typeof n.type)return i.errors=[{instancePath:t+"/runtime/type",schemaPath:"#/properties/runtime/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=0===e}else u=!0;if(u){if(void 0!==n.api){let e=n.api;const o=0;if("string"!=typeof e)return i.errors=[{instancePath:t+"/runtime/api",schemaPath:"#/properties/runtime/properties/api/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if("nodejs-ipc"!==e)return i.errors=[{instancePath:t+"/runtime/api",schemaPath:"#/properties/runtime/properties/api/enum",keyword:"enum",params:{allowedValues:s.properties.runtime.properties.api.enum},message:"must be equal to one of the allowed values"}],!1;u=0===o}else u=!0;if(u){if(void 0!==n.apiVersion){const e=0;if("string"!=typeof n.apiVersion)return i.errors=[{instancePath:t+"/runtime/apiVersion",schemaPath:"#/properties/runtime/properties/apiVersion/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;u=0===e}else u=!0;if(u)if(void 0!==n.entrypoint){const e=0;if("string"!=typeof n.entrypoint)return i.errors=[{instancePath:t+"/runtime/entrypoint",schemaPath:"#/properties/runtime/properties/entrypoint/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;u=0===e}else u=!0}}}}c=0===o}else c=!0;if(c){if(void 0!==e.manufacturer){const n=0;if("string"!=typeof e.manufacturer)return i.errors=[{instancePath:t+"/manufacturer",schemaPath:"#/properties/manufacturer/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;c=0===n}else c=!0;if(c){if(void 0!==e.products){let n=e.products;const s=0;if(0===s){if(!Array.isArray(n))return i.errors=[{instancePath:t+"/products",schemaPath:"#/properties/products/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;{var h=!0;const e=n.length;for(let s=0;s1){const o={};for(;s--;){let r=n[s];if("string"==typeof r){if("number"==typeof o[r])return e=o[r],i.errors=[{instancePath:t+"/products",schemaPath:"#/properties/products/uniqueItems",keyword:"uniqueItems",params:{i:s,j:e},message:"must NOT have duplicate items (items ## "+e+" and "+s+" are identical)"}],!1;o[r]=s}}}}}}c=0===s}else c=!0;if(c)if(void 0!==e.keywords){let n=e.keywords;const s=0;if(0===s){if(!Array.isArray(n))return i.errors=[{instancePath:t+"/keywords",schemaPath:"#/properties/keywords/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;{var p=!0;const e=n.length;for(let s=0;s1){const o={};for(;s--;){let r=n[s];if("string"==typeof r){if("number"==typeof o[r])return e=o[r],i.errors=[{instancePath:t+"/keywords",schemaPath:"#/properties/keywords/uniqueItems",keyword:"uniqueItems",params:{i:s,j:e},message:"must NOT have duplicate items (items ## "+e+" and "+s+" are identical)"}],!1;o[r]=s}}}}}}c=0===s}else c=!0}}}}}}}}}}}}}return i.errors=null,!0}},7e3:(e,t,n)=>{"use strict";const s=n(4865);e.exports=(e,t={})=>{if("function"!=typeof e)throw new TypeError(`Expected the first argument to be a function, got \`${typeof e}\``);const{wait:n=0,maxWait:o=0,before:i=!1,after:r=!0}=t;if(!i&&!r)throw new Error("Both `before` and `after` are false, function wouldn't be called.");let a,c,l;const g=function(...t){const s=this,g=i&&!a;return clearTimeout(a),a=setTimeout((()=>{a=void 0,c&&(clearTimeout(c),c=void 0),r&&(l=e.apply(s,t))}),n),o>0&&!c&&r&&(c=setTimeout((()=>{c=void 0,a&&(clearTimeout(a),a=void 0),l=e.apply(s,t)}),o)),g&&(l=e.apply(s,t)),l};return s(g,e),g.cancel=()=>{a&&(clearTimeout(a),a=void 0),c&&(clearTimeout(c),c=void 0)},g}},1635:(e,t,n)=>{"use strict";n.r(t),n.d(t,{__addDisposableResource:()=>X,__assign:()=>i,__asyncDelegator:()=>B,__asyncGenerator:()=>v,__asyncValues:()=>W,__await:()=>G,__awaiter:()=>p,__classPrivateFieldGet:()=>H,__classPrivateFieldIn:()=>Y,__classPrivateFieldSet:()=>k,__createBinding:()=>m,__decorate:()=>a,__disposeResources:()=>_,__esDecorate:()=>l,__exportStar:()=>C,__extends:()=>o,__generator:()=>I,__importDefault:()=>R,__importStar:()=>w,__makeTemplateObject:()=>S,__metadata:()=>h,__param:()=>c,__propKey:()=>d,__read:()=>y,__rest:()=>r,__runInitializers:()=>g,__setFunctionName:()=>u,__spread:()=>f,__spreadArray:()=>Z,__spreadArrays:()=>A,__values:()=>b,default:()=>J});var s=function(e,t){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},s(e,t)};function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}s(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var i=function(){return i=Object.assign||function(e){for(var t,n=1,s=arguments.length;n=0;a--)(o=e[a])&&(r=(i<3?o(r):i>3?o(t,n,r):o(t,n))||r);return i>3&&r&&Object.defineProperty(t,n,r),r}function c(e,t){return function(n,s){t(n,s,e)}}function l(e,t,n,s,o,i){function r(e){if(void 0!==e&&"function"!=typeof e)throw new TypeError("Function expected");return e}for(var a,c=s.kind,l="getter"===c?"get":"setter"===c?"set":"value",g=!t&&e?s.static?e:e.prototype:null,d=t||(g?Object.getOwnPropertyDescriptor(g,s.name):{}),u=!1,h=n.length-1;h>=0;h--){var p={};for(var I in s)p[I]="access"===I?{}:s[I];for(var I in s.access)p.access[I]=s.access[I];p.addInitializer=function(e){if(u)throw new TypeError("Cannot add initializers after decoration has completed");i.push(r(e||null))};var m=(0,n[h])("accessor"===c?{get:d.get,set:d.set}:d[l],p);if("accessor"===c){if(void 0===m)continue;if(null===m||"object"!=typeof m)throw new TypeError("Object expected");(a=r(m.get))&&(d.get=a),(a=r(m.set))&&(d.set=a),(a=r(m.init))&&o.unshift(a)}else(a=r(m))&&("field"===c?o.unshift(a):d[l]=a)}g&&Object.defineProperty(g,s.name,d),u=!0}function g(e,t,n){for(var s=arguments.length>2,o=0;o0&&o[o.length-1])||6!==a[0]&&2!==a[0])){r=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]=e.length&&(e=void 0),{value:e&&e[s++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function y(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var s,o,i=n.call(e),r=[];try{for(;(void 0===t||t-- >0)&&!(s=i.next()).done;)r.push(s.value)}catch(e){o={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return r}function f(){for(var e=[],t=0;t1||a(e,t)}))})}function a(e,t){try{(n=o[e](t)).value instanceof G?Promise.resolve(n.value.v).then(c,l):g(i[0][2],n)}catch(e){g(i[0][3],e)}var n}function c(e){a("next",e)}function l(e){a("throw",e)}function g(e,t){e(t),i.shift(),i.length&&a(i[0][0],i[0][1])}}function B(e){var t,n;return t={},s("next"),s("throw",(function(e){throw e})),s("return"),t[Symbol.iterator]=function(){return this},t;function s(s,o){t[s]=e[s]?function(t){return(n=!n)?{value:G(e[s](t)),done:!1}:o?o(t):t}:o}}function W(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=b(e),t={},s("next"),s("throw"),s("return"),t[Symbol.asyncIterator]=function(){return this},t);function s(n){t[n]=e[n]&&function(t){return new Promise((function(s,o){!function(e,t,n,s){Promise.resolve(s).then((function(t){e({value:t,done:n})}),t)}(s,o,(t=e[n](t)).done,t.value)}))}}}function S(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var V=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t};function w(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&m(t,e,n);return V(t,e),t}function R(e){return e&&e.__esModule?e:{default:e}}function H(e,t,n,s){if("a"===n&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?s:"a"===n?s.call(e):s?s.value:t.get(e)}function k(e,t,n,s,o){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?o.call(e,n):o?o.value=n:t.set(e,n),n}function Y(e,t){if(null===t||"object"!=typeof t&&"function"!=typeof t)throw new TypeError("Cannot use 'in' operator on non-object");return"function"==typeof e?t===e:e.has(t)}function X(e,t,n){if(null!=t){if("object"!=typeof t&&"function"!=typeof t)throw new TypeError("Object expected.");var s;if(n){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");s=t[Symbol.asyncDispose]}if(void 0===s){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");s=t[Symbol.dispose]}if("function"!=typeof s)throw new TypeError("Object not disposable.");e.stack.push({value:t,dispose:s,async:n})}else n&&e.stack.push({async:!0});return t}var N="function"==typeof SuppressedError?SuppressedError:function(e,t,n){var s=new Error(n);return s.name="SuppressedError",s.error=e,s.suppressed=t,s};function _(e){function t(t){e.error=e.hasError?new N(t,e.error,"An error was suppressed during disposal."):t,e.hasError=!0}return function n(){for(;e.stack.length;){var s=e.stack.pop();try{var o=s.dispose&&s.dispose.call(s.value);if(s.async)return Promise.resolve(o).then(n,(function(e){return t(e),n()}))}catch(e){t(e)}}if(e.hasError)throw e.error}()}const J={__extends:o,__assign:i,__rest:r,__decorate:a,__param:c,__metadata:h,__awaiter:p,__generator:I,__createBinding:m,__exportStar:C,__values:b,__read:y,__spread:f,__spreadArrays:A,__spreadArray:Z,__await:G,__asyncGenerator:v,__asyncDelegator:B,__asyncValues:W,__makeTemplateObject:S,__importStar:w,__importDefault:R,__classPrivateFieldGet:H,__classPrivateFieldSet:k,__classPrivateFieldIn:Y,__addDisposableResource:X,__disposeResources:_}},8736:(e,t,n)=>{"use strict";var s=n(6278),o=n(7113);const i=[{id:"0",label:"No fade to black",cmd:Buffer.from([85,170,0,175,254,0,4,0,0,0,1,48,0,0,0,0,139,0,0,0,2,1,0,0,0,0,0,0,0,10,19,0,0,0,0,0,91,123,34,115,99,114,101,101,110,73,100,34,58,50,53,53,44,34,115,99,114,101,101,110,84,121,112,101,34,58,50,44,34,70,84,66,34,58,123,34,101,110,97,98,108,101,34,58,48,44,34,116,105,109,101,34,58,48,125,125,44,123,34,115,99,114,101,101,110,73,100,34,58,50,53,53,44,34,115,99,114,101,101,110,84,121,112,101,34,58,52,44,34,70,84,66,34,58,123,34,101,110,97,98,108,101,34,58,48,44,34,116,105,109,101,34,58,48,125,125,93,122,125])},{id:"1",label:"Fade to black",cmd:Buffer.from([85,170,0,146,254,0,4,0,0,0,1,48,0,0,0,0,139,0,0,0,2,1,0,0,0,0,0,0,0,10,19,0,0,0,0,0,91,123,34,115,99,114,101,101,110,73,100,34,58,50,53,53,44,34,115,99,114,101,101,110,84,121,112,101,34,58,50,44,34,70,84,66,34,58,123,34,101,110,97,98,108,101,34,58,49,44,34,116,105,109,101,34,58,48,125,125,44,123,34,115,99,114,101,101,110,73,100,34,58,50,53,53,44,34,115,99,114,101,101,110,84,121,112,101,34,58,52,44,34,70,84,66,34,58,123,34,101,110,97,98,108,101,34,58,49,44,34,116,105,109,101,34,58,48,125,125,93,95,125])}],r=[{id:"0",label:"Unfreeze",cmd:Buffer.from([85,170,0,229,254,0,4,0,0,0,1,48,0,0,0,0,105,0,0,0,2,1,0,0,0,0,0,0,0,9,19,0,0,0,0,0,91,123,34,115,99,114,101,101,110,73,100,34,58,50,53,53,44,34,115,99,114,101,101,110,84,121,112,101,34,58,50,44,34,102,114,101,101,122,101,34,58,48,125,44,123,34,115,99,114,101,101,110,73,100,34,58,50,53,53,44,34,115,99,114,101,101,110,84,121,112,101,34,58,52,44,34,102,114,101,101,122,101,34,58,48,125,93,174,115])},{id:"1",label:"Freeze",cmd:Buffer.from([85,170,0,202,254,0,4,0,0,0,1,48,0,0,0,0,105,0,0,0,2,1,0,0,0,0,0,0,0,9,19,0,0,0,0,0,91,123,34,115,99,114,101,101,110,73,100,34,58,50,53,53,44,34,115,99,114,101,101,110,84,121,112,101,34,58,50,44,34,102,114,101,101,122,101,34,58,49,125,44,123,34,115,99,114,101,101,110,73,100,34,58,50,53,53,44,34,115,99,114,101,101,110,84,121,112,101,34,58,52,44,34,102,114,101,101,122,101,34,58,49,125,93,242,115])}],a=[85,170,0,106,254,0,4,0,0,0,1,48,0,0,0,0,181,0,0,0,2,1,0,0,0,0,0,0,0,14,19,0,0,0,0,0,91,123,34,115,99,114,101,101,110,73,100,34,58,50,53,53,44,34,115,99,114,101,101,110,84,121,112,101,34,58,50,44,34,115,119,105,116,99,104,69,102,102,101,99,116,34,58,123,34,116,105,109,101,34,58,49,44,34,100,105,114,101,99,116,105,111,110,34,58,48,44,34,116,121,112,101,34,58,49,125,125,44,123,34,115,99,114,101,101,110,73,100,34,58,50,53,53,44,34,115,99,114,101,101,110,84,121,112,101,34,58,52,44,34,115,119,105,116,99,104,69,102,102,101,99,116,34,58,123,34,116,105,109,101,34,58,49,44,34,100,105,114,101,99,116,105,111,110,34,58,48,44,34,116,121,112,101,34,58,49,125,125,93,89,141],c=[85,170,0,113,254,0,4,0,0,0,1,48,0,0,0,0,181,0,0,0,2,1,0,0,0,0,0,0,0,14,19,0,0,0,0,0,91,123,34,115,99,114,101,101,110,73,100,34,58,50,53,53,44,34,115,99,114,101,101,110,84,121,112,101,34,58,50,44,34,115,119,105,116,99,104,69,102,102,101,99,116,34,58,123,34,116,105,109,101,34,58,49,44,34,100,105,114,101,99,116,105,111,110,34,58,48,44,34,116,121,112,101,34,58,48,125,125,44,123,34,115,99,114,101,101,110,73,100,34,58,50,53,53,44,34,115,99,114,101,101,110,84,121,112,101,34,58,52,44,34,115,119,105,116,99,104,69,102,102,101,99,116,34,58,123,34,116,105,109,101,34,58,49,44,34,100,105,114,101,99,116,105,111,110,34,58,48,44,34,116,121,112,101,34,58,48,125,125,93,94,141],l={pvw:[85,170,0,82,254,0,4,0,0,0,1,48,0,0,0,0,39,0,0,0,2,1,0,0,0,0,0,0,0,14,17,0,0,0,0,0,123,34,112,114,101,115,101,116,65,112,112,108,121,84,121,112,101,34,58,48,125,4,95],pgm:[85,170,0,33,254,0,4,0,0,0,1,48,0,0,0,0,39,0,0,0,2,1,0,0,0,0,0,0,0,14,17,0,0,0,0,0,123,34,112,114,101,115,101,116,65,112,112,108,121,84,121,112,101,34,58,49,125,212,94]},g=[{id:"0",label:"No fade to black",default:"0"},{id:"1",label:"Fade to black",default:"1"}],d=[{id:"0",label:"Unfreeze",default:"0"},{id:"1",label:"Freeze",default:"1"}],u=[{id:"pvw",label:"Load to\nPVW",default:"pvw"},{id:"pgm",label:"Load to\nPGM",default:"pgm"}],h={http:{id:"http",label:"http"},https:{id:"https",label:"https"}},p={pvw:48,pgm:49},I=[{id:"0",label:"Copy",default:"0"},{id:"1",label:"Swap",default:"1"}],m=[{id:"0",label:"Close",default:"0"},{id:"1",label:"Open",default:"1"}],C=["n10","n20","d32"],b=["d12"],y=["n10","n20","d12","d32"],f=["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"],A=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Blob","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","WeakRef","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","FormData","URLSearchParams","HTMLElement","NaN",...f],Z=["null","undefined","string","number","bigint","boolean","symbol"];function G(e){return t=>typeof t===e}const{toString:v}=Object.prototype,B=e=>{const t=v.call(e).slice(8,-1);return/HTML\w+Element/.test(t)&&S.domElement(e)?"HTMLElement":(n=t,A.includes(n)?t:void 0);var n},W=e=>t=>B(t)===e;function S(e){if(null===e)return"null";switch(typeof e){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"NaN":"number";case"boolean":return"boolean";case"function":return"Function";case"bigint":return"bigint";case"symbol":return"symbol"}if(S.observable(e))return"Observable";if(S.array(e))return"Array";if(S.buffer(e))return"Buffer";const t=B(e);if(t)return t;if(e instanceof String||e instanceof Boolean||e instanceof Number)throw new TypeError("Please don't use object wrappers for primitive types");return"Object"}S.undefined=G("undefined"),S.string=G("string");const V=G("number");S.number=e=>V(e)&&!S.nan(e),S.positiveNumber=e=>S.number(e)&&e>0,S.negativeNumber=e=>S.number(e)&&e<0,S.bigint=G("bigint"),S.function_=G("function"),S.null_=e=>null===e,S.class_=e=>S.function_(e)&&e.toString().startsWith("class "),S.boolean=e=>!0===e||!1===e,S.symbol=G("symbol"),S.numericString=e=>S.string(e)&&!S.emptyStringOrWhitespace(e)&&!Number.isNaN(Number(e)),S.array=(e,t)=>!!Array.isArray(e)&&(!S.function_(t)||e.every((e=>t(e)))),S.buffer=e=>e?.constructor?.isBuffer?.(e)??!1,S.blob=e=>W("Blob")(e),S.nullOrUndefined=e=>S.null_(e)||S.undefined(e),S.object=e=>!S.null_(e)&&("object"==typeof e||S.function_(e)),S.iterable=e=>S.function_(e?.[Symbol.iterator]),S.asyncIterable=e=>S.function_(e?.[Symbol.asyncIterator]),S.generator=e=>S.iterable(e)&&S.function_(e?.next)&&S.function_(e?.throw),S.asyncGenerator=e=>S.asyncIterable(e)&&S.function_(e.next)&&S.function_(e.throw),S.nativePromise=e=>W("Promise")(e),S.promise=e=>S.nativePromise(e)||(e=>S.function_(e?.then)&&S.function_(e?.catch))(e),S.generatorFunction=W("GeneratorFunction"),S.asyncGeneratorFunction=e=>"AsyncGeneratorFunction"===B(e),S.asyncFunction=e=>"AsyncFunction"===B(e),S.boundFunction=e=>S.function_(e)&&!e.hasOwnProperty("prototype"),S.regExp=W("RegExp"),S.date=W("Date"),S.error=W("Error"),S.map=e=>W("Map")(e),S.set=e=>W("Set")(e),S.weakMap=e=>W("WeakMap")(e),S.weakSet=e=>W("WeakSet")(e),S.weakRef=e=>W("WeakRef")(e),S.int8Array=W("Int8Array"),S.uint8Array=W("Uint8Array"),S.uint8ClampedArray=W("Uint8ClampedArray"),S.int16Array=W("Int16Array"),S.uint16Array=W("Uint16Array"),S.int32Array=W("Int32Array"),S.uint32Array=W("Uint32Array"),S.float32Array=W("Float32Array"),S.float64Array=W("Float64Array"),S.bigInt64Array=W("BigInt64Array"),S.bigUint64Array=W("BigUint64Array"),S.arrayBuffer=W("ArrayBuffer"),S.sharedArrayBuffer=W("SharedArrayBuffer"),S.dataView=W("DataView"),S.enumCase=(e,t)=>Object.values(t).includes(e),S.directInstanceOf=(e,t)=>Object.getPrototypeOf(e)===t.prototype,S.urlInstance=e=>W("URL")(e),S.urlString=e=>{if(!S.string(e))return!1;try{return new URL(e),!0}catch{return!1}},S.truthy=e=>Boolean(e),S.falsy=e=>!e,S.nan=e=>Number.isNaN(e),S.primitive=e=>{return S.null_(e)||(t=typeof e,Z.includes(t));var t},S.integer=e=>Number.isInteger(e),S.safeInteger=e=>Number.isSafeInteger(e),S.plainObject=e=>{if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)},S.typedArray=e=>{return t=B(e),f.includes(t);var t},S.arrayLike=e=>!S.nullOrUndefined(e)&&!S.function_(e)&&(e=>S.safeInteger(e)&&e>=0)(e.length),S.tupleLike=(e,t)=>!(!S.array(t)||!S.array(e)||t.length!==e.length)&&t.every(((t,n)=>t(e[n]))),S.inRange=(e,t)=>{if(S.number(t))return e>=Math.min(0,t)&&e<=Math.max(t,0);if(S.array(t)&&2===t.length)return e>=Math.min(...t)&&e<=Math.max(...t);throw new TypeError(`Invalid range: ${JSON.stringify(t)}`)};const w=["innerHTML","ownerDocument","style","attributes","nodeValue"];S.domElement=e=>S.object(e)&&1===e.nodeType&&S.string(e.nodeName)&&!S.plainObject(e)&&w.every((t=>t in e)),S.observable=e=>!!e&&(e===e[Symbol.observable]?.()||e===e["@@observable"]?.()),S.nodeStream=e=>S.object(e)&&S.function_(e.pipe)&&!S.observable(e),S.infinite=e=>e===Number.POSITIVE_INFINITY||e===Number.NEGATIVE_INFINITY;const R=e=>t=>S.integer(t)&&Math.abs(t%2)===e;S.evenInteger=R(0),S.oddInteger=R(1),S.emptyArray=e=>S.array(e)&&0===e.length,S.nonEmptyArray=e=>S.array(e)&&e.length>0,S.emptyString=e=>S.string(e)&&0===e.length,S.emptyStringOrWhitespace=e=>S.emptyString(e)||(e=>S.string(e)&&!/\S/.test(e))(e),S.nonEmptyString=e=>S.string(e)&&e.length>0,S.nonEmptyStringAndNotWhitespace=e=>S.string(e)&&!S.emptyStringOrWhitespace(e),S.emptyObject=e=>S.object(e)&&!S.map(e)&&!S.set(e)&&0===Object.keys(e).length,S.nonEmptyObject=e=>S.object(e)&&!S.map(e)&&!S.set(e)&&Object.keys(e).length>0,S.emptySet=e=>S.set(e)&&0===e.size,S.nonEmptySet=e=>S.set(e)&&e.size>0,S.emptyMap=e=>S.map(e)&&0===e.size,S.nonEmptyMap=e=>S.map(e)&&e.size>0,S.propertyKey=e=>S.any([S.string,S.number,S.symbol],e),S.formData=e=>W("FormData")(e),S.urlSearchParams=e=>W("URLSearchParams")(e);const H=(e,t,n)=>{if(!S.function_(t))throw new TypeError(`Invalid predicate: ${JSON.stringify(t)}`);if(0===n.length)throw new TypeError("Invalid number of values");return e.call(n,t)};S.any=(e,...t)=>(S.array(e)?e:[e]).some((e=>H(Array.prototype.some,e,t))),S.all=(e,...t)=>H(Array.prototype.every,e,t);const k=(e,t,n,s={})=>{if(!e){const{multipleValues:e}=s,o=e?`received values of types ${[...new Set(n.map((e=>`\`${S(e)}\``)))].join(", ")}`:`received value of type \`${S(n)}\``;throw new TypeError(`Expected value which is \`${t}\`, ${o}.`)}},Y={undefined:e=>k(S.undefined(e),"undefined",e),string:e=>k(S.string(e),"string",e),number:e=>k(S.number(e),"number",e),positiveNumber:e=>k(S.positiveNumber(e),"positive number",e),negativeNumber:e=>k(S.negativeNumber(e),"negative number",e),bigint:e=>k(S.bigint(e),"bigint",e),function_:e=>k(S.function_(e),"Function",e),null_:e=>k(S.null_(e),"null",e),class_:e=>k(S.class_(e),"Class",e),boolean:e=>k(S.boolean(e),"boolean",e),symbol:e=>k(S.symbol(e),"symbol",e),numericString:e=>k(S.numericString(e),"string with a number",e),array:(e,t)=>{k(S.array(e),"Array",e),t&&e.forEach(t)},buffer:e=>k(S.buffer(e),"Buffer",e),blob:e=>k(S.blob(e),"Blob",e),nullOrUndefined:e=>k(S.nullOrUndefined(e),"null or undefined",e),object:e=>k(S.object(e),"Object",e),iterable:e=>k(S.iterable(e),"Iterable",e),asyncIterable:e=>k(S.asyncIterable(e),"AsyncIterable",e),generator:e=>k(S.generator(e),"Generator",e),asyncGenerator:e=>k(S.asyncGenerator(e),"AsyncGenerator",e),nativePromise:e=>k(S.nativePromise(e),"native Promise",e),promise:e=>k(S.promise(e),"Promise",e),generatorFunction:e=>k(S.generatorFunction(e),"GeneratorFunction",e),asyncGeneratorFunction:e=>k(S.asyncGeneratorFunction(e),"AsyncGeneratorFunction",e),asyncFunction:e=>k(S.asyncFunction(e),"AsyncFunction",e),boundFunction:e=>k(S.boundFunction(e),"Function",e),regExp:e=>k(S.regExp(e),"RegExp",e),date:e=>k(S.date(e),"Date",e),error:e=>k(S.error(e),"Error",e),map:e=>k(S.map(e),"Map",e),set:e=>k(S.set(e),"Set",e),weakMap:e=>k(S.weakMap(e),"WeakMap",e),weakSet:e=>k(S.weakSet(e),"WeakSet",e),weakRef:e=>k(S.weakRef(e),"WeakRef",e),int8Array:e=>k(S.int8Array(e),"Int8Array",e),uint8Array:e=>k(S.uint8Array(e),"Uint8Array",e),uint8ClampedArray:e=>k(S.uint8ClampedArray(e),"Uint8ClampedArray",e),int16Array:e=>k(S.int16Array(e),"Int16Array",e),uint16Array:e=>k(S.uint16Array(e),"Uint16Array",e),int32Array:e=>k(S.int32Array(e),"Int32Array",e),uint32Array:e=>k(S.uint32Array(e),"Uint32Array",e),float32Array:e=>k(S.float32Array(e),"Float32Array",e),float64Array:e=>k(S.float64Array(e),"Float64Array",e),bigInt64Array:e=>k(S.bigInt64Array(e),"BigInt64Array",e),bigUint64Array:e=>k(S.bigUint64Array(e),"BigUint64Array",e),arrayBuffer:e=>k(S.arrayBuffer(e),"ArrayBuffer",e),sharedArrayBuffer:e=>k(S.sharedArrayBuffer(e),"SharedArrayBuffer",e),dataView:e=>k(S.dataView(e),"DataView",e),enumCase:(e,t)=>k(S.enumCase(e,t),"EnumCase",e),urlInstance:e=>k(S.urlInstance(e),"URL",e),urlString:e=>k(S.urlString(e),"string with a URL",e),truthy:e=>k(S.truthy(e),"truthy",e),falsy:e=>k(S.falsy(e),"falsy",e),nan:e=>k(S.nan(e),"NaN",e),primitive:e=>k(S.primitive(e),"primitive",e),integer:e=>k(S.integer(e),"integer",e),safeInteger:e=>k(S.safeInteger(e),"integer",e),plainObject:e=>k(S.plainObject(e),"plain object",e),typedArray:e=>k(S.typedArray(e),"TypedArray",e),arrayLike:e=>k(S.arrayLike(e),"array-like",e),tupleLike:(e,t)=>k(S.tupleLike(e,t),"tuple-like",e),domElement:e=>k(S.domElement(e),"HTMLElement",e),observable:e=>k(S.observable(e),"Observable",e),nodeStream:e=>k(S.nodeStream(e),"Node.js Stream",e),infinite:e=>k(S.infinite(e),"infinite number",e),emptyArray:e=>k(S.emptyArray(e),"empty array",e),nonEmptyArray:e=>k(S.nonEmptyArray(e),"non-empty array",e),emptyString:e=>k(S.emptyString(e),"empty string",e),emptyStringOrWhitespace:e=>k(S.emptyStringOrWhitespace(e),"empty string or whitespace",e),nonEmptyString:e=>k(S.nonEmptyString(e),"non-empty string",e),nonEmptyStringAndNotWhitespace:e=>k(S.nonEmptyStringAndNotWhitespace(e),"non-empty string and not whitespace",e),emptyObject:e=>k(S.emptyObject(e),"empty object",e),nonEmptyObject:e=>k(S.nonEmptyObject(e),"non-empty object",e),emptySet:e=>k(S.emptySet(e),"empty set",e),nonEmptySet:e=>k(S.nonEmptySet(e),"non-empty set",e),emptyMap:e=>k(S.emptyMap(e),"empty map",e),nonEmptyMap:e=>k(S.nonEmptyMap(e),"non-empty map",e),propertyKey:e=>k(S.propertyKey(e),"PropertyKey",e),formData:e=>k(S.formData(e),"FormData",e),urlSearchParams:e=>k(S.urlSearchParams(e),"URLSearchParams",e),evenInteger:e=>k(S.evenInteger(e),"even integer",e),oddInteger:e=>k(S.oddInteger(e),"odd integer",e),directInstanceOf:(e,t)=>k(S.directInstanceOf(e,t),"T",e),inRange:(e,t)=>k(S.inRange(e,t),"in range",e),any:(e,...t)=>k(S.any(e,...t),"predicate returns truthy for any value",t,{multipleValues:!0}),all:(e,...t)=>k(S.all(e,...t),"predicate returns truthy for all values",t,{multipleValues:!0})};Object.defineProperties(S,{class:{value:S.class_},function:{value:S.function_},null:{value:S.null_}}),Object.defineProperties(Y,{class:{value:Y.class_},function:{value:Y.function_},null:{value:Y.null_}});const X=S,N=require("node:events");class _ extends Error{constructor(e){super(e||"Promise was canceled"),this.name="CancelError"}get isCanceled(){return!0}}class J{static fn(e){return(...t)=>new J(((n,s,o)=>{t.push(o),e(...t).then(n,s)}))}constructor(e){this._cancelHandlers=[],this._isPending=!0,this._isCanceled=!1,this._rejectOnCancel=!0,this._promise=new Promise(((t,n)=>{this._reject=n;const s=e=>{if(!this._isPending)throw new Error("The `onCancel` handler was attached after the promise settled.");this._cancelHandlers.push(e)};Object.defineProperties(s,{shouldReject:{get:()=>this._rejectOnCancel,set:e=>{this._rejectOnCancel=e}}}),e((e=>{this._isCanceled&&s.shouldReject||(this._isPending=!1,t(e))}),(e=>{this._isPending=!1,n(e)}),s)}))}then(e,t){return this._promise.then(e,t)}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(const e of this._cancelHandlers)e()}catch(e){return void this._reject(e)}this._rejectOnCancel&&this._reject(new _(e))}}get isCanceled(){return this._isCanceled}}Object.setPrototypeOf(J.prototype,Promise.prototype);class F extends Error{constructor(e,t,n){var s;if(super(e),Object.defineProperty(this,"input",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"stack",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"response",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"request",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"timings",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Error.captureStackTrace(this,this.constructor),this.name="RequestError",this.code=t.code??"ERR_GOT_REQUEST_ERROR",this.input=t.input,s=n,X.object(s)&&"_onResponse"in s?(Object.defineProperty(this,"request",{enumerable:!1,value:n}),Object.defineProperty(this,"response",{enumerable:!1,value:n.response}),this.options=n.options):this.options=n,this.timings=this.request?.timings,X.string(t.stack)&&X.string(this.stack)){const e=this.stack.indexOf(this.message)+this.message.length,n=this.stack.slice(e).split("\n").reverse(),s=t.stack.slice(t.stack.indexOf(t.message)+t.message.length).split("\n").reverse();for(;s.length>0&&s[0]===n[0];)n.shift();this.stack=`${this.stack.slice(0,e)}${n.reverse().join("\n")}${s.reverse().join("\n")}`}}}class K extends F{constructor(e){super(`Redirected ${e.options.maxRedirects} times. Aborting.`,{},e),this.name="MaxRedirectsError",this.code="ERR_TOO_MANY_REDIRECTS"}}class x extends F{constructor(e){super(`Response code ${e.statusCode} (${e.statusMessage})`,{},e.request),this.name="HTTPError",this.code="ERR_NON_2XX_3XX_RESPONSE"}}class E extends F{constructor(e,t){super(e.message,e,t),this.name="CacheError",this.code="ERR_GOT_REQUEST_ERROR"===this.code?"ERR_CACHE_ACCESS":this.code}}class T extends F{constructor(e,t){super(e.message,e,t),this.name="UploadError",this.code="ERR_GOT_REQUEST_ERROR"===this.code?"ERR_UPLOAD":this.code}}class z extends F{constructor(e,t,n){super(e.message,e,n),Object.defineProperty(this,"timings",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"event",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name="TimeoutError",this.event=e.event,this.timings=t}}class U extends F{constructor(e,t){super(e.message,e,t),this.name="ReadError",this.code="ERR_GOT_REQUEST_ERROR"===this.code?"ERR_READING_RESPONSE_STREAM":this.code}}class O extends F{constructor(e){super("Retrying",{},e),this.name="RetryError",this.code="ERR_RETRYING"}}class L extends F{constructor(e){super("This operation was aborted.",{},e),this.code="ERR_ABORTED",this.name="AbortError"}}const j=require("node:process"),Q=require("node:buffer"),M=require("node:stream"),P=require("node:http");var D=n(4434),q=n(9023),$=n(687);const ee=require("node:url"),te=require("node:crypto"),ne=(e,t)=>t.some((t=>t instanceof RegExp?t.test(e):t===e)),se=new Set(["https:","http:","file:"]);var oe=n(4594),ie=n(7234);function re(e){return Object.fromEntries(Object.entries(e).map((([e,t])=>[e.toLowerCase(),t])))}class ae extends M.Readable{statusCode;headers;body;url;constructor({statusCode:e,headers:t,body:n,url:s}){if("number"!=typeof e)throw new TypeError("Argument `statusCode` should be a number");if("object"!=typeof t)throw new TypeError("Argument `headers` should be an object");if(!(n instanceof Uint8Array))throw new TypeError("Argument `body` should be a buffer");if("string"!=typeof s)throw new TypeError("Argument `url` should be a string");super({read(){this.push(n),this.push(null)}}),this.statusCode=e,this.headers=re(t),this.body=n,this.url=s}}var ce=n(8387);const le=["aborted","complete","headers","httpVersion","httpVersionMinor","httpVersionMajor","method","rawHeaders","rawTrailers","setTimeout","socket","statusCode","statusMessage","trailers","url"];class ge extends Error{constructor(e){super(e.message),Object.assign(this,e)}}class de extends Error{constructor(e){super(e.message),Object.assign(this,e)}}const ue=Object.entries,he=e=>{const t={...e};return t.path=`${e.pathname||"/"}${e.search||""}`,delete t.pathname,delete t.search,t},pe=e=>({protocol:e.protocol,auth:e.auth,hostname:e.hostname||e.host||"localhost",port:e.port,pathname:e.pathname,search:e.search}),Ie=e=>{const t=[];for(const n of Object.keys(e))t[n.toLowerCase()]=e[n];return t},me=class{constructor(e,t){this.hooks=new Map,this.request=()=>(e,t)=>{let n;if("string"==typeof e)n=pe(ee.parse(e)),e={};else if(e instanceof ee.URL)n=pe(ee.parse(e.toString())),e={};else{const[t,...s]=(e.path??"").split("?"),o=s.length>0?`?${s.join("?")}`:"";n=pe({...e,pathname:t,search:o})}(e={headers:{},method:"GET",cache:!0,strictTtl:!1,automaticFailover:!1,...e,...he(n)}).headers=Object.fromEntries(ue(e.headers).map((([e,t])=>[e.toLowerCase(),t])));const s=new N,o=function(e,t){if("string"!=typeof(t={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,removeExplicitPort:!1,sortQueryParameters:!0,...t}).defaultProtocol||t.defaultProtocol.endsWith(":")||(t.defaultProtocol=`${t.defaultProtocol}:`),e=e.trim(),/^data:/i.test(e))return((e,{stripHash:t})=>{const n=/^data:(?[^,]*?),(?[^#]*?)(?:#(?.*))?$/.exec(e);if(!n)throw new Error(`Invalid URL: ${e}`);let{type:s,data:o,hash:i}=n.groups;const r=s.split(";");i=t?"":i;let a=!1;"base64"===r[r.length-1]&&(r.pop(),a=!0);const c=r.shift()?.toLowerCase()??"",l=[...r.map((e=>{let[t,n=""]=e.split("=").map((e=>e.trim()));return"charset"===t&&(n=n.toLowerCase(),"us-ascii"===n)?"":`${t}${n?`=${n}`:""}`})).filter(Boolean)];return a&&l.push("base64"),(l.length>0||c&&"text/plain"!==c)&&l.unshift(c),`data:${l.join(";")},${a?o.trim():o}${i?`#${i}`:""}`})(e,t);if((e=>{try{const{protocol:t}=new URL(e);return t.endsWith(":")&&!se.has(t)}catch{return!1}})(e))return e;const n=e.startsWith("//");!n&&/^\.*\//.test(e)||(e=e.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,t.defaultProtocol));const s=new URL(e);if(t.forceHttp&&t.forceHttps)throw new Error("The `forceHttp` and `forceHttps` options cannot be used together");if(t.forceHttp&&"https:"===s.protocol&&(s.protocol="http:"),t.forceHttps&&"http:"===s.protocol&&(s.protocol="https:"),t.stripAuthentication&&(s.username="",s.password=""),t.stripHash?s.hash="":t.stripTextFragment&&(s.hash=s.hash.replace(/#?:~:text.*?$/i,"")),s.pathname){const e=/\b[a-z][a-z\d+\-.]{1,50}:\/\//g;let t=0,n="";for(;;){const o=e.exec(s.pathname);if(!o)break;const i=o[0],r=o.index;n+=s.pathname.slice(t,r).replace(/\/{2,}/g,"/"),n+=i,t=r+i.length}n+=s.pathname.slice(t,s.pathname.length).replace(/\/{2,}/g,"/"),s.pathname=n}if(s.pathname)try{s.pathname=decodeURI(s.pathname)}catch{}if(!0===t.removeDirectoryIndex&&(t.removeDirectoryIndex=[/^index\.[a-z]+$/]),Array.isArray(t.removeDirectoryIndex)&&t.removeDirectoryIndex.length>0){let e=s.pathname.split("/");const n=e[e.length-1];ne(n,t.removeDirectoryIndex)&&(e=e.slice(0,-1),s.pathname=e.slice(1).join("/")+"/")}if(s.hostname&&(s.hostname=s.hostname.replace(/\.$/,""),t.stripWWW&&/^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(s.hostname)&&(s.hostname=s.hostname.replace(/^www\./,""))),Array.isArray(t.removeQueryParameters))for(const e of[...s.searchParams.keys()])ne(e,t.removeQueryParameters)&&s.searchParams.delete(e);if(Array.isArray(t.keepQueryParameters)||!0!==t.removeQueryParameters||(s.search=""),Array.isArray(t.keepQueryParameters)&&t.keepQueryParameters.length>0)for(const e of[...s.searchParams.keys()])ne(e,t.keepQueryParameters)||s.searchParams.delete(e);if(t.sortQueryParameters){s.searchParams.sort();try{s.search=decodeURIComponent(s.search)}catch{}}t.removeTrailingSlash&&(s.pathname=s.pathname.replace(/\/$/,"")),t.removeExplicitPort&&s.port&&(s.port="");const o=e;return e=s.toString(),t.removeSingleSlash||"/"!==s.pathname||o.endsWith("/")||""!==s.hash||(e=e.replace(/\/$/,"")),(t.removeTrailingSlash||"/"===s.pathname)&&""===s.hash&&t.removeSingleSlash&&(e=e.replace(/\/$/,"")),n&&!t.normalizeProtocol&&(e=e.replace(/^http:\/\//,"//")),t.stripProtocol&&(e=e.replace(/^(?:https?:)?\/\//,"")),e}(ee.format(n),{stripWWW:!1,removeTrailingSlash:!1,stripAuthentication:!1});let i=`${e.method}:${o}`;e.body&&void 0!==e.method&&["POST","PATCH","PUT"].includes(e.method)&&(e.body instanceof M.Readable?e.cache=!1:i+=`:${te.createHash("md5").update(e.body).digest("hex")}`);let r=!1,a=!1;const c=e=>{a=!0;let n=!1,o=()=>{};const c=new Promise((e=>{o=()=>{n||(n=!0,e())}})),l=async n=>{if(r){n.status=n.statusCode;const t=ie.fromObject(r.cachePolicy).revalidatedPolicy(e,n);if(!t.modified){n.resume(),await new Promise((e=>{n.once("end",e)}));const e=Ie(t.policy.responseHeaders());(n=new ae({statusCode:r.statusCode,headers:e,body:r.body,url:r.url})).cachePolicy=t.policy,n.fromCache=!0}}let o;n.fromCache||(n.cachePolicy=new ie(e,n,e),n.fromCache=!1),e.cache&&n.cachePolicy.storable()?(o=(e=>{const t=new M.PassThrough({autoDestroy:!1});return function(e,t){if(t._readableState.autoDestroy)throw new Error("The second stream must have the `autoDestroy` option set to `false`");const n=new Set([...Object.keys(e),...le]),s={};for(const o of n)o in t||(s[o]={get(){const t=e[o];return"function"==typeof t?t.bind(e):t},set(t){e[o]=t},enumerable:!0,configurable:!1});Object.defineProperties(t,s),e.once("aborted",(()=>{t.destroy(),t.emit("aborted")})),e.once("close",(()=>{e.complete&&t.readable?t.once("end",(()=>{t.emit("close")})):t.emit("close")}))}(e,t),e.pipe(t)})(n),(async()=>{try{const t=oe.buffer(n);await Promise.race([c,new Promise((e=>n.once("end",e))),new Promise((e=>n.once("close",e)))]);const s=await t;let o={url:n.url,statusCode:n.fromCache?r.statusCode:n.statusCode,body:s,cachePolicy:n.cachePolicy.toObject()},a=e.strictTtl?n.cachePolicy.timeToLive():void 0;if(e.maxTtl&&(a=a?Math.min(a,e.maxTtl):e.maxTtl),this.hooks.size>0)for(const e of this.hooks.keys())o=await this.runHook(e,o,n);await this.cache.set(i,o,a)}catch(e){s.emit("error",new de(e))}})()):e.cache&&r&&(async()=>{try{await this.cache.delete(i)}catch(e){s.emit("error",new de(e))}})(),s.emit("response",o??n),"function"==typeof t&&t(o??n)};try{const t=this.cacheRequest(e,l);t.once("error",o),t.once("abort",o),t.once("destroy",o),s.emit("request",t)}catch(e){s.emit("error",new ge(e))}};return(async()=>{const n=async e=>{await Promise.resolve();const n=e.cache?await this.cache.get(i):void 0;if(void 0===n&&!e.forceRefresh)return void c(e);const o=ie.fromObject(n.cachePolicy);if(o.satisfiesWithoutRevalidation(e)&&!e.forceRefresh){const e=Ie(o.responseHeaders()),i=new ae({statusCode:n.statusCode,headers:e,body:n.body,url:n.url});i.cachePolicy=o,i.fromCache=!0,s.emit("response",i),"function"==typeof t&&t(i)}else o.satisfiesWithoutRevalidation(e)&&Date.now()>=o.timeToLive()&&e.forceRefresh?(await this.cache.delete(i),e.headers=o.revalidationHeaders(e),c(e)):(r=n,e.headers=o.revalidationHeaders(e),c(e))},o=e=>s.emit("error",new de(e));if(this.cache instanceof ce){const e=this.cache;e.once("error",o),s.on("error",(()=>e.removeListener("error",o))),s.on("response",(()=>e.removeListener("error",o)))}try{await n(e)}catch(t){e.automaticFailover&&!a&&c(e),s.emit("error",new de(t))}})(),s},this.addHook=(e,t)=>{this.hooks.has(e)||this.hooks.set(e,t)},this.removeHook=e=>this.hooks.delete(e),this.getHook=e=>this.hooks.get(e),this.runHook=async(e,...t)=>this.hooks.get(e)?.(...t),this.cache=t instanceof ce?t:new ce("string"==typeof t?{uri:t,namespace:"cacheable-request"}:{store:t,namespace:"cacheable-request"}),this.request=this.request.bind(this),this.cacheRequest=e}};var Ce=n(602);const be=e=>"function"==typeof e,ye=e=>Boolean(e&&be(e.constructor)&&"FormData"===e[Symbol.toStringTag]&&be(e.append)&&be(e.getAll)&&be(e.entries)&&be(e[Symbol.iterator])),fe=e=>{if(be(e[Symbol.asyncIterator]))return e;if(be(e.getReader))return async function*(e){const t=e.getReader();for(;;){const{done:e,value:n}=await t.read();if(e)break;yield n}}(e);throw new TypeError("Unsupported data source: Expected either ReadableStream or async iterable.")},Ae=e=>String(e).replace(/\r|\n/g,((e,t,n)=>"\r"===e&&"\n"!==n[t+1]||"\n"===e&&"\r"!==n[t-1]?"\r\n":e));function Ze(e){if("object"!==(e=>Object.prototype.toString.call(e).slice(8,-1).toLowerCase())(e))return!1;const t=Object.getPrototypeOf(e);return null==t||(t.constructor&&t.constructor.toString())===Object.toString()}function Ge(e,t){if("string"==typeof t)for(const[n,s]of Object.entries(e))if(t.toLowerCase()===n.toLowerCase())return s}const ve=e=>String(e).replace(/\r/g,"%0D").replace(/\n/g,"%0A").replace(/"/g,"%22"),Be=e=>Boolean(e&&"object"==typeof e&&be(e.constructor)&&"File"===e[Symbol.toStringTag]&&be(e.stream)&&null!=e.name);var We,Se,Ve,we,Re,He,ke,Ye,Xe,Ne,_e,Je=function(e,t,n,s,o){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?o.call(e,n):o?o.value=n:t.set(e,n),n},Fe=function(e,t,n,s){if("a"===n&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?s:"a"===n?s.call(e):s?s.value:t.get(e)};const Ke={enableAdditionalHeaders:!1},xe={writable:!1,configurable:!1};class Ee{constructor(e,t,n){if(We.add(this),Se.set(this,"\r\n"),Ve.set(this,void 0),we.set(this,void 0),Re.set(this,"-".repeat(2)),He.set(this,new TextEncoder),ke.set(this,void 0),Ye.set(this,void 0),Xe.set(this,void 0),!ye(e))throw new TypeError("Expected first argument to be a FormData instance.");let s;if(Ze(t)?n=t:s=t,s||(s=function(){let e=16,t="";for(;e--;)t+="abcdefghijklmnopqrstuvwxyz0123456789"[36*Math.random()<<0];return t}()),"string"!=typeof s)throw new TypeError("Expected boundary argument to be a string.");if(n&&!Ze(n))throw new TypeError("Expected options argument to be an object.");Je(this,Ye,Array.from(e.entries()),"f"),Je(this,Xe,{...Ke,...n},"f"),Je(this,Ve,Fe(this,He,"f").encode(Fe(this,Se,"f")),"f"),Je(this,we,Fe(this,Ve,"f").byteLength,"f"),this.boundary=`form-data-boundary-${s}`,this.contentType=`multipart/form-data; boundary=${this.boundary}`,Je(this,ke,Fe(this,He,"f").encode(`${Fe(this,Re,"f")}${this.boundary}${Fe(this,Re,"f")}${Fe(this,Se,"f").repeat(2)}`),"f");const o={"Content-Type":this.contentType},i=Fe(this,We,"m",_e).call(this);var r;i&&(this.contentLength=i,o["Content-Length"]=i),this.headers=(r=Object.freeze(o),new Proxy(r,{get:(e,t)=>Ge(e,t),has:(e,t)=>void 0!==Ge(e,t)})),Object.defineProperties(this,{boundary:xe,contentType:xe,contentLength:xe,headers:xe})}getContentLength(){return null==this.contentLength?void 0:Number(this.contentLength)}*values(){for(const[e,t]of Fe(this,Ye,"f")){const n=Be(t)?t:Fe(this,He,"f").encode(Ae(t));yield Fe(this,We,"m",Ne).call(this,e,n),yield n,yield Fe(this,Ve,"f")}yield Fe(this,ke,"f")}async*encode(){for(const e of this.values())Be(e)?yield*fe(e.stream()):yield e}[(Se=new WeakMap,Ve=new WeakMap,we=new WeakMap,Re=new WeakMap,He=new WeakMap,ke=new WeakMap,Ye=new WeakMap,Xe=new WeakMap,We=new WeakSet,Ne=function(e,t){let n="";n+=`${Fe(this,Re,"f")}${this.boundary}${Fe(this,Se,"f")}`,n+=`Content-Disposition: form-data; name="${ve(e)}"`,Be(t)&&(n+=`; filename="${ve(t.name)}"${Fe(this,Se,"f")}`,n+=`Content-Type: ${t.type||"application/octet-stream"}`);const s=Be(t)?t.size:t.byteLength;return!0!==Fe(this,Xe,"f").enableAdditionalHeaders||null==s||isNaN(s)||(n+=`${Fe(this,Se,"f")}Content-Length: ${Be(t)?t.size:t.byteLength}`),Fe(this,He,"f").encode(`${n}${Fe(this,Se,"f").repeat(2)}`)},_e=function(){let e=0;for(const[t,n]of Fe(this,Ye,"f")){const s=Be(n)?n:Fe(this,He,"f").encode(Ae(n)),o=Be(s)?s.size:s.byteLength;if(null==o||isNaN(o))return;e+=Fe(this,We,"m",Ne).call(this,t,s).byteLength,e+=o,e+=Fe(this,we,"f")}return String(e+Fe(this,ke,"f").byteLength)},Symbol.iterator)](){return this.values()}[Symbol.asyncIterator](){return this.encode()}}const Te=require("node:util");function ze(e){return X.nodeStream(e)&&X.function_(e.getBoundary)}function Ue(e,t,n){const s={};for(const o of n){const n=(...e)=>{t.emit(o,...e)};s[o]=n,e.on(o,n)}return()=>{for(const[t,n]of Object.entries(s))e.off(t,n)}}const Oe=require("node:net"),Le=Symbol("reentry"),je=()=>{};class Qe extends Error{constructor(e,t){super(`Timeout awaiting '${t}' for ${e}ms`),Object.defineProperty(this,"event",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name="TimeoutError",this.code="ETIMEDOUT"}}const Me=({attemptCount:e,retryOptions:t,error:n,retryAfter:s,computedValue:o})=>{if("RetryError"===n.name)return 1;if(e>t.limit)return 0;const i=t.methods.includes(n.options.method),r=t.errorCodes.includes(n.code),a=n.response&&t.statusCodes.includes(n.response.statusCode);if(!i||!r&&!a)return 0;if(n.response){if(s)return s>o?0:s;if(413===n.response.statusCode)return 0}const c=Math.random()*t.noise;return Math.min(2**(e-1)*1e3,t.backoffLimit)+c},Pe=require("node:tls"),De=require("node:https"),qe=require("node:dns"),$e=require("node:os"),{Resolver:et}=qe.promises,tt=Symbol("cacheableLookupCreateConnection"),nt=Symbol("cacheableLookupInstance"),st=Symbol("expires"),ot="number"==typeof qe.ALL,it=e=>{if(!e||"function"!=typeof e.createConnection)throw new Error("Expected an Agent instance as the first argument")},rt=()=>{let e=!1,t=!1;for(const n of Object.values($e.networkInterfaces()))for(const s of n)if(!s.internal&&("IPv6"===s.family?t=!0:e=!0,e&&t))return{has4:e,has6:t};return{has4:e,has6:t}},at=e=>e.catch((e=>{if("ENODATA"===e.code||"ENOTFOUND"===e.code||"ENOENT"===e.code)return[];throw e})),ct={ttl:!0},lt={all:!0},gt={all:!0,family:4},dt={all:!0,family:6};class ut{constructor({cache:e=new Map,maxTtl:t=1/0,fallbackDuration:n=3600,errorTtl:s=.15,resolver:o=new et,lookup:i=qe.lookup}={}){if(this.maxTtl=t,this.errorTtl=s,this._cache=e,this._resolver=o,this._dnsLookup=i&&(0,Te.promisify)(i),this.stats={cache:0,query:0},this._resolver instanceof et?(this._resolve4=this._resolver.resolve4.bind(this._resolver),this._resolve6=this._resolver.resolve6.bind(this._resolver)):(this._resolve4=(0,Te.promisify)(this._resolver.resolve4.bind(this._resolver)),this._resolve6=(0,Te.promisify)(this._resolver.resolve6.bind(this._resolver))),this._iface=rt(),this._pending={},this._nextRemovalTime=!1,this._hostnamesToFallback=new Set,this.fallbackDuration=n,n>0){const e=setInterval((()=>{this._hostnamesToFallback.clear()}),1e3*n);e.unref&&e.unref(),this._fallbackInterval=e}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,t,n){if("function"==typeof t?(n=t,t={}):"number"==typeof t&&(t={family:t}),!n)throw new Error("Callback must be a function.");this.lookupAsync(e,t).then((e=>{t.all?n(null,e):n(null,e.address,e.family,e.expires,e.ttl,e.source)}),n)}async lookupAsync(e,t={}){"number"==typeof t&&(t={family:t});let n=await this.query(e);if(6===t.family){const e=n.filter((e=>6===e.family));t.hints&qe.V4MAPPED&&(ot&&t.hints&qe.ALL||0===e.length)?(e=>{for(const t of e)6!==t.family&&(t.address=`::ffff:${t.address}`,t.family=6)})(n):n=e}else 4===t.family&&(n=n.filter((e=>4===e.family)));if(t.hints&qe.ADDRCONFIG){const{_iface:e}=this;n=n.filter((t=>6===t.family?e.has6:e.has4))}if(0===n.length){const t=new Error(`cacheableLookup ENOTFOUND ${e}`);throw t.code="ENOTFOUND",t.hostname=e,t}return t.all?n:n[0]}async query(e){let t="cache",n=await this._cache.get(e);if(n&&this.stats.cache++,!n){const s=this._pending[e];if(s)this.stats.cache++,n=await s;else{t="query";const s=this.queryAndCache(e);this._pending[e]=s,this.stats.query++;try{n=await s}finally{delete this._pending[e]}}}return n=n.map((e=>({...e,source:t}))),n}async _resolve(e){const[t,n]=await Promise.all([at(this._resolve4(e,ct)),at(this._resolve6(e,ct))]);let s=0,o=0,i=0;const r=Date.now();for(const e of t)e.family=4,e.expires=r+1e3*e.ttl,s=Math.max(s,e.ttl);for(const e of n)e.family=6,e.expires=r+1e3*e.ttl,o=Math.max(o,e.ttl);return i=t.length>0?n.length>0?Math.min(s,o):s:o,{entries:[...t,...n],cacheTtl:i}}async _lookup(e){try{const[t,n]=await Promise.all([at(this._dnsLookup(e,gt)),at(this._dnsLookup(e,dt))]);return{entries:[...t,...n],cacheTtl:0}}catch{return{entries:[],cacheTtl:0}}}async _set(e,t,n){if(this.maxTtl>0&&n>0){n=1e3*Math.min(n,this.maxTtl),t[st]=Date.now()+n;try{await this._cache.set(e,t,n)}catch(e){this.lookupAsync=async()=>{const t=new Error("Cache Error. Please recreate the CacheableLookup instance.");throw t.cause=e,t}}s=this._cache,Symbol.iterator in s&&this._tick(n)}var s}async queryAndCache(e){if(this._hostnamesToFallback.has(e))return this._dnsLookup(e,lt);let t=await this._resolve(e);0===t.entries.length&&this._dnsLookup&&(t=await this._lookup(e),0!==t.entries.length&&this.fallbackDuration>0&&this._hostnamesToFallback.add(e));const n=0===t.entries.length?this.errorTtl:t.cacheTtl;return await this._set(e,t.entries,n),t.entries}_tick(e){const t=this._nextRemovalTime;(!t||e{this._nextRemovalTime=!1;let e=1/0;const t=Date.now();for(const[n,s]of this._cache){const o=s[st];t>=o?this._cache.delete(n):o("lookup"in t||(t.lookup=this.lookup),e[tt](t,n))}uninstall(e){if(it(e),e[tt]){if(e[nt]!==this)throw new Error("The agent is not owned by this CacheableLookup instance");e.createConnection=e[tt],delete e[tt],delete e[nt]}}updateInterfaceInfo(){const{_iface:e}=this;this._iface=rt(),(e.has4&&!this._iface.has4||e.has6&&!this._iface.has6)&&this._cache.clear()}clear(e){e?this._cache.delete(e):this._cache.clear()}}var ht=n(5769);const[pt,It]=j.versions.node.split(".").map(Number),mt=new Map;let Ct;const bt={request:void 0,agent:{http:void 0,https:void 0,http2:void 0},h2session:void 0,decompress:!0,timeout:{connect:void 0,lookup:void 0,read:void 0,request:void 0,response:void 0,secureConnect:void 0,send:void 0,socket:void 0},prefixUrl:"",body:void 0,form:void 0,json:void 0,cookieJar:void 0,ignoreInvalidCookies:!1,searchParams:void 0,dnsLookup:void 0,dnsCache:void 0,context:{},hooks:{init:[],beforeRequest:[],beforeError:[],beforeRedirect:[],beforeRetry:[],afterResponse:[]},followRedirect:!0,maxRedirects:10,cache:void 0,throwHttpErrors:!0,username:"",password:"",http2:!1,allowGetBody:!1,headers:{"user-agent":"got (https://github.com/sindresorhus/got)"},methodRewriting:!1,dnsLookupIpVersion:void 0,parseJson:JSON.parse,stringifyJson:JSON.stringify,retry:{limit:2,methods:["GET","PUT","HEAD","DELETE","OPTIONS","TRACE"],statusCodes:[408,413,429,500,502,503,504,521,522,524],errorCodes:["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN"],maxRetryAfter:void 0,calculateDelay:({computedValue:e})=>e,backoffLimit:Number.POSITIVE_INFINITY,noise:100},localAddress:void 0,method:"GET",createConnection:void 0,cacheOptions:{shared:void 0,cacheHeuristic:void 0,immutableMinTimeToLive:void 0,ignoreCargoCult:void 0},https:{alpnProtocols:void 0,rejectUnauthorized:void 0,checkServerIdentity:void 0,certificateAuthority:void 0,key:void 0,certificate:void 0,passphrase:void 0,pfx:void 0,ciphers:void 0,honorCipherOrder:void 0,minVersion:void 0,maxVersion:void 0,signatureAlgorithms:void 0,tlsSessionLifetime:void 0,dhparam:void 0,ecdhCurve:void 0,certificateRevocationLists:void 0},encoding:void 0,resolveBodyOnly:!1,isStream:!1,responseType:"text",url:void 0,pagination:{transform:e=>"json"===e.request.options.responseType?e.body:JSON.parse(e.body),paginate({response:e}){const t=e.headers.link;if("string"!=typeof t||""===t.trim())return!1;const n=function(e){const t=[],n=e.split(",");for(const s of n){const[n,...o]=s.split(";"),i=n.trim();if("<"!==i[0]||">"!==i[i.length-1])throw new Error(`Invalid format of the Link header reference: ${i}`);const r=i.slice(1,-1),a={};if(0===o.length)throw new Error(`Unexpected end of Link header parameters: ${o.join(";")}`);for(const t of o){const n=t.trim(),s=n.indexOf("=");if(-1===s)throw new Error(`Failed to parse Link header: ${e}`);const o=n.slice(0,s).trim(),i=n.slice(s+1).trim();a[o]=i}t.push({reference:r,parameters:a})}return t}(t).find((e=>"next"===e.parameters.rel||'"next"'===e.parameters.rel));return!!n&&{url:new URL(n.reference,e.url)}},filter:()=>!0,shouldContinue:()=>!0,countLimit:Number.POSITIVE_INFINITY,backoff:0,requestLimit:1e4,stackAllItems:!1},setHost:!0,maxHeaderSize:void 0,signal:void 0,enableUnixSockets:!1},yt=e=>{const t=[e.timeout.socket,e.timeout.connect,e.timeout.lookup,e.timeout.request,e.timeout.secureConnect].filter((e=>"number"==typeof e));if(t.length>0)return Math.min(...t)},ft=(e,t,n)=>{const s=e.hooks?.init;if(s)for(const e of s)e(t,n)};class At{constructor(e,t,n){if(Object.defineProperty(this,"_unixOptions",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_internals",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_merging",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_init",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Y.any([X.string,X.urlInstance,X.object,X.undefined],e),Y.any([X.object,X.undefined],t),Y.any([X.object,X.undefined],n),e instanceof At||t instanceof At)throw new TypeError("The defaults must be passed as the third argument");this._internals=(e=>{const{hooks:t,retry:n}=e,s={...e,context:{...e.context},cacheOptions:{...e.cacheOptions},https:{...e.https},agent:{...e.agent},headers:{...e.headers},retry:{...n,errorCodes:[...n.errorCodes],methods:[...n.methods],statusCodes:[...n.statusCodes]},timeout:{...e.timeout},hooks:{init:[...t.init],beforeRequest:[...t.beforeRequest],beforeError:[...t.beforeError],beforeRedirect:[...t.beforeRedirect],beforeRetry:[...t.beforeRetry],afterResponse:[...t.afterResponse]},searchParams:e.searchParams?new URLSearchParams(e.searchParams):void 0,pagination:{...e.pagination}};return void 0!==s.url&&(s.prefixUrl=""),s})(n?._internals??n??bt),this._init=[...n?._init??[]],this._merging=!1,this._unixOptions=void 0;try{if(X.plainObject(e))try{this.merge(e),this.merge(t)}finally{this.url=e.url}else try{this.merge(t)}finally{if(void 0!==t?.url){if(void 0!==e)throw new TypeError("The `url` option is mutually exclusive with the `input` argument");this.url=t.url}else void 0!==e&&(this.url=e)}}catch(e){throw e.options=this,e}}merge(e){if(e)if(e instanceof At)for(const t of e._init)this.merge(t);else{e=(e=>{const{hooks:t,retry:n}=e,s={...e};return X.object(e.context)&&(s.context={...e.context}),X.object(e.cacheOptions)&&(s.cacheOptions={...e.cacheOptions}),X.object(e.https)&&(s.https={...e.https}),X.object(e.cacheOptions)&&(s.cacheOptions={...s.cacheOptions}),X.object(e.agent)&&(s.agent={...e.agent}),X.object(e.headers)&&(s.headers={...e.headers}),X.object(n)&&(s.retry={...n},X.array(n.errorCodes)&&(s.retry.errorCodes=[...n.errorCodes]),X.array(n.methods)&&(s.retry.methods=[...n.methods]),X.array(n.statusCodes)&&(s.retry.statusCodes=[...n.statusCodes])),X.object(e.timeout)&&(s.timeout={...e.timeout}),X.object(t)&&(s.hooks={...t},X.array(t.init)&&(s.hooks.init=[...t.init]),X.array(t.beforeRequest)&&(s.hooks.beforeRequest=[...t.beforeRequest]),X.array(t.beforeError)&&(s.hooks.beforeError=[...t.beforeError]),X.array(t.beforeRedirect)&&(s.hooks.beforeRedirect=[...t.beforeRedirect]),X.array(t.beforeRetry)&&(s.hooks.beforeRetry=[...t.beforeRetry]),X.array(t.afterResponse)&&(s.hooks.afterResponse=[...t.afterResponse])),X.object(e.pagination)&&(s.pagination={...e.pagination}),s})(e),ft(this,e,this),ft(e,e,this),this._merging=!0,"isStream"in e&&(this.isStream=e.isStream);try{let t=!1;for(const n in e){if("mutableDefaults"===n||"handlers"===n)continue;if("url"===n)continue;if(!(n in this))throw new Error(`Unexpected option: ${n}`);const s=e[n];void 0!==s&&(this[n]=s,t=!0)}t&&this._init.push(e)}finally{this._merging=!1}}}get request(){return this._internals.request}set request(e){Y.any([X.function_,X.undefined],e),this._internals.request=e}get agent(){return this._internals.agent}set agent(e){Y.plainObject(e);for(const t in e){if(!(t in this._internals.agent))throw new TypeError(`Unexpected agent option: ${t}`);Y.any([X.object,X.undefined],e[t])}this._merging?Object.assign(this._internals.agent,e):this._internals.agent={...e}}get h2session(){return this._internals.h2session}set h2session(e){this._internals.h2session=e}get decompress(){return this._internals.decompress}set decompress(e){Y.boolean(e),this._internals.decompress=e}get timeout(){return this._internals.timeout}set timeout(e){Y.plainObject(e);for(const t in e){if(!(t in this._internals.timeout))throw new Error(`Unexpected timeout option: ${t}`);Y.any([X.number,X.undefined],e[t])}this._merging?Object.assign(this._internals.timeout,e):this._internals.timeout={...e}}get prefixUrl(){return this._internals.prefixUrl}set prefixUrl(e){if(Y.any([X.string,X.urlInstance],e),""!==e){if((e=e.toString()).endsWith("/")||(e+="/"),this._internals.prefixUrl&&this._internals.url){const{href:t}=this._internals.url;this._internals.url.href=e+t.slice(this._internals.prefixUrl.length)}this._internals.prefixUrl=e}else this._internals.prefixUrl=""}get body(){return this._internals.body}set body(e){Y.any([X.string,X.buffer,X.nodeStream,X.generator,X.asyncGenerator,ye,X.undefined],e),X.nodeStream(e)&&Y.truthy(e.readable),void 0!==e&&(Y.undefined(this._internals.form),Y.undefined(this._internals.json)),this._internals.body=e}get form(){return this._internals.form}set form(e){Y.any([X.plainObject,X.undefined],e),void 0!==e&&(Y.undefined(this._internals.body),Y.undefined(this._internals.json)),this._internals.form=e}get json(){return this._internals.json}set json(e){void 0!==e&&(Y.undefined(this._internals.body),Y.undefined(this._internals.form)),this._internals.json=e}get url(){return this._internals.url}set url(e){if(Y.any([X.string,X.urlInstance,X.undefined],e),void 0===e)return void(this._internals.url=void 0);if(X.string(e)&&e.startsWith("/"))throw new Error("`url` must not start with a slash");const t=`${this.prefixUrl}${e.toString()}`,n=new URL(t);if(this._internals.url=n,"unix:"===n.protocol&&(n.href=`http://unix${n.pathname}${n.search}`),"http:"!==n.protocol&&"https:"!==n.protocol){const e=new Error(`Unsupported protocol: ${n.protocol}`);throw e.code="ERR_UNSUPPORTED_PROTOCOL",e}if(this._internals.username&&(n.username=this._internals.username,this._internals.username=""),this._internals.password&&(n.password=this._internals.password,this._internals.password=""),this._internals.searchParams&&(n.search=this._internals.searchParams.toString(),this._internals.searchParams=void 0),"unix"!==n.hostname)this._unixOptions=void 0;else{if(!this._internals.enableUnixSockets)throw new Error("Using UNIX domain sockets but option `enableUnixSockets` is not enabled");const e=/(?.+?):(?.+)/.exec(`${n.pathname}${n.search}`);if(e?.groups){const{socketPath:t,path:n}=e.groups;this._unixOptions={socketPath:t,path:n,host:""}}else this._unixOptions=void 0}}get cookieJar(){return this._internals.cookieJar}set cookieJar(e){if(Y.any([X.object,X.undefined],e),void 0===e)return void(this._internals.cookieJar=void 0);let{setCookie:t,getCookieString:n}=e;Y.function_(t),Y.function_(n),4===t.length&&0===n.length?(t=(0,Te.promisify)(t.bind(e)),n=(0,Te.promisify)(n.bind(e)),this._internals.cookieJar={setCookie:t,getCookieString:n}):this._internals.cookieJar=e}get signal(){return this._internals.signal}set signal(e){Y.object(e),this._internals.signal=e}get ignoreInvalidCookies(){return this._internals.ignoreInvalidCookies}set ignoreInvalidCookies(e){Y.boolean(e),this._internals.ignoreInvalidCookies=e}get searchParams(){return this._internals.url?this._internals.url.searchParams:(void 0===this._internals.searchParams&&(this._internals.searchParams=new URLSearchParams),this._internals.searchParams)}set searchParams(e){Y.any([X.string,X.object,X.undefined],e);const t=this._internals.url;if(void 0===e)return this._internals.searchParams=void 0,void(t&&(t.search=""));const n=this.searchParams;let s;if(X.string(e))s=new URLSearchParams(e);else if(e instanceof URLSearchParams)s=e;else{!function(e){for(const t in e){const n=e[t];Y.any([X.string,X.number,X.boolean,X.null_,X.undefined],n)}}(e),s=new URLSearchParams;for(const t in e){const o=e[t];null===o?s.append(t,""):void 0===o?n.delete(t):s.append(t,o)}}if(this._merging){for(const e of s.keys())n.delete(e);for(const[e,t]of s)n.append(e,t)}else t?t.search=n.toString():this._internals.searchParams=n}get searchParameters(){throw new Error("The `searchParameters` option does not exist. Use `searchParams` instead.")}set searchParameters(e){throw new Error("The `searchParameters` option does not exist. Use `searchParams` instead.")}get dnsLookup(){return this._internals.dnsLookup}set dnsLookup(e){Y.any([X.function_,X.undefined],e),this._internals.dnsLookup=e}get dnsCache(){return this._internals.dnsCache}set dnsCache(e){Y.any([X.object,X.boolean,X.undefined],e),this._internals.dnsCache=!0===e?Ct||(Ct=new ut,Ct):!1===e?void 0:e}get context(){return this._internals.context}set context(e){Y.object(e),this._merging?Object.assign(this._internals.context,e):this._internals.context={...e}}get hooks(){return this._internals.hooks}set hooks(e){Y.object(e);for(const t in e){if(!(t in this._internals.hooks))throw new Error(`Unexpected hook event: ${t}`);const n=t,s=e[n];if(Y.any([X.array,X.undefined],s),s)for(const e of s)Y.function_(e);if(this._merging)s&&this._internals.hooks[n].push(...s);else{if(!s)throw new Error(`Missing hook event: ${t}`);this._internals.hooks[t]=[...s]}}}get followRedirect(){return this._internals.followRedirect}set followRedirect(e){Y.boolean(e),this._internals.followRedirect=e}get followRedirects(){throw new TypeError("The `followRedirects` option does not exist. Use `followRedirect` instead.")}set followRedirects(e){throw new TypeError("The `followRedirects` option does not exist. Use `followRedirect` instead.")}get maxRedirects(){return this._internals.maxRedirects}set maxRedirects(e){Y.number(e),this._internals.maxRedirects=e}get cache(){return this._internals.cache}set cache(e){Y.any([X.object,X.string,X.boolean,X.undefined],e),this._internals.cache=!0===e?mt:!1===e?void 0:e}get throwHttpErrors(){return this._internals.throwHttpErrors}set throwHttpErrors(e){Y.boolean(e),this._internals.throwHttpErrors=e}get username(){const e=this._internals.url,t=e?e.username:this._internals.username;return decodeURIComponent(t)}set username(e){Y.string(e);const t=this._internals.url,n=encodeURIComponent(e);t?t.username=n:this._internals.username=n}get password(){const e=this._internals.url,t=e?e.password:this._internals.password;return decodeURIComponent(t)}set password(e){Y.string(e);const t=this._internals.url,n=encodeURIComponent(e);t?t.password=n:this._internals.password=n}get http2(){return this._internals.http2}set http2(e){Y.boolean(e),this._internals.http2=e}get allowGetBody(){return this._internals.allowGetBody}set allowGetBody(e){Y.boolean(e),this._internals.allowGetBody=e}get headers(){return this._internals.headers}set headers(e){Y.plainObject(e),this._merging?Object.assign(this._internals.headers,re(e)):this._internals.headers=re(e)}get methodRewriting(){return this._internals.methodRewriting}set methodRewriting(e){Y.boolean(e),this._internals.methodRewriting=e}get dnsLookupIpVersion(){return this._internals.dnsLookupIpVersion}set dnsLookupIpVersion(e){if(void 0!==e&&4!==e&&6!==e)throw new TypeError(`Invalid DNS lookup IP version: ${e}`);this._internals.dnsLookupIpVersion=e}get parseJson(){return this._internals.parseJson}set parseJson(e){Y.function_(e),this._internals.parseJson=e}get stringifyJson(){return this._internals.stringifyJson}set stringifyJson(e){Y.function_(e),this._internals.stringifyJson=e}get retry(){return this._internals.retry}set retry(e){if(Y.plainObject(e),Y.any([X.function_,X.undefined],e.calculateDelay),Y.any([X.number,X.undefined],e.maxRetryAfter),Y.any([X.number,X.undefined],e.limit),Y.any([X.array,X.undefined],e.methods),Y.any([X.array,X.undefined],e.statusCodes),Y.any([X.array,X.undefined],e.errorCodes),Y.any([X.number,X.undefined],e.noise),e.noise&&Math.abs(e.noise)>100)throw new Error(`The maximum acceptable retry noise is +/- 100ms, got ${e.noise}`);for(const t in e)if(!(t in this._internals.retry))throw new Error(`Unexpected retry option: ${t}`);this._merging?Object.assign(this._internals.retry,e):this._internals.retry={...e};const{retry:t}=this._internals;t.methods=[...new Set(t.methods.map((e=>e.toUpperCase())))],t.statusCodes=[...new Set(t.statusCodes)],t.errorCodes=[...new Set(t.errorCodes)]}get localAddress(){return this._internals.localAddress}set localAddress(e){Y.any([X.string,X.undefined],e),this._internals.localAddress=e}get method(){return this._internals.method}set method(e){Y.string(e),this._internals.method=e.toUpperCase()}get createConnection(){return this._internals.createConnection}set createConnection(e){Y.any([X.function_,X.undefined],e),this._internals.createConnection=e}get cacheOptions(){return this._internals.cacheOptions}set cacheOptions(e){Y.plainObject(e),Y.any([X.boolean,X.undefined],e.shared),Y.any([X.number,X.undefined],e.cacheHeuristic),Y.any([X.number,X.undefined],e.immutableMinTimeToLive),Y.any([X.boolean,X.undefined],e.ignoreCargoCult);for(const t in e)if(!(t in this._internals.cacheOptions))throw new Error(`Cache option \`${t}\` does not exist`);this._merging?Object.assign(this._internals.cacheOptions,e):this._internals.cacheOptions={...e}}get https(){return this._internals.https}set https(e){Y.plainObject(e),Y.any([X.boolean,X.undefined],e.rejectUnauthorized),Y.any([X.function_,X.undefined],e.checkServerIdentity),Y.any([X.string,X.object,X.array,X.undefined],e.certificateAuthority),Y.any([X.string,X.object,X.array,X.undefined],e.key),Y.any([X.string,X.object,X.array,X.undefined],e.certificate),Y.any([X.string,X.undefined],e.passphrase),Y.any([X.string,X.buffer,X.array,X.undefined],e.pfx),Y.any([X.array,X.undefined],e.alpnProtocols),Y.any([X.string,X.undefined],e.ciphers),Y.any([X.string,X.buffer,X.undefined],e.dhparam),Y.any([X.string,X.undefined],e.signatureAlgorithms),Y.any([X.string,X.undefined],e.minVersion),Y.any([X.string,X.undefined],e.maxVersion),Y.any([X.boolean,X.undefined],e.honorCipherOrder),Y.any([X.number,X.undefined],e.tlsSessionLifetime),Y.any([X.string,X.undefined],e.ecdhCurve),Y.any([X.string,X.buffer,X.array,X.undefined],e.certificateRevocationLists);for(const t in e)if(!(t in this._internals.https))throw new Error(`HTTPS option \`${t}\` does not exist`);this._merging?Object.assign(this._internals.https,e):this._internals.https={...e}}get encoding(){return this._internals.encoding}set encoding(e){if(null===e)throw new TypeError("To get a Buffer, set `options.responseType` to `buffer` instead");Y.any([X.string,X.undefined],e),this._internals.encoding=e}get resolveBodyOnly(){return this._internals.resolveBodyOnly}set resolveBodyOnly(e){Y.boolean(e),this._internals.resolveBodyOnly=e}get isStream(){return this._internals.isStream}set isStream(e){Y.boolean(e),this._internals.isStream=e}get responseType(){return this._internals.responseType}set responseType(e){if(void 0!==e){if("text"!==e&&"buffer"!==e&&"json"!==e)throw new Error(`Invalid \`responseType\` option: ${e}`);this._internals.responseType=e}else this._internals.responseType="text"}get pagination(){return this._internals.pagination}set pagination(e){Y.object(e),this._merging?Object.assign(this._internals.pagination,e):this._internals.pagination=e}get auth(){throw new Error("Parameter `auth` is deprecated. Use `username` / `password` instead.")}set auth(e){throw new Error("Parameter `auth` is deprecated. Use `username` / `password` instead.")}get setHost(){return this._internals.setHost}set setHost(e){Y.boolean(e),this._internals.setHost=e}get maxHeaderSize(){return this._internals.maxHeaderSize}set maxHeaderSize(e){Y.any([X.number,X.undefined],e),this._internals.maxHeaderSize=e}get enableUnixSockets(){return this._internals.enableUnixSockets}set enableUnixSockets(e){Y.boolean(e),this._internals.enableUnixSockets=e}toJSON(){return{...this._internals}}[Symbol.for("nodejs.util.inspect.custom")](e,t){return(0,Te.inspect)(this._internals,t)}createNativeRequestOptions(){const e=this._internals;let t;t="https:"===e.url.protocol?e.http2?e.agent:e.agent.https:e.agent.http;const{https:n}=e;let{pfx:s}=n;return X.array(s)&&X.plainObject(s[0])&&(s=s.map((e=>({buf:e.buffer,passphrase:e.passphrase})))),{...e.cacheOptions,...this._unixOptions,ALPNProtocols:n.alpnProtocols,ca:n.certificateAuthority,cert:n.certificate,key:n.key,passphrase:n.passphrase,pfx:n.pfx,rejectUnauthorized:n.rejectUnauthorized,checkServerIdentity:n.checkServerIdentity??Pe.checkServerIdentity,ciphers:n.ciphers,honorCipherOrder:n.honorCipherOrder,minVersion:n.minVersion,maxVersion:n.maxVersion,sigalgs:n.signatureAlgorithms,sessionTimeout:n.tlsSessionLifetime,dhparam:n.dhparam,ecdhCurve:n.ecdhCurve,crl:n.certificateRevocationLists,lookup:e.dnsLookup??e.dnsCache?.lookup,family:e.dnsLookupIpVersion,agent:t,setHost:e.setHost,method:e.method,maxHeaderSize:e.maxHeaderSize,localAddress:e.localAddress,headers:e.headers,createConnection:e.createConnection,timeout:e.http2?yt(e):void 0,h2session:e.h2session}}getRequestFunction(){const e=this._internals.url,{request:t}=this._internals;return!t&&e?this.getFallbackRequestFunction():t}getFallbackRequestFunction(){const e=this._internals.url;if(e){if("https:"===e.protocol){if(this._internals.http2){if(pt<15||15===pt&&It<10){const e=new Error("To use the `http2` option, install Node.js 15.10.0 or above");throw e.code="EUNSUPPORTED",e}return ht.auto}return De.request}return P.request}}freeze(){const e=this._internals;Object.freeze(e),Object.freeze(e.hooks),Object.freeze(e.hooks.afterResponse),Object.freeze(e.hooks.beforeError),Object.freeze(e.hooks.beforeRedirect),Object.freeze(e.hooks.beforeRequest),Object.freeze(e.hooks.beforeRetry),Object.freeze(e.hooks.init),Object.freeze(e.https),Object.freeze(e.cacheOptions),Object.freeze(e.agent),Object.freeze(e.headers),Object.freeze(e.timeout),Object.freeze(e.retry),Object.freeze(e.retry.errorCodes),Object.freeze(e.retry.methods),Object.freeze(e.retry.statusCodes)}}const Zt=e=>{const{statusCode:t}=e,n=e.request.options.followRedirect?299:399;return t>=200&&t<=n||304===t};class Gt extends F{constructor(e,t){const{options:n}=t.request;super(`${e.message} in "${n.url.toString()}"`,e,t.request),this.name="ParseError",this.code="ERR_BODY_PARSE_FAILURE"}}const vt=(e,t,n,s)=>{const{rawBody:o}=e;try{if("text"===t)return o.toString(s);if("json"===t)return 0===o.length?"":n(o.toString(s));if("buffer"===t)return o}catch(t){throw new Gt(t,e)}throw new Gt({message:`Unknown body type '${t}'`,name:"Error"},e)};function Bt(e){return"unix:"===e.protocol||"unix"===e.hostname}const{buffer:Wt}=oe,St=X.string(j.versions.brotli),Vt=new Set(["GET","HEAD"]),wt=new class{constructor(){Object.defineProperty(this,"weakMap",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"map",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.weakMap=new WeakMap,this.map=new Map}set(e,t){"object"==typeof e?this.weakMap.set(e,t):this.map.set(e,t)}get(e){return"object"==typeof e?this.weakMap.get(e):this.map.get(e)}has(e){return"object"==typeof e?this.weakMap.has(e):this.map.has(e)}},Rt=new Set([300,301,302,303,304,307,308]),Ht=["socket","connect","continue","information","upgrade"],kt=()=>{};class Yt extends M.Duplex{constructor(e,t,n){super({autoDestroy:!1,highWaterMark:0}),Object.defineProperty(this,"constructor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_noPipe",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"response",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"requestUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"redirectUrls",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"retryCount",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_stopRetry",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_downloadedSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_uploadedSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_stopReading",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_pipedServerResponses",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_request",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_responseSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_bodySize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_unproxyEvents",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_isFromCache",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_cannotHaveBody",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_triggerRead",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_cancelTimeouts",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_removeListeners",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_nativeResponse",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_flushed",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_aborted",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_requestInitialized",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._downloadedSize=0,this._uploadedSize=0,this._stopReading=!1,this._pipedServerResponses=new Set,this._cannotHaveBody=!1,this._unproxyEvents=kt,this._triggerRead=!1,this._cancelTimeouts=kt,this._removeListeners=kt,this._jobs=[],this._flushed=!1,this._requestInitialized=!1,this._aborted=!1,this.redirectUrls=[],this.retryCount=0,this._stopRetry=kt,this.on("pipe",(e=>{e?.headers&&Object.assign(this.options.headers,e.headers)})),this.on("newListener",(e=>{if("retry"===e&&this.listenerCount("retry")>0)throw new Error("A retry listener has been attached already.")}));try{if(this.options=new At(e,t,n),!this.options.url){if(""===this.options.prefixUrl)throw new TypeError("Missing `url` property");this.options.url=""}this.requestUrl=this.options.url}catch(e){const{options:t}=e;return t&&(this.options=t),void(this.flush=async()=>{this.flush=async()=>{},this.destroy(e)})}const{body:s}=this.options;if(X.nodeStream(s)&&s.once("error",(e=>{this._flushed?this._beforeError(new T(e,this)):this.flush=async()=>{this.flush=async()=>{},this._beforeError(new T(e,this))}})),this.options.signal){const e=()=>{this.destroy(new L(this))};this.options.signal.aborted?e():(this.options.signal.addEventListener("abort",e),this._removeListeners=()=>{this.options.signal?.removeEventListener("abort",e)})}}async flush(){if(!this._flushed){this._flushed=!0;try{if(await this._finalizeBody(),this.destroyed)return;if(await this._makeRequest(),this.destroyed)return void this._request?.destroy();for(const e of this._jobs)e();this._jobs.length=0,this._requestInitialized=!0}catch(e){this._beforeError(e)}}}_beforeError(e){if(this._stopReading)return;const{response:t,options:n}=this,s=this.retryCount+("RetryError"===e.name?0:1);this._stopReading=!0,e instanceof F||(e=new F(e.message,e,this));const o=e;(async()=>{if(!t?.readable||t.rawBody||this._request?.socket?.destroyed||(t.setEncoding(this.readableEncoding),await this._setRawBody(t)&&(t.body=t.rawBody.toString())),0!==this.listenerCount("retry")){let i;try{let e;t&&"retry-after"in t.headers&&(e=Number(t.headers["retry-after"]),Number.isNaN(e)?(e=Date.parse(t.headers["retry-after"])-Date.now(),e<=0&&(e=1)):e*=1e3);const r=n.retry;i=await r.calculateDelay({attemptCount:s,retryOptions:r,error:o,retryAfter:e,computedValue:Me({attemptCount:s,retryOptions:r,error:o,retryAfter:e,computedValue:r.maxRetryAfter??n.timeout.request??Number.POSITIVE_INFINITY})})}catch(e){return void this._error(new F(e.message,e,this))}if(i){if(await new Promise((e=>{const t=setTimeout(e,i);this._stopRetry=()=>{clearTimeout(t),e()}})),this.destroyed)return;try{for(const e of this.options.hooks.beforeRetry)await e(o,this.retryCount+1)}catch(t){return void this._error(new F(t.message,e,this))}if(this.destroyed)return;return this.destroy(),void this.emit("retry",this.retryCount+1,e,(e=>{const t=new Yt(n.url,e,n);return t.retryCount=this.retryCount+1,j.nextTick((()=>{t.flush()})),t}))}}this._error(o)})()}_read(){this._triggerRead=!0;const{response:e}=this;if(e&&!this._stopReading){let t;for(e.readableLength&&(this._triggerRead=!1);null!==(t=e.read());){this._downloadedSize+=t.length;const e=this.downloadProgress;e.percent<1&&this.emit("downloadProgress",e),this.push(t)}}}_write(e,t,n){const s=()=>{this._writeRequest(e,t,n)};this._requestInitialized?s():this._jobs.push(s)}_final(e){const t=()=>{this._request&&!this._request.destroyed?this._request.end((t=>{this._request._writableState?.errored||(t||(this._bodySize=this._uploadedSize,this.emit("uploadProgress",this.uploadProgress),this._request.emit("upload-complete")),e(t))})):e()};this._requestInitialized?t():this._jobs.push(t)}_destroy(e,t){if(this._stopReading=!0,this.flush=async()=>{},this._stopRetry(),this._cancelTimeouts(),this._removeListeners(),this.options){const{body:e}=this.options;X.nodeStream(e)&&e.destroy()}this._request&&this._request.destroy(),null===e||X.undefined(e)||e instanceof F||(e=new F(e.message,e,this)),t(e)}pipe(e,t){return e instanceof P.ServerResponse&&this._pipedServerResponses.add(e),super.pipe(e,t)}unpipe(e){return e instanceof P.ServerResponse&&this._pipedServerResponses.delete(e),super.unpipe(e),this}async _finalizeBody(){const{options:e}=this,{headers:t}=e,n=!X.undefined(e.form),s=!X.undefined(e.json),o=!X.undefined(e.body),i=Vt.has(e.method)&&!("GET"===e.method&&e.allowGetBody);if(this._cannotHaveBody=i,n||s||o){if(i)throw new TypeError(`The \`${e.method}\` method cannot be used with a body`);const s=!X.string(t["content-type"]);if(o){if(ye(e.body)){const n=new Ee(e.body);s&&(t["content-type"]=n.headers["Content-Type"]),"Content-Length"in n.headers&&(t["content-length"]=n.headers["Content-Length"]),e.body=n.encode()}ze(e.body)&&s&&(t["content-type"]=`multipart/form-data; boundary=${e.body.getBoundary()}`)}else if(n){s&&(t["content-type"]="application/x-www-form-urlencoded");const{form:n}=e;e.form=void 0,e.body=new URLSearchParams(n).toString()}else{s&&(t["content-type"]="application/json");const{json:n}=e;e.json=void 0,e.body=e.stringifyJson(n)}const r=await async function(e,t){return t&&"content-length"in t?Number(t["content-length"]):e?X.string(e)?Q.Buffer.byteLength(e):X.buffer(e)?e.length:ze(e)?(0,Te.promisify)(e.getLength.bind(e))():void 0:0}(e.body,e.headers);X.undefined(t["content-length"])&&X.undefined(t["transfer-encoding"])&&!i&&!X.undefined(r)&&(t["content-length"]=String(r))}"json"!==e.responseType||"accept"in e.headers||(e.headers.accept="application/json"),this._bodySize=Number(t["content-length"])||void 0}async _onResponseBase(e){if(this.isAborted)return;const{options:t}=this,{url:n}=t;this._nativeResponse=e,t.decompress&&(e=Ce(e));const s=e.statusCode,o=e;o.statusMessage=o.statusMessage??P.STATUS_CODES[s],o.url=t.url.toString(),o.requestUrl=this.requestUrl,o.redirectUrls=this.redirectUrls,o.request=this,o.isFromCache=this._nativeResponse.fromCache??!1,o.ip=this.ip,o.retryCount=this.retryCount,o.ok=Zt(o),this._isFromCache=o.isFromCache,this._responseSize=Number(e.headers["content-length"])||void 0,this.response=o,e.once("end",(()=>{this._responseSize=this._downloadedSize,this.emit("downloadProgress",this.downloadProgress)})),e.once("error",(t=>{this._aborted=!0,e.destroy(),this._beforeError(new U(t,this))})),e.once("aborted",(()=>{this._aborted=!0,this._beforeError(new U({name:"Error",message:"The server aborted pending request",code:"ECONNRESET"},this))})),this.emit("downloadProgress",this.downloadProgress);const i=e.headers["set-cookie"];if(X.object(t.cookieJar)&&i){let e=i.map((async e=>t.cookieJar.setCookie(e,n.toString())));t.ignoreInvalidCookies&&(e=e.map((async e=>{try{await e}catch{}})));try{await Promise.all(e)}catch(e){return void this._beforeError(e)}}if(!this.isAborted)if(t.followRedirect&&e.headers.location&&Rt.has(s)){if(e.resume(),this._cancelTimeouts(),this._unproxyEvents(),this.redirectUrls.length>=t.maxRedirects)return void this._beforeError(new K(this));this._request=void 0;const i=new At(void 0,void 0,this.options),r=303===s&&"GET"!==i.method&&"HEAD"!==i.method,a=307!==s&&308!==s,c=i.methodRewriting&&a;(r||c)&&(i.method="GET",i.body=void 0,i.json=void 0,i.form=void 0,delete i.headers["content-length"]);try{const t=Q.Buffer.from(e.headers.location,"binary").toString(),s=new URL(t,n);if(!Bt(n)&&Bt(s))return void this._beforeError(new F("Cannot redirect to UNIX socket",{},this));s.hostname!==n.hostname||s.port!==n.port?("host"in i.headers&&delete i.headers.host,"cookie"in i.headers&&delete i.headers.cookie,"authorization"in i.headers&&delete i.headers.authorization,(i.username||i.password)&&(i.username="",i.password="")):(s.username=i.username,s.password=i.password),this.redirectUrls.push(s),i.prefixUrl="",i.url=s;for(const e of i.hooks.beforeRedirect)await e(i,o);this.emit("redirect",i,o),this.options=i,await this._makeRequest()}catch(e){return void this._beforeError(e)}}else if(t.isStream&&t.throwHttpErrors&&!Zt(o))this._beforeError(new x(o));else if(e.on("readable",(()=>{this._triggerRead&&this._read()})),this.on("resume",(()=>{e.resume()})),this.on("pause",(()=>{e.pause()})),e.once("end",(()=>{this.push(null)})),this._noPipe)await this._setRawBody()&&this.emit("response",e);else{this.emit("response",e);for(const n of this._pipedServerResponses)if(!n.headersSent){for(const s in e.headers){const o=!t.decompress||"content-encoding"!==s,i=e.headers[s];o&&n.setHeader(s,i)}n.statusCode=s}}}async _setRawBody(e=this){if(e.readableEnded)return!1;try{const t=await Wt(e);if(!this.isAborted)return this.response.rawBody=t,!0}catch{}return!1}async _onResponse(e){try{await this._onResponseBase(e)}catch(e){this._beforeError(e)}}_onRequest(e){const{options:t}=this,{timeout:n,url:s}=t;(e=>{if(e.timings)return e.timings;const t={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}};e.timings=t;const n=e=>{e.once(D.errorMonitor,(()=>{t.error=Date.now(),t.phases.total=t.error-t.start}))};n(e);const s=()=>{t.abort=Date.now(),t.phases.total=t.abort-t.start};e.prependOnceListener("abort",s);const o=e=>{if(t.socket=Date.now(),t.phases.wait=t.socket-t.start,q.types.isProxy(e))return;const n=()=>{t.lookup=Date.now(),t.phases.dns=t.lookup-t.socket};e.prependOnceListener("lookup",n),$(e,{connect:()=>{t.connect=Date.now(),void 0===t.lookup&&(e.removeListener("lookup",n),t.lookup=t.connect,t.phases.dns=t.lookup-t.socket),t.phases.tcp=t.connect-t.lookup},secureConnect:()=>{t.secureConnect=Date.now(),t.phases.tls=t.secureConnect-t.connect}})};e.socket?o(e.socket):e.prependOnceListener("socket",o);const i=()=>{t.upload=Date.now(),t.phases.request=t.upload-(t.secureConnect??t.connect)};e.writableFinished?i():e.prependOnceListener("finish",i),e.prependOnceListener("response",(o=>{t.response=Date.now(),t.phases.firstByte=t.response-t.upload,o.timings=t,n(o),o.prependOnceListener("end",(()=>{e.off("abort",s),o.off("aborted",s),t.phases.total||(t.end=Date.now(),t.phases.download=t.end-t.response,t.phases.total=t.end-t.start)})),o.prependOnceListener("aborted",s)}))})(e),this.options.http2&&e.setTimeout(0),this._cancelTimeouts=function(e,t,n){if(Le in e)return je;e[Le]=!0;const s=[],{once:o,unhandleAll:i}=function(){const e=[];return{once(t,n,s){t.once(n,s),e.push({origin:t,event:n,fn:s})},unhandleAll(){for(const t of e){const{origin:e,event:n,fn:s}=t;e.removeListener(n,s)}e.length=0}}}(),r=(e,t,n)=>{const o=setTimeout(t,e,e,n);o.unref?.();const i=()=>{clearTimeout(o)};return s.push(i),i},{host:a,hostname:c}=n,l=(t,n)=>{e.destroy(new Qe(t,n))},g=()=>{for(const e of s)e();i()};if(e.once("error",(t=>{if(g(),0===e.listenerCount("error"))throw t})),void 0!==t.request){const n=r(t.request,l,"request");o(e,"response",(e=>{o(e,"end",n)}))}if(void 0!==t.socket){const{socket:n}=t,o=()=>{l(n,"socket")};e.setTimeout(n,o),s.push((()=>{e.removeListener("timeout",o)}))}const d=void 0!==t.lookup,u=void 0!==t.connect,h=void 0!==t.secureConnect,p=void 0!==t.send;return(d||u||h||p)&&o(e,"socket",(s=>{const{socketPath:i}=e;if(s.connecting){const e=Boolean(i??0!==Oe.isIP(c??a??""));if(d&&!e&&void 0===s.address().address){const e=r(t.lookup,l,"lookup");o(s,"lookup",e)}if(u){const n=()=>r(t.connect,l,"connect");e?o(s,"connect",n()):o(s,"lookup",(e=>{null===e&&o(s,"connect",n())}))}h&&"https:"===n.protocol&&o(s,"connect",(()=>{const e=r(t.secureConnect,l,"secureConnect");o(s,"secureConnect",e)}))}if(p){const n=()=>r(t.send,l,"send");s.connecting?o(s,"connect",(()=>{o(e,"upload-complete",n())})):o(e,"upload-complete",n())}})),void 0!==t.response&&o(e,"upload-complete",(()=>{const n=r(t.response,l,"response");o(e,"response",n)})),void 0!==t.read&&o(e,"response",(e=>{const n=r(t.read,l,"read");o(e,"end",n)})),g}(e,n,s);const o=t.cache?"cacheableResponse":"response";e.once(o,(e=>{this._onResponse(e)})),e.once("error",(t=>{this._aborted=!0,e.destroy(),t=t instanceof Qe?new z(t,this.timings,this):new F(t.message,t,this),this._beforeError(t)})),this._unproxyEvents=Ue(e,this,Ht),this._request=e,this.emit("uploadProgress",this.uploadProgress),this._sendBody(),this.emit("request",e)}async _asyncWrite(e){return new Promise(((t,n)=>{super.write(e,(e=>{e?n(e):t()}))}))}_sendBody(){const{body:e}=this.options,t=0===this.redirectUrls.length?this:this._request??this;X.nodeStream(e)?e.pipe(t):X.generator(e)||X.asyncGenerator(e)?(async()=>{try{for await(const t of e)await this._asyncWrite(t);super.end()}catch(e){this._beforeError(e)}})():X.undefined(e)?(this._cannotHaveBody||this._noPipe)&&t.end():(this._writeRequest(e,void 0,(()=>{})),t.end())}_prepareCache(e){if(!wt.has(e)){const t=new me(((e,t)=>{const n=e._request(e,t);return X.promise(n)&&(n.once=(e,t)=>{if("error"===e)(async()=>{try{await n}catch(e){t(e)}})();else{if("abort"!==e)throw new Error(`Unknown HTTP2 promise event: ${e}`);(async()=>{try{(await n).once("abort",t)}catch{}})()}return n}),n}),e);wt.set(e,t.request())}}async _createCacheableRequest(e,t){return new Promise(((n,s)=>{let o;Object.assign(t,function(e){const t={protocol:e.protocol,hostname:X.string(e.hostname)&&e.hostname.startsWith("[")?e.hostname.slice(1,-1):e.hostname,host:e.host,hash:e.hash,search:e.search,pathname:e.pathname,href:e.href,path:`${e.pathname||""}${e.search||""}`};return X.string(e.port)&&e.port.length>0&&(t.port=Number(e.port)),(e.username||e.password)&&(t.auth=`${e.username||""}:${e.password||""}`),t}(e));const i=wt.get(t.cache)(t,(async e=>{if(e._readableState.autoDestroy=!1,o){const t=()=>{e.req&&(e.complete=e.req.res.complete)};e.prependOnceListener("end",t),t(),(await o).emit("cacheableResponse",e)}n(e)}));i.once("error",s),i.once("request",(async e=>{o=e,n(o)}))}))}async _makeRequest(){const{options:e}=this,{headers:t,username:n,password:s}=e,o=e.cookieJar;for(const e in t)if(X.undefined(t[e]))delete t[e];else if(X.null_(t[e]))throw new TypeError(`Use \`undefined\` instead of \`null\` to delete the \`${e}\` header`);if(e.decompress&&X.undefined(t["accept-encoding"])&&(t["accept-encoding"]=St?"gzip, deflate, br":"gzip, deflate"),n||s){const e=Q.Buffer.from(`${n}:${s}`).toString("base64");t.authorization=`Basic ${e}`}if(o){const n=await o.getCookieString(e.url.toString());X.nonEmptyString(n)&&(t.cookie=n)}let i;e.prefixUrl="";for(const t of e.hooks.beforeRequest){const n=await t(e);if(!X.undefined(n)){i=()=>n;break}}i||(i=e.getRequestFunction());const r=e.url;this._requestOptions=e.createNativeRequestOptions(),e.cache&&(this._requestOptions._request=i,this._requestOptions.cache=e.cache,this._requestOptions.body=e.body,this._prepareCache(e.cache));const a=e.cache?this._createCacheableRequest:i;try{let t=a(r,this._requestOptions);X.promise(t)&&(t=await t),X.undefined(t)&&(t=e.getFallbackRequestFunction()(r,this._requestOptions),X.promise(t)&&(t=await t)),(c=t).writable&&!c.writableEnded?this._onRequest(t):this.writable?(this.once("finish",(()=>{this._onResponse(t)})),this._sendBody()):this._onResponse(t)}catch(e){if(e instanceof de)throw new E(e,this);throw e}var c}async _error(e){try{if(e instanceof x&&!this.options.throwHttpErrors);else for(const t of this.options.hooks.beforeError)e=await t(e)}catch(t){e=new F(t.message,t,this)}this.destroy(e)}_writeRequest(e,t,n){this._request&&!this._request.destroyed&&this._request.write(e,t,(s=>{if(!s&&!this._request.destroyed){this._uploadedSize+=Q.Buffer.byteLength(e,t);const n=this.uploadProgress;n.percent<1&&this.emit("uploadProgress",n)}n(s)}))}get ip(){return this.socket?.remoteAddress}get isAborted(){return this._aborted}get socket(){return this._request?.socket??void 0}get downloadProgress(){let e;return e=this._responseSize?this._downloadedSize/this._responseSize:this._responseSize===this._downloadedSize?1:0,{percent:e,transferred:this._downloadedSize,total:this._responseSize}}get uploadProgress(){let e;return e=this._bodySize?this._uploadedSize/this._bodySize:this._bodySize===this._uploadedSize?1:0,{percent:e,transferred:this._uploadedSize,total:this._bodySize}}get timings(){return this._request?.timings}get isFromCache(){return this._isFromCache}get reusedSocket(){return this._request?.reusedSocket}}class Xt extends F{constructor(e){super("Promise was canceled",{},e),this.name="CancelError",this.code="ERR_CANCELED"}get isCanceled(){return!0}}const Nt=["request","response","redirect","uploadProgress","downloadProgress"];function _t(e){let t,n,s;const o=new N.EventEmitter,i=new J(((r,a,c)=>{c((()=>{t.destroy()})),c.shouldReject=!1,c((()=>{a(new Xt(t))}));const l=g=>{c((()=>{}));const d=e??new Yt(void 0,void 0,s);d.retryCount=g,d._noPipe=!0,t=d,d.once("response",(async e=>{const t=(e.headers["content-encoding"]??"").toLowerCase(),s="gzip"===t||"deflate"===t||"br"===t,{options:o}=d;if(s&&!o.decompress)e.body=e.rawBody;else try{e.body=vt(e,o.responseType,o.parseJson,o.encoding)}catch(t){if(e.body=e.rawBody.toString(),Zt(e))return void d._beforeError(t)}try{const t=o.hooks.afterResponse;for(const[n,s]of t.entries())if(e=await s(e,(async e=>{throw o.merge(e),o.prefixUrl="",e.url&&(o.url=e.url),o.hooks.afterResponse=o.hooks.afterResponse.slice(0,n),new O(d)})),!X.object(e)||!X.number(e.statusCode)||X.nullOrUndefined(e.body))throw new TypeError("The `afterResponse` hook returned an invalid value")}catch(e){return void d._beforeError(e)}n=e,Zt(e)?(d.destroy(),r(d.options.resolveBodyOnly?e.body:e)):d._beforeError(new x(e))}));const u=e=>{if(i.isCanceled)return;const{options:t}=d;if(e instanceof x&&!t.throwHttpErrors){const{response:t}=e;return d.destroy(),void r(d.options.resolveBodyOnly?t.body:t)}a(e)};d.once("error",u);const h=d.options?.body;d.once("retry",((t,n)=>{e=void 0;const o=d.options.body;if(h===o&&X.nodeStream(o))return n.message="Cannot retry with consumed body stream",void u(n);s=d.options,l(t)})),Ue(d,o,Nt),X.undefined(e)&&d.flush()};l(0)}));i.on=(e,t)=>(o.on(e,t),i),i.off=(e,t)=>(o.off(e,t),i);const r=e=>{const t=(async()=>{await i;const{options:t}=n.request;return vt(n,e,t.parseJson,t.encoding)})();return Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)),t};return i.json=()=>{if(t.options){const{headers:e}=t.options;t.writableFinished||"accept"in e||(e.accept="application/json")}return r("json")},i.buffer=()=>r("buffer"),i.text=()=>r("text"),i}const Jt=async e=>new Promise((t=>{setTimeout(t,e)})),Ft=e=>X.function_(e),Kt=["get","post","put","patch","head","delete"],xt=e=>{e={options:new At(void 0,void 0,e.options),handlers:[...e.handlers],mutableDefaults:e.mutableDefaults},Object.defineProperty(e,"mutableDefaults",{enumerable:!0,configurable:!1,writable:!1});const t=(t,n,s=e.options)=>{const o=new Yt(t,n,s);let i;const r=e=>(o.options=e,o._noPipe=!e.isStream,o.flush(),e.isStream?o:(i||(i=_t(o)),i));let a=0;const c=t=>{const n=(e.handlers[a++]??r)(t,c);if(X.promise(n)&&!o.options.isStream&&(i||(i=_t(o)),n!==i)){const e=Object.getOwnPropertyDescriptors(i);for(const t in e)t in n&&delete e[t];Object.defineProperties(n,e),n.cancel=i.cancel}return n};return c(o.options)};t.extend=(...t)=>{const n=new At(void 0,void 0,e.options),s=[...e.handlers];let o;for(const e of t)Ft(e)?(n.merge(e.defaults.options),s.push(...e.defaults.handlers),o=e.defaults.mutableDefaults):(n.merge(e),e.handlers&&s.push(...e.handlers),o=e.mutableDefaults);return xt({options:n,handlers:s,mutableDefaults:Boolean(o)})};const n=async function*(n,s){let o=new At(n,s,e.options);o.resolveBodyOnly=!1;const{pagination:i}=o;Y.function_(i.transform),Y.function_(i.shouldContinue),Y.function_(i.filter),Y.function_(i.paginate),Y.number(i.countLimit),Y.number(i.requestLimit),Y.number(i.backoff);const r=[];let{countLimit:a}=i,c=0;for(;c{const s=[];for await(const o of n(e,t))s.push(o);return s},t.paginate.each=n,t.stream=(e,n)=>t(e,{...n,isStream:!0});for(const e of Kt)t[e]=(n,s)=>t(n,{...s,method:e}),t.stream[e]=(n,s)=>t(n,{...s,method:e,isStream:!0});return e.mutableDefaults||(Object.freeze(e.handlers),e.options.freeze()),Object.defineProperty(t,"defaults",{value:e,writable:!1,configurable:!1,enumerable:!0}),t},Et=xt({options:new At,handlers:[],mutableDefaults:!1});var Tt=n(4040);const zt=async(e,t)=>{const n=await Et.post(`${e}/v1/system/auth/login`,{https:{rejectUnauthorized:!1},json:t,timeout:{request:1e3}});return JSON.parse(n.body)};async function Ut(e,t,n){if(this.log("info",`8273: ${e?.body}`),8273===e?.code||8273===e?.body?.code)if(this.config.isOldVersion){const e=await zt(this.config.baseURL,{username:this.config.username,password:this.config.password});0===e.code&&(this.config.token=e.data.token,await t.bind(this)(this.config.token,...n))}else{const e=await Lt(this.config.url,this.config.UCenterFlag);if(0===e.code){const{sn:s,startTime:o}=e.data;this.log("info",`handleReqWithToken getOpenDetail resData: ${e.data}`),this.config.token=jt(s,o),this.log("info",`handleReqWithToken generateToken: ${this.config.token}`),await t.bind(this)(this.config.token,...n)}}}async function Ot(e,...t){const n=await e.bind(this)(this.config.token,...t);Ut.bind(this)(n,e,t)}const Lt=async(e,t)=>{const n=await Et.get(`${e}/v1/node/open-detail`,{timeout:{request:1e3},https:{rejectUnauthorized:!1},headers:{ip:t?.ip,port:t?.port,protocol:t?.protocol,Accept:"*/*",Connection:"keep-alive","Content-Type":"application/json"}});return JSON.parse(n.body)},jt=(e,t)=>Tt.sign({SN:e},t,{algorithm:"HS256",noTimestamp:!0}),Qt=e=>C.includes(e.config.modelId),Mt=e=>{const t=e.config.modelId?.toLowerCase();return t&&("q"===t.substring(0,1)||"d"===t.substring(0,1))},Pt={take:function(){let e=Buffer.from(a);this.socket.send(e)},cut:function(){let e=Buffer.from(c);this.socket.send(e)},ftb:function(e){let t=i.find((t=>t.id===e.options.ftb));this.config.ftb=e.options.ftb,this.checkFeedbacks("ftb"),this.socket.send(t.cmd)},freeze:function(e){this.config.freeze=e.options.freeze,this.checkFeedbacks("freeze");let t=r.find((t=>t.id===e.options.freeze));this.socket.send(t.cmd)},presetType:function(e){this.config.presetType=e.options.presetType,this.checkFeedbacks("pgm")},preset:function(e){let t=Buffer.from(l[this.config.presetType??"pvw"]);this.socket.send(t),setTimeout((()=>{let t=((e,t)=>{let n=[],s=0,o=e,i=25693;for((o<1||o>240)&&(console.log("error","Invalid temp_index, value="+o+", use default value 1"),o=1);o>0;)n[s]=Math.floor(o%10)+48,i+=n[s],o=Math.floor(o/10),s+=1;let r,a,c,l=[],g=[],d=[],u=[],h=[];switch(l=Buffer.from([85,170,0,125,254,0,4,0,0,0,1,48,0,0,0,0]),g=Buffer.from([0,0,2,1,0,0,0,0,0,0,0,1,21,0,0,0,0,0,91,123,34,102,105,108,101,73,100,34,58]),d=Buffer.from([44,34,102,105,108,101,84,121,112,101,34,58,54,44,34,97,112,112,108,121,84,121,112,101,34,58]),u=Buffer.from([t]),h=Buffer.from([125,93]),s){case 1:i+=59,r=Buffer.from([59,0]),a=Buffer.from([n[0]]);break;case 2:i+=60,r=Buffer.from([60,0]),a=Buffer.from([n[1],n[0]]);break;case 3:i+=61,r=Buffer.from([61,0]),a=Buffer.from([n[2],n[1],n[0]]);break;default:console.log("error","Invalid preset buf len!")}c=Buffer.from([255&i,i>>8&255]);let p=l.length+g.length+d.length+u.length+h.length+r.length+a.length+c.length;return Buffer.concat([l,r,g,a,d,u,h,c],p)})(e.options.preset,p[this.config.presetType]??p.pvw);this.socket.send(t)}),500)}};async function Dt(e){return await Et.put(`${this.config.baseURL}/v1/screen/selected/take`,{headers:{Authorization:e,ip:this.config?.UCenterFlag?.ip,port:this.config?.UCenterFlag?.port,protocol:this.config?.UCenterFlag?.protocol},https:{rejectUnauthorized:!1},json:{direction:0,effectSelect:0,switchEffect:{time:500,type:1}}})}async function qt(e,t,n){const s={direction:+n||0};return await Et.put(`${this.config.baseURL}/v1/screen/selected/cut`,{headers:{Authorization:e,ip:this.config?.UCenterFlag?.ip,port:this.config?.UCenterFlag?.port,protocol:this.config?.UCenterFlag?.protocol},https:{rejectUnauthorized:!1},json:s})}async function $t(e,t){this.config.ftb=t.options.ftb,this.checkFeedbacks("ftb");const n={ftb:{enable:Number(t.options.ftb),time:700}};return await Et.put(`${this.config.baseURL}/v1/screen/selected/ftb`,{headers:{Authorization:e,ip:this.config?.UCenterFlag?.ip,port:this.config?.UCenterFlag?.port,protocol:this.config?.UCenterFlag?.protocol},https:{rejectUnauthorized:!1},json:n})}async function en(e,t){this.config.freeze=t.options.freeze,this.checkFeedbacks("freeze");const n={freeze:Number(t.options.freeze)};return await Et.put(`${this.config.baseURL}/v1/screen/selected/freeze`,{headers:{Authorization:e,ip:this.config?.UCenterFlag?.ip,port:this.config?.UCenterFlag?.port,protocol:this.config?.UCenterFlag?.protocol},https:{rejectUnauthorized:!1},json:n})}async function tn(e,t){const n={sceneType:t.options.sceneType,presetId:t.options.presetId,id:t.options.preset};this.log("info",`getPresetReq-obj: ${JSON.stringify(n)}`);const s=await Et.put(`${this.config.baseURL}/v1/preset/play`,{headers:{Authorization:e,ip:this.config?.UCenterFlag?.ip,port:this.config?.UCenterFlag?.port,protocol:this.config?.UCenterFlag?.protocol},https:{rejectUnauthorized:!1},json:n}).json();return this.log("info",`场景设置成功了${JSON.stringify(s)}`),s}async function nn(e,t){this.log("info",t.options.select),this.log("info",JSON.stringify(this.screenSelect));const n=[{screenId:Number(t.options.screenId),select:Number(t.options.select)}],s=await Et.put(`${this.config.baseURL}/v1/screen/select`,{headers:{Authorization:e,ip:this.config?.UCenterFlag?.ip,port:this.config?.UCenterFlag?.port,protocol:this.config?.UCenterFlag?.protocol},https:{rejectUnauthorized:!1},json:n}).json();return this.log("info",22222),this.log("info",JSON.stringify(s)),0===s.code&&this.screenSelect[t.options.screenId]!==t.options.select&&(this.screenSelect[t.options.screenId]=Number(t.options.select),this.checkFeedbacks("screen")),this.log("info",`屏幕设置成功了${JSON.stringify(s)}`),s}async function sn(e,t){let n=-1;for(let e in this.layerSelect)1===this.layerSelect[e]&&(n=e);if(this.log("info",n),-1===n)return;const s=[{layerId:Number(n),source:{general:{sourceId:t.options.sourceId,sourceType:t.options.sourceType,relationId:0}}}];this.log("info",JSON.stringify(s));const o=await Et.put(`${this.config.baseURL}/v1/layers/source`,{headers:{Authorization:e,ip:this.config?.UCenterFlag?.ip,port:this.config?.UCenterFlag?.port,protocol:this.config?.UCenterFlag?.protocol},https:{rejectUnauthorized:!1},json:s}).json();return this.log("info",`切源成功了${JSON.stringify(o)}`),o}async function on(e,t){this.config.swapCopy=t.options.swapCopy,this.checkFeedbacks("swapCopy");const n={enable:+t.options.swapCopy};this.log("info",`setSwapCopyReq: ${JSON.stringify(n)}}`);const s=await Et.put(`${this.config.baseURL}/v1/screen/global/swap`,{headers:{Authorization:e,ip:this.config?.UCenterFlag?.ip,port:this.config?.UCenterFlag?.port,protocol:this.config?.UCenterFlag?.protocol},https:{rejectUnauthorized:!1},json:n});return this.log("info",`${s.body}`),s}let rn=null;async function an(e,t){this.log("info",`takeTime_direction: ${t.options.direction}`);const n=t.options.direction;if(this.config.globalSwitchEffect?.time){if("left"===n){const e=+this.config.globalSwitchEffect.time-100;this.config.globalSwitchEffect.time=e>=100?e:100}else if("right"===n){const e=+this.config.globalSwitchEffect.time+100;this.config.globalSwitchEffect.time=e<=1e4?e:1e4}const s={switchEffect:{time:this.config.globalSwitchEffect.time,type:1}};clearTimeout(rn),rn=setTimeout((async()=>{this.log("info",`takeTimeReq: ${JSON.stringify(s)}}`);const n=await Et.put(`${this.config.baseURL}/v1/screen/global/switch-effect`,{headers:{Authorization:e,ip:this.config?.UCenterFlag?.ip,port:this.config?.UCenterFlag?.port,protocol:this.config?.UCenterFlag?.protocol},https:{rejectUnauthorized:!1},json:s});this.log("info",`${n.body}`),Ut.bind(this)(n,an,[t])}),300)}}async function cn(e,t){this.config.mapping=t.options.mapping,this.checkFeedbacks("mapping");const n={nodeId:1,enable:+t.options.mapping};this.log("info",`setMappingReq: ${JSON.stringify(n)}}`);const s=await Et.put(`${this.config.baseURL}/v1/node/interface-location`,{headers:{Authorization:e,ip:this.config?.UCenterFlag?.ip,port:this.config?.UCenterFlag?.port,protocol:this.config?.UCenterFlag?.protocol},https:{rejectUnauthorized:!1},json:n});return this.log("info",`${s.body}`),s}function ln(e,t){Ot.bind(this)(qt,e,t)}const gn={take:function(e){Ot.bind(this)(Dt,e)},cut:ln,ftb:function(e){Ot.bind(this)($t,e)},freeze:function(e){Ot.bind(this)(en,e)},presetType:function(e){this.config.presetType=e.options.presetType,this.checkFeedbacks("pgm")},preset:function(e){Ot.bind(this)(tn,e)},screen:function(e){Ot.bind(this)(nn,e)},layer:function(e){for(let t in this.layerSelect)t!=e.options.layerId&&(this.layerSelect[t]=0);this.layerSelect[e.options.layerId]=Number(e.options.selected),this.log("info",JSON.stringify(this.layerSelect)),this.checkFeedbacks("layer")},source:function(e){Ot.bind(this)(sn,e)},swapCopy:function(e){Ot.bind(this)(on,e)},matchPgm:ln,takeTime:function(e){Ot.bind(this)(an,e)},mapping:function(e){Ot.bind(this)(cn,e)}},dn={take:{type:"button",category:"Display",name:"TAKE",style:{text:"TAKE",size:"24",color:(0,s.combineRgb)(255,255,255),bgcolor:(0,s.combineRgb)(255,0,0)},steps:[{down:[{actionId:"take",options:{}}]}],feedbacks:[]},cut:{type:"button",category:"Display",name:"CUT",style:{text:"CUT",size:"24",color:(0,s.combineRgb)(255,255,255),bgcolor:(0,s.combineRgb)(255,0,0)},steps:[{down:[{actionId:"cut",options:{}}]}],feedbacks:[]},ftb:{type:"button",category:"Display",name:"FTB",style:{text:"FTB",size:"18",color:(0,s.combineRgb)(255,255,255),bgcolor:(0,s.combineRgb)(0,0,0)},steps:[{down:[{actionId:"ftb",options:{ftb:"1"}}]},{down:[{actionId:"ftb",options:{ftb:"0"}}]}],feedbacks:[{feedbackId:"ftb",style:{bgcolor:(0,s.combineRgb)(255,0,0)},options:{}}]},freeze:{type:"button",category:"Display",name:"Freeze",style:{text:"Freeze",size:"18",color:(0,s.combineRgb)(255,255,255),bgcolor:(0,s.combineRgb)(0,0,0)},steps:[{down:[{actionId:"freeze",options:{freeze:"1"}}]},{down:[{actionId:"freeze",options:{freeze:"0"}}]}],feedbacks:[{feedbackId:"freeze",style:{bgcolor:(0,s.combineRgb)(255,0,0)},options:{}}]},presetType:{type:"button",category:"Display",name:"presetType",style:{text:"Load to\nPVW",size:"18",color:(0,s.combineRgb)(255,255,255),bgcolor:(0,s.combineRgb)(0,0,0)},steps:[{down:[{actionId:"presetType",options:{presetType:"pgm"}}]},{down:[{actionId:"presetType",options:{presetType:"pvw"}}]}],feedbacks:[{feedbackId:"pgm",style:{bgcolor:(0,s.combineRgb)(255,0,0),text:"Load to\nPGM"},options:{}}]}},un={type:"button",name:"SwapCopy",category:"Display",style:{text:"Swap\nCopy",size:"18",color:(0,s.combineRgb)(255,255,255),bgcolor:(0,s.combineRgb)(0,0,0)},steps:[{down:[{actionId:"swapCopy",options:{swapCopy:"0"}}]},{down:[{actionId:"swapCopy",options:{swapCopy:"1"}}]}],feedbacks:[{feedbackId:"swapCopy",style:{bgcolor:(0,s.combineRgb)(255,0,0)},options:{}}]},hn={type:"button",category:"Display",name:"MatchPGM",style:{text:"Match\nPGM",size:"18",color:(0,s.combineRgb)(255,255,255),bgcolor:(0,s.combineRgb)(0,0,0)},steps:[{down:[{actionId:"matchPgm",options:{}}]}],feedbacks:[]},pn={type:"button",category:"Display",name:"TakeTime",style:{text:"Take\nTime",size:"18",color:(0,s.combineRgb)(255,255,255),bgcolor:(0,s.combineRgb)(0,0,0)},steps:[{rotate_left:[{actionId:"takeTimeLeft",options:{direction:"left"}}],rotate_right:[{actionId:"takeTimeRight",options:{direction:"right"}}]}],options:{rotaryActions:!0},feedbacks:[]},In={type:"button",category:"Display",name:"Take\nTime-",previewStyle:{text:"Take\nTime-",size:"18",color:(0,s.combineRgb)(255,255,255),bgcolor:(0,s.combineRgb)(0,0,0)},style:{text:"Time-",size:"18",color:(0,s.combineRgb)(255,255,255),bgcolor:(0,s.combineRgb)(0,0,0)},steps:[{down:[{actionId:"takeTimeLeft",options:{direction:"left"}}]}]},mn={type:"button",category:"Display",name:"Take\nTime+",previewStyle:{text:"Take\nTime+",size:"18",color:(0,s.combineRgb)(255,255,255),bgcolor:(0,s.combineRgb)(0,0,0)},style:{text:"Time+",size:"18",color:(0,s.combineRgb)(255,255,255),bgcolor:(0,s.combineRgb)(0,0,0)},steps:[{down:[{actionId:"takeTimeRight",options:{direction:"right"}}]}]},Cn={type:"button",name:"Mapping",category:"Display",style:{text:"Mapping",size:"16",color:(0,s.combineRgb)(255,255,255),bgcolor:(0,s.combineRgb)(0,0,0)},steps:[{down:[{actionId:"mapping",options:{mapping:"1"}}]},{down:[{actionId:"mapping",options:{mapping:"0"}}]}],feedbacks:[{feedbackId:"mapping",style:{bgcolor:(0,s.combineRgb)(255,0,0)},options:{}}]},bn=function(e){return Qt(e)&&(Object.assign(dn,{swapCopy:un,matchPgm:hn,takeTime:pn,takeTimeLeft:In,takeTimeRight:mn}),Mt(e)&&Object.assign(dn,{mapping:Cn})),dn},yn=async(e,t)=>{let n=t;try{await e()}catch(t){if(n-=1,!(n>0))throw Error;await yn(e,n)}},fn=async(e,t,n)=>{let s=[];n.log("log","Input来了");try{const o=await Et.get(`${e}/v1/interface/list-thumb`,{headers:{Authorization:t,ip:n.config?.UCenterFlag?.ip,port:n.config?.UCenterFlag?.port,protocol:n.config?.UCenterFlag?.protocol},https:{rejectUnauthorized:!1}}).json();0===o.code&&(s=(o.data.list??[]).filter((e=>2===e?.auxiliaryInfo?.connectorInfo?.interfaceType&&0==e?.auxiliaryInfo?.connectorInfo?.workMode)).map((e=>({...e,sourceId:"2-"+e.interfaceId,sourceType:2,name:e.general.name}))))}catch(e){}return s},An=async(e,t,n)=>{let s=[];n.log("log","Screen来了");try{const o=await Et.get(`${e}/v1/screen/list-detail`,{headers:{Authorization:t,ip:n.config?.UCenterFlag?.ip,port:n.config?.UCenterFlag?.port,protocol:n.config?.UCenterFlag?.protocol},https:{rejectUnauthorized:!1}}).json();0===o.code&&(o.data.list??[]).filter((e=>2===e?.screenIdObj.type)).forEach((e=>{let t={...e,sourceId:"3-"+e.screenId,sourceType:3,name:e.general.name+"-PGM"};s.push(t)}))}catch(e){}return s},Zn=async(e,t,n)=>{let s=[];n.log("log","图片的源来了");try{const o=await Et.get(`${e}/v1/picture/list`,{headers:{Authorization:t,ip:n.config?.UCenterFlag?.ip,port:n.config?.UCenterFlag?.port,protocol:n.config?.UCenterFlag?.protocol},https:{rejectUnauthorized:!1}}).json();0===o.code&&(s=(o.data.list??[]).map((e=>({...e,sourceId:e.pictureObj.type+"-"+e.pictureId+"-pic",sourceType:e.pictureObj.type,name:e.general.name}))))}catch(e){}return s},Gn=async(e,t,n)=>{let s=[];try{const o=await Et.get(`${e}/v1/interface/crop-source`,{headers:{Authorization:t,ip:n.config?.UCenterFlag?.ip,port:n.config?.UCenterFlag?.port,protocol:n.config?.UCenterFlag?.protocol},https:{rejectUnauthorized:!1}}).json();0===o.code&&(s=(o.data.list??[]).map((e=>({...e,sourceId:"8-"+e.cropId,sourceType:8,name:e.name}))))}catch(e){}return s},vn=["ftb","freeze","presetType","swapCopy"];class Bn extends s.InstanceBase{constructor(e){super(e),this.PROTOCOL_TYPE=Object.values(h),this.DEVICES_INFO=function(){const e={};return y.forEach((t=>{var n;e[t]={id:t,label:(n=t,n.split(" ").map((e=>e.charAt(0).toUpperCase()+e.slice(1))).join(" ")),ftb:C.includes(t)?g:i,freeze:C.includes(t)?d:r}})),e}(),this.DEVICES=Object.values(this.DEVICES_INFO),this.screenSelect={},this.layerSelect={},this.presetDefinitionPreset={},this.presetDefinitionScreen={},this.presetDefinitionLayer={},this.presetDefinitionSource={},this.DEVICES.sort((function(e,t){var n=e.label.toLowerCase(),s=t.label.toLowerCase();return ns?1:0}))}updateActions(){this.log("debug","update actions...."),this.setActionDefinitions((e=>{const t=e.config.modelId,n=C.includes(t),s=n?gn:Pt;let o={};return o.take={name:"TAKE",options:[],callback:async t=>{try{s.take.bind(e)(t)}catch(t){e.log("error","take send error")}}},o.cut={name:"CUT",options:[],callback:async t=>{try{s.cut.bind(e)(t)}catch(t){e.log("error","cut send error")}}},o.ftb={name:"Make the screen fade to black or return to normal",options:[{type:"dropdown",name:"FTB",id:"ftb",default:"1",choices:n?g:i}],callback:async t=>{try{s.ftb.bind(e)(t)}catch(t){e.log("error","FTB send error")}}},o.freeze={name:"Freeze/Unfreeze the screen",options:[{type:"dropdown",name:"FRZ",id:"freeze",default:"1",choices:n?d:r}],callback:async t=>{try{s.freeze.bind(e)(t)}catch(t){e.log("error","FTB send error")}}},o.presetType={name:"Choose a destination to load the preset",options:[{type:"dropdown",name:"PVW/PGM",id:"presetType",default:"pvw",choices:u}],callback:async t=>{try{s.presetType.bind(e)(t)}catch(t){e.log("error","presetType set error")}}},o.preset={name:"Select a preset to load",options:[{type:"dropdown",name:"Preset",id:"presetId",default:1,choices:Object.values(e.presetDefinitionPreset).map((e=>({id:e.presetId,label:e.name})))}],callback:async t=>{try{let n=e.presetDefinitionPreset[`preset-play${t.options.presetId}`];if(!n)return;let o={options:{presetId:n.presetId,i:n.i,sceneType:n.sceneType}};s.preset.bind(e)(o)}catch(t){e.log("error","load_preset send error")}}},o.screen={name:"Select/Deselect a screen",options:[{type:"dropdown",name:"Screen",id:"screenId",default:1,choices:Object.values(e.presetDefinitionScreen).map((e=>({id:e.screenId,label:e.name})))},{type:"dropdown",name:"ScreenSelect",id:"select",default:"0",choices:[{id:"0",label:"Deselect the screen",default:"0"},{id:"1",label:"Select the screen",default:"1"}]}],callback:async t=>{try{s.screen.bind(e)(t)}catch(t){e.log("error","load_preset send error")}}},o.layer={name:"Select/Deselect a layer",options:[{type:"dropdown",name:"Layer",id:"layerId",default:1,choices:Object.values(e.presetDefinitionLayer).map((e=>({id:e.layerId,label:e.name})))},{type:"dropdown",name:"ScreenSelect",id:"selected",default:"0",choices:[{id:"0",label:"Deselect the layer",default:"0"},{id:"1",label:"Select the layer",default:"1"}]}],callback:async t=>{try{s.layer.bind(e)(t)}catch(t){e.log("error","load_preset send error")}}},o.source={name:"Change the source for the selected layer",options:[{type:"dropdown",name:"Source",id:"sourceId",default:1,choices:Object.values(e.presetDefinitionSource).map((e=>({id:e.sourceId.toString(),label:e.name})))}],callback:async t=>{try{let[n,o]=t.options.sourceId.split("-"),i={options:{sourceId:Number(o),sourceType:Number(n)}};s.source.bind(e)(i)}catch(t){e.log("error","load_source send error")}}},n&&(o.swapCopy={name:"Swap between PGM and PVM/Copy PVW to PGM",options:[{type:"dropdown",name:"SwapCopy",id:"swapCopy",default:"1",choices:I}],callback:async t=>{try{s.swapCopy.bind(e)(t)}catch(t){e.log("error","SwapCopy send error")}}},o.matchPgm={name:"Copy layers from PGM of the selected screen to PVW",options:[],callback:async t=>{try{s.matchPgm.bind(e)(t,1)}catch(t){e.log("error","MatchPGM send error")}}},o.takeTimeRight={name:"Increase the transition duration of Take",options:[],callback:async t=>{try{s.takeTime.bind(e)(t)}catch(t){e.log("error","Take Time+ send error")}}},o.takeTimeLeft={name:"Decrease the transition duration of Take",options:[],callback:async t=>{try{s.takeTime.bind(e)(t)}catch(t){e.log("error","Take Time- send error")}}},Mt(e)&&(o.mapping={name:"Enable or disable output mapping.",options:[{type:"dropdown",name:"mapping",id:"mapping",default:"0",choices:m}],callback:async t=>{try{s.mapping.bind(e)(t)}catch(t){e.log("error","Mapping send error")}}})),o})(this))}updateFeedbacks(){this.setFeedbackDefinitions((e=>{let t={};return t.ftb={type:"boolean",name:"FTB Status Detection",description:"Change the style when FTB is pressed.",defaultStyle:{bgcolor:(0,s.combineRgb)(255,0,0)},options:[],callback:()=>"1"===e.config.ftb},t.freeze={type:"boolean",name:"Freeze Status Detection",description:"Change the style when Freeze is pressed.",defaultStyle:{bgcolor:(0,s.combineRgb)(255,0,0)},options:[],callback:()=>"1"===e.config.freeze},t.pgm={type:"boolean",name:"PGM Status Detection",description:"Change the style when Load preset to PGM.",defaultStyle:{bgcolor:(0,s.combineRgb)(255,0,0),text:"Load to\nPGM"},options:[],callback:()=>"pgm"===e.config.presetType},t.screen={type:"boolean",name:"screen",description:"Change the style when Load preset to Screen",defaultStyle:{bgcolor:(0,s.combineRgb)(255,0,0),text:"Load to\nScreen"},options:[],callback:t=>1==e.screenSelect[t.options.screenId]},t.layer={type:"boolean",name:"layer",description:"Change the style when Load preset to layer",defaultStyle:{bgcolor:(0,s.combineRgb)(255,0,0),text:"Load to\nLayer"},options:[],callback:t=>1==e.layerSelect[t.options.layerId]},Qt(e)&&(t.swapCopy={type:"boolean",name:"SwapCopy Status Detection",description:"Change the style when swapCopy mode is pressed.",defaultStyle:{bgcolor:(0,s.combineRgb)(255,0,0)},options:[],callback:()=>"1"===e.config.swapCopy},Mt(e)&&(t.mapping={type:"boolean",name:"Mapping Status Detection",description:"Change the style when mapping is pressed.",defaultStyle:{bgcolor:(0,s.combineRgb)(255,0,0)},options:[],callback:()=>"1"===e.config.mapping})),t})(this))}getConfigFields(){return this.log("getting the fields...."),[{type:"static-text",id:"info",width:12,label:"Information",value:"This module will allow you to control the following products: N10, N20, D12 and D32."},{type:"textinput",id:"host",label:"IP Address",width:6,default:"192.168.0.10",regex:s.Regex.IP},{type:"dropdown",id:"modelId",label:"Model",width:6,choices:this.DEVICES,default:this.DEVICES[0].id},{type:"textinput",id:"username",label:"Username",width:6,default:"",isVisibleData:{httpDevices:C,config:this.config},isVisible:(e,t)=>t.httpDevices.includes(e.modelId)&&!!t.config.isOldVersion&&e.modelId===t.config.modelId},{type:"textinput",id:"password",label:"Password",width:6,default:"",isVisibleData:{httpDevices:C,config:this.config},isVisible:(e,t)=>t.httpDevices.includes(e.modelId)&&!!t.config.isOldVersion&&e.modelId===t.config.modelId}]}async destroy(){this.log("info","destroy:"+this.id),void 0!==this.socket&&this.socket.destroy(),void 0!==this.udp&&this.udp.destroy(),this.heartbeat&&(clearInterval(this.heartbeat),delete this.heartbeat),this.presetBeat&&(clearInterval(this.presetBeat),delete this.presetBeat)}async getDevicesByUCenter(){this.log("info","getDevicesByUCenter-start..."),this.config.protocol="https",this.config.port="19998",this.config.baseURL=`${this.config.protocol}://${this.config.host}:${this.config.port}/unico`;try{const e=await(async e=>{const t=await Et.get(`${e}/v1/ucenter/device-list`,{timeout:{request:1e3},https:{rejectUnauthorized:!1}});return JSON.parse(t.body)})(this.config.baseURL);if(0===e.code){const t=e.data?.list?.find((e=>e.ip===this.config.host)),n=t?.protocols?.[0]?.linkType??"http",s=["http","https"].includes(n)?n:"http";this.log("info",`getDevicesByUCenter-protocol:${s}`),this.config.UCenterFlag={protocol:s,ip:"127.0.0.1",port:"8088"},await this.getDeviceStatusByOpenDetail(),this.getGlobalSwitchEffect()}}catch(e){await this.getProtocol()}}async getDeviceStatusByPWD(){this.config.baseURL=`${this.config.protocol}://${this.config.host}:${this.config.port}/unico`,this.log("info",`getDeviceStatusByPWD-url:${this.config.baseURL} - ${(new Date).getTime()}`),this.log("info",`tokenInfo:${this.config.username}/${this.config.password}`);const e=await zt(this.config.baseURL,{username:this.config.username,password:this.config.password});this.log("info","tokenRes:"),this.log("info",JSON.stringify(e)),0===e.code?(this.config.token=e.data.token,this.updateStatus(s.InstanceStatus.Ok)):8274===e.code?this.updateStatus(s.InstanceStatus.BadConfig):this.updateStatus(s.InstanceStatus.ConnectionFailure)}async getDeviceStatusByOpenDetail(){this.config.baseURL=`${this.config.protocol}://${this.config.host}:${this.config.port}/unico`,this.log("info",`getDeviceStatusByOpenDetail-url:${this.config.baseURL} - ${(new Date).getTime()}`);const e=await Lt(this.config.baseURL,this.config.UCenterFlag);if(this.log("info",`getDeviceStatusByOpenDetail-res:${JSON.stringify(e)}`),0===e.code)this.config.token=jt(e.data.sn,e.data.startTime),this.log("info",`generateToken-res: ${this.config.token}`),this.updateStatus(s.InstanceStatus.Ok),C.includes(this.config.modelId)&&(this.getAllData(),this.presetBeat=setInterval((()=>this.getAllData()),1e4));else{if(8273===e.code)throw this.log("info",`getDeviceStatusByOpenDetail-Interface exception: ${JSON.stringify(e)}`),Error("Interface exception");this.updateStatus(s.InstanceStatus.ConnectionFailure)}}async getGlobalSwitchEffect(){this.config.baseURL=`${this.config.protocol}://${this.config.host}:${this.config.port}/unico`;const e=await(async(e,t,n)=>{const s=await Et.get(`${e}/v1/screen/global/switch-effect`,{timeout:{request:1e3},https:{rejectUnauthorized:!1},headers:{Authorization:n,ip:t?.ip,port:t?.port,protocol:t?.protocol}});return JSON.parse(s.body)})(this.config.baseURL,this.config.UCenterFlag,this.config.token);this.log("info",`${e?.code}`),0===e.code?this.config.globalSwitchEffect=e.data?.switchEffect||{}:this.log("info",`getGlobalSwitchEffect exception: ${JSON.stringify(e)}`)}async getProtocol(){this.log("info","getProtocol"),this.config.port=8088;const e=this.config.isOldVersion?this.getDeviceStatusByPWD:this.getDeviceStatusByOpenDetail;try{try{this.config.protocol="http",await yn(e.bind(this),3)}catch(t){this.config.protocol="https",await yn(e.bind(this),3)}this.getGlobalSwitchEffect()}catch(e){this.log("info",`getProtocol-${this.config.protocol}-cache-${e.code}`),this.config.isOldVersion?this.updateStatus(s.InstanceStatus.ConnectionFailure):(this.config.isOldVersion=!0,this.updateStatus(s.InstanceStatus.ConnectionFailure,"Please reconfigure the device connection information."))}}async getPresetList(){this.config.baseURL=`${this.config.protocol}://${this.config.host}:${this.config.port}/unico`;let e=[];try{const t=await(async(e,t,n)=>await Et.get(`${e}/v1/preset/list-detail`,{headers:{Authorization:t,ip:n.config?.UCenterFlag?.ip,port:n.config?.UCenterFlag?.port,protocol:n.config?.UCenterFlag?.protocol},https:{rejectUnauthorized:!1}}).json())(this.config.baseURL,this.config.token,this);0===t.code&&(e=t.data.list)}catch(e){}return this.log("log",JSON.stringify(e)),e}async getScreenList(){this.config.baseURL=`${this.config.protocol}://${this.config.host}:${this.config.port}/unico`;let e=[];try{const t=await(async(e,t,n)=>await Et.get(`${e}/v1/screen/list-detail`,{headers:{Authorization:t,ip:n.config?.UCenterFlag?.ip,port:n.config?.UCenterFlag?.port,protocol:n.config?.UCenterFlag?.protocol},https:{rejectUnauthorized:!1}}).json())(this.config.baseURL,this.config.token,this);0===t.code&&(e=(t.data.list??[]).filter((e=>1==e.enable)))}catch(e){}return e}async getLayerList(){this.log("info","getLayerList2"),this.config.baseURL=`${this.config.protocol}://${this.config.host}:${this.config.port}/unico`;let e=[];try{const t=await(async(e,t,n)=>await Et.get(`${e}/v1/layers/list-detail`,{headers:{Authorization:t,ip:n.config?.UCenterFlag?.ip,port:n.config?.UCenterFlag?.port,protocol:n.config?.UCenterFlag?.protocol},https:{rejectUnauthorized:!1}}).json())(this.config.baseURL,this.config.token,this);0===t.code&&(e=(t.data.list??[]).filter((e=>0!==e?.source?.general?.sourceType)))}catch(e){}return e}async getSourceList(){this.log("info","getLayerList2"),this.config.baseURL=`${this.config.protocol}://${this.config.host}:${this.config.port}/unico`;let e=[];try{const t=await(async(e,t,n)=>{n.log("info","来了");const s=await Promise.all([fn(e,t,n),An(e,t,n),Zn(e,t,n),Gn(e,t,n)]);return{code:0,data:{list:[...s[0],...s[1],...s[2],...s[3]]}}})(this.config.baseURL,this.config.token,this);0===t.code&&(e=t.data.list)}catch(e){}return e}async getAllData(){Promise.all([this.getPresetList(),this.getScreenList(),this.getLayerList(),this.getSourceList()]).then((e=>{const t=e[0],n=e[1],o=n.filter((e=>2===e.screenIdObj.type||4===e.screenIdObj.type)),i=e[2],r=e[3];this.presetDefinitionPreset={},this.presetDefinitionScreen={},this.presetDefinitionLayer={},this.presetDefinitionSource={},this.presetDefinitionPreset=(e=>{const t={};for(let n=1;n<=e.length;n++){const o=e[n-1],i={type:"button",category:"Presets",name:o.general.name,presetId:o.presetId,sceneType:o.presetIdObj.sceneType,i:n,style:{text:o.general.name,size:"auto",color:(0,s.combineRgb)(0,0,0),bgcolor:(0,s.combineRgb)(0,255,0)},steps:[{down:[{actionId:"preset",options:{presetId:o.presetId,sceneType:o.presetIdObj.sceneType,playType:o.presetIdObj.playType,preset:n}}]}],feedbacks:[]};t["preset-play"+o.presetId]=i}return t})(t),this.presetDefinitionScreen=((e,t)=>{const n={};t.log("info","啦啦啦11"),t.log("info",JSON.stringify(t.screenSelect));for(let o=1;o<=e.length;o++){const i=e[o-1],r={type:"button",category:"Screens",name:i.general.name,screenId:i.screenId,style:{text:i.general.name,size:"auto",color:(0,s.combineRgb)(0,0,0),bgcolor:(0,s.combineRgb)(0,255,0)},steps:[{down:[{actionId:"screen",options:{select:"0",screenId:i.screenId}}]},{down:[{actionId:"screen",options:{select:"1",screenId:i.screenId}}]}],feedbacks:[{feedbackId:"screen",style:{bgcolor:(0,s.combineRgb)(255,0,0)},options:{screenId:i.screenId,type:i.screenIdObj.type,name:i.general.name}}]};n["screen-play"+i.screenId]=r,t.screenSelect[i.screenId]=i.select}return n})(o,this),this.presetDefinitionLayer=((e,t=[],n)=>{const o={};for(let i=1;i<=e.length;i++){const r=e[i-1],a=(t.find((e=>e.screenId===r.layerIdObj.attachScreenId))?.general?.name??"")+"\n"+(2===r.layerIdObj.sceneType?"PGM":4===r.layerIdObj.sceneType?"PVM":"")+"\n"+r.general.name,c={type:"button",category:"Layers",name:a,layerId:r.layerId,style:{text:a,size:"auto",color:(0,s.combineRgb)(0,0,0),bgcolor:(0,s.combineRgb)(0,255,0)},steps:[{down:[{actionId:"layer",options:{selected:"1",layerId:r.layerId,name:r.general.name}}]},{down:[{actionId:"layer",options:{selected:"0",layerId:r.layerId,name:r.general.name}}]}],feedbacks:[{feedbackId:"layer",style:{bgcolor:(0,s.combineRgb)(255,0,0)},options:{layerId:r.layerId,name:r.general.name}}]};o["layer-play"+r.layerId]=c,n.layerSelect[r.layerId]=1===n.layerSelect[r.layerId]?1:0}return o})(i,n,this),this.presetDefinitionSource=((e,t)=>{const n={};for(let t=1;t<=e.length;t++){const o=e[t-1],i={type:"button",category:"Sources",name:o.name,sourceId:o.sourceId,style:{text:o.name,size:"auto",color:(0,s.combineRgb)(0,0,0),bgcolor:(0,s.combineRgb)(0,255,0)},steps:[{down:[{actionId:"source",options:{sourceId:o.sourceId,sourceType:o.sourceType,relationId:0}}]}],feedbacks:[]};n["source-play"+o.sourceId]=i}return n})(r),this.setPresetDefinitions({...bn(this),...this.presetDefinitionPreset,...this.presetDefinitionScreen,...this.presetDefinitionLayer,...this.presetDefinitionSource}),this.updateActions(),this.updateFeedbacks()}))}updateDeviceStatus(e){this.log("debug","ping test:"+e+", lastState:"+this.lastState),1==e?(this.log("debug","ping check ok."),0!==this.lastState&&(this.log("info","connection recover, try to reconnect device."),this.updateStatus(s.InstanceStatus.Connecting),this.initUDP(),this.initTCP(),this.lastState=0)):0==e&&0===this.lastState&&(this.updateStatus(s.InstanceStatus.ConnectionFailure),this.log("info","ping check failure."),this.lastState=1)}pingTest(){o.sys.probe(this.config.host,(e=>this.updateDeviceStatus(e)),{timeout:1})}initTCP(){void 0!==this.socket&&(this.socket.destroy(),delete this.socket),this.config.port=5400,this.config.host?(this.socket=new s.TCPHelper(this.config.host,this.config.port),this.socket.on("status_change",((e,t)=>{this.updateStatus(e,t)})),this.socket.on("error",(e=>{if(this.updateStatus(s.InstanceStatus.ConnectionFailure),this.log("error","Network error: "+e.message),console.log("TCP Connection error, Try to reconnect."),this.updateStatus(s.InstanceStatus.Connecting),void 0!==this.udp){let e=Buffer.from([114,101,113,78,79,86,65,83,84,65,82,95,76,73,78,75,58,0,0,3,254,255]);this.udp.send(e)}else this.initUDP()})),this.socket.on("connect",(()=>{let e=Buffer.from([85,170,0,0,254,0,0,0,0,0,0,0,2,0,0,0,2,0,87,86]);this.socket.send(e),this.log("debug","Connected"),this.updateStatus(s.InstanceStatus.Ok)})),this.socket.on("data",(e=>{}))):(this.log("error","No host configured"),this.updateStatus(s.InstanceStatus.BadConfig))}initUDP(){if(void 0!==this.udp&&(this.udp.destroy(),delete this.udp),void 0!==this.config.host?(this.udp=new s.UDPHelper(this.config.host,3800),this.udp.on("error",(e=>{this.debug("Network error",e),this.log("error","Network error: "+e.message),this.updateStatus(s.InstanceStatus.ConnectionFailure)})),this.udp.on("data",(()=>{})),this.udp.on("status_change",((e,t)=>{this.log("debug","UDP status_change: "+e)})),this.log("debug","initUDP finish")):(this.log("error","No host configured"),this.updateStatus(s.InstanceStatus.BadConfig)),void 0!==this.udp){let e=Buffer.from([114,101,113,78,79,86,65,83,84,65,82,95,76,73,78,75,58,0,0,3,254,255]);this.udp.send(e),this.log("info","UDP registration.")}}updateDefaultInfo(){vn.map((e=>{delete this.config[e]})),this.updateActions(),this.updateFeedbacks(),this.setPresetDefinitions(bn(this))}async configUpdated(e){this.log("info","configUpdated modules..."),this.updateStatus(s.InstanceStatus.Connecting);let t=!1;if(this.config.host===e.host&&this.config.modelId===e.modelId||(t=!0),delete this.config.token,t&&delete this.config.isOldVersion,this.config={...this.config,...e,model:this.DEVICES_INFO[e.modelId]},C.includes(this.config.modelId))this.log("info","http configUpdated handle..."),this.log("debug",`this.config:${JSON.stringify(this.config)}`),void 0!==this.socket&&this.socket.destroy(),this.heartbeat&&(clearInterval(this.heartbeat),delete this.heartbeat),this.presetBeat&&(clearInterval(this.heartbeat),delete this.heartbeat),this.screenSelect={},this.layerSelect={},await this.getDevicesByUCenter(),this.updateDefaultInfo.bind(this)();else{if(!0!==t&&void 0!==this.socket)return;this.heartbeat&&(clearInterval(this.heartbeat),delete this.heartbeat),this.initUDP(),this.initTCP(),this.heartbeat=setInterval((()=>this.pingTest()),1e4),this.updateDefaultInfo.bind(this)()}}async init(e){this.updateStatus(s.InstanceStatus.Connecting),this.config=Object.assign({},e),void 0!==this.config.modelId?this.config.model=this.DEVICES_INFO[this.config.modelId]:(this.config.modelId=this.DEVICES[0].id,this.config.model=this.DEVICES[0]),b.includes(this.config.modelId)?(this.initUDP(),this.initTCP(),this.heartbeat=setInterval((()=>this.pingTest()),1e4)):C.includes(this.config.modelId)&&await this.getDevicesByUCenter(),this.updateDefaultInfo.bind(this)()}}(0,s.runEntrypoint)(Bn,[function(e,t){let n={updatedConfig:null,updatedActions:[],updatedFeedbacks:[]};t.config&&(n.updatedConfig=t.config,t.config.modelID&&!t.config.modelId&&(n.updatedConfig.modelId=t.config.modelID),t.config.presetType||(n.updatedConfig.presetType="pvw"));for(const e of t.actions)switch(e.actionId){case"change_black":e.actionId="ftb",e.options={ftb:"1"},n.updatedActions.push(e);break;case"change_freeze":e.actionId="freeze",e.options={freeze:"1"},n.updatedActions.push(e);break;case"load_preset":e.actionId="preset",e.options={preset:"1"},n.updatedActions.push(e)}return n}])}},t={};function n(s){var o=t[s];if(void 0!==o)return o.exports;var i=t[s]={id:s,loaded:!1,exports:{}};return e[s].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}n.c=t,n.d=(e,t)=>{for(var s in t)n.o(t,s)&&!n.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},n.hmd=e=>((e=Object.create(e)).children||(e.children=[]),Object.defineProperty(e,"exports",{enumerable:!0,set:()=>{throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+e.id)}}),e),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n(n.s=8736)})(); \ No newline at end of file diff --git a/novastar-switcher/main.js.LICENSE.txt b/novastar-switcher/main.js.LICENSE.txt new file mode 100644 index 00000000..21d6cb08 --- /dev/null +++ b/novastar-switcher/main.js.LICENSE.txt @@ -0,0 +1 @@ +/*! safe-buffer. MIT License. Feross Aboukhadijeh */ diff --git a/novastar-switcher/package.json b/novastar-switcher/package.json index 485292d3..ae44cbb8 100644 --- a/novastar-switcher/package.json +++ b/novastar-switcher/package.json @@ -1 +1 @@ -{"name":"novastar-switcher","version":"1.2.1","license":"MIT","type":"commonjs","dependencies":{}} \ No newline at end of file +{"name":"novastar-switcher","version":"1.3.0","license":"MIT","type":"commonjs","dependencies":{}} \ No newline at end of file