@equinor/fusion-framework-cli 11.3.1 → 12.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/build/bin.mjs CHANGED
@@ -1 +1 @@
1
- import{loadConfigFromFile as e,mergeConfig as t,build as r}from"vite";import n from"vite-tsconfig-paths";import{dirname as i,resolve as o,basename as s,extname as a,relative as c}from"node:path";import{readPackageUp as l}from"read-package-up";import u,{fileURLToPath as f}from"node:url";import p from"url";import h from"node:module";import d from"util";import{accessSync as m,constants as g,readFileSync as v,statSync as y,existsSync as E,mkdirSync as b,writeFileSync as w}from"node:fs";import{stat as L,mkdir as S}from"node:fs/promises";import{importConfig as C,FileNotFoundError as I}from"@equinor/fusion-imports";import D from"deepmerge";import O from"node:assert";import{execSync as N}from"node:child_process";import A,{z as P}from"zod";import _ from"fs";import R from"path";import T from"zlib";import x from"crypto";import $ from"ora";import{createDevServer as F,processServices as U}from"@equinor/fusion-framework-dev-server";import{enableAuthModule as k}from"@equinor/fusion-framework-module-msal-node";const B=(e=0)=>t=>`[${t+e}m`,M=(e=0)=>t=>`[${38+e};5;${t}m`,G=(e=0)=>(t,r,n)=>`[${38+e};2;${t};${r};${n}m`,j={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(j.modifier);Object.keys(j.color),Object.keys(j.bgColor);const z=function(){const e=new Map;for(const[t,r]of Object.entries(j)){for(const[t,n]of Object.entries(r))j[t]={open:`[${n[0]}m`,close:`[${n[1]}m`},r[t]=j[t],e.set(n[0],n[1]);Object.defineProperty(j,t,{value:r,enumerable:!1})}return Object.defineProperty(j,"codes",{value:e,enumerable:!1}),j.color.close="",j.bgColor.close="",j.color.ansi=B(),j.color.ansi256=M(),j.color.ansi16m=G(),j.bgColor.ansi=B(10),j.bgColor.ansi256=M(10),j.bgColor.ansi16m=G(10),Object.defineProperties(j,{rgbToAnsi256:{value:(e,t,r)=>e===t&&t===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(r/255*5),enumerable:!1},hexToRgb:{value(e){const t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[r]=t;3===r.length&&(r=[...r].map(e=>e+e).join(""));const n=Number.parseInt(r,16);return[n>>16&255,n>>8&255,255&n]},enumerable:!1},hexToAnsi256:{value:e=>j.rgbToAnsi256(...j.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return e-8+90;let t,r,n;if(e>=232)t=(10*(e-232)+8)/255,r=t,n=t;else{const i=(e-=16)%36;t=Math.floor(e/36)/5,r=Math.floor(i/6)/5,n=i%6/5}const i=2*Math.max(t,r,n);if(0===i)return 30;let o=30+(Math.round(n)<<2|Math.round(r)<<1|Math.round(t));return 2===i&&(o+=60),o},enumerable:!1},rgbToAnsi:{value:(e,t,r)=>j.ansi256ToAnsi(j.rgbToAnsi256(e,t,r)),enumerable:!1},hexToAnsi:{value:e=>j.ansi256ToAnsi(j.hexToAnsi256(e)),enumerable:!1}}),j}(),H=(()=>{if(!("navigator"in globalThis))return 0;if(globalThis.navigator.userAgentData){const e=navigator.userAgentData.brands.find(({brand:e})=>"Chromium"===e);if(e&&e.version>93)return 3}return/\b(Chrome|Chromium)\//.test(globalThis.navigator.userAgent)?1:0})(),q=0!==H&&{level:H},W={stdout:q,stderr:q};function V(e,t,r){let n=e.indexOf(t);if(-1===n)return e;const i=t.length;let o=0,s="";do{s+=e.slice(o,n)+t+r,o=n+i,n=e.indexOf(t,o)}while(-1!==n);return s+=e.slice(o),s}const{stdout:Y,stderr:K}=W,Z=Symbol("GENERATOR"),X=Symbol("STYLER"),J=Symbol("IS_EMPTY"),Q=["ansi","ansi","ansi256","ansi16m"],ee=Object.create(null),te=e=>{const t=(...e)=>e.join(" ");return((e,t={})=>{if(t.level&&!(Number.isInteger(t.level)&&t.level>=0&&t.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");const r=Y?Y.level:0;e.level=void 0===t.level?r:t.level})(t,e),Object.setPrototypeOf(t,re.prototype),t};function re(e){return te(e)}Object.setPrototypeOf(re.prototype,Function.prototype);for(const[e,t]of Object.entries(z))ee[e]={get(){const r=ae(this,se(t.open,t.close,this[X]),this[J]);return Object.defineProperty(this,e,{value:r}),r}};ee.visible={get(){const e=ae(this,this[X],!0);return Object.defineProperty(this,"visible",{value:e}),e}};const ne=(e,t,r,...n)=>"rgb"===e?"ansi16m"===t?z[r].ansi16m(...n):"ansi256"===t?z[r].ansi256(z.rgbToAnsi256(...n)):z[r].ansi(z.rgbToAnsi(...n)):"hex"===e?ne("rgb",t,r,...z.hexToRgb(...n)):z[r][e](...n),ie=["rgb","hex","ansi256"];for(const e of ie){ee[e]={get(){const{level:t}=this;return function(...r){const n=se(ne(e,Q[t],"color",...r),z.color.close,this[X]);return ae(this,n,this[J])}}};ee["bg"+e[0].toUpperCase()+e.slice(1)]={get(){const{level:t}=this;return function(...r){const n=se(ne(e,Q[t],"bgColor",...r),z.bgColor.close,this[X]);return ae(this,n,this[J])}}}}const oe=Object.defineProperties(()=>{},{...ee,level:{enumerable:!0,get(){return this[Z].level},set(e){this[Z].level=e}}}),se=(e,t,r)=>{let n,i;return void 0===r?(n=e,i=t):(n=r.openAll+e,i=t+r.closeAll),{open:e,close:t,openAll:n,closeAll:i,parent:r}},ae=(e,t,r)=>{const n=(...e)=>ce(n,1===e.length?""+e[0]:e.join(" "));return Object.setPrototypeOf(n,oe),n[Z]=e,n[X]=t,n[J]=r,n},ce=(e,t)=>{if(e.level<=0||!t)return e[J]?"":t;let r=e[X];if(void 0===r)return t;const{openAll:n,closeAll:i}=r;if(t.includes(""))for(;void 0!==r;)t=V(t,r.close,r.open),r=r.parent;const o=t.indexOf("\n");return-1!==o&&(t=function(e,t,r,n){let i=0,o="";do{const s="\r"===e[n-1];o+=e.slice(i,s?n-1:n)+t+(s?"\r\n":"\n")+r,i=n+1,n=e.indexOf("\n",i)}while(-1!==n);return o+=e.slice(i),o}(t,i,n,o)),n+t+i};Object.defineProperties(re.prototype,ee);const le=re();function ue(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var fe,pe,he,de;function me(){if(pe)return fe;pe=1;const e="object"==typeof process&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};return fe=e}function ge(){if(de)return he;de=1;const e=Number.MAX_SAFE_INTEGER||9007199254740991;return he={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:e,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}}re({level:K?K.level:0});var ve,ye,Ee,be,we,Le,Se,Ce,Ie,De,Oe,Ne,Ae,Pe={exports:{}};function _e(){return ve||(ve=1,function(e,t){const{MAX_SAFE_COMPONENT_LENGTH:r,MAX_SAFE_BUILD_LENGTH:n,MAX_LENGTH:i}=ge(),o=me(),s=(t=e.exports={}).re=[],a=t.safeRe=[],c=t.src=[],l=t.safeSrc=[],u=t.t={};let f=0;const p="[a-zA-Z0-9-]",h=[["\\s",1],["\\d",i],[p,n]],d=(e,t,r)=>{const n=(e=>{for(const[t,r]of h)e=e.split(`${t}*`).join(`${t}{0,${r}}`).split(`${t}+`).join(`${t}{1,${r}}`);return e})(t),i=f++;o(e,i,t),u[e]=i,c[i]=t,l[i]=n,s[i]=new RegExp(t,r?"g":void 0),a[i]=new RegExp(n,r?"g":void 0)};d("NUMERICIDENTIFIER","0|[1-9]\\d*"),d("NUMERICIDENTIFIERLOOSE","\\d+"),d("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${p}*`),d("MAINVERSION",`(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})`),d("MAINVERSIONLOOSE",`(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})`),d("PRERELEASEIDENTIFIER",`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIER]})`),d("PRERELEASEIDENTIFIERLOOSE",`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIERLOOSE]})`),d("PRERELEASE",`(?:-(${c[u.PRERELEASEIDENTIFIER]}(?:\\.${c[u.PRERELEASEIDENTIFIER]})*))`),d("PRERELEASELOOSE",`(?:-?(${c[u.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[u.PRERELEASEIDENTIFIERLOOSE]})*))`),d("BUILDIDENTIFIER",`${p}+`),d("BUILD",`(?:\\+(${c[u.BUILDIDENTIFIER]}(?:\\.${c[u.BUILDIDENTIFIER]})*))`),d("FULLPLAIN",`v?${c[u.MAINVERSION]}${c[u.PRERELEASE]}?${c[u.BUILD]}?`),d("FULL",`^${c[u.FULLPLAIN]}$`),d("LOOSEPLAIN",`[v=\\s]*${c[u.MAINVERSIONLOOSE]}${c[u.PRERELEASELOOSE]}?${c[u.BUILD]}?`),d("LOOSE",`^${c[u.LOOSEPLAIN]}$`),d("GTLT","((?:<|>)?=?)"),d("XRANGEIDENTIFIERLOOSE",`${c[u.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),d("XRANGEIDENTIFIER",`${c[u.NUMERICIDENTIFIER]}|x|X|\\*`),d("XRANGEPLAIN",`[v=\\s]*(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:${c[u.PRERELEASE]})?${c[u.BUILD]}?)?)?`),d("XRANGEPLAINLOOSE",`[v=\\s]*(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:${c[u.PRERELEASELOOSE]})?${c[u.BUILD]}?)?)?`),d("XRANGE",`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAIN]}$`),d("XRANGELOOSE",`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAINLOOSE]}$`),d("COERCEPLAIN",`(^|[^\\d])(\\d{1,${r}})(?:\\.(\\d{1,${r}}))?(?:\\.(\\d{1,${r}}))?`),d("COERCE",`${c[u.COERCEPLAIN]}(?:$|[^\\d])`),d("COERCEFULL",c[u.COERCEPLAIN]+`(?:${c[u.PRERELEASE]})?`+`(?:${c[u.BUILD]})?(?:$|[^\\d])`),d("COERCERTL",c[u.COERCE],!0),d("COERCERTLFULL",c[u.COERCEFULL],!0),d("LONETILDE","(?:~>?)"),d("TILDETRIM",`(\\s*)${c[u.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",d("TILDE",`^${c[u.LONETILDE]}${c[u.XRANGEPLAIN]}$`),d("TILDELOOSE",`^${c[u.LONETILDE]}${c[u.XRANGEPLAINLOOSE]}$`),d("LONECARET","(?:\\^)"),d("CARETTRIM",`(\\s*)${c[u.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",d("CARET",`^${c[u.LONECARET]}${c[u.XRANGEPLAIN]}$`),d("CARETLOOSE",`^${c[u.LONECARET]}${c[u.XRANGEPLAINLOOSE]}$`),d("COMPARATORLOOSE",`^${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]})$|^$`),d("COMPARATOR",`^${c[u.GTLT]}\\s*(${c[u.FULLPLAIN]})$|^$`),d("COMPARATORTRIM",`(\\s*)${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]}|${c[u.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",d("HYPHENRANGE",`^\\s*(${c[u.XRANGEPLAIN]})\\s+-\\s+(${c[u.XRANGEPLAIN]})\\s*$`),d("HYPHENRANGELOOSE",`^\\s*(${c[u.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[u.XRANGEPLAINLOOSE]})\\s*$`),d("STAR","(<|>)?=?\\s*\\*"),d("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),d("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")}(Pe,Pe.exports)),Pe.exports}function Re(){if(Ee)return ye;Ee=1;const e=Object.freeze({loose:!0}),t=Object.freeze({});return ye=r=>r?"object"!=typeof r?e:r:t}function Te(){if(we)return be;we=1;const e=/^[0-9]+$/,t=(t,r)=>{const n=e.test(t),i=e.test(r);return n&&i&&(t=+t,r=+r),t===r?0:n&&!i?-1:i&&!n?1:t<r?-1:1};return be={compareIdentifiers:t,rcompareIdentifiers:(e,r)=>t(r,e)},be}function xe(){if(Se)return Le;Se=1;const e=me(),{MAX_LENGTH:t,MAX_SAFE_INTEGER:r}=ge(),{safeRe:n,t:i}=_e(),o=Re(),{compareIdentifiers:s}=Te();class a{constructor(s,c){if(c=o(c),s instanceof a){if(s.loose===!!c.loose&&s.includePrerelease===!!c.includePrerelease)return s;s=s.version}else if("string"!=typeof s)throw new TypeError(`Invalid version. Must be a string. Got type "${typeof s}".`);if(s.length>t)throw new TypeError(`version is longer than ${t} characters`);e("SemVer",s,c),this.options=c,this.loose=!!c.loose,this.includePrerelease=!!c.includePrerelease;const l=s.trim().match(c.loose?n[i.LOOSE]:n[i.FULL]);if(!l)throw new TypeError(`Invalid Version: ${s}`);if(this.raw=s,this.major=+l[1],this.minor=+l[2],this.patch=+l[3],this.major>r||this.major<0)throw new TypeError("Invalid major version");if(this.minor>r||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>r||this.patch<0)throw new TypeError("Invalid patch version");l[4]?this.prerelease=l[4].split(".").map(e=>{if(/^[0-9]+$/.test(e)){const t=+e;if(t>=0&&t<r)return t}return e}):this.prerelease=[],this.build=l[5]?l[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(t){if(e("SemVer.compare",this.version,this.options,t),!(t instanceof a)){if("string"==typeof t&&t===this.version)return 0;t=new a(t,this.options)}return t.version===this.version?0:this.compareMain(t)||this.comparePre(t)}compareMain(e){return e instanceof a||(e=new a(e,this.options)),s(this.major,e.major)||s(this.minor,e.minor)||s(this.patch,e.patch)}comparePre(t){if(t instanceof a||(t=new a(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let r=0;do{const n=this.prerelease[r],i=t.prerelease[r];if(e("prerelease compare",r,n,i),void 0===n&&void 0===i)return 0;if(void 0===i)return 1;if(void 0===n)return-1;if(n!==i)return s(n,i)}while(++r)}compareBuild(t){t instanceof a||(t=new a(t,this.options));let r=0;do{const n=this.build[r],i=t.build[r];if(e("build compare",r,n,i),void 0===n&&void 0===i)return 0;if(void 0===i)return 1;if(void 0===n)return-1;if(n!==i)return s(n,i)}while(++r)}inc(e,t,r){if(e.startsWith("pre")){if(!t&&!1===r)throw new Error("invalid increment argument: identifier is empty");if(t){const e=`-${t}`.match(this.options.loose?n[i.PRERELEASELOOSE]:n[i.PRERELEASE]);if(!e||e[1]!==t)throw new Error(`invalid identifier: ${t}`)}}switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",t,r);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",t,r);break;case"prepatch":this.prerelease.length=0,this.inc("patch",t,r),this.inc("pre",t,r);break;case"prerelease":0===this.prerelease.length&&this.inc("patch",t,r),this.inc("pre",t,r);break;case"release":if(0===this.prerelease.length)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":0===this.minor&&0===this.patch&&0!==this.prerelease.length||this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":0===this.patch&&0!==this.prerelease.length||this.minor++,this.patch=0,this.prerelease=[];break;case"patch":0===this.prerelease.length&&this.patch++,this.prerelease=[];break;case"pre":{const e=Number(r)?1:0;if(0===this.prerelease.length)this.prerelease=[e];else{let n=this.prerelease.length;for(;--n>=0;)"number"==typeof this.prerelease[n]&&(this.prerelease[n]++,n=-2);if(-1===n){if(t===this.prerelease.join(".")&&!1===r)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(e)}}if(t){let n=[t,e];!1===r&&(n=[t]),0===s(this.prerelease[0],t)?isNaN(this.prerelease[1])&&(this.prerelease=n):this.prerelease=n}break}default:throw new Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}}return Le=a}function $e(){if(Ie)return Ce;Ie=1;const e=xe();return Ce=(t,r,n=!1)=>{if(t instanceof e)return t;try{return new e(t,r)}catch(e){if(!n)return null;throw e}},Ce}function Fe(){if(Oe)return De;Oe=1;const e=$e();return De=(t,r)=>{const n=e(t,r);return n?n.version:null},De}function Ue(){if(Ae)return Ne;Ae=1;const e=$e();return Ne=(t,r)=>{const n=e(t.trim().replace(/^[=v]+/,""),r);return n?n.version:null},Ne}var ke,Be,Me,Ge,je,ze,He,qe,We,Ve,Ye=["0BSD","3D-Slicer-1.0","AAL","ADSL","AFL-1.1","AFL-1.2","AFL-2.0","AFL-2.1","AFL-3.0","AGPL-1.0-only","AGPL-1.0-or-later","AGPL-3.0-only","AGPL-3.0-or-later","AMD-newlib","AMDPLPA","AML","AML-glslang","AMPAS","ANTLR-PD","ANTLR-PD-fallback","APAFML","APL-1.0","APSL-1.0","APSL-1.1","APSL-1.2","APSL-2.0","ASWF-Digital-Assets-1.0","ASWF-Digital-Assets-1.1","Abstyles","AdaCore-doc","Adobe-2006","Adobe-Display-PostScript","Adobe-Glyph","Adobe-Utopia","Afmparse","Aladdin","Apache-1.0","Apache-1.1","Apache-2.0","App-s2p","Arphic-1999","Artistic-1.0","Artistic-1.0-Perl","Artistic-1.0-cl8","Artistic-2.0","Artistic-dist","Aspell-RU","BSD-1-Clause","BSD-2-Clause","BSD-2-Clause-Darwin","BSD-2-Clause-Patent","BSD-2-Clause-Views","BSD-2-Clause-first-lines","BSD-2-Clause-pkgconf-disclaimer","BSD-3-Clause","BSD-3-Clause-Attribution","BSD-3-Clause-Clear","BSD-3-Clause-HP","BSD-3-Clause-LBNL","BSD-3-Clause-Modification","BSD-3-Clause-No-Military-License","BSD-3-Clause-No-Nuclear-License","BSD-3-Clause-No-Nuclear-License-2014","BSD-3-Clause-No-Nuclear-Warranty","BSD-3-Clause-Open-MPI","BSD-3-Clause-Sun","BSD-3-Clause-acpica","BSD-3-Clause-flex","BSD-4-Clause","BSD-4-Clause-Shortened","BSD-4-Clause-UC","BSD-4.3RENO","BSD-4.3TAHOE","BSD-Advertising-Acknowledgement","BSD-Attribution-HPND-disclaimer","BSD-Inferno-Nettverk","BSD-Protection","BSD-Source-Code","BSD-Source-beginning-file","BSD-Systemics","BSD-Systemics-W3Works","BSL-1.0","BUSL-1.1","Baekmuk","Bahyph","Barr","Beerware","BitTorrent-1.0","BitTorrent-1.1","Bitstream-Charter","Bitstream-Vera","BlueOak-1.0.0","Boehm-GC","Boehm-GC-without-fee","Borceux","Brian-Gladman-2-Clause","Brian-Gladman-3-Clause","C-UDA-1.0","CAL-1.0","CAL-1.0-Combined-Work-Exception","CATOSL-1.1","CC-BY-1.0","CC-BY-2.0","CC-BY-2.5","CC-BY-2.5-AU","CC-BY-3.0","CC-BY-3.0-AT","CC-BY-3.0-AU","CC-BY-3.0-DE","CC-BY-3.0-IGO","CC-BY-3.0-NL","CC-BY-3.0-US","CC-BY-4.0","CC-BY-NC-1.0","CC-BY-NC-2.0","CC-BY-NC-2.5","CC-BY-NC-3.0","CC-BY-NC-3.0-DE","CC-BY-NC-4.0","CC-BY-NC-ND-1.0","CC-BY-NC-ND-2.0","CC-BY-NC-ND-2.5","CC-BY-NC-ND-3.0","CC-BY-NC-ND-3.0-DE","CC-BY-NC-ND-3.0-IGO","CC-BY-NC-ND-4.0","CC-BY-NC-SA-1.0","CC-BY-NC-SA-2.0","CC-BY-NC-SA-2.0-DE","CC-BY-NC-SA-2.0-FR","CC-BY-NC-SA-2.0-UK","CC-BY-NC-SA-2.5","CC-BY-NC-SA-3.0","CC-BY-NC-SA-3.0-DE","CC-BY-NC-SA-3.0-IGO","CC-BY-NC-SA-4.0","CC-BY-ND-1.0","CC-BY-ND-2.0","CC-BY-ND-2.5","CC-BY-ND-3.0","CC-BY-ND-3.0-DE","CC-BY-ND-4.0","CC-BY-SA-1.0","CC-BY-SA-2.0","CC-BY-SA-2.0-UK","CC-BY-SA-2.1-JP","CC-BY-SA-2.5","CC-BY-SA-3.0","CC-BY-SA-3.0-AT","CC-BY-SA-3.0-DE","CC-BY-SA-3.0-IGO","CC-BY-SA-4.0","CC-PDDC","CC-PDM-1.0","CC-SA-1.0","CC0-1.0","CDDL-1.0","CDDL-1.1","CDL-1.0","CDLA-Permissive-1.0","CDLA-Permissive-2.0","CDLA-Sharing-1.0","CECILL-1.0","CECILL-1.1","CECILL-2.0","CECILL-2.1","CECILL-B","CECILL-C","CERN-OHL-1.1","CERN-OHL-1.2","CERN-OHL-P-2.0","CERN-OHL-S-2.0","CERN-OHL-W-2.0","CFITSIO","CMU-Mach","CMU-Mach-nodoc","CNRI-Jython","CNRI-Python","CNRI-Python-GPL-Compatible","COIL-1.0","CPAL-1.0","CPL-1.0","CPOL-1.02","CUA-OPL-1.0","Caldera","Caldera-no-preamble","Catharon","ClArtistic","Clips","Community-Spec-1.0","Condor-1.1","Cornell-Lossless-JPEG","Cronyx","Crossword","CryptoSwift","CrystalStacker","Cube","D-FSL-1.0","DEC-3-Clause","DL-DE-BY-2.0","DL-DE-ZERO-2.0","DOC","DRL-1.0","DRL-1.1","DSDP","DocBook-DTD","DocBook-Schema","DocBook-Stylesheet","DocBook-XML","Dotseqn","ECL-1.0","ECL-2.0","EFL-1.0","EFL-2.0","EPICS","EPL-1.0","EPL-2.0","EUDatagrid","EUPL-1.0","EUPL-1.1","EUPL-1.2","Elastic-2.0","Entessa","ErlPL-1.1","Eurosym","FBM","FDK-AAC","FSFAP","FSFAP-no-warranty-disclaimer","FSFUL","FSFULLR","FSFULLRSD","FSFULLRWD","FSL-1.1-ALv2","FSL-1.1-MIT","FTL","Fair","Ferguson-Twofish","Frameworx-1.0","FreeBSD-DOC","FreeImage","Furuseth","GCR-docs","GD","GFDL-1.1-invariants-only","GFDL-1.1-invariants-or-later","GFDL-1.1-no-invariants-only","GFDL-1.1-no-invariants-or-later","GFDL-1.1-only","GFDL-1.1-or-later","GFDL-1.2-invariants-only","GFDL-1.2-invariants-or-later","GFDL-1.2-no-invariants-only","GFDL-1.2-no-invariants-or-later","GFDL-1.2-only","GFDL-1.2-or-later","GFDL-1.3-invariants-only","GFDL-1.3-invariants-or-later","GFDL-1.3-no-invariants-only","GFDL-1.3-no-invariants-or-later","GFDL-1.3-only","GFDL-1.3-or-later","GL2PS","GLWTPL","GPL-1.0-only","GPL-1.0-or-later","GPL-2.0-only","GPL-2.0-or-later","GPL-3.0-only","GPL-3.0-or-later","Game-Programming-Gems","Giftware","Glide","Glulxe","Graphics-Gems","Gutmann","HDF5","HIDAPI","HP-1986","HP-1989","HPND","HPND-DEC","HPND-Fenneberg-Livingston","HPND-INRIA-IMAG","HPND-Intel","HPND-Kevlin-Henney","HPND-MIT-disclaimer","HPND-Markus-Kuhn","HPND-Netrek","HPND-Pbmplus","HPND-UC","HPND-UC-export-US","HPND-doc","HPND-doc-sell","HPND-export-US","HPND-export-US-acknowledgement","HPND-export-US-modify","HPND-export2-US","HPND-merchantability-variant","HPND-sell-MIT-disclaimer-xserver","HPND-sell-regexpr","HPND-sell-variant","HPND-sell-variant-MIT-disclaimer","HPND-sell-variant-MIT-disclaimer-rev","HTMLTIDY","HaskellReport","Hippocratic-2.1","IBM-pibs","ICU","IEC-Code-Components-EULA","IJG","IJG-short","IPA","IPL-1.0","ISC","ISC-Veillard","ImageMagick","Imlib2","Info-ZIP","Inner-Net-2.0","InnoSetup","Intel","Intel-ACPI","Interbase-1.0","JPL-image","JPNIC","JSON","Jam","JasPer-2.0","Kastrup","Kazlib","Knuth-CTAN","LAL-1.2","LAL-1.3","LGPL-2.0-only","LGPL-2.0-or-later","LGPL-2.1-only","LGPL-2.1-or-later","LGPL-3.0-only","LGPL-3.0-or-later","LGPLLR","LOOP","LPD-document","LPL-1.0","LPL-1.02","LPPL-1.0","LPPL-1.1","LPPL-1.2","LPPL-1.3a","LPPL-1.3c","LZMA-SDK-9.11-to-9.20","LZMA-SDK-9.22","Latex2e","Latex2e-translated-notice","Leptonica","LiLiQ-P-1.1","LiLiQ-R-1.1","LiLiQ-Rplus-1.1","Libpng","Linux-OpenIB","Linux-man-pages-1-para","Linux-man-pages-copyleft","Linux-man-pages-copyleft-2-para","Linux-man-pages-copyleft-var","Lucida-Bitmap-Fonts","MIPS","MIT","MIT-0","MIT-CMU","MIT-Click","MIT-Festival","MIT-Khronos-old","MIT-Modern-Variant","MIT-Wu","MIT-advertising","MIT-enna","MIT-feh","MIT-open-group","MIT-testregex","MITNFA","MMIXware","MPEG-SSG","MPL-1.0","MPL-1.1","MPL-2.0","MPL-2.0-no-copyleft-exception","MS-LPL","MS-PL","MS-RL","MTLL","Mackerras-3-Clause","Mackerras-3-Clause-acknowledgment","MakeIndex","Martin-Birgmeier","McPhee-slideshow","Minpack","MirOS","Motosoto","MulanPSL-1.0","MulanPSL-2.0","Multics","Mup","NAIST-2003","NASA-1.3","NBPL-1.0","NCBI-PD","NCGL-UK-2.0","NCL","NCSA","NGPL","NICTA-1.0","NIST-PD","NIST-PD-fallback","NIST-Software","NLOD-1.0","NLOD-2.0","NLPL","NOSL","NPL-1.0","NPL-1.1","NPOSL-3.0","NRL","NTIA-PD","NTP","NTP-0","Naumen","NetCDF","Newsletr","Nokia","Noweb","O-UDA-1.0","OAR","OCCT-PL","OCLC-2.0","ODC-By-1.0","ODbL-1.0","OFFIS","OFL-1.0","OFL-1.0-RFN","OFL-1.0-no-RFN","OFL-1.1","OFL-1.1-RFN","OFL-1.1-no-RFN","OGC-1.0","OGDL-Taiwan-1.0","OGL-Canada-2.0","OGL-UK-1.0","OGL-UK-2.0","OGL-UK-3.0","OGTSL","OLDAP-1.1","OLDAP-1.2","OLDAP-1.3","OLDAP-1.4","OLDAP-2.0","OLDAP-2.0.1","OLDAP-2.1","OLDAP-2.2","OLDAP-2.2.1","OLDAP-2.2.2","OLDAP-2.3","OLDAP-2.4","OLDAP-2.5","OLDAP-2.6","OLDAP-2.7","OLDAP-2.8","OLFL-1.3","OML","OPL-1.0","OPL-UK-3.0","OPUBL-1.0","OSET-PL-2.1","OSL-1.0","OSL-1.1","OSL-2.0","OSL-2.1","OSL-3.0","OpenPBS-2.3","OpenSSL","OpenSSL-standalone","OpenVision","PADL","PDDL-1.0","PHP-3.0","PHP-3.01","PPL","PSF-2.0","Parity-6.0.0","Parity-7.0.0","Pixar","Plexus","PolyForm-Noncommercial-1.0.0","PolyForm-Small-Business-1.0.0","PostgreSQL","Python-2.0","Python-2.0.1","QPL-1.0","QPL-1.0-INRIA-2004","Qhull","RHeCos-1.1","RPL-1.1","RPL-1.5","RPSL-1.0","RSA-MD","RSCPL","Rdisc","Ruby","Ruby-pty","SAX-PD","SAX-PD-2.0","SCEA","SGI-B-1.0","SGI-B-1.1","SGI-B-2.0","SGI-OpenGL","SGP4","SHL-0.5","SHL-0.51","SISSL","SISSL-1.2","SL","SMAIL-GPL","SMLNJ","SMPPL","SNIA","SOFA","SPL-1.0","SSH-OpenSSH","SSH-short","SSLeay-standalone","SSPL-1.0","SUL-1.0","SWL","Saxpath","SchemeReport","Sendmail","Sendmail-8.23","Sendmail-Open-Source-1.1","SimPL-2.0","Sleepycat","Soundex","Spencer-86","Spencer-94","Spencer-99","SugarCRM-1.1.3","Sun-PPP","Sun-PPP-2000","SunPro","Symlinks","TAPR-OHL-1.0","TCL","TCP-wrappers","TGPPL-1.0","TMate","TORQUE-1.1","TOSL","TPDL","TPL-1.0","TTWL","TTYP0","TU-Berlin-1.0","TU-Berlin-2.0","TermReadKey","ThirdEye","TrustedQSL","UCAR","UCL-1.0","UMich-Merit","UPL-1.0","URT-RLE","Ubuntu-font-1.0","Unicode-3.0","Unicode-DFS-2015","Unicode-DFS-2016","Unicode-TOU","UnixCrypt","Unlicense","Unlicense-libtelnet","Unlicense-libwhirlpool","VOSTROM","VSL-1.0","Vim","W3C","W3C-19980720","W3C-20150513","WTFPL","Watcom-1.0","Widget-Workshop","Wsuipa","X11","X11-distribute-modifications-variant","X11-swapped","XFree86-1.1","XSkat","Xdebug-1.03","Xerox","Xfig","Xnet","YPL-1.0","YPL-1.1","ZPL-1.1","ZPL-2.0","ZPL-2.1","Zed","Zeeff","Zend-2.0","Zimbra-1.3","Zimbra-1.4","Zlib","any-OSI","any-OSI-perl-modules","bcrypt-Solar-Designer","blessing","bzip2-1.0.6","check-cvs","checkmk","copyleft-next-0.3.0","copyleft-next-0.3.1","curl","cve-tou","diffmark","dtoa","dvipdfm","eGenix","etalab-2.0","fwlw","gSOAP-1.3b","generic-xts","gnuplot","gtkbook","hdparm","iMatix","jove","libpng-1.6.35","libpng-2.0","libselinux-1.0","libtiff","libutil-David-Nugent","lsof","magaz","mailprio","man2html","metamail","mpi-permissive","mpich2","mplus","ngrep","pkgconf","pnmstitch","psfrag","psutils","python-ldap","radvd","snprintf","softSurfer","ssh-keyscan","swrule","threeparttable","ulem","w3m","wwl","xinetd","xkeyboard-config-Zinoviev","xlock","xpp","xzoom","zlib-acknowledgement"],Ke=["AGPL-1.0","AGPL-3.0","BSD-2-Clause-FreeBSD","BSD-2-Clause-NetBSD","GFDL-1.1","GFDL-1.2","GFDL-1.3","GPL-1.0","GPL-2.0","GPL-2.0-with-GCC-exception","GPL-2.0-with-autoconf-exception","GPL-2.0-with-bison-exception","GPL-2.0-with-classpath-exception","GPL-2.0-with-font-exception","GPL-3.0","GPL-3.0-with-GCC-exception","GPL-3.0-with-autoconf-exception","LGPL-2.0","LGPL-2.1","LGPL-3.0","Net-SNMP","Nunit","StandardML-NJ","bzip2-1.0.5","eCos-2.0","wxWindows"],Ze=["389-exception","Asterisk-exception","Autoconf-exception-2.0","Autoconf-exception-3.0","Autoconf-exception-generic","Autoconf-exception-generic-3.0","Autoconf-exception-macro","Bison-exception-1.24","Bison-exception-2.2","Bootloader-exception","Classpath-exception-2.0","CLISP-exception-2.0","cryptsetup-OpenSSL-exception","DigiRule-FOSS-exception","eCos-exception-2.0","Fawkes-Runtime-exception","FLTK-exception","fmt-exception","Font-exception-2.0","freertos-exception-2.0","GCC-exception-2.0","GCC-exception-2.0-note","GCC-exception-3.1","Gmsh-exception","GNAT-exception","GNOME-examples-exception","GNU-compiler-exception","gnu-javamail-exception","GPL-3.0-interface-exception","GPL-3.0-linking-exception","GPL-3.0-linking-source-exception","GPL-CC-1.0","GStreamer-exception-2005","GStreamer-exception-2008","i2p-gpl-java-exception","KiCad-libraries-exception","LGPL-3.0-linking-exception","libpri-OpenH323-exception","Libtool-exception","Linux-syscall-note","LLGPL","LLVM-exception","LZMA-exception","mif-exception","OCaml-LGPL-linking-exception","OCCT-exception-1.0","OpenJDK-assembly-exception-1.0","openvpn-openssl-exception","PS-or-PDF-font-exception-20170817","QPL-1.0-INRIA-2004-exception","Qt-GPL-exception-1.0","Qt-LGPL-exception-1.1","Qwt-exception-1.0","SANE-exception","SHL-2.0","SHL-2.1","stunnel-exception","SWI-exception","Swift-exception","Texinfo-exception","u-boot-exception-2.0","UBDL-exception","Universal-FOSS-exception-1.0","vsftpd-openssl-exception","WxWindows-exception-3.1","x11vnc-openssl-exception"];function Xe(){if(Be)return ke;Be=1;var e=[].concat(Ye).concat(Ke),t=Ze;return ke=function(r){var n=0;function i(){return n<r.length}function o(e){if(e instanceof RegExp){var t=r.slice(n).match(e);if(t)return n+=t[0].length,t[0]}else if(r.indexOf(e,n)===n)return n+=e.length,e}function s(){o(/[ ]*/)}function a(){return o(/[A-Za-z0-9-.]+/)}function c(){var e=a();if(!e)throw new Error("Expected idstring at offset "+n);return e}function l(){return function(){for(var e,t=["WITH","AND","OR","(",")",":","+"],i=0;i<t.length&&!(e=o(t[i]));i++);if("+"===e&&n>1&&" "===r[n-2])throw new Error("Space before `+`");return e&&{type:"OPERATOR",string:e}}()||function(){if(o("DocumentRef-"))return{type:"DOCUMENTREF",string:c()}}()||function(){if(o("LicenseRef-"))return{type:"LICENSEREF",string:c()}}()||(i=n,s=a(),-1!==e.indexOf(s)?{type:"LICENSE",string:s}:-1!==t.indexOf(s)?{type:"EXCEPTION",string:s}:void(n=i));var i,s}for(var u=[];i()&&(s(),i());){var f=l();if(!f)throw new Error("Unexpected `"+r[n]+"` at offset "+n);u.push(f)}return u},ke}function Je(){return Ge||(Ge=1,Me=function(e){var t=0;function r(){return t<e.length}function n(){return r()?e[t]:null}function i(){if(!r())throw new Error;t++}function o(e){var t=n();if(t&&"OPERATOR"===t.type&&e===t.string)return i(),t.string}function s(){var e=n();if(e&&"LICENSE"===e.type){i();var t={license:e.string};o("+")&&(t.plus=!0);var r=function(){if(o("WITH")){var e=n();if(e&&"EXCEPTION"===e.type)return i(),e.string;throw new Error("Expected exception after `WITH`")}}();return r&&(t.exception=r),t}}function a(e,t){return function r(){var n=t();if(n){if(!o(e))return n;var i=r();if(!i)throw new Error("Expected expression");return{left:n,conjunction:e.toLowerCase(),right:i}}}}var c=a("AND",function(){return function(){if(o("(")){var e=l();if(!o(")"))throw new Error("Expected `)`");return e}}()||function(){var e=t,r="",s=n();if("DOCUMENTREF"===s.type&&(i(),r+="DocumentRef-"+s.string+":",!o(":")))throw new Error("Expected `:` after `DocumentRef-...`");if("LICENSEREF"===(s=n()).type)return i(),{license:r+="LicenseRef-"+s.string};t=e}()||s()}),l=a("OR",c),u=l();if(!u||r())throw new Error("Syntax error");return u}),Me}function Qe(){if(ze)return je;ze=1;var e=Xe(),t=Je();return je=function(r){return t(e(r))}}function et(){if(Ve)return We;Ve=1;var e=Qe(),t=function(){if(qe)return He;qe=1;var e=Qe(),t=Ye;function r(t){try{return e(t),!0}catch(e){return!1}}function n(e,t){var r=t[0].length-e[0].length;return 0!==r?r:e[0].toUpperCase().localeCompare(t[0].toUpperCase())}var i=[["APGL","AGPL"],["Gpl","GPL"],["GLP","GPL"],["APL","Apache"],["ISD","ISC"],["GLP","GPL"],["IST","ISC"],["Claude","Clause"],[" or later","+"],[" International",""],["GNU","GPL"],["GUN","GPL"],["+",""],["GNU GPL","GPL"],["GNU LGPL","LGPL"],["GNU/GPL","GPL"],["GNU GLP","GPL"],["GNU LESSER GENERAL PUBLIC LICENSE","LGPL"],["GNU Lesser General Public License","LGPL"],["GNU LESSER GENERAL PUBLIC LICENSE","LGPL-2.1"],["GNU Lesser General Public License","LGPL-2.1"],["LESSER GENERAL PUBLIC LICENSE","LGPL"],["Lesser General Public License","LGPL"],["LESSER GENERAL PUBLIC LICENSE","LGPL-2.1"],["Lesser General Public License","LGPL-2.1"],["GNU General Public License","GPL"],["Gnu public license","GPL"],["GNU Public License","GPL"],["GNU GENERAL PUBLIC LICENSE","GPL"],["MTI","MIT"],["Mozilla Public License","MPL"],["Universal Permissive License","UPL"],["WTH","WTF"],["WTFGPL","WTFPL"],["-License",""]].sort(n),o=[function(e){return e.toUpperCase()},function(e){return e.trim()},function(e){return e.replace(/\./g,"")},function(e){return e.replace(/\s+/g,"")},function(e){return e.replace(/\s+/g,"-")},function(e){return e.replace("v","-")},function(e){return e.replace(/,?\s*(\d)/,"-$1")},function(e){return e.replace(/,?\s*(\d)/,"-$1.0")},function(e){return e.replace(/,?\s*(V\.|v\.|V|v|Version|version)\s*(\d)/,"-$2")},function(e){return e.replace(/,?\s*(V\.|v\.|V|v|Version|version)\s*(\d)/,"-$2.0")},function(e){return e[0].toUpperCase()+e.slice(1)},function(e){return e.replace("/","-")},function(e){return e.replace(/\s*V\s*(\d)/,"-$1").replace(/(\d)$/,"$1.0")},function(e){return-1!==e.indexOf("3.0")?e+"-or-later":e+"-only"},function(e){return e+"only"},function(e){return e.replace(/(\d)$/,"-$1.0")},function(e){return e.replace(/(-| )?(\d)$/,"-$2-Clause")},function(e){return e.replace(/(-| )clause(-| )(\d)/,"-$3-Clause")},function(e){return e.replace(/\b(Modified|New|Revised)(-| )?BSD((-| )License)?/i,"BSD-3-Clause")},function(e){return e.replace(/\bSimplified(-| )?BSD((-| )License)?/i,"BSD-2-Clause")},function(e){return e.replace(/\b(Free|Net)(-| )?BSD((-| )License)?/i,"BSD-2-Clause-$1BSD")},function(e){return e.replace(/\bClear(-| )?BSD((-| )License)?/i,"BSD-3-Clause-Clear")},function(e){return e.replace(/\b(Old|Original)(-| )?BSD((-| )License)?/i,"BSD-4-Clause")},function(e){return"CC-"+e},function(e){return"CC-"+e+"-4.0"},function(e){return e.replace("Attribution","BY").replace("NonCommercial","NC").replace("NoDerivatives","ND").replace(/ (\d)/,"-$1").replace(/ ?International/,"")},function(e){return"CC-"+e.replace("Attribution","BY").replace("NonCommercial","NC").replace("NoDerivatives","ND").replace(/ (\d)/,"-$1").replace(/ ?International/,"")+"-4.0"}],s=t.map(function(e){var t=/^(.*)-\d+\.\d+$/.exec(e);return t?[t[0],t[1]]:[e,null]}).reduce(function(e,t){var r=t[1];return e[r]=e[r]||[],e[r].push(t[0]),e},{}),a=Object.keys(s).map(function(e){return[e,s[e]]}).filter(function(e){return 1===e[1].length&&null!==e[0]&&"APL"!==e[0]}).map(function(e){return[e[0],e[1][0]]});s=void 0;var c=[["UNLI","Unlicense"],["WTF","WTFPL"],["2 CLAUSE","BSD-2-Clause"],["2-CLAUSE","BSD-2-Clause"],["3 CLAUSE","BSD-3-Clause"],["3-CLAUSE","BSD-3-Clause"],["AFFERO","AGPL-3.0-or-later"],["AGPL","AGPL-3.0-or-later"],["APACHE","Apache-2.0"],["ARTISTIC","Artistic-2.0"],["Affero","AGPL-3.0-or-later"],["BEER","Beerware"],["BOOST","BSL-1.0"],["BSD","BSD-2-Clause"],["CDDL","CDDL-1.1"],["ECLIPSE","EPL-1.0"],["FUCK","WTFPL"],["GNU","GPL-3.0-or-later"],["LGPL","LGPL-3.0-or-later"],["GPLV1","GPL-1.0-only"],["GPL-1","GPL-1.0-only"],["GPLV2","GPL-2.0-only"],["GPL-2","GPL-2.0-only"],["GPL","GPL-3.0-or-later"],["MIT +NO-FALSE-ATTRIBS","MITNFA"],["MIT","MIT"],["MPL","MPL-2.0"],["X11","X11"],["ZLIB","Zlib"]].concat(a).sort(n),l=function(e){for(var t=0;t<o.length;t++){var n=o[t](e).trim();if(n!==e&&r(n))return n}return null},u=function(e){for(var t=e.toUpperCase(),r=0;r<c.length;r++){var n=c[r];if(t.indexOf(n[0])>-1)return n[1]}return null},f=function(e,t){for(var r=0;r<i.length;r++){var n=i[r],o=n[0];if(e.indexOf(o)>-1){var s=t(e.replace(o,n[1]));if(null!==s)return s}}return null};return He=function(e,t){var n=void 0===(t=t||{}).upgrade||!!t.upgrade;function i(e){return n?function(e){return-1!==["GPL-1.0","LGPL-1.0","AGPL-1.0","GPL-2.0","LGPL-2.0","AGPL-2.0","LGPL-2.1"].indexOf(e)?e+"-only":-1!==["GPL-1.0+","GPL-2.0+","GPL-3.0+","LGPL-2.0+","LGPL-2.1+","LGPL-3.0+","AGPL-1.0+","AGPL-3.0+"].indexOf(e)?e.replace(/\+$/,"-or-later"):-1!==["GPL-3.0","LGPL-3.0","AGPL-3.0"].indexOf(e)?e+"-or-later":e}(e):e}if("string"!=typeof e||0===e.trim().length)throw Error("Invalid argument. Expected non-empty string.");if(r(e=e.trim()))return i(e);var o=e.replace(/\+$/,"").trim();if(r(o))return i(o);var s=l(e);return null!==s||null!==(s=f(e,function(e){return r(e)?e:l(e)}))||null!==(s=u(e))||null!==(s=f(e,u))?i(s):null}}(),r='license should be a valid SPDX license expression (without "LicenseRef"), "UNLICENSED", or "SEE LICENSE IN <filename>"',n=/^SEE LICEN[CS]E IN (.+)$/;function i(e,t){return t.slice(0,e.length)===e}function o(e){if(e.hasOwnProperty("license")){var t=e.license;return i("LicenseRef",t)||i("DocumentRef",t)}return o(e.left)||o(e.right)}return We=function(i){var s;try{s=e(i)}catch(e){var a;if("UNLICENSED"===i||"UNLICENCED"===i)return{validForOldPackages:!0,validForNewPackages:!0,unlicensed:!0};if(a=n.exec(i))return{validForOldPackages:!0,validForNewPackages:!0,inFile:a[1]};var c={validForOldPackages:!1,validForNewPackages:!1,warnings:[r]};if(0!==i.trim().length){var l=t(i);l&&c.warnings.push('license is similar to the valid expression "'+l+'"')}return c}return o(s)?{validForNewPackages:!1,validForOldPackages:!1,spdx:!0,warnings:[r]}:{validForNewPackages:!0,validForOldPackages:!0,spdx:!0}}}var tt,rt,nt,it,ot,st,at,ct,lt,ut,ft,pt={};function ht(){if(tt)return pt;tt=1,Object.defineProperty(pt,"__esModule",{value:!0}),pt.LRUCache=void 0;const e="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,t=new Set,r="object"==typeof process&&process?process:{},n=(e,t,n,i)=>{"function"==typeof r.emitWarning?r.emitWarning(e,t,n,i):console.error(`[${n}] ${t}: ${e}`)};let i=globalThis.AbortController,o=globalThis.AbortSignal;if(void 0===i){o=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(e,t){this._onabort.push(t)}},i=class{constructor(){t()}signal=new o;abort(e){if(!this.signal.aborted){this.signal.reason=e,this.signal.aborted=!0;for(const t of this.signal._onabort)t(e);this.signal.onabort?.(e)}}};let e="1"!==r.env?.LRU_CACHE_IGNORE_AC_WARNING;const t=()=>{e&&(e=!1,n("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",t))}}const s=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),a=e=>s(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?c:null:null;class c extends Array{constructor(e){super(e),this.fill(0)}}class l{heap;length;static#e=!1;static create(e){const t=a(e);if(!t)return[];l.#e=!0;const r=new l(e,t);return l.#e=!1,r}constructor(e,t){if(!l.#e)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}}class u{#t;#r;#n;#i;#o;#s;#a;#c;get perf(){return this.#c}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#l;#u;#f;#p;#h;#d;#m;#g;#v;#y;#E;#b;#w;#L;#S;#C;#I;#D;static unsafeExposeInternals(e){return{starts:e.#w,ttls:e.#L,sizes:e.#b,keyMap:e.#f,keyList:e.#p,valList:e.#h,next:e.#d,prev:e.#m,get head(){return e.#g},get tail(){return e.#v},free:e.#y,isBackgroundFetch:t=>e.#O(t),backgroundFetch:(t,r,n,i)=>e.#N(t,r,n,i),moveToTail:t=>e.#A(t),indexes:t=>e.#P(t),rindexes:t=>e.#_(t),isStale:t=>e.#R(t)}}get max(){return this.#t}get maxSize(){return this.#r}get calculatedSize(){return this.#u}get size(){return this.#l}get fetchMethod(){return this.#s}get memoMethod(){return this.#a}get dispose(){return this.#n}get onInsert(){return this.#i}get disposeAfter(){return this.#o}constructor(r){const{max:i=0,ttl:o,ttlResolution:c=1,ttlAutopurge:f,updateAgeOnGet:p,updateAgeOnHas:h,allowStale:d,dispose:m,onInsert:g,disposeAfter:v,noDisposeOnSet:y,noUpdateTTL:E,maxSize:b=0,maxEntrySize:w=0,sizeCalculation:L,fetchMethod:S,memoMethod:C,noDeleteOnFetchRejection:I,noDeleteOnStaleGet:D,allowStaleOnFetchRejection:O,allowStaleOnFetchAbort:N,ignoreFetchAbort:A,perf:P}=r;if(void 0!==P&&"function"!=typeof P?.now)throw new TypeError("perf option must have a now() method if specified");if(this.#c=P??e,0!==i&&!s(i))throw new TypeError("max option must be a nonnegative integer");const _=i?a(i):Array;if(!_)throw new Error("invalid max value: "+i);if(this.#t=i,this.#r=b,this.maxEntrySize=w||this.#r,this.sizeCalculation=L,this.sizeCalculation){if(!this.#r&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if("function"!=typeof this.sizeCalculation)throw new TypeError("sizeCalculation set to non-function")}if(void 0!==C&&"function"!=typeof C)throw new TypeError("memoMethod must be a function if defined");if(this.#a=C,void 0!==S&&"function"!=typeof S)throw new TypeError("fetchMethod must be a function if specified");if(this.#s=S,this.#C=!!S,this.#f=new Map,this.#p=new Array(i).fill(void 0),this.#h=new Array(i).fill(void 0),this.#d=new _(i),this.#m=new _(i),this.#g=0,this.#v=0,this.#y=l.create(i),this.#l=0,this.#u=0,"function"==typeof m&&(this.#n=m),"function"==typeof g&&(this.#i=g),"function"==typeof v?(this.#o=v,this.#E=[]):(this.#o=void 0,this.#E=void 0),this.#S=!!this.#n,this.#D=!!this.#i,this.#I=!!this.#o,this.noDisposeOnSet=!!y,this.noUpdateTTL=!!E,this.noDeleteOnFetchRejection=!!I,this.allowStaleOnFetchRejection=!!O,this.allowStaleOnFetchAbort=!!N,this.ignoreFetchAbort=!!A,0!==this.maxEntrySize){if(0!==this.#r&&!s(this.#r))throw new TypeError("maxSize must be a positive integer if specified");if(!s(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#T()}if(this.allowStale=!!d,this.noDeleteOnStaleGet=!!D,this.updateAgeOnGet=!!p,this.updateAgeOnHas=!!h,this.ttlResolution=s(c)||0===c?c:1,this.ttlAutopurge=!!f,this.ttl=o||0,this.ttl){if(!s(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#x()}if(0===this.#t&&0===this.ttl&&0===this.#r)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#t&&!this.#r){const e="LRU_CACHE_UNBOUNDED";if((e=>!t.has(e))(e)){t.add(e);n("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",e,u)}}}getRemainingTTL(e){return this.#f.has(e)?1/0:0}#x(){const e=new c(this.#t),t=new c(this.#t);this.#L=e,this.#w=t,this.#$=(r,n,i=this.#c.now())=>{if(t[r]=0!==n?i:0,e[r]=n,0!==n&&this.ttlAutopurge){const e=setTimeout(()=>{this.#R(r)&&this.#F(this.#p[r],"expire")},n+1);e.unref&&e.unref()}},this.#U=r=>{t[r]=0!==e[r]?this.#c.now():0},this.#k=(i,o)=>{if(e[o]){const s=e[o],a=t[o];if(!s||!a)return;i.ttl=s,i.start=a,i.now=r||n();const c=i.now-a;i.remainingTTL=s-c}};let r=0;const n=()=>{const e=this.#c.now();if(this.ttlResolution>0){r=e;const t=setTimeout(()=>r=0,this.ttlResolution);t.unref&&t.unref()}return e};this.getRemainingTTL=i=>{const o=this.#f.get(i);if(void 0===o)return 0;const s=e[o],a=t[o];if(!s||!a)return 1/0;return s-((r||n())-a)},this.#R=i=>{const o=t[i],s=e[i];return!!s&&!!o&&(r||n())-o>s}}#U=()=>{};#k=()=>{};#$=()=>{};#R=()=>!1;#T(){const e=new c(this.#t);this.#u=0,this.#b=e,this.#B=t=>{this.#u-=e[t],e[t]=0},this.#M=(e,t,r,n)=>{if(this.#O(t))return 0;if(!s(r)){if(!n)throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");if("function"!=typeof n)throw new TypeError("sizeCalculation must be a function");if(r=n(t,e),!s(r))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return r},this.#G=(t,r,n)=>{if(e[t]=r,this.#r){const r=this.#r-e[t];for(;this.#u>r;)this.#j(!0)}this.#u+=e[t],n&&(n.entrySize=r,n.totalCalculatedSize=this.#u)}}#B=e=>{};#G=(e,t,r)=>{};#M=(e,t,r,n)=>{if(r||n)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#P({allowStale:e=this.allowStale}={}){if(this.#l)for(let t=this.#v;this.#z(t)&&(!e&&this.#R(t)||(yield t),t!==this.#g);)t=this.#m[t]}*#_({allowStale:e=this.allowStale}={}){if(this.#l)for(let t=this.#g;this.#z(t)&&(!e&&this.#R(t)||(yield t),t!==this.#v);)t=this.#d[t]}#z(e){return void 0!==e&&this.#f.get(this.#p[e])===e}*entries(){for(const e of this.#P())void 0===this.#h[e]||void 0===this.#p[e]||this.#O(this.#h[e])||(yield[this.#p[e],this.#h[e]])}*rentries(){for(const e of this.#_())void 0===this.#h[e]||void 0===this.#p[e]||this.#O(this.#h[e])||(yield[this.#p[e],this.#h[e]])}*keys(){for(const e of this.#P()){const t=this.#p[e];void 0===t||this.#O(this.#h[e])||(yield t)}}*rkeys(){for(const e of this.#_()){const t=this.#p[e];void 0===t||this.#O(this.#h[e])||(yield t)}}*values(){for(const e of this.#P()){void 0===this.#h[e]||this.#O(this.#h[e])||(yield this.#h[e])}}*rvalues(){for(const e of this.#_()){void 0===this.#h[e]||this.#O(this.#h[e])||(yield this.#h[e])}}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,t={}){for(const r of this.#P()){const n=this.#h[r],i=this.#O(n)?n.__staleWhileFetching:n;if(void 0!==i&&e(i,this.#p[r],this))return this.get(this.#p[r],t)}}forEach(e,t=this){for(const r of this.#P()){const n=this.#h[r],i=this.#O(n)?n.__staleWhileFetching:n;void 0!==i&&e.call(t,i,this.#p[r],this)}}rforEach(e,t=this){for(const r of this.#_()){const n=this.#h[r],i=this.#O(n)?n.__staleWhileFetching:n;void 0!==i&&e.call(t,i,this.#p[r],this)}}purgeStale(){let e=!1;for(const t of this.#_({allowStale:!0}))this.#R(t)&&(this.#F(this.#p[t],"expire"),e=!0);return e}info(e){const t=this.#f.get(e);if(void 0===t)return;const r=this.#h[t],n=this.#O(r)?r.__staleWhileFetching:r;if(void 0===n)return;const i={value:n};if(this.#L&&this.#w){const e=this.#L[t],r=this.#w[t];if(e&&r){const t=e-(this.#c.now()-r);i.ttl=t,i.start=Date.now()}}return this.#b&&(i.size=this.#b[t]),i}dump(){const e=[];for(const t of this.#P({allowStale:!0})){const r=this.#p[t],n=this.#h[t],i=this.#O(n)?n.__staleWhileFetching:n;if(void 0===i||void 0===r)continue;const o={value:i};if(this.#L&&this.#w){o.ttl=this.#L[t];const e=this.#c.now()-this.#w[t];o.start=Math.floor(Date.now()-e)}this.#b&&(o.size=this.#b[t]),e.unshift([r,o])}return e}load(e){this.clear();for(const[t,r]of e){if(r.start){const e=Date.now()-r.start;r.start=this.#c.now()-e}this.set(t,r.value,r)}}set(e,t,r={}){if(void 0===t)return this.delete(e),this;const{ttl:n=this.ttl,start:i,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:s=this.sizeCalculation,status:a}=r;let{noUpdateTTL:c=this.noUpdateTTL}=r;const l=this.#M(e,t,r.size||0,s);if(this.maxEntrySize&&l>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.#F(e,"set"),this;let u=0===this.#l?void 0:this.#f.get(e);if(void 0===u)u=0===this.#l?this.#v:0!==this.#y.length?this.#y.pop():this.#l===this.#t?this.#j(!1):this.#l,this.#p[u]=e,this.#h[u]=t,this.#f.set(e,u),this.#d[this.#v]=u,this.#m[u]=this.#v,this.#v=u,this.#l++,this.#G(u,l,a),a&&(a.set="add"),c=!1,this.#D&&this.#i?.(t,e,"add");else{this.#A(u);const r=this.#h[u];if(t!==r){if(this.#C&&this.#O(r)){r.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:t}=r;void 0===t||o||(this.#S&&this.#n?.(t,e,"set"),this.#I&&this.#E?.push([t,e,"set"]))}else o||(this.#S&&this.#n?.(r,e,"set"),this.#I&&this.#E?.push([r,e,"set"]));if(this.#B(u),this.#G(u,l,a),this.#h[u]=t,a){a.set="replace";const e=r&&this.#O(r)?r.__staleWhileFetching:r;void 0!==e&&(a.oldValue=e)}}else a&&(a.set="update");this.#D&&this.onInsert?.(t,e,t===r?"update":"replace")}if(0===n||this.#L||this.#x(),this.#L&&(c||this.#$(u,n,i),a&&this.#k(a,u)),!o&&this.#I&&this.#E){const e=this.#E;let t;for(;t=e?.shift();)this.#o?.(...t)}return this}pop(){try{for(;this.#l;){const e=this.#h[this.#g];if(this.#j(!0),this.#O(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(void 0!==e)return e}}finally{if(this.#I&&this.#E){const e=this.#E;let t;for(;t=e?.shift();)this.#o?.(...t)}}}#j(e){const t=this.#g,r=this.#p[t],n=this.#h[t];return this.#C&&this.#O(n)?n.__abortController.abort(new Error("evicted")):(this.#S||this.#I)&&(this.#S&&this.#n?.(n,r,"evict"),this.#I&&this.#E?.push([n,r,"evict"])),this.#B(t),e&&(this.#p[t]=void 0,this.#h[t]=void 0,this.#y.push(t)),1===this.#l?(this.#g=this.#v=0,this.#y.length=0):this.#g=this.#d[t],this.#f.delete(r),this.#l--,t}has(e,t={}){const{updateAgeOnHas:r=this.updateAgeOnHas,status:n}=t,i=this.#f.get(e);if(void 0!==i){const e=this.#h[i];if(this.#O(e)&&void 0===e.__staleWhileFetching)return!1;if(!this.#R(i))return r&&this.#U(i),n&&(n.has="hit",this.#k(n,i)),!0;n&&(n.has="stale",this.#k(n,i))}else n&&(n.has="miss");return!1}peek(e,t={}){const{allowStale:r=this.allowStale}=t,n=this.#f.get(e);if(void 0===n||!r&&this.#R(n))return;const i=this.#h[n];return this.#O(i)?i.__staleWhileFetching:i}#N(e,t,r,n){const o=void 0===t?void 0:this.#h[t];if(this.#O(o))return o;const s=new i,{signal:a}=r;a?.addEventListener("abort",()=>s.abort(a.reason),{signal:s.signal});const c={signal:s.signal,options:r,context:n},l=(n,i=!1)=>{const{aborted:o}=s.signal,a=r.ignoreFetchAbort&&void 0!==n;if(r.status&&(o&&!i?(r.status.fetchAborted=!0,r.status.fetchError=s.signal.reason,a&&(r.status.fetchAbortIgnored=!0)):r.status.fetchResolved=!0),o&&!a&&!i)return u(s.signal.reason);const l=f;return this.#h[t]===f&&(void 0===n?void 0!==l.__staleWhileFetching?this.#h[t]=l.__staleWhileFetching:this.#F(e,"fetch"):(r.status&&(r.status.fetchUpdated=!0),this.set(e,n,c.options))),n},u=n=>{const{aborted:i}=s.signal,o=i&&r.allowStaleOnFetchAbort,a=o||r.allowStaleOnFetchRejection,c=a||r.noDeleteOnFetchRejection,l=f;if(this.#h[t]===f){!c||void 0===l.__staleWhileFetching?this.#F(e,"fetch"):o||(this.#h[t]=l.__staleWhileFetching)}if(a)return r.status&&void 0!==l.__staleWhileFetching&&(r.status.returnedStale=!0),l.__staleWhileFetching;if(l.__returned===l)throw n};r.status&&(r.status.fetchDispatched=!0);const f=new Promise((t,n)=>{const i=this.#s?.(e,o,c);i&&i instanceof Promise&&i.then(e=>t(void 0===e?void 0:e),n),s.signal.addEventListener("abort",()=>{r.ignoreFetchAbort&&!r.allowStaleOnFetchAbort||(t(void 0),r.allowStaleOnFetchAbort&&(t=e=>l(e,!0)))})}).then(l,e=>(r.status&&(r.status.fetchRejected=!0,r.status.fetchError=e),u(e))),p=Object.assign(f,{__abortController:s,__staleWhileFetching:o,__returned:void 0});return void 0===t?(this.set(e,p,{...c.options,status:void 0}),t=this.#f.get(e)):this.#h[t]=p,p}#O(e){if(!this.#C)return!1;const t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof i}async fetch(e,t={}){const{allowStale:r=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:s=this.noDisposeOnSet,size:a=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:l=this.noUpdateTTL,noDeleteOnFetchRejection:u=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:f=this.allowStaleOnFetchRejection,ignoreFetchAbort:p=this.ignoreFetchAbort,allowStaleOnFetchAbort:h=this.allowStaleOnFetchAbort,context:d,forceRefresh:m=!1,status:g,signal:v}=t;if(!this.#C)return g&&(g.fetch="get"),this.get(e,{allowStale:r,updateAgeOnGet:n,noDeleteOnStaleGet:i,status:g});const y={allowStale:r,updateAgeOnGet:n,noDeleteOnStaleGet:i,ttl:o,noDisposeOnSet:s,size:a,sizeCalculation:c,noUpdateTTL:l,noDeleteOnFetchRejection:u,allowStaleOnFetchRejection:f,allowStaleOnFetchAbort:h,ignoreFetchAbort:p,status:g,signal:v};let E=this.#f.get(e);if(void 0===E){g&&(g.fetch="miss");const t=this.#N(e,E,y,d);return t.__returned=t}{const t=this.#h[E];if(this.#O(t)){const e=r&&void 0!==t.__staleWhileFetching;return g&&(g.fetch="inflight",e&&(g.returnedStale=!0)),e?t.__staleWhileFetching:t.__returned=t}const i=this.#R(E);if(!m&&!i)return g&&(g.fetch="hit"),this.#A(E),n&&this.#U(E),g&&this.#k(g,E),t;const o=this.#N(e,E,y,d),s=void 0!==o.__staleWhileFetching&&r;return g&&(g.fetch=i?"stale":"refresh",s&&i&&(g.returnedStale=!0)),s?o.__staleWhileFetching:o.__returned=o}}async forceFetch(e,t={}){const r=await this.fetch(e,t);if(void 0===r)throw new Error("fetch() returned undefined");return r}memo(e,t={}){const r=this.#a;if(!r)throw new Error("no memoMethod provided to constructor");const{context:n,forceRefresh:i,...o}=t,s=this.get(e,o);if(!i&&void 0!==s)return s;const a=r(e,s,{options:o,context:n});return this.set(e,a,o),a}get(e,t={}){const{allowStale:r=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,status:o}=t,s=this.#f.get(e);if(void 0!==s){const t=this.#h[s],a=this.#O(t);return o&&this.#k(o,s),this.#R(s)?(o&&(o.get="stale"),a?(o&&r&&void 0!==t.__staleWhileFetching&&(o.returnedStale=!0),r?t.__staleWhileFetching:void 0):(i||this.#F(e,"expire"),o&&r&&(o.returnedStale=!0),r?t:void 0)):(o&&(o.get="hit"),a?t.__staleWhileFetching:(this.#A(s),n&&this.#U(s),t))}o&&(o.get="miss")}#H(e,t){this.#m[t]=e,this.#d[e]=t}#A(e){e!==this.#v&&(e===this.#g?this.#g=this.#d[e]:this.#H(this.#m[e],this.#d[e]),this.#H(this.#v,e),this.#v=e)}delete(e){return this.#F(e,"delete")}#F(e,t){let r=!1;if(0!==this.#l){const n=this.#f.get(e);if(void 0!==n)if(r=!0,1===this.#l)this.#q(t);else{this.#B(n);const r=this.#h[n];if(this.#O(r)?r.__abortController.abort(new Error("deleted")):(this.#S||this.#I)&&(this.#S&&this.#n?.(r,e,t),this.#I&&this.#E?.push([r,e,t])),this.#f.delete(e),this.#p[n]=void 0,this.#h[n]=void 0,n===this.#v)this.#v=this.#m[n];else if(n===this.#g)this.#g=this.#d[n];else{const e=this.#m[n];this.#d[e]=this.#d[n];const t=this.#d[n];this.#m[t]=this.#m[n]}this.#l--,this.#y.push(n)}}if(this.#I&&this.#E?.length){const e=this.#E;let t;for(;t=e?.shift();)this.#o?.(...t)}return r}clear(){return this.#q("delete")}#q(e){for(const t of this.#_({allowStale:!0})){const r=this.#h[t];if(this.#O(r))r.__abortController.abort(new Error("deleted"));else{const n=this.#p[t];this.#S&&this.#n?.(r,n,e),this.#I&&this.#E?.push([r,n,e])}}if(this.#f.clear(),this.#h.fill(void 0),this.#p.fill(void 0),this.#L&&this.#w&&(this.#L.fill(0),this.#w.fill(0)),this.#b&&this.#b.fill(0),this.#g=0,this.#v=0,this.#y.length=0,this.#u=0,this.#l=0,this.#I&&this.#E){const e=this.#E;let t;for(;t=e?.shift();)this.#o?.(...t)}}}return pt.LRUCache=u,pt}function dt(){if(ot)return it;ot=1;const e=p,t=(e,t,r)=>{const n=e.indexOf(r);return e.lastIndexOf(t,n>-1?n:1/0)},r=t=>{try{return new e.URL(t)}catch{}};return it=(e,n)=>{const i=n?((e,t)=>{const r=e.indexOf(":"),n=e.slice(0,r+1);if(Object.prototype.hasOwnProperty.call(t,n))return e;const i=e.indexOf("@");return i>-1?i>r?`git+ssh://${e}`:e:e.indexOf("//")===r+1?e:`${e.slice(0,r+1)}//${e.slice(r+1)}`})(e,n):e;return r(i)||r((e=>{const r=t(e,"@","#"),n=t(e,":","#");return n>r&&(e=e.slice(0,n)+"/"+e.slice(n+1)),-1===t(e,":","#")&&-1===e.indexOf("//")&&(e=`git+ssh://${e}`),e})(i))},it}function mt(){if(at)return st;at=1;const e=dt();return st=(t,r,{gitHosts:n,protocols:i})=>{if(!t)return;const o=(e=>{const t=e.indexOf("#"),r=e.indexOf("/"),n=e.indexOf("/",r+1),i=e.indexOf(":"),o=/\s/.exec(e),s=e.indexOf("@"),a=!o||t>-1&&o.index>t,c=-1===s||t>-1&&s>t,l=-1===i||t>-1&&i>t,u=-1===n||t>-1&&n>t,f=r>0,p=t>-1?"/"!==e[t-1]:!e.endsWith("/"),h=!e.startsWith(".");return a&&f&&p&&h&&c&&l&&u})(t)?`github:${t}`:t,s=e(o,i);if(!s)return;const a=n.byShortcut[s.protocol],c=n.byDomain[s.hostname.startsWith("www.")?s.hostname.slice(4):s.hostname],l=a||c;if(!l)return;const u=n[a||c];let f=null;i[s.protocol]?.auth&&(s.username||s.password)&&(f=`${s.username}${s.password?":"+s.password:""}`);let p=null,h=null,d=null,m=null;try{if(a){let e=s.pathname.startsWith("/")?s.pathname.slice(1):s.pathname;const t=e.indexOf("@");t>-1&&(e=e.slice(t+1));const r=e.lastIndexOf("/");r>-1?(h=decodeURIComponent(e.slice(0,r)),h||(h=null),d=decodeURIComponent(e.slice(r+1))):d=decodeURIComponent(e),d.endsWith(".git")&&(d=d.slice(0,-4)),s.hash&&(p=decodeURIComponent(s.hash.slice(1))),m="shortcut"}else{if(!u.protocols.includes(s.protocol))return;const e=u.extract(s);if(!e)return;h=e.user&&decodeURIComponent(e.user),d=decodeURIComponent(e.project),p=decodeURIComponent(e.committish),m=i[s.protocol]?.name||s.protocol.slice(0,-1)}}catch(e){if(e instanceof URIError)return;throw e}return[l,h,f,d,p,m,r]}}function gt(){if(lt)return ct;lt=1;const{LRUCache:e}=ht(),t=function(){if(nt)return rt;nt=1;const e=(...e)=>e.every(e=>e)?e.join(""):"",t=e=>e?encodeURIComponent(e):"",r=e=>e.toLowerCase().replace(/^\W+/g,"").replace(/(?<!\W)\W+$/,"").replace(/\//g,"").replace(/\W+/g,"-"),n={sshtemplate:({domain:t,user:r,project:n,committish:i})=>`git@${t}:${r}/${n}.git${e("#",i)}`,sshurltemplate:({domain:t,user:r,project:n,committish:i})=>`git+ssh://git@${t}/${r}/${n}.git${e("#",i)}`,edittemplate:({domain:r,user:n,project:i,committish:o,editpath:s,path:a})=>`https://${r}/${n}/${i}${e("/",s,"/",t(o||"HEAD"),"/",a)}`,browsetemplate:({domain:r,user:n,project:i,committish:o,treepath:s})=>`https://${r}/${n}/${i}${e("/",s,"/",t(o))}`,browsetreetemplate:({domain:r,user:n,project:i,committish:o,treepath:s,path:a,fragment:c,hashformat:l})=>`https://${r}/${n}/${i}/${s}/${t(o||"HEAD")}/${a}${e("#",l(c||""))}`,browseblobtemplate:({domain:r,user:n,project:i,committish:o,blobpath:s,path:a,fragment:c,hashformat:l})=>`https://${r}/${n}/${i}/${s}/${t(o||"HEAD")}/${a}${e("#",l(c||""))}`,docstemplate:({domain:r,user:n,project:i,treepath:o,committish:s})=>`https://${r}/${n}/${i}${e("/",o,"/",t(s))}#readme`,httpstemplate:({auth:t,domain:r,user:n,project:i,committish:o})=>`git+https://${e(t,"@")}${r}/${n}/${i}.git${e("#",o)}`,filetemplate:({domain:e,user:r,project:n,committish:i,path:o})=>`https://${e}/${r}/${n}/raw/${t(i||"HEAD")}/${o}`,shortcuttemplate:({type:t,user:r,project:n,committish:i})=>`${t}:${r}/${n}${e("#",i)}`,pathtemplate:({user:t,project:r,committish:n})=>`${t}/${r}${e("#",n)}`,bugstemplate:({domain:e,user:t,project:r})=>`https://${e}/${t}/${r}/issues`,hashformat:r},i={};i.github={protocols:["git:","http:","git+ssh:","git+https:","ssh:","https:"],domain:"github.com",treepath:"tree",blobpath:"blob",editpath:"edit",filetemplate:({auth:r,user:n,project:i,committish:o,path:s})=>`https://${e(r,"@")}raw.githubusercontent.com/${n}/${i}/${t(o||"HEAD")}/${s}`,gittemplate:({auth:t,domain:r,user:n,project:i,committish:o})=>`git://${e(t,"@")}${r}/${n}/${i}.git${e("#",o)}`,tarballtemplate:({domain:e,user:r,project:n,committish:i})=>`https://codeload.${e}/${r}/${n}/tar.gz/${t(i||"HEAD")}`,extract:e=>{let[,t,r,n,i]=e.pathname.split("/",5);if((!n||"tree"===n)&&(n||(i=e.hash.slice(1)),r&&r.endsWith(".git")&&(r=r.slice(0,-4)),t&&r))return{user:t,project:r,committish:i}}},i.bitbucket={protocols:["git+ssh:","git+https:","ssh:","https:"],domain:"bitbucket.org",treepath:"src",blobpath:"src",editpath:"?mode=edit",edittemplate:({domain:r,user:n,project:i,committish:o,treepath:s,path:a,editpath:c})=>`https://${r}/${n}/${i}${e("/",s,"/",t(o||"HEAD"),"/",a,c)}`,tarballtemplate:({domain:e,user:r,project:n,committish:i})=>`https://${e}/${r}/${n}/get/${t(i||"HEAD")}.tar.gz`,extract:e=>{let[,t,r,n]=e.pathname.split("/",4);if(!["get"].includes(n)&&(r&&r.endsWith(".git")&&(r=r.slice(0,-4)),t&&r))return{user:t,project:r,committish:e.hash.slice(1)}}},i.gitlab={protocols:["git+ssh:","git+https:","ssh:","https:"],domain:"gitlab.com",treepath:"tree",blobpath:"tree",editpath:"-/edit",httpstemplate:({auth:t,domain:r,user:n,project:i,committish:o})=>`git+https://${e(t,"@")}${r}/${n}/${i}.git${e("#",o)}`,tarballtemplate:({domain:e,user:r,project:n,committish:i})=>`https://${e}/${r}/${n}/repository/archive.tar.gz?ref=${t(i||"HEAD")}`,extract:e=>{const t=e.pathname.slice(1);if(t.includes("/-/")||t.includes("/archive.tar.gz"))return;const r=t.split("/");let n=r.pop();n.endsWith(".git")&&(n=n.slice(0,-4));const i=r.join("/");return i&&n?{user:i,project:n,committish:e.hash.slice(1)}:void 0}},i.gist={protocols:["git:","git+ssh:","git+https:","ssh:","https:"],domain:"gist.github.com",editpath:"edit",sshtemplate:({domain:t,project:r,committish:n})=>`git@${t}:${r}.git${e("#",n)}`,sshurltemplate:({domain:t,project:r,committish:n})=>`git+ssh://git@${t}/${r}.git${e("#",n)}`,edittemplate:({domain:r,user:n,project:i,committish:o,editpath:s})=>`https://${r}/${n}/${i}${e("/",t(o))}/${s}`,browsetemplate:({domain:r,project:n,committish:i})=>`https://${r}/${n}${e("/",t(i))}`,browsetreetemplate:({domain:r,project:n,committish:i,path:o,hashformat:s})=>`https://${r}/${n}${e("/",t(i))}${e("#",s(o))}`,browseblobtemplate:({domain:r,project:n,committish:i,path:o,hashformat:s})=>`https://${r}/${n}${e("/",t(i))}${e("#",s(o))}`,docstemplate:({domain:r,project:n,committish:i})=>`https://${r}/${n}${e("/",t(i))}`,httpstemplate:({domain:t,project:r,committish:n})=>`git+https://${t}/${r}.git${e("#",n)}`,filetemplate:({user:r,project:n,committish:i,path:o})=>`https://gist.githubusercontent.com/${r}/${n}/raw${e("/",t(i))}/${o}`,shortcuttemplate:({type:t,project:r,committish:n})=>`${t}:${r}${e("#",n)}`,pathtemplate:({project:t,committish:r})=>`${t}${e("#",r)}`,bugstemplate:({domain:e,project:t})=>`https://${e}/${t}`,gittemplate:({domain:t,project:r,committish:n})=>`git://${t}/${r}.git${e("#",n)}`,tarballtemplate:({project:e,committish:r})=>`https://codeload.github.com/gist/${e}/tar.gz/${t(r||"HEAD")}`,extract:e=>{let[,t,r,n]=e.pathname.split("/",4);if("raw"!==n){if(!r){if(!t)return;r=t,t=null}return r.endsWith(".git")&&(r=r.slice(0,-4)),{user:t,project:r,committish:e.hash.slice(1)}}},hashformat:function(e){return e&&"file-"+r(e)}},i.sourcehut={protocols:["git+ssh:","https:"],domain:"git.sr.ht",treepath:"tree",blobpath:"tree",filetemplate:({domain:e,user:r,project:n,committish:i,path:o})=>`https://${e}/${r}/${n}/blob/${t(i)||"HEAD"}/${o}`,httpstemplate:({domain:t,user:r,project:n,committish:i})=>`https://${t}/${r}/${n}.git${e("#",i)}`,tarballtemplate:({domain:e,user:r,project:n,committish:i})=>`https://${e}/${r}/${n}/archive/${t(i)||"HEAD"}.tar.gz`,bugstemplate:()=>null,extract:e=>{let[,t,r,n]=e.pathname.split("/",4);if(!["archive"].includes(n)&&(r&&r.endsWith(".git")&&(r=r.slice(0,-4)),t&&r))return{user:t,project:r,committish:e.hash.slice(1)}}};for(const[e,t]of Object.entries(i))i[e]=Object.assign({},n,t);return rt=i}(),r=mt(),n=dt(),i=new e({max:1e3});class o{constructor(e,t,r,n,i,s,a={}){Object.assign(this,o.#W[e],{type:e,user:t,auth:r,project:n,committish:i,default:s,opts:a})}static#W={byShortcut:{},byDomain:{}};static#V={"git+ssh:":{name:"sshurl"},"ssh:":{name:"sshurl"},"git+https:":{name:"https",auth:!0},"git:":{auth:!0},"http:":{auth:!0},"https:":{auth:!0},"git+http:":{auth:!0}};static addHost(e,t){o.#W[e]=t,o.#W.byDomain[t.domain]=e,o.#W.byShortcut[`${e}:`]=e,o.#V[`${e}:`]={name:e}}static fromUrl(e,t){if("string"!=typeof e)return;const n=e+JSON.stringify(t||{});if(!i.has(n)){const s=r(e,t,{gitHosts:o.#W,protocols:o.#V});i.set(n,s?new o(...s):void 0)}return i.get(n)}static fromManifest(e,t={}){if(!e||"object"!=typeof e)return;const r=e.repository,n=r&&("string"==typeof r?r:"object"==typeof r&&"string"==typeof r.url?r.url:null);if(!n)throw new Error("no repository");const i=n&&o.fromUrl(n.replace(/^git\+/,""),t)||null;if(i)return i;const s=function(e){try{const{protocol:t,hostname:r,pathname:n}=new URL(e);if(!r)return null;return`${/(?:git\+)http:$/.test(t)?"http:":"https:"}//${r}${n.replace(/\.git$/,"")}`}catch{return null}}(n);return o.fromUrl(s,t)||s}static parseUrl(e){return n(e)}#Y(e,t){if("function"!=typeof e)return null;const r={...this,...this.opts,...t};r.path||(r.path=""),r.path.startsWith("/")&&(r.path=r.path.slice(1)),r.noCommittish&&(r.committish=null);const n=e(r);return r.noGitPlus&&n.startsWith("git+")?n.slice(4):n}hash(){return this.committish?`#${this.committish}`:""}ssh(e){return this.#Y(this.sshtemplate,e)}sshurl(e){return this.#Y(this.sshurltemplate,e)}browse(e,...t){return"string"!=typeof e?this.#Y(this.browsetemplate,e):"string"!=typeof t[0]?this.#Y(this.browsetreetemplate,{...t[0],path:e}):this.#Y(this.browsetreetemplate,{...t[1],fragment:t[0],path:e})}browseFile(e,...t){return"string"!=typeof t[0]?this.#Y(this.browseblobtemplate,{...t[0],path:e}):this.#Y(this.browseblobtemplate,{...t[1],fragment:t[0],path:e})}docs(e){return this.#Y(this.docstemplate,e)}bugs(e){return this.#Y(this.bugstemplate,e)}https(e){return this.#Y(this.httpstemplate,e)}git(e){return this.#Y(this.gittemplate,e)}shortcut(e){return this.#Y(this.shortcuttemplate,e)}path(e){return this.#Y(this.pathtemplate,e)}tarball(e){return this.#Y(this.tarballtemplate,{...e,noCommittish:!1})}file(e,t){return this.#Y(this.filetemplate,{...t,path:e})}edit(e,t){return this.#Y(this.edittemplate,{...t,path:e})}getDefaultRepresentation(){return this.default}toString(e){return this.default&&"function"==typeof this[this.default]?this[this.default](e):this.sshurl(e)}}for(const[e,r]of Object.entries(t))o.addHost(e,r);return ct=o}var vt,yt,Et={topLevel:{dependancies:"dependencies",dependecies:"dependencies",depdenencies:"dependencies",devEependencies:"devDependencies",depends:"dependencies","dev-dependencies":"devDependencies",devDependences:"devDependencies",devDepenencies:"devDependencies",devdependencies:"devDependencies",repostitory:"repository",repo:"repository",prefereGlobal:"preferGlobal",hompage:"homepage",hampage:"homepage",autohr:"author",autor:"author",contributers:"contributors",publicationConfig:"publishConfig",script:"scripts"},bugs:{web:"url",name:"url"},script:{server:"start",tests:"test"}};function bt(){if(yt)return vt;yt=1;var{URL:e}=u,t=Fe(),r=Ue(),n=et(),i=gt(),{isBuiltin:o}=h,s=["dependencies","devDependencies","optionalDependencies"],a=(ft||(ft=1,ut=function(e){if(!e)return;if("ERROR: No README data found!"===e)return;e=e.trim().split("\n");let t=0;for(;e[t]&&e[t].trim().match(/^(#|$)/);)t++;const r=e.length;let n=t+1;for(;n<r&&e[n].trim();)n++;return e.slice(t,n).join(" ").trim()}),ut),c=Et,l=e=>e.includes("@")&&e.indexOf("@")<e.lastIndexOf(".");function f(e,t){return e.author&&(e.author=t(e.author)),["maintainers","contributors"].forEach(function(r){Array.isArray(e[r])&&(e[r]=e[r].map(t))}),e}function p(e){if("string"==typeof e)return e;var t=e.name||"",r=e.url||e.web,n=r?" ("+r+")":"",i=e.email||e.mail;return t+(i?" <"+i+">":"")+n}function d(e){if("string"!=typeof e)return e;var t=e.match(/^([^(<]+)/),r=e.match(/\(([^()]+)\)/),n=e.match(/<([^<>]+)>/),i={};return t&&t[0].trim()&&(i.name=t[0].trim()),n&&(i.email=n[1]),r&&(i.url=r[1]),i}return vt={warn:function(){},fixRepositoryField:function(e){if(e.repositories&&(this.warn("repositories"),e.repository=e.repositories[0]),!e.repository)return this.warn("missingRepository");"string"==typeof e.repository&&(e.repository={type:"git",url:e.repository});var t=e.repository.url||"";if(t){var r=i.fromUrl(t);r&&(t=e.repository.url="shortcut"===r.getDefaultRepresentation()?r.https():r.toString())}t.match(/github.com\/[^/]+\/[^/]+\.git\.git$/)&&this.warn("brokenGitUrl",t)},fixTypos:function(e){Object.keys(c.topLevel).forEach(function(t){Object.prototype.hasOwnProperty.call(e,t)&&this.warn("typo",t,c.topLevel[t])},this)},fixScriptsField:function(e){if(e.scripts)return"object"!=typeof e.scripts?(this.warn("nonObjectScripts"),void delete e.scripts):void Object.keys(e.scripts).forEach(function(t){"string"!=typeof e.scripts[t]?(this.warn("nonStringScript"),delete e.scripts[t]):c.script[t]&&!e.scripts[c.script[t]]&&this.warn("typo",t,c.script[t],"scripts")},this)},fixFilesField:function(e){var t=e.files;t&&!Array.isArray(t)?(this.warn("nonArrayFiles"),delete e.files):e.files&&(e.files=e.files.filter(function(e){return!(!e||"string"!=typeof e)||(this.warn("invalidFilename",e),!1)},this))},fixBinField:function(e){if(e.bin&&"string"==typeof e.bin){var t,r={};(t=e.name.match(/^@[^/]+[/](.*)$/))?r[t[1]]=e.bin:r[e.name]=e.bin,e.bin=r}},fixManField:function(e){e.man&&"string"==typeof e.man&&(e.man=[e.man])},fixBundleDependenciesField:function(e){var t="bundledDependencies",r="bundleDependencies";e[t]&&!e[r]&&(e[r]=e[t],delete e[t]),e[r]&&!Array.isArray(e[r])?(this.warn("nonArrayBundleDependencies"),delete e[r]):e[r]&&(e[r]=e[r].filter(function(t){return t&&"string"==typeof t?(e.dependencies||(e.dependencies={}),Object.prototype.hasOwnProperty.call(e.dependencies,t)||(this.warn("nonDependencyBundleDependency",t),e.dependencies[t]="*"),!0):(this.warn("nonStringBundleDependency",t),!1)},this))},fixDependencies:function(e){!function(e,t){s.forEach(function(r){e[r]&&(e[r]=function(e,t,r){if(!e)return{};"string"==typeof e&&(e=e.trim().split(/[\n\r\s\t ,]+/));if(!Array.isArray(e))return e;r("deprecatedArrayDependencies",t);var n={};return e.filter(function(e){return"string"==typeof e}).forEach(function(e){var t=(e=e.trim().split(/(:?[@\s><=])/)).shift(),r=e.join("");r=(r=r.trim()).replace(/^@/,""),n[t]=r}),n}(e[r],r,t))})}(e,this.warn),function(e){var t=e.optionalDependencies;if(!t)return;var r=e.dependencies||{};Object.keys(t).forEach(function(e){r[e]=t[e]}),e.dependencies=r}(e,this.warn),this.fixBundleDependenciesField(e),["dependencies","devDependencies"].forEach(function(t){if(t in e)return e[t]&&"object"==typeof e[t]?void Object.keys(e[t]).forEach(function(r){var n=e[t][r];"string"!=typeof n&&(this.warn("nonStringDependency",r,JSON.stringify(n)),delete e[t][r]);var o=i.fromUrl(e[t][r]);o&&(e[t][r]=o.toString())},this):(this.warn("nonObjectDependencies",t),void delete e[t])},this)},fixModulesField:function(e){e.modules&&(this.warn("deprecatedModules"),delete e.modules)},fixKeywordsField:function(e){"string"==typeof e.keywords&&(e.keywords=e.keywords.split(/,\s+/)),e.keywords&&!Array.isArray(e.keywords)?(delete e.keywords,this.warn("nonArrayKeywords")):e.keywords&&(e.keywords=e.keywords.filter(function(e){return!("string"!=typeof e||!e)||(this.warn("nonStringKeyword"),!1)},this))},fixVersionField:function(e,n){var i=!n;if(!e.version)return e.version="",!0;if(!t(e.version,i))throw new Error('Invalid version: "'+e.version+'"');return e.version=r(e.version,i),!0},fixPeople:function(e){f(e,p),f(e,d)},fixNameField:function(e,t){"boolean"==typeof t?t={strict:t}:void 0===t&&(t={});var r=t.strict;if(e.name||r){if("string"!=typeof e.name)throw new Error("name field must be a string.");r||(e.name=e.name.trim()),function(e,t,r){if("."===e.charAt(0)||!function(e){if("@"!==e.charAt(0))return!1;var t=e.slice(1).split("/");if(2!==t.length)return!1;return t[0]&&t[1]&&t[0]===encodeURIComponent(t[0])&&t[1]===encodeURIComponent(t[1])}(e)&&(n=e,n.match(/[/@\s+%:]/)||n!==encodeURIComponent(n))||t&&!r&&e!==e.toLowerCase()||"node_modules"===e.toLowerCase()||"favicon.ico"===e.toLowerCase())throw new Error("Invalid name: "+JSON.stringify(e));var n}(e.name,r,t.allowLegacyCase),o(e.name)&&this.warn("conflictingName",e.name)}else e.name=""},fixDescriptionField:function(e){e.description&&"string"!=typeof e.description&&(this.warn("nonStringDescription"),delete e.description),e.readme&&!e.description&&(e.description=a(e.readme)),void 0===e.description&&delete e.description,e.description||this.warn("missingDescription")},fixReadmeField:function(e){e.readme||(this.warn("missingReadme"),e.readme="ERROR: No README data found!")},fixBugsField:function(t){if(!t.bugs&&t.repository&&t.repository.url){var r=i.fromUrl(t.repository.url);r&&r.bugs()&&(t.bugs={url:r.bugs()})}else if(t.bugs){if("string"==typeof t.bugs)l(t.bugs)?t.bugs={email:t.bugs}:e.canParse(t.bugs)?t.bugs={url:t.bugs}:this.warn("nonEmailUrlBugsString");else{!function(e,t){if(!e)return;Object.keys(e).forEach(function(r){c.bugs[r]&&(t("typo",r,c.bugs[r],"bugs"),e[c.bugs[r]]=e[r],delete e[r])})}(t.bugs,this.warn);var n=t.bugs;t.bugs={},n.url&&(e.canParse(n.url)?t.bugs.url=n.url:this.warn("nonUrlBugsUrlField")),n.email&&("string"==typeof n.email&&l(n.email)?t.bugs.email=n.email:this.warn("nonEmailBugsEmailField"))}t.bugs.email||t.bugs.url||(delete t.bugs,this.warn("emptyNormalizedBugs"))}},fixHomepageField:function(t){if(!t.homepage&&t.repository&&t.repository.url){var r=i.fromUrl(t.repository.url);r&&r.docs()&&(t.homepage=r.docs())}if(t.homepage)return"string"!=typeof t.homepage?(this.warn("nonUrlHomepage"),delete t.homepage):void(e.canParse(t.homepage)||(t.homepage="http://"+t.homepage))},fixLicenseField:function(e){const t=e.license||e.licence;return t?"string"!=typeof t||t.length<1||""===t.trim()?this.warn("invalidLicense"):n(t).validForNewPackages?void 0:this.warn("invalidLicense"):this.warn("missingLicense")}},vt}var wt,Lt,St,Ct,It={repositories:"'repositories' (plural) Not supported. Please pick one as the 'repository' field",missingRepository:"No repository field.",brokenGitUrl:"Probably broken git url: %s",nonObjectScripts:"scripts must be an object",nonStringScript:"script values must be string commands",nonArrayFiles:"Invalid 'files' member",invalidFilename:"Invalid filename in 'files' list: %s",nonArrayBundleDependencies:"Invalid 'bundleDependencies' list. Must be array of package names",nonStringBundleDependency:"Invalid bundleDependencies member: %s",nonDependencyBundleDependency:"Non-dependency in bundleDependencies: %s",nonObjectDependencies:"%s field must be an object",nonStringDependency:"Invalid dependency: %s %s",deprecatedArrayDependencies:"specifying %s as array is deprecated",deprecatedModules:"modules field is deprecated",nonArrayKeywords:"keywords should be an array of strings",nonStringKeyword:"keywords should be an array of strings",conflictingName:"%s is also the name of a node core module.",nonStringDescription:"'description' field should be a string",missingDescription:"No description",missingReadme:"No README data",missingLicense:"No license field.",nonEmailUrlBugsString:"Bug string field must be url, email, or {email,url}",nonUrlBugsUrlField:"bugs.url field must be a string url. Deleted.",nonEmailBugsEmailField:"bugs.email field must be a string email. Deleted.",emptyNormalizedBugs:"Normalized value of bugs field is an empty object. Deleted.",nonUrlHomepage:"homepage field must be a string url. Deleted.",invalidLicense:"license should be a valid SPDX license expression",typo:"%s should probably be %s."};function Dt(){if(Lt)return wt;Lt=1;var e=d,t=It;function r(r,n,i){return i&&(r=i+"['"+r+"']",n=i+"['"+n+"']"),e.format(t.typo,r,n)}return wt=function(){var n=Array.prototype.slice.call(arguments,0),i=n.shift();if("typo"===i)return r.apply(null,n);var o=t[i]?t[i]:i+": '%s'";return n.unshift(o),e.format.apply(null,n)},wt}var Ot=function(){if(Ct)return St;Ct=1,St=n;var e=bt();n.fixer=e;var t=Dt(),r=["name","version","description","repository","modules","scripts","files","bin","man","bugs","keywords","readme","homepage","license"].map(function(e){return i(e)+"Field"});function n(n,o,s){!0===o&&(o=null,s=!0),s||(s=!1),o&&!n.private||(o=function(){}),n.scripts&&"node-gyp rebuild"===n.scripts.install&&!n.scripts.preinstall&&(n.gypfile=!0),e.warn=function(){o(t.apply(null,arguments))},r.forEach(function(t){e["fix"+i(t)](n,s)}),n._id=n.name+"@"+n.version}function i(e){return e.charAt(0).toUpperCase()+e.slice(1)}return r=r.concat(["dependencies","people","typos"]),St}(),Nt=ue(Ot);const At=(e,t)=>{try{return m(e,g.F_OK),!0}catch(e){return!1}},Pt=["index.ts","index.tsx","main.ts","main.tsx"],_t=(e,t,r)=>{const n=o(e??process.cwd(),"src"),i=Pt,s=i.map(e=>o(n,e)).find(e=>At(e));if(!s)throw new Error(`Unable to resolve entry point, ensure ${i.join(", ")} exists in ${n}`);return s},Rt=(e,t)=>D(e,t,{arrayMerge:(e,t)=>{const r=t[0]??e[0];return"object"==typeof r&&"match"in r&&"middleware"in r?((e,t,r)=>{const n=r.reduce((t,r)=>Object.assign(t,{[String(r[e])]:r}),{}),i={...t.reduce((t,r)=>Object.assign(t,{[String(r[e])]:r}),{}),...n};return Object.values(i)})("match",e,t):[...new Set([...e,...t])]}}),Tt=async(r,o)=>{const{packageJson:c,root:l}=o,{config:u}=await e(r)??{},f=c.main??c.module??"./dist/bundle.js",p=_t(l);if("build"===r.command){if(i(f)===l)throw new Error("outDir cannot be root, please specify package.main or package.module in package.json");if("src"===i(f))throw new Error("outDir cannot be src, please specify package.main or package.module in package.json");if(i(f)===process.cwd())throw new Error("outDir cannot be the current working directory, please specify package.main or package.module in package.json")}return t({root:l,plugins:[n()],define:{"process.env.NODE_ENV":JSON.stringify(r.mode),"process.env.NODE_DEBUG":"production"!==r.mode,"process.env.FUSION_LOG_LEVEL":"production"===r.mode?1:3},build:{outDir:i(f),lib:{entry:p,fileName:s(f,a(f)),formats:["es"]},emptyOutDir:!0}},u??{})};function xt(e,t){O("object"==typeof e,t)}const $t=e=>{if(e.repository)return"string"==typeof e.repository?e.repository:e.repository.url},Ft=()=>{try{return N("git remote get-url origin").toString().trim().replace("git@github.com:","https://github.com/").replace(/\.git$/,"")}catch(e){return}},Ut=(e="HEAD")=>{try{return N(`git rev-parse ${e}`).toString().trim()}catch(e){return}},kt=()=>{if(process.env.GITHUB_ACTIONS){const e=(()=>{const e=process.env.GITHUB_EVENT_NAME||"unknown",t=process.env.GITHUB_ACTOR||"unknown",r=process.env.GITHUB_RUN_ID||"unknown",n=process.env.GITHUB_REPOSITORY||"unknown",i=process.env.GITHUB_WORKFLOW||"unknown",o=process.env.GITHUB_SERVER_URL||"https://github.com";let s="unknown";"unknown"!==n&&"unknown"!==r&&(s=`${o.replace(/\/$/,"")}/${n}/actions/runs/${r}`);const a={eventName:e,actor:t,runId:r,runUrl:s,workflow:i};if(process.env.GITHUB_EVENT_PATH)try{const e=v(process.env.GITHUB_EVENT_PATH,"utf8");Object.assign(a,JSON.parse(e))}catch{console.error("Failed to parse GitHub event payload")}return a})(),t={source:"github",reason:e.eventName,workflow:e.workflow,runId:e.runId,runUrl:e.runUrl,commitId:e.head_commit?.id,repository:e.repository?.name,repository_homepage:e.repository?.homepage,repository_license:e.repository?.license?.name,repository_owner:e.repository?.owner?.login,repository_owner_avatar_url:e.repository?.owner?.avatar_url,actor:e.actor,sender_login:e.sender?.login,sender_avatar_url:e.sender?.avatar_url};return e.pull_request?{...t,branch:e.pull_request.head?.ref,commitId:e.pull_request.head?.sha,htmlUrl:e.pull_request.html_url}:e.release?{...t,tag:e.release.tag_name,htmlUrl:e.release.html_url}:t}if(process.env.SYSTEM_TEAMPROJECT){const e=(()=>{const e=process.env.BUILD_BUILDID||"unknown",t=process.env.BUILD_DEFINITIONNAME||"unknown",r=process.env.BUILD_REPOSITORY_NAME||"unknown",n=process.env.SYSTEM_TEAMPROJECT||"unknown",i=process.env.SYSTEM_COLLECTIONURI||"unknown",o=process.env.BUILD_REQUESTEDFOR||"unknown",s=process.env.BUILD_SOURCEBRANCH||"unknown",a=process.env.BUILD_SOURCEVERSION||"unknown",c=process.env.BUILD_REASON||"unknown";let l="unknown";return"unknown"!==i&&"unknown"!==n&&"unknown"!==e&&(l=`${i.replace(/\/$/,"")}${n}/_build/results?buildId=${e}`),{runId:e,pipelineName:t,repository:r,project:n,orgUrl:i,actor:o,branch:s,commitId:a,runUrl:l,reason:c}})();return{source:"azure_devops",reason:e.reason,repository:e.repository,runId:e.runId,runUrl:e.runUrl,actor:e.actor,branch:e.branch,commitId:e.commitId,workflow:e.pipelineName}}},Bt=["png","jpg","jpeg","gif","svg","ico","webp","mp4","webm","mp3","woff2","woff","eot","ttf","otf","pdf","md","txt"],Mt=(e,t)=>{xt(t,"expected packageJson"),O(t.name,"expected [name] in packageJson"),O(t.version,"expected [version] in packageJson");const r=((e,t)=>"build"===e.command||e.isPreview?t.main||t.module||"dist/app-bundle.js":_t(e.root))(e,t),n=t.name.replace(/^@|\w.*\//gm,""),i=t.version,o="build"===e.command?void 0:`/bundles/apps/${n}@${i}`,s=$t(t)??Ft();return{appKey:n,displayName:t.name,description:t.description||"",keywords:t.keywords,type:"standalone",build:{entryPoint:r,assetPath:o,githubRepo:s,version:i,timestamp:(new Date).toISOString(),commitSha:Ut(),annotations:kt(),projectPage:t.homepage,allowedExtensions:Bt.map(e=>`.${e}`)}}},Gt=(e,t)=>D(e,t),jt=P.object({environment:P.record(P.any()).describe("Key-value map of environment-specific variables for the application. Defaults to an empty object if not provided.").optional().default({}),endpoints:P.record(P.object({url:P.string().describe("The endpoint URL. This field is required."),scopes:P.array(P.string()).optional().default([]).describe("List of scopes required for accessing this endpoint. Defaults to an empty array.")})).describe("A mapping of endpoint names to their configuration objects. Each endpoint must specify a URL and may specify scopes.").optional()}).describe("The API application configuration schema, defining environment variables and endpoints for the application."),zt=["B","kB","MB","GB","TB","PB","EB","ZB","YB"],Ht=["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],qt=["b","kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],Wt=["b","kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],Vt=(e,t,r)=>{let n=e;return"string"==typeof t||Array.isArray(t)?n=e.toLocaleString(t,r):!0!==t&&void 0===r||(n=e.toLocaleString(void 0,r)),n},Yt=e=>{if("number"==typeof e)return Math.log10(e);const t=e.toString(10);return t.length+Math.log10("0."+t.slice(0,15))};function Kt(e,t){if("bigint"!=typeof e&&!Number.isFinite(e))throw new TypeError(`Expected a finite number, got ${typeof e}: ${e}`);const r=(t={bits:!1,binary:!1,space:!0,...t}).bits?t.binary?Wt:qt:t.binary?Ht:zt,n=t.space?" ":"";if(t.signed&&("number"==typeof e?0===e:0n===e))return` 0${n}${r[0]}`;const i=e<0,o=i?"-":t.signed?"+":"";let s;if(i&&(e=-e),void 0!==t.minimumFractionDigits&&(s={minimumFractionDigits:t.minimumFractionDigits}),void 0!==t.maximumFractionDigits&&(s={maximumFractionDigits:t.maximumFractionDigits,...s}),e<1){return o+Vt(e,t.locale,s)+n+r[0]}const a=Math.min(Math.floor(t.binary?("number"==typeof(c=e)?Math.log(c):Yt(c)*Math.log(10))/Math.log(1024):Yt(e)/3),r.length-1);var c;if(e=((e,t)=>{if("number"==typeof e)return e/t;const r=e/BigInt(t),n=e%BigInt(t);return Number(r)+Number(n)/t})(e,(t.binary?1024:1e3)**a),!s){const t=Math.max(3,Number.parseInt(e,10).toString().length);e=e.toPrecision(t)}return o+Vt(Number(e),t.locale,s)+n+r[a]}const Zt=(e,t)=>le.blueBright(t?.relative?`./${c(t?.cwd??process.cwd(),e)}`:e),Xt=e=>"string"==typeof e?Xt(y(e).size):le.yellowBright(Kt(e)),Jt=async(e,t,r)=>{const n=Mt(e,t.packageJson);try{r?.log?.start("loading application package...");const{manifest:t,path:i}=await(async(e,t)=>{const r=t?.file??[`app.manifest.${e.environment}`,"app.manifest","app.manifest.config"],n=await C(r,{baseDir:e.root,extensions:t?.extensions,script:{resolve:async r=>{const n=t?.base??{};if("function"==typeof r.default){const t=await r.default(e,{base:n});return Gt(n,t??{})}return Gt(n,r.default??{})}}});return{manifest:n.config,path:n.path,extension:n.extension}})(e,{base:n,file:r?.manifestPath});if(!t.build)throw new Error(`Application manifest for ${t.appKey} does not contain build information, please check the manifest file.`);return"serve"===e.command&&(t.build.assetPath=`/bundles/apps/${t.appKey}/${t.build.version}`),r?.log?.succeed("generated manifest from",Zt(i,{relative:!0})),t}catch(e){if(e instanceof I){if(r?.manifestPath){const t=new Error(`Failed to load manifest file ${Zt(r.manifestPath)}, please check the path.`,{cause:e});throw r?.log?.fail(t.message),t}return r?.log?.succeed(le.dim("no local manifest config applied, using default generated from package")),n}throw r?.log?.fail(`failed to resolve application manifest ${r?.manifestPath?Zt(r?.manifestPath):""}`),e}};async function Qt(e){e?.start("resolve project package");try{const t=await(async e=>{const t=await l({...e,normalize:!1});if(!t)throw new Error("failed to find package.json");const r={...t.packageJson};return Nt(r),{packageJson:{...r,version:t.packageJson.version},path:t.path,root:i(t.path)}})();return e?.succeed("📦",le.yellowBright([t.packageJson.name,t.packageJson.version].join("@"))),e?.info("🏠",le.blueBright(t.root)),t}catch(t){throw e?.fail("☠️","failed to resolve project package"),t}}const er=async e=>{const{log:t}=e??{},r=await Qt(t);t?.debug("package",r);const n={command:"build",mode:process.env.NODE_ENV??"production",root:r.root,...e?.env};t?.debug("env:",n);const i=await Jt(n,r,{log:t,manifestPath:e?.manifest});return t?.debug("manifest:",i),{manifest:i,pkg:r,env:n}},tr=async e=>{const{log:t}=e??{};t?.log(le.bold("Starting to build application"));const{manifest:n,pkg:i,env:o}=await er({log:t,manifest:e?.manifest});t?.start("loading vite config...");const s=await Tt(o,i);t?.succeed("vite config applied"),t?.debug("vite config:",s),t?.start("🤞🏻","building application..."),t?.startNativeConsoleCapture(),await r(s),t?.stopNativeConsoleCapture(),t?.succeed("build completed 😘");return{pkg:i,manifest:n,outDir:s.build.outDir}};var rr,nr,ir={exports:{}};function or(){return nr?rr:(nr=1,rr={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,END64HDR:20,END64SIG:117853008,END64START:4,END64OFF:8,END64NUMDISKS:16,ZIP64SIG:101075792,ZIP64HDR:56,ZIP64LEAD:12,ZIP64SIZE:4,ZIP64VEM:12,ZIP64VER:14,ZIP64DSK:16,ZIP64DSKDIR:20,ZIP64SUB:24,ZIP64TOT:32,ZIP64SIZB:40,ZIP64OFF:48,ZIP64EXTRA:56,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,AES_ENCRYPT:99,FLG_ENC:1,FLG_COMP1:2,FLG_COMP2:4,FLG_DESC:8,FLG_ENH:16,FLG_PATCH:32,FLG_STR:64,FLG_EFS:2048,FLG_MSK:4096,FILE:2,BUFFER:1,NONE:0,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535,EF_ZIP64_SUNCOMP:0,EF_ZIP64_SCOMP:8,EF_ZIP64_RHO:16,EF_ZIP64_DSN:24})}var sr,ar,cr,lr,ur,fr,pr,hr,dr={};function mr(){return sr||(sr=1,function(e){const t={INVALID_LOC:"Invalid LOC header (bad signature)",INVALID_CEN:"Invalid CEN header (bad signature)",INVALID_END:"Invalid END header (bad signature)",DESCRIPTOR_NOT_EXIST:"No descriptor present",DESCRIPTOR_UNKNOWN:"Unknown descriptor format",DESCRIPTOR_FAULTY:"Descriptor data is malformed",NO_DATA:"Nothing to decompress",BAD_CRC:"CRC32 checksum failed {0}",FILE_IN_THE_WAY:"There is a file in the way: {0}",UNKNOWN_METHOD:"Invalid/unsupported compression method",AVAIL_DATA:"inflate::Available inflate data did not terminate",INVALID_DISTANCE:"inflate::Invalid literal/length or distance code in fixed or dynamic block",TO_MANY_CODES:"inflate::Dynamic block code description: too many length or distance codes",INVALID_REPEAT_LEN:"inflate::Dynamic block code description: repeat more than specified lengths",INVALID_REPEAT_FIRST:"inflate::Dynamic block code description: repeat lengths with no first length",INCOMPLETE_CODES:"inflate::Dynamic block code description: code lengths codes incomplete",INVALID_DYN_DISTANCE:"inflate::Dynamic block code description: invalid distance code lengths",INVALID_CODES_LEN:"inflate::Dynamic block code description: invalid literal/length code lengths",INVALID_STORE_BLOCK:"inflate::Stored block length did not match one's complement",INVALID_BLOCK_TYPE:"inflate::Invalid block type (type == 3)",CANT_EXTRACT_FILE:"Could not extract the file",CANT_OVERRIDE:"Target file already exists",DISK_ENTRY_TOO_LARGE:"Number of disk entries is too large",NO_ZIP:"No zip file was loaded",NO_ENTRY:"Entry doesn't exist",DIRECTORY_CONTENT_ERROR:"A directory cannot have content",FILE_NOT_FOUND:'File not found: "{0}"',NOT_IMPLEMENTED:"Not implemented",INVALID_FILENAME:"Invalid filename",INVALID_FORMAT:"Invalid or unsupported zip format. No END header found",INVALID_PASS_PARAM:"Incompatible password parameter",WRONG_PASSWORD:"Wrong Password",COMMENT_TOO_LONG:"Comment is too long",EXTRA_FIELD_PARSE_ERROR:"Extra field parsing error"};function r(e){return function(...t){return t.length&&(e=e.replace(/\{(\d)\}/g,(e,r)=>t[r]||"")),new Error("ADM-ZIP: "+e)}}for(const n of Object.keys(t))e[n]=r(t[n])}(dr)),dr}function gr(){return hr||(hr=1,ir.exports=function(){if(cr)return ar;cr=1;const e=_,t=R,r=or(),n=mr(),i="object"==typeof process&&"win32"===process.platform,o=e=>"object"==typeof e&&null!==e,s=new Uint32Array(256).map((e,t)=>{for(let e=0;e<8;e++)1&t?t=3988292384^t>>>1:t>>>=1;return t>>>0});function a(r){this.sep=t.sep,this.fs=e,o(r)&&o(r.fs)&&"function"==typeof r.fs.statSync&&(this.fs=r.fs)}return ar=a,a.prototype.makeDir=function(e){const t=this;!function(e){let r=e.split(t.sep)[0];e.split(t.sep).forEach(function(e){if(e&&":"!==e.substr(-1,1)){var i;r+=t.sep+e;try{i=t.fs.statSync(r)}catch(e){t.fs.mkdirSync(r)}if(i&&i.isFile())throw n.FILE_IN_THE_WAY(`"${r}"`)}})}(e)},a.prototype.writeFileTo=function(e,r,n,i){const o=this;if(o.fs.existsSync(e)){if(!n)return!1;if(o.fs.statSync(e).isDirectory())return!1}var s,a=t.dirname(e);o.fs.existsSync(a)||o.makeDir(a);try{s=o.fs.openSync(e,"w",438)}catch(t){o.fs.chmodSync(e,438),s=o.fs.openSync(e,"w",438)}if(s)try{o.fs.writeSync(s,r,0,r.length,0)}finally{o.fs.closeSync(s)}return o.fs.chmodSync(e,i||438),!0},a.prototype.writeFileToAsync=function(e,r,n,i,o){"function"==typeof i&&(o=i,i=void 0);const s=this;s.fs.exists(e,function(a){if(a&&!n)return o(!1);s.fs.stat(e,function(n,c){if(a&&c.isDirectory())return o(!1);var l=t.dirname(e);s.fs.exists(l,function(t){t||s.makeDir(l),s.fs.open(e,"w",438,function(t,n){t?s.fs.chmod(e,438,function(){s.fs.open(e,"w",438,function(t,n){s.fs.write(n,r,0,r.length,0,function(){s.fs.close(n,function(){s.fs.chmod(e,i||438,function(){o(!0)})})})})}):n?s.fs.write(n,r,0,r.length,0,function(){s.fs.close(n,function(){s.fs.chmod(e,i||438,function(){o(!0)})})}):s.fs.chmod(e,i||438,function(){o(!0)})})})})})},a.prototype.findFiles=function(e){const r=this;return function e(n,i,o){let s=[];return r.fs.readdirSync(n).forEach(function(a){const c=t.join(n,a),l=r.fs.statSync(c);s.push(t.normalize(c)+(l.isDirectory()?r.sep:"")),l.isDirectory()&&o&&(s=s.concat(e(c,i,o)))}),s}(e,void 0,!0)},a.prototype.findFilesAsync=function(e,r){const n=this;let i=[];n.fs.readdir(e,function(o,s){if(o)return r(o);let a=s.length;if(!a)return r(null,i);s.forEach(function(o){o=t.join(e,o),n.fs.stat(o,function(e,s){if(e)return r(e);s&&(i.push(t.normalize(o)+(s.isDirectory()?n.sep:"")),s.isDirectory()?n.findFilesAsync(o,function(e,t){if(e)return r(e);i=i.concat(t),--a||r(null,i)}):--a||r(null,i))})})})},a.prototype.getAttributes=function(){},a.prototype.setAttributes=function(){},a.crc32update=function(e,t){return s[255&(e^t)]^e>>>8},a.crc32=function(e){"string"==typeof e&&(e=Buffer.from(e,"utf8"));let t=e.length,r=-1;for(let n=0;n<t;)r=a.crc32update(r,e[n++]);return~r>>>0},a.methodToString=function(e){switch(e){case r.STORED:return"STORED ("+e+")";case r.DEFLATED:return"DEFLATED ("+e+")";default:return"UNSUPPORTED ("+e+")"}},a.canonical=function(e){if(!e)return"";const r=t.posix.normalize("/"+e.split("\\").join("/"));return t.join(".",r)},a.zipnamefix=function(e){if(!e)return"";const r=t.posix.normalize("/"+e.split("\\").join("/"));return t.posix.join(".",r)},a.findLast=function(e,t){if(!Array.isArray(e))throw new TypeError("arr is not array");for(let r=(e.length>>>0)-1;r>=0;r--)if(t(e[r],r,e))return e[r]},a.sanitize=function(e,r){e=t.resolve(t.normalize(e));for(var n=r.split("/"),i=0,o=n.length;i<o;i++){var s=t.normalize(t.join(e,n.slice(i,o).join(t.sep)));if(0===s.indexOf(e))return s}return t.normalize(t.join(e,t.basename(r)))},a.toBuffer=function(e,t){return Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e):"string"==typeof e?t(e):Buffer.alloc(0)},a.readBigUInt64LE=function(e,t){var r=Buffer.from(e.slice(t,t+8));return r.swap64(),parseInt(`0x${r.toString("hex")}`)},a.fromDOS2Date=function(e){return new Date(1980+(e>>25&127),Math.max((e>>21&15)-1,0),Math.max(e>>16&31,1),e>>11&31,e>>5&63,(31&e)<<1)},a.fromDate2DOS=function(e){let t=0,r=0;return e.getFullYear()>1979&&(t=(e.getFullYear()-1980&127)<<9|e.getMonth()+1<<5|e.getDate(),r=e.getHours()<<11|e.getMinutes()<<5|e.getSeconds()>>1),t<<16|r},a.isWin=i,a.crcTable=s,ar}(),ir.exports.Constants=or(),ir.exports.Errors=mr(),ir.exports.FileAttr=function(){if(ur)return lr;ur=1;const e=R;return lr=function(t,{fs:r}){var n=t||"",i={directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0},o=null;return n&&r.existsSync(n)?(o=r.statSync(n),i.directory=o.isDirectory(),i.mtime=o.mtime,i.atime=o.atime,i.executable=!!(73&o.mode),i.readonly=!(128&o.mode),i.hidden="."===e.basename(n)[0]):console.warn("Invalid path: "+n),{get directory(){return i.directory},get readOnly(){return i.readonly},get hidden(){return i.hidden},get mtime(){return i.mtime},get atime(){return i.atime},get executable(){return i.executable},decodeAttributes:function(){},encodeAttributes:function(){},toJSON:function(){return{path:n,isDirectory:i.directory,isReadOnly:i.readonly,isHidden:i.hidden,isExecutable:i.executable,mTime:i.mtime,aTime:i.atime}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}}(),ir.exports.decoder=pr?fr:(pr=1,fr={efs:!0,encode:e=>Buffer.from(e,"utf8"),decode:e=>e.toString("utf8")})),ir.exports}var vr,yr,Er,br,wr,Lr={};function Sr(){if(yr)return vr;yr=1;var e=gr(),t=e.Constants;return vr=function(){var r=20,n=10,i=0,o=0,s=0,a=0,c=0,l=0,u=0,f=0,p=0,h=0,d=0,m=0,g=0;r|=e.isWin?2560:768,i|=t.FLG_EFS;const v={extraLen:0},y=e=>Math.max(0,e)>>>0;return s=e.fromDate2DOS(new Date),{get made(){return r},set made(e){r=e},get version(){return n},set version(e){n=e},get flags(){return i},set flags(e){i=e},get flags_efs(){return(i&t.FLG_EFS)>0},set flags_efs(e){e?i|=t.FLG_EFS:i&=~t.FLG_EFS},get flags_desc(){return(i&t.FLG_DESC)>0},set flags_desc(e){e?i|=t.FLG_DESC:i&=~t.FLG_DESC},get method(){return o},set method(e){switch(e){case t.STORED:this.version=10;case t.DEFLATED:default:this.version=20}o=e},get time(){return e.fromDOS2Date(this.timeval)},set time(t){this.timeval=e.fromDate2DOS(t)},get timeval(){return s},set timeval(e){s=y(e)},get timeHighByte(){return e=s>>>8,255&Math.max(0,e);var e},get crc(){return a},set crc(e){a=y(e)},get compressedSize(){return c},set compressedSize(e){c=y(e)},get size(){return l},set size(e){l=y(e)},get fileNameLength(){return u},set fileNameLength(e){u=e},get extraLength(){return f},set extraLength(e){f=e},get extraLocalLength(){return v.extraLen},set extraLocalLength(e){v.extraLen=e},get commentLength(){return p},set commentLength(e){p=e},get diskNumStart(){return h},set diskNumStart(e){h=y(e)},get inAttr(){return d},set inAttr(e){d=y(e)},get attr(){return m},set attr(e){m=y(e)},get fileAttr(){return(m||0)>>16&4095},get offset(){return g},set offset(e){g=y(e)},get encrypted(){return(i&t.FLG_ENC)===t.FLG_ENC},get centralHeaderSize(){return t.CENHDR+u+f+p},get realDataOffset(){return g+t.LOCHDR+v.fnameLen+v.extraLen},get localHeader(){return v},loadLocalHeaderFromBinary:function(r){var n=r.slice(g,g+t.LOCHDR);if(n.readUInt32LE(0)!==t.LOCSIG)throw e.Errors.INVALID_LOC();v.version=n.readUInt16LE(t.LOCVER),v.flags=n.readUInt16LE(t.LOCFLG),v.method=n.readUInt16LE(t.LOCHOW),v.time=n.readUInt32LE(t.LOCTIM),v.crc=n.readUInt32LE(t.LOCCRC),v.compressedSize=n.readUInt32LE(t.LOCSIZ),v.size=n.readUInt32LE(t.LOCLEN),v.fnameLen=n.readUInt16LE(t.LOCNAM),v.extraLen=n.readUInt16LE(t.LOCEXT);const i=g+t.LOCHDR+v.fnameLen,o=i+v.extraLen;return r.slice(i,o)},loadFromBinary:function(v){if(v.length!==t.CENHDR||v.readUInt32LE(0)!==t.CENSIG)throw e.Errors.INVALID_CEN();r=v.readUInt16LE(t.CENVEM),n=v.readUInt16LE(t.CENVER),i=v.readUInt16LE(t.CENFLG),o=v.readUInt16LE(t.CENHOW),s=v.readUInt32LE(t.CENTIM),a=v.readUInt32LE(t.CENCRC),c=v.readUInt32LE(t.CENSIZ),l=v.readUInt32LE(t.CENLEN),u=v.readUInt16LE(t.CENNAM),f=v.readUInt16LE(t.CENEXT),p=v.readUInt16LE(t.CENCOM),h=v.readUInt16LE(t.CENDSK),d=v.readUInt16LE(t.CENATT),m=v.readUInt32LE(t.CENATX),g=v.readUInt32LE(t.CENOFF)},localHeaderToBinary:function(){var e=Buffer.alloc(t.LOCHDR);return e.writeUInt32LE(t.LOCSIG,0),e.writeUInt16LE(n,t.LOCVER),e.writeUInt16LE(i,t.LOCFLG),e.writeUInt16LE(o,t.LOCHOW),e.writeUInt32LE(s,t.LOCTIM),e.writeUInt32LE(a,t.LOCCRC),e.writeUInt32LE(c,t.LOCSIZ),e.writeUInt32LE(l,t.LOCLEN),e.writeUInt16LE(u,t.LOCNAM),e.writeUInt16LE(v.extraLen,t.LOCEXT),e},centralHeaderToBinary:function(){var e=Buffer.alloc(t.CENHDR+u+f+p);return e.writeUInt32LE(t.CENSIG,0),e.writeUInt16LE(r,t.CENVEM),e.writeUInt16LE(n,t.CENVER),e.writeUInt16LE(i,t.CENFLG),e.writeUInt16LE(o,t.CENHOW),e.writeUInt32LE(s,t.CENTIM),e.writeUInt32LE(a,t.CENCRC),e.writeUInt32LE(c,t.CENSIZ),e.writeUInt32LE(l,t.CENLEN),e.writeUInt16LE(u,t.CENNAM),e.writeUInt16LE(f,t.CENEXT),e.writeUInt16LE(p,t.CENCOM),e.writeUInt16LE(h,t.CENDSK),e.writeUInt16LE(d,t.CENATT),e.writeUInt32LE(m,t.CENATX),e.writeUInt32LE(g,t.CENOFF),e},toJSON:function(){const s=function(e){return e+" bytes"};return{made:r,version:n,flags:i,method:e.methodToString(o),time:this.time,crc:"0x"+a.toString(16).toUpperCase(),compressedSize:s(c),size:s(l),fileNameLength:s(u),extraLength:s(f),commentLength:s(p),diskNumStart:h,inAttr:d,attr:m,offset:g,centralHeaderSize:s(t.CENHDR+u+f+p)}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}}function Cr(){return wr||(wr=1,Lr.EntryHeader=Sr(),Lr.MainHeader=function(){if(br)return Er;br=1;var e=gr(),t=e.Constants;return Er=function(){var r=0,n=0,i=0,o=0,s=0;return{get diskEntries(){return r},set diskEntries(e){r=n=e},get totalEntries(){return n},set totalEntries(e){n=r=e},get size(){return i},set size(e){i=e},get offset(){return o},set offset(e){o=e},get commentLength(){return s},set commentLength(e){s=e},get mainHeaderSize(){return t.ENDHDR+s},loadFromBinary:function(a){if((a.length!==t.ENDHDR||a.readUInt32LE(0)!==t.ENDSIG)&&(a.length<t.ZIP64HDR||a.readUInt32LE(0)!==t.ZIP64SIG))throw e.Errors.INVALID_END();a.readUInt32LE(0)===t.ENDSIG?(r=a.readUInt16LE(t.ENDSUB),n=a.readUInt16LE(t.ENDTOT),i=a.readUInt32LE(t.ENDSIZ),o=a.readUInt32LE(t.ENDOFF),s=a.readUInt16LE(t.ENDCOM)):(r=e.readBigUInt64LE(a,t.ZIP64SUB),n=e.readBigUInt64LE(a,t.ZIP64TOT),i=e.readBigUInt64LE(a,t.ZIP64SIZE),o=e.readBigUInt64LE(a,t.ZIP64OFF),s=0)},toBinary:function(){var e=Buffer.alloc(t.ENDHDR+s);return e.writeUInt32LE(t.ENDSIG,0),e.writeUInt32LE(0,4),e.writeUInt16LE(r,t.ENDSUB),e.writeUInt16LE(n,t.ENDTOT),e.writeUInt32LE(i,t.ENDSIZ),e.writeUInt32LE(o,t.ENDOFF),e.writeUInt16LE(s,t.ENDCOM),e.fill(" ",t.ENDHDR),e},toJSON:function(){return{diskEntries:r,totalEntries:n,size:i+" bytes",offset:function(e,t){let r=e.toString(16).toUpperCase();for(;r.length<t;)r="0"+r;return"0x"+r}(o,4),commentLength:s}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}},Er}()),Lr}var Ir,Dr,Or,Nr,Ar,Pr,_r,Rr,Tr,xr,$r,Fr,Ur,kr={};function Br(){if(Pr)return Ar;Pr=1;const{randomFillSync:e}=x,t=mr(),r=new Uint32Array(256).map((e,t)=>{for(let e=0;e<8;e++)1&t?t=t>>>1^3988292384:t>>>=1;return t>>>0}),n=(e,t)=>Math.imul(e,t)>>>0,i=(e,t)=>r[255&(e^t)]^e>>>8,o=()=>"function"==typeof e?e(Buffer.alloc(12)):o.node();o.node=()=>{const e=Buffer.alloc(12),t=e.length;for(let r=0;r<t;r++)e[r]=256*Math.random()&255;return e};const s={genSalt:o};function a(e){const t=Buffer.isBuffer(e)?e:Buffer.from(e);this.keys=new Uint32Array([305419896,591751049,878082192]);for(let e=0;e<t.length;e++)this.updateKeys(t[e])}return a.prototype.updateKeys=function(e){const t=this.keys;return t[0]=i(t[0],e),t[1]+=255&t[0],t[1]=n(t[1],134775813)+1,t[2]=i(t[2],t[1]>>>24),e},a.prototype.next=function(){const e=(2|this.keys[2])>>>0;return n(e,1^e)>>8&255},Ar={decrypt:function(e,r,n){if(!e||!Buffer.isBuffer(e)||e.length<12)return Buffer.alloc(0);const i=function(e){const t=new a(e);return function(e){const r=Buffer.alloc(e.length);let n=0;for(let i of e)r[n++]=t.updateKeys(i^t.next());return r}}(n),o=i(e.slice(0,12)),s=8&~r.flags?r.crc>>>24:r.timeHighByte;if(o[11]!==s)throw t.WRONG_PASSWORD();return i(e.slice(12))},encrypt:function(e,t,r,n=!1){null==e&&(e=Buffer.alloc(0)),Buffer.isBuffer(e)||(e=Buffer.from(e.toString()));const i=function(e){const t=new a(e);return function(e,r,n=0){r||(r=Buffer.alloc(e.length));for(let i of e){const e=t.next();r[n++]=i^e,t.updateKeys(i)}return r}}(r),o=s.genSalt();o[11]=t.crc>>>24&255,n&&(o[10]=t.crc>>>16&255);const c=Buffer.alloc(e.length+12);return i(o,c),i(e,c,12)},_salter:function(e){Buffer.isBuffer(e)&&e.length>=12?s.genSalt=function(){return e.slice(0,12)}:s.genSalt="node"===e?o.node:o}},Ar}function Mr(){return _r||(_r=1,kr.Deflater=(Dr||(Dr=1,Ir=function(e){var t=T,r={chunkSize:1024*(parseInt(e.length/1024)+1)};return{deflate:function(){return t.deflateRawSync(e,r)},deflateAsync:function(n){var i=t.createDeflateRaw(r),o=[],s=0;i.on("data",function(e){o.push(e),s+=e.length}),i.on("end",function(){var e=Buffer.alloc(s),t=0;e.fill(0);for(var r=0;r<o.length;r++){var i=o[r];i.copy(e,t),t+=i.length}n&&n(e)}),i.end(e)}}}),Ir),kr.Inflater=function(){if(Nr)return Or;Nr=1;const e=+(process.versions?process.versions.node:"").split(".")[0]||0;return Or=function(t,r){var n=T;const i=e>=15&&r>0?{maxOutputLength:r}:{};return{inflate:function(){return n.inflateRawSync(t,i)},inflateAsync:function(e){var r=n.createInflateRaw(i),o=[],s=0;r.on("data",function(e){o.push(e),s+=e.length}),r.on("end",function(){var t=Buffer.alloc(s),r=0;t.fill(0);for(var n=0;n<o.length;n++){var i=o[n];i.copy(t,r),r+=i.length}e&&e(t)}),r.end(t)}}},Or}(),kr.ZipCrypto=Br()),kr}function Gr(){if(Tr)return Rr;Tr=1;var e=gr(),t=Cr(),r=e.Constants,n=Mr();return Rr=function(i,o){var s=new t.EntryHeader,a=Buffer.alloc(0),c=Buffer.alloc(0),l=!1,u=null,f=Buffer.alloc(0),p=Buffer.alloc(0),h=!0;const d=i,m="object"==typeof d.decoder?d.decoder:e.decoder;function g(){return o&&o instanceof Uint8Array?(p=s.loadLocalHeaderFromBinary(o),o.slice(s.realDataOffset,s.realDataOffset+s.compressedSize)):Buffer.alloc(0)}function v(t){if(s.flags_desc){const n={},i=s.realDataOffset+s.compressedSize;if(o.readUInt32LE(i)==r.LOCSIG||o.readUInt32LE(i)==r.CENSIG)throw e.Errors.DESCRIPTOR_NOT_EXIST();if(o.readUInt32LE(i)==r.EXTSIG)n.crc=o.readUInt32LE(i+r.EXTCRC),n.compressedSize=o.readUInt32LE(i+r.EXTSIZ),n.size=o.readUInt32LE(i+r.EXTLEN);else{if(19280!==o.readUInt16LE(i+12))throw e.Errors.DESCRIPTOR_UNKNOWN();n.crc=o.readUInt32LE(i+r.EXTCRC-4),n.compressedSize=o.readUInt32LE(i+r.EXTSIZ-4),n.size=o.readUInt32LE(i+r.EXTLEN-4)}if(n.compressedSize!==s.compressedSize||n.size!==s.size||n.crc!==s.crc)throw e.Errors.DESCRIPTOR_FAULTY();if(e.crc32(t)!==n.crc)return!1}else if(e.crc32(t)!==s.localHeader.crc)return!1;return!0}function y(t,r,i){if(void 0===r&&"string"==typeof t&&(i=t,t=void 0),l)return t&&r&&r(Buffer.alloc(0),e.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var o=g();if(0===o.length)return t&&r&&r(o),o;if(s.encrypted){if("string"!=typeof i&&!Buffer.isBuffer(i))throw e.Errors.INVALID_PASS_PARAM();o=n.ZipCrypto.decrypt(o,s,i)}var c=Buffer.alloc(s.size);switch(s.method){case e.Constants.STORED:if(o.copy(c),v(c))return t&&r&&r(c),c;throw t&&r&&r(c,e.Errors.BAD_CRC()),e.Errors.BAD_CRC();case e.Constants.DEFLATED:var u=new n.Inflater(o,s.size);if(!t){if(u.inflate(c).copy(c,0),!v(c))throw e.Errors.BAD_CRC(`"${m.decode(a)}"`);return c}u.inflateAsync(function(t){t.copy(t,0),r&&(v(t)?r(t):r(t,e.Errors.BAD_CRC()))});break;default:throw t&&r&&r(Buffer.alloc(0),e.Errors.UNKNOWN_METHOD()),e.Errors.UNKNOWN_METHOD()}}function E(t,r){if((!u||!u.length)&&Buffer.isBuffer(o))return t&&r&&r(g()),g();if(u.length&&!l){var i;switch(s.method){case e.Constants.STORED:return s.compressedSize=s.size,i=Buffer.alloc(u.length),u.copy(i),t&&r&&r(i),i;default:case e.Constants.DEFLATED:var a=new n.Deflater(u);if(!t){var c=a.deflate();return s.compressedSize=c.length,c}a.deflateAsync(function(e){i=Buffer.alloc(e.length),s.compressedSize=e.length,e.copy(i),r&&r(i)}),a=null}}else{if(!t||!r)return Buffer.alloc(0);r(Buffer.alloc(0))}}function b(e,t){return(e.readUInt32LE(t+4)<<4)+e.readUInt32LE(t)}function w(e){var t,n,i,o;e.length>=r.EF_ZIP64_SCOMP&&(t=b(e,r.EF_ZIP64_SUNCOMP),s.size===r.EF_ZIP64_OR_32&&(s.size=t)),e.length>=r.EF_ZIP64_RHO&&(n=b(e,r.EF_ZIP64_SCOMP),s.compressedSize===r.EF_ZIP64_OR_32&&(s.compressedSize=n)),e.length>=r.EF_ZIP64_DSN&&(i=b(e,r.EF_ZIP64_RHO),s.offset===r.EF_ZIP64_OR_32&&(s.offset=i)),e.length>=r.EF_ZIP64_DSN+4&&(o=e.readUInt32LE(r.EF_ZIP64_DSN),s.diskNumStart===r.EF_ZIP64_OR_16&&(s.diskNumStart=o))}return h=!!m.hasOwnProperty("efs")&&m.efs,{get entryName(){return m.decode(a)},get rawEntryName(){return a},set entryName(t){var r=(a=e.toBuffer(t,m.encode))[a.length-1];l=47===r||92===r,s.fileNameLength=a.length},get efs(){return"function"==typeof h?h(this.entryName):h},get extra(){return f},set extra(t){f=t,s.extraLength=t.length,function(t){try{for(var n,i,o,s=0;s+4<t.length;)n=t.readUInt16LE(s),s+=2,i=t.readUInt16LE(s),s+=2,o=t.slice(s,s+i),s+=i,r.ID_ZIP64===n&&w(o)}catch(t){throw e.Errors.EXTRA_FIELD_PARSE_ERROR()}}(t)},get comment(){return m.decode(c)},set comment(t){if(c=e.toBuffer(t,m.encode),s.commentLength=c.length,c.length>65535)throw e.Errors.COMMENT_TOO_LONG()},get name(){var e=m.decode(a);return l?e.substr(e.length-1).split("/").pop():e.split("/").pop()},get isDirectory(){return l},getCompressedData:function(){return E(!1,null)},getCompressedDataAsync:function(e){E(!0,e)},setData:function(t){u=e.toBuffer(t,e.decoder.encode),!l&&u.length?(s.size=u.length,s.method=e.Constants.DEFLATED,s.crc=e.crc32(t),s.changed=!0):s.method=e.Constants.STORED},getData:function(e){return s.changed?u:y(!1,null,e)},getDataAsync:function(e,t){s.changed?e(u):y(!0,e,t)},set attr(e){s.attr=e},get attr(){return s.attr},set header(e){s.loadFromBinary(e)},get header(){return s},packCentralHeader:function(){s.flags_efs=this.efs,s.extraLength=f.length;var t=s.centralHeaderToBinary(),r=e.Constants.CENHDR;return a.copy(t,r),r+=a.length,f.copy(t,r),r+=s.extraLength,c.copy(t,r),t},packLocalHeader:function(){let e=0;s.flags_efs=this.efs,s.extraLocalLength=p.length;const t=s.localHeaderToBinary(),r=Buffer.alloc(t.length+a.length+s.extraLocalLength);return t.copy(r,e),e+=t.length,a.copy(r,e),e+=a.length,p.copy(r,e),e+=p.length,r},toJSON:function(){const e=function(e){return"<"+(e&&e.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:s.toJSON(),compressedData:e(o),data:e(u)}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}},Rr}function jr(){if($r)return xr;$r=1;const e=Gr(),t=Cr(),r=gr();return xr=function(n,i){var o=[],s={},a=Buffer.alloc(0),c=new t.MainHeader,l=!1;const u=new Set,f=i,{noSort:p,decoder:h}=f;function d(){if(l=!0,s={},c.diskEntries>(n.length-c.offset)/r.Constants.CENHDR)throw r.Errors.DISK_ENTRY_TOO_LARGE();o=new Array(c.diskEntries);for(var t=c.offset,i=0;i<o.length;i++){var a=t,p=new e(f,n);p.header=n.slice(a,a+=r.Constants.CENHDR),p.entryName=n.slice(a,a+=p.header.fileNameLength),p.header.extraLength&&(p.extra=n.slice(a,a+=p.header.extraLength)),p.header.commentLength&&(p.comment=n.slice(a,a+p.header.commentLength)),t+=p.header.centralHeaderSize,o[i]=p,s[p.entryName]=p}u.clear(),function(){const t=new Set;for(const e of Object.keys(s)){const r=e.split("/");if(r.pop(),r.length)for(let e=0;e<r.length;e++){const n=r.slice(0,e+1).join("/")+"/";t.add(n)}}for(const r of t)if(!(r in s)){const t=new e(f);t.entryName=r,t.attr=16,t.temporary=!0,o.push(t),s[t.entryName]=t,u.add(t)}}()}function m(){o.length>1&&!p&&o.sort((e,t)=>e.entryName.toLowerCase().localeCompare(t.entryName.toLowerCase()))}return n?function(e){var t=n.length-r.Constants.ENDHDR,i=Math.max(0,t-65535),o=i,s=n.length,l=-1,u=0;"boolean"==typeof f.trailingSpace&&f.trailingSpace&&(i=0);for(;t>=o;t--)if(80===n[t])if(n.readUInt32LE(t)!==r.Constants.ENDSIG)if(n.readUInt32LE(t)!==r.Constants.END64SIG){if(n.readUInt32LE(t)===r.Constants.ZIP64SIG){l=t,s=t+r.readBigUInt64LE(n,t+r.Constants.ZIP64SIZE)+r.Constants.ZIP64LEAD;break}}else o=i;else l=t,u=t,s=t+r.Constants.ENDHDR,o=t-r.Constants.END64HDR;if(-1==l)throw r.Errors.INVALID_FORMAT();c.loadFromBinary(n.slice(l,s)),c.commentLength&&(a=n.slice(u+r.Constants.ENDHDR));e&&d()}(f.readEntries):l=!0,{get entries(){return l||d(),o.filter(e=>!u.has(e))},get comment(){return h.decode(a)},set comment(e){a=r.toBuffer(e,h.encode),c.commentLength=a.length},getEntryCount:function(){return l?o.length:c.diskEntries},forEach:function(e){this.entries.forEach(e)},getEntry:function(e){return l||d(),s[e]||null},setEntry:function(e){l||d(),o.push(e),s[e.entryName]=e,c.totalEntries=o.length},deleteFile:function(e,t=!0){l||d();const r=s[e];this.getEntryChildren(r,t).map(e=>e.entryName).forEach(this.deleteEntry)},deleteEntry:function(e){l||d();const t=s[e],r=o.indexOf(t);r>=0&&(o.splice(r,1),delete s[e],c.totalEntries=o.length)},getEntryChildren:function(e,t=!0){if(l||d(),"object"==typeof e){if(e.isDirectory&&t){const t=[],r=e.entryName;for(const e of o)e.entryName.startsWith(r)&&t.push(e);return t}return[e]}return[]},getChildCount:function(e){if(e&&e.isDirectory){const t=this.getEntryChildren(e);return t.includes(e)?t.length-1:t.length}return 0},compressToBuffer:function(){l||d(),m();const e=[],t=[];let i=0,o=0;c.size=0,c.offset=0;let s=0;for(const r of this.entries){const n=r.getCompressedData();r.header.offset=o;const a=r.packLocalHeader(),l=a.length+n.length;o+=l,e.push(a),e.push(n);const u=r.packCentralHeader();t.push(u),c.size+=u.length,i+=l+u.length,s++}i+=c.mainHeaderSize,c.offset=o,c.totalEntries=s,o=0;const u=Buffer.alloc(i);for(const t of e)t.copy(u,o),o+=t.length;for(const e of t)e.copy(u,o),o+=e.length;const f=c.toBinary();return a&&a.copy(f,r.Constants.ENDHDR),f.copy(u,o),n=u,l=!1,u},toAsyncBuffer:function(e,t,i,o){try{l||d(),m();const t=[],s=[];let u=0,f=0,p=0;c.size=0,c.offset=0;const h=function(d){if(d.length>0){const e=d.shift(),r=e.entryName+e.extra.toString();i&&i(r),e.getCompressedDataAsync(function(n){o&&o(r),e.header.offset=f;const i=e.packLocalHeader(),a=i.length+n.length;f+=a,t.push(i),t.push(n);const l=e.packCentralHeader();s.push(l),c.size+=l.length,u+=a+l.length,p++,h(d)})}else{u+=c.mainHeaderSize,c.offset=f,c.totalEntries=p,f=0;const i=Buffer.alloc(u);t.forEach(function(e){e.copy(i,f),f+=e.length}),s.forEach(function(e){e.copy(i,f),f+=e.length});const o=c.toBinary();a&&a.copy(o,r.Constants.ENDHDR),o.copy(i,f),n=i,l=!1,e(i)}};h(Array.from(this.entries))}catch(e){t(e)}}}},xr}var zr=function(){if(Ur)return Fr;Ur=1;const e=gr(),t=R,r=Gr(),n=jr(),i=(...t)=>e.findLast(t,e=>"boolean"==typeof e),o=(...t)=>e.findLast(t,e=>"string"==typeof e),s={noSort:!1,readEntries:!1,method:e.Constants.NONE,fs:null};return Fr=function(a,c){let l=null;const u=Object.assign(Object.create(null),s);a&&"object"==typeof a&&(a instanceof Uint8Array||(Object.assign(u,a),a=u.input?u.input:void 0,u.input&&delete u.input),Buffer.isBuffer(a)&&(l=a,u.method=e.Constants.BUFFER,a=void 0)),Object.assign(u,c);const f=new e(u);if("object"==typeof u.decoder&&"function"==typeof u.decoder.encode&&"function"==typeof u.decoder.decode||(u.decoder=e.decoder),a&&"string"==typeof a){if(!f.fs.existsSync(a))throw e.Errors.INVALID_FILENAME();u.method=e.Constants.FILE,u.filename=a,l=f.fs.readFileSync(a)}const p=new n(l,u),{canonical:h,sanitize:d,zipnamefix:m}=e;function g(e){var r;if(e&&p&&("string"==typeof e&&(r=p.getEntry(t.posix.normalize(e))),"object"==typeof e&&void 0!==e.entryName&&void 0!==e.header&&(r=p.getEntry(e.entryName)),r))return r;return null}function v(e){const{join:r,normalize:n,sep:i}=t.posix;return r(".",n(i+e.split("\\").join(i)+i))}function y(e){return e instanceof RegExp?(t=e,function(e){return t.test(e)}):"function"!=typeof e?()=>!0:e;var t}const E=(e,r)=>{let n=r.slice(-1);return n=n===f.sep?f.sep:"",t.relative(e,r)+n};return{readFile:function(e,t){var r=g(e);return r&&r.getData(t)||null},childCount:function(e){const t=g(e);if(t)return p.getChildCount(t)},readFileAsync:function(e,t){var r=g(e);r?r.getDataAsync(t):t(null,"getEntry failed for:"+e)},readAsText:function(e,t){var r=g(e);if(r){var n=r.getData();if(n&&n.length)return n.toString(t||"utf8")}return""},readAsTextAsync:function(e,t,r){var n=g(e);n?n.getDataAsync(function(e,n){n?t(e,n):e&&e.length?t(e.toString(r||"utf8")):t("")}):t("")},deleteFile:function(e,t=!0){var r=g(e);r&&p.deleteFile(r.entryName,t)},deleteEntry:function(e){var t=g(e);t&&p.deleteEntry(t.entryName)},addZipComment:function(e){p.comment=e},getZipComment:function(){return p.comment||""},addZipEntryComment:function(e,t){var r=g(e);r&&(r.comment=t)},getZipEntryComment:function(e){var t=g(e);return t&&t.comment||""},updateFile:function(e,t){var r=g(e);r&&r.setData(t)},addLocalFile:function(r,n,i,o){if(!f.fs.existsSync(r))throw e.Errors.FILE_NOT_FOUND(r);{n=n?v(n):"";const e=t.win32.basename(t.win32.normalize(r));n+=i||e;const s=f.fs.statSync(r),a=s.isFile()?f.fs.readFileSync(r):Buffer.alloc(0);s.isDirectory()&&(n+=f.sep),this.addFile(n,a,o,s)}},addLocalFileAsync:function(e,r){e="object"==typeof e?e:{localPath:e};const n=t.resolve(e.localPath),{comment:i}=e;let{zipPath:o,zipName:s}=e;const a=this;f.fs.stat(n,function(e,c){if(e)return r(e,!1);o=o?v(o):"";const l=t.win32.basename(t.win32.normalize(n));if(o+=s||l,c.isFile())f.fs.readFile(n,function(e,t){return e?r(e,!1):(a.addFile(o,t,i,c),setImmediate(r,void 0,!0))});else if(c.isDirectory())return o+=f.sep,a.addFile(o,Buffer.alloc(0),i,c),setImmediate(r,void 0,!0)})},addLocalFolder:function(r,n,i){if(i=y(i),n=n?v(n):"",r=t.normalize(r),!f.fs.existsSync(r))throw e.Errors.FILE_NOT_FOUND(r);{const e=f.findFiles(r),o=this;if(e.length)for(const s of e){const e=t.join(n,E(r,s));i(e)&&o.addLocalFile(s,t.dirname(e))}}},addLocalFolderAsync:function(r,n,i,o){o=y(o),i=i?v(i):"",r=t.normalize(r);var s=this;f.fs.open(r,"r",function(t){if(t&&"ENOENT"===t.code)n(void 0,e.Errors.FILE_NOT_FOUND(r));else if(t)n(void 0,t);else{var a=f.findFiles(r),c=-1,l=function(){if((c+=1)<a.length){var e=a[c],t=E(r,e).split("\\").join("/");t=t.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),o(t)?f.fs.stat(e,function(r,o){r&&n(void 0,r),o.isFile()?f.fs.readFile(e,function(e,r){e?n(void 0,e):(s.addFile(i+t,r,"",o),l())}):(s.addFile(i+t+"/",Buffer.alloc(0),"",o),l())}):process.nextTick(()=>{l()})}else n(!0,void 0)};l()}})},addLocalFolderAsync2:function(r,n){const i=this;r="object"==typeof r?r:{localPath:r},localPath=t.resolve(v(r.localPath));let{zipPath:o,filter:s,namefix:a}=r;var c;s instanceof RegExp?(c=s,s=function(e){return c.test(e)}):"function"!=typeof s&&(s=function(){return!0}),o=o?v(o):"","latin1"==a&&(a=e=>e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),"function"!=typeof a&&(a=e=>e);const l=e=>t.join(o,a(E(localPath,e))),u=e=>t.win32.basename(t.win32.normalize(a(e)));f.fs.open(localPath,"r",function(r){r&&"ENOENT"===r.code?n(void 0,e.Errors.FILE_NOT_FOUND(localPath)):r?n(void 0,r):f.findFilesAsync(localPath,function(e,r){if(e)return n(e);(r=r.filter(e=>s(l(e)))).length||n(void 0,!1),setImmediate(r.reverse().reduce(function(e,r){return function(n,o){if(n||!1===o)return setImmediate(e,n,!1);i.addLocalFileAsync({localPath:r,zipPath:t.dirname(l(r)),zipName:u(r)},e)}},n))})})},addLocalFolderPromise:function(e,t){return new Promise((r,n)=>{this.addLocalFolderAsync2(Object.assign({localPath:e},t),(e,t)=>{e&&n(e),t&&r(this)})})},addFile:function(e,t,n,i){let o=g(e=m(e));const s=null!=o;s||(o=new r(u),o.entryName=e),o.comment=n||"";const a="object"==typeof i&&i instanceof f.fs.Stats;a&&(o.header.time=i.mtime);var c=o.isDirectory?16:0;let l=o.isDirectory?16384:32768;return l|=a?4095&i.mode:"number"==typeof i?4095&i:o.isDirectory?493:420,c=(c|l<<16)>>>0,o.attr=c,o.setData(t),s||p.setEntry(o),o},getEntries:function(e){return p.password=e,p?p.entries:[]},getEntry:function(e){return g(e)},getEntryCount:function(){return p.getEntryCount()},forEach:function(e){return p.forEach(e)},extractEntryTo:function(r,n,s,a,c,l){a=i(!1,a),c=i(!1,c),s=i(!0,s),l=o(c,l);var u=g(r);if(!u)throw e.Errors.NO_ENTRY();var m=h(u.entryName),v=d(n,l&&!u.isDirectory?l:s?m:t.basename(m));if(u.isDirectory)return p.getEntryChildren(u).forEach(function(r){if(r.isDirectory)return;var i=r.getData();if(!i)throw e.Errors.CANT_EXTRACT_FILE();var o=h(r.entryName),l=d(n,s?o:t.basename(o));const u=c?r.header.fileAttr:void 0;f.writeFileTo(l,i,a,u)}),!0;var y=u.getData(p.password);if(!y)throw e.Errors.CANT_EXTRACT_FILE();if(f.fs.existsSync(v)&&!a)throw e.Errors.CANT_OVERRIDE();const E=c?r.header.fileAttr:void 0;return f.writeFileTo(v,y,a,E),!0},test:function(e){if(!p)return!1;for(var t in p.entries)try{if(t.isDirectory)continue;if(!p.entries[t].getData(e))return!1}catch(e){return!1}return!0},extractAllTo:function(t,r,n,s){if(n=i(!1,n),s=o(n,s),r=i(!1,r),!p)throw e.Errors.NO_ZIP();p.entries.forEach(function(i){var o=d(t,h(i.entryName));if(i.isDirectory)return void f.makeDir(o);var a=i.getData(s);if(!a)throw e.Errors.CANT_EXTRACT_FILE();const c=n?i.header.fileAttr:void 0;f.writeFileTo(o,a,r,c);try{f.fs.utimesSync(o,i.header.time,i.header.time)}catch(t){throw e.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(r,n,o,s){if(s=((...t)=>e.findLast(t,e=>"function"==typeof e))(n,o,s),o=i(!1,o),n=i(!1,n),!s)return new Promise((e,t)=>{this.extractAllToAsync(r,n,o,function(r){r?t(r):e(this)})});if(!p)return void s(e.Errors.NO_ZIP());r=t.resolve(r);const a=e=>d(r,t.normalize(h(e.entryName))),c=(e,t)=>new Error(e+': "'+t+'"'),l=[],u=[];p.entries.forEach(e=>{e.isDirectory?l.push(e):u.push(e)});for(const e of l){const t=a(e),r=o?e.header.fileAttr:void 0;try{f.makeDir(t),r&&f.fs.chmodSync(t,r),f.fs.utimesSync(t,e.header.time,e.header.time)}catch(e){s(c("Unable to create folder",t))}}u.reverse().reduce(function(i,s){return function(a){if(a)i(a);else{const a=t.normalize(h(s.entryName)),l=d(r,a);s.getDataAsync(function(t,r){if(r)i(r);else if(t){const e=o?s.header.fileAttr:void 0;f.writeFileToAsync(l,t,n,e,function(e){e||i(c("Unable to write file",l)),f.fs.utimes(l,s.header.time,s.header.time,function(e){e?i(c("Unable to set times",l)):i()})})}else i(e.Errors.CANT_EXTRACT_FILE())})}}},s)()},writeZip:function(e,t){if(1===arguments.length&&"function"==typeof e&&(t=e,e=""),!e&&u.filename&&(e=u.filename),e){var r=p.compressToBuffer();if(r){var n=f.writeFileTo(e,r,!0);"function"==typeof t&&t(n?null:new Error("failed"),"")}}},writeZipPromise:function(e,t){const{overwrite:r,perm:n}=Object.assign({overwrite:!0},t);return new Promise((t,i)=>{!e&&u.filename&&(e=u.filename),e||i("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(o=>{f.writeFileToAsync(e,o,r,n,e=>e?t(e):i("ADM-ZIP: Wasn't able to write zip file"))},i)})},toBufferPromise:function(){return new Promise((e,t)=>{p.toAsyncBuffer(e,t)})},toBuffer:function(e,t,r,n){return"function"==typeof e?(p.toAsyncBuffer(e,t,r,n),null):p.compressToBuffer()}}},Fr}(),Hr=ue(zr);class qr{#K;get ora(){return this.#K}set attachConsole(e){e?(console.log=this.info.bind(this),console.info=this.info.bind(this)):console=Yr}static Global(e){return Wr=new qr(e),Wr}static Clone(e){const{prefixText:t}=e||Wr;return new qr({prefixText:t})}static get Current(){return Wr}static set Current(e){Wr=e}constructor(e){this.#K=$(e)}get prefixText(){return this.#K.prefixText}info(...e){this.#K.info(Vr(e))}succeed(...e){this.#K.succeed(Vr(e))}start(...e){this.#K.start(Vr(e))}fail(...e){this.#K.fail(Vr(e))}warn(...e){this.#K.warn(Vr(e))}clear(){this.#K.clear()}stop(){this.#K.stop()}stopAndPersist(...e){this.#K.stopAndPersist(...e)}}let Wr=new qr;const Vr=e=>e.length?e.join(" "):void 0,Yr=console;let Kr=class{spinner;debugMode;constructor(e,t){this.spinner=new qr({prefixText:e}),this.debugMode=t?.debug??!1}start(...e){this.spinner.start(...e)}succeed(...e){this.spinner.succeed(...e)}fail(...e){this.spinner.fail(...e)}error(...e){console.log(...e)}warn(...e){this.spinner.warn(...e)}info(...e){this.spinner.info(...e)}log(...e){this.spinner.info(...e)}debug(...e){this.debugMode&&console.debug(...e)}startNativeConsoleCapture(){this.spinner.attachConsole=!0}stopNativeConsoleCapture(){this.spinner.attachConsole=!1}};const Zr=e=>{const t={spa:{templateEnv:(r=e.template,{portal:{id:"@equinor/fusion-framework-dev-portal"},title:"Fusion Dev Portal",serviceDiscovery:{url:"/@fusion-services",scopes:["5a842df8-3238-415d-b168-9f16a6a6031b/.default"]},msal:{clientId:"9b707e3a-3e90-41ed-a47e-652a1e3b53d0",tenantId:"3aa4a235-b6e2-48d5-9195-7fcf05b459b0",redirectUri:"/authentication/login-callback",requiresAuth:"true"},serviceWorker:{resources:[{url:"/apps-proxy",rewrite:"/@fusion-api/apps",scopes:["5a842df8-3238-415d-b168-9f16a6a6031b/.default"]},{url:"/help-proxy",rewrite:"/@fusion-api/help",scopes:["5a842df8-3238-415d-b168-9f16a6a6031b/.default"]}]},...r})},api:{serviceDiscoveryUrl:"https://discovery.fusion.equinor.com/service-registry/environments/ci/services/",processServices:(e,t)=>{const{data:r,routes:n}=U(e,t);return{data:r.concat({key:"portals",name:"Portal Service - MOCK",uri:"/@fusion-api/portals"}),routes:n}}}};var r;return e.app&&((e,t,r)=>{const{build:n,appKey:i}=t;if(!n)throw new Error("App manifest does not contain build information");e.api.routes??=[],e.api.routes.push({match:[`/apps/bundles/apps/${i}/${n.version}/*path`,`/apps/bundles/apps/${i}@${n.version}/*path`],middleware:async(e,t,r)=>{const n=e.params?.path;!1===Array.isArray(n)&&r(),t.writeHead(302,{"content-type":"application/javascript",location:`/${n.join("/")}`}),t.end()}}),e.api.routes.push({match:`/apps/persons/me/apps/${i}`,middleware:async(e,r)=>{r.writeHead(200,{"content-type":"application/json"}),r.end(JSON.stringify({id:"dev-server-generated-id",...t}))}}),e.api.routes.push({match:`/apps/apps/${i}/builds/${n.version}/config`,middleware:async(e,t)=>{t.writeHead(200,{"content-type":"application/json"}),t.end(JSON.stringify(r))}})})(t,e.app.manifest,e.app.config),e.portal&&((e,t,r)=>{e.api.routes??=[];const n="portal-config";e.api.routes.push({match:`/${n}/portals/${t.name}{@:tag}`,middleware:async(e,r)=>{r.writeHead(200,{"content-type":"application/json"}),r.end(JSON.stringify(t))}}),r&&e.api.routes.push({match:`/${n}/portals/${t.name}{@:tag}/config`,middleware:async(e,t)=>{t.writeHead(200,{"content-type":"application/json"}),t.end(JSON.stringify(r))}})})(t,e.portal.manifest,e.portal.config),t},Xr=async(e,t,r)=>{const n=Zr(t),i=await(async(e,t,r)=>C("dev-server.config",{baseDir:e.root,extensions:r?.extensions,script:{resolve:async r=>{let n;if("function"==typeof r.default){const i={...t};n=await r.default(e,{base:i})}else n=r.default;return Rt(t,n??{})}}}))(e,n).catch(()=>({config:n}));return F(i.config,r)},Jr=(e,t,r)=>{const n=i(String(e));E(n)||b(n,{recursive:!0}),w(e,t,r)},Qr=["package.json","LICENSE.md","README.md","CHANGELOG.md"],en=async(e,t)=>{const{archive:r,log:n}=t??{},s=i(e.path),a=t?.buildDir??"dist",c=o(s,a);if(!(await L(c)).isDirectory())throw new Error(`Build directory ${a} does not exist`);n?.log(le.bold("Starting to pack bundle"));const l=new Hr;if(l.addLocalFolder(c,a),t?.content)for(const[e,r]of Object.entries(t.content))l.addFile(e,Buffer.from(r)),n?.info("📄",Zt(e,{relative:!0}));n?.info("📂",Zt(c,{relative:!0}));for(const t of Qr.concat(e.packageJson.files??[])){const e=o(s,t),r=i(e.replace(s,""));At(e)?(l.addLocalFile(e,r),n?.info("📄",Zt(e,{relative:!0}))):n?.warn(le.dim("📄",Zt(e,{relative:!0})))}return r&&(At(i(r))||await S(i(r),{recursive:!0}),n?.start("compressing content"),await l.writeZipPromise(r),n?.succeed("📚",Zt(r,{relative:!0}),Xt(r))),l},tn=async e=>{const{log:t,manifest:r}=e;process.env.NODE_ENV,process.cwd();const{pkg:n,manifest:i}=await tr({log:t,manifest:r});if(!i.build)throw new Error("Manifest build config not found");return{archive:await en(n,{log:t,archive:e?.archive,content:{"app-manifest.json":JSON.stringify(i.build,null,2),"metadata.json":JSON.stringify({name:i.appKey,version:i.build.version})}}).catch(e=>{t?.error("Failed to create package:",e),process.exit(1)}),manifest:i}},rn=async(e,t)=>{const{log:r}=t;try{r?.start("create application configuration"),r?.info(`generating config with ${le.red.dim(e.command)} command in ${le.green.dim(e.mode)} mode`);const n=await((e,t)=>{const r=t?.file??[`app.config.${e.environment}`,"app.config"];return C(r,{baseDir:e.root,extensions:t?.extensions,script:{resolve:async r=>{const n=t?.base??{environment:{}};if("function"==typeof r.default){const t=await r.default(e,{base:n})??n;return jt.parse(t??n)}return jt.parse(r.default??n)}}})})(e,{file:t?.config});return r?.succeed("⚙️ generated config from ",Zt(n.path,{relative:!0})),n.config}catch(e){if(e instanceof I){if(!t.config)return r?.succeed(le.dim("⚙️ no local application config applied, using built-in")),{environment:{}};r?.warn(`failed to load config file ${Zt(t.config)}, please check the path.`)}throw r?.fail("failed to resolve application config"),r?.debug(e),e}},nn=async e=>{const{log:t}=e??{},r=await Qt(t),n={command:"build",mode:process.env.NODE_ENV??"production",root:r.root,...e?.env},i=await rn(n,{log:t,config:e?.config});if(t?.debug("config:",i),e?.output){t?.start("writing config to file");try{await Jr(e.output,JSON.stringify(i,null,2)),t?.succeed("config written successfully",Zt(e.output,{relative:!0}))}catch(e){throw t?.fail("failed to write config"),e}}return{config:i,pkg:r}};class on extends Error{response;static Name="HttpResponseError";constructor(e,t,r){super(e,r),this.response=t}}class sn extends on{static Name="HttpJsonResponseError";data;constructor(e,t,r){super(e,t,r),this.name=sn.Name,this.data=r?.data}}class an extends on{static Name="ServerSentEventResponseError";constructor(e,t,r){super(e,t,r),this.name=an.Name}}var cn,ln,un,fn,pn,hn,dn,mn,gn,vn,yn,En,bn,wn,Ln,Sn,Cn,In,Dn,On,Nn,An,Pn,_n,Rn,Tn,xn,$n,Fn,Un,kn,Bn,Mn,Gn,jn,zn,Hn,qn,Wn,Vn,Yn,Kn,Zn,Xn,Jn,Qn,ei,ti,ri,ni,ii,oi,si,ai,ci,li,ui,fi,pi,hi,di,mi,gi,vi,yi,Ei,bi,wi,Li,Si,Ci,Ii;function Di(){if(wn)return bn;wn=1;const e=xe();return bn=(t,r,n)=>new e(t,n).compare(new e(r,n)),bn}function Oi(){if(On)return Dn;On=1;const e=xe();return Dn=(t,r,n)=>{const i=new e(t,n),o=new e(r,n);return i.compare(o)||i.compareBuild(o)},Dn}function Ni(){if(Tn)return Rn;Tn=1;const e=Di();return Rn=(t,r,n)=>e(t,r,n)>0,Rn}function Ai(){if($n)return xn;$n=1;const e=Di();return xn=(t,r,n)=>e(t,r,n)<0,xn}function Pi(){if(Un)return Fn;Un=1;const e=Di();return Fn=(t,r,n)=>0===e(t,r,n),Fn}function _i(){if(Bn)return kn;Bn=1;const e=Di();return kn=(t,r,n)=>0!==e(t,r,n),kn}function Ri(){if(Gn)return Mn;Gn=1;const e=Di();return Mn=(t,r,n)=>e(t,r,n)>=0,Mn}function Ti(){if(zn)return jn;zn=1;const e=Di();return jn=(t,r,n)=>e(t,r,n)<=0,jn}function xi(){if(qn)return Hn;qn=1;const e=Pi(),t=_i(),r=Ni(),n=Ri(),i=Ai(),o=Ti();return Hn=(s,a,c,l)=>{switch(a){case"===":return"object"==typeof s&&(s=s.version),"object"==typeof c&&(c=c.version),s===c;case"!==":return"object"==typeof s&&(s=s.version),"object"==typeof c&&(c=c.version),s!==c;case"":case"=":case"==":return e(s,c,l);case"!=":return t(s,c,l);case">":return r(s,c,l);case">=":return n(s,c,l);case"<":return i(s,c,l);case"<=":return o(s,c,l);default:throw new TypeError(`Invalid operator: ${a}`)}},Hn}function $i(){if(Xn)return Zn;Xn=1;const e=/\s+/g;class t{constructor(r,o){if(o=n(o),r instanceof t)return r.loose===!!o.loose&&r.includePrerelease===!!o.includePrerelease?r:new t(r.raw,o);if(r instanceof i)return this.raw=r.value,this.set=[[r]],this.formatted=void 0,this;if(this.options=o,this.loose=!!o.loose,this.includePrerelease=!!o.includePrerelease,this.raw=r.trim().replace(e," "),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=>!d(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&&m(e[0])){this.set=[e];break}}this.formatted=void 0}get range(){if(void 0===this.formatted){this.formatted="";for(let e=0;e<this.set.length;e++){e>0&&(this.formatted+="||");const t=this.set[e];for(let e=0;e<t.length;e++)e>0&&(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&&p)|(this.options.loose&&h))+":"+e,n=r.get(t);if(n)return n;const s=this.options.loose,m=s?a[c.HYPHENRANGELOOSE]:a[c.HYPHENRANGE];e=e.replace(m,O(this.options.includePrerelease)),o("hyphen replace",e),e=e.replace(a[c.COMPARATORTRIM],l),o("comparator trim",e),e=e.replace(a[c.TILDETRIM],u),o("tilde trim",e),e=e.replace(a[c.CARETTRIM],f),o("caret trim",e);let g=e.split(" ").map(e=>v(e,this.options)).join(" ").split(/\s+/).map(e=>D(e,this.options));s&&(g=g.filter(e=>(o("loose invalid filter",e,this.options),!!e.match(a[c.COMPARATORLOOSE])))),o("range list",g);const y=new Map,E=g.map(e=>new i(e,this.options));for(const e of E){if(d(e))return[e];y.set(e.value,e)}y.size>1&&y.has("")&&y.delete("");const b=[...y.values()];return r.set(t,b),b}intersects(e,r){if(!(e instanceof t))throw new TypeError("a Range is required");return this.set.some(t=>g(t,r)&&e.set.some(e=>g(e,r)&&t.every(t=>e.every(e=>t.intersects(e,r)))))}test(e){if(!e)return!1;if("string"==typeof e)try{e=new s(e,this.options)}catch(e){return!1}for(let t=0;t<this.set.length;t++)if(N(this.set[t],e,this.options))return!0;return!1}}Zn=t;const r=new(Kn?Yn:(Kn=1,Yn=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}})),n=Re(),i=Fi(),o=me(),s=xe(),{safeRe:a,t:c,comparatorTrimReplace:l,tildeTrimReplace:u,caretTrimReplace:f}=_e(),{FLAG_INCLUDE_PRERELEASE:p,FLAG_LOOSE:h}=ge(),d=e=>"<0.0.0-0"===e.value,m=e=>""===e.value,g=(e,t)=>{let r=!0;const n=e.slice();let i=n.pop();for(;r&&n.length;)r=n.every(e=>i.intersects(e,t)),i=n.pop();return r},v=(e,t)=>(o("comp",e,t),e=w(e,t),o("caret",e),e=E(e,t),o("tildes",e),e=S(e,t),o("xrange",e),e=I(e,t),o("stars",e),e),y=e=>!e||"x"===e.toLowerCase()||"*"===e,E=(e,t)=>e.trim().split(/\s+/).map(e=>b(e,t)).join(" "),b=(e,t)=>{const r=t.loose?a[c.TILDELOOSE]:a[c.TILDE];return e.replace(r,(t,r,n,i,s)=>{let a;return o("tilde",e,t,r,n,i,s),y(r)?a="":y(n)?a=`>=${r}.0.0 <${+r+1}.0.0-0`:y(i)?a=`>=${r}.${n}.0 <${r}.${+n+1}.0-0`:s?(o("replaceTilde pr",s),a=`>=${r}.${n}.${i}-${s} <${r}.${+n+1}.0-0`):a=`>=${r}.${n}.${i} <${r}.${+n+1}.0-0`,o("tilde return",a),a})},w=(e,t)=>e.trim().split(/\s+/).map(e=>L(e,t)).join(" "),L=(e,t)=>{o("caret",e,t);const r=t.loose?a[c.CARETLOOSE]:a[c.CARET],n=t.includePrerelease?"-0":"";return e.replace(r,(t,r,i,s,a)=>{let c;return o("caret",e,t,r,i,s,a),y(r)?c="":y(i)?c=`>=${r}.0.0${n} <${+r+1}.0.0-0`:y(s)?c="0"===r?`>=${r}.${i}.0${n} <${r}.${+i+1}.0-0`:`>=${r}.${i}.0${n} <${+r+1}.0.0-0`:a?(o("replaceCaret pr",a),c="0"===r?"0"===i?`>=${r}.${i}.${s}-${a} <${r}.${i}.${+s+1}-0`:`>=${r}.${i}.${s}-${a} <${r}.${+i+1}.0-0`:`>=${r}.${i}.${s}-${a} <${+r+1}.0.0-0`):(o("no pr"),c="0"===r?"0"===i?`>=${r}.${i}.${s}${n} <${r}.${i}.${+s+1}-0`:`>=${r}.${i}.${s}${n} <${r}.${+i+1}.0-0`:`>=${r}.${i}.${s} <${+r+1}.0.0-0`),o("caret return",c),c})},S=(e,t)=>(o("replaceXRanges",e,t),e.split(/\s+/).map(e=>C(e,t)).join(" ")),C=(e,t)=>{e=e.trim();const r=t.loose?a[c.XRANGELOOSE]:a[c.XRANGE];return e.replace(r,(r,n,i,s,a,c)=>{o("xRange",e,r,n,i,s,a,c);const l=y(i),u=l||y(s),f=u||y(a),p=f;return"="===n&&p&&(n=""),c=t.includePrerelease?"-0":"",l?r=">"===n||"<"===n?"<0.0.0-0":"*":n&&p?(u&&(s=0),a=0,">"===n?(n=">=",u?(i=+i+1,s=0,a=0):(s=+s+1,a=0)):"<="===n&&(n="<",u?i=+i+1:s=+s+1),"<"===n&&(c="-0"),r=`${n+i}.${s}.${a}${c}`):u?r=`>=${i}.0.0${c} <${+i+1}.0.0-0`:f&&(r=`>=${i}.${s}.0${c} <${i}.${+s+1}.0-0`),o("xRange return",r),r})},I=(e,t)=>(o("replaceStars",e,t),e.trim().replace(a[c.STAR],"")),D=(e,t)=>(o("replaceGTE0",e,t),e.trim().replace(a[t.includePrerelease?c.GTE0PRE:c.GTE0],"")),O=e=>(t,r,n,i,o,s,a,c,l,u,f,p)=>`${r=y(n)?"":y(i)?`>=${n}.0.0${e?"-0":""}`:y(o)?`>=${n}.${i}.0${e?"-0":""}`:s?`>=${r}`:`>=${r}${e?"-0":""}`} ${c=y(l)?"":y(u)?`<${+l+1}.0.0-0`:y(f)?`<${l}.${+u+1}.0-0`:p?`<=${l}.${u}.${f}-${p}`:e?`<${l}.${u}.${+f+1}-0`:`<=${c}`}`.trim(),N=(e,t,r)=>{for(let r=0;r<e.length;r++)if(!e[r].test(t))return!1;if(t.prerelease.length&&!r.includePrerelease){for(let r=0;r<e.length;r++)if(o(e[r].semver),e[r].semver!==i.ANY&&e[r].semver.prerelease.length>0){const n=e[r].semver;if(n.major===t.major&&n.minor===t.minor&&n.patch===t.patch)return!0}return!1}return!0};return Zn}function Fi(){if(Qn)return Jn;Qn=1;const e=Symbol("SemVer ANY");class t{static get ANY(){return e}constructor(n,i){if(i=r(i),n instanceof t){if(n.loose===!!i.loose)return n;n=n.value}n=n.trim().split(/\s+/).join(" "),s("comparator",n,i),this.options=i,this.loose=!!i.loose,this.parse(n),this.semver===e?this.value="":this.value=this.operator+this.semver.version,s("comp",this)}parse(t){const r=this.options.loose?n[i.COMPARATORLOOSE]:n[i.COMPARATOR],o=t.match(r);if(!o)throw new TypeError(`Invalid comparator: ${t}`);this.operator=void 0!==o[1]?o[1]:"","="===this.operator&&(this.operator=""),o[2]?this.semver=new a(o[2],this.options.loose):this.semver=e}toString(){return this.value}test(t){if(s("Comparator.test",t,this.options.loose),this.semver===e||t===e)return!0;if("string"==typeof t)try{t=new a(t,this.options)}catch(e){return!1}return o(t,this.operator,this.semver,this.options)}intersects(e,n){if(!(e instanceof t))throw new TypeError("a Comparator is required");return""===this.operator?""===this.value||new c(e.value,n).test(this.value):""===e.operator?""===e.value||new c(this.value,n).test(e.semver):(!(n=r(n)).includePrerelease||"<0.0.0-0"!==this.value&&"<0.0.0-0"!==e.value)&&(!(!n.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("="))||(!!(o(this.semver,"<",e.semver,n)&&this.operator.startsWith(">")&&e.operator.startsWith("<"))||!!(o(this.semver,">",e.semver,n)&&this.operator.startsWith("<")&&e.operator.startsWith(">")))))))}}Jn=t;const r=Re(),{safeRe:n,t:i}=_e(),o=xi(),s=me(),a=xe(),c=$i();return Jn}function Ui(){if(ti)return ei;ti=1;const e=$i();return ei=(t,r,n)=>{try{r=new e(r,n)}catch(e){return!1}return r.test(t)},ei}function ki(){if(fi)return ui;fi=1;const e=$i();return ui=(t,r)=>{try{return new e(t,r).range||"*"}catch(e){return null}},ui}function Bi(){if(hi)return pi;hi=1;const e=xe(),t=Fi(),{ANY:r}=t,n=$i(),i=Ui(),o=Ni(),s=Ai(),a=Ti(),c=Ri();return pi=(l,u,f,p)=>{let h,d,m,g,v;switch(l=new e(l,p),u=new n(u,p),f){case">":h=o,d=a,m=s,g=">",v=">=";break;case"<":h=s,d=c,m=o,g="<",v="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(i(l,u,p))return!1;for(let e=0;e<u.set.length;++e){const n=u.set[e];let i=null,o=null;if(n.forEach(e=>{e.semver===r&&(e=new t(">=0.0.0")),i=i||e,o=o||e,h(e.semver,i.semver,p)?i=e:m(e.semver,o.semver,p)&&(o=e)}),i.operator===g||i.operator===v)return!1;if((!o.operator||o.operator===g)&&d(l,o.semver))return!1;if(o.operator===v&&m(l,o.semver))return!1}return!0},pi}var Mi=function(){if(Ii)return Ci;Ii=1;const e=_e(),t=ge(),r=xe(),n=Te(),i=$e(),o=Fe(),s=Ue(),a=function(){if(ln)return cn;ln=1;const e=xe();return cn=(t,r,n,i,o)=>{"string"==typeof n&&(o=i,i=n,n=void 0);try{return new e(t instanceof e?t.version:t,n).inc(r,i,o).version}catch(e){return null}},cn}(),c=function(){if(fn)return un;fn=1;const e=$e();return un=(t,r)=>{const n=e(t,null,!0),i=e(r,null,!0),o=n.compare(i);if(0===o)return null;const s=o>0,a=s?n:i,c=s?i:n,l=!!a.prerelease.length;if(c.prerelease.length&&!l){if(!c.patch&&!c.minor)return"major";if(0===c.compareMain(a))return c.minor&&!c.patch?"minor":"patch"}const u=l?"pre":"";return n.major!==i.major?u+"major":n.minor!==i.minor?u+"minor":n.patch!==i.patch?u+"patch":"prerelease"}}(),l=function(){if(hn)return pn;hn=1;const e=xe();return pn=(t,r)=>new e(t,r).major,pn}(),u=function(){if(mn)return dn;mn=1;const e=xe();return dn=(t,r)=>new e(t,r).minor,dn}(),f=function(){if(vn)return gn;vn=1;const e=xe();return gn=(t,r)=>new e(t,r).patch,gn}(),p=function(){if(En)return yn;En=1;const e=$e();return yn=(t,r)=>{const n=e(t,r);return n&&n.prerelease.length?n.prerelease:null},yn}(),h=Di(),d=function(){if(Sn)return Ln;Sn=1;const e=Di();return Ln=(t,r,n)=>e(r,t,n),Ln}(),m=function(){if(In)return Cn;In=1;const e=Di();return Cn=(t,r)=>e(t,r,!0),Cn}(),g=Oi(),v=function(){if(An)return Nn;An=1;const e=Oi();return Nn=(t,r)=>t.sort((t,n)=>e(t,n,r)),Nn}(),y=function(){if(_n)return Pn;_n=1;const e=Oi();return Pn=(t,r)=>t.sort((t,n)=>e(n,t,r)),Pn}(),E=Ni(),b=Ai(),w=Pi(),L=_i(),S=Ri(),C=Ti(),I=xi(),D=function(){if(Vn)return Wn;Vn=1;const e=xe(),t=$e(),{safeRe:r,t:n}=_e();return Wn=(i,o)=>{if(i instanceof e)return i;if("number"==typeof i&&(i=String(i)),"string"!=typeof i)return null;let s=null;if((o=o||{}).rtl){const e=o.includePrerelease?r[n.COERCERTLFULL]:r[n.COERCERTL];let t;for(;(t=e.exec(i))&&(!s||s.index+s[0].length!==i.length);)s&&t.index+t[0].length===s.index+s[0].length||(s=t),e.lastIndex=t.index+t[1].length+t[2].length;e.lastIndex=-1}else s=i.match(o.includePrerelease?r[n.COERCEFULL]:r[n.COERCE]);if(null===s)return null;const a=s[2],c=s[3]||"0",l=s[4]||"0",u=o.includePrerelease&&s[5]?`-${s[5]}`:"",f=o.includePrerelease&&s[6]?`+${s[6]}`:"";return t(`${a}.${c}.${l}${u}${f}`,o)},Wn}(),O=Fi(),N=$i(),A=Ui(),P=function(){if(ni)return ri;ni=1;const e=$i();return ri=(t,r)=>new e(t,r).set.map(e=>e.map(e=>e.value).join(" ").trim().split(" ")),ri}(),_=function(){if(oi)return ii;oi=1;const e=xe(),t=$i();return ii=(r,n,i)=>{let o=null,s=null,a=null;try{a=new t(n,i)}catch(e){return null}return r.forEach(t=>{a.test(t)&&(o&&-1!==s.compare(t)||(o=t,s=new e(o,i)))}),o},ii}(),R=function(){if(ai)return si;ai=1;const e=xe(),t=$i();return si=(r,n,i)=>{let o=null,s=null,a=null;try{a=new t(n,i)}catch(e){return null}return r.forEach(t=>{a.test(t)&&(o&&1!==s.compare(t)||(o=t,s=new e(o,i)))}),o},si}(),T=function(){if(li)return ci;li=1;const e=xe(),t=$i(),r=Ni();return ci=(n,i)=>{n=new t(n,i);let o=new e("0.0.0");if(n.test(o))return o;if(o=new e("0.0.0-0"),n.test(o))return o;o=null;for(let t=0;t<n.set.length;++t){const i=n.set[t];let s=null;i.forEach(t=>{const n=new e(t.semver.version);switch(t.operator){case">":0===n.prerelease.length?n.patch++:n.prerelease.push(0),n.raw=n.format();case"":case">=":s&&!r(n,s)||(s=n);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${t.operator}`)}}),!s||o&&!r(o,s)||(o=s)}return o&&n.test(o)?o:null},ci}(),x=ki(),$=Bi(),F=function(){if(mi)return di;mi=1;const e=Bi();return di=(t,r,n)=>e(t,r,">",n),di}(),U=function(){if(vi)return gi;vi=1;const e=Bi();return gi=(t,r,n)=>e(t,r,"<",n),gi}(),k=function(){if(Ei)return yi;Ei=1;const e=$i();return yi=(t,r,n)=>(t=new e(t,n),r=new e(r,n),t.intersects(r,n))}(),B=function(){if(wi)return bi;wi=1;const e=Ui(),t=Di();return bi=(r,n,i)=>{const o=[];let s=null,a=null;const c=r.sort((e,r)=>t(e,r,i));for(const t of c)e(t,n,i)?(a=t,s||(s=t)):(a&&o.push([s,a]),a=null,s=null);s&&o.push([s,null]);const l=[];for(const[e,t]of o)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 u=l.join(" || "),f="string"==typeof n.raw?n.raw:String(n);return u.length<f.length?u:n},bi}(),M=function(){if(Si)return Li;Si=1;const e=$i(),t=Fi(),{ANY:r}=t,n=Ui(),i=Di(),o=[new t(">=0.0.0-0")],s=[new t(">=0.0.0")],a=(e,t,a)=>{if(e===t)return!0;if(1===e.length&&e[0].semver===r){if(1===t.length&&t[0].semver===r)return!0;e=a.includePrerelease?o:s}if(1===t.length&&t[0].semver===r){if(a.includePrerelease)return!0;t=s}const u=new Set;let f,p,h,d,m,g,v;for(const t of e)">"===t.operator||">="===t.operator?f=c(f,t,a):"<"===t.operator||"<="===t.operator?p=l(p,t,a):u.add(t.semver);if(u.size>1)return null;if(f&&p){if(h=i(f.semver,p.semver,a),h>0)return null;if(0===h&&(">="!==f.operator||"<="!==p.operator))return null}for(const e of u){if(f&&!n(e,String(f),a))return null;if(p&&!n(e,String(p),a))return null;for(const r of t)if(!n(e,String(r),a))return!1;return!0}let y=!(!p||a.includePrerelease||!p.semver.prerelease.length)&&p.semver,E=!(!f||a.includePrerelease||!f.semver.prerelease.length)&&f.semver;y&&1===y.prerelease.length&&"<"===p.operator&&0===y.prerelease[0]&&(y=!1);for(const e of t){if(v=v||">"===e.operator||">="===e.operator,g=g||"<"===e.operator||"<="===e.operator,f)if(E&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===E.major&&e.semver.minor===E.minor&&e.semver.patch===E.patch&&(E=!1),">"===e.operator||">="===e.operator){if(d=c(f,e,a),d===e&&d!==f)return!1}else if(">="===f.operator&&!n(f.semver,String(e),a))return!1;if(p)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(m=l(p,e,a),m===e&&m!==p)return!1}else if("<="===p.operator&&!n(p.semver,String(e),a))return!1;if(!e.operator&&(p||f)&&0!==h)return!1}return!(f&&g&&!p&&0!==h||p&&v&&!f&&0!==h||E||y)},c=(e,t,r)=>{if(!e)return t;const n=i(e.semver,t.semver,r);return n>0?e:n<0||">"===t.operator&&">="===e.operator?t:e},l=(e,t,r)=>{if(!e)return t;const n=i(e.semver,t.semver,r);return n<0?e:n>0||"<"===t.operator&&"<="===e.operator?t:e};return Li=(t,r,n={})=>{if(t===r)return!0;t=new e(t,n),r=new e(r,n);let i=!1;e:for(const e of t.set){for(const t of r.set){const r=a(e,t,n);if(i=i||null!==r,r)continue e}if(i)return!1}return!0}}();return Ci={parse:i,valid:o,clean:s,inc:a,diff:c,major:l,minor:u,patch:f,prerelease:p,compare:h,rcompare:d,compareLoose:m,compareBuild:g,sort:v,rsort:y,gt:E,lt:b,eq:w,neq:L,gte:S,lte:C,cmp:I,coerce:D,Comparator:O,Range:N,satisfies:A,toComparators:P,maxSatisfying:_,minSatisfying:R,minVersion:T,validRange:x,outside:$,gtr:F,ltr:U,intersects:k,simplifyRange:B,subset:M,SemVer:r,re:e.re,src:e.src,tokens:e.t,SEMVER_SPEC_VERSION:t.SEMVER_SPEC_VERSION,RELEASE_TYPES:t.RELEASE_TYPES,compareIdentifiers:n.compareIdentifiers,rcompareIdentifiers:n.rcompareIdentifiers}}();class Gi extends Mi.SemVer{satisfies(e){return Mi.satisfies(this,e)}}let ji=class{domain;level=Number(process.env.FUSION_LOG_LEVEL)||1;constructor(e){this.domain=e}_createMessage(e){return[`%c FUSION FRAMEWORK %c ${this.domain} %c %s`,"background: rgb(179, 13, 47); color: white; padding: 1px;","background: rgb(244, 244, 244); color: rgb(36, 55, 70); padding: 1px;","background: none; color: inherit",...e.reduce((e,t)=>e.concat(t,"\n"),[])]}debug(...e){this.level>3&&console.debug(...this._createMessage(e))}info(...e){this.level>2&&console.info(...this._createMessage(e))}warn(...e){this.level>1&&console.warn(...this._createMessage(e))}error(...e){this.level>0&&console.error(...this._createMessage(e))}};class zi extends ji{formatModuleName(e){return`📦${("string"==typeof e?e:e.name).replace(/([A-Z])/g," $1").toUpperCase()}`}}var Hi=function(e,t){return Hi=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},Hi(e,t)};function qi(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}Hi(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var Wi=function(){return Wi=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Wi.apply(this,arguments)};function Vi(e,t,r,n){return new(r||(r=Promise))(function(i,o){function s(e){try{c(n.next(e))}catch(e){o(e)}}function a(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}c((n=n.apply(e,t||[])).next())})}function Yi(e,t){var r,n,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function Ki(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Zi(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s}function Xi(e,t,r){if(r||2===arguments.length)for(var n,i=0,o=t.length;i<o;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}function Ji(e){return this instanceof Ji?(this.v=e,this):new Ji(e)}function Qi(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,i=r.apply(e,t||[]),o=[];return n=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),s("next"),s("throw"),s("return",function(e){return function(t){return Promise.resolve(t).then(e,l)}}),n[Symbol.asyncIterator]=function(){return this},n;function s(e,t){i[e]&&(n[e]=function(t){return new Promise(function(r,n){o.push([e,t,r,n])>1||a(e,t)})},t&&(n[e]=t(n[e])))}function a(e,t){try{!function(e){e.value instanceof Ji?Promise.resolve(e.value.v).then(c,l):u(o[0][2],e)}(i[e](t))}catch(e){u(o[0][3],e)}}function c(e){a("next",e)}function l(e){a("throw",e)}function u(e,t){e(t),o.shift(),o.length&&a(o[0][0],o[0][1])}}function eo(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=Ki(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise(function(n,i){(function(e,t,r,n){Promise.resolve(n).then(function(t){e({value:t,done:r})},t)})(n,i,(t=e[r](t)).done,t.value)})}}}function to(e){return"function"==typeof e}function ro(e){var t=e(function(e){Error.call(e),e.stack=(new Error).stack});return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}"function"==typeof SuppressedError&&SuppressedError;var no=ro(function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map(function(e,t){return t+1+") "+e.toString()}).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}});function io(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var oo=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}var t;return e.prototype.unsubscribe=function(){var e,t,r,n,i;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var s=Ki(o),a=s.next();!a.done;a=s.next()){a.value.remove(this)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=s.return)&&t.call(s)}finally{if(e)throw e.error}}else o.remove(this);var c=this.initialTeardown;if(to(c))try{c()}catch(e){i=e instanceof no?e.errors:[e]}var l=this._finalizers;if(l){this._finalizers=null;try{for(var u=Ki(l),f=u.next();!f.done;f=u.next()){var p=f.value;try{co(p)}catch(e){i=null!=i?i:[],e instanceof no?i=Xi(Xi([],Zi(i)),Zi(e.errors)):i.push(e)}}}catch(e){r={error:e}}finally{try{f&&!f.done&&(n=u.return)&&n.call(u)}finally{if(r)throw r.error}}}if(i)throw new no(i)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)co(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(r=this._finalizers)&&void 0!==r?r:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&io(t,e)},e.prototype.remove=function(t){var r=this._finalizers;r&&io(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}(),so=oo.EMPTY;function ao(e){return e instanceof oo||e&&"closed"in e&&to(e.remove)&&to(e.add)&&to(e.unsubscribe)}function co(e){to(e)?e():e.unsubscribe()}var lo={Promise:void 0},uo=function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setTimeout.apply(void 0,Xi([e,t],Zi(r)))};function fo(e){uo(function(){throw e})}function po(){}function ho(e){e()}var mo=function(e){function t(t){var r=e.call(this)||this;return r.isStopped=!1,t?(r.destination=t,ao(t)&&t.add(r)):r.destination=Eo,r}return qi(t,e),t.create=function(e,t,r){return new vo(e,t,r)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(oo),go=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){yo(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){yo(e)}else yo(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){yo(e)}},e}(),vo=function(e){function t(t,r,n){var i,o=e.call(this)||this;return i=to(t)||!t?{next:null!=t?t:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:t,o.destination=new go(i),o}return qi(t,e),t}(mo);function yo(e){fo(e)}var Eo={closed:!0,next:po,error:function(e){throw e},complete:po},bo="function"==typeof Symbol&&Symbol.observable||"@@observable";function wo(e){return e}var Lo=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(e,t,r){var n,i=this,o=(n=e)&&n instanceof mo||function(e){return e&&to(e.next)&&to(e.error)&&to(e.complete)}(n)&&ao(n)?e:new vo(e,t,r);return ho(function(){var e=i,t=e.operator,r=e.source;o.add(t?t.call(o,r):r?i._subscribe(o):i._trySubscribe(o))}),o},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var r=this;return new(t=So(t))(function(t,n){var i=new vo({next:function(t){try{e(t)}catch(e){n(e),i.unsubscribe()}},error:n,complete:t});r.subscribe(i)})},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[bo]=function(){return this},e.prototype.pipe=function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return(0===(e=t).length?wo:1===e.length?e[0]:function(t){return e.reduce(function(e,t){return t(e)},t)})(this)},e.prototype.toPromise=function(e){var t=this;return new(e=So(e))(function(e,r){var n;t.subscribe(function(e){return n=e},function(e){return r(e)},function(){return e(n)})})},e.create=function(t){return new e(t)},e}();function So(e){var t;return null!==(t=null!=e?e:lo.Promise)&&void 0!==t?t:Promise}function Co(e){return function(t){if(function(e){return to(null==e?void 0:e.lift)}(t))return t.lift(function(t){try{return e(t,this)}catch(e){this.error(e)}});throw new TypeError("Unable to lift unknown Observable type")}}function Io(e,t,r,n,i){return new Do(e,t,r,n,i)}var Do=function(e){function t(t,r,n,i,o,s){var a=e.call(this,t)||this;return a.onFinalize=o,a.shouldUnsubscribe=s,a._next=r?function(e){try{r(e)}catch(e){t.error(e)}}:e.prototype._next,a._error=i?function(e){try{i(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,a._complete=n?function(){try{n()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,a}return qi(t,e),t.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;e.prototype.unsubscribe.call(this),!r&&(null===(t=this.onFinalize)||void 0===t||t.call(this))}},t}(mo),Oo=ro(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),No=function(e){function t(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return qi(t,e),t.prototype.lift=function(e){var t=new Ao(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new Oo},t.prototype.next=function(e){var t=this;ho(function(){var r,n;if(t._throwIfClosed(),!t.isStopped){t.currentObservers||(t.currentObservers=Array.from(t.observers));try{for(var i=Ki(t.currentObservers),o=i.next();!o.done;o=i.next()){o.value.next(e)}}catch(e){r={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}}})},t.prototype.error=function(e){var t=this;ho(function(){if(t._throwIfClosed(),!t.isStopped){t.hasError=t.isStopped=!0,t.thrownError=e;for(var r=t.observers;r.length;)r.shift().error(e)}})},t.prototype.complete=function(){var e=this;ho(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var t=e.observers;t.length;)t.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return(null===(e=this.observers)||void 0===e?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,r=this,n=r.hasError,i=r.isStopped,o=r.observers;return n||i?so:(this.currentObservers=null,o.push(e),new oo(function(){t.currentObservers=null,io(o,e)}))},t.prototype._checkFinalizedStatuses=function(e){var t=this,r=t.hasError,n=t.thrownError,i=t.isStopped;r?e.error(n):i&&e.complete()},t.prototype.asObservable=function(){var e=new Lo;return e.source=this,e},t.create=function(e,t){return new Ao(e,t)},t}(Lo),Ao=function(e){function t(t,r){var n=e.call(this)||this;return n.destination=t,n.source=r,n}return qi(t,e),t.prototype.next=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===r||r.call(t,e)},t.prototype.error=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===r||r.call(t,e)},t.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},t.prototype._subscribe=function(e){var t,r;return null!==(r=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==r?r:so},t}(No),Po=function(e){function t(t){var r=e.call(this)||this;return r._value=t,r}return qi(t,e),Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(t){var r=e.prototype._subscribe.call(this,t);return!r.closed&&t.next(this._value),r},t.prototype.getValue=function(){var e=this,t=e.hasError,r=e.thrownError,n=e._value;if(t)throw r;return this._throwIfClosed(),n},t.prototype.next=function(t){e.prototype.next.call(this,this._value=t)},t}(No),_o={now:function(){return(_o.delegate||Date).now()},delegate:void 0},Ro=function(e){function t(t,r,n){void 0===t&&(t=1/0),void 0===r&&(r=1/0),void 0===n&&(n=_o);var i=e.call(this)||this;return i._bufferSize=t,i._windowTime=r,i._timestampProvider=n,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=r===1/0,i._bufferSize=Math.max(1,t),i._windowTime=Math.max(1,r),i}return qi(t,e),t.prototype.next=function(t){var r=this,n=r.isStopped,i=r._buffer,o=r._infiniteTimeWindow,s=r._timestampProvider,a=r._windowTime;n||(i.push(t),!o&&i.push(s.now()+a)),this._trimBuffer(),e.prototype.next.call(this,t)},t.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var t=this._innerSubscribe(e),r=this._infiniteTimeWindow,n=this._buffer.slice(),i=0;i<n.length&&!e.closed;i+=r?1:2)e.next(n[i]);return this._checkFinalizedStatuses(e),t},t.prototype._trimBuffer=function(){var e=this,t=e._bufferSize,r=e._timestampProvider,n=e._buffer,i=e._infiniteTimeWindow,o=(i?1:2)*t;if(t<1/0&&o<n.length&&n.splice(0,n.length-o),!i){for(var s=r.now(),a=0,c=1;c<n.length&&n[c]<=s;c+=2)a=c;a&&n.splice(0,a+1)}},t}(No),To=function(e){function t(t,r){return e.call(this)||this}return qi(t,e),t.prototype.schedule=function(e,t){return this},t}(oo),xo=function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setInterval.apply(void 0,Xi([e,t],Zi(r)))},$o=function(e){return clearInterval(e)},Fo=function(e){function t(t,r){var n=e.call(this,t,r)||this;return n.scheduler=t,n.work=r,n.pending=!1,n}return qi(t,e),t.prototype.schedule=function(e,t){var r;if(void 0===t&&(t=0),this.closed)return this;this.state=e;var n=this.id,i=this.scheduler;return null!=n&&(this.id=this.recycleAsyncId(i,n,t)),this.pending=!0,this.delay=t,this.id=null!==(r=this.id)&&void 0!==r?r:this.requestAsyncId(i,this.id,t),this},t.prototype.requestAsyncId=function(e,t,r){return void 0===r&&(r=0),xo(e.flush.bind(e,this),r)},t.prototype.recycleAsyncId=function(e,t,r){if(void 0===r&&(r=0),null!=r&&this.delay===r&&!1===this.pending)return t;null!=t&&$o(t)},t.prototype.execute=function(e,t){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var r=this._execute(e,t);if(r)return r;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,t){var r,n=!1;try{this.work(e)}catch(e){n=!0,r=e||new Error("Scheduled action threw falsy error")}if(n)return this.unsubscribe(),r},t.prototype.unsubscribe=function(){if(!this.closed){var t=this.id,r=this.scheduler,n=r.actions;this.work=this.state=this.scheduler=null,this.pending=!1,io(n,this),null!=t&&(this.id=this.recycleAsyncId(r,t,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(To),Uo=function(){function e(t,r){void 0===r&&(r=e.now),this.schedulerActionCtor=t,this.now=r}return e.prototype.schedule=function(e,t,r){return void 0===t&&(t=0),new this.schedulerActionCtor(this,e).schedule(r,t)},e.now=_o.now,e}(),ko=function(e){function t(t,r){void 0===r&&(r=Uo.now);var n=e.call(this,t,r)||this;return n.actions=[],n._active=!1,n}return qi(t,e),t.prototype.flush=function(e){var t=this.actions;if(this._active)t.push(e);else{var r;this._active=!0;do{if(r=e.execute(e.state,e.delay))break}while(e=t.shift());if(this._active=!1,r){for(;e=t.shift();)e.unsubscribe();throw r}}},t}(Uo),Bo=new ko(Fo),Mo=Bo,Go=new Lo(function(e){return e.complete()});function jo(e){return e&&to(e.schedule)}function zo(e){return e[e.length-1]}var Ho=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e};function qo(e){return to(null==e?void 0:e.then)}function Wo(e){return to(e[bo])}function Vo(e){return Symbol.asyncIterator&&to(null==e?void 0:e[Symbol.asyncIterator])}function Yo(e){return new TypeError("You provided "+(null!==e&&"object"==typeof e?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}var Ko="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function Zo(e){return to(null==e?void 0:e[Ko])}function Xo(e){return Qi(this,arguments,function(){var t,r,n;return Yi(this,function(i){switch(i.label){case 0:t=e.getReader(),i.label=1;case 1:i.trys.push([1,,9,10]),i.label=2;case 2:return[4,Ji(t.read())];case 3:return r=i.sent(),n=r.value,r.done?[4,Ji(void 0)]:[3,5];case 4:return[2,i.sent()];case 5:return[4,Ji(n)];case 6:return[4,i.sent()];case 7:return i.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})})}function Jo(e){return to(null==e?void 0:e.getReader)}function Qo(e){if(e instanceof Lo)return e;if(null!=e){if(Wo(e))return i=e,new Lo(function(e){var t=i[bo]();if(to(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")});if(Ho(e))return n=e,new Lo(function(e){for(var t=0;t<n.length&&!e.closed;t++)e.next(n[t]);e.complete()});if(qo(e))return r=e,new Lo(function(e){r.then(function(t){e.closed||(e.next(t),e.complete())},function(t){return e.error(t)}).then(null,fo)});if(Vo(e))return es(e);if(Zo(e))return t=e,new Lo(function(e){var r,n;try{for(var i=Ki(t),o=i.next();!o.done;o=i.next()){var s=o.value;if(e.next(s),e.closed)return}}catch(e){r={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}e.complete()});if(Jo(e))return es(Xo(e))}var t,r,n,i;throw Yo(e)}function es(e){return new Lo(function(t){(function(e,t){var r,n,i,o;return Vi(this,void 0,void 0,function(){var s,a;return Yi(this,function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),r=eo(e),c.label=1;case 1:return[4,r.next()];case 2:if((n=c.sent()).done)return[3,4];if(s=n.value,t.next(s),t.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=c.sent(),i={error:a},[3,11];case 6:return c.trys.push([6,,9,10]),n&&!n.done&&(o=r.return)?[4,o.call(r)]:[3,8];case 7:c.sent(),c.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})})(e,t).catch(function(e){return t.error(e)})})}function ts(e,t,r,n,i){void 0===n&&(n=0),void 0===i&&(i=!1);var o=t.schedule(function(){r(),i?e.add(this.schedule(null,n)):this.unsubscribe()},n);if(e.add(o),!i)return o}function rs(e,t){return void 0===t&&(t=0),Co(function(r,n){r.subscribe(Io(n,function(r){return ts(n,e,function(){return n.next(r)},t)},function(){return ts(n,e,function(){return n.complete()},t)},function(r){return ts(n,e,function(){return n.error(r)},t)}))})}function ns(e,t){return void 0===t&&(t=0),Co(function(r,n){n.add(e.schedule(function(){return r.subscribe(n)},t))})}function is(e,t){if(!e)throw new Error("Iterable cannot be null");return new Lo(function(r){ts(r,t,function(){var n=e[Symbol.asyncIterator]();ts(r,t,function(){n.next().then(function(e){e.done?r.complete():r.next(e.value)})},0,!0)})})}function os(e,t){if(null!=e){if(Wo(e))return function(e,t){return Qo(e).pipe(ns(t),rs(t))}(e,t);if(Ho(e))return function(e,t){return new Lo(function(r){var n=0;return t.schedule(function(){n===e.length?r.complete():(r.next(e[n++]),r.closed||this.schedule())})})}(e,t);if(qo(e))return function(e,t){return Qo(e).pipe(ns(t),rs(t))}(e,t);if(Vo(e))return is(e,t);if(Zo(e))return function(e,t){return new Lo(function(r){var n;return ts(r,t,function(){n=e[Ko](),ts(r,t,function(){var e,t,i;try{t=(e=n.next()).value,i=e.done}catch(e){return void r.error(e)}i?r.complete():r.next(t)},0,!0)}),function(){return to(null==n?void 0:n.return)&&n.return()}})}(e,t);if(Jo(e))return function(e,t){return is(Xo(e),t)}(e,t)}throw Yo(e)}function ss(e,t){return t?os(e,t):Qo(e)}function as(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=function(e){return jo(zo(e))?e.pop():void 0}(e);return ss(e,r)}var cs=ro(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function ls(e,t){var r="object"==typeof t;return new Promise(function(n,i){var o,s=!1;e.subscribe({next:function(e){o=e,s=!0},error:i,complete:function(){s?n(o):r?n(t.defaultValue):i(new cs)}})})}function us(e,t){var r="object"==typeof t;return new Promise(function(n,i){var o=new vo({next:function(e){n(e),o.unsubscribe()},error:i,complete:function(){r?n(t.defaultValue):i(new cs)}});e.subscribe(o)})}function fs(e){return e instanceof Date&&!isNaN(e)}var ps=ro(function(e){return function(t){void 0===t&&(t=null),e(this),this.message="Timeout has occurred",this.name="TimeoutError",this.info=t}});function hs(e){throw new ps(e)}function ds(e,t){return Co(function(r,n){var i=0;r.subscribe(Io(n,function(r){n.next(e.call(t,r,i++))}))})}var ms=Array.isArray;function gs(e){return ds(function(t){return function(e,t){return ms(t)?e.apply(void 0,Xi([],Zi(t))):e(t)}(e,t)})}function vs(e,t,r,n,i,o,s,a){var c=[],l=0,u=0,f=!1,p=function(){!f||c.length||l||t.complete()},h=function(e){return l<n?d(e):c.push(e)},d=function(e){o&&t.next(e),l++;var a=!1;Qo(r(e,u++)).subscribe(Io(t,function(e){null==i||i(e),o?h(e):t.next(e)},function(){a=!0},void 0,function(){if(a)try{l--;for(var e=function(){var e=c.shift();s||d(e)};c.length&&l<n;)e();p()}catch(e){t.error(e)}}))};return e.subscribe(Io(t,h,function(){f=!0,p()})),function(){null==a||a()}}function ys(e,t,r){return void 0===r&&(r=1/0),to(t)?ys(function(r,n){return ds(function(e,i){return t(r,e,n,i)})(Qo(e(r,n)))},r):("number"==typeof t&&(r=t),Co(function(t,n){return vs(t,n,e,r)}))}var Es=["addListener","removeListener"],bs=["addEventListener","removeEventListener"],ws=["on","off"];function Ls(e,t,r,n){if(to(r)&&(n=r,r=void 0),n)return Ls(e,t,r).pipe(gs(n));var i=Zi(function(e){return to(e.addEventListener)&&to(e.removeEventListener)}(e)?bs.map(function(n){return function(i){return e[n](t,i,r)}}):function(e){return to(e.addListener)&&to(e.removeListener)}(e)?Es.map(Ss(e,t)):function(e){return to(e.on)&&to(e.off)}(e)?ws.map(Ss(e,t)):[],2),o=i[0],s=i[1];if(!o&&Ho(e))return ys(function(e){return Ls(e,t,r)})(Qo(e));if(!o)throw new TypeError("Invalid event target");return new Lo(function(e){var t=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return e.next(1<t.length?t:t[0])};return o(t),function(){return s(t)}})}function Ss(e,t){return function(r){return function(n){return e[r](t,n)}}}function Cs(e,t,r){void 0===e&&(e=0),void 0===r&&(r=Mo);var n=-1;return null!=t&&(jo(t)?r=t:n=t),new Lo(function(t){var i=fs(e)?+e-r.now():e;i<0&&(i=0);var o=0;return r.schedule(function(){t.closed||(t.next(o++),0<=n?this.schedule(void 0,n):t.complete())},i)})}function Is(e,t){return Co(function(r,n){var i=0;r.subscribe(Io(n,function(r){return e.call(t,r,i++)&&n.next(r)}))})}function Ds(e){return Co(function(t,r){var n,i=null,o=!1;i=t.subscribe(Io(r,void 0,void 0,function(s){n=Qo(e(s,Ds(e)(t))),i?(i.unsubscribe(),i=null,n.subscribe(r)):o=!0})),o&&(i.unsubscribe(),i=null,n.subscribe(r))})}function Os(e,t,r,n,i){return function(o,s){var a=r,c=t,l=0;o.subscribe(Io(s,function(t){var r=l++;c=a?e(c,t,r):(a=!0,t),n&&s.next(c)},i&&function(){a&&s.next(c),s.complete()}))}}function Ns(e,t){return Co(Os(e,t,arguments.length>=2,!1,!0))}function As(e,t){return void 0===t&&(t=wo),e=null!=e?e:Ps,Co(function(r,n){var i,o=!0;r.subscribe(Io(n,function(r){var s=t(r);!o&&e(i,s)||(o=!1,i=s,n.next(r))}))})}function Ps(e,t){return e===t}function _s(e){return void 0===e&&(e=Rs),Co(function(t,r){var n=!1;t.subscribe(Io(r,function(e){n=!0,r.next(e)},function(){return n?r.complete():r.error(e())}))})}function Rs(){return new cs}function Ts(e){return Co(function(t,r){try{t.subscribe(r)}finally{r.add(e)}})}function xs(e,t){var r=arguments.length>=2;return function(e){return e.pipe(wo,(n=1)<=0?function(){return Go}:Co(function(e,t){var r=[];e.subscribe(Io(t,function(e){r.push(e),n<r.length&&r.shift()},function(){var e,n;try{for(var i=Ki(r),o=i.next();!o.done;o=i.next()){var s=o.value;t.next(s)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}t.complete()},void 0,function(){r=null}))}),r?function(e){return Co(function(t,r){var n=!1;t.subscribe(Io(r,function(e){n=!0,r.next(e)},function(){n||r.next(e),r.complete()}))})}(t):_s(function(){return new cs}));var n}}function $s(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];if(!0!==t){if(!1!==t){var i=new vo({next:function(){i.unsubscribe(),e()}});return Qo(t.apply(void 0,Xi([],Zi(r)))).subscribe(i)}}else e()}function Fs(e,t){return Co(function(r,n){var i=null,o=0,s=!1,a=function(){return s&&!i&&n.complete()};r.subscribe(Io(n,function(r){null==i||i.unsubscribe();var s=0,c=o++;Qo(e(r,c)).subscribe(i=Io(n,function(e){return n.next(t?t(r,e,c,s++):e)},function(){i=null,a()}))},function(){s=!0,a()}))})}function Us(e){return Co(function(t,r){Qo(e).subscribe(Io(r,function(){return r.complete()},po)),!r.closed&&t.subscribe(r)})}function ks(e,t,r){var n=to(e)||t||r?{next:e,error:t,complete:r}:e;return n?Co(function(e,t){var r;null===(r=n.subscribe)||void 0===r||r.call(n);var i=!0;e.subscribe(Io(t,function(e){var r;null===(r=n.next)||void 0===r||r.call(n,e),t.next(e)},function(){var e;i=!1,null===(e=n.complete)||void 0===e||e.call(n),t.complete()},function(e){var r;i=!1,null===(r=n.error)||void 0===r||r.call(n,e),t.error(e)},function(){var e,t;i&&(null===(e=n.unsubscribe)||void 0===e||e.call(n)),null===(t=n.finalize)||void 0===t||t.call(n)}))}):wo}function Bs(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r,n=to(zo(r=e))?r.pop():void 0;return Co(function(t,r){for(var i=e.length,o=new Array(i),s=e.map(function(){return!1}),a=!1,c=function(t){Qo(e[t]).subscribe(Io(r,function(e){o[t]=e,a||s[t]||(s[t]=!0,(a=s.every(wo))&&(s=null))},po))},l=0;l<i;l++)c(l);t.subscribe(Io(r,function(e){if(a){var t=Xi([e],Zi(o));r.next(n?n.apply(void 0,Xi([],Zi(t))):t)}}))})}const Ms=(e,t,r)=>{const n="string"==typeof t?t.split("."):t,i=n.shift();return i&&(e[i]??={},n.length?Ms(e[i],n,r):Object.assign(e,{[i]:r})),e};class Gs{#Z={};createConfig(e,t){return ss(this._createConfig(e,t))}async createConfigAsync(e,t){return ls(this.createConfig(e,t))}_set(e,t){const r="function"==typeof t?t:async()=>t;this.#Z[e]=r}_get(e){return this.#Z[e]}_has(e){return e in this.#Z}_createConfig(e,t){return ss(this._buildConfig(e,t)).pipe(Fs(t=>this._processConfig(t,e)))}_buildConfig(e,t){return ss(Object.entries(this.#Z)).pipe(ys(([t,r])=>ss(r(e)).pipe(Is(e=>void 0!==e),ds(e=>({target:t,value:e})),Ds(e=>(console.error(`Failed to execute config callback: ${r.name} for attribute: '${t}'`,e),Go)))),Ns((e,{target:t,value:r})=>Ms(e,t,r),t??{}))}_processConfig(e,t){return as(e)}}class js{#X;#J;get version(){return this.#X}constructor(e){const{version:t}=e;this.#X=new Gi(t),this.#J=new oo}_addTeardown(e){return this.#J.add(e),()=>this.#J.remove(e)}dispose(){this.#J.unsubscribe()}}class zs extends Error{constructor(){super("It was too slow"),this.name="RequiredModuleTimeoutError"}}class Hs{logger=new zi("ModulesConfigurator");_configs=[];_afterConfiguration=[];_afterInit=[];_modules;constructor(e){this._modules=new Set(e)}get modules(){return[...this._modules]}configure(...e){for(const t of e)this.addConfig(t)}addConfig(e){const{module:t,afterConfig:r,afterInit:n,configure:i}=e;this._modules.add(t),i&&this._configs.push((e,r)=>i(e[t.name],r)),r&&this._afterConfiguration.push(e=>r(e[t.name])),n&&this._afterInit.push(e=>n(e[t.name]))}onConfigured(e){this._afterConfiguration.push(e)}onInitialized(e){this._afterInit.push(e)}async initialize(e){const t=await this._configure(e),r=await this._initialize(t,e);return await this._postInitialize(r,e),Object.seal(Object.assign({},r,{dispose:()=>this.dispose(r)}))}async _configure(e){const t=await this._createConfig(e);return await Promise.all(this._configs.map(r=>Promise.resolve(r(t,e)))),await this._postConfigure(t),t}_createConfig(e){const{modules:t,logger:r,_afterConfiguration:n,_afterInit:i}=this,o=ss(t).pipe(ys(async t=>{r.debug(`🛠 creating configurator ${r.formatModuleName(t)}`);try{const n=await(t.configure?.(e));return r.debug(`🛠 created configurator for ${r.formatModuleName(t)}`,n),{[t.name]:n}}catch(e){throw r.error(`🛠 Failed to created configurator for ${r.formatModuleName(t)}`,e),e}}),Ns((e,t)=>Object.assign(e,t),{onAfterConfiguration(e){n.push(e)},onAfterInit(e){i.push(e)}}));return ls(o)}async _postConfigure(e){const{modules:t,logger:r,_afterConfiguration:n}=this;if(await Promise.allSettled(t.filter(e=>!!e.postConfigure).map(async t=>{try{await(t.postConfigure?.(e)),r.debug(`🏗📌 post configured ${r.formatModuleName(t)}`,t)}catch(e){r.warn(`🏗📌 post configure failed ${r.formatModuleName(t)}`)}})),n.length)try{r.debug(`🏗📌 post configure hooks [${n.length}]`),await Promise.allSettled(n.map(t=>Promise.resolve(t(e)))),r.debug("🏗📌 post configure hooks complete")}catch(e){r.warn("🏗📌 post configure hook failed",e)}}async _initialize(e,t){const{modules:r,logger:n}=this,i=r.map(e=>e.name),o=new Po({}),s=e=>i.includes(e),a=(e,t=60)=>{if(!i.includes(e))throw n.error(`🚀⌛️ Cannot not require ${n.formatModuleName(String(e))} since module is not defined!`),Error(`cannot not require [${String(e)}] since module is not defined!`);return o.value[e]?(n.debug(`🚀⌛️ ${n.formatModuleName(String(e))} is initiated, skipping queue`),Promise.resolve(o.value[e])):(n.debug(`🚀⌛️ Awaiting init ${n.formatModuleName(String(e))}, timeout ${t}s`),us(o.pipe(Is(t=>!!t[e]),ds(t=>t[e]),function(e){var t=fs(e)?{first:e}:"number"==typeof e?{each:e}:e,r=t.first,n=t.each,i=t.with,o=void 0===i?hs:i,s=t.scheduler,a=void 0===s?Bo:s,c=t.meta,l=void 0===c?null:c;if(null==r&&null==n)throw new TypeError("No timeout provided.");return Co(function(e,t){var i,s,c=null,u=0,f=function(e){s=ts(t,a,function(){try{i.unsubscribe(),Qo(o({meta:l,lastValue:c,seen:u})).subscribe(t)}catch(e){t.error(e)}},e)};i=e.subscribe(Io(t,function(e){null==s||s.unsubscribe(),u++,t.next(c=e),n>0&&f(n)},void 0,void 0,function(){(null==s?void 0:s.closed)||null==s||s.unsubscribe(),c=null})),!u&&f(null!=r?"number"==typeof r?r:+r-a.now():n)})}({each:1e3*t,with:()=>{return t=to(e=()=>new zs)?e:function(){return e},new Lo(function(e){return e.error(t())});var e,t}}))))};ss(r).pipe(ys(r=>{const i=r.name;return n.debug(`🚀 initializing ${n.formatModuleName(r)}`),ss(Promise.resolve(r.initialize({ref:t,config:e[i],requireInstance:a,hasModule:s}))).pipe(ds(e=>{if(!(e instanceof js||e.version instanceof Gi)){n.debug("🤷 module does not extends the [BaseModuleProvider] or exposes [SemanticVersion]");try{e.version=r.version instanceof Gi?r.version:new Gi(r.version??"0.0.0-unknown")}catch(e){n.error("🚨 failed to set module version")}}return n.debug(`🚀 initialized ${n.formatModuleName(r)}`),[i,e]}))})).subscribe({next:([e,t])=>{o.next(Object.assign(o.value,{[e]:t}))},error:e=>{n.error("🚨 failed to initialize",e),o.error(e)},complete:()=>o.complete()});const c=await ls(o);return Object.seal(c),c}async _postInitialize(e,t){const{modules:r,logger:n,_afterInit:i}=this,o=ss(r).pipe(Is(e=>!!e.postInitialize),ks(e=>n.debug(`🚀📌 post initializing moule ${n.formatModuleName(e)}`)),ys(r=>ss(r.postInitialize({ref:t,modules:e,instance:e[r.name]})).pipe(ks(()=>{n.debug(`🚀📌 post initialized moule ${n.formatModuleName(r)}`)}),Ds(e=>(n.warn(`🚀📌 post initialize failed moule ${n.formatModuleName(r)}`,e),Go)))));if(await new Promise((e,t)=>{o.subscribe({complete:()=>e(!0),error:t})}),i.length)try{n.debug(`🚀📌 post configure hooks [${i.length}]`),await Promise.allSettled(i.map(t=>Promise.resolve(t(e)))),n.debug("🚀📌 post configure hooks complete")}catch(e){n.warn("🚀📌 post configure hook failed",e)}n.debug(`🎉 Modules initialized ${r.map(n.formatModuleName)}`,e),n.info("🟢 Modules initialized")}async dispose(e,t){const{modules:r}=this;await Promise.allSettled(r.filter(e=>!!e.dispose).map(async r=>{await(r.dispose?.({ref:t,modules:e,instance:e[r.name]}))}))}}class qs{_operators;get operators(){return this._operators}constructor(e){this._operators=e&&"operators"in e?{...e.operators}:e??{}}add(e,t){if(Object.keys(this._operators).includes(e))throw Error(`Operator [${e}] already defined`);return this.set(e,t)}set(e,t){return this._operators[e]=t,this}remove(e){return delete this._operators[e],this}get(e){return this._operators[e]}process(e){return Object.values(this._operators).length?ss(Object.values(this._operators)).pipe((t=(e,t)=>Promise.resolve(t(e)).then(t=>t??e),r=e,n=1,Co(function(e,i){var o=r;return vs(e,i,function(e,r){return t(o,e,r)},n,function(e){o=e},!1,void 0,function(){return o=null})})),xs()):as(e);var t,r,n}}class Ws extends qs{setHeader(e,t){const r=((e,t)=>r=>{const n=new Headers(r.headers);return n.append(e,t),{...r,headers:n}})(e,t);return this.set("header-"+e,r)}}class Vs extends qs{}const Ys=()=>P.custom(e=>e===e?.toUpperCase(),e=>({code:P.ZodIssueCode.custom,validation:"uppercase",path:["method"],message:[`Provided HTTP method '${e}' must be in uppercase.`,"See RFC 7231 Section 4.1 for more information","https://www.rfc-editor.org/rfc/rfc7231#section-4.1"].join(" ")})),Ks=P.object({attributionReporting:P.object({eventSourceEligible:P.boolean().optional(),triggerEligible:P.boolean().optional()}).optional(),body:P.union([P.string(),P.instanceof(Blob),P.instanceof(ArrayBuffer),P.instanceof(FormData),P.instanceof(URLSearchParams),P.instanceof(ReadableStream)]).optional(),browsingTopics:P.boolean().optional(),cache:P.enum(["default","no-store","reload","no-cache","force-cache","only-if-cached"]).optional(),credentials:P.enum(["omit","same-origin","include"]).optional(),headers:P.record(P.string(),P.string()).optional().or(P.instanceof(Headers)),integrity:P.string().optional(),keepalive:P.boolean().optional(),method:Ys().pipe(P.enum(["GET","POST","PUT","DELETE","PATCH","OPTIONS","HEAD","CONNECT","TRACE"],{errorMap:e=>{const{received:t,options:r}=e;return{message:["Invalid request method.",`Expected '${r.join(" | ")}', but received '${t}'.`,"See RFC 2615 Section 9 for more information","https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html"].join(" ")}}})).optional(),mode:P.enum(["same-origin","cors","no-cors","navigate","websocket"]).optional(),priority:P.enum(["low","high","auto"]).optional(),redirect:P.enum(["follow","error","manual"]).optional(),referrer:P.string().optional(),referrerPolicy:P.enum(["no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"]).optional(),signal:P.instanceof(AbortSignal).optional()}).extend({uri:P.string(),path:P.string().optional()}),Zs=e=>e=>{const{error:t,success:r,data:n}=Ys().safeParse(e.method);if(e.method=r?n:e.method?.toUpperCase(),t)for(const e of t.errors)console.warn(e.message);return e},Xs=e=>e=>{const{strict:t,parse:r}={},n=t?Ks:Ks.passthrough();try{const t=n.parse(e);return r?t:void 0}catch(e){if(r)throw e;console.error("Invalid request options",e.message)}};class Js{_clients={};get clients(){return{...this._clients}}defaultHttpClientCtor;defaultHttpRequestHandler=new Ws({"capitalize-method":Zs(),"request-validation":Xs()});constructor(e){this.defaultHttpClientCtor=e}hasClient(e){return Object.keys(this._clients).includes(e)}configureClient(e,t){const r="string"==typeof t?{baseUri:t}:t,n="function"==typeof r?{onCreate:r}:r;return this._clients[e]={...this._clients[e],...n},this}}class Qs extends Error{}class ea{config;get defaultHttpRequestHandler(){return this.config.defaultHttpRequestHandler}constructor(e){this.config=e}hasClient(e){return Object.keys(this.config.clients).includes(e)}createClient(e){const t=this._resolveConfig(e),{baseUri:r,defaultScopes:n=[],onCreate:i,ctor:o=this.config.defaultHttpClientCtor,requestHandler:s=this.defaultHttpRequestHandler}=t,a=new o(r||"",{requestHandler:s});return Object.assign(a,{defaultScopes:n}),i?.(a),a}createCustomClient(e){return this.createClient(e)}_resolveConfig(e){if("string"==typeof e){const r=this.config.clients[e];if(!r&&(t=e,new RegExp("^(https?:\\/\\/)?((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.?)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*(\\?[;&a-z\\d%_.~+=-]*)?(\\#[-a-z\\d_]*)?$","i").test(t)))return{baseUri:e};if(!r)throw new Qs(`No registered http client for key [${e}]`);return r}var t;return e}}function ta(e,t){void 0===t&&(t={});var r=t.selector,n=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r}(t,["selector"]);return new Lo(function(t){var i=new AbortController,o=i.signal,s=!0,a=n.signal;if(a)if(a.aborted)i.abort();else{var c=function(){o.aborted||i.abort()};a.addEventListener("abort",c),t.add(function(){return a.removeEventListener("abort",c)})}var l=Wi(Wi({},n),{signal:o}),u=function(e){s=!1,t.error(e)};return fetch(e,l).then(function(e){r?Qo(r(e)).subscribe(Io(t,void 0,function(){s=!1,t.complete()},u)):(s=!1,t.next(e),t.complete())}).catch(u),function(){s&&i.abort()}})}const ra=async e=>{if(204===e.status)return Promise.resolve();try{const t=await e.json();if(!e.ok)throw new sn("network response was not OK",e,{data:t});return t}catch(t){if(t instanceof sn)throw t;throw new sn("failed to parse response",e,{cause:t})}},na=async e=>{if(!e.ok)throw new Error("network response was not OK");if(204===e.status)throw new Error("no content");const t=e.headers.get("content-disposition")?.split(";").find(e=>e.includes("filename="))?.replace("filename=","")?.trim();try{return{filename:t,blob:await e.blob()}}catch(e){throw Error("failed to parse response")}},ia=e=>{try{return JSON.parse(e)}catch{return e}};function*oa(e,t){const r=e.split("\n\n"),n=t?.dataParser||ia;for(const e of r){if(!e.trim())continue;const t=e.split("\n").reduce((e,t)=>{if(!t)return e;const r=t.indexOf(":");if(-1===r)return e;const i=t.slice(0,r).trim(),o=t.slice(r+1).trim();return"data"===i?e.data=n(o):e[i]=o,e},{});Object.keys(t).length&&(yield t)}}const sa=e=>t=>{if(!t.ok)throw new an(`HTTP error! Status: ${t.status}`,t);if(!t.body)throw new an("Response body is not readable",t);if(!t.headers.get("Content-Type")?.includes("text/event-stream"))throw new an("Response is not a text/event-stream",t);const r=t.body.getReader();return ss(async function*(e,t){const r=!!t?.skipHeartbeats,n=t?.eventFilter?Array.isArray(t.eventFilter)?t.eventFilter:[t.eventFilter]:null,i=new TextDecoder;for(;;){const{done:o,value:s}=await e.read();if(o)break;const a=oa(i.decode(s,{stream:!0}),{dataParser:t?.dataParser});for(const e of a)if(e.retry)await new Promise(t=>setTimeout(t,Number.parseInt(e.retry??"300",10)));else{if(r){if(!e.event&&!e.data&&!e.id)continue;if(e.event&&["heartbeat","ping"].includes(e.event))continue}(!n||e.event&&n.includes(e.event))&&(yield e)}}}(r,{dataParser:e?.dataParser,skipHeartbeats:e?.skipHeartbeats,eventFilter:e?.eventFilter})).pipe(Us(e?.abortSignal?Ls(e.abortSignal,"abort"):Go),Ts(async()=>{await r.cancel().catch(()=>{}),r.releaseLock()}))};class aa{uri;requestHandler;responseHandler;_request$=new No;_response$=new No;_abort$=new No;get request$(){return this._request$.asObservable()}get response$(){return this._response$.asObservable()}constructor(e,t){this.uri=e,this.requestHandler=new Ws(t?.requestHandler),this.responseHandler=new Vs(t?.responseHandler),this._init()}_init(){}fetch$(e,t){return this._fetch$(e,t)}fetch(e,t){return us(this.fetch$(e,t))}fetchAsync(e,t){return this.fetch(e,t)}json$(e,t){const r="object"==typeof t?.body?JSON.stringify(t?.body):t?.body,n=t?.selector??ra,i=new Headers(t?.headers);return i.append("Accept","application/json"),i.append("Content-Type","application/json"),this.fetch$(e,{...t,body:r,selector:n,headers:i})}json(e,t){return us(this.json$(e,t))}blob$(e,t){const r=t?.selector??na,n={...t,selector:r};return this.fetch$(e,n)}blob(e,t){return us(this.blob$(e,t))}sse$(e,t,r){const n=new Headers(t?.headers);n.append("Accept","text/event-stream"),n.append("Content-Type","text/event-stream"),n.append("Cache-Control","no-cache"),n.append("Connection","keep-alive");const i=sa({...r,abortSignal:t?.signal});return this._fetch$(e,{selector:i,...t,headers:n})}jsonAsync(e,t){return this.json(e,t)}execute(e,t,r){return this[e](t,r)}abort(){this._abort$.next()}_fetch$(e,t){const{selector:r,...n}=t||{},i=as({...n,uri:this._resolveUrl(e)}).pipe(Fs(e=>this._prepareRequest(e)),ks(e=>this._request$.next(e)),Fs(({uri:e,path:t,...r})=>ta(e,r)),Fs(e=>this._prepareResponse(e)),ks(e=>this._response$.next(e)),Fs(e=>{if(r)try{return r(e)}catch(t){throw new on("failed to execute response selector",e,{cause:t})}return as(e)}),Us(this._abort$));return i}_prepareRequest(e){return this.requestHandler.process(e)}_prepareResponse(e){return this.responseHandler.process(e)}_resolveUrl(e){const{origin:t,pathname:r}=new URL(this.uri,this.uri.startsWith("http")?void 0:window.location.origin),n=[r,e].join("/").replace(/\/{2,}/g,"/");return new URL(n,t).href}}class ca extends aa{defaultScopes=[];fetch$(e,t){const r=Object.assign(t||{},{scopes:this.defaultScopes.concat(t?.scopes||[])});return super._fetch$(e,r)}}const la={name:"http",configure:()=>new Js(ca),initialize:async({config:e,hasModule:t,requireInstance:r})=>{const n=new ea(e);if(t("auth")){const e=await r("auth");n.defaultHttpRequestHandler.set("MSAL",async t=>{const{scopes:r=[]}=t;if(r.length){const n=await e.acquireAccessToken({scopes:r});if(n){const e=new Headers(t.headers);return e.set("Authorization",`Bearer ${n}`),{...t,headers:e}}}})}return n}},ua=(...e)=>t=>t.pipe(function(e,t){return to(t)?ys(e,t,1):ys(e,1)}(...e)),fa=(...e)=>t=>t.pipe(ys(...e)),pa=(...e)=>t=>t.pipe(Fs(...e)),ha=e=>e.pipe(ds(e=>e.value));var da=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function ma(e){if(!function(e){return"string"==typeof e&&da.test(e)}(e))throw TypeError("Invalid UUID");let t;return Uint8Array.of((t=parseInt(e.slice(0,8),16))>>>24,t>>>16&255,t>>>8&255,255&t,(t=parseInt(e.slice(9,13),16))>>>8,255&t,(t=parseInt(e.slice(14,18),16))>>>8,255&t,(t=parseInt(e.slice(19,23),16))>>>8,255&t,(t=parseInt(e.slice(24,36),16))/1099511627776&255,t/4294967296&255,t>>>24&255,t>>>16&255,t>>>8&255,255&t)}const ga=[];for(let e=0;e<256;++e)ga.push((e+256).toString(16).slice(1));function va(e,t=0){return(ga[e[t+0]]+ga[e[t+1]]+ga[e[t+2]]+ga[e[t+3]]+"-"+ga[e[t+4]]+ga[e[t+5]]+"-"+ga[e[t+6]]+ga[e[t+7]]+"-"+ga[e[t+8]]+ga[e[t+9]]+"-"+ga[e[t+10]]+ga[e[t+11]]+ga[e[t+12]]+ga[e[t+13]]+ga[e[t+14]]+ga[e[t+15]]).toLowerCase()}let ya;const Ea=new Uint8Array(16);function ba(e,t,r,n,i,o){const s="string"==typeof r?function(e){e=unescape(encodeURIComponent(e));const t=new Uint8Array(e.length);for(let r=0;r<e.length;++r)t[r]=e.charCodeAt(r);return t}(r):r,a="string"==typeof n?ma(n):n;if("string"==typeof n&&(n=ma(n)),16!==n?.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let c=new Uint8Array(16+s.length);if(c.set(a),c.set(s,a.length),c=t(c),c[6]=15&c[6]|e,c[8]=63&c[8]|128,i){o=o||0;for(let e=0;e<16;++e)i[o+e]=c[e];return i}return va(c)}var wa={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function La(e,t,r){if(wa.randomUUID&&!e)return wa.randomUUID();const n=(e=e||{}).random??e.rng?.()??function(){if(!ya){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");ya=crypto.getRandomValues.bind(crypto)}return ya(Ea)}();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=15&n[6]|64,n[8]=63&n[8]|128,va(n)}function Sa(e,t,r,n){switch(e){case 0:return t&r^~t&n;case 1:case 3:return t^r^n;case 2:return t&r^t&n^r&n}}function Ca(e,t){return e<<t|e>>>32-t}function Ia(e){const t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520],n=new Uint8Array(e.length+1);n.set(e),n[e.length]=128;const i=(e=n).length/4+2,o=Math.ceil(i/16),s=new Array(o);for(let t=0;t<o;++t){const r=new Uint32Array(16);for(let n=0;n<16;++n)r[n]=e[64*t+4*n]<<24|e[64*t+4*n+1]<<16|e[64*t+4*n+2]<<8|e[64*t+4*n+3];s[t]=r}s[o-1][14]=8*(e.length-1)/Math.pow(2,32),s[o-1][14]=Math.floor(s[o-1][14]),s[o-1][15]=8*(e.length-1)&4294967295;for(let e=0;e<o;++e){const n=new Uint32Array(80);for(let t=0;t<16;++t)n[t]=s[e][t];for(let e=16;e<80;++e)n[e]=Ca(n[e-3]^n[e-8]^n[e-14]^n[e-16],1);let i=r[0],o=r[1],a=r[2],c=r[3],l=r[4];for(let e=0;e<80;++e){const r=Math.floor(e/20),s=Ca(i,5)+Sa(r,o,a,c)+l+t[r]+n[e]>>>0;l=c,c=a,a=Ca(o,30)>>>0,o=i,i=s}r[0]=r[0]+i>>>0,r[1]=r[1]+o>>>0,r[2]=r[2]+a>>>0,r[3]=r[3]+c>>>0,r[4]=r[4]+l>>>0}return Uint8Array.of(r[0]>>24,r[0]>>16,r[0]>>8,r[0],r[1]>>24,r[1]>>16,r[1]>>8,r[1],r[2]>>24,r[2]>>16,r[2]>>8,r[2],r[3]>>24,r[3]>>16,r[3]>>8,r[3],r[4]>>24,r[4]>>16,r[4]>>8,r[4])}function Da(e,t,r,n){return ba(80,Ia,e,t,r,n)}Da.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Da.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8";class Oa extends Error{type;request;constructor(e,t){super(t.message,{cause:t.cause}),this.type=e,this.name="QueryClientError",this.request=t.request}}function Na(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];if("production"!==process.env.NODE_ENV){var i=mc[e],o=i?"function"==typeof i?i.apply(null,r):i:"unknown error nr: "+e;throw Error("[Immer] "+o)}throw Error("[Immer] minified error nr: "+e+(r.length?" "+r.map(function(e){return"'"+e+"'"}).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function Aa(e){return!!e&&!!e[dc]}function Pa(e){var t;return!!e&&(function(e){if(!e||"object"!=typeof e)return!1;var t=Object.getPrototypeOf(e);if(null===t)return!0;var r=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return r===Object||"function"==typeof r&&Function.toString.call(r)===gc}(e)||Array.isArray(e)||!!e[hc]||!!(null===(t=e.constructor)||void 0===t?void 0:t[hc])||$a(e)||Fa(e))}function _a(e,t,r){void 0===r&&(r=!1),0===Ra(e)?(r?Object.keys:vc)(e).forEach(function(n){r&&"symbol"==typeof n||t(n,e[n],e)}):e.forEach(function(r,n){return t(n,r,e)})}function Ra(e){var t=e[dc];return t?t.i>3?t.i-4:t.i:Array.isArray(e)?1:$a(e)?2:Fa(e)?3:0}function Ta(e,t){return 2===Ra(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function xa(e,t,r){var n=Ra(e);2===n?e.set(t,r):3===n?e.add(r):e[t]=r}function $a(e){return lc&&e instanceof Map}function Fa(e){return uc&&e instanceof Set}function Ua(e){return e.o||e.t}function ka(e){if(Array.isArray(e))return Array.prototype.slice.call(e);var t=yc(e);delete t[dc];for(var r=vc(t),n=0;n<r.length;n++){var i=r[n],o=t[i];!1===o.writable&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(t[i]={configurable:!0,writable:!0,enumerable:o.enumerable,value:e[i]})}return Object.create(Object.getPrototypeOf(e),t)}function Ba(e,t){return void 0===t&&(t=!1),Ga(e)||Aa(e)||!Pa(e)||(Ra(e)>1&&(e.set=e.add=e.clear=e.delete=Ma),Object.freeze(e),t&&_a(e,function(e,t){return Ba(t,!0)},!0)),e}function Ma(){Na(2)}function Ga(e){return null==e||"object"!=typeof e||Object.isFrozen(e)}function ja(e){var t=Ec[e];return t||Na(18,e),t}function za(){return"production"===process.env.NODE_ENV||ac||Na(0),ac}function Ha(e,t){t&&(ja("Patches"),e.u=[],e.s=[],e.v=t)}function qa(e){Wa(e),e.p.forEach(Ya),e.p=null}function Wa(e){e===ac&&(ac=e.l)}function Va(e){return ac={p:[],l:ac,h:e,m:!0,_:0}}function Ya(e){var t=e[dc];0===t.i||1===t.i?t.j():t.g=!0}function Ka(e,t){t._=t.p.length;var r=t.p[0],n=void 0!==e&&e!==r;return t.h.O||ja("ES5").S(t,e,n),n?(r[dc].P&&(qa(t),Na(4)),Pa(e)&&(e=Za(t,e),t.l||Ja(t,e)),t.u&&ja("Patches").M(r[dc].t,e,t.u,t.s)):e=Za(t,r,[]),qa(t),t.u&&t.v(t.u,t.s),e!==pc?e:void 0}function Za(e,t,r){if(Ga(t))return t;var n=t[dc];if(!n)return _a(t,function(i,o){return Xa(e,n,t,i,o,r)},!0),t;if(n.A!==e)return t;if(!n.P)return Ja(e,n.t,!0),n.t;if(!n.I){n.I=!0,n.A._--;var i=4===n.i||5===n.i?n.o=ka(n.k):n.o,o=i,s=!1;3===n.i&&(o=new Set(i),i.clear(),s=!0),_a(o,function(t,o){return Xa(e,n,i,t,o,r,s)}),Ja(e,i,!1),r&&e.u&&ja("Patches").N(n,r,e.u,e.s)}return n.o}function Xa(e,t,r,n,i,o,s){if("production"!==process.env.NODE_ENV&&i===r&&Na(5),Aa(i)){var a=Za(e,i,o&&t&&3!==t.i&&!Ta(t.R,n)?o.concat(n):void 0);if(xa(r,n,a),!Aa(a))return;e.m=!1}else s&&r.add(i);if(Pa(i)&&!Ga(i)){if(!e.h.D&&e._<1)return;Za(e,i),t&&t.A.l||Ja(e,i)}}function Ja(e,t,r){void 0===r&&(r=!1),!e.l&&e.h.D&&e.m&&Ba(t,r)}function Qa(e,t){var r=e[dc];return(r?Ua(r):e)[t]}function ec(e,t){if(t in e)for(var r=Object.getPrototypeOf(e);r;){var n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=Object.getPrototypeOf(r)}}function tc(e){e.P||(e.P=!0,e.l&&tc(e.l))}function rc(e){e.o||(e.o=ka(e.t))}function nc(e,t,r){var n=$a(t)?ja("MapSet").F(t,r):Fa(t)?ja("MapSet").T(t,r):e.O?function(e,t){var r=Array.isArray(e),n={i:r?1:0,A:t?t.A:za(),P:!1,I:!1,R:{},l:t,t:e,k:null,o:null,j:null,C:!1},i=n,o=bc;r&&(i=[n],o=wc);var s=Proxy.revocable(i,o),a=s.revoke,c=s.proxy;return n.k=c,n.j=a,c}(t,r):ja("ES5").J(t,r);return(r?r.A:za()).p.push(n),n}function ic(e){return Aa(e)||Na(22,e),function e(t){if(!Pa(t))return t;var r,n=t[dc],i=Ra(t);if(n){if(!n.P&&(n.i<4||!ja("ES5").K(n)))return n.t;n.I=!0,r=oc(t,i),n.I=!1}else r=oc(t,i);return _a(r,function(t,i){n&&function(e,t){return 2===Ra(e)?e.get(t):e[t]}(n.t,t)===i||xa(r,t,e(i))}),3===i?new Set(r):r}(e)}function oc(e,t){switch(t){case 2:return new Map(e);case 3:return Array.from(e)}return ka(e)}var sc,ac,cc="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),lc="undefined"!=typeof Map,uc="undefined"!=typeof Set,fc="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,pc=cc?Symbol.for("immer-nothing"):((sc={})["immer-nothing"]=!0,sc),hc=cc?Symbol.for("immer-draftable"):"__$immer_draftable",dc=cc?Symbol.for("immer-state"):"__$immer_state",mc={0:"Illegal state",1:"Immer drafts cannot have computed properties",2:"This object has been frozen and should not be mutated",3:function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},4:"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",5:"Immer forbids circular references",6:"The first or second argument to `produce` must be a function",7:"The third argument to `produce` must be a function or undefined",8:"First argument to `createDraft` must be a plain object, an array, or an immerable object",9:"First argument to `finishDraft` must be a draft returned by `createDraft`",10:"The given draft is already finalized",11:"Object.defineProperty() cannot be used on an Immer draft",12:"Object.setPrototypeOf() cannot be used on an Immer draft",13:"Immer only supports deleting array indices",14:"Immer only supports setting array indices and the 'length' property",15:function(e){return"Cannot apply patch, path doesn't resolve: "+e},16:'Sets cannot have "replace" patches.',17:function(e){return"Unsupported patch operation: "+e},18:function(e){return"The plugin for '"+e+"' has not been loaded into Immer. To enable the plugin, import and call `enable"+e+"()` when initializing your application."},20:"Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available",21:function(e){return"produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '"+e+"'"},22:function(e){return"'current' expects a draft, got: "+e},23:function(e){return"'original' expects a draft, got: "+e},24:"Patching reserved attributes like __proto__, prototype and constructor is not allowed"},gc=""+Object.prototype.constructor,vc="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames,yc=Object.getOwnPropertyDescriptors||function(e){var t={};return vc(e).forEach(function(r){t[r]=Object.getOwnPropertyDescriptor(e,r)}),t},Ec={},bc={get:function(e,t){if(t===dc)return e;var r=Ua(e);if(!Ta(r,t))return function(e,t,r){var n,i=ec(t,r);return i?"value"in i?i.value:null===(n=i.get)||void 0===n?void 0:n.call(e.k):void 0}(e,r,t);var n=r[t];return e.I||!Pa(n)?n:n===Qa(e.t,t)?(rc(e),e.o[t]=nc(e.A.h,n,e)):n},has:function(e,t){return t in Ua(e)},ownKeys:function(e){return Reflect.ownKeys(Ua(e))},set:function(e,t,r){var n=ec(Ua(e),t);if(null==n?void 0:n.set)return n.set.call(e.k,r),!0;if(!e.P){var i=Qa(Ua(e),t),o=null==i?void 0:i[dc];if(o&&o.t===r)return e.o[t]=r,e.R[t]=!1,!0;if(function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}(r,i)&&(void 0!==r||Ta(e.t,t)))return!0;rc(e),tc(e)}return e.o[t]===r&&(void 0!==r||t in e.o)||Number.isNaN(r)&&Number.isNaN(e.o[t])||(e.o[t]=r,e.R[t]=!0),!0},deleteProperty:function(e,t){return void 0!==Qa(e.t,t)||t in e.t?(e.R[t]=!1,rc(e),tc(e)):delete e.R[t],e.o&&delete e.o[t],!0},getOwnPropertyDescriptor:function(e,t){var r=Ua(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n?{writable:!0,configurable:1!==e.i||"length"!==t,enumerable:n.enumerable,value:r[t]}:n},defineProperty:function(){Na(11)},getPrototypeOf:function(e){return Object.getPrototypeOf(e.t)},setPrototypeOf:function(){Na(12)}},wc={};_a(bc,function(e,t){wc[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}}),wc.deleteProperty=function(e,t){return"production"!==process.env.NODE_ENV&&isNaN(parseInt(t))&&Na(13),wc.set.call(this,e,t,void 0)},wc.set=function(e,t,r){return"production"!==process.env.NODE_ENV&&"length"!==t&&isNaN(parseInt(t))&&Na(14),bc.set.call(this,e[0],t,r,e[0])};var Lc=function(){function e(e){var t=this;this.O=fc,this.D=!0,this.produce=function(e,r,n){if("function"==typeof e&&"function"!=typeof r){var i=r;r=e;var o=t;return function(e){var t=this;void 0===e&&(e=i);for(var n=arguments.length,s=Array(n>1?n-1:0),a=1;a<n;a++)s[a-1]=arguments[a];return o.produce(e,function(e){var n;return(n=r).call.apply(n,[t,e].concat(s))})}}var s;if("function"!=typeof r&&Na(6),void 0!==n&&"function"!=typeof n&&Na(7),Pa(e)){var a=Va(t),c=nc(t,e,void 0),l=!0;try{s=r(c),l=!1}finally{l?qa(a):Wa(a)}return"undefined"!=typeof Promise&&s instanceof Promise?s.then(function(e){return Ha(a,n),Ka(e,a)},function(e){throw qa(a),e}):(Ha(a,n),Ka(s,a))}if(!e||"object"!=typeof e){if(void 0===(s=r(e))&&(s=e),s===pc&&(s=void 0),t.D&&Ba(s,!0),n){var u=[],f=[];ja("Patches").M(e,s,u,f),n(u,f)}return s}Na(21,e)},this.produceWithPatches=function(e,r){if("function"==typeof e)return function(r){for(var n=arguments.length,i=Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return t.produceWithPatches(r,function(t){return e.apply(void 0,[t].concat(i))})};var n,i,o=t.produce(e,r,function(e,t){n=e,i=t});return"undefined"!=typeof Promise&&o instanceof Promise?o.then(function(e){return[e,n,i]}):[o,n,i]},"boolean"==typeof(null==e?void 0:e.useProxies)&&this.setUseProxies(e.useProxies),"boolean"==typeof(null==e?void 0:e.autoFreeze)&&this.setAutoFreeze(e.autoFreeze)}var t=e.prototype;return t.createDraft=function(e){Pa(e)||Na(8),Aa(e)&&(e=ic(e));var t=Va(this),r=nc(this,e,void 0);return r[dc].C=!0,Wa(t),r},t.finishDraft=function(e,t){var r=e&&e[dc];"production"!==process.env.NODE_ENV&&(r&&r.C||Na(9),r.I&&Na(10));var n=r.A;return Ha(n,t),Ka(void 0,n)},t.setAutoFreeze=function(e){this.D=e},t.setUseProxies=function(e){e&&!fc&&Na(20),this.O=e},t.applyPatches=function(e,t){var r;for(r=t.length-1;r>=0;r--){var n=t[r];if(0===n.path.length&&"replace"===n.op){e=n.value;break}}r>-1&&(t=t.slice(r+1));var i=ja("Patches").$;return Aa(e)?i(e,t):this.produce(e,function(e){return i(e,t)})},e}(),Sc=new Lc,Cc=Sc.produce;Sc.produceWithPatches.bind(Sc),Sc.setAutoFreeze.bind(Sc),Sc.setUseProxies.bind(Sc),Sc.applyPatches.bind(Sc),Sc.createDraft.bind(Sc),Sc.finishDraft.bind(Sc);const Ic=(...e)=>Is(t=>e.includes(t.type));class Dc extends Lo{#Q=new No;#ee;get action$(){return this.#Q.asObservable()}get value(){return this.#ee.value}get closed(){return this.#ee.closed||this.#Q.closed}constructor(e,t){super(e=>this.#ee.subscribe(e));const r="getInitialState"in e?e.getInitialState():t;this.#ee=new Po(r),this.#Q.pipe(function(e,t){return Co(Os(e,t,arguments.length>=2,!0))}(e,r),As()).subscribe(this.#ee),this.reset=()=>this.#ee.next(r)}reset;next(e){this.#Q.next(e)}select(e,t){return this.#ee.pipe(ds(e),As(t))}addEffect(e,t){const r="function"==typeof e?this.action$:Array.isArray(e)?this.action$.pipe(Ic(...e)):this.action$.pipe(Ic(e)),n=t||e;return r.pipe(ys(e=>ss(new Promise((t,r)=>{try{t(n(e,this.value))}catch(e){r(e)}})).pipe(Ds(e=>(console.warn("unhandled effect",e),Go)))),Is(e=>!!e),rs(Bo)).subscribe(this.#Q)}addEpic(e){return this.addFlow(e)}addFlow(e){const t=e(this.action$,this);if(!t)throw new TypeError(`addEpic: one of the provided effects "${e.name||"<anonymous>"}" does not return a stream. Double check you're not missing a return statement!`);return t.pipe(Ds(e=>(console.trace("unhandled exception, epic closed!",e),Go)),rs(Bo)).subscribe(this.#Q)}unsubscribe(){this.#Q.unsubscribe(),this.#ee.unsubscribe()}complete(){this.#Q.complete(),this.#ee.complete()}asObservable(){return this.#ee.asObservable()}}function Oc(e,t){function r(...r){if(t){const n=t(...r);if(!n)throw new Error("prepareAction did not return an object");return{type:e,payload:n.payload,..."meta"in n&&{meta:n.meta},..."error"in n&&{error:n.error}}}return{type:e,payload:r[0]}}return r.toString=()=>`${e}`,r.type=e,r.match=t=>t.type===e,r}const Nc="::";function Ac(e,t,r,n){const i=Oc([e,"request"].join(Nc),t);return r&&Object.assign(i,{success:Oc([e,"success"].join(Nc),r)}),n&&Object.assign(i,{failure:Oc([e,"failure"].join(Nc),n)}),i}function Pc(e){return Pa(e)?Cc(e,()=>{}):e}function _c(e,t){const[r,n,i]=function(e){const t={},r=[];let n;const i={addCase(e,o){if("production"!==process.env.NODE_ENV){if(r.length>0)throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");if(n)throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`")}const s="string"==typeof e?e:e.type;if(s in t)throw new Error("addCase cannot be called with two reducers for the same action type");return t[s]=o,i},addMatcher(e,t){if("production"!==process.env.NODE_ENV&&n)throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return r.push({matcher:e,reducer:t}),i},addDefaultCase(e){if("production"!==process.env.NODE_ENV&&n)throw new Error("`builder.addDefaultCase` can only be called once");return n=e,i}};return e(i),[t,r,n]}(t);let o;if(function(e){return"function"==typeof e}(e))o=()=>Pc(e());else{const t=Pc(e);o=()=>t}function s(e,t){let s=[r[t.type],...n.filter(({matcher:e})=>e(t)).map(({reducer:e})=>e)];return i&&0===s.filter(e=>!!e).length&&(s=[i]),s.reduce((e,r)=>{if(r){if(Aa(e)){const n=r(e,t);return void 0===n?e:n}if(Pa(e))return Cc(e,e=>r(e,t));{const n=r(e,t);if(void 0===n){if(null===e)return e;throw Error("A case reducer on a non-draftable value must not return undefined")}return n}}return e},e??o())}return s.getInitialState=o,s}const Rc={request:Oc("client/request",(e,t)=>({payload:{args:e,options:t},meta:{transaction:La(),created:Date.now()}})),execute:Ac("client/execute",e=>({payload:e,meta:{transaction:e,created:Date.now()}}),e=>({payload:e,meta:{transaction:e.transaction,created:Date.now()}}),(e,t)=>({payload:e,meta:{transaction:t,created:Date.now()}})),cancel:Oc("client/cancel",(e,t)=>({payload:{transaction:e,reason:t},meta:{transaction:e,created:Date.now()}})),error:Oc("client/error",(e,t)=>({payload:{transaction:e,error:t},meta:{transaction:e,created:Date.now()}}))},Tc=e=>e.pipe(Is(Rc.request.match),ds(e=>Rc.execute(e.meta.transaction))),xc=e=>{const t=Number(e);if(Object.values($c).includes(t))return t;if(isNaN(t))return(e=>{if("string"!=typeof e)throw new Error("Expected LogLevel key to be a string.");const t=e.toLowerCase(),r=Object.keys($c).find(e=>e.toLowerCase()===t);if(!r)throw new Error(`Failed to parse LogLevel from string: ${e}.`);return $c[r]})(e);throw Error(`Invalid log level: ${e}`)};var $c;!function(e){e[e.None=0]="None",e[e.Error=1]="Error",e[e.Warning=2]="Warning",e[e.Info=3]="Info",e[e.Debug=4]="Debug"}($c||($c={}));const Fc=(()=>{const e=process.env.FUSION_LOG_LEVEL;if(e)try{return xc(e)}catch(e){return"development"===process.env.NODE_ENV?$c.Debug:$c.Error}return $c.Error})();class Uc{level=Fc;version="1.1.7";_log$=new No;get log(){return this._log$.pipe(Is(e=>this.level>=e.lvl))}debug(...e){this._log$.next({lvl:$c.Debug,msg:this._createMessage($c.Debug,...e)})}info(...e){this._log$.next({lvl:$c.Info,msg:this._createMessage($c.Info,...e)})}warn(...e){this._log$.next({lvl:$c.Warning,msg:this._createMessage($c.Warning,...e)})}error(...e){this._log$.next({lvl:$c.Error,msg:this._createMessage($c.Error,...e)})}}class kc extends Uc{title;subtitle;constructor(e,t){super(),this.title=e,this.subtitle=t,this.log.subscribe(({lvl:e,msg:t})=>{switch(e){case $c.Debug:console.debug(...t);break;case $c.Info:console.info(...t);break;case $c.Warning:console.warn(...t);break;case $c.Error:console.error(...t)}})}_createMessage(e,...t){return[this._formatTitle(e),...t]}_formatTitle(e){const t=le.magenta([this.title,this.subtitle].filter(e=>!!e).join(" - "));switch(e){case $c.Warning:case $c.Error:return le.bold(t)}return t}createSubLogger(e,t,r){const n=new kc(`${this.title}::${e}`,t??this.subtitle);return n.level=void 0===r?this.level:r,n}}class Bc extends Lo{#te=new Po("idle");get status(){return this.#te.value}get status$(){return this.#te.asObservable()}#re;#ne;get transaction(){return this.#ne}created=Date.now();get closed(){return"complete"===this.status||"error"===this.status||"canceled"===this.status}constructor(e,t,r){super(t=>{const{transaction:n}=this,i=e.action$.pipe(Is(e=>e.meta.transaction===n));t.add(e.state$.pipe(Is(e=>!!e[n]),ds(e=>e[n])).subscribe(e=>{this.#te.next(e.status)})),t.add(i.pipe(Is(Rc.execute.success.match),ds(({payload:e})=>e)).subscribe(e=>{this.#te.next("complete"),t.next(e),t.complete()})),t.add(i.pipe(Is(Rc.error.match),ds(({payload:e})=>e)).subscribe(e=>{this.#te.next("error"),t.error(e.error)})),t.add(i.pipe(Is(Rc.cancel.match)).subscribe(e=>{this.#te.next("canceled"),t.error(new Oa("abort",{message:e.payload.reason||`job: ${n} was canceled`,request:this.#re.getRequest(e.meta.transaction)}))})),r?.signal&&t.add(Ls(r?.signal,"abort").pipe(ds(()=>Rc.cancel(n,`job: ${n} was aborted on signal from caller: ${r?.ref}`))).subscribe(t=>e.next(t))),t.add(()=>{this.complete()})}),this.#re=e;const n=Rc.request(t,{ref:r?.ref,retry:r?.retry});this.#ne=n.meta.transaction,this.#re.next(n)}complete(e){this.closed||this.cancel(e??`job: ${this.transaction} was completed`)}cancel(e){const t=this.transaction;this.#re.cancel(t,e??`job: ${t} was canceled`)}[Symbol.dispose](){this.complete()}}class Mc extends Lo{#ee;#ie;#oe;get closed(){return this.#ee.closed}get state$(){return this.#ee.asObservable()}get action$(){return this.#ee.action$}get success$(){return this.action$.pipe(Is(Rc.execute.success.match),ds(({payload:e})=>e))}get error$(){return this.action$.pipe(Ic("client/error"),Bs(this.#ee),ds(([e,t])=>{const{payload:r,meta:{transaction:n}}=e,i=t[n];return new Oa("error",{request:i,message:`job: ${n} failed`,cause:r})}))}constructor(e,t){super(e=>this.#ee.subscribe(e)),this.#ee=new Dc(((e={})=>_c(e,e=>{e.addCase(Rc.request,(e,t)=>{e[t.meta.transaction]={...t.payload,...t.meta,execution:[],errors:[],status:"idle"}}),e.addCase(Rc.execute,(e,t)=>{const r=e[t.payload];r&&(r.execution.push(Date.now()),r.status="active")}),e.addCase(Rc.execute.success,(e,t)=>{delete e[t.payload.transaction]}),e.addCase(Rc.execute.failure,(e,t)=>{const r=e[t.meta.transaction];r&&(r.errors.push(t.payload),r.status="failed")}),e.addCase(Rc.error,(e,t)=>{delete e[t.meta.transaction]}),e.addCase(Rc.cancel,(e,t)=>{delete e[t.meta.transaction]})}))({})),this.#ie=new oo(()=>this.#ee.complete()),this.#ie.add(this.#ee.addFlow(Tc)),this.#ie.add(this.#ee.addFlow((e=>(t,r)=>t.pipe(Is(Rc.execute.match),Bs(r),ys(([r,n])=>{const i=r.payload,o=n[i],s=new AbortController,a=t.pipe(Is(Rc.cancel.match),Is(e=>e.payload.transaction===i),ks(()=>{s.signal.aborted||s.abort()}));try{return ss(e(o.args,s.signal)).pipe(ds(e=>Rc.execute.success({...o,status:"complete",completed:Date.now(),value:e})),Ds(e=>as(Rc.execute.failure(e,i))),Us(a))}catch(e){return as(Rc.execute.failure(e,i))}})))(e))),this.#ie.add(this.#ee.addFlow((e=>(t,r)=>t.pipe(Is(Rc.execute.failure.match),Bs(r),ys(([t,n])=>{const{transaction:i}=t.meta,o=n[i];if(!o)return as(Rc.error(i,new Oa("error",{message:"request not found, cannot retry request, most likely removed while scheduled for retry!"})));const s=o.execution.length,a=Object.assign({},e,o.options?.retry),c=o.errors?.slice(-1)[0]??new Oa("error",{message:"no errors registered for request!",request:o});if(s>a.count){const e=0===a.count?c:new Oa("error",{message:"maximum retries executed!",cause:o.errors,request:o});return as(Rc.error(i,e))}return("function"==typeof a.delay?ss(a.delay(c)).pipe(Ds(e=>as(Rc.error(i,new Oa("error",{message:"retry delay callback failed!",cause:[...o.errors??[],e],request:o}))))):Cs(a.delay)).pipe(Bs(r),Is(([e,t])=>!!t[i]),ks(([,e])=>{if(!e[i])throw new Oa("error",{message:"request not found, most likely removed while scheduled for retry",cause:o.errors,request:o})}),ds(()=>Rc.execute(i)))})))(Object.assign({count:0,delay:0},t?.retry)))),this.#oe=t?.logger??new kc("QueryClient"),this.#ee.addEffect(Rc.request.type,({payload:e,meta:{transaction:t}})=>{this.#oe.debug("Job requested",{transaction:t,payload:e})}),this.#ee.addEffect(Rc.execute.type,({payload:e,meta:{transaction:t}})=>{this.#oe.debug("Job executing",{transaction:t,payload:e})}),this.#ee.addEffect(Rc.execute.success.type,({payload:e})=>{this.#oe.info("Job complete",{...e})}),this.#ee.addEffect(Rc.execute.failure.type,({payload:e,meta:{transaction:t}})=>{this.#oe.debug("Job failed",{transaction:t,payload:e})}),this.#ee.addEffect(Rc.cancel.type,({payload:{reason:e},meta:{transaction:t}})=>{this.#oe.debug("Job canceled",{transaction:t,reason:e})}),this.#ee.addEffect(Rc.error.type,({payload:{transaction:e,error:t}})=>{this.#oe.error("Job error",{transaction:e,error:t})})}next(e){this.#ee.next(e)}query(e,t){const r=new Bc(this,e,t),n=r.pipe(function(e){void 0===e&&(e={});var t=e.connector,r=void 0===t?function(){return new No}:t,n=e.resetOnError,i=void 0===n||n,o=e.resetOnComplete,s=void 0===o||o,a=e.resetOnRefCountZero,c=void 0===a||a;return function(e){var t,n,o,a=0,l=!1,u=!1,f=function(){null==n||n.unsubscribe(),n=void 0},p=function(){f(),t=o=void 0,l=u=!1},h=function(){var e=t;p(),null==e||e.unsubscribe()};return Co(function(e,d){a++,u||l||f();var m=o=null!=o?o:r();d.add(function(){0!==--a||u||l||(n=$s(h,c))}),m.subscribe(d),!t&&a>0&&(t=new vo({next:function(e){return m.next(e)},error:function(e){u=!0,f(),n=$s(p,i,e),m.error(e)},complete:function(){l=!0,f(),n=$s(p,s),m.complete()}}),Qo(e).subscribe(t))})(e)}}({connector:()=>new Ro,resetOnRefCountZero:!1}));return Object.defineProperties(n,{transaction:{get:()=>r.transaction},created:{get:()=>r.created},status:{get:()=>r.status},closed:{get:()=>r.closed},cancel:{value:e=>r.cancel(e)},complete:{value:()=>r.complete()}}),n}async nextAsync(e,t){return us(this.query(e,t))}getRequest(e){return this.#ee.value[e]}getRequestByRef(e){return Object.values(this.#ee.value).find(t=>t.ref===e)}cancelTaskByRef(e,t){const r=this.getRequestByRef(e);r?.ref&&this.cancel(r.transaction,t)}cancel(e,t){if(e)this.#ee.value[e]?(t??=`cancelation requested for job: ${e}`,this.#ee.next(Rc.cancel(e,t))):this.#oe.warn("Task not registered, nothing to cancel",{transaction:e,reason:t});else for(const e of Object.keys(this.#ee.value))this.cancel(e,"all transactions requested canceled")}on(e,t){return this.#ee.addEffect(Rc[e].type,e=>{t(e,this)})}complete(){this.#ie.unsubscribe()}}const Gc={set:Oc("cache/set",(e,t)=>({payload:{key:e,record:t}})),insert:Oc("cache/insert",(e,t)=>({payload:{key:e,entry:t}})),remove:Oc("cache/remove",e=>({payload:e})),invalidate:Oc("cache/invalidate",(e,t)=>({payload:e,meta:{item:t}})),mutate:Oc("cache/mutate",(e,t,r)=>({payload:{...t,key:e},meta:{item:r}})),trim:Oc("cache/trim",e=>({payload:e}))},jc=(e,t)=>(t.updated??0)-(e.updated??0);class zc{#ee;get state(){return this.#ee.value}get state$(){return this.#ee.asObservable()}get action$(){return this.#ee.action$}constructor(e){const{trimming:t,initial:r}=e??{};this.#ee=new Dc(function(e,t={}){return _c(t,t=>t.addCase(e.set,(e,t)=>{const{key:r,record:n}=t.payload;e[r]=n}).addCase(e.insert,(e,t)=>{const{key:r,entry:n}=t.payload,i=e[r];if(i)i.updated=Date.now(),i.updates??=0,i.updates++,i.value=n.value,i.transaction=n.transaction,i.mutated=void 0;else{const t=Date.now();e[r]={...n,created:t,updated:t}}}).addCase(e.remove,(e,t)=>{delete e[t.payload]}).addCase(e.invalidate,(e,t)=>{const r=t.payload?[t.payload]:Object.keys(e);for(const t of r){const r=e[t];r&&(r.updated=void 0)}}).addCase(e.mutate,(e,t)=>{const{key:r,value:n,updated:i}=t.payload,o=e[r];o&&(o.value=n,o.updated=i,o.mutated=Date.now(),o.updates??=0,o.updates++)}).addCase(e.trim,(e,t)=>{const{payload:r}=t,n=r.sort??jc,i=Object.keys(e),o=Object.entries(e).filter(([e,t])=>!r.validate||r.validate(t)).sort((e,t)=>n(e[1],t[1])).slice(0,r.size??Number.MAX_SAFE_INTEGER).map(([e])=>e);if(i.length!==o.length)for(const t of i){const r=o.indexOf(t);-1!==r?o.splice(r,1):delete e[t]}}))}(Gc,r)),t&&this.#ee.addEffect("cache/set",()=>this.#ee.next(Gc.trim(t)))}has(e){return e in this.#ee.value}setItem(e,t){const{args:r,transaction:n,value:i}=t;this.#ee.next(Gc.insert(e,{args:r,transaction:n,value:i}))}getItem(e){return this.#ee.value[e]}removeItem(e){this.#ee.next(Gc.remove(e))}invalidate(e){const t=e?this.#ee.value[e]:void 0;this.#ee.next(Gc.invalidate(e,t))}mutate(e,t){const r=e in this.#ee.value?this.#ee.value[e]:void 0;if(!r)throw new Error(`Cannot mutate cache item with key ${e}: item not found`);const n="function"==typeof t?t(r?.value):t;return this.#ee.next(Gc.mutate(e,n,r)),()=>this.#ee.next(Gc.set(e,r))}trim(e){this.#ee.next(Gc.trim(e))}reset(){this.#ee.reset()}complete(){this.#ee.complete()}}class Hc extends No{key;args;options;#se=Date.now();get created(){return this.#se}#ae=La();get uuid(){return this.#ae}constructor(e,t,r){super(),this.key=e,this.args=t,this.options=r}processJob(e,t){return e.pipe(ds(t=>{const{key:r,uuid:n,created:i}=this;return{key:r,uuid:n,created:i,status:"complete",transaction:e.transaction,complete:t.completed,value:t.value}}),Ts(()=>{t?.debug("QueryTask complete",{uuid:this.uuid,key:this.key,job:{status:e.status,transaction:e.transaction}}),e.complete()})).subscribe(this)}}class qc{static extractQueryValue=ha;#ie=new oo;#re;#ce;#le=new No;#ue={};#fe;#pe;#he=La();#oe;get client(){return this.#re}get cache(){return this.#ce}constructor(e){this.#oe=e.logger??new kc("Query",this.#he),this.#fe=t=>Da(e.key(t),this.#he),this.#pe=e?.validate??((e=0)=>t=>(t.updated??0)+e>Date.now())(e?.expire),e.client instanceof Mc?this.#re=e.client:(this.#re=new Mc(e.client.fn,{logger:this.#oe.createSubLogger("Client"),...e.client.options}),this.#ie.add(()=>this.#re.complete())),e.cache instanceof zc?this.#ce=e.cache:(this.#ce=new zc(e.cache||{}),this.#ie.add(()=>this.#ce.complete()));const t=((e="switch")=>"function"==typeof e?e:(()=>{switch(e){case"concat":return ua;case"merge":return fa;case"switch":return pa;default:throw new Error(`Invalid queue operator: ${e}`)}})())(e.queueOperator);var r,n;this.#ie.add(()=>this.#le.complete()),this.#ie.add(this.#le.pipe(ks(e=>this.#oe.debug("Task added to queue",{key:e})),Is(e=>!!(e in this.#ue)),t(e=>{const t=this.#ue[e],{args:r,options:n,uuid:i}=t;if(this.#oe.debug("Task selected from queue",{key:e,task:t.uuid,args:r,options:n}),!t?.observed)return this.#oe.debug("Task skipped",{task:i}),delete this.#ue[e],Go;const o=this.#re.query(r,{...n,ref:t.uuid});return new Lo(r=>{const{transaction:n}=o;var s,a;this.#oe.info("Task stated",{task:i,transaction:n}),r.add(()=>{this.#oe.debug("Task closed",{task:i,transaction:n,jobStatus:o.status}),o.complete("task closed"),delete this.#ue[e]}),r.add((s=10,void 0===a&&(a=Bo),Cs(s,s,a)).pipe(Is(()=>!t.observed)).subscribe(()=>{o.cancel(`task: ${t.uuid} is not observed`),r.complete()})),r.add(t.processJob(o,this.#oe)),o.pipe(ds(e=>({result:e,task:t})),Ds(()=>Go)).subscribe(r)})}),(r=()=>!this.#re.closed,void 0===n&&(n=!1),Co(function(e,t){var i=0;e.subscribe(Io(t,function(e){var o=r(e,i++);(o||n)&&t.next(e),!o&&t.complete()}))}))).subscribe(e=>{const{value:t,transaction:r}=e.result,{args:n,key:i,uuid:o}=e.task;this.#oe.debug("Task output added to cache",{uuid:o,args:n,key:i,transaction:r,value:t}),this.#ce.setItem(i,{value:t,args:n,transaction:r})}))}query(e,t){return this._query(e,t)}queryAsync(e,t){const{skipResolve:r,...n}=t||{},i=r?us:ls;return new Promise((r,o)=>{t?.signal&&t.signal.addEventListener("abort",()=>o(new Error("Query aborted"))),i(this._query(e,n).pipe(_s())).then(r,o)})}persistentQuery(e,t){const r=this.#fe(e),n=this._query(e,t);return new Lo(i=>{i.add(n.subscribe({next:i.next.bind(i),error:i.error.bind(i)}));const o=t?.cache?.validate||this.#pe;i.add(this.cache.state$.pipe(Is(e=>r in e),ds(t=>({...t[r],key:r,status:"cache",hasValidCache:o(t[r],e)}))).subscribe(i))}).pipe(As((e,t)=>e.transaction===t.transaction&&e.mutated===t.mutated))}generateCacheKey(e){return this.#fe(e)}mutate(e,t,r){const n=this.#fe(e);if(n in this.cache.state==!1){if(void 0===r?.allowCreation)throw new Error(`Cannot mutate cache item with key ${n}: item not found and option "allowCreation" is false`);if(!1===r.allowCreation)return()=>{};const{value:i}="function"==typeof t?t():t;this.cache.setItem(n,{args:e,transaction:La(),value:i})}return this.#ce.mutate(n,t)}invalidate(e){this.#ce.invalidate(e&&this.#fe(e))}complete(){this.#ie.unsubscribe()}onInvalidate(e){const t=this.#ce.action$.pipe(Ic("cache/invalidate")).subscribe(t=>e({detail:{item:t.meta.item}}));return()=>t.unsubscribe()}onMutate(e){const t=this.#ce.action$.pipe(Ic("cache/mutate")).subscribe(t=>e({detail:{changes:t.payload,current:t.meta.item}}));return()=>t.unsubscribe()}_query(e,t){const r=this.#fe(e),n=this._createTask(r,e,t);return this.#oe.debug("New query created",{key:r,args:e,options:t}),n}_createTask(e,t,r){return new Lo(n=>{if(r?.signal){if(r?.signal.aborted)return this.#oe.debug("Abort signal already triggered by caller",{key:e}),n.complete();n.add(Ls(r?.signal,"abort").subscribe(()=>{this.#oe.debug("Abort signal triggered by caller",{key:e}),n.complete()}))}const i=this.#ce.getItem(e);if(i){this.#oe.debug("Query has cache",{key:e,cacheEntry:i});const o=r?.cache?.suppressInvalid??!1,s=(r?.cache?.validate||this.#pe)(i,t),a={...i,key:e,status:"cache",hasValidCache:s};if(this.#oe.info("Query cache valid, completing",{hasValidCache:s,suppressInvalid:o,record:a}),n.next(a),s||o)return n.complete();this.#oe.debug("Query cache entry is invalid, proceeding to fetch new data",{key:e})}const o=e in this.#ue;this.#ue[e]??=new Hc(e,t,r);const s=this.#ue[e];n.add(s.subscribe(n)),this.#oe.info(o?"Query connected to existing task":"Query started new task",{key:e}),o||this.#le.next(e)})}}const Wc=A.object({key:A.string().describe("The key used to identify the service"),uri:A.string().describe("The URI of the service"),id:A.string().optional().describe("The ID of the service"),environment:A.string().optional().describe("The environment of the service"),name:A.string().optional().describe("The name of the service"),scopes:A.array(A.string()).optional().default([]).describe("Endpoint authentication scopes"),tags:A.array(A.string()).optional().describe("Tags for the service")}).describe("A service from the service discovery API").transform(e=>({...e,get defaultScopes(){return e.scopes??[]}})),Vc=A.array(Wc).describe("A list of services from the service discovery API"),Yc=e=>ss(ra(e)).pipe(ds(e=>Vc.default([]).parse(e)));class Kc{#de;endpoint;http;constructor({http:e,endpoint:t}){this.http=e,this.endpoint=t,this.#de=new qc({client:{fn:()=>e.fetch$(t??"",{selector:Yc})},key:()=>"services",expire:3e5})}resolveServices(e){return(e?us:ls)(qc.extractQueryValue(this.#de.query()))}async resolveService(e,t){const r=(await this.resolveServices(t)).find(t=>t.key===e);if(!r)throw Error(`Failed to resolve service, invalid key [${e}]`);return r}}class Zc extends Gs{async _createConfig(e,t){if(!e.hasModule("http"))throw new Error("http module is required");if(!this._has("discoveryClient")){(await e.requireInstance("http")).hasClient("service_discovery")&&this.configureServiceDiscoveryClientByClientKey("service_discovery")}return ls(ss(super._createConfig(e,t)))}_processConfig(e,t){if(!e.discoveryClient)throw new Error("discoveryClient is required, please configure it");return super._processConfig(e,t)}setServiceDiscoveryClient(e){this._set("discoveryClient","function"==typeof e?e:async()=>e)}configureServiceDiscoveryClient(e){this.setServiceDiscoveryClient(async t=>{const{httpClient:r,endpoint:n}=await ls(ss(e(t)))??{};if(r)return new Kc({http:r,endpoint:n});throw Error("httpClient is required")})}configureServiceDiscoveryClientByClientKey(e,t){this.configureServiceDiscoveryClient(async({requireInstance:r})=>({httpClient:(await r("http")).createClient(e),endpoint:t}))}}class Xc{config;_http;constructor(e,t){this.config=e,this._http=t}resolveServices(){return this.config.discoveryClient.resolveServices()}async resolveService(e){return this.config.discoveryClient.resolveService(e)}async createClient(e,t){const r=await this.resolveService(e);if(!r)throw Error(`Could not load configuration of service [${e}]`);return this._http.createClient({...t,baseUri:r.uri,defaultScopes:r.scopes})}async configureClient(e,t){const{key:r,alias:n}="string"==typeof e?{key:e,alias:e}:e,{uri:i,scopes:o}=await this.resolveService(r);var s,a;t.addConfig((s=n,a={baseUri:i,defaultScopes:o},{module:la,configure:e=>{e.configureClient(s,a)}}))}}const Jc={name:"serviceDiscovery",configure:()=>new Zc,initialize:async e=>{const{requireInstance:t,ref:r}=e,n=await e.config.createConfigAsync(e,{...r?.serviceDiscovery?.config}),i=await t("http");return new Xc(n,i)}},Qc=(e,t)=>{e.addConfig((e=>({module:Jc,configure:t=>e(t)}))(()=>Promise.resolve()))};var el,tl,rl,nl={},il=[{name:"Agola CI",constant:"AGOLA",env:"AGOLA_GIT_REF",pr:"AGOLA_PULL_REQUEST_ID"},{name:"Appcircle",constant:"APPCIRCLE",env:"AC_APPCIRCLE",pr:{env:"AC_GIT_PR",ne:"false"}},{name:"AppVeyor",constant:"APPVEYOR",env:"APPVEYOR",pr:"APPVEYOR_PULL_REQUEST_NUMBER"},{name:"AWS CodeBuild",constant:"CODEBUILD",env:"CODEBUILD_BUILD_ARN",pr:{env:"CODEBUILD_WEBHOOK_EVENT",any:["PULL_REQUEST_CREATED","PULL_REQUEST_UPDATED","PULL_REQUEST_REOPENED"]}},{name:"Azure Pipelines",constant:"AZURE_PIPELINES",env:"TF_BUILD",pr:{BUILD_REASON:"PullRequest"}},{name:"Bamboo",constant:"BAMBOO",env:"bamboo_planKey"},{name:"Bitbucket Pipelines",constant:"BITBUCKET",env:"BITBUCKET_COMMIT",pr:"BITBUCKET_PR_ID"},{name:"Bitrise",constant:"BITRISE",env:"BITRISE_IO",pr:"BITRISE_PULL_REQUEST"},{name:"Buddy",constant:"BUDDY",env:"BUDDY_WORKSPACE_ID",pr:"BUDDY_EXECUTION_PULL_REQUEST_ID"},{name:"Buildkite",constant:"BUILDKITE",env:"BUILDKITE",pr:{env:"BUILDKITE_PULL_REQUEST",ne:"false"}},{name:"CircleCI",constant:"CIRCLE",env:"CIRCLECI",pr:"CIRCLE_PULL_REQUEST"},{name:"Cirrus CI",constant:"CIRRUS",env:"CIRRUS_CI",pr:"CIRRUS_PR"},{name:"Cloudflare Pages",constant:"CLOUDFLARE_PAGES",env:"CF_PAGES"},{name:"Cloudflare Workers",constant:"CLOUDFLARE_WORKERS",env:"WORKERS_CI"},{name:"Codefresh",constant:"CODEFRESH",env:"CF_BUILD_ID",pr:{any:["CF_PULL_REQUEST_NUMBER","CF_PULL_REQUEST_ID"]}},{name:"Codemagic",constant:"CODEMAGIC",env:"CM_BUILD_ID",pr:"CM_PULL_REQUEST"},{name:"Codeship",constant:"CODESHIP",env:{CI_NAME:"codeship"}},{name:"Drone",constant:"DRONE",env:"DRONE",pr:{DRONE_BUILD_EVENT:"pull_request"}},{name:"dsari",constant:"DSARI",env:"DSARI"},{name:"Earthly",constant:"EARTHLY",env:"EARTHLY_CI"},{name:"Expo Application Services",constant:"EAS",env:"EAS_BUILD"},{name:"Gerrit",constant:"GERRIT",env:"GERRIT_PROJECT"},{name:"Gitea Actions",constant:"GITEA_ACTIONS",env:"GITEA_ACTIONS"},{name:"GitHub Actions",constant:"GITHUB_ACTIONS",env:"GITHUB_ACTIONS",pr:{GITHUB_EVENT_NAME:"pull_request"}},{name:"GitLab CI",constant:"GITLAB",env:"GITLAB_CI",pr:"CI_MERGE_REQUEST_ID"},{name:"GoCD",constant:"GOCD",env:"GO_PIPELINE_LABEL"},{name:"Google Cloud Build",constant:"GOOGLE_CLOUD_BUILD",env:"BUILDER_OUTPUT"},{name:"Harness CI",constant:"HARNESS",env:"HARNESS_BUILD_ID"},{name:"Heroku",constant:"HEROKU",env:{env:"NODE",includes:"/app/.heroku/node/bin/node"}},{name:"Hudson",constant:"HUDSON",env:"HUDSON_URL"},{name:"Jenkins",constant:"JENKINS",env:["JENKINS_URL","BUILD_ID"],pr:{any:["ghprbPullId","CHANGE_ID"]}},{name:"LayerCI",constant:"LAYERCI",env:"LAYERCI",pr:"LAYERCI_PULL_REQUEST"},{name:"Magnum CI",constant:"MAGNUM",env:"MAGNUM"},{name:"Netlify CI",constant:"NETLIFY",env:"NETLIFY",pr:{env:"PULL_REQUEST",ne:"false"}},{name:"Nevercode",constant:"NEVERCODE",env:"NEVERCODE",pr:{env:"NEVERCODE_PULL_REQUEST",ne:"false"}},{name:"Prow",constant:"PROW",env:"PROW_JOB_ID"},{name:"ReleaseHub",constant:"RELEASEHUB",env:"RELEASE_BUILD_ID"},{name:"Render",constant:"RENDER",env:"RENDER",pr:{IS_PULL_REQUEST:"true"}},{name:"Sail CI",constant:"SAIL",env:"SAILCI",pr:"SAIL_PULL_REQUEST_NUMBER"},{name:"Screwdriver",constant:"SCREWDRIVER",env:"SCREWDRIVER",pr:{env:"SD_PULL_REQUEST",ne:"false"}},{name:"Semaphore",constant:"SEMAPHORE",env:"SEMAPHORE",pr:"PULL_REQUEST_NUMBER"},{name:"Sourcehut",constant:"SOURCEHUT",env:{CI_NAME:"sourcehut"}},{name:"Strider CD",constant:"STRIDER",env:"STRIDER"},{name:"TaskCluster",constant:"TASKCLUSTER",env:["TASK_ID","RUN_ID"]},{name:"TeamCity",constant:"TEAMCITY",env:"TEAMCITY_VERSION"},{name:"Travis CI",constant:"TRAVIS",env:"TRAVIS",pr:{env:"TRAVIS_PULL_REQUEST",ne:"false"}},{name:"Vela",constant:"VELA",env:"VELA",pr:{VELA_PULL_REQUEST:"1"}},{name:"Vercel",constant:"VERCEL",env:{any:["NOW_BUILDER","VERCEL"]},pr:"VERCEL_GIT_PULL_REQUEST_ID"},{name:"Visual Studio App Center",constant:"APPCENTER",env:"APPCENTER_BUILD_ID"},{name:"Woodpecker",constant:"WOODPECKER",env:{CI:"woodpecker"},pr:{CI_BUILD_EVENT:"pull_request"}},{name:"Xcode Cloud",constant:"XCODE_CLOUD",env:"CI_XCODE_PROJECT",pr:"CI_PULL_REQUEST_NUMBER"},{name:"Xcode Server",constant:"XCODE_SERVER",env:"XCS"}];function ol(){return el||(el=1,function(e){const t=il,r=process.env;function n(e){return"string"==typeof e?!!r[e]:"env"in e?r[e.env]&&r[e.env].includes(e.includes):"any"in e?e.any.some(function(e){return!!r[e]}):Object.keys(e).every(function(t){return r[t]===e[t]})}Object.defineProperty(e,"_vendors",{value:t.map(function(e){return e.constant})}),e.name=null,e.isPR=null,e.id=null,t.forEach(function(t){const i=(Array.isArray(t.env)?t.env:[t.env]).every(function(e){return n(e)});e[t.constant]=i,i&&(e.name=t.name,e.isPR=function(e){switch(typeof e.pr){case"string":return!!r[e.pr];case"object":return"env"in e.pr?"any"in e.pr?e.pr.any.some(function(t){return r[e.pr.env]===t}):e.pr.env in r&&r[e.pr.env]!==e.pr.ne:"any"in e.pr?e.pr.any.some(function(e){return!!r[e]}):n(e.pr);default:return null}}(t),e.id=t.constant)}),e.isCI=!("false"===r.CI||!(r.BUILD_ID||r.BUILD_NUMBER||r.CI||r.CI_APP_ID||r.CI_BUILD_ID||r.CI_BUILD_NUMBER||r.CI_NAME||r.CONTINUOUS_INTEGRATION||r.RUN_ID||e.name))}(nl)),nl}var sl=ue(rl?tl:(rl=1,tl=ol().isCI));const al=["5a842df8-3238-415d-b168-9f16a6a6031b/.default"];var cl;!function(e){e.ContinuesIntegration="ci",e.QualityAssurance="fqa",e.Training="tr",e.Production="fprd",e.Development="dev"}(cl||(cl={}));const ll=e=>e&&!sl?cl.Development:cl.ContinuesIntegration,ul=async e=>{const t=new Hs,r=e.env??cl.ContinuesIntegration;t.addConfig({module:la,configure:t=>{const n=r===cl.Development?cl.ContinuesIntegration:r,i=e.serviceDiscovery?.url??new URL(`/service-registry/environments/${n}/services`,"https://discovery.fusion.equinor.com").toString(),o=e.serviceDiscovery?.scope??al;t.configureClient("service_discovery",{baseUri:i,defaultScopes:o})}}),Qc(t),k(t,t=>{const{auth:r}=e;if("token"in r&&r.token){const{token:e}=r;return t.setMode("token_only"),void t.setAccessToken(e)}const{clientId:n,tenantId:i,interactive:o}=r;if(!n||!i)throw new Error("clientId and tenantId are required for auth module");if(t.setClientConfig(i,n),t.setMode(o?"interactive":"silent"),o){const{server:e}=r;if(!e.port)throw new Error("server.port is required for interactive mode");t.setServerPort(e.port),t.setServerOnOpen(e.onOpen)}});return await t.initialize()},fl=async e=>{const{log:t}=e,{config:r}=await nn({log:t,config:e.config,env:{environment:e.environment}}),{manifest:n}=await er({log:t,manifest:e.manifest,env:{environment:e.environment}}),i=n.build?.version;if(!i){const e=new Error("No build version found in the manifest. Please make sure the manifest is valid.");throw t?.fail("🤪",e.message),e}t?.start("Initializing Fusion Framework...");const o=await ul({env:e.environment,auth:e.auth});t?.succeed("Initialized Fusion Framework");const s=await o.serviceDiscovery.createClient("apps");s.request$.subscribe(e=>{t?.debug("Request:",e),t?.info("🌎","Executing request to:",Zt(e.uri))}),t?.start("Publishing application config"),t?.info("Using environment:",le.redBright(e.environment));try{const e=await s.json(`/apps/${n.appKey}/builds/${i}/config`,{method:"PUT",body:r});t?.debug("Response:",e),t?.succeed("Published application config")}catch(e){if(e instanceof sn)switch(e.response.status){case 410:t?.fail("🤬",`App ${n.appKey} is deleted from apps-service. Please check the app key and try again.`);break;case 404:t?.fail("🤬",`App ${n.appKey} not found. Please check the app key and try again.`);break;case 403:case 401:t?.fail("🤬","You are not authorized to publish application config. Please check your permissions.");break;default:t?.fail("🤬","Failed to publish application config.",`Status code: ${e.response.status}`,`Message: ${e.response.statusText}`)}throw e}},pl=async e=>{const{log:r}=e??{},n="@equinor/fusion-framework-dev-portal",o=await Qt(r),s={root:o.root,environment:"local",...e?.env,mode:"development",command:"serve"},a=await Jt(s,o,{log:r,manifestPath:e?.manifest}),c=await rn(s,{log:r,config:e?.config});let u,p;const h=f(import.meta.resolve(n));At(h)?(u=h,p=await l({cwd:h}).then(e=>e?i(e?.path):void 0)):r?.info(`Portal ${n} is external, skipping entry point resolution`);const d=p?[o.root,p]:[o.root];r?.debug(`File system access allowed for: \n${d.join("\n")}\n`);const m=t(await Tt(s,o),{server:{port:e?.port||3e3,host:"localhost",fs:{allow:d}}}),g={template:{portal:{id:n}},app:{manifest:a,config:c}};u&&(g.portal={manifest:{name:n,build:{templateEntry:u,assetPath:"/@fs"}},config:{}}),r?.debug("vite config:",m),r?.debug("dev server config:",g),r?.start("Starting app development server...");const v=await Xr(s,g,m);await v.listen(),r?.succeed("App development server started successfully");const y=v.config.server.https?"https":"http",E=v.config.server.host||"localhost",b=v.config.server.port||5173;return r?.info(`App development server is running at: ${y}://${E}:${b}/apps/${a.appKey}`),v},hl=async e=>{const{log:t}=e,r=await Qt(t),n=await Jt({command:"build",mode:"production"},r,{log:t});t?.start("Initializing Fusion Framework...");const i=await ul({env:e.environment,auth:"token"in e.auth?{token:e.auth.token}:e.auth});t?.succeed("Initialized Fusion Framework");const o=await i.serviceDiscovery.createClient("apps");o.request$.subscribe(e=>{t?.info("🌎","Executing request to:",e.uri),t?.debug("Request:",e)});try{t?.start(`Checking if ${n.appKey} is registered in app store`);const e=await o.fetch(`/apps/${n.appKey}`,{method:"HEAD"});if(e.ok)return t?.succeed("😃",`Application ${n.appKey} is registered in app store`);if(404===e.status)return t?.fail("😞",`Application ${n.appKey} is not registered in app store`);throw new Error(`Unexpected response status: ${e.status}`)}catch(e){t?.fail("🙅‍♂️","Error checking application registration"),t?.error("Error checking application registration:",e)}},dl=e=>{const t=e.getEntry("metadata.json");if(!t)throw new Error("Metadata file not found in bundle");return new Promise((e,r)=>{t.getDataAsync((t,n)=>{if(n)return r(new Error("Failed to read metadata file",{cause:n}));try{return e(JSON.parse(String(t)))}catch(e){r(new Error("Failed to parse metadata file",{cause:e}))}})})};const ml=async e=>{const{log:t,framework:r}=e,n="string"==typeof e.fileOrBundle?new Hr(e.fileOrBundle):e.fileOrBundle,{name:i}=e.appKey?{name:e.appKey}:await dl(n).catch(e=>{t?.error("Failed to resolve manifest:",e),process.exit(1)});t?.info("📦",`Uploading application bundle for ${le.bold(i)}`),t?.debug("Bundle contents:",(await n.getEntries()).map(e=>e.entryName));const o=await n.toBufferPromise().catch(e=>{t?.error("Failed to read bundle content:",e),process.exit(1)});try{const e=await r.serviceDiscovery.createClient("apps");e.request$.subscribe(e=>{t?.info("🌎","Executing request to:",e.uri),t?.debug("Request:",e)});const n=await e.fetch(`/bundles/apps/${i}`,{method:"POST",body:new Blob([o],{type:"application/zip"}),headers:{"Content-Type":"application/zip"}});if(!n.ok){try{const{error:e}=await n.json();t?.debug("Error:",e),e.message&&t?.warn(le.red(`🤯 error: ${e.code}\n`),le.yellowBright(e.message),"\n")}catch(e){t?.debug("Error:",n.statusText)}!function(e,t){switch(e.status){case 409:throw new Error(`${e.status} - Version is already published, please generate a new release`);case 410:throw new Error(`${e.status} - ${t} is removed from Fusion app store`);case 404:throw new Error(`${e.status} - ${t} not found, please add your application in App Admin before publishing`);case 401:case 403:throw new Error(`${e.status} - This is not allowed for your role on ${t}`);case 500:throw new Error(`${e.status} - Internal server error, please try again later or contact support`);default:throw new Error(`Failed to upload bundle. HTTP status ${e.status}, ${e.statusText}`)}}(n,i)}t?.succeed("Successfully uploaded application bundle"),t?.debug("Response:",n);try{return{name:i,version:(await n.json()).version}}catch(e){throw new Error(`Failed to parse response from app service: ${e instanceof Error?e.message:e}`)}}catch(e){t?.fail("🙅‍♂️","Failed to upload application bundle"),t?.error(e),process.exit(1)}};var gl;!function(e){e.Latest="latest",e.Preview="preview"}(gl||(gl={}));const vl=async e=>{const{tag:t,appKey:r,version:n,framework:i,log:o}=e;["latest","preview"].includes(t)||(o?.fail("🤪",'Invalid tag. Use "latest" or "preview".'),process.exit(1)),r||(o?.fail("🤪","Application key is required."),process.exit(1)),n||(o?.fail("🤪","Version is required."),process.exit(1));const s=await i.serviceDiscovery.createClient("apps");s.request$.subscribe(e=>{o?.debug("Request:",e),o?.info("🌎","Executing request to:",Zt(e.uri))}),o?.start("Publishing application config");try{const e=await s.json(`/apps/${r}/tags/${t}`,{method:"PUT",body:{version:n}});return o?.debug("Response:",e),o?.succeed("Tagged application successfully",le.greenBright(`${r}@${n} - ${t}`)),e}catch(e){if(e instanceof sn)switch(e.response.status){case 410:o?.fail("🤬",`App ${r} is deleted from apps-service. Please check the app key and try again.`);break;case 404:o?.fail("🤬",`App ${r} not found. Please check the app key and try again.`);break;case 403:case 401:o?.fail("🤬","You are not authorized to tag application. Please check your permissions.");break;default:o?.fail("🤬","Failed to tag application",`Status code: ${e.response.status}`,`Error: ${e.message}`)}throw e}},yl=P.object({templateEntry:P.string({required_error:"templateEntry is required in build section",invalid_type_error:"templateEntry must be a string"}).describe("Main entry point for the portal"),schemaEntry:P.string({required_error:"schemaEntry is required in build section",invalid_type_error:"schemaEntry must be a string"}).describe("Schema file for portal validation"),assetPath:P.string({invalid_type_error:"assetPath must be a string"}).optional().describe("Asset path for dev/preview builds"),githubRepo:P.string({invalid_type_error:"githubRepo must be a string"}).optional().describe("GitHub repo URL or local git remote"),version:P.string({required_error:"version is required in build section",invalid_type_error:"version must be a string"}).describe("Version from package.json"),timestamp:P.string({required_error:"timestamp is required in build section",invalid_type_error:"timestamp must be a string"}).describe("Current build timestamp (ISO8601)"),commitSha:P.string({required_error:"commitSha is required in build section",invalid_type_error:"commitSha must be a string"}).describe("Current git commit SHA"),annotations:P.record(P.string(),{invalid_type_error:"annotations must be a record of string values"}).optional().describe("Optional build annotations"),projectPage:P.string({invalid_type_error:"projectPage must be a string"}).optional().describe("Optional project homepage"),allowedExtensions:P.array(P.string({invalid_type_error:"Each allowed extension must be a string"}),{required_error:"allowedExtensions is required in build section",invalid_type_error:"allowedExtensions must be an array of strings"}).describe("List of allowed asset extensions (with leading dot)"),schema:P.record(P.unknown(),{invalid_type_error:"schema must be a record of unknown values"}).optional().describe("Optional schema for the portal"),config:P.record(P.unknown(),{invalid_type_error:"config must be a record of unknown values"}).optional().describe("Optional configuration for the portal")}),El=P.object({name:P.string({required_error:"name is required in portal manifest",invalid_type_error:"name must be a string"}).describe("Short app key (unscoped, derived from package name)"),displayName:P.string({invalid_type_error:"displayName must be a string"}).optional().describe("Full package name, may include scope"),description:P.string({invalid_type_error:"description must be a string"}).optional().describe("Description of the portal"),build:yl}),bl=(e,t)=>{xt(t,"expected packageJson"),O(t.name,"expected [name] in packageJson"),O(t.version,"expected [version] in packageJson");const r=((e,t)=>"build"===e.command||e.isPreview?t.main||t.module||"dist/bundle.js":_t(e.root))(e,t),n=t.name.replace(/^@|\w.*\//gm,""),i=t.version,o="build"===e.command?void 0:"/@fs",s=$t(t)??Ft(),a={name:n,displayName:t.name,description:t.description||"",build:{templateEntry:r,schemaEntry:"portal.schema.json",assetPath:o,githubRepo:s,version:i,timestamp:(new Date).toISOString(),commitSha:Ut(),annotations:{...kt()},projectPage:t.homepage,allowedExtensions:Bt.map(e=>`.${e}`)}},c=El.safeParse(a);if(!c.success){const e=c.error.issues.map(e=>`- ${e.path.join(".")}: ${e.message}`).join("\n");throw new Error(["Invalid portal manifest generated from package.json:",e].join("\n"))}return c.data},wl=async(e,t,r)=>{const n=bl(e,t.packageJson);try{r?.log?.start("loading manifest...");const t=await(async(e,t)=>{const r=t?.file??[`portal.manifest.${e.environment}`,"portal.manifest"],n=await C(r,{baseDir:e.root,extensions:t?.extensions,script:{resolve:async r=>{const n=t?.base??{};let i;return i="function"==typeof r.default?await r.default(e,{base:n})??void 0:r.default,i?D(n,i):n}}}),i=n.config,o=El.safeParse(i);if(!o.success)throw new Error(`Invalid portal manifest: ${o.error.errors.map(e=>`${e.path.join(".")}: ${e.message}`).join("; ")}`);return{manifest:i,path:n.path,extension:n.extension}})(e,{base:n});return r?.log?.succeed("generated manifest from",Zt(t.path,{relative:!0})),t.manifest}catch(e){if(e instanceof I){if(r?.manifestPath){const t=new Error(`Failed to load manifest file ${Zt(r.manifestPath)}, please check the path.`,{cause:e});throw r?.log?.fail(t.message),t}return r?.log?.succeed(le.dim("no local manifest config applied, using default generated from package")),n}throw r?.log?.fail(`failed to resolve application manifest ${r?.manifestPath?Zt(r?.manifestPath):""}`),e}},Ll=async(e,t)=>{const{log:r}=t;try{r?.start("create portal configuration"),r?.info(`generating config with ${le.red.dim(e.command)} command in ${le.green.dim(e.mode)} mode`);const n=await((e,t)=>{const r=t?.file??[`portal.config.${e.environment}`,"portal.config"];return C(r,{baseDir:e.root,extensions:t?.extensions,script:{resolve:async r=>{const n=t?.schema??A.object({}).passthrough(),i=t?.base??{};if("function"==typeof r.default){const t=await r.default(i,e)??i;return n.parse(t)}return n.parse(r.default??i)}}})})(e,{file:t?.config});return r?.succeed("⚙️ generated config from ",Zt(n.path,{relative:!0})),n.config}catch(e){if(e instanceof I){if(!t.config)return r?.succeed(le.dim("⚙️ no local portal config applied, using built-in")),{};r?.warn(`failed to load config file ${Zt(t.config)}, please check the path.`)}throw r?.fail("failed to resolve portal config"),r?.debug(e),e}},Sl=async e=>{const{log:r}=e??{},n=await Qt(r),i={root:n.root,environment:"local",...e?.env,mode:"development",command:"serve"},o=await wl(i,n,{log:r,manifestPath:e?.manifest}),s=await Ll(i,{log:r,config:e?.config}),a=t(await Tt(i,n),{server:{port:e?.server?.port,fs:{allow:[n.root]}}}),c={template:{portal:{id:o.name}},portal:{manifest:o,config:s}};r?.debug("vite config:",a),r?.debug("dev server config:",c),r?.start("Starting app development server...");const l=await Xr(i,c,a);return await l.listen(),r?.succeed(`Started app development server on ${l.resolvedUrls?.local?.[0]}`),l},Cl=async e=>{const{log:t}=e??{},r=await Qt(t);t?.debug("package",r);const n={command:"build",mode:process.env.NODE_ENV??"production",root:r.root,...e?.env};t?.debug("env:",n);const i=await wl(n,r,{log:t,manifestPath:e?.manifest});return t?.debug("manifest:",i),{manifest:i,pkg:r,env:n}},Il=async e=>{const{log:t}=e??{};t?.log(le.bold("Starting to build portal"));const{manifest:n,pkg:i,env:o}=await Cl({log:t,manifest:e?.manifest});t?.start("loading vite config...");const s=await Tt(o,i);t?.succeed("vite config applied"),t?.debug("vite config:",s),t?.start("🤞🏻","building portal..."),t?.startNativeConsoleCapture(),await r(s),t?.stopNativeConsoleCapture(),t?.succeed("build completed 😘");return{pkg:i,manifest:n,outDir:s.build.outDir}},Dl=async e=>{const{log:t,manifest:r}=e,n={command:"build",mode:process.env.NODE_ENV??"production",environment:null,root:process.cwd()},{pkg:i,manifest:o}=await Il({log:t,manifest:r});if(!o.build)throw new Error("Manifest build config not found");const s=await(async(e,t)=>{const r=t?.file??[`portal.schema.${e.environment}`,"portal.schema"],n=await C(r,{baseDir:e.root,extensions:t?.extensions,script:{resolve:async t=>{const r="function"==typeof t.default?await Promise.resolve(t.default(e)):t.default;if(!r)throw new Error("Schema function did not return a valid schema");return r}}});return{schema:n.config,path:n.path,extension:n.extension}})(n,{file:e?.schema});t?.debug("Schema:",s);return{archive:await en(i,{log:t,archive:e?.archive,content:{"portal-template-manifest.json":JSON.stringify(o.build,null,2),"portal.schema.json":JSON.stringify(s.schema,null,2),"metadata.json":JSON.stringify({name:o.name,version:o.build.version})}}).catch(e=>{t?.error("Failed to create package:",e),process.exit(1)}),manifest:o,schema:s.schema}},Ol=async e=>{const{log:t}=e??{},r=await Qt(t),n={command:"build",mode:process.env.NODE_ENV??"production",root:r.root,...e?.env},i=await Ll(n,{log:t,config:e?.config});if(t?.debug("config:",i),e?.output){t?.start("writing config to file");try{await Jr(e.output,JSON.stringify(i,null,2)),t?.succeed("config written successfully",Zt(e.output,{relative:!0}))}catch(e){throw t?.fail("failed to write config"),e}}return{config:i,pkg:r}},Nl=async e=>{const{log:t,portal:r}=e,{config:n}=await Ol({log:t,config:e.config,env:{environment:e.environment}});t?.start("Initializing Fusion Framework...");const i=await ul({env:e.environment,auth:e.auth});t?.succeed("Initialized Fusion Framework");const o=await i.serviceDiscovery.createClient("portals");o.request$.subscribe(e=>{t?.debug("Request:",e),t?.info("🌎","Executing request to:",Zt(e.uri))}),t?.start("Publishing portal config"),t?.info("Using environment:",le.redBright(e.environment));try{const e=await o.json(`/portals/${r.name}@${r.version}/config`,{method:"PUT",body:n});t?.debug("Response:",e),t?.succeed("Published portal config")}catch(e){if(e instanceof sn)switch(e.response.status){case 410:t?.fail("🤬",`Portal ${r.name} is deleted from portals-service. Please check the portal key and try again.`);break;case 404:t?.fail("🤬",`Portal ${r.name} not found. Please check the portal key and try again.`);break;case 403:case 401:t?.fail("🤬","You are not authorized to publish portal config. Please check your permissions.");break;default:t?.fail("🤬","Failed to publish portal config.",`Status code: ${e.response.status}`,`Message: ${e.response.statusText}`)}throw e}};const Al=async e=>{const{log:t,framework:r}=e,n="string"==typeof e.fileOrBundle?new Hr(e.fileOrBundle):e.fileOrBundle,{name:i}=e.name?{name:e.name}:await dl(n).catch(e=>{t?.error("Failed to resolve manifest:",e),process.exit(1)}),o=await n.toBufferPromise().catch(e=>{t?.error("Failed to read bundle content:",e),process.exit(1)});try{const e=await r.serviceDiscovery.createClient("portal-config");e.request$.subscribe(e=>{t?.info("🌎","Executing request to:",e.uri),t?.debug("Request:",e)});const n=await e.fetch(`/bundles/templates/${i}`,{method:"POST",body:new Blob([o],{type:"application/zip"}),headers:{"Content-Type":"application/zip"}});if(!n.ok){try{const{error:e}=await n.json();t?.debug("Error:",e),e.message&&t?.warn(le.red(`🤯 error: ${e.code}\n`),le.yellowBright(e.message),"\n")}catch(e){t?.debug("Error:",n.statusText)}!function(e,t){switch(e.status){case 409:throw new Error(`${e.status} - Version is already published, please generate a new release`);case 410:throw new Error(`${e.status} - ${t} is removed from Fusion`);case 404:throw new Error(`${e.status} - ${t} not found`);case 401:case 403:throw new Error(`${e.status} - This is not allowed for your role on ${t}`);case 500:throw new Error(`${e.status} - Internal server error, please try again later or contact support`);default:throw new Error(`Failed to upload bundle. HTTP status ${e.status}, ${e.statusText}`)}}(n,i)}t?.succeed("Successfully uploaded portal bundle"),t?.debug("Response:",n)}catch(e){t?.fail("🙅‍♂️","Failed to upload portal bundle"),t?.error(e),process.exit(1)}};var Pl;!function(e){e.Latest="latest",e.Preview="preview"}(Pl||(Pl={}));const _l=async e=>{const{tag:t,name:r,version:n,framework:i,log:o}=e;["latest","preview"].includes(t)||(o?.fail("🤪",'Invalid tag. Use "latest" or "preview".'),process.exit(1)),r||(o?.fail("🤪","Portal name is required."),process.exit(1)),n||(o?.fail("🤪","Version is required."),process.exit(1)),o?.info("Tagging portal:",le.greenBright(`${r}@${t}`,n));const s=await i.serviceDiscovery.createClient("portal-config");s.request$.subscribe(e=>{o?.debug("Request:",e),o?.info("🌎","Executing request to:",Zt(e.uri))}),o?.start("Tagging portal template...");try{const e=await s.json(`/templates/${r}/tags/${t}`,{method:"PUT",body:{version:n}});o?.debug("Response:",e),o?.succeed("Tagged portal template successfully"),o?.info("🚀",JSON.stringify(e))}catch(e){if(e instanceof sn){const{data:t,response:n}=e;switch(o?.debug("Error:",t),t&&o?.warn(le.red(`🤯 error: ${t.code}\n`),le.yellowBright(t.message),"\n"),n?.status){case 410:o?.fail(`🤬 - ${n?.status} -`,`${r} is deleted. Please check the name and try again.`);break;case 404:o?.fail(`🤬 - ${n?.status} -`,`${r} not found. Please check the name and try again.`);break;case 403:case 401:o?.fail(`🤬 - ${n?.status} -`,"You are not authorized to tag. Please check your permissions.");break;default:o?.fail(`🤬 - ${n?.status} -`,"Failed to tag",`Error: ${e.message}`)}}throw e}};export{gl as AllowedAppTags,Pl as AllowedPortalTags,Kr as ConsoleLogger,cl as FusionEnv,tr as buildApplication,Il as buildPortal,tn as bundleApp,Dl as bundlePortal,hl as checkApp,nn as generateApplicationConfig,Ol as generatePortalConfig,ul as initializeFramework,er as loadAppManifest,Cl as loadPortalManifest,en as pack,fl as publishAppConfig,Nl as publishPortalConfig,ll as resolveDefaultEnv,pl as startAppDevServer,Sl as startPortalDevServer,vl as tagApplication,_l as tagPortal,ml as uploadApplication,Al as uploadPortalBundle};
1
+ import{loadConfigFromFile as e,mergeConfig as t,build as r}from"vite";import n from"vite-tsconfig-paths";import{dirname as i,resolve as o,basename as s,extname as a,relative as c}from"node:path";import{readPackageUp as l}from"read-package-up";import u,{fileURLToPath as f}from"node:url";import p from"url";import h from"node:module";import d from"util";import{accessSync as m,constants as g,readFileSync as v,statSync as y,existsSync as E,mkdirSync as b,writeFileSync as w}from"node:fs";import{stat as L,mkdir as S}from"node:fs/promises";import{importConfig as C,FileNotFoundError as I}from"@equinor/fusion-imports";import D from"deepmerge";import _ from"node:assert";import{execSync as O}from"node:child_process";import N,{z as A}from"zod";import P from"fs";import T from"path";import R from"zlib";import x from"crypto";import $ from"ora";import{createDevServer as F,processServices as U}from"@equinor/fusion-framework-dev-server";import{enableAuthModule as k}from"@equinor/fusion-framework-module-msal-node";const B=(e=0)=>t=>`[${t+e}m`,M=(e=0)=>t=>`[${38+e};5;${t}m`,G=(e=0)=>(t,r,n)=>`[${38+e};2;${t};${r};${n}m`,j={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(j.modifier);Object.keys(j.color),Object.keys(j.bgColor);const z=function(){const e=new Map;for(const[t,r]of Object.entries(j)){for(const[t,n]of Object.entries(r))j[t]={open:`[${n[0]}m`,close:`[${n[1]}m`},r[t]=j[t],e.set(n[0],n[1]);Object.defineProperty(j,t,{value:r,enumerable:!1})}return Object.defineProperty(j,"codes",{value:e,enumerable:!1}),j.color.close="",j.bgColor.close="",j.color.ansi=B(),j.color.ansi256=M(),j.color.ansi16m=G(),j.bgColor.ansi=B(10),j.bgColor.ansi256=M(10),j.bgColor.ansi16m=G(10),Object.defineProperties(j,{rgbToAnsi256:{value:(e,t,r)=>e===t&&t===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(r/255*5),enumerable:!1},hexToRgb:{value(e){const t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[r]=t;3===r.length&&(r=[...r].map(e=>e+e).join(""));const n=Number.parseInt(r,16);return[n>>16&255,n>>8&255,255&n]},enumerable:!1},hexToAnsi256:{value:e=>j.rgbToAnsi256(...j.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return e-8+90;let t,r,n;if(e>=232)t=(10*(e-232)+8)/255,r=t,n=t;else{const i=(e-=16)%36;t=Math.floor(e/36)/5,r=Math.floor(i/6)/5,n=i%6/5}const i=2*Math.max(t,r,n);if(0===i)return 30;let o=30+(Math.round(n)<<2|Math.round(r)<<1|Math.round(t));return 2===i&&(o+=60),o},enumerable:!1},rgbToAnsi:{value:(e,t,r)=>j.ansi256ToAnsi(j.rgbToAnsi256(e,t,r)),enumerable:!1},hexToAnsi:{value:e=>j.ansi256ToAnsi(j.hexToAnsi256(e)),enumerable:!1}}),j}(),H=(()=>{if(!("navigator"in globalThis))return 0;if(globalThis.navigator.userAgentData){const e=navigator.userAgentData.brands.find(({brand:e})=>"Chromium"===e);if(e&&e.version>93)return 3}return/\b(Chrome|Chromium)\//.test(globalThis.navigator.userAgent)?1:0})(),W=0!==H&&{level:H},V={stdout:W,stderr:W};function q(e,t,r){let n=e.indexOf(t);if(-1===n)return e;const i=t.length;let o=0,s="";do{s+=e.slice(o,n)+t+r,o=n+i,n=e.indexOf(t,o)}while(-1!==n);return s+=e.slice(o),s}const{stdout:Y,stderr:K}=V,Z=Symbol("GENERATOR"),X=Symbol("STYLER"),J=Symbol("IS_EMPTY"),Q=["ansi","ansi","ansi256","ansi16m"],ee=Object.create(null),te=e=>{const t=(...e)=>e.join(" ");return((e,t={})=>{if(t.level&&!(Number.isInteger(t.level)&&t.level>=0&&t.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");const r=Y?Y.level:0;e.level=void 0===t.level?r:t.level})(t,e),Object.setPrototypeOf(t,re.prototype),t};function re(e){return te(e)}Object.setPrototypeOf(re.prototype,Function.prototype);for(const[e,t]of Object.entries(z))ee[e]={get(){const r=ae(this,se(t.open,t.close,this[X]),this[J]);return Object.defineProperty(this,e,{value:r}),r}};ee.visible={get(){const e=ae(this,this[X],!0);return Object.defineProperty(this,"visible",{value:e}),e}};const ne=(e,t,r,...n)=>"rgb"===e?"ansi16m"===t?z[r].ansi16m(...n):"ansi256"===t?z[r].ansi256(z.rgbToAnsi256(...n)):z[r].ansi(z.rgbToAnsi(...n)):"hex"===e?ne("rgb",t,r,...z.hexToRgb(...n)):z[r][e](...n),ie=["rgb","hex","ansi256"];for(const e of ie){ee[e]={get(){const{level:t}=this;return function(...r){const n=se(ne(e,Q[t],"color",...r),z.color.close,this[X]);return ae(this,n,this[J])}}};ee["bg"+e[0].toUpperCase()+e.slice(1)]={get(){const{level:t}=this;return function(...r){const n=se(ne(e,Q[t],"bgColor",...r),z.bgColor.close,this[X]);return ae(this,n,this[J])}}}}const oe=Object.defineProperties(()=>{},{...ee,level:{enumerable:!0,get(){return this[Z].level},set(e){this[Z].level=e}}}),se=(e,t,r)=>{let n,i;return void 0===r?(n=e,i=t):(n=r.openAll+e,i=t+r.closeAll),{open:e,close:t,openAll:n,closeAll:i,parent:r}},ae=(e,t,r)=>{const n=(...e)=>ce(n,1===e.length?""+e[0]:e.join(" "));return Object.setPrototypeOf(n,oe),n[Z]=e,n[X]=t,n[J]=r,n},ce=(e,t)=>{if(e.level<=0||!t)return e[J]?"":t;let r=e[X];if(void 0===r)return t;const{openAll:n,closeAll:i}=r;if(t.includes(""))for(;void 0!==r;)t=q(t,r.close,r.open),r=r.parent;const o=t.indexOf("\n");return-1!==o&&(t=function(e,t,r,n){let i=0,o="";do{const s="\r"===e[n-1];o+=e.slice(i,s?n-1:n)+t+(s?"\r\n":"\n")+r,i=n+1,n=e.indexOf("\n",i)}while(-1!==n);return o+=e.slice(i),o}(t,i,n,o)),n+t+i};Object.defineProperties(re.prototype,ee);const le=re();function ue(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var fe,pe,he,de;function me(){if(pe)return fe;pe=1;const e="object"==typeof process&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};return fe=e}function ge(){if(de)return he;de=1;const e=Number.MAX_SAFE_INTEGER||9007199254740991;return he={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:e,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}}re({level:K?K.level:0});var ve,ye,Ee,be,we,Le,Se,Ce,Ie,De,_e,Oe,Ne,Ae={exports:{}};function Pe(){return ve||(ve=1,function(e,t){const{MAX_SAFE_COMPONENT_LENGTH:r,MAX_SAFE_BUILD_LENGTH:n,MAX_LENGTH:i}=ge(),o=me(),s=(t=e.exports={}).re=[],a=t.safeRe=[],c=t.src=[],l=t.safeSrc=[],u=t.t={};let f=0;const p="[a-zA-Z0-9-]",h=[["\\s",1],["\\d",i],[p,n]],d=(e,t,r)=>{const n=(e=>{for(const[t,r]of h)e=e.split(`${t}*`).join(`${t}{0,${r}}`).split(`${t}+`).join(`${t}{1,${r}}`);return e})(t),i=f++;o(e,i,t),u[e]=i,c[i]=t,l[i]=n,s[i]=new RegExp(t,r?"g":void 0),a[i]=new RegExp(n,r?"g":void 0)};d("NUMERICIDENTIFIER","0|[1-9]\\d*"),d("NUMERICIDENTIFIERLOOSE","\\d+"),d("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${p}*`),d("MAINVERSION",`(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})`),d("MAINVERSIONLOOSE",`(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})`),d("PRERELEASEIDENTIFIER",`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIER]})`),d("PRERELEASEIDENTIFIERLOOSE",`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIERLOOSE]})`),d("PRERELEASE",`(?:-(${c[u.PRERELEASEIDENTIFIER]}(?:\\.${c[u.PRERELEASEIDENTIFIER]})*))`),d("PRERELEASELOOSE",`(?:-?(${c[u.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[u.PRERELEASEIDENTIFIERLOOSE]})*))`),d("BUILDIDENTIFIER",`${p}+`),d("BUILD",`(?:\\+(${c[u.BUILDIDENTIFIER]}(?:\\.${c[u.BUILDIDENTIFIER]})*))`),d("FULLPLAIN",`v?${c[u.MAINVERSION]}${c[u.PRERELEASE]}?${c[u.BUILD]}?`),d("FULL",`^${c[u.FULLPLAIN]}$`),d("LOOSEPLAIN",`[v=\\s]*${c[u.MAINVERSIONLOOSE]}${c[u.PRERELEASELOOSE]}?${c[u.BUILD]}?`),d("LOOSE",`^${c[u.LOOSEPLAIN]}$`),d("GTLT","((?:<|>)?=?)"),d("XRANGEIDENTIFIERLOOSE",`${c[u.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),d("XRANGEIDENTIFIER",`${c[u.NUMERICIDENTIFIER]}|x|X|\\*`),d("XRANGEPLAIN",`[v=\\s]*(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:${c[u.PRERELEASE]})?${c[u.BUILD]}?)?)?`),d("XRANGEPLAINLOOSE",`[v=\\s]*(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:${c[u.PRERELEASELOOSE]})?${c[u.BUILD]}?)?)?`),d("XRANGE",`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAIN]}$`),d("XRANGELOOSE",`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAINLOOSE]}$`),d("COERCEPLAIN",`(^|[^\\d])(\\d{1,${r}})(?:\\.(\\d{1,${r}}))?(?:\\.(\\d{1,${r}}))?`),d("COERCE",`${c[u.COERCEPLAIN]}(?:$|[^\\d])`),d("COERCEFULL",c[u.COERCEPLAIN]+`(?:${c[u.PRERELEASE]})?`+`(?:${c[u.BUILD]})?(?:$|[^\\d])`),d("COERCERTL",c[u.COERCE],!0),d("COERCERTLFULL",c[u.COERCEFULL],!0),d("LONETILDE","(?:~>?)"),d("TILDETRIM",`(\\s*)${c[u.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",d("TILDE",`^${c[u.LONETILDE]}${c[u.XRANGEPLAIN]}$`),d("TILDELOOSE",`^${c[u.LONETILDE]}${c[u.XRANGEPLAINLOOSE]}$`),d("LONECARET","(?:\\^)"),d("CARETTRIM",`(\\s*)${c[u.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",d("CARET",`^${c[u.LONECARET]}${c[u.XRANGEPLAIN]}$`),d("CARETLOOSE",`^${c[u.LONECARET]}${c[u.XRANGEPLAINLOOSE]}$`),d("COMPARATORLOOSE",`^${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]})$|^$`),d("COMPARATOR",`^${c[u.GTLT]}\\s*(${c[u.FULLPLAIN]})$|^$`),d("COMPARATORTRIM",`(\\s*)${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]}|${c[u.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",d("HYPHENRANGE",`^\\s*(${c[u.XRANGEPLAIN]})\\s+-\\s+(${c[u.XRANGEPLAIN]})\\s*$`),d("HYPHENRANGELOOSE",`^\\s*(${c[u.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[u.XRANGEPLAINLOOSE]})\\s*$`),d("STAR","(<|>)?=?\\s*\\*"),d("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),d("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")}(Ae,Ae.exports)),Ae.exports}function Te(){if(Ee)return ye;Ee=1;const e=Object.freeze({loose:!0}),t=Object.freeze({});return ye=r=>r?"object"!=typeof r?e:r:t}function Re(){if(we)return be;we=1;const e=/^[0-9]+$/,t=(t,r)=>{const n=e.test(t),i=e.test(r);return n&&i&&(t=+t,r=+r),t===r?0:n&&!i?-1:i&&!n?1:t<r?-1:1};return be={compareIdentifiers:t,rcompareIdentifiers:(e,r)=>t(r,e)}}function xe(){if(Se)return Le;Se=1;const e=me(),{MAX_LENGTH:t,MAX_SAFE_INTEGER:r}=ge(),{safeRe:n,t:i}=Pe(),o=Te(),{compareIdentifiers:s}=Re();class a{constructor(s,c){if(c=o(c),s instanceof a){if(s.loose===!!c.loose&&s.includePrerelease===!!c.includePrerelease)return s;s=s.version}else if("string"!=typeof s)throw new TypeError(`Invalid version. Must be a string. Got type "${typeof s}".`);if(s.length>t)throw new TypeError(`version is longer than ${t} characters`);e("SemVer",s,c),this.options=c,this.loose=!!c.loose,this.includePrerelease=!!c.includePrerelease;const l=s.trim().match(c.loose?n[i.LOOSE]:n[i.FULL]);if(!l)throw new TypeError(`Invalid Version: ${s}`);if(this.raw=s,this.major=+l[1],this.minor=+l[2],this.patch=+l[3],this.major>r||this.major<0)throw new TypeError("Invalid major version");if(this.minor>r||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>r||this.patch<0)throw new TypeError("Invalid patch version");l[4]?this.prerelease=l[4].split(".").map(e=>{if(/^[0-9]+$/.test(e)){const t=+e;if(t>=0&&t<r)return t}return e}):this.prerelease=[],this.build=l[5]?l[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(t){if(e("SemVer.compare",this.version,this.options,t),!(t instanceof a)){if("string"==typeof t&&t===this.version)return 0;t=new a(t,this.options)}return t.version===this.version?0:this.compareMain(t)||this.comparePre(t)}compareMain(e){return e instanceof a||(e=new a(e,this.options)),s(this.major,e.major)||s(this.minor,e.minor)||s(this.patch,e.patch)}comparePre(t){if(t instanceof a||(t=new a(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let r=0;do{const n=this.prerelease[r],i=t.prerelease[r];if(e("prerelease compare",r,n,i),void 0===n&&void 0===i)return 0;if(void 0===i)return 1;if(void 0===n)return-1;if(n!==i)return s(n,i)}while(++r)}compareBuild(t){t instanceof a||(t=new a(t,this.options));let r=0;do{const n=this.build[r],i=t.build[r];if(e("build compare",r,n,i),void 0===n&&void 0===i)return 0;if(void 0===i)return 1;if(void 0===n)return-1;if(n!==i)return s(n,i)}while(++r)}inc(e,t,r){if(e.startsWith("pre")){if(!t&&!1===r)throw new Error("invalid increment argument: identifier is empty");if(t){const e=`-${t}`.match(this.options.loose?n[i.PRERELEASELOOSE]:n[i.PRERELEASE]);if(!e||e[1]!==t)throw new Error(`invalid identifier: ${t}`)}}switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",t,r);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",t,r);break;case"prepatch":this.prerelease.length=0,this.inc("patch",t,r),this.inc("pre",t,r);break;case"prerelease":0===this.prerelease.length&&this.inc("patch",t,r),this.inc("pre",t,r);break;case"release":if(0===this.prerelease.length)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":0===this.minor&&0===this.patch&&0!==this.prerelease.length||this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":0===this.patch&&0!==this.prerelease.length||this.minor++,this.patch=0,this.prerelease=[];break;case"patch":0===this.prerelease.length&&this.patch++,this.prerelease=[];break;case"pre":{const e=Number(r)?1:0;if(0===this.prerelease.length)this.prerelease=[e];else{let n=this.prerelease.length;for(;--n>=0;)"number"==typeof this.prerelease[n]&&(this.prerelease[n]++,n=-2);if(-1===n){if(t===this.prerelease.join(".")&&!1===r)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(e)}}if(t){let n=[t,e];!1===r&&(n=[t]),0===s(this.prerelease[0],t)?isNaN(this.prerelease[1])&&(this.prerelease=n):this.prerelease=n}break}default:throw new Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}}return Le=a}function $e(){if(Ie)return Ce;Ie=1;const e=xe();return Ce=(t,r,n=!1)=>{if(t instanceof e)return t;try{return new e(t,r)}catch(e){if(!n)return null;throw e}},Ce}function Fe(){if(_e)return De;_e=1;const e=$e();return De=(t,r)=>{const n=e(t,r);return n?n.version:null},De}function Ue(){if(Ne)return Oe;Ne=1;const e=$e();return Oe=(t,r)=>{const n=e(t.trim().replace(/^[=v]+/,""),r);return n?n.version:null},Oe}var ke,Be,Me,Ge,je,ze,He,We,Ve,qe,Ye=["0BSD","3D-Slicer-1.0","AAL","ADSL","AFL-1.1","AFL-1.2","AFL-2.0","AFL-2.1","AFL-3.0","AGPL-1.0-only","AGPL-1.0-or-later","AGPL-3.0-only","AGPL-3.0-or-later","AMD-newlib","AMDPLPA","AML","AML-glslang","AMPAS","ANTLR-PD","ANTLR-PD-fallback","APAFML","APL-1.0","APSL-1.0","APSL-1.1","APSL-1.2","APSL-2.0","ASWF-Digital-Assets-1.0","ASWF-Digital-Assets-1.1","Abstyles","AdaCore-doc","Adobe-2006","Adobe-Display-PostScript","Adobe-Glyph","Adobe-Utopia","Afmparse","Aladdin","Apache-1.0","Apache-1.1","Apache-2.0","App-s2p","Arphic-1999","Artistic-1.0","Artistic-1.0-Perl","Artistic-1.0-cl8","Artistic-2.0","Artistic-dist","Aspell-RU","BSD-1-Clause","BSD-2-Clause","BSD-2-Clause-Darwin","BSD-2-Clause-Patent","BSD-2-Clause-Views","BSD-2-Clause-first-lines","BSD-2-Clause-pkgconf-disclaimer","BSD-3-Clause","BSD-3-Clause-Attribution","BSD-3-Clause-Clear","BSD-3-Clause-HP","BSD-3-Clause-LBNL","BSD-3-Clause-Modification","BSD-3-Clause-No-Military-License","BSD-3-Clause-No-Nuclear-License","BSD-3-Clause-No-Nuclear-License-2014","BSD-3-Clause-No-Nuclear-Warranty","BSD-3-Clause-Open-MPI","BSD-3-Clause-Sun","BSD-3-Clause-acpica","BSD-3-Clause-flex","BSD-4-Clause","BSD-4-Clause-Shortened","BSD-4-Clause-UC","BSD-4.3RENO","BSD-4.3TAHOE","BSD-Advertising-Acknowledgement","BSD-Attribution-HPND-disclaimer","BSD-Inferno-Nettverk","BSD-Protection","BSD-Source-Code","BSD-Source-beginning-file","BSD-Systemics","BSD-Systemics-W3Works","BSL-1.0","BUSL-1.1","Baekmuk","Bahyph","Barr","Beerware","BitTorrent-1.0","BitTorrent-1.1","Bitstream-Charter","Bitstream-Vera","BlueOak-1.0.0","Boehm-GC","Boehm-GC-without-fee","Borceux","Brian-Gladman-2-Clause","Brian-Gladman-3-Clause","C-UDA-1.0","CAL-1.0","CAL-1.0-Combined-Work-Exception","CATOSL-1.1","CC-BY-1.0","CC-BY-2.0","CC-BY-2.5","CC-BY-2.5-AU","CC-BY-3.0","CC-BY-3.0-AT","CC-BY-3.0-AU","CC-BY-3.0-DE","CC-BY-3.0-IGO","CC-BY-3.0-NL","CC-BY-3.0-US","CC-BY-4.0","CC-BY-NC-1.0","CC-BY-NC-2.0","CC-BY-NC-2.5","CC-BY-NC-3.0","CC-BY-NC-3.0-DE","CC-BY-NC-4.0","CC-BY-NC-ND-1.0","CC-BY-NC-ND-2.0","CC-BY-NC-ND-2.5","CC-BY-NC-ND-3.0","CC-BY-NC-ND-3.0-DE","CC-BY-NC-ND-3.0-IGO","CC-BY-NC-ND-4.0","CC-BY-NC-SA-1.0","CC-BY-NC-SA-2.0","CC-BY-NC-SA-2.0-DE","CC-BY-NC-SA-2.0-FR","CC-BY-NC-SA-2.0-UK","CC-BY-NC-SA-2.5","CC-BY-NC-SA-3.0","CC-BY-NC-SA-3.0-DE","CC-BY-NC-SA-3.0-IGO","CC-BY-NC-SA-4.0","CC-BY-ND-1.0","CC-BY-ND-2.0","CC-BY-ND-2.5","CC-BY-ND-3.0","CC-BY-ND-3.0-DE","CC-BY-ND-4.0","CC-BY-SA-1.0","CC-BY-SA-2.0","CC-BY-SA-2.0-UK","CC-BY-SA-2.1-JP","CC-BY-SA-2.5","CC-BY-SA-3.0","CC-BY-SA-3.0-AT","CC-BY-SA-3.0-DE","CC-BY-SA-3.0-IGO","CC-BY-SA-4.0","CC-PDDC","CC-PDM-1.0","CC-SA-1.0","CC0-1.0","CDDL-1.0","CDDL-1.1","CDL-1.0","CDLA-Permissive-1.0","CDLA-Permissive-2.0","CDLA-Sharing-1.0","CECILL-1.0","CECILL-1.1","CECILL-2.0","CECILL-2.1","CECILL-B","CECILL-C","CERN-OHL-1.1","CERN-OHL-1.2","CERN-OHL-P-2.0","CERN-OHL-S-2.0","CERN-OHL-W-2.0","CFITSIO","CMU-Mach","CMU-Mach-nodoc","CNRI-Jython","CNRI-Python","CNRI-Python-GPL-Compatible","COIL-1.0","CPAL-1.0","CPL-1.0","CPOL-1.02","CUA-OPL-1.0","Caldera","Caldera-no-preamble","Catharon","ClArtistic","Clips","Community-Spec-1.0","Condor-1.1","Cornell-Lossless-JPEG","Cronyx","Crossword","CryptoSwift","CrystalStacker","Cube","D-FSL-1.0","DEC-3-Clause","DL-DE-BY-2.0","DL-DE-ZERO-2.0","DOC","DRL-1.0","DRL-1.1","DSDP","DocBook-DTD","DocBook-Schema","DocBook-Stylesheet","DocBook-XML","Dotseqn","ECL-1.0","ECL-2.0","EFL-1.0","EFL-2.0","EPICS","EPL-1.0","EPL-2.0","EUDatagrid","EUPL-1.0","EUPL-1.1","EUPL-1.2","Elastic-2.0","Entessa","ErlPL-1.1","Eurosym","FBM","FDK-AAC","FSFAP","FSFAP-no-warranty-disclaimer","FSFUL","FSFULLR","FSFULLRSD","FSFULLRWD","FSL-1.1-ALv2","FSL-1.1-MIT","FTL","Fair","Ferguson-Twofish","Frameworx-1.0","FreeBSD-DOC","FreeImage","Furuseth","GCR-docs","GD","GFDL-1.1-invariants-only","GFDL-1.1-invariants-or-later","GFDL-1.1-no-invariants-only","GFDL-1.1-no-invariants-or-later","GFDL-1.1-only","GFDL-1.1-or-later","GFDL-1.2-invariants-only","GFDL-1.2-invariants-or-later","GFDL-1.2-no-invariants-only","GFDL-1.2-no-invariants-or-later","GFDL-1.2-only","GFDL-1.2-or-later","GFDL-1.3-invariants-only","GFDL-1.3-invariants-or-later","GFDL-1.3-no-invariants-only","GFDL-1.3-no-invariants-or-later","GFDL-1.3-only","GFDL-1.3-or-later","GL2PS","GLWTPL","GPL-1.0-only","GPL-1.0-or-later","GPL-2.0-only","GPL-2.0-or-later","GPL-3.0-only","GPL-3.0-or-later","Game-Programming-Gems","Giftware","Glide","Glulxe","Graphics-Gems","Gutmann","HDF5","HIDAPI","HP-1986","HP-1989","HPND","HPND-DEC","HPND-Fenneberg-Livingston","HPND-INRIA-IMAG","HPND-Intel","HPND-Kevlin-Henney","HPND-MIT-disclaimer","HPND-Markus-Kuhn","HPND-Netrek","HPND-Pbmplus","HPND-UC","HPND-UC-export-US","HPND-doc","HPND-doc-sell","HPND-export-US","HPND-export-US-acknowledgement","HPND-export-US-modify","HPND-export2-US","HPND-merchantability-variant","HPND-sell-MIT-disclaimer-xserver","HPND-sell-regexpr","HPND-sell-variant","HPND-sell-variant-MIT-disclaimer","HPND-sell-variant-MIT-disclaimer-rev","HTMLTIDY","HaskellReport","Hippocratic-2.1","IBM-pibs","ICU","IEC-Code-Components-EULA","IJG","IJG-short","IPA","IPL-1.0","ISC","ISC-Veillard","ImageMagick","Imlib2","Info-ZIP","Inner-Net-2.0","InnoSetup","Intel","Intel-ACPI","Interbase-1.0","JPL-image","JPNIC","JSON","Jam","JasPer-2.0","Kastrup","Kazlib","Knuth-CTAN","LAL-1.2","LAL-1.3","LGPL-2.0-only","LGPL-2.0-or-later","LGPL-2.1-only","LGPL-2.1-or-later","LGPL-3.0-only","LGPL-3.0-or-later","LGPLLR","LOOP","LPD-document","LPL-1.0","LPL-1.02","LPPL-1.0","LPPL-1.1","LPPL-1.2","LPPL-1.3a","LPPL-1.3c","LZMA-SDK-9.11-to-9.20","LZMA-SDK-9.22","Latex2e","Latex2e-translated-notice","Leptonica","LiLiQ-P-1.1","LiLiQ-R-1.1","LiLiQ-Rplus-1.1","Libpng","Linux-OpenIB","Linux-man-pages-1-para","Linux-man-pages-copyleft","Linux-man-pages-copyleft-2-para","Linux-man-pages-copyleft-var","Lucida-Bitmap-Fonts","MIPS","MIT","MIT-0","MIT-CMU","MIT-Click","MIT-Festival","MIT-Khronos-old","MIT-Modern-Variant","MIT-Wu","MIT-advertising","MIT-enna","MIT-feh","MIT-open-group","MIT-testregex","MITNFA","MMIXware","MPEG-SSG","MPL-1.0","MPL-1.1","MPL-2.0","MPL-2.0-no-copyleft-exception","MS-LPL","MS-PL","MS-RL","MTLL","Mackerras-3-Clause","Mackerras-3-Clause-acknowledgment","MakeIndex","Martin-Birgmeier","McPhee-slideshow","Minpack","MirOS","Motosoto","MulanPSL-1.0","MulanPSL-2.0","Multics","Mup","NAIST-2003","NASA-1.3","NBPL-1.0","NCBI-PD","NCGL-UK-2.0","NCL","NCSA","NGPL","NICTA-1.0","NIST-PD","NIST-PD-fallback","NIST-Software","NLOD-1.0","NLOD-2.0","NLPL","NOSL","NPL-1.0","NPL-1.1","NPOSL-3.0","NRL","NTIA-PD","NTP","NTP-0","Naumen","NetCDF","Newsletr","Nokia","Noweb","O-UDA-1.0","OAR","OCCT-PL","OCLC-2.0","ODC-By-1.0","ODbL-1.0","OFFIS","OFL-1.0","OFL-1.0-RFN","OFL-1.0-no-RFN","OFL-1.1","OFL-1.1-RFN","OFL-1.1-no-RFN","OGC-1.0","OGDL-Taiwan-1.0","OGL-Canada-2.0","OGL-UK-1.0","OGL-UK-2.0","OGL-UK-3.0","OGTSL","OLDAP-1.1","OLDAP-1.2","OLDAP-1.3","OLDAP-1.4","OLDAP-2.0","OLDAP-2.0.1","OLDAP-2.1","OLDAP-2.2","OLDAP-2.2.1","OLDAP-2.2.2","OLDAP-2.3","OLDAP-2.4","OLDAP-2.5","OLDAP-2.6","OLDAP-2.7","OLDAP-2.8","OLFL-1.3","OML","OPL-1.0","OPL-UK-3.0","OPUBL-1.0","OSET-PL-2.1","OSL-1.0","OSL-1.1","OSL-2.0","OSL-2.1","OSL-3.0","OpenPBS-2.3","OpenSSL","OpenSSL-standalone","OpenVision","PADL","PDDL-1.0","PHP-3.0","PHP-3.01","PPL","PSF-2.0","Parity-6.0.0","Parity-7.0.0","Pixar","Plexus","PolyForm-Noncommercial-1.0.0","PolyForm-Small-Business-1.0.0","PostgreSQL","Python-2.0","Python-2.0.1","QPL-1.0","QPL-1.0-INRIA-2004","Qhull","RHeCos-1.1","RPL-1.1","RPL-1.5","RPSL-1.0","RSA-MD","RSCPL","Rdisc","Ruby","Ruby-pty","SAX-PD","SAX-PD-2.0","SCEA","SGI-B-1.0","SGI-B-1.1","SGI-B-2.0","SGI-OpenGL","SGP4","SHL-0.5","SHL-0.51","SISSL","SISSL-1.2","SL","SMAIL-GPL","SMLNJ","SMPPL","SNIA","SOFA","SPL-1.0","SSH-OpenSSH","SSH-short","SSLeay-standalone","SSPL-1.0","SUL-1.0","SWL","Saxpath","SchemeReport","Sendmail","Sendmail-8.23","Sendmail-Open-Source-1.1","SimPL-2.0","Sleepycat","Soundex","Spencer-86","Spencer-94","Spencer-99","SugarCRM-1.1.3","Sun-PPP","Sun-PPP-2000","SunPro","Symlinks","TAPR-OHL-1.0","TCL","TCP-wrappers","TGPPL-1.0","TMate","TORQUE-1.1","TOSL","TPDL","TPL-1.0","TTWL","TTYP0","TU-Berlin-1.0","TU-Berlin-2.0","TermReadKey","ThirdEye","TrustedQSL","UCAR","UCL-1.0","UMich-Merit","UPL-1.0","URT-RLE","Ubuntu-font-1.0","Unicode-3.0","Unicode-DFS-2015","Unicode-DFS-2016","Unicode-TOU","UnixCrypt","Unlicense","Unlicense-libtelnet","Unlicense-libwhirlpool","VOSTROM","VSL-1.0","Vim","W3C","W3C-19980720","W3C-20150513","WTFPL","Watcom-1.0","Widget-Workshop","Wsuipa","X11","X11-distribute-modifications-variant","X11-swapped","XFree86-1.1","XSkat","Xdebug-1.03","Xerox","Xfig","Xnet","YPL-1.0","YPL-1.1","ZPL-1.1","ZPL-2.0","ZPL-2.1","Zed","Zeeff","Zend-2.0","Zimbra-1.3","Zimbra-1.4","Zlib","any-OSI","any-OSI-perl-modules","bcrypt-Solar-Designer","blessing","bzip2-1.0.6","check-cvs","checkmk","copyleft-next-0.3.0","copyleft-next-0.3.1","curl","cve-tou","diffmark","dtoa","dvipdfm","eGenix","etalab-2.0","fwlw","gSOAP-1.3b","generic-xts","gnuplot","gtkbook","hdparm","iMatix","jove","libpng-1.6.35","libpng-2.0","libselinux-1.0","libtiff","libutil-David-Nugent","lsof","magaz","mailprio","man2html","metamail","mpi-permissive","mpich2","mplus","ngrep","pkgconf","pnmstitch","psfrag","psutils","python-ldap","radvd","snprintf","softSurfer","ssh-keyscan","swrule","threeparttable","ulem","w3m","wwl","xinetd","xkeyboard-config-Zinoviev","xlock","xpp","xzoom","zlib-acknowledgement"],Ke=["AGPL-1.0","AGPL-3.0","BSD-2-Clause-FreeBSD","BSD-2-Clause-NetBSD","GFDL-1.1","GFDL-1.2","GFDL-1.3","GPL-1.0","GPL-2.0","GPL-2.0-with-GCC-exception","GPL-2.0-with-autoconf-exception","GPL-2.0-with-bison-exception","GPL-2.0-with-classpath-exception","GPL-2.0-with-font-exception","GPL-3.0","GPL-3.0-with-GCC-exception","GPL-3.0-with-autoconf-exception","LGPL-2.0","LGPL-2.1","LGPL-3.0","Net-SNMP","Nunit","StandardML-NJ","bzip2-1.0.5","eCos-2.0","wxWindows"],Ze=["389-exception","Asterisk-exception","Autoconf-exception-2.0","Autoconf-exception-3.0","Autoconf-exception-generic","Autoconf-exception-generic-3.0","Autoconf-exception-macro","Bison-exception-1.24","Bison-exception-2.2","Bootloader-exception","Classpath-exception-2.0","CLISP-exception-2.0","cryptsetup-OpenSSL-exception","DigiRule-FOSS-exception","eCos-exception-2.0","Fawkes-Runtime-exception","FLTK-exception","fmt-exception","Font-exception-2.0","freertos-exception-2.0","GCC-exception-2.0","GCC-exception-2.0-note","GCC-exception-3.1","Gmsh-exception","GNAT-exception","GNOME-examples-exception","GNU-compiler-exception","gnu-javamail-exception","GPL-3.0-interface-exception","GPL-3.0-linking-exception","GPL-3.0-linking-source-exception","GPL-CC-1.0","GStreamer-exception-2005","GStreamer-exception-2008","i2p-gpl-java-exception","KiCad-libraries-exception","LGPL-3.0-linking-exception","libpri-OpenH323-exception","Libtool-exception","Linux-syscall-note","LLGPL","LLVM-exception","LZMA-exception","mif-exception","OCaml-LGPL-linking-exception","OCCT-exception-1.0","OpenJDK-assembly-exception-1.0","openvpn-openssl-exception","PS-or-PDF-font-exception-20170817","QPL-1.0-INRIA-2004-exception","Qt-GPL-exception-1.0","Qt-LGPL-exception-1.1","Qwt-exception-1.0","SANE-exception","SHL-2.0","SHL-2.1","stunnel-exception","SWI-exception","Swift-exception","Texinfo-exception","u-boot-exception-2.0","UBDL-exception","Universal-FOSS-exception-1.0","vsftpd-openssl-exception","WxWindows-exception-3.1","x11vnc-openssl-exception"];function Xe(){if(Be)return ke;Be=1;var e=[].concat(Ye).concat(Ke),t=Ze;return ke=function(r){var n=0;function i(){return n<r.length}function o(e){if(e instanceof RegExp){var t=r.slice(n).match(e);if(t)return n+=t[0].length,t[0]}else if(r.indexOf(e,n)===n)return n+=e.length,e}function s(){o(/[ ]*/)}function a(){return o(/[A-Za-z0-9-.]+/)}function c(){var e=a();if(!e)throw new Error("Expected idstring at offset "+n);return e}function l(){return function(){for(var e,t=["WITH","AND","OR","(",")",":","+"],i=0;i<t.length&&!(e=o(t[i]));i++);if("+"===e&&n>1&&" "===r[n-2])throw new Error("Space before `+`");return e&&{type:"OPERATOR",string:e}}()||function(){if(o("DocumentRef-"))return{type:"DOCUMENTREF",string:c()}}()||function(){if(o("LicenseRef-"))return{type:"LICENSEREF",string:c()}}()||(i=n,s=a(),-1!==e.indexOf(s)?{type:"LICENSE",string:s}:-1!==t.indexOf(s)?{type:"EXCEPTION",string:s}:void(n=i));var i,s}for(var u=[];i()&&(s(),i());){var f=l();if(!f)throw new Error("Unexpected `"+r[n]+"` at offset "+n);u.push(f)}return u}}function Je(){return Ge?Me:(Ge=1,Me=function(e){var t=0;function r(){return t<e.length}function n(){return r()?e[t]:null}function i(){if(!r())throw new Error;t++}function o(e){var t=n();if(t&&"OPERATOR"===t.type&&e===t.string)return i(),t.string}function s(){var e=n();if(e&&"LICENSE"===e.type){i();var t={license:e.string};o("+")&&(t.plus=!0);var r=function(){if(o("WITH")){var e=n();if(e&&"EXCEPTION"===e.type)return i(),e.string;throw new Error("Expected exception after `WITH`")}}();return r&&(t.exception=r),t}}function a(e,t){return function r(){var n=t();if(n){if(!o(e))return n;var i=r();if(!i)throw new Error("Expected expression");return{left:n,conjunction:e.toLowerCase(),right:i}}}}var c=a("AND",function(){return function(){if(o("(")){var e=l();if(!o(")"))throw new Error("Expected `)`");return e}}()||function(){var e=t,r="",s=n();if("DOCUMENTREF"===s.type&&(i(),r+="DocumentRef-"+s.string+":",!o(":")))throw new Error("Expected `:` after `DocumentRef-...`");if("LICENSEREF"===(s=n()).type)return i(),{license:r+="LicenseRef-"+s.string};t=e}()||s()}),l=a("OR",c),u=l();if(!u||r())throw new Error("Syntax error");return u})}function Qe(){if(ze)return je;ze=1;var e=Xe(),t=Je();return je=function(r){return t(e(r))}}function et(){if(qe)return Ve;qe=1;var e=Qe(),t=function(){if(We)return He;We=1;var e=Qe(),t=Ye;function r(t){try{return e(t),!0}catch(e){return!1}}function n(e,t){var r=t[0].length-e[0].length;return 0!==r?r:e[0].toUpperCase().localeCompare(t[0].toUpperCase())}var i=[["APGL","AGPL"],["Gpl","GPL"],["GLP","GPL"],["APL","Apache"],["ISD","ISC"],["GLP","GPL"],["IST","ISC"],["Claude","Clause"],[" or later","+"],[" International",""],["GNU","GPL"],["GUN","GPL"],["+",""],["GNU GPL","GPL"],["GNU LGPL","LGPL"],["GNU/GPL","GPL"],["GNU GLP","GPL"],["GNU LESSER GENERAL PUBLIC LICENSE","LGPL"],["GNU Lesser General Public License","LGPL"],["GNU LESSER GENERAL PUBLIC LICENSE","LGPL-2.1"],["GNU Lesser General Public License","LGPL-2.1"],["LESSER GENERAL PUBLIC LICENSE","LGPL"],["Lesser General Public License","LGPL"],["LESSER GENERAL PUBLIC LICENSE","LGPL-2.1"],["Lesser General Public License","LGPL-2.1"],["GNU General Public License","GPL"],["Gnu public license","GPL"],["GNU Public License","GPL"],["GNU GENERAL PUBLIC LICENSE","GPL"],["MTI","MIT"],["Mozilla Public License","MPL"],["Universal Permissive License","UPL"],["WTH","WTF"],["WTFGPL","WTFPL"],["-License",""]].sort(n),o=[function(e){return e.toUpperCase()},function(e){return e.trim()},function(e){return e.replace(/\./g,"")},function(e){return e.replace(/\s+/g,"")},function(e){return e.replace(/\s+/g,"-")},function(e){return e.replace("v","-")},function(e){return e.replace(/,?\s*(\d)/,"-$1")},function(e){return e.replace(/,?\s*(\d)/,"-$1.0")},function(e){return e.replace(/,?\s*(V\.|v\.|V|v|Version|version)\s*(\d)/,"-$2")},function(e){return e.replace(/,?\s*(V\.|v\.|V|v|Version|version)\s*(\d)/,"-$2.0")},function(e){return e[0].toUpperCase()+e.slice(1)},function(e){return e.replace("/","-")},function(e){return e.replace(/\s*V\s*(\d)/,"-$1").replace(/(\d)$/,"$1.0")},function(e){return-1!==e.indexOf("3.0")?e+"-or-later":e+"-only"},function(e){return e+"only"},function(e){return e.replace(/(\d)$/,"-$1.0")},function(e){return e.replace(/(-| )?(\d)$/,"-$2-Clause")},function(e){return e.replace(/(-| )clause(-| )(\d)/,"-$3-Clause")},function(e){return e.replace(/\b(Modified|New|Revised)(-| )?BSD((-| )License)?/i,"BSD-3-Clause")},function(e){return e.replace(/\bSimplified(-| )?BSD((-| )License)?/i,"BSD-2-Clause")},function(e){return e.replace(/\b(Free|Net)(-| )?BSD((-| )License)?/i,"BSD-2-Clause-$1BSD")},function(e){return e.replace(/\bClear(-| )?BSD((-| )License)?/i,"BSD-3-Clause-Clear")},function(e){return e.replace(/\b(Old|Original)(-| )?BSD((-| )License)?/i,"BSD-4-Clause")},function(e){return"CC-"+e},function(e){return"CC-"+e+"-4.0"},function(e){return e.replace("Attribution","BY").replace("NonCommercial","NC").replace("NoDerivatives","ND").replace(/ (\d)/,"-$1").replace(/ ?International/,"")},function(e){return"CC-"+e.replace("Attribution","BY").replace("NonCommercial","NC").replace("NoDerivatives","ND").replace(/ (\d)/,"-$1").replace(/ ?International/,"")+"-4.0"}],s=t.map(function(e){var t=/^(.*)-\d+\.\d+$/.exec(e);return t?[t[0],t[1]]:[e,null]}).reduce(function(e,t){var r=t[1];return e[r]=e[r]||[],e[r].push(t[0]),e},{}),a=Object.keys(s).map(function(e){return[e,s[e]]}).filter(function(e){return 1===e[1].length&&null!==e[0]&&"APL"!==e[0]}).map(function(e){return[e[0],e[1][0]]});s=void 0;var c=[["UNLI","Unlicense"],["WTF","WTFPL"],["2 CLAUSE","BSD-2-Clause"],["2-CLAUSE","BSD-2-Clause"],["3 CLAUSE","BSD-3-Clause"],["3-CLAUSE","BSD-3-Clause"],["AFFERO","AGPL-3.0-or-later"],["AGPL","AGPL-3.0-or-later"],["APACHE","Apache-2.0"],["ARTISTIC","Artistic-2.0"],["Affero","AGPL-3.0-or-later"],["BEER","Beerware"],["BOOST","BSL-1.0"],["BSD","BSD-2-Clause"],["CDDL","CDDL-1.1"],["ECLIPSE","EPL-1.0"],["FUCK","WTFPL"],["GNU","GPL-3.0-or-later"],["LGPL","LGPL-3.0-or-later"],["GPLV1","GPL-1.0-only"],["GPL-1","GPL-1.0-only"],["GPLV2","GPL-2.0-only"],["GPL-2","GPL-2.0-only"],["GPL","GPL-3.0-or-later"],["MIT +NO-FALSE-ATTRIBS","MITNFA"],["MIT","MIT"],["MPL","MPL-2.0"],["X11","X11"],["ZLIB","Zlib"]].concat(a).sort(n),l=function(e){for(var t=0;t<o.length;t++){var n=o[t](e).trim();if(n!==e&&r(n))return n}return null},u=function(e){for(var t=e.toUpperCase(),r=0;r<c.length;r++){var n=c[r];if(t.indexOf(n[0])>-1)return n[1]}return null},f=function(e,t){for(var r=0;r<i.length;r++){var n=i[r],o=n[0];if(e.indexOf(o)>-1){var s=t(e.replace(o,n[1]));if(null!==s)return s}}return null};return He=function(e,t){var n=void 0===(t=t||{}).upgrade||!!t.upgrade;function i(e){return n?function(e){return-1!==["GPL-1.0","LGPL-1.0","AGPL-1.0","GPL-2.0","LGPL-2.0","AGPL-2.0","LGPL-2.1"].indexOf(e)?e+"-only":-1!==["GPL-1.0+","GPL-2.0+","GPL-3.0+","LGPL-2.0+","LGPL-2.1+","LGPL-3.0+","AGPL-1.0+","AGPL-3.0+"].indexOf(e)?e.replace(/\+$/,"-or-later"):-1!==["GPL-3.0","LGPL-3.0","AGPL-3.0"].indexOf(e)?e+"-or-later":e}(e):e}if("string"!=typeof e||0===e.trim().length)throw Error("Invalid argument. Expected non-empty string.");if(r(e=e.trim()))return i(e);var o=e.replace(/\+$/,"").trim();if(r(o))return i(o);var s=l(e);return null!==s||null!==(s=f(e,function(e){return r(e)?e:l(e)}))||null!==(s=u(e))||null!==(s=f(e,u))?i(s):null}}(),r='license should be a valid SPDX license expression (without "LicenseRef"), "UNLICENSED", or "SEE LICENSE IN <filename>"',n=/^SEE LICEN[CS]E IN (.+)$/;function i(e,t){return t.slice(0,e.length)===e}function o(e){if(e.hasOwnProperty("license")){var t=e.license;return i("LicenseRef",t)||i("DocumentRef",t)}return o(e.left)||o(e.right)}return Ve=function(i){var s;try{s=e(i)}catch(e){var a;if("UNLICENSED"===i||"UNLICENCED"===i)return{validForOldPackages:!0,validForNewPackages:!0,unlicensed:!0};if(a=n.exec(i))return{validForOldPackages:!0,validForNewPackages:!0,inFile:a[1]};var c={validForOldPackages:!1,validForNewPackages:!1,warnings:[r]};if(0!==i.trim().length){var l=t(i);l&&c.warnings.push('license is similar to the valid expression "'+l+'"')}return c}return o(s)?{validForNewPackages:!1,validForOldPackages:!1,spdx:!0,warnings:[r]}:{validForNewPackages:!0,validForOldPackages:!0,spdx:!0}}}var tt,rt,nt,it,ot,st,at,ct,lt,ut,ft,pt={};function ht(){if(tt)return pt;tt=1,Object.defineProperty(pt,"__esModule",{value:!0}),pt.LRUCache=void 0;const e="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,t=new Set,r="object"==typeof process&&process?process:{},n=(e,t,n,i)=>{"function"==typeof r.emitWarning?r.emitWarning(e,t,n,i):console.error(`[${n}] ${t}: ${e}`)};let i=globalThis.AbortController,o=globalThis.AbortSignal;if(void 0===i){o=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(e,t){this._onabort.push(t)}},i=class{constructor(){t()}signal=new o;abort(e){if(!this.signal.aborted){this.signal.reason=e,this.signal.aborted=!0;for(const t of this.signal._onabort)t(e);this.signal.onabort?.(e)}}};let e="1"!==r.env?.LRU_CACHE_IGNORE_AC_WARNING;const t=()=>{e&&(e=!1,n("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",t))}}const s=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),a=e=>s(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?c:null:null;class c extends Array{constructor(e){super(e),this.fill(0)}}class l{heap;length;static#e=!1;static create(e){const t=a(e);if(!t)return[];l.#e=!0;const r=new l(e,t);return l.#e=!1,r}constructor(e,t){if(!l.#e)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}}class u{#t;#r;#n;#i;#o;#s;#a;#c;get perf(){return this.#c}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#l;#u;#f;#p;#h;#d;#m;#g;#v;#y;#E;#b;#w;#L;#S;#C;#I;#D;static unsafeExposeInternals(e){return{starts:e.#w,ttls:e.#L,sizes:e.#b,keyMap:e.#f,keyList:e.#p,valList:e.#h,next:e.#d,prev:e.#m,get head(){return e.#g},get tail(){return e.#v},free:e.#y,isBackgroundFetch:t=>e.#_(t),backgroundFetch:(t,r,n,i)=>e.#O(t,r,n,i),moveToTail:t=>e.#N(t),indexes:t=>e.#A(t),rindexes:t=>e.#P(t),isStale:t=>e.#T(t)}}get max(){return this.#t}get maxSize(){return this.#r}get calculatedSize(){return this.#u}get size(){return this.#l}get fetchMethod(){return this.#s}get memoMethod(){return this.#a}get dispose(){return this.#n}get onInsert(){return this.#i}get disposeAfter(){return this.#o}constructor(r){const{max:i=0,ttl:o,ttlResolution:c=1,ttlAutopurge:f,updateAgeOnGet:p,updateAgeOnHas:h,allowStale:d,dispose:m,onInsert:g,disposeAfter:v,noDisposeOnSet:y,noUpdateTTL:E,maxSize:b=0,maxEntrySize:w=0,sizeCalculation:L,fetchMethod:S,memoMethod:C,noDeleteOnFetchRejection:I,noDeleteOnStaleGet:D,allowStaleOnFetchRejection:_,allowStaleOnFetchAbort:O,ignoreFetchAbort:N,perf:A}=r;if(void 0!==A&&"function"!=typeof A?.now)throw new TypeError("perf option must have a now() method if specified");if(this.#c=A??e,0!==i&&!s(i))throw new TypeError("max option must be a nonnegative integer");const P=i?a(i):Array;if(!P)throw new Error("invalid max value: "+i);if(this.#t=i,this.#r=b,this.maxEntrySize=w||this.#r,this.sizeCalculation=L,this.sizeCalculation){if(!this.#r&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if("function"!=typeof this.sizeCalculation)throw new TypeError("sizeCalculation set to non-function")}if(void 0!==C&&"function"!=typeof C)throw new TypeError("memoMethod must be a function if defined");if(this.#a=C,void 0!==S&&"function"!=typeof S)throw new TypeError("fetchMethod must be a function if specified");if(this.#s=S,this.#C=!!S,this.#f=new Map,this.#p=new Array(i).fill(void 0),this.#h=new Array(i).fill(void 0),this.#d=new P(i),this.#m=new P(i),this.#g=0,this.#v=0,this.#y=l.create(i),this.#l=0,this.#u=0,"function"==typeof m&&(this.#n=m),"function"==typeof g&&(this.#i=g),"function"==typeof v?(this.#o=v,this.#E=[]):(this.#o=void 0,this.#E=void 0),this.#S=!!this.#n,this.#D=!!this.#i,this.#I=!!this.#o,this.noDisposeOnSet=!!y,this.noUpdateTTL=!!E,this.noDeleteOnFetchRejection=!!I,this.allowStaleOnFetchRejection=!!_,this.allowStaleOnFetchAbort=!!O,this.ignoreFetchAbort=!!N,0!==this.maxEntrySize){if(0!==this.#r&&!s(this.#r))throw new TypeError("maxSize must be a positive integer if specified");if(!s(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#R()}if(this.allowStale=!!d,this.noDeleteOnStaleGet=!!D,this.updateAgeOnGet=!!p,this.updateAgeOnHas=!!h,this.ttlResolution=s(c)||0===c?c:1,this.ttlAutopurge=!!f,this.ttl=o||0,this.ttl){if(!s(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#x()}if(0===this.#t&&0===this.ttl&&0===this.#r)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#t&&!this.#r){const e="LRU_CACHE_UNBOUNDED";if((e=>!t.has(e))(e)){t.add(e);n("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",e,u)}}}getRemainingTTL(e){return this.#f.has(e)?1/0:0}#x(){const e=new c(this.#t),t=new c(this.#t);this.#L=e,this.#w=t,this.#$=(r,n,i=this.#c.now())=>{if(t[r]=0!==n?i:0,e[r]=n,0!==n&&this.ttlAutopurge){const e=setTimeout(()=>{this.#T(r)&&this.#F(this.#p[r],"expire")},n+1);e.unref&&e.unref()}},this.#U=r=>{t[r]=0!==e[r]?this.#c.now():0},this.#k=(i,o)=>{if(e[o]){const s=e[o],a=t[o];if(!s||!a)return;i.ttl=s,i.start=a,i.now=r||n();const c=i.now-a;i.remainingTTL=s-c}};let r=0;const n=()=>{const e=this.#c.now();if(this.ttlResolution>0){r=e;const t=setTimeout(()=>r=0,this.ttlResolution);t.unref&&t.unref()}return e};this.getRemainingTTL=i=>{const o=this.#f.get(i);if(void 0===o)return 0;const s=e[o],a=t[o];if(!s||!a)return 1/0;return s-((r||n())-a)},this.#T=i=>{const o=t[i],s=e[i];return!!s&&!!o&&(r||n())-o>s}}#U=()=>{};#k=()=>{};#$=()=>{};#T=()=>!1;#R(){const e=new c(this.#t);this.#u=0,this.#b=e,this.#B=t=>{this.#u-=e[t],e[t]=0},this.#M=(e,t,r,n)=>{if(this.#_(t))return 0;if(!s(r)){if(!n)throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");if("function"!=typeof n)throw new TypeError("sizeCalculation must be a function");if(r=n(t,e),!s(r))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return r},this.#G=(t,r,n)=>{if(e[t]=r,this.#r){const r=this.#r-e[t];for(;this.#u>r;)this.#j(!0)}this.#u+=e[t],n&&(n.entrySize=r,n.totalCalculatedSize=this.#u)}}#B=e=>{};#G=(e,t,r)=>{};#M=(e,t,r,n)=>{if(r||n)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#A({allowStale:e=this.allowStale}={}){if(this.#l)for(let t=this.#v;this.#z(t)&&(!e&&this.#T(t)||(yield t),t!==this.#g);)t=this.#m[t]}*#P({allowStale:e=this.allowStale}={}){if(this.#l)for(let t=this.#g;this.#z(t)&&(!e&&this.#T(t)||(yield t),t!==this.#v);)t=this.#d[t]}#z(e){return void 0!==e&&this.#f.get(this.#p[e])===e}*entries(){for(const e of this.#A())void 0===this.#h[e]||void 0===this.#p[e]||this.#_(this.#h[e])||(yield[this.#p[e],this.#h[e]])}*rentries(){for(const e of this.#P())void 0===this.#h[e]||void 0===this.#p[e]||this.#_(this.#h[e])||(yield[this.#p[e],this.#h[e]])}*keys(){for(const e of this.#A()){const t=this.#p[e];void 0===t||this.#_(this.#h[e])||(yield t)}}*rkeys(){for(const e of this.#P()){const t=this.#p[e];void 0===t||this.#_(this.#h[e])||(yield t)}}*values(){for(const e of this.#A()){void 0===this.#h[e]||this.#_(this.#h[e])||(yield this.#h[e])}}*rvalues(){for(const e of this.#P()){void 0===this.#h[e]||this.#_(this.#h[e])||(yield this.#h[e])}}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,t={}){for(const r of this.#A()){const n=this.#h[r],i=this.#_(n)?n.__staleWhileFetching:n;if(void 0!==i&&e(i,this.#p[r],this))return this.get(this.#p[r],t)}}forEach(e,t=this){for(const r of this.#A()){const n=this.#h[r],i=this.#_(n)?n.__staleWhileFetching:n;void 0!==i&&e.call(t,i,this.#p[r],this)}}rforEach(e,t=this){for(const r of this.#P()){const n=this.#h[r],i=this.#_(n)?n.__staleWhileFetching:n;void 0!==i&&e.call(t,i,this.#p[r],this)}}purgeStale(){let e=!1;for(const t of this.#P({allowStale:!0}))this.#T(t)&&(this.#F(this.#p[t],"expire"),e=!0);return e}info(e){const t=this.#f.get(e);if(void 0===t)return;const r=this.#h[t],n=this.#_(r)?r.__staleWhileFetching:r;if(void 0===n)return;const i={value:n};if(this.#L&&this.#w){const e=this.#L[t],r=this.#w[t];if(e&&r){const t=e-(this.#c.now()-r);i.ttl=t,i.start=Date.now()}}return this.#b&&(i.size=this.#b[t]),i}dump(){const e=[];for(const t of this.#A({allowStale:!0})){const r=this.#p[t],n=this.#h[t],i=this.#_(n)?n.__staleWhileFetching:n;if(void 0===i||void 0===r)continue;const o={value:i};if(this.#L&&this.#w){o.ttl=this.#L[t];const e=this.#c.now()-this.#w[t];o.start=Math.floor(Date.now()-e)}this.#b&&(o.size=this.#b[t]),e.unshift([r,o])}return e}load(e){this.clear();for(const[t,r]of e){if(r.start){const e=Date.now()-r.start;r.start=this.#c.now()-e}this.set(t,r.value,r)}}set(e,t,r={}){if(void 0===t)return this.delete(e),this;const{ttl:n=this.ttl,start:i,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:s=this.sizeCalculation,status:a}=r;let{noUpdateTTL:c=this.noUpdateTTL}=r;const l=this.#M(e,t,r.size||0,s);if(this.maxEntrySize&&l>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.#F(e,"set"),this;let u=0===this.#l?void 0:this.#f.get(e);if(void 0===u)u=0===this.#l?this.#v:0!==this.#y.length?this.#y.pop():this.#l===this.#t?this.#j(!1):this.#l,this.#p[u]=e,this.#h[u]=t,this.#f.set(e,u),this.#d[this.#v]=u,this.#m[u]=this.#v,this.#v=u,this.#l++,this.#G(u,l,a),a&&(a.set="add"),c=!1,this.#D&&this.#i?.(t,e,"add");else{this.#N(u);const r=this.#h[u];if(t!==r){if(this.#C&&this.#_(r)){r.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:t}=r;void 0===t||o||(this.#S&&this.#n?.(t,e,"set"),this.#I&&this.#E?.push([t,e,"set"]))}else o||(this.#S&&this.#n?.(r,e,"set"),this.#I&&this.#E?.push([r,e,"set"]));if(this.#B(u),this.#G(u,l,a),this.#h[u]=t,a){a.set="replace";const e=r&&this.#_(r)?r.__staleWhileFetching:r;void 0!==e&&(a.oldValue=e)}}else a&&(a.set="update");this.#D&&this.onInsert?.(t,e,t===r?"update":"replace")}if(0===n||this.#L||this.#x(),this.#L&&(c||this.#$(u,n,i),a&&this.#k(a,u)),!o&&this.#I&&this.#E){const e=this.#E;let t;for(;t=e?.shift();)this.#o?.(...t)}return this}pop(){try{for(;this.#l;){const e=this.#h[this.#g];if(this.#j(!0),this.#_(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(void 0!==e)return e}}finally{if(this.#I&&this.#E){const e=this.#E;let t;for(;t=e?.shift();)this.#o?.(...t)}}}#j(e){const t=this.#g,r=this.#p[t],n=this.#h[t];return this.#C&&this.#_(n)?n.__abortController.abort(new Error("evicted")):(this.#S||this.#I)&&(this.#S&&this.#n?.(n,r,"evict"),this.#I&&this.#E?.push([n,r,"evict"])),this.#B(t),e&&(this.#p[t]=void 0,this.#h[t]=void 0,this.#y.push(t)),1===this.#l?(this.#g=this.#v=0,this.#y.length=0):this.#g=this.#d[t],this.#f.delete(r),this.#l--,t}has(e,t={}){const{updateAgeOnHas:r=this.updateAgeOnHas,status:n}=t,i=this.#f.get(e);if(void 0!==i){const e=this.#h[i];if(this.#_(e)&&void 0===e.__staleWhileFetching)return!1;if(!this.#T(i))return r&&this.#U(i),n&&(n.has="hit",this.#k(n,i)),!0;n&&(n.has="stale",this.#k(n,i))}else n&&(n.has="miss");return!1}peek(e,t={}){const{allowStale:r=this.allowStale}=t,n=this.#f.get(e);if(void 0===n||!r&&this.#T(n))return;const i=this.#h[n];return this.#_(i)?i.__staleWhileFetching:i}#O(e,t,r,n){const o=void 0===t?void 0:this.#h[t];if(this.#_(o))return o;const s=new i,{signal:a}=r;a?.addEventListener("abort",()=>s.abort(a.reason),{signal:s.signal});const c={signal:s.signal,options:r,context:n},l=(n,i=!1)=>{const{aborted:o}=s.signal,a=r.ignoreFetchAbort&&void 0!==n;if(r.status&&(o&&!i?(r.status.fetchAborted=!0,r.status.fetchError=s.signal.reason,a&&(r.status.fetchAbortIgnored=!0)):r.status.fetchResolved=!0),o&&!a&&!i)return u(s.signal.reason);const l=f;return this.#h[t]===f&&(void 0===n?void 0!==l.__staleWhileFetching?this.#h[t]=l.__staleWhileFetching:this.#F(e,"fetch"):(r.status&&(r.status.fetchUpdated=!0),this.set(e,n,c.options))),n},u=n=>{const{aborted:i}=s.signal,o=i&&r.allowStaleOnFetchAbort,a=o||r.allowStaleOnFetchRejection,c=a||r.noDeleteOnFetchRejection,l=f;if(this.#h[t]===f){!c||void 0===l.__staleWhileFetching?this.#F(e,"fetch"):o||(this.#h[t]=l.__staleWhileFetching)}if(a)return r.status&&void 0!==l.__staleWhileFetching&&(r.status.returnedStale=!0),l.__staleWhileFetching;if(l.__returned===l)throw n};r.status&&(r.status.fetchDispatched=!0);const f=new Promise((t,n)=>{const i=this.#s?.(e,o,c);i&&i instanceof Promise&&i.then(e=>t(void 0===e?void 0:e),n),s.signal.addEventListener("abort",()=>{r.ignoreFetchAbort&&!r.allowStaleOnFetchAbort||(t(void 0),r.allowStaleOnFetchAbort&&(t=e=>l(e,!0)))})}).then(l,e=>(r.status&&(r.status.fetchRejected=!0,r.status.fetchError=e),u(e))),p=Object.assign(f,{__abortController:s,__staleWhileFetching:o,__returned:void 0});return void 0===t?(this.set(e,p,{...c.options,status:void 0}),t=this.#f.get(e)):this.#h[t]=p,p}#_(e){if(!this.#C)return!1;const t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof i}async fetch(e,t={}){const{allowStale:r=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:s=this.noDisposeOnSet,size:a=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:l=this.noUpdateTTL,noDeleteOnFetchRejection:u=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:f=this.allowStaleOnFetchRejection,ignoreFetchAbort:p=this.ignoreFetchAbort,allowStaleOnFetchAbort:h=this.allowStaleOnFetchAbort,context:d,forceRefresh:m=!1,status:g,signal:v}=t;if(!this.#C)return g&&(g.fetch="get"),this.get(e,{allowStale:r,updateAgeOnGet:n,noDeleteOnStaleGet:i,status:g});const y={allowStale:r,updateAgeOnGet:n,noDeleteOnStaleGet:i,ttl:o,noDisposeOnSet:s,size:a,sizeCalculation:c,noUpdateTTL:l,noDeleteOnFetchRejection:u,allowStaleOnFetchRejection:f,allowStaleOnFetchAbort:h,ignoreFetchAbort:p,status:g,signal:v};let E=this.#f.get(e);if(void 0===E){g&&(g.fetch="miss");const t=this.#O(e,E,y,d);return t.__returned=t}{const t=this.#h[E];if(this.#_(t)){const e=r&&void 0!==t.__staleWhileFetching;return g&&(g.fetch="inflight",e&&(g.returnedStale=!0)),e?t.__staleWhileFetching:t.__returned=t}const i=this.#T(E);if(!m&&!i)return g&&(g.fetch="hit"),this.#N(E),n&&this.#U(E),g&&this.#k(g,E),t;const o=this.#O(e,E,y,d),s=void 0!==o.__staleWhileFetching&&r;return g&&(g.fetch=i?"stale":"refresh",s&&i&&(g.returnedStale=!0)),s?o.__staleWhileFetching:o.__returned=o}}async forceFetch(e,t={}){const r=await this.fetch(e,t);if(void 0===r)throw new Error("fetch() returned undefined");return r}memo(e,t={}){const r=this.#a;if(!r)throw new Error("no memoMethod provided to constructor");const{context:n,forceRefresh:i,...o}=t,s=this.get(e,o);if(!i&&void 0!==s)return s;const a=r(e,s,{options:o,context:n});return this.set(e,a,o),a}get(e,t={}){const{allowStale:r=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,status:o}=t,s=this.#f.get(e);if(void 0!==s){const t=this.#h[s],a=this.#_(t);return o&&this.#k(o,s),this.#T(s)?(o&&(o.get="stale"),a?(o&&r&&void 0!==t.__staleWhileFetching&&(o.returnedStale=!0),r?t.__staleWhileFetching:void 0):(i||this.#F(e,"expire"),o&&r&&(o.returnedStale=!0),r?t:void 0)):(o&&(o.get="hit"),a?t.__staleWhileFetching:(this.#N(s),n&&this.#U(s),t))}o&&(o.get="miss")}#H(e,t){this.#m[t]=e,this.#d[e]=t}#N(e){e!==this.#v&&(e===this.#g?this.#g=this.#d[e]:this.#H(this.#m[e],this.#d[e]),this.#H(this.#v,e),this.#v=e)}delete(e){return this.#F(e,"delete")}#F(e,t){let r=!1;if(0!==this.#l){const n=this.#f.get(e);if(void 0!==n)if(r=!0,1===this.#l)this.#W(t);else{this.#B(n);const r=this.#h[n];if(this.#_(r)?r.__abortController.abort(new Error("deleted")):(this.#S||this.#I)&&(this.#S&&this.#n?.(r,e,t),this.#I&&this.#E?.push([r,e,t])),this.#f.delete(e),this.#p[n]=void 0,this.#h[n]=void 0,n===this.#v)this.#v=this.#m[n];else if(n===this.#g)this.#g=this.#d[n];else{const e=this.#m[n];this.#d[e]=this.#d[n];const t=this.#d[n];this.#m[t]=this.#m[n]}this.#l--,this.#y.push(n)}}if(this.#I&&this.#E?.length){const e=this.#E;let t;for(;t=e?.shift();)this.#o?.(...t)}return r}clear(){return this.#W("delete")}#W(e){for(const t of this.#P({allowStale:!0})){const r=this.#h[t];if(this.#_(r))r.__abortController.abort(new Error("deleted"));else{const n=this.#p[t];this.#S&&this.#n?.(r,n,e),this.#I&&this.#E?.push([r,n,e])}}if(this.#f.clear(),this.#h.fill(void 0),this.#p.fill(void 0),this.#L&&this.#w&&(this.#L.fill(0),this.#w.fill(0)),this.#b&&this.#b.fill(0),this.#g=0,this.#v=0,this.#y.length=0,this.#u=0,this.#l=0,this.#I&&this.#E){const e=this.#E;let t;for(;t=e?.shift();)this.#o?.(...t)}}}return pt.LRUCache=u,pt}function dt(){if(ot)return it;ot=1;const e=p,t=(e,t,r)=>{const n=e.indexOf(r);return e.lastIndexOf(t,n>-1?n:1/0)},r=t=>{try{return new e.URL(t)}catch{}};return it=(e,n)=>{const i=n?((e,t)=>{const r=e.indexOf(":"),n=e.slice(0,r+1);if(Object.prototype.hasOwnProperty.call(t,n))return e;const i=e.indexOf("@");return i>-1?i>r?`git+ssh://${e}`:e:e.indexOf("//")===r+1?e:`${e.slice(0,r+1)}//${e.slice(r+1)}`})(e,n):e;return r(i)||r((e=>{const r=t(e,"@","#"),n=t(e,":","#");return n>r&&(e=e.slice(0,n)+"/"+e.slice(n+1)),-1===t(e,":","#")&&-1===e.indexOf("//")&&(e=`git+ssh://${e}`),e})(i))},it}function mt(){if(at)return st;at=1;const e=dt();return st=(t,r,{gitHosts:n,protocols:i})=>{if(!t)return;const o=(e=>{const t=e.indexOf("#"),r=e.indexOf("/"),n=e.indexOf("/",r+1),i=e.indexOf(":"),o=/\s/.exec(e),s=e.indexOf("@"),a=!o||t>-1&&o.index>t,c=-1===s||t>-1&&s>t,l=-1===i||t>-1&&i>t,u=-1===n||t>-1&&n>t,f=r>0,p=t>-1?"/"!==e[t-1]:!e.endsWith("/"),h=!e.startsWith(".");return a&&f&&p&&h&&c&&l&&u})(t)?`github:${t}`:t,s=e(o,i);if(!s)return;const a=n.byShortcut[s.protocol],c=n.byDomain[s.hostname.startsWith("www.")?s.hostname.slice(4):s.hostname],l=a||c;if(!l)return;const u=n[a||c];let f=null;i[s.protocol]?.auth&&(s.username||s.password)&&(f=`${s.username}${s.password?":"+s.password:""}`);let p=null,h=null,d=null,m=null;try{if(a){let e=s.pathname.startsWith("/")?s.pathname.slice(1):s.pathname;const t=e.indexOf("@");t>-1&&(e=e.slice(t+1));const r=e.lastIndexOf("/");r>-1?(h=decodeURIComponent(e.slice(0,r)),h||(h=null),d=decodeURIComponent(e.slice(r+1))):d=decodeURIComponent(e),d.endsWith(".git")&&(d=d.slice(0,-4)),s.hash&&(p=decodeURIComponent(s.hash.slice(1))),m="shortcut"}else{if(!u.protocols.includes(s.protocol))return;const e=u.extract(s);if(!e)return;h=e.user&&decodeURIComponent(e.user),d=decodeURIComponent(e.project),p=decodeURIComponent(e.committish),m=i[s.protocol]?.name||s.protocol.slice(0,-1)}}catch(e){if(e instanceof URIError)return;throw e}return[l,h,f,d,p,m,r]}}function gt(){if(lt)return ct;lt=1;const{LRUCache:e}=ht(),t=function(){if(nt)return rt;nt=1;const e=(...e)=>e.every(e=>e)?e.join(""):"",t=e=>e?encodeURIComponent(e):"",r=e=>e.toLowerCase().replace(/^\W+/g,"").replace(/(?<!\W)\W+$/,"").replace(/\//g,"").replace(/\W+/g,"-"),n={sshtemplate:({domain:t,user:r,project:n,committish:i})=>`git@${t}:${r}/${n}.git${e("#",i)}`,sshurltemplate:({domain:t,user:r,project:n,committish:i})=>`git+ssh://git@${t}/${r}/${n}.git${e("#",i)}`,edittemplate:({domain:r,user:n,project:i,committish:o,editpath:s,path:a})=>`https://${r}/${n}/${i}${e("/",s,"/",t(o||"HEAD"),"/",a)}`,browsetemplate:({domain:r,user:n,project:i,committish:o,treepath:s})=>`https://${r}/${n}/${i}${e("/",s,"/",t(o))}`,browsetreetemplate:({domain:r,user:n,project:i,committish:o,treepath:s,path:a,fragment:c,hashformat:l})=>`https://${r}/${n}/${i}/${s}/${t(o||"HEAD")}/${a}${e("#",l(c||""))}`,browseblobtemplate:({domain:r,user:n,project:i,committish:o,blobpath:s,path:a,fragment:c,hashformat:l})=>`https://${r}/${n}/${i}/${s}/${t(o||"HEAD")}/${a}${e("#",l(c||""))}`,docstemplate:({domain:r,user:n,project:i,treepath:o,committish:s})=>`https://${r}/${n}/${i}${e("/",o,"/",t(s))}#readme`,httpstemplate:({auth:t,domain:r,user:n,project:i,committish:o})=>`git+https://${e(t,"@")}${r}/${n}/${i}.git${e("#",o)}`,filetemplate:({domain:e,user:r,project:n,committish:i,path:o})=>`https://${e}/${r}/${n}/raw/${t(i||"HEAD")}/${o}`,shortcuttemplate:({type:t,user:r,project:n,committish:i})=>`${t}:${r}/${n}${e("#",i)}`,pathtemplate:({user:t,project:r,committish:n})=>`${t}/${r}${e("#",n)}`,bugstemplate:({domain:e,user:t,project:r})=>`https://${e}/${t}/${r}/issues`,hashformat:r},i={};i.github={protocols:["git:","http:","git+ssh:","git+https:","ssh:","https:"],domain:"github.com",treepath:"tree",blobpath:"blob",editpath:"edit",filetemplate:({auth:r,user:n,project:i,committish:o,path:s})=>`https://${e(r,"@")}raw.githubusercontent.com/${n}/${i}/${t(o||"HEAD")}/${s}`,gittemplate:({auth:t,domain:r,user:n,project:i,committish:o})=>`git://${e(t,"@")}${r}/${n}/${i}.git${e("#",o)}`,tarballtemplate:({domain:e,user:r,project:n,committish:i})=>`https://codeload.${e}/${r}/${n}/tar.gz/${t(i||"HEAD")}`,extract:e=>{let[,t,r,n,i]=e.pathname.split("/",5);if((!n||"tree"===n)&&(n||(i=e.hash.slice(1)),r&&r.endsWith(".git")&&(r=r.slice(0,-4)),t&&r))return{user:t,project:r,committish:i}}},i.bitbucket={protocols:["git+ssh:","git+https:","ssh:","https:"],domain:"bitbucket.org",treepath:"src",blobpath:"src",editpath:"?mode=edit",edittemplate:({domain:r,user:n,project:i,committish:o,treepath:s,path:a,editpath:c})=>`https://${r}/${n}/${i}${e("/",s,"/",t(o||"HEAD"),"/",a,c)}`,tarballtemplate:({domain:e,user:r,project:n,committish:i})=>`https://${e}/${r}/${n}/get/${t(i||"HEAD")}.tar.gz`,extract:e=>{let[,t,r,n]=e.pathname.split("/",4);if(!["get"].includes(n)&&(r&&r.endsWith(".git")&&(r=r.slice(0,-4)),t&&r))return{user:t,project:r,committish:e.hash.slice(1)}}},i.gitlab={protocols:["git+ssh:","git+https:","ssh:","https:"],domain:"gitlab.com",treepath:"tree",blobpath:"tree",editpath:"-/edit",httpstemplate:({auth:t,domain:r,user:n,project:i,committish:o})=>`git+https://${e(t,"@")}${r}/${n}/${i}.git${e("#",o)}`,tarballtemplate:({domain:e,user:r,project:n,committish:i})=>`https://${e}/${r}/${n}/repository/archive.tar.gz?ref=${t(i||"HEAD")}`,extract:e=>{const t=e.pathname.slice(1);if(t.includes("/-/")||t.includes("/archive.tar.gz"))return;const r=t.split("/");let n=r.pop();n.endsWith(".git")&&(n=n.slice(0,-4));const i=r.join("/");return i&&n?{user:i,project:n,committish:e.hash.slice(1)}:void 0}},i.gist={protocols:["git:","git+ssh:","git+https:","ssh:","https:"],domain:"gist.github.com",editpath:"edit",sshtemplate:({domain:t,project:r,committish:n})=>`git@${t}:${r}.git${e("#",n)}`,sshurltemplate:({domain:t,project:r,committish:n})=>`git+ssh://git@${t}/${r}.git${e("#",n)}`,edittemplate:({domain:r,user:n,project:i,committish:o,editpath:s})=>`https://${r}/${n}/${i}${e("/",t(o))}/${s}`,browsetemplate:({domain:r,project:n,committish:i})=>`https://${r}/${n}${e("/",t(i))}`,browsetreetemplate:({domain:r,project:n,committish:i,path:o,hashformat:s})=>`https://${r}/${n}${e("/",t(i))}${e("#",s(o))}`,browseblobtemplate:({domain:r,project:n,committish:i,path:o,hashformat:s})=>`https://${r}/${n}${e("/",t(i))}${e("#",s(o))}`,docstemplate:({domain:r,project:n,committish:i})=>`https://${r}/${n}${e("/",t(i))}`,httpstemplate:({domain:t,project:r,committish:n})=>`git+https://${t}/${r}.git${e("#",n)}`,filetemplate:({user:r,project:n,committish:i,path:o})=>`https://gist.githubusercontent.com/${r}/${n}/raw${e("/",t(i))}/${o}`,shortcuttemplate:({type:t,project:r,committish:n})=>`${t}:${r}${e("#",n)}`,pathtemplate:({project:t,committish:r})=>`${t}${e("#",r)}`,bugstemplate:({domain:e,project:t})=>`https://${e}/${t}`,gittemplate:({domain:t,project:r,committish:n})=>`git://${t}/${r}.git${e("#",n)}`,tarballtemplate:({project:e,committish:r})=>`https://codeload.github.com/gist/${e}/tar.gz/${t(r||"HEAD")}`,extract:e=>{let[,t,r,n]=e.pathname.split("/",4);if("raw"!==n){if(!r){if(!t)return;r=t,t=null}return r.endsWith(".git")&&(r=r.slice(0,-4)),{user:t,project:r,committish:e.hash.slice(1)}}},hashformat:function(e){return e&&"file-"+r(e)}},i.sourcehut={protocols:["git+ssh:","https:"],domain:"git.sr.ht",treepath:"tree",blobpath:"tree",filetemplate:({domain:e,user:r,project:n,committish:i,path:o})=>`https://${e}/${r}/${n}/blob/${t(i)||"HEAD"}/${o}`,httpstemplate:({domain:t,user:r,project:n,committish:i})=>`https://${t}/${r}/${n}.git${e("#",i)}`,tarballtemplate:({domain:e,user:r,project:n,committish:i})=>`https://${e}/${r}/${n}/archive/${t(i)||"HEAD"}.tar.gz`,bugstemplate:()=>null,extract:e=>{let[,t,r,n]=e.pathname.split("/",4);if(!["archive"].includes(n)&&(r&&r.endsWith(".git")&&(r=r.slice(0,-4)),t&&r))return{user:t,project:r,committish:e.hash.slice(1)}}};for(const[e,t]of Object.entries(i))i[e]=Object.assign({},n,t);return rt=i}(),r=mt(),n=dt(),i=new e({max:1e3});class o{constructor(e,t,r,n,i,s,a={}){Object.assign(this,o.#V[e],{type:e,user:t,auth:r,project:n,committish:i,default:s,opts:a})}static#V={byShortcut:{},byDomain:{}};static#q={"git+ssh:":{name:"sshurl"},"ssh:":{name:"sshurl"},"git+https:":{name:"https",auth:!0},"git:":{auth:!0},"http:":{auth:!0},"https:":{auth:!0},"git+http:":{auth:!0}};static addHost(e,t){o.#V[e]=t,o.#V.byDomain[t.domain]=e,o.#V.byShortcut[`${e}:`]=e,o.#q[`${e}:`]={name:e}}static fromUrl(e,t){if("string"!=typeof e)return;const n=e+JSON.stringify(t||{});if(!i.has(n)){const s=r(e,t,{gitHosts:o.#V,protocols:o.#q});i.set(n,s?new o(...s):void 0)}return i.get(n)}static fromManifest(e,t={}){if(!e||"object"!=typeof e)return;const r=e.repository,n=r&&("string"==typeof r?r:"object"==typeof r&&"string"==typeof r.url?r.url:null);if(!n)throw new Error("no repository");const i=n&&o.fromUrl(n.replace(/^git\+/,""),t)||null;if(i)return i;const s=function(e){try{const{protocol:t,hostname:r,pathname:n}=new URL(e);if(!r)return null;return`${/(?:git\+)http:$/.test(t)?"http:":"https:"}//${r}${n.replace(/\.git$/,"")}`}catch{return null}}(n);return o.fromUrl(s,t)||s}static parseUrl(e){return n(e)}#Y(e,t){if("function"!=typeof e)return null;const r={...this,...this.opts,...t};r.path||(r.path=""),r.path.startsWith("/")&&(r.path=r.path.slice(1)),r.noCommittish&&(r.committish=null);const n=e(r);return r.noGitPlus&&n.startsWith("git+")?n.slice(4):n}hash(){return this.committish?`#${this.committish}`:""}ssh(e){return this.#Y(this.sshtemplate,e)}sshurl(e){return this.#Y(this.sshurltemplate,e)}browse(e,...t){return"string"!=typeof e?this.#Y(this.browsetemplate,e):"string"!=typeof t[0]?this.#Y(this.browsetreetemplate,{...t[0],path:e}):this.#Y(this.browsetreetemplate,{...t[1],fragment:t[0],path:e})}browseFile(e,...t){return"string"!=typeof t[0]?this.#Y(this.browseblobtemplate,{...t[0],path:e}):this.#Y(this.browseblobtemplate,{...t[1],fragment:t[0],path:e})}docs(e){return this.#Y(this.docstemplate,e)}bugs(e){return this.#Y(this.bugstemplate,e)}https(e){return this.#Y(this.httpstemplate,e)}git(e){return this.#Y(this.gittemplate,e)}shortcut(e){return this.#Y(this.shortcuttemplate,e)}path(e){return this.#Y(this.pathtemplate,e)}tarball(e){return this.#Y(this.tarballtemplate,{...e,noCommittish:!1})}file(e,t){return this.#Y(this.filetemplate,{...t,path:e})}edit(e,t){return this.#Y(this.edittemplate,{...t,path:e})}getDefaultRepresentation(){return this.default}toString(e){return this.default&&"function"==typeof this[this.default]?this[this.default](e):this.sshurl(e)}}for(const[e,r]of Object.entries(t))o.addHost(e,r);return ct=o}var vt,yt,Et={topLevel:{dependancies:"dependencies",dependecies:"dependencies",depdenencies:"dependencies",devEependencies:"devDependencies",depends:"dependencies","dev-dependencies":"devDependencies",devDependences:"devDependencies",devDepenencies:"devDependencies",devdependencies:"devDependencies",repostitory:"repository",repo:"repository",prefereGlobal:"preferGlobal",hompage:"homepage",hampage:"homepage",autohr:"author",autor:"author",contributers:"contributors",publicationConfig:"publishConfig",script:"scripts"},bugs:{web:"url",name:"url"},script:{server:"start",tests:"test"}};function bt(){if(yt)return vt;yt=1;var{URL:e}=u,t=Fe(),r=Ue(),n=et(),i=gt(),{isBuiltin:o}=h,s=["dependencies","devDependencies","optionalDependencies"],a=ft?ut:(ft=1,ut=function(e){if(!e)return;if("ERROR: No README data found!"===e)return;e=e.trim().split("\n");let t=0;for(;e[t]&&e[t].trim().match(/^(#|$)/);)t++;const r=e.length;let n=t+1;for(;n<r&&e[n].trim();)n++;return e.slice(t,n).join(" ").trim()}),c=Et,l=e=>e.includes("@")&&e.indexOf("@")<e.lastIndexOf(".");function f(e,t){return e.author&&(e.author=t(e.author)),["maintainers","contributors"].forEach(function(r){Array.isArray(e[r])&&(e[r]=e[r].map(t))}),e}function p(e){if("string"==typeof e)return e;var t=e.name||"",r=e.url||e.web,n=r?" ("+r+")":"",i=e.email||e.mail;return t+(i?" <"+i+">":"")+n}function d(e){if("string"!=typeof e)return e;var t=e.match(/^([^(<]+)/),r=e.match(/\(([^()]+)\)/),n=e.match(/<([^<>]+)>/),i={};return t&&t[0].trim()&&(i.name=t[0].trim()),n&&(i.email=n[1]),r&&(i.url=r[1]),i}return vt={warn:function(){},fixRepositoryField:function(e){if(e.repositories&&(this.warn("repositories"),e.repository=e.repositories[0]),!e.repository)return this.warn("missingRepository");"string"==typeof e.repository&&(e.repository={type:"git",url:e.repository});var t=e.repository.url||"";if(t){var r=i.fromUrl(t);r&&(t=e.repository.url="shortcut"===r.getDefaultRepresentation()?r.https():r.toString())}t.match(/github.com\/[^/]+\/[^/]+\.git\.git$/)&&this.warn("brokenGitUrl",t)},fixTypos:function(e){Object.keys(c.topLevel).forEach(function(t){Object.prototype.hasOwnProperty.call(e,t)&&this.warn("typo",t,c.topLevel[t])},this)},fixScriptsField:function(e){if(e.scripts)return"object"!=typeof e.scripts?(this.warn("nonObjectScripts"),void delete e.scripts):void Object.keys(e.scripts).forEach(function(t){"string"!=typeof e.scripts[t]?(this.warn("nonStringScript"),delete e.scripts[t]):c.script[t]&&!e.scripts[c.script[t]]&&this.warn("typo",t,c.script[t],"scripts")},this)},fixFilesField:function(e){var t=e.files;t&&!Array.isArray(t)?(this.warn("nonArrayFiles"),delete e.files):e.files&&(e.files=e.files.filter(function(e){return!(!e||"string"!=typeof e)||(this.warn("invalidFilename",e),!1)},this))},fixBinField:function(e){if(e.bin&&"string"==typeof e.bin){var t,r={};(t=e.name.match(/^@[^/]+[/](.*)$/))?r[t[1]]=e.bin:r[e.name]=e.bin,e.bin=r}},fixManField:function(e){e.man&&"string"==typeof e.man&&(e.man=[e.man])},fixBundleDependenciesField:function(e){var t="bundledDependencies",r="bundleDependencies";e[t]&&!e[r]&&(e[r]=e[t],delete e[t]),e[r]&&!Array.isArray(e[r])?(this.warn("nonArrayBundleDependencies"),delete e[r]):e[r]&&(e[r]=e[r].filter(function(t){return t&&"string"==typeof t?(e.dependencies||(e.dependencies={}),Object.prototype.hasOwnProperty.call(e.dependencies,t)||(this.warn("nonDependencyBundleDependency",t),e.dependencies[t]="*"),!0):(this.warn("nonStringBundleDependency",t),!1)},this))},fixDependencies:function(e){!function(e,t){s.forEach(function(r){e[r]&&(e[r]=function(e,t,r){if(!e)return{};"string"==typeof e&&(e=e.trim().split(/[\n\r\s\t ,]+/));if(!Array.isArray(e))return e;r("deprecatedArrayDependencies",t);var n={};return e.filter(function(e){return"string"==typeof e}).forEach(function(e){var t=(e=e.trim().split(/(:?[@\s><=])/)).shift(),r=e.join("");r=(r=r.trim()).replace(/^@/,""),n[t]=r}),n}(e[r],r,t))})}(e,this.warn),function(e){var t=e.optionalDependencies;if(!t)return;var r=e.dependencies||{};Object.keys(t).forEach(function(e){r[e]=t[e]}),e.dependencies=r}(e,this.warn),this.fixBundleDependenciesField(e),["dependencies","devDependencies"].forEach(function(t){if(t in e)return e[t]&&"object"==typeof e[t]?void Object.keys(e[t]).forEach(function(r){var n=e[t][r];"string"!=typeof n&&(this.warn("nonStringDependency",r,JSON.stringify(n)),delete e[t][r]);var o=i.fromUrl(e[t][r]);o&&(e[t][r]=o.toString())},this):(this.warn("nonObjectDependencies",t),void delete e[t])},this)},fixModulesField:function(e){e.modules&&(this.warn("deprecatedModules"),delete e.modules)},fixKeywordsField:function(e){"string"==typeof e.keywords&&(e.keywords=e.keywords.split(/,\s+/)),e.keywords&&!Array.isArray(e.keywords)?(delete e.keywords,this.warn("nonArrayKeywords")):e.keywords&&(e.keywords=e.keywords.filter(function(e){return!("string"!=typeof e||!e)||(this.warn("nonStringKeyword"),!1)},this))},fixVersionField:function(e,n){var i=!n;if(!e.version)return e.version="",!0;if(!t(e.version,i))throw new Error('Invalid version: "'+e.version+'"');return e.version=r(e.version,i),!0},fixPeople:function(e){f(e,p),f(e,d)},fixNameField:function(e,t){"boolean"==typeof t?t={strict:t}:void 0===t&&(t={});var r=t.strict;if(e.name||r){if("string"!=typeof e.name)throw new Error("name field must be a string.");r||(e.name=e.name.trim()),function(e,t,r){if("."===e.charAt(0)||!function(e){if("@"!==e.charAt(0))return!1;var t=e.slice(1).split("/");if(2!==t.length)return!1;return t[0]&&t[1]&&t[0]===encodeURIComponent(t[0])&&t[1]===encodeURIComponent(t[1])}(e)&&(n=e,n.match(/[/@\s+%:]/)||n!==encodeURIComponent(n))||t&&!r&&e!==e.toLowerCase()||"node_modules"===e.toLowerCase()||"favicon.ico"===e.toLowerCase())throw new Error("Invalid name: "+JSON.stringify(e));var n}(e.name,r,t.allowLegacyCase),o(e.name)&&this.warn("conflictingName",e.name)}else e.name=""},fixDescriptionField:function(e){e.description&&"string"!=typeof e.description&&(this.warn("nonStringDescription"),delete e.description),e.readme&&!e.description&&(e.description=a(e.readme)),void 0===e.description&&delete e.description,e.description||this.warn("missingDescription")},fixReadmeField:function(e){e.readme||(this.warn("missingReadme"),e.readme="ERROR: No README data found!")},fixBugsField:function(t){if(!t.bugs&&t.repository&&t.repository.url){var r=i.fromUrl(t.repository.url);r&&r.bugs()&&(t.bugs={url:r.bugs()})}else if(t.bugs){if("string"==typeof t.bugs)l(t.bugs)?t.bugs={email:t.bugs}:e.canParse(t.bugs)?t.bugs={url:t.bugs}:this.warn("nonEmailUrlBugsString");else{!function(e,t){if(!e)return;Object.keys(e).forEach(function(r){c.bugs[r]&&(t("typo",r,c.bugs[r],"bugs"),e[c.bugs[r]]=e[r],delete e[r])})}(t.bugs,this.warn);var n=t.bugs;t.bugs={},n.url&&(e.canParse(n.url)?t.bugs.url=n.url:this.warn("nonUrlBugsUrlField")),n.email&&("string"==typeof n.email&&l(n.email)?t.bugs.email=n.email:this.warn("nonEmailBugsEmailField"))}t.bugs.email||t.bugs.url||(delete t.bugs,this.warn("emptyNormalizedBugs"))}},fixHomepageField:function(t){if(!t.homepage&&t.repository&&t.repository.url){var r=i.fromUrl(t.repository.url);r&&r.docs()&&(t.homepage=r.docs())}if(t.homepage)return"string"!=typeof t.homepage?(this.warn("nonUrlHomepage"),delete t.homepage):void(e.canParse(t.homepage)||(t.homepage="http://"+t.homepage))},fixLicenseField:function(e){const t=e.license||e.licence;return t?"string"!=typeof t||t.length<1||""===t.trim()?this.warn("invalidLicense"):n(t).validForNewPackages?void 0:this.warn("invalidLicense"):this.warn("missingLicense")}},vt}var wt,Lt,St,Ct,It={repositories:"'repositories' (plural) Not supported. Please pick one as the 'repository' field",missingRepository:"No repository field.",brokenGitUrl:"Probably broken git url: %s",nonObjectScripts:"scripts must be an object",nonStringScript:"script values must be string commands",nonArrayFiles:"Invalid 'files' member",invalidFilename:"Invalid filename in 'files' list: %s",nonArrayBundleDependencies:"Invalid 'bundleDependencies' list. Must be array of package names",nonStringBundleDependency:"Invalid bundleDependencies member: %s",nonDependencyBundleDependency:"Non-dependency in bundleDependencies: %s",nonObjectDependencies:"%s field must be an object",nonStringDependency:"Invalid dependency: %s %s",deprecatedArrayDependencies:"specifying %s as array is deprecated",deprecatedModules:"modules field is deprecated",nonArrayKeywords:"keywords should be an array of strings",nonStringKeyword:"keywords should be an array of strings",conflictingName:"%s is also the name of a node core module.",nonStringDescription:"'description' field should be a string",missingDescription:"No description",missingReadme:"No README data",missingLicense:"No license field.",nonEmailUrlBugsString:"Bug string field must be url, email, or {email,url}",nonUrlBugsUrlField:"bugs.url field must be a string url. Deleted.",nonEmailBugsEmailField:"bugs.email field must be a string email. Deleted.",emptyNormalizedBugs:"Normalized value of bugs field is an empty object. Deleted.",nonUrlHomepage:"homepage field must be a string url. Deleted.",invalidLicense:"license should be a valid SPDX license expression",typo:"%s should probably be %s."};function Dt(){if(Lt)return wt;Lt=1;var e=d,t=It;function r(r,n,i){return i&&(r=i+"['"+r+"']",n=i+"['"+n+"']"),e.format(t.typo,r,n)}return wt=function(){var n=Array.prototype.slice.call(arguments,0),i=n.shift();if("typo"===i)return r.apply(null,n);var o=t[i]?t[i]:i+": '%s'";return n.unshift(o),e.format.apply(null,n)},wt}var _t=function(){if(Ct)return St;Ct=1,St=n;var e=bt();n.fixer=e;var t=Dt(),r=["name","version","description","repository","modules","scripts","files","bin","man","bugs","keywords","readme","homepage","license"].map(function(e){return i(e)+"Field"});function n(n,o,s){!0===o&&(o=null,s=!0),s||(s=!1),o&&!n.private||(o=function(){}),n.scripts&&"node-gyp rebuild"===n.scripts.install&&!n.scripts.preinstall&&(n.gypfile=!0),e.warn=function(){o(t.apply(null,arguments))},r.forEach(function(t){e["fix"+i(t)](n,s)}),n._id=n.name+"@"+n.version}function i(e){return e.charAt(0).toUpperCase()+e.slice(1)}return r=r.concat(["dependencies","people","typos"]),St}(),Ot=ue(_t);const Nt=(e,t)=>{try{return m(e,g.F_OK),!0}catch(e){return!1}},At=["index.ts","index.tsx","main.ts","main.tsx"],Pt=(e,t,r)=>{const n=o(e??process.cwd(),"src"),i=At,s=i.map(e=>o(n,e)).find(e=>Nt(e));if(!s)throw new Error(`Unable to resolve entry point, ensure ${i.join(", ")} exists in ${n}`);return s},Tt=(e,t)=>D(e,t,{arrayMerge:(e,t)=>{const r=t[0]??e[0];return"object"==typeof r&&"match"in r&&"middleware"in r?((e,t,r)=>{const n=r.reduce((t,r)=>Object.assign(t,{[String(r[e])]:r}),{}),i={...t.reduce((t,r)=>Object.assign(t,{[String(r[e])]:r}),{}),...n};return Object.values(i)})("match",e,t):[...new Set([...e,...t])]}}),Rt=async(r,o)=>{const{packageJson:c,root:l}=o,{config:u}=await e(r)??{},f=c.main??c.module??"./dist/bundle.js",p=Pt(l);if("build"===r.command){if(i(f)===l)throw new Error("outDir cannot be root, please specify package.main or package.module in package.json");if("src"===i(f))throw new Error("outDir cannot be src, please specify package.main or package.module in package.json");if(i(f)===process.cwd())throw new Error("outDir cannot be the current working directory, please specify package.main or package.module in package.json")}return t({root:l,plugins:[n()],define:{"process.env.NODE_ENV":JSON.stringify(r.mode),"process.env.NODE_DEBUG":"production"!==r.mode,"process.env.FUSION_LOG_LEVEL":"production"===r.mode?1:3},build:{outDir:i(f),lib:{entry:p,fileName:s(f,a(f)),formats:["es"]},emptyOutDir:!0}},u??{})};function xt(e,t){_("object"==typeof e,t)}const $t=e=>{if(e.repository)return"string"==typeof e.repository?e.repository:e.repository.url},Ft=()=>{try{return O("git remote get-url origin").toString().trim().replace("git@github.com:","https://github.com/").replace(/\.git$/,"")}catch(e){return}},Ut=(e="HEAD")=>{try{return O(`git rev-parse ${e}`).toString().trim()}catch(e){return}},kt=()=>{if(process.env.GITHUB_ACTIONS){const e=(()=>{const e=process.env.GITHUB_EVENT_NAME||"unknown",t=process.env.GITHUB_ACTOR||"unknown",r=process.env.GITHUB_RUN_ID||"unknown",n=process.env.GITHUB_REPOSITORY||"unknown",i=process.env.GITHUB_WORKFLOW||"unknown",o=process.env.GITHUB_SERVER_URL||"https://github.com";let s="unknown";"unknown"!==n&&"unknown"!==r&&(s=`${o.replace(/\/$/,"")}/${n}/actions/runs/${r}`);const a={eventName:e,actor:t,runId:r,runUrl:s,workflow:i};if(process.env.GITHUB_EVENT_PATH)try{const e=v(process.env.GITHUB_EVENT_PATH,"utf8");Object.assign(a,JSON.parse(e))}catch{console.error("Failed to parse GitHub event payload")}return a})(),t={source:"github",reason:e.eventName,workflow:e.workflow,runId:e.runId,runUrl:e.runUrl,commitId:e.head_commit?.id,repository:e.repository?.name,repository_homepage:e.repository?.homepage,repository_license:e.repository?.license?.name,repository_owner:e.repository?.owner?.login,repository_owner_avatar_url:e.repository?.owner?.avatar_url,actor:e.actor,sender_login:e.sender?.login,sender_avatar_url:e.sender?.avatar_url};return e.pull_request?{...t,branch:e.pull_request.head?.ref,commitId:e.pull_request.head?.sha,htmlUrl:e.pull_request.html_url}:e.release?{...t,tag:e.release.tag_name,htmlUrl:e.release.html_url}:t}if(process.env.SYSTEM_TEAMPROJECT){const e=(()=>{const e=process.env.BUILD_BUILDID||"unknown",t=process.env.BUILD_DEFINITIONNAME||"unknown",r=process.env.BUILD_REPOSITORY_NAME||"unknown",n=process.env.SYSTEM_TEAMPROJECT||"unknown",i=process.env.SYSTEM_COLLECTIONURI||"unknown",o=process.env.BUILD_REQUESTEDFOR||"unknown",s=process.env.BUILD_SOURCEBRANCH||"unknown",a=process.env.BUILD_SOURCEVERSION||"unknown",c=process.env.BUILD_REASON||"unknown";let l="unknown";return"unknown"!==i&&"unknown"!==n&&"unknown"!==e&&(l=`${i.replace(/\/$/,"")}${n}/_build/results?buildId=${e}`),{runId:e,pipelineName:t,repository:r,project:n,orgUrl:i,actor:o,branch:s,commitId:a,runUrl:l,reason:c}})();return{source:"azure_devops",reason:e.reason,repository:e.repository,runId:e.runId,runUrl:e.runUrl,actor:e.actor,branch:e.branch,commitId:e.commitId,workflow:e.pipelineName}}},Bt=["png","jpg","jpeg","gif","svg","ico","webp","mp4","webm","mp3","woff2","woff","eot","ttf","otf","pdf","md","txt"],Mt=(e,t)=>{xt(t,"expected packageJson"),_(t.name,"expected [name] in packageJson"),_(t.version,"expected [version] in packageJson");const r=((e,t)=>"build"===e.command||e.isPreview?t.main||t.module||"dist/app-bundle.js":Pt(e.root))(e,t),n=t.name.replace(/^@|\w.*\//gm,""),i=t.version,o="build"===e.command?void 0:`/bundles/apps/${n}@${i}`,s=$t(t)??Ft();return{appKey:n,displayName:t.name,description:t.description||"",keywords:t.keywords,type:"standalone",build:{entryPoint:r,assetPath:o,githubRepo:s,version:i,timestamp:(new Date).toISOString(),commitSha:Ut(),annotations:kt(),projectPage:t.homepage,allowedExtensions:Bt.map(e=>`.${e}`)}}},Gt=(e,t)=>D(e,t),jt=A.object({environment:A.record(A.string(),A.any()).describe("Key-value map of environment-specific variables for the application. Defaults to an empty object if not provided.").optional().default({}),endpoints:A.record(A.string(),A.object({url:A.string({message:"The endpoint URL. This field is required."}),scopes:A.array(A.string()).optional().default([]).describe("List of scopes required for accessing this endpoint. Defaults to an empty array.")})).describe("A mapping of endpoint names to their configuration objects. Each endpoint must specify a URL and may specify scopes.").optional()}).describe("The API application configuration schema, defining environment variables and endpoints for the application."),zt=["B","kB","MB","GB","TB","PB","EB","ZB","YB"],Ht=["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],Wt=["b","kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],Vt=["b","kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],qt=(e,t,r)=>{let n=e;return"string"==typeof t||Array.isArray(t)?n=e.toLocaleString(t,r):!0!==t&&void 0===r||(n=e.toLocaleString(void 0,r)),n},Yt=e=>{if("number"==typeof e)return Math.log10(e);const t=e.toString(10);return t.length+Math.log10("0."+t.slice(0,15))};function Kt(e,t){if("bigint"!=typeof e&&!Number.isFinite(e))throw new TypeError(`Expected a finite number, got ${typeof e}: ${e}`);const r=(t={bits:!1,binary:!1,space:!0,...t}).bits?t.binary?Vt:Wt:t.binary?Ht:zt,n=t.space?" ":"";if(t.signed&&("number"==typeof e?0===e:0n===e))return` 0${n}${r[0]}`;const i=e<0,o=i?"-":t.signed?"+":"";let s;if(i&&(e=-e),void 0!==t.minimumFractionDigits&&(s={minimumFractionDigits:t.minimumFractionDigits}),void 0!==t.maximumFractionDigits&&(s={maximumFractionDigits:t.maximumFractionDigits,...s}),e<1){return o+qt(e,t.locale,s)+n+r[0]}const a=Math.min(Math.floor(t.binary?("number"==typeof(c=e)?Math.log(c):Yt(c)*Math.log(10))/Math.log(1024):Yt(e)/3),r.length-1);var c;if(e=((e,t)=>{if("number"==typeof e)return e/t;const r=e/BigInt(t),n=e%BigInt(t);return Number(r)+Number(n)/t})(e,(t.binary?1024:1e3)**a),!s){const t=Math.max(3,Number.parseInt(e,10).toString().length);e=e.toPrecision(t)}return o+qt(Number(e),t.locale,s)+n+r[a]}const Zt=(e,t)=>le.blueBright(t?.relative?`./${c(t?.cwd??process.cwd(),e)}`:e),Xt=e=>"string"==typeof e?Xt(y(e).size):le.yellowBright(Kt(e)),Jt=async(e,t,r)=>{const n=Mt(e,t.packageJson);try{r?.log?.start("loading application package...");const{manifest:t,path:i}=await(async(e,t)=>{const r=t?.file??[`app.manifest.${e.environment}`,"app.manifest","app.manifest.config"],n=await C(r,{baseDir:e.root,extensions:t?.extensions,script:{resolve:async r=>{const n=t?.base??{};if("function"==typeof r.default){const t=await r.default(e,{base:n});return Gt(n,t??{})}return Gt(n,r.default??{})}}});return{manifest:n.config,path:n.path,extension:n.extension}})(e,{base:n,file:r?.manifestPath});if(!t.build)throw new Error(`Application manifest for ${t.appKey} does not contain build information, please check the manifest file.`);return"serve"===e.command&&(t.build.assetPath=`/bundles/apps/${t.appKey}/${t.build.version}`),r?.log?.succeed("generated manifest from",Zt(i,{relative:!0})),t}catch(e){if(e instanceof I){if(r?.manifestPath){const t=new Error(`Failed to load manifest file ${Zt(r.manifestPath)}, please check the path.`,{cause:e});throw r?.log?.fail(t.message),t}return r?.log?.succeed(le.dim("no local manifest config applied, using default generated from package")),n}throw r?.log?.fail(`failed to resolve application manifest ${r?.manifestPath?Zt(r?.manifestPath):""}`),e}};async function Qt(e){e?.start("resolve project package");try{const t=await(async e=>{const t=await l({...e,normalize:!1});if(!t)throw new Error("failed to find package.json");const r={...t.packageJson};return Ot(r),{packageJson:{...r,version:t.packageJson.version},path:t.path,root:i(t.path)}})();return e?.succeed("📦",le.yellowBright([t.packageJson.name,t.packageJson.version].join("@"))),e?.info("🏠",le.blueBright(t.root)),t}catch(t){throw e?.fail("☠️","failed to resolve project package"),t}}const er=async e=>{const{log:t}=e??{},r=await Qt(t);t?.debug("package",r);const n={command:"build",mode:process.env.NODE_ENV??"production",root:r.root,...e?.env};t?.debug("env:",n);const i=await Jt(n,r,{log:t,manifestPath:e?.manifest});return t?.debug("manifest:",i),{manifest:i,pkg:r,env:n}},tr=async e=>{const{log:t}=e??{};t?.log(le.bold("Starting to build application"));const{manifest:n,pkg:i,env:o}=await er({log:t,manifest:e?.manifest});t?.start("loading vite config...");const s=await Rt(o,i);t?.succeed("vite config applied"),t?.debug("vite config:",s),t?.start("🤞🏻","building application..."),t?.startNativeConsoleCapture(),await r(s),t?.stopNativeConsoleCapture(),t?.succeed("build completed 😘");return{pkg:i,manifest:n,outDir:s.build.outDir}};var rr,nr,ir={exports:{}};function or(){return nr?rr:(nr=1,rr={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,END64HDR:20,END64SIG:117853008,END64START:4,END64OFF:8,END64NUMDISKS:16,ZIP64SIG:101075792,ZIP64HDR:56,ZIP64LEAD:12,ZIP64SIZE:4,ZIP64VEM:12,ZIP64VER:14,ZIP64DSK:16,ZIP64DSKDIR:20,ZIP64SUB:24,ZIP64TOT:32,ZIP64SIZB:40,ZIP64OFF:48,ZIP64EXTRA:56,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,AES_ENCRYPT:99,FLG_ENC:1,FLG_COMP1:2,FLG_COMP2:4,FLG_DESC:8,FLG_ENH:16,FLG_PATCH:32,FLG_STR:64,FLG_EFS:2048,FLG_MSK:4096,FILE:2,BUFFER:1,NONE:0,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535,EF_ZIP64_SUNCOMP:0,EF_ZIP64_SCOMP:8,EF_ZIP64_RHO:16,EF_ZIP64_DSN:24})}var sr,ar,cr,lr,ur,fr,pr,hr,dr={};function mr(){return sr||(sr=1,function(e){const t={INVALID_LOC:"Invalid LOC header (bad signature)",INVALID_CEN:"Invalid CEN header (bad signature)",INVALID_END:"Invalid END header (bad signature)",DESCRIPTOR_NOT_EXIST:"No descriptor present",DESCRIPTOR_UNKNOWN:"Unknown descriptor format",DESCRIPTOR_FAULTY:"Descriptor data is malformed",NO_DATA:"Nothing to decompress",BAD_CRC:"CRC32 checksum failed {0}",FILE_IN_THE_WAY:"There is a file in the way: {0}",UNKNOWN_METHOD:"Invalid/unsupported compression method",AVAIL_DATA:"inflate::Available inflate data did not terminate",INVALID_DISTANCE:"inflate::Invalid literal/length or distance code in fixed or dynamic block",TO_MANY_CODES:"inflate::Dynamic block code description: too many length or distance codes",INVALID_REPEAT_LEN:"inflate::Dynamic block code description: repeat more than specified lengths",INVALID_REPEAT_FIRST:"inflate::Dynamic block code description: repeat lengths with no first length",INCOMPLETE_CODES:"inflate::Dynamic block code description: code lengths codes incomplete",INVALID_DYN_DISTANCE:"inflate::Dynamic block code description: invalid distance code lengths",INVALID_CODES_LEN:"inflate::Dynamic block code description: invalid literal/length code lengths",INVALID_STORE_BLOCK:"inflate::Stored block length did not match one's complement",INVALID_BLOCK_TYPE:"inflate::Invalid block type (type == 3)",CANT_EXTRACT_FILE:"Could not extract the file",CANT_OVERRIDE:"Target file already exists",DISK_ENTRY_TOO_LARGE:"Number of disk entries is too large",NO_ZIP:"No zip file was loaded",NO_ENTRY:"Entry doesn't exist",DIRECTORY_CONTENT_ERROR:"A directory cannot have content",FILE_NOT_FOUND:'File not found: "{0}"',NOT_IMPLEMENTED:"Not implemented",INVALID_FILENAME:"Invalid filename",INVALID_FORMAT:"Invalid or unsupported zip format. No END header found",INVALID_PASS_PARAM:"Incompatible password parameter",WRONG_PASSWORD:"Wrong Password",COMMENT_TOO_LONG:"Comment is too long",EXTRA_FIELD_PARSE_ERROR:"Extra field parsing error"};function r(e){return function(...t){return t.length&&(e=e.replace(/\{(\d)\}/g,(e,r)=>t[r]||"")),new Error("ADM-ZIP: "+e)}}for(const n of Object.keys(t))e[n]=r(t[n])}(dr)),dr}function gr(){return hr||(hr=1,ir.exports=function(){if(cr)return ar;cr=1;const e=P,t=T,r=or(),n=mr(),i="object"==typeof process&&"win32"===process.platform,o=e=>"object"==typeof e&&null!==e,s=new Uint32Array(256).map((e,t)=>{for(let e=0;e<8;e++)1&t?t=3988292384^t>>>1:t>>>=1;return t>>>0});function a(r){this.sep=t.sep,this.fs=e,o(r)&&o(r.fs)&&"function"==typeof r.fs.statSync&&(this.fs=r.fs)}return ar=a,a.prototype.makeDir=function(e){const t=this;!function(e){let r=e.split(t.sep)[0];e.split(t.sep).forEach(function(e){if(e&&":"!==e.substr(-1,1)){var i;r+=t.sep+e;try{i=t.fs.statSync(r)}catch(e){t.fs.mkdirSync(r)}if(i&&i.isFile())throw n.FILE_IN_THE_WAY(`"${r}"`)}})}(e)},a.prototype.writeFileTo=function(e,r,n,i){const o=this;if(o.fs.existsSync(e)){if(!n)return!1;if(o.fs.statSync(e).isDirectory())return!1}var s,a=t.dirname(e);o.fs.existsSync(a)||o.makeDir(a);try{s=o.fs.openSync(e,"w",438)}catch(t){o.fs.chmodSync(e,438),s=o.fs.openSync(e,"w",438)}if(s)try{o.fs.writeSync(s,r,0,r.length,0)}finally{o.fs.closeSync(s)}return o.fs.chmodSync(e,i||438),!0},a.prototype.writeFileToAsync=function(e,r,n,i,o){"function"==typeof i&&(o=i,i=void 0);const s=this;s.fs.exists(e,function(a){if(a&&!n)return o(!1);s.fs.stat(e,function(n,c){if(a&&c.isDirectory())return o(!1);var l=t.dirname(e);s.fs.exists(l,function(t){t||s.makeDir(l),s.fs.open(e,"w",438,function(t,n){t?s.fs.chmod(e,438,function(){s.fs.open(e,"w",438,function(t,n){s.fs.write(n,r,0,r.length,0,function(){s.fs.close(n,function(){s.fs.chmod(e,i||438,function(){o(!0)})})})})}):n?s.fs.write(n,r,0,r.length,0,function(){s.fs.close(n,function(){s.fs.chmod(e,i||438,function(){o(!0)})})}):s.fs.chmod(e,i||438,function(){o(!0)})})})})})},a.prototype.findFiles=function(e){const r=this;return function e(n,i,o){let s=[];return r.fs.readdirSync(n).forEach(function(a){const c=t.join(n,a),l=r.fs.statSync(c);s.push(t.normalize(c)+(l.isDirectory()?r.sep:"")),l.isDirectory()&&o&&(s=s.concat(e(c,i,o)))}),s}(e,void 0,!0)},a.prototype.findFilesAsync=function(e,r){const n=this;let i=[];n.fs.readdir(e,function(o,s){if(o)return r(o);let a=s.length;if(!a)return r(null,i);s.forEach(function(o){o=t.join(e,o),n.fs.stat(o,function(e,s){if(e)return r(e);s&&(i.push(t.normalize(o)+(s.isDirectory()?n.sep:"")),s.isDirectory()?n.findFilesAsync(o,function(e,t){if(e)return r(e);i=i.concat(t),--a||r(null,i)}):--a||r(null,i))})})})},a.prototype.getAttributes=function(){},a.prototype.setAttributes=function(){},a.crc32update=function(e,t){return s[255&(e^t)]^e>>>8},a.crc32=function(e){"string"==typeof e&&(e=Buffer.from(e,"utf8"));let t=e.length,r=-1;for(let n=0;n<t;)r=a.crc32update(r,e[n++]);return~r>>>0},a.methodToString=function(e){switch(e){case r.STORED:return"STORED ("+e+")";case r.DEFLATED:return"DEFLATED ("+e+")";default:return"UNSUPPORTED ("+e+")"}},a.canonical=function(e){if(!e)return"";const r=t.posix.normalize("/"+e.split("\\").join("/"));return t.join(".",r)},a.zipnamefix=function(e){if(!e)return"";const r=t.posix.normalize("/"+e.split("\\").join("/"));return t.posix.join(".",r)},a.findLast=function(e,t){if(!Array.isArray(e))throw new TypeError("arr is not array");for(let r=(e.length>>>0)-1;r>=0;r--)if(t(e[r],r,e))return e[r]},a.sanitize=function(e,r){e=t.resolve(t.normalize(e));for(var n=r.split("/"),i=0,o=n.length;i<o;i++){var s=t.normalize(t.join(e,n.slice(i,o).join(t.sep)));if(0===s.indexOf(e))return s}return t.normalize(t.join(e,t.basename(r)))},a.toBuffer=function(e,t){return Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e):"string"==typeof e?t(e):Buffer.alloc(0)},a.readBigUInt64LE=function(e,t){var r=Buffer.from(e.slice(t,t+8));return r.swap64(),parseInt(`0x${r.toString("hex")}`)},a.fromDOS2Date=function(e){return new Date(1980+(e>>25&127),Math.max((e>>21&15)-1,0),Math.max(e>>16&31,1),e>>11&31,e>>5&63,(31&e)<<1)},a.fromDate2DOS=function(e){let t=0,r=0;return e.getFullYear()>1979&&(t=(e.getFullYear()-1980&127)<<9|e.getMonth()+1<<5|e.getDate(),r=e.getHours()<<11|e.getMinutes()<<5|e.getSeconds()>>1),t<<16|r},a.isWin=i,a.crcTable=s,ar}(),ir.exports.Constants=or(),ir.exports.Errors=mr(),ir.exports.FileAttr=function(){if(ur)return lr;ur=1;const e=T;return lr=function(t,{fs:r}){var n=t||"",i={directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0},o=null;return n&&r.existsSync(n)?(o=r.statSync(n),i.directory=o.isDirectory(),i.mtime=o.mtime,i.atime=o.atime,i.executable=!!(73&o.mode),i.readonly=!(128&o.mode),i.hidden="."===e.basename(n)[0]):console.warn("Invalid path: "+n),{get directory(){return i.directory},get readOnly(){return i.readonly},get hidden(){return i.hidden},get mtime(){return i.mtime},get atime(){return i.atime},get executable(){return i.executable},decodeAttributes:function(){},encodeAttributes:function(){},toJSON:function(){return{path:n,isDirectory:i.directory,isReadOnly:i.readonly,isHidden:i.hidden,isExecutable:i.executable,mTime:i.mtime,aTime:i.atime}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}}(),ir.exports.decoder=pr?fr:(pr=1,fr={efs:!0,encode:e=>Buffer.from(e,"utf8"),decode:e=>e.toString("utf8")})),ir.exports}var vr,yr,Er,br,wr,Lr={};function Sr(){if(yr)return vr;yr=1;var e=gr(),t=e.Constants;return vr=function(){var r=20,n=10,i=0,o=0,s=0,a=0,c=0,l=0,u=0,f=0,p=0,h=0,d=0,m=0,g=0;r|=e.isWin?2560:768,i|=t.FLG_EFS;const v={extraLen:0},y=e=>Math.max(0,e)>>>0;return s=e.fromDate2DOS(new Date),{get made(){return r},set made(e){r=e},get version(){return n},set version(e){n=e},get flags(){return i},set flags(e){i=e},get flags_efs(){return(i&t.FLG_EFS)>0},set flags_efs(e){e?i|=t.FLG_EFS:i&=~t.FLG_EFS},get flags_desc(){return(i&t.FLG_DESC)>0},set flags_desc(e){e?i|=t.FLG_DESC:i&=~t.FLG_DESC},get method(){return o},set method(e){switch(e){case t.STORED:this.version=10;case t.DEFLATED:default:this.version=20}o=e},get time(){return e.fromDOS2Date(this.timeval)},set time(t){this.timeval=e.fromDate2DOS(t)},get timeval(){return s},set timeval(e){s=y(e)},get timeHighByte(){return e=s>>>8,255&Math.max(0,e);var e},get crc(){return a},set crc(e){a=y(e)},get compressedSize(){return c},set compressedSize(e){c=y(e)},get size(){return l},set size(e){l=y(e)},get fileNameLength(){return u},set fileNameLength(e){u=e},get extraLength(){return f},set extraLength(e){f=e},get extraLocalLength(){return v.extraLen},set extraLocalLength(e){v.extraLen=e},get commentLength(){return p},set commentLength(e){p=e},get diskNumStart(){return h},set diskNumStart(e){h=y(e)},get inAttr(){return d},set inAttr(e){d=y(e)},get attr(){return m},set attr(e){m=y(e)},get fileAttr(){return(m||0)>>16&4095},get offset(){return g},set offset(e){g=y(e)},get encrypted(){return(i&t.FLG_ENC)===t.FLG_ENC},get centralHeaderSize(){return t.CENHDR+u+f+p},get realDataOffset(){return g+t.LOCHDR+v.fnameLen+v.extraLen},get localHeader(){return v},loadLocalHeaderFromBinary:function(r){var n=r.slice(g,g+t.LOCHDR);if(n.readUInt32LE(0)!==t.LOCSIG)throw e.Errors.INVALID_LOC();v.version=n.readUInt16LE(t.LOCVER),v.flags=n.readUInt16LE(t.LOCFLG),v.method=n.readUInt16LE(t.LOCHOW),v.time=n.readUInt32LE(t.LOCTIM),v.crc=n.readUInt32LE(t.LOCCRC),v.compressedSize=n.readUInt32LE(t.LOCSIZ),v.size=n.readUInt32LE(t.LOCLEN),v.fnameLen=n.readUInt16LE(t.LOCNAM),v.extraLen=n.readUInt16LE(t.LOCEXT);const i=g+t.LOCHDR+v.fnameLen,o=i+v.extraLen;return r.slice(i,o)},loadFromBinary:function(v){if(v.length!==t.CENHDR||v.readUInt32LE(0)!==t.CENSIG)throw e.Errors.INVALID_CEN();r=v.readUInt16LE(t.CENVEM),n=v.readUInt16LE(t.CENVER),i=v.readUInt16LE(t.CENFLG),o=v.readUInt16LE(t.CENHOW),s=v.readUInt32LE(t.CENTIM),a=v.readUInt32LE(t.CENCRC),c=v.readUInt32LE(t.CENSIZ),l=v.readUInt32LE(t.CENLEN),u=v.readUInt16LE(t.CENNAM),f=v.readUInt16LE(t.CENEXT),p=v.readUInt16LE(t.CENCOM),h=v.readUInt16LE(t.CENDSK),d=v.readUInt16LE(t.CENATT),m=v.readUInt32LE(t.CENATX),g=v.readUInt32LE(t.CENOFF)},localHeaderToBinary:function(){var e=Buffer.alloc(t.LOCHDR);return e.writeUInt32LE(t.LOCSIG,0),e.writeUInt16LE(n,t.LOCVER),e.writeUInt16LE(i,t.LOCFLG),e.writeUInt16LE(o,t.LOCHOW),e.writeUInt32LE(s,t.LOCTIM),e.writeUInt32LE(a,t.LOCCRC),e.writeUInt32LE(c,t.LOCSIZ),e.writeUInt32LE(l,t.LOCLEN),e.writeUInt16LE(u,t.LOCNAM),e.writeUInt16LE(v.extraLen,t.LOCEXT),e},centralHeaderToBinary:function(){var e=Buffer.alloc(t.CENHDR+u+f+p);return e.writeUInt32LE(t.CENSIG,0),e.writeUInt16LE(r,t.CENVEM),e.writeUInt16LE(n,t.CENVER),e.writeUInt16LE(i,t.CENFLG),e.writeUInt16LE(o,t.CENHOW),e.writeUInt32LE(s,t.CENTIM),e.writeUInt32LE(a,t.CENCRC),e.writeUInt32LE(c,t.CENSIZ),e.writeUInt32LE(l,t.CENLEN),e.writeUInt16LE(u,t.CENNAM),e.writeUInt16LE(f,t.CENEXT),e.writeUInt16LE(p,t.CENCOM),e.writeUInt16LE(h,t.CENDSK),e.writeUInt16LE(d,t.CENATT),e.writeUInt32LE(m,t.CENATX),e.writeUInt32LE(g,t.CENOFF),e},toJSON:function(){const s=function(e){return e+" bytes"};return{made:r,version:n,flags:i,method:e.methodToString(o),time:this.time,crc:"0x"+a.toString(16).toUpperCase(),compressedSize:s(c),size:s(l),fileNameLength:s(u),extraLength:s(f),commentLength:s(p),diskNumStart:h,inAttr:d,attr:m,offset:g,centralHeaderSize:s(t.CENHDR+u+f+p)}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}}function Cr(){return wr||(wr=1,Lr.EntryHeader=Sr(),Lr.MainHeader=function(){if(br)return Er;br=1;var e=gr(),t=e.Constants;return Er=function(){var r=0,n=0,i=0,o=0,s=0;return{get diskEntries(){return r},set diskEntries(e){r=n=e},get totalEntries(){return n},set totalEntries(e){n=r=e},get size(){return i},set size(e){i=e},get offset(){return o},set offset(e){o=e},get commentLength(){return s},set commentLength(e){s=e},get mainHeaderSize(){return t.ENDHDR+s},loadFromBinary:function(a){if((a.length!==t.ENDHDR||a.readUInt32LE(0)!==t.ENDSIG)&&(a.length<t.ZIP64HDR||a.readUInt32LE(0)!==t.ZIP64SIG))throw e.Errors.INVALID_END();a.readUInt32LE(0)===t.ENDSIG?(r=a.readUInt16LE(t.ENDSUB),n=a.readUInt16LE(t.ENDTOT),i=a.readUInt32LE(t.ENDSIZ),o=a.readUInt32LE(t.ENDOFF),s=a.readUInt16LE(t.ENDCOM)):(r=e.readBigUInt64LE(a,t.ZIP64SUB),n=e.readBigUInt64LE(a,t.ZIP64TOT),i=e.readBigUInt64LE(a,t.ZIP64SIZE),o=e.readBigUInt64LE(a,t.ZIP64OFF),s=0)},toBinary:function(){var e=Buffer.alloc(t.ENDHDR+s);return e.writeUInt32LE(t.ENDSIG,0),e.writeUInt32LE(0,4),e.writeUInt16LE(r,t.ENDSUB),e.writeUInt16LE(n,t.ENDTOT),e.writeUInt32LE(i,t.ENDSIZ),e.writeUInt32LE(o,t.ENDOFF),e.writeUInt16LE(s,t.ENDCOM),e.fill(" ",t.ENDHDR),e},toJSON:function(){return{diskEntries:r,totalEntries:n,size:i+" bytes",offset:function(e,t){let r=e.toString(16).toUpperCase();for(;r.length<t;)r="0"+r;return"0x"+r}(o,4),commentLength:s}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}}}()),Lr}var Ir,Dr,_r,Or,Nr,Ar,Pr,Tr,Rr,xr,$r,Fr,Ur,kr={};function Br(){if(Ar)return Nr;Ar=1;const{randomFillSync:e}=x,t=mr(),r=new Uint32Array(256).map((e,t)=>{for(let e=0;e<8;e++)1&t?t=t>>>1^3988292384:t>>>=1;return t>>>0}),n=(e,t)=>Math.imul(e,t)>>>0,i=(e,t)=>r[255&(e^t)]^e>>>8,o=()=>"function"==typeof e?e(Buffer.alloc(12)):o.node();o.node=()=>{const e=Buffer.alloc(12),t=e.length;for(let r=0;r<t;r++)e[r]=256*Math.random()&255;return e};const s={genSalt:o};function a(e){const t=Buffer.isBuffer(e)?e:Buffer.from(e);this.keys=new Uint32Array([305419896,591751049,878082192]);for(let e=0;e<t.length;e++)this.updateKeys(t[e])}return a.prototype.updateKeys=function(e){const t=this.keys;return t[0]=i(t[0],e),t[1]+=255&t[0],t[1]=n(t[1],134775813)+1,t[2]=i(t[2],t[1]>>>24),e},a.prototype.next=function(){const e=(2|this.keys[2])>>>0;return n(e,1^e)>>8&255},Nr={decrypt:function(e,r,n){if(!e||!Buffer.isBuffer(e)||e.length<12)return Buffer.alloc(0);const i=function(e){const t=new a(e);return function(e){const r=Buffer.alloc(e.length);let n=0;for(let i of e)r[n++]=t.updateKeys(i^t.next());return r}}(n),o=i(e.slice(0,12)),s=8&~r.flags?r.crc>>>24:r.timeHighByte;if(o[11]!==s)throw t.WRONG_PASSWORD();return i(e.slice(12))},encrypt:function(e,t,r,n=!1){null==e&&(e=Buffer.alloc(0)),Buffer.isBuffer(e)||(e=Buffer.from(e.toString()));const i=function(e){const t=new a(e);return function(e,r,n=0){r||(r=Buffer.alloc(e.length));for(let i of e){const e=t.next();r[n++]=i^e,t.updateKeys(i)}return r}}(r),o=s.genSalt();o[11]=t.crc>>>24&255,n&&(o[10]=t.crc>>>16&255);const c=Buffer.alloc(e.length+12);return i(o,c),i(e,c,12)},_salter:function(e){Buffer.isBuffer(e)&&e.length>=12?s.genSalt=function(){return e.slice(0,12)}:s.genSalt="node"===e?o.node:o}}}function Mr(){return Pr||(Pr=1,kr.Deflater=Dr?Ir:(Dr=1,Ir=function(e){var t=R,r={chunkSize:1024*(parseInt(e.length/1024)+1)};return{deflate:function(){return t.deflateRawSync(e,r)},deflateAsync:function(n){var i=t.createDeflateRaw(r),o=[],s=0;i.on("data",function(e){o.push(e),s+=e.length}),i.on("end",function(){var e=Buffer.alloc(s),t=0;e.fill(0);for(var r=0;r<o.length;r++){var i=o[r];i.copy(e,t),t+=i.length}n&&n(e)}),i.end(e)}}}),kr.Inflater=function(){if(Or)return _r;Or=1;const e=+(process.versions?process.versions.node:"").split(".")[0]||0;return _r=function(t,r){var n=R;const i=e>=15&&r>0?{maxOutputLength:r}:{};return{inflate:function(){return n.inflateRawSync(t,i)},inflateAsync:function(e){var r=n.createInflateRaw(i),o=[],s=0;r.on("data",function(e){o.push(e),s+=e.length}),r.on("end",function(){var t=Buffer.alloc(s),r=0;t.fill(0);for(var n=0;n<o.length;n++){var i=o[n];i.copy(t,r),r+=i.length}e&&e(t)}),r.end(t)}}}}(),kr.ZipCrypto=Br()),kr}function Gr(){if(Rr)return Tr;Rr=1;var e=gr(),t=Cr(),r=e.Constants,n=Mr();return Tr=function(i,o){var s=new t.EntryHeader,a=Buffer.alloc(0),c=Buffer.alloc(0),l=!1,u=null,f=Buffer.alloc(0),p=Buffer.alloc(0),h=!0;const d=i,m="object"==typeof d.decoder?d.decoder:e.decoder;function g(){return o&&o instanceof Uint8Array?(p=s.loadLocalHeaderFromBinary(o),o.slice(s.realDataOffset,s.realDataOffset+s.compressedSize)):Buffer.alloc(0)}function v(t){if(s.flags_desc){const n={},i=s.realDataOffset+s.compressedSize;if(o.readUInt32LE(i)==r.LOCSIG||o.readUInt32LE(i)==r.CENSIG)throw e.Errors.DESCRIPTOR_NOT_EXIST();if(o.readUInt32LE(i)==r.EXTSIG)n.crc=o.readUInt32LE(i+r.EXTCRC),n.compressedSize=o.readUInt32LE(i+r.EXTSIZ),n.size=o.readUInt32LE(i+r.EXTLEN);else{if(19280!==o.readUInt16LE(i+12))throw e.Errors.DESCRIPTOR_UNKNOWN();n.crc=o.readUInt32LE(i+r.EXTCRC-4),n.compressedSize=o.readUInt32LE(i+r.EXTSIZ-4),n.size=o.readUInt32LE(i+r.EXTLEN-4)}if(n.compressedSize!==s.compressedSize||n.size!==s.size||n.crc!==s.crc)throw e.Errors.DESCRIPTOR_FAULTY();if(e.crc32(t)!==n.crc)return!1}else if(e.crc32(t)!==s.localHeader.crc)return!1;return!0}function y(t,r,i){if(void 0===r&&"string"==typeof t&&(i=t,t=void 0),l)return t&&r&&r(Buffer.alloc(0),e.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var o=g();if(0===o.length)return t&&r&&r(o),o;if(s.encrypted){if("string"!=typeof i&&!Buffer.isBuffer(i))throw e.Errors.INVALID_PASS_PARAM();o=n.ZipCrypto.decrypt(o,s,i)}var c=Buffer.alloc(s.size);switch(s.method){case e.Constants.STORED:if(o.copy(c),v(c))return t&&r&&r(c),c;throw t&&r&&r(c,e.Errors.BAD_CRC()),e.Errors.BAD_CRC();case e.Constants.DEFLATED:var u=new n.Inflater(o,s.size);if(!t){if(u.inflate(c).copy(c,0),!v(c))throw e.Errors.BAD_CRC(`"${m.decode(a)}"`);return c}u.inflateAsync(function(t){t.copy(t,0),r&&(v(t)?r(t):r(t,e.Errors.BAD_CRC()))});break;default:throw t&&r&&r(Buffer.alloc(0),e.Errors.UNKNOWN_METHOD()),e.Errors.UNKNOWN_METHOD()}}function E(t,r){if((!u||!u.length)&&Buffer.isBuffer(o))return t&&r&&r(g()),g();if(u.length&&!l){var i;switch(s.method){case e.Constants.STORED:return s.compressedSize=s.size,i=Buffer.alloc(u.length),u.copy(i),t&&r&&r(i),i;default:case e.Constants.DEFLATED:var a=new n.Deflater(u);if(!t){var c=a.deflate();return s.compressedSize=c.length,c}a.deflateAsync(function(e){i=Buffer.alloc(e.length),s.compressedSize=e.length,e.copy(i),r&&r(i)}),a=null}}else{if(!t||!r)return Buffer.alloc(0);r(Buffer.alloc(0))}}function b(e,t){return(e.readUInt32LE(t+4)<<4)+e.readUInt32LE(t)}function w(e){var t,n,i,o;e.length>=r.EF_ZIP64_SCOMP&&(t=b(e,r.EF_ZIP64_SUNCOMP),s.size===r.EF_ZIP64_OR_32&&(s.size=t)),e.length>=r.EF_ZIP64_RHO&&(n=b(e,r.EF_ZIP64_SCOMP),s.compressedSize===r.EF_ZIP64_OR_32&&(s.compressedSize=n)),e.length>=r.EF_ZIP64_DSN&&(i=b(e,r.EF_ZIP64_RHO),s.offset===r.EF_ZIP64_OR_32&&(s.offset=i)),e.length>=r.EF_ZIP64_DSN+4&&(o=e.readUInt32LE(r.EF_ZIP64_DSN),s.diskNumStart===r.EF_ZIP64_OR_16&&(s.diskNumStart=o))}return h=!!m.hasOwnProperty("efs")&&m.efs,{get entryName(){return m.decode(a)},get rawEntryName(){return a},set entryName(t){var r=(a=e.toBuffer(t,m.encode))[a.length-1];l=47===r||92===r,s.fileNameLength=a.length},get efs(){return"function"==typeof h?h(this.entryName):h},get extra(){return f},set extra(t){f=t,s.extraLength=t.length,function(t){try{for(var n,i,o,s=0;s+4<t.length;)n=t.readUInt16LE(s),s+=2,i=t.readUInt16LE(s),s+=2,o=t.slice(s,s+i),s+=i,r.ID_ZIP64===n&&w(o)}catch(t){throw e.Errors.EXTRA_FIELD_PARSE_ERROR()}}(t)},get comment(){return m.decode(c)},set comment(t){if(c=e.toBuffer(t,m.encode),s.commentLength=c.length,c.length>65535)throw e.Errors.COMMENT_TOO_LONG()},get name(){var e=m.decode(a);return l?e.substr(e.length-1).split("/").pop():e.split("/").pop()},get isDirectory(){return l},getCompressedData:function(){return E(!1,null)},getCompressedDataAsync:function(e){E(!0,e)},setData:function(t){u=e.toBuffer(t,e.decoder.encode),!l&&u.length?(s.size=u.length,s.method=e.Constants.DEFLATED,s.crc=e.crc32(t),s.changed=!0):s.method=e.Constants.STORED},getData:function(e){return s.changed?u:y(!1,null,e)},getDataAsync:function(e,t){s.changed?e(u):y(!0,e,t)},set attr(e){s.attr=e},get attr(){return s.attr},set header(e){s.loadFromBinary(e)},get header(){return s},packCentralHeader:function(){s.flags_efs=this.efs,s.extraLength=f.length;var t=s.centralHeaderToBinary(),r=e.Constants.CENHDR;return a.copy(t,r),r+=a.length,f.copy(t,r),r+=s.extraLength,c.copy(t,r),t},packLocalHeader:function(){let e=0;s.flags_efs=this.efs,s.extraLocalLength=p.length;const t=s.localHeaderToBinary(),r=Buffer.alloc(t.length+a.length+s.extraLocalLength);return t.copy(r,e),e+=t.length,a.copy(r,e),e+=a.length,p.copy(r,e),e+=p.length,r},toJSON:function(){const e=function(e){return"<"+(e&&e.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:s.toJSON(),compressedData:e(o),data:e(u)}},toString:function(){return JSON.stringify(this.toJSON(),null,"\t")}}},Tr}function jr(){if($r)return xr;$r=1;const e=Gr(),t=Cr(),r=gr();return xr=function(n,i){var o=[],s={},a=Buffer.alloc(0),c=new t.MainHeader,l=!1;const u=new Set,f=i,{noSort:p,decoder:h}=f;function d(){if(l=!0,s={},c.diskEntries>(n.length-c.offset)/r.Constants.CENHDR)throw r.Errors.DISK_ENTRY_TOO_LARGE();o=new Array(c.diskEntries);for(var t=c.offset,i=0;i<o.length;i++){var a=t,p=new e(f,n);p.header=n.slice(a,a+=r.Constants.CENHDR),p.entryName=n.slice(a,a+=p.header.fileNameLength),p.header.extraLength&&(p.extra=n.slice(a,a+=p.header.extraLength)),p.header.commentLength&&(p.comment=n.slice(a,a+p.header.commentLength)),t+=p.header.centralHeaderSize,o[i]=p,s[p.entryName]=p}u.clear(),function(){const t=new Set;for(const e of Object.keys(s)){const r=e.split("/");if(r.pop(),r.length)for(let e=0;e<r.length;e++){const n=r.slice(0,e+1).join("/")+"/";t.add(n)}}for(const r of t)if(!(r in s)){const t=new e(f);t.entryName=r,t.attr=16,t.temporary=!0,o.push(t),s[t.entryName]=t,u.add(t)}}()}function m(){o.length>1&&!p&&o.sort((e,t)=>e.entryName.toLowerCase().localeCompare(t.entryName.toLowerCase()))}return n?function(e){var t=n.length-r.Constants.ENDHDR,i=Math.max(0,t-65535),o=i,s=n.length,l=-1,u=0;"boolean"==typeof f.trailingSpace&&f.trailingSpace&&(i=0);for(;t>=o;t--)if(80===n[t])if(n.readUInt32LE(t)!==r.Constants.ENDSIG)if(n.readUInt32LE(t)!==r.Constants.END64SIG){if(n.readUInt32LE(t)===r.Constants.ZIP64SIG){l=t,s=t+r.readBigUInt64LE(n,t+r.Constants.ZIP64SIZE)+r.Constants.ZIP64LEAD;break}}else o=i;else l=t,u=t,s=t+r.Constants.ENDHDR,o=t-r.Constants.END64HDR;if(-1==l)throw r.Errors.INVALID_FORMAT();c.loadFromBinary(n.slice(l,s)),c.commentLength&&(a=n.slice(u+r.Constants.ENDHDR));e&&d()}(f.readEntries):l=!0,{get entries(){return l||d(),o.filter(e=>!u.has(e))},get comment(){return h.decode(a)},set comment(e){a=r.toBuffer(e,h.encode),c.commentLength=a.length},getEntryCount:function(){return l?o.length:c.diskEntries},forEach:function(e){this.entries.forEach(e)},getEntry:function(e){return l||d(),s[e]||null},setEntry:function(e){l||d(),o.push(e),s[e.entryName]=e,c.totalEntries=o.length},deleteFile:function(e,t=!0){l||d();const r=s[e];this.getEntryChildren(r,t).map(e=>e.entryName).forEach(this.deleteEntry)},deleteEntry:function(e){l||d();const t=s[e],r=o.indexOf(t);r>=0&&(o.splice(r,1),delete s[e],c.totalEntries=o.length)},getEntryChildren:function(e,t=!0){if(l||d(),"object"==typeof e){if(e.isDirectory&&t){const t=[],r=e.entryName;for(const e of o)e.entryName.startsWith(r)&&t.push(e);return t}return[e]}return[]},getChildCount:function(e){if(e&&e.isDirectory){const t=this.getEntryChildren(e);return t.includes(e)?t.length-1:t.length}return 0},compressToBuffer:function(){l||d(),m();const e=[],t=[];let i=0,o=0;c.size=0,c.offset=0;let s=0;for(const r of this.entries){const n=r.getCompressedData();r.header.offset=o;const a=r.packLocalHeader(),l=a.length+n.length;o+=l,e.push(a),e.push(n);const u=r.packCentralHeader();t.push(u),c.size+=u.length,i+=l+u.length,s++}i+=c.mainHeaderSize,c.offset=o,c.totalEntries=s,o=0;const u=Buffer.alloc(i);for(const t of e)t.copy(u,o),o+=t.length;for(const e of t)e.copy(u,o),o+=e.length;const f=c.toBinary();return a&&a.copy(f,r.Constants.ENDHDR),f.copy(u,o),n=u,l=!1,u},toAsyncBuffer:function(e,t,i,o){try{l||d(),m();const t=[],s=[];let u=0,f=0,p=0;c.size=0,c.offset=0;const h=function(d){if(d.length>0){const e=d.shift(),r=e.entryName+e.extra.toString();i&&i(r),e.getCompressedDataAsync(function(n){o&&o(r),e.header.offset=f;const i=e.packLocalHeader(),a=i.length+n.length;f+=a,t.push(i),t.push(n);const l=e.packCentralHeader();s.push(l),c.size+=l.length,u+=a+l.length,p++,h(d)})}else{u+=c.mainHeaderSize,c.offset=f,c.totalEntries=p,f=0;const i=Buffer.alloc(u);t.forEach(function(e){e.copy(i,f),f+=e.length}),s.forEach(function(e){e.copy(i,f),f+=e.length});const o=c.toBinary();a&&a.copy(o,r.Constants.ENDHDR),o.copy(i,f),n=i,l=!1,e(i)}};h(Array.from(this.entries))}catch(e){t(e)}}}},xr}var zr=function(){if(Ur)return Fr;Ur=1;const e=gr(),t=T,r=Gr(),n=jr(),i=(...t)=>e.findLast(t,e=>"boolean"==typeof e),o=(...t)=>e.findLast(t,e=>"string"==typeof e),s={noSort:!1,readEntries:!1,method:e.Constants.NONE,fs:null};return Fr=function(a,c){let l=null;const u=Object.assign(Object.create(null),s);a&&"object"==typeof a&&(a instanceof Uint8Array||(Object.assign(u,a),a=u.input?u.input:void 0,u.input&&delete u.input),Buffer.isBuffer(a)&&(l=a,u.method=e.Constants.BUFFER,a=void 0)),Object.assign(u,c);const f=new e(u);if("object"==typeof u.decoder&&"function"==typeof u.decoder.encode&&"function"==typeof u.decoder.decode||(u.decoder=e.decoder),a&&"string"==typeof a){if(!f.fs.existsSync(a))throw e.Errors.INVALID_FILENAME();u.method=e.Constants.FILE,u.filename=a,l=f.fs.readFileSync(a)}const p=new n(l,u),{canonical:h,sanitize:d,zipnamefix:m}=e;function g(e){var r;if(e&&p&&("string"==typeof e&&(r=p.getEntry(t.posix.normalize(e))),"object"==typeof e&&void 0!==e.entryName&&void 0!==e.header&&(r=p.getEntry(e.entryName)),r))return r;return null}function v(e){const{join:r,normalize:n,sep:i}=t.posix;return r(".",n(i+e.split("\\").join(i)+i))}function y(e){return e instanceof RegExp?(t=e,function(e){return t.test(e)}):"function"!=typeof e?()=>!0:e;var t}const E=(e,r)=>{let n=r.slice(-1);return n=n===f.sep?f.sep:"",t.relative(e,r)+n};return{readFile:function(e,t){var r=g(e);return r&&r.getData(t)||null},childCount:function(e){const t=g(e);if(t)return p.getChildCount(t)},readFileAsync:function(e,t){var r=g(e);r?r.getDataAsync(t):t(null,"getEntry failed for:"+e)},readAsText:function(e,t){var r=g(e);if(r){var n=r.getData();if(n&&n.length)return n.toString(t||"utf8")}return""},readAsTextAsync:function(e,t,r){var n=g(e);n?n.getDataAsync(function(e,n){n?t(e,n):e&&e.length?t(e.toString(r||"utf8")):t("")}):t("")},deleteFile:function(e,t=!0){var r=g(e);r&&p.deleteFile(r.entryName,t)},deleteEntry:function(e){var t=g(e);t&&p.deleteEntry(t.entryName)},addZipComment:function(e){p.comment=e},getZipComment:function(){return p.comment||""},addZipEntryComment:function(e,t){var r=g(e);r&&(r.comment=t)},getZipEntryComment:function(e){var t=g(e);return t&&t.comment||""},updateFile:function(e,t){var r=g(e);r&&r.setData(t)},addLocalFile:function(r,n,i,o){if(!f.fs.existsSync(r))throw e.Errors.FILE_NOT_FOUND(r);{n=n?v(n):"";const e=t.win32.basename(t.win32.normalize(r));n+=i||e;const s=f.fs.statSync(r),a=s.isFile()?f.fs.readFileSync(r):Buffer.alloc(0);s.isDirectory()&&(n+=f.sep),this.addFile(n,a,o,s)}},addLocalFileAsync:function(e,r){e="object"==typeof e?e:{localPath:e};const n=t.resolve(e.localPath),{comment:i}=e;let{zipPath:o,zipName:s}=e;const a=this;f.fs.stat(n,function(e,c){if(e)return r(e,!1);o=o?v(o):"";const l=t.win32.basename(t.win32.normalize(n));if(o+=s||l,c.isFile())f.fs.readFile(n,function(e,t){return e?r(e,!1):(a.addFile(o,t,i,c),setImmediate(r,void 0,!0))});else if(c.isDirectory())return o+=f.sep,a.addFile(o,Buffer.alloc(0),i,c),setImmediate(r,void 0,!0)})},addLocalFolder:function(r,n,i){if(i=y(i),n=n?v(n):"",r=t.normalize(r),!f.fs.existsSync(r))throw e.Errors.FILE_NOT_FOUND(r);{const e=f.findFiles(r),o=this;if(e.length)for(const s of e){const e=t.join(n,E(r,s));i(e)&&o.addLocalFile(s,t.dirname(e))}}},addLocalFolderAsync:function(r,n,i,o){o=y(o),i=i?v(i):"",r=t.normalize(r);var s=this;f.fs.open(r,"r",function(t){if(t&&"ENOENT"===t.code)n(void 0,e.Errors.FILE_NOT_FOUND(r));else if(t)n(void 0,t);else{var a=f.findFiles(r),c=-1,l=function(){if((c+=1)<a.length){var e=a[c],t=E(r,e).split("\\").join("/");t=t.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),o(t)?f.fs.stat(e,function(r,o){r&&n(void 0,r),o.isFile()?f.fs.readFile(e,function(e,r){e?n(void 0,e):(s.addFile(i+t,r,"",o),l())}):(s.addFile(i+t+"/",Buffer.alloc(0),"",o),l())}):process.nextTick(()=>{l()})}else n(!0,void 0)};l()}})},addLocalFolderAsync2:function(r,n){const i=this;r="object"==typeof r?r:{localPath:r},localPath=t.resolve(v(r.localPath));let{zipPath:o,filter:s,namefix:a}=r;var c;s instanceof RegExp?(c=s,s=function(e){return c.test(e)}):"function"!=typeof s&&(s=function(){return!0}),o=o?v(o):"","latin1"==a&&(a=e=>e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),"function"!=typeof a&&(a=e=>e);const l=e=>t.join(o,a(E(localPath,e))),u=e=>t.win32.basename(t.win32.normalize(a(e)));f.fs.open(localPath,"r",function(r){r&&"ENOENT"===r.code?n(void 0,e.Errors.FILE_NOT_FOUND(localPath)):r?n(void 0,r):f.findFilesAsync(localPath,function(e,r){if(e)return n(e);(r=r.filter(e=>s(l(e)))).length||n(void 0,!1),setImmediate(r.reverse().reduce(function(e,r){return function(n,o){if(n||!1===o)return setImmediate(e,n,!1);i.addLocalFileAsync({localPath:r,zipPath:t.dirname(l(r)),zipName:u(r)},e)}},n))})})},addLocalFolderPromise:function(e,t){return new Promise((r,n)=>{this.addLocalFolderAsync2(Object.assign({localPath:e},t),(e,t)=>{e&&n(e),t&&r(this)})})},addFile:function(e,t,n,i){let o=g(e=m(e));const s=null!=o;s||(o=new r(u),o.entryName=e),o.comment=n||"";const a="object"==typeof i&&i instanceof f.fs.Stats;a&&(o.header.time=i.mtime);var c=o.isDirectory?16:0;let l=o.isDirectory?16384:32768;return l|=a?4095&i.mode:"number"==typeof i?4095&i:o.isDirectory?493:420,c=(c|l<<16)>>>0,o.attr=c,o.setData(t),s||p.setEntry(o),o},getEntries:function(e){return p.password=e,p?p.entries:[]},getEntry:function(e){return g(e)},getEntryCount:function(){return p.getEntryCount()},forEach:function(e){return p.forEach(e)},extractEntryTo:function(r,n,s,a,c,l){a=i(!1,a),c=i(!1,c),s=i(!0,s),l=o(c,l);var u=g(r);if(!u)throw e.Errors.NO_ENTRY();var m=h(u.entryName),v=d(n,l&&!u.isDirectory?l:s?m:t.basename(m));if(u.isDirectory)return p.getEntryChildren(u).forEach(function(r){if(r.isDirectory)return;var i=r.getData();if(!i)throw e.Errors.CANT_EXTRACT_FILE();var o=h(r.entryName),l=d(n,s?o:t.basename(o));const u=c?r.header.fileAttr:void 0;f.writeFileTo(l,i,a,u)}),!0;var y=u.getData(p.password);if(!y)throw e.Errors.CANT_EXTRACT_FILE();if(f.fs.existsSync(v)&&!a)throw e.Errors.CANT_OVERRIDE();const E=c?r.header.fileAttr:void 0;return f.writeFileTo(v,y,a,E),!0},test:function(e){if(!p)return!1;for(var t in p.entries)try{if(t.isDirectory)continue;if(!p.entries[t].getData(e))return!1}catch(e){return!1}return!0},extractAllTo:function(t,r,n,s){if(n=i(!1,n),s=o(n,s),r=i(!1,r),!p)throw e.Errors.NO_ZIP();p.entries.forEach(function(i){var o=d(t,h(i.entryName));if(i.isDirectory)return void f.makeDir(o);var a=i.getData(s);if(!a)throw e.Errors.CANT_EXTRACT_FILE();const c=n?i.header.fileAttr:void 0;f.writeFileTo(o,a,r,c);try{f.fs.utimesSync(o,i.header.time,i.header.time)}catch(t){throw e.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(r,n,o,s){if(s=((...t)=>e.findLast(t,e=>"function"==typeof e))(n,o,s),o=i(!1,o),n=i(!1,n),!s)return new Promise((e,t)=>{this.extractAllToAsync(r,n,o,function(r){r?t(r):e(this)})});if(!p)return void s(e.Errors.NO_ZIP());r=t.resolve(r);const a=e=>d(r,t.normalize(h(e.entryName))),c=(e,t)=>new Error(e+': "'+t+'"'),l=[],u=[];p.entries.forEach(e=>{e.isDirectory?l.push(e):u.push(e)});for(const e of l){const t=a(e),r=o?e.header.fileAttr:void 0;try{f.makeDir(t),r&&f.fs.chmodSync(t,r),f.fs.utimesSync(t,e.header.time,e.header.time)}catch(e){s(c("Unable to create folder",t))}}u.reverse().reduce(function(i,s){return function(a){if(a)i(a);else{const a=t.normalize(h(s.entryName)),l=d(r,a);s.getDataAsync(function(t,r){if(r)i(r);else if(t){const e=o?s.header.fileAttr:void 0;f.writeFileToAsync(l,t,n,e,function(e){e||i(c("Unable to write file",l)),f.fs.utimes(l,s.header.time,s.header.time,function(e){e?i(c("Unable to set times",l)):i()})})}else i(e.Errors.CANT_EXTRACT_FILE())})}}},s)()},writeZip:function(e,t){if(1===arguments.length&&"function"==typeof e&&(t=e,e=""),!e&&u.filename&&(e=u.filename),e){var r=p.compressToBuffer();if(r){var n=f.writeFileTo(e,r,!0);"function"==typeof t&&t(n?null:new Error("failed"),"")}}},writeZipPromise:function(e,t){const{overwrite:r,perm:n}=Object.assign({overwrite:!0},t);return new Promise((t,i)=>{!e&&u.filename&&(e=u.filename),e||i("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(o=>{f.writeFileToAsync(e,o,r,n,e=>e?t(e):i("ADM-ZIP: Wasn't able to write zip file"))},i)})},toBufferPromise:function(){return new Promise((e,t)=>{p.toAsyncBuffer(e,t)})},toBuffer:function(e,t,r,n){return"function"==typeof e?(p.toAsyncBuffer(e,t,r,n),null):p.compressToBuffer()}}},Fr}(),Hr=ue(zr);class Wr{#K;get ora(){return this.#K}set attachConsole(e){e?(console.log=this.info.bind(this),console.info=this.info.bind(this)):console=Yr}static Global(e){return Vr=new Wr(e),Vr}static Clone(e){const{prefixText:t}=e||Vr;return new Wr({prefixText:t})}static get Current(){return Vr}static set Current(e){Vr=e}constructor(e){this.#K=$(e)}get prefixText(){return this.#K.prefixText}info(...e){this.#K.info(qr(e))}succeed(...e){this.#K.succeed(qr(e))}start(...e){this.#K.start(qr(e))}fail(...e){this.#K.fail(qr(e))}warn(...e){this.#K.warn(qr(e))}clear(){this.#K.clear()}stop(){this.#K.stop()}stopAndPersist(...e){this.#K.stopAndPersist(...e)}}let Vr=new Wr;const qr=e=>e.length?e.join(" "):void 0,Yr=console;let Kr=class{spinner;debugMode;constructor(e,t){this.spinner=new Wr({prefixText:e}),this.debugMode=t?.debug??!1}start(...e){this.spinner.start(...e)}succeed(...e){this.spinner.succeed(...e)}fail(...e){this.spinner.fail(...e)}error(...e){console.log(...e)}warn(...e){this.spinner.warn(...e)}info(...e){this.spinner.info(...e)}log(...e){this.spinner.info(...e)}debug(...e){this.debugMode&&console.debug(...e)}startNativeConsoleCapture(){this.spinner.attachConsole=!0}stopNativeConsoleCapture(){this.spinner.attachConsole=!1}};const Zr=e=>{const t={spa:{templateEnv:(r=e.template,{portal:{id:"@equinor/fusion-framework-dev-portal"},title:"Fusion Dev Portal",serviceDiscovery:{url:"/@fusion-services",scopes:["5a842df8-3238-415d-b168-9f16a6a6031b/.default"]},msal:{clientId:"9b707e3a-3e90-41ed-a47e-652a1e3b53d0",tenantId:"3aa4a235-b6e2-48d5-9195-7fcf05b459b0",redirectUri:"/authentication/login-callback",requiresAuth:"true"},serviceWorker:{resources:[{url:"/apps-proxy",rewrite:"/@fusion-api/apps",scopes:["5a842df8-3238-415d-b168-9f16a6a6031b/.default"]},{url:"/help-proxy",rewrite:"/@fusion-api/help",scopes:["5a842df8-3238-415d-b168-9f16a6a6031b/.default"]}]},...r})},api:{serviceDiscoveryUrl:"https://discovery.fusion.equinor.com/service-registry/environments/ci/services/",processServices:(e,t)=>{const{data:r,routes:n}=U(e,t);return{data:r.concat({key:"portals",name:"Portal Service - MOCK",uri:"/@fusion-api/portals"}),routes:n}}}};var r;return e.app&&((e,t,r)=>{const{build:n,appKey:i}=t;if(!n)throw new Error("App manifest does not contain build information");e.api.routes??=[],e.api.routes.push({match:[`/apps/bundles/apps/${i}/${n.version}/*path`,`/apps/bundles/apps/${i}@${n.version}/*path`],middleware:async(e,t,r)=>{const n=e.params?.path;!1===Array.isArray(n)&&r(),t.writeHead(302,{"content-type":"application/javascript",location:`/${n.join("/")}`}),t.end()}}),e.api.routes.push({match:`/apps/persons/me/apps/${i}`,middleware:async(e,r)=>{r.writeHead(200,{"content-type":"application/json"}),r.end(JSON.stringify({id:"dev-server-generated-id",...t}))}}),e.api.routes.push({match:`/apps/apps/${i}/builds/${n.version}/config`,middleware:async(e,t)=>{t.writeHead(200,{"content-type":"application/json"}),t.end(JSON.stringify(r))}})})(t,e.app.manifest,e.app.config),e.portal&&((e,t,r)=>{e.api.routes??=[];const n="portal-config";e.api.routes.push({match:`/${n}/portals/${t.name}{@:tag}`,middleware:async(e,r)=>{r.writeHead(200,{"content-type":"application/json"}),r.end(JSON.stringify(t))}}),r&&e.api.routes.push({match:`/${n}/portals/${t.name}{@:tag}/config`,middleware:async(e,t)=>{t.writeHead(200,{"content-type":"application/json"}),t.end(JSON.stringify(r))}})})(t,e.portal.manifest,e.portal.config),t},Xr=async(e,t,r)=>{const n=Zr(t),i=await(async(e,t,r)=>C("dev-server.config",{baseDir:e.root,extensions:r?.extensions,script:{resolve:async r=>{let n;if("function"==typeof r.default){const i={...t};n=await r.default(e,{base:i})}else n=r.default;return Tt(t,n??{})}}}))(e,n).catch(()=>({config:n}));return F(i.config,r)},Jr=(e,t,r)=>{const n=i(String(e));E(n)||b(n,{recursive:!0}),w(e,t,r)},Qr=["package.json","LICENSE.md","README.md","CHANGELOG.md"],en=async(e,t)=>{const{archive:r,log:n}=t??{},s=i(e.path),a=t?.buildDir??"dist",c=o(s,a);if(!(await L(c)).isDirectory())throw new Error(`Build directory ${a} does not exist`);n?.log(le.bold("Starting to pack bundle"));const l=new Hr;if(l.addLocalFolder(c,a),t?.content)for(const[e,r]of Object.entries(t.content))l.addFile(e,Buffer.from(r)),n?.info("📄",Zt(e,{relative:!0}));n?.info("📂",Zt(c,{relative:!0}));for(const t of Qr.concat(e.packageJson.files??[])){const e=o(s,t),r=i(e.replace(s,""));Nt(e)?(l.addLocalFile(e,r),n?.info("📄",Zt(e,{relative:!0}))):n?.warn(le.dim("📄",Zt(e,{relative:!0})))}return r&&(Nt(i(r))||await S(i(r),{recursive:!0}),n?.start("compressing content"),await l.writeZipPromise(r),n?.succeed("📚",Zt(r,{relative:!0}),Xt(r))),l},tn=async e=>{const{log:t,manifest:r}=e;process.env.NODE_ENV,process.cwd();const{pkg:n,manifest:i}=await tr({log:t,manifest:r});if(!i.build)throw new Error("Manifest build config not found");return{archive:await en(n,{log:t,archive:e?.archive,content:{"app-manifest.json":JSON.stringify(i.build,null,2),"metadata.json":JSON.stringify({name:i.appKey,version:i.build.version})}}).catch(e=>{t?.error("Failed to create package:",e),process.exit(1)}),manifest:i}},rn=async(e,t)=>{const{log:r}=t;try{r?.start("create application configuration"),r?.info(`generating config with ${le.red.dim(e.command)} command in ${le.green.dim(e.mode)} mode`);const n=await((e,t)=>{const r=t?.file??[`app.config.${e.environment}`,"app.config"];return C(r,{baseDir:e.root,extensions:t?.extensions,script:{resolve:async r=>{const n=t?.base??{environment:{}};if("function"==typeof r.default){const t=await r.default(e,{base:n})??n;return jt.parse(t??n)}return jt.parse(r.default??n)}}})})(e,{file:t?.config});return r?.succeed("⚙️ generated config from ",Zt(n.path,{relative:!0})),n.config}catch(e){if(e instanceof I){if(!t.config)return r?.succeed(le.dim("⚙️ no local application config applied, using built-in")),{environment:{}};r?.warn(`failed to load config file ${Zt(t.config)}, please check the path.`)}throw r?.fail("failed to resolve application config"),r?.debug(e),e}},nn=async e=>{const{log:t}=e??{},r=await Qt(t),n={command:"build",mode:process.env.NODE_ENV??"production",root:r.root,...e?.env},i=await rn(n,{log:t,config:e?.config});if(t?.debug("config:",i),e?.output){t?.start("writing config to file");try{await Jr(e.output,JSON.stringify(i,null,2)),t?.succeed("config written successfully",Zt(e.output,{relative:!0}))}catch(e){throw t?.fail("failed to write config"),e}}return{config:i,pkg:r}};class on extends Error{response;static Name="HttpResponseError";constructor(e,t,r){super(e,r),this.response=t}}class sn extends on{static Name="HttpJsonResponseError";data;constructor(e,t,r){super(e,t,r),this.name=sn.Name,this.data=r?.data}}class an extends on{static Name="ServerSentEventResponseError";constructor(e,t,r){super(e,t,r),this.name=an.Name}}var cn,ln,un,fn,pn,hn,dn,mn,gn,vn,yn,En,bn,wn,Ln,Sn,Cn,In,Dn,_n,On,Nn,An,Pn,Tn,Rn,xn,$n,Fn,Un,kn,Bn,Mn,Gn,jn,zn,Hn,Wn,Vn,qn,Yn,Kn,Zn,Xn,Jn,Qn,ei,ti,ri,ni,ii,oi,si,ai,ci,li,ui,fi,pi,hi,di,mi,gi,vi,yi,Ei,bi,wi,Li,Si,Ci,Ii;function Di(){if(wn)return bn;wn=1;const e=xe();return bn=(t,r,n)=>new e(t,n).compare(new e(r,n))}function _i(){if(_n)return Dn;_n=1;const e=xe();return Dn=(t,r,n)=>{const i=new e(t,n),o=new e(r,n);return i.compare(o)||i.compareBuild(o)}}function Oi(){if(Rn)return Tn;Rn=1;const e=Di();return Tn=(t,r,n)=>e(t,r,n)>0}function Ni(){if($n)return xn;$n=1;const e=Di();return xn=(t,r,n)=>e(t,r,n)<0}function Ai(){if(Un)return Fn;Un=1;const e=Di();return Fn=(t,r,n)=>0===e(t,r,n)}function Pi(){if(Bn)return kn;Bn=1;const e=Di();return kn=(t,r,n)=>0!==e(t,r,n)}function Ti(){if(Gn)return Mn;Gn=1;const e=Di();return Mn=(t,r,n)=>e(t,r,n)>=0}function Ri(){if(zn)return jn;zn=1;const e=Di();return jn=(t,r,n)=>e(t,r,n)<=0}function xi(){if(Wn)return Hn;Wn=1;const e=Ai(),t=Pi(),r=Oi(),n=Ti(),i=Ni(),o=Ri();return Hn=(s,a,c,l)=>{switch(a){case"===":return"object"==typeof s&&(s=s.version),"object"==typeof c&&(c=c.version),s===c;case"!==":return"object"==typeof s&&(s=s.version),"object"==typeof c&&(c=c.version),s!==c;case"":case"=":case"==":return e(s,c,l);case"!=":return t(s,c,l);case">":return r(s,c,l);case">=":return n(s,c,l);case"<":return i(s,c,l);case"<=":return o(s,c,l);default:throw new TypeError(`Invalid operator: ${a}`)}}}function $i(){if(Xn)return Zn;Xn=1;const e=/\s+/g;class t{constructor(r,o){if(o=n(o),r instanceof t)return r.loose===!!o.loose&&r.includePrerelease===!!o.includePrerelease?r:new t(r.raw,o);if(r instanceof i)return this.raw=r.value,this.set=[[r]],this.formatted=void 0,this;if(this.options=o,this.loose=!!o.loose,this.includePrerelease=!!o.includePrerelease,this.raw=r.trim().replace(e," "),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=>!d(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&&m(e[0])){this.set=[e];break}}this.formatted=void 0}get range(){if(void 0===this.formatted){this.formatted="";for(let e=0;e<this.set.length;e++){e>0&&(this.formatted+="||");const t=this.set[e];for(let e=0;e<t.length;e++)e>0&&(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&&p)|(this.options.loose&&h))+":"+e,n=r.get(t);if(n)return n;const s=this.options.loose,m=s?a[c.HYPHENRANGELOOSE]:a[c.HYPHENRANGE];e=e.replace(m,_(this.options.includePrerelease)),o("hyphen replace",e),e=e.replace(a[c.COMPARATORTRIM],l),o("comparator trim",e),e=e.replace(a[c.TILDETRIM],u),o("tilde trim",e),e=e.replace(a[c.CARETTRIM],f),o("caret trim",e);let g=e.split(" ").map(e=>v(e,this.options)).join(" ").split(/\s+/).map(e=>D(e,this.options));s&&(g=g.filter(e=>(o("loose invalid filter",e,this.options),!!e.match(a[c.COMPARATORLOOSE])))),o("range list",g);const y=new Map,E=g.map(e=>new i(e,this.options));for(const e of E){if(d(e))return[e];y.set(e.value,e)}y.size>1&&y.has("")&&y.delete("");const b=[...y.values()];return r.set(t,b),b}intersects(e,r){if(!(e instanceof t))throw new TypeError("a Range is required");return this.set.some(t=>g(t,r)&&e.set.some(e=>g(e,r)&&t.every(t=>e.every(e=>t.intersects(e,r)))))}test(e){if(!e)return!1;if("string"==typeof e)try{e=new s(e,this.options)}catch(e){return!1}for(let t=0;t<this.set.length;t++)if(O(this.set[t],e,this.options))return!0;return!1}}Zn=t;const r=new(Kn?Yn:(Kn=1,Yn=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}})),n=Te(),i=Fi(),o=me(),s=xe(),{safeRe:a,t:c,comparatorTrimReplace:l,tildeTrimReplace:u,caretTrimReplace:f}=Pe(),{FLAG_INCLUDE_PRERELEASE:p,FLAG_LOOSE:h}=ge(),d=e=>"<0.0.0-0"===e.value,m=e=>""===e.value,g=(e,t)=>{let r=!0;const n=e.slice();let i=n.pop();for(;r&&n.length;)r=n.every(e=>i.intersects(e,t)),i=n.pop();return r},v=(e,t)=>(o("comp",e,t),e=w(e,t),o("caret",e),e=E(e,t),o("tildes",e),e=S(e,t),o("xrange",e),e=I(e,t),o("stars",e),e),y=e=>!e||"x"===e.toLowerCase()||"*"===e,E=(e,t)=>e.trim().split(/\s+/).map(e=>b(e,t)).join(" "),b=(e,t)=>{const r=t.loose?a[c.TILDELOOSE]:a[c.TILDE];return e.replace(r,(t,r,n,i,s)=>{let a;return o("tilde",e,t,r,n,i,s),y(r)?a="":y(n)?a=`>=${r}.0.0 <${+r+1}.0.0-0`:y(i)?a=`>=${r}.${n}.0 <${r}.${+n+1}.0-0`:s?(o("replaceTilde pr",s),a=`>=${r}.${n}.${i}-${s} <${r}.${+n+1}.0-0`):a=`>=${r}.${n}.${i} <${r}.${+n+1}.0-0`,o("tilde return",a),a})},w=(e,t)=>e.trim().split(/\s+/).map(e=>L(e,t)).join(" "),L=(e,t)=>{o("caret",e,t);const r=t.loose?a[c.CARETLOOSE]:a[c.CARET],n=t.includePrerelease?"-0":"";return e.replace(r,(t,r,i,s,a)=>{let c;return o("caret",e,t,r,i,s,a),y(r)?c="":y(i)?c=`>=${r}.0.0${n} <${+r+1}.0.0-0`:y(s)?c="0"===r?`>=${r}.${i}.0${n} <${r}.${+i+1}.0-0`:`>=${r}.${i}.0${n} <${+r+1}.0.0-0`:a?(o("replaceCaret pr",a),c="0"===r?"0"===i?`>=${r}.${i}.${s}-${a} <${r}.${i}.${+s+1}-0`:`>=${r}.${i}.${s}-${a} <${r}.${+i+1}.0-0`:`>=${r}.${i}.${s}-${a} <${+r+1}.0.0-0`):(o("no pr"),c="0"===r?"0"===i?`>=${r}.${i}.${s}${n} <${r}.${i}.${+s+1}-0`:`>=${r}.${i}.${s}${n} <${r}.${+i+1}.0-0`:`>=${r}.${i}.${s} <${+r+1}.0.0-0`),o("caret return",c),c})},S=(e,t)=>(o("replaceXRanges",e,t),e.split(/\s+/).map(e=>C(e,t)).join(" ")),C=(e,t)=>{e=e.trim();const r=t.loose?a[c.XRANGELOOSE]:a[c.XRANGE];return e.replace(r,(r,n,i,s,a,c)=>{o("xRange",e,r,n,i,s,a,c);const l=y(i),u=l||y(s),f=u||y(a),p=f;return"="===n&&p&&(n=""),c=t.includePrerelease?"-0":"",l?r=">"===n||"<"===n?"<0.0.0-0":"*":n&&p?(u&&(s=0),a=0,">"===n?(n=">=",u?(i=+i+1,s=0,a=0):(s=+s+1,a=0)):"<="===n&&(n="<",u?i=+i+1:s=+s+1),"<"===n&&(c="-0"),r=`${n+i}.${s}.${a}${c}`):u?r=`>=${i}.0.0${c} <${+i+1}.0.0-0`:f&&(r=`>=${i}.${s}.0${c} <${i}.${+s+1}.0-0`),o("xRange return",r),r})},I=(e,t)=>(o("replaceStars",e,t),e.trim().replace(a[c.STAR],"")),D=(e,t)=>(o("replaceGTE0",e,t),e.trim().replace(a[t.includePrerelease?c.GTE0PRE:c.GTE0],"")),_=e=>(t,r,n,i,o,s,a,c,l,u,f,p)=>`${r=y(n)?"":y(i)?`>=${n}.0.0${e?"-0":""}`:y(o)?`>=${n}.${i}.0${e?"-0":""}`:s?`>=${r}`:`>=${r}${e?"-0":""}`} ${c=y(l)?"":y(u)?`<${+l+1}.0.0-0`:y(f)?`<${l}.${+u+1}.0-0`:p?`<=${l}.${u}.${f}-${p}`:e?`<${l}.${u}.${+f+1}-0`:`<=${c}`}`.trim(),O=(e,t,r)=>{for(let r=0;r<e.length;r++)if(!e[r].test(t))return!1;if(t.prerelease.length&&!r.includePrerelease){for(let r=0;r<e.length;r++)if(o(e[r].semver),e[r].semver!==i.ANY&&e[r].semver.prerelease.length>0){const n=e[r].semver;if(n.major===t.major&&n.minor===t.minor&&n.patch===t.patch)return!0}return!1}return!0};return Zn}function Fi(){if(Qn)return Jn;Qn=1;const e=Symbol("SemVer ANY");class t{static get ANY(){return e}constructor(n,i){if(i=r(i),n instanceof t){if(n.loose===!!i.loose)return n;n=n.value}n=n.trim().split(/\s+/).join(" "),s("comparator",n,i),this.options=i,this.loose=!!i.loose,this.parse(n),this.semver===e?this.value="":this.value=this.operator+this.semver.version,s("comp",this)}parse(t){const r=this.options.loose?n[i.COMPARATORLOOSE]:n[i.COMPARATOR],o=t.match(r);if(!o)throw new TypeError(`Invalid comparator: ${t}`);this.operator=void 0!==o[1]?o[1]:"","="===this.operator&&(this.operator=""),o[2]?this.semver=new a(o[2],this.options.loose):this.semver=e}toString(){return this.value}test(t){if(s("Comparator.test",t,this.options.loose),this.semver===e||t===e)return!0;if("string"==typeof t)try{t=new a(t,this.options)}catch(e){return!1}return o(t,this.operator,this.semver,this.options)}intersects(e,n){if(!(e instanceof t))throw new TypeError("a Comparator is required");return""===this.operator?""===this.value||new c(e.value,n).test(this.value):""===e.operator?""===e.value||new c(this.value,n).test(e.semver):(!(n=r(n)).includePrerelease||"<0.0.0-0"!==this.value&&"<0.0.0-0"!==e.value)&&(!(!n.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("="))||(!!(o(this.semver,"<",e.semver,n)&&this.operator.startsWith(">")&&e.operator.startsWith("<"))||!!(o(this.semver,">",e.semver,n)&&this.operator.startsWith("<")&&e.operator.startsWith(">")))))))}}Jn=t;const r=Te(),{safeRe:n,t:i}=Pe(),o=xi(),s=me(),a=xe(),c=$i();return Jn}function Ui(){if(ti)return ei;ti=1;const e=$i();return ei=(t,r,n)=>{try{r=new e(r,n)}catch(e){return!1}return r.test(t)},ei}function ki(){if(fi)return ui;fi=1;const e=$i();return ui=(t,r)=>{try{return new e(t,r).range||"*"}catch(e){return null}},ui}function Bi(){if(hi)return pi;hi=1;const e=xe(),t=Fi(),{ANY:r}=t,n=$i(),i=Ui(),o=Oi(),s=Ni(),a=Ri(),c=Ti();return pi=(l,u,f,p)=>{let h,d,m,g,v;switch(l=new e(l,p),u=new n(u,p),f){case">":h=o,d=a,m=s,g=">",v=">=";break;case"<":h=s,d=c,m=o,g="<",v="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(i(l,u,p))return!1;for(let e=0;e<u.set.length;++e){const n=u.set[e];let i=null,o=null;if(n.forEach(e=>{e.semver===r&&(e=new t(">=0.0.0")),i=i||e,o=o||e,h(e.semver,i.semver,p)?i=e:m(e.semver,o.semver,p)&&(o=e)}),i.operator===g||i.operator===v)return!1;if((!o.operator||o.operator===g)&&d(l,o.semver))return!1;if(o.operator===v&&m(l,o.semver))return!1}return!0},pi}var Mi=function(){if(Ii)return Ci;Ii=1;const e=Pe(),t=ge(),r=xe(),n=Re(),i=$e(),o=Fe(),s=Ue(),a=function(){if(ln)return cn;ln=1;const e=xe();return cn=(t,r,n,i,o)=>{"string"==typeof n&&(o=i,i=n,n=void 0);try{return new e(t instanceof e?t.version:t,n).inc(r,i,o).version}catch(e){return null}},cn}(),c=function(){if(fn)return un;fn=1;const e=$e();return un=(t,r)=>{const n=e(t,null,!0),i=e(r,null,!0),o=n.compare(i);if(0===o)return null;const s=o>0,a=s?n:i,c=s?i:n,l=!!a.prerelease.length;if(c.prerelease.length&&!l){if(!c.patch&&!c.minor)return"major";if(0===c.compareMain(a))return c.minor&&!c.patch?"minor":"patch"}const u=l?"pre":"";return n.major!==i.major?u+"major":n.minor!==i.minor?u+"minor":n.patch!==i.patch?u+"patch":"prerelease"}}(),l=function(){if(hn)return pn;hn=1;const e=xe();return pn=(t,r)=>new e(t,r).major}(),u=function(){if(mn)return dn;mn=1;const e=xe();return dn=(t,r)=>new e(t,r).minor}(),f=function(){if(vn)return gn;vn=1;const e=xe();return gn=(t,r)=>new e(t,r).patch}(),p=function(){if(En)return yn;En=1;const e=$e();return yn=(t,r)=>{const n=e(t,r);return n&&n.prerelease.length?n.prerelease:null},yn}(),h=Di(),d=function(){if(Sn)return Ln;Sn=1;const e=Di();return Ln=(t,r,n)=>e(r,t,n)}(),m=function(){if(In)return Cn;In=1;const e=Di();return Cn=(t,r)=>e(t,r,!0)}(),g=_i(),v=function(){if(Nn)return On;Nn=1;const e=_i();return On=(t,r)=>t.sort((t,n)=>e(t,n,r))}(),y=function(){if(Pn)return An;Pn=1;const e=_i();return An=(t,r)=>t.sort((t,n)=>e(n,t,r))}(),E=Oi(),b=Ni(),w=Ai(),L=Pi(),S=Ti(),C=Ri(),I=xi(),D=function(){if(qn)return Vn;qn=1;const e=xe(),t=$e(),{safeRe:r,t:n}=Pe();return Vn=(i,o)=>{if(i instanceof e)return i;if("number"==typeof i&&(i=String(i)),"string"!=typeof i)return null;let s=null;if((o=o||{}).rtl){const e=o.includePrerelease?r[n.COERCERTLFULL]:r[n.COERCERTL];let t;for(;(t=e.exec(i))&&(!s||s.index+s[0].length!==i.length);)s&&t.index+t[0].length===s.index+s[0].length||(s=t),e.lastIndex=t.index+t[1].length+t[2].length;e.lastIndex=-1}else s=i.match(o.includePrerelease?r[n.COERCEFULL]:r[n.COERCE]);if(null===s)return null;const a=s[2],c=s[3]||"0",l=s[4]||"0",u=o.includePrerelease&&s[5]?`-${s[5]}`:"",f=o.includePrerelease&&s[6]?`+${s[6]}`:"";return t(`${a}.${c}.${l}${u}${f}`,o)},Vn}(),_=Fi(),O=$i(),N=Ui(),A=function(){if(ni)return ri;ni=1;const e=$i();return ri=(t,r)=>new e(t,r).set.map(e=>e.map(e=>e.value).join(" ").trim().split(" ")),ri}(),P=function(){if(oi)return ii;oi=1;const e=xe(),t=$i();return ii=(r,n,i)=>{let o=null,s=null,a=null;try{a=new t(n,i)}catch(e){return null}return r.forEach(t=>{a.test(t)&&(o&&-1!==s.compare(t)||(o=t,s=new e(o,i)))}),o},ii}(),T=function(){if(ai)return si;ai=1;const e=xe(),t=$i();return si=(r,n,i)=>{let o=null,s=null,a=null;try{a=new t(n,i)}catch(e){return null}return r.forEach(t=>{a.test(t)&&(o&&1!==s.compare(t)||(o=t,s=new e(o,i)))}),o},si}(),R=function(){if(li)return ci;li=1;const e=xe(),t=$i(),r=Oi();return ci=(n,i)=>{n=new t(n,i);let o=new e("0.0.0");if(n.test(o))return o;if(o=new e("0.0.0-0"),n.test(o))return o;o=null;for(let t=0;t<n.set.length;++t){const i=n.set[t];let s=null;i.forEach(t=>{const n=new e(t.semver.version);switch(t.operator){case">":0===n.prerelease.length?n.patch++:n.prerelease.push(0),n.raw=n.format();case"":case">=":s&&!r(n,s)||(s=n);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${t.operator}`)}}),!s||o&&!r(o,s)||(o=s)}return o&&n.test(o)?o:null},ci}(),x=ki(),$=Bi(),F=function(){if(mi)return di;mi=1;const e=Bi();return di=(t,r,n)=>e(t,r,">",n),di}(),U=function(){if(vi)return gi;vi=1;const e=Bi();return gi=(t,r,n)=>e(t,r,"<",n),gi}(),k=function(){if(Ei)return yi;Ei=1;const e=$i();return yi=(t,r,n)=>(t=new e(t,n),r=new e(r,n),t.intersects(r,n))}(),B=function(){if(wi)return bi;wi=1;const e=Ui(),t=Di();return bi=(r,n,i)=>{const o=[];let s=null,a=null;const c=r.sort((e,r)=>t(e,r,i));for(const t of c)e(t,n,i)?(a=t,s||(s=t)):(a&&o.push([s,a]),a=null,s=null);s&&o.push([s,null]);const l=[];for(const[e,t]of o)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 u=l.join(" || "),f="string"==typeof n.raw?n.raw:String(n);return u.length<f.length?u:n},bi}(),M=function(){if(Si)return Li;Si=1;const e=$i(),t=Fi(),{ANY:r}=t,n=Ui(),i=Di(),o=[new t(">=0.0.0-0")],s=[new t(">=0.0.0")],a=(e,t,a)=>{if(e===t)return!0;if(1===e.length&&e[0].semver===r){if(1===t.length&&t[0].semver===r)return!0;e=a.includePrerelease?o:s}if(1===t.length&&t[0].semver===r){if(a.includePrerelease)return!0;t=s}const u=new Set;let f,p,h,d,m,g,v;for(const t of e)">"===t.operator||">="===t.operator?f=c(f,t,a):"<"===t.operator||"<="===t.operator?p=l(p,t,a):u.add(t.semver);if(u.size>1)return null;if(f&&p){if(h=i(f.semver,p.semver,a),h>0)return null;if(0===h&&(">="!==f.operator||"<="!==p.operator))return null}for(const e of u){if(f&&!n(e,String(f),a))return null;if(p&&!n(e,String(p),a))return null;for(const r of t)if(!n(e,String(r),a))return!1;return!0}let y=!(!p||a.includePrerelease||!p.semver.prerelease.length)&&p.semver,E=!(!f||a.includePrerelease||!f.semver.prerelease.length)&&f.semver;y&&1===y.prerelease.length&&"<"===p.operator&&0===y.prerelease[0]&&(y=!1);for(const e of t){if(v=v||">"===e.operator||">="===e.operator,g=g||"<"===e.operator||"<="===e.operator,f)if(E&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===E.major&&e.semver.minor===E.minor&&e.semver.patch===E.patch&&(E=!1),">"===e.operator||">="===e.operator){if(d=c(f,e,a),d===e&&d!==f)return!1}else if(">="===f.operator&&!n(f.semver,String(e),a))return!1;if(p)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(m=l(p,e,a),m===e&&m!==p)return!1}else if("<="===p.operator&&!n(p.semver,String(e),a))return!1;if(!e.operator&&(p||f)&&0!==h)return!1}return!(f&&g&&!p&&0!==h||p&&v&&!f&&0!==h||E||y)},c=(e,t,r)=>{if(!e)return t;const n=i(e.semver,t.semver,r);return n>0?e:n<0||">"===t.operator&&">="===e.operator?t:e},l=(e,t,r)=>{if(!e)return t;const n=i(e.semver,t.semver,r);return n<0?e:n>0||"<"===t.operator&&"<="===e.operator?t:e};return Li=(t,r,n={})=>{if(t===r)return!0;t=new e(t,n),r=new e(r,n);let i=!1;e:for(const e of t.set){for(const t of r.set){const r=a(e,t,n);if(i=i||null!==r,r)continue e}if(i)return!1}return!0}}();return Ci={parse:i,valid:o,clean:s,inc:a,diff:c,major:l,minor:u,patch:f,prerelease:p,compare:h,rcompare:d,compareLoose:m,compareBuild:g,sort:v,rsort:y,gt:E,lt:b,eq:w,neq:L,gte:S,lte:C,cmp:I,coerce:D,Comparator:_,Range:O,satisfies:N,toComparators:A,maxSatisfying:P,minSatisfying:T,minVersion:R,validRange:x,outside:$,gtr:F,ltr:U,intersects:k,simplifyRange:B,subset:M,SemVer:r,re:e.re,src:e.src,tokens:e.t,SEMVER_SPEC_VERSION:t.SEMVER_SPEC_VERSION,RELEASE_TYPES:t.RELEASE_TYPES,compareIdentifiers:n.compareIdentifiers,rcompareIdentifiers:n.rcompareIdentifiers}}();class Gi extends Mi.SemVer{satisfies(e){return Mi.satisfies(this,e)}}let ji=class{domain;level=Number(process.env.FUSION_LOG_LEVEL)||1;constructor(e){this.domain=e}_createMessage(e){return[`%c FUSION FRAMEWORK %c ${this.domain} %c %s`,"background: rgb(179, 13, 47); color: white; padding: 1px;","background: rgb(244, 244, 244); color: rgb(36, 55, 70); padding: 1px;","background: none; color: inherit",...e.reduce((e,t)=>e.concat(t,"\n"),[])]}debug(...e){this.level>3&&console.debug(...this._createMessage(e))}info(...e){this.level>2&&console.info(...this._createMessage(e))}warn(...e){this.level>1&&console.warn(...this._createMessage(e))}error(...e){this.level>0&&console.error(...this._createMessage(e))}};class zi extends ji{formatModuleName(e){return`📦${("string"==typeof e?e:e.name).replace(/([A-Z])/g," $1").toUpperCase()}`}}var Hi=function(e,t){return Hi=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},Hi(e,t)};function Wi(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}Hi(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var Vi=function(){return Vi=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Vi.apply(this,arguments)};function qi(e,t,r,n){return new(r||(r=Promise))(function(i,o){function s(e){try{c(n.next(e))}catch(e){o(e)}}function a(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}c((n=n.apply(e,t||[])).next())})}function Yi(e,t){var r,n,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function Ki(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Zi(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s}function Xi(e,t,r){if(r||2===arguments.length)for(var n,i=0,o=t.length;i<o;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}function Ji(e){return this instanceof Ji?(this.v=e,this):new Ji(e)}function Qi(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,i=r.apply(e,t||[]),o=[];return n=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),s("next"),s("throw"),s("return",function(e){return function(t){return Promise.resolve(t).then(e,l)}}),n[Symbol.asyncIterator]=function(){return this},n;function s(e,t){i[e]&&(n[e]=function(t){return new Promise(function(r,n){o.push([e,t,r,n])>1||a(e,t)})},t&&(n[e]=t(n[e])))}function a(e,t){try{(r=i[e](t)).value instanceof Ji?Promise.resolve(r.value.v).then(c,l):u(o[0][2],r)}catch(e){u(o[0][3],e)}var r}function c(e){a("next",e)}function l(e){a("throw",e)}function u(e,t){e(t),o.shift(),o.length&&a(o[0][0],o[0][1])}}function eo(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=Ki(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise(function(n,i){(function(e,t,r,n){Promise.resolve(n).then(function(t){e({value:t,done:r})},t)})(n,i,(t=e[r](t)).done,t.value)})}}}function to(e){return"function"==typeof e}function ro(e){var t=e(function(e){Error.call(e),e.stack=(new Error).stack});return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}"function"==typeof SuppressedError&&SuppressedError;var no=ro(function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map(function(e,t){return t+1+") "+e.toString()}).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}});function io(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var oo=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}var t;return e.prototype.unsubscribe=function(){var e,t,r,n,i;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var s=Ki(o),a=s.next();!a.done;a=s.next()){a.value.remove(this)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=s.return)&&t.call(s)}finally{if(e)throw e.error}}else o.remove(this);var c=this.initialTeardown;if(to(c))try{c()}catch(e){i=e instanceof no?e.errors:[e]}var l=this._finalizers;if(l){this._finalizers=null;try{for(var u=Ki(l),f=u.next();!f.done;f=u.next()){var p=f.value;try{co(p)}catch(e){i=null!=i?i:[],e instanceof no?i=Xi(Xi([],Zi(i)),Zi(e.errors)):i.push(e)}}}catch(e){r={error:e}}finally{try{f&&!f.done&&(n=u.return)&&n.call(u)}finally{if(r)throw r.error}}}if(i)throw new no(i)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)co(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(r=this._finalizers)&&void 0!==r?r:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&io(t,e)},e.prototype.remove=function(t){var r=this._finalizers;r&&io(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}(),so=oo.EMPTY;function ao(e){return e instanceof oo||e&&"closed"in e&&to(e.remove)&&to(e.add)&&to(e.unsubscribe)}function co(e){to(e)?e():e.unsubscribe()}var lo={Promise:void 0},uo=function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setTimeout.apply(void 0,Xi([e,t],Zi(r)))};function fo(e){uo(function(){throw e})}function po(){}function ho(e){e()}var mo=function(e){function t(t){var r=e.call(this)||this;return r.isStopped=!1,t?(r.destination=t,ao(t)&&t.add(r)):r.destination=Eo,r}return Wi(t,e),t.create=function(e,t,r){return new vo(e,t,r)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(oo),go=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){yo(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){yo(e)}else yo(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){yo(e)}},e}(),vo=function(e){function t(t,r,n){var i,o=e.call(this)||this;return i=to(t)||!t?{next:null!=t?t:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:t,o.destination=new go(i),o}return Wi(t,e),t}(mo);function yo(e){fo(e)}var Eo={closed:!0,next:po,error:function(e){throw e},complete:po},bo="function"==typeof Symbol&&Symbol.observable||"@@observable";function wo(e){return e}var Lo=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(e,t,r){var n,i=this,o=(n=e)&&n instanceof mo||function(e){return e&&to(e.next)&&to(e.error)&&to(e.complete)}(n)&&ao(n)?e:new vo(e,t,r);return ho(function(){var e=i,t=e.operator,r=e.source;o.add(t?t.call(o,r):r?i._subscribe(o):i._trySubscribe(o))}),o},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var r=this;return new(t=So(t))(function(t,n){var i=new vo({next:function(t){try{e(t)}catch(e){n(e),i.unsubscribe()}},error:n,complete:t});r.subscribe(i)})},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[bo]=function(){return this},e.prototype.pipe=function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return(0===(e=t).length?wo:1===e.length?e[0]:function(t){return e.reduce(function(e,t){return t(e)},t)})(this)},e.prototype.toPromise=function(e){var t=this;return new(e=So(e))(function(e,r){var n;t.subscribe(function(e){return n=e},function(e){return r(e)},function(){return e(n)})})},e.create=function(t){return new e(t)},e}();function So(e){var t;return null!==(t=null!=e?e:lo.Promise)&&void 0!==t?t:Promise}function Co(e){return function(t){if(function(e){return to(null==e?void 0:e.lift)}(t))return t.lift(function(t){try{return e(t,this)}catch(e){this.error(e)}});throw new TypeError("Unable to lift unknown Observable type")}}function Io(e,t,r,n,i){return new Do(e,t,r,n,i)}var Do=function(e){function t(t,r,n,i,o,s){var a=e.call(this,t)||this;return a.onFinalize=o,a.shouldUnsubscribe=s,a._next=r?function(e){try{r(e)}catch(e){t.error(e)}}:e.prototype._next,a._error=i?function(e){try{i(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,a._complete=n?function(){try{n()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,a}return Wi(t,e),t.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;e.prototype.unsubscribe.call(this),!r&&(null===(t=this.onFinalize)||void 0===t||t.call(this))}},t}(mo),_o=ro(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Oo=function(e){function t(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return Wi(t,e),t.prototype.lift=function(e){var t=new No(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new _o},t.prototype.next=function(e){var t=this;ho(function(){var r,n;if(t._throwIfClosed(),!t.isStopped){t.currentObservers||(t.currentObservers=Array.from(t.observers));try{for(var i=Ki(t.currentObservers),o=i.next();!o.done;o=i.next()){o.value.next(e)}}catch(e){r={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}}})},t.prototype.error=function(e){var t=this;ho(function(){if(t._throwIfClosed(),!t.isStopped){t.hasError=t.isStopped=!0,t.thrownError=e;for(var r=t.observers;r.length;)r.shift().error(e)}})},t.prototype.complete=function(){var e=this;ho(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var t=e.observers;t.length;)t.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return(null===(e=this.observers)||void 0===e?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,r=this,n=r.hasError,i=r.isStopped,o=r.observers;return n||i?so:(this.currentObservers=null,o.push(e),new oo(function(){t.currentObservers=null,io(o,e)}))},t.prototype._checkFinalizedStatuses=function(e){var t=this,r=t.hasError,n=t.thrownError,i=t.isStopped;r?e.error(n):i&&e.complete()},t.prototype.asObservable=function(){var e=new Lo;return e.source=this,e},t.create=function(e,t){return new No(e,t)},t}(Lo),No=function(e){function t(t,r){var n=e.call(this)||this;return n.destination=t,n.source=r,n}return Wi(t,e),t.prototype.next=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===r||r.call(t,e)},t.prototype.error=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===r||r.call(t,e)},t.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},t.prototype._subscribe=function(e){var t,r;return null!==(r=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==r?r:so},t}(Oo),Ao=function(e){function t(t){var r=e.call(this)||this;return r._value=t,r}return Wi(t,e),Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(t){var r=e.prototype._subscribe.call(this,t);return!r.closed&&t.next(this._value),r},t.prototype.getValue=function(){var e=this,t=e.hasError,r=e.thrownError,n=e._value;if(t)throw r;return this._throwIfClosed(),n},t.prototype.next=function(t){e.prototype.next.call(this,this._value=t)},t}(Oo),Po={now:function(){return(Po.delegate||Date).now()},delegate:void 0},To=function(e){function t(t,r,n){void 0===t&&(t=1/0),void 0===r&&(r=1/0),void 0===n&&(n=Po);var i=e.call(this)||this;return i._bufferSize=t,i._windowTime=r,i._timestampProvider=n,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=r===1/0,i._bufferSize=Math.max(1,t),i._windowTime=Math.max(1,r),i}return Wi(t,e),t.prototype.next=function(t){var r=this,n=r.isStopped,i=r._buffer,o=r._infiniteTimeWindow,s=r._timestampProvider,a=r._windowTime;n||(i.push(t),!o&&i.push(s.now()+a)),this._trimBuffer(),e.prototype.next.call(this,t)},t.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var t=this._innerSubscribe(e),r=this._infiniteTimeWindow,n=this._buffer.slice(),i=0;i<n.length&&!e.closed;i+=r?1:2)e.next(n[i]);return this._checkFinalizedStatuses(e),t},t.prototype._trimBuffer=function(){var e=this,t=e._bufferSize,r=e._timestampProvider,n=e._buffer,i=e._infiniteTimeWindow,o=(i?1:2)*t;if(t<1/0&&o<n.length&&n.splice(0,n.length-o),!i){for(var s=r.now(),a=0,c=1;c<n.length&&n[c]<=s;c+=2)a=c;a&&n.splice(0,a+1)}},t}(Oo),Ro=function(e){function t(t,r){return e.call(this)||this}return Wi(t,e),t.prototype.schedule=function(e,t){return this},t}(oo),xo=function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setInterval.apply(void 0,Xi([e,t],Zi(r)))},$o=function(e){return clearInterval(e)},Fo=function(e){function t(t,r){var n=e.call(this,t,r)||this;return n.scheduler=t,n.work=r,n.pending=!1,n}return Wi(t,e),t.prototype.schedule=function(e,t){var r;if(void 0===t&&(t=0),this.closed)return this;this.state=e;var n=this.id,i=this.scheduler;return null!=n&&(this.id=this.recycleAsyncId(i,n,t)),this.pending=!0,this.delay=t,this.id=null!==(r=this.id)&&void 0!==r?r:this.requestAsyncId(i,this.id,t),this},t.prototype.requestAsyncId=function(e,t,r){return void 0===r&&(r=0),xo(e.flush.bind(e,this),r)},t.prototype.recycleAsyncId=function(e,t,r){if(void 0===r&&(r=0),null!=r&&this.delay===r&&!1===this.pending)return t;null!=t&&$o(t)},t.prototype.execute=function(e,t){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var r=this._execute(e,t);if(r)return r;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,t){var r,n=!1;try{this.work(e)}catch(e){n=!0,r=e||new Error("Scheduled action threw falsy error")}if(n)return this.unsubscribe(),r},t.prototype.unsubscribe=function(){if(!this.closed){var t=this.id,r=this.scheduler,n=r.actions;this.work=this.state=this.scheduler=null,this.pending=!1,io(n,this),null!=t&&(this.id=this.recycleAsyncId(r,t,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(Ro),Uo=function(){function e(t,r){void 0===r&&(r=e.now),this.schedulerActionCtor=t,this.now=r}return e.prototype.schedule=function(e,t,r){return void 0===t&&(t=0),new this.schedulerActionCtor(this,e).schedule(r,t)},e.now=Po.now,e}(),ko=function(e){function t(t,r){void 0===r&&(r=Uo.now);var n=e.call(this,t,r)||this;return n.actions=[],n._active=!1,n}return Wi(t,e),t.prototype.flush=function(e){var t=this.actions;if(this._active)t.push(e);else{var r;this._active=!0;do{if(r=e.execute(e.state,e.delay))break}while(e=t.shift());if(this._active=!1,r){for(;e=t.shift();)e.unsubscribe();throw r}}},t}(Uo),Bo=new ko(Fo),Mo=Bo,Go=new Lo(function(e){return e.complete()});function jo(e){return e&&to(e.schedule)}function zo(e){return e[e.length-1]}var Ho=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e};function Wo(e){return to(null==e?void 0:e.then)}function Vo(e){return to(e[bo])}function qo(e){return Symbol.asyncIterator&&to(null==e?void 0:e[Symbol.asyncIterator])}function Yo(e){return new TypeError("You provided "+(null!==e&&"object"==typeof e?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}var Ko="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function Zo(e){return to(null==e?void 0:e[Ko])}function Xo(e){return Qi(this,arguments,function(){var t,r,n;return Yi(this,function(i){switch(i.label){case 0:t=e.getReader(),i.label=1;case 1:i.trys.push([1,,9,10]),i.label=2;case 2:return[4,Ji(t.read())];case 3:return r=i.sent(),n=r.value,r.done?[4,Ji(void 0)]:[3,5];case 4:return[2,i.sent()];case 5:return[4,Ji(n)];case 6:return[4,i.sent()];case 7:return i.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})})}function Jo(e){return to(null==e?void 0:e.getReader)}function Qo(e){if(e instanceof Lo)return e;if(null!=e){if(Vo(e))return i=e,new Lo(function(e){var t=i[bo]();if(to(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")});if(Ho(e))return n=e,new Lo(function(e){for(var t=0;t<n.length&&!e.closed;t++)e.next(n[t]);e.complete()});if(Wo(e))return r=e,new Lo(function(e){r.then(function(t){e.closed||(e.next(t),e.complete())},function(t){return e.error(t)}).then(null,fo)});if(qo(e))return es(e);if(Zo(e))return t=e,new Lo(function(e){var r,n;try{for(var i=Ki(t),o=i.next();!o.done;o=i.next()){var s=o.value;if(e.next(s),e.closed)return}}catch(e){r={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}e.complete()});if(Jo(e))return es(Xo(e))}var t,r,n,i;throw Yo(e)}function es(e){return new Lo(function(t){(function(e,t){var r,n,i,o;return qi(this,void 0,void 0,function(){var s,a;return Yi(this,function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),r=eo(e),c.label=1;case 1:return[4,r.next()];case 2:if((n=c.sent()).done)return[3,4];if(s=n.value,t.next(s),t.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=c.sent(),i={error:a},[3,11];case 6:return c.trys.push([6,,9,10]),n&&!n.done&&(o=r.return)?[4,o.call(r)]:[3,8];case 7:c.sent(),c.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})})(e,t).catch(function(e){return t.error(e)})})}function ts(e,t,r,n,i){void 0===n&&(n=0),void 0===i&&(i=!1);var o=t.schedule(function(){r(),i?e.add(this.schedule(null,n)):this.unsubscribe()},n);if(e.add(o),!i)return o}function rs(e,t){return void 0===t&&(t=0),Co(function(r,n){r.subscribe(Io(n,function(r){return ts(n,e,function(){return n.next(r)},t)},function(){return ts(n,e,function(){return n.complete()},t)},function(r){return ts(n,e,function(){return n.error(r)},t)}))})}function ns(e,t){return void 0===t&&(t=0),Co(function(r,n){n.add(e.schedule(function(){return r.subscribe(n)},t))})}function is(e,t){if(!e)throw new Error("Iterable cannot be null");return new Lo(function(r){ts(r,t,function(){var n=e[Symbol.asyncIterator]();ts(r,t,function(){n.next().then(function(e){e.done?r.complete():r.next(e.value)})},0,!0)})})}function os(e,t){if(null!=e){if(Vo(e))return function(e,t){return Qo(e).pipe(ns(t),rs(t))}(e,t);if(Ho(e))return function(e,t){return new Lo(function(r){var n=0;return t.schedule(function(){n===e.length?r.complete():(r.next(e[n++]),r.closed||this.schedule())})})}(e,t);if(Wo(e))return function(e,t){return Qo(e).pipe(ns(t),rs(t))}(e,t);if(qo(e))return is(e,t);if(Zo(e))return function(e,t){return new Lo(function(r){var n;return ts(r,t,function(){n=e[Ko](),ts(r,t,function(){var e,t,i;try{t=(e=n.next()).value,i=e.done}catch(e){return void r.error(e)}i?r.complete():r.next(t)},0,!0)}),function(){return to(null==n?void 0:n.return)&&n.return()}})}(e,t);if(Jo(e))return function(e,t){return is(Xo(e),t)}(e,t)}throw Yo(e)}function ss(e,t){return t?os(e,t):Qo(e)}function as(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=function(e){return jo(zo(e))?e.pop():void 0}(e);return ss(e,r)}var cs=ro(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function ls(e,t){var r="object"==typeof t;return new Promise(function(n,i){var o,s=!1;e.subscribe({next:function(e){o=e,s=!0},error:i,complete:function(){s?n(o):r?n(t.defaultValue):i(new cs)}})})}function us(e,t){var r="object"==typeof t;return new Promise(function(n,i){var o=new vo({next:function(e){n(e),o.unsubscribe()},error:i,complete:function(){r?n(t.defaultValue):i(new cs)}});e.subscribe(o)})}function fs(e){return e instanceof Date&&!isNaN(e)}var ps=ro(function(e){return function(t){void 0===t&&(t=null),e(this),this.message="Timeout has occurred",this.name="TimeoutError",this.info=t}});function hs(e){throw new ps(e)}function ds(e,t){return Co(function(r,n){var i=0;r.subscribe(Io(n,function(r){n.next(e.call(t,r,i++))}))})}var ms=Array.isArray;function gs(e){return ds(function(t){return function(e,t){return ms(t)?e.apply(void 0,Xi([],Zi(t))):e(t)}(e,t)})}function vs(e,t,r,n,i,o,s,a){var c=[],l=0,u=0,f=!1,p=function(){!f||c.length||l||t.complete()},h=function(e){return l<n?d(e):c.push(e)},d=function(e){o&&t.next(e),l++;var a=!1;Qo(r(e,u++)).subscribe(Io(t,function(e){null==i||i(e),o?h(e):t.next(e)},function(){a=!0},void 0,function(){if(a)try{l--;for(var e=function(){var e=c.shift();s||d(e)};c.length&&l<n;)e();p()}catch(e){t.error(e)}}))};return e.subscribe(Io(t,h,function(){f=!0,p()})),function(){null==a||a()}}function ys(e,t,r){return void 0===r&&(r=1/0),to(t)?ys(function(r,n){return ds(function(e,i){return t(r,e,n,i)})(Qo(e(r,n)))},r):("number"==typeof t&&(r=t),Co(function(t,n){return vs(t,n,e,r)}))}var Es=["addListener","removeListener"],bs=["addEventListener","removeEventListener"],ws=["on","off"];function Ls(e,t,r,n){if(to(r)&&(n=r,r=void 0),n)return Ls(e,t,r).pipe(gs(n));var i=Zi(function(e){return to(e.addEventListener)&&to(e.removeEventListener)}(e)?bs.map(function(n){return function(i){return e[n](t,i,r)}}):function(e){return to(e.addListener)&&to(e.removeListener)}(e)?Es.map(Ss(e,t)):function(e){return to(e.on)&&to(e.off)}(e)?ws.map(Ss(e,t)):[],2),o=i[0],s=i[1];if(!o&&Ho(e))return ys(function(e){return Ls(e,t,r)})(Qo(e));if(!o)throw new TypeError("Invalid event target");return new Lo(function(e){var t=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return e.next(1<t.length?t:t[0])};return o(t),function(){return s(t)}})}function Ss(e,t){return function(r){return function(n){return e[r](t,n)}}}function Cs(e,t,r){void 0===e&&(e=0),void 0===r&&(r=Mo);var n=-1;return null!=t&&(jo(t)?r=t:n=t),new Lo(function(t){var i=fs(e)?+e-r.now():e;i<0&&(i=0);var o=0;return r.schedule(function(){t.closed||(t.next(o++),0<=n?this.schedule(void 0,n):t.complete())},i)})}function Is(e,t){return Co(function(r,n){var i=0;r.subscribe(Io(n,function(r){return e.call(t,r,i++)&&n.next(r)}))})}function Ds(e){return Co(function(t,r){var n,i=null,o=!1;i=t.subscribe(Io(r,void 0,void 0,function(s){n=Qo(e(s,Ds(e)(t))),i?(i.unsubscribe(),i=null,n.subscribe(r)):o=!0})),o&&(i.unsubscribe(),i=null,n.subscribe(r))})}function _s(e,t,r,n,i){return function(o,s){var a=r,c=t,l=0;o.subscribe(Io(s,function(t){var r=l++;c=a?e(c,t,r):(a=!0,t),n&&s.next(c)},i&&function(){a&&s.next(c),s.complete()}))}}function Os(e,t){return Co(_s(e,t,arguments.length>=2,!1,!0))}function Ns(e,t){return void 0===t&&(t=wo),e=null!=e?e:As,Co(function(r,n){var i,o=!0;r.subscribe(Io(n,function(r){var s=t(r);!o&&e(i,s)||(o=!1,i=s,n.next(r))}))})}function As(e,t){return e===t}function Ps(e){return void 0===e&&(e=Ts),Co(function(t,r){var n=!1;t.subscribe(Io(r,function(e){n=!0,r.next(e)},function(){return n?r.complete():r.error(e())}))})}function Ts(){return new cs}function Rs(e){return Co(function(t,r){try{t.subscribe(r)}finally{r.add(e)}})}function xs(e,t){var r=arguments.length>=2;return function(e){return e.pipe(wo,(n=1)<=0?function(){return Go}:Co(function(e,t){var r=[];e.subscribe(Io(t,function(e){r.push(e),n<r.length&&r.shift()},function(){var e,n;try{for(var i=Ki(r),o=i.next();!o.done;o=i.next()){var s=o.value;t.next(s)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}t.complete()},void 0,function(){r=null}))}),r?function(e){return Co(function(t,r){var n=!1;t.subscribe(Io(r,function(e){n=!0,r.next(e)},function(){n||r.next(e),r.complete()}))})}(t):Ps(function(){return new cs}));var n}}function $s(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];if(!0!==t){if(!1!==t){var i=new vo({next:function(){i.unsubscribe(),e()}});return Qo(t.apply(void 0,Xi([],Zi(r)))).subscribe(i)}}else e()}function Fs(e,t){return Co(function(r,n){var i=null,o=0,s=!1,a=function(){return s&&!i&&n.complete()};r.subscribe(Io(n,function(r){null==i||i.unsubscribe();var s=0,c=o++;Qo(e(r,c)).subscribe(i=Io(n,function(e){return n.next(t?t(r,e,c,s++):e)},function(){i=null,a()}))},function(){s=!0,a()}))})}function Us(e){return Co(function(t,r){Qo(e).subscribe(Io(r,function(){return r.complete()},po)),!r.closed&&t.subscribe(r)})}function ks(e,t,r){var n=to(e)||t||r?{next:e,error:t,complete:r}:e;return n?Co(function(e,t){var r;null===(r=n.subscribe)||void 0===r||r.call(n);var i=!0;e.subscribe(Io(t,function(e){var r;null===(r=n.next)||void 0===r||r.call(n,e),t.next(e)},function(){var e;i=!1,null===(e=n.complete)||void 0===e||e.call(n),t.complete()},function(e){var r;i=!1,null===(r=n.error)||void 0===r||r.call(n,e),t.error(e)},function(){var e,t;i&&(null===(e=n.unsubscribe)||void 0===e||e.call(n)),null===(t=n.finalize)||void 0===t||t.call(n)}))}):wo}function Bs(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r,n=to(zo(r=e))?r.pop():void 0;return Co(function(t,r){for(var i=e.length,o=new Array(i),s=e.map(function(){return!1}),a=!1,c=function(t){Qo(e[t]).subscribe(Io(r,function(e){o[t]=e,a||s[t]||(s[t]=!0,(a=s.every(wo))&&(s=null))},po))},l=0;l<i;l++)c(l);t.subscribe(Io(r,function(e){if(a){var t=Xi([e],Zi(o));r.next(n?n.apply(void 0,Xi([],Zi(t))):t)}}))})}const Ms=(e,t,r)=>{const n="string"==typeof t?t.split("."):t,i=n.shift();return i&&(e[i]??={},n.length?Ms(e[i],n,r):Object.assign(e,{[i]:r})),e};class Gs{#Z={};createConfig(e,t){return ss(this._createConfig(e,t))}async createConfigAsync(e,t){return ls(this.createConfig(e,t))}_set(e,t){const r="function"==typeof t?t:async()=>t;this.#Z[e]=r}_get(e){return this.#Z[e]}_has(e){return e in this.#Z}_createConfig(e,t){return ss(this._buildConfig(e,t)).pipe(Fs(t=>this._processConfig(t,e)))}_buildConfig(e,t){return ss(Object.entries(this.#Z)).pipe(ys(([t,r])=>ss(r(e)).pipe(Is(e=>void 0!==e),ds(e=>({target:t,value:e})),Ds(e=>(console.error(`Failed to execute config callback: ${r.name} for attribute: '${t}'`,e),Go)))),Os((e,{target:t,value:r})=>Ms(e,t,r),t??{}))}_processConfig(e,t){return as(e)}}class js{#X;#J;get version(){return this.#X}constructor(e){const{version:t}=e;this.#X=new Gi(t),this.#J=new oo}_addTeardown(e){return this.#J.add(e),()=>this.#J.remove(e)}dispose(){this.#J.unsubscribe()}}class zs extends Error{constructor(){super("It was too slow"),this.name="RequiredModuleTimeoutError"}}class Hs{logger=new zi("ModulesConfigurator");_configs=[];_afterConfiguration=[];_afterInit=[];_modules;constructor(e){this._modules=new Set(e)}get modules(){return[...this._modules]}configure(...e){for(const t of e)this.addConfig(t)}addConfig(e){const{module:t,afterConfig:r,afterInit:n,configure:i}=e;this._modules.add(t),i&&this._configs.push((e,r)=>i(e[t.name],r)),r&&this._afterConfiguration.push(e=>r(e[t.name])),n&&this._afterInit.push(e=>n(e[t.name]))}onConfigured(e){this._afterConfiguration.push(e)}onInitialized(e){this._afterInit.push(e)}async initialize(e){const t=await this._configure(e),r=await this._initialize(t,e);return await this._postInitialize(r,e),Object.seal(Object.assign({},r,{dispose:()=>this.dispose(r)}))}async _configure(e){const t=await this._createConfig(e);return await Promise.all(this._configs.map(r=>Promise.resolve(r(t,e)))),await this._postConfigure(t),t}_createConfig(e){const{modules:t,logger:r,_afterConfiguration:n,_afterInit:i}=this,o=ss(t).pipe(ys(async t=>{r.debug(`🛠 creating configurator ${r.formatModuleName(t)}`);try{const n=await(t.configure?.(e));return r.debug(`🛠 created configurator for ${r.formatModuleName(t)}`,n),{[t.name]:n}}catch(e){throw r.error(`🛠 Failed to created configurator for ${r.formatModuleName(t)}`,e),e}}),Os((e,t)=>Object.assign(e,t),{onAfterConfiguration(e){n.push(e)},onAfterInit(e){i.push(e)}}));return ls(o)}async _postConfigure(e){const{modules:t,logger:r,_afterConfiguration:n}=this;if(await Promise.allSettled(t.filter(e=>!!e.postConfigure).map(async t=>{try{await(t.postConfigure?.(e)),r.debug(`🏗📌 post configured ${r.formatModuleName(t)}`,t)}catch(e){r.warn(`🏗📌 post configure failed ${r.formatModuleName(t)}`)}})),n.length)try{r.debug(`🏗📌 post configure hooks [${n.length}]`),await Promise.allSettled(n.map(t=>Promise.resolve(t(e)))),r.debug("🏗📌 post configure hooks complete")}catch(e){r.warn("🏗📌 post configure hook failed",e)}}async _initialize(e,t){const{modules:r,logger:n}=this,i=r.map(e=>e.name),o=new Ao({}),s=e=>i.includes(e),a=(e,t=60)=>{if(!i.includes(e))throw n.error(`🚀⌛️ Cannot not require ${n.formatModuleName(String(e))} since module is not defined!`),Error(`cannot not require [${String(e)}] since module is not defined!`);return o.value[e]?(n.debug(`🚀⌛️ ${n.formatModuleName(String(e))} is initiated, skipping queue`),Promise.resolve(o.value[e])):(n.debug(`🚀⌛️ Awaiting init ${n.formatModuleName(String(e))}, timeout ${t}s`),us(o.pipe(Is(t=>!!t[e]),ds(t=>t[e]),function(e){var t=fs(e)?{first:e}:"number"==typeof e?{each:e}:e,r=t.first,n=t.each,i=t.with,o=void 0===i?hs:i,s=t.scheduler,a=void 0===s?Bo:s,c=t.meta,l=void 0===c?null:c;if(null==r&&null==n)throw new TypeError("No timeout provided.");return Co(function(e,t){var i,s,c=null,u=0,f=function(e){s=ts(t,a,function(){try{i.unsubscribe(),Qo(o({meta:l,lastValue:c,seen:u})).subscribe(t)}catch(e){t.error(e)}},e)};i=e.subscribe(Io(t,function(e){null==s||s.unsubscribe(),u++,t.next(c=e),n>0&&f(n)},void 0,void 0,function(){(null==s?void 0:s.closed)||null==s||s.unsubscribe(),c=null})),!u&&f(null!=r?"number"==typeof r?r:+r-a.now():n)})}({each:1e3*t,with:()=>{return t=to(e=()=>new zs)?e:function(){return e},new Lo(function(e){return e.error(t())});var e,t}}))))};ss(r).pipe(ys(r=>{const i=r.name;return n.debug(`🚀 initializing ${n.formatModuleName(r)}`),ss(Promise.resolve(r.initialize({ref:t,config:e[i],requireInstance:a,hasModule:s}))).pipe(ds(e=>{if(!(e instanceof js||e.version instanceof Gi)){n.debug("🤷 module does not extends the [BaseModuleProvider] or exposes [SemanticVersion]");try{e.version=r.version instanceof Gi?r.version:new Gi(r.version??"0.0.0-unknown")}catch(e){n.error("🚨 failed to set module version")}}return n.debug(`🚀 initialized ${n.formatModuleName(r)}`),[i,e]}))})).subscribe({next:([e,t])=>{o.next(Object.assign(o.value,{[e]:t}))},error:e=>{n.error("🚨 failed to initialize",e),o.error(e)},complete:()=>o.complete()});const c=await ls(o);return Object.seal(c),c}async _postInitialize(e,t){const{modules:r,logger:n,_afterInit:i}=this,o=ss(r).pipe(Is(e=>!!e.postInitialize),ks(e=>n.debug(`🚀📌 post initializing moule ${n.formatModuleName(e)}`)),ys(r=>ss(r.postInitialize({ref:t,modules:e,instance:e[r.name]})).pipe(ks(()=>{n.debug(`🚀📌 post initialized moule ${n.formatModuleName(r)}`)}),Ds(e=>(n.warn(`🚀📌 post initialize failed moule ${n.formatModuleName(r)}`,e),Go)))));if(await new Promise((e,t)=>{o.subscribe({complete:()=>e(!0),error:t})}),i.length)try{n.debug(`🚀📌 post configure hooks [${i.length}]`),await Promise.allSettled(i.map(t=>Promise.resolve(t(e)))),n.debug("🚀📌 post configure hooks complete")}catch(e){n.warn("🚀📌 post configure hook failed",e)}n.debug(`🎉 Modules initialized ${r.map(n.formatModuleName)}`,e),n.info("🟢 Modules initialized")}async dispose(e,t){const{modules:r}=this;await Promise.allSettled(r.filter(e=>!!e.dispose).map(async r=>{await(r.dispose?.({ref:t,modules:e,instance:e[r.name]}))}))}}class Ws{_operators;get operators(){return this._operators}constructor(e){this._operators=e&&"operators"in e?{...e.operators}:e??{}}add(e,t){if(Object.keys(this._operators).includes(e))throw Error(`Operator [${e}] already defined`);return this.set(e,t)}set(e,t){return this._operators[e]=t,this}remove(e){return delete this._operators[e],this}get(e){return this._operators[e]}process(e){return Object.values(this._operators).length?ss(Object.values(this._operators)).pipe((t=(e,t)=>Promise.resolve(t(e)).then(t=>t??e),r=e,n=1,Co(function(e,i){var o=r;return vs(e,i,function(e,r){return t(o,e,r)},n,function(e){o=e},!1,void 0,function(){return o=null})})),xs()):as(e);var t,r,n}}class Vs extends Ws{setHeader(e,t){const r=((e,t)=>r=>{const n=new Headers(r.headers);return n.append(e,t),{...r,headers:n}})(e,t);return this.set("header-"+e,r)}}class qs extends Ws{}const Ys=()=>A.string().refine(e=>e===e?.toUpperCase(),{message:["Provided HTTP method must be in uppercase.","See RFC 7231 Section 4.1 for more information","https://www.rfc-editor.org/rfc/rfc7231#section-4.1"].join(" ")}),Ks=A.object({attributionReporting:A.object({eventSourceEligible:A.boolean().optional(),triggerEligible:A.boolean().optional()}).optional(),body:A.union([A.string(),A.instanceof(Blob),A.instanceof(ArrayBuffer),A.instanceof(FormData),A.instanceof(URLSearchParams),A.instanceof(ReadableStream)]).optional(),browsingTopics:A.boolean().optional(),cache:A.enum(["default","no-store","reload","no-cache","force-cache","only-if-cached"]).optional(),credentials:A.enum(["omit","same-origin","include"]).optional(),headers:A.record(A.string(),A.string()).optional().or(A.instanceof(Headers)),integrity:A.string().optional(),keepalive:A.boolean().optional(),method:Ys().pipe(A.enum(["GET","POST","PUT","DELETE","PATCH","OPTIONS","HEAD","CONNECT","TRACE"],{message:"Invalid request method. Expected one of: GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD, CONNECT, TRACE. See RFC 2615 Section 9 for more information: https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html"})).optional(),mode:A.enum(["same-origin","cors","no-cors","navigate","websocket"]).optional(),priority:A.enum(["low","high","auto"]).optional(),redirect:A.enum(["follow","error","manual"]).optional(),referrer:A.string().optional(),referrerPolicy:A.enum(["no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"]).optional(),signal:A.instanceof(AbortSignal).optional()}).extend({uri:A.string(),path:A.string().optional()}),Zs=e=>e=>{const{error:t,success:r,data:n}=Ys().safeParse(e.method);if(e.method=r?n:e.method?.toUpperCase(),t)for(const e of t.issues)console.warn(e.message);return e},Xs=e=>e=>{const{strict:t,parse:r}={},n=t?Ks:Ks.passthrough();try{const t=n.parse(e);return r?t:void 0}catch(e){if(r)throw e;console.error("Invalid request options",e.message)}};class Js{_clients={};get clients(){return{...this._clients}}defaultHttpClientCtor;defaultHttpRequestHandler=new Vs({"capitalize-method":Zs(),"request-validation":Xs()});constructor(e){this.defaultHttpClientCtor=e}hasClient(e){return Object.keys(this._clients).includes(e)}configureClient(e,t){const r="string"==typeof t?{baseUri:t}:t,n="function"==typeof r?{onCreate:r}:r;return this._clients[e]={...this._clients[e],...n},this}}class Qs extends Error{}class ea{config;get defaultHttpRequestHandler(){return this.config.defaultHttpRequestHandler}constructor(e){this.config=e}hasClient(e){return Object.keys(this.config.clients).includes(e)}createClient(e){const t=this._resolveConfig(e),{baseUri:r,defaultScopes:n=[],onCreate:i,ctor:o=this.config.defaultHttpClientCtor,requestHandler:s=this.defaultHttpRequestHandler}=t,a=new o(r||"",{requestHandler:s});return Object.assign(a,{defaultScopes:n}),i?.(a),a}createCustomClient(e){return this.createClient(e)}_resolveConfig(e){if("string"==typeof e){const r=this.config.clients[e];if(!r&&(t=e,new RegExp("^(https?:\\/\\/)?((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.?)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*(\\?[;&a-z\\d%_.~+=-]*)?(\\#[-a-z\\d_]*)?$","i").test(t)))return{baseUri:e};if(!r)throw new Qs(`No registered http client for key [${e}]`);return r}var t;return e}}function ta(e,t){void 0===t&&(t={});var r=t.selector,n=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r}(t,["selector"]);return new Lo(function(t){var i=new AbortController,o=i.signal,s=!0,a=n.signal;if(a)if(a.aborted)i.abort();else{var c=function(){o.aborted||i.abort()};a.addEventListener("abort",c),t.add(function(){return a.removeEventListener("abort",c)})}var l=Vi(Vi({},n),{signal:o}),u=function(e){s=!1,t.error(e)};return fetch(e,l).then(function(e){r?Qo(r(e)).subscribe(Io(t,void 0,function(){s=!1,t.complete()},u)):(s=!1,t.next(e),t.complete())}).catch(u),function(){s&&i.abort()}})}const ra=async e=>{if(204===e.status)return Promise.resolve();try{const t=await e.json();if(!e.ok)throw new sn("network response was not OK",e,{data:t});return t}catch(t){if(t instanceof sn)throw t;throw new sn("failed to parse response",e,{cause:t})}},na=async e=>{if(!e.ok)throw new Error("network response was not OK");if(204===e.status)throw new Error("no content");const t=e.headers.get("content-disposition")?.split(";").find(e=>e.includes("filename="))?.replace("filename=","")?.trim();try{return{filename:t,blob:await e.blob()}}catch(e){throw Error("failed to parse response")}},ia=e=>{try{return JSON.parse(e)}catch{return e}};function*oa(e,t){const r=e.split("\n\n"),n=t?.dataParser||ia;for(const e of r){if(!e.trim())continue;const t=e.split("\n").reduce((e,t)=>{if(!t)return e;const r=t.indexOf(":");if(-1===r)return e;const i=t.slice(0,r).trim(),o=t.slice(r+1).trim();return"data"===i?e.data=n(o):e[i]=o,e},{});Object.keys(t).length&&(yield t)}}const sa=e=>t=>{if(!t.ok)throw new an(`HTTP error! Status: ${t.status}`,t);if(!t.body)throw new an("Response body is not readable",t);if(!t.headers.get("Content-Type")?.includes("text/event-stream"))throw new an("Response is not a text/event-stream",t);const r=t.body.getReader();return ss(async function*(e,t){const r=!!t?.skipHeartbeats,n=t?.eventFilter?Array.isArray(t.eventFilter)?t.eventFilter:[t.eventFilter]:null,i=new TextDecoder;for(;;){const{done:o,value:s}=await e.read();if(o)break;const a=oa(i.decode(s,{stream:!0}),{dataParser:t?.dataParser});for(const e of a)if(e.retry)await new Promise(t=>setTimeout(t,Number.parseInt(e.retry??"300",10)));else{if(r){if(!e.event&&!e.data&&!e.id)continue;if(e.event&&["heartbeat","ping"].includes(e.event))continue}(!n||e.event&&n.includes(e.event))&&(yield e)}}}(r,{dataParser:e?.dataParser,skipHeartbeats:e?.skipHeartbeats,eventFilter:e?.eventFilter})).pipe(Us(e?.abortSignal?Ls(e.abortSignal,"abort"):Go),Rs(async()=>{await r.cancel().catch(()=>{}),r.releaseLock()}))};class aa{uri;requestHandler;responseHandler;_request$=new Oo;_response$=new Oo;_abort$=new Oo;get request$(){return this._request$.asObservable()}get response$(){return this._response$.asObservable()}constructor(e,t){this.uri=e,this.requestHandler=new Vs(t?.requestHandler),this.responseHandler=new qs(t?.responseHandler),this._init()}_init(){}fetch$(e,t){return this._fetch$(e,t)}fetch(e,t){return us(this.fetch$(e,t))}fetchAsync(e,t){return this.fetch(e,t)}json$(e,t){const r="object"==typeof t?.body?JSON.stringify(t?.body):t?.body,n=t?.selector??ra,i=new Headers(t?.headers);return i.append("Accept","application/json"),i.append("Content-Type","application/json"),this.fetch$(e,{...t,body:r,selector:n,headers:i})}json(e,t){return us(this.json$(e,t))}blob$(e,t){const r=t?.selector??na,n={...t,selector:r};return this.fetch$(e,n)}blob(e,t){return us(this.blob$(e,t))}sse$(e,t,r){const n=new Headers(t?.headers);n.append("Accept","text/event-stream"),n.append("Content-Type","text/event-stream"),n.append("Cache-Control","no-cache"),n.append("Connection","keep-alive");const i=sa({...r,abortSignal:t?.signal});return this._fetch$(e,{selector:i,...t,headers:n})}jsonAsync(e,t){return this.json(e,t)}execute(e,t,r){return this[e](t,r)}abort(){this._abort$.next()}_fetch$(e,t){const{selector:r,...n}=t||{};return as({...n,uri:this._resolveUrl(e)}).pipe(Fs(e=>this._prepareRequest(e)),ks(e=>this._request$.next(e)),Fs(({uri:e,path:t,...r})=>ta(e,r)),Fs(e=>this._prepareResponse(e)),ks(e=>this._response$.next(e)),Fs(e=>{if(r)try{return r(e)}catch(t){throw new on("failed to execute response selector",e,{cause:t})}return as(e)}),Us(this._abort$))}_prepareRequest(e){return this.requestHandler.process(e)}_prepareResponse(e){return this.responseHandler.process(e)}_resolveUrl(e){const{origin:t,pathname:r}=new URL(this.uri,this.uri.startsWith("http")?void 0:window.location.origin),n=[r,e].join("/").replace(/\/{2,}/g,"/");return new URL(n,t).href}}class ca extends aa{defaultScopes=[];fetch$(e,t){const r=Object.assign(t||{},{scopes:this.defaultScopes.concat(t?.scopes||[])});return super._fetch$(e,r)}}const la={name:"http",configure:()=>new Js(ca),initialize:async({config:e,hasModule:t,requireInstance:r})=>{const n=new ea(e);if(t("auth")){const e=await r("auth");n.defaultHttpRequestHandler.set("MSAL",async t=>{const{scopes:r=[]}=t;if(r.length){const n=await e.acquireAccessToken({scopes:r});if(n){const e=new Headers(t.headers);return e.set("Authorization",`Bearer ${n}`),{...t,headers:e}}}})}return n}},ua=(...e)=>t=>t.pipe(function(e,t){return to(t)?ys(e,t,1):ys(e,1)}(...e)),fa=(...e)=>t=>t.pipe(ys(...e)),pa=(...e)=>t=>t.pipe(Fs(...e)),ha=e=>e.pipe(ds(e=>e.value));var da=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function ma(e){if(!function(e){return"string"==typeof e&&da.test(e)}(e))throw TypeError("Invalid UUID");let t;return Uint8Array.of((t=parseInt(e.slice(0,8),16))>>>24,t>>>16&255,t>>>8&255,255&t,(t=parseInt(e.slice(9,13),16))>>>8,255&t,(t=parseInt(e.slice(14,18),16))>>>8,255&t,(t=parseInt(e.slice(19,23),16))>>>8,255&t,(t=parseInt(e.slice(24,36),16))/1099511627776&255,t/4294967296&255,t>>>24&255,t>>>16&255,t>>>8&255,255&t)}const ga=[];for(let e=0;e<256;++e)ga.push((e+256).toString(16).slice(1));function va(e,t=0){return(ga[e[t+0]]+ga[e[t+1]]+ga[e[t+2]]+ga[e[t+3]]+"-"+ga[e[t+4]]+ga[e[t+5]]+"-"+ga[e[t+6]]+ga[e[t+7]]+"-"+ga[e[t+8]]+ga[e[t+9]]+"-"+ga[e[t+10]]+ga[e[t+11]]+ga[e[t+12]]+ga[e[t+13]]+ga[e[t+14]]+ga[e[t+15]]).toLowerCase()}let ya;const Ea=new Uint8Array(16);function ba(e,t,r,n,i,o){const s="string"==typeof r?function(e){e=unescape(encodeURIComponent(e));const t=new Uint8Array(e.length);for(let r=0;r<e.length;++r)t[r]=e.charCodeAt(r);return t}(r):r,a="string"==typeof n?ma(n):n;if("string"==typeof n&&(n=ma(n)),16!==n?.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let c=new Uint8Array(16+s.length);if(c.set(a),c.set(s,a.length),c=t(c),c[6]=15&c[6]|e,c[8]=63&c[8]|128,i){o=o||0;for(let e=0;e<16;++e)i[o+e]=c[e];return i}return va(c)}var wa={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function La(e,t,r){const n=(e=e||{}).random??e.rng?.()??function(){if(!ya){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");ya=crypto.getRandomValues.bind(crypto)}return ya(Ea)}();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=15&n[6]|64,n[8]=63&n[8]|128,va(n)}function Sa(e,t,r){return wa.randomUUID&&!e?wa.randomUUID():La(e)}function Ca(e,t,r,n){switch(e){case 0:return t&r^~t&n;case 1:case 3:return t^r^n;case 2:return t&r^t&n^r&n}}function Ia(e,t){return e<<t|e>>>32-t}function Da(e){const t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520],n=new Uint8Array(e.length+1);n.set(e),n[e.length]=128;const i=(e=n).length/4+2,o=Math.ceil(i/16),s=new Array(o);for(let t=0;t<o;++t){const r=new Uint32Array(16);for(let n=0;n<16;++n)r[n]=e[64*t+4*n]<<24|e[64*t+4*n+1]<<16|e[64*t+4*n+2]<<8|e[64*t+4*n+3];s[t]=r}s[o-1][14]=8*(e.length-1)/Math.pow(2,32),s[o-1][14]=Math.floor(s[o-1][14]),s[o-1][15]=8*(e.length-1)&4294967295;for(let e=0;e<o;++e){const n=new Uint32Array(80);for(let t=0;t<16;++t)n[t]=s[e][t];for(let e=16;e<80;++e)n[e]=Ia(n[e-3]^n[e-8]^n[e-14]^n[e-16],1);let i=r[0],o=r[1],a=r[2],c=r[3],l=r[4];for(let e=0;e<80;++e){const r=Math.floor(e/20),s=Ia(i,5)+Ca(r,o,a,c)+l+t[r]+n[e]>>>0;l=c,c=a,a=Ia(o,30)>>>0,o=i,i=s}r[0]=r[0]+i>>>0,r[1]=r[1]+o>>>0,r[2]=r[2]+a>>>0,r[3]=r[3]+c>>>0,r[4]=r[4]+l>>>0}return Uint8Array.of(r[0]>>24,r[0]>>16,r[0]>>8,r[0],r[1]>>24,r[1]>>16,r[1]>>8,r[1],r[2]>>24,r[2]>>16,r[2]>>8,r[2],r[3]>>24,r[3]>>16,r[3]>>8,r[3],r[4]>>24,r[4]>>16,r[4]>>8,r[4])}function _a(e,t,r,n){return ba(80,Da,e,t,r,n)}_a.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",_a.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8";class Oa extends Error{type;request;constructor(e,t){super(t.message,{cause:t.cause}),this.type=e,this.name="QueryClientError",this.request=t.request}}var Na=Symbol.for("immer-nothing"),Aa=Symbol.for("immer-draftable"),Pa=Symbol.for("immer-state"),Ta="production"!==process.env.NODE_ENV?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function Ra(e,...t){if("production"!==process.env.NODE_ENV){const r=Ta[e],n="function"==typeof r?r.apply(null,t):r;throw new Error(`[Immer] ${n}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var xa=Object.getPrototypeOf;function $a(e){return!!e&&!!e[Pa]}function Fa(e){return!!e&&(ka(e)||Array.isArray(e)||!!e[Aa]||!!e.constructor?.[Aa]||za(e)||Ha(e))}var Ua=Object.prototype.constructor.toString();function ka(e){if(!e||"object"!=typeof e)return!1;const t=xa(e);if(null===t)return!0;const r=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return r===Object||"function"==typeof r&&Function.toString.call(r)===Ua}function Ba(e,t){0===Ma(e)?Reflect.ownKeys(e).forEach(r=>{t(r,e[r],e)}):e.forEach((r,n)=>t(n,r,e))}function Ma(e){const t=e[Pa];return t?t.type_:Array.isArray(e)?1:za(e)?2:Ha(e)?3:0}function Ga(e,t){return 2===Ma(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function ja(e,t,r){const n=Ma(e);2===n?e.set(t,r):3===n?e.add(r):e[t]=r}function za(e){return e instanceof Map}function Ha(e){return e instanceof Set}function Wa(e){return e.copy_||e.base_}function Va(e,t){if(za(e))return new Map(e);if(Ha(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const r=ka(e);if(!0===t||"class_only"===t&&!r){const t=Object.getOwnPropertyDescriptors(e);delete t[Pa];let r=Reflect.ownKeys(t);for(let n=0;n<r.length;n++){const i=r[n],o=t[i];!1===o.writable&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(t[i]={configurable:!0,writable:!0,enumerable:o.enumerable,value:e[i]})}return Object.create(xa(e),t)}{const t=xa(e);if(null!==t&&r)return{...e};const n=Object.create(t);return Object.assign(n,e)}}function qa(e,t=!1){return Ka(e)||$a(e)||!Fa(e)||(Ma(e)>1&&Object.defineProperties(e,{set:{value:Ya},add:{value:Ya},clear:{value:Ya},delete:{value:Ya}}),Object.freeze(e),t&&Object.values(e).forEach(e=>qa(e,!0))),e}function Ya(){Ra(2)}function Ka(e){return Object.isFrozen(e)}var Za,Xa={};function Ja(e){const t=Xa[e];return t||Ra(0,e),t}function Qa(){return Za}function ec(e,t){t&&(Ja("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function tc(e){rc(e),e.drafts_.forEach(ic),e.drafts_=null}function rc(e){e===Za&&(Za=e.parent_)}function nc(e){return Za={drafts_:[],parent_:Za,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function ic(e){const t=e[Pa];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function oc(e,t){t.unfinalizedDrafts_=t.drafts_.length;const r=t.drafts_[0];return void 0!==e&&e!==r?(r[Pa].modified_&&(tc(t),Ra(4)),Fa(e)&&(e=sc(t,e),t.parent_||cc(t,e)),t.patches_&&Ja("Patches").generateReplacementPatches_(r[Pa].base_,e,t.patches_,t.inversePatches_)):e=sc(t,r,[]),tc(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Na?e:void 0}function sc(e,t,r){if(Ka(t))return t;const n=t[Pa];if(!n)return Ba(t,(i,o)=>ac(e,n,t,i,o,r)),t;if(n.scope_!==e)return t;if(!n.modified_)return cc(e,n.base_,!0),n.base_;if(!n.finalized_){n.finalized_=!0,n.scope_.unfinalizedDrafts_--;const t=n.copy_;let i=t,o=!1;3===n.type_&&(i=new Set(t),t.clear(),o=!0),Ba(i,(i,s)=>ac(e,n,t,i,s,r,o)),cc(e,t,!1),r&&e.patches_&&Ja("Patches").generatePatches_(n,r,e.patches_,e.inversePatches_)}return n.copy_}function ac(e,t,r,n,i,o,s){if("production"!==process.env.NODE_ENV&&i===r&&Ra(5),$a(i)){const s=sc(e,i,o&&t&&3!==t.type_&&!Ga(t.assigned_,n)?o.concat(n):void 0);if(ja(r,n,s),!$a(s))return;e.canAutoFreeze_=!1}else s&&r.add(i);if(Fa(i)&&!Ka(i)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;sc(e,i),t&&t.scope_.parent_||"symbol"==typeof n||!(za(r)?r.has(n):Object.prototype.propertyIsEnumerable.call(r,n))||cc(e,i)}}function cc(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&qa(t,r)}var lc={get(e,t){if(t===Pa)return e;const r=Wa(e);if(!Ga(r,t))return function(e,t,r){const n=pc(t,r);return n?"value"in n?n.value:n.get?.call(e.draft_):void 0}(e,r,t);const n=r[t];return e.finalized_||!Fa(n)?n:n===fc(e.base_,t)?(dc(e),e.copy_[t]=mc(n,e)):n},has:(e,t)=>t in Wa(e),ownKeys:e=>Reflect.ownKeys(Wa(e)),set(e,t,r){const n=pc(Wa(e),t);if(n?.set)return n.set.call(e.draft_,r),!0;if(!e.modified_){const n=fc(Wa(e),t),s=n?.[Pa];if(s&&s.base_===r)return e.copy_[t]=r,e.assigned_[t]=!1,!0;if(((i=r)===(o=n)?0!==i||1/i==1/o:i!=i&&o!=o)&&(void 0!==r||Ga(e.base_,t)))return!0;dc(e),hc(e)}var i,o;return e.copy_[t]===r&&(void 0!==r||t in e.copy_)||Number.isNaN(r)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=r,e.assigned_[t]=!0),!0},deleteProperty:(e,t)=>(void 0!==fc(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,dc(e),hc(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const r=Wa(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:n.enumerable,value:r[t]}:n},defineProperty(){Ra(11)},getPrototypeOf:e=>xa(e.base_),setPrototypeOf(){Ra(12)}},uc={};function fc(e,t){const r=e[Pa];return(r?Wa(r):e)[t]}function pc(e,t){if(!(t in e))return;let r=xa(e);for(;r;){const e=Object.getOwnPropertyDescriptor(r,t);if(e)return e;r=xa(r)}}function hc(e){e.modified_||(e.modified_=!0,e.parent_&&hc(e.parent_))}function dc(e){e.copy_||(e.copy_=Va(e.base_,e.scope_.immer_.useStrictShallowCopy_))}Ba(lc,(e,t)=>{uc[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}}),uc.deleteProperty=function(e,t){return"production"!==process.env.NODE_ENV&&isNaN(parseInt(t))&&Ra(13),uc.set.call(this,e,t,void 0)},uc.set=function(e,t,r){return"production"!==process.env.NODE_ENV&&"length"!==t&&isNaN(parseInt(t))&&Ra(14),lc.set.call(this,e[0],t,r,e[0])};function mc(e,t){const r=za(e)?Ja("MapSet").proxyMap_(e,t):Ha(e)?Ja("MapSet").proxySet_(e,t):function(e,t){const r=Array.isArray(e),n={type_:r?1:0,scope_:t?t.scope_:Qa(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=n,o=lc;r&&(i=[n],o=uc);const{revoke:s,proxy:a}=Proxy.revocable(i,o);return n.draft_=a,n.revoke_=s,a}(e,t);return(t?t.scope_:Qa()).drafts_.push(r),r}function gc(e){if(!Fa(e)||Ka(e))return e;const t=e[Pa];let r;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=Va(e,t.scope_.immer_.useStrictShallowCopy_)}else r=Va(e,!0);return Ba(r,(e,t)=>{ja(r,e,gc(t))}),t&&(t.finalized_=!1),r}var vc=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,t,r)=>{if("function"==typeof e&&"function"!=typeof t){const r=t;t=e;const n=this;return function(e=r,...i){return n.produce(e,e=>t.call(this,e,...i))}}let n;if("function"!=typeof t&&Ra(6),void 0!==r&&"function"!=typeof r&&Ra(7),Fa(e)){const i=nc(this),o=mc(e,void 0);let s=!0;try{n=t(o),s=!1}finally{s?tc(i):rc(i)}return ec(i,r),oc(n,i)}if(!e||"object"!=typeof e){if(n=t(e),void 0===n&&(n=e),n===Na&&(n=void 0),this.autoFreeze_&&qa(n,!0),r){const t=[],i=[];Ja("Patches").generateReplacementPatches_(e,n,t,i),r(t,i)}return n}Ra(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...r)=>this.produceWithPatches(t,t=>e(t,...r));let r,n;return[this.produce(e,t,(e,t)=>{r=e,n=t}),r,n]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){Fa(e)||Ra(8),$a(e)&&(e=function(e){$a(e)||Ra(10,e);return gc(e)}(e));const t=nc(this),r=mc(e,void 0);return r[Pa].isManual_=!0,rc(t),r}finishDraft(e,t){const r=e&&e[Pa];r&&r.isManual_||Ra(9);const{scope_:n}=r;return ec(n,t),oc(void 0,n)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let r;for(r=t.length-1;r>=0;r--){const n=t[r];if(0===n.path.length&&"replace"===n.op){e=n.value;break}}r>-1&&(t=t.slice(r+1));const n=Ja("Patches").applyPatches_;return $a(e)?n(e,t):this.produce(e,e=>n(e,t))}},yc=vc.produce;const Ec=(...e)=>Is(t=>e.includes(t.type));class bc extends Lo{#Q=new Oo;#ee;get action$(){return this.#Q.asObservable()}get value(){return this.#ee.value}get closed(){return this.#ee.closed||this.#Q.closed}constructor(e,t){super(e=>this.#ee.subscribe(e));const r="getInitialState"in e?e.getInitialState():t;this.#ee=new Ao(r),this.#Q.pipe(function(e,t){return Co(_s(e,t,arguments.length>=2,!0))}(e,r),Ns()).subscribe(this.#ee),this.reset=()=>this.#ee.next(r)}reset;next(e){this.#Q.next(e)}select(e,t){return this.#ee.pipe(ds(e),Ns(t))}addEffect(e,t){const r="function"==typeof e?this.action$:Array.isArray(e)?this.action$.pipe(Ec(...e)):this.action$.pipe(Ec(e)),n=t||e;return r.pipe(ys(e=>ss(new Promise((t,r)=>{try{t(n(e,this.value))}catch(e){r(e)}})).pipe(Ds(e=>(console.warn("unhandled effect",e),Go)))),Is(e=>!!e),rs(Bo)).subscribe(this.#Q)}addEpic(e){return this.addFlow(e)}addFlow(e){const t=e(this.action$,this);if(!t)throw new TypeError(`addEpic: one of the provided effects "${e.name||"<anonymous>"}" does not return a stream. Double check you're not missing a return statement!`);return t.pipe(Ds(e=>(console.trace("unhandled exception, epic closed!",e),Go)),rs(Bo)).subscribe(this.#Q)}unsubscribe(){this.#Q.unsubscribe(),this.#ee.unsubscribe()}complete(){this.#Q.complete(),this.#ee.complete()}asObservable(){return this.#ee.asObservable()}}function wc(e,t){function r(...r){if(t){const n=t(...r);if(!n)throw new Error("prepareAction did not return an object");return{type:e,payload:n.payload,..."meta"in n&&{meta:n.meta},..."error"in n&&{error:n.error}}}return{type:e,payload:r[0]}}return r.toString=()=>`${e}`,r.type=e,r.match=t=>t.type===e,r}const Lc="::";function Sc(e,t,r,n){const i=wc([e,"request"].join(Lc),t);return r&&Object.assign(i,{success:wc([e,"success"].join(Lc),r)}),n&&Object.assign(i,{failure:wc([e,"failure"].join(Lc),n)}),i}function Cc(e){return Fa(e)?yc(e,()=>{}):e}function Ic(e,t){const[r,n,i]=function(e){const t={},r=[];let n;const i={addCase(e,o){if("production"!==process.env.NODE_ENV){if(r.length>0)throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");if(n)throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`")}const s="string"==typeof e?e:e.type;if(s in t)throw new Error("addCase cannot be called with two reducers for the same action type");return t[s]=o,i},addMatcher(e,t){if("production"!==process.env.NODE_ENV&&n)throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return r.push({matcher:e,reducer:t}),i},addDefaultCase(e){if("production"!==process.env.NODE_ENV&&n)throw new Error("`builder.addDefaultCase` can only be called once");return n=e,i}};return e(i),[t,r,n]}(t);let o;if("function"==typeof e)o=()=>Cc(e());else{const t=Cc(e);o=()=>t}function s(e,t){let s=[r[t.type],...n.filter(({matcher:e})=>e(t)).map(({reducer:e})=>e)];return i&&0===s.filter(e=>!!e).length&&(s=[i]),s.reduce((e,r)=>{if(r){if($a(e)){const n=r(e,t);return void 0===n?e:n}if(Fa(e))return yc(e,e=>r(e,t));{const n=r(e,t);if(void 0===n){if(null===e)return e;throw Error("A case reducer on a non-draftable value must not return undefined")}return n}}return e},e??o())}return s.getInitialState=o,s}const Dc={request:wc("client/request",(e,t)=>({payload:{args:e,options:t},meta:{transaction:Sa(),created:Date.now()}})),execute:Sc("client/execute",e=>({payload:e,meta:{transaction:e,created:Date.now()}}),e=>({payload:e,meta:{transaction:e.transaction,created:Date.now()}}),(e,t)=>({payload:e,meta:{transaction:t,created:Date.now()}})),cancel:wc("client/cancel",(e,t)=>({payload:{transaction:e,reason:t},meta:{transaction:e,created:Date.now()}})),error:wc("client/error",(e,t)=>({payload:{transaction:e,error:t},meta:{transaction:e,created:Date.now()}}))},_c=e=>e.pipe(Is(Dc.request.match),ds(e=>Dc.execute(e.meta.transaction))),Oc=e=>{const t=Number(e);if(Object.values(Nc).includes(t))return t;if(isNaN(t))return(e=>{if("string"!=typeof e)throw new Error("Expected LogLevel key to be a string.");const t=e.toLowerCase(),r=Object.keys(Nc).find(e=>e.toLowerCase()===t);if(!r)throw new Error(`Failed to parse LogLevel from string: ${e}.`);return Nc[r]})(e);throw Error(`Invalid log level: ${e}`)};var Nc;!function(e){e[e.None=0]="None",e[e.Error=1]="Error",e[e.Warning=2]="Warning",e[e.Info=3]="Info",e[e.Debug=4]="Debug"}(Nc||(Nc={}));const Ac=(()=>{const e=process.env.FUSION_LOG_LEVEL;if(e)try{return Oc(e)}catch(e){return"development"===process.env.NODE_ENV?Nc.Debug:Nc.Error}return Nc.Error})();class Pc{level=Ac;version="1.1.7";_log$=new Oo;get log(){return this._log$.pipe(Is(e=>this.level>=e.lvl))}debug(...e){this._log$.next({lvl:Nc.Debug,msg:this._createMessage(Nc.Debug,...e)})}info(...e){this._log$.next({lvl:Nc.Info,msg:this._createMessage(Nc.Info,...e)})}warn(...e){this._log$.next({lvl:Nc.Warning,msg:this._createMessage(Nc.Warning,...e)})}error(...e){this._log$.next({lvl:Nc.Error,msg:this._createMessage(Nc.Error,...e)})}}class Tc extends Pc{title;subtitle;constructor(e,t){super(),this.title=e,this.subtitle=t,this.log.subscribe(({lvl:e,msg:t})=>{switch(e){case Nc.Debug:console.debug(...t);break;case Nc.Info:console.info(...t);break;case Nc.Warning:console.warn(...t);break;case Nc.Error:console.error(...t)}})}_createMessage(e,...t){return[this._formatTitle(e),...t]}_formatTitle(e){const t=le.magenta([this.title,this.subtitle].filter(e=>!!e).join(" - "));switch(e){case Nc.Warning:case Nc.Error:return le.bold(t)}return t}createSubLogger(e,t,r){const n=new Tc(`${this.title}::${e}`,t??this.subtitle);return n.level=void 0===r?this.level:r,n}}class Rc extends Lo{#te=new Ao("idle");get status(){return this.#te.value}get status$(){return this.#te.asObservable()}#re;#ne;get transaction(){return this.#ne}created=Date.now();get closed(){return"complete"===this.status||"error"===this.status||"canceled"===this.status}constructor(e,t,r){super(t=>{const{transaction:n}=this,i=e.action$.pipe(Is(e=>e.meta.transaction===n));t.add(e.state$.pipe(Is(e=>!!e[n]),ds(e=>e[n])).subscribe(e=>{this.#te.next(e.status)})),t.add(i.pipe(Is(Dc.execute.success.match),ds(({payload:e})=>e)).subscribe(e=>{this.#te.next("complete"),t.next(e),t.complete()})),t.add(i.pipe(Is(Dc.error.match),ds(({payload:e})=>e)).subscribe(e=>{this.#te.next("error"),t.error(e.error)})),t.add(i.pipe(Is(Dc.cancel.match)).subscribe(e=>{this.#te.next("canceled"),t.error(new Oa("abort",{message:e.payload.reason||`job: ${n} was canceled`,request:this.#re.getRequest(e.meta.transaction)}))})),r?.signal&&t.add(Ls(r?.signal,"abort").pipe(ds(()=>Dc.cancel(n,`job: ${n} was aborted on signal from caller: ${r?.ref}`))).subscribe(t=>e.next(t))),t.add(()=>{this.complete()})}),this.#re=e;const n=Dc.request(t,{ref:r?.ref,retry:r?.retry});this.#ne=n.meta.transaction,this.#re.next(n)}complete(e){this.closed||this.cancel(e??`job: ${this.transaction} was completed`)}cancel(e){const t=this.transaction;this.#re.cancel(t,e??`job: ${t} was canceled`)}[Symbol.dispose](){this.complete()}}class xc extends Lo{#ee;#ie;#oe;get closed(){return this.#ee.closed}get state$(){return this.#ee.asObservable()}get action$(){return this.#ee.action$}get success$(){return this.action$.pipe(Is(Dc.execute.success.match),ds(({payload:e})=>e))}get error$(){return this.action$.pipe(Ec("client/error"),Bs(this.#ee),ds(([e,t])=>{const{payload:r,meta:{transaction:n}}=e,i=t[n];return new Oa("error",{request:i,message:`job: ${n} failed`,cause:r})}))}constructor(e,t){super(e=>this.#ee.subscribe(e)),this.#ee=new bc(((e={})=>Ic(e,e=>{e.addCase(Dc.request,(e,t)=>{e[t.meta.transaction]={...t.payload,...t.meta,execution:[],errors:[],status:"idle"}}),e.addCase(Dc.execute,(e,t)=>{const r=e[t.payload];r&&(r.execution.push(Date.now()),r.status="active")}),e.addCase(Dc.execute.success,(e,t)=>{delete e[t.payload.transaction]}),e.addCase(Dc.execute.failure,(e,t)=>{const r=e[t.meta.transaction];r&&(r.errors.push(t.payload),r.status="failed")}),e.addCase(Dc.error,(e,t)=>{delete e[t.meta.transaction]}),e.addCase(Dc.cancel,(e,t)=>{delete e[t.meta.transaction]})}))({})),this.#ie=new oo(()=>this.#ee.complete()),this.#ie.add(this.#ee.addFlow(_c)),this.#ie.add(this.#ee.addFlow((e=>(t,r)=>t.pipe(Is(Dc.execute.match),Bs(r),ys(([r,n])=>{const i=r.payload,o=n[i],s=new AbortController,a=t.pipe(Is(Dc.cancel.match),Is(e=>e.payload.transaction===i),ks(()=>{s.signal.aborted||s.abort()}));try{return ss(e(o.args,s.signal)).pipe(ds(e=>Dc.execute.success({...o,status:"complete",completed:Date.now(),value:e})),Ds(e=>as(Dc.execute.failure(e,i))),Us(a))}catch(e){return as(Dc.execute.failure(e,i))}})))(e))),this.#ie.add(this.#ee.addFlow((e=>(t,r)=>t.pipe(Is(Dc.execute.failure.match),Bs(r),ys(([t,n])=>{const{transaction:i}=t.meta,o=n[i];if(!o)return as(Dc.error(i,new Oa("error",{message:"request not found, cannot retry request, most likely removed while scheduled for retry!"})));const s=o.execution.length,a=Object.assign({},e,o.options?.retry),c=o.errors?.slice(-1)[0]??new Oa("error",{message:"no errors registered for request!",request:o});if(s>a.count){const e=0===a.count?c:new Oa("error",{message:"maximum retries executed!",cause:o.errors,request:o});return as(Dc.error(i,e))}return("function"==typeof a.delay?ss(a.delay(c)).pipe(Ds(e=>as(Dc.error(i,new Oa("error",{message:"retry delay callback failed!",cause:[...o.errors??[],e],request:o}))))):Cs(a.delay)).pipe(Bs(r),Is(([e,t])=>!!t[i]),ks(([,e])=>{if(!e[i])throw new Oa("error",{message:"request not found, most likely removed while scheduled for retry",cause:o.errors,request:o})}),ds(()=>Dc.execute(i)))})))(Object.assign({count:0,delay:0},t?.retry)))),this.#oe=t?.logger??new Tc("QueryClient"),this.#ee.addEffect(Dc.request.type,({payload:e,meta:{transaction:t}})=>{this.#oe.debug("Job requested",{transaction:t,payload:e})}),this.#ee.addEffect(Dc.execute.type,({payload:e,meta:{transaction:t}})=>{this.#oe.debug("Job executing",{transaction:t,payload:e})}),this.#ee.addEffect(Dc.execute.success.type,({payload:e})=>{this.#oe.info("Job complete",{...e})}),this.#ee.addEffect(Dc.execute.failure.type,({payload:e,meta:{transaction:t}})=>{this.#oe.debug("Job failed",{transaction:t,payload:e})}),this.#ee.addEffect(Dc.cancel.type,({payload:{reason:e},meta:{transaction:t}})=>{this.#oe.debug("Job canceled",{transaction:t,reason:e})}),this.#ee.addEffect(Dc.error.type,({payload:{transaction:e,error:t}})=>{this.#oe.error("Job error",{transaction:e,error:t})})}next(e){this.#ee.next(e)}query(e,t){const r=new Rc(this,e,t),n=r.pipe(function(e){void 0===e&&(e={});var t=e.connector,r=void 0===t?function(){return new Oo}:t,n=e.resetOnError,i=void 0===n||n,o=e.resetOnComplete,s=void 0===o||o,a=e.resetOnRefCountZero,c=void 0===a||a;return function(e){var t,n,o,a=0,l=!1,u=!1,f=function(){null==n||n.unsubscribe(),n=void 0},p=function(){f(),t=o=void 0,l=u=!1},h=function(){var e=t;p(),null==e||e.unsubscribe()};return Co(function(e,d){a++,u||l||f();var m=o=null!=o?o:r();d.add(function(){0!==--a||u||l||(n=$s(h,c))}),m.subscribe(d),!t&&a>0&&(t=new vo({next:function(e){return m.next(e)},error:function(e){u=!0,f(),n=$s(p,i,e),m.error(e)},complete:function(){l=!0,f(),n=$s(p,s),m.complete()}}),Qo(e).subscribe(t))})(e)}}({connector:()=>new To,resetOnRefCountZero:!1}));return Object.defineProperties(n,{transaction:{get:()=>r.transaction},created:{get:()=>r.created},status:{get:()=>r.status},closed:{get:()=>r.closed},cancel:{value:e=>r.cancel(e)},complete:{value:()=>r.complete()}}),n}async nextAsync(e,t){return us(this.query(e,t))}getRequest(e){return this.#ee.value[e]}getRequestByRef(e){return Object.values(this.#ee.value).find(t=>t.ref===e)}cancelTaskByRef(e,t){const r=this.getRequestByRef(e);r?.ref&&this.cancel(r.transaction,t)}cancel(e,t){if(e)this.#ee.value[e]?(t??=`cancelation requested for job: ${e}`,this.#ee.next(Dc.cancel(e,t))):this.#oe.warn("Task not registered, nothing to cancel",{transaction:e,reason:t});else for(const e of Object.keys(this.#ee.value))this.cancel(e,"all transactions requested canceled")}on(e,t){return this.#ee.addEffect(Dc[e].type,e=>{t(e,this)})}complete(){this.#ie.unsubscribe()}}const $c={set:wc("cache/set",(e,t)=>({payload:{key:e,record:t}})),insert:wc("cache/insert",(e,t)=>({payload:{key:e,entry:t}})),remove:wc("cache/remove",e=>({payload:e})),invalidate:wc("cache/invalidate",(e,t)=>({payload:e,meta:{item:t}})),mutate:wc("cache/mutate",(e,t,r)=>({payload:{...t,key:e},meta:{item:r}})),trim:wc("cache/trim",e=>({payload:e}))},Fc=(e,t)=>(t.updated??0)-(e.updated??0);class Uc{#ee;get state(){return this.#ee.value}get state$(){return this.#ee.asObservable()}get action$(){return this.#ee.action$}constructor(e){const{trimming:t,initial:r}=e??{};this.#ee=new bc(function(e,t={}){return Ic(t,t=>t.addCase(e.set,(e,t)=>{const{key:r,record:n}=t.payload;e[r]=n}).addCase(e.insert,(e,t)=>{const{key:r,entry:n}=t.payload,i=e[r];if(i)i.updated=Date.now(),i.updates??=0,i.updates++,i.value=n.value,i.transaction=n.transaction,i.mutated=void 0;else{const t=Date.now();e[r]={...n,created:t,updated:t}}}).addCase(e.remove,(e,t)=>{delete e[t.payload]}).addCase(e.invalidate,(e,t)=>{const r=t.payload?[t.payload]:Object.keys(e);for(const t of r){const r=e[t];r&&(r.updated=void 0)}}).addCase(e.mutate,(e,t)=>{const{key:r,value:n,updated:i}=t.payload,o=e[r];o&&(o.value=n,o.updated=i,o.mutated=Date.now(),o.updates??=0,o.updates++)}).addCase(e.trim,(e,t)=>{const{payload:r}=t,n=r.sort??Fc,i=Object.keys(e),o=Object.entries(e).filter(([e,t])=>!r.validate||r.validate(t)).sort((e,t)=>n(e[1],t[1])).slice(0,r.size??Number.MAX_SAFE_INTEGER).map(([e])=>e);if(i.length!==o.length)for(const t of i){const r=o.indexOf(t);-1!==r?o.splice(r,1):delete e[t]}}))}($c,r)),t&&this.#ee.addEffect("cache/set",()=>this.#ee.next($c.trim(t)))}has(e){return e in this.#ee.value}setItem(e,t){const{args:r,transaction:n,value:i}=t;this.#ee.next($c.insert(e,{args:r,transaction:n,value:i}))}getItem(e){return this.#ee.value[e]}removeItem(e){this.#ee.next($c.remove(e))}invalidate(e){const t=e?this.#ee.value[e]:void 0;this.#ee.next($c.invalidate(e,t))}mutate(e,t){const r=e in this.#ee.value?this.#ee.value[e]:void 0;if(!r)throw new Error(`Cannot mutate cache item with key ${e}: item not found`);const n="function"==typeof t?t(r?.value):t;return this.#ee.next($c.mutate(e,n,r)),()=>this.#ee.next($c.set(e,r))}trim(e){this.#ee.next($c.trim(e))}reset(){this.#ee.reset()}complete(){this.#ee.complete()}}class kc extends Oo{key;args;options;#se=Date.now();get created(){return this.#se}#ae=Sa();get uuid(){return this.#ae}constructor(e,t,r){super(),this.key=e,this.args=t,this.options=r}processJob(e,t){return e.pipe(ds(t=>{const{key:r,uuid:n,created:i}=this;return{key:r,uuid:n,created:i,status:"complete",transaction:e.transaction,complete:t.completed,value:t.value}}),Rs(()=>{t?.debug("QueryTask complete",{uuid:this.uuid,key:this.key,job:{status:e.status,transaction:e.transaction}}),e.complete()})).subscribe(this)}}class Bc{static extractQueryValue=ha;#ie=new oo;#re;#ce;#le=new Oo;#ue={};#fe;#pe;#he=Sa();#oe;get client(){return this.#re}get cache(){return this.#ce}constructor(e){this.#oe=e.logger??new Tc("Query",this.#he),this.#fe=t=>_a(e.key(t),this.#he),this.#pe=e?.validate??((e=0)=>t=>(t.updated??0)+e>Date.now())(e?.expire),e.client instanceof xc?this.#re=e.client:(this.#re=new xc(e.client.fn,{logger:this.#oe.createSubLogger("Client"),...e.client.options}),this.#ie.add(()=>this.#re.complete())),e.cache instanceof Uc?this.#ce=e.cache:(this.#ce=new Uc(e.cache||{}),this.#ie.add(()=>this.#ce.complete()));const t=((e="switch")=>"function"==typeof e?e:(()=>{switch(e){case"concat":return ua;case"merge":return fa;case"switch":return pa;default:throw new Error(`Invalid queue operator: ${e}`)}})())(e.queueOperator);var r,n;this.#ie.add(()=>this.#le.complete()),this.#ie.add(this.#le.pipe(ks(e=>this.#oe.debug("Task added to queue",{key:e})),Is(e=>!!(e in this.#ue)),t(e=>{const t=this.#ue[e],{args:r,options:n,uuid:i}=t;if(this.#oe.debug("Task selected from queue",{key:e,task:t.uuid,args:r,options:n}),!t?.observed)return this.#oe.debug("Task skipped",{task:i}),delete this.#ue[e],Go;const o=this.#re.query(r,{...n,ref:t.uuid});return new Lo(r=>{const{transaction:n}=o;var s,a;this.#oe.info("Task stated",{task:i,transaction:n}),r.add(()=>{this.#oe.debug("Task closed",{task:i,transaction:n,jobStatus:o.status}),o.complete("task closed"),delete this.#ue[e]}),r.add((s=10,void 0===a&&(a=Bo),Cs(s,s,a)).pipe(Is(()=>!t.observed)).subscribe(()=>{o.cancel(`task: ${t.uuid} is not observed`),r.complete()})),r.add(t.processJob(o,this.#oe)),o.pipe(ds(e=>({result:e,task:t})),Ds(()=>Go)).subscribe(r)})}),(r=()=>!this.#re.closed,void 0===n&&(n=!1),Co(function(e,t){var i=0;e.subscribe(Io(t,function(e){var o=r(e,i++);(o||n)&&t.next(e),!o&&t.complete()}))}))).subscribe(e=>{const{value:t,transaction:r}=e.result,{args:n,key:i,uuid:o}=e.task;this.#oe.debug("Task output added to cache",{uuid:o,args:n,key:i,transaction:r,value:t}),this.#ce.setItem(i,{value:t,args:n,transaction:r})}))}query(e,t){return this._query(e,t)}queryAsync(e,t){const{skipResolve:r,...n}=t||{},i=r?us:ls;return new Promise((r,o)=>{t?.signal&&t.signal.addEventListener("abort",()=>o(new Error("Query aborted"))),i(this._query(e,n).pipe(Ps())).then(r,o)})}persistentQuery(e,t){const r=this.#fe(e),n=this._query(e,t);return new Lo(i=>{i.add(n.subscribe({next:i.next.bind(i),error:i.error.bind(i)}));const o=t?.cache?.validate||this.#pe;i.add(this.cache.state$.pipe(Is(e=>r in e),ds(t=>({...t[r],key:r,status:"cache",hasValidCache:o(t[r],e)}))).subscribe(i))}).pipe(Ns((e,t)=>e.transaction===t.transaction&&e.mutated===t.mutated))}generateCacheKey(e){return this.#fe(e)}mutate(e,t,r){const n=this.#fe(e);if(n in this.cache.state==!1){if(void 0===r?.allowCreation)throw new Error(`Cannot mutate cache item with key ${n}: item not found and option "allowCreation" is false`);if(!1===r.allowCreation)return()=>{};const{value:i}="function"==typeof t?t():t;this.cache.setItem(n,{args:e,transaction:Sa(),value:i})}return this.#ce.mutate(n,t)}invalidate(e){this.#ce.invalidate(e&&this.#fe(e))}complete(){this.#ie.unsubscribe()}onInvalidate(e){const t=this.#ce.action$.pipe(Ec("cache/invalidate")).subscribe(t=>e({detail:{item:t.meta.item}}));return()=>t.unsubscribe()}onMutate(e){const t=this.#ce.action$.pipe(Ec("cache/mutate")).subscribe(t=>e({detail:{changes:t.payload,current:t.meta.item}}));return()=>t.unsubscribe()}_query(e,t){const r=this.#fe(e),n=this._createTask(r,e,t);return this.#oe.debug("New query created",{key:r,args:e,options:t}),n}_createTask(e,t,r){return new Lo(n=>{if(r?.signal){if(r?.signal.aborted)return this.#oe.debug("Abort signal already triggered by caller",{key:e}),n.complete();n.add(Ls(r?.signal,"abort").subscribe(()=>{this.#oe.debug("Abort signal triggered by caller",{key:e}),n.complete()}))}const i=this.#ce.getItem(e);if(i){this.#oe.debug("Query has cache",{key:e,cacheEntry:i});const o=r?.cache?.suppressInvalid??!1,s=(r?.cache?.validate||this.#pe)(i,t),a={...i,key:e,status:"cache",hasValidCache:s};if(this.#oe.info("Query cache valid, completing",{hasValidCache:s,suppressInvalid:o,record:a}),n.next(a),s||o)return n.complete();this.#oe.debug("Query cache entry is invalid, proceeding to fetch new data",{key:e})}const o=e in this.#ue;this.#ue[e]??=new kc(e,t,r);const s=this.#ue[e];n.add(s.subscribe(n)),this.#oe.info(o?"Query connected to existing task":"Query started new task",{key:e}),o||this.#le.next(e)})}}const Mc=N.object({key:N.string().describe("The key used to identify the service"),uri:N.string().describe("The URI of the service"),id:N.string().optional().describe("The ID of the service"),environment:N.string().optional().describe("The environment of the service"),name:N.string().optional().describe("The name of the service"),scopes:N.array(N.string()).optional().default([]).describe("Endpoint authentication scopes"),tags:N.array(N.string()).optional().describe("Tags for the service")}).describe("A service from the service discovery API").transform(e=>({...e,get defaultScopes(){return e.scopes??[]}})),Gc=N.array(Mc).describe("A list of services from the service discovery API"),jc=e=>ss(ra(e)).pipe(ds(e=>Gc.default([]).parse(e)));class zc{#de;endpoint;http;constructor({http:e,endpoint:t}){this.http=e,this.endpoint=t,this.#de=new Bc({client:{fn:()=>e.fetch$(t??"",{selector:jc})},key:()=>"services",expire:3e5})}resolveServices(e){return(e?us:ls)(Bc.extractQueryValue(this.#de.query()))}async resolveService(e,t){const r=(await this.resolveServices(t)).find(t=>t.key===e);if(!r)throw Error(`Failed to resolve service, invalid key [${e}]`);return r}}class Hc extends Gs{async _createConfig(e,t){if(!e.hasModule("http"))throw new Error("http module is required");if(!this._has("discoveryClient")){(await e.requireInstance("http")).hasClient("service_discovery")&&this.configureServiceDiscoveryClientByClientKey("service_discovery")}return ls(ss(super._createConfig(e,t)))}_processConfig(e,t){if(!e.discoveryClient)throw new Error("discoveryClient is required, please configure it");return super._processConfig(e,t)}setServiceDiscoveryClient(e){this._set("discoveryClient","function"==typeof e?e:async()=>e)}configureServiceDiscoveryClient(e){this.setServiceDiscoveryClient(async t=>{const{httpClient:r,endpoint:n}=await ls(ss(e(t)))??{};if(r)return new zc({http:r,endpoint:n});throw Error("httpClient is required")})}configureServiceDiscoveryClientByClientKey(e,t){this.configureServiceDiscoveryClient(async({requireInstance:r})=>({httpClient:(await r("http")).createClient(e),endpoint:t}))}}class Wc{config;_http;constructor(e,t){this.config=e,this._http=t}resolveServices(){return this.config.discoveryClient.resolveServices()}async resolveService(e){return this.config.discoveryClient.resolveService(e)}async createClient(e,t){const r=await this.resolveService(e);if(!r)throw Error(`Could not load configuration of service [${e}]`);return this._http.createClient({...t,baseUri:r.uri,defaultScopes:r.scopes})}async configureClient(e,t){const{key:r,alias:n}="string"==typeof e?{key:e,alias:e}:e,{uri:i,scopes:o}=await this.resolveService(r);var s,a;t.addConfig((s=n,a={baseUri:i,defaultScopes:o},{module:la,configure:e=>{e.configureClient(s,a)}}))}}const Vc={name:"serviceDiscovery",configure:()=>new Hc,initialize:async e=>{const{requireInstance:t,ref:r}=e,n=await e.config.createConfigAsync(e,{...r?.serviceDiscovery?.config}),i=await t("http");return new Wc(n,i)}},qc=(e,t)=>{e.addConfig((e=>({module:Vc,configure:t=>e(t)}))(()=>Promise.resolve()))};var Yc,Kc,Zc,Xc={},Jc=[{name:"Agola CI",constant:"AGOLA",env:"AGOLA_GIT_REF",pr:"AGOLA_PULL_REQUEST_ID"},{name:"Appcircle",constant:"APPCIRCLE",env:"AC_APPCIRCLE",pr:{env:"AC_GIT_PR",ne:"false"}},{name:"AppVeyor",constant:"APPVEYOR",env:"APPVEYOR",pr:"APPVEYOR_PULL_REQUEST_NUMBER"},{name:"AWS CodeBuild",constant:"CODEBUILD",env:"CODEBUILD_BUILD_ARN",pr:{env:"CODEBUILD_WEBHOOK_EVENT",any:["PULL_REQUEST_CREATED","PULL_REQUEST_UPDATED","PULL_REQUEST_REOPENED"]}},{name:"Azure Pipelines",constant:"AZURE_PIPELINES",env:"TF_BUILD",pr:{BUILD_REASON:"PullRequest"}},{name:"Bamboo",constant:"BAMBOO",env:"bamboo_planKey"},{name:"Bitbucket Pipelines",constant:"BITBUCKET",env:"BITBUCKET_COMMIT",pr:"BITBUCKET_PR_ID"},{name:"Bitrise",constant:"BITRISE",env:"BITRISE_IO",pr:"BITRISE_PULL_REQUEST"},{name:"Buddy",constant:"BUDDY",env:"BUDDY_WORKSPACE_ID",pr:"BUDDY_EXECUTION_PULL_REQUEST_ID"},{name:"Buildkite",constant:"BUILDKITE",env:"BUILDKITE",pr:{env:"BUILDKITE_PULL_REQUEST",ne:"false"}},{name:"CircleCI",constant:"CIRCLE",env:"CIRCLECI",pr:"CIRCLE_PULL_REQUEST"},{name:"Cirrus CI",constant:"CIRRUS",env:"CIRRUS_CI",pr:"CIRRUS_PR"},{name:"Cloudflare Pages",constant:"CLOUDFLARE_PAGES",env:"CF_PAGES"},{name:"Cloudflare Workers",constant:"CLOUDFLARE_WORKERS",env:"WORKERS_CI"},{name:"Codefresh",constant:"CODEFRESH",env:"CF_BUILD_ID",pr:{any:["CF_PULL_REQUEST_NUMBER","CF_PULL_REQUEST_ID"]}},{name:"Codemagic",constant:"CODEMAGIC",env:"CM_BUILD_ID",pr:"CM_PULL_REQUEST"},{name:"Codeship",constant:"CODESHIP",env:{CI_NAME:"codeship"}},{name:"Drone",constant:"DRONE",env:"DRONE",pr:{DRONE_BUILD_EVENT:"pull_request"}},{name:"dsari",constant:"DSARI",env:"DSARI"},{name:"Earthly",constant:"EARTHLY",env:"EARTHLY_CI"},{name:"Expo Application Services",constant:"EAS",env:"EAS_BUILD"},{name:"Gerrit",constant:"GERRIT",env:"GERRIT_PROJECT"},{name:"Gitea Actions",constant:"GITEA_ACTIONS",env:"GITEA_ACTIONS"},{name:"GitHub Actions",constant:"GITHUB_ACTIONS",env:"GITHUB_ACTIONS",pr:{GITHUB_EVENT_NAME:"pull_request"}},{name:"GitLab CI",constant:"GITLAB",env:"GITLAB_CI",pr:"CI_MERGE_REQUEST_ID"},{name:"GoCD",constant:"GOCD",env:"GO_PIPELINE_LABEL"},{name:"Google Cloud Build",constant:"GOOGLE_CLOUD_BUILD",env:"BUILDER_OUTPUT"},{name:"Harness CI",constant:"HARNESS",env:"HARNESS_BUILD_ID"},{name:"Heroku",constant:"HEROKU",env:{env:"NODE",includes:"/app/.heroku/node/bin/node"}},{name:"Hudson",constant:"HUDSON",env:"HUDSON_URL"},{name:"Jenkins",constant:"JENKINS",env:["JENKINS_URL","BUILD_ID"],pr:{any:["ghprbPullId","CHANGE_ID"]}},{name:"LayerCI",constant:"LAYERCI",env:"LAYERCI",pr:"LAYERCI_PULL_REQUEST"},{name:"Magnum CI",constant:"MAGNUM",env:"MAGNUM"},{name:"Netlify CI",constant:"NETLIFY",env:"NETLIFY",pr:{env:"PULL_REQUEST",ne:"false"}},{name:"Nevercode",constant:"NEVERCODE",env:"NEVERCODE",pr:{env:"NEVERCODE_PULL_REQUEST",ne:"false"}},{name:"Prow",constant:"PROW",env:"PROW_JOB_ID"},{name:"ReleaseHub",constant:"RELEASEHUB",env:"RELEASE_BUILD_ID"},{name:"Render",constant:"RENDER",env:"RENDER",pr:{IS_PULL_REQUEST:"true"}},{name:"Sail CI",constant:"SAIL",env:"SAILCI",pr:"SAIL_PULL_REQUEST_NUMBER"},{name:"Screwdriver",constant:"SCREWDRIVER",env:"SCREWDRIVER",pr:{env:"SD_PULL_REQUEST",ne:"false"}},{name:"Semaphore",constant:"SEMAPHORE",env:"SEMAPHORE",pr:"PULL_REQUEST_NUMBER"},{name:"Sourcehut",constant:"SOURCEHUT",env:{CI_NAME:"sourcehut"}},{name:"Strider CD",constant:"STRIDER",env:"STRIDER"},{name:"TaskCluster",constant:"TASKCLUSTER",env:["TASK_ID","RUN_ID"]},{name:"TeamCity",constant:"TEAMCITY",env:"TEAMCITY_VERSION"},{name:"Travis CI",constant:"TRAVIS",env:"TRAVIS",pr:{env:"TRAVIS_PULL_REQUEST",ne:"false"}},{name:"Vela",constant:"VELA",env:"VELA",pr:{VELA_PULL_REQUEST:"1"}},{name:"Vercel",constant:"VERCEL",env:{any:["NOW_BUILDER","VERCEL"]},pr:"VERCEL_GIT_PULL_REQUEST_ID"},{name:"Visual Studio App Center",constant:"APPCENTER",env:"APPCENTER_BUILD_ID"},{name:"Woodpecker",constant:"WOODPECKER",env:{CI:"woodpecker"},pr:{CI_BUILD_EVENT:"pull_request"}},{name:"Xcode Cloud",constant:"XCODE_CLOUD",env:"CI_XCODE_PROJECT",pr:"CI_PULL_REQUEST_NUMBER"},{name:"Xcode Server",constant:"XCODE_SERVER",env:"XCS"}];function Qc(){return Yc||(Yc=1,function(e){const t=Jc,r=process.env;function n(e){return"string"==typeof e?!!r[e]:"env"in e?r[e.env]&&r[e.env].includes(e.includes):"any"in e?e.any.some(function(e){return!!r[e]}):Object.keys(e).every(function(t){return r[t]===e[t]})}Object.defineProperty(e,"_vendors",{value:t.map(function(e){return e.constant})}),e.name=null,e.isPR=null,e.id=null,t.forEach(function(t){const i=(Array.isArray(t.env)?t.env:[t.env]).every(function(e){return n(e)});e[t.constant]=i,i&&(e.name=t.name,e.isPR=function(e){switch(typeof e.pr){case"string":return!!r[e.pr];case"object":return"env"in e.pr?"any"in e.pr?e.pr.any.some(function(t){return r[e.pr.env]===t}):e.pr.env in r&&r[e.pr.env]!==e.pr.ne:"any"in e.pr?e.pr.any.some(function(e){return!!r[e]}):n(e.pr);default:return null}}(t),e.id=t.constant)}),e.isCI=!("false"===r.CI||!(r.BUILD_ID||r.BUILD_NUMBER||r.CI||r.CI_APP_ID||r.CI_BUILD_ID||r.CI_BUILD_NUMBER||r.CI_NAME||r.CONTINUOUS_INTEGRATION||r.RUN_ID||e.name))}(Xc)),Xc}var el=ue(Zc?Kc:(Zc=1,Kc=Qc().isCI));const tl=["5a842df8-3238-415d-b168-9f16a6a6031b/.default"];var rl;!function(e){e.ContinuesIntegration="ci",e.QualityAssurance="fqa",e.Training="tr",e.Production="fprd",e.Development="dev"}(rl||(rl={}));const nl=e=>e&&!el?rl.Development:rl.ContinuesIntegration,il=async e=>{const t=new Hs,r=e.env??rl.ContinuesIntegration;t.addConfig({module:la,configure:t=>{const n=r===rl.Development?rl.ContinuesIntegration:r,i=e.serviceDiscovery?.url??new URL(`/service-registry/environments/${n}/services`,"https://discovery.fusion.equinor.com").toString(),o=e.serviceDiscovery?.scope??tl;t.configureClient("service_discovery",{baseUri:i,defaultScopes:o})}}),qc(t),k(t,t=>{const{auth:r}=e;if("token"in r&&r.token){const{token:e}=r;return t.setMode("token_only"),void t.setAccessToken(e)}const{clientId:n,tenantId:i,interactive:o}=r;if(!n||!i)throw new Error("clientId and tenantId are required for auth module");if(t.setClientConfig(i,n),t.setMode(o?"interactive":"silent"),o){const{server:e}=r;if(!e.port)throw new Error("server.port is required for interactive mode");t.setServerPort(e.port),t.setServerOnOpen(e.onOpen)}});return await t.initialize()},ol=async e=>{const{log:t}=e,{config:r}=await nn({log:t,config:e.config,env:{environment:e.environment}}),{manifest:n}=await er({log:t,manifest:e.manifest,env:{environment:e.environment}}),i=n.build?.version;if(!i){const e=new Error("No build version found in the manifest. Please make sure the manifest is valid.");throw t?.fail("🤪",e.message),e}t?.start("Initializing Fusion Framework...");const o=await il({env:e.environment,auth:e.auth});t?.succeed("Initialized Fusion Framework");const s=await o.serviceDiscovery.createClient("apps");s.request$.subscribe(e=>{t?.debug("Request:",e),t?.info("🌎","Executing request to:",Zt(e.uri))}),t?.start("Publishing application config"),t?.info("Using environment:",le.redBright(e.environment));try{const e=await s.json(`/apps/${n.appKey}/builds/${i}/config`,{method:"PUT",body:r});t?.debug("Response:",e),t?.succeed("Published application config")}catch(e){if(e instanceof sn)switch(e.response.status){case 410:t?.fail("🤬",`App ${n.appKey} is deleted from apps-service. Please check the app key and try again.`);break;case 404:t?.fail("🤬",`App ${n.appKey} not found. Please check the app key and try again.`);break;case 403:case 401:t?.fail("🤬","You are not authorized to publish application config. Please check your permissions.");break;default:t?.fail("🤬","Failed to publish application config.",`Status code: ${e.response.status}`,`Message: ${e.response.statusText}`)}throw e}},sl=async e=>{const{log:r}=e??{},n="@equinor/fusion-framework-dev-portal",o=await Qt(r),s={root:o.root,environment:"local",...e?.env,mode:"development",command:"serve"},a=await Jt(s,o,{log:r,manifestPath:e?.manifest}),c=await rn(s,{log:r,config:e?.config});let u,p;const h=f(import.meta.resolve(n));Nt(h)?(u=h,p=await l({cwd:h}).then(e=>e?i(e?.path):void 0)):r?.info(`Portal ${n} is external, skipping entry point resolution`);const d=p?[o.root,p]:[o.root];r?.debug(`File system access allowed for: \n${d.join("\n")}\n`);const m=t(await Rt(s,o),{server:{port:e?.port||3e3,host:"localhost",fs:{allow:d}}}),g={template:{portal:{id:n}},app:{manifest:a,config:c}};u&&(g.portal={manifest:{name:n,build:{templateEntry:u,assetPath:"/@fs"}},config:{}}),r?.debug("vite config:",m),r?.debug("dev server config:",g),r?.start("Starting app development server...");const v=await Xr(s,g,m);await v.listen(),r?.succeed("App development server started successfully");const y=v.config.server.https?"https":"http",E=v.config.server.host||"localhost",b=v.config.server.port||5173;return r?.info(`App development server is running at: ${y}://${E}:${b}/apps/${a.appKey}`),v},al=async e=>{const{log:t}=e,r=await Qt(t),n=await Jt({command:"build",mode:"production"},r,{log:t});t?.start("Initializing Fusion Framework...");const i=await il({env:e.environment,auth:"token"in e.auth?{token:e.auth.token}:e.auth});t?.succeed("Initialized Fusion Framework");const o=await i.serviceDiscovery.createClient("apps");o.request$.subscribe(e=>{t?.info("🌎","Executing request to:",e.uri),t?.debug("Request:",e)});try{t?.start(`Checking if ${n.appKey} is registered in app store`);const e=await o.fetch(`/apps/${n.appKey}`,{method:"HEAD"});if(e.ok)return t?.succeed("😃",`Application ${n.appKey} is registered in app store`);if(404===e.status)return t?.fail("😞",`Application ${n.appKey} is not registered in app store`);throw new Error(`Unexpected response status: ${e.status}`)}catch(e){t?.fail("🙅‍♂️","Error checking application registration"),t?.error("Error checking application registration:",e)}},cl=e=>{const t=e.getEntry("metadata.json");if(!t)throw new Error("Metadata file not found in bundle");return new Promise((e,r)=>{t.getDataAsync((t,n)=>{if(n)return r(new Error("Failed to read metadata file",{cause:n}));try{return e(JSON.parse(String(t)))}catch(e){r(new Error("Failed to parse metadata file",{cause:e}))}})})};const ll=async e=>{const{log:t,framework:r}=e,n="string"==typeof e.fileOrBundle?new Hr(e.fileOrBundle):e.fileOrBundle,{name:i}=e.appKey?{name:e.appKey}:await cl(n).catch(e=>{t?.error("Failed to resolve manifest:",e),process.exit(1)});t?.info("📦",`Uploading application bundle for ${le.bold(i)}`),t?.debug("Bundle contents:",(await n.getEntries()).map(e=>e.entryName));const o=await n.toBufferPromise().catch(e=>{t?.error("Failed to read bundle content:",e),process.exit(1)});try{const e=await r.serviceDiscovery.createClient("apps");e.request$.subscribe(e=>{t?.info("🌎","Executing request to:",e.uri),t?.debug("Request:",e)});const n=await e.fetch(`/bundles/apps/${i}`,{method:"POST",body:new Blob([o],{type:"application/zip"}),headers:{"Content-Type":"application/zip"}});if(!n.ok){try{const{error:e}=await n.json();t?.debug("Error:",e),e.message&&t?.warn(le.red(`🤯 error: ${e.code}\n`),le.yellowBright(e.message),"\n")}catch(e){t?.debug("Error:",n.statusText)}!function(e,t){switch(e.status){case 409:throw new Error(`${e.status} - Version is already published, please generate a new release`);case 410:throw new Error(`${e.status} - ${t} is removed from Fusion app store`);case 404:throw new Error(`${e.status} - ${t} not found, please add your application in App Admin before publishing`);case 401:case 403:throw new Error(`${e.status} - This is not allowed for your role on ${t}`);case 500:throw new Error(`${e.status} - Internal server error, please try again later or contact support`);default:throw new Error(`Failed to upload bundle. HTTP status ${e.status}, ${e.statusText}`)}}(n,i)}t?.succeed("Successfully uploaded application bundle"),t?.debug("Response:",n);try{return{name:i,version:(await n.json()).version}}catch(e){throw new Error(`Failed to parse response from app service: ${e instanceof Error?e.message:e}`)}}catch(e){t?.fail("🙅‍♂️","Failed to upload application bundle"),t?.error(e),process.exit(1)}};var ul;!function(e){e.Latest="latest",e.Preview="preview"}(ul||(ul={}));const fl=async e=>{const{tag:t,appKey:r,version:n,framework:i,log:o}=e;["latest","preview"].includes(t)||(o?.fail("🤪",'Invalid tag. Use "latest" or "preview".'),process.exit(1)),r||(o?.fail("🤪","Application key is required."),process.exit(1)),n||(o?.fail("🤪","Version is required."),process.exit(1));const s=await i.serviceDiscovery.createClient("apps");s.request$.subscribe(e=>{o?.debug("Request:",e),o?.info("🌎","Executing request to:",Zt(e.uri))}),o?.start("Publishing application config");try{const e=await s.json(`/apps/${r}/tags/${t}`,{method:"PUT",body:{version:n}});return o?.debug("Response:",e),o?.succeed("Tagged application successfully",le.greenBright(`${r}@${n} - ${t}`)),e}catch(e){if(e instanceof sn)switch(e.response.status){case 410:o?.fail("🤬",`App ${r} is deleted from apps-service. Please check the app key and try again.`);break;case 404:o?.fail("🤬",`App ${r} not found. Please check the app key and try again.`);break;case 403:case 401:o?.fail("🤬","You are not authorized to tag application. Please check your permissions.");break;default:o?.fail("🤬","Failed to tag application",`Status code: ${e.response.status}`,`Error: ${e.message}`)}throw e}},pl=A.object({templateEntry:A.string({message:"templateEntry must be a string"}).describe("Main entry point for the portal"),schemaEntry:A.string({message:"schemaEntry must be a string"}).describe("Schema file for portal validation"),assetPath:A.string({message:"assetPath must be a string"}).optional().describe("Asset path for dev/preview builds"),githubRepo:A.string({message:"githubRepo must be a string"}).optional().describe("GitHub repo URL or local git remote"),version:A.string({message:"version must be a string"}).describe("Version from package.json"),timestamp:A.string({message:"timestamp must be a string"}).describe("Current build timestamp (ISO8601)"),commitSha:A.string({message:"commitSha must be a string"}).describe("Current git commit SHA"),annotations:A.record(A.string(),A.string()).optional().describe("Optional build annotations"),projectPage:A.string({message:"projectPage must be a string"}).optional().describe("Optional project homepage"),allowedExtensions:A.array(A.string({message:"Each allowed extension must be a string"}),{message:"allowedExtensions must be an array of strings"}).describe("List of allowed asset extensions (with leading dot)"),schema:A.record(A.string(),A.unknown()).optional().describe("Optional schema for the portal"),config:A.record(A.string(),A.unknown()).optional().describe("Optional configuration for the portal")}),hl=A.object({name:A.string({message:"name must be a string"}).describe("Short app key (unscoped, derived from package name)"),displayName:A.string({message:"displayName must be a string"}).optional().describe("Full package name, may include scope"),description:A.string({message:"description must be a string"}).optional().describe("Description of the portal"),build:pl}),dl=(e,t)=>{xt(t,"expected packageJson"),_(t.name,"expected [name] in packageJson"),_(t.version,"expected [version] in packageJson");const r=((e,t)=>"build"===e.command||e.isPreview?t.main||t.module||"dist/bundle.js":Pt(e.root))(e,t),n=t.name.replace(/^@|\w.*\//gm,""),i=t.version,o="build"===e.command?void 0:"/@fs",s=$t(t)??Ft(),a={name:n,displayName:t.name,description:t.description||"",build:{templateEntry:r,schemaEntry:"portal.schema.json",assetPath:o,githubRepo:s,version:i,timestamp:(new Date).toISOString(),commitSha:Ut(),annotations:{...kt()},projectPage:t.homepage,allowedExtensions:Bt.map(e=>`.${e}`)}},c=hl.safeParse(a);if(!c.success){const e=c.error.issues.map(e=>`- ${e.path.join(".")}: ${e.message}`).join("\n");throw new Error(["Invalid portal manifest generated from package.json:",e].join("\n"))}return c.data},ml=async(e,t,r)=>{const n=dl(e,t.packageJson);try{r?.log?.start("loading manifest...");const t=await(async(e,t)=>{const r=t?.file??[`portal.manifest.${e.environment}`,"portal.manifest"],n=await C(r,{baseDir:e.root,extensions:t?.extensions,script:{resolve:async r=>{const n=t?.base??{};let i;return i="function"==typeof r.default?await r.default(e,{base:n})??void 0:r.default,i?D(n,i):n}}}),i=n.config,o=hl.safeParse(i);if(!o.success)throw new Error(`Invalid portal manifest: ${o.error.issues.map(e=>`${e.path.join(".")}: ${e.message}`).join("; ")}`);return{manifest:i,path:n.path,extension:n.extension}})(e,{base:n});return r?.log?.succeed("generated manifest from",Zt(t.path,{relative:!0})),t.manifest}catch(e){if(e instanceof I){if(r?.manifestPath){const t=new Error(`Failed to load manifest file ${Zt(r.manifestPath)}, please check the path.`,{cause:e});throw r?.log?.fail(t.message),t}return r?.log?.succeed(le.dim("no local manifest config applied, using default generated from package")),n}throw r?.log?.fail(`failed to resolve application manifest ${r?.manifestPath?Zt(r?.manifestPath):""}`),e}},gl=async(e,t)=>{const{log:r}=t;try{r?.start("create portal configuration"),r?.info(`generating config with ${le.red.dim(e.command)} command in ${le.green.dim(e.mode)} mode`);const n=await((e,t)=>{const r=t?.file??[`portal.config.${e.environment}`,"portal.config"];return C(r,{baseDir:e.root,extensions:t?.extensions,script:{resolve:async r=>{const n=t?.schema??N.object({}).passthrough(),i=t?.base??{};if("function"==typeof r.default){const t=await r.default(i,e)??i;return n.parse(t)}return n.parse(r.default??i)}}})})(e,{file:t?.config});return r?.succeed("⚙️ generated config from ",Zt(n.path,{relative:!0})),n.config}catch(e){if(e instanceof I){if(!t.config)return r?.succeed(le.dim("⚙️ no local portal config applied, using built-in")),{};r?.warn(`failed to load config file ${Zt(t.config)}, please check the path.`)}throw r?.fail("failed to resolve portal config"),r?.debug(e),e}},vl=async e=>{const{log:r}=e??{},n=await Qt(r),i={root:n.root,environment:"local",...e?.env,mode:"development",command:"serve"},o=await ml(i,n,{log:r,manifestPath:e?.manifest}),s=await gl(i,{log:r,config:e?.config}),a=t(await Rt(i,n),{server:{port:e?.server?.port,fs:{allow:[n.root]}}}),c={template:{portal:{id:o.name}},portal:{manifest:o,config:s}};r?.debug("vite config:",a),r?.debug("dev server config:",c),r?.start("Starting app development server...");const l=await Xr(i,c,a);return await l.listen(),r?.succeed(`Started app development server on ${l.resolvedUrls?.local?.[0]}`),l},yl=async e=>{const{log:t}=e??{},r=await Qt(t);t?.debug("package",r);const n={command:"build",mode:process.env.NODE_ENV??"production",root:r.root,...e?.env};t?.debug("env:",n);const i=await ml(n,r,{log:t,manifestPath:e?.manifest});return t?.debug("manifest:",i),{manifest:i,pkg:r,env:n}},El=async e=>{const{log:t}=e??{};t?.log(le.bold("Starting to build portal"));const{manifest:n,pkg:i,env:o}=await yl({log:t,manifest:e?.manifest});t?.start("loading vite config...");const s=await Rt(o,i);t?.succeed("vite config applied"),t?.debug("vite config:",s),t?.start("🤞🏻","building portal..."),t?.startNativeConsoleCapture(),await r(s),t?.stopNativeConsoleCapture(),t?.succeed("build completed 😘");return{pkg:i,manifest:n,outDir:s.build.outDir}},bl=async e=>{const{log:t,manifest:r}=e,n={command:"build",mode:process.env.NODE_ENV??"production",environment:null,root:process.cwd()},{pkg:i,manifest:o}=await El({log:t,manifest:r});if(!o.build)throw new Error("Manifest build config not found");const s=await(async(e,t)=>{const r=t?.file??[`portal.schema.${e.environment}`,"portal.schema"],n=await C(r,{baseDir:e.root,extensions:t?.extensions,script:{resolve:async t=>{const r="function"==typeof t.default?await Promise.resolve(t.default(e)):t.default;if(!r)throw new Error("Schema function did not return a valid schema");return r}}});return{schema:n.config,path:n.path,extension:n.extension}})(n,{file:e?.schema});t?.debug("Schema:",s);return{archive:await en(i,{log:t,archive:e?.archive,content:{"portal-template-manifest.json":JSON.stringify(o.build,null,2),"portal.schema.json":JSON.stringify(s.schema,null,2),"metadata.json":JSON.stringify({name:o.name,version:o.build.version})}}).catch(e=>{t?.error("Failed to create package:",e),process.exit(1)}),manifest:o,schema:s.schema}},wl=async e=>{const{log:t}=e??{},r=await Qt(t),n={command:"build",mode:process.env.NODE_ENV??"production",root:r.root,...e?.env},i=await gl(n,{log:t,config:e?.config});if(t?.debug("config:",i),e?.output){t?.start("writing config to file");try{await Jr(e.output,JSON.stringify(i,null,2)),t?.succeed("config written successfully",Zt(e.output,{relative:!0}))}catch(e){throw t?.fail("failed to write config"),e}}return{config:i,pkg:r}},Ll=async e=>{const{log:t,portal:r}=e,{config:n}=await wl({log:t,config:e.config,env:{environment:e.environment}});t?.start("Initializing Fusion Framework...");const i=await il({env:e.environment,auth:e.auth});t?.succeed("Initialized Fusion Framework");const o=await i.serviceDiscovery.createClient("portals");o.request$.subscribe(e=>{t?.debug("Request:",e),t?.info("🌎","Executing request to:",Zt(e.uri))}),t?.start("Publishing portal config"),t?.info("Using environment:",le.redBright(e.environment));try{const e=await o.json(`/portals/${r.name}@${r.version}/config`,{method:"PUT",body:n});t?.debug("Response:",e),t?.succeed("Published portal config")}catch(e){if(e instanceof sn)switch(e.response.status){case 410:t?.fail("🤬",`Portal ${r.name} is deleted from portals-service. Please check the portal key and try again.`);break;case 404:t?.fail("🤬",`Portal ${r.name} not found. Please check the portal key and try again.`);break;case 403:case 401:t?.fail("🤬","You are not authorized to publish portal config. Please check your permissions.");break;default:t?.fail("🤬","Failed to publish portal config.",`Status code: ${e.response.status}`,`Message: ${e.response.statusText}`)}throw e}};const Sl=async e=>{const{log:t,framework:r}=e,n="string"==typeof e.fileOrBundle?new Hr(e.fileOrBundle):e.fileOrBundle,{name:i}=e.name?{name:e.name}:await cl(n).catch(e=>{t?.error("Failed to resolve manifest:",e),process.exit(1)}),o=await n.toBufferPromise().catch(e=>{t?.error("Failed to read bundle content:",e),process.exit(1)});try{const e=await r.serviceDiscovery.createClient("portal-config");e.request$.subscribe(e=>{t?.info("🌎","Executing request to:",e.uri),t?.debug("Request:",e)});const n=await e.fetch(`/bundles/templates/${i}`,{method:"POST",body:new Blob([o],{type:"application/zip"}),headers:{"Content-Type":"application/zip"}});if(!n.ok){try{const{error:e}=await n.json();t?.debug("Error:",e),e.message&&t?.warn(le.red(`🤯 error: ${e.code}\n`),le.yellowBright(e.message),"\n")}catch(e){t?.debug("Error:",n.statusText)}!function(e,t){switch(e.status){case 409:throw new Error(`${e.status} - Version is already published, please generate a new release`);case 410:throw new Error(`${e.status} - ${t} is removed from Fusion`);case 404:throw new Error(`${e.status} - ${t} not found`);case 401:case 403:throw new Error(`${e.status} - This is not allowed for your role on ${t}`);case 500:throw new Error(`${e.status} - Internal server error, please try again later or contact support`);default:throw new Error(`Failed to upload bundle. HTTP status ${e.status}, ${e.statusText}`)}}(n,i)}t?.succeed("Successfully uploaded portal bundle"),t?.debug("Response:",n)}catch(e){t?.fail("🙅‍♂️","Failed to upload portal bundle"),t?.error(e),process.exit(1)}};var Cl;!function(e){e.Latest="latest",e.Preview="preview"}(Cl||(Cl={}));const Il=async e=>{const{tag:t,name:r,version:n,framework:i,log:o}=e;["latest","preview"].includes(t)||(o?.fail("🤪",'Invalid tag. Use "latest" or "preview".'),process.exit(1)),r||(o?.fail("🤪","Portal name is required."),process.exit(1)),n||(o?.fail("🤪","Version is required."),process.exit(1)),o?.info("Tagging portal:",le.greenBright(`${r}@${t}`,n));const s=await i.serviceDiscovery.createClient("portal-config");s.request$.subscribe(e=>{o?.debug("Request:",e),o?.info("🌎","Executing request to:",Zt(e.uri))}),o?.start("Tagging portal template...");try{const e=await s.json(`/templates/${r}/tags/${t}`,{method:"PUT",body:{version:n}});o?.debug("Response:",e),o?.succeed("Tagged portal template successfully"),o?.info("🚀",JSON.stringify(e))}catch(e){if(e instanceof sn){const{data:t,response:n}=e;switch(o?.debug("Error:",t),t&&o?.warn(le.red(`🤯 error: ${t.code}\n`),le.yellowBright(t.message),"\n"),n?.status){case 410:o?.fail(`🤬 - ${n?.status} -`,`${r} is deleted. Please check the name and try again.`);break;case 404:o?.fail(`🤬 - ${n?.status} -`,`${r} not found. Please check the name and try again.`);break;case 403:case 401:o?.fail(`🤬 - ${n?.status} -`,"You are not authorized to tag. Please check your permissions.");break;default:o?.fail(`🤬 - ${n?.status} -`,"Failed to tag",`Error: ${e.message}`)}}throw e}};export{ul as AllowedAppTags,Cl as AllowedPortalTags,Kr as ConsoleLogger,rl as FusionEnv,tr as buildApplication,El as buildPortal,tn as bundleApp,bl as bundlePortal,al as checkApp,nn as generateApplicationConfig,wl as generatePortalConfig,il as initializeFramework,er as loadAppManifest,yl as loadPortalManifest,en as pack,ol as publishAppConfig,Ll as publishPortalConfig,nl as resolveDefaultEnv,sl as startAppDevServer,vl as startPortalDevServer,fl as tagApplication,Il as tagPortal,ll as uploadApplication,Sl as uploadPortalBundle};