authhero 0.99.2 → 0.101.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/dist/authhero.cjs CHANGED
@@ -1,14 +1,14 @@
1
- "use strict";var Em=Object.defineProperty;var Im=(t,e,n)=>e in t?Em(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var te=(t,e,n)=>Im(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@hono/zod-openapi"),ne=t=>typeof t=="string",Ar=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},zu=t=>t==null?"":""+t,zm=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},Nm=/###/g,Nu=t=>t&&t.indexOf("###")>-1?t.replace(Nm,"."):t,Cu=t=>!t||ne(t),Or=(t,e,n)=>{const r=ne(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(Cu(t))return{};const s=Nu(r[i]);!t[s]&&n&&(t[s]=new n),Object.prototype.hasOwnProperty.call(t,s)?t=t[s]:t={},++i}return Cu(t)?{}:{obj:t,k:Nu(r[i])}},ju=(t,e,n)=>{const{obj:r,k:i}=Or(t,e,Object);if(r!==void 0||e.length===1){r[i]=n;return}let s=e[e.length-1],a=e.slice(0,e.length-1),c=Or(t,a,Object);for(;c.obj===void 0&&a.length;)s=`${a[a.length-1]}.${s}`,a=a.slice(0,a.length-1),c=Or(t,a,Object),c!=null&&c.obj&&typeof c.obj[`${c.k}.${s}`]<"u"&&(c.obj=void 0);c.obj[`${c.k}.${s}`]=n},Cm=(t,e,n,r)=>{const{obj:i,k:s}=Or(t,e,Object);i[s]=i[s]||[],i[s].push(n)},Yi=(t,e)=>{const{obj:n,k:r}=Or(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},jm=(t,e,n)=>{const r=Yi(t,n);return r!==void 0?r:Yi(e,n)},rf=(t,e,n)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?ne(t[r])||t[r]instanceof String||ne(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):rf(t[r],e[r],n):t[r]=e[r]);return t},Un=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var $m={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const Om=t=>ne(t)?t.replace(/[&<>"'\/]/g,e=>$m[e]):t;class Bm{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const n=this.regExpMap.get(e);if(n!==void 0)return n;const r=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,r),this.regExpQueue.push(e),r}}const Tm=[" ",",","?","!",";"],Pm=new Bm(20),Rm=(t,e,n)=>{e=e||"",n=n||"";const r=Tm.filter(a=>e.indexOf(a)<0&&n.indexOf(a)<0);if(r.length===0)return!0;const i=Pm.getRegExp(`(${r.map(a=>a==="?"?"\\?":a).join("|")})`);let s=!i.test(t);if(!s){const a=t.indexOf(n);a>0&&!i.test(t.substring(0,a))&&(s=!0)}return s},Sa=function(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:".";if(!t)return;if(t[e])return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;const r=e.split(n);let i=t;for(let s=0;s<r.length;){if(!i||typeof i!="object")return;let a,c="";for(let l=s;l<r.length;++l)if(l!==s&&(c+=n),c+=r[l],a=i[c],a!==void 0){if(["string","number","boolean"].indexOf(typeof a)>-1&&l<r.length-1)continue;s+=l-s+1;break}i=a}return i},Xi=t=>t==null?void 0:t.replace("_","-"),Lm={type:"logger",log(t){this.output("log",t)},warn(t){this.output("warn",t)},error(t){this.output("error",t)},output(t,e){var n,r;(r=(n=console==null?void 0:console[t])==null?void 0:n.apply)==null||r.call(n,console,e)}};class Qi{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.init(e,n)}init(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.prefix=n.prefix||"i18next:",this.logger=e||Lm,this.options=n,this.debug=n.debug}log(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.forward(n,"log","",!0)}warn(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.forward(n,"warn","",!0)}error(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.forward(n,"error","")}deprecate(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.forward(n,"warn","WARNING DEPRECATED: ",!0)}forward(e,n,r,i){return i&&!this.debug?null:(ne(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new Qi(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new Qi(this.logger,e)}}var St=new Qi;class Gs{constructor(){this.observers={}}on(e,n){return e.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);const i=this.observers[r].get(n)||0;this.observers[r].set(n,i+1)}),this}off(e,n){if(this.observers[e]){if(!n){delete this.observers[e];return}this.observers[e].delete(n)}}emit(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];this.observers[e]&&Array.from(this.observers[e].entries()).forEach(a=>{let[c,l]=a;for(let u=0;u<l;u++)c(...r)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(a=>{let[c,l]=a;for(let u=0;u<l;u++)c.apply(c,[e,...r])})}}class $u extends Gs{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{ns:["translation"],defaultNS:"translation"};super(),this.data=e||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){const n=this.options.ns.indexOf(e);n>-1&&this.options.ns.splice(n,1)}getResource(e,n,r){var u,p;let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const s=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,a=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let c;e.indexOf(".")>-1?c=e.split("."):(c=[e,n],r&&(Array.isArray(r)?c.push(...r):ne(r)&&s?c.push(...r.split(s)):c.push(r)));const l=Yi(this.data,c);return!l&&!n&&!r&&e.indexOf(".")>-1&&(e=c[0],n=c[1],r=c.slice(2).join(".")),l||!a||!ne(r)?l:Sa((p=(u=this.data)==null?void 0:u[e])==null?void 0:p[n],r,s)}addResource(e,n,r,i){let s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1};const a=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator;let c=[e,n];r&&(c=c.concat(a?r.split(a):r)),e.indexOf(".")>-1&&(c=e.split("."),i=n,n=c[1]),this.addNamespaces(n),ju(this.data,c,i),s.silent||this.emit("added",e,n,r,i)}addResources(e,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(const s in r)(ne(r[s])||Array.isArray(r[s]))&&this.addResource(e,n,s,r[s],{silent:!0});i.silent||this.emit("added",e,n,r)}addResourceBundle(e,n,r,i,s){let a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1,skipCopy:!1},c=[e,n];e.indexOf(".")>-1&&(c=e.split("."),i=r,r=n,n=c[1]),this.addNamespaces(n);let l=Yi(this.data,c)||{};a.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?rf(l,r,s):l={...l,...r},ju(this.data,c,l),a.silent||this.emit("added",e,n,r)}removeResourceBundle(e,n){this.hasResourceBundle(e,n)&&delete this.data[e][n],this.removeNamespaces(n),this.emit("removed",e,n)}hasResourceBundle(e,n){return this.getResource(e,n)!==void 0}getResourceBundle(e,n){return n||(n=this.options.defaultNS),this.getResource(e,n)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const n=this.getDataByLanguage(e);return!!(n&&Object.keys(n)||[]).find(i=>n[i]&&Object.keys(n[i]).length>0)}toJSON(){return this.data}}var sf={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,n,r,i){return t.forEach(s=>{var a;e=((a=this.processors[s])==null?void 0:a.process(e,n,r,i))??e}),e}};const Ou={};class es extends Gs{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),zm(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=St.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};if(e==null)return!1;const r=this.resolve(e,n);return(r==null?void 0:r.res)!==void 0}extractFromKey(e,n){let r=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");const i=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let s=n.ns||this.options.defaultNS||[];const a=r&&e.indexOf(r)>-1,c=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!Rm(e,r,i);if(a&&!c){const l=e.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:e,namespaces:ne(s)?[s]:s};const u=e.split(r);(r!==i||r===i&&this.options.ns.indexOf(u[0])>-1)&&(s=u.shift()),e=u.join(i)}return{key:e,namespaces:ne(s)?[s]:s}}translate(e,n,r){if(typeof n!="object"&&this.options.overloadTranslationOptionHandler&&(n=this.options.overloadTranslationOptionHandler(arguments)),typeof n=="object"&&(n={...n}),n||(n={}),e==null)return"";Array.isArray(e)||(e=[String(e)]);const i=n.returnDetails!==void 0?n.returnDetails:this.options.returnDetails,s=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator,{key:a,namespaces:c}=this.extractFromKey(e[e.length-1],n),l=c[c.length-1],u=n.lng||this.language,p=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if((u==null?void 0:u.toLowerCase())==="cimode"){if(p){const L=n.nsSeparator||this.options.nsSeparator;return i?{res:`${l}${L}${a}`,usedKey:a,exactUsedKey:a,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:`${l}${L}${a}`}return i?{res:a,usedKey:a,exactUsedKey:a,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:a}const h=this.resolve(e,n);let m=h==null?void 0:h.res;const v=(h==null?void 0:h.usedKey)||a,f=(h==null?void 0:h.exactUsedKey)||a,_=Object.prototype.toString.apply(m),w=["[object Number]","[object Function]","[object RegExp]"],S=n.joinArrays!==void 0?n.joinArrays:this.options.joinArrays,C=!this.i18nFormat||this.i18nFormat.handleAsObject,B=!ne(m)&&typeof m!="boolean"&&typeof m!="number";if(C&&m&&B&&w.indexOf(_)<0&&!(ne(S)&&Array.isArray(m))){if(!n.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const L=this.options.returnedObjectHandler?this.options.returnedObjectHandler(v,m,{...n,ns:c}):`key '${a} (${this.language})' returned an object instead of string.`;return i?(h.res=L,h.usedParams=this.getUsedParamsDetails(n),h):L}if(s){const L=Array.isArray(m),Q=L?[]:{},ce=L?f:v;for(const le in m)if(Object.prototype.hasOwnProperty.call(m,le)){const De=`${ce}${s}${le}`;Q[le]=this.translate(De,{...n,joinArrays:!1,ns:c}),Q[le]===De&&(Q[le]=m[le])}m=Q}}else if(C&&ne(S)&&Array.isArray(m))m=m.join(S),m&&(m=this.extendTranslation(m,e,n,r));else{let L=!1,Q=!1;const ce=n.count!==void 0&&!ne(n.count),le=es.hasDefaultValue(n),De=ce?this.pluralResolver.getSuffix(u,n.count,n):"",Ue=n.ordinal&&ce?this.pluralResolver.getSuffix(u,n.count,{ordinal:!1}):"",Re=ce&&!n.ordinal&&n.count===0,j=Re&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${De}`]||n[`defaultValue${Ue}`]||n.defaultValue;!this.isValidLookup(m)&&le&&(L=!0,m=j),this.isValidLookup(m)||(Q=!0,m=a);const E=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&Q?void 0:m,x=le&&j!==m&&this.options.updateMissing;if(Q||L||x){if(this.logger.log(x?"updateKey":"missingKey",u,l,a,x?j:m),s){const X=this.resolve(a,{...n,keySeparator:!1});X&&X.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let k=[];const $=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if(this.options.saveMissingTo==="fallback"&&$&&$[0])for(let X=0;X<$.length;X++)k.push($[X]);else this.options.saveMissingTo==="all"?k=this.languageUtils.toResolveHierarchy(n.lng||this.language):k.push(n.lng||this.language);const U=(X,G,ie)=>{var H;const de=le&&ie!==m?ie:E;this.options.missingKeyHandler?this.options.missingKeyHandler(X,l,G,de,x,n):(H=this.backendConnector)!=null&&H.saveMissing&&this.backendConnector.saveMissing(X,l,G,de,x,n),this.emit("missingKey",X,l,G,m)};this.options.saveMissing&&(this.options.saveMissingPlurals&&ce?k.forEach(X=>{const G=this.pluralResolver.getSuffixes(X,n);Re&&n[`defaultValue${this.options.pluralSeparator}zero`]&&G.indexOf(`${this.options.pluralSeparator}zero`)<0&&G.push(`${this.options.pluralSeparator}zero`),G.forEach(ie=>{U([X],a+ie,n[`defaultValue${ie}`]||j)})}):U(k,a,j))}m=this.extendTranslation(m,e,n,h,r),Q&&m===a&&this.options.appendNamespaceToMissingKey&&(m=`${l}:${a}`),(Q||L)&&this.options.parseMissingKeyHandler&&(m=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}:${a}`:a,L?m:void 0))}return i?(h.res=m,h.usedParams=this.getUsedParamsDetails(n),h):m}extendTranslation(e,n,r,i,s){var u,p;var a=this;if((u=this.i18nFormat)!=null&&u.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const h=ne(e)&&(((p=r==null?void 0:r.interpolation)==null?void 0:p.skipOnVariables)!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let m;if(h){const f=e.match(this.interpolator.nestingRegexp);m=f&&f.length}let v=r.replace&&!ne(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(v={...this.options.interpolation.defaultVariables,...v}),e=this.interpolator.interpolate(e,v,r.lng||this.language||i.usedLng,r),h){const f=e.match(this.interpolator.nestingRegexp),_=f&&f.length;m<_&&(r.nest=!1)}!r.lng&&i&&i.res&&(r.lng=this.language||i.usedLng),r.nest!==!1&&(e=this.interpolator.nest(e,function(){for(var f=arguments.length,_=new Array(f),w=0;w<f;w++)_[w]=arguments[w];return(s==null?void 0:s[0])===_[0]&&!r.context?(a.logger.warn(`It seems you are nesting recursively key: ${_[0]} in key: ${n[0]}`),null):a.translate(..._,n)},r)),r.interpolation&&this.interpolator.reset()}const c=r.postProcess||this.options.postProcess,l=ne(c)?[c]:c;return e!=null&&(l!=null&&l.length)&&r.applyPostProcessor!==!1&&(e=sf.handle(l,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),e}resolve(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r,i,s,a,c;return ne(e)&&(e=[e]),e.forEach(l=>{if(this.isValidLookup(r))return;const u=this.extractFromKey(l,n),p=u.key;i=p;let h=u.namespaces;this.options.fallbackNS&&(h=h.concat(this.options.fallbackNS));const m=n.count!==void 0&&!ne(n.count),v=m&&!n.ordinal&&n.count===0,f=n.context!==void 0&&(ne(n.context)||typeof n.context=="number")&&n.context!=="",_=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);h.forEach(w=>{var S,C;this.isValidLookup(r)||(c=w,!Ou[`${_[0]}-${w}`]&&((S=this.utils)!=null&&S.hasLoadedNamespace)&&!((C=this.utils)!=null&&C.hasLoadedNamespace(c))&&(Ou[`${_[0]}-${w}`]=!0,this.logger.warn(`key "${i}" for languages "${_.join(", ")}" won't get resolved as namespace "${c}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),_.forEach(B=>{var ce;if(this.isValidLookup(r))return;a=B;const L=[p];if((ce=this.i18nFormat)!=null&&ce.addLookupKeys)this.i18nFormat.addLookupKeys(L,p,B,w,n);else{let le;m&&(le=this.pluralResolver.getSuffix(B,n.count,n));const De=`${this.options.pluralSeparator}zero`,Ue=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(L.push(p+le),n.ordinal&&le.indexOf(Ue)===0&&L.push(p+le.replace(Ue,this.options.pluralSeparator)),v&&L.push(p+De)),f){const Re=`${p}${this.options.contextSeparator}${n.context}`;L.push(Re),m&&(L.push(Re+le),n.ordinal&&le.indexOf(Ue)===0&&L.push(Re+le.replace(Ue,this.options.pluralSeparator)),v&&L.push(Re+De))}}let Q;for(;Q=L.pop();)this.isValidLookup(r)||(s=Q,r=this.getResource(B,w,Q,n))}))})}),{res:r,usedKey:i,exactUsedKey:s,usedLng:a,usedNS:c}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,n,r){var s;let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return(s=this.i18nFormat)!=null&&s.getResource?this.i18nFormat.getResource(e,n,r,i):this.resourceStore.getResource(e,n,r,i)}getUsedParamsDetails(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=e.replace&&!ne(e.replace);let i=r?e.replace:e;if(r&&typeof e.count<"u"&&(i.count=e.count),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!r){i={...i};for(const s of n)delete i[s]}return i}static hasDefaultValue(e){const n="defaultValue";for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&n===r.substring(0,n.length)&&e[r]!==void 0)return!0;return!1}}class Bu{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=St.create("languageUtils")}getScriptPartFromCode(e){if(e=Xi(e),!e||e.indexOf("-")<0)return null;const n=e.split("-");return n.length===2||(n.pop(),n[n.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(e){if(e=Xi(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(ne(e)&&e.indexOf("-")>-1){let n;try{n=Intl.getCanonicalLocales(e)[0]}catch{}return n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let n;return e.forEach(r=>{if(n)return;const i=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(i))&&(n=i)}),!n&&this.options.supportedLngs&&e.forEach(r=>{if(n)return;const i=this.getLanguagePartFromCode(r);if(this.isSupportedCode(i))return n=i;n=this.options.supportedLngs.find(s=>{if(s===i)return s;if(!(s.indexOf("-")<0&&i.indexOf("-")<0)&&(s.indexOf("-")>0&&i.indexOf("-")<0&&s.substring(0,s.indexOf("-"))===i||s.indexOf(i)===0&&i.length>1))return s})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(e,n){if(!e)return[];if(typeof e=="function"&&(e=e(n)),ne(e)&&(e=[e]),Array.isArray(e))return e;if(!n)return e.default||[];let r=e[n];return r||(r=e[this.getScriptPartFromCode(n)]),r||(r=e[this.formatLanguageCode(n)]),r||(r=e[this.getLanguagePartFromCode(n)]),r||(r=e.default),r||[]}toResolveHierarchy(e,n){const r=this.getFallbackCodes(n||this.options.fallbackLng||[],e),i=[],s=a=>{a&&(this.isSupportedCode(a)?i.push(a):this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`))};return ne(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&s(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&s(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&s(this.getLanguagePartFromCode(e))):ne(e)&&s(this.formatLanguageCode(e)),r.forEach(a=>{i.indexOf(a)<0&&s(this.formatLanguageCode(a))}),i}}const Tu={zero:0,one:1,two:2,few:3,many:4,other:5},Pu={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Um{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=e,this.options=n,this.logger=St.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const r=Xi(e==="dev"?"en":e),i=n.ordinal?"ordinal":"cardinal",s=JSON.stringify({cleanedCode:r,type:i});if(s in this.pluralRulesCache)return this.pluralRulesCache[s];let a;try{a=new Intl.PluralRules(r,{type:i})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),Pu;if(!e.match(/-|_/))return Pu;const l=this.languageUtils.getLanguagePartFromCode(e);a=this.getRule(l,n)}return this.pluralRulesCache[s]=a,a}needsPlural(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),(r==null?void 0:r.resolvedOptions().pluralCategories.length)>1}getPluralFormsOfKey(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.getSuffixes(e,r).map(i=>`${n}${i}`)}getSuffixes(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),r?r.resolvedOptions().pluralCategories.sort((i,s)=>Tu[i]-Tu[s]).map(i=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${i}`):[]}getSuffix(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const i=this.getRule(e,r);return i?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${i.select(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,r))}}const Ru=function(t,e,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:".",i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,s=jm(t,e,n);return!s&&i&&ne(n)&&(s=Sa(t,n,r),s===void 0&&(s=Sa(e,n,r))),s},ta=t=>t.replace(/\$/g,"$$$$");class Vm{constructor(){var n;let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=St.create("interpolator"),this.options=e,this.format=((n=e==null?void 0:e.interpolation)==null?void 0:n.format)||(r=>r),this.init(e)}init(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};e.interpolation||(e.interpolation={escapeValue:!0});const{escape:n,escapeValue:r,useRawValueToEscape:i,prefix:s,prefixEscaped:a,suffix:c,suffixEscaped:l,formatSeparator:u,unescapeSuffix:p,unescapePrefix:h,nestingPrefix:m,nestingPrefixEscaped:v,nestingSuffix:f,nestingSuffixEscaped:_,nestingOptionsSeparator:w,maxReplaces:S,alwaysFormat:C}=e.interpolation;this.escape=n!==void 0?n:Om,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=s?Un(s):a||"{{",this.suffix=c?Un(c):l||"}}",this.formatSeparator=u||",",this.unescapePrefix=p?"":h||"-",this.unescapeSuffix=this.unescapePrefix?"":p||"",this.nestingPrefix=m?Un(m):v||Un("$t("),this.nestingSuffix=f?Un(f):_||Un(")"),this.nestingOptionsSeparator=w||",",this.maxReplaces=S||1e3,this.alwaysFormat=C!==void 0?C:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(n,r)=>(n==null?void 0:n.source)===r?(n.lastIndex=0,n):new RegExp(r,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}(.+?)${this.nestingSuffix}`)}interpolate(e,n,r,i){var v;let s,a,c;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=f=>{if(f.indexOf(this.formatSeparator)<0){const C=Ru(n,l,f,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(C,void 0,r,{...i,...n,interpolationkey:f}):C}const _=f.split(this.formatSeparator),w=_.shift().trim(),S=_.join(this.formatSeparator).trim();return this.format(Ru(n,l,w,this.options.keySeparator,this.options.ignoreJSONStructure),S,r,{...i,...n,interpolationkey:w})};this.resetRegExp();const p=(i==null?void 0:i.missingInterpolationHandler)||this.options.missingInterpolationHandler,h=((v=i==null?void 0:i.interpolation)==null?void 0:v.skipOnVariables)!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:f=>ta(f)},{regex:this.regexp,safeValue:f=>this.escapeValue?ta(this.escape(f)):ta(f)}].forEach(f=>{for(c=0;s=f.regex.exec(e);){const _=s[1].trim();if(a=u(_),a===void 0)if(typeof p=="function"){const S=p(e,s,i);a=ne(S)?S:""}else if(i&&Object.prototype.hasOwnProperty.call(i,_))a="";else if(h){a=s[0];continue}else this.logger.warn(`missed to pass in variable ${_} for interpolating ${e}`),a="";else!ne(a)&&!this.useRawValueToEscape&&(a=zu(a));const w=f.safeValue(a);if(e=e.replace(s[0],w),h?(f.regex.lastIndex+=a.length,f.regex.lastIndex-=s[0].length):f.regex.lastIndex=0,c++,c>=this.maxReplaces)break}}),e}nest(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i,s,a;const c=(l,u)=>{const p=this.nestingOptionsSeparator;if(l.indexOf(p)<0)return l;const h=l.split(new RegExp(`${p}[ ]*{`));let m=`{${h[1]}`;l=h[0],m=this.interpolate(m,a);const v=m.match(/'/g),f=m.match(/"/g);(((v==null?void 0:v.length)??0)%2===0&&!f||f.length%2!==0)&&(m=m.replace(/'/g,'"'));try{a=JSON.parse(m),u&&(a={...u,...a})}catch(_){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,_),`${l}${p}${m}`}return a.defaultValue&&a.defaultValue.indexOf(this.prefix)>-1&&delete a.defaultValue,l};for(;i=this.nestingRegexp.exec(e);){let l=[];a={...r},a=a.replace&&!ne(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;let u=!1;if(i[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(i[1])){const p=i[1].split(this.formatSeparator).map(h=>h.trim());i[1]=p.shift(),l=p,u=!0}if(s=n(c.call(this,i[1].trim(),a),a),s&&i[0]===e&&!ne(s))return s;ne(s)||(s=zu(s)),s||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),s=""),u&&(s=l.reduce((p,h)=>this.format(p,h,r.lng,{...r,interpolationkey:i[1].trim()}),s.trim())),e=e.replace(i[0],s),this.regexp.lastIndex=0}return e}}const qm=t=>{let e=t.toLowerCase().trim();const n={};if(t.indexOf("(")>-1){const r=t.split("(");e=r[0].toLowerCase().trim();const i=r[1].substring(0,r[1].length-1);e==="currency"&&i.indexOf(":")<0?n.currency||(n.currency=i.trim()):e==="relativetime"&&i.indexOf(":")<0?n.range||(n.range=i.trim()):i.split(";").forEach(a=>{if(a){const[c,...l]=a.split(":"),u=l.join(":").trim().replace(/^'+|'+$/g,""),p=c.trim();n[p]||(n[p]=u),u==="false"&&(n[p]=!1),u==="true"&&(n[p]=!0),isNaN(u)||(n[p]=parseInt(u,10))}})}return{formatName:e,formatOptions:n}},Vn=t=>{const e={};return(n,r,i)=>{let s=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(s={...s,[i.interpolationkey]:void 0});const a=r+JSON.stringify(s);let c=e[a];return c||(c=t(Xi(r),i),e[a]=c),c(n)}};class Mm{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=St.create("formatter"),this.options=e,this.formats={number:Vn((n,r)=>{const i=new Intl.NumberFormat(n,{...r});return s=>i.format(s)}),currency:Vn((n,r)=>{const i=new Intl.NumberFormat(n,{...r,style:"currency"});return s=>i.format(s)}),datetime:Vn((n,r)=>{const i=new Intl.DateTimeFormat(n,{...r});return s=>i.format(s)}),relativetime:Vn((n,r)=>{const i=new Intl.RelativeTimeFormat(n,{...r});return s=>i.format(s,r.range||"day")}),list:Vn((n,r)=>{const i=new Intl.ListFormat(n,{...r});return s=>i.format(s)})},this.init(e)}init(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};this.formatSeparator=n.interpolation.formatSeparator||","}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=Vn(n)}format(e,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const s=n.split(this.formatSeparator);if(s.length>1&&s[0].indexOf("(")>1&&s[0].indexOf(")")<0&&s.find(c=>c.indexOf(")")>-1)){const c=s.findIndex(l=>l.indexOf(")")>-1);s[0]=[s[0],...s.splice(1,c)].join(this.formatSeparator)}return s.reduce((c,l)=>{var h;const{formatName:u,formatOptions:p}=qm(l);if(this.formats[u]){let m=c;try{const v=((h=i==null?void 0:i.formatParams)==null?void 0:h[i.interpolationkey])||{},f=v.locale||v.lng||i.locale||i.lng||r;m=this.formats[u](c,f,{...p,...i,...v})}catch(v){this.logger.warn(v)}return m}else this.logger.warn(`there was no format function for ${u}`);return c},e)}}const Dm=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class Hm extends Gs{constructor(e,n,r){var s,a;let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=St.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],(a=(s=this.backend)==null?void 0:s.init)==null||a.call(s,r,i.backend,i)}queueLoad(e,n,r,i){const s={},a={},c={},l={};return e.forEach(u=>{let p=!0;n.forEach(h=>{const m=`${u}|${h}`;!r.reload&&this.store.hasResourceBundle(u,h)?this.state[m]=2:this.state[m]<0||(this.state[m]===1?a[m]===void 0&&(a[m]=!0):(this.state[m]=1,p=!1,a[m]===void 0&&(a[m]=!0),s[m]===void 0&&(s[m]=!0),l[h]===void 0&&(l[h]=!0)))}),p||(c[u]=!0)}),(Object.keys(s).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(s),pending:Object.keys(a),toLoadLanguages:Object.keys(c),toLoadNamespaces:Object.keys(l)}}loaded(e,n,r){const i=e.split("|"),s=i[0],a=i[1];n&&this.emit("failedLoading",s,a,n),!n&&r&&this.store.addResourceBundle(s,a,r,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&r&&(this.state[e]=0);const c={};this.queue.forEach(l=>{Cm(l.loaded,[s],a),Dm(l,e),n&&l.errors.push(n),l.pendingCount===0&&!l.done&&(Object.keys(l.loaded).forEach(u=>{c[u]||(c[u]={});const p=l.loaded[u];p.length&&p.forEach(h=>{c[u][h]===void 0&&(c[u][h]=!0)})}),l.done=!0,l.errors.length?l.callback(l.errors):l.callback())}),this.emit("loaded",c),this.queue=this.queue.filter(l=>!l.done)}read(e,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,a=arguments.length>5?arguments[5]:void 0;if(!e.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:n,fcName:r,tried:i,wait:s,callback:a});return}this.readingCalls++;const c=(u,p)=>{if(this.readingCalls--,this.waitingReads.length>0){const h=this.waitingReads.shift();this.read(h.lng,h.ns,h.fcName,h.tried,h.wait,h.callback)}if(u&&p&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,e,n,r,i+1,s*2,a)},s);return}a(u,p)},l=this.backend[r].bind(this.backend);if(l.length===2){try{const u=l(e,n);u&&typeof u.then=="function"?u.then(p=>c(null,p)).catch(c):c(null,u)}catch(u){c(u)}return}return l(e,n,c)}prepareLoading(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();ne(e)&&(e=this.languageUtils.toResolveHierarchy(e)),ne(n)&&(n=[n]);const s=this.queueLoad(e,n,r,i);if(!s.toLoad.length)return s.pending.length||i(),null;s.toLoad.forEach(a=>{this.loadOne(a)})}load(e,n,r){this.prepareLoading(e,n,{},r)}reload(e,n,r){this.prepareLoading(e,n,{reload:!0},r)}loadOne(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const r=e.split("|"),i=r[0],s=r[1];this.read(i,s,"read",void 0,void 0,(a,c)=>{a&&this.logger.warn(`${n}loading namespace ${s} for language ${i} failed`,a),!a&&c&&this.logger.log(`${n}loaded namespace ${s} for language ${i}`,c),this.loaded(e,a,c)})}saveMissing(e,n,r,i,s){var l,u,p,h,m;let a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{},c=arguments.length>6&&arguments[6]!==void 0?arguments[6]:()=>{};if((u=(l=this.services)==null?void 0:l.utils)!=null&&u.hasLoadedNamespace&&!((h=(p=this.services)==null?void 0:p.utils)!=null&&h.hasLoadedNamespace(n))){this.logger.warn(`did not save key "${r}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(r==null||r==="")){if((m=this.backend)!=null&&m.create){const v={...a,isUpdate:s},f=this.backend.create.bind(this.backend);if(f.length<6)try{let _;f.length===5?_=f(e,n,r,i,v):_=f(e,n,r,i),_&&typeof _.then=="function"?_.then(w=>c(null,w)).catch(c):c(null,_)}catch(_){c(_)}else f(e,n,r,i,c,v)}!e||!e[0]||this.store.addResource(e[0],n,r,i)}}}const Lu=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:t=>{let e={};if(typeof t[1]=="object"&&(e=t[1]),ne(t[1])&&(e.defaultValue=t[1]),ne(t[2])&&(e.tDescription=t[2]),typeof t[2]=="object"||typeof t[3]=="object"){const n=t[3]||t[2];Object.keys(n).forEach(r=>{e[r]=n[r]})}return e},interpolation:{escapeValue:!0,format:t=>t,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}),Uu=t=>{var e,n;return ne(t.ns)&&(t.ns=[t.ns]),ne(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),ne(t.fallbackNS)&&(t.fallbackNS=[t.fallbackNS]),((n=(e=t.supportedLngs)==null?void 0:e.indexOf)==null?void 0:n.call(e,"cimode"))<0&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),typeof t.initImmediate=="boolean"&&(t.initAsync=t.initImmediate),t},Ci=()=>{},Fm=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class qr extends Gs{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(super(),this.options=Uu(e),this.services={},this.logger=St,this.modules={external:[]},Fm(this),n&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,n),this;setTimeout(()=>{this.init(e,n)},0)}}init(){var e=this;let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;this.isInitializing=!0,typeof n=="function"&&(r=n,n={}),!n.defaultNS&&n.defaultNS!==!1&&n.ns&&(ne(n.ns)?n.defaultNS=n.ns:n.ns.indexOf("translation")<0&&(n.defaultNS=n.ns[0]));const i=Lu();this.options={...i,...this.options,...Uu(n)},this.options.interpolation={...i.interpolation,...this.options.interpolation},n.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=n.keySeparator),n.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=n.nsSeparator);const s=p=>p?typeof p=="function"?new p:p:null;if(!this.options.isClone){this.modules.logger?St.init(s(this.modules.logger),this.options):St.init(null,this.options);let p;this.modules.formatter?p=this.modules.formatter:p=Mm;const h=new Bu(this.options);this.store=new $u(this.options.resources,this.options);const m=this.services;m.logger=St,m.resourceStore=this.store,m.languageUtils=h,m.pluralResolver=new Um(h,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),p&&(!this.options.interpolation.format||this.options.interpolation.format===i.interpolation.format)&&(m.formatter=s(p),m.formatter.init(m,this.options),this.options.interpolation.format=m.formatter.format.bind(m.formatter)),m.interpolator=new Vm(this.options),m.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},m.backendConnector=new Hm(s(this.modules.backend),m.resourceStore,m,this.options),m.backendConnector.on("*",function(v){for(var f=arguments.length,_=new Array(f>1?f-1:0),w=1;w<f;w++)_[w-1]=arguments[w];e.emit(v,..._)}),this.modules.languageDetector&&(m.languageDetector=s(this.modules.languageDetector),m.languageDetector.init&&m.languageDetector.init(m,this.options.detection,this.options)),this.modules.i18nFormat&&(m.i18nFormat=s(this.modules.i18nFormat),m.i18nFormat.init&&m.i18nFormat.init(this)),this.translator=new es(this.services,this.options),this.translator.on("*",function(v){for(var f=arguments.length,_=new Array(f>1?f-1:0),w=1;w<f;w++)_[w-1]=arguments[w];e.emit(v,..._)}),this.modules.external.forEach(v=>{v.init&&v.init(this)})}if(this.format=this.options.interpolation.format,r||(r=Ci),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const p=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);p.length>0&&p[0]!=="dev"&&(this.options.lng=p[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(p=>{this[p]=function(){return e.store[p](...arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(p=>{this[p]=function(){return e.store[p](...arguments),e}});const l=Ar(),u=()=>{const p=(h,m)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),l.resolve(m),r(h,m)};if(this.languages&&!this.isInitialized)return p(null,this.t.bind(this));this.changeLanguage(this.options.lng,p)};return this.options.resources||!this.options.initAsync?u():setTimeout(u,0),l}loadResources(e){var s,a;let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Ci;const i=ne(e)?e:this.language;if(typeof e=="function"&&(r=e),!this.options.resources||this.options.partialBundledLanguages){if((i==null?void 0:i.toLowerCase())==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const c=[],l=u=>{if(!u||u==="cimode")return;this.services.languageUtils.toResolveHierarchy(u).forEach(h=>{h!=="cimode"&&c.indexOf(h)<0&&c.push(h)})};i?l(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(p=>l(p)),(a=(s=this.options.preload)==null?void 0:s.forEach)==null||a.call(s,u=>l(u)),this.services.backendConnector.load(c,this.options.ns,u=>{!u&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(u)})}else r(null)}reloadResources(e,n,r){const i=Ar();return typeof e=="function"&&(r=e,e=void 0),typeof n=="function"&&(r=n,n=void 0),e||(e=this.languages),n||(n=this.options.ns),r||(r=Ci),this.services.backendConnector.reload(e,n,s=>{i.resolve(),r(s)}),i}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return e.type==="backend"&&(this.modules.backend=e),(e.type==="logger"||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type==="languageDetector"&&(this.modules.languageDetector=e),e.type==="i18nFormat"&&(this.modules.i18nFormat=e),e.type==="postProcessor"&&sf.addPostProcessor(e),e.type==="formatter"&&(this.modules.formatter=e),e.type==="3rdParty"&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&!(["cimode","dev"].indexOf(e)>-1))for(let n=0;n<this.languages.length;n++){const r=this.languages[n];if(!(["cimode","dev"].indexOf(r)>-1)&&this.store.hasLanguageSomeTranslations(r)){this.resolvedLanguage=r;break}}}changeLanguage(e,n){var r=this;this.isLanguageChangingTo=e;const i=Ar();this.emit("languageChanging",e);const s=l=>{this.language=l,this.languages=this.services.languageUtils.toResolveHierarchy(l),this.resolvedLanguage=void 0,this.setResolvedLanguage(l)},a=(l,u)=>{u?(s(u),this.translator.changeLanguage(u),this.isLanguageChangingTo=void 0,this.emit("languageChanged",u),this.logger.log("languageChanged",u)):this.isLanguageChangingTo=void 0,i.resolve(function(){return r.t(...arguments)}),n&&n(l,function(){return r.t(...arguments)})},c=l=>{var p,h;!e&&!l&&this.services.languageDetector&&(l=[]);const u=ne(l)?l:this.services.languageUtils.getBestMatchFromCodes(l);u&&(this.language||s(u),this.translator.language||this.translator.changeLanguage(u),(h=(p=this.services.languageDetector)==null?void 0:p.cacheUserLanguage)==null||h.call(p,u)),this.loadResources(u,m=>{a(m,u)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?c(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(c):this.services.languageDetector.detect(c):c(e),i}getFixedT(e,n,r){var i=this;const s=function(a,c){let l;if(typeof c!="object"){for(var u=arguments.length,p=new Array(u>2?u-2:0),h=2;h<u;h++)p[h-2]=arguments[h];l=i.options.overloadTranslationOptionHandler([a,c].concat(p))}else l={...c};l.lng=l.lng||s.lng,l.lngs=l.lngs||s.lngs,l.ns=l.ns||s.ns,l.keyPrefix!==""&&(l.keyPrefix=l.keyPrefix||r||s.keyPrefix);const m=i.options.keySeparator||".";let v;return l.keyPrefix&&Array.isArray(a)?v=a.map(f=>`${l.keyPrefix}${m}${f}`):v=l.keyPrefix?`${l.keyPrefix}${m}${a}`:a,i.t(v,l)};return ne(e)?s.lng=e:s.lngs=e,s.ns=n,s.keyPrefix=r,s}t(){var i;for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return(i=this.translator)==null?void 0:i.translate(...n)}exists(){var i;for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return(i=this.translator)==null?void 0:i.exists(...n)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const r=n.lng||this.resolvedLanguage||this.languages[0],i=this.options?this.options.fallbackLng:!1,s=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const a=(c,l)=>{const u=this.services.backendConnector.state[`${c}|${l}`];return u===-1||u===0||u===2};if(n.precheck){const c=n.precheck(this,a);if(c!==void 0)return c}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(r,e)&&(!i||a(s,e)))}loadNamespaces(e,n){const r=Ar();return this.options.ns?(ne(e)&&(e=[e]),e.forEach(i=>{this.options.ns.indexOf(i)<0&&this.options.ns.push(i)}),this.loadResources(i=>{r.resolve(),n&&n(i)}),r):(n&&n(),Promise.resolve())}loadLanguages(e,n){const r=Ar();ne(e)&&(e=[e]);const i=this.options.preload||[],s=e.filter(a=>i.indexOf(a)<0&&this.services.languageUtils.isSupportedCode(a));return s.length?(this.options.preload=i.concat(s),this.loadResources(a=>{r.resolve(),n&&n(a)}),r):(n&&n(),Promise.resolve())}dir(e){var i,s;if(e||(e=this.resolvedLanguage||(((i=this.languages)==null?void 0:i.length)>0?this.languages[0]:this.language)),!e)return"rtl";const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],r=((s=this.services)==null?void 0:s.languageUtils)||new Bu(Lu());return n.indexOf(r.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;return new qr(e,n)}cloneInstance(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Ci;const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},s=new qr(i);if((e.debug!==void 0||e.prefix!==void 0)&&(s.logger=s.logger.clone(e)),["store","services","language"].forEach(c=>{s[c]=this[c]}),s.services={...this.services},s.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},r){const c=Object.keys(this.store.data).reduce((l,u)=>(l[u]={...this.store.data[u]},Object.keys(l[u]).reduce((p,h)=>(p[h]={...l[u][h]},p),{})),{});s.store=new $u(c,i),s.services.resourceStore=s.store}return s.translator=new es(s.services,i),s.translator.on("*",function(c){for(var l=arguments.length,u=new Array(l>1?l-1:0),p=1;p<l;p++)u[p-1]=arguments[p];s.emit(c,...u)}),s.init(i,n),s.translator.options=i,s.translator.backendConnector.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},s}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const P=qr.createInstance();P.createInstance=qr.createInstance;P.createInstance;P.dir;P.init;P.loadResources;P.reloadResources;P.use;P.changeLanguage;P.getFixedT;const se=P.t;P.exists;P.setDefaultNamespace;P.hasLoadedNamespace;P.loadNamespaces;P.loadLanguages;const nn=o.z.object({start:o.z.number(),limit:o.z.number(),length:o.z.number()}),of=o.z.object({created_at:o.z.string(),updated_at:o.z.string()}),af=o.z.object({email:o.z.string().optional(),email_verified:o.z.boolean().optional(),name:o.z.string().optional(),username:o.z.string().optional(),given_name:o.z.string().optional(),phone_number:o.z.string().optional(),phone_verified:o.z.boolean().optional(),family_name:o.z.string().optional()}).catchall(o.z.any()),cf=o.z.object({connection:o.z.string(),user_id:o.z.string(),provider:o.z.string(),isSocial:o.z.boolean(),access_token:o.z.string().optional(),access_token_secret:o.z.string().optional(),refresh_token:o.z.string().optional(),profileData:af.optional()}),Js=o.z.object({email:o.z.string().optional(),username:o.z.string().optional(),given_name:o.z.string().optional(),family_name:o.z.string().optional(),nickname:o.z.string().optional(),name:o.z.string().optional(),picture:o.z.string().optional(),locale:o.z.string().optional(),linked_to:o.z.string().optional(),profileData:o.z.string().optional(),user_id:o.z.string().optional(),app_metadata:o.z.any().default({}).optional(),user_metadata:o.z.any().default({}).optional()}),ts=Js.extend({email_verified:o.z.boolean().default(!1),verify_email:o.z.boolean().optional(),last_ip:o.z.string().optional(),last_login:o.z.string().optional(),user_id:o.z.string().optional(),provider:o.z.string().default("email"),connection:o.z.string().default("email"),is_social:o.z.boolean().optional()}),el=o.z.object({...ts.shape,...of.shape,user_id:o.z.string(),is_social:o.z.boolean(),email:o.z.string(),login_count:o.z.number(),identities:o.z.array(cf).optional()}),xt=el,Km=Js.extend({email:o.z.string(),login_count:o.z.number(),multifactor:o.z.array(o.z.string()).optional(),last_ip:o.z.string().optional(),last_login:o.z.string().optional(),user_id:o.z.string()}).catchall(o.z.any()),Wm="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Gm=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=Wm[n[t]&63];return e};const lf=o.z.object({audience:o.z.string().optional(),recipient:o.z.string().optional(),createUpnClaim:o.z.boolean().optional(),mapUnknownClaimsAsIs:o.z.boolean().optional(),passthroughClaimsWithNoMapping:o.z.boolean().optional(),mapIdentities:o.z.boolean().optional(),signatureAlgorithm:o.z.string().optional(),digestAlgorithm:o.z.string().optional(),issuer:o.z.string().optional(),destination:o.z.string().optional(),lifetimeInSeconds:o.z.number().optional(),signResponse:o.z.boolean().optional(),nameIdentifierFormat:o.z.string().optional(),nameIdentifierProbes:o.z.array(o.z.string()).optional(),authnContextClassRef:o.z.string().optional(),mappings:o.z.record(o.z.string()).optional()}),ns=o.z.object({id:o.z.string(),name:o.z.string(),callbacks:o.z.array(o.z.string()).default([]).optional().openapi({description:"Comma-separated list of URLs whitelisted to use as a callback to the client after authentication."}),allowed_origins:o.z.array(o.z.string()).default([]).optional().openapi({description:"Comma-separated list of URLs allowed to make requests from JavaScript to Auth0 API (typically used with CORS). By default, all your callback URLs will be allowed. This field allows you to enter other origins if necessary. You can also use wildcards at the subdomain level. Query strings and hash information are not taken into account when validating these URLs."}),web_origins:o.z.array(o.z.string()).default([]).optional().openapi({description:"Comma-separated list of allowed origins for use with Cross-Origin Authentication, Device Flow, and web message response mode."}),allowed_logout_urls:o.z.array(o.z.string()).default([]).optional().openapi({description:"Comma-separated list of URLs that are valid to redirect to after logout from Auth0. Wildcards are allowed for subdomains."}),allowed_clients:o.z.array(o.z.string()).default([]).optional().openapi({description:"Ids of clients that will be allowed to perform delegation requests. Clients that will be allowed to make delegation request. By default, all your clients will be allowed. This field allows you to specify specific clients"}),addons:o.z.object({samlp:lf.optional()}).default({}).optional().openapi({description:"Addons associated with the client. The key is the addon's package name and the value is an object with the configuration for the addon."}),email_validation:o.z.enum(["enabled","disabled","enforced"]).default("enforced").optional().openapi({description:"Defines if it possible to sign in with an unverified email and if verification emails will be sent. This is not available in auth0"}),client_secret:o.z.string().default(()=>Gm()).optional(),disable_sign_ups:o.z.boolean().optional().default(!1).openapi({description:"Prevents users from signing up using the hosted login page. This is not available in auth0"})}),mn=o.z.object({created_at:o.z.string().transform(t=>t===null?"":t),updated_at:o.z.string().transform(t=>t===null?"":t),...ns.shape});var Pt=(t=>(t.TOKEN="token",t.TOKEN_ID_TOKEN="token id_token",t.CODE="code",t))(Pt||{}),Yt=(t=>(t.QUERY="query",t.FRAGMENT="fragment",t.FORM_POST="form_post",t.WEB_MESSAGE="web_message",t.SAML_POST="saml_post",t))(Yt||{}),Zs=(t=>(t.S256="S256",t.Plain="plain",t))(Zs||{});const tl=o.z.object({client_id:o.z.string(),act_as:o.z.string().optional(),response_type:o.z.nativeEnum(Pt).optional(),response_mode:o.z.nativeEnum(Yt).optional(),redirect_uri:o.z.string().optional(),audience:o.z.string().optional(),organization:o.z.string().optional(),state:o.z.string().optional(),nonce:o.z.string().optional(),scope:o.z.string().optional(),prompt:o.z.string().optional(),code_challenge_method:o.z.nativeEnum(Zs).optional(),code_challenge:o.z.string().optional(),username:o.z.string().optional(),ui_locales:o.z.string().optional(),vendor_id:o.z.string().optional()}),Aa=o.z.object({colors:o.z.object({primary:o.z.string(),page_background:o.z.object({type:o.z.string().optional(),start:o.z.string().optional(),end:o.z.string().optional(),angle_deg:o.z.number().optional()}).optional()}).optional(),logo_url:o.z.string().optional(),favicon_url:o.z.string().optional(),font:o.z.object({url:o.z.string()}).optional()}),rs=o.z.object({id:o.z.string().optional(),name:o.z.string(),strategy:o.z.string(),options:o.z.object({kid:o.z.string().optional(),team_id:o.z.string().optional(),realms:o.z.string().optional(),client_id:o.z.string().optional(),client_secret:o.z.string().optional(),app_secret:o.z.string().optional(),scope:o.z.string().optional(),authorization_endpoint:o.z.string().default("").optional(),token_endpoint:o.z.string().default("").optional(),userinfo_endpoint:o.z.string().default("").optional(),jwks_uri:o.z.string().default("").optional(),discovery_url:o.z.string().default("").optional(),issuer:o.z.string().default("").optional()}).default({}).optional(),enabled_clients:o.z.array(o.z.string()).default([]).optional(),response_type:o.z.custom().optional(),response_mode:o.z.custom().optional()}),Ft=o.z.object({id:o.z.string(),created_at:o.z.string().transform(t=>t===null?"":t),updated_at:o.z.string().transform(t=>t===null?"":t)}).extend(rs.shape),is=o.z.object({name:o.z.string(),audience:o.z.string(),sender_email:o.z.string().email(),sender_name:o.z.string(),support_url:o.z.string().url().optional(),logo:o.z.string().url().optional(),primary_color:o.z.string().optional(),secondary_color:o.z.string().optional(),language:o.z.string().optional(),id:o.z.string().optional()}),Fn=o.z.object({created_at:o.z.string().transform(t=>t===null?"":t),updated_at:o.z.string().transform(t=>t===null?"":t),...is.shape,id:o.z.string()}),uf=o.z.object({logoUrl:o.z.string(),loginBackgroundImage:o.z.string().nullish(),style:o.z.object({primaryColor:o.z.string(),buttonTextColor:o.z.string(),primaryHoverColor:o.z.string()}),supportEmail:o.z.string().nullable(),supportUrl:o.z.string().nullable(),name:o.z.string(),showGreyishBackground:o.z.boolean().optional(),termsAndConditionsUrl:o.z.string().nullable(),companyName:o.z.string().optional(),checkoutHideSocial:o.z.boolean().optional(),siteUrl:o.z.string().nullable(),manageSubscriptionsUrl:o.z.string().optional()});o.z.object({...mn.shape,tenant:Fn,connections:o.z.array(Ft)});const df=o.z.enum(["password_reset","email_verification","otp","authorization_code","oauth2_state","ticket"]),pf=o.z.object({code_id:o.z.string().openapi({description:"The code that will be used in for instance an email verification flow"}),login_id:o.z.string().openapi({description:"The id of the login session that the code is connected to"}),connection_id:o.z.string().optional().openapi({description:"The connection that the code is connected to"}),code_type:df,code_verifier:o.z.string().optional().openapi({description:"The code verifier used in PKCE in outbound flows"}),expires_at:o.z.string(),used_at:o.z.string().optional(),user_id:o.z.string().optional()}),Jm=o.z.object({...pf.shape,created_at:o.z.string()}),nl=o.z.object({domain:o.z.string(),custom_domain_id:o.z.string().optional(),type:o.z.enum(["auth0_managed_certs","self_managed_certs"]),verification_method:o.z.enum(["txt"]).optional(),tls_policy:o.z.enum(["recommended"]).optional(),custom_client_ip_header:o.z.enum(["true-client-ip","cf-connecting-ip","x-forwarded-for","x-azure-clientip","null"]).optional(),domain_metadata:o.z.record(o.z.string().max(255)).optional()}),ff=o.z.object({name:o.z.literal("txt"),record:o.z.string(),domain:o.z.string()}),fn=o.z.object({...nl.shape,custom_domain_id:o.z.string(),primary:o.z.boolean(),status:o.z.enum(["disabled","pending","pending_verification","ready"]),origin_domain_name:o.z.string().optional(),verification:o.z.object({methods:o.z.array(ff)}).optional(),tls_policy:o.z.string().optional()}),ss=o.z.object({trigger_id:o.z.enum(["pre-user-signup","post-user-registration","post-user-login"]),enabled:o.z.boolean().default(!1),url:o.z.string(),hook_id:o.z.string().optional(),synchronous:o.z.boolean().default(!1),priority:o.z.number().optional()}),Dn=ss.extend({...of.shape,hook_id:o.z.string()}),rl=o.z.object({alg:o.z.enum(["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512"]),e:o.z.string(),kid:o.z.string(),kty:o.z.enum(["RSA","EC","oct"]),n:o.z.string(),x5t:o.z.string().optional(),x5c:o.z.array(o.z.string()).optional(),use:o.z.enum(["sig","enc"]).optional()}),hf=o.z.object({keys:o.z.array(rl)}),Ea=o.z.object({issuer:o.z.string(),authorization_endpoint:o.z.string(),token_endpoint:o.z.string(),device_authorization_endpoint:o.z.string(),userinfo_endpoint:o.z.string(),mfa_challenge_endpoint:o.z.string(),jwks_uri:o.z.string(),registration_endpoint:o.z.string(),revocation_endpoint:o.z.string(),scopes_supported:o.z.array(o.z.string()),response_types_supported:o.z.array(o.z.string()),code_challenge_methods_supported:o.z.array(o.z.string()),response_modes_supported:o.z.array(o.z.string()),subject_types_supported:o.z.array(o.z.string()),id_token_signing_alg_values_supported:o.z.array(o.z.string()),token_endpoint_auth_methods_supported:o.z.array(o.z.string()),claims_supported:o.z.array(o.z.string()),request_uri_parameter_supported:o.z.boolean(),request_parameter_supported:o.z.boolean(),token_endpoint_auth_signing_alg_values_supported:o.z.array(o.z.string())}),gf=o.z.object({csrf_token:o.z.string(),auth0Client:o.z.string().optional(),authParams:tl,expires_at:o.z.string(),deleted_at:o.z.string().optional(),ip:o.z.string().optional(),useragent:o.z.string().optional(),session_id:o.z.string().optional(),authorization_url:o.z.string().optional()}).openapi({description:"This represents a login sesion"}),Zm=o.z.object({...gf.shape,id:o.z.string().openapi({description:"This is is used as the state in the universal login"}),created_at:o.z.string(),updated_at:o.z.string()});var he=(t=>(t.FAILED_SILENT_AUTH="fsa",t.FAILED_SIGNUP="fs",t.FAILED_LOGIN="f",t.FAILED_LOGIN_INCORRECT_PASSWORD="fp",t.FAILED_CHANGE_PASSWORD="fcp",t.FAILED_BY_CONNECTOR="fc",t.FAILED_LOGIN_INVALID_EMAIL_USERNAME="fu",t.FAILED_HOOK="fh",t.FAILED_CROSS_ORIGIN_AUTHENTICATION="fcoa",t.SUCCESS_API_OPERATION="sapi",t.SUCCESS_CHANGE_PASSWORD="scp",t.SUCCESS_CHANGE_PASSWORD_REQUEST="scpr",t.SUCCESS_CHANGE_USERNAME="scu",t.SUCCESS_CROSS_ORIGIN_AUTHENTICATION="scoa",t.SUCCESS_EXCHANGE_AUTHORIZATION_CODE_FOR_ACCESS_TOKEN="seacft",t.SUCCESS_EXCHANGE_REFRESH_TOKEN_FOR_ACCESS_TOKEN="serft",t.SUCCESS_LOGIN="s",t.SUCCESS_LOGOUT="slo",t.SUCCESS_SIGNUP="ss",t.SUCCESS_SILENT_AUTH="ssa",t.SUCCESS_VERIFICATION_EMAIL="sv",t.SUCCESS_VERIFICATION_EMAIL_REQUEST="svr",t.CODE_LINK_SENT="cls",t.BLOCKED_ACCOUNT_EMAIL="limit_wc",t.BLOCKED_ACCOUNT_IP="limit_sul",t.BLOCKED_IP_ADDRESS="limit_mu",t))(he||{});const Ym=o.z.enum(["cls","fsa","fs","f","fc","fcoa","fcp","fh","fp","fs","fu","s","sapi","scoa","scp","scpr","scu","seacft","serft","slo","ss","ssa","sv","svr"]),mf=o.z.object({name:o.z.string(),version:o.z.string(),env:o.z.object({node:o.z.string().optional()}).optional()}),os=o.z.object({type:Ym,date:o.z.string(),description:o.z.string().optional(),log_id:o.z.string().optional(),_id:o.z.string().optional(),ip:o.z.string(),user_agent:o.z.string(),details:o.z.any().optional(),isMobile:o.z.boolean(),user_id:o.z.string().optional(),user_name:o.z.string().optional(),connection:o.z.string().optional(),connection_id:o.z.string().optional(),client_id:o.z.string().optional(),client_name:o.z.string().optional(),audience:o.z.string().optional(),scope:o.z.array(o.z.string()).optional(),strategy:o.z.string().optional(),strategy_type:o.z.string().optional(),hostname:o.z.string().optional(),auth0_client:mf.optional()}),_f=o.z.object({user_id:o.z.string(),password:o.z.string(),algorithm:o.z.enum(["bcrypt","argon2id"]).default("argon2id")}),Xm=o.z.object({..._f.shape,created_at:o.z.string(),updated_at:o.z.string()}),yf=o.z.object({initial_user_agent:o.z.string().describe("First user agent of the device from which this user logged in"),initial_ip:o.z.string().describe("First IP address associated with this session"),initial_asn:o.z.string().describe("First autonomous system number associated with this session"),last_user_agent:o.z.string().describe("Last user agent of the device from which this user logged in"),last_ip:o.z.string().describe("Last IP address from which this user logged in"),last_asn:o.z.string().describe("Last autonomous system number from which this user logged in")}),vf=o.z.object({id:o.z.string(),revoked_at:o.z.string().optional(),used_at:o.z.string().optional(),user_id:o.z.string().describe("The user ID associated with the session"),expires_at:o.z.string().optional(),idle_expires_at:o.z.string().optional(),device:yf.describe("Metadata related to the device used in the session"),clients:o.z.array(o.z.string()).describe("List of client details for the session")}),Ys=o.z.object({created_at:o.z.string(),updated_at:o.z.string(),authenticated_at:o.z.string(),last_interaction_at:o.z.string(),...vf.shape}),Ia=o.z.object({kid:o.z.string().openapi({description:"The key id of the signing key"}),cert:o.z.string().openapi({description:"The public certificate of the signing key"}),fingerprint:o.z.string().openapi({description:"The cert fingerprint"}),thumbprint:o.z.string().openapi({description:"The cert thumbprint"}),pkcs7:o.z.string().optional().openapi({description:"The private key in pkcs7 format"}),current:o.z.boolean().optional().openapi({description:"True if the key is the current key"}),next:o.z.boolean().optional().openapi({description:"True if the key is the next key"}),previous:o.z.boolean().optional().openapi({description:"True if the key is the previous key"}),current_since:o.z.string().optional().openapi({description:"The date and time when the key became the current key"}),current_until:o.z.string().optional().openapi({description:"The date and time when the current key was rotated"}),revoked:o.z.boolean().optional().openapi({description:"True if the key is revoked"}),revoked_at:o.z.string().optional().openapi({description:"The date and time when the key was revoked"})});var Br=(t=>(t.RefreshToken="refresh_token",t.AuthorizationCode="authorization_code",t.ClientCredential="client_credentials",t.Passwordless="passwordless",t.Password="password",t))(Br||{});const wf=o.z.object({access_token:o.z.string(),id_token:o.z.string().optional(),scope:o.z.string().optional(),state:o.z.string().optional(),refresh_token:o.z.string().optional(),token_type:o.z.string(),expires_in:o.z.number()});o.z.object({code:o.z.string(),state:o.z.string().optional()});const bf=o.z.object({button_border_radius:o.z.number(),button_border_weight:o.z.number(),buttons_style:o.z.enum(["pill"]),input_border_radius:o.z.number(),input_border_weight:o.z.number(),inputs_style:o.z.enum(["pill"]),show_widget_shadow:o.z.boolean(),widget_border_weight:o.z.number(),widget_corner_radius:o.z.number()}),kf=o.z.object({base_focus_color:o.z.string(),base_hover_color:o.z.string(),body_text:o.z.string(),captcha_widget_theme:o.z.enum(["auto"]),error:o.z.string(),header:o.z.string(),icons:o.z.string(),input_background:o.z.string(),input_border:o.z.string(),input_filled_text:o.z.string(),input_labels_placeholders:o.z.string(),links_focused_components:o.z.string(),primary_button:o.z.string(),primary_button_label:o.z.string(),secondary_button_border:o.z.string(),secondary_button_label:o.z.string(),success:o.z.string(),widget_background:o.z.string(),widget_border:o.z.string()}),hn=o.z.object({bold:o.z.boolean(),size:o.z.number()}),xf=o.z.object({body_text:hn,buttons_text:hn,font_url:o.z.string(),input_labels:hn,links:hn,links_style:o.z.enum(["normal"]),reference_text_size:o.z.number(),subtitle:hn,title:hn}),Sf=o.z.object({background_color:o.z.string(),background_image_url:o.z.string(),page_layout:o.z.enum(["center"])}),Af=o.z.object({header_text_alignment:o.z.enum(["center"]),logo_height:o.z.number(),logo_position:o.z.enum(["center"]),logo_url:o.z.string(),social_buttons_layout:o.z.enum(["bottom"])}),Ef=o.z.object({borders:bf,colors:kf,displayName:o.z.string(),fonts:xf,page_background:Sf,widget:Af}),Qm=Ef.extend({themeId:o.z.string()}),Li=o.z.object({universal_login_experience:o.z.enum(["new","classic"]).default("new"),identifier_first:o.z.boolean().default(!0),password_first:o.z.boolean().default(!1),webauthn_platform_first_factor:o.z.boolean()}),Ui=o.z.object({name:o.z.string(),enabled:o.z.boolean().optional().default(!0),default_from_address:o.z.string().optional(),credentials:o.z.union([o.z.object({accessKeyId:o.z.string(),secretAccessKey:o.z.string(),region:o.z.string()}),o.z.object({smtp_host:o.z.array(o.z.string()),smtp_port:o.z.number(),smtp_user:o.z.string(),smtp_pass:o.z.string()}),o.z.object({api_key:o.z.string(),domain:o.z.string().optional()}),o.z.object({connectionString:o.z.string()}),o.z.object({tenantId:o.z.string(),clientId:o.z.string(),clientSecret:o.z.string()})]),settings:o.z.object({}).optional()}),il=o.z.object({id:o.z.string(),session_id:o.z.string(),user_id:o.z.string(),client_id:o.z.string(),expires_at:o.z.string().optional(),idle_expires_at:o.z.string().optional(),last_exchanged_at:o.z.string().optional(),device:yf,resource_servers:o.z.array(o.z.object({audience:o.z.string(),scopes:o.z.string()})),rotating:o.z.boolean()}),e_=o.z.object({created_at:o.z.string(),...il.shape});function t_(t){const[e,n]=t.split("|");if(!e||!n)throw new Error(`Invalid user_id: ${t}`);return{connection:e,id:n}}const n_=new o.OpenAPIHono().openapi(o.createRoute({tags:["branding"],method:"get",path:"/",request:{headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Aa}},description:"Branding settings"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=await t.env.data.branding.get(e);return n?t.json(n):t.json({})}).openapi(o.createRoute({tags:["branding"],method:"patch",path:"/",request:{headers:o.z.object({"tenant-id":o.z.string()}),body:{content:{"application/json":{schema:o.z.object(Aa.shape).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Branding settings"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json");return await t.env.data.branding.set(e,n),t.text("OK")});var z=class extends Error{constructor(e=500,n){super(n==null?void 0:n.message,{cause:n==null?void 0:n.cause});te(this,"res");te(this,"status");this.res=n==null?void 0:n.res,this.status=e}getResponse(){return this.res?new Response(this.res.body,{status:this.status,headers:this.res.headers}):new Response(this.message,{status:this.status})}},as=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function If(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function r_(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var n=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(r){var i=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:function(){return t[r]}})}),n}function i_(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var zf={exports:{}};const s_={},o_=Object.freeze(Object.defineProperty({__proto__:null,default:s_},Symbol.toStringTag,{value:"Module"})),a_=r_(o_);(function(t){/**
1
+ "use strict";var Im=Object.defineProperty;var zm=(t,e,n)=>e in t?Im(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var te=(t,e,n)=>zm(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@hono/zod-openapi"),ne=t=>typeof t=="string",Ar=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},Nu=t=>t==null?"":""+t,Nm=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},Cm=/###/g,Cu=t=>t&&t.indexOf("###")>-1?t.replace(Cm,"."):t,ju=t=>!t||ne(t),Or=(t,e,n)=>{const r=ne(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(ju(t))return{};const s=Cu(r[i]);!t[s]&&n&&(t[s]=new n),Object.prototype.hasOwnProperty.call(t,s)?t=t[s]:t={},++i}return ju(t)?{}:{obj:t,k:Cu(r[i])}},$u=(t,e,n)=>{const{obj:r,k:i}=Or(t,e,Object);if(r!==void 0||e.length===1){r[i]=n;return}let s=e[e.length-1],a=e.slice(0,e.length-1),c=Or(t,a,Object);for(;c.obj===void 0&&a.length;)s=`${a[a.length-1]}.${s}`,a=a.slice(0,a.length-1),c=Or(t,a,Object),c!=null&&c.obj&&typeof c.obj[`${c.k}.${s}`]<"u"&&(c.obj=void 0);c.obj[`${c.k}.${s}`]=n},jm=(t,e,n,r)=>{const{obj:i,k:s}=Or(t,e,Object);i[s]=i[s]||[],i[s].push(n)},Yi=(t,e)=>{const{obj:n,k:r}=Or(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},$m=(t,e,n)=>{const r=Yi(t,n);return r!==void 0?r:Yi(e,n)},sf=(t,e,n)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?ne(t[r])||t[r]instanceof String||ne(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):sf(t[r],e[r],n):t[r]=e[r]);return t},Un=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Om={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const Bm=t=>ne(t)?t.replace(/[&<>"'\/]/g,e=>Om[e]):t;class Tm{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const n=this.regExpMap.get(e);if(n!==void 0)return n;const r=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,r),this.regExpQueue.push(e),r}}const Pm=[" ",",","?","!",";"],Rm=new Tm(20),Lm=(t,e,n)=>{e=e||"",n=n||"";const r=Pm.filter(a=>e.indexOf(a)<0&&n.indexOf(a)<0);if(r.length===0)return!0;const i=Rm.getRegExp(`(${r.map(a=>a==="?"?"\\?":a).join("|")})`);let s=!i.test(t);if(!s){const a=t.indexOf(n);a>0&&!i.test(t.substring(0,a))&&(s=!0)}return s},Sa=function(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:".";if(!t)return;if(t[e])return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;const r=e.split(n);let i=t;for(let s=0;s<r.length;){if(!i||typeof i!="object")return;let a,c="";for(let l=s;l<r.length;++l)if(l!==s&&(c+=n),c+=r[l],a=i[c],a!==void 0){if(["string","number","boolean"].indexOf(typeof a)>-1&&l<r.length-1)continue;s+=l-s+1;break}i=a}return i},Xi=t=>t==null?void 0:t.replace("_","-"),Um={type:"logger",log(t){this.output("log",t)},warn(t){this.output("warn",t)},error(t){this.output("error",t)},output(t,e){var n,r;(r=(n=console==null?void 0:console[t])==null?void 0:n.apply)==null||r.call(n,console,e)}};class Qi{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.init(e,n)}init(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.prefix=n.prefix||"i18next:",this.logger=e||Um,this.options=n,this.debug=n.debug}log(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.forward(n,"log","",!0)}warn(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.forward(n,"warn","",!0)}error(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.forward(n,"error","")}deprecate(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.forward(n,"warn","WARNING DEPRECATED: ",!0)}forward(e,n,r,i){return i&&!this.debug?null:(ne(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new Qi(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new Qi(this.logger,e)}}var St=new Qi;class Gs{constructor(){this.observers={}}on(e,n){return e.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);const i=this.observers[r].get(n)||0;this.observers[r].set(n,i+1)}),this}off(e,n){if(this.observers[e]){if(!n){delete this.observers[e];return}this.observers[e].delete(n)}}emit(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];this.observers[e]&&Array.from(this.observers[e].entries()).forEach(a=>{let[c,l]=a;for(let u=0;u<l;u++)c(...r)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(a=>{let[c,l]=a;for(let u=0;u<l;u++)c.apply(c,[e,...r])})}}class Ou extends Gs{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{ns:["translation"],defaultNS:"translation"};super(),this.data=e||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){const n=this.options.ns.indexOf(e);n>-1&&this.options.ns.splice(n,1)}getResource(e,n,r){var u,p;let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const s=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,a=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let c;e.indexOf(".")>-1?c=e.split("."):(c=[e,n],r&&(Array.isArray(r)?c.push(...r):ne(r)&&s?c.push(...r.split(s)):c.push(r)));const l=Yi(this.data,c);return!l&&!n&&!r&&e.indexOf(".")>-1&&(e=c[0],n=c[1],r=c.slice(2).join(".")),l||!a||!ne(r)?l:Sa((p=(u=this.data)==null?void 0:u[e])==null?void 0:p[n],r,s)}addResource(e,n,r,i){let s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1};const a=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator;let c=[e,n];r&&(c=c.concat(a?r.split(a):r)),e.indexOf(".")>-1&&(c=e.split("."),i=n,n=c[1]),this.addNamespaces(n),$u(this.data,c,i),s.silent||this.emit("added",e,n,r,i)}addResources(e,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(const s in r)(ne(r[s])||Array.isArray(r[s]))&&this.addResource(e,n,s,r[s],{silent:!0});i.silent||this.emit("added",e,n,r)}addResourceBundle(e,n,r,i,s){let a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1,skipCopy:!1},c=[e,n];e.indexOf(".")>-1&&(c=e.split("."),i=r,r=n,n=c[1]),this.addNamespaces(n);let l=Yi(this.data,c)||{};a.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?sf(l,r,s):l={...l,...r},$u(this.data,c,l),a.silent||this.emit("added",e,n,r)}removeResourceBundle(e,n){this.hasResourceBundle(e,n)&&delete this.data[e][n],this.removeNamespaces(n),this.emit("removed",e,n)}hasResourceBundle(e,n){return this.getResource(e,n)!==void 0}getResourceBundle(e,n){return n||(n=this.options.defaultNS),this.getResource(e,n)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const n=this.getDataByLanguage(e);return!!(n&&Object.keys(n)||[]).find(i=>n[i]&&Object.keys(n[i]).length>0)}toJSON(){return this.data}}var of={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,n,r,i){return t.forEach(s=>{var a;e=((a=this.processors[s])==null?void 0:a.process(e,n,r,i))??e}),e}};const Bu={};class es extends Gs{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Nm(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=St.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};if(e==null)return!1;const r=this.resolve(e,n);return(r==null?void 0:r.res)!==void 0}extractFromKey(e,n){let r=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");const i=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let s=n.ns||this.options.defaultNS||[];const a=r&&e.indexOf(r)>-1,c=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!Lm(e,r,i);if(a&&!c){const l=e.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:e,namespaces:ne(s)?[s]:s};const u=e.split(r);(r!==i||r===i&&this.options.ns.indexOf(u[0])>-1)&&(s=u.shift()),e=u.join(i)}return{key:e,namespaces:ne(s)?[s]:s}}translate(e,n,r){if(typeof n!="object"&&this.options.overloadTranslationOptionHandler&&(n=this.options.overloadTranslationOptionHandler(arguments)),typeof n=="object"&&(n={...n}),n||(n={}),e==null)return"";Array.isArray(e)||(e=[String(e)]);const i=n.returnDetails!==void 0?n.returnDetails:this.options.returnDetails,s=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator,{key:a,namespaces:c}=this.extractFromKey(e[e.length-1],n),l=c[c.length-1],u=n.lng||this.language,p=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if((u==null?void 0:u.toLowerCase())==="cimode"){if(p){const L=n.nsSeparator||this.options.nsSeparator;return i?{res:`${l}${L}${a}`,usedKey:a,exactUsedKey:a,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:`${l}${L}${a}`}return i?{res:a,usedKey:a,exactUsedKey:a,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:a}const h=this.resolve(e,n);let m=h==null?void 0:h.res;const v=(h==null?void 0:h.usedKey)||a,f=(h==null?void 0:h.exactUsedKey)||a,_=Object.prototype.toString.apply(m),w=["[object Number]","[object Function]","[object RegExp]"],S=n.joinArrays!==void 0?n.joinArrays:this.options.joinArrays,C=!this.i18nFormat||this.i18nFormat.handleAsObject,B=!ne(m)&&typeof m!="boolean"&&typeof m!="number";if(C&&m&&B&&w.indexOf(_)<0&&!(ne(S)&&Array.isArray(m))){if(!n.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const L=this.options.returnedObjectHandler?this.options.returnedObjectHandler(v,m,{...n,ns:c}):`key '${a} (${this.language})' returned an object instead of string.`;return i?(h.res=L,h.usedParams=this.getUsedParamsDetails(n),h):L}if(s){const L=Array.isArray(m),Q=L?[]:{},ce=L?f:v;for(const le in m)if(Object.prototype.hasOwnProperty.call(m,le)){const De=`${ce}${s}${le}`;Q[le]=this.translate(De,{...n,joinArrays:!1,ns:c}),Q[le]===De&&(Q[le]=m[le])}m=Q}}else if(C&&ne(S)&&Array.isArray(m))m=m.join(S),m&&(m=this.extendTranslation(m,e,n,r));else{let L=!1,Q=!1;const ce=n.count!==void 0&&!ne(n.count),le=es.hasDefaultValue(n),De=ce?this.pluralResolver.getSuffix(u,n.count,n):"",Ue=n.ordinal&&ce?this.pluralResolver.getSuffix(u,n.count,{ordinal:!1}):"",Re=ce&&!n.ordinal&&n.count===0,j=Re&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${De}`]||n[`defaultValue${Ue}`]||n.defaultValue;!this.isValidLookup(m)&&le&&(L=!0,m=j),this.isValidLookup(m)||(Q=!0,m=a);const E=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&Q?void 0:m,x=le&&j!==m&&this.options.updateMissing;if(Q||L||x){if(this.logger.log(x?"updateKey":"missingKey",u,l,a,x?j:m),s){const X=this.resolve(a,{...n,keySeparator:!1});X&&X.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let k=[];const $=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if(this.options.saveMissingTo==="fallback"&&$&&$[0])for(let X=0;X<$.length;X++)k.push($[X]);else this.options.saveMissingTo==="all"?k=this.languageUtils.toResolveHierarchy(n.lng||this.language):k.push(n.lng||this.language);const U=(X,G,ie)=>{var H;const de=le&&ie!==m?ie:E;this.options.missingKeyHandler?this.options.missingKeyHandler(X,l,G,de,x,n):(H=this.backendConnector)!=null&&H.saveMissing&&this.backendConnector.saveMissing(X,l,G,de,x,n),this.emit("missingKey",X,l,G,m)};this.options.saveMissing&&(this.options.saveMissingPlurals&&ce?k.forEach(X=>{const G=this.pluralResolver.getSuffixes(X,n);Re&&n[`defaultValue${this.options.pluralSeparator}zero`]&&G.indexOf(`${this.options.pluralSeparator}zero`)<0&&G.push(`${this.options.pluralSeparator}zero`),G.forEach(ie=>{U([X],a+ie,n[`defaultValue${ie}`]||j)})}):U(k,a,j))}m=this.extendTranslation(m,e,n,h,r),Q&&m===a&&this.options.appendNamespaceToMissingKey&&(m=`${l}:${a}`),(Q||L)&&this.options.parseMissingKeyHandler&&(m=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}:${a}`:a,L?m:void 0))}return i?(h.res=m,h.usedParams=this.getUsedParamsDetails(n),h):m}extendTranslation(e,n,r,i,s){var u,p;var a=this;if((u=this.i18nFormat)!=null&&u.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const h=ne(e)&&(((p=r==null?void 0:r.interpolation)==null?void 0:p.skipOnVariables)!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let m;if(h){const f=e.match(this.interpolator.nestingRegexp);m=f&&f.length}let v=r.replace&&!ne(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(v={...this.options.interpolation.defaultVariables,...v}),e=this.interpolator.interpolate(e,v,r.lng||this.language||i.usedLng,r),h){const f=e.match(this.interpolator.nestingRegexp),_=f&&f.length;m<_&&(r.nest=!1)}!r.lng&&i&&i.res&&(r.lng=this.language||i.usedLng),r.nest!==!1&&(e=this.interpolator.nest(e,function(){for(var f=arguments.length,_=new Array(f),w=0;w<f;w++)_[w]=arguments[w];return(s==null?void 0:s[0])===_[0]&&!r.context?(a.logger.warn(`It seems you are nesting recursively key: ${_[0]} in key: ${n[0]}`),null):a.translate(..._,n)},r)),r.interpolation&&this.interpolator.reset()}const c=r.postProcess||this.options.postProcess,l=ne(c)?[c]:c;return e!=null&&(l!=null&&l.length)&&r.applyPostProcessor!==!1&&(e=of.handle(l,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),e}resolve(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r,i,s,a,c;return ne(e)&&(e=[e]),e.forEach(l=>{if(this.isValidLookup(r))return;const u=this.extractFromKey(l,n),p=u.key;i=p;let h=u.namespaces;this.options.fallbackNS&&(h=h.concat(this.options.fallbackNS));const m=n.count!==void 0&&!ne(n.count),v=m&&!n.ordinal&&n.count===0,f=n.context!==void 0&&(ne(n.context)||typeof n.context=="number")&&n.context!=="",_=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);h.forEach(w=>{var S,C;this.isValidLookup(r)||(c=w,!Bu[`${_[0]}-${w}`]&&((S=this.utils)!=null&&S.hasLoadedNamespace)&&!((C=this.utils)!=null&&C.hasLoadedNamespace(c))&&(Bu[`${_[0]}-${w}`]=!0,this.logger.warn(`key "${i}" for languages "${_.join(", ")}" won't get resolved as namespace "${c}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),_.forEach(B=>{var ce;if(this.isValidLookup(r))return;a=B;const L=[p];if((ce=this.i18nFormat)!=null&&ce.addLookupKeys)this.i18nFormat.addLookupKeys(L,p,B,w,n);else{let le;m&&(le=this.pluralResolver.getSuffix(B,n.count,n));const De=`${this.options.pluralSeparator}zero`,Ue=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(L.push(p+le),n.ordinal&&le.indexOf(Ue)===0&&L.push(p+le.replace(Ue,this.options.pluralSeparator)),v&&L.push(p+De)),f){const Re=`${p}${this.options.contextSeparator}${n.context}`;L.push(Re),m&&(L.push(Re+le),n.ordinal&&le.indexOf(Ue)===0&&L.push(Re+le.replace(Ue,this.options.pluralSeparator)),v&&L.push(Re+De))}}let Q;for(;Q=L.pop();)this.isValidLookup(r)||(s=Q,r=this.getResource(B,w,Q,n))}))})}),{res:r,usedKey:i,exactUsedKey:s,usedLng:a,usedNS:c}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,n,r){var s;let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return(s=this.i18nFormat)!=null&&s.getResource?this.i18nFormat.getResource(e,n,r,i):this.resourceStore.getResource(e,n,r,i)}getUsedParamsDetails(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=e.replace&&!ne(e.replace);let i=r?e.replace:e;if(r&&typeof e.count<"u"&&(i.count=e.count),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!r){i={...i};for(const s of n)delete i[s]}return i}static hasDefaultValue(e){const n="defaultValue";for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&n===r.substring(0,n.length)&&e[r]!==void 0)return!0;return!1}}class Tu{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=St.create("languageUtils")}getScriptPartFromCode(e){if(e=Xi(e),!e||e.indexOf("-")<0)return null;const n=e.split("-");return n.length===2||(n.pop(),n[n.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(e){if(e=Xi(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(ne(e)&&e.indexOf("-")>-1){let n;try{n=Intl.getCanonicalLocales(e)[0]}catch{}return n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let n;return e.forEach(r=>{if(n)return;const i=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(i))&&(n=i)}),!n&&this.options.supportedLngs&&e.forEach(r=>{if(n)return;const i=this.getLanguagePartFromCode(r);if(this.isSupportedCode(i))return n=i;n=this.options.supportedLngs.find(s=>{if(s===i)return s;if(!(s.indexOf("-")<0&&i.indexOf("-")<0)&&(s.indexOf("-")>0&&i.indexOf("-")<0&&s.substring(0,s.indexOf("-"))===i||s.indexOf(i)===0&&i.length>1))return s})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(e,n){if(!e)return[];if(typeof e=="function"&&(e=e(n)),ne(e)&&(e=[e]),Array.isArray(e))return e;if(!n)return e.default||[];let r=e[n];return r||(r=e[this.getScriptPartFromCode(n)]),r||(r=e[this.formatLanguageCode(n)]),r||(r=e[this.getLanguagePartFromCode(n)]),r||(r=e.default),r||[]}toResolveHierarchy(e,n){const r=this.getFallbackCodes(n||this.options.fallbackLng||[],e),i=[],s=a=>{a&&(this.isSupportedCode(a)?i.push(a):this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`))};return ne(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&s(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&s(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&s(this.getLanguagePartFromCode(e))):ne(e)&&s(this.formatLanguageCode(e)),r.forEach(a=>{i.indexOf(a)<0&&s(this.formatLanguageCode(a))}),i}}const Pu={zero:0,one:1,two:2,few:3,many:4,other:5},Ru={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Vm{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=e,this.options=n,this.logger=St.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const r=Xi(e==="dev"?"en":e),i=n.ordinal?"ordinal":"cardinal",s=JSON.stringify({cleanedCode:r,type:i});if(s in this.pluralRulesCache)return this.pluralRulesCache[s];let a;try{a=new Intl.PluralRules(r,{type:i})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),Ru;if(!e.match(/-|_/))return Ru;const l=this.languageUtils.getLanguagePartFromCode(e);a=this.getRule(l,n)}return this.pluralRulesCache[s]=a,a}needsPlural(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),(r==null?void 0:r.resolvedOptions().pluralCategories.length)>1}getPluralFormsOfKey(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.getSuffixes(e,r).map(i=>`${n}${i}`)}getSuffixes(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),r?r.resolvedOptions().pluralCategories.sort((i,s)=>Pu[i]-Pu[s]).map(i=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${i}`):[]}getSuffix(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const i=this.getRule(e,r);return i?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${i.select(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,r))}}const Lu=function(t,e,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:".",i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,s=$m(t,e,n);return!s&&i&&ne(n)&&(s=Sa(t,n,r),s===void 0&&(s=Sa(e,n,r))),s},ta=t=>t.replace(/\$/g,"$$$$");class qm{constructor(){var n;let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=St.create("interpolator"),this.options=e,this.format=((n=e==null?void 0:e.interpolation)==null?void 0:n.format)||(r=>r),this.init(e)}init(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};e.interpolation||(e.interpolation={escapeValue:!0});const{escape:n,escapeValue:r,useRawValueToEscape:i,prefix:s,prefixEscaped:a,suffix:c,suffixEscaped:l,formatSeparator:u,unescapeSuffix:p,unescapePrefix:h,nestingPrefix:m,nestingPrefixEscaped:v,nestingSuffix:f,nestingSuffixEscaped:_,nestingOptionsSeparator:w,maxReplaces:S,alwaysFormat:C}=e.interpolation;this.escape=n!==void 0?n:Bm,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=s?Un(s):a||"{{",this.suffix=c?Un(c):l||"}}",this.formatSeparator=u||",",this.unescapePrefix=p?"":h||"-",this.unescapeSuffix=this.unescapePrefix?"":p||"",this.nestingPrefix=m?Un(m):v||Un("$t("),this.nestingSuffix=f?Un(f):_||Un(")"),this.nestingOptionsSeparator=w||",",this.maxReplaces=S||1e3,this.alwaysFormat=C!==void 0?C:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(n,r)=>(n==null?void 0:n.source)===r?(n.lastIndex=0,n):new RegExp(r,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}(.+?)${this.nestingSuffix}`)}interpolate(e,n,r,i){var v;let s,a,c;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=f=>{if(f.indexOf(this.formatSeparator)<0){const C=Lu(n,l,f,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(C,void 0,r,{...i,...n,interpolationkey:f}):C}const _=f.split(this.formatSeparator),w=_.shift().trim(),S=_.join(this.formatSeparator).trim();return this.format(Lu(n,l,w,this.options.keySeparator,this.options.ignoreJSONStructure),S,r,{...i,...n,interpolationkey:w})};this.resetRegExp();const p=(i==null?void 0:i.missingInterpolationHandler)||this.options.missingInterpolationHandler,h=((v=i==null?void 0:i.interpolation)==null?void 0:v.skipOnVariables)!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:f=>ta(f)},{regex:this.regexp,safeValue:f=>this.escapeValue?ta(this.escape(f)):ta(f)}].forEach(f=>{for(c=0;s=f.regex.exec(e);){const _=s[1].trim();if(a=u(_),a===void 0)if(typeof p=="function"){const S=p(e,s,i);a=ne(S)?S:""}else if(i&&Object.prototype.hasOwnProperty.call(i,_))a="";else if(h){a=s[0];continue}else this.logger.warn(`missed to pass in variable ${_} for interpolating ${e}`),a="";else!ne(a)&&!this.useRawValueToEscape&&(a=Nu(a));const w=f.safeValue(a);if(e=e.replace(s[0],w),h?(f.regex.lastIndex+=a.length,f.regex.lastIndex-=s[0].length):f.regex.lastIndex=0,c++,c>=this.maxReplaces)break}}),e}nest(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i,s,a;const c=(l,u)=>{const p=this.nestingOptionsSeparator;if(l.indexOf(p)<0)return l;const h=l.split(new RegExp(`${p}[ ]*{`));let m=`{${h[1]}`;l=h[0],m=this.interpolate(m,a);const v=m.match(/'/g),f=m.match(/"/g);(((v==null?void 0:v.length)??0)%2===0&&!f||f.length%2!==0)&&(m=m.replace(/'/g,'"'));try{a=JSON.parse(m),u&&(a={...u,...a})}catch(_){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,_),`${l}${p}${m}`}return a.defaultValue&&a.defaultValue.indexOf(this.prefix)>-1&&delete a.defaultValue,l};for(;i=this.nestingRegexp.exec(e);){let l=[];a={...r},a=a.replace&&!ne(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;let u=!1;if(i[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(i[1])){const p=i[1].split(this.formatSeparator).map(h=>h.trim());i[1]=p.shift(),l=p,u=!0}if(s=n(c.call(this,i[1].trim(),a),a),s&&i[0]===e&&!ne(s))return s;ne(s)||(s=Nu(s)),s||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),s=""),u&&(s=l.reduce((p,h)=>this.format(p,h,r.lng,{...r,interpolationkey:i[1].trim()}),s.trim())),e=e.replace(i[0],s),this.regexp.lastIndex=0}return e}}const Mm=t=>{let e=t.toLowerCase().trim();const n={};if(t.indexOf("(")>-1){const r=t.split("(");e=r[0].toLowerCase().trim();const i=r[1].substring(0,r[1].length-1);e==="currency"&&i.indexOf(":")<0?n.currency||(n.currency=i.trim()):e==="relativetime"&&i.indexOf(":")<0?n.range||(n.range=i.trim()):i.split(";").forEach(a=>{if(a){const[c,...l]=a.split(":"),u=l.join(":").trim().replace(/^'+|'+$/g,""),p=c.trim();n[p]||(n[p]=u),u==="false"&&(n[p]=!1),u==="true"&&(n[p]=!0),isNaN(u)||(n[p]=parseInt(u,10))}})}return{formatName:e,formatOptions:n}},Vn=t=>{const e={};return(n,r,i)=>{let s=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(s={...s,[i.interpolationkey]:void 0});const a=r+JSON.stringify(s);let c=e[a];return c||(c=t(Xi(r),i),e[a]=c),c(n)}};class Dm{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=St.create("formatter"),this.options=e,this.formats={number:Vn((n,r)=>{const i=new Intl.NumberFormat(n,{...r});return s=>i.format(s)}),currency:Vn((n,r)=>{const i=new Intl.NumberFormat(n,{...r,style:"currency"});return s=>i.format(s)}),datetime:Vn((n,r)=>{const i=new Intl.DateTimeFormat(n,{...r});return s=>i.format(s)}),relativetime:Vn((n,r)=>{const i=new Intl.RelativeTimeFormat(n,{...r});return s=>i.format(s,r.range||"day")}),list:Vn((n,r)=>{const i=new Intl.ListFormat(n,{...r});return s=>i.format(s)})},this.init(e)}init(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};this.formatSeparator=n.interpolation.formatSeparator||","}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=Vn(n)}format(e,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const s=n.split(this.formatSeparator);if(s.length>1&&s[0].indexOf("(")>1&&s[0].indexOf(")")<0&&s.find(c=>c.indexOf(")")>-1)){const c=s.findIndex(l=>l.indexOf(")")>-1);s[0]=[s[0],...s.splice(1,c)].join(this.formatSeparator)}return s.reduce((c,l)=>{var h;const{formatName:u,formatOptions:p}=Mm(l);if(this.formats[u]){let m=c;try{const v=((h=i==null?void 0:i.formatParams)==null?void 0:h[i.interpolationkey])||{},f=v.locale||v.lng||i.locale||i.lng||r;m=this.formats[u](c,f,{...p,...i,...v})}catch(v){this.logger.warn(v)}return m}else this.logger.warn(`there was no format function for ${u}`);return c},e)}}const Hm=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class Fm extends Gs{constructor(e,n,r){var s,a;let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=St.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],(a=(s=this.backend)==null?void 0:s.init)==null||a.call(s,r,i.backend,i)}queueLoad(e,n,r,i){const s={},a={},c={},l={};return e.forEach(u=>{let p=!0;n.forEach(h=>{const m=`${u}|${h}`;!r.reload&&this.store.hasResourceBundle(u,h)?this.state[m]=2:this.state[m]<0||(this.state[m]===1?a[m]===void 0&&(a[m]=!0):(this.state[m]=1,p=!1,a[m]===void 0&&(a[m]=!0),s[m]===void 0&&(s[m]=!0),l[h]===void 0&&(l[h]=!0)))}),p||(c[u]=!0)}),(Object.keys(s).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(s),pending:Object.keys(a),toLoadLanguages:Object.keys(c),toLoadNamespaces:Object.keys(l)}}loaded(e,n,r){const i=e.split("|"),s=i[0],a=i[1];n&&this.emit("failedLoading",s,a,n),!n&&r&&this.store.addResourceBundle(s,a,r,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&r&&(this.state[e]=0);const c={};this.queue.forEach(l=>{jm(l.loaded,[s],a),Hm(l,e),n&&l.errors.push(n),l.pendingCount===0&&!l.done&&(Object.keys(l.loaded).forEach(u=>{c[u]||(c[u]={});const p=l.loaded[u];p.length&&p.forEach(h=>{c[u][h]===void 0&&(c[u][h]=!0)})}),l.done=!0,l.errors.length?l.callback(l.errors):l.callback())}),this.emit("loaded",c),this.queue=this.queue.filter(l=>!l.done)}read(e,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,a=arguments.length>5?arguments[5]:void 0;if(!e.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:n,fcName:r,tried:i,wait:s,callback:a});return}this.readingCalls++;const c=(u,p)=>{if(this.readingCalls--,this.waitingReads.length>0){const h=this.waitingReads.shift();this.read(h.lng,h.ns,h.fcName,h.tried,h.wait,h.callback)}if(u&&p&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,e,n,r,i+1,s*2,a)},s);return}a(u,p)},l=this.backend[r].bind(this.backend);if(l.length===2){try{const u=l(e,n);u&&typeof u.then=="function"?u.then(p=>c(null,p)).catch(c):c(null,u)}catch(u){c(u)}return}return l(e,n,c)}prepareLoading(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();ne(e)&&(e=this.languageUtils.toResolveHierarchy(e)),ne(n)&&(n=[n]);const s=this.queueLoad(e,n,r,i);if(!s.toLoad.length)return s.pending.length||i(),null;s.toLoad.forEach(a=>{this.loadOne(a)})}load(e,n,r){this.prepareLoading(e,n,{},r)}reload(e,n,r){this.prepareLoading(e,n,{reload:!0},r)}loadOne(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const r=e.split("|"),i=r[0],s=r[1];this.read(i,s,"read",void 0,void 0,(a,c)=>{a&&this.logger.warn(`${n}loading namespace ${s} for language ${i} failed`,a),!a&&c&&this.logger.log(`${n}loaded namespace ${s} for language ${i}`,c),this.loaded(e,a,c)})}saveMissing(e,n,r,i,s){var l,u,p,h,m;let a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{},c=arguments.length>6&&arguments[6]!==void 0?arguments[6]:()=>{};if((u=(l=this.services)==null?void 0:l.utils)!=null&&u.hasLoadedNamespace&&!((h=(p=this.services)==null?void 0:p.utils)!=null&&h.hasLoadedNamespace(n))){this.logger.warn(`did not save key "${r}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(r==null||r==="")){if((m=this.backend)!=null&&m.create){const v={...a,isUpdate:s},f=this.backend.create.bind(this.backend);if(f.length<6)try{let _;f.length===5?_=f(e,n,r,i,v):_=f(e,n,r,i),_&&typeof _.then=="function"?_.then(w=>c(null,w)).catch(c):c(null,_)}catch(_){c(_)}else f(e,n,r,i,c,v)}!e||!e[0]||this.store.addResource(e[0],n,r,i)}}}const Uu=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:t=>{let e={};if(typeof t[1]=="object"&&(e=t[1]),ne(t[1])&&(e.defaultValue=t[1]),ne(t[2])&&(e.tDescription=t[2]),typeof t[2]=="object"||typeof t[3]=="object"){const n=t[3]||t[2];Object.keys(n).forEach(r=>{e[r]=n[r]})}return e},interpolation:{escapeValue:!0,format:t=>t,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}),Vu=t=>{var e,n;return ne(t.ns)&&(t.ns=[t.ns]),ne(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),ne(t.fallbackNS)&&(t.fallbackNS=[t.fallbackNS]),((n=(e=t.supportedLngs)==null?void 0:e.indexOf)==null?void 0:n.call(e,"cimode"))<0&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),typeof t.initImmediate=="boolean"&&(t.initAsync=t.initImmediate),t},Ci=()=>{},Km=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class qr extends Gs{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(super(),this.options=Vu(e),this.services={},this.logger=St,this.modules={external:[]},Km(this),n&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,n),this;setTimeout(()=>{this.init(e,n)},0)}}init(){var e=this;let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;this.isInitializing=!0,typeof n=="function"&&(r=n,n={}),!n.defaultNS&&n.defaultNS!==!1&&n.ns&&(ne(n.ns)?n.defaultNS=n.ns:n.ns.indexOf("translation")<0&&(n.defaultNS=n.ns[0]));const i=Uu();this.options={...i,...this.options,...Vu(n)},this.options.interpolation={...i.interpolation,...this.options.interpolation},n.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=n.keySeparator),n.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=n.nsSeparator);const s=p=>p?typeof p=="function"?new p:p:null;if(!this.options.isClone){this.modules.logger?St.init(s(this.modules.logger),this.options):St.init(null,this.options);let p;this.modules.formatter?p=this.modules.formatter:p=Dm;const h=new Tu(this.options);this.store=new Ou(this.options.resources,this.options);const m=this.services;m.logger=St,m.resourceStore=this.store,m.languageUtils=h,m.pluralResolver=new Vm(h,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),p&&(!this.options.interpolation.format||this.options.interpolation.format===i.interpolation.format)&&(m.formatter=s(p),m.formatter.init(m,this.options),this.options.interpolation.format=m.formatter.format.bind(m.formatter)),m.interpolator=new qm(this.options),m.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},m.backendConnector=new Fm(s(this.modules.backend),m.resourceStore,m,this.options),m.backendConnector.on("*",function(v){for(var f=arguments.length,_=new Array(f>1?f-1:0),w=1;w<f;w++)_[w-1]=arguments[w];e.emit(v,..._)}),this.modules.languageDetector&&(m.languageDetector=s(this.modules.languageDetector),m.languageDetector.init&&m.languageDetector.init(m,this.options.detection,this.options)),this.modules.i18nFormat&&(m.i18nFormat=s(this.modules.i18nFormat),m.i18nFormat.init&&m.i18nFormat.init(this)),this.translator=new es(this.services,this.options),this.translator.on("*",function(v){for(var f=arguments.length,_=new Array(f>1?f-1:0),w=1;w<f;w++)_[w-1]=arguments[w];e.emit(v,..._)}),this.modules.external.forEach(v=>{v.init&&v.init(this)})}if(this.format=this.options.interpolation.format,r||(r=Ci),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const p=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);p.length>0&&p[0]!=="dev"&&(this.options.lng=p[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(p=>{this[p]=function(){return e.store[p](...arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(p=>{this[p]=function(){return e.store[p](...arguments),e}});const l=Ar(),u=()=>{const p=(h,m)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),l.resolve(m),r(h,m)};if(this.languages&&!this.isInitialized)return p(null,this.t.bind(this));this.changeLanguage(this.options.lng,p)};return this.options.resources||!this.options.initAsync?u():setTimeout(u,0),l}loadResources(e){var s,a;let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Ci;const i=ne(e)?e:this.language;if(typeof e=="function"&&(r=e),!this.options.resources||this.options.partialBundledLanguages){if((i==null?void 0:i.toLowerCase())==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const c=[],l=u=>{if(!u||u==="cimode")return;this.services.languageUtils.toResolveHierarchy(u).forEach(h=>{h!=="cimode"&&c.indexOf(h)<0&&c.push(h)})};i?l(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(p=>l(p)),(a=(s=this.options.preload)==null?void 0:s.forEach)==null||a.call(s,u=>l(u)),this.services.backendConnector.load(c,this.options.ns,u=>{!u&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(u)})}else r(null)}reloadResources(e,n,r){const i=Ar();return typeof e=="function"&&(r=e,e=void 0),typeof n=="function"&&(r=n,n=void 0),e||(e=this.languages),n||(n=this.options.ns),r||(r=Ci),this.services.backendConnector.reload(e,n,s=>{i.resolve(),r(s)}),i}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return e.type==="backend"&&(this.modules.backend=e),(e.type==="logger"||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type==="languageDetector"&&(this.modules.languageDetector=e),e.type==="i18nFormat"&&(this.modules.i18nFormat=e),e.type==="postProcessor"&&of.addPostProcessor(e),e.type==="formatter"&&(this.modules.formatter=e),e.type==="3rdParty"&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&!(["cimode","dev"].indexOf(e)>-1))for(let n=0;n<this.languages.length;n++){const r=this.languages[n];if(!(["cimode","dev"].indexOf(r)>-1)&&this.store.hasLanguageSomeTranslations(r)){this.resolvedLanguage=r;break}}}changeLanguage(e,n){var r=this;this.isLanguageChangingTo=e;const i=Ar();this.emit("languageChanging",e);const s=l=>{this.language=l,this.languages=this.services.languageUtils.toResolveHierarchy(l),this.resolvedLanguage=void 0,this.setResolvedLanguage(l)},a=(l,u)=>{u?(s(u),this.translator.changeLanguage(u),this.isLanguageChangingTo=void 0,this.emit("languageChanged",u),this.logger.log("languageChanged",u)):this.isLanguageChangingTo=void 0,i.resolve(function(){return r.t(...arguments)}),n&&n(l,function(){return r.t(...arguments)})},c=l=>{var p,h;!e&&!l&&this.services.languageDetector&&(l=[]);const u=ne(l)?l:this.services.languageUtils.getBestMatchFromCodes(l);u&&(this.language||s(u),this.translator.language||this.translator.changeLanguage(u),(h=(p=this.services.languageDetector)==null?void 0:p.cacheUserLanguage)==null||h.call(p,u)),this.loadResources(u,m=>{a(m,u)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?c(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(c):this.services.languageDetector.detect(c):c(e),i}getFixedT(e,n,r){var i=this;const s=function(a,c){let l;if(typeof c!="object"){for(var u=arguments.length,p=new Array(u>2?u-2:0),h=2;h<u;h++)p[h-2]=arguments[h];l=i.options.overloadTranslationOptionHandler([a,c].concat(p))}else l={...c};l.lng=l.lng||s.lng,l.lngs=l.lngs||s.lngs,l.ns=l.ns||s.ns,l.keyPrefix!==""&&(l.keyPrefix=l.keyPrefix||r||s.keyPrefix);const m=i.options.keySeparator||".";let v;return l.keyPrefix&&Array.isArray(a)?v=a.map(f=>`${l.keyPrefix}${m}${f}`):v=l.keyPrefix?`${l.keyPrefix}${m}${a}`:a,i.t(v,l)};return ne(e)?s.lng=e:s.lngs=e,s.ns=n,s.keyPrefix=r,s}t(){var i;for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return(i=this.translator)==null?void 0:i.translate(...n)}exists(){var i;for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return(i=this.translator)==null?void 0:i.exists(...n)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const r=n.lng||this.resolvedLanguage||this.languages[0],i=this.options?this.options.fallbackLng:!1,s=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const a=(c,l)=>{const u=this.services.backendConnector.state[`${c}|${l}`];return u===-1||u===0||u===2};if(n.precheck){const c=n.precheck(this,a);if(c!==void 0)return c}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(r,e)&&(!i||a(s,e)))}loadNamespaces(e,n){const r=Ar();return this.options.ns?(ne(e)&&(e=[e]),e.forEach(i=>{this.options.ns.indexOf(i)<0&&this.options.ns.push(i)}),this.loadResources(i=>{r.resolve(),n&&n(i)}),r):(n&&n(),Promise.resolve())}loadLanguages(e,n){const r=Ar();ne(e)&&(e=[e]);const i=this.options.preload||[],s=e.filter(a=>i.indexOf(a)<0&&this.services.languageUtils.isSupportedCode(a));return s.length?(this.options.preload=i.concat(s),this.loadResources(a=>{r.resolve(),n&&n(a)}),r):(n&&n(),Promise.resolve())}dir(e){var i,s;if(e||(e=this.resolvedLanguage||(((i=this.languages)==null?void 0:i.length)>0?this.languages[0]:this.language)),!e)return"rtl";const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],r=((s=this.services)==null?void 0:s.languageUtils)||new Tu(Uu());return n.indexOf(r.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;return new qr(e,n)}cloneInstance(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Ci;const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},s=new qr(i);if((e.debug!==void 0||e.prefix!==void 0)&&(s.logger=s.logger.clone(e)),["store","services","language"].forEach(c=>{s[c]=this[c]}),s.services={...this.services},s.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},r){const c=Object.keys(this.store.data).reduce((l,u)=>(l[u]={...this.store.data[u]},Object.keys(l[u]).reduce((p,h)=>(p[h]={...l[u][h]},p),{})),{});s.store=new Ou(c,i),s.services.resourceStore=s.store}return s.translator=new es(s.services,i),s.translator.on("*",function(c){for(var l=arguments.length,u=new Array(l>1?l-1:0),p=1;p<l;p++)u[p-1]=arguments[p];s.emit(c,...u)}),s.init(i,n),s.translator.options=i,s.translator.backendConnector.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},s}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const P=qr.createInstance();P.createInstance=qr.createInstance;P.createInstance;P.dir;P.init;P.loadResources;P.reloadResources;P.use;P.changeLanguage;P.getFixedT;const se=P.t;P.exists;P.setDefaultNamespace;P.hasLoadedNamespace;P.loadNamespaces;P.loadLanguages;const rn=o.z.object({start:o.z.number(),limit:o.z.number(),length:o.z.number()}),af=o.z.object({created_at:o.z.string(),updated_at:o.z.string()}),cf=o.z.object({email:o.z.string().optional(),email_verified:o.z.boolean().optional(),name:o.z.string().optional(),username:o.z.string().optional(),given_name:o.z.string().optional(),phone_number:o.z.string().optional(),phone_verified:o.z.boolean().optional(),family_name:o.z.string().optional()}).catchall(o.z.any()),lf=o.z.object({connection:o.z.string(),user_id:o.z.string(),provider:o.z.string(),isSocial:o.z.boolean(),access_token:o.z.string().optional(),access_token_secret:o.z.string().optional(),refresh_token:o.z.string().optional(),profileData:cf.optional()}),Js=o.z.object({email:o.z.string().optional(),username:o.z.string().optional(),given_name:o.z.string().optional(),family_name:o.z.string().optional(),nickname:o.z.string().optional(),name:o.z.string().optional(),picture:o.z.string().optional(),locale:o.z.string().optional(),linked_to:o.z.string().optional(),profileData:o.z.string().optional(),user_id:o.z.string().optional(),app_metadata:o.z.any().default({}).optional(),user_metadata:o.z.any().default({}).optional()}),ts=Js.extend({email_verified:o.z.boolean().default(!1),verify_email:o.z.boolean().optional(),last_ip:o.z.string().optional(),last_login:o.z.string().optional(),user_id:o.z.string().optional(),provider:o.z.string().default("email"),connection:o.z.string().default("email"),is_social:o.z.boolean().optional()}),el=o.z.object({...ts.shape,...af.shape,user_id:o.z.string(),is_social:o.z.boolean(),email:o.z.string(),login_count:o.z.number(),identities:o.z.array(lf).optional()}),xt=el,Wm=Js.extend({email:o.z.string(),login_count:o.z.number(),multifactor:o.z.array(o.z.string()).optional(),last_ip:o.z.string().optional(),last_login:o.z.string().optional(),user_id:o.z.string()}).catchall(o.z.any()),Gm="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Jm=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=Gm[n[t]&63];return e};const uf=o.z.object({audience:o.z.string().optional(),recipient:o.z.string().optional(),createUpnClaim:o.z.boolean().optional(),mapUnknownClaimsAsIs:o.z.boolean().optional(),passthroughClaimsWithNoMapping:o.z.boolean().optional(),mapIdentities:o.z.boolean().optional(),signatureAlgorithm:o.z.string().optional(),digestAlgorithm:o.z.string().optional(),issuer:o.z.string().optional(),destination:o.z.string().optional(),lifetimeInSeconds:o.z.number().optional(),signResponse:o.z.boolean().optional(),nameIdentifierFormat:o.z.string().optional(),nameIdentifierProbes:o.z.array(o.z.string()).optional(),authnContextClassRef:o.z.string().optional(),mappings:o.z.record(o.z.string()).optional()}),ns=o.z.object({id:o.z.string(),name:o.z.string(),callbacks:o.z.array(o.z.string()).default([]).optional().openapi({description:"Comma-separated list of URLs whitelisted to use as a callback to the client after authentication."}),allowed_origins:o.z.array(o.z.string()).default([]).optional().openapi({description:"Comma-separated list of URLs allowed to make requests from JavaScript to Auth0 API (typically used with CORS). By default, all your callback URLs will be allowed. This field allows you to enter other origins if necessary. You can also use wildcards at the subdomain level. Query strings and hash information are not taken into account when validating these URLs."}),web_origins:o.z.array(o.z.string()).default([]).optional().openapi({description:"Comma-separated list of allowed origins for use with Cross-Origin Authentication, Device Flow, and web message response mode."}),allowed_logout_urls:o.z.array(o.z.string()).default([]).optional().openapi({description:"Comma-separated list of URLs that are valid to redirect to after logout from Auth0. Wildcards are allowed for subdomains."}),allowed_clients:o.z.array(o.z.string()).default([]).optional().openapi({description:"Ids of clients that will be allowed to perform delegation requests. Clients that will be allowed to make delegation request. By default, all your clients will be allowed. This field allows you to specify specific clients"}),addons:o.z.object({samlp:uf.optional()}).default({}).optional().openapi({description:"Addons associated with the client. The key is the addon's package name and the value is an object with the configuration for the addon."}),email_validation:o.z.enum(["enabled","disabled","enforced"]).default("enforced").optional().openapi({description:"Defines if it possible to sign in with an unverified email and if verification emails will be sent. This is not available in auth0"}),client_secret:o.z.string().default(()=>Jm()).optional(),disable_sign_ups:o.z.boolean().optional().default(!1).openapi({description:"Prevents users from signing up using the hosted login page. This is not available in auth0"})}),mn=o.z.object({created_at:o.z.string().transform(t=>t===null?"":t),updated_at:o.z.string().transform(t=>t===null?"":t),...ns.shape});var Pt=(t=>(t.TOKEN="token",t.TOKEN_ID_TOKEN="token id_token",t.CODE="code",t))(Pt||{}),Xt=(t=>(t.QUERY="query",t.FRAGMENT="fragment",t.FORM_POST="form_post",t.WEB_MESSAGE="web_message",t.SAML_POST="saml_post",t))(Xt||{}),Zs=(t=>(t.S256="S256",t.Plain="plain",t))(Zs||{});const tl=o.z.object({client_id:o.z.string(),act_as:o.z.string().optional(),response_type:o.z.nativeEnum(Pt).optional(),response_mode:o.z.nativeEnum(Xt).optional(),redirect_uri:o.z.string().optional(),audience:o.z.string().optional(),organization:o.z.string().optional(),state:o.z.string().optional(),nonce:o.z.string().optional(),scope:o.z.string().optional(),prompt:o.z.string().optional(),code_challenge_method:o.z.nativeEnum(Zs).optional(),code_challenge:o.z.string().optional(),username:o.z.string().optional(),ui_locales:o.z.string().optional(),vendor_id:o.z.string().optional()}),Aa=o.z.object({colors:o.z.object({primary:o.z.string(),page_background:o.z.object({type:o.z.string().optional(),start:o.z.string().optional(),end:o.z.string().optional(),angle_deg:o.z.number().optional()}).optional()}).optional(),logo_url:o.z.string().optional(),favicon_url:o.z.string().optional(),font:o.z.object({url:o.z.string()}).optional()}),rs=o.z.object({id:o.z.string().optional(),name:o.z.string(),strategy:o.z.string(),options:o.z.object({kid:o.z.string().optional(),team_id:o.z.string().optional(),realms:o.z.string().optional(),client_id:o.z.string().optional(),client_secret:o.z.string().optional(),app_secret:o.z.string().optional(),scope:o.z.string().optional(),authorization_endpoint:o.z.string().default("").optional(),token_endpoint:o.z.string().default("").optional(),userinfo_endpoint:o.z.string().default("").optional(),jwks_uri:o.z.string().default("").optional(),discovery_url:o.z.string().default("").optional(),issuer:o.z.string().default("").optional()}).default({}).optional(),enabled_clients:o.z.array(o.z.string()).default([]).optional(),response_type:o.z.custom().optional(),response_mode:o.z.custom().optional()}),Kt=o.z.object({id:o.z.string(),created_at:o.z.string().transform(t=>t===null?"":t),updated_at:o.z.string().transform(t=>t===null?"":t)}).extend(rs.shape),is=o.z.object({name:o.z.string(),audience:o.z.string(),sender_email:o.z.string().email(),sender_name:o.z.string(),support_url:o.z.string().url().optional(),logo:o.z.string().url().optional(),primary_color:o.z.string().optional(),secondary_color:o.z.string().optional(),language:o.z.string().optional(),id:o.z.string().optional()}),Fn=o.z.object({created_at:o.z.string().transform(t=>t===null?"":t),updated_at:o.z.string().transform(t=>t===null?"":t),...is.shape,id:o.z.string()}),df=o.z.object({logoUrl:o.z.string(),loginBackgroundImage:o.z.string().nullish(),style:o.z.object({primaryColor:o.z.string(),buttonTextColor:o.z.string(),primaryHoverColor:o.z.string()}),supportEmail:o.z.string().nullable(),supportUrl:o.z.string().nullable(),name:o.z.string(),showGreyishBackground:o.z.boolean().optional(),termsAndConditionsUrl:o.z.string().nullable(),companyName:o.z.string().optional(),checkoutHideSocial:o.z.boolean().optional(),siteUrl:o.z.string().nullable(),manageSubscriptionsUrl:o.z.string().optional()});o.z.object({...mn.shape,tenant:Fn,connections:o.z.array(Kt)});const pf=o.z.enum(["password_reset","email_verification","otp","authorization_code","oauth2_state","ticket"]),ff=o.z.object({code_id:o.z.string().openapi({description:"The code that will be used in for instance an email verification flow"}),login_id:o.z.string().openapi({description:"The id of the login session that the code is connected to"}),connection_id:o.z.string().optional().openapi({description:"The connection that the code is connected to"}),code_type:pf,code_verifier:o.z.string().optional().openapi({description:"The code verifier used in PKCE in outbound flows"}),expires_at:o.z.string(),used_at:o.z.string().optional(),user_id:o.z.string().optional()}),Zm=o.z.object({...ff.shape,created_at:o.z.string()}),nl=o.z.object({domain:o.z.string(),custom_domain_id:o.z.string().optional(),type:o.z.enum(["auth0_managed_certs","self_managed_certs"]),verification_method:o.z.enum(["txt"]).optional(),tls_policy:o.z.enum(["recommended"]).optional(),custom_client_ip_header:o.z.enum(["true-client-ip","cf-connecting-ip","x-forwarded-for","x-azure-clientip","null"]).optional(),domain_metadata:o.z.record(o.z.string().max(255)).optional()}),hf=o.z.object({name:o.z.literal("txt"),record:o.z.string(),domain:o.z.string()}),Ft=o.z.object({...nl.shape,custom_domain_id:o.z.string(),primary:o.z.boolean(),status:o.z.enum(["disabled","pending","pending_verification","ready"]),origin_domain_name:o.z.string().optional(),verification:o.z.object({methods:o.z.array(hf)}).optional(),tls_policy:o.z.string().optional()}),Ym=Ft.extend({tenant_id:o.z.string()}),ss=o.z.object({trigger_id:o.z.enum(["pre-user-signup","post-user-registration","post-user-login"]),enabled:o.z.boolean().default(!1),url:o.z.string(),hook_id:o.z.string().optional(),synchronous:o.z.boolean().default(!1),priority:o.z.number().optional()}),Dn=ss.extend({...af.shape,hook_id:o.z.string()}),rl=o.z.object({alg:o.z.enum(["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512"]),e:o.z.string(),kid:o.z.string(),kty:o.z.enum(["RSA","EC","oct"]),n:o.z.string(),x5t:o.z.string().optional(),x5c:o.z.array(o.z.string()).optional(),use:o.z.enum(["sig","enc"]).optional()}),gf=o.z.object({keys:o.z.array(rl)}),Ea=o.z.object({issuer:o.z.string(),authorization_endpoint:o.z.string(),token_endpoint:o.z.string(),device_authorization_endpoint:o.z.string(),userinfo_endpoint:o.z.string(),mfa_challenge_endpoint:o.z.string(),jwks_uri:o.z.string(),registration_endpoint:o.z.string(),revocation_endpoint:o.z.string(),scopes_supported:o.z.array(o.z.string()),response_types_supported:o.z.array(o.z.string()),code_challenge_methods_supported:o.z.array(o.z.string()),response_modes_supported:o.z.array(o.z.string()),subject_types_supported:o.z.array(o.z.string()),id_token_signing_alg_values_supported:o.z.array(o.z.string()),token_endpoint_auth_methods_supported:o.z.array(o.z.string()),claims_supported:o.z.array(o.z.string()),request_uri_parameter_supported:o.z.boolean(),request_parameter_supported:o.z.boolean(),token_endpoint_auth_signing_alg_values_supported:o.z.array(o.z.string())}),mf=o.z.object({csrf_token:o.z.string(),auth0Client:o.z.string().optional(),authParams:tl,expires_at:o.z.string(),deleted_at:o.z.string().optional(),ip:o.z.string().optional(),useragent:o.z.string().optional(),session_id:o.z.string().optional(),authorization_url:o.z.string().optional()}).openapi({description:"This represents a login sesion"}),Xm=o.z.object({...mf.shape,id:o.z.string().openapi({description:"This is is used as the state in the universal login"}),created_at:o.z.string(),updated_at:o.z.string()});var he=(t=>(t.FAILED_SILENT_AUTH="fsa",t.FAILED_SIGNUP="fs",t.FAILED_LOGIN="f",t.FAILED_LOGIN_INCORRECT_PASSWORD="fp",t.FAILED_CHANGE_PASSWORD="fcp",t.FAILED_BY_CONNECTOR="fc",t.FAILED_LOGIN_INVALID_EMAIL_USERNAME="fu",t.FAILED_HOOK="fh",t.FAILED_CROSS_ORIGIN_AUTHENTICATION="fcoa",t.SUCCESS_API_OPERATION="sapi",t.SUCCESS_CHANGE_PASSWORD="scp",t.SUCCESS_CHANGE_PASSWORD_REQUEST="scpr",t.SUCCESS_CHANGE_USERNAME="scu",t.SUCCESS_CROSS_ORIGIN_AUTHENTICATION="scoa",t.SUCCESS_EXCHANGE_AUTHORIZATION_CODE_FOR_ACCESS_TOKEN="seacft",t.SUCCESS_EXCHANGE_REFRESH_TOKEN_FOR_ACCESS_TOKEN="serft",t.SUCCESS_LOGIN="s",t.SUCCESS_LOGOUT="slo",t.SUCCESS_SIGNUP="ss",t.SUCCESS_SILENT_AUTH="ssa",t.SUCCESS_VERIFICATION_EMAIL="sv",t.SUCCESS_VERIFICATION_EMAIL_REQUEST="svr",t.CODE_LINK_SENT="cls",t.BLOCKED_ACCOUNT_EMAIL="limit_wc",t.BLOCKED_ACCOUNT_IP="limit_sul",t.BLOCKED_IP_ADDRESS="limit_mu",t))(he||{});const Qm=o.z.enum(["cls","fsa","fs","f","fc","fcoa","fcp","fh","fp","fs","fu","s","sapi","scoa","scp","scpr","scu","seacft","serft","slo","ss","ssa","sv","svr"]),_f=o.z.object({name:o.z.string(),version:o.z.string(),env:o.z.object({node:o.z.string().optional()}).optional()}),os=o.z.object({type:Qm,date:o.z.string(),description:o.z.string().optional(),log_id:o.z.string().optional(),_id:o.z.string().optional(),ip:o.z.string(),user_agent:o.z.string(),details:o.z.any().optional(),isMobile:o.z.boolean(),user_id:o.z.string().optional(),user_name:o.z.string().optional(),connection:o.z.string().optional(),connection_id:o.z.string().optional(),client_id:o.z.string().optional(),client_name:o.z.string().optional(),audience:o.z.string().optional(),scope:o.z.array(o.z.string()).optional(),strategy:o.z.string().optional(),strategy_type:o.z.string().optional(),hostname:o.z.string().optional(),auth0_client:_f.optional()}),yf=o.z.object({user_id:o.z.string(),password:o.z.string(),algorithm:o.z.enum(["bcrypt","argon2id"]).default("argon2id")}),e_=o.z.object({...yf.shape,created_at:o.z.string(),updated_at:o.z.string()}),vf=o.z.object({initial_user_agent:o.z.string().describe("First user agent of the device from which this user logged in"),initial_ip:o.z.string().describe("First IP address associated with this session"),initial_asn:o.z.string().describe("First autonomous system number associated with this session"),last_user_agent:o.z.string().describe("Last user agent of the device from which this user logged in"),last_ip:o.z.string().describe("Last IP address from which this user logged in"),last_asn:o.z.string().describe("Last autonomous system number from which this user logged in")}),wf=o.z.object({id:o.z.string(),revoked_at:o.z.string().optional(),used_at:o.z.string().optional(),user_id:o.z.string().describe("The user ID associated with the session"),expires_at:o.z.string().optional(),idle_expires_at:o.z.string().optional(),device:vf.describe("Metadata related to the device used in the session"),clients:o.z.array(o.z.string()).describe("List of client details for the session")}),Ys=o.z.object({created_at:o.z.string(),updated_at:o.z.string(),authenticated_at:o.z.string(),last_interaction_at:o.z.string(),...wf.shape}),Ia=o.z.object({kid:o.z.string().openapi({description:"The key id of the signing key"}),cert:o.z.string().openapi({description:"The public certificate of the signing key"}),fingerprint:o.z.string().openapi({description:"The cert fingerprint"}),thumbprint:o.z.string().openapi({description:"The cert thumbprint"}),pkcs7:o.z.string().optional().openapi({description:"The private key in pkcs7 format"}),current:o.z.boolean().optional().openapi({description:"True if the key is the current key"}),next:o.z.boolean().optional().openapi({description:"True if the key is the next key"}),previous:o.z.boolean().optional().openapi({description:"True if the key is the previous key"}),current_since:o.z.string().optional().openapi({description:"The date and time when the key became the current key"}),current_until:o.z.string().optional().openapi({description:"The date and time when the current key was rotated"}),revoked:o.z.boolean().optional().openapi({description:"True if the key is revoked"}),revoked_at:o.z.string().optional().openapi({description:"The date and time when the key was revoked"})});var Br=(t=>(t.RefreshToken="refresh_token",t.AuthorizationCode="authorization_code",t.ClientCredential="client_credentials",t.Passwordless="passwordless",t.Password="password",t))(Br||{});const bf=o.z.object({access_token:o.z.string(),id_token:o.z.string().optional(),scope:o.z.string().optional(),state:o.z.string().optional(),refresh_token:o.z.string().optional(),token_type:o.z.string(),expires_in:o.z.number()});o.z.object({code:o.z.string(),state:o.z.string().optional()});const kf=o.z.object({button_border_radius:o.z.number(),button_border_weight:o.z.number(),buttons_style:o.z.enum(["pill"]),input_border_radius:o.z.number(),input_border_weight:o.z.number(),inputs_style:o.z.enum(["pill"]),show_widget_shadow:o.z.boolean(),widget_border_weight:o.z.number(),widget_corner_radius:o.z.number()}),xf=o.z.object({base_focus_color:o.z.string(),base_hover_color:o.z.string(),body_text:o.z.string(),captcha_widget_theme:o.z.enum(["auto"]),error:o.z.string(),header:o.z.string(),icons:o.z.string(),input_background:o.z.string(),input_border:o.z.string(),input_filled_text:o.z.string(),input_labels_placeholders:o.z.string(),links_focused_components:o.z.string(),primary_button:o.z.string(),primary_button_label:o.z.string(),secondary_button_border:o.z.string(),secondary_button_label:o.z.string(),success:o.z.string(),widget_background:o.z.string(),widget_border:o.z.string()}),hn=o.z.object({bold:o.z.boolean(),size:o.z.number()}),Sf=o.z.object({body_text:hn,buttons_text:hn,font_url:o.z.string(),input_labels:hn,links:hn,links_style:o.z.enum(["normal"]),reference_text_size:o.z.number(),subtitle:hn,title:hn}),Af=o.z.object({background_color:o.z.string(),background_image_url:o.z.string(),page_layout:o.z.enum(["center"])}),Ef=o.z.object({header_text_alignment:o.z.enum(["center"]),logo_height:o.z.number(),logo_position:o.z.enum(["center"]),logo_url:o.z.string(),social_buttons_layout:o.z.enum(["bottom"])}),If=o.z.object({borders:kf,colors:xf,displayName:o.z.string(),fonts:Sf,page_background:Af,widget:Ef}),t_=If.extend({themeId:o.z.string()}),Li=o.z.object({universal_login_experience:o.z.enum(["new","classic"]).default("new"),identifier_first:o.z.boolean().default(!0),password_first:o.z.boolean().default(!1),webauthn_platform_first_factor:o.z.boolean()}),Ui=o.z.object({name:o.z.string(),enabled:o.z.boolean().optional().default(!0),default_from_address:o.z.string().optional(),credentials:o.z.union([o.z.object({accessKeyId:o.z.string(),secretAccessKey:o.z.string(),region:o.z.string()}),o.z.object({smtp_host:o.z.array(o.z.string()),smtp_port:o.z.number(),smtp_user:o.z.string(),smtp_pass:o.z.string()}),o.z.object({api_key:o.z.string(),domain:o.z.string().optional()}),o.z.object({connectionString:o.z.string()}),o.z.object({tenantId:o.z.string(),clientId:o.z.string(),clientSecret:o.z.string()})]),settings:o.z.object({}).optional()}),il=o.z.object({id:o.z.string(),session_id:o.z.string(),user_id:o.z.string(),client_id:o.z.string(),expires_at:o.z.string().optional(),idle_expires_at:o.z.string().optional(),last_exchanged_at:o.z.string().optional(),device:vf,resource_servers:o.z.array(o.z.object({audience:o.z.string(),scopes:o.z.string()})),rotating:o.z.boolean()}),n_=o.z.object({created_at:o.z.string(),...il.shape});function r_(t){const[e,n]=t.split("|");if(!e||!n)throw new Error(`Invalid user_id: ${t}`);return{connection:e,id:n}}const i_=new o.OpenAPIHono().openapi(o.createRoute({tags:["branding"],method:"get",path:"/",request:{headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Aa}},description:"Branding settings"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=await t.env.data.branding.get(e);return n?t.json(n):t.json({})}).openapi(o.createRoute({tags:["branding"],method:"patch",path:"/",request:{headers:o.z.object({"tenant-id":o.z.string()}),body:{content:{"application/json":{schema:o.z.object(Aa.shape).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Branding settings"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json");return await t.env.data.branding.set(e,n),t.text("OK")});var z=class extends Error{constructor(e=500,n){super(n==null?void 0:n.message,{cause:n==null?void 0:n.cause});te(this,"res");te(this,"status");this.res=n==null?void 0:n.res,this.status=e}getResponse(){return this.res?new Response(this.res.body,{status:this.status,headers:this.res.headers}):new Response(this.message,{status:this.status})}},as=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function zf(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function s_(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var n=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(r){var i=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:function(){return t[r]}})}),n}function o_(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Nf={exports:{}};const a_={},c_=Object.freeze(Object.defineProperty({__proto__:null,default:a_},Symbol.toStringTag,{value:"Module"})),l_=s_(c_);(function(t){/**
2
2
  * @license bcrypt.js (c) 2013 Daniel Wirtz <dcode@dcode.io>
3
3
  * Released under the Apache License, Version 2.0
4
4
  * see: https://github.com/dcodeIO/bcrypt.js for details
5
- */(function(e,n){typeof i_=="function"&&t&&t.exports?t.exports=n():(e.dcodeIO=e.dcodeIO||{}).bcrypt=n()})(as,function(){var e={},n=null;function r(j){if(t&&t.exports)try{return a_.randomBytes(j)}catch{}try{var N;return(self.crypto||self.msCrypto).getRandomValues(N=new Uint32Array(j)),Array.prototype.slice.call(N)}catch{}if(!n)throw Error("Neither WebCryptoAPI nor a crypto module is available. Use bcrypt.setRandomFallback to set an alternative");return n(j)}var i=!1;try{r(1),i=!0}catch{}n=null,e.setRandomFallback=function(j){n=j},e.genSaltSync=function(j,N){if(j=j||_,typeof j!="number")throw Error("Illegal arguments: "+typeof j+", "+typeof N);j<4?j=4:j>31&&(j=31);var E=[];return E.push("$2a$"),j<10&&E.push("0"),E.push(j.toString()),E.push("$"),E.push(h(r(f),f)),E.join("")},e.genSalt=function(j,N,E){if(typeof N=="function"&&(E=N,N=void 0),typeof j=="function"&&(E=j,j=void 0),typeof j>"u")j=_;else if(typeof j!="number")throw Error("illegal arguments: "+typeof j);function x(k){a(function(){try{k(null,e.genSaltSync(j))}catch($){k($)}})}if(E){if(typeof E!="function")throw Error("Illegal callback: "+typeof E);x(E)}else return new Promise(function(k,$){x(function(U,X){if(U){$(U);return}k(X)})})},e.hashSync=function(j,N){if(typeof N>"u"&&(N=_),typeof N=="number"&&(N=e.genSaltSync(N)),typeof j!="string"||typeof N!="string")throw Error("Illegal arguments: "+typeof j+", "+typeof N);return Re(j,N)},e.hash=function(j,N,E,x){function k($){typeof j=="string"&&typeof N=="number"?e.genSalt(N,function(U,X){Re(j,X,$,x)}):typeof j=="string"&&typeof N=="string"?Re(j,N,$,x):a($.bind(this,Error("Illegal arguments: "+typeof j+", "+typeof N)))}if(E){if(typeof E!="function")throw Error("Illegal callback: "+typeof E);k(E)}else return new Promise(function($,U){k(function(X,G){if(X){U(X);return}$(G)})})};function s(j,N){for(var E=0,x=0,k=0,$=j.length;k<$;++k)j.charCodeAt(k)===N.charCodeAt(k)?++E:++x;return E<0?!1:x===0}e.compareSync=function(j,N){if(typeof j!="string"||typeof N!="string")throw Error("Illegal arguments: "+typeof j+", "+typeof N);return N.length!==60?!1:s(e.hashSync(j,N.substr(0,N.length-31)),N)},e.compare=function(j,N,E,x){function k($){if(typeof j!="string"||typeof N!="string"){a($.bind(this,Error("Illegal arguments: "+typeof j+", "+typeof N)));return}if(N.length!==60){a($.bind(this,null,!1));return}e.hash(j,N.substr(0,29),function(U,X){U?$(U):$(null,s(X,N))},x)}if(E){if(typeof E!="function")throw Error("Illegal callback: "+typeof E);k(E)}else return new Promise(function($,U){k(function(X,G){if(X){U(X);return}$(G)})})},e.getRounds=function(j){if(typeof j!="string")throw Error("Illegal arguments: "+typeof j);return parseInt(j.split("$")[2],10)},e.getSalt=function(j){if(typeof j!="string")throw Error("Illegal arguments: "+typeof j);if(j.length!==60)throw Error("Illegal hash length: "+j.length+" != 60");return j.substring(0,29)};var a=typeof process<"u"&&process&&typeof process.nextTick=="function"?typeof setImmediate=="function"?setImmediate:process.nextTick:setTimeout;function c(j){var N=[],E=0;return v.encodeUTF16toUTF8(function(){return E>=j.length?null:j.charCodeAt(E++)},function(x){N.push(x)}),N}var l="./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),u=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,54,55,56,57,58,59,60,61,62,63,-1,-1,-1,-1,-1,-1,-1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,-1,-1,-1,-1,-1,-1,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,-1,-1,-1,-1,-1],p=String.fromCharCode;function h(j,N){var E=0,x=[],k,$;if(N<=0||N>j.length)throw Error("Illegal len: "+N);for(;E<N;){if(k=j[E++]&255,x.push(l[k>>2&63]),k=(k&3)<<4,E>=N){x.push(l[k&63]);break}if($=j[E++]&255,k|=$>>4&15,x.push(l[k&63]),k=($&15)<<2,E>=N){x.push(l[k&63]);break}$=j[E++]&255,k|=$>>6&3,x.push(l[k&63]),x.push(l[$&63])}return x.join("")}function m(j,N){var E=0,x=j.length,k=0,$=[],U,X,G,ie,de,H;if(N<=0)throw Error("Illegal len: "+N);for(;E<x-1&&k<N&&(H=j.charCodeAt(E++),U=H<u.length?u[H]:-1,H=j.charCodeAt(E++),X=H<u.length?u[H]:-1,!(U==-1||X==-1||(de=U<<2>>>0,de|=(X&48)>>4,$.push(p(de)),++k>=N||E>=x)||(H=j.charCodeAt(E++),G=H<u.length?u[H]:-1,G==-1)||(de=(X&15)<<4>>>0,de|=(G&60)>>2,$.push(p(de)),++k>=N||E>=x)));)H=j.charCodeAt(E++),ie=H<u.length?u[H]:-1,de=(G&3)<<6>>>0,de|=ie,$.push(p(de)),++k;var Ne=[];for(E=0;E<k;E++)Ne.push($[E].charCodeAt(0));return Ne}var v=function(){var j={};return j.MAX_CODEPOINT=1114111,j.encodeUTF8=function(N,E){var x=null;for(typeof N=="number"&&(x=N,N=function(){return null});x!==null||(x=N())!==null;)x<128?E(x&127):x<2048?(E(x>>6&31|192),E(x&63|128)):x<65536?(E(x>>12&15|224),E(x>>6&63|128),E(x&63|128)):(E(x>>18&7|240),E(x>>12&63|128),E(x>>6&63|128),E(x&63|128)),x=null},j.decodeUTF8=function(N,E){for(var x,k,$,U,X=function(G){G=G.slice(0,G.indexOf(null));var ie=Error(G.toString());throw ie.name="TruncatedError",ie.bytes=G,ie};(x=N())!==null;)if(!(x&128))E(x);else if((x&224)===192)(k=N())===null&&X([x,k]),E((x&31)<<6|k&63);else if((x&240)===224)((k=N())===null||($=N())===null)&&X([x,k,$]),E((x&15)<<12|(k&63)<<6|$&63);else if((x&248)===240)((k=N())===null||($=N())===null||(U=N())===null)&&X([x,k,$,U]),E((x&7)<<18|(k&63)<<12|($&63)<<6|U&63);else throw RangeError("Illegal starting byte: "+x)},j.UTF16toUTF8=function(N,E){for(var x,k=null;(x=k!==null?k:N())!==null;){if(x>=55296&&x<=57343&&(k=N())!==null&&k>=56320&&k<=57343){E((x-55296)*1024+k-56320+65536),k=null;continue}E(x)}k!==null&&E(k)},j.UTF8toUTF16=function(N,E){var x=null;for(typeof N=="number"&&(x=N,N=function(){return null});x!==null||(x=N())!==null;)x<=65535?E(x):(x-=65536,E((x>>10)+55296),E(x%1024+56320)),x=null},j.encodeUTF16toUTF8=function(N,E){j.UTF16toUTF8(N,function(x){j.encodeUTF8(x,E)})},j.decodeUTF8toUTF16=function(N,E){j.decodeUTF8(N,function(x){j.UTF8toUTF16(x,E)})},j.calculateCodePoint=function(N){return N<128?1:N<2048?2:N<65536?3:4},j.calculateUTF8=function(N){for(var E,x=0;(E=N())!==null;)x+=j.calculateCodePoint(E);return x},j.calculateUTF16asUTF8=function(N){var E=0,x=0;return j.UTF16toUTF8(N,function(k){++E,x+=j.calculateCodePoint(k)}),[E,x]},j}();Date.now=Date.now||function(){return+new Date};var f=16,_=10,w=16,S=100,C=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731],B=[3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,1904987480,2182433518,2069144605,3260701109,2620446009,720527379,3318853667,677414384,3393288472,3101374703,2390351024,1614419982,1822297739,2954791486,3608508353,3174124327,2024746970,1432378464,3864339955,2857741204,1464375394,1676153920,1439316330,715854006,3033291828,289532110,2706671279,2087905683,3018724369,1668267050,732546397,1947742710,3462151702,2609353502,2950085171,1814351708,2050118529,680887927,999245976,1800124847,3300911131,1713906067,1641548236,4213287313,1216130144,1575780402,4018429277,3917837745,3693486850,3949271944,596196993,3549867205,258830323,2213823033,772490370,2760122372,1774776394,2652871518,566650946,4142492826,1728879713,2882767088,1783734482,3629395816,2517608232,2874225571,1861159788,326777828,3124490320,2130389656,2716951837,967770486,1724537150,2185432712,2364442137,1164943284,2105845187,998989502,3765401048,2244026483,1075463327,1455516326,1322494562,910128902,469688178,1117454909,936433444,3490320968,3675253459,1240580251,122909385,2157517691,634681816,4142456567,3825094682,3061402683,2540495037,79693498,3249098678,1084186820,1583128258,426386531,1761308591,1047286709,322548459,995290223,1845252383,2603652396,3431023940,2942221577,3202600964,3727903485,1712269319,422464435,3234572375,1170764815,3523960633,3117677531,1434042557,442511882,3600875718,1076654713,1738483198,4213154764,2393238008,3677496056,1014306527,4251020053,793779912,2902807211,842905082,4246964064,1395751752,1040244610,2656851899,3396308128,445077038,3742853595,3577915638,679411651,2892444358,2354009459,1767581616,3150600392,3791627101,3102740896,284835224,4246832056,1258075500,768725851,2589189241,3069724005,3532540348,1274779536,3789419226,2764799539,1660621633,3471099624,4011903706,913787905,3497959166,737222580,2514213453,2928710040,3937242737,1804850592,3499020752,2949064160,2386320175,2390070455,2415321851,4061277028,2290661394,2416832540,1336762016,1754252060,3520065937,3014181293,791618072,3188594551,3933548030,2332172193,3852520463,3043980520,413987798,3465142937,3030929376,4245938359,2093235073,3534596313,375366246,2157278981,2479649556,555357303,3870105701,2008414854,3344188149,4221384143,3956125452,2067696032,3594591187,2921233993,2428461,544322398,577241275,1471733935,610547355,4027169054,1432588573,1507829418,2025931657,3646575487,545086370,48609733,2200306550,1653985193,298326376,1316178497,3007786442,2064951626,458293330,2589141269,3591329599,3164325604,727753846,2179363840,146436021,1461446943,4069977195,705550613,3059967265,3887724982,4281599278,3313849956,1404054877,2845806497,146425753,1854211946,1266315497,3048417604,3681880366,3289982499,290971e4,1235738493,2632868024,2414719590,3970600049,1771706367,1449415276,3266420449,422970021,1963543593,2690192192,3826793022,1062508698,1531092325,1804592342,2583117782,2714934279,4024971509,1294809318,4028980673,1289560198,2221992742,1669523910,35572830,157838143,1052438473,1016535060,1802137761,1753167236,1386275462,3080475397,2857371447,1040679964,2145300060,2390574316,1461121720,2956646967,4031777805,4028374788,33600511,2920084762,1018524850,629373528,3691585981,3515945977,2091462646,2486323059,586499841,988145025,935516892,3367335476,2599673255,2839830854,265290510,3972581182,2759138881,3795373465,1005194799,847297441,406762289,1314163512,1332590856,1866599683,4127851711,750260880,613907577,1450815602,3165620655,3734664991,3650291728,3012275730,3704569646,1427272223,778793252,1343938022,2676280711,2052605720,1946737175,3164576444,3914038668,3967478842,3682934266,1661551462,3294938066,4011595847,840292616,3712170807,616741398,312560963,711312465,1351876610,322626781,1910503582,271666773,2175563734,1594956187,70604529,3617834859,1007753275,1495573769,4069517037,2549218298,2663038764,504708206,2263041392,3941167025,2249088522,1514023603,1998579484,1312622330,694541497,2582060303,2151582166,1382467621,776784248,2618340202,3323268794,2497899128,2784771155,503983604,4076293799,907881277,423175695,432175456,1378068232,4145222326,3954048622,3938656102,3820766613,2793130115,2977904593,26017576,3274890735,3194772133,1700274565,1756076034,4006520079,3677328699,720338349,1533947780,354530856,688349552,3973924725,1637815568,332179504,3949051286,53804574,2852348879,3044236432,1282449977,3583942155,3416972820,4006381244,1617046695,2628476075,3002303598,1686838959,431878346,2686675385,1700445008,1080580658,1009431731,832498133,3223435511,2605976345,2271191193,2516031870,1648197032,4164389018,2548247927,300782431,375919233,238389289,3353747414,2531188641,2019080857,1475708069,455242339,2609103871,448939670,3451063019,1395535956,2413381860,1841049896,1491858159,885456874,4264095073,4001119347,1565136089,3898914787,1108368660,540939232,1173283510,2745871338,3681308437,4207628240,3343053890,4016749493,1699691293,1103962373,3625875870,2256883143,3830138730,1031889488,3479347698,1535977030,4236805024,3251091107,2132092099,1774941330,1199868427,1452454533,157007616,2904115357,342012276,595725824,1480756522,206960106,497939518,591360097,863170706,2375253569,3596610801,1814182875,2094937945,3421402208,1082520231,3463918190,2785509508,435703966,3908032597,1641649973,2842273706,3305899714,1510255612,2148256476,2655287854,3276092548,4258621189,236887753,3681803219,274041037,1734335097,3815195456,3317970021,1899903192,1026095262,4050517792,356393447,2410691914,3873677099,3682840055,3913112168,2491498743,4132185628,2489919796,1091903735,1979897079,3170134830,3567386728,3557303409,857797738,1136121015,1342202287,507115054,2535736646,337727348,3213592640,1301675037,2528481711,1895095763,1721773893,3216771564,62756741,2142006736,835421444,2531993523,1442658625,3659876326,2882144922,676362277,1392781812,170690266,3921047035,1759253602,3611846912,1745797284,664899054,1329594018,3901205900,3045908486,2062866102,2865634940,3543621612,3464012697,1080764994,553557557,3656615353,3996768171,991055499,499776247,1265440854,648242737,3940784050,980351604,3713745714,1749149687,3396870395,4211799374,3640570775,1161844396,3125318951,1431517754,545492359,4268468663,3499529547,1437099964,2702547544,3433638243,2581715763,2787789398,1060185593,1593081372,2418618748,4260947970,69676912,2159744348,86519011,2512459080,3838209314,1220612927,3339683548,133810670,1090789135,1078426020,1569222167,845107691,3583754449,4072456591,1091646820,628848692,1613405280,3757631651,526609435,236106946,48312990,2942717905,3402727701,1797494240,859738849,992217954,4005476642,2243076622,3870952857,3732016268,765654824,3490871365,2511836413,1685915746,3888969200,1414112111,2273134842,3281911079,4080962846,172450625,2569994100,980381355,4109958455,2819808352,2716589560,2568741196,3681446669,3329971472,1835478071,660984891,3704678404,4045999559,3422617507,3040415634,1762651403,1719377915,3470491036,2693910283,3642056355,3138596744,1364962596,2073328063,1983633131,926494387,3423689081,2150032023,4096667949,1749200295,3328846651,309677260,2016342300,1779581495,3079819751,111262694,1274766160,443224088,298511866,1025883608,3806446537,1145181785,168956806,3641502830,3584813610,1689216846,3666258015,3200248200,1692713982,2646376535,4042768518,1618508792,1610833997,3523052358,4130873264,2001055236,3610705100,2202168115,4028541809,2961195399,1006657119,2006996926,3186142756,1430667929,3210227297,1314452623,4074634658,4101304120,2273951170,1399257539,3367210612,3027628629,1190975929,2062231137,2333990788,2221543033,2438960610,1181637006,548689776,2362791313,3372408396,3104550113,3145860560,296247880,1970579870,3078560182,3769228297,1714227617,3291629107,3898220290,166772364,1251581989,493813264,448347421,195405023,2709975567,677966185,3703036547,1463355134,2715995803,1338867538,1343315457,2802222074,2684532164,233230375,2599980071,2000651841,3277868038,1638401717,4028070440,3237316320,6314154,819756386,300326615,590932579,1405279636,3267499572,3150704214,2428286686,3959192993,3461946742,1862657033,1266418056,963775037,2089974820,2263052895,1917689273,448879540,3550394620,3981727096,150775221,3627908307,1303187396,508620638,2975983352,2726630617,1817252668,1876281319,1457606340,908771278,3720792119,3617206836,2455994898,1729034894,1080033504,976866871,3556439503,2881648439,1522871579,1555064734,1336096578,3548522304,2579274686,3574697629,3205460757,3593280638,3338716283,3079412587,564236357,2993598910,1781952180,1464380207,3163844217,3332601554,1699332808,1393555694,1183702653,3581086237,1288719814,691649499,2847557200,2895455976,3193889540,2717570544,1781354906,1676643554,2592534050,3230253752,1126444790,2770207658,2633158820,2210423226,2615765581,2414155088,3127139286,673620729,2805611233,1269405062,4015350505,3341807571,4149409754,1057255273,2012875353,2162469141,2276492801,2601117357,993977747,3918593370,2654263191,753973209,36408145,2530585658,25011837,3520020182,2088578344,530523599,2918365339,1524020338,1518925132,3760827505,3759777254,1202760957,3985898139,3906192525,674977740,4174734889,2031300136,2019492241,3983892565,4153806404,3822280332,352677332,2297720250,60907813,90501309,3286998549,1016092578,2535922412,2839152426,457141659,509813237,4120667899,652014361,1966332200,2975202805,55981186,2327461051,676427537,3255491064,2882294119,3433927263,1307055953,942726286,933058658,2468411793,3933900994,4215176142,1361170020,2001714738,2830558078,3274259782,1222529897,1679025792,2729314320,3714953764,1770335741,151462246,3013232138,1682292957,1483529935,471910574,1539241949,458788160,3436315007,1807016891,3718408830,978976581,1043663428,3165965781,1927990952,4200891579,2372276910,3208408903,3533431907,1412390302,2931980059,4132332400,1947078029,3881505623,4168226417,2941484381,1077988104,1320477388,886195818,18198404,3786409e3,2509781533,112762804,3463356488,1866414978,891333506,18488651,661792760,1628790961,3885187036,3141171499,876946877,2693282273,1372485963,791857591,2686433993,3759982718,3167212022,3472953795,2716379847,445679433,3561995674,3504004811,3574258232,54117162,3331405415,2381918588,3769707343,4154350007,1140177722,4074052095,668550556,3214352940,367459370,261225585,2610173221,4209349473,3468074219,3265815641,314222801,3066103646,3808782860,282218597,3406013506,3773591054,379116347,1285071038,846784868,2669647154,3771962079,3550491691,2305946142,453669953,1268987020,3317592352,3279303384,3744833421,2610507566,3859509063,266596637,3847019092,517658769,3462560207,3443424879,370717030,4247526661,2224018117,4143653529,4112773975,2788324899,2477274417,1456262402,2901442914,1517677493,1846949527,2295493580,3734397586,2176403920,1280348187,1908823572,3871786941,846861322,1172426758,3287448474,3383383037,1655181056,3139813346,901632758,1897031941,2986607138,3066810236,3447102507,1393639104,373351379,950779232,625454576,3124240540,4148612726,2007998917,544563296,2244738638,2330496472,2058025392,1291430526,424198748,50039436,29584100,3605783033,2429876329,2791104160,1057563949,3255363231,3075367218,3463963227,1469046755,985887462],L=[1332899944,1700884034,1701343084,1684370003,1668446532,1869963892];function Q(j,N,E,x){var k,$=j[N],U=j[N+1];return $^=E[0],k=x[$>>>24],k+=x[256|$>>16&255],k^=x[512|$>>8&255],k+=x[768|$&255],U^=k^E[1],k=x[U>>>24],k+=x[256|U>>16&255],k^=x[512|U>>8&255],k+=x[768|U&255],$^=k^E[2],k=x[$>>>24],k+=x[256|$>>16&255],k^=x[512|$>>8&255],k+=x[768|$&255],U^=k^E[3],k=x[U>>>24],k+=x[256|U>>16&255],k^=x[512|U>>8&255],k+=x[768|U&255],$^=k^E[4],k=x[$>>>24],k+=x[256|$>>16&255],k^=x[512|$>>8&255],k+=x[768|$&255],U^=k^E[5],k=x[U>>>24],k+=x[256|U>>16&255],k^=x[512|U>>8&255],k+=x[768|U&255],$^=k^E[6],k=x[$>>>24],k+=x[256|$>>16&255],k^=x[512|$>>8&255],k+=x[768|$&255],U^=k^E[7],k=x[U>>>24],k+=x[256|U>>16&255],k^=x[512|U>>8&255],k+=x[768|U&255],$^=k^E[8],k=x[$>>>24],k+=x[256|$>>16&255],k^=x[512|$>>8&255],k+=x[768|$&255],U^=k^E[9],k=x[U>>>24],k+=x[256|U>>16&255],k^=x[512|U>>8&255],k+=x[768|U&255],$^=k^E[10],k=x[$>>>24],k+=x[256|$>>16&255],k^=x[512|$>>8&255],k+=x[768|$&255],U^=k^E[11],k=x[U>>>24],k+=x[256|U>>16&255],k^=x[512|U>>8&255],k+=x[768|U&255],$^=k^E[12],k=x[$>>>24],k+=x[256|$>>16&255],k^=x[512|$>>8&255],k+=x[768|$&255],U^=k^E[13],k=x[U>>>24],k+=x[256|U>>16&255],k^=x[512|U>>8&255],k+=x[768|U&255],$^=k^E[14],k=x[$>>>24],k+=x[256|$>>16&255],k^=x[512|$>>8&255],k+=x[768|$&255],U^=k^E[15],k=x[U>>>24],k+=x[256|U>>16&255],k^=x[512|U>>8&255],k+=x[768|U&255],$^=k^E[16],j[N]=U^E[w+1],j[N+1]=$,j}function ce(j,N){for(var E=0,x=0;E<4;++E)x=x<<8|j[N]&255,N=(N+1)%j.length;return{key:x,offp:N}}function le(j,N,E){for(var x=0,k=[0,0],$=N.length,U=E.length,X,G=0;G<$;G++)X=ce(j,x),x=X.offp,N[G]=N[G]^X.key;for(G=0;G<$;G+=2)k=Q(k,0,N,E),N[G]=k[0],N[G+1]=k[1];for(G=0;G<U;G+=2)k=Q(k,0,N,E),E[G]=k[0],E[G+1]=k[1]}function De(j,N,E,x){for(var k=0,$=[0,0],U=E.length,X=x.length,G,ie=0;ie<U;ie++)G=ce(N,k),k=G.offp,E[ie]=E[ie]^G.key;for(k=0,ie=0;ie<U;ie+=2)G=ce(j,k),k=G.offp,$[0]^=G.key,G=ce(j,k),k=G.offp,$[1]^=G.key,$=Q($,0,E,x),E[ie]=$[0],E[ie+1]=$[1];for(ie=0;ie<X;ie+=2)G=ce(j,k),k=G.offp,$[0]^=G.key,G=ce(j,k),k=G.offp,$[1]^=G.key,$=Q($,0,E,x),x[ie]=$[0],x[ie+1]=$[1]}function Ue(j,N,E,x,k){var $=L.slice(),U=$.length,X;if(E<4||E>31)if(X=Error("Illegal number of rounds (4-31): "+E),x){a(x.bind(this,X));return}else throw X;if(N.length!==f)if(X=Error("Illegal salt length: "+N.length+" != "+f),x){a(x.bind(this,X));return}else throw X;E=1<<E>>>0;var G,ie,de=0,H;Int32Array?(G=new Int32Array(C),ie=new Int32Array(B)):(G=C.slice(),ie=B.slice()),De(N,j,G,ie);function Ne(){if(k&&k(de/E),de<E)for(var ge=Date.now();de<E&&(de=de+1,le(j,G,ie),le(N,G,ie),!(Date.now()-ge>S)););else{for(de=0;de<64;de++)for(H=0;H<U>>1;H++)Q($,H<<1,G,ie);var Se=[];for(de=0;de<U;de++)Se.push(($[de]>>24&255)>>>0),Se.push(($[de]>>16&255)>>>0),Se.push(($[de]>>8&255)>>>0),Se.push(($[de]&255)>>>0);if(x){x(null,Se);return}else return Se}x&&a(Ne)}if(typeof x<"u")Ne();else for(var pn;;)if(typeof(pn=Ne())<"u")return pn||[]}function Re(j,N,E,x){var k;if(typeof j!="string"||typeof N!="string")if(k=Error("Invalid string / salt: Not a string"),E){a(E.bind(this,k));return}else throw k;var $,U;if(N.charAt(0)!=="$"||N.charAt(1)!=="2")if(k=Error("Invalid salt version: "+N.substring(0,2)),E){a(E.bind(this,k));return}else throw k;if(N.charAt(2)==="$")$="\0",U=3;else{if($=N.charAt(2),$!=="a"&&$!=="b"&&$!=="y"||N.charAt(3)!=="$")if(k=Error("Invalid salt revision: "+N.substring(2,4)),E){a(E.bind(this,k));return}else throw k;U=4}if(N.charAt(U+2)>"$")if(k=Error("Missing salt rounds"),E){a(E.bind(this,k));return}else throw k;var X=parseInt(N.substring(U,U+1),10)*10,G=parseInt(N.substring(U+1,U+2),10),ie=X+G,de=N.substring(U+3,U+25);j+=$>="a"?"\0":"";var H=c(j),Ne=m(de,f);function pn(ge){var Se=[];return Se.push("$2"),$>="a"&&Se.push($),Se.push("$"),ie<10&&Se.push("0"),Se.push(ie.toString()),Se.push("$"),Se.push(h(Ne,Ne.length)),Se.push(h(ge,L.length*4-1)),Se.join("")}if(typeof E>"u")return pn(Ue(H,Ne,ie));Ue(H,Ne,ie,function(ge,Se){ge?E(ge,null):E(null,pn(Se))},x)}return e.encodeBase64=h,e.decodeBase64=m,e})})(zf);var c_=zf.exports;const si=If(c_),l_="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let u_=t=>crypto.getRandomValues(new Uint8Array(t)),d_=(t,e,n)=>{let r=(2<<Math.log2(t.length-1))-1,i=-~(1.6*r*e/t.length);return(s=e)=>{let a="";for(;;){let c=n(i),l=i;for(;l--;)if(a+=t[c[l]&r]||"",a.length===s)return a}}},p_=(t,e=21)=>d_(t,e,u_),xe=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=l_[n[t]&63];return e};const f_=24;function Xs(){return p_("0123456789abcdef",f_)()}function Vu(t){if(!t.includes("|"))return console.error("Invalid user_id format"),t;const[,e]=t.split("|");return e}function h_(t){return async(e,n)=>{if(!n.email||!n.email_verified)return t.users.create(e,n);const r=await ro({userAdapter:t.users,tenant_id:e,email:n.email});return r?(await t.users.create(e,{...n,linked_to:r.user_id}),r):t.users.create(e,n)}}function ve(t,e){return{type:e.type,description:e.description||"",ip:t.req.header("x-real-ip")||"",user_agent:t.req.header("user-agent")||"",date:new Date().toISOString(),details:{request:{method:t.req.method,path:t.req.path,qs:t.req.queries(),body:e.body||t.var.body||""}},isMobile:!1,client_id:t.var.client_id,client_name:"",user_id:e.userId||t.var.user_id||"",hostname:t.req.header("host")||"",user_name:t.var.username||"",connection_id:"",connection:t.var.connection||"",strategy:e.strategy||"",strategy_type:e.strategy_type||"",audience:"",scope:[]}}class sl{constructor(e,n){te(this,"value");te(this,"unit");this.value=e,this.unit=n}milliseconds(){return this.unit==="ms"?this.value:this.unit==="s"?this.value*1e3:this.unit==="m"?this.value*1e3*60:this.unit==="h"?this.value*1e3*60*60:this.unit==="d"?this.value*1e3*60*60*24:this.value*1e3*60*60*24*7}seconds(){return this.milliseconds()/1e3}transform(e){return new sl(Math.round(this.milliseconds()*e),"ms")}}class g_{constructor(e){te(this,"hash");this.hash=e}async verify(e,n,r){const i=await crypto.subtle.importKey("spki",e,{name:"RSASSA-PKCS1-v1_5",hash:this.hash},!1,["verify"]);return await crypto.subtle.verify("RSASSA-PKCS1-v1_5",i,n,r)}async sign(e,n){const r=await crypto.subtle.importKey("pkcs8",e,{name:"RSASSA-PKCS1-v1_5",hash:this.hash},!1,["sign"]);return await crypto.subtle.sign("RSASSA-PKCS1-v1_5",r,n)}async generateKeyPair(e){const n=await crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",hash:this.hash,modulusLength:e??2048,publicExponent:new Uint8Array([1,0,1])},!0,["sign"]),r=await crypto.subtle.exportKey("pkcs8",n.privateKey),i=await crypto.subtle.exportKey("spki",n.publicKey);return{privateKey:r,publicKey:i}}}async function Nf(t){return await crypto.subtle.digest("SHA-256",t)}const qu="0123456789abcdef";function za(t){const e=new Uint8Array(t);let n="";for(let r=0;r<e.length;r++){const i=e[r]>>4;n+=qu[i];const s=e[r]&15;n+=qu[s]}return n}class Cf{constructor(e,n){te(this,"alphabet");te(this,"padding");te(this,"decodeMap",new Map);if(e.length!==32)throw new Error("Invalid alphabet");if(this.alphabet=e,this.padding=(n==null?void 0:n.padding)??"=",this.alphabet.includes(this.padding)||this.padding.length!==1)throw new Error("Invalid padding");for(let r=0;r<e.length;r++)this.decodeMap.set(e[r],r)}encode(e,n){let r="",i=0,s=0;for(let c=0;c<e.length;c++)for(i=i<<8|e[c],s+=8;s>=5;)s-=5,r+=this.alphabet[i>>s&31];if(s>0&&(r+=this.alphabet[i<<5-s&31]),(n==null?void 0:n.includePadding)??!0){const c=(8-r.length%8)%8;for(let l=0;l<c;l++)r+="="}return r}decode(e,n){const r=(n==null?void 0:n.strict)??!0,i=Math.ceil(e.length/8),s=[];for(let a=0;a<i;a++){let c=0;const l=[];for(let p=0;p<8;p++){const h=e[a*8+p];if(h==="="){if(a+1!==i)throw new Error(`Invalid character: ${h}`);c+=1;continue}if(h===void 0){if(r)throw new Error("Invalid data");c+=1;continue}const m=this.decodeMap.get(h)??null;if(m===null)throw new Error(`Invalid character: ${h}`);l.push(m)}if(c===8||c===7||c===5||c===2)throw new Error("Invalid padding");const u=(l[0]<<3)+(l[1]>>2);if(s.push(u),c<6){const p=((l[1]&3)<<6)+(l[2]<<1)+(l[3]>>4);s.push(p)}if(c<4){const p=((l[3]&255)<<4)+(l[4]>>1);s.push(p)}if(c<3){const p=((l[4]&1)<<7)+(l[5]<<2)+(l[6]>>3);s.push(p)}if(c<1){const p=((l[6]&7)<<5)+l[7];s.push(p)}}return Uint8Array.from(s)}}new Cf("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567");new Cf("0123456789ABCDEFGHIJKLMNOPQRSTUV");class jf{constructor(e,n){te(this,"alphabet");te(this,"padding");te(this,"decodeMap",new Map);if(e.length!==64)throw new Error("Invalid alphabet");if(this.alphabet=e,this.padding=(n==null?void 0:n.padding)??"=",this.alphabet.includes(this.padding)||this.padding.length!==1)throw new Error("Invalid padding");for(let r=0;r<e.length;r++)this.decodeMap.set(e[r],r)}encode(e,n){let r="",i=0,s=0;for(let c=0;c<e.length;c++)for(i=i<<8|e[c],s+=8;s>=6;)s+=-6,r+=this.alphabet[i>>s&63];if(s>0&&(r+=this.alphabet[i<<6-s&63]),(n==null?void 0:n.includePadding)??!0){const c=(4-r.length%4)%4;for(let l=0;l<c;l++)r+="="}return r}decode(e,n){const r=(n==null?void 0:n.strict)??!0,i=Math.ceil(e.length/4),s=[];for(let a=0;a<i;a++){let c=0,l=0;for(let u=0;u<4;u++){const p=e[a*4+u];if(p==="="){if(a+1!==i)throw new Error(`Invalid character: ${p}`);c+=1;continue}if(p===void 0){if(r)throw new Error("Invalid data");c+=1;continue}const h=this.decodeMap.get(p)??null;if(h===null)throw new Error(`Invalid character: ${p}`);l+=h<<6*(3-u)}s.push(l>>16&255),c<2&&s.push(l>>8&255),c<1&&s.push(l&255)}return Uint8Array.from(s)}}const m_=new jf("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),wn=new jf("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_");async function Mu(t,e,n,r){const i={alg:t,typ:"JWT",...r==null?void 0:r.headers},s={...n};(r==null?void 0:r.audiences)!==void 0&&(s.aud=r.audiences),(r==null?void 0:r.subject)!==void 0&&(s.sub=r.subject),(r==null?void 0:r.issuer)!==void 0&&(s.iss=r.issuer),(r==null?void 0:r.jwtId)!==void 0&&(s.jti=r.jwtId),(r==null?void 0:r.expiresIn)!==void 0&&(s.exp=Math.floor(Date.now()/1e3)+r.expiresIn.seconds()),(r==null?void 0:r.notBefore)!==void 0&&(s.nbf=Math.floor(r.notBefore.getTime()/1e3)),s.iat=Math.floor(Date.now()/1e3);const a=new TextEncoder,c=wn.encode(a.encode(JSON.stringify(i)),{includePadding:!1}),l=wn.encode(a.encode(JSON.stringify(s)),{includePadding:!1}),u=a.encode([c,l].join(".")),p=await y_(t).sign(e,u),h=wn.encode(new Uint8Array(p),{includePadding:!1});return[c,l,h].join(".")}function __(t){const e=t.split(".");return e.length!==3?null:e}function ol(t){const e=__(t);if(!e)return null;const n=new TextDecoder,r=wn.decode(e[0],{strict:!1}),i=wn.decode(e[1],{strict:!1}),s=JSON.parse(n.decode(r));if(typeof s!="object"||s===null||!("alg"in s)||!v_(s.alg)||"typ"in s&&s.typ!=="JWT")return null;const a=JSON.parse(n.decode(i));if(typeof a!="object"||a===null)return null;const c={algorithm:s.alg,expiresAt:null,subject:null,issuedAt:null,issuer:null,jwtId:null,audiences:null,notBefore:null};if("exp"in a){if(typeof a.exp!="number")return null;c.expiresAt=new Date(a.exp*1e3)}if("iss"in a){if(typeof a.iss!="string")return null;c.issuer=a.iss}if("sub"in a){if(typeof a.sub!="string")return null;c.subject=a.sub}if("aud"in a)if(Array.isArray(a.aud)){for(const l of a.aud)if(typeof l!="string")return null;c.audiences=a.aud}else{if(typeof a.aud!="string")return null;c.audiences=[a.aud]}if("nbf"in a){if(typeof a.nbf!="number")return null;c.notBefore=new Date(a.nbf*1e3)}if("iat"in a){if(typeof a.iat!="number")return null;c.issuedAt=new Date(a.iat*1e3)}if("jti"in a){if(typeof a.jti!="string")return null;c.jwtId=a.jti}return{value:t,header:{...s,typ:"JWT",alg:s.alg},payload:{...a},parts:e,...c}}function y_(t){return new g_(w_[t])}function v_(t){return typeof t!="string"?!1:["HS256","HS384","HS512","RS256","RS384","RS512","ES256","ES384","ES512","PS256","PS384","PS512"].includes(t)}const w_={RS256:"SHA-256",RS384:"SHA-384",RS512:"SHA-512"};function b_(){const t=new Uint8Array(32);return crypto.getRandomValues(t),wn.encode(t,{includePadding:!1})}function k_(t){try{const n=/-----BEGIN (?:RSA )?(?:PRIVATE|PUBLIC) KEY-----([^-]*)-----END (?:RSA )?(?:PRIVATE|PUBLIC) KEY-----/.exec(t);if(!n||!n[1])throw new Error("Invalid PEM format");return Uint8Array.from(atob(n[1].replace(/\s/g,"")),r=>r.charCodeAt(0)).buffer}finally{t=t.replace(/./g,"\0")}}async function x_(t,e){if(e==="plain")return t;const n=new TextEncoder().encode(t),r=await Nf(n);return wn.encode(new Uint8Array(r),{includePadding:!1})}const ji=60*5,Qs=30*24*60*60,Jn=24*60*60,S_="auth-token",Na=30*60*1e3,A_=7*24*60*60*1e3,E_=5*60,I_=5*60,z_=30*60*1e3,N_=30*60*1e3,C_=24*60*60*1e3;function $f(t,e,n){const r=[];return r.push([encodeURIComponent(t),encodeURIComponent(e)]),(n==null?void 0:n.domain)!==void 0&&r.push(["Domain",n.domain]),(n==null?void 0:n.expires)!==void 0&&r.push(["Expires",n.expires.toUTCString()]),n!=null&&n.httpOnly&&r.push(["HttpOnly"]),(n==null?void 0:n.maxAge)!==void 0&&r.push(["Max-Age",n.maxAge.toString()]),(n==null?void 0:n.path)!==void 0&&r.push(["Path",n.path]),(n==null?void 0:n.sameSite)==="lax"&&r.push(["SameSite","Lax"]),(n==null?void 0:n.sameSite)==="none"&&r.push(["SameSite","None"]),(n==null?void 0:n.sameSite)==="strict"&&r.push(["SameSite","Strict"]),n!=null&&n.secure&&r.push(["Secure"]),r.map(i=>i.join("=")).join("; ")}function j_(t){const e=new Map,n=t.split("; ");for(const r of n){const i=r.split("="),s=i[0],a=i[1]??"";s&&e.set(decodeURIComponent(s),decodeURIComponent(a))}return e}function al(t){return`${t}-${S_}`}function Of(t){if(!t)return;if(t==="localhost"||/^(\d{1,3}\.){3}\d{1,3}$/.test(t))return t;const e=t.split(".");return e.length>2?`.${e.slice(-2).join(".")}`:`.${t}`}function cs(t,e){return e?j_(e).get(al(t)):void 0}function $_(t,e){return $f(al(t),"",{path:"/",httpOnly:!0,secure:!0,maxAge:0,sameSite:"none",domain:e?Of(e):void 0})}function Bf(t,e,n){return $f(al(t),e,{path:"/",httpOnly:!0,secure:!0,maxAge:Qs,sameSite:"none",domain:n?Of(n):void 0})}var cl={},eo={};(function(t){const e=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",n=e+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040",r="["+e+"]["+n+"]*",i=new RegExp("^"+r+"$"),s=function(c,l){const u=[];let p=l.exec(c);for(;p;){const h=[];h.startIndex=l.lastIndex-p[0].length;const m=p.length;for(let v=0;v<m;v++)h.push(p[v]);u.push(h),p=l.exec(c)}return u},a=function(c){const l=i.exec(c);return!(l===null||typeof l>"u")};t.isExist=function(c){return typeof c<"u"},t.isEmptyObject=function(c){return Object.keys(c).length===0},t.merge=function(c,l,u){if(l){const p=Object.keys(l),h=p.length;for(let m=0;m<h;m++)u==="strict"?c[p[m]]=[l[p[m]]]:c[p[m]]=l[p[m]]}},t.getValue=function(c){return t.isExist(c)?c:""},t.isName=a,t.getAllMatches=s,t.nameRegexp=r})(eo);const ll=eo,O_={allowBooleanAttributes:!1,unpairedTags:[]};cl.validate=function(t,e){e=Object.assign({},O_,e);const n=[];let r=!1,i=!1;t[0]==="\uFEFF"&&(t=t.substr(1));for(let s=0;s<t.length;s++)if(t[s]==="<"&&t[s+1]==="?"){if(s+=2,s=Hu(t,s),s.err)return s}else if(t[s]==="<"){let a=s;if(s++,t[s]==="!"){s=Fu(t,s);continue}else{let c=!1;t[s]==="/"&&(c=!0,s++);let l="";for(;s<t.length&&t[s]!==">"&&t[s]!==" "&&t[s]!==" "&&t[s]!==`
6
- `&&t[s]!=="\r";s++)l+=t[s];if(l=l.trim(),l[l.length-1]==="/"&&(l=l.substring(0,l.length-1),s--),!q_(l)){let h;return l.trim().length===0?h="Invalid space after '<'.":h="Tag '"+l+"' is an invalid name.",be("InvalidTag",h,Ve(t,s))}const u=P_(t,s);if(u===!1)return be("InvalidAttr","Attributes for '"+l+"' have open quote.",Ve(t,s));let p=u.value;if(s=u.index,p[p.length-1]==="/"){const h=s-p.length;p=p.substring(0,p.length-1);const m=Ku(p,e);if(m===!0)r=!0;else return be(m.err.code,m.err.msg,Ve(t,h+m.err.line))}else if(c)if(u.tagClosed){if(p.trim().length>0)return be("InvalidTag","Closing tag '"+l+"' can't have attributes or invalid starting.",Ve(t,a));if(n.length===0)return be("InvalidTag","Closing tag '"+l+"' has not been opened.",Ve(t,a));{const h=n.pop();if(l!==h.tagName){let m=Ve(t,h.tagStartPos);return be("InvalidTag","Expected closing tag '"+h.tagName+"' (opened in line "+m.line+", col "+m.col+") instead of closing tag '"+l+"'.",Ve(t,a))}n.length==0&&(i=!0)}}else return be("InvalidTag","Closing tag '"+l+"' doesn't have proper closing.",Ve(t,s));else{const h=Ku(p,e);if(h!==!0)return be(h.err.code,h.err.msg,Ve(t,s-p.length+h.err.line));if(i===!0)return be("InvalidXml","Multiple possible root nodes found.",Ve(t,s));e.unpairedTags.indexOf(l)!==-1||n.push({tagName:l,tagStartPos:a}),r=!0}for(s++;s<t.length;s++)if(t[s]==="<")if(t[s+1]==="!"){s++,s=Fu(t,s);continue}else if(t[s+1]==="?"){if(s=Hu(t,++s),s.err)return s}else break;else if(t[s]==="&"){const h=U_(t,s);if(h==-1)return be("InvalidChar","char '&' is not expected.",Ve(t,s));s=h}else if(i===!0&&!Du(t[s]))return be("InvalidXml","Extra text at the end",Ve(t,s));t[s]==="<"&&s--}}else{if(Du(t[s]))continue;return be("InvalidChar","char '"+t[s]+"' is not expected.",Ve(t,s))}if(r){if(n.length==1)return be("InvalidTag","Unclosed tag '"+n[0].tagName+"'.",Ve(t,n[0].tagStartPos));if(n.length>0)return be("InvalidXml","Invalid '"+JSON.stringify(n.map(s=>s.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1})}else return be("InvalidXml","Start tag expected.",1);return!0};function Du(t){return t===" "||t===" "||t===`
7
- `||t==="\r"}function Hu(t,e){const n=e;for(;e<t.length;e++)if(t[e]=="?"||t[e]==" "){const r=t.substr(n,e-n);if(e>5&&r==="xml")return be("InvalidXml","XML declaration allowed only at the start of the document.",Ve(t,e));if(t[e]=="?"&&t[e+1]==">"){e++;break}else continue}return e}function Fu(t,e){if(t.length>e+5&&t[e+1]==="-"&&t[e+2]==="-"){for(e+=3;e<t.length;e++)if(t[e]==="-"&&t[e+1]==="-"&&t[e+2]===">"){e+=2;break}}else if(t.length>e+8&&t[e+1]==="D"&&t[e+2]==="O"&&t[e+3]==="C"&&t[e+4]==="T"&&t[e+5]==="Y"&&t[e+6]==="P"&&t[e+7]==="E"){let n=1;for(e+=8;e<t.length;e++)if(t[e]==="<")n++;else if(t[e]===">"&&(n--,n===0))break}else if(t.length>e+9&&t[e+1]==="["&&t[e+2]==="C"&&t[e+3]==="D"&&t[e+4]==="A"&&t[e+5]==="T"&&t[e+6]==="A"&&t[e+7]==="["){for(e+=8;e<t.length;e++)if(t[e]==="]"&&t[e+1]==="]"&&t[e+2]===">"){e+=2;break}}return e}const B_='"',T_="'";function P_(t,e){let n="",r="",i=!1;for(;e<t.length;e++){if(t[e]===B_||t[e]===T_)r===""?r=t[e]:r!==t[e]||(r="");else if(t[e]===">"&&r===""){i=!0;break}n+=t[e]}return r!==""?!1:{value:n,index:e,tagClosed:i}}const R_=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function Ku(t,e){const n=ll.getAllMatches(t,R_),r={};for(let i=0;i<n.length;i++){if(n[i][1].length===0)return be("InvalidAttr","Attribute '"+n[i][2]+"' has no space in starting.",Er(n[i]));if(n[i][3]!==void 0&&n[i][4]===void 0)return be("InvalidAttr","Attribute '"+n[i][2]+"' is without value.",Er(n[i]));if(n[i][3]===void 0&&!e.allowBooleanAttributes)return be("InvalidAttr","boolean attribute '"+n[i][2]+"' is not allowed.",Er(n[i]));const s=n[i][2];if(!V_(s))return be("InvalidAttr","Attribute '"+s+"' is an invalid name.",Er(n[i]));if(!r.hasOwnProperty(s))r[s]=1;else return be("InvalidAttr","Attribute '"+s+"' is repeated.",Er(n[i]))}return!0}function L_(t,e){let n=/\d/;for(t[e]==="x"&&(e++,n=/[\da-fA-F]/);e<t.length;e++){if(t[e]===";")return e;if(!t[e].match(n))break}return-1}function U_(t,e){if(e++,t[e]===";")return-1;if(t[e]==="#")return e++,L_(t,e);let n=0;for(;e<t.length;e++,n++)if(!(t[e].match(/\w/)&&n<20)){if(t[e]===";")break;return-1}return e}function be(t,e,n){return{err:{code:t,msg:e,line:n.line||n,col:n.col}}}function V_(t){return ll.isName(t)}function q_(t){return ll.isName(t)}function Ve(t,e){const n=t.substring(0,e).split(/\r?\n/);return{line:n.length,col:n[n.length-1].length+1}}function Er(t){return t.startIndex+t[1].length}var ul={};const Tf={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(t,e,n){return t}},M_=function(t){return Object.assign({},Tf,t)};ul.buildOptions=M_;ul.defaultOptions=Tf;class D_{constructor(e){this.tagname=e,this.child=[],this[":@"]={}}add(e,n){e==="__proto__"&&(e="#__proto__"),this.child.push({[e]:n})}addChild(e){e.tagname==="__proto__"&&(e.tagname="#__proto__"),e[":@"]&&Object.keys(e[":@"]).length>0?this.child.push({[e.tagname]:e.child,":@":e[":@"]}):this.child.push({[e.tagname]:e.child})}}var H_=D_;const F_=eo;function K_(t,e){const n={};if(t[e+3]==="O"&&t[e+4]==="C"&&t[e+5]==="T"&&t[e+6]==="Y"&&t[e+7]==="P"&&t[e+8]==="E"){e=e+9;let r=1,i=!1,s=!1,a="";for(;e<t.length;e++)if(t[e]==="<"&&!s){if(i&&J_(t,e)){e+=7;let c,l;[c,l,e]=W_(t,e+1),l.indexOf("&")===-1&&(n[Q_(c)]={regx:RegExp(`&${c};`,"g"),val:l})}else if(i&&Z_(t,e))e+=8;else if(i&&Y_(t,e))e+=8;else if(i&&X_(t,e))e+=9;else if(G_)s=!0;else throw new Error("Invalid DOCTYPE");r++,a=""}else if(t[e]===">"){if(s?t[e-1]==="-"&&t[e-2]==="-"&&(s=!1,r--):r--,r===0)break}else t[e]==="["?i=!0:a+=t[e];if(r!==0)throw new Error("Unclosed DOCTYPE")}else throw new Error("Invalid Tag instead of DOCTYPE");return{entities:n,i:e}}function W_(t,e){let n="";for(;e<t.length&&t[e]!=="'"&&t[e]!=='"';e++)n+=t[e];if(n=n.trim(),n.indexOf(" ")!==-1)throw new Error("External entites are not supported");const r=t[e++];let i="";for(;e<t.length&&t[e]!==r;e++)i+=t[e];return[n,i,e]}function G_(t,e){return t[e+1]==="!"&&t[e+2]==="-"&&t[e+3]==="-"}function J_(t,e){return t[e+1]==="!"&&t[e+2]==="E"&&t[e+3]==="N"&&t[e+4]==="T"&&t[e+5]==="I"&&t[e+6]==="T"&&t[e+7]==="Y"}function Z_(t,e){return t[e+1]==="!"&&t[e+2]==="E"&&t[e+3]==="L"&&t[e+4]==="E"&&t[e+5]==="M"&&t[e+6]==="E"&&t[e+7]==="N"&&t[e+8]==="T"}function Y_(t,e){return t[e+1]==="!"&&t[e+2]==="A"&&t[e+3]==="T"&&t[e+4]==="T"&&t[e+5]==="L"&&t[e+6]==="I"&&t[e+7]==="S"&&t[e+8]==="T"}function X_(t,e){return t[e+1]==="!"&&t[e+2]==="N"&&t[e+3]==="O"&&t[e+4]==="T"&&t[e+5]==="A"&&t[e+6]==="T"&&t[e+7]==="I"&&t[e+8]==="O"&&t[e+9]==="N"}function Q_(t){if(F_.isName(t))return t;throw new Error(`Invalid entity name ${t}`)}var e0=K_;const t0=/^[-+]?0x[a-fA-F0-9]+$/,n0=/^([\-\+])?(0*)(\.[0-9]+([eE]\-?[0-9]+)?|[0-9]+(\.[0-9]+([eE]\-?[0-9]+)?)?)$/;!Number.parseInt&&window.parseInt&&(Number.parseInt=window.parseInt);!Number.parseFloat&&window.parseFloat&&(Number.parseFloat=window.parseFloat);const r0={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};function i0(t,e={}){if(e=Object.assign({},r0,e),!t||typeof t!="string")return t;let n=t.trim();if(e.skipLike!==void 0&&e.skipLike.test(n))return t;if(e.hex&&t0.test(n))return Number.parseInt(n,16);{const r=n0.exec(n);if(r){const i=r[1],s=r[2];let a=s0(r[3]);const c=r[4]||r[6];if(!e.leadingZeros&&s.length>0&&i&&n[2]!==".")return t;if(!e.leadingZeros&&s.length>0&&!i&&n[1]!==".")return t;{const l=Number(n),u=""+l;return u.search(/[eE]/)!==-1||c?e.eNotation?l:t:n.indexOf(".")!==-1?u==="0"&&a===""||u===a||i&&u==="-"+a?l:t:s?a===u||i+a===u?l:t:n===u||n===i+u?l:t}}else return t}}function s0(t){return t&&t.indexOf(".")!==-1&&(t=t.replace(/0+$/,""),t==="."?t="0":t[0]==="."?t="0"+t:t[t.length-1]==="."&&(t=t.substr(0,t.length-1))),t}var o0=i0;function a0(t){return typeof t=="function"?t:Array.isArray(t)?e=>{for(const n of t)if(typeof n=="string"&&e===n||n instanceof RegExp&&n.test(e))return!0}:()=>!1}var Pf=a0;const Rf=eo,Ir=H_,c0=e0,l0=o0,u0=Pf;let d0=class{constructor(e){this.options=e,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:"&"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"¢"},pound:{regex:/&(pound|#163);/g,val:"£"},yen:{regex:/&(yen|#165);/g,val:"¥"},euro:{regex:/&(euro|#8364);/g,val:"€"},copyright:{regex:/&(copy|#169);/g,val:"©"},reg:{regex:/&(reg|#174);/g,val:"®"},inr:{regex:/&(inr|#8377);/g,val:"₹"},num_dec:{regex:/&#([0-9]{1,7});/g,val:(n,r)=>String.fromCharCode(Number.parseInt(r,10))},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(n,r)=>String.fromCharCode(Number.parseInt(r,16))}},this.addExternalEntities=p0,this.parseXml=_0,this.parseTextData=f0,this.resolveNameSpace=h0,this.buildAttributesMap=m0,this.isItStopNode=b0,this.replaceEntitiesValue=v0,this.readStopNodeData=x0,this.saveTextToParentTag=w0,this.addChild=y0,this.ignoreAttributesFn=u0(this.options.ignoreAttributes)}};function p0(t){const e=Object.keys(t);for(let n=0;n<e.length;n++){const r=e[n];this.lastEntities[r]={regex:new RegExp("&"+r+";","g"),val:t[r]}}}function f0(t,e,n,r,i,s,a){if(t!==void 0&&(this.options.trimValues&&!r&&(t=t.trim()),t.length>0)){a||(t=this.replaceEntitiesValue(t));const c=this.options.tagValueProcessor(e,t,n,i,s);return c==null?t:typeof c!=typeof t||c!==t?c:this.options.trimValues?ja(t,this.options.parseTagValue,this.options.numberParseOptions):t.trim()===t?ja(t,this.options.parseTagValue,this.options.numberParseOptions):t}}function h0(t){if(this.options.removeNSPrefix){const e=t.split(":"),n=t.charAt(0)==="/"?"/":"";if(e[0]==="xmlns")return"";e.length===2&&(t=n+e[1])}return t}const g0=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function m0(t,e,n){if(this.options.ignoreAttributes!==!0&&typeof t=="string"){const r=Rf.getAllMatches(t,g0),i=r.length,s={};for(let a=0;a<i;a++){const c=this.resolveNameSpace(r[a][1]);if(this.ignoreAttributesFn(c,e))continue;let l=r[a][4],u=this.options.attributeNamePrefix+c;if(c.length)if(this.options.transformAttributeName&&(u=this.options.transformAttributeName(u)),u==="__proto__"&&(u="#__proto__"),l!==void 0){this.options.trimValues&&(l=l.trim()),l=this.replaceEntitiesValue(l);const p=this.options.attributeValueProcessor(c,l,e);p==null?s[u]=l:typeof p!=typeof l||p!==l?s[u]=p:s[u]=ja(l,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(s[u]=!0)}if(!Object.keys(s).length)return;if(this.options.attributesGroupName){const a={};return a[this.options.attributesGroupName]=s,a}return s}}const _0=function(t){t=t.replace(/\r\n?/g,`
8
- `);const e=new Ir("!xml");let n=e,r="",i="";for(let s=0;s<t.length;s++)if(t[s]==="<")if(t[s+1]==="/"){const c=_n(t,">",s,"Closing Tag is not closed.");let l=t.substring(s+2,c).trim();if(this.options.removeNSPrefix){const h=l.indexOf(":");h!==-1&&(l=l.substr(h+1))}this.options.transformTagName&&(l=this.options.transformTagName(l)),n&&(r=this.saveTextToParentTag(r,n,i));const u=i.substring(i.lastIndexOf(".")+1);if(l&&this.options.unpairedTags.indexOf(l)!==-1)throw new Error(`Unpaired tag can not be used as closing tag: </${l}>`);let p=0;u&&this.options.unpairedTags.indexOf(u)!==-1?(p=i.lastIndexOf(".",i.lastIndexOf(".")-1),this.tagsNodeStack.pop()):p=i.lastIndexOf("."),i=i.substring(0,p),n=this.tagsNodeStack.pop(),r="",s=c}else if(t[s+1]==="?"){let c=Ca(t,s,!1,"?>");if(!c)throw new Error("Pi Tag is not closed.");if(r=this.saveTextToParentTag(r,n,i),!(this.options.ignoreDeclaration&&c.tagName==="?xml"||this.options.ignorePiTags)){const l=new Ir(c.tagName);l.add(this.options.textNodeName,""),c.tagName!==c.tagExp&&c.attrExpPresent&&(l[":@"]=this.buildAttributesMap(c.tagExp,i,c.tagName)),this.addChild(n,l,i)}s=c.closeIndex+1}else if(t.substr(s+1,3)==="!--"){const c=_n(t,"-->",s+4,"Comment is not closed.");if(this.options.commentPropName){const l=t.substring(s+4,c-2);r=this.saveTextToParentTag(r,n,i),n.add(this.options.commentPropName,[{[this.options.textNodeName]:l}])}s=c}else if(t.substr(s+1,2)==="!D"){const c=c0(t,s);this.docTypeEntities=c.entities,s=c.i}else if(t.substr(s+1,2)==="!["){const c=_n(t,"]]>",s,"CDATA is not closed.")-2,l=t.substring(s+9,c);r=this.saveTextToParentTag(r,n,i);let u=this.parseTextData(l,n.tagname,i,!0,!1,!0,!0);u==null&&(u=""),this.options.cdataPropName?n.add(this.options.cdataPropName,[{[this.options.textNodeName]:l}]):n.add(this.options.textNodeName,u),s=c+2}else{let c=Ca(t,s,this.options.removeNSPrefix),l=c.tagName;const u=c.rawTagName;let p=c.tagExp,h=c.attrExpPresent,m=c.closeIndex;this.options.transformTagName&&(l=this.options.transformTagName(l)),n&&r&&n.tagname!=="!xml"&&(r=this.saveTextToParentTag(r,n,i,!1));const v=n;if(v&&this.options.unpairedTags.indexOf(v.tagname)!==-1&&(n=this.tagsNodeStack.pop(),i=i.substring(0,i.lastIndexOf("."))),l!==e.tagname&&(i+=i?"."+l:l),this.isItStopNode(this.options.stopNodes,i,l)){let f="";if(p.length>0&&p.lastIndexOf("/")===p.length-1)l[l.length-1]==="/"?(l=l.substr(0,l.length-1),i=i.substr(0,i.length-1),p=l):p=p.substr(0,p.length-1),s=c.closeIndex;else if(this.options.unpairedTags.indexOf(l)!==-1)s=c.closeIndex;else{const w=this.readStopNodeData(t,u,m+1);if(!w)throw new Error(`Unexpected end of ${u}`);s=w.i,f=w.tagContent}const _=new Ir(l);l!==p&&h&&(_[":@"]=this.buildAttributesMap(p,i,l)),f&&(f=this.parseTextData(f,l,i,!0,h,!0,!0)),i=i.substr(0,i.lastIndexOf(".")),_.add(this.options.textNodeName,f),this.addChild(n,_,i)}else{if(p.length>0&&p.lastIndexOf("/")===p.length-1){l[l.length-1]==="/"?(l=l.substr(0,l.length-1),i=i.substr(0,i.length-1),p=l):p=p.substr(0,p.length-1),this.options.transformTagName&&(l=this.options.transformTagName(l));const f=new Ir(l);l!==p&&h&&(f[":@"]=this.buildAttributesMap(p,i,l)),this.addChild(n,f,i),i=i.substr(0,i.lastIndexOf("."))}else{const f=new Ir(l);this.tagsNodeStack.push(n),l!==p&&h&&(f[":@"]=this.buildAttributesMap(p,i,l)),this.addChild(n,f,i),n=f}r="",s=m}}else r+=t[s];return e.child};function y0(t,e,n){const r=this.options.updateTag(e.tagname,n,e[":@"]);r===!1||(typeof r=="string"&&(e.tagname=r),t.addChild(e))}const v0=function(t){if(this.options.processEntities){for(let e in this.docTypeEntities){const n=this.docTypeEntities[e];t=t.replace(n.regx,n.val)}for(let e in this.lastEntities){const n=this.lastEntities[e];t=t.replace(n.regex,n.val)}if(this.options.htmlEntities)for(let e in this.htmlEntities){const n=this.htmlEntities[e];t=t.replace(n.regex,n.val)}t=t.replace(this.ampEntity.regex,this.ampEntity.val)}return t};function w0(t,e,n,r){return t&&(r===void 0&&(r=Object.keys(e.child).length===0),t=this.parseTextData(t,e.tagname,n,!1,e[":@"]?Object.keys(e[":@"]).length!==0:!1,r),t!==void 0&&t!==""&&e.add(this.options.textNodeName,t),t=""),t}function b0(t,e,n){const r="*."+n;for(const i in t){const s=t[i];if(r===s||e===s)return!0}return!1}function k0(t,e,n=">"){let r,i="";for(let s=e;s<t.length;s++){let a=t[s];if(r)a===r&&(r="");else if(a==='"'||a==="'")r=a;else if(a===n[0])if(n[1]){if(t[s+1]===n[1])return{data:i,index:s}}else return{data:i,index:s};else a===" "&&(a=" ");i+=a}}function _n(t,e,n,r){const i=t.indexOf(e,n);if(i===-1)throw new Error(r);return i+e.length-1}function Ca(t,e,n,r=">"){const i=k0(t,e+1,r);if(!i)return;let s=i.data;const a=i.index,c=s.search(/\s/);let l=s,u=!0;c!==-1&&(l=s.substring(0,c),s=s.substring(c+1).trimStart());const p=l;if(n){const h=l.indexOf(":");h!==-1&&(l=l.substr(h+1),u=l!==i.data.substr(h+1))}return{tagName:l,tagExp:s,closeIndex:a,attrExpPresent:u,rawTagName:p}}function x0(t,e,n){const r=n;let i=1;for(;n<t.length;n++)if(t[n]==="<")if(t[n+1]==="/"){const s=_n(t,">",n,`${e} is not closed`);if(t.substring(n+2,s).trim()===e&&(i--,i===0))return{tagContent:t.substring(r,n),i:s};n=s}else if(t[n+1]==="?")n=_n(t,"?>",n+1,"StopNode is not closed.");else if(t.substr(n+1,3)==="!--")n=_n(t,"-->",n+3,"StopNode is not closed.");else if(t.substr(n+1,2)==="![")n=_n(t,"]]>",n,"StopNode is not closed.")-2;else{const s=Ca(t,n,">");s&&((s&&s.tagName)===e&&s.tagExp[s.tagExp.length-1]!=="/"&&i++,n=s.closeIndex)}}function ja(t,e,n){if(e&&typeof t=="string"){const r=t.trim();return r==="true"?!0:r==="false"?!1:l0(t,n)}else return Rf.isExist(t)?t:""}var S0=d0,Lf={};function A0(t,e){return Uf(t,e)}function Uf(t,e,n){let r;const i={};for(let s=0;s<t.length;s++){const a=t[s],c=E0(a);let l="";if(n===void 0?l=c:l=n+"."+c,c===e.textNodeName)r===void 0?r=a[c]:r+=""+a[c];else{if(c===void 0)continue;if(a[c]){let u=Uf(a[c],e,l);const p=z0(u,e);a[":@"]?I0(u,a[":@"],l,e):Object.keys(u).length===1&&u[e.textNodeName]!==void 0&&!e.alwaysCreateTextNode?u=u[e.textNodeName]:Object.keys(u).length===0&&(e.alwaysCreateTextNode?u[e.textNodeName]="":u=""),i[c]!==void 0&&i.hasOwnProperty(c)?(Array.isArray(i[c])||(i[c]=[i[c]]),i[c].push(u)):e.isArray(c,l,p)?i[c]=[u]:i[c]=u}}}return typeof r=="string"?r.length>0&&(i[e.textNodeName]=r):r!==void 0&&(i[e.textNodeName]=r),i}function E0(t){const e=Object.keys(t);for(let n=0;n<e.length;n++){const r=e[n];if(r!==":@")return r}}function I0(t,e,n,r){if(e){const i=Object.keys(e),s=i.length;for(let a=0;a<s;a++){const c=i[a];r.isArray(c,n+"."+c,!0,!0)?t[c]=[e[c]]:t[c]=e[c]}}}function z0(t,e){const{textNodeName:n}=e,r=Object.keys(t).length;return!!(r===0||r===1&&(t[n]||typeof t[n]=="boolean"||t[n]===0))}Lf.prettify=A0;const{buildOptions:N0}=ul,C0=S0,{prettify:j0}=Lf,$0=cl;let O0=class{constructor(e){this.externalEntities={},this.options=N0(e)}parse(e,n){if(typeof e!="string")if(e.toString)e=e.toString();else throw new Error("XML data is accepted in String or Bytes[] form.");if(n){n===!0&&(n={});const s=$0.validate(e,n);if(s!==!0)throw Error(`${s.err.msg}:${s.err.line}:${s.err.col}`)}const r=new C0(this.options);r.addExternalEntities(this.externalEntities);const i=r.parseXml(e);return this.options.preserveOrder||i===void 0?i:j0(i,this.options)}addEntity(e,n){if(n.indexOf("&")!==-1)throw new Error("Entity value can't have '&'");if(e.indexOf("&")!==-1||e.indexOf(";")!==-1)throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");if(n==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[e]=n}};var B0=O0;const T0=`
9
- `;function P0(t,e){let n="";return e.format&&e.indentBy.length>0&&(n=T0),Vf(t,e,"",n)}function Vf(t,e,n,r){let i="",s=!1;for(let a=0;a<t.length;a++){const c=t[a],l=R0(c);if(l===void 0)continue;let u="";if(n.length===0?u=l:u=`${n}.${l}`,l===e.textNodeName){let f=c[l];L0(u,e)||(f=e.tagValueProcessor(l,f),f=qf(f,e)),s&&(i+=r),i+=f,s=!1;continue}else if(l===e.cdataPropName){s&&(i+=r),i+=`<![CDATA[${c[l][0][e.textNodeName]}]]>`,s=!1;continue}else if(l===e.commentPropName){i+=r+`<!--${c[l][0][e.textNodeName]}-->`,s=!0;continue}else if(l[0]==="?"){const f=Wu(c[":@"],e),_=l==="?xml"?"":r;let w=c[l][0][e.textNodeName];w=w.length!==0?" "+w:"",i+=_+`<${l}${w}${f}?>`,s=!0;continue}let p=r;p!==""&&(p+=e.indentBy);const h=Wu(c[":@"],e),m=r+`<${l}${h}`,v=Vf(c[l],e,u,p);e.unpairedTags.indexOf(l)!==-1?e.suppressUnpairedNode?i+=m+">":i+=m+"/>":(!v||v.length===0)&&e.suppressEmptyNode?i+=m+"/>":v&&v.endsWith(">")?i+=m+`>${v}${r}</${l}>`:(i+=m+">",v&&r!==""&&(v.includes("/>")||v.includes("</"))?i+=r+e.indentBy+v+r:i+=v,i+=`</${l}>`),s=!0}return i}function R0(t){const e=Object.keys(t);for(let n=0;n<e.length;n++){const r=e[n];if(t.hasOwnProperty(r)&&r!==":@")return r}}function Wu(t,e){let n="";if(t&&!e.ignoreAttributes)for(let r in t){if(!t.hasOwnProperty(r))continue;let i=e.attributeValueProcessor(r,t[r]);i=qf(i,e),i===!0&&e.suppressBooleanAttributes?n+=` ${r.substr(e.attributeNamePrefix.length)}`:n+=` ${r.substr(e.attributeNamePrefix.length)}="${i}"`}return n}function L0(t,e){t=t.substr(0,t.length-e.textNodeName.length-1);let n=t.substr(t.lastIndexOf(".")+1);for(let r in e.stopNodes)if(e.stopNodes[r]===t||e.stopNodes[r]==="*."+n)return!0;return!1}function qf(t,e){if(t&&t.length>0&&e.processEntities)for(let n=0;n<e.entities.length;n++){const r=e.entities[n];t=t.replace(r.regex,r.val)}return t}var U0=P0;const V0=U0,q0=Pf,M0={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp("&","g"),val:"&amp;"},{regex:new RegExp(">","g"),val:"&gt;"},{regex:new RegExp("<","g"),val:"&lt;"},{regex:new RegExp("'","g"),val:"&apos;"},{regex:new RegExp('"',"g"),val:"&quot;"}],processEntities:!0,stopNodes:[],oneListGroup:!1};function rn(t){this.options=Object.assign({},M0,t),this.options.ignoreAttributes===!0||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn=q0(this.options.ignoreAttributes),this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=F0),this.processTextOrObjNode=D0,this.options.format?(this.indentate=H0,this.tagEndChar=`>
5
+ */(function(e,n){typeof o_=="function"&&t&&t.exports?t.exports=n():(e.dcodeIO=e.dcodeIO||{}).bcrypt=n()})(as,function(){var e={},n=null;function r(j){if(t&&t.exports)try{return l_.randomBytes(j)}catch{}try{var N;return(self.crypto||self.msCrypto).getRandomValues(N=new Uint32Array(j)),Array.prototype.slice.call(N)}catch{}if(!n)throw Error("Neither WebCryptoAPI nor a crypto module is available. Use bcrypt.setRandomFallback to set an alternative");return n(j)}var i=!1;try{r(1),i=!0}catch{}n=null,e.setRandomFallback=function(j){n=j},e.genSaltSync=function(j,N){if(j=j||_,typeof j!="number")throw Error("Illegal arguments: "+typeof j+", "+typeof N);j<4?j=4:j>31&&(j=31);var E=[];return E.push("$2a$"),j<10&&E.push("0"),E.push(j.toString()),E.push("$"),E.push(h(r(f),f)),E.join("")},e.genSalt=function(j,N,E){if(typeof N=="function"&&(E=N,N=void 0),typeof j=="function"&&(E=j,j=void 0),typeof j>"u")j=_;else if(typeof j!="number")throw Error("illegal arguments: "+typeof j);function x(k){a(function(){try{k(null,e.genSaltSync(j))}catch($){k($)}})}if(E){if(typeof E!="function")throw Error("Illegal callback: "+typeof E);x(E)}else return new Promise(function(k,$){x(function(U,X){if(U){$(U);return}k(X)})})},e.hashSync=function(j,N){if(typeof N>"u"&&(N=_),typeof N=="number"&&(N=e.genSaltSync(N)),typeof j!="string"||typeof N!="string")throw Error("Illegal arguments: "+typeof j+", "+typeof N);return Re(j,N)},e.hash=function(j,N,E,x){function k($){typeof j=="string"&&typeof N=="number"?e.genSalt(N,function(U,X){Re(j,X,$,x)}):typeof j=="string"&&typeof N=="string"?Re(j,N,$,x):a($.bind(this,Error("Illegal arguments: "+typeof j+", "+typeof N)))}if(E){if(typeof E!="function")throw Error("Illegal callback: "+typeof E);k(E)}else return new Promise(function($,U){k(function(X,G){if(X){U(X);return}$(G)})})};function s(j,N){for(var E=0,x=0,k=0,$=j.length;k<$;++k)j.charCodeAt(k)===N.charCodeAt(k)?++E:++x;return E<0?!1:x===0}e.compareSync=function(j,N){if(typeof j!="string"||typeof N!="string")throw Error("Illegal arguments: "+typeof j+", "+typeof N);return N.length!==60?!1:s(e.hashSync(j,N.substr(0,N.length-31)),N)},e.compare=function(j,N,E,x){function k($){if(typeof j!="string"||typeof N!="string"){a($.bind(this,Error("Illegal arguments: "+typeof j+", "+typeof N)));return}if(N.length!==60){a($.bind(this,null,!1));return}e.hash(j,N.substr(0,29),function(U,X){U?$(U):$(null,s(X,N))},x)}if(E){if(typeof E!="function")throw Error("Illegal callback: "+typeof E);k(E)}else return new Promise(function($,U){k(function(X,G){if(X){U(X);return}$(G)})})},e.getRounds=function(j){if(typeof j!="string")throw Error("Illegal arguments: "+typeof j);return parseInt(j.split("$")[2],10)},e.getSalt=function(j){if(typeof j!="string")throw Error("Illegal arguments: "+typeof j);if(j.length!==60)throw Error("Illegal hash length: "+j.length+" != 60");return j.substring(0,29)};var a=typeof process<"u"&&process&&typeof process.nextTick=="function"?typeof setImmediate=="function"?setImmediate:process.nextTick:setTimeout;function c(j){var N=[],E=0;return v.encodeUTF16toUTF8(function(){return E>=j.length?null:j.charCodeAt(E++)},function(x){N.push(x)}),N}var l="./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),u=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,54,55,56,57,58,59,60,61,62,63,-1,-1,-1,-1,-1,-1,-1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,-1,-1,-1,-1,-1,-1,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,-1,-1,-1,-1,-1],p=String.fromCharCode;function h(j,N){var E=0,x=[],k,$;if(N<=0||N>j.length)throw Error("Illegal len: "+N);for(;E<N;){if(k=j[E++]&255,x.push(l[k>>2&63]),k=(k&3)<<4,E>=N){x.push(l[k&63]);break}if($=j[E++]&255,k|=$>>4&15,x.push(l[k&63]),k=($&15)<<2,E>=N){x.push(l[k&63]);break}$=j[E++]&255,k|=$>>6&3,x.push(l[k&63]),x.push(l[$&63])}return x.join("")}function m(j,N){var E=0,x=j.length,k=0,$=[],U,X,G,ie,de,H;if(N<=0)throw Error("Illegal len: "+N);for(;E<x-1&&k<N&&(H=j.charCodeAt(E++),U=H<u.length?u[H]:-1,H=j.charCodeAt(E++),X=H<u.length?u[H]:-1,!(U==-1||X==-1||(de=U<<2>>>0,de|=(X&48)>>4,$.push(p(de)),++k>=N||E>=x)||(H=j.charCodeAt(E++),G=H<u.length?u[H]:-1,G==-1)||(de=(X&15)<<4>>>0,de|=(G&60)>>2,$.push(p(de)),++k>=N||E>=x)));)H=j.charCodeAt(E++),ie=H<u.length?u[H]:-1,de=(G&3)<<6>>>0,de|=ie,$.push(p(de)),++k;var Ne=[];for(E=0;E<k;E++)Ne.push($[E].charCodeAt(0));return Ne}var v=function(){var j={};return j.MAX_CODEPOINT=1114111,j.encodeUTF8=function(N,E){var x=null;for(typeof N=="number"&&(x=N,N=function(){return null});x!==null||(x=N())!==null;)x<128?E(x&127):x<2048?(E(x>>6&31|192),E(x&63|128)):x<65536?(E(x>>12&15|224),E(x>>6&63|128),E(x&63|128)):(E(x>>18&7|240),E(x>>12&63|128),E(x>>6&63|128),E(x&63|128)),x=null},j.decodeUTF8=function(N,E){for(var x,k,$,U,X=function(G){G=G.slice(0,G.indexOf(null));var ie=Error(G.toString());throw ie.name="TruncatedError",ie.bytes=G,ie};(x=N())!==null;)if(!(x&128))E(x);else if((x&224)===192)(k=N())===null&&X([x,k]),E((x&31)<<6|k&63);else if((x&240)===224)((k=N())===null||($=N())===null)&&X([x,k,$]),E((x&15)<<12|(k&63)<<6|$&63);else if((x&248)===240)((k=N())===null||($=N())===null||(U=N())===null)&&X([x,k,$,U]),E((x&7)<<18|(k&63)<<12|($&63)<<6|U&63);else throw RangeError("Illegal starting byte: "+x)},j.UTF16toUTF8=function(N,E){for(var x,k=null;(x=k!==null?k:N())!==null;){if(x>=55296&&x<=57343&&(k=N())!==null&&k>=56320&&k<=57343){E((x-55296)*1024+k-56320+65536),k=null;continue}E(x)}k!==null&&E(k)},j.UTF8toUTF16=function(N,E){var x=null;for(typeof N=="number"&&(x=N,N=function(){return null});x!==null||(x=N())!==null;)x<=65535?E(x):(x-=65536,E((x>>10)+55296),E(x%1024+56320)),x=null},j.encodeUTF16toUTF8=function(N,E){j.UTF16toUTF8(N,function(x){j.encodeUTF8(x,E)})},j.decodeUTF8toUTF16=function(N,E){j.decodeUTF8(N,function(x){j.UTF8toUTF16(x,E)})},j.calculateCodePoint=function(N){return N<128?1:N<2048?2:N<65536?3:4},j.calculateUTF8=function(N){for(var E,x=0;(E=N())!==null;)x+=j.calculateCodePoint(E);return x},j.calculateUTF16asUTF8=function(N){var E=0,x=0;return j.UTF16toUTF8(N,function(k){++E,x+=j.calculateCodePoint(k)}),[E,x]},j}();Date.now=Date.now||function(){return+new Date};var f=16,_=10,w=16,S=100,C=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731],B=[3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,1904987480,2182433518,2069144605,3260701109,2620446009,720527379,3318853667,677414384,3393288472,3101374703,2390351024,1614419982,1822297739,2954791486,3608508353,3174124327,2024746970,1432378464,3864339955,2857741204,1464375394,1676153920,1439316330,715854006,3033291828,289532110,2706671279,2087905683,3018724369,1668267050,732546397,1947742710,3462151702,2609353502,2950085171,1814351708,2050118529,680887927,999245976,1800124847,3300911131,1713906067,1641548236,4213287313,1216130144,1575780402,4018429277,3917837745,3693486850,3949271944,596196993,3549867205,258830323,2213823033,772490370,2760122372,1774776394,2652871518,566650946,4142492826,1728879713,2882767088,1783734482,3629395816,2517608232,2874225571,1861159788,326777828,3124490320,2130389656,2716951837,967770486,1724537150,2185432712,2364442137,1164943284,2105845187,998989502,3765401048,2244026483,1075463327,1455516326,1322494562,910128902,469688178,1117454909,936433444,3490320968,3675253459,1240580251,122909385,2157517691,634681816,4142456567,3825094682,3061402683,2540495037,79693498,3249098678,1084186820,1583128258,426386531,1761308591,1047286709,322548459,995290223,1845252383,2603652396,3431023940,2942221577,3202600964,3727903485,1712269319,422464435,3234572375,1170764815,3523960633,3117677531,1434042557,442511882,3600875718,1076654713,1738483198,4213154764,2393238008,3677496056,1014306527,4251020053,793779912,2902807211,842905082,4246964064,1395751752,1040244610,2656851899,3396308128,445077038,3742853595,3577915638,679411651,2892444358,2354009459,1767581616,3150600392,3791627101,3102740896,284835224,4246832056,1258075500,768725851,2589189241,3069724005,3532540348,1274779536,3789419226,2764799539,1660621633,3471099624,4011903706,913787905,3497959166,737222580,2514213453,2928710040,3937242737,1804850592,3499020752,2949064160,2386320175,2390070455,2415321851,4061277028,2290661394,2416832540,1336762016,1754252060,3520065937,3014181293,791618072,3188594551,3933548030,2332172193,3852520463,3043980520,413987798,3465142937,3030929376,4245938359,2093235073,3534596313,375366246,2157278981,2479649556,555357303,3870105701,2008414854,3344188149,4221384143,3956125452,2067696032,3594591187,2921233993,2428461,544322398,577241275,1471733935,610547355,4027169054,1432588573,1507829418,2025931657,3646575487,545086370,48609733,2200306550,1653985193,298326376,1316178497,3007786442,2064951626,458293330,2589141269,3591329599,3164325604,727753846,2179363840,146436021,1461446943,4069977195,705550613,3059967265,3887724982,4281599278,3313849956,1404054877,2845806497,146425753,1854211946,1266315497,3048417604,3681880366,3289982499,290971e4,1235738493,2632868024,2414719590,3970600049,1771706367,1449415276,3266420449,422970021,1963543593,2690192192,3826793022,1062508698,1531092325,1804592342,2583117782,2714934279,4024971509,1294809318,4028980673,1289560198,2221992742,1669523910,35572830,157838143,1052438473,1016535060,1802137761,1753167236,1386275462,3080475397,2857371447,1040679964,2145300060,2390574316,1461121720,2956646967,4031777805,4028374788,33600511,2920084762,1018524850,629373528,3691585981,3515945977,2091462646,2486323059,586499841,988145025,935516892,3367335476,2599673255,2839830854,265290510,3972581182,2759138881,3795373465,1005194799,847297441,406762289,1314163512,1332590856,1866599683,4127851711,750260880,613907577,1450815602,3165620655,3734664991,3650291728,3012275730,3704569646,1427272223,778793252,1343938022,2676280711,2052605720,1946737175,3164576444,3914038668,3967478842,3682934266,1661551462,3294938066,4011595847,840292616,3712170807,616741398,312560963,711312465,1351876610,322626781,1910503582,271666773,2175563734,1594956187,70604529,3617834859,1007753275,1495573769,4069517037,2549218298,2663038764,504708206,2263041392,3941167025,2249088522,1514023603,1998579484,1312622330,694541497,2582060303,2151582166,1382467621,776784248,2618340202,3323268794,2497899128,2784771155,503983604,4076293799,907881277,423175695,432175456,1378068232,4145222326,3954048622,3938656102,3820766613,2793130115,2977904593,26017576,3274890735,3194772133,1700274565,1756076034,4006520079,3677328699,720338349,1533947780,354530856,688349552,3973924725,1637815568,332179504,3949051286,53804574,2852348879,3044236432,1282449977,3583942155,3416972820,4006381244,1617046695,2628476075,3002303598,1686838959,431878346,2686675385,1700445008,1080580658,1009431731,832498133,3223435511,2605976345,2271191193,2516031870,1648197032,4164389018,2548247927,300782431,375919233,238389289,3353747414,2531188641,2019080857,1475708069,455242339,2609103871,448939670,3451063019,1395535956,2413381860,1841049896,1491858159,885456874,4264095073,4001119347,1565136089,3898914787,1108368660,540939232,1173283510,2745871338,3681308437,4207628240,3343053890,4016749493,1699691293,1103962373,3625875870,2256883143,3830138730,1031889488,3479347698,1535977030,4236805024,3251091107,2132092099,1774941330,1199868427,1452454533,157007616,2904115357,342012276,595725824,1480756522,206960106,497939518,591360097,863170706,2375253569,3596610801,1814182875,2094937945,3421402208,1082520231,3463918190,2785509508,435703966,3908032597,1641649973,2842273706,3305899714,1510255612,2148256476,2655287854,3276092548,4258621189,236887753,3681803219,274041037,1734335097,3815195456,3317970021,1899903192,1026095262,4050517792,356393447,2410691914,3873677099,3682840055,3913112168,2491498743,4132185628,2489919796,1091903735,1979897079,3170134830,3567386728,3557303409,857797738,1136121015,1342202287,507115054,2535736646,337727348,3213592640,1301675037,2528481711,1895095763,1721773893,3216771564,62756741,2142006736,835421444,2531993523,1442658625,3659876326,2882144922,676362277,1392781812,170690266,3921047035,1759253602,3611846912,1745797284,664899054,1329594018,3901205900,3045908486,2062866102,2865634940,3543621612,3464012697,1080764994,553557557,3656615353,3996768171,991055499,499776247,1265440854,648242737,3940784050,980351604,3713745714,1749149687,3396870395,4211799374,3640570775,1161844396,3125318951,1431517754,545492359,4268468663,3499529547,1437099964,2702547544,3433638243,2581715763,2787789398,1060185593,1593081372,2418618748,4260947970,69676912,2159744348,86519011,2512459080,3838209314,1220612927,3339683548,133810670,1090789135,1078426020,1569222167,845107691,3583754449,4072456591,1091646820,628848692,1613405280,3757631651,526609435,236106946,48312990,2942717905,3402727701,1797494240,859738849,992217954,4005476642,2243076622,3870952857,3732016268,765654824,3490871365,2511836413,1685915746,3888969200,1414112111,2273134842,3281911079,4080962846,172450625,2569994100,980381355,4109958455,2819808352,2716589560,2568741196,3681446669,3329971472,1835478071,660984891,3704678404,4045999559,3422617507,3040415634,1762651403,1719377915,3470491036,2693910283,3642056355,3138596744,1364962596,2073328063,1983633131,926494387,3423689081,2150032023,4096667949,1749200295,3328846651,309677260,2016342300,1779581495,3079819751,111262694,1274766160,443224088,298511866,1025883608,3806446537,1145181785,168956806,3641502830,3584813610,1689216846,3666258015,3200248200,1692713982,2646376535,4042768518,1618508792,1610833997,3523052358,4130873264,2001055236,3610705100,2202168115,4028541809,2961195399,1006657119,2006996926,3186142756,1430667929,3210227297,1314452623,4074634658,4101304120,2273951170,1399257539,3367210612,3027628629,1190975929,2062231137,2333990788,2221543033,2438960610,1181637006,548689776,2362791313,3372408396,3104550113,3145860560,296247880,1970579870,3078560182,3769228297,1714227617,3291629107,3898220290,166772364,1251581989,493813264,448347421,195405023,2709975567,677966185,3703036547,1463355134,2715995803,1338867538,1343315457,2802222074,2684532164,233230375,2599980071,2000651841,3277868038,1638401717,4028070440,3237316320,6314154,819756386,300326615,590932579,1405279636,3267499572,3150704214,2428286686,3959192993,3461946742,1862657033,1266418056,963775037,2089974820,2263052895,1917689273,448879540,3550394620,3981727096,150775221,3627908307,1303187396,508620638,2975983352,2726630617,1817252668,1876281319,1457606340,908771278,3720792119,3617206836,2455994898,1729034894,1080033504,976866871,3556439503,2881648439,1522871579,1555064734,1336096578,3548522304,2579274686,3574697629,3205460757,3593280638,3338716283,3079412587,564236357,2993598910,1781952180,1464380207,3163844217,3332601554,1699332808,1393555694,1183702653,3581086237,1288719814,691649499,2847557200,2895455976,3193889540,2717570544,1781354906,1676643554,2592534050,3230253752,1126444790,2770207658,2633158820,2210423226,2615765581,2414155088,3127139286,673620729,2805611233,1269405062,4015350505,3341807571,4149409754,1057255273,2012875353,2162469141,2276492801,2601117357,993977747,3918593370,2654263191,753973209,36408145,2530585658,25011837,3520020182,2088578344,530523599,2918365339,1524020338,1518925132,3760827505,3759777254,1202760957,3985898139,3906192525,674977740,4174734889,2031300136,2019492241,3983892565,4153806404,3822280332,352677332,2297720250,60907813,90501309,3286998549,1016092578,2535922412,2839152426,457141659,509813237,4120667899,652014361,1966332200,2975202805,55981186,2327461051,676427537,3255491064,2882294119,3433927263,1307055953,942726286,933058658,2468411793,3933900994,4215176142,1361170020,2001714738,2830558078,3274259782,1222529897,1679025792,2729314320,3714953764,1770335741,151462246,3013232138,1682292957,1483529935,471910574,1539241949,458788160,3436315007,1807016891,3718408830,978976581,1043663428,3165965781,1927990952,4200891579,2372276910,3208408903,3533431907,1412390302,2931980059,4132332400,1947078029,3881505623,4168226417,2941484381,1077988104,1320477388,886195818,18198404,3786409e3,2509781533,112762804,3463356488,1866414978,891333506,18488651,661792760,1628790961,3885187036,3141171499,876946877,2693282273,1372485963,791857591,2686433993,3759982718,3167212022,3472953795,2716379847,445679433,3561995674,3504004811,3574258232,54117162,3331405415,2381918588,3769707343,4154350007,1140177722,4074052095,668550556,3214352940,367459370,261225585,2610173221,4209349473,3468074219,3265815641,314222801,3066103646,3808782860,282218597,3406013506,3773591054,379116347,1285071038,846784868,2669647154,3771962079,3550491691,2305946142,453669953,1268987020,3317592352,3279303384,3744833421,2610507566,3859509063,266596637,3847019092,517658769,3462560207,3443424879,370717030,4247526661,2224018117,4143653529,4112773975,2788324899,2477274417,1456262402,2901442914,1517677493,1846949527,2295493580,3734397586,2176403920,1280348187,1908823572,3871786941,846861322,1172426758,3287448474,3383383037,1655181056,3139813346,901632758,1897031941,2986607138,3066810236,3447102507,1393639104,373351379,950779232,625454576,3124240540,4148612726,2007998917,544563296,2244738638,2330496472,2058025392,1291430526,424198748,50039436,29584100,3605783033,2429876329,2791104160,1057563949,3255363231,3075367218,3463963227,1469046755,985887462],L=[1332899944,1700884034,1701343084,1684370003,1668446532,1869963892];function Q(j,N,E,x){var k,$=j[N],U=j[N+1];return $^=E[0],k=x[$>>>24],k+=x[256|$>>16&255],k^=x[512|$>>8&255],k+=x[768|$&255],U^=k^E[1],k=x[U>>>24],k+=x[256|U>>16&255],k^=x[512|U>>8&255],k+=x[768|U&255],$^=k^E[2],k=x[$>>>24],k+=x[256|$>>16&255],k^=x[512|$>>8&255],k+=x[768|$&255],U^=k^E[3],k=x[U>>>24],k+=x[256|U>>16&255],k^=x[512|U>>8&255],k+=x[768|U&255],$^=k^E[4],k=x[$>>>24],k+=x[256|$>>16&255],k^=x[512|$>>8&255],k+=x[768|$&255],U^=k^E[5],k=x[U>>>24],k+=x[256|U>>16&255],k^=x[512|U>>8&255],k+=x[768|U&255],$^=k^E[6],k=x[$>>>24],k+=x[256|$>>16&255],k^=x[512|$>>8&255],k+=x[768|$&255],U^=k^E[7],k=x[U>>>24],k+=x[256|U>>16&255],k^=x[512|U>>8&255],k+=x[768|U&255],$^=k^E[8],k=x[$>>>24],k+=x[256|$>>16&255],k^=x[512|$>>8&255],k+=x[768|$&255],U^=k^E[9],k=x[U>>>24],k+=x[256|U>>16&255],k^=x[512|U>>8&255],k+=x[768|U&255],$^=k^E[10],k=x[$>>>24],k+=x[256|$>>16&255],k^=x[512|$>>8&255],k+=x[768|$&255],U^=k^E[11],k=x[U>>>24],k+=x[256|U>>16&255],k^=x[512|U>>8&255],k+=x[768|U&255],$^=k^E[12],k=x[$>>>24],k+=x[256|$>>16&255],k^=x[512|$>>8&255],k+=x[768|$&255],U^=k^E[13],k=x[U>>>24],k+=x[256|U>>16&255],k^=x[512|U>>8&255],k+=x[768|U&255],$^=k^E[14],k=x[$>>>24],k+=x[256|$>>16&255],k^=x[512|$>>8&255],k+=x[768|$&255],U^=k^E[15],k=x[U>>>24],k+=x[256|U>>16&255],k^=x[512|U>>8&255],k+=x[768|U&255],$^=k^E[16],j[N]=U^E[w+1],j[N+1]=$,j}function ce(j,N){for(var E=0,x=0;E<4;++E)x=x<<8|j[N]&255,N=(N+1)%j.length;return{key:x,offp:N}}function le(j,N,E){for(var x=0,k=[0,0],$=N.length,U=E.length,X,G=0;G<$;G++)X=ce(j,x),x=X.offp,N[G]=N[G]^X.key;for(G=0;G<$;G+=2)k=Q(k,0,N,E),N[G]=k[0],N[G+1]=k[1];for(G=0;G<U;G+=2)k=Q(k,0,N,E),E[G]=k[0],E[G+1]=k[1]}function De(j,N,E,x){for(var k=0,$=[0,0],U=E.length,X=x.length,G,ie=0;ie<U;ie++)G=ce(N,k),k=G.offp,E[ie]=E[ie]^G.key;for(k=0,ie=0;ie<U;ie+=2)G=ce(j,k),k=G.offp,$[0]^=G.key,G=ce(j,k),k=G.offp,$[1]^=G.key,$=Q($,0,E,x),E[ie]=$[0],E[ie+1]=$[1];for(ie=0;ie<X;ie+=2)G=ce(j,k),k=G.offp,$[0]^=G.key,G=ce(j,k),k=G.offp,$[1]^=G.key,$=Q($,0,E,x),x[ie]=$[0],x[ie+1]=$[1]}function Ue(j,N,E,x,k){var $=L.slice(),U=$.length,X;if(E<4||E>31)if(X=Error("Illegal number of rounds (4-31): "+E),x){a(x.bind(this,X));return}else throw X;if(N.length!==f)if(X=Error("Illegal salt length: "+N.length+" != "+f),x){a(x.bind(this,X));return}else throw X;E=1<<E>>>0;var G,ie,de=0,H;Int32Array?(G=new Int32Array(C),ie=new Int32Array(B)):(G=C.slice(),ie=B.slice()),De(N,j,G,ie);function Ne(){if(k&&k(de/E),de<E)for(var ge=Date.now();de<E&&(de=de+1,le(j,G,ie),le(N,G,ie),!(Date.now()-ge>S)););else{for(de=0;de<64;de++)for(H=0;H<U>>1;H++)Q($,H<<1,G,ie);var Se=[];for(de=0;de<U;de++)Se.push(($[de]>>24&255)>>>0),Se.push(($[de]>>16&255)>>>0),Se.push(($[de]>>8&255)>>>0),Se.push(($[de]&255)>>>0);if(x){x(null,Se);return}else return Se}x&&a(Ne)}if(typeof x<"u")Ne();else for(var fn;;)if(typeof(fn=Ne())<"u")return fn||[]}function Re(j,N,E,x){var k;if(typeof j!="string"||typeof N!="string")if(k=Error("Invalid string / salt: Not a string"),E){a(E.bind(this,k));return}else throw k;var $,U;if(N.charAt(0)!=="$"||N.charAt(1)!=="2")if(k=Error("Invalid salt version: "+N.substring(0,2)),E){a(E.bind(this,k));return}else throw k;if(N.charAt(2)==="$")$="\0",U=3;else{if($=N.charAt(2),$!=="a"&&$!=="b"&&$!=="y"||N.charAt(3)!=="$")if(k=Error("Invalid salt revision: "+N.substring(2,4)),E){a(E.bind(this,k));return}else throw k;U=4}if(N.charAt(U+2)>"$")if(k=Error("Missing salt rounds"),E){a(E.bind(this,k));return}else throw k;var X=parseInt(N.substring(U,U+1),10)*10,G=parseInt(N.substring(U+1,U+2),10),ie=X+G,de=N.substring(U+3,U+25);j+=$>="a"?"\0":"";var H=c(j),Ne=m(de,f);function fn(ge){var Se=[];return Se.push("$2"),$>="a"&&Se.push($),Se.push("$"),ie<10&&Se.push("0"),Se.push(ie.toString()),Se.push("$"),Se.push(h(Ne,Ne.length)),Se.push(h(ge,L.length*4-1)),Se.join("")}if(typeof E>"u")return fn(Ue(H,Ne,ie));Ue(H,Ne,ie,function(ge,Se){ge?E(ge,null):E(null,fn(Se))},x)}return e.encodeBase64=h,e.decodeBase64=m,e})})(Nf);var u_=Nf.exports;const si=zf(u_),d_="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let p_=t=>crypto.getRandomValues(new Uint8Array(t)),f_=(t,e,n)=>{let r=(2<<Math.log2(t.length-1))-1,i=-~(1.6*r*e/t.length);return(s=e)=>{let a="";for(;;){let c=n(i),l=i;for(;l--;)if(a+=t[c[l]&r]||"",a.length===s)return a}}},h_=(t,e=21)=>f_(t,e,p_),xe=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=d_[n[t]&63];return e};const g_=24;function Xs(){return h_("0123456789abcdef",g_)()}function qu(t){if(!t.includes("|"))return console.error("Invalid user_id format"),t;const[,e]=t.split("|");return e}function m_(t){return async(e,n)=>{if(!n.email||!n.email_verified)return t.users.create(e,n);const r=await ro({userAdapter:t.users,tenant_id:e,email:n.email});return r?(await t.users.create(e,{...n,linked_to:r.user_id}),r):t.users.create(e,n)}}function ve(t,e){return{type:e.type,description:e.description||"",ip:t.req.header("x-real-ip")||"",user_agent:t.req.header("user-agent")||"",date:new Date().toISOString(),details:{request:{method:t.req.method,path:t.req.path,qs:t.req.queries(),body:e.body||t.var.body||""}},isMobile:!1,client_id:t.var.client_id,client_name:"",user_id:e.userId||t.var.user_id||"",hostname:t.req.header("host")||"",user_name:t.var.username||"",connection_id:"",connection:t.var.connection||"",strategy:e.strategy||"",strategy_type:e.strategy_type||"",audience:"",scope:[]}}class sl{constructor(e,n){te(this,"value");te(this,"unit");this.value=e,this.unit=n}milliseconds(){return this.unit==="ms"?this.value:this.unit==="s"?this.value*1e3:this.unit==="m"?this.value*1e3*60:this.unit==="h"?this.value*1e3*60*60:this.unit==="d"?this.value*1e3*60*60*24:this.value*1e3*60*60*24*7}seconds(){return this.milliseconds()/1e3}transform(e){return new sl(Math.round(this.milliseconds()*e),"ms")}}class __{constructor(e){te(this,"hash");this.hash=e}async verify(e,n,r){const i=await crypto.subtle.importKey("spki",e,{name:"RSASSA-PKCS1-v1_5",hash:this.hash},!1,["verify"]);return await crypto.subtle.verify("RSASSA-PKCS1-v1_5",i,n,r)}async sign(e,n){const r=await crypto.subtle.importKey("pkcs8",e,{name:"RSASSA-PKCS1-v1_5",hash:this.hash},!1,["sign"]);return await crypto.subtle.sign("RSASSA-PKCS1-v1_5",r,n)}async generateKeyPair(e){const n=await crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",hash:this.hash,modulusLength:e??2048,publicExponent:new Uint8Array([1,0,1])},!0,["sign"]),r=await crypto.subtle.exportKey("pkcs8",n.privateKey),i=await crypto.subtle.exportKey("spki",n.publicKey);return{privateKey:r,publicKey:i}}}async function Cf(t){return await crypto.subtle.digest("SHA-256",t)}const Mu="0123456789abcdef";function za(t){const e=new Uint8Array(t);let n="";for(let r=0;r<e.length;r++){const i=e[r]>>4;n+=Mu[i];const s=e[r]&15;n+=Mu[s]}return n}class jf{constructor(e,n){te(this,"alphabet");te(this,"padding");te(this,"decodeMap",new Map);if(e.length!==32)throw new Error("Invalid alphabet");if(this.alphabet=e,this.padding=(n==null?void 0:n.padding)??"=",this.alphabet.includes(this.padding)||this.padding.length!==1)throw new Error("Invalid padding");for(let r=0;r<e.length;r++)this.decodeMap.set(e[r],r)}encode(e,n){let r="",i=0,s=0;for(let c=0;c<e.length;c++)for(i=i<<8|e[c],s+=8;s>=5;)s-=5,r+=this.alphabet[i>>s&31];if(s>0&&(r+=this.alphabet[i<<5-s&31]),(n==null?void 0:n.includePadding)??!0){const c=(8-r.length%8)%8;for(let l=0;l<c;l++)r+="="}return r}decode(e,n){const r=(n==null?void 0:n.strict)??!0,i=Math.ceil(e.length/8),s=[];for(let a=0;a<i;a++){let c=0;const l=[];for(let p=0;p<8;p++){const h=e[a*8+p];if(h==="="){if(a+1!==i)throw new Error(`Invalid character: ${h}`);c+=1;continue}if(h===void 0){if(r)throw new Error("Invalid data");c+=1;continue}const m=this.decodeMap.get(h)??null;if(m===null)throw new Error(`Invalid character: ${h}`);l.push(m)}if(c===8||c===7||c===5||c===2)throw new Error("Invalid padding");const u=(l[0]<<3)+(l[1]>>2);if(s.push(u),c<6){const p=((l[1]&3)<<6)+(l[2]<<1)+(l[3]>>4);s.push(p)}if(c<4){const p=((l[3]&255)<<4)+(l[4]>>1);s.push(p)}if(c<3){const p=((l[4]&1)<<7)+(l[5]<<2)+(l[6]>>3);s.push(p)}if(c<1){const p=((l[6]&7)<<5)+l[7];s.push(p)}}return Uint8Array.from(s)}}new jf("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567");new jf("0123456789ABCDEFGHIJKLMNOPQRSTUV");class $f{constructor(e,n){te(this,"alphabet");te(this,"padding");te(this,"decodeMap",new Map);if(e.length!==64)throw new Error("Invalid alphabet");if(this.alphabet=e,this.padding=(n==null?void 0:n.padding)??"=",this.alphabet.includes(this.padding)||this.padding.length!==1)throw new Error("Invalid padding");for(let r=0;r<e.length;r++)this.decodeMap.set(e[r],r)}encode(e,n){let r="",i=0,s=0;for(let c=0;c<e.length;c++)for(i=i<<8|e[c],s+=8;s>=6;)s+=-6,r+=this.alphabet[i>>s&63];if(s>0&&(r+=this.alphabet[i<<6-s&63]),(n==null?void 0:n.includePadding)??!0){const c=(4-r.length%4)%4;for(let l=0;l<c;l++)r+="="}return r}decode(e,n){const r=(n==null?void 0:n.strict)??!0,i=Math.ceil(e.length/4),s=[];for(let a=0;a<i;a++){let c=0,l=0;for(let u=0;u<4;u++){const p=e[a*4+u];if(p==="="){if(a+1!==i)throw new Error(`Invalid character: ${p}`);c+=1;continue}if(p===void 0){if(r)throw new Error("Invalid data");c+=1;continue}const h=this.decodeMap.get(p)??null;if(h===null)throw new Error(`Invalid character: ${p}`);l+=h<<6*(3-u)}s.push(l>>16&255),c<2&&s.push(l>>8&255),c<1&&s.push(l&255)}return Uint8Array.from(s)}}const y_=new $f("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),wn=new $f("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_");async function Du(t,e,n,r){const i={alg:t,typ:"JWT",...r==null?void 0:r.headers},s={...n};(r==null?void 0:r.audiences)!==void 0&&(s.aud=r.audiences),(r==null?void 0:r.subject)!==void 0&&(s.sub=r.subject),(r==null?void 0:r.issuer)!==void 0&&(s.iss=r.issuer),(r==null?void 0:r.jwtId)!==void 0&&(s.jti=r.jwtId),(r==null?void 0:r.expiresIn)!==void 0&&(s.exp=Math.floor(Date.now()/1e3)+r.expiresIn.seconds()),(r==null?void 0:r.notBefore)!==void 0&&(s.nbf=Math.floor(r.notBefore.getTime()/1e3)),s.iat=Math.floor(Date.now()/1e3);const a=new TextEncoder,c=wn.encode(a.encode(JSON.stringify(i)),{includePadding:!1}),l=wn.encode(a.encode(JSON.stringify(s)),{includePadding:!1}),u=a.encode([c,l].join(".")),p=await w_(t).sign(e,u),h=wn.encode(new Uint8Array(p),{includePadding:!1});return[c,l,h].join(".")}function v_(t){const e=t.split(".");return e.length!==3?null:e}function ol(t){const e=v_(t);if(!e)return null;const n=new TextDecoder,r=wn.decode(e[0],{strict:!1}),i=wn.decode(e[1],{strict:!1}),s=JSON.parse(n.decode(r));if(typeof s!="object"||s===null||!("alg"in s)||!b_(s.alg)||"typ"in s&&s.typ!=="JWT")return null;const a=JSON.parse(n.decode(i));if(typeof a!="object"||a===null)return null;const c={algorithm:s.alg,expiresAt:null,subject:null,issuedAt:null,issuer:null,jwtId:null,audiences:null,notBefore:null};if("exp"in a){if(typeof a.exp!="number")return null;c.expiresAt=new Date(a.exp*1e3)}if("iss"in a){if(typeof a.iss!="string")return null;c.issuer=a.iss}if("sub"in a){if(typeof a.sub!="string")return null;c.subject=a.sub}if("aud"in a)if(Array.isArray(a.aud)){for(const l of a.aud)if(typeof l!="string")return null;c.audiences=a.aud}else{if(typeof a.aud!="string")return null;c.audiences=[a.aud]}if("nbf"in a){if(typeof a.nbf!="number")return null;c.notBefore=new Date(a.nbf*1e3)}if("iat"in a){if(typeof a.iat!="number")return null;c.issuedAt=new Date(a.iat*1e3)}if("jti"in a){if(typeof a.jti!="string")return null;c.jwtId=a.jti}return{value:t,header:{...s,typ:"JWT",alg:s.alg},payload:{...a},parts:e,...c}}function w_(t){return new __(k_[t])}function b_(t){return typeof t!="string"?!1:["HS256","HS384","HS512","RS256","RS384","RS512","ES256","ES384","ES512","PS256","PS384","PS512"].includes(t)}const k_={RS256:"SHA-256",RS384:"SHA-384",RS512:"SHA-512"};function x_(){const t=new Uint8Array(32);return crypto.getRandomValues(t),wn.encode(t,{includePadding:!1})}function S_(t){try{const n=/-----BEGIN (?:RSA )?(?:PRIVATE|PUBLIC) KEY-----([^-]*)-----END (?:RSA )?(?:PRIVATE|PUBLIC) KEY-----/.exec(t);if(!n||!n[1])throw new Error("Invalid PEM format");return Uint8Array.from(atob(n[1].replace(/\s/g,"")),r=>r.charCodeAt(0)).buffer}finally{t=t.replace(/./g,"\0")}}async function A_(t,e){if(e==="plain")return t;const n=new TextEncoder().encode(t),r=await Cf(n);return wn.encode(new Uint8Array(r),{includePadding:!1})}const ji=60*5,Qs=30*24*60*60,Jn=24*60*60,E_="auth-token",Na=30*60*1e3,I_=7*24*60*60*1e3,z_=5*60,N_=5*60,C_=30*60*1e3,j_=30*60*1e3,$_=24*60*60*1e3;function Of(t,e,n){const r=[];return r.push([encodeURIComponent(t),encodeURIComponent(e)]),(n==null?void 0:n.domain)!==void 0&&r.push(["Domain",n.domain]),(n==null?void 0:n.expires)!==void 0&&r.push(["Expires",n.expires.toUTCString()]),n!=null&&n.httpOnly&&r.push(["HttpOnly"]),(n==null?void 0:n.maxAge)!==void 0&&r.push(["Max-Age",n.maxAge.toString()]),(n==null?void 0:n.path)!==void 0&&r.push(["Path",n.path]),(n==null?void 0:n.sameSite)==="lax"&&r.push(["SameSite","Lax"]),(n==null?void 0:n.sameSite)==="none"&&r.push(["SameSite","None"]),(n==null?void 0:n.sameSite)==="strict"&&r.push(["SameSite","Strict"]),n!=null&&n.secure&&r.push(["Secure"]),r.map(i=>i.join("=")).join("; ")}function O_(t){const e=new Map,n=t.split("; ");for(const r of n){const i=r.split("="),s=i[0],a=i[1]??"";s&&e.set(decodeURIComponent(s),decodeURIComponent(a))}return e}function al(t){return`${t}-${E_}`}function Bf(t){if(!t)return;if(t==="localhost"||/^(\d{1,3}\.){3}\d{1,3}$/.test(t))return t;const e=t.split(".");return e.length>2?`.${e.slice(-2).join(".")}`:`.${t}`}function cs(t,e){return e?O_(e).get(al(t)):void 0}function B_(t,e){return Of(al(t),"",{path:"/",httpOnly:!0,secure:!0,maxAge:0,sameSite:"none",domain:e?Bf(e):void 0})}function Tf(t,e,n){return Of(al(t),e,{path:"/",httpOnly:!0,secure:!0,maxAge:Qs,sameSite:"none",domain:n?Bf(n):void 0})}var cl={},eo={};(function(t){const e=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",n=e+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040",r="["+e+"]["+n+"]*",i=new RegExp("^"+r+"$"),s=function(c,l){const u=[];let p=l.exec(c);for(;p;){const h=[];h.startIndex=l.lastIndex-p[0].length;const m=p.length;for(let v=0;v<m;v++)h.push(p[v]);u.push(h),p=l.exec(c)}return u},a=function(c){const l=i.exec(c);return!(l===null||typeof l>"u")};t.isExist=function(c){return typeof c<"u"},t.isEmptyObject=function(c){return Object.keys(c).length===0},t.merge=function(c,l,u){if(l){const p=Object.keys(l),h=p.length;for(let m=0;m<h;m++)u==="strict"?c[p[m]]=[l[p[m]]]:c[p[m]]=l[p[m]]}},t.getValue=function(c){return t.isExist(c)?c:""},t.isName=a,t.getAllMatches=s,t.nameRegexp=r})(eo);const ll=eo,T_={allowBooleanAttributes:!1,unpairedTags:[]};cl.validate=function(t,e){e=Object.assign({},T_,e);const n=[];let r=!1,i=!1;t[0]==="\uFEFF"&&(t=t.substr(1));for(let s=0;s<t.length;s++)if(t[s]==="<"&&t[s+1]==="?"){if(s+=2,s=Fu(t,s),s.err)return s}else if(t[s]==="<"){let a=s;if(s++,t[s]==="!"){s=Ku(t,s);continue}else{let c=!1;t[s]==="/"&&(c=!0,s++);let l="";for(;s<t.length&&t[s]!==">"&&t[s]!==" "&&t[s]!==" "&&t[s]!==`
6
+ `&&t[s]!=="\r";s++)l+=t[s];if(l=l.trim(),l[l.length-1]==="/"&&(l=l.substring(0,l.length-1),s--),!D_(l)){let h;return l.trim().length===0?h="Invalid space after '<'.":h="Tag '"+l+"' is an invalid name.",be("InvalidTag",h,Ve(t,s))}const u=L_(t,s);if(u===!1)return be("InvalidAttr","Attributes for '"+l+"' have open quote.",Ve(t,s));let p=u.value;if(s=u.index,p[p.length-1]==="/"){const h=s-p.length;p=p.substring(0,p.length-1);const m=Wu(p,e);if(m===!0)r=!0;else return be(m.err.code,m.err.msg,Ve(t,h+m.err.line))}else if(c)if(u.tagClosed){if(p.trim().length>0)return be("InvalidTag","Closing tag '"+l+"' can't have attributes or invalid starting.",Ve(t,a));if(n.length===0)return be("InvalidTag","Closing tag '"+l+"' has not been opened.",Ve(t,a));{const h=n.pop();if(l!==h.tagName){let m=Ve(t,h.tagStartPos);return be("InvalidTag","Expected closing tag '"+h.tagName+"' (opened in line "+m.line+", col "+m.col+") instead of closing tag '"+l+"'.",Ve(t,a))}n.length==0&&(i=!0)}}else return be("InvalidTag","Closing tag '"+l+"' doesn't have proper closing.",Ve(t,s));else{const h=Wu(p,e);if(h!==!0)return be(h.err.code,h.err.msg,Ve(t,s-p.length+h.err.line));if(i===!0)return be("InvalidXml","Multiple possible root nodes found.",Ve(t,s));e.unpairedTags.indexOf(l)!==-1||n.push({tagName:l,tagStartPos:a}),r=!0}for(s++;s<t.length;s++)if(t[s]==="<")if(t[s+1]==="!"){s++,s=Ku(t,s);continue}else if(t[s+1]==="?"){if(s=Fu(t,++s),s.err)return s}else break;else if(t[s]==="&"){const h=q_(t,s);if(h==-1)return be("InvalidChar","char '&' is not expected.",Ve(t,s));s=h}else if(i===!0&&!Hu(t[s]))return be("InvalidXml","Extra text at the end",Ve(t,s));t[s]==="<"&&s--}}else{if(Hu(t[s]))continue;return be("InvalidChar","char '"+t[s]+"' is not expected.",Ve(t,s))}if(r){if(n.length==1)return be("InvalidTag","Unclosed tag '"+n[0].tagName+"'.",Ve(t,n[0].tagStartPos));if(n.length>0)return be("InvalidXml","Invalid '"+JSON.stringify(n.map(s=>s.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1})}else return be("InvalidXml","Start tag expected.",1);return!0};function Hu(t){return t===" "||t===" "||t===`
7
+ `||t==="\r"}function Fu(t,e){const n=e;for(;e<t.length;e++)if(t[e]=="?"||t[e]==" "){const r=t.substr(n,e-n);if(e>5&&r==="xml")return be("InvalidXml","XML declaration allowed only at the start of the document.",Ve(t,e));if(t[e]=="?"&&t[e+1]==">"){e++;break}else continue}return e}function Ku(t,e){if(t.length>e+5&&t[e+1]==="-"&&t[e+2]==="-"){for(e+=3;e<t.length;e++)if(t[e]==="-"&&t[e+1]==="-"&&t[e+2]===">"){e+=2;break}}else if(t.length>e+8&&t[e+1]==="D"&&t[e+2]==="O"&&t[e+3]==="C"&&t[e+4]==="T"&&t[e+5]==="Y"&&t[e+6]==="P"&&t[e+7]==="E"){let n=1;for(e+=8;e<t.length;e++)if(t[e]==="<")n++;else if(t[e]===">"&&(n--,n===0))break}else if(t.length>e+9&&t[e+1]==="["&&t[e+2]==="C"&&t[e+3]==="D"&&t[e+4]==="A"&&t[e+5]==="T"&&t[e+6]==="A"&&t[e+7]==="["){for(e+=8;e<t.length;e++)if(t[e]==="]"&&t[e+1]==="]"&&t[e+2]===">"){e+=2;break}}return e}const P_='"',R_="'";function L_(t,e){let n="",r="",i=!1;for(;e<t.length;e++){if(t[e]===P_||t[e]===R_)r===""?r=t[e]:r!==t[e]||(r="");else if(t[e]===">"&&r===""){i=!0;break}n+=t[e]}return r!==""?!1:{value:n,index:e,tagClosed:i}}const U_=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function Wu(t,e){const n=ll.getAllMatches(t,U_),r={};for(let i=0;i<n.length;i++){if(n[i][1].length===0)return be("InvalidAttr","Attribute '"+n[i][2]+"' has no space in starting.",Er(n[i]));if(n[i][3]!==void 0&&n[i][4]===void 0)return be("InvalidAttr","Attribute '"+n[i][2]+"' is without value.",Er(n[i]));if(n[i][3]===void 0&&!e.allowBooleanAttributes)return be("InvalidAttr","boolean attribute '"+n[i][2]+"' is not allowed.",Er(n[i]));const s=n[i][2];if(!M_(s))return be("InvalidAttr","Attribute '"+s+"' is an invalid name.",Er(n[i]));if(!r.hasOwnProperty(s))r[s]=1;else return be("InvalidAttr","Attribute '"+s+"' is repeated.",Er(n[i]))}return!0}function V_(t,e){let n=/\d/;for(t[e]==="x"&&(e++,n=/[\da-fA-F]/);e<t.length;e++){if(t[e]===";")return e;if(!t[e].match(n))break}return-1}function q_(t,e){if(e++,t[e]===";")return-1;if(t[e]==="#")return e++,V_(t,e);let n=0;for(;e<t.length;e++,n++)if(!(t[e].match(/\w/)&&n<20)){if(t[e]===";")break;return-1}return e}function be(t,e,n){return{err:{code:t,msg:e,line:n.line||n,col:n.col}}}function M_(t){return ll.isName(t)}function D_(t){return ll.isName(t)}function Ve(t,e){const n=t.substring(0,e).split(/\r?\n/);return{line:n.length,col:n[n.length-1].length+1}}function Er(t){return t.startIndex+t[1].length}var ul={};const Pf={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(t,e,n){return t}},H_=function(t){return Object.assign({},Pf,t)};ul.buildOptions=H_;ul.defaultOptions=Pf;class F_{constructor(e){this.tagname=e,this.child=[],this[":@"]={}}add(e,n){e==="__proto__"&&(e="#__proto__"),this.child.push({[e]:n})}addChild(e){e.tagname==="__proto__"&&(e.tagname="#__proto__"),e[":@"]&&Object.keys(e[":@"]).length>0?this.child.push({[e.tagname]:e.child,":@":e[":@"]}):this.child.push({[e.tagname]:e.child})}}var K_=F_;const W_=eo;function G_(t,e){const n={};if(t[e+3]==="O"&&t[e+4]==="C"&&t[e+5]==="T"&&t[e+6]==="Y"&&t[e+7]==="P"&&t[e+8]==="E"){e=e+9;let r=1,i=!1,s=!1,a="";for(;e<t.length;e++)if(t[e]==="<"&&!s){if(i&&Y_(t,e)){e+=7;let c,l;[c,l,e]=J_(t,e+1),l.indexOf("&")===-1&&(n[t0(c)]={regx:RegExp(`&${c};`,"g"),val:l})}else if(i&&X_(t,e))e+=8;else if(i&&Q_(t,e))e+=8;else if(i&&e0(t,e))e+=9;else if(Z_)s=!0;else throw new Error("Invalid DOCTYPE");r++,a=""}else if(t[e]===">"){if(s?t[e-1]==="-"&&t[e-2]==="-"&&(s=!1,r--):r--,r===0)break}else t[e]==="["?i=!0:a+=t[e];if(r!==0)throw new Error("Unclosed DOCTYPE")}else throw new Error("Invalid Tag instead of DOCTYPE");return{entities:n,i:e}}function J_(t,e){let n="";for(;e<t.length&&t[e]!=="'"&&t[e]!=='"';e++)n+=t[e];if(n=n.trim(),n.indexOf(" ")!==-1)throw new Error("External entites are not supported");const r=t[e++];let i="";for(;e<t.length&&t[e]!==r;e++)i+=t[e];return[n,i,e]}function Z_(t,e){return t[e+1]==="!"&&t[e+2]==="-"&&t[e+3]==="-"}function Y_(t,e){return t[e+1]==="!"&&t[e+2]==="E"&&t[e+3]==="N"&&t[e+4]==="T"&&t[e+5]==="I"&&t[e+6]==="T"&&t[e+7]==="Y"}function X_(t,e){return t[e+1]==="!"&&t[e+2]==="E"&&t[e+3]==="L"&&t[e+4]==="E"&&t[e+5]==="M"&&t[e+6]==="E"&&t[e+7]==="N"&&t[e+8]==="T"}function Q_(t,e){return t[e+1]==="!"&&t[e+2]==="A"&&t[e+3]==="T"&&t[e+4]==="T"&&t[e+5]==="L"&&t[e+6]==="I"&&t[e+7]==="S"&&t[e+8]==="T"}function e0(t,e){return t[e+1]==="!"&&t[e+2]==="N"&&t[e+3]==="O"&&t[e+4]==="T"&&t[e+5]==="A"&&t[e+6]==="T"&&t[e+7]==="I"&&t[e+8]==="O"&&t[e+9]==="N"}function t0(t){if(W_.isName(t))return t;throw new Error(`Invalid entity name ${t}`)}var n0=G_;const r0=/^[-+]?0x[a-fA-F0-9]+$/,i0=/^([\-\+])?(0*)(\.[0-9]+([eE]\-?[0-9]+)?|[0-9]+(\.[0-9]+([eE]\-?[0-9]+)?)?)$/;!Number.parseInt&&window.parseInt&&(Number.parseInt=window.parseInt);!Number.parseFloat&&window.parseFloat&&(Number.parseFloat=window.parseFloat);const s0={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};function o0(t,e={}){if(e=Object.assign({},s0,e),!t||typeof t!="string")return t;let n=t.trim();if(e.skipLike!==void 0&&e.skipLike.test(n))return t;if(e.hex&&r0.test(n))return Number.parseInt(n,16);{const r=i0.exec(n);if(r){const i=r[1],s=r[2];let a=a0(r[3]);const c=r[4]||r[6];if(!e.leadingZeros&&s.length>0&&i&&n[2]!==".")return t;if(!e.leadingZeros&&s.length>0&&!i&&n[1]!==".")return t;{const l=Number(n),u=""+l;return u.search(/[eE]/)!==-1||c?e.eNotation?l:t:n.indexOf(".")!==-1?u==="0"&&a===""||u===a||i&&u==="-"+a?l:t:s?a===u||i+a===u?l:t:n===u||n===i+u?l:t}}else return t}}function a0(t){return t&&t.indexOf(".")!==-1&&(t=t.replace(/0+$/,""),t==="."?t="0":t[0]==="."?t="0"+t:t[t.length-1]==="."&&(t=t.substr(0,t.length-1))),t}var c0=o0;function l0(t){return typeof t=="function"?t:Array.isArray(t)?e=>{for(const n of t)if(typeof n=="string"&&e===n||n instanceof RegExp&&n.test(e))return!0}:()=>!1}var Rf=l0;const Lf=eo,Ir=K_,u0=n0,d0=c0,p0=Rf;let f0=class{constructor(e){this.options=e,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:"&"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"¢"},pound:{regex:/&(pound|#163);/g,val:"£"},yen:{regex:/&(yen|#165);/g,val:"¥"},euro:{regex:/&(euro|#8364);/g,val:"€"},copyright:{regex:/&(copy|#169);/g,val:"©"},reg:{regex:/&(reg|#174);/g,val:"®"},inr:{regex:/&(inr|#8377);/g,val:"₹"},num_dec:{regex:/&#([0-9]{1,7});/g,val:(n,r)=>String.fromCharCode(Number.parseInt(r,10))},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(n,r)=>String.fromCharCode(Number.parseInt(r,16))}},this.addExternalEntities=h0,this.parseXml=v0,this.parseTextData=g0,this.resolveNameSpace=m0,this.buildAttributesMap=y0,this.isItStopNode=x0,this.replaceEntitiesValue=b0,this.readStopNodeData=A0,this.saveTextToParentTag=k0,this.addChild=w0,this.ignoreAttributesFn=p0(this.options.ignoreAttributes)}};function h0(t){const e=Object.keys(t);for(let n=0;n<e.length;n++){const r=e[n];this.lastEntities[r]={regex:new RegExp("&"+r+";","g"),val:t[r]}}}function g0(t,e,n,r,i,s,a){if(t!==void 0&&(this.options.trimValues&&!r&&(t=t.trim()),t.length>0)){a||(t=this.replaceEntitiesValue(t));const c=this.options.tagValueProcessor(e,t,n,i,s);return c==null?t:typeof c!=typeof t||c!==t?c:this.options.trimValues?ja(t,this.options.parseTagValue,this.options.numberParseOptions):t.trim()===t?ja(t,this.options.parseTagValue,this.options.numberParseOptions):t}}function m0(t){if(this.options.removeNSPrefix){const e=t.split(":"),n=t.charAt(0)==="/"?"/":"";if(e[0]==="xmlns")return"";e.length===2&&(t=n+e[1])}return t}const _0=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function y0(t,e,n){if(this.options.ignoreAttributes!==!0&&typeof t=="string"){const r=Lf.getAllMatches(t,_0),i=r.length,s={};for(let a=0;a<i;a++){const c=this.resolveNameSpace(r[a][1]);if(this.ignoreAttributesFn(c,e))continue;let l=r[a][4],u=this.options.attributeNamePrefix+c;if(c.length)if(this.options.transformAttributeName&&(u=this.options.transformAttributeName(u)),u==="__proto__"&&(u="#__proto__"),l!==void 0){this.options.trimValues&&(l=l.trim()),l=this.replaceEntitiesValue(l);const p=this.options.attributeValueProcessor(c,l,e);p==null?s[u]=l:typeof p!=typeof l||p!==l?s[u]=p:s[u]=ja(l,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(s[u]=!0)}if(!Object.keys(s).length)return;if(this.options.attributesGroupName){const a={};return a[this.options.attributesGroupName]=s,a}return s}}const v0=function(t){t=t.replace(/\r\n?/g,`
8
+ `);const e=new Ir("!xml");let n=e,r="",i="";for(let s=0;s<t.length;s++)if(t[s]==="<")if(t[s+1]==="/"){const c=_n(t,">",s,"Closing Tag is not closed.");let l=t.substring(s+2,c).trim();if(this.options.removeNSPrefix){const h=l.indexOf(":");h!==-1&&(l=l.substr(h+1))}this.options.transformTagName&&(l=this.options.transformTagName(l)),n&&(r=this.saveTextToParentTag(r,n,i));const u=i.substring(i.lastIndexOf(".")+1);if(l&&this.options.unpairedTags.indexOf(l)!==-1)throw new Error(`Unpaired tag can not be used as closing tag: </${l}>`);let p=0;u&&this.options.unpairedTags.indexOf(u)!==-1?(p=i.lastIndexOf(".",i.lastIndexOf(".")-1),this.tagsNodeStack.pop()):p=i.lastIndexOf("."),i=i.substring(0,p),n=this.tagsNodeStack.pop(),r="",s=c}else if(t[s+1]==="?"){let c=Ca(t,s,!1,"?>");if(!c)throw new Error("Pi Tag is not closed.");if(r=this.saveTextToParentTag(r,n,i),!(this.options.ignoreDeclaration&&c.tagName==="?xml"||this.options.ignorePiTags)){const l=new Ir(c.tagName);l.add(this.options.textNodeName,""),c.tagName!==c.tagExp&&c.attrExpPresent&&(l[":@"]=this.buildAttributesMap(c.tagExp,i,c.tagName)),this.addChild(n,l,i)}s=c.closeIndex+1}else if(t.substr(s+1,3)==="!--"){const c=_n(t,"-->",s+4,"Comment is not closed.");if(this.options.commentPropName){const l=t.substring(s+4,c-2);r=this.saveTextToParentTag(r,n,i),n.add(this.options.commentPropName,[{[this.options.textNodeName]:l}])}s=c}else if(t.substr(s+1,2)==="!D"){const c=u0(t,s);this.docTypeEntities=c.entities,s=c.i}else if(t.substr(s+1,2)==="!["){const c=_n(t,"]]>",s,"CDATA is not closed.")-2,l=t.substring(s+9,c);r=this.saveTextToParentTag(r,n,i);let u=this.parseTextData(l,n.tagname,i,!0,!1,!0,!0);u==null&&(u=""),this.options.cdataPropName?n.add(this.options.cdataPropName,[{[this.options.textNodeName]:l}]):n.add(this.options.textNodeName,u),s=c+2}else{let c=Ca(t,s,this.options.removeNSPrefix),l=c.tagName;const u=c.rawTagName;let p=c.tagExp,h=c.attrExpPresent,m=c.closeIndex;this.options.transformTagName&&(l=this.options.transformTagName(l)),n&&r&&n.tagname!=="!xml"&&(r=this.saveTextToParentTag(r,n,i,!1));const v=n;if(v&&this.options.unpairedTags.indexOf(v.tagname)!==-1&&(n=this.tagsNodeStack.pop(),i=i.substring(0,i.lastIndexOf("."))),l!==e.tagname&&(i+=i?"."+l:l),this.isItStopNode(this.options.stopNodes,i,l)){let f="";if(p.length>0&&p.lastIndexOf("/")===p.length-1)l[l.length-1]==="/"?(l=l.substr(0,l.length-1),i=i.substr(0,i.length-1),p=l):p=p.substr(0,p.length-1),s=c.closeIndex;else if(this.options.unpairedTags.indexOf(l)!==-1)s=c.closeIndex;else{const w=this.readStopNodeData(t,u,m+1);if(!w)throw new Error(`Unexpected end of ${u}`);s=w.i,f=w.tagContent}const _=new Ir(l);l!==p&&h&&(_[":@"]=this.buildAttributesMap(p,i,l)),f&&(f=this.parseTextData(f,l,i,!0,h,!0,!0)),i=i.substr(0,i.lastIndexOf(".")),_.add(this.options.textNodeName,f),this.addChild(n,_,i)}else{if(p.length>0&&p.lastIndexOf("/")===p.length-1){l[l.length-1]==="/"?(l=l.substr(0,l.length-1),i=i.substr(0,i.length-1),p=l):p=p.substr(0,p.length-1),this.options.transformTagName&&(l=this.options.transformTagName(l));const f=new Ir(l);l!==p&&h&&(f[":@"]=this.buildAttributesMap(p,i,l)),this.addChild(n,f,i),i=i.substr(0,i.lastIndexOf("."))}else{const f=new Ir(l);this.tagsNodeStack.push(n),l!==p&&h&&(f[":@"]=this.buildAttributesMap(p,i,l)),this.addChild(n,f,i),n=f}r="",s=m}}else r+=t[s];return e.child};function w0(t,e,n){const r=this.options.updateTag(e.tagname,n,e[":@"]);r===!1||(typeof r=="string"&&(e.tagname=r),t.addChild(e))}const b0=function(t){if(this.options.processEntities){for(let e in this.docTypeEntities){const n=this.docTypeEntities[e];t=t.replace(n.regx,n.val)}for(let e in this.lastEntities){const n=this.lastEntities[e];t=t.replace(n.regex,n.val)}if(this.options.htmlEntities)for(let e in this.htmlEntities){const n=this.htmlEntities[e];t=t.replace(n.regex,n.val)}t=t.replace(this.ampEntity.regex,this.ampEntity.val)}return t};function k0(t,e,n,r){return t&&(r===void 0&&(r=Object.keys(e.child).length===0),t=this.parseTextData(t,e.tagname,n,!1,e[":@"]?Object.keys(e[":@"]).length!==0:!1,r),t!==void 0&&t!==""&&e.add(this.options.textNodeName,t),t=""),t}function x0(t,e,n){const r="*."+n;for(const i in t){const s=t[i];if(r===s||e===s)return!0}return!1}function S0(t,e,n=">"){let r,i="";for(let s=e;s<t.length;s++){let a=t[s];if(r)a===r&&(r="");else if(a==='"'||a==="'")r=a;else if(a===n[0])if(n[1]){if(t[s+1]===n[1])return{data:i,index:s}}else return{data:i,index:s};else a===" "&&(a=" ");i+=a}}function _n(t,e,n,r){const i=t.indexOf(e,n);if(i===-1)throw new Error(r);return i+e.length-1}function Ca(t,e,n,r=">"){const i=S0(t,e+1,r);if(!i)return;let s=i.data;const a=i.index,c=s.search(/\s/);let l=s,u=!0;c!==-1&&(l=s.substring(0,c),s=s.substring(c+1).trimStart());const p=l;if(n){const h=l.indexOf(":");h!==-1&&(l=l.substr(h+1),u=l!==i.data.substr(h+1))}return{tagName:l,tagExp:s,closeIndex:a,attrExpPresent:u,rawTagName:p}}function A0(t,e,n){const r=n;let i=1;for(;n<t.length;n++)if(t[n]==="<")if(t[n+1]==="/"){const s=_n(t,">",n,`${e} is not closed`);if(t.substring(n+2,s).trim()===e&&(i--,i===0))return{tagContent:t.substring(r,n),i:s};n=s}else if(t[n+1]==="?")n=_n(t,"?>",n+1,"StopNode is not closed.");else if(t.substr(n+1,3)==="!--")n=_n(t,"-->",n+3,"StopNode is not closed.");else if(t.substr(n+1,2)==="![")n=_n(t,"]]>",n,"StopNode is not closed.")-2;else{const s=Ca(t,n,">");s&&((s&&s.tagName)===e&&s.tagExp[s.tagExp.length-1]!=="/"&&i++,n=s.closeIndex)}}function ja(t,e,n){if(e&&typeof t=="string"){const r=t.trim();return r==="true"?!0:r==="false"?!1:d0(t,n)}else return Lf.isExist(t)?t:""}var E0=f0,Uf={};function I0(t,e){return Vf(t,e)}function Vf(t,e,n){let r;const i={};for(let s=0;s<t.length;s++){const a=t[s],c=z0(a);let l="";if(n===void 0?l=c:l=n+"."+c,c===e.textNodeName)r===void 0?r=a[c]:r+=""+a[c];else{if(c===void 0)continue;if(a[c]){let u=Vf(a[c],e,l);const p=C0(u,e);a[":@"]?N0(u,a[":@"],l,e):Object.keys(u).length===1&&u[e.textNodeName]!==void 0&&!e.alwaysCreateTextNode?u=u[e.textNodeName]:Object.keys(u).length===0&&(e.alwaysCreateTextNode?u[e.textNodeName]="":u=""),i[c]!==void 0&&i.hasOwnProperty(c)?(Array.isArray(i[c])||(i[c]=[i[c]]),i[c].push(u)):e.isArray(c,l,p)?i[c]=[u]:i[c]=u}}}return typeof r=="string"?r.length>0&&(i[e.textNodeName]=r):r!==void 0&&(i[e.textNodeName]=r),i}function z0(t){const e=Object.keys(t);for(let n=0;n<e.length;n++){const r=e[n];if(r!==":@")return r}}function N0(t,e,n,r){if(e){const i=Object.keys(e),s=i.length;for(let a=0;a<s;a++){const c=i[a];r.isArray(c,n+"."+c,!0,!0)?t[c]=[e[c]]:t[c]=e[c]}}}function C0(t,e){const{textNodeName:n}=e,r=Object.keys(t).length;return!!(r===0||r===1&&(t[n]||typeof t[n]=="boolean"||t[n]===0))}Uf.prettify=I0;const{buildOptions:j0}=ul,$0=E0,{prettify:O0}=Uf,B0=cl;let T0=class{constructor(e){this.externalEntities={},this.options=j0(e)}parse(e,n){if(typeof e!="string")if(e.toString)e=e.toString();else throw new Error("XML data is accepted in String or Bytes[] form.");if(n){n===!0&&(n={});const s=B0.validate(e,n);if(s!==!0)throw Error(`${s.err.msg}:${s.err.line}:${s.err.col}`)}const r=new $0(this.options);r.addExternalEntities(this.externalEntities);const i=r.parseXml(e);return this.options.preserveOrder||i===void 0?i:O0(i,this.options)}addEntity(e,n){if(n.indexOf("&")!==-1)throw new Error("Entity value can't have '&'");if(e.indexOf("&")!==-1||e.indexOf(";")!==-1)throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");if(n==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[e]=n}};var P0=T0;const R0=`
9
+ `;function L0(t,e){let n="";return e.format&&e.indentBy.length>0&&(n=R0),qf(t,e,"",n)}function qf(t,e,n,r){let i="",s=!1;for(let a=0;a<t.length;a++){const c=t[a],l=U0(c);if(l===void 0)continue;let u="";if(n.length===0?u=l:u=`${n}.${l}`,l===e.textNodeName){let f=c[l];V0(u,e)||(f=e.tagValueProcessor(l,f),f=Mf(f,e)),s&&(i+=r),i+=f,s=!1;continue}else if(l===e.cdataPropName){s&&(i+=r),i+=`<![CDATA[${c[l][0][e.textNodeName]}]]>`,s=!1;continue}else if(l===e.commentPropName){i+=r+`<!--${c[l][0][e.textNodeName]}-->`,s=!0;continue}else if(l[0]==="?"){const f=Gu(c[":@"],e),_=l==="?xml"?"":r;let w=c[l][0][e.textNodeName];w=w.length!==0?" "+w:"",i+=_+`<${l}${w}${f}?>`,s=!0;continue}let p=r;p!==""&&(p+=e.indentBy);const h=Gu(c[":@"],e),m=r+`<${l}${h}`,v=qf(c[l],e,u,p);e.unpairedTags.indexOf(l)!==-1?e.suppressUnpairedNode?i+=m+">":i+=m+"/>":(!v||v.length===0)&&e.suppressEmptyNode?i+=m+"/>":v&&v.endsWith(">")?i+=m+`>${v}${r}</${l}>`:(i+=m+">",v&&r!==""&&(v.includes("/>")||v.includes("</"))?i+=r+e.indentBy+v+r:i+=v,i+=`</${l}>`),s=!0}return i}function U0(t){const e=Object.keys(t);for(let n=0;n<e.length;n++){const r=e[n];if(t.hasOwnProperty(r)&&r!==":@")return r}}function Gu(t,e){let n="";if(t&&!e.ignoreAttributes)for(let r in t){if(!t.hasOwnProperty(r))continue;let i=e.attributeValueProcessor(r,t[r]);i=Mf(i,e),i===!0&&e.suppressBooleanAttributes?n+=` ${r.substr(e.attributeNamePrefix.length)}`:n+=` ${r.substr(e.attributeNamePrefix.length)}="${i}"`}return n}function V0(t,e){t=t.substr(0,t.length-e.textNodeName.length-1);let n=t.substr(t.lastIndexOf(".")+1);for(let r in e.stopNodes)if(e.stopNodes[r]===t||e.stopNodes[r]==="*."+n)return!0;return!1}function Mf(t,e){if(t&&t.length>0&&e.processEntities)for(let n=0;n<e.entities.length;n++){const r=e.entities[n];t=t.replace(r.regex,r.val)}return t}var q0=L0;const M0=q0,D0=Rf,H0={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp("&","g"),val:"&amp;"},{regex:new RegExp(">","g"),val:"&gt;"},{regex:new RegExp("<","g"),val:"&lt;"},{regex:new RegExp("'","g"),val:"&apos;"},{regex:new RegExp('"',"g"),val:"&quot;"}],processEntities:!0,stopNodes:[],oneListGroup:!1};function sn(t){this.options=Object.assign({},H0,t),this.options.ignoreAttributes===!0||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn=D0(this.options.ignoreAttributes),this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=W0),this.processTextOrObjNode=F0,this.options.format?(this.indentate=K0,this.tagEndChar=`>
10
10
  `,this.newLine=`
11
- `):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}rn.prototype.build=function(t){return this.options.preserveOrder?V0(t,this.options):(Array.isArray(t)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(t={[this.options.arrayNodeName]:t}),this.j2x(t,0,[]).val)};rn.prototype.j2x=function(t,e,n){let r="",i="";const s=n.join(".");for(let a in t)if(Object.prototype.hasOwnProperty.call(t,a))if(typeof t[a]>"u")this.isAttribute(a)&&(i+="");else if(t[a]===null)this.isAttribute(a)?i+="":a[0]==="?"?i+=this.indentate(e)+"<"+a+"?"+this.tagEndChar:i+=this.indentate(e)+"<"+a+"/"+this.tagEndChar;else if(t[a]instanceof Date)i+=this.buildTextValNode(t[a],a,"",e);else if(typeof t[a]!="object"){const c=this.isAttribute(a);if(c&&!this.ignoreAttributesFn(c,s))r+=this.buildAttrPairStr(c,""+t[a]);else if(!c)if(a===this.options.textNodeName){let l=this.options.tagValueProcessor(a,""+t[a]);i+=this.replaceEntitiesValue(l)}else i+=this.buildTextValNode(t[a],a,"",e)}else if(Array.isArray(t[a])){const c=t[a].length;let l="",u="";for(let p=0;p<c;p++){const h=t[a][p];if(!(typeof h>"u"))if(h===null)a[0]==="?"?i+=this.indentate(e)+"<"+a+"?"+this.tagEndChar:i+=this.indentate(e)+"<"+a+"/"+this.tagEndChar;else if(typeof h=="object")if(this.options.oneListGroup){const m=this.j2x(h,e+1,n.concat(a));l+=m.val,this.options.attributesGroupName&&h.hasOwnProperty(this.options.attributesGroupName)&&(u+=m.attrStr)}else l+=this.processTextOrObjNode(h,a,e,n);else if(this.options.oneListGroup){let m=this.options.tagValueProcessor(a,h);m=this.replaceEntitiesValue(m),l+=m}else l+=this.buildTextValNode(h,a,"",e)}this.options.oneListGroup&&(l=this.buildObjectNode(l,a,u,e)),i+=l}else if(this.options.attributesGroupName&&a===this.options.attributesGroupName){const c=Object.keys(t[a]),l=c.length;for(let u=0;u<l;u++)r+=this.buildAttrPairStr(c[u],""+t[a][c[u]])}else i+=this.processTextOrObjNode(t[a],a,e,n);return{attrStr:r,val:i}};rn.prototype.buildAttrPairStr=function(t,e){return e=this.options.attributeValueProcessor(t,""+e),e=this.replaceEntitiesValue(e),this.options.suppressBooleanAttributes&&e==="true"?" "+t:" "+t+'="'+e+'"'};function D0(t,e,n,r){const i=this.j2x(t,n+1,r.concat(e));return t[this.options.textNodeName]!==void 0&&Object.keys(t).length===1?this.buildTextValNode(t[this.options.textNodeName],e,i.attrStr,n):this.buildObjectNode(i.val,e,i.attrStr,n)}rn.prototype.buildObjectNode=function(t,e,n,r){if(t==="")return e[0]==="?"?this.indentate(r)+"<"+e+n+"?"+this.tagEndChar:this.indentate(r)+"<"+e+n+this.closeTag(e)+this.tagEndChar;{let i="</"+e+this.tagEndChar,s="";return e[0]==="?"&&(s="?",i=""),(n||n==="")&&t.indexOf("<")===-1?this.indentate(r)+"<"+e+n+s+">"+t+i:this.options.commentPropName!==!1&&e===this.options.commentPropName&&s.length===0?this.indentate(r)+`<!--${t}-->`+this.newLine:this.indentate(r)+"<"+e+n+s+this.tagEndChar+t+this.indentate(r)+i}};rn.prototype.closeTag=function(t){let e="";return this.options.unpairedTags.indexOf(t)!==-1?this.options.suppressUnpairedNode||(e="/"):this.options.suppressEmptyNode?e="/":e=`></${t}`,e};rn.prototype.buildTextValNode=function(t,e,n,r){if(this.options.cdataPropName!==!1&&e===this.options.cdataPropName)return this.indentate(r)+`<![CDATA[${t}]]>`+this.newLine;if(this.options.commentPropName!==!1&&e===this.options.commentPropName)return this.indentate(r)+`<!--${t}-->`+this.newLine;if(e[0]==="?")return this.indentate(r)+"<"+e+n+"?"+this.tagEndChar;{let i=this.options.tagValueProcessor(e,t);return i=this.replaceEntitiesValue(i),i===""?this.indentate(r)+"<"+e+n+this.closeTag(e)+this.tagEndChar:this.indentate(r)+"<"+e+n+">"+i+"</"+e+this.tagEndChar}};rn.prototype.replaceEntitiesValue=function(t){if(t&&t.length>0&&this.options.processEntities)for(let e=0;e<this.options.entities.length;e++){const n=this.options.entities[e];t=t.replace(n.regex,n.val)}return t};function H0(t){return this.options.indentBy.repeat(t)}function F0(t){return t.startsWith(this.options.attributeNamePrefix)&&t!==this.options.textNodeName?t.substr(this.attrPrefixLen):!1}var K0=rn;const W0=cl,G0=B0,J0=K0;var Z0={XMLParser:G0,XMLValidator:W0,XMLBuilder:J0};function Y0(t,e,n){const r=n?`<input type="hidden" name="RelayState" value="${n}" />`:"",i=`
11
+ `):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}sn.prototype.build=function(t){return this.options.preserveOrder?M0(t,this.options):(Array.isArray(t)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(t={[this.options.arrayNodeName]:t}),this.j2x(t,0,[]).val)};sn.prototype.j2x=function(t,e,n){let r="",i="";const s=n.join(".");for(let a in t)if(Object.prototype.hasOwnProperty.call(t,a))if(typeof t[a]>"u")this.isAttribute(a)&&(i+="");else if(t[a]===null)this.isAttribute(a)?i+="":a[0]==="?"?i+=this.indentate(e)+"<"+a+"?"+this.tagEndChar:i+=this.indentate(e)+"<"+a+"/"+this.tagEndChar;else if(t[a]instanceof Date)i+=this.buildTextValNode(t[a],a,"",e);else if(typeof t[a]!="object"){const c=this.isAttribute(a);if(c&&!this.ignoreAttributesFn(c,s))r+=this.buildAttrPairStr(c,""+t[a]);else if(!c)if(a===this.options.textNodeName){let l=this.options.tagValueProcessor(a,""+t[a]);i+=this.replaceEntitiesValue(l)}else i+=this.buildTextValNode(t[a],a,"",e)}else if(Array.isArray(t[a])){const c=t[a].length;let l="",u="";for(let p=0;p<c;p++){const h=t[a][p];if(!(typeof h>"u"))if(h===null)a[0]==="?"?i+=this.indentate(e)+"<"+a+"?"+this.tagEndChar:i+=this.indentate(e)+"<"+a+"/"+this.tagEndChar;else if(typeof h=="object")if(this.options.oneListGroup){const m=this.j2x(h,e+1,n.concat(a));l+=m.val,this.options.attributesGroupName&&h.hasOwnProperty(this.options.attributesGroupName)&&(u+=m.attrStr)}else l+=this.processTextOrObjNode(h,a,e,n);else if(this.options.oneListGroup){let m=this.options.tagValueProcessor(a,h);m=this.replaceEntitiesValue(m),l+=m}else l+=this.buildTextValNode(h,a,"",e)}this.options.oneListGroup&&(l=this.buildObjectNode(l,a,u,e)),i+=l}else if(this.options.attributesGroupName&&a===this.options.attributesGroupName){const c=Object.keys(t[a]),l=c.length;for(let u=0;u<l;u++)r+=this.buildAttrPairStr(c[u],""+t[a][c[u]])}else i+=this.processTextOrObjNode(t[a],a,e,n);return{attrStr:r,val:i}};sn.prototype.buildAttrPairStr=function(t,e){return e=this.options.attributeValueProcessor(t,""+e),e=this.replaceEntitiesValue(e),this.options.suppressBooleanAttributes&&e==="true"?" "+t:" "+t+'="'+e+'"'};function F0(t,e,n,r){const i=this.j2x(t,n+1,r.concat(e));return t[this.options.textNodeName]!==void 0&&Object.keys(t).length===1?this.buildTextValNode(t[this.options.textNodeName],e,i.attrStr,n):this.buildObjectNode(i.val,e,i.attrStr,n)}sn.prototype.buildObjectNode=function(t,e,n,r){if(t==="")return e[0]==="?"?this.indentate(r)+"<"+e+n+"?"+this.tagEndChar:this.indentate(r)+"<"+e+n+this.closeTag(e)+this.tagEndChar;{let i="</"+e+this.tagEndChar,s="";return e[0]==="?"&&(s="?",i=""),(n||n==="")&&t.indexOf("<")===-1?this.indentate(r)+"<"+e+n+s+">"+t+i:this.options.commentPropName!==!1&&e===this.options.commentPropName&&s.length===0?this.indentate(r)+`<!--${t}-->`+this.newLine:this.indentate(r)+"<"+e+n+s+this.tagEndChar+t+this.indentate(r)+i}};sn.prototype.closeTag=function(t){let e="";return this.options.unpairedTags.indexOf(t)!==-1?this.options.suppressUnpairedNode||(e="/"):this.options.suppressEmptyNode?e="/":e=`></${t}`,e};sn.prototype.buildTextValNode=function(t,e,n,r){if(this.options.cdataPropName!==!1&&e===this.options.cdataPropName)return this.indentate(r)+`<![CDATA[${t}]]>`+this.newLine;if(this.options.commentPropName!==!1&&e===this.options.commentPropName)return this.indentate(r)+`<!--${t}-->`+this.newLine;if(e[0]==="?")return this.indentate(r)+"<"+e+n+"?"+this.tagEndChar;{let i=this.options.tagValueProcessor(e,t);return i=this.replaceEntitiesValue(i),i===""?this.indentate(r)+"<"+e+n+this.closeTag(e)+this.tagEndChar:this.indentate(r)+"<"+e+n+">"+i+"</"+e+this.tagEndChar}};sn.prototype.replaceEntitiesValue=function(t){if(t&&t.length>0&&this.options.processEntities)for(let e=0;e<this.options.entities.length;e++){const n=this.options.entities[e];t=t.replace(n.regex,n.val)}return t};function K0(t){return this.options.indentBy.repeat(t)}function W0(t){return t.startsWith(this.options.attributeNamePrefix)&&t!==this.options.textNodeName?t.substr(this.attrPrefixLen):!1}var G0=sn;const J0=cl,Z0=P0,Y0=G0;var X0={XMLParser:Z0,XMLValidator:J0,XMLBuilder:Y0};function Q0(t,e,n){const r=n?`<input type="hidden" name="RelayState" value="${n}" />`:"",i=`
12
12
  <!DOCTYPE html>
13
13
  <html>
14
14
  <body onload="document.forms[0].submit()">
@@ -26,7 +26,7 @@
26
26
  }};
27
27
  <\/script>
28
28
  </body>
29
- </html>`;return new Response(i,{headers:{"Content-Type":"text/html"}})}async function X0(t,e,n,r,i){var m,v,f;if(!n.redirect_uri)throw new z(400,{message:"Missing redirect_uri in authParams"});const[s]=await t.env.data.keys.list();if(!s)throw new z(500,{message:"No signing key found"});if(!((m=e.addons)!=null&&m.samlp))throw new z(400,{message:`SAML Addon is not enabled for client ${e.id}`});const{recipient:a,audience:c}=e.addons.samlp,l=n.state||"";if(!a||!l||!r||!n.state)throw new z(400,{message:"Missing recipient or inResponseTo"});const u=JSON.parse(n.state),p=new URL(n.redirect_uri),h=await Q0(t,{issuer:t.env.ISSUER,audience:c||n.client_id,destination:p.toString(),inResponseTo:u.requestId,userId:((f=(v=r.app_metadata)==null?void 0:v.vimeo)==null?void 0:f.user_id)||r.user_id,email:r.email,sessionIndex:i,signature:{privateKeyPem:s.pkcs7,cert:s.cert,kid:s.kid}});return Y0(p.toString(),h,u.relayState)}async function Q0(t,e){const n=e.notBefore||new Date().toISOString(),r=e.notAfter||new Date(new Date(n).getTime()+10*60*1e3).toISOString(),i=e.issueInstant||n,s=e.sessionNotOnOrAfter||r,a=e.responseId||`_${xe()}`,c=e.assertionId||`_${xe()}`,l=[{"samlp:Response":[{"saml:Issuer":[{"#text":e.issuer}]},{"samlp:Status":[{"samlp:StatusCode":[],":@":{"@_Value":"urn:oasis:names:tc:SAML:2.0:status:Success"}}]},{"saml:Assertion":[{"saml:Issuer":[{"#text":e.issuer}]},{"saml:Subject":[{"saml:NameID":[{"#text":e.email}],":@":{"@_Format":"urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"}},{"saml:SubjectConfirmation":[{"saml:SubjectConfirmationData":[],":@":{"@_InResponseTo":e.inResponseTo,"@_NotOnOrAfter":r,"@_Recipient":e.destination}}],":@":{"@_Method":"urn:oasis:names:tc:SAML:2.0:cm:bearer"}}]},{"saml:Conditions":[{"saml:AudienceRestriction":[{"saml:Audience":[{"#text":e.audience}]}]}],":@":{"@_NotBefore":n,"@_NotOnOrAfter":r}},{"saml:AuthnStatement":[{"saml:AuthnContext":[{"saml:AuthnContextClassRef":[{"#text":"urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified"}]}]}],":@":{"@_AuthnInstant":i,"@_SessionIndex":e.sessionIndex,"@_SessionNotOnOrAfter":s}},{"saml:AttributeStatement":[{"saml:Attribute":[{"saml:AttributeValue":[{"#text":e.userId}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_FriendlyName":"persistent","@_Name":"id","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":e.email}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"email","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":"manage-account"}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":"default-roles-master"}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":"offline_access"}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":"view-profile"}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":"uma_authorization"}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":"manage-account-links"}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}}]}],":@":{"@_xmlns":"urn:oasis:names:tc:SAML:2.0:assertion","@_ID":c,"@_IssueInstant":i,"@_Version":"2.0"}}],":@":{"@_xmlns:samlp":"urn:oasis:names:tc:SAML:2.0:protocol","@_xmlns:saml":"urn:oasis:names:tc:SAML:2.0:assertion","@_Destination":e.destination,"@_ID":a,"@_InResponseTo":e.inResponseTo,"@_IssueInstant":i,"@_Version":"2.0"}}];let p=new Z0.XMLBuilder({ignoreAttributes:!1,suppressEmptyNode:!0,preserveOrder:!0}).build(l);if(e.signature){const m=await fetch(t.env.SAML_SIGN_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({xmlContent:p,privateKey:e.signature.privateKeyPem,publicCert:e.signature.cert})});if(!m.ok)throw new Error(`Failed to sign SAML response: ${m.status}`);p=await m.text()}return e.encode===!1?p:btoa(p)}var ey={deno:"Deno",bun:"Bun",workerd:"Cloudflare-Workers",node:"Node.js"},ty=()=>{var n,r;const t=globalThis;if(typeof navigator<"u"&&typeof navigator.userAgent=="string"){for(const[i,s]of Object.entries(ey))if(ny(s))return i}return typeof(t==null?void 0:t.EdgeRuntime)=="string"?"edge-light":(t==null?void 0:t.fastly)!==void 0?"fastly":((r=(n=t==null?void 0:t.process)==null?void 0:n.release)==null?void 0:r.name)==="node"?"node":"other"},ny=t=>navigator.userAgent.startsWith(t);function nt(t,e){ty()==="workerd"&&t.executionCtx.waitUntil(e)}function sn(t){var e,n,r;return{auth0Client:(e=t.query("auth0Client"))==null?void 0:e.slice(0,255),ip:(n=t.header("x-real-ip"))==null?void 0:n.slice(0,45),useragent:(r=t.header("user-agent"))==null?void 0:r.slice(0,512)}}const Gu=["sub","iss","aud","exp","nbf","iat","jti"];async function to(t,e){var _,w;const{authParams:n,user:r,client:i,session_id:s}=e,c=(await t.env.data.keys.list()).filter(S=>!S.revoked_at||new Date(S.revoked_at)>new Date),l=c[c.length-1];if(!(l!=null&&l.pkcs7))throw new z(500,{message:"No signing key available"});const u=k_(l.pkcs7),p={aud:n.audience||"default",scope:n.scope||"",sub:(r==null?void 0:r.user_id)||n.client_id,iss:t.env.ISSUER,tenant_id:t.var.tenant_id,sid:s},h=r&&((_=n.scope)!=null&&_.split(" ").includes("openid"))?{aud:n.client_id,sub:r.user_id,iss:t.env.ISSUER,sid:s,nonce:n.nonce,given_name:r.given_name,family_name:r.family_name,nickname:r.nickname,picture:r.picture,locale:r.locale,name:r.name,email:r.email,email_verified:r.email_verified}:void 0;(w=t.env.hooks)!=null&&w.onExecuteCredentialsExchange&&await t.env.hooks.onExecuteCredentialsExchange({client:i,user:r,request:{ip:t.req.header("x-real-ip")||"",user_agent:t.req.header("user-agent")||"",method:t.req.method,url:t.req.url},scope:n.scope||"",grant_type:""},{accessToken:{setCustomClaim:(S,C)=>{if(Gu.includes(S))throw new Error(`Cannot overwrite reserved claim '${S}'`);p[S]=C}},idToken:{setCustomClaim:(S,C)=>{if(Gu.includes(S))throw new Error(`Cannot overwrite reserved claim '${S}'`);h&&(h[S]=C)}},access:{deny:S=>{throw new z(400,{message:`Access denied: ${S}`})}}});const m={includeIssuedTimestamp:!0,expiresIn:new sl(1,"d"),headers:{kid:l.kid}},v=await Mu("RS256",u,p,m),f=h?await Mu("RS256",u,h,m):void 0;return{access_token:v,refresh_token:e.refresh_token,id_token:f,token_type:"Bearer",expires_in:86400}}async function Mf(t,e){return e.loginSession||(e.loginSession=await t.env.data.loginSessions.create(e.client.tenant.id,{expires_at:new Date(Date.now()+Jn*1e3).toISOString(),authParams:e.authParams,authorization_url:t.req.url,csrf_token:xe(),...sn(t.req)})),{code:(await t.env.data.codes.create(e.client.tenant.id,{code_id:xe(),user_id:e.user.user_id,code_type:"authorization_code",login_id:e.loginSession.id,expires_at:new Date(Date.now()+E_*1e3).toISOString()})).code_id,state:e.authParams.state}}async function ry(t,e){const{client:n,scope:r,audience:i=n.tenant.audience,session_id:s}=e;return await t.env.data.refreshTokens.create(n.tenant.id,{id:xe(),session_id:s,client_id:n.id,expires_at:new Date(Date.now()+Qs*1e3).toISOString(),user_id:e.user.user_id,device:{last_ip:t.req.header("x-real-ip")||"",initial_ip:t.req.header("x-real-ip")||"",last_user_agent:t.req.header("user-agent")||"",initial_user_agent:t.req.header("user-agent")||"",initial_asn:"",last_asn:""},resource_servers:[{audience:i,scopes:r}],rotating:!1})}async function Df(t,{user:e,client:n,loginSession:r}){const i=await t.env.data.sessions.create(n.tenant.id,{id:xe(),user_id:e.user_id,idle_expires_at:new Date(Date.now()+Qs*1e3).toISOString(),device:{last_ip:t.req.header("x-real-ip")||"",initial_ip:t.req.header("x-real-ip")||"",last_user_agent:t.req.header("user-agent")||"",initial_user_agent:t.req.header("user-agent")||"",initial_asn:"",last_asn:""},clients:[n.id]});await t.env.data.loginSessions.update(n.tenant.id,r.id,{session_id:i.id});const{scope:s,audience:a}=r.authParams,c=s!=null&&s.split(" ").includes("offline_access")?await ry(t,{session_id:i.id,user:e,client:n,scope:s,audience:a}):void 0;return{...i,refresh_token:c}}async function on(t,e){var v;const{authParams:n,user:r,client:i,ticketAuth:s}=e,a=ve(t,{type:he.SUCCESS_LOGIN,description:`Successful login for ${r.user_id}`,userId:r.user_id});if(nt(t,t.env.data.logs.create(i.tenant.id,a)),nt(t,t.env.data.users.update(i.tenant.id,r.user_id,{last_login:new Date().toISOString(),last_ip:t.req.header("x-real-ip")||"",login_count:r.login_count+1})),s){if(!e.loginSession)throw new z(500,{message:"Login session not found"});const f=b_(),_=xe(12),w=await t.env.data.codes.create(i.tenant.id,{code_id:xe(),code_type:"ticket",login_id:e.loginSession.id,expires_at:new Date(Date.now()+z_).toISOString(),code_verifier:[_,f].join("|")});return t.json({login_ticket:w.code_id,co_verifier:f,co_id:_})}let c=e.refreshToken,l=e.sessionId,u=r;if(!l){if(!e.loginSession)throw new z(500,{message:"Login session not found"});u=await ay(t,t.env.data)(i.tenant.id,r);const f=await Df(t,{user:r,client:i,loginSession:e.loginSession});l=f.id,c=(v=f.refresh_token)==null?void 0:v.id}if(e.authParams.response_mode===Yt.SAML_POST)return X0(t,e.client,e.authParams,u,l);const p=await to(t,{authParams:n,user:u,client:i,session_id:l,refresh_token:c}),h=new Headers({"set-cookie":Bf(i.tenant.id,l,t.req.header("host"))});if(n.response_mode===Yt.WEB_MESSAGE)return t.json(p,{headers:h});if((n.response_type||Pt.CODE)===Pt.CODE){const f=await Mf(t,e);if(!n.redirect_uri)throw new z(400,{message:"Redirect uri not found"});const _=new URL(n.redirect_uri);_.searchParams.set("code",f.code),f.state&&_.searchParams.set("state",f.state),h.set("location",_.toString())}return new Response("Redirecting",{status:302,headers:h})}async function iy(t,e,n){const r=await t.env.data.tenants.get(e);if(!r)throw new Error(`Tenant not found: ${e}`);return to(t,{client:{id:t.env.ISSUER,tenant:r,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),name:t.env.ISSUER,disable_sign_ups:!1,connections:[]},authParams:{client_id:t.env.ISSUER,response_type:Pt.TOKEN,scope:n}})}async function dl(t,e,n){const r=await iy(t,n.tenant_id,"webhook");for await(const i of e)if(!(await fetch(i.url,{method:"POST",headers:{Authorization:`Bearer ${r.access_token}`,"Content-Type":"application/json"},body:JSON.stringify(n)})).ok){const a=ve(t,{type:he.FAILED_HOOK,description:`Failed to invoke hook ${i.hook_id}`});await t.env.data.logs.create(n.tenant_id,a)}}function sy(t){return async(e,n)=>{const{hooks:r}=await t.env.data.hooks.list(e);return await dl(t,r,{tenant_id:e,user:n,trigger_id:"post-user-registration"}),n}}function oy(t){return async(e,n)=>{const{hooks:r}=await t.env.data.hooks.list(e,{q:"trigger_id:pre-user-signup",page:0,per_page:100,include_totals:!1});await dl(t,r,{tenant_id:e,email:n,trigger_id:"pre-user-signup"})}}function ay(t,e){return async(n,r)=>{const{hooks:i}=await e.hooks.list(n,{q:"trigger_id:post-user-login",page:0,per_page:100,include_totals:!1});return await dl(t,i,{tenant_id:n,user:r,trigger_id:"post-user-login"}),r}}function cy(t,e){return async(n,r)=>{var a,c,l;const i={method:t.req.method,ip:t.req.query("x-real-ip")||"",user_agent:t.req.query("user-agent"),url:((a=t.var.loginSession)==null?void 0:a.authorization_url)||t.req.url};if((c=t.env.hooks)!=null&&c.onExecutePreUserRegistration)try{await t.env.hooks.onExecutePreUserRegistration({user:r,request:i},{user:{setUserMetadata:async(u,p)=>{r[u]=p}}})}catch{const p=ve(t,{type:he.FAILED_SIGNUP,description:"Pre user registration hook failed"});await e.logs.create(n,p)}let s=await h_(e)(n,r);if((l=t.env.hooks)!=null&&l.onExecutePostUserRegistration)try{await t.env.hooks.onExecutePostUserRegistration({user:r,request:i},{user:{}})}catch{const p=ve(t,{type:he.FAILED_SIGNUP,description:"Post user registration hook failed"});await t.env.data.logs.create(n,p)}return await sy(t)(n,s),s}}async function ly(t,e,n,r){if(e.disable_sign_ups&&!await ro({userAdapter:n.users,tenant_id:e.tenant.id,email:r})){const s=ve(t,{type:he.FAILED_SIGNUP,description:"Public signup is disabled"});throw await n.logs.create(e.tenant.id,s),new z(400,{message:"Signups are disabled for this client"})}await oy(t)(t.var.tenant_id||"",r)}function no(t,e){return{...e,users:{...e.users,create:cy(t,e)}}}function Hf(t){return no(t,t.env.data)}async function pl(t,e,n){return(await t.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${n}`})).users}async function ur({userAdapter:t,tenant_id:e,email:n,provider:r}){const{users:i}=await t.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${n} provider:${r}`});return i.length>1&&console.error("More than one user found for same email and provider"),i[0]||null}async function ro({userAdapter:t,tenant_id:e,email:n}){var c;const{users:r}=await t.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${n}`}),i=r.filter(l=>!(l.provider==="auth2"&&!l.email_verified));if(i.length===0)return;const s=i.filter(l=>!l.linked_to);if(s.length>0)return s.length>1&&console.error("More than one primary user found for same email"),s[0];const a=await t.get(e,(c=i[0])==null?void 0:c.linked_to);if(!a)throw new Error("Primary account not found");return a}async function ls({userAdapter:t,tenant_id:e,email:n,provider:r}){const i=await ur({userAdapter:t,tenant_id:e,email:n,provider:r});return i?i.linked_to?t.get(e,i.linked_to):i:null}async function io(t,e){const{email:n,provider:r,connection:i,client:s,userId:a,isSocial:c,profileData:l={},ip:u=""}=e;let p=await ls({userAdapter:t.env.data.users,tenant_id:e.client.tenant.id,email:n,provider:r});if(!p){const h={user_id:`${r}|${a||Xs()}`,email:n,name:n,provider:r,connection:i,email_verified:!0,last_ip:u,is_social:c,last_login:new Date().toISOString(),profileData:JSON.stringify(l)};p=await Hf(t).users.create(s.tenant.id,h),t.set("user_id",p.user_id)}return p}const Xt=o.z.object({page:o.z.string().min(0).optional().default("0").transform(t=>parseInt(t,10)).openapi({description:"The page number where 0 is the first page"}),per_page:o.z.string().min(1).optional().default("10").transform(t=>parseInt(t,10)).openapi({description:"The number of items per page"}),include_totals:o.z.string().optional().default("false").transform(t=>t==="true").openapi({description:"If the total number of items should be included in the response"}),sort:o.z.string().regex(/^.+:(-1|1)$/).optional().openapi({description:"A property that should have the format 'string:-1' or 'string:1'"}),q:o.z.string().optional().openapi({description:"A lucene query string used to filter the results"})});function dr(t){if(!t)return;const[e,n]=t.split(":"),r=n==="1"?"asc":"desc";if(!(!e||!r))return{sort_by:e,sort_order:r}}const Ju=nn.extend({users:o.z.array(xt)}),uy=nn.extend({sessions:o.z.array(Ys)}),dy=new o.OpenAPIHono().openapi(o.createRoute({tags:["users"],method:"get",path:"/",request:{query:Xt,headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:o.z.union([o.z.array(xt),Ju])}},description:"List of users"}}}),async t=>{const{page:e,per_page:n,include_totals:r,sort:i,q:s}=t.req.valid("query"),{"tenant-id":a}=t.req.valid("header");if(s!=null&&s.includes("identities.profileData.email")){const p=s.split("=")[1],m=(await t.env.data.users.list(a,{page:e,per_page:n,include_totals:r,q:`email:${p}`})).users.filter(_=>_.linked_to),[v]=m;if(!v)return t.json([]);const f=await t.env.data.users.get(a,v.linked_to);if(!f)throw new z(500,{message:"Primary account not found"});return t.json([xt.parse(f)])}const c=["-_exists_:linked_to"];s&&c.push(s);const l=await t.env.data.users.list(a,{page:e,per_page:n,include_totals:r,sort:dr(i),q:c.join(" ")}),u=l.users.filter(p=>!p.linked_to);return r?t.json(Ju.parse({users:u,length:l.length,start:l.start,limit:l.limit})):t.json(o.z.array(xt).parse(u))}).openapi(o.createRoute({tags:["users"],method:"get",path:"/{user_id}",request:{headers:o.z.object({"tenant-id":o.z.string()}),params:o.z.object({user_id:o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:xt}},description:"List of users"}}}),async t=>{const{user_id:e}=t.req.valid("param"),{"tenant-id":n}=t.req.valid("header"),r=await t.env.data.users.get(n,e);if(!r)throw new z(404);if(r.linked_to)throw new z(404,{message:"User is linked to another user"});return t.json(r)}).openapi(o.createRoute({tags:["users"],method:"delete",path:"/{user_id}",request:{headers:o.z.object({"tenant-id":o.z.string()}),params:o.z.object({user_id:o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{const{user_id:e}=t.req.valid("param"),{"tenant-id":n}=t.req.valid("header");if(!await t.env.data.users.remove(n,e))throw new z(404);return t.text("OK")}).openapi(o.createRoute({tags:["users"],method:"post",path:"/",request:{headers:o.z.object({"tenant-id":o.z.string()}),body:{content:{"application/json":{schema:o.z.object({...ts.shape})}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:xt}},description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json");t.set("body",n);const{email:r}=n;if(!r)throw new z(400,{message:"Email is required"});const i=r.toLowerCase(),s=`${n.provider}|${n.user_id||Xs()}`;try{const a=await t.env.data.users.create(e,{email:i,user_id:s,name:n.name||i,provider:n.provider,connection:n.connection,email_verified:n.email_verified||!1,last_ip:"",is_social:!1,last_login:new Date().toISOString()});t.set("user_id",a.user_id);const c=ve(t,{type:he.SUCCESS_API_OPERATION,description:"User created"});nt(t,t.env.data.logs.create(e,c));const l={...a,identities:[{connection:a.connection,provider:a.provider,user_id:Vu(a.user_id),isSocial:a.is_social}]};return t.json(xt.parse(l),{status:201})}catch(a){throw a.message==="User already exists"?new z(409,{message:"User already exists"}):a}}).openapi(o.createRoute({tags:["users"],method:"patch",path:"/{user_id}",request:{headers:o.z.object({"tenant-id":o.z.string()}),body:{content:{"application/json":{schema:o.z.object({...ts.shape,verify_email:o.z.boolean(),password:o.z.string()}).partial()}}},params:o.z.object({user_id:o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{var p;const{data:e}=t.env,{"tenant-id":n}=t.req.valid("header"),r=t.req.valid("json"),{user_id:i}=t.req.valid("param"),{verify_email:s,password:a,...c}=r,l=await e.users.get(n,i);if(!l)throw new z(404);if(c.email&&c.email!==l.email){const h=await pl(t.env.data.users,n,c.email);if(h.length&&h.some(m=>m.user_id!==i))throw new z(409,{message:"Another user with the same email address already exists."})}if(l.linked_to)throw new z(404,{message:"User is linked to another user"});if(await t.env.data.users.update(n,i,c),a){const h=(p=l.identities)==null?void 0:p.find(f=>f.connection==="Username-Password-Authentication");if(!h)throw new z(400,{message:"User does not have a password identity"});const m={user_id:h.user_id,password:await si.hash(a,10),algorithm:"bcrypt"};await e.passwords.get(n,h.user_id)?await e.passwords.update(n,m):await e.passwords.create(n,m)}const u=await t.env.data.users.get(n,i);if(!u)throw new z(500);return t.json(u)}).openapi(o.createRoute({tags:["users"],method:"post",path:"/{user_id}/identities",request:{headers:o.z.object({"tenant-id":o.z.string()}),body:{content:{"application/json":{schema:o.z.union([o.z.object({link_with:o.z.string()}),o.z.object({user_id:o.z.string(),provider:o.z.string(),connection:o.z.string().optional()})])}}},params:o.z.object({user_id:o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:o.z.array(o.z.object({connection:o.z.string(),provider:o.z.string(),user_id:o.z.string(),isSocial:o.z.boolean()}))}},description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),{user_id:r}=t.req.valid("param"),i="link_with"in n?n.link_with:n.user_id,s=await t.env.data.users.get(e,r);if(!s)throw new z(400,{message:"Linking an inexistent identity is not allowed."});await t.env.data.users.update(e,i,{linked_to:r});const a=await t.env.data.users.list(e,{page:0,per_page:10,include_totals:!1,q:`linked_to:${r}`}),c=[s,...a.users].map(l=>({connection:l.connection,provider:l.provider,user_id:Vu(l.user_id),isSocial:l.is_social}));return t.json(c,{status:201})}).openapi(o.createRoute({tags:["users"],method:"delete",path:"/{user_id}/identities/{provider}/{linked_user_id}",request:{headers:o.z.object({"tenant-id":o.z.string()}),params:o.z.object({user_id:o.z.string(),provider:o.z.string(),linked_user_id:o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:o.z.array(xt)}},description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{user_id:n,provider:r,linked_user_id:i}=t.req.valid("param");await t.env.data.users.unlink(e,n,r,i);const s=await t.env.data.users.get(e,n);if(!s)throw new z(404);return t.json([xt.parse(s)])}).openapi(o.createRoute({tags:["users"],method:"get",path:"/{user_id}/sessions",request:{query:Xt,headers:o.z.object({"tenant-id":o.z.string()}),params:o.z.object({user_id:o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:o.z.union([o.z.array(Ys),uy])}},description:"List of sessions"}}}),async t=>{const{user_id:e}=t.req.valid("param"),{include_totals:n}=t.req.valid("query"),{"tenant-id":r}=t.req.valid("header"),i=await t.env.data.sessions.list(r,{page:0,per_page:10,include_totals:!1,q:`user_id:${e}`});return n?t.json(i):t.json(i.sessions)});/*! *****************************************************************************
29
+ </html>`;return new Response(i,{headers:{"Content-Type":"text/html"}})}async function ey(t,e,n,r,i){var m,v,f;if(!n.redirect_uri)throw new z(400,{message:"Missing redirect_uri in authParams"});const[s]=await t.env.data.keys.list();if(!s)throw new z(500,{message:"No signing key found"});if(!((m=e.addons)!=null&&m.samlp))throw new z(400,{message:`SAML Addon is not enabled for client ${e.id}`});const{recipient:a,audience:c}=e.addons.samlp,l=n.state||"";if(!a||!l||!r||!n.state)throw new z(400,{message:"Missing recipient or inResponseTo"});const u=JSON.parse(n.state),p=new URL(n.redirect_uri),h=await ty(t,{issuer:t.env.ISSUER,audience:c||n.client_id,destination:p.toString(),inResponseTo:u.requestId,userId:((f=(v=r.app_metadata)==null?void 0:v.vimeo)==null?void 0:f.user_id)||r.user_id,email:r.email,sessionIndex:i,signature:{privateKeyPem:s.pkcs7,cert:s.cert,kid:s.kid}});return Q0(p.toString(),h,u.relayState)}async function ty(t,e){const n=e.notBefore||new Date().toISOString(),r=e.notAfter||new Date(new Date(n).getTime()+10*60*1e3).toISOString(),i=e.issueInstant||n,s=e.sessionNotOnOrAfter||r,a=e.responseId||`_${xe()}`,c=e.assertionId||`_${xe()}`,l=[{"samlp:Response":[{"saml:Issuer":[{"#text":e.issuer}]},{"samlp:Status":[{"samlp:StatusCode":[],":@":{"@_Value":"urn:oasis:names:tc:SAML:2.0:status:Success"}}]},{"saml:Assertion":[{"saml:Issuer":[{"#text":e.issuer}]},{"saml:Subject":[{"saml:NameID":[{"#text":e.email}],":@":{"@_Format":"urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"}},{"saml:SubjectConfirmation":[{"saml:SubjectConfirmationData":[],":@":{"@_InResponseTo":e.inResponseTo,"@_NotOnOrAfter":r,"@_Recipient":e.destination}}],":@":{"@_Method":"urn:oasis:names:tc:SAML:2.0:cm:bearer"}}]},{"saml:Conditions":[{"saml:AudienceRestriction":[{"saml:Audience":[{"#text":e.audience}]}]}],":@":{"@_NotBefore":n,"@_NotOnOrAfter":r}},{"saml:AuthnStatement":[{"saml:AuthnContext":[{"saml:AuthnContextClassRef":[{"#text":"urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified"}]}]}],":@":{"@_AuthnInstant":i,"@_SessionIndex":e.sessionIndex,"@_SessionNotOnOrAfter":s}},{"saml:AttributeStatement":[{"saml:Attribute":[{"saml:AttributeValue":[{"#text":e.userId}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_FriendlyName":"persistent","@_Name":"id","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":e.email}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"email","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":"manage-account"}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":"default-roles-master"}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":"offline_access"}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":"view-profile"}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":"uma_authorization"}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":"manage-account-links"}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}}]}],":@":{"@_xmlns":"urn:oasis:names:tc:SAML:2.0:assertion","@_ID":c,"@_IssueInstant":i,"@_Version":"2.0"}}],":@":{"@_xmlns:samlp":"urn:oasis:names:tc:SAML:2.0:protocol","@_xmlns:saml":"urn:oasis:names:tc:SAML:2.0:assertion","@_Destination":e.destination,"@_ID":a,"@_InResponseTo":e.inResponseTo,"@_IssueInstant":i,"@_Version":"2.0"}}];let p=new X0.XMLBuilder({ignoreAttributes:!1,suppressEmptyNode:!0,preserveOrder:!0}).build(l);if(e.signature){const m=await fetch(t.env.SAML_SIGN_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({xmlContent:p,privateKey:e.signature.privateKeyPem,publicCert:e.signature.cert})});if(!m.ok)throw new Error(`Failed to sign SAML response: ${m.status}`);p=await m.text()}return e.encode===!1?p:btoa(p)}var ny={deno:"Deno",bun:"Bun",workerd:"Cloudflare-Workers",node:"Node.js"},ry=()=>{var n,r;const t=globalThis;if(typeof navigator<"u"&&typeof navigator.userAgent=="string"){for(const[i,s]of Object.entries(ny))if(iy(s))return i}return typeof(t==null?void 0:t.EdgeRuntime)=="string"?"edge-light":(t==null?void 0:t.fastly)!==void 0?"fastly":((r=(n=t==null?void 0:t.process)==null?void 0:n.release)==null?void 0:r.name)==="node"?"node":"other"},iy=t=>navigator.userAgent.startsWith(t);function nt(t,e){ry()==="workerd"&&t.executionCtx.waitUntil(e)}function on(t){var e,n,r;return{auth0Client:(e=t.query("auth0Client"))==null?void 0:e.slice(0,255),ip:(n=t.header("x-real-ip"))==null?void 0:n.slice(0,45),useragent:(r=t.header("user-agent"))==null?void 0:r.slice(0,512)}}const Ju=["sub","iss","aud","exp","nbf","iat","jti"];async function to(t,e){var _,w;const{authParams:n,user:r,client:i,session_id:s}=e,c=(await t.env.data.keys.list()).filter(S=>!S.revoked_at||new Date(S.revoked_at)>new Date),l=c[c.length-1];if(!(l!=null&&l.pkcs7))throw new z(500,{message:"No signing key available"});const u=S_(l.pkcs7),p={aud:n.audience||"default",scope:n.scope||"",sub:(r==null?void 0:r.user_id)||n.client_id,iss:t.env.ISSUER,tenant_id:t.var.tenant_id,sid:s},h=r&&((_=n.scope)!=null&&_.split(" ").includes("openid"))?{aud:n.client_id,sub:r.user_id,iss:t.env.ISSUER,sid:s,nonce:n.nonce,given_name:r.given_name,family_name:r.family_name,nickname:r.nickname,picture:r.picture,locale:r.locale,name:r.name,email:r.email,email_verified:r.email_verified}:void 0;(w=t.env.hooks)!=null&&w.onExecuteCredentialsExchange&&await t.env.hooks.onExecuteCredentialsExchange({client:i,user:r,request:{ip:t.req.header("x-real-ip")||"",user_agent:t.req.header("user-agent")||"",method:t.req.method,url:t.req.url},scope:n.scope||"",grant_type:""},{accessToken:{setCustomClaim:(S,C)=>{if(Ju.includes(S))throw new Error(`Cannot overwrite reserved claim '${S}'`);p[S]=C}},idToken:{setCustomClaim:(S,C)=>{if(Ju.includes(S))throw new Error(`Cannot overwrite reserved claim '${S}'`);h&&(h[S]=C)}},access:{deny:S=>{throw new z(400,{message:`Access denied: ${S}`})}}});const m={includeIssuedTimestamp:!0,expiresIn:new sl(1,"d"),headers:{kid:l.kid}},v=await Du("RS256",u,p,m),f=h?await Du("RS256",u,h,m):void 0;return{access_token:v,refresh_token:e.refresh_token,id_token:f,token_type:"Bearer",expires_in:86400}}async function Df(t,e){return e.loginSession||(e.loginSession=await t.env.data.loginSessions.create(e.client.tenant.id,{expires_at:new Date(Date.now()+Jn*1e3).toISOString(),authParams:e.authParams,authorization_url:t.req.url,csrf_token:xe(),...on(t.req)})),{code:(await t.env.data.codes.create(e.client.tenant.id,{code_id:xe(),user_id:e.user.user_id,code_type:"authorization_code",login_id:e.loginSession.id,expires_at:new Date(Date.now()+z_*1e3).toISOString()})).code_id,state:e.authParams.state}}async function sy(t,e){const{client:n,scope:r,audience:i=n.tenant.audience,session_id:s}=e;return await t.env.data.refreshTokens.create(n.tenant.id,{id:xe(),session_id:s,client_id:n.id,expires_at:new Date(Date.now()+Qs*1e3).toISOString(),user_id:e.user.user_id,device:{last_ip:t.req.header("x-real-ip")||"",initial_ip:t.req.header("x-real-ip")||"",last_user_agent:t.req.header("user-agent")||"",initial_user_agent:t.req.header("user-agent")||"",initial_asn:"",last_asn:""},resource_servers:[{audience:i,scopes:r}],rotating:!1})}async function Hf(t,{user:e,client:n,loginSession:r}){const i=await t.env.data.sessions.create(n.tenant.id,{id:xe(),user_id:e.user_id,idle_expires_at:new Date(Date.now()+Qs*1e3).toISOString(),device:{last_ip:t.req.header("x-real-ip")||"",initial_ip:t.req.header("x-real-ip")||"",last_user_agent:t.req.header("user-agent")||"",initial_user_agent:t.req.header("user-agent")||"",initial_asn:"",last_asn:""},clients:[n.id]});await t.env.data.loginSessions.update(n.tenant.id,r.id,{session_id:i.id});const{scope:s,audience:a}=r.authParams,c=s!=null&&s.split(" ").includes("offline_access")?await sy(t,{session_id:i.id,user:e,client:n,scope:s,audience:a}):void 0;return{...i,refresh_token:c}}async function an(t,e){var v;const{authParams:n,user:r,client:i,ticketAuth:s}=e,a=ve(t,{type:he.SUCCESS_LOGIN,description:`Successful login for ${r.user_id}`,userId:r.user_id});if(nt(t,t.env.data.logs.create(i.tenant.id,a)),nt(t,t.env.data.users.update(i.tenant.id,r.user_id,{last_login:new Date().toISOString(),last_ip:t.req.header("x-real-ip")||"",login_count:r.login_count+1})),s){if(!e.loginSession)throw new z(500,{message:"Login session not found"});const f=x_(),_=xe(12),w=await t.env.data.codes.create(i.tenant.id,{code_id:xe(),code_type:"ticket",login_id:e.loginSession.id,expires_at:new Date(Date.now()+C_).toISOString(),code_verifier:[_,f].join("|")});return t.json({login_ticket:w.code_id,co_verifier:f,co_id:_})}let c=e.refreshToken,l=e.sessionId,u=r;if(!l){if(!e.loginSession)throw new z(500,{message:"Login session not found"});u=await ly(t,t.env.data)(i.tenant.id,r);const f=await Hf(t,{user:r,client:i,loginSession:e.loginSession});l=f.id,c=(v=f.refresh_token)==null?void 0:v.id}if(e.authParams.response_mode===Xt.SAML_POST)return ey(t,e.client,e.authParams,u,l);const p=await to(t,{authParams:n,user:u,client:i,session_id:l,refresh_token:c}),h=new Headers({"set-cookie":Tf(i.tenant.id,l,t.req.header("host"))});if(n.response_mode===Xt.WEB_MESSAGE)return t.json(p,{headers:h});if((n.response_type||Pt.CODE)===Pt.CODE){const f=await Df(t,e);if(!n.redirect_uri)throw new z(400,{message:"Redirect uri not found"});const _=new URL(n.redirect_uri);_.searchParams.set("code",f.code),f.state&&_.searchParams.set("state",f.state),h.set("location",_.toString())}return new Response("Redirecting",{status:302,headers:h})}async function oy(t,e,n){const r=await t.env.data.tenants.get(e);if(!r)throw new Error(`Tenant not found: ${e}`);return to(t,{client:{id:t.env.ISSUER,tenant:r,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),name:t.env.ISSUER,disable_sign_ups:!1,connections:[]},authParams:{client_id:t.env.ISSUER,response_type:Pt.TOKEN,scope:n}})}async function dl(t,e,n){const r=await oy(t,n.tenant_id,"webhook");for await(const i of e)if(!(await fetch(i.url,{method:"POST",headers:{Authorization:`Bearer ${r.access_token}`,"Content-Type":"application/json"},body:JSON.stringify(n)})).ok){const a=ve(t,{type:he.FAILED_HOOK,description:`Failed to invoke hook ${i.hook_id}`});await t.env.data.logs.create(n.tenant_id,a)}}function ay(t){return async(e,n)=>{const{hooks:r}=await t.env.data.hooks.list(e);return await dl(t,r,{tenant_id:e,user:n,trigger_id:"post-user-registration"}),n}}function cy(t){return async(e,n)=>{const{hooks:r}=await t.env.data.hooks.list(e,{q:"trigger_id:pre-user-signup",page:0,per_page:100,include_totals:!1});await dl(t,r,{tenant_id:e,email:n,trigger_id:"pre-user-signup"})}}function ly(t,e){return async(n,r)=>{const{hooks:i}=await e.hooks.list(n,{q:"trigger_id:post-user-login",page:0,per_page:100,include_totals:!1});return await dl(t,i,{tenant_id:n,user:r,trigger_id:"post-user-login"}),r}}function uy(t,e){return async(n,r)=>{var a,c,l;const i={method:t.req.method,ip:t.req.query("x-real-ip")||"",user_agent:t.req.query("user-agent"),url:((a=t.var.loginSession)==null?void 0:a.authorization_url)||t.req.url};if((c=t.env.hooks)!=null&&c.onExecutePreUserRegistration)try{await t.env.hooks.onExecutePreUserRegistration({user:r,request:i},{user:{setUserMetadata:async(u,p)=>{r[u]=p}}})}catch{const p=ve(t,{type:he.FAILED_SIGNUP,description:"Pre user registration hook failed"});await e.logs.create(n,p)}let s=await m_(e)(n,r);if((l=t.env.hooks)!=null&&l.onExecutePostUserRegistration)try{await t.env.hooks.onExecutePostUserRegistration({user:r,request:i},{user:{}})}catch{const p=ve(t,{type:he.FAILED_SIGNUP,description:"Post user registration hook failed"});await t.env.data.logs.create(n,p)}return await ay(t)(n,s),s}}async function dy(t,e,n,r){if(e.disable_sign_ups&&!await ro({userAdapter:n.users,tenant_id:e.tenant.id,email:r})){const s=ve(t,{type:he.FAILED_SIGNUP,description:"Public signup is disabled"});throw await n.logs.create(e.tenant.id,s),new z(400,{message:"Signups are disabled for this client"})}await cy(t)(t.var.tenant_id||"",r)}function no(t,e){return{...e,users:{...e.users,create:uy(t,e)}}}function Ff(t){return no(t,t.env.data)}async function pl(t,e,n){return(await t.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${n}`})).users}async function ur({userAdapter:t,tenant_id:e,email:n,provider:r}){const{users:i}=await t.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${n} provider:${r}`});return i.length>1&&console.error("More than one user found for same email and provider"),i[0]||null}async function ro({userAdapter:t,tenant_id:e,email:n}){var c;const{users:r}=await t.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${n}`}),i=r.filter(l=>!(l.provider==="auth2"&&!l.email_verified));if(i.length===0)return;const s=i.filter(l=>!l.linked_to);if(s.length>0)return s.length>1&&console.error("More than one primary user found for same email"),s[0];const a=await t.get(e,(c=i[0])==null?void 0:c.linked_to);if(!a)throw new Error("Primary account not found");return a}async function ls({userAdapter:t,tenant_id:e,email:n,provider:r}){const i=await ur({userAdapter:t,tenant_id:e,email:n,provider:r});return i?i.linked_to?t.get(e,i.linked_to):i:null}async function io(t,e){const{email:n,provider:r,connection:i,client:s,userId:a,isSocial:c,profileData:l={},ip:u=""}=e;let p=await ls({userAdapter:t.env.data.users,tenant_id:e.client.tenant.id,email:n,provider:r});if(!p){const h={user_id:`${r}|${a||Xs()}`,email:n,name:n,provider:r,connection:i,email_verified:!0,last_ip:u,is_social:c,last_login:new Date().toISOString(),profileData:JSON.stringify(l)};p=await Ff(t).users.create(s.tenant.id,h),t.set("user_id",p.user_id)}return p}const Qt=o.z.object({page:o.z.string().min(0).optional().default("0").transform(t=>parseInt(t,10)).openapi({description:"The page number where 0 is the first page"}),per_page:o.z.string().min(1).optional().default("10").transform(t=>parseInt(t,10)).openapi({description:"The number of items per page"}),include_totals:o.z.string().optional().default("false").transform(t=>t==="true").openapi({description:"If the total number of items should be included in the response"}),sort:o.z.string().regex(/^.+:(-1|1)$/).optional().openapi({description:"A property that should have the format 'string:-1' or 'string:1'"}),q:o.z.string().optional().openapi({description:"A lucene query string used to filter the results"})});function dr(t){if(!t)return;const[e,n]=t.split(":"),r=n==="1"?"asc":"desc";if(!(!e||!r))return{sort_by:e,sort_order:r}}const Zu=rn.extend({users:o.z.array(xt)}),py=rn.extend({sessions:o.z.array(Ys)}),fy=new o.OpenAPIHono().openapi(o.createRoute({tags:["users"],method:"get",path:"/",request:{query:Qt,headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:o.z.union([o.z.array(xt),Zu])}},description:"List of users"}}}),async t=>{const{page:e,per_page:n,include_totals:r,sort:i,q:s}=t.req.valid("query"),{"tenant-id":a}=t.req.valid("header");if(s!=null&&s.includes("identities.profileData.email")){const p=s.split("=")[1],m=(await t.env.data.users.list(a,{page:e,per_page:n,include_totals:r,q:`email:${p}`})).users.filter(_=>_.linked_to),[v]=m;if(!v)return t.json([]);const f=await t.env.data.users.get(a,v.linked_to);if(!f)throw new z(500,{message:"Primary account not found"});return t.json([xt.parse(f)])}const c=["-_exists_:linked_to"];s&&c.push(s);const l=await t.env.data.users.list(a,{page:e,per_page:n,include_totals:r,sort:dr(i),q:c.join(" ")}),u=l.users.filter(p=>!p.linked_to);return r?t.json(Zu.parse({users:u,length:l.length,start:l.start,limit:l.limit})):t.json(o.z.array(xt).parse(u))}).openapi(o.createRoute({tags:["users"],method:"get",path:"/{user_id}",request:{headers:o.z.object({"tenant-id":o.z.string()}),params:o.z.object({user_id:o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:xt}},description:"List of users"}}}),async t=>{const{user_id:e}=t.req.valid("param"),{"tenant-id":n}=t.req.valid("header"),r=await t.env.data.users.get(n,e);if(!r)throw new z(404);if(r.linked_to)throw new z(404,{message:"User is linked to another user"});return t.json(r)}).openapi(o.createRoute({tags:["users"],method:"delete",path:"/{user_id}",request:{headers:o.z.object({"tenant-id":o.z.string()}),params:o.z.object({user_id:o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{const{user_id:e}=t.req.valid("param"),{"tenant-id":n}=t.req.valid("header");if(!await t.env.data.users.remove(n,e))throw new z(404);return t.text("OK")}).openapi(o.createRoute({tags:["users"],method:"post",path:"/",request:{headers:o.z.object({"tenant-id":o.z.string()}),body:{content:{"application/json":{schema:o.z.object({...ts.shape})}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:xt}},description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json");t.set("body",n);const{email:r}=n;if(!r)throw new z(400,{message:"Email is required"});const i=r.toLowerCase(),s=`${n.provider}|${n.user_id||Xs()}`;try{const a=await t.env.data.users.create(e,{email:i,user_id:s,name:n.name||i,provider:n.provider,connection:n.connection,email_verified:n.email_verified||!1,last_ip:"",is_social:!1,last_login:new Date().toISOString()});t.set("user_id",a.user_id);const c=ve(t,{type:he.SUCCESS_API_OPERATION,description:"User created"});nt(t,t.env.data.logs.create(e,c));const l={...a,identities:[{connection:a.connection,provider:a.provider,user_id:qu(a.user_id),isSocial:a.is_social}]};return t.json(xt.parse(l),{status:201})}catch(a){throw a.message==="User already exists"?new z(409,{message:"User already exists"}):a}}).openapi(o.createRoute({tags:["users"],method:"patch",path:"/{user_id}",request:{headers:o.z.object({"tenant-id":o.z.string()}),body:{content:{"application/json":{schema:o.z.object({...ts.shape,verify_email:o.z.boolean(),password:o.z.string()}).partial()}}},params:o.z.object({user_id:o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{var p;const{data:e}=t.env,{"tenant-id":n}=t.req.valid("header"),r=t.req.valid("json"),{user_id:i}=t.req.valid("param"),{verify_email:s,password:a,...c}=r,l=await e.users.get(n,i);if(!l)throw new z(404);if(c.email&&c.email!==l.email){const h=await pl(t.env.data.users,n,c.email);if(h.length&&h.some(m=>m.user_id!==i))throw new z(409,{message:"Another user with the same email address already exists."})}if(l.linked_to)throw new z(404,{message:"User is linked to another user"});if(await t.env.data.users.update(n,i,c),a){const h=(p=l.identities)==null?void 0:p.find(f=>f.connection==="Username-Password-Authentication");if(!h)throw new z(400,{message:"User does not have a password identity"});const m={user_id:h.user_id,password:await si.hash(a,10),algorithm:"bcrypt"};await e.passwords.get(n,h.user_id)?await e.passwords.update(n,m):await e.passwords.create(n,m)}const u=await t.env.data.users.get(n,i);if(!u)throw new z(500);return t.json(u)}).openapi(o.createRoute({tags:["users"],method:"post",path:"/{user_id}/identities",request:{headers:o.z.object({"tenant-id":o.z.string()}),body:{content:{"application/json":{schema:o.z.union([o.z.object({link_with:o.z.string()}),o.z.object({user_id:o.z.string(),provider:o.z.string(),connection:o.z.string().optional()})])}}},params:o.z.object({user_id:o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:o.z.array(o.z.object({connection:o.z.string(),provider:o.z.string(),user_id:o.z.string(),isSocial:o.z.boolean()}))}},description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),{user_id:r}=t.req.valid("param"),i="link_with"in n?n.link_with:n.user_id,s=await t.env.data.users.get(e,r);if(!s)throw new z(400,{message:"Linking an inexistent identity is not allowed."});await t.env.data.users.update(e,i,{linked_to:r});const a=await t.env.data.users.list(e,{page:0,per_page:10,include_totals:!1,q:`linked_to:${r}`}),c=[s,...a.users].map(l=>({connection:l.connection,provider:l.provider,user_id:qu(l.user_id),isSocial:l.is_social}));return t.json(c,{status:201})}).openapi(o.createRoute({tags:["users"],method:"delete",path:"/{user_id}/identities/{provider}/{linked_user_id}",request:{headers:o.z.object({"tenant-id":o.z.string()}),params:o.z.object({user_id:o.z.string(),provider:o.z.string(),linked_user_id:o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:o.z.array(xt)}},description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{user_id:n,provider:r,linked_user_id:i}=t.req.valid("param");await t.env.data.users.unlink(e,n,r,i);const s=await t.env.data.users.get(e,n);if(!s)throw new z(404);return t.json([xt.parse(s)])}).openapi(o.createRoute({tags:["users"],method:"get",path:"/{user_id}/sessions",request:{query:Qt,headers:o.z.object({"tenant-id":o.z.string()}),params:o.z.object({user_id:o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:o.z.union([o.z.array(Ys),py])}},description:"List of sessions"}}}),async t=>{const{user_id:e}=t.req.valid("param"),{include_totals:n}=t.req.valid("query"),{"tenant-id":r}=t.req.valid("header"),i=await t.env.data.sessions.list(r,{page:0,per_page:10,include_totals:!1,q:`user_id:${e}`});return n?t.json(i):t.json(i.sessions)});/*! *****************************************************************************
30
30
  Copyright (C) Microsoft. All rights reserved.
31
31
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use
32
32
  this file except in compliance with the License. You may obtain a copy of the
@@ -39,7 +39,7 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
39
39
 
40
40
  See the Apache Version 2.0 License for specific language governing permissions
41
41
  and limitations under the License.
42
- ***************************************************************************** */var Zu;(function(t){(function(e){var n=typeof globalThis=="object"?globalThis:typeof as=="object"?as:typeof self=="object"?self:typeof this=="object"?this:c(),r=i(t);typeof n.Reflect<"u"&&(r=i(n.Reflect,r)),e(r,n),typeof n.Reflect>"u"&&(n.Reflect=t);function i(l,u){return function(p,h){Object.defineProperty(l,p,{configurable:!0,writable:!0,value:h}),u&&u(p,h)}}function s(){try{return Function("return this;")()}catch{}}function a(){try{return(0,eval)("(function() { return this; })()")}catch{}}function c(){return s()||a()}})(function(e,n){var r=Object.prototype.hasOwnProperty,i=typeof Symbol=="function",s=i&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",a=i&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",c=typeof Object.create=="function",l={__proto__:[]}instanceof Array,u=!c&&!l,p={create:c?function(){return ea(Object.create(null))}:l?function(){return ea({__proto__:null})}:function(){return ea({})},has:u?function(A,I){return r.call(A,I)}:function(A,I){return I in A},get:u?function(A,I){return r.call(A,I)?A[I]:void 0}:function(A,I){return A[I]}},h=Object.getPrototypeOf(Function),m=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:bm(),v=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:km(),f=typeof WeakMap=="function"?WeakMap:xm(),_=i?Symbol.for("@reflect-metadata:registry"):void 0,w=ym(),S=vm(w);function C(A,I,O,V){if(H(O)){if(!wu(A))throw new TypeError;if(!bu(I))throw new TypeError;return N(A,I)}else{if(!wu(A))throw new TypeError;if(!ge(I))throw new TypeError;if(!ge(V)&&!H(V)&&!Ne(V))throw new TypeError;return Ne(V)&&(V=void 0),O=wt(O),E(A,I,O,V)}}e("decorate",C);function B(A,I){function O(V,ee){if(!ge(V))throw new TypeError;if(!H(ee)&&!mm(ee))throw new TypeError;X(A,I,V,ee)}return O}e("metadata",B);function L(A,I,O,V){if(!ge(O))throw new TypeError;return H(V)||(V=wt(V)),X(A,I,O,V)}e("defineMetadata",L);function Q(A,I,O){if(!ge(I))throw new TypeError;return H(O)||(O=wt(O)),x(A,I,O)}e("hasMetadata",Q);function ce(A,I,O){if(!ge(I))throw new TypeError;return H(O)||(O=wt(O)),k(A,I,O)}e("hasOwnMetadata",ce);function le(A,I,O){if(!ge(I))throw new TypeError;return H(O)||(O=wt(O)),$(A,I,O)}e("getMetadata",le);function De(A,I,O){if(!ge(I))throw new TypeError;return H(O)||(O=wt(O)),U(A,I,O)}e("getOwnMetadata",De);function Ue(A,I){if(!ge(A))throw new TypeError;return H(I)||(I=wt(I)),G(A,I)}e("getMetadataKeys",Ue);function Re(A,I){if(!ge(A))throw new TypeError;return H(I)||(I=wt(I)),ie(A,I)}e("getOwnMetadataKeys",Re);function j(A,I,O){if(!ge(I))throw new TypeError;if(H(O)||(O=wt(O)),!ge(I))throw new TypeError;H(O)||(O=wt(O));var V=Sr(I,O,!1);return H(V)?!1:V.OrdinaryDeleteMetadata(A,I,O)}e("deleteMetadata",j);function N(A,I){for(var O=A.length-1;O>=0;--O){var V=A[O],ee=V(I);if(!H(ee)&&!Ne(ee)){if(!bu(ee))throw new TypeError;I=ee}}return I}function E(A,I,O,V){for(var ee=A.length-1;ee>=0;--ee){var Ce=A[ee],Ee=Ce(I,O,V);if(!H(Ee)&&!Ne(Ee)){if(!ge(Ee))throw new TypeError;V=Ee}}return V}function x(A,I,O){var V=k(A,I,O);if(V)return!0;var ee=Qo(I);return Ne(ee)?!1:x(A,ee,O)}function k(A,I,O){var V=Sr(I,O,!1);return H(V)?!1:vu(V.OrdinaryHasOwnMetadata(A,I,O))}function $(A,I,O){var V=k(A,I,O);if(V)return U(A,I,O);var ee=Qo(I);if(!Ne(ee))return $(A,ee,O)}function U(A,I,O){var V=Sr(I,O,!1);if(!H(V))return V.OrdinaryGetOwnMetadata(A,I,O)}function X(A,I,O,V){var ee=Sr(O,V,!0);ee.OrdinaryDefineOwnMetadata(A,I,O,V)}function G(A,I){var O=ie(A,I),V=Qo(A);if(V===null)return O;var ee=G(V,I);if(ee.length<=0)return O;if(O.length<=0)return ee;for(var Ce=new v,Ee=[],oe=0,D=O;oe<D.length;oe++){var W=D[oe],Z=Ce.has(W);Z||(Ce.add(W),Ee.push(W))}for(var Y=0,ae=ee;Y<ae.length;Y++){var W=ae[Y],Z=Ce.has(W);Z||(Ce.add(W),Ee.push(W))}return Ee}function ie(A,I){var O=Sr(A,I,!1);return O?O.OrdinaryOwnMetadataKeys(A,I):[]}function de(A){if(A===null)return 1;switch(typeof A){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return A===null?1:6;default:return 6}}function H(A){return A===void 0}function Ne(A){return A===null}function pn(A){return typeof A=="symbol"}function ge(A){return typeof A=="object"?A!==null:typeof A=="function"}function Se(A,I){switch(de(A)){case 0:return A;case 1:return A;case 2:return A;case 3:return A;case 4:return A;case 5:return A}var O="string",V=ku(A,s);if(V!==void 0){var ee=V.call(A,O);if(ge(ee))throw new TypeError;return ee}return hm(A)}function hm(A,I){var O,V;{var ee=A.toString;if(Ni(ee)){var V=ee.call(A);if(!ge(V))return V}var O=A.valueOf;if(Ni(O)){var V=O.call(A);if(!ge(V))return V}}throw new TypeError}function vu(A){return!!A}function gm(A){return""+A}function wt(A){var I=Se(A);return pn(I)?I:gm(I)}function wu(A){return Array.isArray?Array.isArray(A):A instanceof Object?A instanceof Array:Object.prototype.toString.call(A)==="[object Array]"}function Ni(A){return typeof A=="function"}function bu(A){return typeof A=="function"}function mm(A){switch(de(A)){case 3:return!0;case 4:return!0;default:return!1}}function Xo(A,I){return A===I||A!==A&&I!==I}function ku(A,I){var O=A[I];if(O!=null){if(!Ni(O))throw new TypeError;return O}}function xu(A){var I=ku(A,a);if(!Ni(I))throw new TypeError;var O=I.call(A);if(!ge(O))throw new TypeError;return O}function Su(A){return A.value}function Au(A){var I=A.next();return I.done?!1:I}function Eu(A){var I=A.return;I&&I.call(A)}function Qo(A){var I=Object.getPrototypeOf(A);if(typeof A!="function"||A===h||I!==h)return I;var O=A.prototype,V=O&&Object.getPrototypeOf(O);if(V==null||V===Object.prototype)return I;var ee=V.constructor;return typeof ee!="function"||ee===A?I:ee}function _m(){var A;!H(_)&&typeof n.Reflect<"u"&&!(_ in n.Reflect)&&typeof n.Reflect.defineMetadata=="function"&&(A=wm(n.Reflect));var I,O,V,ee=new f,Ce={registerProvider:Ee,getProvider:D,setProvider:Z};return Ce;function Ee(Y){if(!Object.isExtensible(Ce))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case A===Y:break;case H(I):I=Y;break;case I===Y:break;case H(O):O=Y;break;case O===Y:break;default:V===void 0&&(V=new v),V.add(Y);break}}function oe(Y,ae){if(!H(I)){if(I.isProviderFor(Y,ae))return I;if(!H(O)){if(O.isProviderFor(Y,ae))return I;if(!H(V))for(var me=xu(V);;){var we=Au(me);if(!we)return;var ut=Su(we);if(ut.isProviderFor(Y,ae))return Eu(me),ut}}}if(!H(A)&&A.isProviderFor(Y,ae))return A}function D(Y,ae){var me=ee.get(Y),we;return H(me)||(we=me.get(ae)),H(we)&&(we=oe(Y,ae),H(we)||(H(me)&&(me=new m,ee.set(Y,me)),me.set(ae,we))),we}function W(Y){if(H(Y))throw new TypeError;return I===Y||O===Y||!H(V)&&V.has(Y)}function Z(Y,ae,me){if(!W(me))throw new Error("Metadata provider not registered.");var we=D(Y,ae);if(we!==me){if(!H(we))return!1;var ut=ee.get(Y);H(ut)&&(ut=new m,ee.set(Y,ut)),ut.set(ae,me)}return!0}}function ym(){var A;return!H(_)&&ge(n.Reflect)&&Object.isExtensible(n.Reflect)&&(A=n.Reflect[_]),H(A)&&(A=_m()),!H(_)&&ge(n.Reflect)&&Object.isExtensible(n.Reflect)&&Object.defineProperty(n.Reflect,_,{enumerable:!1,configurable:!1,writable:!1,value:A}),A}function vm(A){var I=new f,O={isProviderFor:function(W,Z){var Y=I.get(W);return H(Y)?!1:Y.has(Z)},OrdinaryDefineOwnMetadata:Ee,OrdinaryHasOwnMetadata:ee,OrdinaryGetOwnMetadata:Ce,OrdinaryOwnMetadataKeys:oe,OrdinaryDeleteMetadata:D};return w.registerProvider(O),O;function V(W,Z,Y){var ae=I.get(W),me=!1;if(H(ae)){if(!Y)return;ae=new m,I.set(W,ae),me=!0}var we=ae.get(Z);if(H(we)){if(!Y)return;if(we=new m,ae.set(Z,we),!A.setProvider(W,Z,O))throw ae.delete(Z),me&&I.delete(W),new Error("Wrong provider for target.")}return we}function ee(W,Z,Y){var ae=V(Z,Y,!1);return H(ae)?!1:vu(ae.has(W))}function Ce(W,Z,Y){var ae=V(Z,Y,!1);if(!H(ae))return ae.get(W)}function Ee(W,Z,Y,ae){var me=V(Y,ae,!0);me.set(W,Z)}function oe(W,Z){var Y=[],ae=V(W,Z,!1);if(H(ae))return Y;for(var me=ae.keys(),we=xu(me),ut=0;;){var Iu=Au(we);if(!Iu)return Y.length=ut,Y;var Sm=Su(Iu);try{Y[ut]=Sm}catch(Am){try{Eu(we)}finally{throw Am}}ut++}}function D(W,Z,Y){var ae=V(Z,Y,!1);if(H(ae)||!ae.delete(W))return!1;if(ae.size===0){var me=I.get(Z);H(me)||(me.delete(Y),me.size===0&&I.delete(me))}return!0}}function wm(A){var I=A.defineMetadata,O=A.hasOwnMetadata,V=A.getOwnMetadata,ee=A.getOwnMetadataKeys,Ce=A.deleteMetadata,Ee=new f,oe={isProviderFor:function(D,W){var Z=Ee.get(D);return!H(Z)&&Z.has(W)?!0:ee(D,W).length?(H(Z)&&(Z=new v,Ee.set(D,Z)),Z.add(W),!0):!1},OrdinaryDefineOwnMetadata:I,OrdinaryHasOwnMetadata:O,OrdinaryGetOwnMetadata:V,OrdinaryOwnMetadataKeys:ee,OrdinaryDeleteMetadata:Ce};return oe}function Sr(A,I,O){var V=w.getProvider(A,I);if(!H(V))return V;if(O){if(w.setProvider(A,I,S))return S;throw new Error("Illegal state.")}}function bm(){var A={},I=[],O=function(){function oe(D,W,Z){this._index=0,this._keys=D,this._values=W,this._selector=Z}return oe.prototype["@@iterator"]=function(){return this},oe.prototype[a]=function(){return this},oe.prototype.next=function(){var D=this._index;if(D>=0&&D<this._keys.length){var W=this._selector(this._keys[D],this._values[D]);return D+1>=this._keys.length?(this._index=-1,this._keys=I,this._values=I):this._index++,{value:W,done:!1}}return{value:void 0,done:!0}},oe.prototype.throw=function(D){throw this._index>=0&&(this._index=-1,this._keys=I,this._values=I),D},oe.prototype.return=function(D){return this._index>=0&&(this._index=-1,this._keys=I,this._values=I),{value:D,done:!0}},oe}(),V=function(){function oe(){this._keys=[],this._values=[],this._cacheKey=A,this._cacheIndex=-2}return Object.defineProperty(oe.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),oe.prototype.has=function(D){return this._find(D,!1)>=0},oe.prototype.get=function(D){var W=this._find(D,!1);return W>=0?this._values[W]:void 0},oe.prototype.set=function(D,W){var Z=this._find(D,!0);return this._values[Z]=W,this},oe.prototype.delete=function(D){var W=this._find(D,!1);if(W>=0){for(var Z=this._keys.length,Y=W+1;Y<Z;Y++)this._keys[Y-1]=this._keys[Y],this._values[Y-1]=this._values[Y];return this._keys.length--,this._values.length--,Xo(D,this._cacheKey)&&(this._cacheKey=A,this._cacheIndex=-2),!0}return!1},oe.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=A,this._cacheIndex=-2},oe.prototype.keys=function(){return new O(this._keys,this._values,ee)},oe.prototype.values=function(){return new O(this._keys,this._values,Ce)},oe.prototype.entries=function(){return new O(this._keys,this._values,Ee)},oe.prototype["@@iterator"]=function(){return this.entries()},oe.prototype[a]=function(){return this.entries()},oe.prototype._find=function(D,W){if(!Xo(this._cacheKey,D)){this._cacheIndex=-1;for(var Z=0;Z<this._keys.length;Z++)if(Xo(this._keys[Z],D)){this._cacheIndex=Z;break}}return this._cacheIndex<0&&W&&(this._cacheIndex=this._keys.length,this._keys.push(D),this._values.push(void 0)),this._cacheIndex},oe}();return V;function ee(oe,D){return oe}function Ce(oe,D){return D}function Ee(oe,D){return[oe,D]}}function km(){var A=function(){function I(){this._map=new m}return Object.defineProperty(I.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),I.prototype.has=function(O){return this._map.has(O)},I.prototype.add=function(O){return this._map.set(O,O),this},I.prototype.delete=function(O){return this._map.delete(O)},I.prototype.clear=function(){this._map.clear()},I.prototype.keys=function(){return this._map.keys()},I.prototype.values=function(){return this._map.keys()},I.prototype.entries=function(){return this._map.entries()},I.prototype["@@iterator"]=function(){return this.keys()},I.prototype[a]=function(){return this.keys()},I}();return A}function xm(){var A=16,I=p.create(),O=V();return function(){function D(){this._key=V()}return D.prototype.has=function(W){var Z=ee(W,!1);return Z!==void 0?p.has(Z,this._key):!1},D.prototype.get=function(W){var Z=ee(W,!1);return Z!==void 0?p.get(Z,this._key):void 0},D.prototype.set=function(W,Z){var Y=ee(W,!0);return Y[this._key]=Z,this},D.prototype.delete=function(W){var Z=ee(W,!1);return Z!==void 0?delete Z[this._key]:!1},D.prototype.clear=function(){this._key=V()},D}();function V(){var D;do D="@@WeakMap@@"+oe();while(p.has(I,D));return I[D]=!0,D}function ee(D,W){if(!r.call(D,O)){if(!W)return;Object.defineProperty(D,O,{value:p.create()})}return D[O]}function Ce(D,W){for(var Z=0;Z<W;++Z)D[Z]=Math.random()*255|0;return D}function Ee(D){if(typeof Uint8Array=="function"){var W=new Uint8Array(D);return typeof crypto<"u"?crypto.getRandomValues(W):typeof msCrypto<"u"?msCrypto.getRandomValues(W):Ce(W,D),W}return Ce(new Array(D),D)}function oe(){var D=Ee(A);D[6]=D[6]&79|64,D[8]=D[8]&191|128;for(var W="",Z=0;Z<A;++Z){var Y=D[Z];(Z===4||Z===6||Z===8)&&(W+="-"),Y<16&&(W+="0"),W+=Y.toString(16).toLowerCase()}return W}}function ea(A){return A.__=void 0,delete A.__,A}})})(Zu||(Zu={}));/*!
42
+ ***************************************************************************** */var Yu;(function(t){(function(e){var n=typeof globalThis=="object"?globalThis:typeof as=="object"?as:typeof self=="object"?self:typeof this=="object"?this:c(),r=i(t);typeof n.Reflect<"u"&&(r=i(n.Reflect,r)),e(r,n),typeof n.Reflect>"u"&&(n.Reflect=t);function i(l,u){return function(p,h){Object.defineProperty(l,p,{configurable:!0,writable:!0,value:h}),u&&u(p,h)}}function s(){try{return Function("return this;")()}catch{}}function a(){try{return(0,eval)("(function() { return this; })()")}catch{}}function c(){return s()||a()}})(function(e,n){var r=Object.prototype.hasOwnProperty,i=typeof Symbol=="function",s=i&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",a=i&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",c=typeof Object.create=="function",l={__proto__:[]}instanceof Array,u=!c&&!l,p={create:c?function(){return ea(Object.create(null))}:l?function(){return ea({__proto__:null})}:function(){return ea({})},has:u?function(A,I){return r.call(A,I)}:function(A,I){return I in A},get:u?function(A,I){return r.call(A,I)?A[I]:void 0}:function(A,I){return A[I]}},h=Object.getPrototypeOf(Function),m=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:km(),v=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:xm(),f=typeof WeakMap=="function"?WeakMap:Sm(),_=i?Symbol.for("@reflect-metadata:registry"):void 0,w=vm(),S=wm(w);function C(A,I,O,V){if(H(O)){if(!bu(A))throw new TypeError;if(!ku(I))throw new TypeError;return N(A,I)}else{if(!bu(A))throw new TypeError;if(!ge(I))throw new TypeError;if(!ge(V)&&!H(V)&&!Ne(V))throw new TypeError;return Ne(V)&&(V=void 0),O=wt(O),E(A,I,O,V)}}e("decorate",C);function B(A,I){function O(V,ee){if(!ge(V))throw new TypeError;if(!H(ee)&&!_m(ee))throw new TypeError;X(A,I,V,ee)}return O}e("metadata",B);function L(A,I,O,V){if(!ge(O))throw new TypeError;return H(V)||(V=wt(V)),X(A,I,O,V)}e("defineMetadata",L);function Q(A,I,O){if(!ge(I))throw new TypeError;return H(O)||(O=wt(O)),x(A,I,O)}e("hasMetadata",Q);function ce(A,I,O){if(!ge(I))throw new TypeError;return H(O)||(O=wt(O)),k(A,I,O)}e("hasOwnMetadata",ce);function le(A,I,O){if(!ge(I))throw new TypeError;return H(O)||(O=wt(O)),$(A,I,O)}e("getMetadata",le);function De(A,I,O){if(!ge(I))throw new TypeError;return H(O)||(O=wt(O)),U(A,I,O)}e("getOwnMetadata",De);function Ue(A,I){if(!ge(A))throw new TypeError;return H(I)||(I=wt(I)),G(A,I)}e("getMetadataKeys",Ue);function Re(A,I){if(!ge(A))throw new TypeError;return H(I)||(I=wt(I)),ie(A,I)}e("getOwnMetadataKeys",Re);function j(A,I,O){if(!ge(I))throw new TypeError;if(H(O)||(O=wt(O)),!ge(I))throw new TypeError;H(O)||(O=wt(O));var V=Sr(I,O,!1);return H(V)?!1:V.OrdinaryDeleteMetadata(A,I,O)}e("deleteMetadata",j);function N(A,I){for(var O=A.length-1;O>=0;--O){var V=A[O],ee=V(I);if(!H(ee)&&!Ne(ee)){if(!ku(ee))throw new TypeError;I=ee}}return I}function E(A,I,O,V){for(var ee=A.length-1;ee>=0;--ee){var Ce=A[ee],Ee=Ce(I,O,V);if(!H(Ee)&&!Ne(Ee)){if(!ge(Ee))throw new TypeError;V=Ee}}return V}function x(A,I,O){var V=k(A,I,O);if(V)return!0;var ee=Qo(I);return Ne(ee)?!1:x(A,ee,O)}function k(A,I,O){var V=Sr(I,O,!1);return H(V)?!1:wu(V.OrdinaryHasOwnMetadata(A,I,O))}function $(A,I,O){var V=k(A,I,O);if(V)return U(A,I,O);var ee=Qo(I);if(!Ne(ee))return $(A,ee,O)}function U(A,I,O){var V=Sr(I,O,!1);if(!H(V))return V.OrdinaryGetOwnMetadata(A,I,O)}function X(A,I,O,V){var ee=Sr(O,V,!0);ee.OrdinaryDefineOwnMetadata(A,I,O,V)}function G(A,I){var O=ie(A,I),V=Qo(A);if(V===null)return O;var ee=G(V,I);if(ee.length<=0)return O;if(O.length<=0)return ee;for(var Ce=new v,Ee=[],oe=0,D=O;oe<D.length;oe++){var W=D[oe],Z=Ce.has(W);Z||(Ce.add(W),Ee.push(W))}for(var Y=0,ae=ee;Y<ae.length;Y++){var W=ae[Y],Z=Ce.has(W);Z||(Ce.add(W),Ee.push(W))}return Ee}function ie(A,I){var O=Sr(A,I,!1);return O?O.OrdinaryOwnMetadataKeys(A,I):[]}function de(A){if(A===null)return 1;switch(typeof A){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return A===null?1:6;default:return 6}}function H(A){return A===void 0}function Ne(A){return A===null}function fn(A){return typeof A=="symbol"}function ge(A){return typeof A=="object"?A!==null:typeof A=="function"}function Se(A,I){switch(de(A)){case 0:return A;case 1:return A;case 2:return A;case 3:return A;case 4:return A;case 5:return A}var O="string",V=xu(A,s);if(V!==void 0){var ee=V.call(A,O);if(ge(ee))throw new TypeError;return ee}return gm(A)}function gm(A,I){var O,V;{var ee=A.toString;if(Ni(ee)){var V=ee.call(A);if(!ge(V))return V}var O=A.valueOf;if(Ni(O)){var V=O.call(A);if(!ge(V))return V}}throw new TypeError}function wu(A){return!!A}function mm(A){return""+A}function wt(A){var I=Se(A);return fn(I)?I:mm(I)}function bu(A){return Array.isArray?Array.isArray(A):A instanceof Object?A instanceof Array:Object.prototype.toString.call(A)==="[object Array]"}function Ni(A){return typeof A=="function"}function ku(A){return typeof A=="function"}function _m(A){switch(de(A)){case 3:return!0;case 4:return!0;default:return!1}}function Xo(A,I){return A===I||A!==A&&I!==I}function xu(A,I){var O=A[I];if(O!=null){if(!Ni(O))throw new TypeError;return O}}function Su(A){var I=xu(A,a);if(!Ni(I))throw new TypeError;var O=I.call(A);if(!ge(O))throw new TypeError;return O}function Au(A){return A.value}function Eu(A){var I=A.next();return I.done?!1:I}function Iu(A){var I=A.return;I&&I.call(A)}function Qo(A){var I=Object.getPrototypeOf(A);if(typeof A!="function"||A===h||I!==h)return I;var O=A.prototype,V=O&&Object.getPrototypeOf(O);if(V==null||V===Object.prototype)return I;var ee=V.constructor;return typeof ee!="function"||ee===A?I:ee}function ym(){var A;!H(_)&&typeof n.Reflect<"u"&&!(_ in n.Reflect)&&typeof n.Reflect.defineMetadata=="function"&&(A=bm(n.Reflect));var I,O,V,ee=new f,Ce={registerProvider:Ee,getProvider:D,setProvider:Z};return Ce;function Ee(Y){if(!Object.isExtensible(Ce))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case A===Y:break;case H(I):I=Y;break;case I===Y:break;case H(O):O=Y;break;case O===Y:break;default:V===void 0&&(V=new v),V.add(Y);break}}function oe(Y,ae){if(!H(I)){if(I.isProviderFor(Y,ae))return I;if(!H(O)){if(O.isProviderFor(Y,ae))return I;if(!H(V))for(var me=Su(V);;){var we=Eu(me);if(!we)return;var ut=Au(we);if(ut.isProviderFor(Y,ae))return Iu(me),ut}}}if(!H(A)&&A.isProviderFor(Y,ae))return A}function D(Y,ae){var me=ee.get(Y),we;return H(me)||(we=me.get(ae)),H(we)&&(we=oe(Y,ae),H(we)||(H(me)&&(me=new m,ee.set(Y,me)),me.set(ae,we))),we}function W(Y){if(H(Y))throw new TypeError;return I===Y||O===Y||!H(V)&&V.has(Y)}function Z(Y,ae,me){if(!W(me))throw new Error("Metadata provider not registered.");var we=D(Y,ae);if(we!==me){if(!H(we))return!1;var ut=ee.get(Y);H(ut)&&(ut=new m,ee.set(Y,ut)),ut.set(ae,me)}return!0}}function vm(){var A;return!H(_)&&ge(n.Reflect)&&Object.isExtensible(n.Reflect)&&(A=n.Reflect[_]),H(A)&&(A=ym()),!H(_)&&ge(n.Reflect)&&Object.isExtensible(n.Reflect)&&Object.defineProperty(n.Reflect,_,{enumerable:!1,configurable:!1,writable:!1,value:A}),A}function wm(A){var I=new f,O={isProviderFor:function(W,Z){var Y=I.get(W);return H(Y)?!1:Y.has(Z)},OrdinaryDefineOwnMetadata:Ee,OrdinaryHasOwnMetadata:ee,OrdinaryGetOwnMetadata:Ce,OrdinaryOwnMetadataKeys:oe,OrdinaryDeleteMetadata:D};return w.registerProvider(O),O;function V(W,Z,Y){var ae=I.get(W),me=!1;if(H(ae)){if(!Y)return;ae=new m,I.set(W,ae),me=!0}var we=ae.get(Z);if(H(we)){if(!Y)return;if(we=new m,ae.set(Z,we),!A.setProvider(W,Z,O))throw ae.delete(Z),me&&I.delete(W),new Error("Wrong provider for target.")}return we}function ee(W,Z,Y){var ae=V(Z,Y,!1);return H(ae)?!1:wu(ae.has(W))}function Ce(W,Z,Y){var ae=V(Z,Y,!1);if(!H(ae))return ae.get(W)}function Ee(W,Z,Y,ae){var me=V(Y,ae,!0);me.set(W,Z)}function oe(W,Z){var Y=[],ae=V(W,Z,!1);if(H(ae))return Y;for(var me=ae.keys(),we=Su(me),ut=0;;){var zu=Eu(we);if(!zu)return Y.length=ut,Y;var Am=Au(zu);try{Y[ut]=Am}catch(Em){try{Iu(we)}finally{throw Em}}ut++}}function D(W,Z,Y){var ae=V(Z,Y,!1);if(H(ae)||!ae.delete(W))return!1;if(ae.size===0){var me=I.get(Z);H(me)||(me.delete(Y),me.size===0&&I.delete(me))}return!0}}function bm(A){var I=A.defineMetadata,O=A.hasOwnMetadata,V=A.getOwnMetadata,ee=A.getOwnMetadataKeys,Ce=A.deleteMetadata,Ee=new f,oe={isProviderFor:function(D,W){var Z=Ee.get(D);return!H(Z)&&Z.has(W)?!0:ee(D,W).length?(H(Z)&&(Z=new v,Ee.set(D,Z)),Z.add(W),!0):!1},OrdinaryDefineOwnMetadata:I,OrdinaryHasOwnMetadata:O,OrdinaryGetOwnMetadata:V,OrdinaryOwnMetadataKeys:ee,OrdinaryDeleteMetadata:Ce};return oe}function Sr(A,I,O){var V=w.getProvider(A,I);if(!H(V))return V;if(O){if(w.setProvider(A,I,S))return S;throw new Error("Illegal state.")}}function km(){var A={},I=[],O=function(){function oe(D,W,Z){this._index=0,this._keys=D,this._values=W,this._selector=Z}return oe.prototype["@@iterator"]=function(){return this},oe.prototype[a]=function(){return this},oe.prototype.next=function(){var D=this._index;if(D>=0&&D<this._keys.length){var W=this._selector(this._keys[D],this._values[D]);return D+1>=this._keys.length?(this._index=-1,this._keys=I,this._values=I):this._index++,{value:W,done:!1}}return{value:void 0,done:!0}},oe.prototype.throw=function(D){throw this._index>=0&&(this._index=-1,this._keys=I,this._values=I),D},oe.prototype.return=function(D){return this._index>=0&&(this._index=-1,this._keys=I,this._values=I),{value:D,done:!0}},oe}(),V=function(){function oe(){this._keys=[],this._values=[],this._cacheKey=A,this._cacheIndex=-2}return Object.defineProperty(oe.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),oe.prototype.has=function(D){return this._find(D,!1)>=0},oe.prototype.get=function(D){var W=this._find(D,!1);return W>=0?this._values[W]:void 0},oe.prototype.set=function(D,W){var Z=this._find(D,!0);return this._values[Z]=W,this},oe.prototype.delete=function(D){var W=this._find(D,!1);if(W>=0){for(var Z=this._keys.length,Y=W+1;Y<Z;Y++)this._keys[Y-1]=this._keys[Y],this._values[Y-1]=this._values[Y];return this._keys.length--,this._values.length--,Xo(D,this._cacheKey)&&(this._cacheKey=A,this._cacheIndex=-2),!0}return!1},oe.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=A,this._cacheIndex=-2},oe.prototype.keys=function(){return new O(this._keys,this._values,ee)},oe.prototype.values=function(){return new O(this._keys,this._values,Ce)},oe.prototype.entries=function(){return new O(this._keys,this._values,Ee)},oe.prototype["@@iterator"]=function(){return this.entries()},oe.prototype[a]=function(){return this.entries()},oe.prototype._find=function(D,W){if(!Xo(this._cacheKey,D)){this._cacheIndex=-1;for(var Z=0;Z<this._keys.length;Z++)if(Xo(this._keys[Z],D)){this._cacheIndex=Z;break}}return this._cacheIndex<0&&W&&(this._cacheIndex=this._keys.length,this._keys.push(D),this._values.push(void 0)),this._cacheIndex},oe}();return V;function ee(oe,D){return oe}function Ce(oe,D){return D}function Ee(oe,D){return[oe,D]}}function xm(){var A=function(){function I(){this._map=new m}return Object.defineProperty(I.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),I.prototype.has=function(O){return this._map.has(O)},I.prototype.add=function(O){return this._map.set(O,O),this},I.prototype.delete=function(O){return this._map.delete(O)},I.prototype.clear=function(){this._map.clear()},I.prototype.keys=function(){return this._map.keys()},I.prototype.values=function(){return this._map.keys()},I.prototype.entries=function(){return this._map.entries()},I.prototype["@@iterator"]=function(){return this.keys()},I.prototype[a]=function(){return this.keys()},I}();return A}function Sm(){var A=16,I=p.create(),O=V();return function(){function D(){this._key=V()}return D.prototype.has=function(W){var Z=ee(W,!1);return Z!==void 0?p.has(Z,this._key):!1},D.prototype.get=function(W){var Z=ee(W,!1);return Z!==void 0?p.get(Z,this._key):void 0},D.prototype.set=function(W,Z){var Y=ee(W,!0);return Y[this._key]=Z,this},D.prototype.delete=function(W){var Z=ee(W,!1);return Z!==void 0?delete Z[this._key]:!1},D.prototype.clear=function(){this._key=V()},D}();function V(){var D;do D="@@WeakMap@@"+oe();while(p.has(I,D));return I[D]=!0,D}function ee(D,W){if(!r.call(D,O)){if(!W)return;Object.defineProperty(D,O,{value:p.create()})}return D[O]}function Ce(D,W){for(var Z=0;Z<W;++Z)D[Z]=Math.random()*255|0;return D}function Ee(D){if(typeof Uint8Array=="function"){var W=new Uint8Array(D);return typeof crypto<"u"?crypto.getRandomValues(W):typeof msCrypto<"u"?msCrypto.getRandomValues(W):Ce(W,D),W}return Ce(new Array(D),D)}function oe(){var D=Ee(A);D[6]=D[6]&79|64,D[8]=D[8]&191|128;for(var W="",Z=0;Z<A;++Z){var Y=D[Z];(Z===4||Z===6||Z===8)&&(W+="-"),Y<16&&(W+="0"),W+=Y.toString(16).toLowerCase()}return W}}function ea(A){return A.__=void 0,delete A.__,A}})})(Yu||(Yu={}));/*!
43
43
  * MIT License
44
44
  *
45
45
  * Copyright (c) 2017-2022 Peculiar Ventures, LLC
@@ -62,9 +62,9 @@ and limitations under the License.
62
62
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
63
63
  * SOFTWARE.
64
64
  *
65
- */const py="[object ArrayBuffer]";class M{static isArrayBuffer(e){return Object.prototype.toString.call(e)===py}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,n){if(e.constructor===n)return e;if(this.isArrayBuffer(e))return new n(e);if(this.isArrayBufferView(e))return new n(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(e,n){const r=M.toUint8Array(e),i=M.toUint8Array(n);if(r.length!==i.byteLength)return!1;for(let s=0;s<r.length;s++)if(r[s]!==i[s])return!1;return!0}static concat(...e){let n;Array.isArray(e[0])&&!(e[1]instanceof Function)||Array.isArray(e[0])&&e[1]instanceof Function?n=e[0]:e[e.length-1]instanceof Function?n=e.slice(0,e.length-1):n=e;let r=0;for(const a of n)r+=a.byteLength;const i=new Uint8Array(r);let s=0;for(const a of n){const c=this.toUint8Array(a);i.set(c,s),s+=c.length}return e[e.length-1]instanceof Function?this.toView(i,e[e.length-1]):i.buffer}}const na="string",fy=/^[0-9a-f]+$/i,hy=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,gy=/^[a-zA-Z0-9-_]+$/;class Yu{static fromString(e){const n=unescape(encodeURIComponent(e)),r=new Uint8Array(n.length);for(let i=0;i<n.length;i++)r[i]=n.charCodeAt(i);return r.buffer}static toString(e){const n=M.toUint8Array(e);let r="";for(let s=0;s<n.length;s++)r+=String.fromCharCode(n[s]);return decodeURIComponent(escape(r))}}class bt{static toString(e,n=!1){const r=M.toArrayBuffer(e),i=new DataView(r);let s="";for(let a=0;a<r.byteLength;a+=2){const c=i.getUint16(a,n);s+=String.fromCharCode(c)}return s}static fromString(e,n=!1){const r=new ArrayBuffer(e.length*2),i=new DataView(r);for(let s=0;s<e.length;s++)i.setUint16(s*2,e.charCodeAt(s),n);return r}}class J{static isHex(e){return typeof e===na&&fy.test(e)}static isBase64(e){return typeof e===na&&hy.test(e)}static isBase64Url(e){return typeof e===na&&gy.test(e)}static ToString(e,n="utf8"){const r=M.toUint8Array(e);switch(n.toLowerCase()){case"utf8":return this.ToUtf8String(r);case"binary":return this.ToBinary(r);case"hex":return this.ToHex(r);case"base64":return this.ToBase64(r);case"base64url":return this.ToBase64Url(r);case"utf16le":return bt.toString(r,!0);case"utf16":case"utf16be":return bt.toString(r);default:throw new Error(`Unknown type of encoding '${n}'`)}}static FromString(e,n="utf8"){if(!e)return new ArrayBuffer(0);switch(n.toLowerCase()){case"utf8":return this.FromUtf8String(e);case"binary":return this.FromBinary(e);case"hex":return this.FromHex(e);case"base64":return this.FromBase64(e);case"base64url":return this.FromBase64Url(e);case"utf16le":return bt.fromString(e,!0);case"utf16":case"utf16be":return bt.fromString(e);default:throw new Error(`Unknown type of encoding '${n}'`)}}static ToBase64(e){const n=M.toUint8Array(e);if(typeof btoa<"u"){const r=this.ToString(n,"binary");return btoa(r)}else return Buffer.from(n).toString("base64")}static FromBase64(e){const n=this.formatString(e);if(!n)return new ArrayBuffer(0);if(!J.isBase64(n))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob<"u"?this.FromBinary(atob(n)):new Uint8Array(Buffer.from(n,"base64")).buffer}static FromBase64Url(e){const n=this.formatString(e);if(!n)return new ArrayBuffer(0);if(!J.isBase64Url(n))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(n.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(e,n=J.DEFAULT_UTF8_ENCODING){switch(n){case"ascii":return this.FromBinary(e);case"utf8":return Yu.fromString(e);case"utf16":case"utf16be":return bt.fromString(e);case"utf16le":case"usc2":return bt.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${n}'`)}}static ToUtf8String(e,n=J.DEFAULT_UTF8_ENCODING){switch(n){case"ascii":return this.ToBinary(e);case"utf8":return Yu.toString(e);case"utf16":case"utf16be":return bt.toString(e);case"utf16le":case"usc2":return bt.toString(e,!0);default:throw new Error(`Unknown type of encoding '${n}'`)}}static FromBinary(e){const n=e.length,r=new Uint8Array(n);for(let i=0;i<n;i++)r[i]=e.charCodeAt(i);return r.buffer}static ToBinary(e){const n=M.toUint8Array(e);let r="";for(let i=0;i<n.length;i++)r+=String.fromCharCode(n[i]);return r}static ToHex(e){const n=M.toUint8Array(e);let r="";const i=n.length;for(let s=0;s<i;s++){const a=n[s];a<16&&(r+="0"),r+=a.toString(16)}return r}static FromHex(e){let n=this.formatString(e);if(!n)return new ArrayBuffer(0);if(!J.isHex(n))throw new TypeError("Argument 'hexString' is not HEX encoded");n.length%2&&(n=`0${n}`);const r=new Uint8Array(n.length/2);for(let i=0;i<n.length;i=i+2){const s=n.slice(i,i+2);r[i/2]=parseInt(s,16)}return r.buffer}static ToUtf16String(e,n=!1){return bt.toString(e,n)}static FromUtf16String(e,n=!1){return bt.fromString(e,n)}static Base64Padding(e){const n=4-e.length%4;if(n<4)for(let r=0;r<n;r++)e+="=";return e}static formatString(e){return(e==null?void 0:e.replace(/[\n\r\t ]/g,""))||""}}J.DEFAULT_UTF8_ENCODING="utf8";function my(...t){const e=t.map(i=>i.byteLength).reduce((i,s)=>i+s),n=new Uint8Array(e);let r=0;return t.map(i=>new Uint8Array(i)).forEach(i=>{for(const s of i)n[r++]=s}),n.buffer}function Ff(t,e){if(!(t&&e)||t.byteLength!==e.byteLength)return!1;const n=new Uint8Array(t),r=new Uint8Array(e);for(let i=0;i<t.byteLength;i++)if(n[i]!==r[i])return!1;return!0}/*!
65
+ */const hy="[object ArrayBuffer]";class M{static isArrayBuffer(e){return Object.prototype.toString.call(e)===hy}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,n){if(e.constructor===n)return e;if(this.isArrayBuffer(e))return new n(e);if(this.isArrayBufferView(e))return new n(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(e,n){const r=M.toUint8Array(e),i=M.toUint8Array(n);if(r.length!==i.byteLength)return!1;for(let s=0;s<r.length;s++)if(r[s]!==i[s])return!1;return!0}static concat(...e){let n;Array.isArray(e[0])&&!(e[1]instanceof Function)||Array.isArray(e[0])&&e[1]instanceof Function?n=e[0]:e[e.length-1]instanceof Function?n=e.slice(0,e.length-1):n=e;let r=0;for(const a of n)r+=a.byteLength;const i=new Uint8Array(r);let s=0;for(const a of n){const c=this.toUint8Array(a);i.set(c,s),s+=c.length}return e[e.length-1]instanceof Function?this.toView(i,e[e.length-1]):i.buffer}}const na="string",gy=/^[0-9a-f]+$/i,my=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,_y=/^[a-zA-Z0-9-_]+$/;class Xu{static fromString(e){const n=unescape(encodeURIComponent(e)),r=new Uint8Array(n.length);for(let i=0;i<n.length;i++)r[i]=n.charCodeAt(i);return r.buffer}static toString(e){const n=M.toUint8Array(e);let r="";for(let s=0;s<n.length;s++)r+=String.fromCharCode(n[s]);return decodeURIComponent(escape(r))}}class bt{static toString(e,n=!1){const r=M.toArrayBuffer(e),i=new DataView(r);let s="";for(let a=0;a<r.byteLength;a+=2){const c=i.getUint16(a,n);s+=String.fromCharCode(c)}return s}static fromString(e,n=!1){const r=new ArrayBuffer(e.length*2),i=new DataView(r);for(let s=0;s<e.length;s++)i.setUint16(s*2,e.charCodeAt(s),n);return r}}class J{static isHex(e){return typeof e===na&&gy.test(e)}static isBase64(e){return typeof e===na&&my.test(e)}static isBase64Url(e){return typeof e===na&&_y.test(e)}static ToString(e,n="utf8"){const r=M.toUint8Array(e);switch(n.toLowerCase()){case"utf8":return this.ToUtf8String(r);case"binary":return this.ToBinary(r);case"hex":return this.ToHex(r);case"base64":return this.ToBase64(r);case"base64url":return this.ToBase64Url(r);case"utf16le":return bt.toString(r,!0);case"utf16":case"utf16be":return bt.toString(r);default:throw new Error(`Unknown type of encoding '${n}'`)}}static FromString(e,n="utf8"){if(!e)return new ArrayBuffer(0);switch(n.toLowerCase()){case"utf8":return this.FromUtf8String(e);case"binary":return this.FromBinary(e);case"hex":return this.FromHex(e);case"base64":return this.FromBase64(e);case"base64url":return this.FromBase64Url(e);case"utf16le":return bt.fromString(e,!0);case"utf16":case"utf16be":return bt.fromString(e);default:throw new Error(`Unknown type of encoding '${n}'`)}}static ToBase64(e){const n=M.toUint8Array(e);if(typeof btoa<"u"){const r=this.ToString(n,"binary");return btoa(r)}else return Buffer.from(n).toString("base64")}static FromBase64(e){const n=this.formatString(e);if(!n)return new ArrayBuffer(0);if(!J.isBase64(n))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob<"u"?this.FromBinary(atob(n)):new Uint8Array(Buffer.from(n,"base64")).buffer}static FromBase64Url(e){const n=this.formatString(e);if(!n)return new ArrayBuffer(0);if(!J.isBase64Url(n))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(n.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(e,n=J.DEFAULT_UTF8_ENCODING){switch(n){case"ascii":return this.FromBinary(e);case"utf8":return Xu.fromString(e);case"utf16":case"utf16be":return bt.fromString(e);case"utf16le":case"usc2":return bt.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${n}'`)}}static ToUtf8String(e,n=J.DEFAULT_UTF8_ENCODING){switch(n){case"ascii":return this.ToBinary(e);case"utf8":return Xu.toString(e);case"utf16":case"utf16be":return bt.toString(e);case"utf16le":case"usc2":return bt.toString(e,!0);default:throw new Error(`Unknown type of encoding '${n}'`)}}static FromBinary(e){const n=e.length,r=new Uint8Array(n);for(let i=0;i<n;i++)r[i]=e.charCodeAt(i);return r.buffer}static ToBinary(e){const n=M.toUint8Array(e);let r="";for(let i=0;i<n.length;i++)r+=String.fromCharCode(n[i]);return r}static ToHex(e){const n=M.toUint8Array(e);let r="";const i=n.length;for(let s=0;s<i;s++){const a=n[s];a<16&&(r+="0"),r+=a.toString(16)}return r}static FromHex(e){let n=this.formatString(e);if(!n)return new ArrayBuffer(0);if(!J.isHex(n))throw new TypeError("Argument 'hexString' is not HEX encoded");n.length%2&&(n=`0${n}`);const r=new Uint8Array(n.length/2);for(let i=0;i<n.length;i=i+2){const s=n.slice(i,i+2);r[i/2]=parseInt(s,16)}return r.buffer}static ToUtf16String(e,n=!1){return bt.toString(e,n)}static FromUtf16String(e,n=!1){return bt.fromString(e,n)}static Base64Padding(e){const n=4-e.length%4;if(n<4)for(let r=0;r<n;r++)e+="=";return e}static formatString(e){return(e==null?void 0:e.replace(/[\n\r\t ]/g,""))||""}}J.DEFAULT_UTF8_ENCODING="utf8";function yy(...t){const e=t.map(i=>i.byteLength).reduce((i,s)=>i+s),n=new Uint8Array(e);let r=0;return t.map(i=>new Uint8Array(i)).forEach(i=>{for(const s of i)n[r++]=s}),n.buffer}function Kf(t,e){if(!(t&&e)||t.byteLength!==e.byteLength)return!1;const n=new Uint8Array(t),r=new Uint8Array(e);for(let i=0;i<t.byteLength;i++)if(n[i]!==r[i])return!1;return!0}/*!
66
66
  Copyright (c) Peculiar Ventures, LLC
67
- */function Zn(t,e){let n=0;if(t.length===1)return t[0];for(let r=t.length-1;r>=0;r--)n+=t[t.length-1-r]*Math.pow(2,e*r);return n}function xn(t,e,n=-1){const r=n;let i=t,s=0,a=Math.pow(2,e);for(let c=1;c<8;c++){if(t<a){let l;if(r<0)l=new ArrayBuffer(c),s=c;else{if(r<c)return new ArrayBuffer(0);l=new ArrayBuffer(r),s=r}const u=new Uint8Array(l);for(let p=c-1;p>=0;p--){const h=Math.pow(2,p*e);u[s-p-1]=Math.floor(i/h),i-=u[s-p-1]*h}return l}a*=Math.pow(2,e)}return new ArrayBuffer(0)}function $a(...t){let e=0,n=0;for(const s of t)e+=s.length;const r=new ArrayBuffer(e),i=new Uint8Array(r);for(const s of t)i.set(s,n),n+=s.length;return i}function Kf(){const t=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){const c=t[0]===255&&t[1]&128,l=t[0]===0&&(t[1]&128)===0;(c||l)&&this.warnings.push("Needlessly long format")}const e=new ArrayBuffer(this.valueHex.byteLength),n=new Uint8Array(e);for(let c=0;c<this.valueHex.byteLength;c++)n[c]=0;n[0]=t[0]&128;const r=Zn(n,8),i=new ArrayBuffer(this.valueHex.byteLength),s=new Uint8Array(i);for(let c=0;c<this.valueHex.byteLength;c++)s[c]=t[c];return s[0]&=127,Zn(s,8)-r}function _y(t){const e=t<0?t*-1:t;let n=128;for(let r=1;r<8;r++){if(e<=n){if(t<0){const a=n-e,c=xn(a,8,r),l=new Uint8Array(c);return l[0]|=128,c}let i=xn(e,8,r),s=new Uint8Array(i);if(s[0]&128){const a=i.slice(0),c=new Uint8Array(a);i=new ArrayBuffer(i.byteLength+1),s=new Uint8Array(i);for(let l=0;l<a.byteLength;l++)s[l+1]=c[l];s[0]=0}return i}n*=Math.pow(2,8)}return new ArrayBuffer(0)}function yy(t,e){if(t.byteLength!==e.byteLength)return!1;const n=new Uint8Array(t),r=new Uint8Array(e);for(let i=0;i<n.length;i++)if(n[i]!==r[i])return!1;return!0}function Ye(t,e){const n=t.toString(10);if(e<n.length)return"";const r=e-n.length,i=new Array(r);for(let a=0;a<r;a++)i[a]="0";return i.join("").concat(n)}/*!
67
+ */function Zn(t,e){let n=0;if(t.length===1)return t[0];for(let r=t.length-1;r>=0;r--)n+=t[t.length-1-r]*Math.pow(2,e*r);return n}function xn(t,e,n=-1){const r=n;let i=t,s=0,a=Math.pow(2,e);for(let c=1;c<8;c++){if(t<a){let l;if(r<0)l=new ArrayBuffer(c),s=c;else{if(r<c)return new ArrayBuffer(0);l=new ArrayBuffer(r),s=r}const u=new Uint8Array(l);for(let p=c-1;p>=0;p--){const h=Math.pow(2,p*e);u[s-p-1]=Math.floor(i/h),i-=u[s-p-1]*h}return l}a*=Math.pow(2,e)}return new ArrayBuffer(0)}function $a(...t){let e=0,n=0;for(const s of t)e+=s.length;const r=new ArrayBuffer(e),i=new Uint8Array(r);for(const s of t)i.set(s,n),n+=s.length;return i}function Wf(){const t=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){const c=t[0]===255&&t[1]&128,l=t[0]===0&&(t[1]&128)===0;(c||l)&&this.warnings.push("Needlessly long format")}const e=new ArrayBuffer(this.valueHex.byteLength),n=new Uint8Array(e);for(let c=0;c<this.valueHex.byteLength;c++)n[c]=0;n[0]=t[0]&128;const r=Zn(n,8),i=new ArrayBuffer(this.valueHex.byteLength),s=new Uint8Array(i);for(let c=0;c<this.valueHex.byteLength;c++)s[c]=t[c];return s[0]&=127,Zn(s,8)-r}function vy(t){const e=t<0?t*-1:t;let n=128;for(let r=1;r<8;r++){if(e<=n){if(t<0){const a=n-e,c=xn(a,8,r),l=new Uint8Array(c);return l[0]|=128,c}let i=xn(e,8,r),s=new Uint8Array(i);if(s[0]&128){const a=i.slice(0),c=new Uint8Array(a);i=new ArrayBuffer(i.byteLength+1),s=new Uint8Array(i);for(let l=0;l<a.byteLength;l++)s[l+1]=c[l];s[0]=0}return i}n*=Math.pow(2,8)}return new ArrayBuffer(0)}function wy(t,e){if(t.byteLength!==e.byteLength)return!1;const n=new Uint8Array(t),r=new Uint8Array(e);for(let i=0;i<n.length;i++)if(n[i]!==r[i])return!1;return!0}function Ye(t,e){const n=t.toString(10);if(e<n.length)return"";const r=e-n.length,i=new Array(r);for(let a=0;a<r;a++)i[a]="0";return i.join("").concat(n)}/*!
68
68
  * Copyright (c) 2014, GMO GlobalSign
69
69
  * Copyright (c) 2015-2022, Peculiar Ventures
70
70
  * All rights reserved.
@@ -96,11 +96,11 @@ and limitations under the License.
96
96
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
97
97
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
98
98
  *
99
- */function us(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function fl(t){let e=0,n=0;for(let i=0;i<t.length;i++){const s=t[i];e+=s.byteLength}const r=new Uint8Array(e);for(let i=0;i<t.length;i++){const s=t[i];r.set(new Uint8Array(s),n),n+=s.byteLength}return r.buffer}function Mt(t,e,n,r){return e instanceof Uint8Array?e.byteLength?n<0?(t.error="Wrong parameter: inputOffset less than zero",!1):r<0?(t.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-n-r<0?(t.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(t.error="Wrong parameter: inputBuffer has zero length",!1):(t.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}class so{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return fl(this.items)}}const zr=[new Uint8Array([1])],Xu="0123456789",ra="name",Qu="valueHexView",vy="isHexOnly",wy="idBlock",by="tagClass",ky="tagNumber",xy="isConstructed",Sy="fromBER",Ay="toBER",Ey="local",Fe="",yt=new ArrayBuffer(0),oo=new Uint8Array(0),Mr="EndOfContent",Wf="OCTET STRING",Gf="BIT STRING";function Nt(t){var e;return e=class extends t{constructor(...r){var i;super(...r);const s=r[0]||{};this.isHexOnly=(i=s.isHexOnly)!==null&&i!==void 0?i:!1,this.valueHexView=s.valueHex?M.toUint8Array(s.valueHex):oo}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(r){this.valueHexView=new Uint8Array(r)}fromBER(r,i,s){const a=r instanceof ArrayBuffer?new Uint8Array(r):r;if(!Mt(this,a,i,s))return-1;const c=i+s;return this.valueHexView=a.subarray(i,c),this.valueHexView.length?(this.blockLength=s,c):(this.warnings.push("Zero buffer length"),i)}toBER(r=!1){return this.isHexOnly?r?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",yt)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:J.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}class Pn{constructor({blockLength:e=0,error:n=Fe,warnings:r=[],valueBeforeDecode:i=oo}={}){this.blockLength=e,this.error=n,this.warnings=r,this.valueBeforeDecodeView=M.toUint8Array(i)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:J.ToHex(this.valueBeforeDecodeView)}}}Pn.NAME="baseBlock";class Me extends Pn{fromBER(e,n,r){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}}Me.NAME="valueBlock";class Jf extends Nt(Pn){constructor({idBlock:e={}}={}){var n,r,i,s;super(),e?(this.isHexOnly=(n=e.isHexOnly)!==null&&n!==void 0?n:!1,this.valueHexView=e.valueHex?M.toUint8Array(e.valueHex):oo,this.tagClass=(r=e.tagClass)!==null&&r!==void 0?r:-1,this.tagNumber=(i=e.tagNumber)!==null&&i!==void 0?i:-1,this.isConstructed=(s=e.isConstructed)!==null&&s!==void 0?s:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let n=0;switch(this.tagClass){case 1:n|=0;break;case 2:n|=64;break;case 3:n|=128;break;case 4:n|=192;break;default:return this.error="Unknown tag class",yt}if(this.isConstructed&&(n|=32),this.tagNumber<31&&!this.isHexOnly){const i=new Uint8Array(1);if(!e){let s=this.tagNumber;s&=31,n|=s,i[0]=n}return i.buffer}if(!this.isHexOnly){const i=xn(this.tagNumber,7),s=new Uint8Array(i),a=i.byteLength,c=new Uint8Array(a+1);if(c[0]=n|31,!e){for(let l=0;l<a-1;l++)c[l+1]=s[l]|128;c[a]=s[a-1]}return c.buffer}const r=new Uint8Array(this.valueHexView.byteLength+1);if(r[0]=n|31,!e){const i=this.valueHexView;for(let s=0;s<i.length-1;s++)r[s+1]=i[s]|128;r[this.valueHexView.byteLength]=i[i.length-1]}return r.buffer}fromBER(e,n,r){const i=M.toUint8Array(e);if(!Mt(this,i,n,r))return-1;const s=i.subarray(n,n+r);if(s.length===0)return this.error="Zero buffer length",-1;switch(s[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(s[0]&32)===32,this.isHexOnly=!1;const c=s[0]&31;if(c!==31)this.tagNumber=c,this.blockLength=1;else{let l=1,u=this.valueHexView=new Uint8Array(255),p=255;for(;s[l]&128;){if(u[l-1]=s[l]&127,l++,l>=s.length)return this.error="End of input reached before message was fully decoded",-1;if(l===p){p+=255;const m=new Uint8Array(p);for(let v=0;v<u.length;v++)m[v]=u[v];u=this.valueHexView=new Uint8Array(p)}}this.blockLength=l+1,u[l-1]=s[l]&127;const h=new Uint8Array(l);for(let m=0;m<l;m++)h[m]=u[m];u=this.valueHexView=new Uint8Array(l),u.set(h),this.blockLength<=9?this.tagNumber=Zn(u,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return n+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}}Jf.NAME="identificationBlock";class Zf extends Pn{constructor({lenBlock:e={}}={}){var n,r,i;super(),this.isIndefiniteForm=(n=e.isIndefiniteForm)!==null&&n!==void 0?n:!1,this.longFormUsed=(r=e.longFormUsed)!==null&&r!==void 0?r:!1,this.length=(i=e.length)!==null&&i!==void 0?i:0}fromBER(e,n,r){const i=M.toUint8Array(e);if(!Mt(this,i,n,r))return-1;const s=i.subarray(n,n+r);if(s.length===0)return this.error="Zero buffer length",-1;if(s[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=s[0]===128,this.isIndefiniteForm)return this.blockLength=1,n+this.blockLength;if(this.longFormUsed=!!(s[0]&128),this.longFormUsed===!1)return this.length=s[0],this.blockLength=1,n+this.blockLength;const a=s[0]&127;if(a>8)return this.error="Too big integer",-1;if(a+1>s.length)return this.error="End of input reached before message was fully decoded",-1;const c=n+1,l=i.subarray(c,c+a);return l[a-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=Zn(l,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=a+1,n+this.blockLength}toBER(e=!1){let n,r;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return n=new ArrayBuffer(1),e===!1&&(r=new Uint8Array(n),r[0]=128),n;if(this.longFormUsed){const i=xn(this.length,8);if(i.byteLength>127)return this.error="Too big length",yt;if(n=new ArrayBuffer(i.byteLength+1),e)return n;const s=new Uint8Array(i);r=new Uint8Array(n),r[0]=i.byteLength|128;for(let a=0;a<i.byteLength;a++)r[a+1]=s[a];return n}return n=new ArrayBuffer(1),e===!1&&(r=new Uint8Array(n),r[0]=this.length),n}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}}Zf.NAME="lengthBlock";const K={};class Be extends Pn{constructor({name:e=Fe,optional:n=!1,primitiveSchema:r,...i}={},s){super(i),this.name=e,this.optional=n,r&&(this.primitiveSchema=r),this.idBlock=new Jf(i),this.lenBlock=new Zf(i),this.valueBlock=s?new s(i):new Me(i)}fromBER(e,n,r){const i=this.valueBlock.fromBER(e,n,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}toBER(e,n){const r=n||new so;n||Yf(this);const i=this.idBlock.toBER(e);if(r.write(i),this.lenBlock.isIndefiniteForm)r.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,r),r.write(new ArrayBuffer(2));else{const s=this.valueBlock.toBER(e);this.lenBlock.length=s.byteLength;const a=this.lenBlock.toBER(e);r.write(a),r.write(s)}return n?yt:r.final()}toJSON(){const e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return e==="ascii"?this.onAsciiEncoding():J.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${J.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;const n=this.toBER(),r=e.toBER();return yy(n,r)}}Be.NAME="BaseBlock";function Yf(t){if(t instanceof K.Constructed)for(const e of t.valueBlock.value)Yf(e)&&(t.lenBlock.isIndefiniteForm=!0);return!!t.lenBlock.isIndefiniteForm}class hl extends Be{constructor({value:e=Fe,...n}={},r){super(n,r),e&&this.fromString(e)}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}fromBER(e,n,r){const i=this.valueBlock.fromBER(e,n,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}}hl.NAME="BaseStringBlock";class Xf extends Nt(Me){constructor({isHexOnly:e=!0,...n}={}){super(n),this.isHexOnly=e}}Xf.NAME="PrimitiveValueBlock";var Qf;class oi extends Be{constructor(e={}){super(e,Xf),this.idBlock.isConstructed=!1}}Qf=oi;K.Primitive=Qf;oi.NAME="PRIMITIVE";function Iy(t,e){if(t instanceof e)return t;const n=new e;return n.idBlock=t.idBlock,n.lenBlock=t.lenBlock,n.warnings=t.warnings,n.valueBeforeDecodeView=t.valueBeforeDecodeView,n}function pr(t,e=0,n=t.length){const r=e;let i=new Be({},Me);const s=new Pn;if(!Mt(s,t,e,n))return i.error=s.error,{offset:-1,result:i};if(!t.subarray(e,e+n).length)return i.error="Zero buffer length",{offset:-1,result:i};let c=i.idBlock.fromBER(t,e,n);if(i.idBlock.warnings.length&&i.warnings.concat(i.idBlock.warnings),c===-1)return i.error=i.idBlock.error,{offset:-1,result:i};if(e=c,n-=i.idBlock.blockLength,c=i.lenBlock.fromBER(t,e,n),i.lenBlock.warnings.length&&i.warnings.concat(i.lenBlock.warnings),c===-1)return i.error=i.lenBlock.error,{offset:-1,result:i};if(e=c,n-=i.lenBlock.blockLength,!i.idBlock.isConstructed&&i.lenBlock.isIndefiniteForm)return i.error="Indefinite length form used for primitive encoding form",{offset:-1,result:i};let l=Be;switch(i.idBlock.tagClass){case 1:if(i.idBlock.tagNumber>=37&&i.idBlock.isHexOnly===!1)return i.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:i};switch(i.idBlock.tagNumber){case 0:if(i.idBlock.isConstructed&&i.lenBlock.length>0)return i.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:i};l=K.EndOfContent;break;case 1:l=K.Boolean;break;case 2:l=K.Integer;break;case 3:l=K.BitString;break;case 4:l=K.OctetString;break;case 5:l=K.Null;break;case 6:l=K.ObjectIdentifier;break;case 10:l=K.Enumerated;break;case 12:l=K.Utf8String;break;case 13:l=K.RelativeObjectIdentifier;break;case 14:l=K.TIME;break;case 15:return i.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:i};case 16:l=K.Sequence;break;case 17:l=K.Set;break;case 18:l=K.NumericString;break;case 19:l=K.PrintableString;break;case 20:l=K.TeletexString;break;case 21:l=K.VideotexString;break;case 22:l=K.IA5String;break;case 23:l=K.UTCTime;break;case 24:l=K.GeneralizedTime;break;case 25:l=K.GraphicString;break;case 26:l=K.VisibleString;break;case 27:l=K.GeneralString;break;case 28:l=K.UniversalString;break;case 29:l=K.CharacterString;break;case 30:l=K.BmpString;break;case 31:l=K.DATE;break;case 32:l=K.TimeOfDay;break;case 33:l=K.DateTime;break;case 34:l=K.Duration;break;default:{const u=i.idBlock.isConstructed?new K.Constructed:new K.Primitive;u.idBlock=i.idBlock,u.lenBlock=i.lenBlock,u.warnings=i.warnings,i=u}}break;case 2:case 3:case 4:default:l=i.idBlock.isConstructed?K.Constructed:K.Primitive}return i=Iy(i,l),c=i.fromBER(t,e,i.lenBlock.isIndefiniteForm?n:i.lenBlock.length),i.valueBeforeDecodeView=t.subarray(r,r+i.blockLength),{offset:c,result:i}}function Kn(t){if(!t.byteLength){const e=new Be({},Me);return e.error="Input buffer has zero length",{offset:-1,result:e}}return pr(M.toUint8Array(t).slice(),0,t.byteLength)}function zy(t,e){return t?1:e}class Gt extends Me{constructor({value:e=[],isIndefiniteForm:n=!1,...r}={}){super(r),this.value=e,this.isIndefiniteForm=n}fromBER(e,n,r){const i=M.toUint8Array(e);if(!Mt(this,i,n,r))return-1;if(this.valueBeforeDecodeView=i.subarray(n,n+r),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),n;let s=n;for(;zy(this.isIndefiniteForm,r)>0;){const a=pr(i,s,r);if(a.offset===-1)return this.error=a.result.error,this.warnings.concat(a.result.warnings),-1;if(s=a.offset,this.blockLength+=a.result.blockLength,r-=a.result.blockLength,this.value.push(a.result),this.isIndefiniteForm&&a.result.constructor.NAME===Mr)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===Mr?this.value.pop():this.warnings.push("No EndOfContent block encoded")),s}toBER(e,n){const r=n||new so;for(let i=0;i<this.value.length;i++)this.value[i].toBER(e,r);return n?yt:r.final()}toJSON(){const e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(const n of this.value)e.value.push(n.toJSON());return e}}Gt.NAME="ConstructedValueBlock";var eh;class Ke extends Be{constructor(e={}){super(e,Gt),this.idBlock.isConstructed=!0}fromBER(e,n,r){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;const i=this.valueBlock.fromBER(e,n,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}onAsciiEncoding(){const e=[];for(const r of this.valueBlock.value)e.push(r.toString("ascii").split(`
99
+ */function us(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function fl(t){let e=0,n=0;for(let i=0;i<t.length;i++){const s=t[i];e+=s.byteLength}const r=new Uint8Array(e);for(let i=0;i<t.length;i++){const s=t[i];r.set(new Uint8Array(s),n),n+=s.byteLength}return r.buffer}function Mt(t,e,n,r){return e instanceof Uint8Array?e.byteLength?n<0?(t.error="Wrong parameter: inputOffset less than zero",!1):r<0?(t.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-n-r<0?(t.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(t.error="Wrong parameter: inputBuffer has zero length",!1):(t.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}class so{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return fl(this.items)}}const zr=[new Uint8Array([1])],Qu="0123456789",ra="name",ed="valueHexView",by="isHexOnly",ky="idBlock",xy="tagClass",Sy="tagNumber",Ay="isConstructed",Ey="fromBER",Iy="toBER",zy="local",Fe="",yt=new ArrayBuffer(0),oo=new Uint8Array(0),Mr="EndOfContent",Gf="OCTET STRING",Jf="BIT STRING";function Nt(t){var e;return e=class extends t{constructor(...r){var i;super(...r);const s=r[0]||{};this.isHexOnly=(i=s.isHexOnly)!==null&&i!==void 0?i:!1,this.valueHexView=s.valueHex?M.toUint8Array(s.valueHex):oo}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(r){this.valueHexView=new Uint8Array(r)}fromBER(r,i,s){const a=r instanceof ArrayBuffer?new Uint8Array(r):r;if(!Mt(this,a,i,s))return-1;const c=i+s;return this.valueHexView=a.subarray(i,c),this.valueHexView.length?(this.blockLength=s,c):(this.warnings.push("Zero buffer length"),i)}toBER(r=!1){return this.isHexOnly?r?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",yt)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:J.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}class Pn{constructor({blockLength:e=0,error:n=Fe,warnings:r=[],valueBeforeDecode:i=oo}={}){this.blockLength=e,this.error=n,this.warnings=r,this.valueBeforeDecodeView=M.toUint8Array(i)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:J.ToHex(this.valueBeforeDecodeView)}}}Pn.NAME="baseBlock";class Me extends Pn{fromBER(e,n,r){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}}Me.NAME="valueBlock";class Zf extends Nt(Pn){constructor({idBlock:e={}}={}){var n,r,i,s;super(),e?(this.isHexOnly=(n=e.isHexOnly)!==null&&n!==void 0?n:!1,this.valueHexView=e.valueHex?M.toUint8Array(e.valueHex):oo,this.tagClass=(r=e.tagClass)!==null&&r!==void 0?r:-1,this.tagNumber=(i=e.tagNumber)!==null&&i!==void 0?i:-1,this.isConstructed=(s=e.isConstructed)!==null&&s!==void 0?s:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let n=0;switch(this.tagClass){case 1:n|=0;break;case 2:n|=64;break;case 3:n|=128;break;case 4:n|=192;break;default:return this.error="Unknown tag class",yt}if(this.isConstructed&&(n|=32),this.tagNumber<31&&!this.isHexOnly){const i=new Uint8Array(1);if(!e){let s=this.tagNumber;s&=31,n|=s,i[0]=n}return i.buffer}if(!this.isHexOnly){const i=xn(this.tagNumber,7),s=new Uint8Array(i),a=i.byteLength,c=new Uint8Array(a+1);if(c[0]=n|31,!e){for(let l=0;l<a-1;l++)c[l+1]=s[l]|128;c[a]=s[a-1]}return c.buffer}const r=new Uint8Array(this.valueHexView.byteLength+1);if(r[0]=n|31,!e){const i=this.valueHexView;for(let s=0;s<i.length-1;s++)r[s+1]=i[s]|128;r[this.valueHexView.byteLength]=i[i.length-1]}return r.buffer}fromBER(e,n,r){const i=M.toUint8Array(e);if(!Mt(this,i,n,r))return-1;const s=i.subarray(n,n+r);if(s.length===0)return this.error="Zero buffer length",-1;switch(s[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(s[0]&32)===32,this.isHexOnly=!1;const c=s[0]&31;if(c!==31)this.tagNumber=c,this.blockLength=1;else{let l=1,u=this.valueHexView=new Uint8Array(255),p=255;for(;s[l]&128;){if(u[l-1]=s[l]&127,l++,l>=s.length)return this.error="End of input reached before message was fully decoded",-1;if(l===p){p+=255;const m=new Uint8Array(p);for(let v=0;v<u.length;v++)m[v]=u[v];u=this.valueHexView=new Uint8Array(p)}}this.blockLength=l+1,u[l-1]=s[l]&127;const h=new Uint8Array(l);for(let m=0;m<l;m++)h[m]=u[m];u=this.valueHexView=new Uint8Array(l),u.set(h),this.blockLength<=9?this.tagNumber=Zn(u,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return n+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}}Zf.NAME="identificationBlock";class Yf extends Pn{constructor({lenBlock:e={}}={}){var n,r,i;super(),this.isIndefiniteForm=(n=e.isIndefiniteForm)!==null&&n!==void 0?n:!1,this.longFormUsed=(r=e.longFormUsed)!==null&&r!==void 0?r:!1,this.length=(i=e.length)!==null&&i!==void 0?i:0}fromBER(e,n,r){const i=M.toUint8Array(e);if(!Mt(this,i,n,r))return-1;const s=i.subarray(n,n+r);if(s.length===0)return this.error="Zero buffer length",-1;if(s[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=s[0]===128,this.isIndefiniteForm)return this.blockLength=1,n+this.blockLength;if(this.longFormUsed=!!(s[0]&128),this.longFormUsed===!1)return this.length=s[0],this.blockLength=1,n+this.blockLength;const a=s[0]&127;if(a>8)return this.error="Too big integer",-1;if(a+1>s.length)return this.error="End of input reached before message was fully decoded",-1;const c=n+1,l=i.subarray(c,c+a);return l[a-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=Zn(l,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=a+1,n+this.blockLength}toBER(e=!1){let n,r;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return n=new ArrayBuffer(1),e===!1&&(r=new Uint8Array(n),r[0]=128),n;if(this.longFormUsed){const i=xn(this.length,8);if(i.byteLength>127)return this.error="Too big length",yt;if(n=new ArrayBuffer(i.byteLength+1),e)return n;const s=new Uint8Array(i);r=new Uint8Array(n),r[0]=i.byteLength|128;for(let a=0;a<i.byteLength;a++)r[a+1]=s[a];return n}return n=new ArrayBuffer(1),e===!1&&(r=new Uint8Array(n),r[0]=this.length),n}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}}Yf.NAME="lengthBlock";const K={};class Be extends Pn{constructor({name:e=Fe,optional:n=!1,primitiveSchema:r,...i}={},s){super(i),this.name=e,this.optional=n,r&&(this.primitiveSchema=r),this.idBlock=new Zf(i),this.lenBlock=new Yf(i),this.valueBlock=s?new s(i):new Me(i)}fromBER(e,n,r){const i=this.valueBlock.fromBER(e,n,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}toBER(e,n){const r=n||new so;n||Xf(this);const i=this.idBlock.toBER(e);if(r.write(i),this.lenBlock.isIndefiniteForm)r.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,r),r.write(new ArrayBuffer(2));else{const s=this.valueBlock.toBER(e);this.lenBlock.length=s.byteLength;const a=this.lenBlock.toBER(e);r.write(a),r.write(s)}return n?yt:r.final()}toJSON(){const e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return e==="ascii"?this.onAsciiEncoding():J.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${J.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;const n=this.toBER(),r=e.toBER();return wy(n,r)}}Be.NAME="BaseBlock";function Xf(t){if(t instanceof K.Constructed)for(const e of t.valueBlock.value)Xf(e)&&(t.lenBlock.isIndefiniteForm=!0);return!!t.lenBlock.isIndefiniteForm}class hl extends Be{constructor({value:e=Fe,...n}={},r){super(n,r),e&&this.fromString(e)}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}fromBER(e,n,r){const i=this.valueBlock.fromBER(e,n,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}}hl.NAME="BaseStringBlock";class Qf extends Nt(Me){constructor({isHexOnly:e=!0,...n}={}){super(n),this.isHexOnly=e}}Qf.NAME="PrimitiveValueBlock";var eh;class oi extends Be{constructor(e={}){super(e,Qf),this.idBlock.isConstructed=!1}}eh=oi;K.Primitive=eh;oi.NAME="PRIMITIVE";function Ny(t,e){if(t instanceof e)return t;const n=new e;return n.idBlock=t.idBlock,n.lenBlock=t.lenBlock,n.warnings=t.warnings,n.valueBeforeDecodeView=t.valueBeforeDecodeView,n}function pr(t,e=0,n=t.length){const r=e;let i=new Be({},Me);const s=new Pn;if(!Mt(s,t,e,n))return i.error=s.error,{offset:-1,result:i};if(!t.subarray(e,e+n).length)return i.error="Zero buffer length",{offset:-1,result:i};let c=i.idBlock.fromBER(t,e,n);if(i.idBlock.warnings.length&&i.warnings.concat(i.idBlock.warnings),c===-1)return i.error=i.idBlock.error,{offset:-1,result:i};if(e=c,n-=i.idBlock.blockLength,c=i.lenBlock.fromBER(t,e,n),i.lenBlock.warnings.length&&i.warnings.concat(i.lenBlock.warnings),c===-1)return i.error=i.lenBlock.error,{offset:-1,result:i};if(e=c,n-=i.lenBlock.blockLength,!i.idBlock.isConstructed&&i.lenBlock.isIndefiniteForm)return i.error="Indefinite length form used for primitive encoding form",{offset:-1,result:i};let l=Be;switch(i.idBlock.tagClass){case 1:if(i.idBlock.tagNumber>=37&&i.idBlock.isHexOnly===!1)return i.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:i};switch(i.idBlock.tagNumber){case 0:if(i.idBlock.isConstructed&&i.lenBlock.length>0)return i.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:i};l=K.EndOfContent;break;case 1:l=K.Boolean;break;case 2:l=K.Integer;break;case 3:l=K.BitString;break;case 4:l=K.OctetString;break;case 5:l=K.Null;break;case 6:l=K.ObjectIdentifier;break;case 10:l=K.Enumerated;break;case 12:l=K.Utf8String;break;case 13:l=K.RelativeObjectIdentifier;break;case 14:l=K.TIME;break;case 15:return i.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:i};case 16:l=K.Sequence;break;case 17:l=K.Set;break;case 18:l=K.NumericString;break;case 19:l=K.PrintableString;break;case 20:l=K.TeletexString;break;case 21:l=K.VideotexString;break;case 22:l=K.IA5String;break;case 23:l=K.UTCTime;break;case 24:l=K.GeneralizedTime;break;case 25:l=K.GraphicString;break;case 26:l=K.VisibleString;break;case 27:l=K.GeneralString;break;case 28:l=K.UniversalString;break;case 29:l=K.CharacterString;break;case 30:l=K.BmpString;break;case 31:l=K.DATE;break;case 32:l=K.TimeOfDay;break;case 33:l=K.DateTime;break;case 34:l=K.Duration;break;default:{const u=i.idBlock.isConstructed?new K.Constructed:new K.Primitive;u.idBlock=i.idBlock,u.lenBlock=i.lenBlock,u.warnings=i.warnings,i=u}}break;case 2:case 3:case 4:default:l=i.idBlock.isConstructed?K.Constructed:K.Primitive}return i=Ny(i,l),c=i.fromBER(t,e,i.lenBlock.isIndefiniteForm?n:i.lenBlock.length),i.valueBeforeDecodeView=t.subarray(r,r+i.blockLength),{offset:c,result:i}}function Kn(t){if(!t.byteLength){const e=new Be({},Me);return e.error="Input buffer has zero length",{offset:-1,result:e}}return pr(M.toUint8Array(t).slice(),0,t.byteLength)}function Cy(t,e){return t?1:e}class Jt extends Me{constructor({value:e=[],isIndefiniteForm:n=!1,...r}={}){super(r),this.value=e,this.isIndefiniteForm=n}fromBER(e,n,r){const i=M.toUint8Array(e);if(!Mt(this,i,n,r))return-1;if(this.valueBeforeDecodeView=i.subarray(n,n+r),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),n;let s=n;for(;Cy(this.isIndefiniteForm,r)>0;){const a=pr(i,s,r);if(a.offset===-1)return this.error=a.result.error,this.warnings.concat(a.result.warnings),-1;if(s=a.offset,this.blockLength+=a.result.blockLength,r-=a.result.blockLength,this.value.push(a.result),this.isIndefiniteForm&&a.result.constructor.NAME===Mr)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===Mr?this.value.pop():this.warnings.push("No EndOfContent block encoded")),s}toBER(e,n){const r=n||new so;for(let i=0;i<this.value.length;i++)this.value[i].toBER(e,r);return n?yt:r.final()}toJSON(){const e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(const n of this.value)e.value.push(n.toJSON());return e}}Jt.NAME="ConstructedValueBlock";var th;class Ke extends Be{constructor(e={}){super(e,Jt),this.idBlock.isConstructed=!0}fromBER(e,n,r){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;const i=this.valueBlock.fromBER(e,n,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}onAsciiEncoding(){const e=[];for(const r of this.valueBlock.value)e.push(r.toString("ascii").split(`
100
100
  `).map(i=>` ${i}`).join(`
101
101
  `));const n=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${n} :
102
102
  ${e.join(`
103
- `)}`:`${n} :`}}eh=Ke;K.Constructed=eh;Ke.NAME="CONSTRUCTED";class th extends Me{fromBER(e,n,r){return n}toBER(e){return yt}}th.override="EndOfContentValueBlock";var nh;class gl extends Be{constructor(e={}){super(e,th),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}nh=gl;K.EndOfContent=nh;gl.NAME=Mr;var rh;class Sn extends Be{constructor(e={}){super(e,Me),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,n,r){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=r,n+r>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):n+r}toBER(e,n){const r=new ArrayBuffer(2);if(!e){const i=new Uint8Array(r);i[0]=5,i[1]=0}return n&&n.write(r),r}onAsciiEncoding(){return`${this.constructor.NAME}`}}rh=Sn;K.Null=rh;Sn.NAME="NULL";class ih extends Nt(Me){constructor({value:e,...n}={}){super(n),n.valueHex?this.valueHexView=M.toUint8Array(n.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}get value(){for(const e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}fromBER(e,n,r){const i=M.toUint8Array(e);return Mt(this,i,n,r)?(this.valueHexView=i.subarray(n,n+r),r>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,Kf.call(this),this.blockLength=r,n+r):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}ih.NAME="BooleanValueBlock";var sh;class ao extends Be{constructor(e={}){super(e,ih),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}}sh=ao;K.Boolean=sh;ao.NAME="BOOLEAN";class oh extends Nt(Gt){constructor({isConstructed:e=!1,...n}={}){super(n),this.isConstructed=e}fromBER(e,n,r){let i=0;if(this.isConstructed){if(this.isHexOnly=!1,i=Gt.prototype.fromBER.call(this,e,n,r),i===-1)return i;for(let s=0;s<this.value.length;s++){const a=this.value[s].constructor.NAME;if(a===Mr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(a!==Wf)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,i=super.fromBER(e,n,r),this.blockLength=r;return i}toBER(e,n){return this.isConstructed?Gt.prototype.toBER.call(this,e,n):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}}oh.NAME="OctetStringValueBlock";var ah;let bn=class ch extends Be{constructor({idBlock:e={},lenBlock:n={},...r}={}){var i,s;(i=r.isConstructed)!==null&&i!==void 0||(r.isConstructed=!!(!((s=r.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:r.isConstructed,...e},lenBlock:{...n,isIndefiniteForm:!!r.isIndefiniteForm},...r},oh),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,n,r){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,r===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),n;if(!this.valueBlock.isConstructed){const s=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(n,n+r);try{if(s.byteLength){const a=pr(s,0,s.byteLength);a.offset!==-1&&a.offset===r&&(this.valueBlock.value=[a.result])}}catch{}}return super.fromBER(e,n,r)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?Ke.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${J.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;const e=[];for(const n of this.valueBlock.value)n instanceof ch&&e.push(n.valueBlock.valueHexView);return M.concat(e)}};ah=bn;K.OctetString=ah;bn.NAME=Wf;class lh extends Nt(Gt){constructor({unusedBits:e=0,isConstructed:n=!1,...r}={}){super(r),this.unusedBits=e,this.isConstructed=n,this.blockLength=this.valueHexView.byteLength}fromBER(e,n,r){if(!r)return n;let i=-1;if(this.isConstructed){if(i=Gt.prototype.fromBER.call(this,e,n,r),i===-1)return i;for(const c of this.value){const l=c.constructor.NAME;if(l===Mr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(l!==Gf)return this.error="BIT STRING may consists of BIT STRINGs only",-1;const u=c.valueBlock;if(this.unusedBits>0&&u.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=u.unusedBits}return i}const s=M.toUint8Array(e);if(!Mt(this,s,n,r))return-1;const a=s.subarray(n,n+r);if(this.unusedBits=a[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){const c=a.subarray(1);try{if(c.byteLength){const l=pr(c,0,c.byteLength);l.offset!==-1&&l.offset===r-1&&(this.value=[l.result])}}catch{}}return this.valueHexView=a.subarray(1),this.blockLength=a.length,n+r}toBER(e,n){if(this.isConstructed)return Gt.prototype.toBER.call(this,e,n);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return yt;const r=new Uint8Array(this.valueHexView.length+1);return r[0]=this.unusedBits,r.set(this.valueHexView,1),r.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}}lh.NAME="BitStringValueBlock";var uh;let kn=class extends Be{constructor({idBlock:e={},lenBlock:n={},...r}={}){var i,s;(i=r.isConstructed)!==null&&i!==void 0||(r.isConstructed=!!(!((s=r.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:r.isConstructed,...e},lenBlock:{...n,isIndefiniteForm:!!r.isIndefiniteForm},...r},lh),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,n,r){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,n,r)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return Ke.prototype.onAsciiEncoding.call(this);{const e=[],n=this.valueBlock.valueHexView;for(const i of n)e.push(i.toString(2).padStart(8,"0"));const r=e.join("");return`${this.constructor.NAME} : ${r.substring(0,r.length-this.valueBlock.unusedBits)}`}}};uh=kn;K.BitString=uh;kn.NAME=Gf;var dh;function Ny(t,e){const n=new Uint8Array([0]),r=new Uint8Array(t),i=new Uint8Array(e);let s=r.slice(0);const a=s.length-1,c=i.slice(0),l=c.length-1;let u=0;const p=l<a?a:l;let h=0;for(let m=p;m>=0;m--,h++){switch(!0){case h<c.length:u=s[a-h]+c[l-h]+n[0];break;default:u=s[a-h]+n[0]}switch(n[0]=u/10,!0){case h>=s.length:s=$a(new Uint8Array([u%10]),s);break;default:s[a-h]=u%10}}return n[0]>0&&(s=$a(n,s)),s}function ed(t){if(t>=zr.length)for(let e=zr.length;e<=t;e++){const n=new Uint8Array([0]);let r=zr[e-1].slice(0);for(let i=r.length-1;i>=0;i--){const s=new Uint8Array([(r[i]<<1)+n[0]]);n[0]=s[0]/10,r[i]=s[0]%10}n[0]>0&&(r=$a(n,r)),zr.push(r)}return zr[t]}function Cy(t,e){let n=0;const r=new Uint8Array(t),i=new Uint8Array(e),s=r.slice(0),a=s.length-1,c=i.slice(0),l=c.length-1;let u,p=0;for(let h=l;h>=0;h--,p++)switch(u=s[a-p]-c[l-p]-n,!0){case u<0:n=1,s[a-p]=u+10;break;default:n=0,s[a-p]=u}if(n>0)for(let h=a-l+1;h>=0;h--,p++)if(u=s[a-p]-n,u<0)n=1,s[a-p]=u+10;else{n=0,s[a-p]=u;break}return s.slice()}class ml extends Nt(Me){constructor({value:e,...n}={}){super(n),this._valueDec=0,n.valueHex&&this.setValueHex(),e!==void 0&&(this.valueDec=e)}setValueHex(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=Kf.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(_y(e))}get valueDec(){return this._valueDec}fromDER(e,n,r,i=0){const s=this.fromBER(e,n,r);if(s===-1)return s;const a=this.valueHexView;return a[0]===0&&a[1]&128?this.valueHexView=a.subarray(1):i!==0&&a.length<i&&(i-a.length>1&&(i=a.length+1),this.valueHexView=a.subarray(i-a.length)),s}toDER(e=!1){const n=this.valueHexView;switch(!0){case(n[0]&128)!==0:{const r=new Uint8Array(this.valueHexView.length+1);r[0]=0,r.set(n,1),this.valueHexView=r}break;case(n[0]===0&&(n[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,n,r){const i=super.fromBER(e,n,r);return i===-1||this.setValueHex(),i}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){const e=this.valueHexView.length*8-1;let n=new Uint8Array(this.valueHexView.length*8/3),r=0,i;const s=this.valueHexView;let a="",c=!1;for(let l=s.byteLength-1;l>=0;l--){i=s[l];for(let u=0;u<8;u++){if((i&1)===1)switch(r){case e:n=Cy(ed(r),n),a="-";break;default:n=Ny(n,ed(r))}r++,i>>=1}}for(let l=0;l<n.length;l++)n[l]&&(c=!0),c&&(a+=Xu.charAt(n[l]));return c===!1&&(a+=Xu.charAt(0)),a}}dh=ml;ml.NAME="IntegerValueBlock";Object.defineProperty(dh.prototype,"valueHex",{set:function(t){this.valueHexView=new Uint8Array(t),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var ph;class At extends Be{constructor(e={}){super(e,ml),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return us(),BigInt(this.valueBlock.toString())}static fromBigInt(e){us();const n=BigInt(e),r=new so,i=n.toString(16).replace(/^-/,""),s=new Uint8Array(J.FromHex(i));if(n<0){const c=new Uint8Array(s.length+(s[0]&128?1:0));c[0]|=128;const u=BigInt(`0x${J.ToHex(c)}`)+n,p=M.toUint8Array(J.FromHex(u.toString(16)));p[0]|=128,r.write(p)}else s[0]&128&&r.write(new Uint8Array([0])),r.write(s);return new At({valueHex:r.final()})}convertToDER(){const e=new At({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new At({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}}ph=At;K.Integer=ph;At.NAME="INTEGER";var fh;class co extends At{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}fh=co;K.Enumerated=fh;co.NAME="ENUMERATED";class Oa extends Nt(Me){constructor({valueDec:e=-1,isFirstSid:n=!1,...r}={}){super(r),this.valueDec=e,this.isFirstSid=n}fromBER(e,n,r){if(!r)return n;const i=M.toUint8Array(e);if(!Mt(this,i,n,r))return-1;const s=i.subarray(n,n+r);this.valueHexView=new Uint8Array(r);for(let c=0;c<r&&(this.valueHexView[c]=s[c]&127,this.blockLength++,!!(s[c]&128));c++);const a=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)a[c]=this.valueHexView[c];return this.valueHexView=a,s[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=Zn(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),n+this.blockLength)}set valueBigInt(e){us();let n=BigInt(e).toString(2);for(;n.length%7;)n="0"+n;const r=new Uint8Array(n.length/7);for(let i=0;i<r.length;i++)r[i]=parseInt(n.slice(i*7,i*7+7),2)+(i+1<r.length?128:0);this.fromBER(r.buffer,0,r.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const i=this.valueHexView,s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength-1;a++)s[a]=i[a]|128;return s[this.blockLength-1]=i[this.blockLength-1],s.buffer}const n=xn(this.valueDec,7);if(n.byteLength===0)return this.error="Error during encoding SID value",yt;const r=new Uint8Array(n.byteLength);if(!e){const i=new Uint8Array(n),s=n.byteLength-1;for(let a=0;a<s;a++)r[a]=i[a]|128;r[s]=i[s]}return r}toString(){let e="";if(this.isHexOnly)e=J.ToHex(this.valueHexView);else if(this.isFirstSid){let n=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",n-=40):(e="2.",n-=80),e+=n.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}}Oa.NAME="sidBlock";class hh extends Me{constructor({value:e=Fe,...n}={}){super(n),this.value=[],e&&this.fromString(e)}fromBER(e,n,r){let i=n;for(;r>0;){const s=new Oa;if(i=s.fromBER(e,i,r),i===-1)return this.blockLength=0,this.error=s.error,i;this.value.length===0&&(s.isFirstSid=!0),this.blockLength+=s.blockLength,r-=s.blockLength,this.value.push(s)}return i}toBER(e){const n=[];for(let r=0;r<this.value.length;r++){const i=this.value[r].toBER(e);if(i.byteLength===0)return this.error=this.value[r].error,yt;n.push(i)}return fl(n)}fromString(e){this.value=[];let n=0,r=0,i="",s=!1;do if(r=e.indexOf(".",n),r===-1?i=e.substring(n):i=e.substring(n,r),n=r+1,s){const a=this.value[0];let c=0;switch(a.valueDec){case 0:break;case 1:c=40;break;case 2:c=80;break;default:this.value=[];return}const l=parseInt(i,10);if(isNaN(l))return;a.valueDec=l+c,s=!1}else{const a=new Oa;if(i>Number.MAX_SAFE_INTEGER){us();const c=BigInt(i);a.valueBigInt=c}else if(a.valueDec=parseInt(i,10),isNaN(a.valueDec))return;this.value.length||(a.isFirstSid=!0,s=!0),this.value.push(a)}while(r!==-1)}toString(){let e="",n=!1;for(let r=0;r<this.value.length;r++){n=this.value[r].isHexOnly;let i=this.value[r].toString();r!==0&&(e=`${e}.`),n?(i=`{${i}}`,this.value[r].isFirstSid?e=`2.{${i} - 80}`:e+=i):e+=i}return e}toJSON(){const e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let n=0;n<this.value.length;n++)e.sidArray.push(this.value[n].toJSON());return e}}hh.NAME="ObjectIdentifierValueBlock";var gh;class lo extends Be{constructor(e={}){super(e,hh),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}}gh=lo;K.ObjectIdentifier=gh;lo.NAME="OBJECT IDENTIFIER";class Ba extends Nt(Pn){constructor({valueDec:e=0,...n}={}){super(n),this.valueDec=e}fromBER(e,n,r){if(r===0)return n;const i=M.toUint8Array(e);if(!Mt(this,i,n,r))return-1;const s=i.subarray(n,n+r);this.valueHexView=new Uint8Array(r);for(let c=0;c<r&&(this.valueHexView[c]=s[c]&127,this.blockLength++,!!(s[c]&128));c++);const a=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)a[c]=this.valueHexView[c];return this.valueHexView=a,s[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=Zn(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),n+this.blockLength)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const i=this.valueHexView,s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength-1;a++)s[a]=i[a]|128;return s[this.blockLength-1]=i[this.blockLength-1],s.buffer}const n=xn(this.valueDec,7);if(n.byteLength===0)return this.error="Error during encoding SID value",yt;const r=new Uint8Array(n.byteLength);if(!e){const i=new Uint8Array(n),s=n.byteLength-1;for(let a=0;a<s;a++)r[a]=i[a]|128;r[s]=i[s]}return r.buffer}toString(){let e="";return this.isHexOnly?e=J.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}}Ba.NAME="relativeSidBlock";class mh extends Me{constructor({value:e=Fe,...n}={}){super(n),this.value=[],e&&this.fromString(e)}fromBER(e,n,r){let i=n;for(;r>0;){const s=new Ba;if(i=s.fromBER(e,i,r),i===-1)return this.blockLength=0,this.error=s.error,i;this.blockLength+=s.blockLength,r-=s.blockLength,this.value.push(s)}return i}toBER(e,n){const r=[];for(let i=0;i<this.value.length;i++){const s=this.value[i].toBER(e);if(s.byteLength===0)return this.error=this.value[i].error,yt;r.push(s)}return fl(r)}fromString(e){this.value=[];let n=0,r=0,i="";do{r=e.indexOf(".",n),r===-1?i=e.substring(n):i=e.substring(n,r),n=r+1;const s=new Ba;if(s.valueDec=parseInt(i,10),isNaN(s.valueDec))return!0;this.value.push(s)}while(r!==-1);return!0}toString(){let e="",n=!1;for(let r=0;r<this.value.length;r++){n=this.value[r].isHexOnly;let i=this.value[r].toString();r!==0&&(e=`${e}.`),n&&(i=`{${i}}`),e+=i}return e}toJSON(){const e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let n=0;n<this.value.length;n++)e.sidArray.push(this.value[n].toJSON());return e}}mh.NAME="RelativeObjectIdentifierValueBlock";var _h;class _l extends Be{constructor(e={}){super(e,mh),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}}_h=_l;K.RelativeObjectIdentifier=_h;_l.NAME="RelativeObjectIdentifier";var yh;class Bt extends Ke{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}yh=Bt;K.Sequence=yh;Bt.NAME="SEQUENCE";var vh;let Tt=class extends Ke{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};vh=Tt;K.Set=vh;Tt.NAME="SET";class wh extends Nt(Me){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=Fe}toJSON(){return{...super.toJSON(),value:this.value}}}wh.NAME="StringValueBlock";class bh extends wh{}bh.NAME="SimpleStringValueBlock";class et extends hl{constructor({...e}={}){super(e,bh)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,M.toUint8Array(e))}fromString(e){const n=e.length,r=this.valueBlock.valueHexView=new Uint8Array(n);for(let i=0;i<n;i++)r[i]=e.charCodeAt(i);this.valueBlock.value=e}}et.NAME="SIMPLE STRING";class kh extends et{fromBuffer(e){this.valueBlock.valueHexView=M.toUint8Array(e);try{this.valueBlock.value=J.ToUtf8String(e)}catch(n){this.warnings.push(`Error during "decodeURIComponent": ${n}, using raw string`),this.valueBlock.value=J.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(J.FromUtf8String(e)),this.valueBlock.value=e}}kh.NAME="Utf8StringValueBlock";var xh;class Dt extends kh{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}xh=Dt;K.Utf8String=xh;Dt.NAME="UTF8String";class Sh extends et{fromBuffer(e){this.valueBlock.value=J.ToUtf16String(e),this.valueBlock.valueHexView=M.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(J.FromUtf16String(e))}}Sh.NAME="BmpStringValueBlock";var Ah;class uo extends Sh{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}Ah=uo;K.BmpString=Ah;uo.NAME="BMPString";class Eh extends et{fromBuffer(e){const n=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),r=new Uint8Array(n);for(let i=0;i<r.length;i+=4)r[i]=r[i+3],r[i+1]=r[i+2],r[i+2]=0,r[i+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(n))}fromString(e){const n=e.length,r=this.valueBlock.valueHexView=new Uint8Array(n*4);for(let i=0;i<n;i++){const s=xn(e.charCodeAt(i),8),a=new Uint8Array(s);if(a.length>4)continue;const c=4-a.length;for(let l=a.length-1;l>=0;l--)r[i*4+l+c]=a[l]}this.valueBlock.value=e}}Eh.NAME="UniversalStringValueBlock";var Ih;class po extends Eh{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}Ih=po;K.UniversalString=Ih;po.NAME="UniversalString";var zh;class fo extends et{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}zh=fo;K.NumericString=zh;fo.NAME="NumericString";var Nh;class ho extends et{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}Nh=ho;K.PrintableString=Nh;ho.NAME="PrintableString";var Ch;class go extends et{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}Ch=go;K.TeletexString=Ch;go.NAME="TeletexString";var jh;class mo extends et{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}jh=mo;K.VideotexString=jh;mo.NAME="VideotexString";var $h;class _o extends et{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}$h=_o;K.IA5String=$h;_o.NAME="IA5String";var Oh;class yo extends et{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}Oh=yo;K.GraphicString=Oh;yo.NAME="GraphicString";var Bh;class ai extends et{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}Bh=ai;K.VisibleString=Bh;ai.NAME="VisibleString";var Th;class vo extends et{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}Th=vo;K.GeneralString=Th;vo.NAME="GeneralString";var Ph;class wo extends et{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}Ph=wo;K.CharacterString=Ph;wo.NAME="CharacterString";var Rh;class ci extends ai{constructor({value:e,valueDate:n,...r}={}){if(super(r),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let i=0;i<e.length;i++)this.valueBlock.valueHexView[i]=e.charCodeAt(i)}n&&(this.fromDate(n),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,M.toUint8Array(e)))}toBuffer(){const e=this.toString(),n=new ArrayBuffer(e.length),r=new Uint8Array(n);for(let i=0;i<e.length;i++)r[i]=e.charCodeAt(i);return n}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){const r=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(e);if(r===null){this.error="Wrong input string for conversion";return}const i=parseInt(r[1],10);i>=50?this.year=1900+i:this.year=2e3+i,this.month=parseInt(r[2],10),this.day=parseInt(r[3],10),this.hour=parseInt(r[4],10),this.minute=parseInt(r[5],10),this.second=parseInt(r[6],10)}toString(e="iso"){if(e==="iso"){const n=new Array(7);return n[0]=Ye(this.year<2e3?this.year-1900:this.year-2e3,2),n[1]=Ye(this.month,2),n[2]=Ye(this.day,2),n[3]=Ye(this.hour,2),n[4]=Ye(this.minute,2),n[5]=Ye(this.second,2),n[6]="Z",n.join("")}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}}Rh=ci;K.UTCTime=Rh;ci.NAME="UTCTime";var Lh;class bo extends ci{constructor(e={}){var n;super(e),(n=this.millisecond)!==null&&n!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(e){let n=!1,r="",i="",s=0,a,c=0,l=0;if(e[e.length-1]==="Z")r=e.substring(0,e.length-1),n=!0;else{const h=new Number(e[e.length-1]);if(isNaN(h.valueOf()))throw new Error("Wrong input string for conversion");r=e}if(n){if(r.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(r.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let h=1,m=r.indexOf("+"),v="";if(m===-1&&(m=r.indexOf("-"),h=-1),m!==-1){if(v=r.substring(m+1),r=r.substring(0,m),v.length!==2&&v.length!==4)throw new Error("Wrong input string for conversion");let f=parseInt(v.substring(0,2),10);if(isNaN(f.valueOf()))throw new Error("Wrong input string for conversion");if(c=h*f,v.length===4){if(f=parseInt(v.substring(2,4),10),isNaN(f.valueOf()))throw new Error("Wrong input string for conversion");l=h*f}}}let u=r.indexOf(".");if(u===-1&&(u=r.indexOf(",")),u!==-1){const h=new Number(`0${r.substring(u)}`);if(isNaN(h.valueOf()))throw new Error("Wrong input string for conversion");s=h.valueOf(),i=r.substring(0,u)}else i=r;switch(!0){case i.length===8:if(a=/(\d{4})(\d{2})(\d{2})/ig,u!==-1)throw new Error("Wrong input string for conversion");break;case i.length===10:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,u!==-1){let h=60*s;this.minute=Math.floor(h),h=60*(h-this.minute),this.second=Math.floor(h),h=1e3*(h-this.second),this.millisecond=Math.floor(h)}break;case i.length===12:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,u!==-1){let h=60*s;this.second=Math.floor(h),h=1e3*(h-this.second),this.millisecond=Math.floor(h)}break;case i.length===14:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,u!==-1){const h=1e3*s;this.millisecond=Math.floor(h)}break;default:throw new Error("Wrong input string for conversion")}const p=a.exec(i);if(p===null)throw new Error("Wrong input string for conversion");for(let h=1;h<p.length;h++)switch(h){case 1:this.year=parseInt(p[h],10);break;case 2:this.month=parseInt(p[h],10);break;case 3:this.day=parseInt(p[h],10);break;case 4:this.hour=parseInt(p[h],10)+c;break;case 5:this.minute=parseInt(p[h],10)+l;break;case 6:this.second=parseInt(p[h],10);break;default:throw new Error("Wrong input string for conversion")}if(n===!1){const h=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=h.getUTCFullYear(),this.month=h.getUTCMonth(),this.day=h.getUTCDay(),this.hour=h.getUTCHours(),this.minute=h.getUTCMinutes(),this.second=h.getUTCSeconds(),this.millisecond=h.getUTCMilliseconds()}}toString(e="iso"){if(e==="iso"){const n=[];return n.push(Ye(this.year,4)),n.push(Ye(this.month,2)),n.push(Ye(this.day,2)),n.push(Ye(this.hour,2)),n.push(Ye(this.minute,2)),n.push(Ye(this.second,2)),this.millisecond!==0&&(n.push("."),n.push(Ye(this.millisecond,3))),n.push("Z"),n.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}}Lh=bo;K.GeneralizedTime=Lh;bo.NAME="GeneralizedTime";var Uh;class yl extends Dt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}Uh=yl;K.DATE=Uh;yl.NAME="DATE";var Vh;class vl extends Dt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}Vh=vl;K.TimeOfDay=Vh;vl.NAME="TimeOfDay";var qh;class wl extends Dt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}qh=wl;K.DateTime=qh;wl.NAME="DateTime";var Mh;class bl extends Dt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}Mh=bl;K.Duration=Mh;bl.NAME="Duration";var Dh;class kl extends Dt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}Dh=kl;K.TIME=Dh;kl.NAME="TIME";class An{constructor({name:e=Fe,optional:n=!1}={}){this.name=e,this.optional=n}}class xl extends An{constructor({value:e=[],...n}={}){super(n),this.value=e}}class ds extends An{constructor({value:e=new An,local:n=!1,...r}={}){super(r),this.value=e,this.local=n}}class jy{constructor({data:e=oo}={}){this.dataView=M.toUint8Array(e)}get data(){return this.dataView.slice().buffer}set data(e){this.dataView=M.toUint8Array(e)}fromBER(e,n,r){const i=n+r;return this.dataView=M.toUint8Array(e).subarray(n,i),i}toBER(e){return this.dataView.slice().buffer}}function yn(t,e,n){if(n instanceof xl){for(let s=0;s<n.value.length;s++)if(yn(t,e,n.value[s]).verified)return{verified:!0,result:t};{const s={verified:!1,result:{error:"Wrong values for Choice type"}};return n.hasOwnProperty(ra)&&(s.name=n.name),s}}if(n instanceof An)return n.hasOwnProperty(ra)&&(t[n.name]=e),{verified:!0,result:t};if(!(t instanceof Object))return{verified:!1,result:{error:"Wrong root object"}};if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 data"}};if(!(n instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(wy in n))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(Sy in n.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(Ay in n.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const r=n.idBlock.toBER(!1);if(r.byteLength===0)return{verified:!1,result:{error:"Error encoding idBlock for ASN.1 schema"}};if(n.idBlock.fromBER(r,0,r.byteLength)===-1)return{verified:!1,result:{error:"Error decoding idBlock for ASN.1 schema"}};if(n.idBlock.hasOwnProperty(by)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(n.idBlock.tagClass!==e.idBlock.tagClass)return{verified:!1,result:t};if(n.idBlock.hasOwnProperty(ky)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(n.idBlock.tagNumber!==e.idBlock.tagNumber)return{verified:!1,result:t};if(n.idBlock.hasOwnProperty(xy)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(n.idBlock.isConstructed!==e.idBlock.isConstructed)return{verified:!1,result:t};if(!(vy in n.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(n.idBlock.isHexOnly!==e.idBlock.isHexOnly)return{verified:!1,result:t};if(n.idBlock.isHexOnly){if(!(Qu in n.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const s=n.idBlock.valueHexView,a=e.idBlock.valueHexView;if(s.length!==a.length)return{verified:!1,result:t};for(let c=0;c<s.length;c++)if(s[c]!==a[1])return{verified:!1,result:t}}if(n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Fe),n.name&&(t[n.name]=e)),n instanceof K.Constructed){let s=0,a={verified:!1,result:{error:"Unknown error"}},c=n.valueBlock.value.length;if(c>0&&n.valueBlock.value[0]instanceof ds&&(c=e.valueBlock.value.length),c===0)return{verified:!0,result:t};if(e.valueBlock.value.length===0&&n.valueBlock.value.length!==0){let l=!0;for(let u=0;u<n.valueBlock.value.length;u++)l=l&&(n.valueBlock.value[u].optional||!1);return l?{verified:!0,result:t}:(n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Fe),n.name&&delete t[n.name]),t.error="Inconsistent object length",{verified:!1,result:t})}for(let l=0;l<c;l++)if(l-s>=e.valueBlock.value.length){if(n.valueBlock.value[l].optional===!1){const u={verified:!1,result:t};return t.error="Inconsistent length between ASN.1 data and schema",n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Fe),n.name&&(delete t[n.name],u.name=n.name)),u}}else if(n.valueBlock.value[0]instanceof ds){if(a=yn(t,e.valueBlock.value[l],n.valueBlock.value[0].value),a.verified===!1)if(n.valueBlock.value[0].optional)s++;else return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Fe),n.name&&delete t[n.name]),a;if(ra in n.valueBlock.value[0]&&n.valueBlock.value[0].name.length>0){let u={};Ey in n.valueBlock.value[0]&&n.valueBlock.value[0].local?u=e:u=t,typeof u[n.valueBlock.value[0].name]>"u"&&(u[n.valueBlock.value[0].name]=[]),u[n.valueBlock.value[0].name].push(e.valueBlock.value[l])}}else if(a=yn(t,e.valueBlock.value[l-s],n.valueBlock.value[l]),a.verified===!1)if(n.valueBlock.value[l].optional)s++;else return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Fe),n.name&&delete t[n.name]),a;if(a.verified===!1){const l={verified:!1,result:t};return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Fe),n.name&&(delete t[n.name],l.name=n.name)),l}return{verified:!0,result:t}}if(n.primitiveSchema&&Qu in e.valueBlock){const s=pr(e.valueBlock.valueHexView);if(s.offset===-1){const a={verified:!1,result:s.result};return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Fe),n.name&&(delete t[n.name],a.name=n.name)),a}return yn(t,s.result,n.primitiveSchema)}return{verified:!0,result:t}}function $y(t,e){if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};const n=pr(M.toUint8Array(t));return n.offset===-1?{verified:!1,result:n.result}:yn(n.result,n.result,e)}const Hh=Object.freeze(Object.defineProperty({__proto__:null,Any:An,BaseBlock:Be,BaseStringBlock:hl,BitString:kn,BmpString:uo,Boolean:ao,CharacterString:wo,Choice:xl,Constructed:Ke,DATE:yl,DateTime:wl,Duration:bl,EndOfContent:gl,Enumerated:co,GeneralString:vo,GeneralizedTime:bo,GraphicString:yo,HexBlock:Nt,IA5String:_o,Integer:At,Null:Sn,NumericString:fo,ObjectIdentifier:lo,OctetString:bn,Primitive:oi,PrintableString:ho,RawData:jy,RelativeObjectIdentifier:_l,Repeated:ds,Sequence:Bt,Set:Tt,TIME:kl,TeletexString:go,TimeOfDay:vl,UTCTime:ci,UniversalString:po,Utf8String:Dt,ValueBlock:Me,VideotexString:mo,ViewWriter:so,VisibleString:ai,compareSchema:yn,fromBER:Kn,verifySchema:$y},Symbol.toStringTag,{value:"Module"}));var T;(function(t){t[t.Sequence=0]="Sequence",t[t.Set=1]="Set",t[t.Choice=2]="Choice"})(T||(T={}));var b;(function(t){t[t.Any=1]="Any",t[t.Boolean=2]="Boolean",t[t.OctetString=3]="OctetString",t[t.BitString=4]="BitString",t[t.Integer=5]="Integer",t[t.Enumerated=6]="Enumerated",t[t.ObjectIdentifier=7]="ObjectIdentifier",t[t.Utf8String=8]="Utf8String",t[t.BmpString=9]="BmpString",t[t.UniversalString=10]="UniversalString",t[t.NumericString=11]="NumericString",t[t.PrintableString=12]="PrintableString",t[t.TeletexString=13]="TeletexString",t[t.VideotexString=14]="VideotexString",t[t.IA5String=15]="IA5String",t[t.GraphicString=16]="GraphicString",t[t.VisibleString=17]="VisibleString",t[t.GeneralString=18]="GeneralString",t[t.CharacterString=19]="CharacterString",t[t.UTCTime=20]="UTCTime",t[t.GeneralizedTime=21]="GeneralizedTime",t[t.DATE=22]="DATE",t[t.TimeOfDay=23]="TimeOfDay",t[t.DateTime=24]="DateTime",t[t.Duration=25]="Duration",t[t.TIME=26]="TIME",t[t.Null=27]="Null"})(b||(b={}));class ko{constructor(e,n=0){if(this.unusedBits=0,this.value=new ArrayBuffer(0),e)if(typeof e=="number")this.fromNumber(e);else if(M.isBufferSource(e))this.unusedBits=n,this.value=M.toArrayBuffer(e);else throw TypeError("Unsupported type of 'params' argument for BitString")}fromASN(e){if(!(e instanceof kn))throw new TypeError("Argument 'asn' is not instance of ASN.1 BitString");return this.unusedBits=e.valueBlock.unusedBits,this.value=e.valueBlock.valueHex,this}toASN(){return new kn({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new kn({name:e})}toNumber(){let e="";const n=new Uint8Array(this.value);for(const r of n)e+=r.toString(2).padStart(8,"0");return e=e.split("").reverse().join(""),this.unusedBits&&(e=e.slice(this.unusedBits).padStart(this.unusedBits,"0")),parseInt(e,2)}fromNumber(e){let n=e.toString(2);const r=n.length+7>>3;this.unusedBits=(r<<3)-n.length;const i=new Uint8Array(r);n=n.padStart(r<<3,"0").split("").reverse().join("");let s=0;for(;s<r;)i[s]=parseInt(n.slice(s<<3,(s<<3)+8),2),s++;this.value=i.buffer}}class ue{get byteLength(){return this.buffer.byteLength}get byteOffset(){return 0}constructor(e){typeof e=="number"?this.buffer=new ArrayBuffer(e):M.isBufferSource(e)?this.buffer=M.toArrayBuffer(e):Array.isArray(e)?this.buffer=new Uint8Array(e):this.buffer=new ArrayBuffer(0)}fromASN(e){if(!(e instanceof bn))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=e.valueBlock.valueHex,this}toASN(){return new bn({valueHex:this.buffer})}toSchema(e){return new bn({name:e})}}const Oy={fromASN:t=>t instanceof Sn?null:t.valueBeforeDecodeView,toASN:t=>{if(t===null)return new Sn;const e=Kn(t);if(e.result.error)throw new Error(e.result.error);return e.result}},By={fromASN:t=>t.valueBlock.valueHexView.byteLength>=4?t.valueBlock.toString():t.valueBlock.valueDec,toASN:t=>new At({value:+t})},Ty={fromASN:t=>t.valueBlock.valueDec,toASN:t=>new co({value:t})},_e={fromASN:t=>t.valueBlock.valueHexView,toASN:t=>new At({valueHex:t})},Py={fromASN:t=>t.valueBlock.valueHexView,toASN:t=>new kn({valueHex:t})},Ry={fromASN:t=>t.valueBlock.toString(),toASN:t=>new lo({value:t})},Ly={fromASN:t=>t.valueBlock.value,toASN:t=>new ao({value:t})},ps={fromASN:t=>t.valueBlock.valueHexView,toASN:t=>new bn({valueHex:t})},Uy={fromASN:t=>new ue(t.getValue()),toASN:t=>t.toASN()};function at(t){return{fromASN:e=>e.valueBlock.value,toASN:e=>new t({value:e})}}const Fh=at(Dt),Vy=at(uo),qy=at(po),My=at(fo),Dy=at(ho),Hy=at(go),Fy=at(mo),Ky=at(_o),Wy=at(yo),Gy=at(ai),Jy=at(vo),Zy=at(wo),Yy={fromASN:t=>t.toDate(),toASN:t=>new ci({valueDate:t})},Xy={fromASN:t=>t.toDate(),toASN:t=>new bo({valueDate:t})},Qy={fromASN:()=>null,toASN:()=>new Sn};function Sl(t){switch(t){case b.Any:return Oy;case b.BitString:return Py;case b.BmpString:return Vy;case b.Boolean:return Ly;case b.CharacterString:return Zy;case b.Enumerated:return Ty;case b.GeneralString:return Jy;case b.GeneralizedTime:return Xy;case b.GraphicString:return Wy;case b.IA5String:return Ky;case b.Integer:return By;case b.Null:return Qy;case b.NumericString:return My;case b.ObjectIdentifier:return Ry;case b.OctetString:return ps;case b.PrintableString:return Dy;case b.TeletexString:return Hy;case b.UTCTime:return Yy;case b.UniversalString:return qy;case b.Utf8String:return Fh;case b.VideotexString:return Fy;case b.VisibleString:return Gy;default:return null}}function Ot(t){return typeof t=="function"&&t.prototype?t.prototype.toASN&&t.prototype.fromASN?!0:Ot(t.prototype):!!(t&&typeof t=="object"&&"toASN"in t&&"fromASN"in t)}function Kh(t){var e;if(t){const n=Object.getPrototypeOf(t);return((e=n==null?void 0:n.prototype)===null||e===void 0?void 0:e.constructor)===Array?!0:Kh(n)}return!1}function ev(t,e){if(!(t&&e)||t.byteLength!==e.byteLength)return!1;const n=new Uint8Array(t),r=new Uint8Array(e);for(let i=0;i<t.byteLength;i++)if(n[i]!==r[i])return!1;return!0}class tv{constructor(){this.items=new WeakMap}has(e){return this.items.has(e)}get(e,n=!1){const r=this.items.get(e);if(!r)throw new Error(`Cannot get schema for '${e.prototype.constructor.name}' target`);if(n&&!r.schema)throw new Error(`Schema '${e.prototype.constructor.name}' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'.`);return r}cache(e){const n=this.get(e);n.schema||(n.schema=this.create(e,!0))}createDefault(e){const n={type:T.Sequence,items:{}},r=this.findParentSchema(e);return r&&(Object.assign(n,r),n.items=Object.assign({},n.items,r.items)),n}create(e,n){const r=this.items.get(e)||this.createDefault(e),i=[];for(const s in r.items){const a=r.items[s],c=n?s:"";let l;if(typeof a.type=="number"){const p=b[a.type],h=Hh[p];if(!h)throw new Error(`Cannot get ASN1 class by name '${p}'`);l=new h({name:c})}else Ot(a.type)?l=new a.type().toSchema(c):a.optional?this.get(a.type).type===T.Choice?l=new An({name:c}):(l=this.create(a.type,!1),l.name=c):l=new An({name:c});const u=!!a.optional||a.defaultValue!==void 0;if(a.repeated){l.name="";const p=a.repeated==="set"?Tt:Bt;l=new p({name:"",value:[new ds({name:c,value:l})]})}if(a.context!==null&&a.context!==void 0)if(a.implicit)if(typeof a.type=="number"||Ot(a.type)){const p=a.repeated?Ke:oi;i.push(new p({name:c,optional:u,idBlock:{tagClass:3,tagNumber:a.context}}))}else{this.cache(a.type);const p=!!a.repeated;let h=p?l:this.get(a.type,!0).schema;h="valueBlock"in h?h.valueBlock.value:h.value,i.push(new Ke({name:p?"":c,optional:u,idBlock:{tagClass:3,tagNumber:a.context},value:h}))}else i.push(new Ke({optional:u,idBlock:{tagClass:3,tagNumber:a.context},value:[l]}));else l.optional=u,i.push(l)}switch(r.type){case T.Sequence:return new Bt({value:i,name:""});case T.Set:return new Tt({value:i,name:""});case T.Choice:return new xl({value:i,name:""});default:throw new Error("Unsupported ASN1 type in use")}}set(e,n){return this.items.set(e,n),this}findParentSchema(e){const n=Object.getPrototypeOf(e);return n?this.items.get(n)||this.findParentSchema(n):null}}const rt=new tv,R=t=>e=>{let n;rt.has(e)?n=rt.get(e):(n=rt.createDefault(e),rt.set(e,n)),Object.assign(n,t)},g=t=>(e,n)=>{let r;rt.has(e.constructor)?r=rt.get(e.constructor):(r=rt.createDefault(e.constructor),rt.set(e.constructor,r));const i=Object.assign({},t);if(typeof i.type=="number"&&!i.converter){const s=Sl(t.type);if(!s)throw new Error(`Cannot get default converter for property '${n}' of ${e.constructor.name}`);i.converter=s}r.items[n]=i};class td extends Error{constructor(){super(...arguments),this.schemas=[]}}class nv{static parse(e,n){const r=Kn(e);if(r.result.error)throw new Error(r.result.error);return this.fromASN(r.result,n)}static fromASN(e,n){var r;try{if(Ot(n))return new n().fromASN(e);const i=rt.get(n);rt.cache(n);let s=i.schema;if(e.constructor===Ke&&i.type!==T.Choice){s=new Ke({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:i.schema.valueBlock.value});for(const l in i.items)delete e[l]}const a=yn({},e,s);if(!a.verified)throw new td(`Data does not match to ${n.name} ASN1 schema. ${a.result.error}`);const c=new n;if(Kh(n)){if(!("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const l=i.itemType;if(typeof l=="number"){const u=Sl(l);if(!u)throw new Error(`Cannot get default converter for array item of ${n.name} ASN1 schema`);return n.from(e.valueBlock.value,p=>u.fromASN(p))}else return n.from(e.valueBlock.value,u=>this.fromASN(u,l))}for(const l in i.items){const u=a.result[l];if(!u)continue;const p=i.items[l],h=p.type;if(typeof h=="number"||Ot(h)){const m=(r=p.converter)!==null&&r!==void 0?r:Ot(h)?new h:null;if(!m)throw new Error("Converter is empty");if(p.repeated)if(p.implicit){const v=p.repeated==="sequence"?Bt:Tt,f=new v;f.valueBlock=u.valueBlock;const _=Kn(f.toBER(!1));if(_.offset===-1)throw new Error(`Cannot parse the child item. ${_.result.error}`);if(!("value"in _.result.valueBlock&&Array.isArray(_.result.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const w=_.result.valueBlock.value;c[l]=Array.from(w,S=>m.fromASN(S))}else c[l]=Array.from(u,v=>m.fromASN(v));else{let v=u;if(p.implicit){let f;if(Ot(h))f=new h().toSchema("");else{const _=b[h],w=Hh[_];if(!w)throw new Error(`Cannot get '${_}' class from asn1js module`);f=new w}f.valueBlock=v.valueBlock,v=Kn(f.toBER(!1)).result}c[l]=m.fromASN(v)}}else if(p.repeated){if(!Array.isArray(u))throw new Error("Cannot get list of items from the ASN.1 parsed value. ASN.1 value should be iterable.");c[l]=Array.from(u,m=>this.fromASN(m,h))}else c[l]=this.fromASN(u,h)}return c}catch(i){throw i instanceof td&&i.schemas.push(n.name),i}}}class Al{static serialize(e){return e instanceof Be?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&typeof e=="object"&&Ot(e))return e.toASN();if(!(e&&typeof e=="object"))throw new TypeError("Parameter 1 should be type of Object.");const n=e.constructor,r=rt.get(n);rt.cache(n);let i=[];if(r.itemType){if(!Array.isArray(e))throw new TypeError("Parameter 1 should be type of Array.");if(typeof r.itemType=="number"){const a=Sl(r.itemType);if(!a)throw new Error(`Cannot get default converter for array item of ${n.name} ASN1 schema`);i=e.map(c=>a.toASN(c))}else i=e.map(a=>this.toAsnItem({type:r.itemType},"[]",n,a))}else for(const a in r.items){const c=r.items[a],l=e[a];if(l===void 0||c.defaultValue===l||typeof c.defaultValue=="object"&&typeof l=="object"&&ev(this.serialize(c.defaultValue),this.serialize(l)))continue;const u=Al.toAsnItem(c,a,n,l);if(typeof c.context=="number")if(c.implicit)if(!c.repeated&&(typeof c.type=="number"||Ot(c.type))){const p={};p.valueHex=u instanceof Sn?u.valueBeforeDecodeView:u.valueBlock.toBER(),i.push(new oi({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},...p}))}else i.push(new Ke({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:u.valueBlock.value}));else i.push(new Ke({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:[u]}));else c.repeated?i=i.concat(u):i.push(u)}let s;switch(r.type){case T.Sequence:s=new Bt({value:i});break;case T.Set:s=new Tt({value:i});break;case T.Choice:if(!i[0])throw new Error(`Schema '${n.name}' has wrong data. Choice cannot be empty.`);s=i[0];break}return s}static toAsnItem(e,n,r,i){let s;if(typeof e.type=="number"){const a=e.converter;if(!a)throw new Error(`Property '${n}' doesn't have converter for type ${b[e.type]} in schema '${r.name}'`);if(e.repeated){if(!Array.isArray(i))throw new TypeError("Parameter 'objProp' should be type of Array.");const c=Array.from(i,u=>a.toASN(u)),l=e.repeated==="sequence"?Bt:Tt;s=new l({value:c})}else s=a.toASN(i)}else if(e.repeated){if(!Array.isArray(i))throw new TypeError("Parameter 'objProp' should be type of Array.");const a=Array.from(i,l=>this.toASN(l)),c=e.repeated==="sequence"?Bt:Tt;s=new c({value:a})}else s=this.toASN(i);return s}}class fe extends Array{constructor(e=[]){if(typeof e=="number")super(e);else{super();for(const n of e)this.push(n)}}}class q{static serialize(e){return Al.serialize(e)}static parse(e,n){return nv.parse(e,n)}static toString(e){const n=M.isBufferSource(e)?M.toArrayBuffer(e):q.serialize(e),r=Kn(n);if(r.offset===-1)throw new Error(`Cannot decode ASN.1 data. ${r.result.error}`);return r.result.toString()}}function d(t,e,n,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,n):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,n,r);else for(var c=t.length-1;c>=0;c--)(a=t[c])&&(s=(i<3?a(s):i>3?a(e,n,s):a(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s}var Wh={exports:{}};(function(t){(function(e){const n="(0?\\d+|0x[a-f0-9]+)",r={fourOctet:new RegExp(`^${n}\\.${n}\\.${n}\\.${n}$`,"i"),threeOctet:new RegExp(`^${n}\\.${n}\\.${n}$`,"i"),twoOctet:new RegExp(`^${n}\\.${n}$`,"i"),longValue:new RegExp(`^${n}$`,"i")},i=new RegExp("^0[0-7]+$","i"),s=new RegExp("^0x[a-f0-9]+$","i"),a="%[0-9a-z]{1,}",c="(?:[0-9a-f]+::?)+",l={zoneIndex:new RegExp(a,"i"),native:new RegExp(`^(::)?(${c})?([0-9a-f]+)?(::)?(${a})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${n}\\.${n}\\.${n}\\.${n}(${a})?)$`,"i"),transitional:new RegExp(`^((?:${c})|(?:::)(?:${c})?)${n}\\.${n}\\.${n}\\.${n}(${a})?$`,"i")};function u(f,_){if(f.indexOf("::")!==f.lastIndexOf("::"))return null;let w=0,S=-1,C=(f.match(l.zoneIndex)||[])[0],B,L;for(C&&(C=C.substring(1),f=f.replace(/%.+$/,""));(S=f.indexOf(":",S+1))>=0;)w++;if(f.substr(0,2)==="::"&&w--,f.substr(-2,2)==="::"&&w--,w>_)return null;for(L=_-w,B=":";L--;)B+="0:";return f=f.replace("::",B),f[0]===":"&&(f=f.slice(1)),f[f.length-1]===":"&&(f=f.slice(0,-1)),_=function(){const Q=f.split(":"),ce=[];for(let le=0;le<Q.length;le++)ce.push(parseInt(Q[le],16));return ce}(),{parts:_,zoneId:C}}function p(f,_,w,S){if(f.length!==_.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let C=0,B;for(;S>0;){if(B=w-S,B<0&&(B=0),f[C]>>B!==_[C]>>B)return!1;S-=w,C+=1}return!0}function h(f){if(s.test(f))return parseInt(f,16);if(f[0]==="0"&&!isNaN(parseInt(f[1],10))){if(i.test(f))return parseInt(f,8);throw new Error(`ipaddr: cannot parse ${f} as octal`)}return parseInt(f,10)}function m(f,_){for(;f.length<_;)f=`0${f}`;return f}const v={};v.IPv4=function(){function f(_){if(_.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let w,S;for(w=0;w<_.length;w++)if(S=_[w],!(0<=S&&S<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=_}return f.prototype.SpecialRanges={unspecified:[[new f([0,0,0,0]),8]],broadcast:[[new f([255,255,255,255]),32]],multicast:[[new f([224,0,0,0]),4]],linkLocal:[[new f([169,254,0,0]),16]],loopback:[[new f([127,0,0,0]),8]],carrierGradeNat:[[new f([100,64,0,0]),10]],private:[[new f([10,0,0,0]),8],[new f([172,16,0,0]),12],[new f([192,168,0,0]),16]],reserved:[[new f([192,0,0,0]),24],[new f([192,0,2,0]),24],[new f([192,88,99,0]),24],[new f([198,18,0,0]),15],[new f([198,51,100,0]),24],[new f([203,0,113,0]),24],[new f([240,0,0,0]),4]],as112:[[new f([192,175,48,0]),24],[new f([192,31,196,0]),24]],amt:[[new f([192,52,193,0]),24]]},f.prototype.kind=function(){return"ipv4"},f.prototype.match=function(_,w){let S;if(w===void 0&&(S=_,_=S[0],w=S[1]),_.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return p(this.octets,_.octets,8,w)},f.prototype.prefixLengthFromSubnetMask=function(){let _=0,w=!1;const S={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0};let C,B,L;for(C=3;C>=0;C-=1)if(B=this.octets[C],B in S){if(L=S[B],w&&L!==0)return null;L!==8&&(w=!0),_+=L}else return null;return 32-_},f.prototype.range=function(){return v.subnetMatch(this,this.SpecialRanges)},f.prototype.toByteArray=function(){return this.octets.slice(0)},f.prototype.toIPv4MappedAddress=function(){return v.IPv6.parse(`::ffff:${this.toString()}`)},f.prototype.toNormalizedString=function(){return this.toString()},f.prototype.toString=function(){return this.octets.join(".")},f}(),v.IPv4.broadcastAddressFromCIDR=function(f){try{const _=this.parseCIDR(f),w=_[0].toByteArray(),S=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),C=[];let B=0;for(;B<4;)C.push(parseInt(w[B],10)|parseInt(S[B],10)^255),B++;return new this(C)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},v.IPv4.isIPv4=function(f){return this.parser(f)!==null},v.IPv4.isValid=function(f){try{return new this(this.parser(f)),!0}catch{return!1}},v.IPv4.isValidCIDR=function(f){try{return this.parseCIDR(f),!0}catch{return!1}},v.IPv4.isValidFourPartDecimal=function(f){return!!(v.IPv4.isValid(f)&&f.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},v.IPv4.networkAddressFromCIDR=function(f){let _,w,S,C,B;try{for(_=this.parseCIDR(f),S=_[0].toByteArray(),B=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),C=[],w=0;w<4;)C.push(parseInt(S[w],10)&parseInt(B[w],10)),w++;return new this(C)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},v.IPv4.parse=function(f){const _=this.parser(f);if(_===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(_)},v.IPv4.parseCIDR=function(f){let _;if(_=f.match(/^(.+)\/(\d+)$/)){const w=parseInt(_[2]);if(w>=0&&w<=32){const S=[this.parse(_[1]),w];return Object.defineProperty(S,"toString",{value:function(){return this.join("/")}}),S}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},v.IPv4.parser=function(f){let _,w,S;if(_=f.match(r.fourOctet))return function(){const C=_.slice(1,6),B=[];for(let L=0;L<C.length;L++)w=C[L],B.push(h(w));return B}();if(_=f.match(r.longValue)){if(S=h(_[1]),S>4294967295||S<0)throw new Error("ipaddr: address outside defined range");return function(){const C=[];let B;for(B=0;B<=24;B+=8)C.push(S>>B&255);return C}().reverse()}else return(_=f.match(r.twoOctet))?function(){const C=_.slice(1,4),B=[];if(S=h(C[1]),S>16777215||S<0)throw new Error("ipaddr: address outside defined range");return B.push(h(C[0])),B.push(S>>16&255),B.push(S>>8&255),B.push(S&255),B}():(_=f.match(r.threeOctet))?function(){const C=_.slice(1,5),B=[];if(S=h(C[2]),S>65535||S<0)throw new Error("ipaddr: address outside defined range");return B.push(h(C[0])),B.push(h(C[1])),B.push(S>>8&255),B.push(S&255),B}():null},v.IPv4.subnetMaskFromPrefixLength=function(f){if(f=parseInt(f),f<0||f>32)throw new Error("ipaddr: invalid IPv4 prefix length");const _=[0,0,0,0];let w=0;const S=Math.floor(f/8);for(;w<S;)_[w]=255,w++;return S<4&&(_[S]=Math.pow(2,f%8)-1<<8-f%8),new this(_)},v.IPv6=function(){function f(_,w){let S,C;if(_.length===16)for(this.parts=[],S=0;S<=14;S+=2)this.parts.push(_[S]<<8|_[S+1]);else if(_.length===8)this.parts=_;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(S=0;S<this.parts.length;S++)if(C=this.parts[S],!(0<=C&&C<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");w&&(this.zoneId=w)}return f.prototype.SpecialRanges={unspecified:[new f([0,0,0,0,0,0,0,0]),128],linkLocal:[new f([65152,0,0,0,0,0,0,0]),10],multicast:[new f([65280,0,0,0,0,0,0,0]),8],loopback:[new f([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new f([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new f([0,0,0,0,0,65535,0,0]),96],discard:[new f([256,0,0,0,0,0,0,0]),64],rfc6145:[new f([0,0,0,0,65535,0,0,0]),96],rfc6052:[new f([100,65435,0,0,0,0,0,0]),96],"6to4":[new f([8194,0,0,0,0,0,0,0]),16],teredo:[new f([8193,0,0,0,0,0,0,0]),32],benchmarking:[new f([8193,2,0,0,0,0,0,0]),48],amt:[new f([8193,3,0,0,0,0,0,0]),32],as112v6:[[new f([8193,4,274,0,0,0,0,0]),48],[new f([9760,79,32768,0,0,0,0,0]),48]],deprecated:[new f([8193,16,0,0,0,0,0,0]),28],orchid2:[new f([8193,32,0,0,0,0,0,0]),28],droneRemoteIdProtocolEntityTags:[new f([8193,48,0,0,0,0,0,0]),28],reserved:[[new f([8193,0,0,0,0,0,0,0]),23],[new f([8193,3512,0,0,0,0,0,0]),32]]},f.prototype.isIPv4MappedAddress=function(){return this.range()==="ipv4Mapped"},f.prototype.kind=function(){return"ipv6"},f.prototype.match=function(_,w){let S;if(w===void 0&&(S=_,_=S[0],w=S[1]),_.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return p(this.parts,_.parts,16,w)},f.prototype.prefixLengthFromSubnetMask=function(){let _=0,w=!1;const S={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0};let C,B;for(let L=7;L>=0;L-=1)if(C=this.parts[L],C in S){if(B=S[C],w&&B!==0)return null;B!==16&&(w=!0),_+=B}else return null;return 128-_},f.prototype.range=function(){return v.subnetMatch(this,this.SpecialRanges)},f.prototype.toByteArray=function(){let _;const w=[],S=this.parts;for(let C=0;C<S.length;C++)_=S[C],w.push(_>>8),w.push(_&255);return w},f.prototype.toFixedLengthString=function(){const _=(function(){const S=[];for(let C=0;C<this.parts.length;C++)S.push(m(this.parts[C].toString(16),4));return S}).call(this).join(":");let w="";return this.zoneId&&(w=`%${this.zoneId}`),_+w},f.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");const _=this.parts.slice(-2),w=_[0],S=_[1];return new v.IPv4([w>>8,w&255,S>>8,S&255])},f.prototype.toNormalizedString=function(){const _=(function(){const S=[];for(let C=0;C<this.parts.length;C++)S.push(this.parts[C].toString(16));return S}).call(this).join(":");let w="";return this.zoneId&&(w=`%${this.zoneId}`),_+w},f.prototype.toRFC5952String=function(){const _=/((^|:)(0(:|$)){2,})/g,w=this.toNormalizedString();let S=0,C=-1,B;for(;B=_.exec(w);)B[0].length>C&&(S=B.index,C=B[0].length);return C<0?w:`${w.substring(0,S)}::${w.substring(S+C)}`},f.prototype.toString=function(){return this.toRFC5952String()},f}(),v.IPv6.broadcastAddressFromCIDR=function(f){try{const _=this.parseCIDR(f),w=_[0].toByteArray(),S=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),C=[];let B=0;for(;B<16;)C.push(parseInt(w[B],10)|parseInt(S[B],10)^255),B++;return new this(C)}catch(_){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${_})`)}},v.IPv6.isIPv6=function(f){return this.parser(f)!==null},v.IPv6.isValid=function(f){if(typeof f=="string"&&f.indexOf(":")===-1)return!1;try{const _=this.parser(f);return new this(_.parts,_.zoneId),!0}catch{return!1}},v.IPv6.isValidCIDR=function(f){if(typeof f=="string"&&f.indexOf(":")===-1)return!1;try{return this.parseCIDR(f),!0}catch{return!1}},v.IPv6.networkAddressFromCIDR=function(f){let _,w,S,C,B;try{for(_=this.parseCIDR(f),S=_[0].toByteArray(),B=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),C=[],w=0;w<16;)C.push(parseInt(S[w],10)&parseInt(B[w],10)),w++;return new this(C)}catch(L){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${L})`)}},v.IPv6.parse=function(f){const _=this.parser(f);if(_.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(_.parts,_.zoneId)},v.IPv6.parseCIDR=function(f){let _,w,S;if((w=f.match(/^(.+)\/(\d+)$/))&&(_=parseInt(w[2]),_>=0&&_<=128))return S=[this.parse(w[1]),_],Object.defineProperty(S,"toString",{value:function(){return this.join("/")}}),S;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},v.IPv6.parser=function(f){let _,w,S,C,B,L;if(S=f.match(l.deprecatedTransitional))return this.parser(`::ffff:${S[1]}`);if(l.native.test(f))return u(f,8);if((S=f.match(l.transitional))&&(L=S[6]||"",_=S[1],S[1].endsWith("::")||(_=_.slice(0,-1)),_=u(_+L,6),_.parts)){for(B=[parseInt(S[2]),parseInt(S[3]),parseInt(S[4]),parseInt(S[5])],w=0;w<B.length;w++)if(C=B[w],!(0<=C&&C<=255))return null;return _.parts.push(B[0]<<8|B[1]),_.parts.push(B[2]<<8|B[3]),{parts:_.parts,zoneId:_.zoneId}}return null},v.IPv6.subnetMaskFromPrefixLength=function(f){if(f=parseInt(f),f<0||f>128)throw new Error("ipaddr: invalid IPv6 prefix length");const _=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];let w=0;const S=Math.floor(f/8);for(;w<S;)_[w]=255,w++;return S<16&&(_[S]=Math.pow(2,f%8)-1<<8-f%8),new this(_)},v.fromByteArray=function(f){const _=f.length;if(_===4)return new v.IPv4(f);if(_===16)return new v.IPv6(f);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},v.isValid=function(f){return v.IPv6.isValid(f)||v.IPv4.isValid(f)},v.isValidCIDR=function(f){return v.IPv6.isValidCIDR(f)||v.IPv4.isValidCIDR(f)},v.parse=function(f){if(v.IPv6.isValid(f))return v.IPv6.parse(f);if(v.IPv4.isValid(f))return v.IPv4.parse(f);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},v.parseCIDR=function(f){try{return v.IPv6.parseCIDR(f)}catch{try{return v.IPv4.parseCIDR(f)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},v.process=function(f){const _=this.parse(f);return _.kind()==="ipv6"&&_.isIPv4MappedAddress()?_.toIPv4Address():_},v.subnetMatch=function(f,_,w){let S,C,B,L;w==null&&(w="unicast");for(C in _)if(Object.prototype.hasOwnProperty.call(_,C)){for(B=_[C],B[0]&&!(B[0]instanceof Array)&&(B=[B]),S=0;S<B.length;S++)if(L=B[S],f.kind()===L[0].kind()&&f.match.apply(f,L))return C}return w},t.exports?t.exports=v:e.ipaddr=v})(as)})(Wh);var nd=Wh.exports;class rd{static decodeIP(e){if(e.length===64&&parseInt(e,16)===0)return"::/0";if(e.length!==16)return e;const n=parseInt(e.slice(8),16).toString(2).split("").reduce((i,s)=>i+ +s,0);let r=e.slice(0,8).replace(/(.{2})/g,i=>`${parseInt(i,16)}.`);return r=r.slice(0,-1),`${r}/${n}`}static toString(e){if(e.byteLength===4||e.byteLength===16){const n=new Uint8Array(e);return nd.fromByteArray(Array.from(n)).toString()}return this.decodeIP(J.ToHex(e))}static fromString(e){const n=nd.parse(e);return new Uint8Array(n.toByteArray()).buffer}}var Ta,Pa,Ra;let Te=class{constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};d([g({type:b.TeletexString})],Te.prototype,"teletexString",void 0);d([g({type:b.PrintableString})],Te.prototype,"printableString",void 0);d([g({type:b.UniversalString})],Te.prototype,"universalString",void 0);d([g({type:b.Utf8String})],Te.prototype,"utf8String",void 0);d([g({type:b.BmpString})],Te.prototype,"bmpString",void 0);Te=d([R({type:T.Choice})],Te);let Yn=class extends Te{constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?J.ToHex(this.anyValue):super.toString())}};d([g({type:b.IA5String})],Yn.prototype,"ia5String",void 0);d([g({type:b.Any})],Yn.prototype,"anyValue",void 0);Yn=d([R({type:T.Choice})],Yn);class xo{constructor(e={}){this.type="",this.value=new Yn,Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],xo.prototype,"type",void 0);d([g({type:Yn})],xo.prototype,"value",void 0);let Xn=Ta=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Ta.prototype)}};Xn=Ta=d([R({type:T.Set,itemType:xo})],Xn);let La=Pa=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Pa.prototype)}};La=Pa=d([R({type:T.Sequence,itemType:Xn})],La);let ke=Ra=class extends La{constructor(e){super(e),Object.setPrototypeOf(this,Ra.prototype)}};ke=Ra=d([R({type:T.Sequence})],ke);const rv={fromASN:t=>rd.toString(ps.fromASN(t)),toASN:t=>ps.toASN(rd.fromString(t))};class Dr{constructor(e={}){this.typeId="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],Dr.prototype,"typeId",void 0);d([g({type:b.Any,context:0})],Dr.prototype,"value",void 0);class El{constructor(e={}){this.partyName=new Te,Object.assign(this,e)}}d([g({type:Te,optional:!0,context:0,implicit:!0})],El.prototype,"nameAssigner",void 0);d([g({type:Te,context:1,implicit:!0})],El.prototype,"partyName",void 0);let re=class{constructor(e={}){Object.assign(this,e)}};d([g({type:Dr,context:0,implicit:!0})],re.prototype,"otherName",void 0);d([g({type:b.IA5String,context:1,implicit:!0})],re.prototype,"rfc822Name",void 0);d([g({type:b.IA5String,context:2,implicit:!0})],re.prototype,"dNSName",void 0);d([g({type:b.Any,context:3,implicit:!0})],re.prototype,"x400Address",void 0);d([g({type:ke,context:4,implicit:!1})],re.prototype,"directoryName",void 0);d([g({type:El,context:5})],re.prototype,"ediPartyName",void 0);d([g({type:b.IA5String,context:6,implicit:!0})],re.prototype,"uniformResourceIdentifier",void 0);d([g({type:b.OctetString,context:7,implicit:!0,converter:rv})],re.prototype,"iPAddress",void 0);d([g({type:b.ObjectIdentifier,context:8,implicit:!0})],re.prototype,"registeredID",void 0);re=d([R({type:T.Choice})],re);const Il="1.3.6.1.5.5.7",iv=`${Il}.1`,fr=`${Il}.3`,So=`${Il}.48`,id=`${So}.1`,sd=`${So}.2`,od=`${So}.3`,ad=`${So}.5`,an="2.5.29";var Ua;const Va=`${iv}.1`;class li{constructor(e={}){this.accessMethod="",this.accessLocation=new re,Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],li.prototype,"accessMethod",void 0);d([g({type:re})],li.prototype,"accessLocation",void 0);let Hn=Ua=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Ua.prototype)}};Hn=Ua=d([R({type:T.Sequence,itemType:li})],Hn);const qa=`${an}.35`;class zl extends ue{}class vn{constructor(e={}){e&&Object.assign(this,e)}}d([g({type:zl,context:0,optional:!0,implicit:!0})],vn.prototype,"keyIdentifier",void 0);d([g({type:re,context:1,optional:!0,implicit:!0,repeated:"sequence"})],vn.prototype,"authorityCertIssuer",void 0);d([g({type:b.Integer,context:2,optional:!0,implicit:!0,converter:_e})],vn.prototype,"authorityCertSerialNumber",void 0);const Gh=`${an}.19`;class fs{constructor(e={}){this.cA=!1,Object.assign(this,e)}}d([g({type:b.Boolean,defaultValue:!1})],fs.prototype,"cA",void 0);d([g({type:b.Integer,optional:!0})],fs.prototype,"pathLenConstraint",void 0);var Ma;let qe=Ma=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Ma.prototype)}};qe=Ma=d([R({type:T.Sequence,itemType:re})],qe);var Da;let cd=Da=class extends qe{constructor(e){super(e),Object.setPrototypeOf(this,Da.prototype)}};cd=Da=d([R({type:T.Sequence})],cd);var Ha;const Jh=`${an}.32`;let Rt=class{constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};d([g({type:b.IA5String})],Rt.prototype,"ia5String",void 0);d([g({type:b.VisibleString})],Rt.prototype,"visibleString",void 0);d([g({type:b.BmpString})],Rt.prototype,"bmpString",void 0);d([g({type:b.Utf8String})],Rt.prototype,"utf8String",void 0);Rt=d([R({type:T.Choice})],Rt);class Nl{constructor(e={}){this.organization=new Rt,this.noticeNumbers=[],Object.assign(this,e)}}d([g({type:Rt})],Nl.prototype,"organization",void 0);d([g({type:b.Integer,repeated:"sequence"})],Nl.prototype,"noticeNumbers",void 0);class Cl{constructor(e={}){Object.assign(this,e)}}d([g({type:Nl,optional:!0})],Cl.prototype,"noticeRef",void 0);d([g({type:Rt,optional:!0})],Cl.prototype,"explicitText",void 0);let hs=class{constructor(e={}){Object.assign(this,e)}};d([g({type:b.IA5String})],hs.prototype,"cPSuri",void 0);d([g({type:Cl})],hs.prototype,"userNotice",void 0);hs=d([R({type:T.Choice})],hs);class jl{constructor(e={}){this.policyQualifierId="",this.qualifier=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],jl.prototype,"policyQualifierId",void 0);d([g({type:b.Any})],jl.prototype,"qualifier",void 0);class Ao{constructor(e={}){this.policyIdentifier="",Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],Ao.prototype,"policyIdentifier",void 0);d([g({type:jl,repeated:"sequence",optional:!0})],Ao.prototype,"policyQualifiers",void 0);let gs=Ha=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Ha.prototype)}};gs=Ha=d([R({type:T.Sequence,itemType:Ao})],gs);let ms=class{constructor(e=0){this.value=e}};d([g({type:b.Integer})],ms.prototype,"value",void 0);ms=d([R({type:T.Choice})],ms);let ld=class extends ms{};ld=d([R({type:T.Choice})],ld);var Fa;const Ka=`${an}.31`;var dt;(function(t){t[t.unused=1]="unused",t[t.keyCompromise=2]="keyCompromise",t[t.cACompromise=4]="cACompromise",t[t.affiliationChanged=8]="affiliationChanged",t[t.superseded=16]="superseded",t[t.cessationOfOperation=32]="cessationOfOperation",t[t.certificateHold=64]="certificateHold",t[t.privilegeWithdrawn=128]="privilegeWithdrawn",t[t.aACompromise=256]="aACompromise"})(dt||(dt={}));class Zh extends ko{toJSON(){const e=[],n=this.toNumber();return n&dt.aACompromise&&e.push("aACompromise"),n&dt.affiliationChanged&&e.push("affiliationChanged"),n&dt.cACompromise&&e.push("cACompromise"),n&dt.certificateHold&&e.push("certificateHold"),n&dt.cessationOfOperation&&e.push("cessationOfOperation"),n&dt.keyCompromise&&e.push("keyCompromise"),n&dt.privilegeWithdrawn&&e.push("privilegeWithdrawn"),n&dt.superseded&&e.push("superseded"),n&dt.unused&&e.push("unused"),e}toString(){return`[${this.toJSON().join(", ")}]`}}let En=class{constructor(e={}){Object.assign(this,e)}};d([g({type:re,context:0,repeated:"sequence",implicit:!0})],En.prototype,"fullName",void 0);d([g({type:Xn,context:1,implicit:!0})],En.prototype,"nameRelativeToCRLIssuer",void 0);En=d([R({type:T.Choice})],En);class hr{constructor(e={}){Object.assign(this,e)}}d([g({type:En,context:0,optional:!0})],hr.prototype,"distributionPoint",void 0);d([g({type:Zh,context:1,optional:!0,implicit:!0})],hr.prototype,"reasons",void 0);d([g({type:re,context:2,optional:!0,repeated:"sequence",implicit:!0})],hr.prototype,"cRLIssuer",void 0);let Wn=Fa=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Fa.prototype)}};Wn=Fa=d([R({type:T.Sequence,itemType:hr})],Wn);var Wa;let ud=Wa=class extends Wn{constructor(e){super(e),Object.setPrototypeOf(this,Wa.prototype)}};ud=Wa=d([R({type:T.Sequence,itemType:hr})],ud);class Le{constructor(e={}){this.onlyContainsUserCerts=Le.ONLY,this.onlyContainsCACerts=Le.ONLY,this.indirectCRL=Le.ONLY,this.onlyContainsAttributeCerts=Le.ONLY,Object.assign(this,e)}}Le.ONLY=!1;d([g({type:En,context:0,optional:!0})],Le.prototype,"distributionPoint",void 0);d([g({type:b.Boolean,context:1,defaultValue:Le.ONLY,implicit:!0})],Le.prototype,"onlyContainsUserCerts",void 0);d([g({type:b.Boolean,context:2,defaultValue:Le.ONLY,implicit:!0})],Le.prototype,"onlyContainsCACerts",void 0);d([g({type:Zh,context:3,optional:!0,implicit:!0})],Le.prototype,"onlySomeReasons",void 0);d([g({type:b.Boolean,context:4,defaultValue:Le.ONLY,implicit:!0})],Le.prototype,"indirectCRL",void 0);d([g({type:b.Boolean,context:5,defaultValue:Le.ONLY,implicit:!0})],Le.prototype,"onlyContainsAttributeCerts",void 0);var Tr;(function(t){t[t.unspecified=0]="unspecified",t[t.keyCompromise=1]="keyCompromise",t[t.cACompromise=2]="cACompromise",t[t.affiliationChanged=3]="affiliationChanged",t[t.superseded=4]="superseded",t[t.cessationOfOperation=5]="cessationOfOperation",t[t.certificateHold=6]="certificateHold",t[t.removeFromCRL=8]="removeFromCRL",t[t.privilegeWithdrawn=9]="privilegeWithdrawn",t[t.aACompromise=10]="aACompromise"})(Tr||(Tr={}));let Ga=class{constructor(e=Tr.unspecified){this.reason=Tr.unspecified,this.reason=e}toJSON(){return Tr[this.reason]}toString(){return this.toJSON()}};d([g({type:b.Enumerated})],Ga.prototype,"reason",void 0);Ga=d([R({type:T.Choice})],Ga);var Ja;const Yh=`${an}.37`;let _s=Ja=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Ja.prototype)}};_s=Ja=d([R({type:T.Sequence,itemType:b.ObjectIdentifier})],_s);const sv=`${fr}.1`,ov=`${fr}.2`,av=`${fr}.3`,cv=`${fr}.4`,lv=`${fr}.8`,uv=`${fr}.9`;let Za=class{constructor(e=new ArrayBuffer(0)){this.value=e}};d([g({type:b.Integer,converter:_e})],Za.prototype,"value",void 0);Za=d([R({type:T.Choice})],Za);let Ya=class{constructor(e){this.value=new Date,e&&(this.value=e)}};d([g({type:b.GeneralizedTime})],Ya.prototype,"value",void 0);Ya=d([R({type:T.Choice})],Ya);var Xa;let dd=Xa=class extends qe{constructor(e){super(e),Object.setPrototypeOf(this,Xa.prototype)}};dd=Xa=d([R({type:T.Sequence})],dd);const Xh=`${an}.15`;var pt;(function(t){t[t.digitalSignature=1]="digitalSignature",t[t.nonRepudiation=2]="nonRepudiation",t[t.keyEncipherment=4]="keyEncipherment",t[t.dataEncipherment=8]="dataEncipherment",t[t.keyAgreement=16]="keyAgreement",t[t.keyCertSign=32]="keyCertSign",t[t.cRLSign=64]="cRLSign",t[t.encipherOnly=128]="encipherOnly",t[t.decipherOnly=256]="decipherOnly"})(pt||(pt={}));class ia extends ko{toJSON(){const e=this.toNumber(),n=[];return e&pt.cRLSign&&n.push("crlSign"),e&pt.dataEncipherment&&n.push("dataEncipherment"),e&pt.decipherOnly&&n.push("decipherOnly"),e&pt.digitalSignature&&n.push("digitalSignature"),e&pt.encipherOnly&&n.push("encipherOnly"),e&pt.keyAgreement&&n.push("keyAgreement"),e&pt.keyCertSign&&n.push("keyCertSign"),e&pt.keyEncipherment&&n.push("keyEncipherment"),e&pt.nonRepudiation&&n.push("nonRepudiation"),n}toString(){return`[${this.toJSON().join(", ")}]`}}var Qa;class Eo{constructor(e={}){this.base=new re,this.minimum=0,Object.assign(this,e)}}d([g({type:re})],Eo.prototype,"base",void 0);d([g({type:b.Integer,context:0,defaultValue:0,implicit:!0})],Eo.prototype,"minimum",void 0);d([g({type:b.Integer,context:1,optional:!0,implicit:!0})],Eo.prototype,"maximum",void 0);let ys=Qa=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Qa.prototype)}};ys=Qa=d([R({type:T.Sequence,itemType:Eo})],ys);class Qh{constructor(e={}){Object.assign(this,e)}}d([g({type:ys,context:0,optional:!0,implicit:!0})],Qh.prototype,"permittedSubtrees",void 0);d([g({type:ys,context:1,optional:!0,implicit:!0})],Qh.prototype,"excludedSubtrees",void 0);class eg{constructor(e={}){Object.assign(this,e)}}d([g({type:b.Integer,context:0,implicit:!0,optional:!0,converter:_e})],eg.prototype,"requireExplicitPolicy",void 0);d([g({type:b.Integer,context:1,implicit:!0,optional:!0,converter:_e})],eg.prototype,"inhibitPolicyMapping",void 0);var ec;class $l{constructor(e={}){this.issuerDomainPolicy="",this.subjectDomainPolicy="",Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],$l.prototype,"issuerDomainPolicy",void 0);d([g({type:b.ObjectIdentifier})],$l.prototype,"subjectDomainPolicy",void 0);let pd=ec=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,ec.prototype)}};pd=ec=d([R({type:T.Sequence,itemType:$l})],pd);var tc;const tg=`${an}.17`;let nc=tc=class extends qe{constructor(e){super(e),Object.setPrototypeOf(this,tc.prototype)}};nc=tc=d([R({type:T.Sequence})],nc);let Lt=class{constructor(e={}){this.type="",this.values=[],Object.assign(this,e)}};d([g({type:b.ObjectIdentifier})],Lt.prototype,"type",void 0);d([g({type:b.Any,repeated:"set"})],Lt.prototype,"values",void 0);var rc;let fd=rc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,rc.prototype)}};fd=rc=d([R({type:T.Sequence,itemType:Lt})],fd);const ng=`${an}.14`;class Jt extends zl{}class rg{constructor(e={}){Object.assign(this,e)}}d([g({type:b.GeneralizedTime,context:0,implicit:!0,optional:!0})],rg.prototype,"notBefore",void 0);d([g({type:b.GeneralizedTime,context:1,implicit:!0,optional:!0})],rg.prototype,"notAfter",void 0);var Pr;(function(t){t[t.keyUpdateAllowed=1]="keyUpdateAllowed",t[t.newExtensions=2]="newExtensions",t[t.pKIXCertificate=4]="pKIXCertificate"})(Pr||(Pr={}));class ig extends ko{toJSON(){const e=[],n=this.toNumber();return n&Pr.pKIXCertificate&&e.push("pKIXCertificate"),n&Pr.newExtensions&&e.push("newExtensions"),n&Pr.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return`[${this.toJSON().join(", ")}]`}}class sg{constructor(e={}){this.entrustVers="",this.entrustInfoFlags=new ig,Object.assign(this,e)}}d([g({type:b.GeneralString})],sg.prototype,"entrustVers",void 0);d([g({type:ig})],sg.prototype,"entrustInfoFlags",void 0);var ic;let hd=ic=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,ic.prototype)}};hd=ic=d([R({type:T.Sequence,itemType:li})],hd);class F{constructor(e={}){this.algorithm="",Object.assign(this,e)}isEqual(e){return e instanceof F&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&Ff(e.parameters,this.parameters)||e.parameters===this.parameters)}}d([g({type:b.ObjectIdentifier})],F.prototype,"algorithm",void 0);d([g({type:b.Any,optional:!0})],F.prototype,"parameters",void 0);class ft{constructor(e={}){this.algorithm=new F,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:F})],ft.prototype,"algorithm",void 0);d([g({type:b.BitString})],ft.prototype,"subjectPublicKey",void 0);let Oe=class{constructor(e){if(e)if(typeof e=="string"||typeof e=="number"||e instanceof Date){const n=new Date(e);n.getUTCFullYear()>2049?this.generalTime=n:this.utcTime=n}else Object.assign(this,e)}getTime(){const e=this.utcTime||this.generalTime;if(!e)throw new Error("Cannot get time from CHOICE object");return e}};d([g({type:b.UTCTime})],Oe.prototype,"utcTime",void 0);d([g({type:b.GeneralizedTime})],Oe.prototype,"generalTime",void 0);Oe=d([R({type:T.Choice})],Oe);class ui{constructor(e){this.notBefore=new Oe(new Date),this.notAfter=new Oe(new Date),e&&(this.notBefore=new Oe(e.notBefore),this.notAfter=new Oe(e.notAfter))}}d([g({type:Oe})],ui.prototype,"notBefore",void 0);d([g({type:Oe})],ui.prototype,"notAfter",void 0);var sc;let ot=class og{constructor(e={}){this.extnID="",this.critical=og.CRITICAL,this.extnValue=new ue,Object.assign(this,e)}};ot.CRITICAL=!1;d([g({type:b.ObjectIdentifier})],ot.prototype,"extnID",void 0);d([g({type:b.Boolean,defaultValue:ot.CRITICAL})],ot.prototype,"critical",void 0);d([g({type:ue})],ot.prototype,"extnValue",void 0);let Qt=sc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,sc.prototype)}};Qt=sc=d([R({type:T.Sequence,itemType:ot})],Qt);var In;(function(t){t[t.v1=0]="v1",t[t.v2=1]="v2",t[t.v3=2]="v3"})(In||(In={}));class tt{constructor(e={}){this.version=In.v1,this.serialNumber=new ArrayBuffer(0),this.signature=new F,this.issuer=new ke,this.validity=new ui,this.subject=new ke,this.subjectPublicKeyInfo=new ft,Object.assign(this,e)}}d([g({type:b.Integer,context:0,defaultValue:In.v1})],tt.prototype,"version",void 0);d([g({type:b.Integer,converter:_e})],tt.prototype,"serialNumber",void 0);d([g({type:F})],tt.prototype,"signature",void 0);d([g({type:ke})],tt.prototype,"issuer",void 0);d([g({type:ui})],tt.prototype,"validity",void 0);d([g({type:ke})],tt.prototype,"subject",void 0);d([g({type:ft})],tt.prototype,"subjectPublicKeyInfo",void 0);d([g({type:b.BitString,context:1,implicit:!0,optional:!0})],tt.prototype,"issuerUniqueID",void 0);d([g({type:b.BitString,context:2,implicit:!0,optional:!0})],tt.prototype,"subjectUniqueID",void 0);d([g({type:Qt,context:3,optional:!0})],tt.prototype,"extensions",void 0);class zn{constructor(e={}){this.tbsCertificate=new tt,this.signatureAlgorithm=new F,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:tt})],zn.prototype,"tbsCertificate",void 0);d([g({type:F})],zn.prototype,"signatureAlgorithm",void 0);d([g({type:b.BitString})],zn.prototype,"signatureValue",void 0);class Io{constructor(e={}){this.userCertificate=new ArrayBuffer(0),this.revocationDate=new Oe,Object.assign(this,e)}}d([g({type:b.Integer,converter:_e})],Io.prototype,"userCertificate",void 0);d([g({type:Oe})],Io.prototype,"revocationDate",void 0);d([g({type:ot,optional:!0,repeated:"sequence"})],Io.prototype,"crlEntryExtensions",void 0);class Ht{constructor(e={}){this.signature=new F,this.issuer=new ke,this.thisUpdate=new Oe,Object.assign(this,e)}}d([g({type:b.Integer,optional:!0})],Ht.prototype,"version",void 0);d([g({type:F})],Ht.prototype,"signature",void 0);d([g({type:ke})],Ht.prototype,"issuer",void 0);d([g({type:Oe})],Ht.prototype,"thisUpdate",void 0);d([g({type:Oe,optional:!0})],Ht.prototype,"nextUpdate",void 0);d([g({type:Io,repeated:"sequence",optional:!0})],Ht.prototype,"revokedCertificates",void 0);d([g({type:ot,optional:!0,context:0,repeated:"sequence"})],Ht.prototype,"crlExtensions",void 0);class Ol{constructor(e={}){this.tbsCertList=new Ht,this.signatureAlgorithm=new F,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:Ht})],Ol.prototype,"tbsCertList",void 0);d([g({type:F})],Ol.prototype,"signatureAlgorithm",void 0);d([g({type:b.BitString})],Ol.prototype,"signature",void 0);class gr{constructor(e={}){this.issuer=new ke,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:ke})],gr.prototype,"issuer",void 0);d([g({type:b.Integer,converter:_e})],gr.prototype,"serialNumber",void 0);let Qn=class{constructor(e={}){Object.assign(this,e)}};d([g({type:Jt,context:0,implicit:!0})],Qn.prototype,"subjectKeyIdentifier",void 0);d([g({type:gr})],Qn.prototype,"issuerAndSerialNumber",void 0);Qn=d([R({type:T.Choice})],Qn);var Ut;(function(t){t[t.v0=0]="v0",t[t.v1=1]="v1",t[t.v2=2]="v2",t[t.v3=3]="v3",t[t.v4=4]="v4",t[t.v5=5]="v5"})(Ut||(Ut={}));let Hr=class extends F{};Hr=d([R({type:T.Sequence})],Hr);let vs=class extends F{};vs=d([R({type:T.Sequence})],vs);let Et=class extends F{};Et=d([R({type:T.Sequence})],Et);let ws=class extends F{};ws=d([R({type:T.Sequence})],ws);let gd=class extends F{};gd=d([R({type:T.Sequence})],gd);let oc=class extends F{};oc=d([R({type:T.Sequence})],oc);let mr=class{constructor(e={}){this.attrType="",this.attrValues=[],Object.assign(this,e)}};d([g({type:b.ObjectIdentifier})],mr.prototype,"attrType",void 0);d([g({type:b.Any,repeated:"set"})],mr.prototype,"attrValues",void 0);var ac;class Ct{constructor(e={}){this.version=Ut.v0,this.sid=new Qn,this.digestAlgorithm=new Hr,this.signatureAlgorithm=new vs,this.signature=new ue,Object.assign(this,e)}}d([g({type:b.Integer})],Ct.prototype,"version",void 0);d([g({type:Qn})],Ct.prototype,"sid",void 0);d([g({type:Hr})],Ct.prototype,"digestAlgorithm",void 0);d([g({type:mr,repeated:"set",context:0,implicit:!0,optional:!0})],Ct.prototype,"signedAttrs",void 0);d([g({type:vs})],Ct.prototype,"signatureAlgorithm",void 0);d([g({type:ue})],Ct.prototype,"signature",void 0);d([g({type:mr,repeated:"set",context:1,implicit:!0,optional:!0})],Ct.prototype,"unsignedAttrs",void 0);let bs=ac=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,ac.prototype)}};bs=ac=d([R({type:T.Set,itemType:Ct})],bs);let md=class extends Oe{};md=d([R({type:T.Choice})],md);let _d=class extends Ct{};_d=d([R({type:T.Sequence})],_d);class Bl{constructor(e={}){this.acIssuer=new re,this.acSerial=0,this.attrs=[],Object.assign(this,e)}}d([g({type:re})],Bl.prototype,"acIssuer",void 0);d([g({type:b.Integer})],Bl.prototype,"acSerial",void 0);d([g({type:Lt,repeated:"sequence"})],Bl.prototype,"attrs",void 0);var cc;let ks=cc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,cc.prototype)}};ks=cc=d([R({type:T.Sequence,itemType:b.ObjectIdentifier})],ks);class zo{constructor(e={}){this.permitUnSpecified=!0,Object.assign(this,e)}}d([g({type:b.Integer,optional:!0})],zo.prototype,"pathLenConstraint",void 0);d([g({type:ks,implicit:!0,context:0,optional:!0})],zo.prototype,"permittedAttrs",void 0);d([g({type:ks,implicit:!0,context:1,optional:!0})],zo.prototype,"excludedAttrs",void 0);d([g({type:b.Boolean,defaultValue:!0})],zo.prototype,"permitUnSpecified",void 0);class Rn{constructor(e={}){this.issuer=new qe,this.serial=new ArrayBuffer(0),this.issuerUID=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:qe})],Rn.prototype,"issuer",void 0);d([g({type:b.Integer,converter:_e})],Rn.prototype,"serial",void 0);d([g({type:b.BitString,optional:!0})],Rn.prototype,"issuerUID",void 0);var lc;(function(t){t[t.publicKey=0]="publicKey",t[t.publicKeyCert=1]="publicKeyCert",t[t.otherObjectTypes=2]="otherObjectTypes"})(lc||(lc={}));class Ln{constructor(e={}){this.digestedObjectType=lc.publicKey,this.digestAlgorithm=new F,this.objectDigest=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.Enumerated})],Ln.prototype,"digestedObjectType",void 0);d([g({type:b.ObjectIdentifier,optional:!0})],Ln.prototype,"otherObjectTypeID",void 0);d([g({type:F})],Ln.prototype,"digestAlgorithm",void 0);d([g({type:b.BitString})],Ln.prototype,"objectDigest",void 0);class No{constructor(e={}){Object.assign(this,e)}}d([g({type:qe,optional:!0})],No.prototype,"issuerName",void 0);d([g({type:Rn,context:0,implicit:!0,optional:!0})],No.prototype,"baseCertificateID",void 0);d([g({type:Ln,context:1,implicit:!0,optional:!0})],No.prototype,"objectDigestInfo",void 0);let er=class{constructor(e={}){Object.assign(this,e)}};d([g({type:re,repeated:"sequence"})],er.prototype,"v1Form",void 0);d([g({type:No,context:0,implicit:!0})],er.prototype,"v2Form",void 0);er=d([R({type:T.Choice})],er);class Co{constructor(e={}){this.notBeforeTime=new Date,this.notAfterTime=new Date,Object.assign(this,e)}}d([g({type:b.GeneralizedTime})],Co.prototype,"notBeforeTime",void 0);d([g({type:b.GeneralizedTime})],Co.prototype,"notAfterTime",void 0);class di{constructor(e={}){Object.assign(this,e)}}d([g({type:Rn,implicit:!0,context:0,optional:!0})],di.prototype,"baseCertificateID",void 0);d([g({type:qe,implicit:!0,context:1,optional:!0})],di.prototype,"entityName",void 0);d([g({type:Ln,implicit:!0,context:2,optional:!0})],di.prototype,"objectDigestInfo",void 0);var uc;(function(t){t[t.v2=1]="v2"})(uc||(uc={}));class vt{constructor(e={}){this.version=uc.v2,this.holder=new di,this.issuer=new er,this.signature=new F,this.serialNumber=new ArrayBuffer(0),this.attrCertValidityPeriod=new Co,this.attributes=[],Object.assign(this,e)}}d([g({type:b.Integer})],vt.prototype,"version",void 0);d([g({type:di})],vt.prototype,"holder",void 0);d([g({type:er})],vt.prototype,"issuer",void 0);d([g({type:F})],vt.prototype,"signature",void 0);d([g({type:b.Integer,converter:_e})],vt.prototype,"serialNumber",void 0);d([g({type:Co})],vt.prototype,"attrCertValidityPeriod",void 0);d([g({type:Lt,repeated:"sequence"})],vt.prototype,"attributes",void 0);d([g({type:b.BitString,optional:!0})],vt.prototype,"issuerUniqueID",void 0);d([g({type:Qt,optional:!0})],vt.prototype,"extensions",void 0);class jo{constructor(e={}){this.acinfo=new vt,this.signatureAlgorithm=new F,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:vt})],jo.prototype,"acinfo",void 0);d([g({type:F})],jo.prototype,"signatureAlgorithm",void 0);d([g({type:b.BitString})],jo.prototype,"signatureValue",void 0);var xs;(function(t){t[t.unmarked=1]="unmarked",t[t.unclassified=2]="unclassified",t[t.restricted=4]="restricted",t[t.confidential=8]="confidential",t[t.secret=16]="secret",t[t.topSecret=32]="topSecret"})(xs||(xs={}));class dc extends ko{}class Tl{constructor(e={}){this.type="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier,implicit:!0,context:0})],Tl.prototype,"type",void 0);d([g({type:b.Any,implicit:!0,context:1})],Tl.prototype,"value",void 0);class Pl{constructor(e={}){this.policyId="",this.classList=new dc(xs.unclassified),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],Pl.prototype,"policyId",void 0);d([g({type:dc,defaultValue:new dc(xs.unclassified)})],Pl.prototype,"classList",void 0);d([g({type:Tl,repeated:"set"})],Pl.prototype,"securityCategories",void 0);class $o{constructor(e={}){Object.assign(this,e)}}d([g({type:ue})],$o.prototype,"cotets",void 0);d([g({type:b.ObjectIdentifier})],$o.prototype,"oid",void 0);d([g({type:b.Utf8String})],$o.prototype,"string",void 0);class ag{constructor(e={}){this.values=[],Object.assign(this,e)}}d([g({type:qe,implicit:!0,context:0,optional:!0})],ag.prototype,"policyAuthority",void 0);d([g({type:$o,repeated:"sequence"})],ag.prototype,"values",void 0);var pc;class Oo{constructor(e={}){this.targetCertificate=new Rn,Object.assign(this,e)}}d([g({type:Rn})],Oo.prototype,"targetCertificate",void 0);d([g({type:re,optional:!0})],Oo.prototype,"targetName",void 0);d([g({type:Ln,optional:!0})],Oo.prototype,"certDigestInfo",void 0);let tr=class{constructor(e={}){Object.assign(this,e)}};d([g({type:re,context:0,implicit:!0})],tr.prototype,"targetName",void 0);d([g({type:re,context:1,implicit:!0})],tr.prototype,"targetGroup",void 0);d([g({type:Oo,context:2,implicit:!0})],tr.prototype,"targetCert",void 0);tr=d([R({type:T.Choice})],tr);let fc=pc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,pc.prototype)}};fc=pc=d([R({type:T.Sequence,itemType:tr})],fc);var hc;let yd=hc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,hc.prototype)}};yd=hc=d([R({type:T.Sequence,itemType:fc})],yd);class cg{constructor(e={}){Object.assign(this,e)}}d([g({type:qe,implicit:!0,context:0,optional:!0})],cg.prototype,"roleAuthority",void 0);d([g({type:re,implicit:!0,context:1})],cg.prototype,"roleName",void 0);class Rl{constructor(e={}){this.service=new re,this.ident=new re,Object.assign(this,e)}}d([g({type:re})],Rl.prototype,"service",void 0);d([g({type:re})],Rl.prototype,"ident",void 0);d([g({type:ue,optional:!0})],Rl.prototype,"authInfo",void 0);var gc;class Ll{constructor(e={}){this.otherCertFormat="",this.otherCert=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],Ll.prototype,"otherCertFormat",void 0);d([g({type:b.Any})],Ll.prototype,"otherCert",void 0);let nr=class{constructor(e={}){Object.assign(this,e)}};d([g({type:zn})],nr.prototype,"certificate",void 0);d([g({type:jo,context:2,implicit:!0})],nr.prototype,"v2AttrCert",void 0);d([g({type:Ll,context:3,implicit:!0})],nr.prototype,"other",void 0);nr=d([R({type:T.Choice})],nr);let Ss=gc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,gc.prototype)}};Ss=gc=d([R({type:T.Set,itemType:nr})],Ss);class _r{constructor(e={}){this.contentType="",this.content=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],_r.prototype,"contentType",void 0);d([g({type:b.Any,context:0})],_r.prototype,"content",void 0);let Fr=class{constructor(e={}){Object.assign(this,e)}};d([g({type:ue})],Fr.prototype,"single",void 0);d([g({type:b.Any})],Fr.prototype,"any",void 0);Fr=d([R({type:T.Choice})],Fr);class Bo{constructor(e={}){this.eContentType="",Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],Bo.prototype,"eContentType",void 0);d([g({type:Fr,context:0,optional:!0})],Bo.prototype,"eContent",void 0);let Kr=class{constructor(e={}){Object.assign(this,e)}};d([g({type:ue,context:0,implicit:!0,optional:!0})],Kr.prototype,"value",void 0);d([g({type:ue,converter:Uy,context:0,implicit:!0,optional:!0,repeated:"sequence"})],Kr.prototype,"constructedValue",void 0);Kr=d([R({type:T.Choice})],Kr);class pi{constructor(e={}){this.contentType="",this.contentEncryptionAlgorithm=new ws,Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],pi.prototype,"contentType",void 0);d([g({type:ws})],pi.prototype,"contentEncryptionAlgorithm",void 0);d([g({type:Kr,optional:!0})],pi.prototype,"encryptedContent",void 0);class To{constructor(e={}){this.keyAttrId="",Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],To.prototype,"keyAttrId",void 0);d([g({type:b.Any,optional:!0})],To.prototype,"keyAttr",void 0);var mc;class Po{constructor(e={}){this.subjectKeyIdentifier=new Jt,Object.assign(this,e)}}d([g({type:Jt})],Po.prototype,"subjectKeyIdentifier",void 0);d([g({type:b.GeneralizedTime,optional:!0})],Po.prototype,"date",void 0);d([g({type:To,optional:!0})],Po.prototype,"other",void 0);let rr=class{constructor(e={}){Object.assign(this,e)}};d([g({type:Po,context:0,implicit:!0,optional:!0})],rr.prototype,"rKeyId",void 0);d([g({type:gr,optional:!0})],rr.prototype,"issuerAndSerialNumber",void 0);rr=d([R({type:T.Choice})],rr);class Ul{constructor(e={}){this.rid=new rr,this.encryptedKey=new ue,Object.assign(this,e)}}d([g({type:rr})],Ul.prototype,"rid",void 0);d([g({type:ue})],Ul.prototype,"encryptedKey",void 0);let As=mc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,mc.prototype)}};As=mc=d([R({type:T.Sequence,itemType:Ul})],As);class Vl{constructor(e={}){this.algorithm=new F,this.publicKey=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:F})],Vl.prototype,"algorithm",void 0);d([g({type:b.BitString})],Vl.prototype,"publicKey",void 0);let Nn=class{constructor(e={}){Object.assign(this,e)}};d([g({type:Jt,context:0,implicit:!0,optional:!0})],Nn.prototype,"subjectKeyIdentifier",void 0);d([g({type:Vl,context:1,implicit:!0,optional:!0})],Nn.prototype,"originatorKey",void 0);d([g({type:gr,optional:!0})],Nn.prototype,"issuerAndSerialNumber",void 0);Nn=d([R({type:T.Choice})],Nn);class yr{constructor(e={}){this.version=Ut.v3,this.originator=new Nn,this.keyEncryptionAlgorithm=new Et,this.recipientEncryptedKeys=new As,Object.assign(this,e)}}d([g({type:b.Integer})],yr.prototype,"version",void 0);d([g({type:Nn,context:0})],yr.prototype,"originator",void 0);d([g({type:ue,context:1,optional:!0})],yr.prototype,"ukm",void 0);d([g({type:Et})],yr.prototype,"keyEncryptionAlgorithm",void 0);d([g({type:As})],yr.prototype,"recipientEncryptedKeys",void 0);let ir=class{constructor(e={}){Object.assign(this,e)}};d([g({type:Jt,context:0,implicit:!0})],ir.prototype,"subjectKeyIdentifier",void 0);d([g({type:gr})],ir.prototype,"issuerAndSerialNumber",void 0);ir=d([R({type:T.Choice})],ir);class fi{constructor(e={}){this.version=Ut.v0,this.rid=new ir,this.keyEncryptionAlgorithm=new Et,this.encryptedKey=new ue,Object.assign(this,e)}}d([g({type:b.Integer})],fi.prototype,"version",void 0);d([g({type:ir})],fi.prototype,"rid",void 0);d([g({type:Et})],fi.prototype,"keyEncryptionAlgorithm",void 0);d([g({type:ue})],fi.prototype,"encryptedKey",void 0);class hi{constructor(e={}){this.keyIdentifier=new ue,Object.assign(this,e)}}d([g({type:ue})],hi.prototype,"keyIdentifier",void 0);d([g({type:b.GeneralizedTime,optional:!0})],hi.prototype,"date",void 0);d([g({type:To,optional:!0})],hi.prototype,"other",void 0);class gi{constructor(e={}){this.version=Ut.v4,this.kekid=new hi,this.keyEncryptionAlgorithm=new Et,this.encryptedKey=new ue,Object.assign(this,e)}}d([g({type:b.Integer})],gi.prototype,"version",void 0);d([g({type:hi})],gi.prototype,"kekid",void 0);d([g({type:Et})],gi.prototype,"keyEncryptionAlgorithm",void 0);d([g({type:ue})],gi.prototype,"encryptedKey",void 0);class mi{constructor(e={}){this.version=Ut.v0,this.keyEncryptionAlgorithm=new Et,this.encryptedKey=new ue,Object.assign(this,e)}}d([g({type:b.Integer})],mi.prototype,"version",void 0);d([g({type:oc,context:0,optional:!0})],mi.prototype,"keyDerivationAlgorithm",void 0);d([g({type:Et})],mi.prototype,"keyEncryptionAlgorithm",void 0);d([g({type:ue})],mi.prototype,"encryptedKey",void 0);class ql{constructor(e={}){this.oriType="",this.oriValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],ql.prototype,"oriType",void 0);d([g({type:b.Any})],ql.prototype,"oriValue",void 0);let en=class{constructor(e={}){Object.assign(this,e)}};d([g({type:fi,optional:!0})],en.prototype,"ktri",void 0);d([g({type:yr,context:1,implicit:!0,optional:!0})],en.prototype,"kari",void 0);d([g({type:gi,context:2,implicit:!0,optional:!0})],en.prototype,"kekri",void 0);d([g({type:mi,context:3,implicit:!0,optional:!0})],en.prototype,"pwri",void 0);d([g({type:ql,context:4,implicit:!0,optional:!0})],en.prototype,"ori",void 0);en=d([R({type:T.Choice})],en);var _c;let Es=_c=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,_c.prototype)}};Es=_c=d([R({type:T.Set,itemType:en})],Es);var yc;class Ro{constructor(e={}){this.otherRevInfoFormat="",this.otherRevInfo=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],Ro.prototype,"otherRevInfoFormat",void 0);d([g({type:b.Any})],Ro.prototype,"otherRevInfo",void 0);let Is=class{constructor(e={}){this.other=new Ro,Object.assign(this,e)}};d([g({type:Ro,context:1,implicit:!0})],Is.prototype,"other",void 0);Is=d([R({type:T.Choice})],Is);let zs=yc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,yc.prototype)}};zs=yc=d([R({type:T.Set,itemType:Is})],zs);class Ml{constructor(e={}){Object.assign(this,e)}}d([g({type:Ss,context:0,implicit:!0,optional:!0})],Ml.prototype,"certs",void 0);d([g({type:zs,context:1,implicit:!0,optional:!0})],Ml.prototype,"crls",void 0);var vc;let wc=vc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,vc.prototype)}};wc=vc=d([R({type:T.Set,itemType:mr})],wc);class _i{constructor(e={}){this.version=Ut.v0,this.recipientInfos=new Es,this.encryptedContentInfo=new pi,Object.assign(this,e)}}d([g({type:b.Integer})],_i.prototype,"version",void 0);d([g({type:Ml,context:0,implicit:!0,optional:!0})],_i.prototype,"originatorInfo",void 0);d([g({type:Es})],_i.prototype,"recipientInfos",void 0);d([g({type:pi})],_i.prototype,"encryptedContentInfo",void 0);d([g({type:wc,context:1,implicit:!0,optional:!0})],_i.prototype,"unprotectedAttrs",void 0);const dv="1.2.840.113549.1.7.2";var bc;let Ns=bc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,bc.prototype)}};Ns=bc=d([R({type:T.Set,itemType:Hr})],Ns);class vr{constructor(e={}){this.version=Ut.v0,this.digestAlgorithms=new Ns,this.encapContentInfo=new Bo,this.signerInfos=new bs,Object.assign(this,e)}}d([g({type:b.Integer})],vr.prototype,"version",void 0);d([g({type:Ns})],vr.prototype,"digestAlgorithms",void 0);d([g({type:Bo})],vr.prototype,"encapContentInfo",void 0);d([g({type:Ss,context:0,implicit:!0,optional:!0})],vr.prototype,"certificates",void 0);d([g({type:zs,context:1,implicit:!0,optional:!0})],vr.prototype,"crls",void 0);d([g({type:bs})],vr.prototype,"signerInfos",void 0);const Wr="1.2.840.10045.2.1",Dl="1.2.840.10045.4.1",lg="1.2.840.10045.4.3.1",Hl="1.2.840.10045.4.3.2",Fl="1.2.840.10045.4.3.3",Kl="1.2.840.10045.4.3.4",vd="1.2.840.10045.3.1.7",wd="1.3.132.0.34",bd="1.3.132.0.35";function yi(t){return new F({algorithm:t})}const pv=yi(Dl);yi(lg);const fv=yi(Hl),hv=yi(Fl),gv=yi(Kl);let Gr=class{constructor(e={}){Object.assign(this,e)}};d([g({type:b.ObjectIdentifier})],Gr.prototype,"fieldType",void 0);d([g({type:b.Any})],Gr.prototype,"parameters",void 0);Gr=d([R({type:T.Sequence})],Gr);class mv extends ue{}let sr=class{constructor(e={}){Object.assign(this,e)}};d([g({type:b.OctetString})],sr.prototype,"a",void 0);d([g({type:b.OctetString})],sr.prototype,"b",void 0);d([g({type:b.BitString,optional:!0})],sr.prototype,"seed",void 0);sr=d([R({type:T.Sequence})],sr);var kc;(function(t){t[t.ecpVer1=1]="ecpVer1"})(kc||(kc={}));let Vt=class{constructor(e={}){this.version=kc.ecpVer1,Object.assign(this,e)}};d([g({type:b.Integer})],Vt.prototype,"version",void 0);d([g({type:Gr})],Vt.prototype,"fieldID",void 0);d([g({type:sr})],Vt.prototype,"curve",void 0);d([g({type:mv})],Vt.prototype,"base",void 0);d([g({type:b.Integer,converter:_e})],Vt.prototype,"order",void 0);d([g({type:b.Integer,optional:!0})],Vt.prototype,"cofactor",void 0);Vt=d([R({type:T.Sequence})],Vt);let tn=class{constructor(e={}){Object.assign(this,e)}};d([g({type:b.ObjectIdentifier})],tn.prototype,"namedCurve",void 0);d([g({type:b.Null})],tn.prototype,"implicitCurve",void 0);d([g({type:Vt})],tn.prototype,"specifiedCurve",void 0);tn=d([R({type:T.Choice})],tn);class Lo{constructor(e={}){this.version=1,this.privateKey=new ue,Object.assign(this,e)}}d([g({type:b.Integer})],Lo.prototype,"version",void 0);d([g({type:ue})],Lo.prototype,"privateKey",void 0);d([g({type:tn,context:0,optional:!0})],Lo.prototype,"parameters",void 0);d([g({type:b.BitString,context:1,optional:!0})],Lo.prototype,"publicKey",void 0);class Cs{constructor(e={}){this.r=new ArrayBuffer(0),this.s=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.Integer,converter:_e})],Cs.prototype,"r",void 0);d([g({type:b.Integer,converter:_e})],Cs.prototype,"s",void 0);const Ge="1.2.840.113549.1.1",Cn=`${Ge}.1`,_v=`${Ge}.7`,yv=`${Ge}.9`,Rr=`${Ge}.10`,vv=`${Ge}.2`,wv=`${Ge}.4`,js=`${Ge}.5`,bv=`${Ge}.14`,xc=`${Ge}.11`,$s=`${Ge}.12`,Os=`${Ge}.13`,ug=`${Ge}.15`,dg=`${Ge}.16`,Bs="1.3.14.3.2.26",pg="2.16.840.1.101.3.4.2.4",Ts="2.16.840.1.101.3.4.2.1",Ps="2.16.840.1.101.3.4.2.2",Rs="2.16.840.1.101.3.4.2.3",kv="2.16.840.1.101.3.4.2.5",xv="2.16.840.1.101.3.4.2.6",Sv="1.2.840.113549.2.2",Av="1.2.840.113549.2.5",Uo=`${Ge}.8`;function ze(t){return new F({algorithm:t,parameters:null})}ze(Sv);ze(Av);const jn=ze(Bs);ze(pg);ze(Ts);ze(Ps);ze(Rs);ze(kv);ze(xv);const fg=new F({algorithm:Uo,parameters:q.serialize(jn)}),hg=new F({algorithm:yv,parameters:q.serialize(ps.toASN(new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer))});ze(Cn);ze(vv);ze(wv);ze(js);ze(ug);ze(dg);ze($s);ze(Os);ze(ug);ze(dg);class Vo{constructor(e={}){this.hashAlgorithm=new F(jn),this.maskGenAlgorithm=new F({algorithm:Uo,parameters:q.serialize(jn)}),this.pSourceAlgorithm=new F(hg),Object.assign(this,e)}}d([g({type:F,context:0,defaultValue:jn})],Vo.prototype,"hashAlgorithm",void 0);d([g({type:F,context:1,defaultValue:fg})],Vo.prototype,"maskGenAlgorithm",void 0);d([g({type:F,context:2,defaultValue:hg})],Vo.prototype,"pSourceAlgorithm",void 0);new F({algorithm:_v,parameters:q.serialize(new Vo)});class $n{constructor(e={}){this.hashAlgorithm=new F(jn),this.maskGenAlgorithm=new F({algorithm:Uo,parameters:q.serialize(jn)}),this.saltLength=20,this.trailerField=1,Object.assign(this,e)}}d([g({type:F,context:0,defaultValue:jn})],$n.prototype,"hashAlgorithm",void 0);d([g({type:F,context:1,defaultValue:fg})],$n.prototype,"maskGenAlgorithm",void 0);d([g({type:b.Integer,context:2,defaultValue:20})],$n.prototype,"saltLength",void 0);d([g({type:b.Integer,context:3,defaultValue:1})],$n.prototype,"trailerField",void 0);new F({algorithm:Rr,parameters:q.serialize(new $n)});class qo{constructor(e={}){this.digestAlgorithm=new F,this.digest=new ue,Object.assign(this,e)}}d([g({type:F})],qo.prototype,"digestAlgorithm",void 0);d([g({type:ue})],qo.prototype,"digest",void 0);var Sc;class Mo{constructor(e={}){this.prime=new ArrayBuffer(0),this.exponent=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.Integer,converter:_e})],Mo.prototype,"prime",void 0);d([g({type:b.Integer,converter:_e})],Mo.prototype,"exponent",void 0);d([g({type:b.Integer,converter:_e})],Mo.prototype,"coefficient",void 0);let Ac=Sc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Sc.prototype)}};Ac=Sc=d([R({type:T.Sequence,itemType:Mo})],Ac);class jt{constructor(e={}){this.version=0,this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),this.privateExponent=new ArrayBuffer(0),this.prime1=new ArrayBuffer(0),this.prime2=new ArrayBuffer(0),this.exponent1=new ArrayBuffer(0),this.exponent2=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.Integer})],jt.prototype,"version",void 0);d([g({type:b.Integer,converter:_e})],jt.prototype,"modulus",void 0);d([g({type:b.Integer,converter:_e})],jt.prototype,"publicExponent",void 0);d([g({type:b.Integer,converter:_e})],jt.prototype,"privateExponent",void 0);d([g({type:b.Integer,converter:_e})],jt.prototype,"prime1",void 0);d([g({type:b.Integer,converter:_e})],jt.prototype,"prime2",void 0);d([g({type:b.Integer,converter:_e})],jt.prototype,"exponent1",void 0);d([g({type:b.Integer,converter:_e})],jt.prototype,"exponent2",void 0);d([g({type:b.Integer,converter:_e})],jt.prototype,"coefficient",void 0);d([g({type:Ac,optional:!0})],jt.prototype,"otherPrimeInfos",void 0);class Wl{constructor(e={}){this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.Integer,converter:_e})],Wl.prototype,"modulus",void 0);d([g({type:b.Integer,converter:_e})],Wl.prototype,"publicExponent",void 0);var Ec;(function(t){t[t.Transient=0]="Transient",t[t.Singleton=1]="Singleton",t[t.ResolutionScoped=2]="ResolutionScoped",t[t.ContainerScoped=3]="ContainerScoped"})(Ec||(Ec={}));const He=Ec;/*! *****************************************************************************
103
+ `)}`:`${n} :`}}th=Ke;K.Constructed=th;Ke.NAME="CONSTRUCTED";class nh extends Me{fromBER(e,n,r){return n}toBER(e){return yt}}nh.override="EndOfContentValueBlock";var rh;class gl extends Be{constructor(e={}){super(e,nh),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}rh=gl;K.EndOfContent=rh;gl.NAME=Mr;var ih;class Sn extends Be{constructor(e={}){super(e,Me),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,n,r){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=r,n+r>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):n+r}toBER(e,n){const r=new ArrayBuffer(2);if(!e){const i=new Uint8Array(r);i[0]=5,i[1]=0}return n&&n.write(r),r}onAsciiEncoding(){return`${this.constructor.NAME}`}}ih=Sn;K.Null=ih;Sn.NAME="NULL";class sh extends Nt(Me){constructor({value:e,...n}={}){super(n),n.valueHex?this.valueHexView=M.toUint8Array(n.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}get value(){for(const e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}fromBER(e,n,r){const i=M.toUint8Array(e);return Mt(this,i,n,r)?(this.valueHexView=i.subarray(n,n+r),r>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,Wf.call(this),this.blockLength=r,n+r):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}sh.NAME="BooleanValueBlock";var oh;class ao extends Be{constructor(e={}){super(e,sh),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}}oh=ao;K.Boolean=oh;ao.NAME="BOOLEAN";class ah extends Nt(Jt){constructor({isConstructed:e=!1,...n}={}){super(n),this.isConstructed=e}fromBER(e,n,r){let i=0;if(this.isConstructed){if(this.isHexOnly=!1,i=Jt.prototype.fromBER.call(this,e,n,r),i===-1)return i;for(let s=0;s<this.value.length;s++){const a=this.value[s].constructor.NAME;if(a===Mr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(a!==Gf)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,i=super.fromBER(e,n,r),this.blockLength=r;return i}toBER(e,n){return this.isConstructed?Jt.prototype.toBER.call(this,e,n):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}}ah.NAME="OctetStringValueBlock";var ch;let bn=class lh extends Be{constructor({idBlock:e={},lenBlock:n={},...r}={}){var i,s;(i=r.isConstructed)!==null&&i!==void 0||(r.isConstructed=!!(!((s=r.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:r.isConstructed,...e},lenBlock:{...n,isIndefiniteForm:!!r.isIndefiniteForm},...r},ah),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,n,r){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,r===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),n;if(!this.valueBlock.isConstructed){const s=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(n,n+r);try{if(s.byteLength){const a=pr(s,0,s.byteLength);a.offset!==-1&&a.offset===r&&(this.valueBlock.value=[a.result])}}catch{}}return super.fromBER(e,n,r)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?Ke.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${J.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;const e=[];for(const n of this.valueBlock.value)n instanceof lh&&e.push(n.valueBlock.valueHexView);return M.concat(e)}};ch=bn;K.OctetString=ch;bn.NAME=Gf;class uh extends Nt(Jt){constructor({unusedBits:e=0,isConstructed:n=!1,...r}={}){super(r),this.unusedBits=e,this.isConstructed=n,this.blockLength=this.valueHexView.byteLength}fromBER(e,n,r){if(!r)return n;let i=-1;if(this.isConstructed){if(i=Jt.prototype.fromBER.call(this,e,n,r),i===-1)return i;for(const c of this.value){const l=c.constructor.NAME;if(l===Mr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(l!==Jf)return this.error="BIT STRING may consists of BIT STRINGs only",-1;const u=c.valueBlock;if(this.unusedBits>0&&u.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=u.unusedBits}return i}const s=M.toUint8Array(e);if(!Mt(this,s,n,r))return-1;const a=s.subarray(n,n+r);if(this.unusedBits=a[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){const c=a.subarray(1);try{if(c.byteLength){const l=pr(c,0,c.byteLength);l.offset!==-1&&l.offset===r-1&&(this.value=[l.result])}}catch{}}return this.valueHexView=a.subarray(1),this.blockLength=a.length,n+r}toBER(e,n){if(this.isConstructed)return Jt.prototype.toBER.call(this,e,n);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return yt;const r=new Uint8Array(this.valueHexView.length+1);return r[0]=this.unusedBits,r.set(this.valueHexView,1),r.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}}uh.NAME="BitStringValueBlock";var dh;let kn=class extends Be{constructor({idBlock:e={},lenBlock:n={},...r}={}){var i,s;(i=r.isConstructed)!==null&&i!==void 0||(r.isConstructed=!!(!((s=r.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:r.isConstructed,...e},lenBlock:{...n,isIndefiniteForm:!!r.isIndefiniteForm},...r},uh),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,n,r){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,n,r)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return Ke.prototype.onAsciiEncoding.call(this);{const e=[],n=this.valueBlock.valueHexView;for(const i of n)e.push(i.toString(2).padStart(8,"0"));const r=e.join("");return`${this.constructor.NAME} : ${r.substring(0,r.length-this.valueBlock.unusedBits)}`}}};dh=kn;K.BitString=dh;kn.NAME=Jf;var ph;function jy(t,e){const n=new Uint8Array([0]),r=new Uint8Array(t),i=new Uint8Array(e);let s=r.slice(0);const a=s.length-1,c=i.slice(0),l=c.length-1;let u=0;const p=l<a?a:l;let h=0;for(let m=p;m>=0;m--,h++){switch(!0){case h<c.length:u=s[a-h]+c[l-h]+n[0];break;default:u=s[a-h]+n[0]}switch(n[0]=u/10,!0){case h>=s.length:s=$a(new Uint8Array([u%10]),s);break;default:s[a-h]=u%10}}return n[0]>0&&(s=$a(n,s)),s}function td(t){if(t>=zr.length)for(let e=zr.length;e<=t;e++){const n=new Uint8Array([0]);let r=zr[e-1].slice(0);for(let i=r.length-1;i>=0;i--){const s=new Uint8Array([(r[i]<<1)+n[0]]);n[0]=s[0]/10,r[i]=s[0]%10}n[0]>0&&(r=$a(n,r)),zr.push(r)}return zr[t]}function $y(t,e){let n=0;const r=new Uint8Array(t),i=new Uint8Array(e),s=r.slice(0),a=s.length-1,c=i.slice(0),l=c.length-1;let u,p=0;for(let h=l;h>=0;h--,p++)switch(u=s[a-p]-c[l-p]-n,!0){case u<0:n=1,s[a-p]=u+10;break;default:n=0,s[a-p]=u}if(n>0)for(let h=a-l+1;h>=0;h--,p++)if(u=s[a-p]-n,u<0)n=1,s[a-p]=u+10;else{n=0,s[a-p]=u;break}return s.slice()}class ml extends Nt(Me){constructor({value:e,...n}={}){super(n),this._valueDec=0,n.valueHex&&this.setValueHex(),e!==void 0&&(this.valueDec=e)}setValueHex(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=Wf.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(vy(e))}get valueDec(){return this._valueDec}fromDER(e,n,r,i=0){const s=this.fromBER(e,n,r);if(s===-1)return s;const a=this.valueHexView;return a[0]===0&&a[1]&128?this.valueHexView=a.subarray(1):i!==0&&a.length<i&&(i-a.length>1&&(i=a.length+1),this.valueHexView=a.subarray(i-a.length)),s}toDER(e=!1){const n=this.valueHexView;switch(!0){case(n[0]&128)!==0:{const r=new Uint8Array(this.valueHexView.length+1);r[0]=0,r.set(n,1),this.valueHexView=r}break;case(n[0]===0&&(n[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,n,r){const i=super.fromBER(e,n,r);return i===-1||this.setValueHex(),i}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){const e=this.valueHexView.length*8-1;let n=new Uint8Array(this.valueHexView.length*8/3),r=0,i;const s=this.valueHexView;let a="",c=!1;for(let l=s.byteLength-1;l>=0;l--){i=s[l];for(let u=0;u<8;u++){if((i&1)===1)switch(r){case e:n=$y(td(r),n),a="-";break;default:n=jy(n,td(r))}r++,i>>=1}}for(let l=0;l<n.length;l++)n[l]&&(c=!0),c&&(a+=Qu.charAt(n[l]));return c===!1&&(a+=Qu.charAt(0)),a}}ph=ml;ml.NAME="IntegerValueBlock";Object.defineProperty(ph.prototype,"valueHex",{set:function(t){this.valueHexView=new Uint8Array(t),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var fh;class At extends Be{constructor(e={}){super(e,ml),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return us(),BigInt(this.valueBlock.toString())}static fromBigInt(e){us();const n=BigInt(e),r=new so,i=n.toString(16).replace(/^-/,""),s=new Uint8Array(J.FromHex(i));if(n<0){const c=new Uint8Array(s.length+(s[0]&128?1:0));c[0]|=128;const u=BigInt(`0x${J.ToHex(c)}`)+n,p=M.toUint8Array(J.FromHex(u.toString(16)));p[0]|=128,r.write(p)}else s[0]&128&&r.write(new Uint8Array([0])),r.write(s);return new At({valueHex:r.final()})}convertToDER(){const e=new At({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new At({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}}fh=At;K.Integer=fh;At.NAME="INTEGER";var hh;class co extends At{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}hh=co;K.Enumerated=hh;co.NAME="ENUMERATED";class Oa extends Nt(Me){constructor({valueDec:e=-1,isFirstSid:n=!1,...r}={}){super(r),this.valueDec=e,this.isFirstSid=n}fromBER(e,n,r){if(!r)return n;const i=M.toUint8Array(e);if(!Mt(this,i,n,r))return-1;const s=i.subarray(n,n+r);this.valueHexView=new Uint8Array(r);for(let c=0;c<r&&(this.valueHexView[c]=s[c]&127,this.blockLength++,!!(s[c]&128));c++);const a=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)a[c]=this.valueHexView[c];return this.valueHexView=a,s[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=Zn(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),n+this.blockLength)}set valueBigInt(e){us();let n=BigInt(e).toString(2);for(;n.length%7;)n="0"+n;const r=new Uint8Array(n.length/7);for(let i=0;i<r.length;i++)r[i]=parseInt(n.slice(i*7,i*7+7),2)+(i+1<r.length?128:0);this.fromBER(r.buffer,0,r.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const i=this.valueHexView,s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength-1;a++)s[a]=i[a]|128;return s[this.blockLength-1]=i[this.blockLength-1],s.buffer}const n=xn(this.valueDec,7);if(n.byteLength===0)return this.error="Error during encoding SID value",yt;const r=new Uint8Array(n.byteLength);if(!e){const i=new Uint8Array(n),s=n.byteLength-1;for(let a=0;a<s;a++)r[a]=i[a]|128;r[s]=i[s]}return r}toString(){let e="";if(this.isHexOnly)e=J.ToHex(this.valueHexView);else if(this.isFirstSid){let n=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",n-=40):(e="2.",n-=80),e+=n.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}}Oa.NAME="sidBlock";class gh extends Me{constructor({value:e=Fe,...n}={}){super(n),this.value=[],e&&this.fromString(e)}fromBER(e,n,r){let i=n;for(;r>0;){const s=new Oa;if(i=s.fromBER(e,i,r),i===-1)return this.blockLength=0,this.error=s.error,i;this.value.length===0&&(s.isFirstSid=!0),this.blockLength+=s.blockLength,r-=s.blockLength,this.value.push(s)}return i}toBER(e){const n=[];for(let r=0;r<this.value.length;r++){const i=this.value[r].toBER(e);if(i.byteLength===0)return this.error=this.value[r].error,yt;n.push(i)}return fl(n)}fromString(e){this.value=[];let n=0,r=0,i="",s=!1;do if(r=e.indexOf(".",n),r===-1?i=e.substring(n):i=e.substring(n,r),n=r+1,s){const a=this.value[0];let c=0;switch(a.valueDec){case 0:break;case 1:c=40;break;case 2:c=80;break;default:this.value=[];return}const l=parseInt(i,10);if(isNaN(l))return;a.valueDec=l+c,s=!1}else{const a=new Oa;if(i>Number.MAX_SAFE_INTEGER){us();const c=BigInt(i);a.valueBigInt=c}else if(a.valueDec=parseInt(i,10),isNaN(a.valueDec))return;this.value.length||(a.isFirstSid=!0,s=!0),this.value.push(a)}while(r!==-1)}toString(){let e="",n=!1;for(let r=0;r<this.value.length;r++){n=this.value[r].isHexOnly;let i=this.value[r].toString();r!==0&&(e=`${e}.`),n?(i=`{${i}}`,this.value[r].isFirstSid?e=`2.{${i} - 80}`:e+=i):e+=i}return e}toJSON(){const e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let n=0;n<this.value.length;n++)e.sidArray.push(this.value[n].toJSON());return e}}gh.NAME="ObjectIdentifierValueBlock";var mh;class lo extends Be{constructor(e={}){super(e,gh),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}}mh=lo;K.ObjectIdentifier=mh;lo.NAME="OBJECT IDENTIFIER";class Ba extends Nt(Pn){constructor({valueDec:e=0,...n}={}){super(n),this.valueDec=e}fromBER(e,n,r){if(r===0)return n;const i=M.toUint8Array(e);if(!Mt(this,i,n,r))return-1;const s=i.subarray(n,n+r);this.valueHexView=new Uint8Array(r);for(let c=0;c<r&&(this.valueHexView[c]=s[c]&127,this.blockLength++,!!(s[c]&128));c++);const a=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)a[c]=this.valueHexView[c];return this.valueHexView=a,s[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=Zn(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),n+this.blockLength)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const i=this.valueHexView,s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength-1;a++)s[a]=i[a]|128;return s[this.blockLength-1]=i[this.blockLength-1],s.buffer}const n=xn(this.valueDec,7);if(n.byteLength===0)return this.error="Error during encoding SID value",yt;const r=new Uint8Array(n.byteLength);if(!e){const i=new Uint8Array(n),s=n.byteLength-1;for(let a=0;a<s;a++)r[a]=i[a]|128;r[s]=i[s]}return r.buffer}toString(){let e="";return this.isHexOnly?e=J.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}}Ba.NAME="relativeSidBlock";class _h extends Me{constructor({value:e=Fe,...n}={}){super(n),this.value=[],e&&this.fromString(e)}fromBER(e,n,r){let i=n;for(;r>0;){const s=new Ba;if(i=s.fromBER(e,i,r),i===-1)return this.blockLength=0,this.error=s.error,i;this.blockLength+=s.blockLength,r-=s.blockLength,this.value.push(s)}return i}toBER(e,n){const r=[];for(let i=0;i<this.value.length;i++){const s=this.value[i].toBER(e);if(s.byteLength===0)return this.error=this.value[i].error,yt;r.push(s)}return fl(r)}fromString(e){this.value=[];let n=0,r=0,i="";do{r=e.indexOf(".",n),r===-1?i=e.substring(n):i=e.substring(n,r),n=r+1;const s=new Ba;if(s.valueDec=parseInt(i,10),isNaN(s.valueDec))return!0;this.value.push(s)}while(r!==-1);return!0}toString(){let e="",n=!1;for(let r=0;r<this.value.length;r++){n=this.value[r].isHexOnly;let i=this.value[r].toString();r!==0&&(e=`${e}.`),n&&(i=`{${i}}`),e+=i}return e}toJSON(){const e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let n=0;n<this.value.length;n++)e.sidArray.push(this.value[n].toJSON());return e}}_h.NAME="RelativeObjectIdentifierValueBlock";var yh;class _l extends Be{constructor(e={}){super(e,_h),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}}yh=_l;K.RelativeObjectIdentifier=yh;_l.NAME="RelativeObjectIdentifier";var vh;class Bt extends Ke{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}vh=Bt;K.Sequence=vh;Bt.NAME="SEQUENCE";var wh;let Tt=class extends Ke{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};wh=Tt;K.Set=wh;Tt.NAME="SET";class bh extends Nt(Me){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=Fe}toJSON(){return{...super.toJSON(),value:this.value}}}bh.NAME="StringValueBlock";class kh extends bh{}kh.NAME="SimpleStringValueBlock";class et extends hl{constructor({...e}={}){super(e,kh)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,M.toUint8Array(e))}fromString(e){const n=e.length,r=this.valueBlock.valueHexView=new Uint8Array(n);for(let i=0;i<n;i++)r[i]=e.charCodeAt(i);this.valueBlock.value=e}}et.NAME="SIMPLE STRING";class xh extends et{fromBuffer(e){this.valueBlock.valueHexView=M.toUint8Array(e);try{this.valueBlock.value=J.ToUtf8String(e)}catch(n){this.warnings.push(`Error during "decodeURIComponent": ${n}, using raw string`),this.valueBlock.value=J.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(J.FromUtf8String(e)),this.valueBlock.value=e}}xh.NAME="Utf8StringValueBlock";var Sh;class Dt extends xh{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}Sh=Dt;K.Utf8String=Sh;Dt.NAME="UTF8String";class Ah extends et{fromBuffer(e){this.valueBlock.value=J.ToUtf16String(e),this.valueBlock.valueHexView=M.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(J.FromUtf16String(e))}}Ah.NAME="BmpStringValueBlock";var Eh;class uo extends Ah{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}Eh=uo;K.BmpString=Eh;uo.NAME="BMPString";class Ih extends et{fromBuffer(e){const n=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),r=new Uint8Array(n);for(let i=0;i<r.length;i+=4)r[i]=r[i+3],r[i+1]=r[i+2],r[i+2]=0,r[i+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(n))}fromString(e){const n=e.length,r=this.valueBlock.valueHexView=new Uint8Array(n*4);for(let i=0;i<n;i++){const s=xn(e.charCodeAt(i),8),a=new Uint8Array(s);if(a.length>4)continue;const c=4-a.length;for(let l=a.length-1;l>=0;l--)r[i*4+l+c]=a[l]}this.valueBlock.value=e}}Ih.NAME="UniversalStringValueBlock";var zh;class po extends Ih{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}zh=po;K.UniversalString=zh;po.NAME="UniversalString";var Nh;class fo extends et{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}Nh=fo;K.NumericString=Nh;fo.NAME="NumericString";var Ch;class ho extends et{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}Ch=ho;K.PrintableString=Ch;ho.NAME="PrintableString";var jh;class go extends et{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}jh=go;K.TeletexString=jh;go.NAME="TeletexString";var $h;class mo extends et{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}$h=mo;K.VideotexString=$h;mo.NAME="VideotexString";var Oh;class _o extends et{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}Oh=_o;K.IA5String=Oh;_o.NAME="IA5String";var Bh;class yo extends et{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}Bh=yo;K.GraphicString=Bh;yo.NAME="GraphicString";var Th;class ai extends et{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}Th=ai;K.VisibleString=Th;ai.NAME="VisibleString";var Ph;class vo extends et{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}Ph=vo;K.GeneralString=Ph;vo.NAME="GeneralString";var Rh;class wo extends et{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}Rh=wo;K.CharacterString=Rh;wo.NAME="CharacterString";var Lh;class ci extends ai{constructor({value:e,valueDate:n,...r}={}){if(super(r),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let i=0;i<e.length;i++)this.valueBlock.valueHexView[i]=e.charCodeAt(i)}n&&(this.fromDate(n),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,M.toUint8Array(e)))}toBuffer(){const e=this.toString(),n=new ArrayBuffer(e.length),r=new Uint8Array(n);for(let i=0;i<e.length;i++)r[i]=e.charCodeAt(i);return n}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){const r=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(e);if(r===null){this.error="Wrong input string for conversion";return}const i=parseInt(r[1],10);i>=50?this.year=1900+i:this.year=2e3+i,this.month=parseInt(r[2],10),this.day=parseInt(r[3],10),this.hour=parseInt(r[4],10),this.minute=parseInt(r[5],10),this.second=parseInt(r[6],10)}toString(e="iso"){if(e==="iso"){const n=new Array(7);return n[0]=Ye(this.year<2e3?this.year-1900:this.year-2e3,2),n[1]=Ye(this.month,2),n[2]=Ye(this.day,2),n[3]=Ye(this.hour,2),n[4]=Ye(this.minute,2),n[5]=Ye(this.second,2),n[6]="Z",n.join("")}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}}Lh=ci;K.UTCTime=Lh;ci.NAME="UTCTime";var Uh;class bo extends ci{constructor(e={}){var n;super(e),(n=this.millisecond)!==null&&n!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(e){let n=!1,r="",i="",s=0,a,c=0,l=0;if(e[e.length-1]==="Z")r=e.substring(0,e.length-1),n=!0;else{const h=new Number(e[e.length-1]);if(isNaN(h.valueOf()))throw new Error("Wrong input string for conversion");r=e}if(n){if(r.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(r.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let h=1,m=r.indexOf("+"),v="";if(m===-1&&(m=r.indexOf("-"),h=-1),m!==-1){if(v=r.substring(m+1),r=r.substring(0,m),v.length!==2&&v.length!==4)throw new Error("Wrong input string for conversion");let f=parseInt(v.substring(0,2),10);if(isNaN(f.valueOf()))throw new Error("Wrong input string for conversion");if(c=h*f,v.length===4){if(f=parseInt(v.substring(2,4),10),isNaN(f.valueOf()))throw new Error("Wrong input string for conversion");l=h*f}}}let u=r.indexOf(".");if(u===-1&&(u=r.indexOf(",")),u!==-1){const h=new Number(`0${r.substring(u)}`);if(isNaN(h.valueOf()))throw new Error("Wrong input string for conversion");s=h.valueOf(),i=r.substring(0,u)}else i=r;switch(!0){case i.length===8:if(a=/(\d{4})(\d{2})(\d{2})/ig,u!==-1)throw new Error("Wrong input string for conversion");break;case i.length===10:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,u!==-1){let h=60*s;this.minute=Math.floor(h),h=60*(h-this.minute),this.second=Math.floor(h),h=1e3*(h-this.second),this.millisecond=Math.floor(h)}break;case i.length===12:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,u!==-1){let h=60*s;this.second=Math.floor(h),h=1e3*(h-this.second),this.millisecond=Math.floor(h)}break;case i.length===14:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,u!==-1){const h=1e3*s;this.millisecond=Math.floor(h)}break;default:throw new Error("Wrong input string for conversion")}const p=a.exec(i);if(p===null)throw new Error("Wrong input string for conversion");for(let h=1;h<p.length;h++)switch(h){case 1:this.year=parseInt(p[h],10);break;case 2:this.month=parseInt(p[h],10);break;case 3:this.day=parseInt(p[h],10);break;case 4:this.hour=parseInt(p[h],10)+c;break;case 5:this.minute=parseInt(p[h],10)+l;break;case 6:this.second=parseInt(p[h],10);break;default:throw new Error("Wrong input string for conversion")}if(n===!1){const h=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=h.getUTCFullYear(),this.month=h.getUTCMonth(),this.day=h.getUTCDay(),this.hour=h.getUTCHours(),this.minute=h.getUTCMinutes(),this.second=h.getUTCSeconds(),this.millisecond=h.getUTCMilliseconds()}}toString(e="iso"){if(e==="iso"){const n=[];return n.push(Ye(this.year,4)),n.push(Ye(this.month,2)),n.push(Ye(this.day,2)),n.push(Ye(this.hour,2)),n.push(Ye(this.minute,2)),n.push(Ye(this.second,2)),this.millisecond!==0&&(n.push("."),n.push(Ye(this.millisecond,3))),n.push("Z"),n.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}}Uh=bo;K.GeneralizedTime=Uh;bo.NAME="GeneralizedTime";var Vh;class yl extends Dt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}Vh=yl;K.DATE=Vh;yl.NAME="DATE";var qh;class vl extends Dt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}qh=vl;K.TimeOfDay=qh;vl.NAME="TimeOfDay";var Mh;class wl extends Dt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}Mh=wl;K.DateTime=Mh;wl.NAME="DateTime";var Dh;class bl extends Dt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}Dh=bl;K.Duration=Dh;bl.NAME="Duration";var Hh;class kl extends Dt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}Hh=kl;K.TIME=Hh;kl.NAME="TIME";class An{constructor({name:e=Fe,optional:n=!1}={}){this.name=e,this.optional=n}}class xl extends An{constructor({value:e=[],...n}={}){super(n),this.value=e}}class ds extends An{constructor({value:e=new An,local:n=!1,...r}={}){super(r),this.value=e,this.local=n}}class Oy{constructor({data:e=oo}={}){this.dataView=M.toUint8Array(e)}get data(){return this.dataView.slice().buffer}set data(e){this.dataView=M.toUint8Array(e)}fromBER(e,n,r){const i=n+r;return this.dataView=M.toUint8Array(e).subarray(n,i),i}toBER(e){return this.dataView.slice().buffer}}function yn(t,e,n){if(n instanceof xl){for(let s=0;s<n.value.length;s++)if(yn(t,e,n.value[s]).verified)return{verified:!0,result:t};{const s={verified:!1,result:{error:"Wrong values for Choice type"}};return n.hasOwnProperty(ra)&&(s.name=n.name),s}}if(n instanceof An)return n.hasOwnProperty(ra)&&(t[n.name]=e),{verified:!0,result:t};if(!(t instanceof Object))return{verified:!1,result:{error:"Wrong root object"}};if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 data"}};if(!(n instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(ky in n))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(Ey in n.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(Iy in n.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const r=n.idBlock.toBER(!1);if(r.byteLength===0)return{verified:!1,result:{error:"Error encoding idBlock for ASN.1 schema"}};if(n.idBlock.fromBER(r,0,r.byteLength)===-1)return{verified:!1,result:{error:"Error decoding idBlock for ASN.1 schema"}};if(n.idBlock.hasOwnProperty(xy)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(n.idBlock.tagClass!==e.idBlock.tagClass)return{verified:!1,result:t};if(n.idBlock.hasOwnProperty(Sy)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(n.idBlock.tagNumber!==e.idBlock.tagNumber)return{verified:!1,result:t};if(n.idBlock.hasOwnProperty(Ay)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(n.idBlock.isConstructed!==e.idBlock.isConstructed)return{verified:!1,result:t};if(!(by in n.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(n.idBlock.isHexOnly!==e.idBlock.isHexOnly)return{verified:!1,result:t};if(n.idBlock.isHexOnly){if(!(ed in n.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const s=n.idBlock.valueHexView,a=e.idBlock.valueHexView;if(s.length!==a.length)return{verified:!1,result:t};for(let c=0;c<s.length;c++)if(s[c]!==a[1])return{verified:!1,result:t}}if(n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Fe),n.name&&(t[n.name]=e)),n instanceof K.Constructed){let s=0,a={verified:!1,result:{error:"Unknown error"}},c=n.valueBlock.value.length;if(c>0&&n.valueBlock.value[0]instanceof ds&&(c=e.valueBlock.value.length),c===0)return{verified:!0,result:t};if(e.valueBlock.value.length===0&&n.valueBlock.value.length!==0){let l=!0;for(let u=0;u<n.valueBlock.value.length;u++)l=l&&(n.valueBlock.value[u].optional||!1);return l?{verified:!0,result:t}:(n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Fe),n.name&&delete t[n.name]),t.error="Inconsistent object length",{verified:!1,result:t})}for(let l=0;l<c;l++)if(l-s>=e.valueBlock.value.length){if(n.valueBlock.value[l].optional===!1){const u={verified:!1,result:t};return t.error="Inconsistent length between ASN.1 data and schema",n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Fe),n.name&&(delete t[n.name],u.name=n.name)),u}}else if(n.valueBlock.value[0]instanceof ds){if(a=yn(t,e.valueBlock.value[l],n.valueBlock.value[0].value),a.verified===!1)if(n.valueBlock.value[0].optional)s++;else return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Fe),n.name&&delete t[n.name]),a;if(ra in n.valueBlock.value[0]&&n.valueBlock.value[0].name.length>0){let u={};zy in n.valueBlock.value[0]&&n.valueBlock.value[0].local?u=e:u=t,typeof u[n.valueBlock.value[0].name]>"u"&&(u[n.valueBlock.value[0].name]=[]),u[n.valueBlock.value[0].name].push(e.valueBlock.value[l])}}else if(a=yn(t,e.valueBlock.value[l-s],n.valueBlock.value[l]),a.verified===!1)if(n.valueBlock.value[l].optional)s++;else return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Fe),n.name&&delete t[n.name]),a;if(a.verified===!1){const l={verified:!1,result:t};return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Fe),n.name&&(delete t[n.name],l.name=n.name)),l}return{verified:!0,result:t}}if(n.primitiveSchema&&ed in e.valueBlock){const s=pr(e.valueBlock.valueHexView);if(s.offset===-1){const a={verified:!1,result:s.result};return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Fe),n.name&&(delete t[n.name],a.name=n.name)),a}return yn(t,s.result,n.primitiveSchema)}return{verified:!0,result:t}}function By(t,e){if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};const n=pr(M.toUint8Array(t));return n.offset===-1?{verified:!1,result:n.result}:yn(n.result,n.result,e)}const Fh=Object.freeze(Object.defineProperty({__proto__:null,Any:An,BaseBlock:Be,BaseStringBlock:hl,BitString:kn,BmpString:uo,Boolean:ao,CharacterString:wo,Choice:xl,Constructed:Ke,DATE:yl,DateTime:wl,Duration:bl,EndOfContent:gl,Enumerated:co,GeneralString:vo,GeneralizedTime:bo,GraphicString:yo,HexBlock:Nt,IA5String:_o,Integer:At,Null:Sn,NumericString:fo,ObjectIdentifier:lo,OctetString:bn,Primitive:oi,PrintableString:ho,RawData:Oy,RelativeObjectIdentifier:_l,Repeated:ds,Sequence:Bt,Set:Tt,TIME:kl,TeletexString:go,TimeOfDay:vl,UTCTime:ci,UniversalString:po,Utf8String:Dt,ValueBlock:Me,VideotexString:mo,ViewWriter:so,VisibleString:ai,compareSchema:yn,fromBER:Kn,verifySchema:By},Symbol.toStringTag,{value:"Module"}));var T;(function(t){t[t.Sequence=0]="Sequence",t[t.Set=1]="Set",t[t.Choice=2]="Choice"})(T||(T={}));var b;(function(t){t[t.Any=1]="Any",t[t.Boolean=2]="Boolean",t[t.OctetString=3]="OctetString",t[t.BitString=4]="BitString",t[t.Integer=5]="Integer",t[t.Enumerated=6]="Enumerated",t[t.ObjectIdentifier=7]="ObjectIdentifier",t[t.Utf8String=8]="Utf8String",t[t.BmpString=9]="BmpString",t[t.UniversalString=10]="UniversalString",t[t.NumericString=11]="NumericString",t[t.PrintableString=12]="PrintableString",t[t.TeletexString=13]="TeletexString",t[t.VideotexString=14]="VideotexString",t[t.IA5String=15]="IA5String",t[t.GraphicString=16]="GraphicString",t[t.VisibleString=17]="VisibleString",t[t.GeneralString=18]="GeneralString",t[t.CharacterString=19]="CharacterString",t[t.UTCTime=20]="UTCTime",t[t.GeneralizedTime=21]="GeneralizedTime",t[t.DATE=22]="DATE",t[t.TimeOfDay=23]="TimeOfDay",t[t.DateTime=24]="DateTime",t[t.Duration=25]="Duration",t[t.TIME=26]="TIME",t[t.Null=27]="Null"})(b||(b={}));class ko{constructor(e,n=0){if(this.unusedBits=0,this.value=new ArrayBuffer(0),e)if(typeof e=="number")this.fromNumber(e);else if(M.isBufferSource(e))this.unusedBits=n,this.value=M.toArrayBuffer(e);else throw TypeError("Unsupported type of 'params' argument for BitString")}fromASN(e){if(!(e instanceof kn))throw new TypeError("Argument 'asn' is not instance of ASN.1 BitString");return this.unusedBits=e.valueBlock.unusedBits,this.value=e.valueBlock.valueHex,this}toASN(){return new kn({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new kn({name:e})}toNumber(){let e="";const n=new Uint8Array(this.value);for(const r of n)e+=r.toString(2).padStart(8,"0");return e=e.split("").reverse().join(""),this.unusedBits&&(e=e.slice(this.unusedBits).padStart(this.unusedBits,"0")),parseInt(e,2)}fromNumber(e){let n=e.toString(2);const r=n.length+7>>3;this.unusedBits=(r<<3)-n.length;const i=new Uint8Array(r);n=n.padStart(r<<3,"0").split("").reverse().join("");let s=0;for(;s<r;)i[s]=parseInt(n.slice(s<<3,(s<<3)+8),2),s++;this.value=i.buffer}}class ue{get byteLength(){return this.buffer.byteLength}get byteOffset(){return 0}constructor(e){typeof e=="number"?this.buffer=new ArrayBuffer(e):M.isBufferSource(e)?this.buffer=M.toArrayBuffer(e):Array.isArray(e)?this.buffer=new Uint8Array(e):this.buffer=new ArrayBuffer(0)}fromASN(e){if(!(e instanceof bn))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=e.valueBlock.valueHex,this}toASN(){return new bn({valueHex:this.buffer})}toSchema(e){return new bn({name:e})}}const Ty={fromASN:t=>t instanceof Sn?null:t.valueBeforeDecodeView,toASN:t=>{if(t===null)return new Sn;const e=Kn(t);if(e.result.error)throw new Error(e.result.error);return e.result}},Py={fromASN:t=>t.valueBlock.valueHexView.byteLength>=4?t.valueBlock.toString():t.valueBlock.valueDec,toASN:t=>new At({value:+t})},Ry={fromASN:t=>t.valueBlock.valueDec,toASN:t=>new co({value:t})},_e={fromASN:t=>t.valueBlock.valueHexView,toASN:t=>new At({valueHex:t})},Ly={fromASN:t=>t.valueBlock.valueHexView,toASN:t=>new kn({valueHex:t})},Uy={fromASN:t=>t.valueBlock.toString(),toASN:t=>new lo({value:t})},Vy={fromASN:t=>t.valueBlock.value,toASN:t=>new ao({value:t})},ps={fromASN:t=>t.valueBlock.valueHexView,toASN:t=>new bn({valueHex:t})},qy={fromASN:t=>new ue(t.getValue()),toASN:t=>t.toASN()};function at(t){return{fromASN:e=>e.valueBlock.value,toASN:e=>new t({value:e})}}const Kh=at(Dt),My=at(uo),Dy=at(po),Hy=at(fo),Fy=at(ho),Ky=at(go),Wy=at(mo),Gy=at(_o),Jy=at(yo),Zy=at(ai),Yy=at(vo),Xy=at(wo),Qy={fromASN:t=>t.toDate(),toASN:t=>new ci({valueDate:t})},ev={fromASN:t=>t.toDate(),toASN:t=>new bo({valueDate:t})},tv={fromASN:()=>null,toASN:()=>new Sn};function Sl(t){switch(t){case b.Any:return Ty;case b.BitString:return Ly;case b.BmpString:return My;case b.Boolean:return Vy;case b.CharacterString:return Xy;case b.Enumerated:return Ry;case b.GeneralString:return Yy;case b.GeneralizedTime:return ev;case b.GraphicString:return Jy;case b.IA5String:return Gy;case b.Integer:return Py;case b.Null:return tv;case b.NumericString:return Hy;case b.ObjectIdentifier:return Uy;case b.OctetString:return ps;case b.PrintableString:return Fy;case b.TeletexString:return Ky;case b.UTCTime:return Qy;case b.UniversalString:return Dy;case b.Utf8String:return Kh;case b.VideotexString:return Wy;case b.VisibleString:return Zy;default:return null}}function Ot(t){return typeof t=="function"&&t.prototype?t.prototype.toASN&&t.prototype.fromASN?!0:Ot(t.prototype):!!(t&&typeof t=="object"&&"toASN"in t&&"fromASN"in t)}function Wh(t){var e;if(t){const n=Object.getPrototypeOf(t);return((e=n==null?void 0:n.prototype)===null||e===void 0?void 0:e.constructor)===Array?!0:Wh(n)}return!1}function nv(t,e){if(!(t&&e)||t.byteLength!==e.byteLength)return!1;const n=new Uint8Array(t),r=new Uint8Array(e);for(let i=0;i<t.byteLength;i++)if(n[i]!==r[i])return!1;return!0}class rv{constructor(){this.items=new WeakMap}has(e){return this.items.has(e)}get(e,n=!1){const r=this.items.get(e);if(!r)throw new Error(`Cannot get schema for '${e.prototype.constructor.name}' target`);if(n&&!r.schema)throw new Error(`Schema '${e.prototype.constructor.name}' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'.`);return r}cache(e){const n=this.get(e);n.schema||(n.schema=this.create(e,!0))}createDefault(e){const n={type:T.Sequence,items:{}},r=this.findParentSchema(e);return r&&(Object.assign(n,r),n.items=Object.assign({},n.items,r.items)),n}create(e,n){const r=this.items.get(e)||this.createDefault(e),i=[];for(const s in r.items){const a=r.items[s],c=n?s:"";let l;if(typeof a.type=="number"){const p=b[a.type],h=Fh[p];if(!h)throw new Error(`Cannot get ASN1 class by name '${p}'`);l=new h({name:c})}else Ot(a.type)?l=new a.type().toSchema(c):a.optional?this.get(a.type).type===T.Choice?l=new An({name:c}):(l=this.create(a.type,!1),l.name=c):l=new An({name:c});const u=!!a.optional||a.defaultValue!==void 0;if(a.repeated){l.name="";const p=a.repeated==="set"?Tt:Bt;l=new p({name:"",value:[new ds({name:c,value:l})]})}if(a.context!==null&&a.context!==void 0)if(a.implicit)if(typeof a.type=="number"||Ot(a.type)){const p=a.repeated?Ke:oi;i.push(new p({name:c,optional:u,idBlock:{tagClass:3,tagNumber:a.context}}))}else{this.cache(a.type);const p=!!a.repeated;let h=p?l:this.get(a.type,!0).schema;h="valueBlock"in h?h.valueBlock.value:h.value,i.push(new Ke({name:p?"":c,optional:u,idBlock:{tagClass:3,tagNumber:a.context},value:h}))}else i.push(new Ke({optional:u,idBlock:{tagClass:3,tagNumber:a.context},value:[l]}));else l.optional=u,i.push(l)}switch(r.type){case T.Sequence:return new Bt({value:i,name:""});case T.Set:return new Tt({value:i,name:""});case T.Choice:return new xl({value:i,name:""});default:throw new Error("Unsupported ASN1 type in use")}}set(e,n){return this.items.set(e,n),this}findParentSchema(e){const n=Object.getPrototypeOf(e);return n?this.items.get(n)||this.findParentSchema(n):null}}const rt=new rv,R=t=>e=>{let n;rt.has(e)?n=rt.get(e):(n=rt.createDefault(e),rt.set(e,n)),Object.assign(n,t)},g=t=>(e,n)=>{let r;rt.has(e.constructor)?r=rt.get(e.constructor):(r=rt.createDefault(e.constructor),rt.set(e.constructor,r));const i=Object.assign({},t);if(typeof i.type=="number"&&!i.converter){const s=Sl(t.type);if(!s)throw new Error(`Cannot get default converter for property '${n}' of ${e.constructor.name}`);i.converter=s}r.items[n]=i};class nd extends Error{constructor(){super(...arguments),this.schemas=[]}}class iv{static parse(e,n){const r=Kn(e);if(r.result.error)throw new Error(r.result.error);return this.fromASN(r.result,n)}static fromASN(e,n){var r;try{if(Ot(n))return new n().fromASN(e);const i=rt.get(n);rt.cache(n);let s=i.schema;if(e.constructor===Ke&&i.type!==T.Choice){s=new Ke({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:i.schema.valueBlock.value});for(const l in i.items)delete e[l]}const a=yn({},e,s);if(!a.verified)throw new nd(`Data does not match to ${n.name} ASN1 schema. ${a.result.error}`);const c=new n;if(Wh(n)){if(!("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const l=i.itemType;if(typeof l=="number"){const u=Sl(l);if(!u)throw new Error(`Cannot get default converter for array item of ${n.name} ASN1 schema`);return n.from(e.valueBlock.value,p=>u.fromASN(p))}else return n.from(e.valueBlock.value,u=>this.fromASN(u,l))}for(const l in i.items){const u=a.result[l];if(!u)continue;const p=i.items[l],h=p.type;if(typeof h=="number"||Ot(h)){const m=(r=p.converter)!==null&&r!==void 0?r:Ot(h)?new h:null;if(!m)throw new Error("Converter is empty");if(p.repeated)if(p.implicit){const v=p.repeated==="sequence"?Bt:Tt,f=new v;f.valueBlock=u.valueBlock;const _=Kn(f.toBER(!1));if(_.offset===-1)throw new Error(`Cannot parse the child item. ${_.result.error}`);if(!("value"in _.result.valueBlock&&Array.isArray(_.result.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const w=_.result.valueBlock.value;c[l]=Array.from(w,S=>m.fromASN(S))}else c[l]=Array.from(u,v=>m.fromASN(v));else{let v=u;if(p.implicit){let f;if(Ot(h))f=new h().toSchema("");else{const _=b[h],w=Fh[_];if(!w)throw new Error(`Cannot get '${_}' class from asn1js module`);f=new w}f.valueBlock=v.valueBlock,v=Kn(f.toBER(!1)).result}c[l]=m.fromASN(v)}}else if(p.repeated){if(!Array.isArray(u))throw new Error("Cannot get list of items from the ASN.1 parsed value. ASN.1 value should be iterable.");c[l]=Array.from(u,m=>this.fromASN(m,h))}else c[l]=this.fromASN(u,h)}return c}catch(i){throw i instanceof nd&&i.schemas.push(n.name),i}}}class Al{static serialize(e){return e instanceof Be?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&typeof e=="object"&&Ot(e))return e.toASN();if(!(e&&typeof e=="object"))throw new TypeError("Parameter 1 should be type of Object.");const n=e.constructor,r=rt.get(n);rt.cache(n);let i=[];if(r.itemType){if(!Array.isArray(e))throw new TypeError("Parameter 1 should be type of Array.");if(typeof r.itemType=="number"){const a=Sl(r.itemType);if(!a)throw new Error(`Cannot get default converter for array item of ${n.name} ASN1 schema`);i=e.map(c=>a.toASN(c))}else i=e.map(a=>this.toAsnItem({type:r.itemType},"[]",n,a))}else for(const a in r.items){const c=r.items[a],l=e[a];if(l===void 0||c.defaultValue===l||typeof c.defaultValue=="object"&&typeof l=="object"&&nv(this.serialize(c.defaultValue),this.serialize(l)))continue;const u=Al.toAsnItem(c,a,n,l);if(typeof c.context=="number")if(c.implicit)if(!c.repeated&&(typeof c.type=="number"||Ot(c.type))){const p={};p.valueHex=u instanceof Sn?u.valueBeforeDecodeView:u.valueBlock.toBER(),i.push(new oi({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},...p}))}else i.push(new Ke({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:u.valueBlock.value}));else i.push(new Ke({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:[u]}));else c.repeated?i=i.concat(u):i.push(u)}let s;switch(r.type){case T.Sequence:s=new Bt({value:i});break;case T.Set:s=new Tt({value:i});break;case T.Choice:if(!i[0])throw new Error(`Schema '${n.name}' has wrong data. Choice cannot be empty.`);s=i[0];break}return s}static toAsnItem(e,n,r,i){let s;if(typeof e.type=="number"){const a=e.converter;if(!a)throw new Error(`Property '${n}' doesn't have converter for type ${b[e.type]} in schema '${r.name}'`);if(e.repeated){if(!Array.isArray(i))throw new TypeError("Parameter 'objProp' should be type of Array.");const c=Array.from(i,u=>a.toASN(u)),l=e.repeated==="sequence"?Bt:Tt;s=new l({value:c})}else s=a.toASN(i)}else if(e.repeated){if(!Array.isArray(i))throw new TypeError("Parameter 'objProp' should be type of Array.");const a=Array.from(i,l=>this.toASN(l)),c=e.repeated==="sequence"?Bt:Tt;s=new c({value:a})}else s=this.toASN(i);return s}}class fe extends Array{constructor(e=[]){if(typeof e=="number")super(e);else{super();for(const n of e)this.push(n)}}}class q{static serialize(e){return Al.serialize(e)}static parse(e,n){return iv.parse(e,n)}static toString(e){const n=M.isBufferSource(e)?M.toArrayBuffer(e):q.serialize(e),r=Kn(n);if(r.offset===-1)throw new Error(`Cannot decode ASN.1 data. ${r.result.error}`);return r.result.toString()}}function d(t,e,n,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,n):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,n,r);else for(var c=t.length-1;c>=0;c--)(a=t[c])&&(s=(i<3?a(s):i>3?a(e,n,s):a(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s}var Gh={exports:{}};(function(t){(function(e){const n="(0?\\d+|0x[a-f0-9]+)",r={fourOctet:new RegExp(`^${n}\\.${n}\\.${n}\\.${n}$`,"i"),threeOctet:new RegExp(`^${n}\\.${n}\\.${n}$`,"i"),twoOctet:new RegExp(`^${n}\\.${n}$`,"i"),longValue:new RegExp(`^${n}$`,"i")},i=new RegExp("^0[0-7]+$","i"),s=new RegExp("^0x[a-f0-9]+$","i"),a="%[0-9a-z]{1,}",c="(?:[0-9a-f]+::?)+",l={zoneIndex:new RegExp(a,"i"),native:new RegExp(`^(::)?(${c})?([0-9a-f]+)?(::)?(${a})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${n}\\.${n}\\.${n}\\.${n}(${a})?)$`,"i"),transitional:new RegExp(`^((?:${c})|(?:::)(?:${c})?)${n}\\.${n}\\.${n}\\.${n}(${a})?$`,"i")};function u(f,_){if(f.indexOf("::")!==f.lastIndexOf("::"))return null;let w=0,S=-1,C=(f.match(l.zoneIndex)||[])[0],B,L;for(C&&(C=C.substring(1),f=f.replace(/%.+$/,""));(S=f.indexOf(":",S+1))>=0;)w++;if(f.substr(0,2)==="::"&&w--,f.substr(-2,2)==="::"&&w--,w>_)return null;for(L=_-w,B=":";L--;)B+="0:";return f=f.replace("::",B),f[0]===":"&&(f=f.slice(1)),f[f.length-1]===":"&&(f=f.slice(0,-1)),_=function(){const Q=f.split(":"),ce=[];for(let le=0;le<Q.length;le++)ce.push(parseInt(Q[le],16));return ce}(),{parts:_,zoneId:C}}function p(f,_,w,S){if(f.length!==_.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let C=0,B;for(;S>0;){if(B=w-S,B<0&&(B=0),f[C]>>B!==_[C]>>B)return!1;S-=w,C+=1}return!0}function h(f){if(s.test(f))return parseInt(f,16);if(f[0]==="0"&&!isNaN(parseInt(f[1],10))){if(i.test(f))return parseInt(f,8);throw new Error(`ipaddr: cannot parse ${f} as octal`)}return parseInt(f,10)}function m(f,_){for(;f.length<_;)f=`0${f}`;return f}const v={};v.IPv4=function(){function f(_){if(_.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let w,S;for(w=0;w<_.length;w++)if(S=_[w],!(0<=S&&S<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=_}return f.prototype.SpecialRanges={unspecified:[[new f([0,0,0,0]),8]],broadcast:[[new f([255,255,255,255]),32]],multicast:[[new f([224,0,0,0]),4]],linkLocal:[[new f([169,254,0,0]),16]],loopback:[[new f([127,0,0,0]),8]],carrierGradeNat:[[new f([100,64,0,0]),10]],private:[[new f([10,0,0,0]),8],[new f([172,16,0,0]),12],[new f([192,168,0,0]),16]],reserved:[[new f([192,0,0,0]),24],[new f([192,0,2,0]),24],[new f([192,88,99,0]),24],[new f([198,18,0,0]),15],[new f([198,51,100,0]),24],[new f([203,0,113,0]),24],[new f([240,0,0,0]),4]],as112:[[new f([192,175,48,0]),24],[new f([192,31,196,0]),24]],amt:[[new f([192,52,193,0]),24]]},f.prototype.kind=function(){return"ipv4"},f.prototype.match=function(_,w){let S;if(w===void 0&&(S=_,_=S[0],w=S[1]),_.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return p(this.octets,_.octets,8,w)},f.prototype.prefixLengthFromSubnetMask=function(){let _=0,w=!1;const S={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0};let C,B,L;for(C=3;C>=0;C-=1)if(B=this.octets[C],B in S){if(L=S[B],w&&L!==0)return null;L!==8&&(w=!0),_+=L}else return null;return 32-_},f.prototype.range=function(){return v.subnetMatch(this,this.SpecialRanges)},f.prototype.toByteArray=function(){return this.octets.slice(0)},f.prototype.toIPv4MappedAddress=function(){return v.IPv6.parse(`::ffff:${this.toString()}`)},f.prototype.toNormalizedString=function(){return this.toString()},f.prototype.toString=function(){return this.octets.join(".")},f}(),v.IPv4.broadcastAddressFromCIDR=function(f){try{const _=this.parseCIDR(f),w=_[0].toByteArray(),S=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),C=[];let B=0;for(;B<4;)C.push(parseInt(w[B],10)|parseInt(S[B],10)^255),B++;return new this(C)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},v.IPv4.isIPv4=function(f){return this.parser(f)!==null},v.IPv4.isValid=function(f){try{return new this(this.parser(f)),!0}catch{return!1}},v.IPv4.isValidCIDR=function(f){try{return this.parseCIDR(f),!0}catch{return!1}},v.IPv4.isValidFourPartDecimal=function(f){return!!(v.IPv4.isValid(f)&&f.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},v.IPv4.networkAddressFromCIDR=function(f){let _,w,S,C,B;try{for(_=this.parseCIDR(f),S=_[0].toByteArray(),B=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),C=[],w=0;w<4;)C.push(parseInt(S[w],10)&parseInt(B[w],10)),w++;return new this(C)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},v.IPv4.parse=function(f){const _=this.parser(f);if(_===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(_)},v.IPv4.parseCIDR=function(f){let _;if(_=f.match(/^(.+)\/(\d+)$/)){const w=parseInt(_[2]);if(w>=0&&w<=32){const S=[this.parse(_[1]),w];return Object.defineProperty(S,"toString",{value:function(){return this.join("/")}}),S}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},v.IPv4.parser=function(f){let _,w,S;if(_=f.match(r.fourOctet))return function(){const C=_.slice(1,6),B=[];for(let L=0;L<C.length;L++)w=C[L],B.push(h(w));return B}();if(_=f.match(r.longValue)){if(S=h(_[1]),S>4294967295||S<0)throw new Error("ipaddr: address outside defined range");return function(){const C=[];let B;for(B=0;B<=24;B+=8)C.push(S>>B&255);return C}().reverse()}else return(_=f.match(r.twoOctet))?function(){const C=_.slice(1,4),B=[];if(S=h(C[1]),S>16777215||S<0)throw new Error("ipaddr: address outside defined range");return B.push(h(C[0])),B.push(S>>16&255),B.push(S>>8&255),B.push(S&255),B}():(_=f.match(r.threeOctet))?function(){const C=_.slice(1,5),B=[];if(S=h(C[2]),S>65535||S<0)throw new Error("ipaddr: address outside defined range");return B.push(h(C[0])),B.push(h(C[1])),B.push(S>>8&255),B.push(S&255),B}():null},v.IPv4.subnetMaskFromPrefixLength=function(f){if(f=parseInt(f),f<0||f>32)throw new Error("ipaddr: invalid IPv4 prefix length");const _=[0,0,0,0];let w=0;const S=Math.floor(f/8);for(;w<S;)_[w]=255,w++;return S<4&&(_[S]=Math.pow(2,f%8)-1<<8-f%8),new this(_)},v.IPv6=function(){function f(_,w){let S,C;if(_.length===16)for(this.parts=[],S=0;S<=14;S+=2)this.parts.push(_[S]<<8|_[S+1]);else if(_.length===8)this.parts=_;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(S=0;S<this.parts.length;S++)if(C=this.parts[S],!(0<=C&&C<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");w&&(this.zoneId=w)}return f.prototype.SpecialRanges={unspecified:[new f([0,0,0,0,0,0,0,0]),128],linkLocal:[new f([65152,0,0,0,0,0,0,0]),10],multicast:[new f([65280,0,0,0,0,0,0,0]),8],loopback:[new f([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new f([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new f([0,0,0,0,0,65535,0,0]),96],discard:[new f([256,0,0,0,0,0,0,0]),64],rfc6145:[new f([0,0,0,0,65535,0,0,0]),96],rfc6052:[new f([100,65435,0,0,0,0,0,0]),96],"6to4":[new f([8194,0,0,0,0,0,0,0]),16],teredo:[new f([8193,0,0,0,0,0,0,0]),32],benchmarking:[new f([8193,2,0,0,0,0,0,0]),48],amt:[new f([8193,3,0,0,0,0,0,0]),32],as112v6:[[new f([8193,4,274,0,0,0,0,0]),48],[new f([9760,79,32768,0,0,0,0,0]),48]],deprecated:[new f([8193,16,0,0,0,0,0,0]),28],orchid2:[new f([8193,32,0,0,0,0,0,0]),28],droneRemoteIdProtocolEntityTags:[new f([8193,48,0,0,0,0,0,0]),28],reserved:[[new f([8193,0,0,0,0,0,0,0]),23],[new f([8193,3512,0,0,0,0,0,0]),32]]},f.prototype.isIPv4MappedAddress=function(){return this.range()==="ipv4Mapped"},f.prototype.kind=function(){return"ipv6"},f.prototype.match=function(_,w){let S;if(w===void 0&&(S=_,_=S[0],w=S[1]),_.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return p(this.parts,_.parts,16,w)},f.prototype.prefixLengthFromSubnetMask=function(){let _=0,w=!1;const S={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0};let C,B;for(let L=7;L>=0;L-=1)if(C=this.parts[L],C in S){if(B=S[C],w&&B!==0)return null;B!==16&&(w=!0),_+=B}else return null;return 128-_},f.prototype.range=function(){return v.subnetMatch(this,this.SpecialRanges)},f.prototype.toByteArray=function(){let _;const w=[],S=this.parts;for(let C=0;C<S.length;C++)_=S[C],w.push(_>>8),w.push(_&255);return w},f.prototype.toFixedLengthString=function(){const _=(function(){const S=[];for(let C=0;C<this.parts.length;C++)S.push(m(this.parts[C].toString(16),4));return S}).call(this).join(":");let w="";return this.zoneId&&(w=`%${this.zoneId}`),_+w},f.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");const _=this.parts.slice(-2),w=_[0],S=_[1];return new v.IPv4([w>>8,w&255,S>>8,S&255])},f.prototype.toNormalizedString=function(){const _=(function(){const S=[];for(let C=0;C<this.parts.length;C++)S.push(this.parts[C].toString(16));return S}).call(this).join(":");let w="";return this.zoneId&&(w=`%${this.zoneId}`),_+w},f.prototype.toRFC5952String=function(){const _=/((^|:)(0(:|$)){2,})/g,w=this.toNormalizedString();let S=0,C=-1,B;for(;B=_.exec(w);)B[0].length>C&&(S=B.index,C=B[0].length);return C<0?w:`${w.substring(0,S)}::${w.substring(S+C)}`},f.prototype.toString=function(){return this.toRFC5952String()},f}(),v.IPv6.broadcastAddressFromCIDR=function(f){try{const _=this.parseCIDR(f),w=_[0].toByteArray(),S=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),C=[];let B=0;for(;B<16;)C.push(parseInt(w[B],10)|parseInt(S[B],10)^255),B++;return new this(C)}catch(_){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${_})`)}},v.IPv6.isIPv6=function(f){return this.parser(f)!==null},v.IPv6.isValid=function(f){if(typeof f=="string"&&f.indexOf(":")===-1)return!1;try{const _=this.parser(f);return new this(_.parts,_.zoneId),!0}catch{return!1}},v.IPv6.isValidCIDR=function(f){if(typeof f=="string"&&f.indexOf(":")===-1)return!1;try{return this.parseCIDR(f),!0}catch{return!1}},v.IPv6.networkAddressFromCIDR=function(f){let _,w,S,C,B;try{for(_=this.parseCIDR(f),S=_[0].toByteArray(),B=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),C=[],w=0;w<16;)C.push(parseInt(S[w],10)&parseInt(B[w],10)),w++;return new this(C)}catch(L){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${L})`)}},v.IPv6.parse=function(f){const _=this.parser(f);if(_.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(_.parts,_.zoneId)},v.IPv6.parseCIDR=function(f){let _,w,S;if((w=f.match(/^(.+)\/(\d+)$/))&&(_=parseInt(w[2]),_>=0&&_<=128))return S=[this.parse(w[1]),_],Object.defineProperty(S,"toString",{value:function(){return this.join("/")}}),S;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},v.IPv6.parser=function(f){let _,w,S,C,B,L;if(S=f.match(l.deprecatedTransitional))return this.parser(`::ffff:${S[1]}`);if(l.native.test(f))return u(f,8);if((S=f.match(l.transitional))&&(L=S[6]||"",_=S[1],S[1].endsWith("::")||(_=_.slice(0,-1)),_=u(_+L,6),_.parts)){for(B=[parseInt(S[2]),parseInt(S[3]),parseInt(S[4]),parseInt(S[5])],w=0;w<B.length;w++)if(C=B[w],!(0<=C&&C<=255))return null;return _.parts.push(B[0]<<8|B[1]),_.parts.push(B[2]<<8|B[3]),{parts:_.parts,zoneId:_.zoneId}}return null},v.IPv6.subnetMaskFromPrefixLength=function(f){if(f=parseInt(f),f<0||f>128)throw new Error("ipaddr: invalid IPv6 prefix length");const _=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];let w=0;const S=Math.floor(f/8);for(;w<S;)_[w]=255,w++;return S<16&&(_[S]=Math.pow(2,f%8)-1<<8-f%8),new this(_)},v.fromByteArray=function(f){const _=f.length;if(_===4)return new v.IPv4(f);if(_===16)return new v.IPv6(f);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},v.isValid=function(f){return v.IPv6.isValid(f)||v.IPv4.isValid(f)},v.isValidCIDR=function(f){return v.IPv6.isValidCIDR(f)||v.IPv4.isValidCIDR(f)},v.parse=function(f){if(v.IPv6.isValid(f))return v.IPv6.parse(f);if(v.IPv4.isValid(f))return v.IPv4.parse(f);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},v.parseCIDR=function(f){try{return v.IPv6.parseCIDR(f)}catch{try{return v.IPv4.parseCIDR(f)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},v.process=function(f){const _=this.parse(f);return _.kind()==="ipv6"&&_.isIPv4MappedAddress()?_.toIPv4Address():_},v.subnetMatch=function(f,_,w){let S,C,B,L;w==null&&(w="unicast");for(C in _)if(Object.prototype.hasOwnProperty.call(_,C)){for(B=_[C],B[0]&&!(B[0]instanceof Array)&&(B=[B]),S=0;S<B.length;S++)if(L=B[S],f.kind()===L[0].kind()&&f.match.apply(f,L))return C}return w},t.exports?t.exports=v:e.ipaddr=v})(as)})(Gh);var rd=Gh.exports;class id{static decodeIP(e){if(e.length===64&&parseInt(e,16)===0)return"::/0";if(e.length!==16)return e;const n=parseInt(e.slice(8),16).toString(2).split("").reduce((i,s)=>i+ +s,0);let r=e.slice(0,8).replace(/(.{2})/g,i=>`${parseInt(i,16)}.`);return r=r.slice(0,-1),`${r}/${n}`}static toString(e){if(e.byteLength===4||e.byteLength===16){const n=new Uint8Array(e);return rd.fromByteArray(Array.from(n)).toString()}return this.decodeIP(J.ToHex(e))}static fromString(e){const n=rd.parse(e);return new Uint8Array(n.toByteArray()).buffer}}var Ta,Pa,Ra;let Te=class{constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};d([g({type:b.TeletexString})],Te.prototype,"teletexString",void 0);d([g({type:b.PrintableString})],Te.prototype,"printableString",void 0);d([g({type:b.UniversalString})],Te.prototype,"universalString",void 0);d([g({type:b.Utf8String})],Te.prototype,"utf8String",void 0);d([g({type:b.BmpString})],Te.prototype,"bmpString",void 0);Te=d([R({type:T.Choice})],Te);let Yn=class extends Te{constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?J.ToHex(this.anyValue):super.toString())}};d([g({type:b.IA5String})],Yn.prototype,"ia5String",void 0);d([g({type:b.Any})],Yn.prototype,"anyValue",void 0);Yn=d([R({type:T.Choice})],Yn);class xo{constructor(e={}){this.type="",this.value=new Yn,Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],xo.prototype,"type",void 0);d([g({type:Yn})],xo.prototype,"value",void 0);let Xn=Ta=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Ta.prototype)}};Xn=Ta=d([R({type:T.Set,itemType:xo})],Xn);let La=Pa=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Pa.prototype)}};La=Pa=d([R({type:T.Sequence,itemType:Xn})],La);let ke=Ra=class extends La{constructor(e){super(e),Object.setPrototypeOf(this,Ra.prototype)}};ke=Ra=d([R({type:T.Sequence})],ke);const sv={fromASN:t=>id.toString(ps.fromASN(t)),toASN:t=>ps.toASN(id.fromString(t))};class Dr{constructor(e={}){this.typeId="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],Dr.prototype,"typeId",void 0);d([g({type:b.Any,context:0})],Dr.prototype,"value",void 0);class El{constructor(e={}){this.partyName=new Te,Object.assign(this,e)}}d([g({type:Te,optional:!0,context:0,implicit:!0})],El.prototype,"nameAssigner",void 0);d([g({type:Te,context:1,implicit:!0})],El.prototype,"partyName",void 0);let re=class{constructor(e={}){Object.assign(this,e)}};d([g({type:Dr,context:0,implicit:!0})],re.prototype,"otherName",void 0);d([g({type:b.IA5String,context:1,implicit:!0})],re.prototype,"rfc822Name",void 0);d([g({type:b.IA5String,context:2,implicit:!0})],re.prototype,"dNSName",void 0);d([g({type:b.Any,context:3,implicit:!0})],re.prototype,"x400Address",void 0);d([g({type:ke,context:4,implicit:!1})],re.prototype,"directoryName",void 0);d([g({type:El,context:5})],re.prototype,"ediPartyName",void 0);d([g({type:b.IA5String,context:6,implicit:!0})],re.prototype,"uniformResourceIdentifier",void 0);d([g({type:b.OctetString,context:7,implicit:!0,converter:sv})],re.prototype,"iPAddress",void 0);d([g({type:b.ObjectIdentifier,context:8,implicit:!0})],re.prototype,"registeredID",void 0);re=d([R({type:T.Choice})],re);const Il="1.3.6.1.5.5.7",ov=`${Il}.1`,fr=`${Il}.3`,So=`${Il}.48`,sd=`${So}.1`,od=`${So}.2`,ad=`${So}.3`,cd=`${So}.5`,cn="2.5.29";var Ua;const Va=`${ov}.1`;class li{constructor(e={}){this.accessMethod="",this.accessLocation=new re,Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],li.prototype,"accessMethod",void 0);d([g({type:re})],li.prototype,"accessLocation",void 0);let Hn=Ua=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Ua.prototype)}};Hn=Ua=d([R({type:T.Sequence,itemType:li})],Hn);const qa=`${cn}.35`;class zl extends ue{}class vn{constructor(e={}){e&&Object.assign(this,e)}}d([g({type:zl,context:0,optional:!0,implicit:!0})],vn.prototype,"keyIdentifier",void 0);d([g({type:re,context:1,optional:!0,implicit:!0,repeated:"sequence"})],vn.prototype,"authorityCertIssuer",void 0);d([g({type:b.Integer,context:2,optional:!0,implicit:!0,converter:_e})],vn.prototype,"authorityCertSerialNumber",void 0);const Jh=`${cn}.19`;class fs{constructor(e={}){this.cA=!1,Object.assign(this,e)}}d([g({type:b.Boolean,defaultValue:!1})],fs.prototype,"cA",void 0);d([g({type:b.Integer,optional:!0})],fs.prototype,"pathLenConstraint",void 0);var Ma;let qe=Ma=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Ma.prototype)}};qe=Ma=d([R({type:T.Sequence,itemType:re})],qe);var Da;let ld=Da=class extends qe{constructor(e){super(e),Object.setPrototypeOf(this,Da.prototype)}};ld=Da=d([R({type:T.Sequence})],ld);var Ha;const Zh=`${cn}.32`;let Rt=class{constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};d([g({type:b.IA5String})],Rt.prototype,"ia5String",void 0);d([g({type:b.VisibleString})],Rt.prototype,"visibleString",void 0);d([g({type:b.BmpString})],Rt.prototype,"bmpString",void 0);d([g({type:b.Utf8String})],Rt.prototype,"utf8String",void 0);Rt=d([R({type:T.Choice})],Rt);class Nl{constructor(e={}){this.organization=new Rt,this.noticeNumbers=[],Object.assign(this,e)}}d([g({type:Rt})],Nl.prototype,"organization",void 0);d([g({type:b.Integer,repeated:"sequence"})],Nl.prototype,"noticeNumbers",void 0);class Cl{constructor(e={}){Object.assign(this,e)}}d([g({type:Nl,optional:!0})],Cl.prototype,"noticeRef",void 0);d([g({type:Rt,optional:!0})],Cl.prototype,"explicitText",void 0);let hs=class{constructor(e={}){Object.assign(this,e)}};d([g({type:b.IA5String})],hs.prototype,"cPSuri",void 0);d([g({type:Cl})],hs.prototype,"userNotice",void 0);hs=d([R({type:T.Choice})],hs);class jl{constructor(e={}){this.policyQualifierId="",this.qualifier=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],jl.prototype,"policyQualifierId",void 0);d([g({type:b.Any})],jl.prototype,"qualifier",void 0);class Ao{constructor(e={}){this.policyIdentifier="",Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],Ao.prototype,"policyIdentifier",void 0);d([g({type:jl,repeated:"sequence",optional:!0})],Ao.prototype,"policyQualifiers",void 0);let gs=Ha=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Ha.prototype)}};gs=Ha=d([R({type:T.Sequence,itemType:Ao})],gs);let ms=class{constructor(e=0){this.value=e}};d([g({type:b.Integer})],ms.prototype,"value",void 0);ms=d([R({type:T.Choice})],ms);let ud=class extends ms{};ud=d([R({type:T.Choice})],ud);var Fa;const Ka=`${cn}.31`;var dt;(function(t){t[t.unused=1]="unused",t[t.keyCompromise=2]="keyCompromise",t[t.cACompromise=4]="cACompromise",t[t.affiliationChanged=8]="affiliationChanged",t[t.superseded=16]="superseded",t[t.cessationOfOperation=32]="cessationOfOperation",t[t.certificateHold=64]="certificateHold",t[t.privilegeWithdrawn=128]="privilegeWithdrawn",t[t.aACompromise=256]="aACompromise"})(dt||(dt={}));class Yh extends ko{toJSON(){const e=[],n=this.toNumber();return n&dt.aACompromise&&e.push("aACompromise"),n&dt.affiliationChanged&&e.push("affiliationChanged"),n&dt.cACompromise&&e.push("cACompromise"),n&dt.certificateHold&&e.push("certificateHold"),n&dt.cessationOfOperation&&e.push("cessationOfOperation"),n&dt.keyCompromise&&e.push("keyCompromise"),n&dt.privilegeWithdrawn&&e.push("privilegeWithdrawn"),n&dt.superseded&&e.push("superseded"),n&dt.unused&&e.push("unused"),e}toString(){return`[${this.toJSON().join(", ")}]`}}let En=class{constructor(e={}){Object.assign(this,e)}};d([g({type:re,context:0,repeated:"sequence",implicit:!0})],En.prototype,"fullName",void 0);d([g({type:Xn,context:1,implicit:!0})],En.prototype,"nameRelativeToCRLIssuer",void 0);En=d([R({type:T.Choice})],En);class hr{constructor(e={}){Object.assign(this,e)}}d([g({type:En,context:0,optional:!0})],hr.prototype,"distributionPoint",void 0);d([g({type:Yh,context:1,optional:!0,implicit:!0})],hr.prototype,"reasons",void 0);d([g({type:re,context:2,optional:!0,repeated:"sequence",implicit:!0})],hr.prototype,"cRLIssuer",void 0);let Wn=Fa=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Fa.prototype)}};Wn=Fa=d([R({type:T.Sequence,itemType:hr})],Wn);var Wa;let dd=Wa=class extends Wn{constructor(e){super(e),Object.setPrototypeOf(this,Wa.prototype)}};dd=Wa=d([R({type:T.Sequence,itemType:hr})],dd);class Le{constructor(e={}){this.onlyContainsUserCerts=Le.ONLY,this.onlyContainsCACerts=Le.ONLY,this.indirectCRL=Le.ONLY,this.onlyContainsAttributeCerts=Le.ONLY,Object.assign(this,e)}}Le.ONLY=!1;d([g({type:En,context:0,optional:!0})],Le.prototype,"distributionPoint",void 0);d([g({type:b.Boolean,context:1,defaultValue:Le.ONLY,implicit:!0})],Le.prototype,"onlyContainsUserCerts",void 0);d([g({type:b.Boolean,context:2,defaultValue:Le.ONLY,implicit:!0})],Le.prototype,"onlyContainsCACerts",void 0);d([g({type:Yh,context:3,optional:!0,implicit:!0})],Le.prototype,"onlySomeReasons",void 0);d([g({type:b.Boolean,context:4,defaultValue:Le.ONLY,implicit:!0})],Le.prototype,"indirectCRL",void 0);d([g({type:b.Boolean,context:5,defaultValue:Le.ONLY,implicit:!0})],Le.prototype,"onlyContainsAttributeCerts",void 0);var Tr;(function(t){t[t.unspecified=0]="unspecified",t[t.keyCompromise=1]="keyCompromise",t[t.cACompromise=2]="cACompromise",t[t.affiliationChanged=3]="affiliationChanged",t[t.superseded=4]="superseded",t[t.cessationOfOperation=5]="cessationOfOperation",t[t.certificateHold=6]="certificateHold",t[t.removeFromCRL=8]="removeFromCRL",t[t.privilegeWithdrawn=9]="privilegeWithdrawn",t[t.aACompromise=10]="aACompromise"})(Tr||(Tr={}));let Ga=class{constructor(e=Tr.unspecified){this.reason=Tr.unspecified,this.reason=e}toJSON(){return Tr[this.reason]}toString(){return this.toJSON()}};d([g({type:b.Enumerated})],Ga.prototype,"reason",void 0);Ga=d([R({type:T.Choice})],Ga);var Ja;const Xh=`${cn}.37`;let _s=Ja=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Ja.prototype)}};_s=Ja=d([R({type:T.Sequence,itemType:b.ObjectIdentifier})],_s);const av=`${fr}.1`,cv=`${fr}.2`,lv=`${fr}.3`,uv=`${fr}.4`,dv=`${fr}.8`,pv=`${fr}.9`;let Za=class{constructor(e=new ArrayBuffer(0)){this.value=e}};d([g({type:b.Integer,converter:_e})],Za.prototype,"value",void 0);Za=d([R({type:T.Choice})],Za);let Ya=class{constructor(e){this.value=new Date,e&&(this.value=e)}};d([g({type:b.GeneralizedTime})],Ya.prototype,"value",void 0);Ya=d([R({type:T.Choice})],Ya);var Xa;let pd=Xa=class extends qe{constructor(e){super(e),Object.setPrototypeOf(this,Xa.prototype)}};pd=Xa=d([R({type:T.Sequence})],pd);const Qh=`${cn}.15`;var pt;(function(t){t[t.digitalSignature=1]="digitalSignature",t[t.nonRepudiation=2]="nonRepudiation",t[t.keyEncipherment=4]="keyEncipherment",t[t.dataEncipherment=8]="dataEncipherment",t[t.keyAgreement=16]="keyAgreement",t[t.keyCertSign=32]="keyCertSign",t[t.cRLSign=64]="cRLSign",t[t.encipherOnly=128]="encipherOnly",t[t.decipherOnly=256]="decipherOnly"})(pt||(pt={}));class ia extends ko{toJSON(){const e=this.toNumber(),n=[];return e&pt.cRLSign&&n.push("crlSign"),e&pt.dataEncipherment&&n.push("dataEncipherment"),e&pt.decipherOnly&&n.push("decipherOnly"),e&pt.digitalSignature&&n.push("digitalSignature"),e&pt.encipherOnly&&n.push("encipherOnly"),e&pt.keyAgreement&&n.push("keyAgreement"),e&pt.keyCertSign&&n.push("keyCertSign"),e&pt.keyEncipherment&&n.push("keyEncipherment"),e&pt.nonRepudiation&&n.push("nonRepudiation"),n}toString(){return`[${this.toJSON().join(", ")}]`}}var Qa;class Eo{constructor(e={}){this.base=new re,this.minimum=0,Object.assign(this,e)}}d([g({type:re})],Eo.prototype,"base",void 0);d([g({type:b.Integer,context:0,defaultValue:0,implicit:!0})],Eo.prototype,"minimum",void 0);d([g({type:b.Integer,context:1,optional:!0,implicit:!0})],Eo.prototype,"maximum",void 0);let ys=Qa=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Qa.prototype)}};ys=Qa=d([R({type:T.Sequence,itemType:Eo})],ys);class eg{constructor(e={}){Object.assign(this,e)}}d([g({type:ys,context:0,optional:!0,implicit:!0})],eg.prototype,"permittedSubtrees",void 0);d([g({type:ys,context:1,optional:!0,implicit:!0})],eg.prototype,"excludedSubtrees",void 0);class tg{constructor(e={}){Object.assign(this,e)}}d([g({type:b.Integer,context:0,implicit:!0,optional:!0,converter:_e})],tg.prototype,"requireExplicitPolicy",void 0);d([g({type:b.Integer,context:1,implicit:!0,optional:!0,converter:_e})],tg.prototype,"inhibitPolicyMapping",void 0);var ec;class $l{constructor(e={}){this.issuerDomainPolicy="",this.subjectDomainPolicy="",Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],$l.prototype,"issuerDomainPolicy",void 0);d([g({type:b.ObjectIdentifier})],$l.prototype,"subjectDomainPolicy",void 0);let fd=ec=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,ec.prototype)}};fd=ec=d([R({type:T.Sequence,itemType:$l})],fd);var tc;const ng=`${cn}.17`;let nc=tc=class extends qe{constructor(e){super(e),Object.setPrototypeOf(this,tc.prototype)}};nc=tc=d([R({type:T.Sequence})],nc);let Lt=class{constructor(e={}){this.type="",this.values=[],Object.assign(this,e)}};d([g({type:b.ObjectIdentifier})],Lt.prototype,"type",void 0);d([g({type:b.Any,repeated:"set"})],Lt.prototype,"values",void 0);var rc;let hd=rc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,rc.prototype)}};hd=rc=d([R({type:T.Sequence,itemType:Lt})],hd);const rg=`${cn}.14`;class Zt extends zl{}class ig{constructor(e={}){Object.assign(this,e)}}d([g({type:b.GeneralizedTime,context:0,implicit:!0,optional:!0})],ig.prototype,"notBefore",void 0);d([g({type:b.GeneralizedTime,context:1,implicit:!0,optional:!0})],ig.prototype,"notAfter",void 0);var Pr;(function(t){t[t.keyUpdateAllowed=1]="keyUpdateAllowed",t[t.newExtensions=2]="newExtensions",t[t.pKIXCertificate=4]="pKIXCertificate"})(Pr||(Pr={}));class sg extends ko{toJSON(){const e=[],n=this.toNumber();return n&Pr.pKIXCertificate&&e.push("pKIXCertificate"),n&Pr.newExtensions&&e.push("newExtensions"),n&Pr.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return`[${this.toJSON().join(", ")}]`}}class og{constructor(e={}){this.entrustVers="",this.entrustInfoFlags=new sg,Object.assign(this,e)}}d([g({type:b.GeneralString})],og.prototype,"entrustVers",void 0);d([g({type:sg})],og.prototype,"entrustInfoFlags",void 0);var ic;let gd=ic=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,ic.prototype)}};gd=ic=d([R({type:T.Sequence,itemType:li})],gd);class F{constructor(e={}){this.algorithm="",Object.assign(this,e)}isEqual(e){return e instanceof F&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&Kf(e.parameters,this.parameters)||e.parameters===this.parameters)}}d([g({type:b.ObjectIdentifier})],F.prototype,"algorithm",void 0);d([g({type:b.Any,optional:!0})],F.prototype,"parameters",void 0);class ft{constructor(e={}){this.algorithm=new F,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:F})],ft.prototype,"algorithm",void 0);d([g({type:b.BitString})],ft.prototype,"subjectPublicKey",void 0);let Oe=class{constructor(e){if(e)if(typeof e=="string"||typeof e=="number"||e instanceof Date){const n=new Date(e);n.getUTCFullYear()>2049?this.generalTime=n:this.utcTime=n}else Object.assign(this,e)}getTime(){const e=this.utcTime||this.generalTime;if(!e)throw new Error("Cannot get time from CHOICE object");return e}};d([g({type:b.UTCTime})],Oe.prototype,"utcTime",void 0);d([g({type:b.GeneralizedTime})],Oe.prototype,"generalTime",void 0);Oe=d([R({type:T.Choice})],Oe);class ui{constructor(e){this.notBefore=new Oe(new Date),this.notAfter=new Oe(new Date),e&&(this.notBefore=new Oe(e.notBefore),this.notAfter=new Oe(e.notAfter))}}d([g({type:Oe})],ui.prototype,"notBefore",void 0);d([g({type:Oe})],ui.prototype,"notAfter",void 0);var sc;let ot=class ag{constructor(e={}){this.extnID="",this.critical=ag.CRITICAL,this.extnValue=new ue,Object.assign(this,e)}};ot.CRITICAL=!1;d([g({type:b.ObjectIdentifier})],ot.prototype,"extnID",void 0);d([g({type:b.Boolean,defaultValue:ot.CRITICAL})],ot.prototype,"critical",void 0);d([g({type:ue})],ot.prototype,"extnValue",void 0);let en=sc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,sc.prototype)}};en=sc=d([R({type:T.Sequence,itemType:ot})],en);var In;(function(t){t[t.v1=0]="v1",t[t.v2=1]="v2",t[t.v3=2]="v3"})(In||(In={}));class tt{constructor(e={}){this.version=In.v1,this.serialNumber=new ArrayBuffer(0),this.signature=new F,this.issuer=new ke,this.validity=new ui,this.subject=new ke,this.subjectPublicKeyInfo=new ft,Object.assign(this,e)}}d([g({type:b.Integer,context:0,defaultValue:In.v1})],tt.prototype,"version",void 0);d([g({type:b.Integer,converter:_e})],tt.prototype,"serialNumber",void 0);d([g({type:F})],tt.prototype,"signature",void 0);d([g({type:ke})],tt.prototype,"issuer",void 0);d([g({type:ui})],tt.prototype,"validity",void 0);d([g({type:ke})],tt.prototype,"subject",void 0);d([g({type:ft})],tt.prototype,"subjectPublicKeyInfo",void 0);d([g({type:b.BitString,context:1,implicit:!0,optional:!0})],tt.prototype,"issuerUniqueID",void 0);d([g({type:b.BitString,context:2,implicit:!0,optional:!0})],tt.prototype,"subjectUniqueID",void 0);d([g({type:en,context:3,optional:!0})],tt.prototype,"extensions",void 0);class zn{constructor(e={}){this.tbsCertificate=new tt,this.signatureAlgorithm=new F,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:tt})],zn.prototype,"tbsCertificate",void 0);d([g({type:F})],zn.prototype,"signatureAlgorithm",void 0);d([g({type:b.BitString})],zn.prototype,"signatureValue",void 0);class Io{constructor(e={}){this.userCertificate=new ArrayBuffer(0),this.revocationDate=new Oe,Object.assign(this,e)}}d([g({type:b.Integer,converter:_e})],Io.prototype,"userCertificate",void 0);d([g({type:Oe})],Io.prototype,"revocationDate",void 0);d([g({type:ot,optional:!0,repeated:"sequence"})],Io.prototype,"crlEntryExtensions",void 0);class Ht{constructor(e={}){this.signature=new F,this.issuer=new ke,this.thisUpdate=new Oe,Object.assign(this,e)}}d([g({type:b.Integer,optional:!0})],Ht.prototype,"version",void 0);d([g({type:F})],Ht.prototype,"signature",void 0);d([g({type:ke})],Ht.prototype,"issuer",void 0);d([g({type:Oe})],Ht.prototype,"thisUpdate",void 0);d([g({type:Oe,optional:!0})],Ht.prototype,"nextUpdate",void 0);d([g({type:Io,repeated:"sequence",optional:!0})],Ht.prototype,"revokedCertificates",void 0);d([g({type:ot,optional:!0,context:0,repeated:"sequence"})],Ht.prototype,"crlExtensions",void 0);class Ol{constructor(e={}){this.tbsCertList=new Ht,this.signatureAlgorithm=new F,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:Ht})],Ol.prototype,"tbsCertList",void 0);d([g({type:F})],Ol.prototype,"signatureAlgorithm",void 0);d([g({type:b.BitString})],Ol.prototype,"signature",void 0);class gr{constructor(e={}){this.issuer=new ke,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:ke})],gr.prototype,"issuer",void 0);d([g({type:b.Integer,converter:_e})],gr.prototype,"serialNumber",void 0);let Qn=class{constructor(e={}){Object.assign(this,e)}};d([g({type:Zt,context:0,implicit:!0})],Qn.prototype,"subjectKeyIdentifier",void 0);d([g({type:gr})],Qn.prototype,"issuerAndSerialNumber",void 0);Qn=d([R({type:T.Choice})],Qn);var Ut;(function(t){t[t.v0=0]="v0",t[t.v1=1]="v1",t[t.v2=2]="v2",t[t.v3=3]="v3",t[t.v4=4]="v4",t[t.v5=5]="v5"})(Ut||(Ut={}));let Hr=class extends F{};Hr=d([R({type:T.Sequence})],Hr);let vs=class extends F{};vs=d([R({type:T.Sequence})],vs);let Et=class extends F{};Et=d([R({type:T.Sequence})],Et);let ws=class extends F{};ws=d([R({type:T.Sequence})],ws);let md=class extends F{};md=d([R({type:T.Sequence})],md);let oc=class extends F{};oc=d([R({type:T.Sequence})],oc);let mr=class{constructor(e={}){this.attrType="",this.attrValues=[],Object.assign(this,e)}};d([g({type:b.ObjectIdentifier})],mr.prototype,"attrType",void 0);d([g({type:b.Any,repeated:"set"})],mr.prototype,"attrValues",void 0);var ac;class Ct{constructor(e={}){this.version=Ut.v0,this.sid=new Qn,this.digestAlgorithm=new Hr,this.signatureAlgorithm=new vs,this.signature=new ue,Object.assign(this,e)}}d([g({type:b.Integer})],Ct.prototype,"version",void 0);d([g({type:Qn})],Ct.prototype,"sid",void 0);d([g({type:Hr})],Ct.prototype,"digestAlgorithm",void 0);d([g({type:mr,repeated:"set",context:0,implicit:!0,optional:!0})],Ct.prototype,"signedAttrs",void 0);d([g({type:vs})],Ct.prototype,"signatureAlgorithm",void 0);d([g({type:ue})],Ct.prototype,"signature",void 0);d([g({type:mr,repeated:"set",context:1,implicit:!0,optional:!0})],Ct.prototype,"unsignedAttrs",void 0);let bs=ac=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,ac.prototype)}};bs=ac=d([R({type:T.Set,itemType:Ct})],bs);let _d=class extends Oe{};_d=d([R({type:T.Choice})],_d);let yd=class extends Ct{};yd=d([R({type:T.Sequence})],yd);class Bl{constructor(e={}){this.acIssuer=new re,this.acSerial=0,this.attrs=[],Object.assign(this,e)}}d([g({type:re})],Bl.prototype,"acIssuer",void 0);d([g({type:b.Integer})],Bl.prototype,"acSerial",void 0);d([g({type:Lt,repeated:"sequence"})],Bl.prototype,"attrs",void 0);var cc;let ks=cc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,cc.prototype)}};ks=cc=d([R({type:T.Sequence,itemType:b.ObjectIdentifier})],ks);class zo{constructor(e={}){this.permitUnSpecified=!0,Object.assign(this,e)}}d([g({type:b.Integer,optional:!0})],zo.prototype,"pathLenConstraint",void 0);d([g({type:ks,implicit:!0,context:0,optional:!0})],zo.prototype,"permittedAttrs",void 0);d([g({type:ks,implicit:!0,context:1,optional:!0})],zo.prototype,"excludedAttrs",void 0);d([g({type:b.Boolean,defaultValue:!0})],zo.prototype,"permitUnSpecified",void 0);class Rn{constructor(e={}){this.issuer=new qe,this.serial=new ArrayBuffer(0),this.issuerUID=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:qe})],Rn.prototype,"issuer",void 0);d([g({type:b.Integer,converter:_e})],Rn.prototype,"serial",void 0);d([g({type:b.BitString,optional:!0})],Rn.prototype,"issuerUID",void 0);var lc;(function(t){t[t.publicKey=0]="publicKey",t[t.publicKeyCert=1]="publicKeyCert",t[t.otherObjectTypes=2]="otherObjectTypes"})(lc||(lc={}));class Ln{constructor(e={}){this.digestedObjectType=lc.publicKey,this.digestAlgorithm=new F,this.objectDigest=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.Enumerated})],Ln.prototype,"digestedObjectType",void 0);d([g({type:b.ObjectIdentifier,optional:!0})],Ln.prototype,"otherObjectTypeID",void 0);d([g({type:F})],Ln.prototype,"digestAlgorithm",void 0);d([g({type:b.BitString})],Ln.prototype,"objectDigest",void 0);class No{constructor(e={}){Object.assign(this,e)}}d([g({type:qe,optional:!0})],No.prototype,"issuerName",void 0);d([g({type:Rn,context:0,implicit:!0,optional:!0})],No.prototype,"baseCertificateID",void 0);d([g({type:Ln,context:1,implicit:!0,optional:!0})],No.prototype,"objectDigestInfo",void 0);let er=class{constructor(e={}){Object.assign(this,e)}};d([g({type:re,repeated:"sequence"})],er.prototype,"v1Form",void 0);d([g({type:No,context:0,implicit:!0})],er.prototype,"v2Form",void 0);er=d([R({type:T.Choice})],er);class Co{constructor(e={}){this.notBeforeTime=new Date,this.notAfterTime=new Date,Object.assign(this,e)}}d([g({type:b.GeneralizedTime})],Co.prototype,"notBeforeTime",void 0);d([g({type:b.GeneralizedTime})],Co.prototype,"notAfterTime",void 0);class di{constructor(e={}){Object.assign(this,e)}}d([g({type:Rn,implicit:!0,context:0,optional:!0})],di.prototype,"baseCertificateID",void 0);d([g({type:qe,implicit:!0,context:1,optional:!0})],di.prototype,"entityName",void 0);d([g({type:Ln,implicit:!0,context:2,optional:!0})],di.prototype,"objectDigestInfo",void 0);var uc;(function(t){t[t.v2=1]="v2"})(uc||(uc={}));class vt{constructor(e={}){this.version=uc.v2,this.holder=new di,this.issuer=new er,this.signature=new F,this.serialNumber=new ArrayBuffer(0),this.attrCertValidityPeriod=new Co,this.attributes=[],Object.assign(this,e)}}d([g({type:b.Integer})],vt.prototype,"version",void 0);d([g({type:di})],vt.prototype,"holder",void 0);d([g({type:er})],vt.prototype,"issuer",void 0);d([g({type:F})],vt.prototype,"signature",void 0);d([g({type:b.Integer,converter:_e})],vt.prototype,"serialNumber",void 0);d([g({type:Co})],vt.prototype,"attrCertValidityPeriod",void 0);d([g({type:Lt,repeated:"sequence"})],vt.prototype,"attributes",void 0);d([g({type:b.BitString,optional:!0})],vt.prototype,"issuerUniqueID",void 0);d([g({type:en,optional:!0})],vt.prototype,"extensions",void 0);class jo{constructor(e={}){this.acinfo=new vt,this.signatureAlgorithm=new F,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:vt})],jo.prototype,"acinfo",void 0);d([g({type:F})],jo.prototype,"signatureAlgorithm",void 0);d([g({type:b.BitString})],jo.prototype,"signatureValue",void 0);var xs;(function(t){t[t.unmarked=1]="unmarked",t[t.unclassified=2]="unclassified",t[t.restricted=4]="restricted",t[t.confidential=8]="confidential",t[t.secret=16]="secret",t[t.topSecret=32]="topSecret"})(xs||(xs={}));class dc extends ko{}class Tl{constructor(e={}){this.type="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier,implicit:!0,context:0})],Tl.prototype,"type",void 0);d([g({type:b.Any,implicit:!0,context:1})],Tl.prototype,"value",void 0);class Pl{constructor(e={}){this.policyId="",this.classList=new dc(xs.unclassified),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],Pl.prototype,"policyId",void 0);d([g({type:dc,defaultValue:new dc(xs.unclassified)})],Pl.prototype,"classList",void 0);d([g({type:Tl,repeated:"set"})],Pl.prototype,"securityCategories",void 0);class $o{constructor(e={}){Object.assign(this,e)}}d([g({type:ue})],$o.prototype,"cotets",void 0);d([g({type:b.ObjectIdentifier})],$o.prototype,"oid",void 0);d([g({type:b.Utf8String})],$o.prototype,"string",void 0);class cg{constructor(e={}){this.values=[],Object.assign(this,e)}}d([g({type:qe,implicit:!0,context:0,optional:!0})],cg.prototype,"policyAuthority",void 0);d([g({type:$o,repeated:"sequence"})],cg.prototype,"values",void 0);var pc;class Oo{constructor(e={}){this.targetCertificate=new Rn,Object.assign(this,e)}}d([g({type:Rn})],Oo.prototype,"targetCertificate",void 0);d([g({type:re,optional:!0})],Oo.prototype,"targetName",void 0);d([g({type:Ln,optional:!0})],Oo.prototype,"certDigestInfo",void 0);let tr=class{constructor(e={}){Object.assign(this,e)}};d([g({type:re,context:0,implicit:!0})],tr.prototype,"targetName",void 0);d([g({type:re,context:1,implicit:!0})],tr.prototype,"targetGroup",void 0);d([g({type:Oo,context:2,implicit:!0})],tr.prototype,"targetCert",void 0);tr=d([R({type:T.Choice})],tr);let fc=pc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,pc.prototype)}};fc=pc=d([R({type:T.Sequence,itemType:tr})],fc);var hc;let vd=hc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,hc.prototype)}};vd=hc=d([R({type:T.Sequence,itemType:fc})],vd);class lg{constructor(e={}){Object.assign(this,e)}}d([g({type:qe,implicit:!0,context:0,optional:!0})],lg.prototype,"roleAuthority",void 0);d([g({type:re,implicit:!0,context:1})],lg.prototype,"roleName",void 0);class Rl{constructor(e={}){this.service=new re,this.ident=new re,Object.assign(this,e)}}d([g({type:re})],Rl.prototype,"service",void 0);d([g({type:re})],Rl.prototype,"ident",void 0);d([g({type:ue,optional:!0})],Rl.prototype,"authInfo",void 0);var gc;class Ll{constructor(e={}){this.otherCertFormat="",this.otherCert=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],Ll.prototype,"otherCertFormat",void 0);d([g({type:b.Any})],Ll.prototype,"otherCert",void 0);let nr=class{constructor(e={}){Object.assign(this,e)}};d([g({type:zn})],nr.prototype,"certificate",void 0);d([g({type:jo,context:2,implicit:!0})],nr.prototype,"v2AttrCert",void 0);d([g({type:Ll,context:3,implicit:!0})],nr.prototype,"other",void 0);nr=d([R({type:T.Choice})],nr);let Ss=gc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,gc.prototype)}};Ss=gc=d([R({type:T.Set,itemType:nr})],Ss);class _r{constructor(e={}){this.contentType="",this.content=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],_r.prototype,"contentType",void 0);d([g({type:b.Any,context:0})],_r.prototype,"content",void 0);let Fr=class{constructor(e={}){Object.assign(this,e)}};d([g({type:ue})],Fr.prototype,"single",void 0);d([g({type:b.Any})],Fr.prototype,"any",void 0);Fr=d([R({type:T.Choice})],Fr);class Bo{constructor(e={}){this.eContentType="",Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],Bo.prototype,"eContentType",void 0);d([g({type:Fr,context:0,optional:!0})],Bo.prototype,"eContent",void 0);let Kr=class{constructor(e={}){Object.assign(this,e)}};d([g({type:ue,context:0,implicit:!0,optional:!0})],Kr.prototype,"value",void 0);d([g({type:ue,converter:qy,context:0,implicit:!0,optional:!0,repeated:"sequence"})],Kr.prototype,"constructedValue",void 0);Kr=d([R({type:T.Choice})],Kr);class pi{constructor(e={}){this.contentType="",this.contentEncryptionAlgorithm=new ws,Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],pi.prototype,"contentType",void 0);d([g({type:ws})],pi.prototype,"contentEncryptionAlgorithm",void 0);d([g({type:Kr,optional:!0})],pi.prototype,"encryptedContent",void 0);class To{constructor(e={}){this.keyAttrId="",Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],To.prototype,"keyAttrId",void 0);d([g({type:b.Any,optional:!0})],To.prototype,"keyAttr",void 0);var mc;class Po{constructor(e={}){this.subjectKeyIdentifier=new Zt,Object.assign(this,e)}}d([g({type:Zt})],Po.prototype,"subjectKeyIdentifier",void 0);d([g({type:b.GeneralizedTime,optional:!0})],Po.prototype,"date",void 0);d([g({type:To,optional:!0})],Po.prototype,"other",void 0);let rr=class{constructor(e={}){Object.assign(this,e)}};d([g({type:Po,context:0,implicit:!0,optional:!0})],rr.prototype,"rKeyId",void 0);d([g({type:gr,optional:!0})],rr.prototype,"issuerAndSerialNumber",void 0);rr=d([R({type:T.Choice})],rr);class Ul{constructor(e={}){this.rid=new rr,this.encryptedKey=new ue,Object.assign(this,e)}}d([g({type:rr})],Ul.prototype,"rid",void 0);d([g({type:ue})],Ul.prototype,"encryptedKey",void 0);let As=mc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,mc.prototype)}};As=mc=d([R({type:T.Sequence,itemType:Ul})],As);class Vl{constructor(e={}){this.algorithm=new F,this.publicKey=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:F})],Vl.prototype,"algorithm",void 0);d([g({type:b.BitString})],Vl.prototype,"publicKey",void 0);let Nn=class{constructor(e={}){Object.assign(this,e)}};d([g({type:Zt,context:0,implicit:!0,optional:!0})],Nn.prototype,"subjectKeyIdentifier",void 0);d([g({type:Vl,context:1,implicit:!0,optional:!0})],Nn.prototype,"originatorKey",void 0);d([g({type:gr,optional:!0})],Nn.prototype,"issuerAndSerialNumber",void 0);Nn=d([R({type:T.Choice})],Nn);class yr{constructor(e={}){this.version=Ut.v3,this.originator=new Nn,this.keyEncryptionAlgorithm=new Et,this.recipientEncryptedKeys=new As,Object.assign(this,e)}}d([g({type:b.Integer})],yr.prototype,"version",void 0);d([g({type:Nn,context:0})],yr.prototype,"originator",void 0);d([g({type:ue,context:1,optional:!0})],yr.prototype,"ukm",void 0);d([g({type:Et})],yr.prototype,"keyEncryptionAlgorithm",void 0);d([g({type:As})],yr.prototype,"recipientEncryptedKeys",void 0);let ir=class{constructor(e={}){Object.assign(this,e)}};d([g({type:Zt,context:0,implicit:!0})],ir.prototype,"subjectKeyIdentifier",void 0);d([g({type:gr})],ir.prototype,"issuerAndSerialNumber",void 0);ir=d([R({type:T.Choice})],ir);class fi{constructor(e={}){this.version=Ut.v0,this.rid=new ir,this.keyEncryptionAlgorithm=new Et,this.encryptedKey=new ue,Object.assign(this,e)}}d([g({type:b.Integer})],fi.prototype,"version",void 0);d([g({type:ir})],fi.prototype,"rid",void 0);d([g({type:Et})],fi.prototype,"keyEncryptionAlgorithm",void 0);d([g({type:ue})],fi.prototype,"encryptedKey",void 0);class hi{constructor(e={}){this.keyIdentifier=new ue,Object.assign(this,e)}}d([g({type:ue})],hi.prototype,"keyIdentifier",void 0);d([g({type:b.GeneralizedTime,optional:!0})],hi.prototype,"date",void 0);d([g({type:To,optional:!0})],hi.prototype,"other",void 0);class gi{constructor(e={}){this.version=Ut.v4,this.kekid=new hi,this.keyEncryptionAlgorithm=new Et,this.encryptedKey=new ue,Object.assign(this,e)}}d([g({type:b.Integer})],gi.prototype,"version",void 0);d([g({type:hi})],gi.prototype,"kekid",void 0);d([g({type:Et})],gi.prototype,"keyEncryptionAlgorithm",void 0);d([g({type:ue})],gi.prototype,"encryptedKey",void 0);class mi{constructor(e={}){this.version=Ut.v0,this.keyEncryptionAlgorithm=new Et,this.encryptedKey=new ue,Object.assign(this,e)}}d([g({type:b.Integer})],mi.prototype,"version",void 0);d([g({type:oc,context:0,optional:!0})],mi.prototype,"keyDerivationAlgorithm",void 0);d([g({type:Et})],mi.prototype,"keyEncryptionAlgorithm",void 0);d([g({type:ue})],mi.prototype,"encryptedKey",void 0);class ql{constructor(e={}){this.oriType="",this.oriValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],ql.prototype,"oriType",void 0);d([g({type:b.Any})],ql.prototype,"oriValue",void 0);let tn=class{constructor(e={}){Object.assign(this,e)}};d([g({type:fi,optional:!0})],tn.prototype,"ktri",void 0);d([g({type:yr,context:1,implicit:!0,optional:!0})],tn.prototype,"kari",void 0);d([g({type:gi,context:2,implicit:!0,optional:!0})],tn.prototype,"kekri",void 0);d([g({type:mi,context:3,implicit:!0,optional:!0})],tn.prototype,"pwri",void 0);d([g({type:ql,context:4,implicit:!0,optional:!0})],tn.prototype,"ori",void 0);tn=d([R({type:T.Choice})],tn);var _c;let Es=_c=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,_c.prototype)}};Es=_c=d([R({type:T.Set,itemType:tn})],Es);var yc;class Ro{constructor(e={}){this.otherRevInfoFormat="",this.otherRevInfo=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],Ro.prototype,"otherRevInfoFormat",void 0);d([g({type:b.Any})],Ro.prototype,"otherRevInfo",void 0);let Is=class{constructor(e={}){this.other=new Ro,Object.assign(this,e)}};d([g({type:Ro,context:1,implicit:!0})],Is.prototype,"other",void 0);Is=d([R({type:T.Choice})],Is);let zs=yc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,yc.prototype)}};zs=yc=d([R({type:T.Set,itemType:Is})],zs);class Ml{constructor(e={}){Object.assign(this,e)}}d([g({type:Ss,context:0,implicit:!0,optional:!0})],Ml.prototype,"certs",void 0);d([g({type:zs,context:1,implicit:!0,optional:!0})],Ml.prototype,"crls",void 0);var vc;let wc=vc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,vc.prototype)}};wc=vc=d([R({type:T.Set,itemType:mr})],wc);class _i{constructor(e={}){this.version=Ut.v0,this.recipientInfos=new Es,this.encryptedContentInfo=new pi,Object.assign(this,e)}}d([g({type:b.Integer})],_i.prototype,"version",void 0);d([g({type:Ml,context:0,implicit:!0,optional:!0})],_i.prototype,"originatorInfo",void 0);d([g({type:Es})],_i.prototype,"recipientInfos",void 0);d([g({type:pi})],_i.prototype,"encryptedContentInfo",void 0);d([g({type:wc,context:1,implicit:!0,optional:!0})],_i.prototype,"unprotectedAttrs",void 0);const fv="1.2.840.113549.1.7.2";var bc;let Ns=bc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,bc.prototype)}};Ns=bc=d([R({type:T.Set,itemType:Hr})],Ns);class vr{constructor(e={}){this.version=Ut.v0,this.digestAlgorithms=new Ns,this.encapContentInfo=new Bo,this.signerInfos=new bs,Object.assign(this,e)}}d([g({type:b.Integer})],vr.prototype,"version",void 0);d([g({type:Ns})],vr.prototype,"digestAlgorithms",void 0);d([g({type:Bo})],vr.prototype,"encapContentInfo",void 0);d([g({type:Ss,context:0,implicit:!0,optional:!0})],vr.prototype,"certificates",void 0);d([g({type:zs,context:1,implicit:!0,optional:!0})],vr.prototype,"crls",void 0);d([g({type:bs})],vr.prototype,"signerInfos",void 0);const Wr="1.2.840.10045.2.1",Dl="1.2.840.10045.4.1",ug="1.2.840.10045.4.3.1",Hl="1.2.840.10045.4.3.2",Fl="1.2.840.10045.4.3.3",Kl="1.2.840.10045.4.3.4",wd="1.2.840.10045.3.1.7",bd="1.3.132.0.34",kd="1.3.132.0.35";function yi(t){return new F({algorithm:t})}const hv=yi(Dl);yi(ug);const gv=yi(Hl),mv=yi(Fl),_v=yi(Kl);let Gr=class{constructor(e={}){Object.assign(this,e)}};d([g({type:b.ObjectIdentifier})],Gr.prototype,"fieldType",void 0);d([g({type:b.Any})],Gr.prototype,"parameters",void 0);Gr=d([R({type:T.Sequence})],Gr);class yv extends ue{}let sr=class{constructor(e={}){Object.assign(this,e)}};d([g({type:b.OctetString})],sr.prototype,"a",void 0);d([g({type:b.OctetString})],sr.prototype,"b",void 0);d([g({type:b.BitString,optional:!0})],sr.prototype,"seed",void 0);sr=d([R({type:T.Sequence})],sr);var kc;(function(t){t[t.ecpVer1=1]="ecpVer1"})(kc||(kc={}));let Vt=class{constructor(e={}){this.version=kc.ecpVer1,Object.assign(this,e)}};d([g({type:b.Integer})],Vt.prototype,"version",void 0);d([g({type:Gr})],Vt.prototype,"fieldID",void 0);d([g({type:sr})],Vt.prototype,"curve",void 0);d([g({type:yv})],Vt.prototype,"base",void 0);d([g({type:b.Integer,converter:_e})],Vt.prototype,"order",void 0);d([g({type:b.Integer,optional:!0})],Vt.prototype,"cofactor",void 0);Vt=d([R({type:T.Sequence})],Vt);let nn=class{constructor(e={}){Object.assign(this,e)}};d([g({type:b.ObjectIdentifier})],nn.prototype,"namedCurve",void 0);d([g({type:b.Null})],nn.prototype,"implicitCurve",void 0);d([g({type:Vt})],nn.prototype,"specifiedCurve",void 0);nn=d([R({type:T.Choice})],nn);class Lo{constructor(e={}){this.version=1,this.privateKey=new ue,Object.assign(this,e)}}d([g({type:b.Integer})],Lo.prototype,"version",void 0);d([g({type:ue})],Lo.prototype,"privateKey",void 0);d([g({type:nn,context:0,optional:!0})],Lo.prototype,"parameters",void 0);d([g({type:b.BitString,context:1,optional:!0})],Lo.prototype,"publicKey",void 0);class Cs{constructor(e={}){this.r=new ArrayBuffer(0),this.s=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.Integer,converter:_e})],Cs.prototype,"r",void 0);d([g({type:b.Integer,converter:_e})],Cs.prototype,"s",void 0);const Ge="1.2.840.113549.1.1",Cn=`${Ge}.1`,vv=`${Ge}.7`,wv=`${Ge}.9`,Rr=`${Ge}.10`,bv=`${Ge}.2`,kv=`${Ge}.4`,js=`${Ge}.5`,xv=`${Ge}.14`,xc=`${Ge}.11`,$s=`${Ge}.12`,Os=`${Ge}.13`,dg=`${Ge}.15`,pg=`${Ge}.16`,Bs="1.3.14.3.2.26",fg="2.16.840.1.101.3.4.2.4",Ts="2.16.840.1.101.3.4.2.1",Ps="2.16.840.1.101.3.4.2.2",Rs="2.16.840.1.101.3.4.2.3",Sv="2.16.840.1.101.3.4.2.5",Av="2.16.840.1.101.3.4.2.6",Ev="1.2.840.113549.2.2",Iv="1.2.840.113549.2.5",Uo=`${Ge}.8`;function ze(t){return new F({algorithm:t,parameters:null})}ze(Ev);ze(Iv);const jn=ze(Bs);ze(fg);ze(Ts);ze(Ps);ze(Rs);ze(Sv);ze(Av);const hg=new F({algorithm:Uo,parameters:q.serialize(jn)}),gg=new F({algorithm:wv,parameters:q.serialize(ps.toASN(new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer))});ze(Cn);ze(bv);ze(kv);ze(js);ze(dg);ze(pg);ze($s);ze(Os);ze(dg);ze(pg);class Vo{constructor(e={}){this.hashAlgorithm=new F(jn),this.maskGenAlgorithm=new F({algorithm:Uo,parameters:q.serialize(jn)}),this.pSourceAlgorithm=new F(gg),Object.assign(this,e)}}d([g({type:F,context:0,defaultValue:jn})],Vo.prototype,"hashAlgorithm",void 0);d([g({type:F,context:1,defaultValue:hg})],Vo.prototype,"maskGenAlgorithm",void 0);d([g({type:F,context:2,defaultValue:gg})],Vo.prototype,"pSourceAlgorithm",void 0);new F({algorithm:vv,parameters:q.serialize(new Vo)});class $n{constructor(e={}){this.hashAlgorithm=new F(jn),this.maskGenAlgorithm=new F({algorithm:Uo,parameters:q.serialize(jn)}),this.saltLength=20,this.trailerField=1,Object.assign(this,e)}}d([g({type:F,context:0,defaultValue:jn})],$n.prototype,"hashAlgorithm",void 0);d([g({type:F,context:1,defaultValue:hg})],$n.prototype,"maskGenAlgorithm",void 0);d([g({type:b.Integer,context:2,defaultValue:20})],$n.prototype,"saltLength",void 0);d([g({type:b.Integer,context:3,defaultValue:1})],$n.prototype,"trailerField",void 0);new F({algorithm:Rr,parameters:q.serialize(new $n)});class qo{constructor(e={}){this.digestAlgorithm=new F,this.digest=new ue,Object.assign(this,e)}}d([g({type:F})],qo.prototype,"digestAlgorithm",void 0);d([g({type:ue})],qo.prototype,"digest",void 0);var Sc;class Mo{constructor(e={}){this.prime=new ArrayBuffer(0),this.exponent=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.Integer,converter:_e})],Mo.prototype,"prime",void 0);d([g({type:b.Integer,converter:_e})],Mo.prototype,"exponent",void 0);d([g({type:b.Integer,converter:_e})],Mo.prototype,"coefficient",void 0);let Ac=Sc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Sc.prototype)}};Ac=Sc=d([R({type:T.Sequence,itemType:Mo})],Ac);class jt{constructor(e={}){this.version=0,this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),this.privateExponent=new ArrayBuffer(0),this.prime1=new ArrayBuffer(0),this.prime2=new ArrayBuffer(0),this.exponent1=new ArrayBuffer(0),this.exponent2=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.Integer})],jt.prototype,"version",void 0);d([g({type:b.Integer,converter:_e})],jt.prototype,"modulus",void 0);d([g({type:b.Integer,converter:_e})],jt.prototype,"publicExponent",void 0);d([g({type:b.Integer,converter:_e})],jt.prototype,"privateExponent",void 0);d([g({type:b.Integer,converter:_e})],jt.prototype,"prime1",void 0);d([g({type:b.Integer,converter:_e})],jt.prototype,"prime2",void 0);d([g({type:b.Integer,converter:_e})],jt.prototype,"exponent1",void 0);d([g({type:b.Integer,converter:_e})],jt.prototype,"exponent2",void 0);d([g({type:b.Integer,converter:_e})],jt.prototype,"coefficient",void 0);d([g({type:Ac,optional:!0})],jt.prototype,"otherPrimeInfos",void 0);class Wl{constructor(e={}){this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.Integer,converter:_e})],Wl.prototype,"modulus",void 0);d([g({type:b.Integer,converter:_e})],Wl.prototype,"publicExponent",void 0);var Ec;(function(t){t[t.Transient=0]="Transient",t[t.Singleton=1]="Singleton",t[t.ResolutionScoped=2]="ResolutionScoped",t[t.ContainerScoped=3]="ContainerScoped"})(Ec||(Ec={}));const He=Ec;/*! *****************************************************************************
104
104
  Copyright (c) Microsoft Corporation.
105
105
 
106
106
  Permission to use, copy, modify, and/or distribute this software for any
@@ -113,9 +113,9 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
113
113
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
114
114
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
115
115
  PERFORMANCE OF THIS SOFTWARE.
116
- ***************************************************************************** */var Ic=function(t,e){return Ic=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var i in r)r.hasOwnProperty(i)&&(n[i]=r[i])},Ic(t,e)};function Gl(t,e){Ic(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}function Ev(t,e,n,r){function i(s){return s instanceof n?s:new n(function(a){a(s)})}return new(n||(n=Promise))(function(s,a){function c(p){try{u(r.next(p))}catch(h){a(h)}}function l(p){try{u(r.throw(p))}catch(h){a(h)}}function u(p){p.done?s(p.value):i(p.value).then(c,l)}u((r=r.apply(t,[])).next())})}function Iv(t,e){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,i,s,a;return a={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function c(u){return function(p){return l([u,p])}}function l(u){if(r)throw new TypeError("Generator is already executing.");for(;n;)try{if(r=1,i&&(s=u[0]&2?i.return:u[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,u[1])).done)return s;switch(i=0,s&&(u=[u[0]&2,s.value]),u[0]){case 0:case 1:s=u;break;case 4:return n.label++,{value:u[1],done:!1};case 5:n.label++,i=u[1],u=[0];continue;case 7:u=n.ops.pop(),n.trys.pop();continue;default:if(s=n.trys,!(s=s.length>0&&s[s.length-1])&&(u[0]===6||u[0]===2)){n=0;continue}if(u[0]===3&&(!s||u[1]>s[0]&&u[1]<s[3])){n.label=u[1];break}if(u[0]===6&&n.label<s[1]){n.label=s[1],s=u;break}if(s&&n.label<s[2]){n.label=s[2],n.ops.push(u);break}s[2]&&n.ops.pop(),n.trys.pop();continue}u=e.call(t,n)}catch(p){u=[6,p],i=0}finally{r=s=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function $i(t){var e=typeof Symbol=="function"&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ls(t,e){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var r=n.call(t),i,s=[],a;try{for(;(e===void 0||e-- >0)&&!(i=r.next()).done;)s.push(i.value)}catch(c){a={error:c}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(a)throw a.error}}return s}function gn(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Ls(arguments[e]));return t}var zv="injectionTokens";function Nv(t){var e=Reflect.getMetadata("design:paramtypes",t)||[],n=Reflect.getOwnMetadata(zv,t)||{};return Object.keys(n).forEach(function(r){e[+r]=n[r]}),e}function gg(t){return!!t.useClass}function zc(t){return!!t.useFactory}var mg=function(){function t(e){this.wrap=e,this.reflectMethods=["get","getPrototypeOf","setPrototypeOf","getOwnPropertyDescriptor","defineProperty","has","set","deleteProperty","apply","construct","ownKeys"]}return t.prototype.createProxy=function(e){var n=this,r={},i=!1,s,a=function(){return i||(s=e(n.wrap()),i=!0),s};return new Proxy(r,this.createHandler(a))},t.prototype.createHandler=function(e){var n={},r=function(i){n[i]=function(){for(var s=[],a=0;a<arguments.length;a++)s[a]=arguments[a];s[0]=e();var c=Reflect[i];return c.apply(void 0,gn(s))}};return this.reflectMethods.forEach(r),n},t}();function qn(t){return typeof t=="string"||typeof t=="symbol"}function Cv(t){return typeof t=="object"&&"token"in t&&"multiple"in t}function kd(t){return typeof t=="object"&&"token"in t&&"transform"in t}function jv(t){return typeof t=="function"||t instanceof mg}function Vi(t){return!!t.useToken}function qi(t){return t.useValue!=null}function $v(t){return gg(t)||qi(t)||Vi(t)||zc(t)}var Jl=function(){function t(){this._registryMap=new Map}return t.prototype.entries=function(){return this._registryMap.entries()},t.prototype.getAll=function(e){return this.ensure(e),this._registryMap.get(e)},t.prototype.get=function(e){this.ensure(e);var n=this._registryMap.get(e);return n[n.length-1]||null},t.prototype.set=function(e,n){this.ensure(e),this._registryMap.get(e).push(n)},t.prototype.setAll=function(e,n){this._registryMap.set(e,n)},t.prototype.has=function(e){return this.ensure(e),this._registryMap.get(e).length>0},t.prototype.clear=function(){this._registryMap.clear()},t.prototype.ensure=function(e){this._registryMap.has(e)||this._registryMap.set(e,[])},t}(),Ov=function(t){Gl(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(Jl),xd=function(){function t(){this.scopedResolutions=new Map}return t}();function Bv(t,e){if(t===null)return"at position #"+e;var n=t.split(",")[e].trim();return'"'+n+'" at position #'+e}function Tv(t,e,n){return n===void 0&&(n=" "),gn([t],e.message.split(`
116
+ ***************************************************************************** */var Ic=function(t,e){return Ic=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var i in r)r.hasOwnProperty(i)&&(n[i]=r[i])},Ic(t,e)};function Gl(t,e){Ic(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}function zv(t,e,n,r){function i(s){return s instanceof n?s:new n(function(a){a(s)})}return new(n||(n=Promise))(function(s,a){function c(p){try{u(r.next(p))}catch(h){a(h)}}function l(p){try{u(r.throw(p))}catch(h){a(h)}}function u(p){p.done?s(p.value):i(p.value).then(c,l)}u((r=r.apply(t,[])).next())})}function Nv(t,e){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,i,s,a;return a={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function c(u){return function(p){return l([u,p])}}function l(u){if(r)throw new TypeError("Generator is already executing.");for(;n;)try{if(r=1,i&&(s=u[0]&2?i.return:u[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,u[1])).done)return s;switch(i=0,s&&(u=[u[0]&2,s.value]),u[0]){case 0:case 1:s=u;break;case 4:return n.label++,{value:u[1],done:!1};case 5:n.label++,i=u[1],u=[0];continue;case 7:u=n.ops.pop(),n.trys.pop();continue;default:if(s=n.trys,!(s=s.length>0&&s[s.length-1])&&(u[0]===6||u[0]===2)){n=0;continue}if(u[0]===3&&(!s||u[1]>s[0]&&u[1]<s[3])){n.label=u[1];break}if(u[0]===6&&n.label<s[1]){n.label=s[1],s=u;break}if(s&&n.label<s[2]){n.label=s[2],n.ops.push(u);break}s[2]&&n.ops.pop(),n.trys.pop();continue}u=e.call(t,n)}catch(p){u=[6,p],i=0}finally{r=s=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function $i(t){var e=typeof Symbol=="function"&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ls(t,e){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var r=n.call(t),i,s=[],a;try{for(;(e===void 0||e-- >0)&&!(i=r.next()).done;)s.push(i.value)}catch(c){a={error:c}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(a)throw a.error}}return s}function gn(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Ls(arguments[e]));return t}var Cv="injectionTokens";function jv(t){var e=Reflect.getMetadata("design:paramtypes",t)||[],n=Reflect.getOwnMetadata(Cv,t)||{};return Object.keys(n).forEach(function(r){e[+r]=n[r]}),e}function mg(t){return!!t.useClass}function zc(t){return!!t.useFactory}var _g=function(){function t(e){this.wrap=e,this.reflectMethods=["get","getPrototypeOf","setPrototypeOf","getOwnPropertyDescriptor","defineProperty","has","set","deleteProperty","apply","construct","ownKeys"]}return t.prototype.createProxy=function(e){var n=this,r={},i=!1,s,a=function(){return i||(s=e(n.wrap()),i=!0),s};return new Proxy(r,this.createHandler(a))},t.prototype.createHandler=function(e){var n={},r=function(i){n[i]=function(){for(var s=[],a=0;a<arguments.length;a++)s[a]=arguments[a];s[0]=e();var c=Reflect[i];return c.apply(void 0,gn(s))}};return this.reflectMethods.forEach(r),n},t}();function qn(t){return typeof t=="string"||typeof t=="symbol"}function $v(t){return typeof t=="object"&&"token"in t&&"multiple"in t}function xd(t){return typeof t=="object"&&"token"in t&&"transform"in t}function Ov(t){return typeof t=="function"||t instanceof _g}function Vi(t){return!!t.useToken}function qi(t){return t.useValue!=null}function Bv(t){return mg(t)||qi(t)||Vi(t)||zc(t)}var Jl=function(){function t(){this._registryMap=new Map}return t.prototype.entries=function(){return this._registryMap.entries()},t.prototype.getAll=function(e){return this.ensure(e),this._registryMap.get(e)},t.prototype.get=function(e){this.ensure(e);var n=this._registryMap.get(e);return n[n.length-1]||null},t.prototype.set=function(e,n){this.ensure(e),this._registryMap.get(e).push(n)},t.prototype.setAll=function(e,n){this._registryMap.set(e,n)},t.prototype.has=function(e){return this.ensure(e),this._registryMap.get(e).length>0},t.prototype.clear=function(){this._registryMap.clear()},t.prototype.ensure=function(e){this._registryMap.has(e)||this._registryMap.set(e,[])},t}(),Tv=function(t){Gl(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(Jl),Sd=function(){function t(){this.scopedResolutions=new Map}return t}();function Pv(t,e){if(t===null)return"at position #"+e;var n=t.split(",")[e].trim();return'"'+n+'" at position #'+e}function Rv(t,e,n){return n===void 0&&(n=" "),gn([t],e.message.split(`
117
117
  `).map(function(r){return n+r})).join(`
118
- `)}function Pv(t,e,n){var r=Ls(t.toString().match(/constructor\(([\w, ]+)\)/)||[],2),i=r[1],s=i===void 0?null:i,a=Bv(s,e);return Tv("Cannot inject the dependency "+a+' of "'+t.name+'" constructor. Reason:',n)}function Rv(t){if(typeof t.dispose!="function")return!1;var e=t.dispose;return!(e.length>0)}var Lv=function(t){Gl(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(Jl),Uv=function(t){Gl(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(Jl),Vv=function(){function t(){this.preResolution=new Lv,this.postResolution=new Uv}return t}(),_g=new Map,qv=function(){function t(e){this.parent=e,this._registry=new Ov,this.interceptors=new Vv,this.disposed=!1,this.disposables=new Set}return t.prototype.register=function(e,n,r){r===void 0&&(r={lifecycle:He.Transient}),this.ensureNotDisposed();var i;if($v(n)?i=n:i={useClass:n},Vi(i))for(var s=[e],a=i;a!=null;){var c=a.useToken;if(s.includes(c))throw new Error("Token registration cycle detected! "+gn(s,[c]).join(" -> "));s.push(c);var l=this._registry.get(c);l&&Vi(l.provider)?a=l.provider:a=null}if((r.lifecycle===He.Singleton||r.lifecycle==He.ContainerScoped||r.lifecycle==He.ResolutionScoped)&&(qi(i)||zc(i)))throw new Error('Cannot use lifecycle "'+He[r.lifecycle]+'" with ValueProviders or FactoryProviders');return this._registry.set(e,{provider:i,options:r}),this},t.prototype.registerType=function(e,n){return this.ensureNotDisposed(),qn(n)?this.register(e,{useToken:n}):this.register(e,{useClass:n})},t.prototype.registerInstance=function(e,n){return this.ensureNotDisposed(),this.register(e,{useValue:n})},t.prototype.registerSingleton=function(e,n){if(this.ensureNotDisposed(),qn(e)){if(qn(n))return this.register(e,{useToken:n},{lifecycle:He.Singleton});if(n)return this.register(e,{useClass:n},{lifecycle:He.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var r=e;return n&&!qn(n)&&(r=n),this.register(e,{useClass:r},{lifecycle:He.Singleton})},t.prototype.resolve=function(e,n){n===void 0&&(n=new xd),this.ensureNotDisposed();var r=this.getRegistration(e);if(!r&&qn(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"Single"),r){var i=this.resolveRegistration(r,n);return this.executePostResolutionInterceptor(e,i,"Single"),i}if(jv(e)){var i=this.construct(e,n);return this.executePostResolutionInterceptor(e,i,"Single"),i}throw new Error("Attempted to construct an undefined constructor. Could mean a circular dependency problem. Try using `delay` function.")},t.prototype.executePreResolutionInterceptor=function(e,n){var r,i;if(this.interceptors.preResolution.has(e)){var s=[];try{for(var a=$i(this.interceptors.preResolution.getAll(e)),c=a.next();!c.done;c=a.next()){var l=c.value;l.options.frequency!="Once"&&s.push(l),l.callback(e,n)}}catch(u){r={error:u}}finally{try{c&&!c.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}this.interceptors.preResolution.setAll(e,s)}},t.prototype.executePostResolutionInterceptor=function(e,n,r){var i,s;if(this.interceptors.postResolution.has(e)){var a=[];try{for(var c=$i(this.interceptors.postResolution.getAll(e)),l=c.next();!l.done;l=c.next()){var u=l.value;u.options.frequency!="Once"&&a.push(u),u.callback(e,n,r)}}catch(p){i={error:p}}finally{try{l&&!l.done&&(s=c.return)&&s.call(c)}finally{if(i)throw i.error}}this.interceptors.postResolution.setAll(e,a)}},t.prototype.resolveRegistration=function(e,n){if(this.ensureNotDisposed(),e.options.lifecycle===He.ResolutionScoped&&n.scopedResolutions.has(e))return n.scopedResolutions.get(e);var r=e.options.lifecycle===He.Singleton,i=e.options.lifecycle===He.ContainerScoped,s=r||i,a;return qi(e.provider)?a=e.provider.useValue:Vi(e.provider)?a=s?e.instance||(e.instance=this.resolve(e.provider.useToken,n)):this.resolve(e.provider.useToken,n):gg(e.provider)?a=s?e.instance||(e.instance=this.construct(e.provider.useClass,n)):this.construct(e.provider.useClass,n):zc(e.provider)?a=e.provider.useFactory(this):a=this.construct(e.provider,n),e.options.lifecycle===He.ResolutionScoped&&n.scopedResolutions.set(e,a),a},t.prototype.resolveAll=function(e,n){var r=this;n===void 0&&(n=new xd),this.ensureNotDisposed();var i=this.getAllRegistrations(e);if(!i&&qn(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"All"),i){var s=i.map(function(c){return r.resolveRegistration(c,n)});return this.executePostResolutionInterceptor(e,s,"All"),s}var a=[this.construct(e,n)];return this.executePostResolutionInterceptor(e,a,"All"),a},t.prototype.isRegistered=function(e,n){return n===void 0&&(n=!1),this.ensureNotDisposed(),this._registry.has(e)||n&&(this.parent||!1)&&this.parent.isRegistered(e,!0)},t.prototype.reset=function(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()},t.prototype.clearInstances=function(){var e,n;this.ensureNotDisposed();try{for(var r=$i(this._registry.entries()),i=r.next();!i.done;i=r.next()){var s=Ls(i.value,2),a=s[0],c=s[1];this._registry.setAll(a,c.filter(function(l){return!qi(l.provider)}).map(function(l){return l.instance=void 0,l}))}}catch(l){e={error:l}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}},t.prototype.createChildContainer=function(){var e,n;this.ensureNotDisposed();var r=new t(this);try{for(var i=$i(this._registry.entries()),s=i.next();!s.done;s=i.next()){var a=Ls(s.value,2),c=a[0],l=a[1];l.some(function(u){var p=u.options;return p.lifecycle===He.ContainerScoped})&&r._registry.setAll(c,l.map(function(u){return u.options.lifecycle===He.ContainerScoped?{provider:u.provider,options:u.options}:u}))}}catch(u){e={error:u}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return r},t.prototype.beforeResolution=function(e,n,r){r===void 0&&(r={frequency:"Always"}),this.interceptors.preResolution.set(e,{callback:n,options:r})},t.prototype.afterResolution=function(e,n,r){r===void 0&&(r={frequency:"Always"}),this.interceptors.postResolution.set(e,{callback:n,options:r})},t.prototype.dispose=function(){return Ev(this,void 0,void 0,function(){var e;return Iv(this,function(n){switch(n.label){case 0:return this.disposed=!0,e=[],this.disposables.forEach(function(r){var i=r.dispose();i&&e.push(i)}),[4,Promise.all(e)];case 1:return n.sent(),[2]}})})},t.prototype.getRegistration=function(e){return this.isRegistered(e)?this._registry.get(e):this.parent?this.parent.getRegistration(e):null},t.prototype.getAllRegistrations=function(e){return this.isRegistered(e)?this._registry.getAll(e):this.parent?this.parent.getAllRegistrations(e):null},t.prototype.construct=function(e,n){var r=this;if(e instanceof mg)return e.createProxy(function(s){return r.resolve(s,n)});var i=function(){var s=_g.get(e);if(!s||s.length===0){if(e.length===0)return new e;throw new Error('TypeInfo not known for "'+e.name+'"')}var a=s.map(r.resolveParams(n,e));return new(e.bind.apply(e,gn([void 0],a)))}();return Rv(i)&&this.disposables.add(i),i},t.prototype.resolveParams=function(e,n){var r=this;return function(i,s){var a,c,l;try{return Cv(i)?kd(i)?i.multiple?(a=r.resolve(i.transform)).transform.apply(a,gn([r.resolveAll(i.token)],i.transformArgs)):(c=r.resolve(i.transform)).transform.apply(c,gn([r.resolve(i.token,e)],i.transformArgs)):i.multiple?r.resolveAll(i.token):r.resolve(i.token,e):kd(i)?(l=r.resolve(i.transform,e)).transform.apply(l,gn([r.resolve(i.token,e)],i.transformArgs)):r.resolve(i,e)}catch(u){throw new Error(Pv(n,s,u))}}},t.prototype.ensureNotDisposed=function(){if(this.disposed)throw new Error("This container has been disposed, you cannot interact with a disposed container")},t}(),Pe=new qv;function Do(){return function(t){_g.set(t,Nv(t))}}if(typeof Reflect>"u"||!Reflect.getMetadata)throw new Error(`tsyringe requires a reflect polyfill. Please add 'import "reflect-metadata"' to the top of your entry point.`);var Nc;class Ho{constructor(e={}){this.attrId="",this.attrValues=[],Object.assign(e)}}d([g({type:b.ObjectIdentifier})],Ho.prototype,"attrId",void 0);d([g({type:b.Any,repeated:"set"})],Ho.prototype,"attrValues",void 0);let Sd=Nc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Nc.prototype)}};Sd=Nc=d([R({type:T.Sequence,itemType:Ho})],Sd);var Cc;let Ad=Cc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Cc.prototype)}};Ad=Cc=d([R({type:T.Sequence,itemType:_r})],Ad);class yg{constructor(e={}){this.certId="",this.certValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],yg.prototype,"certId",void 0);d([g({type:b.Any,context:0})],yg.prototype,"certValue",void 0);class vg{constructor(e={}){this.crlId="",this.crltValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],vg.prototype,"crlId",void 0);d([g({type:b.Any,context:0})],vg.prototype,"crltValue",void 0);class wg extends ue{}let Fo=class{constructor(e={}){this.encryptionAlgorithm=new F,this.encryptedData=new wg,Object.assign(this,e)}};d([g({type:F})],Fo.prototype,"encryptionAlgorithm",void 0);d([g({type:wg})],Fo.prototype,"encryptedData",void 0);var jc,$c;(function(t){t[t.v1=0]="v1"})($c||($c={}));class bg extends ue{}let Oc=jc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,jc.prototype)}};Oc=jc=d([R({type:T.Sequence,itemType:Lt})],Oc);class vi{constructor(e={}){this.version=$c.v1,this.privateKeyAlgorithm=new F,this.privateKey=new bg,Object.assign(this,e)}}d([g({type:b.Integer})],vi.prototype,"version",void 0);d([g({type:F})],vi.prototype,"privateKeyAlgorithm",void 0);d([g({type:bg})],vi.prototype,"privateKey",void 0);d([g({type:Oc,implicit:!0,context:0,optional:!0})],vi.prototype,"attributes",void 0);let Ed=class extends vi{};Ed=d([R({type:T.Sequence})],Ed);let Id=class extends Fo{};Id=d([R({type:T.Sequence})],Id);class kg{constructor(e={}){this.secretTypeId="",this.secretValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],kg.prototype,"secretTypeId",void 0);d([g({type:b.Any,context:0})],kg.prototype,"secretValue",void 0);class wi{constructor(e={}){this.mac=new qo,this.macSalt=new ue,this.iterations=1,Object.assign(this,e)}}d([g({type:qo})],wi.prototype,"mac",void 0);d([g({type:ue})],wi.prototype,"macSalt",void 0);d([g({type:b.Integer,defaultValue:1})],wi.prototype,"iterations",void 0);class Ko{constructor(e={}){this.version=3,this.authSafe=new _r,this.macData=new wi,Object.assign(this,e)}}d([g({type:b.Integer})],Ko.prototype,"version",void 0);d([g({type:_r})],Ko.prototype,"authSafe",void 0);d([g({type:wi,optional:!0})],Ko.prototype,"macData",void 0);var Bc;class Wo{constructor(e={}){this.bagId="",this.bagValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],Wo.prototype,"bagId",void 0);d([g({type:b.Any,context:0})],Wo.prototype,"bagValue",void 0);d([g({type:Ho,repeated:"set",optional:!0})],Wo.prototype,"bagAttributes",void 0);let zd=Bc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Bc.prototype)}};zd=Bc=d([R({type:T.Sequence,itemType:Wo})],zd);var Tc,Pc,Rc;const xg="1.2.840.113549.1.9",Sg=`${xg}.7`,Zl=`${xg}.14`;let Us=class extends Te{constructor(e={}){super(e)}toString(){return this.ia5String||super.toString()}};d([g({type:b.IA5String})],Us.prototype,"ia5String",void 0);Us=d([R({type:T.Choice})],Us);let Nd=class extends _r{};Nd=d([R({type:T.Sequence})],Nd);let Cd=class extends Ko{};Cd=d([R({type:T.Sequence})],Cd);let jd=class extends Fo{};jd=d([R({type:T.Sequence})],jd);let Lc=class{constructor(e=""){this.value=e}toString(){return this.value}};d([g({type:b.IA5String})],Lc.prototype,"value",void 0);Lc=d([R({type:T.Choice})],Lc);let $d=class extends Us{};$d=d([R({type:T.Choice})],$d);let Od=class extends Te{};Od=d([R({type:T.Choice})],Od);let Uc=class{constructor(e=new Date){this.value=e}};d([g({type:b.GeneralizedTime})],Uc.prototype,"value",void 0);Uc=d([R({type:T.Choice})],Uc);let Bd=class extends Te{};Bd=d([R({type:T.Choice})],Bd);let Vc=class{constructor(e="M"){this.value=e}toString(){return this.value}};d([g({type:b.PrintableString})],Vc.prototype,"value",void 0);Vc=d([R({type:T.Choice})],Vc);let Vs=class{constructor(e=""){this.value=e}toString(){return this.value}};d([g({type:b.PrintableString})],Vs.prototype,"value",void 0);Vs=d([R({type:T.Choice})],Vs);let Td=class extends Vs{};Td=d([R({type:T.Choice})],Td);let Pd=class extends Te{};Pd=d([R({type:T.Choice})],Pd);let qc=class{constructor(e=""){this.value=e}toString(){return this.value}};d([g({type:b.ObjectIdentifier})],qc.prototype,"value",void 0);qc=d([R({type:T.Choice})],qc);let Rd=class extends Oe{};Rd=d([R({type:T.Choice})],Rd);let Mc=class{constructor(e=0){this.value=e}toString(){return this.value.toString()}};d([g({type:b.Integer})],Mc.prototype,"value",void 0);Mc=d([R({type:T.Choice})],Mc);let Ld=class extends Ct{};Ld=d([R({type:T.Sequence})],Ld);let qs=class extends Te{};qs=d([R({type:T.Choice})],qs);let Ud=Tc=class extends Qt{constructor(e){super(e),Object.setPrototypeOf(this,Tc.prototype)}};Ud=Tc=d([R({type:T.Sequence})],Ud);let Vd=Pc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Pc.prototype)}};Vd=Pc=d([R({type:T.Set,itemType:mr})],Vd);let Dc=class{constructor(e=""){this.value=e}toString(){return this.value}};d([g({type:b.BmpString})],Dc.prototype,"value",void 0);Dc=d([R({type:T.Choice})],Dc);let Hc=class extends F{};Hc=d([R({type:T.Sequence})],Hc);let qd=Rc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Rc.prototype)}};qd=Rc=d([R({type:T.Sequence,itemType:Hc})],qd);var Fc;let Ms=Fc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Fc.prototype)}};Ms=Fc=d([R({type:T.Sequence,itemType:Lt})],Ms);class wr{constructor(e={}){this.version=0,this.subject=new ke,this.subjectPKInfo=new ft,this.attributes=new Ms,Object.assign(this,e)}}d([g({type:b.Integer})],wr.prototype,"version",void 0);d([g({type:ke})],wr.prototype,"subject",void 0);d([g({type:ft})],wr.prototype,"subjectPKInfo",void 0);d([g({type:Ms,implicit:!0,context:0})],wr.prototype,"attributes",void 0);class Jr{constructor(e={}){this.certificationRequestInfo=new wr,this.signatureAlgorithm=new F,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:wr})],Jr.prototype,"certificationRequestInfo",void 0);d([g({type:F})],Jr.prototype,"signatureAlgorithm",void 0);d([g({type:b.BitString})],Jr.prototype,"signature",void 0);/*!
118
+ `)}function Lv(t,e,n){var r=Ls(t.toString().match(/constructor\(([\w, ]+)\)/)||[],2),i=r[1],s=i===void 0?null:i,a=Pv(s,e);return Rv("Cannot inject the dependency "+a+' of "'+t.name+'" constructor. Reason:',n)}function Uv(t){if(typeof t.dispose!="function")return!1;var e=t.dispose;return!(e.length>0)}var Vv=function(t){Gl(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(Jl),qv=function(t){Gl(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(Jl),Mv=function(){function t(){this.preResolution=new Vv,this.postResolution=new qv}return t}(),yg=new Map,Dv=function(){function t(e){this.parent=e,this._registry=new Tv,this.interceptors=new Mv,this.disposed=!1,this.disposables=new Set}return t.prototype.register=function(e,n,r){r===void 0&&(r={lifecycle:He.Transient}),this.ensureNotDisposed();var i;if(Bv(n)?i=n:i={useClass:n},Vi(i))for(var s=[e],a=i;a!=null;){var c=a.useToken;if(s.includes(c))throw new Error("Token registration cycle detected! "+gn(s,[c]).join(" -> "));s.push(c);var l=this._registry.get(c);l&&Vi(l.provider)?a=l.provider:a=null}if((r.lifecycle===He.Singleton||r.lifecycle==He.ContainerScoped||r.lifecycle==He.ResolutionScoped)&&(qi(i)||zc(i)))throw new Error('Cannot use lifecycle "'+He[r.lifecycle]+'" with ValueProviders or FactoryProviders');return this._registry.set(e,{provider:i,options:r}),this},t.prototype.registerType=function(e,n){return this.ensureNotDisposed(),qn(n)?this.register(e,{useToken:n}):this.register(e,{useClass:n})},t.prototype.registerInstance=function(e,n){return this.ensureNotDisposed(),this.register(e,{useValue:n})},t.prototype.registerSingleton=function(e,n){if(this.ensureNotDisposed(),qn(e)){if(qn(n))return this.register(e,{useToken:n},{lifecycle:He.Singleton});if(n)return this.register(e,{useClass:n},{lifecycle:He.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var r=e;return n&&!qn(n)&&(r=n),this.register(e,{useClass:r},{lifecycle:He.Singleton})},t.prototype.resolve=function(e,n){n===void 0&&(n=new Sd),this.ensureNotDisposed();var r=this.getRegistration(e);if(!r&&qn(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"Single"),r){var i=this.resolveRegistration(r,n);return this.executePostResolutionInterceptor(e,i,"Single"),i}if(Ov(e)){var i=this.construct(e,n);return this.executePostResolutionInterceptor(e,i,"Single"),i}throw new Error("Attempted to construct an undefined constructor. Could mean a circular dependency problem. Try using `delay` function.")},t.prototype.executePreResolutionInterceptor=function(e,n){var r,i;if(this.interceptors.preResolution.has(e)){var s=[];try{for(var a=$i(this.interceptors.preResolution.getAll(e)),c=a.next();!c.done;c=a.next()){var l=c.value;l.options.frequency!="Once"&&s.push(l),l.callback(e,n)}}catch(u){r={error:u}}finally{try{c&&!c.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}this.interceptors.preResolution.setAll(e,s)}},t.prototype.executePostResolutionInterceptor=function(e,n,r){var i,s;if(this.interceptors.postResolution.has(e)){var a=[];try{for(var c=$i(this.interceptors.postResolution.getAll(e)),l=c.next();!l.done;l=c.next()){var u=l.value;u.options.frequency!="Once"&&a.push(u),u.callback(e,n,r)}}catch(p){i={error:p}}finally{try{l&&!l.done&&(s=c.return)&&s.call(c)}finally{if(i)throw i.error}}this.interceptors.postResolution.setAll(e,a)}},t.prototype.resolveRegistration=function(e,n){if(this.ensureNotDisposed(),e.options.lifecycle===He.ResolutionScoped&&n.scopedResolutions.has(e))return n.scopedResolutions.get(e);var r=e.options.lifecycle===He.Singleton,i=e.options.lifecycle===He.ContainerScoped,s=r||i,a;return qi(e.provider)?a=e.provider.useValue:Vi(e.provider)?a=s?e.instance||(e.instance=this.resolve(e.provider.useToken,n)):this.resolve(e.provider.useToken,n):mg(e.provider)?a=s?e.instance||(e.instance=this.construct(e.provider.useClass,n)):this.construct(e.provider.useClass,n):zc(e.provider)?a=e.provider.useFactory(this):a=this.construct(e.provider,n),e.options.lifecycle===He.ResolutionScoped&&n.scopedResolutions.set(e,a),a},t.prototype.resolveAll=function(e,n){var r=this;n===void 0&&(n=new Sd),this.ensureNotDisposed();var i=this.getAllRegistrations(e);if(!i&&qn(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"All"),i){var s=i.map(function(c){return r.resolveRegistration(c,n)});return this.executePostResolutionInterceptor(e,s,"All"),s}var a=[this.construct(e,n)];return this.executePostResolutionInterceptor(e,a,"All"),a},t.prototype.isRegistered=function(e,n){return n===void 0&&(n=!1),this.ensureNotDisposed(),this._registry.has(e)||n&&(this.parent||!1)&&this.parent.isRegistered(e,!0)},t.prototype.reset=function(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()},t.prototype.clearInstances=function(){var e,n;this.ensureNotDisposed();try{for(var r=$i(this._registry.entries()),i=r.next();!i.done;i=r.next()){var s=Ls(i.value,2),a=s[0],c=s[1];this._registry.setAll(a,c.filter(function(l){return!qi(l.provider)}).map(function(l){return l.instance=void 0,l}))}}catch(l){e={error:l}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}},t.prototype.createChildContainer=function(){var e,n;this.ensureNotDisposed();var r=new t(this);try{for(var i=$i(this._registry.entries()),s=i.next();!s.done;s=i.next()){var a=Ls(s.value,2),c=a[0],l=a[1];l.some(function(u){var p=u.options;return p.lifecycle===He.ContainerScoped})&&r._registry.setAll(c,l.map(function(u){return u.options.lifecycle===He.ContainerScoped?{provider:u.provider,options:u.options}:u}))}}catch(u){e={error:u}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return r},t.prototype.beforeResolution=function(e,n,r){r===void 0&&(r={frequency:"Always"}),this.interceptors.preResolution.set(e,{callback:n,options:r})},t.prototype.afterResolution=function(e,n,r){r===void 0&&(r={frequency:"Always"}),this.interceptors.postResolution.set(e,{callback:n,options:r})},t.prototype.dispose=function(){return zv(this,void 0,void 0,function(){var e;return Nv(this,function(n){switch(n.label){case 0:return this.disposed=!0,e=[],this.disposables.forEach(function(r){var i=r.dispose();i&&e.push(i)}),[4,Promise.all(e)];case 1:return n.sent(),[2]}})})},t.prototype.getRegistration=function(e){return this.isRegistered(e)?this._registry.get(e):this.parent?this.parent.getRegistration(e):null},t.prototype.getAllRegistrations=function(e){return this.isRegistered(e)?this._registry.getAll(e):this.parent?this.parent.getAllRegistrations(e):null},t.prototype.construct=function(e,n){var r=this;if(e instanceof _g)return e.createProxy(function(s){return r.resolve(s,n)});var i=function(){var s=yg.get(e);if(!s||s.length===0){if(e.length===0)return new e;throw new Error('TypeInfo not known for "'+e.name+'"')}var a=s.map(r.resolveParams(n,e));return new(e.bind.apply(e,gn([void 0],a)))}();return Uv(i)&&this.disposables.add(i),i},t.prototype.resolveParams=function(e,n){var r=this;return function(i,s){var a,c,l;try{return $v(i)?xd(i)?i.multiple?(a=r.resolve(i.transform)).transform.apply(a,gn([r.resolveAll(i.token)],i.transformArgs)):(c=r.resolve(i.transform)).transform.apply(c,gn([r.resolve(i.token,e)],i.transformArgs)):i.multiple?r.resolveAll(i.token):r.resolve(i.token,e):xd(i)?(l=r.resolve(i.transform,e)).transform.apply(l,gn([r.resolve(i.token,e)],i.transformArgs)):r.resolve(i,e)}catch(u){throw new Error(Lv(n,s,u))}}},t.prototype.ensureNotDisposed=function(){if(this.disposed)throw new Error("This container has been disposed, you cannot interact with a disposed container")},t}(),Pe=new Dv;function Do(){return function(t){yg.set(t,jv(t))}}if(typeof Reflect>"u"||!Reflect.getMetadata)throw new Error(`tsyringe requires a reflect polyfill. Please add 'import "reflect-metadata"' to the top of your entry point.`);var Nc;class Ho{constructor(e={}){this.attrId="",this.attrValues=[],Object.assign(e)}}d([g({type:b.ObjectIdentifier})],Ho.prototype,"attrId",void 0);d([g({type:b.Any,repeated:"set"})],Ho.prototype,"attrValues",void 0);let Ad=Nc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Nc.prototype)}};Ad=Nc=d([R({type:T.Sequence,itemType:Ho})],Ad);var Cc;let Ed=Cc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Cc.prototype)}};Ed=Cc=d([R({type:T.Sequence,itemType:_r})],Ed);class vg{constructor(e={}){this.certId="",this.certValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],vg.prototype,"certId",void 0);d([g({type:b.Any,context:0})],vg.prototype,"certValue",void 0);class wg{constructor(e={}){this.crlId="",this.crltValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],wg.prototype,"crlId",void 0);d([g({type:b.Any,context:0})],wg.prototype,"crltValue",void 0);class bg extends ue{}let Fo=class{constructor(e={}){this.encryptionAlgorithm=new F,this.encryptedData=new bg,Object.assign(this,e)}};d([g({type:F})],Fo.prototype,"encryptionAlgorithm",void 0);d([g({type:bg})],Fo.prototype,"encryptedData",void 0);var jc,$c;(function(t){t[t.v1=0]="v1"})($c||($c={}));class kg extends ue{}let Oc=jc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,jc.prototype)}};Oc=jc=d([R({type:T.Sequence,itemType:Lt})],Oc);class vi{constructor(e={}){this.version=$c.v1,this.privateKeyAlgorithm=new F,this.privateKey=new kg,Object.assign(this,e)}}d([g({type:b.Integer})],vi.prototype,"version",void 0);d([g({type:F})],vi.prototype,"privateKeyAlgorithm",void 0);d([g({type:kg})],vi.prototype,"privateKey",void 0);d([g({type:Oc,implicit:!0,context:0,optional:!0})],vi.prototype,"attributes",void 0);let Id=class extends vi{};Id=d([R({type:T.Sequence})],Id);let zd=class extends Fo{};zd=d([R({type:T.Sequence})],zd);class xg{constructor(e={}){this.secretTypeId="",this.secretValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],xg.prototype,"secretTypeId",void 0);d([g({type:b.Any,context:0})],xg.prototype,"secretValue",void 0);class wi{constructor(e={}){this.mac=new qo,this.macSalt=new ue,this.iterations=1,Object.assign(this,e)}}d([g({type:qo})],wi.prototype,"mac",void 0);d([g({type:ue})],wi.prototype,"macSalt",void 0);d([g({type:b.Integer,defaultValue:1})],wi.prototype,"iterations",void 0);class Ko{constructor(e={}){this.version=3,this.authSafe=new _r,this.macData=new wi,Object.assign(this,e)}}d([g({type:b.Integer})],Ko.prototype,"version",void 0);d([g({type:_r})],Ko.prototype,"authSafe",void 0);d([g({type:wi,optional:!0})],Ko.prototype,"macData",void 0);var Bc;class Wo{constructor(e={}){this.bagId="",this.bagValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],Wo.prototype,"bagId",void 0);d([g({type:b.Any,context:0})],Wo.prototype,"bagValue",void 0);d([g({type:Ho,repeated:"set",optional:!0})],Wo.prototype,"bagAttributes",void 0);let Nd=Bc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Bc.prototype)}};Nd=Bc=d([R({type:T.Sequence,itemType:Wo})],Nd);var Tc,Pc,Rc;const Sg="1.2.840.113549.1.9",Ag=`${Sg}.7`,Zl=`${Sg}.14`;let Us=class extends Te{constructor(e={}){super(e)}toString(){return this.ia5String||super.toString()}};d([g({type:b.IA5String})],Us.prototype,"ia5String",void 0);Us=d([R({type:T.Choice})],Us);let Cd=class extends _r{};Cd=d([R({type:T.Sequence})],Cd);let jd=class extends Ko{};jd=d([R({type:T.Sequence})],jd);let $d=class extends Fo{};$d=d([R({type:T.Sequence})],$d);let Lc=class{constructor(e=""){this.value=e}toString(){return this.value}};d([g({type:b.IA5String})],Lc.prototype,"value",void 0);Lc=d([R({type:T.Choice})],Lc);let Od=class extends Us{};Od=d([R({type:T.Choice})],Od);let Bd=class extends Te{};Bd=d([R({type:T.Choice})],Bd);let Uc=class{constructor(e=new Date){this.value=e}};d([g({type:b.GeneralizedTime})],Uc.prototype,"value",void 0);Uc=d([R({type:T.Choice})],Uc);let Td=class extends Te{};Td=d([R({type:T.Choice})],Td);let Vc=class{constructor(e="M"){this.value=e}toString(){return this.value}};d([g({type:b.PrintableString})],Vc.prototype,"value",void 0);Vc=d([R({type:T.Choice})],Vc);let Vs=class{constructor(e=""){this.value=e}toString(){return this.value}};d([g({type:b.PrintableString})],Vs.prototype,"value",void 0);Vs=d([R({type:T.Choice})],Vs);let Pd=class extends Vs{};Pd=d([R({type:T.Choice})],Pd);let Rd=class extends Te{};Rd=d([R({type:T.Choice})],Rd);let qc=class{constructor(e=""){this.value=e}toString(){return this.value}};d([g({type:b.ObjectIdentifier})],qc.prototype,"value",void 0);qc=d([R({type:T.Choice})],qc);let Ld=class extends Oe{};Ld=d([R({type:T.Choice})],Ld);let Mc=class{constructor(e=0){this.value=e}toString(){return this.value.toString()}};d([g({type:b.Integer})],Mc.prototype,"value",void 0);Mc=d([R({type:T.Choice})],Mc);let Ud=class extends Ct{};Ud=d([R({type:T.Sequence})],Ud);let qs=class extends Te{};qs=d([R({type:T.Choice})],qs);let Vd=Tc=class extends en{constructor(e){super(e),Object.setPrototypeOf(this,Tc.prototype)}};Vd=Tc=d([R({type:T.Sequence})],Vd);let qd=Pc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Pc.prototype)}};qd=Pc=d([R({type:T.Set,itemType:mr})],qd);let Dc=class{constructor(e=""){this.value=e}toString(){return this.value}};d([g({type:b.BmpString})],Dc.prototype,"value",void 0);Dc=d([R({type:T.Choice})],Dc);let Hc=class extends F{};Hc=d([R({type:T.Sequence})],Hc);let Md=Rc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Rc.prototype)}};Md=Rc=d([R({type:T.Sequence,itemType:Hc})],Md);var Fc;let Ms=Fc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Fc.prototype)}};Ms=Fc=d([R({type:T.Sequence,itemType:Lt})],Ms);class wr{constructor(e={}){this.version=0,this.subject=new ke,this.subjectPKInfo=new ft,this.attributes=new Ms,Object.assign(this,e)}}d([g({type:b.Integer})],wr.prototype,"version",void 0);d([g({type:ke})],wr.prototype,"subject",void 0);d([g({type:ft})],wr.prototype,"subjectPKInfo",void 0);d([g({type:Ms,implicit:!0,context:0})],wr.prototype,"attributes",void 0);class Jr{constructor(e={}){this.certificationRequestInfo=new wr,this.signatureAlgorithm=new F,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:wr})],Jr.prototype,"certificationRequestInfo",void 0);d([g({type:F})],Jr.prototype,"signatureAlgorithm",void 0);d([g({type:b.BitString})],Jr.prototype,"signature",void 0);/*!
119
119
  * MIT License
120
120
  *
121
121
  * Copyright (c) Peculiar Ventures. All rights reserved.
@@ -138,15 +138,15 @@ PERFORMANCE OF THIS SOFTWARE.
138
138
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
139
139
  * SOFTWARE.
140
140
  *
141
- */const bi="crypto.algorithm";class Mv{getAlgorithms(){return Pe.resolveAll(bi)}toAsnAlgorithm(e){({...e});for(const n of this.getAlgorithms()){const r=n.toAsnAlgorithm(e);if(r)return r}if(/^[0-9.]+$/.test(e.name)){const n=new F({algorithm:e.name});if("parameters"in e){const r=e;n.parameters=r.parameters}return n}throw new Error("Cannot convert WebCrypto algorithm to ASN.1 algorithm")}toWebAlgorithm(e){for(const r of this.getAlgorithms()){const i=r.toWebAlgorithm(e);if(i)return i}return{name:e.algorithm,parameters:e.parameters}}}const On="crypto.algorithmProvider";Pe.registerSingleton(On,Mv);var Mi;const Je="1.3.36.3.3.2.8.1.1",Md=`${Je}.1`,Dd=`${Je}.2`,Hd=`${Je}.3`,Fd=`${Je}.4`,Kd=`${Je}.5`,Wd=`${Je}.6`,Gd=`${Je}.7`,Jd=`${Je}.8`,Zd=`${Je}.9`,Yd=`${Je}.10`,Xd=`${Je}.11`,Qd=`${Je}.12`,ep=`${Je}.13`,tp=`${Je}.14`,np="brainpoolP160r1",rp="brainpoolP160t1",ip="brainpoolP192r1",sp="brainpoolP192t1",op="brainpoolP224r1",ap="brainpoolP224t1",cp="brainpoolP256r1",lp="brainpoolP256t1",up="brainpoolP320r1",dp="brainpoolP320t1",pp="brainpoolP384r1",fp="brainpoolP384t1",hp="brainpoolP512r1",gp="brainpoolP512t1",ye="ECDSA";let Zr=Mi=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case ye.toLowerCase():if("hash"in e)switch((typeof e.hash=="string"?e.hash:e.hash.name).toLowerCase()){case"sha-1":return pv;case"sha-256":return fv;case"sha-384":return hv;case"sha-512":return gv}else if("namedCurve"in e){let n="";switch(e.namedCurve){case"P-256":n=vd;break;case"K-256":n=Mi.SECP256K1;break;case"P-384":n=wd;break;case"P-521":n=bd;break;case np:n=Md;break;case rp:n=Dd;break;case ip:n=Hd;break;case sp:n=Fd;break;case op:n=Kd;break;case ap:n=Wd;break;case cp:n=Gd;break;case lp:n=Jd;break;case up:n=Zd;break;case dp:n=Yd;break;case pp:n=Xd;break;case fp:n=Qd;break;case hp:n=ep;break;case gp:n=tp;break}if(n)return new F({algorithm:Wr,parameters:q.serialize(new tn({namedCurve:n}))})}}return null}toWebAlgorithm(e){switch(e.algorithm){case Dl:return{name:ye,hash:{name:"SHA-1"}};case Hl:return{name:ye,hash:{name:"SHA-256"}};case Fl:return{name:ye,hash:{name:"SHA-384"}};case Kl:return{name:ye,hash:{name:"SHA-512"}};case Wr:{if(!e.parameters)throw new TypeError("Cannot get required parameters from EC algorithm");switch(q.parse(e.parameters,tn).namedCurve){case vd:return{name:ye,namedCurve:"P-256"};case Mi.SECP256K1:return{name:ye,namedCurve:"K-256"};case wd:return{name:ye,namedCurve:"P-384"};case bd:return{name:ye,namedCurve:"P-521"};case Md:return{name:ye,namedCurve:np};case Dd:return{name:ye,namedCurve:rp};case Hd:return{name:ye,namedCurve:ip};case Fd:return{name:ye,namedCurve:sp};case Kd:return{name:ye,namedCurve:op};case Wd:return{name:ye,namedCurve:ap};case Gd:return{name:ye,namedCurve:cp};case Jd:return{name:ye,namedCurve:lp};case Zd:return{name:ye,namedCurve:up};case Yd:return{name:ye,namedCurve:dp};case Xd:return{name:ye,namedCurve:pp};case Qd:return{name:ye,namedCurve:fp};case ep:return{name:ye,namedCurve:hp};case tp:return{name:ye,namedCurve:gp}}}}return null}};Zr.SECP256K1="1.3.132.0.10";Zr=Mi=d([Do()],Zr);Pe.registerSingleton(bi,Zr);const Ag=Symbol("name"),Eg=Symbol("value");class pe{constructor(e,n={},r=""){this[Ag]=e,this[Eg]=r;for(const i in n)this[i]=n[i]}}pe.NAME=Ag;pe.VALUE=Eg;class Dv{static toTextObject(e){const n=new pe("Algorithm Identifier",{},cn.toString(e.algorithm));if(e.parameters)switch(e.algorithm){case Wr:{const r=new Zr().toWebAlgorithm(e);r&&"namedCurve"in r?n["Named Curve"]=r.namedCurve:n.Parameters=e.parameters;break}default:n.Parameters=e.parameters}return n}}class cn{static toString(e){const n=this.items[e];return n||e}}cn.items={[Bs]:"sha1",[pg]:"sha224",[Ts]:"sha256",[Ps]:"sha384",[Rs]:"sha512",[Cn]:"rsaEncryption",[js]:"sha1WithRSAEncryption",[bv]:"sha224WithRSAEncryption",[xc]:"sha256WithRSAEncryption",[$s]:"sha384WithRSAEncryption",[Os]:"sha512WithRSAEncryption",[Wr]:"ecPublicKey",[Dl]:"ecdsaWithSHA1",[lg]:"ecdsaWithSHA224",[Hl]:"ecdsaWithSHA256",[Fl]:"ecdsaWithSHA384",[Kl]:"ecdsaWithSHA512",[sv]:"TLS WWW server authentication",[ov]:"TLS WWW client authentication",[av]:"Code Signing",[cv]:"E-mail Protection",[lv]:"Time Stamping",[uv]:"OCSP Signing",[dv]:"Signed Data"};class Bn{static serialize(e){return this.serializeObj(e).join(`
142
- `)}static pad(e=0){return"".padStart(2*e," ")}static serializeObj(e,n=0){const r=[];let i=this.pad(n++),s="";const a=e[pe.VALUE];a&&(s=` ${a}`),r.push(`${i}${e[pe.NAME]}:${s}`),i=this.pad(n);for(const c in e){if(typeof c=="symbol")continue;const l=e[c],u=c?`${c}: `:"";if(typeof l=="string"||typeof l=="number"||typeof l=="boolean")r.push(`${i}${u}${l}`);else if(l instanceof Date)r.push(`${i}${u}${l.toUTCString()}`);else if(Array.isArray(l))for(const p of l)p[pe.NAME]=c,r.push(...this.serializeObj(p,n));else if(l instanceof pe)l[pe.NAME]=c,r.push(...this.serializeObj(l,n));else if(M.isBufferSource(l))c?(r.push(`${i}${u}`),r.push(...this.serializeBufferSource(l,n+1))):r.push(...this.serializeBufferSource(l,n));else if("toTextObject"in l){const p=l.toTextObject();p[pe.NAME]=c,r.push(...this.serializeObj(p,n))}else throw new TypeError("Cannot serialize data in text format. Unsupported type.")}return r}static serializeBufferSource(e,n=0){const r=this.pad(n),i=M.toUint8Array(e),s=[];for(let a=0;a<i.length;){const c=[];for(let l=0;l<16&&a<i.length;l++){l===8&&c.push("");const u=i[a++].toString(16).padStart(2,"0");c.push(u)}s.push(`${r}${c.join(" ")}`)}return s}static serializeAlgorithm(e){return this.algorithmSerializer.toTextObject(e)}}Bn.oidSerializer=cn;Bn.algorithmSerializer=Dv;class ln{constructor(...e){if(e.length===1){const n=e[0];this.rawData=q.serialize(n),this.onInit(n)}else{const n=q.parse(e[0],e[1]);this.rawData=M.toArrayBuffer(e[0]),this.onInit(n)}}equal(e){return e instanceof ln?Ff(e.rawData,this.rawData):!1}toString(e="text"){switch(e){case"asn":return q.toString(this.rawData);case"text":return Bn.serialize(this.toTextObject());case"hex":return J.ToHex(this.rawData);case"base64":return J.ToBase64(this.rawData);case"base64url":return J.ToBase64Url(this.rawData);default:throw TypeError("Argument 'format' is unsupported value")}}getTextName(){return this.constructor.NAME}toTextObject(){const e=this.toTextObjectEmpty();return e[""]=this.rawData,e}toTextObjectEmpty(e){return new pe(this.getTextName(),{},e)}}ln.NAME="ASN";class ct extends ln{constructor(...e){let n;M.isBufferSource(e[0])?n=M.toArrayBuffer(e[0]):n=q.serialize(new ot({extnID:e[0],critical:e[1],extnValue:new ue(M.toArrayBuffer(e[2]))})),super(n,ot)}onInit(e){this.type=e.extnID,this.critical=e.critical,this.value=e.extnValue.buffer}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.value,e}toTextObjectWithoutValue(){const e=this.toTextObjectEmpty(this.critical?"critical":void 0);return e[pe.NAME]===ct.NAME&&(e[pe.NAME]=cn.toString(this.type)),e}}var Ig;class Kt{static isCryptoKeyPair(e){return e&&e.privateKey&&e.publicKey}static isCryptoKey(e){return e&&e.usages&&e.type&&e.algorithm&&e.extractable!==void 0}constructor(){this.items=new Map,this[Ig]="CryptoProvider",typeof self<"u"&&typeof crypto<"u"?this.set(Kt.DEFAULT,crypto):typeof global<"u"&&global.crypto&&global.crypto.subtle&&this.set(Kt.DEFAULT,global.crypto)}clear(){this.items.clear()}delete(e){return this.items.delete(e)}forEach(e,n){return this.items.forEach(e,n)}has(e){return this.items.has(e)}get size(){return this.items.size}entries(){return this.items.entries()}keys(){return this.items.keys()}values(){return this.items.values()}[Symbol.iterator](){return this.items[Symbol.iterator]()}get(e=Kt.DEFAULT){const n=this.items.get(e.toLowerCase());if(!n)throw new Error(`Cannot get Crypto by name '${e}'`);return n}set(e,n){if(typeof e=="string"){if(!n)throw new TypeError("Argument 'value' is required");this.items.set(e.toLowerCase(),n)}else this.items.set(Kt.DEFAULT,e);return this}}Ig=Symbol.toStringTag;Kt.DEFAULT="default";const $e=new Kt,Hv=/^[0-2](?:\.[1-9][0-9]*)+$/;function Fv(t){return new RegExp(Hv).test(t)}class zg{constructor(e={}){this.items={};for(const n in e)this.register(n,e[n])}get(e){return this.items[e]||null}findId(e){return Fv(e)?e:this.get(e)}register(e,n){this.items[e]=n,this.items[n]=e}}const We=new zg;We.register("CN","2.5.4.3");We.register("L","2.5.4.7");We.register("ST","2.5.4.8");We.register("O","2.5.4.10");We.register("OU","2.5.4.11");We.register("C","2.5.4.6");We.register("DC","0.9.2342.19200300.100.1.25");We.register("E","1.2.840.113549.1.9.1");We.register("G","2.5.4.42");We.register("I","2.5.4.43");We.register("SN","2.5.4.4");We.register("T","2.5.4.12");function Kv(t,e){return`\\${J.ToHex(J.FromUtf8String(e)).toUpperCase()}`}function Wv(t){return t.replace(/([,+"\\<>;])/g,"\\$1").replace(/^([ #])/,"\\$1").replace(/([ ]$)/,"\\$1").replace(/([\r\n\t])/,Kv)}class it{static isASCII(e){for(let n=0;n<e.length;n++)if(e.charCodeAt(n)>255)return!1;return!0}static isPrintableString(e){return/^[A-Za-z0-9 '()+,-./:=?]*$/g.test(e)}constructor(e,n={}){this.extraNames=new zg,this.asn=new ke;for(const r in n)if(Object.prototype.hasOwnProperty.call(n,r)){const i=n[r];this.extraNames.register(r,i)}typeof e=="string"?this.asn=this.fromString(e):e instanceof ke?this.asn=e:M.isBufferSource(e)?this.asn=q.parse(e,ke):this.asn=this.fromJSON(e)}getField(e){const n=this.extraNames.findId(e)||We.findId(e),r=[];for(const i of this.asn)for(const s of i)s.type===n&&r.push(s.value.toString());return r}getName(e){return this.extraNames.get(e)||We.get(e)}toString(){return this.asn.map(e=>e.map(n=>{const r=this.getName(n.type)||n.type,i=n.value.anyValue?`#${J.ToHex(n.value.anyValue)}`:Wv(n.value.toString());return`${r}=${i}`}).join("+")).join(", ")}toJSON(){var e;const n=[];for(const r of this.asn){const i={};for(const s of r){const a=this.getName(s.type)||s.type;(e=i[a])!==null&&e!==void 0||(i[a]=[]),i[a].push(s.value.anyValue?`#${J.ToHex(s.value.anyValue)}`:s.value.toString())}n.push(i)}return n}fromString(e){const n=new ke,r=/(\d\.[\d.]*\d|[A-Za-z]+)=((?:"")|(?:".*?[^\\]")|(?:[^,+].*?(?:[^\\][,+]))|(?:))([,+])?/g;let i=null,s=",";for(;i=r.exec(`${e},`);){let[,a,c]=i;const l=c[c.length-1];(l===","||l==="+")&&(c=c.slice(0,c.length-1),i[3]=l);const u=i[3];a=this.getTypeOid(a);const p=this.createAttribute(a,c);s==="+"?n[n.length-1].push(p):n.push(new Xn([p])),s=u}return n}fromJSON(e){const n=new ke;for(const r of e){const i=new Xn;for(const s in r){const a=this.getTypeOid(s),c=r[s];for(const l of c){const u=this.createAttribute(a,l);i.push(u)}}n.push(i)}return n}getTypeOid(e){if(/[\d.]+/.test(e)||(e=this.getName(e)||""),!e)throw new Error(`Cannot get OID for name type '${e}'`);return e}createAttribute(e,n){const r=new xo({type:e});if(typeof n=="object")for(const i in n)switch(i){case"ia5String":r.value.ia5String=n[i];break;case"utf8String":r.value.utf8String=n[i];break;case"universalString":r.value.universalString=n[i];break;case"bmpString":r.value.bmpString=n[i];break;case"printableString":r.value.printableString=n[i];break}else if(n[0]==="#")r.value.anyValue=J.FromHex(n.slice(1));else{const i=this.processStringValue(n);e===this.getName("E")||e===this.getName("DC")?r.value.ia5String=i:it.isPrintableString(i)?r.value.printableString=i:r.value.utf8String=i}return r}processStringValue(e){const n=/"(.*?[^\\])?"/.exec(e);return n&&(e=n[1]),e.replace(/\\0a/ig,`
143
- `).replace(/\\0d/ig,"\r").replace(/\\0g/ig," ").replace(/\\(.)/g,"$1")}toArrayBuffer(){return q.serialize(this.asn)}async getThumbprint(...e){var n;let r,i="SHA-1";return e.length>=1&&!(!((n=e[0])===null||n===void 0)&&n.subtle)?(i=e[0]||i,r=e[1]||$e.get()):r=e[0]||$e.get(),await r.subtle.digest(i,this.toArrayBuffer())}}const Ng="Cannot initialize GeneralName from ASN.1 data.",mp=`${Ng} Unsupported string format in use.`,Gv=`${Ng} Value doesn't match to GUID regular expression.`,_p=/^([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})$/i,yp="1.3.6.1.4.1.311.25.1",vp="1.3.6.1.4.1.311.20.2.3",sa="dns",oa="dn",aa="email",ca="ip",la="url",ua="guid",da="upn",Oi="id";class Wt extends ln{constructor(...e){let n;if(e.length===2)switch(e[0]){case oa:{const r=new it(e[1]).toArrayBuffer(),i=q.parse(r,ke);n=new re({directoryName:i});break}case sa:n=new re({dNSName:e[1]});break;case aa:n=new re({rfc822Name:e[1]});break;case ua:{const r=new RegExp(_p,"i").exec(e[1]);if(!r)throw new Error("Cannot parse GUID value. Value doesn't match to regular expression");const i=r.slice(1).map((s,a)=>a<3?J.ToHex(new Uint8Array(J.FromHex(s)).reverse()):s).join("");n=new re({otherName:new Dr({typeId:yp,value:q.serialize(new ue(J.FromHex(i)))})});break}case ca:n=new re({iPAddress:e[1]});break;case Oi:n=new re({registeredID:e[1]});break;case da:{n=new re({otherName:new Dr({typeId:vp,value:q.serialize(Fh.toASN(e[1]))})});break}case la:n=new re({uniformResourceIdentifier:e[1]});break;default:throw new Error("Cannot create GeneralName. Unsupported type of the name")}else M.isBufferSource(e[0])?n=q.parse(e[0],re):n=e[0];super(n)}onInit(e){if(e.dNSName!=null)this.type=sa,this.value=e.dNSName;else if(e.rfc822Name!=null)this.type=aa,this.value=e.rfc822Name;else if(e.iPAddress!=null)this.type=ca,this.value=e.iPAddress;else if(e.uniformResourceIdentifier!=null)this.type=la,this.value=e.uniformResourceIdentifier;else if(e.registeredID!=null)this.type=Oi,this.value=e.registeredID;else if(e.directoryName!=null)this.type=oa,this.value=new it(e.directoryName).toString();else if(e.otherName!=null)if(e.otherName.typeId===yp){this.type=ua;const n=q.parse(e.otherName.value,ue),r=new RegExp(_p,"i").exec(J.ToHex(n));if(!r)throw new Error(Gv);this.value=r.slice(1).map((i,s)=>s<3?J.ToHex(new Uint8Array(J.FromHex(i)).reverse()):i).join("-")}else if(e.otherName.typeId===vp)this.type=da,this.value=q.parse(e.otherName.value,Te).toString();else throw new Error(mp);else throw new Error(mp)}toJSON(){return{type:this.type,value:this.value}}toTextObject(){let e;switch(this.type){case oa:case sa:case ua:case ca:case Oi:case da:case la:e=this.type.toUpperCase();break;case aa:e="Email";break;default:throw new Error("Unsupported GeneralName type")}let n=this.value;return this.type===Oi&&(n=cn.toString(n)),new pe(e,void 0,n)}}class Yr extends ln{constructor(e){let n;if(e instanceof qe)n=e;else if(Array.isArray(e)){const r=[];for(const i of e)if(i instanceof re)r.push(i);else{const s=q.parse(new Wt(i.type,i.value).rawData,re);r.push(s)}n=new qe(r)}else if(M.isBufferSource(e))n=q.parse(e,qe);else throw new Error("Cannot initialize GeneralNames. Incorrect incoming arguments");super(n)}onInit(e){const n=[];for(const r of e){let i=null;try{i=new Wt(r)}catch{continue}n.push(i)}this.items=n}toJSON(){return this.items.map(e=>e.toJSON())}toTextObject(){const e=super.toTextObjectEmpty();for(const n of this.items){const r=n.toTextObject();let i=e[r[pe.NAME]];Array.isArray(i)||(i=[],e[r[pe.NAME]]=i),i.push(r)}return e}}Yr.NAME="GeneralNames";const Lr="-{5}",Xr="\\n",Jv=`[^${Xr}]+`,Zv=`${Lr}BEGIN (${Jv}(?=${Lr}))${Lr}`,Yv=`${Lr}END \\1${Lr}`,or="\\n",Xv=`[^:${Xr}]+`,Qv=`(?:[^${Xr}]+${or}(?: +[^${Xr}]+${or})*)`,ew="[a-zA-Z0-9=+/]+",tw=`(?:${ew}${or})+`,wp=`${Zv}${or}(?:((?:${Xv}: ${Qv})+))?${or}?(${tw})${Yv}`;class Xe{static isPem(e){return typeof e=="string"&&new RegExp(wp,"g").test(e)}static decodeWithHeaders(e){e=e.replace(/\r/g,"");const n=new RegExp(wp,"g"),r=[];let i=null;for(;i=n.exec(e);){const s=i[3].replace(new RegExp(`[${Xr}]+`,"g"),""),a={type:i[1],headers:[],rawData:J.FromBase64(s)},c=i[2];if(c){const l=c.split(new RegExp(or,"g"));let u=null;for(const p of l){const[h,m]=p.split(/:(.*)/);if(m===void 0){if(!u)throw new Error("Cannot parse PEM string. Incorrect header value");u.value+=h.trim()}else u&&a.headers.push(u),u={key:h,value:m.trim()}}u&&a.headers.push(u)}r.push(a)}return r}static decode(e){return this.decodeWithHeaders(e).map(r=>r.rawData)}static decodeFirst(e){const n=this.decode(e);if(!n.length)throw new RangeError("PEM string doesn't contain any objects");return n[0]}static encode(e,n){if(Array.isArray(e)){const r=new Array;return n?e.forEach(i=>{if(!M.isBufferSource(i))throw new TypeError("Cannot encode array of BufferSource in PEM format. Not all items of the array are BufferSource");r.push(this.encodeStruct({type:n,rawData:M.toArrayBuffer(i)}))}):e.forEach(i=>{if(!("type"in i))throw new TypeError("Cannot encode array of PemStruct in PEM format. Not all items of the array are PemStrut");r.push(this.encodeStruct(i))}),r.join(`
141
+ */const bi="crypto.algorithm";class Hv{getAlgorithms(){return Pe.resolveAll(bi)}toAsnAlgorithm(e){({...e});for(const n of this.getAlgorithms()){const r=n.toAsnAlgorithm(e);if(r)return r}if(/^[0-9.]+$/.test(e.name)){const n=new F({algorithm:e.name});if("parameters"in e){const r=e;n.parameters=r.parameters}return n}throw new Error("Cannot convert WebCrypto algorithm to ASN.1 algorithm")}toWebAlgorithm(e){for(const r of this.getAlgorithms()){const i=r.toWebAlgorithm(e);if(i)return i}return{name:e.algorithm,parameters:e.parameters}}}const On="crypto.algorithmProvider";Pe.registerSingleton(On,Hv);var Mi;const Je="1.3.36.3.3.2.8.1.1",Dd=`${Je}.1`,Hd=`${Je}.2`,Fd=`${Je}.3`,Kd=`${Je}.4`,Wd=`${Je}.5`,Gd=`${Je}.6`,Jd=`${Je}.7`,Zd=`${Je}.8`,Yd=`${Je}.9`,Xd=`${Je}.10`,Qd=`${Je}.11`,ep=`${Je}.12`,tp=`${Je}.13`,np=`${Je}.14`,rp="brainpoolP160r1",ip="brainpoolP160t1",sp="brainpoolP192r1",op="brainpoolP192t1",ap="brainpoolP224r1",cp="brainpoolP224t1",lp="brainpoolP256r1",up="brainpoolP256t1",dp="brainpoolP320r1",pp="brainpoolP320t1",fp="brainpoolP384r1",hp="brainpoolP384t1",gp="brainpoolP512r1",mp="brainpoolP512t1",ye="ECDSA";let Zr=Mi=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case ye.toLowerCase():if("hash"in e)switch((typeof e.hash=="string"?e.hash:e.hash.name).toLowerCase()){case"sha-1":return hv;case"sha-256":return gv;case"sha-384":return mv;case"sha-512":return _v}else if("namedCurve"in e){let n="";switch(e.namedCurve){case"P-256":n=wd;break;case"K-256":n=Mi.SECP256K1;break;case"P-384":n=bd;break;case"P-521":n=kd;break;case rp:n=Dd;break;case ip:n=Hd;break;case sp:n=Fd;break;case op:n=Kd;break;case ap:n=Wd;break;case cp:n=Gd;break;case lp:n=Jd;break;case up:n=Zd;break;case dp:n=Yd;break;case pp:n=Xd;break;case fp:n=Qd;break;case hp:n=ep;break;case gp:n=tp;break;case mp:n=np;break}if(n)return new F({algorithm:Wr,parameters:q.serialize(new nn({namedCurve:n}))})}}return null}toWebAlgorithm(e){switch(e.algorithm){case Dl:return{name:ye,hash:{name:"SHA-1"}};case Hl:return{name:ye,hash:{name:"SHA-256"}};case Fl:return{name:ye,hash:{name:"SHA-384"}};case Kl:return{name:ye,hash:{name:"SHA-512"}};case Wr:{if(!e.parameters)throw new TypeError("Cannot get required parameters from EC algorithm");switch(q.parse(e.parameters,nn).namedCurve){case wd:return{name:ye,namedCurve:"P-256"};case Mi.SECP256K1:return{name:ye,namedCurve:"K-256"};case bd:return{name:ye,namedCurve:"P-384"};case kd:return{name:ye,namedCurve:"P-521"};case Dd:return{name:ye,namedCurve:rp};case Hd:return{name:ye,namedCurve:ip};case Fd:return{name:ye,namedCurve:sp};case Kd:return{name:ye,namedCurve:op};case Wd:return{name:ye,namedCurve:ap};case Gd:return{name:ye,namedCurve:cp};case Jd:return{name:ye,namedCurve:lp};case Zd:return{name:ye,namedCurve:up};case Yd:return{name:ye,namedCurve:dp};case Xd:return{name:ye,namedCurve:pp};case Qd:return{name:ye,namedCurve:fp};case ep:return{name:ye,namedCurve:hp};case tp:return{name:ye,namedCurve:gp};case np:return{name:ye,namedCurve:mp}}}}return null}};Zr.SECP256K1="1.3.132.0.10";Zr=Mi=d([Do()],Zr);Pe.registerSingleton(bi,Zr);const Eg=Symbol("name"),Ig=Symbol("value");class pe{constructor(e,n={},r=""){this[Eg]=e,this[Ig]=r;for(const i in n)this[i]=n[i]}}pe.NAME=Eg;pe.VALUE=Ig;class Fv{static toTextObject(e){const n=new pe("Algorithm Identifier",{},ln.toString(e.algorithm));if(e.parameters)switch(e.algorithm){case Wr:{const r=new Zr().toWebAlgorithm(e);r&&"namedCurve"in r?n["Named Curve"]=r.namedCurve:n.Parameters=e.parameters;break}default:n.Parameters=e.parameters}return n}}class ln{static toString(e){const n=this.items[e];return n||e}}ln.items={[Bs]:"sha1",[fg]:"sha224",[Ts]:"sha256",[Ps]:"sha384",[Rs]:"sha512",[Cn]:"rsaEncryption",[js]:"sha1WithRSAEncryption",[xv]:"sha224WithRSAEncryption",[xc]:"sha256WithRSAEncryption",[$s]:"sha384WithRSAEncryption",[Os]:"sha512WithRSAEncryption",[Wr]:"ecPublicKey",[Dl]:"ecdsaWithSHA1",[ug]:"ecdsaWithSHA224",[Hl]:"ecdsaWithSHA256",[Fl]:"ecdsaWithSHA384",[Kl]:"ecdsaWithSHA512",[av]:"TLS WWW server authentication",[cv]:"TLS WWW client authentication",[lv]:"Code Signing",[uv]:"E-mail Protection",[dv]:"Time Stamping",[pv]:"OCSP Signing",[fv]:"Signed Data"};class Bn{static serialize(e){return this.serializeObj(e).join(`
142
+ `)}static pad(e=0){return"".padStart(2*e," ")}static serializeObj(e,n=0){const r=[];let i=this.pad(n++),s="";const a=e[pe.VALUE];a&&(s=` ${a}`),r.push(`${i}${e[pe.NAME]}:${s}`),i=this.pad(n);for(const c in e){if(typeof c=="symbol")continue;const l=e[c],u=c?`${c}: `:"";if(typeof l=="string"||typeof l=="number"||typeof l=="boolean")r.push(`${i}${u}${l}`);else if(l instanceof Date)r.push(`${i}${u}${l.toUTCString()}`);else if(Array.isArray(l))for(const p of l)p[pe.NAME]=c,r.push(...this.serializeObj(p,n));else if(l instanceof pe)l[pe.NAME]=c,r.push(...this.serializeObj(l,n));else if(M.isBufferSource(l))c?(r.push(`${i}${u}`),r.push(...this.serializeBufferSource(l,n+1))):r.push(...this.serializeBufferSource(l,n));else if("toTextObject"in l){const p=l.toTextObject();p[pe.NAME]=c,r.push(...this.serializeObj(p,n))}else throw new TypeError("Cannot serialize data in text format. Unsupported type.")}return r}static serializeBufferSource(e,n=0){const r=this.pad(n),i=M.toUint8Array(e),s=[];for(let a=0;a<i.length;){const c=[];for(let l=0;l<16&&a<i.length;l++){l===8&&c.push("");const u=i[a++].toString(16).padStart(2,"0");c.push(u)}s.push(`${r}${c.join(" ")}`)}return s}static serializeAlgorithm(e){return this.algorithmSerializer.toTextObject(e)}}Bn.oidSerializer=ln;Bn.algorithmSerializer=Fv;class un{constructor(...e){if(e.length===1){const n=e[0];this.rawData=q.serialize(n),this.onInit(n)}else{const n=q.parse(e[0],e[1]);this.rawData=M.toArrayBuffer(e[0]),this.onInit(n)}}equal(e){return e instanceof un?Kf(e.rawData,this.rawData):!1}toString(e="text"){switch(e){case"asn":return q.toString(this.rawData);case"text":return Bn.serialize(this.toTextObject());case"hex":return J.ToHex(this.rawData);case"base64":return J.ToBase64(this.rawData);case"base64url":return J.ToBase64Url(this.rawData);default:throw TypeError("Argument 'format' is unsupported value")}}getTextName(){return this.constructor.NAME}toTextObject(){const e=this.toTextObjectEmpty();return e[""]=this.rawData,e}toTextObjectEmpty(e){return new pe(this.getTextName(),{},e)}}un.NAME="ASN";class ct extends un{constructor(...e){let n;M.isBufferSource(e[0])?n=M.toArrayBuffer(e[0]):n=q.serialize(new ot({extnID:e[0],critical:e[1],extnValue:new ue(M.toArrayBuffer(e[2]))})),super(n,ot)}onInit(e){this.type=e.extnID,this.critical=e.critical,this.value=e.extnValue.buffer}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.value,e}toTextObjectWithoutValue(){const e=this.toTextObjectEmpty(this.critical?"critical":void 0);return e[pe.NAME]===ct.NAME&&(e[pe.NAME]=ln.toString(this.type)),e}}var zg;class Wt{static isCryptoKeyPair(e){return e&&e.privateKey&&e.publicKey}static isCryptoKey(e){return e&&e.usages&&e.type&&e.algorithm&&e.extractable!==void 0}constructor(){this.items=new Map,this[zg]="CryptoProvider",typeof self<"u"&&typeof crypto<"u"?this.set(Wt.DEFAULT,crypto):typeof global<"u"&&global.crypto&&global.crypto.subtle&&this.set(Wt.DEFAULT,global.crypto)}clear(){this.items.clear()}delete(e){return this.items.delete(e)}forEach(e,n){return this.items.forEach(e,n)}has(e){return this.items.has(e)}get size(){return this.items.size}entries(){return this.items.entries()}keys(){return this.items.keys()}values(){return this.items.values()}[Symbol.iterator](){return this.items[Symbol.iterator]()}get(e=Wt.DEFAULT){const n=this.items.get(e.toLowerCase());if(!n)throw new Error(`Cannot get Crypto by name '${e}'`);return n}set(e,n){if(typeof e=="string"){if(!n)throw new TypeError("Argument 'value' is required");this.items.set(e.toLowerCase(),n)}else this.items.set(Wt.DEFAULT,e);return this}}zg=Symbol.toStringTag;Wt.DEFAULT="default";const $e=new Wt,Kv=/^[0-2](?:\.[1-9][0-9]*)+$/;function Wv(t){return new RegExp(Kv).test(t)}class Ng{constructor(e={}){this.items={};for(const n in e)this.register(n,e[n])}get(e){return this.items[e]||null}findId(e){return Wv(e)?e:this.get(e)}register(e,n){this.items[e]=n,this.items[n]=e}}const We=new Ng;We.register("CN","2.5.4.3");We.register("L","2.5.4.7");We.register("ST","2.5.4.8");We.register("O","2.5.4.10");We.register("OU","2.5.4.11");We.register("C","2.5.4.6");We.register("DC","0.9.2342.19200300.100.1.25");We.register("E","1.2.840.113549.1.9.1");We.register("G","2.5.4.42");We.register("I","2.5.4.43");We.register("SN","2.5.4.4");We.register("T","2.5.4.12");function Gv(t,e){return`\\${J.ToHex(J.FromUtf8String(e)).toUpperCase()}`}function Jv(t){return t.replace(/([,+"\\<>;])/g,"\\$1").replace(/^([ #])/,"\\$1").replace(/([ ]$)/,"\\$1").replace(/([\r\n\t])/,Gv)}class it{static isASCII(e){for(let n=0;n<e.length;n++)if(e.charCodeAt(n)>255)return!1;return!0}static isPrintableString(e){return/^[A-Za-z0-9 '()+,-./:=?]*$/g.test(e)}constructor(e,n={}){this.extraNames=new Ng,this.asn=new ke;for(const r in n)if(Object.prototype.hasOwnProperty.call(n,r)){const i=n[r];this.extraNames.register(r,i)}typeof e=="string"?this.asn=this.fromString(e):e instanceof ke?this.asn=e:M.isBufferSource(e)?this.asn=q.parse(e,ke):this.asn=this.fromJSON(e)}getField(e){const n=this.extraNames.findId(e)||We.findId(e),r=[];for(const i of this.asn)for(const s of i)s.type===n&&r.push(s.value.toString());return r}getName(e){return this.extraNames.get(e)||We.get(e)}toString(){return this.asn.map(e=>e.map(n=>{const r=this.getName(n.type)||n.type,i=n.value.anyValue?`#${J.ToHex(n.value.anyValue)}`:Jv(n.value.toString());return`${r}=${i}`}).join("+")).join(", ")}toJSON(){var e;const n=[];for(const r of this.asn){const i={};for(const s of r){const a=this.getName(s.type)||s.type;(e=i[a])!==null&&e!==void 0||(i[a]=[]),i[a].push(s.value.anyValue?`#${J.ToHex(s.value.anyValue)}`:s.value.toString())}n.push(i)}return n}fromString(e){const n=new ke,r=/(\d\.[\d.]*\d|[A-Za-z]+)=((?:"")|(?:".*?[^\\]")|(?:[^,+].*?(?:[^\\][,+]))|(?:))([,+])?/g;let i=null,s=",";for(;i=r.exec(`${e},`);){let[,a,c]=i;const l=c[c.length-1];(l===","||l==="+")&&(c=c.slice(0,c.length-1),i[3]=l);const u=i[3];a=this.getTypeOid(a);const p=this.createAttribute(a,c);s==="+"?n[n.length-1].push(p):n.push(new Xn([p])),s=u}return n}fromJSON(e){const n=new ke;for(const r of e){const i=new Xn;for(const s in r){const a=this.getTypeOid(s),c=r[s];for(const l of c){const u=this.createAttribute(a,l);i.push(u)}}n.push(i)}return n}getTypeOid(e){if(/[\d.]+/.test(e)||(e=this.getName(e)||""),!e)throw new Error(`Cannot get OID for name type '${e}'`);return e}createAttribute(e,n){const r=new xo({type:e});if(typeof n=="object")for(const i in n)switch(i){case"ia5String":r.value.ia5String=n[i];break;case"utf8String":r.value.utf8String=n[i];break;case"universalString":r.value.universalString=n[i];break;case"bmpString":r.value.bmpString=n[i];break;case"printableString":r.value.printableString=n[i];break}else if(n[0]==="#")r.value.anyValue=J.FromHex(n.slice(1));else{const i=this.processStringValue(n);e===this.getName("E")||e===this.getName("DC")?r.value.ia5String=i:it.isPrintableString(i)?r.value.printableString=i:r.value.utf8String=i}return r}processStringValue(e){const n=/"(.*?[^\\])?"/.exec(e);return n&&(e=n[1]),e.replace(/\\0a/ig,`
143
+ `).replace(/\\0d/ig,"\r").replace(/\\0g/ig," ").replace(/\\(.)/g,"$1")}toArrayBuffer(){return q.serialize(this.asn)}async getThumbprint(...e){var n;let r,i="SHA-1";return e.length>=1&&!(!((n=e[0])===null||n===void 0)&&n.subtle)?(i=e[0]||i,r=e[1]||$e.get()):r=e[0]||$e.get(),await r.subtle.digest(i,this.toArrayBuffer())}}const Cg="Cannot initialize GeneralName from ASN.1 data.",_p=`${Cg} Unsupported string format in use.`,Zv=`${Cg} Value doesn't match to GUID regular expression.`,yp=/^([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})$/i,vp="1.3.6.1.4.1.311.25.1",wp="1.3.6.1.4.1.311.20.2.3",sa="dns",oa="dn",aa="email",ca="ip",la="url",ua="guid",da="upn",Oi="id";class Gt extends un{constructor(...e){let n;if(e.length===2)switch(e[0]){case oa:{const r=new it(e[1]).toArrayBuffer(),i=q.parse(r,ke);n=new re({directoryName:i});break}case sa:n=new re({dNSName:e[1]});break;case aa:n=new re({rfc822Name:e[1]});break;case ua:{const r=new RegExp(yp,"i").exec(e[1]);if(!r)throw new Error("Cannot parse GUID value. Value doesn't match to regular expression");const i=r.slice(1).map((s,a)=>a<3?J.ToHex(new Uint8Array(J.FromHex(s)).reverse()):s).join("");n=new re({otherName:new Dr({typeId:vp,value:q.serialize(new ue(J.FromHex(i)))})});break}case ca:n=new re({iPAddress:e[1]});break;case Oi:n=new re({registeredID:e[1]});break;case da:{n=new re({otherName:new Dr({typeId:wp,value:q.serialize(Kh.toASN(e[1]))})});break}case la:n=new re({uniformResourceIdentifier:e[1]});break;default:throw new Error("Cannot create GeneralName. Unsupported type of the name")}else M.isBufferSource(e[0])?n=q.parse(e[0],re):n=e[0];super(n)}onInit(e){if(e.dNSName!=null)this.type=sa,this.value=e.dNSName;else if(e.rfc822Name!=null)this.type=aa,this.value=e.rfc822Name;else if(e.iPAddress!=null)this.type=ca,this.value=e.iPAddress;else if(e.uniformResourceIdentifier!=null)this.type=la,this.value=e.uniformResourceIdentifier;else if(e.registeredID!=null)this.type=Oi,this.value=e.registeredID;else if(e.directoryName!=null)this.type=oa,this.value=new it(e.directoryName).toString();else if(e.otherName!=null)if(e.otherName.typeId===vp){this.type=ua;const n=q.parse(e.otherName.value,ue),r=new RegExp(yp,"i").exec(J.ToHex(n));if(!r)throw new Error(Zv);this.value=r.slice(1).map((i,s)=>s<3?J.ToHex(new Uint8Array(J.FromHex(i)).reverse()):i).join("-")}else if(e.otherName.typeId===wp)this.type=da,this.value=q.parse(e.otherName.value,Te).toString();else throw new Error(_p);else throw new Error(_p)}toJSON(){return{type:this.type,value:this.value}}toTextObject(){let e;switch(this.type){case oa:case sa:case ua:case ca:case Oi:case da:case la:e=this.type.toUpperCase();break;case aa:e="Email";break;default:throw new Error("Unsupported GeneralName type")}let n=this.value;return this.type===Oi&&(n=ln.toString(n)),new pe(e,void 0,n)}}class Yr extends un{constructor(e){let n;if(e instanceof qe)n=e;else if(Array.isArray(e)){const r=[];for(const i of e)if(i instanceof re)r.push(i);else{const s=q.parse(new Gt(i.type,i.value).rawData,re);r.push(s)}n=new qe(r)}else if(M.isBufferSource(e))n=q.parse(e,qe);else throw new Error("Cannot initialize GeneralNames. Incorrect incoming arguments");super(n)}onInit(e){const n=[];for(const r of e){let i=null;try{i=new Gt(r)}catch{continue}n.push(i)}this.items=n}toJSON(){return this.items.map(e=>e.toJSON())}toTextObject(){const e=super.toTextObjectEmpty();for(const n of this.items){const r=n.toTextObject();let i=e[r[pe.NAME]];Array.isArray(i)||(i=[],e[r[pe.NAME]]=i),i.push(r)}return e}}Yr.NAME="GeneralNames";const Lr="-{5}",Xr="\\n",Yv=`[^${Xr}]+`,Xv=`${Lr}BEGIN (${Yv}(?=${Lr}))${Lr}`,Qv=`${Lr}END \\1${Lr}`,or="\\n",ew=`[^:${Xr}]+`,tw=`(?:[^${Xr}]+${or}(?: +[^${Xr}]+${or})*)`,nw="[a-zA-Z0-9=+/]+",rw=`(?:${nw}${or})+`,bp=`${Xv}${or}(?:((?:${ew}: ${tw})+))?${or}?(${rw})${Qv}`;class Xe{static isPem(e){return typeof e=="string"&&new RegExp(bp,"g").test(e)}static decodeWithHeaders(e){e=e.replace(/\r/g,"");const n=new RegExp(bp,"g"),r=[];let i=null;for(;i=n.exec(e);){const s=i[3].replace(new RegExp(`[${Xr}]+`,"g"),""),a={type:i[1],headers:[],rawData:J.FromBase64(s)},c=i[2];if(c){const l=c.split(new RegExp(or,"g"));let u=null;for(const p of l){const[h,m]=p.split(/:(.*)/);if(m===void 0){if(!u)throw new Error("Cannot parse PEM string. Incorrect header value");u.value+=h.trim()}else u&&a.headers.push(u),u={key:h,value:m.trim()}}u&&a.headers.push(u)}r.push(a)}return r}static decode(e){return this.decodeWithHeaders(e).map(r=>r.rawData)}static decodeFirst(e){const n=this.decode(e);if(!n.length)throw new RangeError("PEM string doesn't contain any objects");return n[0]}static encode(e,n){if(Array.isArray(e)){const r=new Array;return n?e.forEach(i=>{if(!M.isBufferSource(i))throw new TypeError("Cannot encode array of BufferSource in PEM format. Not all items of the array are BufferSource");r.push(this.encodeStruct({type:n,rawData:M.toArrayBuffer(i)}))}):e.forEach(i=>{if(!("type"in i))throw new TypeError("Cannot encode array of PemStruct in PEM format. Not all items of the array are PemStrut");r.push(this.encodeStruct(i))}),r.join(`
144
144
  `)}else{if(!n)throw new Error("Required argument 'tag' is missed");return this.encodeStruct({type:n,rawData:M.toArrayBuffer(e)})}}static encodeStruct(e){var n;const r=e.type.toLocaleUpperCase(),i=[];if(i.push(`-----BEGIN ${r}-----`),!((n=e.headers)===null||n===void 0)&&n.length){for(const u of e.headers)i.push(`${u.key}: ${u.value}`);i.push("")}const s=J.ToBase64(e.rawData);let a,c=0;const l=Array();for(;c<s.length&&(s.length-c<64?a=s.substring(c):(a=s.substring(c,c+64),c+=64),a.length!==0);)if(l.push(a),a.length<64)break;return i.push(...l),i.push(`-----END ${r}-----`),i.join(`
145
- `)}}Xe.CertificateTag="CERTIFICATE";Xe.CrlTag="CRL";Xe.CertificateRequestTag="CERTIFICATE REQUEST";Xe.PublicKeyTag="PUBLIC KEY";Xe.PrivateKeyTag="PRIVATE KEY";class qt extends ln{static isAsnEncoded(e){return M.isBufferSource(e)||typeof e=="string"}static toArrayBuffer(e){if(typeof e=="string"){if(Xe.isPem(e))return Xe.decode(e)[0];if(J.isHex(e))return J.FromHex(e);if(J.isBase64(e))return J.FromBase64(e);if(J.isBase64Url(e))return J.FromBase64Url(e);throw new TypeError("Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url")}else{const n=J.ToBinary(e);return Xe.isPem(n)?Xe.decode(n)[0]:J.isHex(n)?J.FromHex(n):J.isBase64(n)?J.FromBase64(n):J.isBase64Url(n)?J.FromBase64Url(n):M.toArrayBuffer(e)}}constructor(...e){qt.isAsnEncoded(e[0])?super(qt.toArrayBuffer(e[0]),e[1]):super(e[0])}toString(e="pem"){switch(e){case"pem":return Xe.encode(this.rawData,this.tag);default:return super.toString(e)}}}class ht extends qt{static async create(e,n=$e.get()){if(e instanceof ht)return e;if(Kt.isCryptoKey(e)){if(e.type!=="public")throw new TypeError("Public key is required");const r=await n.subtle.exportKey("spki",e);return new ht(r)}else{if(e.publicKey)return e.publicKey;if(M.isBufferSource(e))return new ht(e);throw new TypeError("Unsupported PublicKeyType")}}constructor(e){qt.isAsnEncoded(e)?super(e,ft):super(e),this.tag=Xe.PublicKeyTag}async export(...e){let n,r=["verify"],i={hash:"SHA-256",...this.algorithm};e.length>1?(i=e[0]||i,r=e[1]||r,n=e[2]||$e.get()):n=e[0]||$e.get();let s=this.rawData;const a=q.parse(this.rawData,ft);return a.algorithm.algorithm===Rr&&(s=nw(a,s)),n.subtle.importKey("spki",s,i,!0,r)}onInit(e){const n=Pe.resolve(On),r=this.algorithm=n.toWebAlgorithm(e.algorithm);switch(e.algorithm.algorithm){case Cn:{const i=q.parse(e.subjectPublicKey,Wl),s=M.toUint8Array(i.modulus);r.publicExponent=M.toUint8Array(i.publicExponent),r.modulusLength=(s[0]?s:s.slice(1)).byteLength<<3;break}}}async getThumbprint(...e){var n;let r,i="SHA-1";return e.length>=1&&!(!((n=e[0])===null||n===void 0)&&n.subtle)?(i=e[0]||i,r=e[1]||$e.get()):r=e[0]||$e.get(),await r.subtle.digest(i,this.rawData)}async getKeyIdentifier(...e){let n,r="SHA-1";e.length===1?typeof e[0]=="string"?(r=e[0],n=$e.get()):n=e[0]:e.length===2?(r=e[0],n=e[1]):n=$e.get();const i=q.parse(this.rawData,ft);return await n.subtle.digest(r,i.subjectPublicKey)}toTextObject(){const e=this.toTextObjectEmpty(),n=q.parse(this.rawData,ft);switch(e.Algorithm=Bn.serializeAlgorithm(n.algorithm),n.algorithm.algorithm){case Wr:e["EC Point"]=n.subjectPublicKey;break;case Cn:default:e["Raw Data"]=n.subjectPublicKey}return e}}function nw(t,e){return t.algorithm=new F({algorithm:Cn,parameters:null}),e=q.serialize(t),e}class Qr extends ct{static async create(e,n=!1,r=$e.get()){if("name"in e&&"serialNumber"in e)return new Qr(e,n);const s=await(await ht.create(e,r)).getKeyIdentifier(r);return new Qr(J.ToHex(s),n)}constructor(...e){if(M.isBufferSource(e[0]))super(e[0]);else if(typeof e[0]=="string"){const n=new vn({keyIdentifier:new zl(J.FromHex(e[0]))});super(qa,e[1],q.serialize(n))}else{const n=e[0],r=n.name instanceof Yr?q.parse(n.name.rawData,qe):n.name,i=new vn({authorityCertIssuer:r,authorityCertSerialNumber:J.FromHex(n.serialNumber)});super(qa,e[1],q.serialize(i))}}onInit(e){super.onInit(e);const n=q.parse(e.extnValue,vn);n.keyIdentifier&&(this.keyId=J.ToHex(n.keyIdentifier)),(n.authorityCertIssuer||n.authorityCertSerialNumber)&&(this.certId={name:n.authorityCertIssuer||[],serialNumber:n.authorityCertSerialNumber?J.ToHex(n.authorityCertSerialNumber):""})}toTextObject(){const e=this.toTextObjectWithoutValue(),n=q.parse(this.value,vn);return n.authorityCertIssuer&&(e["Authority Issuer"]=new Yr(n.authorityCertIssuer).toTextObject()),n.authorityCertSerialNumber&&(e["Authority Serial Number"]=n.authorityCertSerialNumber),n.keyIdentifier&&(e[""]=n.keyIdentifier),e}}Qr.NAME="Authority Key Identifier";class Yl extends ct{constructor(...e){if(M.isBufferSource(e[0])){super(e[0]);const n=q.parse(this.value,fs);this.ca=n.cA,this.pathLength=n.pathLenConstraint}else{const n=new fs({cA:e[0],pathLenConstraint:e[1]});super(Gh,e[2],q.serialize(n)),this.ca=e[0],this.pathLength=e[1]}}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ca&&(e.CA=this.ca),this.pathLength!==void 0&&(e["Path Length"]=this.pathLength),e}}Yl.NAME="Basic Constraints";var bp;(function(t){t.serverAuth="1.3.6.1.5.5.7.3.1",t.clientAuth="1.3.6.1.5.5.7.3.2",t.codeSigning="1.3.6.1.5.5.7.3.3",t.emailProtection="1.3.6.1.5.5.7.3.4",t.timeStamping="1.3.6.1.5.5.7.3.8",t.ocspSigning="1.3.6.1.5.5.7.3.9"})(bp||(bp={}));class Xl extends ct{constructor(...e){if(M.isBufferSource(e[0])){super(e[0]);const n=q.parse(this.value,_s);this.usages=n.map(r=>r)}else{const n=new _s(e[0]);super(Yh,e[1],q.serialize(n)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.usages.map(n=>cn.toString(n)).join(", "),e}}Xl.NAME="Extended Key Usages";var Ds;(function(t){t[t.digitalSignature=1]="digitalSignature",t[t.nonRepudiation=2]="nonRepudiation",t[t.keyEncipherment=4]="keyEncipherment",t[t.dataEncipherment=8]="dataEncipherment",t[t.keyAgreement=16]="keyAgreement",t[t.keyCertSign=32]="keyCertSign",t[t.cRLSign=64]="cRLSign",t[t.encipherOnly=128]="encipherOnly",t[t.decipherOnly=256]="decipherOnly"})(Ds||(Ds={}));class Ql extends ct{constructor(...e){if(M.isBufferSource(e[0])){super(e[0]);const n=q.parse(this.value,ia);this.usages=n.toNumber()}else{const n=new ia(e[0]);super(Xh,e[1],q.serialize(n)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue(),n=q.parse(this.value,ia);return e[""]=n.toJSON().join(", "),e}}Ql.NAME="Key Usages";class ki extends ct{static async create(e,n=!1,r=$e.get()){const s=await(await ht.create(e,r)).getKeyIdentifier(r);return new ki(J.ToHex(s),n)}constructor(...e){if(M.isBufferSource(e[0])){super(e[0]);const n=q.parse(this.value,Jt);this.keyId=J.ToHex(n)}else{const n=typeof e[0]=="string"?J.FromHex(e[0]):e[0],r=new Jt(n);super(ng,e[1],q.serialize(r)),this.keyId=J.ToHex(n)}}toTextObject(){const e=this.toTextObjectWithoutValue(),n=q.parse(this.value,Jt);return e[""]=n,e}}ki.NAME="Subject Key Identifier";class Cg extends ct{constructor(...e){M.isBufferSource(e[0])?super(e[0]):super(tg,e[1],new Yr(e[0]||[]).rawData)}onInit(e){super.onInit(e);const n=q.parse(e.extnValue,nc);this.names=new Yr(n)}toTextObject(){const e=this.toTextObjectWithoutValue(),n=this.names.toTextObject();for(const r in n)e[r]=n[r];return e}}Cg.NAME="Subject Alternative Name";class lt{static register(e,n){this.items.set(e,n)}static create(e){const n=new ct(e),r=this.items.get(n.type);return r?new r(e):n}}lt.items=new Map;class jg extends ct{constructor(...e){var n;if(M.isBufferSource(e[0])){super(e[0]);const r=q.parse(this.value,gs);this.policies=r.map(i=>i.policyIdentifier)}else{const r=e[0],i=(n=e[1])!==null&&n!==void 0?n:!1,s=new gs(r.map(a=>new Ao({policyIdentifier:a})));super(Jh,i,q.serialize(s)),this.policies=r}}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map(n=>new pe("",{},cn.toString(n))),e}}jg.NAME="Certificate Policies";lt.register(Jh,jg);class $g extends ct{constructor(...e){var n;if(M.isBufferSource(e[0]))super(e[0]);else if(Array.isArray(e[0])&&typeof e[0][0]=="string"){const i=e[0].map(a=>new hr({distributionPoint:new En({fullName:[new re({uniformResourceIdentifier:a})]})})),s=new Wn(i);super(Ka,e[1],q.serialize(s))}else{const r=new Wn(e[0]);super(Ka,e[1],q.serialize(r))}(n=this.distributionPoints)!==null&&n!==void 0||(this.distributionPoints=[])}onInit(e){super.onInit(e);const n=q.parse(e.extnValue,Wn);this.distributionPoints=n}toTextObject(){const e=this.toTextObjectWithoutValue();return e["Distribution Point"]=this.distributionPoints.map(n=>{var r;const i={};return n.distributionPoint&&(i[""]=(r=n.distributionPoint.fullName)===null||r===void 0?void 0:r.map(s=>new Wt(s).toString()).join(", ")),n.reasons&&(i.Reasons=n.reasons.toString()),n.cRLIssuer&&(i["CRL Issuer"]=n.cRLIssuer.map(s=>s.toString()).join(", ")),i}),e}}$g.NAME="CRL Distribution Points";class Og extends ct{constructor(...e){var n,r,i,s;if(M.isBufferSource(e[0]))super(e[0]);else if(e[0]instanceof Hn){const a=new Hn(e[0]);super(Va,e[1],q.serialize(a))}else{const a=e[0],c=new Hn;Ti(c,a,id,"ocsp"),Ti(c,a,sd,"caIssuers"),Ti(c,a,od,"timeStamping"),Ti(c,a,ad,"caRepository"),super(Va,e[1],q.serialize(c))}(n=this.ocsp)!==null&&n!==void 0||(this.ocsp=[]),(r=this.caIssuers)!==null&&r!==void 0||(this.caIssuers=[]),(i=this.timeStamping)!==null&&i!==void 0||(this.timeStamping=[]),(s=this.caRepository)!==null&&s!==void 0||(this.caRepository=[])}onInit(e){super.onInit(e),this.ocsp=[],this.caIssuers=[],this.timeStamping=[],this.caRepository=[],q.parse(e.extnValue,Hn).forEach(r=>{switch(r.accessMethod){case id:this.ocsp.push(new Wt(r.accessLocation));break;case sd:this.caIssuers.push(new Wt(r.accessLocation));break;case od:this.timeStamping.push(new Wt(r.accessLocation));break;case ad:this.caRepository.push(new Wt(r.accessLocation));break}})}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ocsp.length&&Bi(e,"OCSP",this.ocsp),this.caIssuers.length&&Bi(e,"CA Issuers",this.caIssuers),this.timeStamping.length&&Bi(e,"Time Stamping",this.timeStamping),this.caRepository.length&&Bi(e,"CA Repository",this.caRepository),e}}Og.NAME="Authority Info Access";function Bi(t,e,n){if(n.length===1)t[e]=n[0].toTextObject();else{const r=new pe("");n.forEach((i,s)=>{const a=i.toTextObject(),c=`${a[pe.NAME]} ${s+1}`;let l=r[c];Array.isArray(l)||(l=[],r[c]=l),l.push(a)}),t[e]=r}}function Ti(t,e,n,r){const i=e[r];i&&(Array.isArray(i)?i:[i]).forEach(a=>{typeof a=="string"&&(a=new Wt("url",a)),t.push(new li({accessMethod:n,accessLocation:q.parse(a.rawData,re)}))})}class br extends ln{constructor(...e){let n;if(M.isBufferSource(e[0]))n=M.toArrayBuffer(e[0]);else{const r=e[0],i=Array.isArray(e[1])?e[1].map(s=>M.toArrayBuffer(s)):[];n=q.serialize(new Lt({type:r,values:i}))}super(n,Lt)}onInit(e){this.type=e.type,this.values=e.values}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Value=this.values.map(n=>new pe("",{"":n})),e}toTextObjectWithoutValue(){const e=this.toTextObjectEmpty();return e[pe.NAME]===br.NAME&&(e[pe.NAME]=cn.toString(this.type)),e}}br.NAME="Attribute";class Bg extends br{constructor(...e){var n;if(M.isBufferSource(e[0]))super(e[0]);else{const r=new qs({printableString:e[0]});super(Sg,[q.serialize(r)])}(n=this.password)!==null&&n!==void 0||(this.password="")}onInit(e){if(super.onInit(e),this.values[0]){const n=q.parse(this.values[0],qs);this.password=n.toString()}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[pe.VALUE]=this.password,e}}Bg.NAME="Challenge Password";class eu extends br{constructor(...e){var n;if(M.isBufferSource(e[0]))super(e[0]);else{const r=e[0],i=new Qt;for(const s of r)i.push(q.parse(s.rawData,ot));super(Zl,[q.serialize(i)])}(n=this.items)!==null&&n!==void 0||(this.items=[])}onInit(e){if(super.onInit(e),this.values[0]){const n=q.parse(this.values[0],Qt);this.items=n.map(r=>lt.create(q.serialize(r)))}}toTextObject(){const e=this.toTextObjectWithoutValue(),n=this.items.map(r=>r.toTextObject());for(const r of n)e[r[pe.NAME]]=r;return e}}eu.NAME="Extensions";class Go{static register(e,n){this.items.set(e,n)}static create(e){const n=new br(e),r=this.items.get(n.type);return r?new r(e):n}}Go.items=new Map;const xi="crypto.signatureFormatter";class rw{toAsnSignature(e,n){return M.toArrayBuffer(n)}toWebSignature(e,n){return M.toArrayBuffer(n)}}var Di;let Kc=Di=class{static createPssParams(e,n){const r=Di.getHashAlgorithm(e);return r?new $n({hashAlgorithm:r,maskGenAlgorithm:new F({algorithm:Uo,parameters:q.serialize(r)}),saltLength:n}):null}static getHashAlgorithm(e){const n=Pe.resolve(On);return typeof e=="string"?n.toAsnAlgorithm({name:e}):typeof e=="object"&&e&&"name"in e?n.toAsnAlgorithm(e):null}toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"rsassa-pkcs1-v1_5":if("hash"in e){let n;if(typeof e.hash=="string")n=e.hash;else if(e.hash&&typeof e.hash=="object"&&"name"in e.hash&&typeof e.hash.name=="string")n=e.hash.name.toUpperCase();else throw new Error("Cannot get hash algorithm name");switch(n.toLowerCase()){case"sha-1":return new F({algorithm:js,parameters:null});case"sha-256":return new F({algorithm:xc,parameters:null});case"sha-384":return new F({algorithm:$s,parameters:null});case"sha-512":return new F({algorithm:Os,parameters:null})}}else return new F({algorithm:Cn,parameters:null});break;case"rsa-pss":if("hash"in e){if(!("saltLength"in e&&typeof e.saltLength=="number"))throw new Error("Cannot get 'saltLength' from 'alg' argument");const n=Di.createPssParams(e.hash,e.saltLength);if(!n)throw new Error("Cannot create PSS parameters");return new F({algorithm:Rr,parameters:q.serialize(n)})}else return new F({algorithm:Rr,parameters:null})}return null}toWebAlgorithm(e){switch(e.algorithm){case Cn:return{name:"RSASSA-PKCS1-v1_5"};case js:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case xc:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case $s:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case Os:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}};case Rr:if(e.parameters){const n=q.parse(e.parameters,$n);return{name:"RSA-PSS",hash:Pe.resolve(On).toWebAlgorithm(n.hashAlgorithm),saltLength:n.saltLength}}else return{name:"RSA-PSS"}}return null}};Kc=Di=d([Do()],Kc);Pe.registerSingleton(bi,Kc);let Wc=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"sha-1":return new F({algorithm:Bs});case"sha-256":return new F({algorithm:Ts});case"sha-384":return new F({algorithm:Ps});case"sha-512":return new F({algorithm:Rs})}return null}toWebAlgorithm(e){switch(e.algorithm){case Bs:return{name:"SHA-1"};case Ts:return{name:"SHA-256"};case Ps:return{name:"SHA-384"};case Rs:return{name:"SHA-512"}}return null}};Wc=d([Do()],Wc);Pe.registerSingleton(bi,Wc);class st{addPadding(e,n){const r=M.toUint8Array(n),i=new Uint8Array(e);return i.set(r,e-r.length),i}removePadding(e,n=!1){let r=M.toUint8Array(e);for(let i=0;i<r.length;i++)if(r[i]){r=r.slice(i);break}if(n&&r[0]>127){const i=new Uint8Array(r.length+1);return i.set(r,1),i.buffer}return r.buffer}toAsnSignature(e,n){if(e.name==="ECDSA"){const r=e.namedCurve,i=st.namedCurveSize.get(r)||st.defaultNamedCurveSize,s=new Cs,a=M.toUint8Array(n);return s.r=this.removePadding(a.slice(0,i),!0),s.s=this.removePadding(a.slice(i,i+i),!0),q.serialize(s)}return null}toWebSignature(e,n){if(e.name==="ECDSA"){const r=q.parse(n,Cs),i=e.namedCurve,s=st.namedCurveSize.get(i)||st.defaultNamedCurveSize,a=this.addPadding(s,this.removePadding(r.r)),c=this.addPadding(s,this.removePadding(r.s));return my(a,c)}return null}}st.namedCurveSize=new Map;st.defaultNamedCurveSize=32;const pa="1.3.101.110",kp="1.3.101.111",fa="1.3.101.112",xp="1.3.101.113";let Gc=class{toAsnAlgorithm(e){let n=null;switch(e.name.toLowerCase()){case"ed25519":n=fa;break;case"x25519":n=pa;break;case"eddsa":switch(e.namedCurve.toLowerCase()){case"ed25519":n=fa;break;case"ed448":n=xp;break}break;case"ecdh-es":switch(e.namedCurve.toLowerCase()){case"x25519":n=pa;break;case"x448":n=kp;break}}return n?new F({algorithm:n}):null}toWebAlgorithm(e){switch(e.algorithm){case fa:return{name:"Ed25519"};case xp:return{name:"EdDSA",namedCurve:"Ed448"};case pa:return{name:"X25519"};case kp:return{name:"ECDH-ES",namedCurve:"X448"}}return null}};Gc=d([Do()],Gc);Pe.registerSingleton(bi,Gc);class iw extends qt{constructor(e){qt.isAsnEncoded(e)?super(e,Jr):super(e),this.tag=Xe.CertificateRequestTag}onInit(e){this.tbs=q.serialize(e.certificationRequestInfo),this.publicKey=new ht(e.certificationRequestInfo.subjectPKInfo);const n=Pe.resolve(On);this.signatureAlgorithm=n.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signature,this.attributes=e.certificationRequestInfo.attributes.map(i=>Go.create(q.serialize(i)));const r=this.getAttribute(Zl);this.extensions=[],r instanceof eu&&(this.extensions=r.items),this.subjectName=new it(e.certificationRequestInfo.subject),this.subject=this.subjectName.toString()}getAttribute(e){for(const n of this.attributes)if(n.type===e)return n;return null}getAttributes(e){return this.attributes.filter(n=>n.type===e)}getExtension(e){for(const n of this.extensions)if(n.type===e)return n;return null}getExtensions(e){return this.extensions.filter(n=>n.type===e)}async verify(e=$e.get()){const n={...this.publicKey.algorithm,...this.signatureAlgorithm},r=await this.publicKey.export(n,["verify"],e),i=Pe.resolveAll(xi).reverse();let s=null;for(const c of i)if(s=c.toWebSignature(n,this.signature),s)break;if(!s)throw Error("Cannot convert WebCrypto signature value to ASN.1 format");return await e.subtle.verify(this.signatureAlgorithm,r,s,this.tbs)}toTextObject(){const e=this.toTextObjectEmpty(),n=q.parse(this.rawData,Jr),r=n.certificationRequestInfo,i=new pe("",{Version:`${In[r.version]} (${r.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){const s=new pe("");for(const a of this.attributes){const c=a.toTextObject();s[c[pe.NAME]]=c}i.Attributes=s}return e.Data=i,e.Signature=new pe("",{Algorithm:Bn.serializeAlgorithm(n.signatureAlgorithm),"":n.signature}),e}}iw.NAME="PKCS#10 Certificate Request";class tu extends qt{constructor(e){qt.isAsnEncoded(e)?super(e,zn):super(e),this.tag=Xe.CertificateTag}onInit(e){const n=e.tbsCertificate;this.tbs=q.serialize(n),this.serialNumber=J.ToHex(n.serialNumber),this.subjectName=new it(n.subject),this.subject=new it(n.subject).toString(),this.issuerName=new it(n.issuer),this.issuer=this.issuerName.toString();const r=Pe.resolve(On);this.signatureAlgorithm=r.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signatureValue;const i=n.validity.notBefore.utcTime||n.validity.notBefore.generalTime;if(!i)throw new Error("Cannot get 'notBefore' value");this.notBefore=i;const s=n.validity.notAfter.utcTime||n.validity.notAfter.generalTime;if(!s)throw new Error("Cannot get 'notAfter' value");this.notAfter=s,this.extensions=[],n.extensions&&(this.extensions=n.extensions.map(a=>lt.create(q.serialize(a)))),this.publicKey=new ht(n.subjectPublicKeyInfo)}getExtension(e){for(const n of this.extensions)if(typeof e=="string"){if(n.type===e)return n}else if(n instanceof e)return n;return null}getExtensions(e){return this.extensions.filter(n=>typeof e=="string"?n.type===e:n instanceof e)}async verify(e={},n=$e.get()){let r,i;const s=e.publicKey;try{if(!s)r={...this.publicKey.algorithm,...this.signatureAlgorithm},i=await this.publicKey.export(r,["verify"],n);else if("publicKey"in s)r={...s.publicKey.algorithm,...this.signatureAlgorithm},i=await s.publicKey.export(r,["verify"],n);else if(s instanceof ht)r={...s.algorithm,...this.signatureAlgorithm},i=await s.export(r,["verify"],n);else if(M.isBufferSource(s)){const u=new ht(s);r={...u.algorithm,...this.signatureAlgorithm},i=await u.export(r,["verify"],n)}else r={...s.algorithm,...this.signatureAlgorithm},i=s}catch{return!1}const a=Pe.resolveAll(xi).reverse();let c=null;for(const u of a)if(c=u.toWebSignature(r,this.signature),c)break;if(!c)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");const l=await n.subtle.verify(this.signatureAlgorithm,i,c,this.tbs);if(e.signatureOnly)return l;{const p=(e.date||new Date).getTime();return l&&this.notBefore.getTime()<p&&p<this.notAfter.getTime()}}async getThumbprint(...e){let n,r="SHA-1";return e[0]&&(e[0].subtle?n=e[0]:(r=e[0]||r,n=e[1])),n??(n=$e.get()),await n.subtle.digest(r,this.rawData)}async isSelfSigned(e=$e.get()){return this.subject===this.issuer&&await this.verify({signatureOnly:!0},e)}toTextObject(){const e=this.toTextObjectEmpty(),n=q.parse(this.rawData,zn),r=n.tbsCertificate,i=new pe("",{Version:`${In[r.version]} (${r.version})`,"Serial Number":r.serialNumber,"Signature Algorithm":Bn.serializeAlgorithm(r.signature),Issuer:this.issuer,Validity:new pe("",{"Not Before":r.validity.notBefore.getTime(),"Not After":r.validity.notAfter.getTime()}),Subject:this.subject,"Subject Public Key Info":this.publicKey});if(r.issuerUniqueID&&(i["Issuer Unique ID"]=r.issuerUniqueID),r.subjectUniqueID&&(i["Subject Unique ID"]=r.subjectUniqueID),this.extensions.length){const s=new pe("");for(const a of this.extensions){const c=a.toTextObject();s[c[pe.NAME]]=c}i.Extensions=s}return e.Data=i,e.Signature=new pe("",{Algorithm:Bn.serializeAlgorithm(n.signatureAlgorithm),"":n.signatureValue}),e}}tu.NAME="Certificate";class sw{static async createSelfSigned(e,n=$e.get()){if(!e.keys.privateKey)throw new Error("Bad field 'keys' in 'params' argument. 'privateKey' is empty");if(!e.keys.publicKey)throw new Error("Bad field 'keys' in 'params' argument. 'publicKey' is empty");return this.create({serialNumber:e.serialNumber,subject:e.name,issuer:e.name,notBefore:e.notBefore,notAfter:e.notAfter,publicKey:e.keys.publicKey,signingKey:e.keys.privateKey,signingAlgorithm:e.signingAlgorithm,extensions:e.extensions},n)}static async create(e,n=$e.get()){var r;let i;e.publicKey instanceof ht?i=e.publicKey.rawData:"publicKey"in e.publicKey?i=e.publicKey.publicKey.rawData:M.isBufferSource(e.publicKey)?i=e.publicKey:i=await n.subtle.exportKey("spki",e.publicKey);const s=e.serialNumber?M.toUint8Array(J.FromHex(e.serialNumber)):n.getRandomValues(new Uint8Array(16));s[0]>127&&(s[0]&=127),s.length>1&&s[0]===0&&(s[1]|=128);const a=e.notBefore||new Date,c=e.notAfter||new Date(a.getTime()+31536e6),l=new zn({tbsCertificate:new tt({version:In.v3,serialNumber:s,validity:new ui({notBefore:a,notAfter:c}),extensions:new Qt(((r=e.extensions)===null||r===void 0?void 0:r.map(w=>q.parse(w.rawData,ot)))||[]),subjectPublicKeyInfo:q.parse(i,ft)})});if(e.subject){const w=e.subject instanceof it?e.subject:new it(e.subject);l.tbsCertificate.subject=q.parse(w.toArrayBuffer(),ke)}if(e.issuer){const w=e.issuer instanceof it?e.issuer:new it(e.issuer);l.tbsCertificate.issuer=q.parse(w.toArrayBuffer(),ke)}const u={hash:"SHA-256"},p="signingKey"in e?{...u,...e.signingAlgorithm,...e.signingKey.algorithm}:{...u,...e.signingAlgorithm},h=Pe.resolve(On);l.tbsCertificate.signature=l.signatureAlgorithm=h.toAsnAlgorithm(p);const m=q.serialize(l.tbsCertificate),v="signingKey"in e?await n.subtle.sign(p,e.signingKey,m):e.signature,f=Pe.resolveAll(xi).reverse();let _=null;for(const w of f)if(_=w.toAsnSignature(p,v),_)break;if(!_)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");return l.signatureValue=_,new tu(q.serialize(l))}}var Sp;(function(t){t[t.unspecified=0]="unspecified",t[t.keyCompromise=1]="keyCompromise",t[t.cACompromise=2]="cACompromise",t[t.affiliationChanged=3]="affiliationChanged",t[t.superseded=4]="superseded",t[t.cessationOfOperation=5]="cessationOfOperation",t[t.certificateHold=6]="certificateHold",t[t.removeFromCRL=8]="removeFromCRL",t[t.privilegeWithdrawn=9]="privilegeWithdrawn",t[t.aACompromise=10]="aACompromise"})(Sp||(Sp={}));lt.register(Gh,Yl);lt.register(Yh,Xl);lt.register(Xh,Ql);lt.register(ng,ki);lt.register(qa,Qr);lt.register(tg,Cg);lt.register(Ka,$g);lt.register(Va,Og);Go.register(Sg,Bg);Go.register(Zl,eu);Pe.registerSingleton(xi,rw);Pe.registerSingleton(xi,st);st.namedCurveSize.set("P-256",32);st.namedCurveSize.set("K-256",32);st.namedCurveSize.set("P-384",48);st.namedCurveSize.set("P-521",66);async function Jc(t){const e={name:"RSASSA-PKCS1-v1_5",hash:"SHA-256",publicExponent:new Uint8Array([1,0,1]),modulusLength:2048},n=await crypto.subtle.generateKey(e,!0,["sign","verify"]),r=xe(),i=za(new TextEncoder().encode(r)),s=await sw.createSelfSigned({serialNumber:i,name:t.name,notBefore:new Date,notAfter:new Date(Date.now()+365*24*60*60*1e3),signingAlgorithm:e,keys:n,extensions:[new Yl(!0,2,!0),new Xl(["1.3.6.1.5.5.7.3.1"],!0),new Ql(Ds.keyCertSign|Ds.cRLSign,!0),await ki.create(n.publicKey)]}),a=await crypto.subtle.exportKey("pkcs8",n.privateKey),c=s.toString("pem"),l=await aw(s),u=za(await s.getThumbprint()),p=ow("PRIVATE",a);return{kid:s.serialNumber,cert:c,thumbprint:u,fingerprint:l,pkcs7:p}}function ow(t,e){const n=m_.encode(new Uint8Array(e));let r=`-----BEGIN ${t} KEY-----\r
145
+ `)}}Xe.CertificateTag="CERTIFICATE";Xe.CrlTag="CRL";Xe.CertificateRequestTag="CERTIFICATE REQUEST";Xe.PublicKeyTag="PUBLIC KEY";Xe.PrivateKeyTag="PRIVATE KEY";class qt extends un{static isAsnEncoded(e){return M.isBufferSource(e)||typeof e=="string"}static toArrayBuffer(e){if(typeof e=="string"){if(Xe.isPem(e))return Xe.decode(e)[0];if(J.isHex(e))return J.FromHex(e);if(J.isBase64(e))return J.FromBase64(e);if(J.isBase64Url(e))return J.FromBase64Url(e);throw new TypeError("Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url")}else{const n=J.ToBinary(e);return Xe.isPem(n)?Xe.decode(n)[0]:J.isHex(n)?J.FromHex(n):J.isBase64(n)?J.FromBase64(n):J.isBase64Url(n)?J.FromBase64Url(n):M.toArrayBuffer(e)}}constructor(...e){qt.isAsnEncoded(e[0])?super(qt.toArrayBuffer(e[0]),e[1]):super(e[0])}toString(e="pem"){switch(e){case"pem":return Xe.encode(this.rawData,this.tag);default:return super.toString(e)}}}class ht extends qt{static async create(e,n=$e.get()){if(e instanceof ht)return e;if(Wt.isCryptoKey(e)){if(e.type!=="public")throw new TypeError("Public key is required");const r=await n.subtle.exportKey("spki",e);return new ht(r)}else{if(e.publicKey)return e.publicKey;if(M.isBufferSource(e))return new ht(e);throw new TypeError("Unsupported PublicKeyType")}}constructor(e){qt.isAsnEncoded(e)?super(e,ft):super(e),this.tag=Xe.PublicKeyTag}async export(...e){let n,r=["verify"],i={hash:"SHA-256",...this.algorithm};e.length>1?(i=e[0]||i,r=e[1]||r,n=e[2]||$e.get()):n=e[0]||$e.get();let s=this.rawData;const a=q.parse(this.rawData,ft);return a.algorithm.algorithm===Rr&&(s=iw(a,s)),n.subtle.importKey("spki",s,i,!0,r)}onInit(e){const n=Pe.resolve(On),r=this.algorithm=n.toWebAlgorithm(e.algorithm);switch(e.algorithm.algorithm){case Cn:{const i=q.parse(e.subjectPublicKey,Wl),s=M.toUint8Array(i.modulus);r.publicExponent=M.toUint8Array(i.publicExponent),r.modulusLength=(s[0]?s:s.slice(1)).byteLength<<3;break}}}async getThumbprint(...e){var n;let r,i="SHA-1";return e.length>=1&&!(!((n=e[0])===null||n===void 0)&&n.subtle)?(i=e[0]||i,r=e[1]||$e.get()):r=e[0]||$e.get(),await r.subtle.digest(i,this.rawData)}async getKeyIdentifier(...e){let n,r="SHA-1";e.length===1?typeof e[0]=="string"?(r=e[0],n=$e.get()):n=e[0]:e.length===2?(r=e[0],n=e[1]):n=$e.get();const i=q.parse(this.rawData,ft);return await n.subtle.digest(r,i.subjectPublicKey)}toTextObject(){const e=this.toTextObjectEmpty(),n=q.parse(this.rawData,ft);switch(e.Algorithm=Bn.serializeAlgorithm(n.algorithm),n.algorithm.algorithm){case Wr:e["EC Point"]=n.subjectPublicKey;break;case Cn:default:e["Raw Data"]=n.subjectPublicKey}return e}}function iw(t,e){return t.algorithm=new F({algorithm:Cn,parameters:null}),e=q.serialize(t),e}class Qr extends ct{static async create(e,n=!1,r=$e.get()){if("name"in e&&"serialNumber"in e)return new Qr(e,n);const s=await(await ht.create(e,r)).getKeyIdentifier(r);return new Qr(J.ToHex(s),n)}constructor(...e){if(M.isBufferSource(e[0]))super(e[0]);else if(typeof e[0]=="string"){const n=new vn({keyIdentifier:new zl(J.FromHex(e[0]))});super(qa,e[1],q.serialize(n))}else{const n=e[0],r=n.name instanceof Yr?q.parse(n.name.rawData,qe):n.name,i=new vn({authorityCertIssuer:r,authorityCertSerialNumber:J.FromHex(n.serialNumber)});super(qa,e[1],q.serialize(i))}}onInit(e){super.onInit(e);const n=q.parse(e.extnValue,vn);n.keyIdentifier&&(this.keyId=J.ToHex(n.keyIdentifier)),(n.authorityCertIssuer||n.authorityCertSerialNumber)&&(this.certId={name:n.authorityCertIssuer||[],serialNumber:n.authorityCertSerialNumber?J.ToHex(n.authorityCertSerialNumber):""})}toTextObject(){const e=this.toTextObjectWithoutValue(),n=q.parse(this.value,vn);return n.authorityCertIssuer&&(e["Authority Issuer"]=new Yr(n.authorityCertIssuer).toTextObject()),n.authorityCertSerialNumber&&(e["Authority Serial Number"]=n.authorityCertSerialNumber),n.keyIdentifier&&(e[""]=n.keyIdentifier),e}}Qr.NAME="Authority Key Identifier";class Yl extends ct{constructor(...e){if(M.isBufferSource(e[0])){super(e[0]);const n=q.parse(this.value,fs);this.ca=n.cA,this.pathLength=n.pathLenConstraint}else{const n=new fs({cA:e[0],pathLenConstraint:e[1]});super(Jh,e[2],q.serialize(n)),this.ca=e[0],this.pathLength=e[1]}}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ca&&(e.CA=this.ca),this.pathLength!==void 0&&(e["Path Length"]=this.pathLength),e}}Yl.NAME="Basic Constraints";var kp;(function(t){t.serverAuth="1.3.6.1.5.5.7.3.1",t.clientAuth="1.3.6.1.5.5.7.3.2",t.codeSigning="1.3.6.1.5.5.7.3.3",t.emailProtection="1.3.6.1.5.5.7.3.4",t.timeStamping="1.3.6.1.5.5.7.3.8",t.ocspSigning="1.3.6.1.5.5.7.3.9"})(kp||(kp={}));class Xl extends ct{constructor(...e){if(M.isBufferSource(e[0])){super(e[0]);const n=q.parse(this.value,_s);this.usages=n.map(r=>r)}else{const n=new _s(e[0]);super(Xh,e[1],q.serialize(n)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.usages.map(n=>ln.toString(n)).join(", "),e}}Xl.NAME="Extended Key Usages";var Ds;(function(t){t[t.digitalSignature=1]="digitalSignature",t[t.nonRepudiation=2]="nonRepudiation",t[t.keyEncipherment=4]="keyEncipherment",t[t.dataEncipherment=8]="dataEncipherment",t[t.keyAgreement=16]="keyAgreement",t[t.keyCertSign=32]="keyCertSign",t[t.cRLSign=64]="cRLSign",t[t.encipherOnly=128]="encipherOnly",t[t.decipherOnly=256]="decipherOnly"})(Ds||(Ds={}));class Ql extends ct{constructor(...e){if(M.isBufferSource(e[0])){super(e[0]);const n=q.parse(this.value,ia);this.usages=n.toNumber()}else{const n=new ia(e[0]);super(Qh,e[1],q.serialize(n)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue(),n=q.parse(this.value,ia);return e[""]=n.toJSON().join(", "),e}}Ql.NAME="Key Usages";class ki extends ct{static async create(e,n=!1,r=$e.get()){const s=await(await ht.create(e,r)).getKeyIdentifier(r);return new ki(J.ToHex(s),n)}constructor(...e){if(M.isBufferSource(e[0])){super(e[0]);const n=q.parse(this.value,Zt);this.keyId=J.ToHex(n)}else{const n=typeof e[0]=="string"?J.FromHex(e[0]):e[0],r=new Zt(n);super(rg,e[1],q.serialize(r)),this.keyId=J.ToHex(n)}}toTextObject(){const e=this.toTextObjectWithoutValue(),n=q.parse(this.value,Zt);return e[""]=n,e}}ki.NAME="Subject Key Identifier";class jg extends ct{constructor(...e){M.isBufferSource(e[0])?super(e[0]):super(ng,e[1],new Yr(e[0]||[]).rawData)}onInit(e){super.onInit(e);const n=q.parse(e.extnValue,nc);this.names=new Yr(n)}toTextObject(){const e=this.toTextObjectWithoutValue(),n=this.names.toTextObject();for(const r in n)e[r]=n[r];return e}}jg.NAME="Subject Alternative Name";class lt{static register(e,n){this.items.set(e,n)}static create(e){const n=new ct(e),r=this.items.get(n.type);return r?new r(e):n}}lt.items=new Map;class $g extends ct{constructor(...e){var n;if(M.isBufferSource(e[0])){super(e[0]);const r=q.parse(this.value,gs);this.policies=r.map(i=>i.policyIdentifier)}else{const r=e[0],i=(n=e[1])!==null&&n!==void 0?n:!1,s=new gs(r.map(a=>new Ao({policyIdentifier:a})));super(Zh,i,q.serialize(s)),this.policies=r}}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map(n=>new pe("",{},ln.toString(n))),e}}$g.NAME="Certificate Policies";lt.register(Zh,$g);class Og extends ct{constructor(...e){var n;if(M.isBufferSource(e[0]))super(e[0]);else if(Array.isArray(e[0])&&typeof e[0][0]=="string"){const i=e[0].map(a=>new hr({distributionPoint:new En({fullName:[new re({uniformResourceIdentifier:a})]})})),s=new Wn(i);super(Ka,e[1],q.serialize(s))}else{const r=new Wn(e[0]);super(Ka,e[1],q.serialize(r))}(n=this.distributionPoints)!==null&&n!==void 0||(this.distributionPoints=[])}onInit(e){super.onInit(e);const n=q.parse(e.extnValue,Wn);this.distributionPoints=n}toTextObject(){const e=this.toTextObjectWithoutValue();return e["Distribution Point"]=this.distributionPoints.map(n=>{var r;const i={};return n.distributionPoint&&(i[""]=(r=n.distributionPoint.fullName)===null||r===void 0?void 0:r.map(s=>new Gt(s).toString()).join(", ")),n.reasons&&(i.Reasons=n.reasons.toString()),n.cRLIssuer&&(i["CRL Issuer"]=n.cRLIssuer.map(s=>s.toString()).join(", ")),i}),e}}Og.NAME="CRL Distribution Points";class Bg extends ct{constructor(...e){var n,r,i,s;if(M.isBufferSource(e[0]))super(e[0]);else if(e[0]instanceof Hn){const a=new Hn(e[0]);super(Va,e[1],q.serialize(a))}else{const a=e[0],c=new Hn;Ti(c,a,sd,"ocsp"),Ti(c,a,od,"caIssuers"),Ti(c,a,ad,"timeStamping"),Ti(c,a,cd,"caRepository"),super(Va,e[1],q.serialize(c))}(n=this.ocsp)!==null&&n!==void 0||(this.ocsp=[]),(r=this.caIssuers)!==null&&r!==void 0||(this.caIssuers=[]),(i=this.timeStamping)!==null&&i!==void 0||(this.timeStamping=[]),(s=this.caRepository)!==null&&s!==void 0||(this.caRepository=[])}onInit(e){super.onInit(e),this.ocsp=[],this.caIssuers=[],this.timeStamping=[],this.caRepository=[],q.parse(e.extnValue,Hn).forEach(r=>{switch(r.accessMethod){case sd:this.ocsp.push(new Gt(r.accessLocation));break;case od:this.caIssuers.push(new Gt(r.accessLocation));break;case ad:this.timeStamping.push(new Gt(r.accessLocation));break;case cd:this.caRepository.push(new Gt(r.accessLocation));break}})}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ocsp.length&&Bi(e,"OCSP",this.ocsp),this.caIssuers.length&&Bi(e,"CA Issuers",this.caIssuers),this.timeStamping.length&&Bi(e,"Time Stamping",this.timeStamping),this.caRepository.length&&Bi(e,"CA Repository",this.caRepository),e}}Bg.NAME="Authority Info Access";function Bi(t,e,n){if(n.length===1)t[e]=n[0].toTextObject();else{const r=new pe("");n.forEach((i,s)=>{const a=i.toTextObject(),c=`${a[pe.NAME]} ${s+1}`;let l=r[c];Array.isArray(l)||(l=[],r[c]=l),l.push(a)}),t[e]=r}}function Ti(t,e,n,r){const i=e[r];i&&(Array.isArray(i)?i:[i]).forEach(a=>{typeof a=="string"&&(a=new Gt("url",a)),t.push(new li({accessMethod:n,accessLocation:q.parse(a.rawData,re)}))})}class br extends un{constructor(...e){let n;if(M.isBufferSource(e[0]))n=M.toArrayBuffer(e[0]);else{const r=e[0],i=Array.isArray(e[1])?e[1].map(s=>M.toArrayBuffer(s)):[];n=q.serialize(new Lt({type:r,values:i}))}super(n,Lt)}onInit(e){this.type=e.type,this.values=e.values}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Value=this.values.map(n=>new pe("",{"":n})),e}toTextObjectWithoutValue(){const e=this.toTextObjectEmpty();return e[pe.NAME]===br.NAME&&(e[pe.NAME]=ln.toString(this.type)),e}}br.NAME="Attribute";class Tg extends br{constructor(...e){var n;if(M.isBufferSource(e[0]))super(e[0]);else{const r=new qs({printableString:e[0]});super(Ag,[q.serialize(r)])}(n=this.password)!==null&&n!==void 0||(this.password="")}onInit(e){if(super.onInit(e),this.values[0]){const n=q.parse(this.values[0],qs);this.password=n.toString()}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[pe.VALUE]=this.password,e}}Tg.NAME="Challenge Password";class eu extends br{constructor(...e){var n;if(M.isBufferSource(e[0]))super(e[0]);else{const r=e[0],i=new en;for(const s of r)i.push(q.parse(s.rawData,ot));super(Zl,[q.serialize(i)])}(n=this.items)!==null&&n!==void 0||(this.items=[])}onInit(e){if(super.onInit(e),this.values[0]){const n=q.parse(this.values[0],en);this.items=n.map(r=>lt.create(q.serialize(r)))}}toTextObject(){const e=this.toTextObjectWithoutValue(),n=this.items.map(r=>r.toTextObject());for(const r of n)e[r[pe.NAME]]=r;return e}}eu.NAME="Extensions";class Go{static register(e,n){this.items.set(e,n)}static create(e){const n=new br(e),r=this.items.get(n.type);return r?new r(e):n}}Go.items=new Map;const xi="crypto.signatureFormatter";class sw{toAsnSignature(e,n){return M.toArrayBuffer(n)}toWebSignature(e,n){return M.toArrayBuffer(n)}}var Di;let Kc=Di=class{static createPssParams(e,n){const r=Di.getHashAlgorithm(e);return r?new $n({hashAlgorithm:r,maskGenAlgorithm:new F({algorithm:Uo,parameters:q.serialize(r)}),saltLength:n}):null}static getHashAlgorithm(e){const n=Pe.resolve(On);return typeof e=="string"?n.toAsnAlgorithm({name:e}):typeof e=="object"&&e&&"name"in e?n.toAsnAlgorithm(e):null}toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"rsassa-pkcs1-v1_5":if("hash"in e){let n;if(typeof e.hash=="string")n=e.hash;else if(e.hash&&typeof e.hash=="object"&&"name"in e.hash&&typeof e.hash.name=="string")n=e.hash.name.toUpperCase();else throw new Error("Cannot get hash algorithm name");switch(n.toLowerCase()){case"sha-1":return new F({algorithm:js,parameters:null});case"sha-256":return new F({algorithm:xc,parameters:null});case"sha-384":return new F({algorithm:$s,parameters:null});case"sha-512":return new F({algorithm:Os,parameters:null})}}else return new F({algorithm:Cn,parameters:null});break;case"rsa-pss":if("hash"in e){if(!("saltLength"in e&&typeof e.saltLength=="number"))throw new Error("Cannot get 'saltLength' from 'alg' argument");const n=Di.createPssParams(e.hash,e.saltLength);if(!n)throw new Error("Cannot create PSS parameters");return new F({algorithm:Rr,parameters:q.serialize(n)})}else return new F({algorithm:Rr,parameters:null})}return null}toWebAlgorithm(e){switch(e.algorithm){case Cn:return{name:"RSASSA-PKCS1-v1_5"};case js:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case xc:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case $s:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case Os:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}};case Rr:if(e.parameters){const n=q.parse(e.parameters,$n);return{name:"RSA-PSS",hash:Pe.resolve(On).toWebAlgorithm(n.hashAlgorithm),saltLength:n.saltLength}}else return{name:"RSA-PSS"}}return null}};Kc=Di=d([Do()],Kc);Pe.registerSingleton(bi,Kc);let Wc=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"sha-1":return new F({algorithm:Bs});case"sha-256":return new F({algorithm:Ts});case"sha-384":return new F({algorithm:Ps});case"sha-512":return new F({algorithm:Rs})}return null}toWebAlgorithm(e){switch(e.algorithm){case Bs:return{name:"SHA-1"};case Ts:return{name:"SHA-256"};case Ps:return{name:"SHA-384"};case Rs:return{name:"SHA-512"}}return null}};Wc=d([Do()],Wc);Pe.registerSingleton(bi,Wc);class st{addPadding(e,n){const r=M.toUint8Array(n),i=new Uint8Array(e);return i.set(r,e-r.length),i}removePadding(e,n=!1){let r=M.toUint8Array(e);for(let i=0;i<r.length;i++)if(r[i]){r=r.slice(i);break}if(n&&r[0]>127){const i=new Uint8Array(r.length+1);return i.set(r,1),i.buffer}return r.buffer}toAsnSignature(e,n){if(e.name==="ECDSA"){const r=e.namedCurve,i=st.namedCurveSize.get(r)||st.defaultNamedCurveSize,s=new Cs,a=M.toUint8Array(n);return s.r=this.removePadding(a.slice(0,i),!0),s.s=this.removePadding(a.slice(i,i+i),!0),q.serialize(s)}return null}toWebSignature(e,n){if(e.name==="ECDSA"){const r=q.parse(n,Cs),i=e.namedCurve,s=st.namedCurveSize.get(i)||st.defaultNamedCurveSize,a=this.addPadding(s,this.removePadding(r.r)),c=this.addPadding(s,this.removePadding(r.s));return yy(a,c)}return null}}st.namedCurveSize=new Map;st.defaultNamedCurveSize=32;const pa="1.3.101.110",xp="1.3.101.111",fa="1.3.101.112",Sp="1.3.101.113";let Gc=class{toAsnAlgorithm(e){let n=null;switch(e.name.toLowerCase()){case"ed25519":n=fa;break;case"x25519":n=pa;break;case"eddsa":switch(e.namedCurve.toLowerCase()){case"ed25519":n=fa;break;case"ed448":n=Sp;break}break;case"ecdh-es":switch(e.namedCurve.toLowerCase()){case"x25519":n=pa;break;case"x448":n=xp;break}}return n?new F({algorithm:n}):null}toWebAlgorithm(e){switch(e.algorithm){case fa:return{name:"Ed25519"};case Sp:return{name:"EdDSA",namedCurve:"Ed448"};case pa:return{name:"X25519"};case xp:return{name:"ECDH-ES",namedCurve:"X448"}}return null}};Gc=d([Do()],Gc);Pe.registerSingleton(bi,Gc);class ow extends qt{constructor(e){qt.isAsnEncoded(e)?super(e,Jr):super(e),this.tag=Xe.CertificateRequestTag}onInit(e){this.tbs=q.serialize(e.certificationRequestInfo),this.publicKey=new ht(e.certificationRequestInfo.subjectPKInfo);const n=Pe.resolve(On);this.signatureAlgorithm=n.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signature,this.attributes=e.certificationRequestInfo.attributes.map(i=>Go.create(q.serialize(i)));const r=this.getAttribute(Zl);this.extensions=[],r instanceof eu&&(this.extensions=r.items),this.subjectName=new it(e.certificationRequestInfo.subject),this.subject=this.subjectName.toString()}getAttribute(e){for(const n of this.attributes)if(n.type===e)return n;return null}getAttributes(e){return this.attributes.filter(n=>n.type===e)}getExtension(e){for(const n of this.extensions)if(n.type===e)return n;return null}getExtensions(e){return this.extensions.filter(n=>n.type===e)}async verify(e=$e.get()){const n={...this.publicKey.algorithm,...this.signatureAlgorithm},r=await this.publicKey.export(n,["verify"],e),i=Pe.resolveAll(xi).reverse();let s=null;for(const c of i)if(s=c.toWebSignature(n,this.signature),s)break;if(!s)throw Error("Cannot convert WebCrypto signature value to ASN.1 format");return await e.subtle.verify(this.signatureAlgorithm,r,s,this.tbs)}toTextObject(){const e=this.toTextObjectEmpty(),n=q.parse(this.rawData,Jr),r=n.certificationRequestInfo,i=new pe("",{Version:`${In[r.version]} (${r.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){const s=new pe("");for(const a of this.attributes){const c=a.toTextObject();s[c[pe.NAME]]=c}i.Attributes=s}return e.Data=i,e.Signature=new pe("",{Algorithm:Bn.serializeAlgorithm(n.signatureAlgorithm),"":n.signature}),e}}ow.NAME="PKCS#10 Certificate Request";class tu extends qt{constructor(e){qt.isAsnEncoded(e)?super(e,zn):super(e),this.tag=Xe.CertificateTag}onInit(e){const n=e.tbsCertificate;this.tbs=q.serialize(n),this.serialNumber=J.ToHex(n.serialNumber),this.subjectName=new it(n.subject),this.subject=new it(n.subject).toString(),this.issuerName=new it(n.issuer),this.issuer=this.issuerName.toString();const r=Pe.resolve(On);this.signatureAlgorithm=r.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signatureValue;const i=n.validity.notBefore.utcTime||n.validity.notBefore.generalTime;if(!i)throw new Error("Cannot get 'notBefore' value");this.notBefore=i;const s=n.validity.notAfter.utcTime||n.validity.notAfter.generalTime;if(!s)throw new Error("Cannot get 'notAfter' value");this.notAfter=s,this.extensions=[],n.extensions&&(this.extensions=n.extensions.map(a=>lt.create(q.serialize(a)))),this.publicKey=new ht(n.subjectPublicKeyInfo)}getExtension(e){for(const n of this.extensions)if(typeof e=="string"){if(n.type===e)return n}else if(n instanceof e)return n;return null}getExtensions(e){return this.extensions.filter(n=>typeof e=="string"?n.type===e:n instanceof e)}async verify(e={},n=$e.get()){let r,i;const s=e.publicKey;try{if(!s)r={...this.publicKey.algorithm,...this.signatureAlgorithm},i=await this.publicKey.export(r,["verify"],n);else if("publicKey"in s)r={...s.publicKey.algorithm,...this.signatureAlgorithm},i=await s.publicKey.export(r,["verify"],n);else if(s instanceof ht)r={...s.algorithm,...this.signatureAlgorithm},i=await s.export(r,["verify"],n);else if(M.isBufferSource(s)){const u=new ht(s);r={...u.algorithm,...this.signatureAlgorithm},i=await u.export(r,["verify"],n)}else r={...s.algorithm,...this.signatureAlgorithm},i=s}catch{return!1}const a=Pe.resolveAll(xi).reverse();let c=null;for(const u of a)if(c=u.toWebSignature(r,this.signature),c)break;if(!c)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");const l=await n.subtle.verify(this.signatureAlgorithm,i,c,this.tbs);if(e.signatureOnly)return l;{const p=(e.date||new Date).getTime();return l&&this.notBefore.getTime()<p&&p<this.notAfter.getTime()}}async getThumbprint(...e){let n,r="SHA-1";return e[0]&&(e[0].subtle?n=e[0]:(r=e[0]||r,n=e[1])),n??(n=$e.get()),await n.subtle.digest(r,this.rawData)}async isSelfSigned(e=$e.get()){return this.subject===this.issuer&&await this.verify({signatureOnly:!0},e)}toTextObject(){const e=this.toTextObjectEmpty(),n=q.parse(this.rawData,zn),r=n.tbsCertificate,i=new pe("",{Version:`${In[r.version]} (${r.version})`,"Serial Number":r.serialNumber,"Signature Algorithm":Bn.serializeAlgorithm(r.signature),Issuer:this.issuer,Validity:new pe("",{"Not Before":r.validity.notBefore.getTime(),"Not After":r.validity.notAfter.getTime()}),Subject:this.subject,"Subject Public Key Info":this.publicKey});if(r.issuerUniqueID&&(i["Issuer Unique ID"]=r.issuerUniqueID),r.subjectUniqueID&&(i["Subject Unique ID"]=r.subjectUniqueID),this.extensions.length){const s=new pe("");for(const a of this.extensions){const c=a.toTextObject();s[c[pe.NAME]]=c}i.Extensions=s}return e.Data=i,e.Signature=new pe("",{Algorithm:Bn.serializeAlgorithm(n.signatureAlgorithm),"":n.signatureValue}),e}}tu.NAME="Certificate";class aw{static async createSelfSigned(e,n=$e.get()){if(!e.keys.privateKey)throw new Error("Bad field 'keys' in 'params' argument. 'privateKey' is empty");if(!e.keys.publicKey)throw new Error("Bad field 'keys' in 'params' argument. 'publicKey' is empty");return this.create({serialNumber:e.serialNumber,subject:e.name,issuer:e.name,notBefore:e.notBefore,notAfter:e.notAfter,publicKey:e.keys.publicKey,signingKey:e.keys.privateKey,signingAlgorithm:e.signingAlgorithm,extensions:e.extensions},n)}static async create(e,n=$e.get()){var r;let i;e.publicKey instanceof ht?i=e.publicKey.rawData:"publicKey"in e.publicKey?i=e.publicKey.publicKey.rawData:M.isBufferSource(e.publicKey)?i=e.publicKey:i=await n.subtle.exportKey("spki",e.publicKey);const s=e.serialNumber?M.toUint8Array(J.FromHex(e.serialNumber)):n.getRandomValues(new Uint8Array(16));s[0]>127&&(s[0]&=127),s.length>1&&s[0]===0&&(s[1]|=128);const a=e.notBefore||new Date,c=e.notAfter||new Date(a.getTime()+31536e6),l=new zn({tbsCertificate:new tt({version:In.v3,serialNumber:s,validity:new ui({notBefore:a,notAfter:c}),extensions:new en(((r=e.extensions)===null||r===void 0?void 0:r.map(w=>q.parse(w.rawData,ot)))||[]),subjectPublicKeyInfo:q.parse(i,ft)})});if(e.subject){const w=e.subject instanceof it?e.subject:new it(e.subject);l.tbsCertificate.subject=q.parse(w.toArrayBuffer(),ke)}if(e.issuer){const w=e.issuer instanceof it?e.issuer:new it(e.issuer);l.tbsCertificate.issuer=q.parse(w.toArrayBuffer(),ke)}const u={hash:"SHA-256"},p="signingKey"in e?{...u,...e.signingAlgorithm,...e.signingKey.algorithm}:{...u,...e.signingAlgorithm},h=Pe.resolve(On);l.tbsCertificate.signature=l.signatureAlgorithm=h.toAsnAlgorithm(p);const m=q.serialize(l.tbsCertificate),v="signingKey"in e?await n.subtle.sign(p,e.signingKey,m):e.signature,f=Pe.resolveAll(xi).reverse();let _=null;for(const w of f)if(_=w.toAsnSignature(p,v),_)break;if(!_)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");return l.signatureValue=_,new tu(q.serialize(l))}}var Ap;(function(t){t[t.unspecified=0]="unspecified",t[t.keyCompromise=1]="keyCompromise",t[t.cACompromise=2]="cACompromise",t[t.affiliationChanged=3]="affiliationChanged",t[t.superseded=4]="superseded",t[t.cessationOfOperation=5]="cessationOfOperation",t[t.certificateHold=6]="certificateHold",t[t.removeFromCRL=8]="removeFromCRL",t[t.privilegeWithdrawn=9]="privilegeWithdrawn",t[t.aACompromise=10]="aACompromise"})(Ap||(Ap={}));lt.register(Jh,Yl);lt.register(Xh,Xl);lt.register(Qh,Ql);lt.register(rg,ki);lt.register(qa,Qr);lt.register(ng,jg);lt.register(Ka,Og);lt.register(Va,Bg);Go.register(Ag,Tg);Go.register(Zl,eu);Pe.registerSingleton(xi,sw);Pe.registerSingleton(xi,st);st.namedCurveSize.set("P-256",32);st.namedCurveSize.set("K-256",32);st.namedCurveSize.set("P-384",48);st.namedCurveSize.set("P-521",66);async function Jc(t){const e={name:"RSASSA-PKCS1-v1_5",hash:"SHA-256",publicExponent:new Uint8Array([1,0,1]),modulusLength:2048},n=await crypto.subtle.generateKey(e,!0,["sign","verify"]),r=xe(),i=za(new TextEncoder().encode(r)),s=await aw.createSelfSigned({serialNumber:i,name:t.name,notBefore:new Date,notAfter:new Date(Date.now()+365*24*60*60*1e3),signingAlgorithm:e,keys:n,extensions:[new Yl(!0,2,!0),new Xl(["1.3.6.1.5.5.7.3.1"],!0),new Ql(Ds.keyCertSign|Ds.cRLSign,!0),await ki.create(n.publicKey)]}),a=await crypto.subtle.exportKey("pkcs8",n.privateKey),c=s.toString("pem"),l=await lw(s),u=za(await s.getThumbprint()),p=cw("PRIVATE",a);return{kid:s.serialNumber,cert:c,thumbprint:u,fingerprint:l,pkcs7:p}}function cw(t,e){const n=y_.encode(new Uint8Array(e));let r=`-----BEGIN ${t} KEY-----\r
146
146
  `,i=0;for(;i<n.length;)i+64<=n.length?r+=n.substr(i,64)+`\r
147
147
  `:r+=n.substr(i)+`\r
148
148
  `,i+=64;return r+=`-----END ${t} KEY-----\r
149
- `,r}async function aw(t){const e=await t.publicKey.export(),n=await crypto.subtle.exportKey("jwk",e),r=JSON.stringify(n,Object.keys(n).sort()),s=new TextEncoder().encode(r);return za(await Nf(s))}const cw=1e3*60*60*24,lw=new o.OpenAPIHono().openapi(o.createRoute({tags:["keys"],method:"get",path:"/signing",request:{headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:o.z.array(Ia)}},description:"List of keys"}}}),async t=>{const n=(await t.env.data.keys.list()).filter(r=>"cert"in r).map(r=>r);return t.json(n)}).openapi(o.createRoute({tags:["keys"],method:"get",path:"/signing/{kid}",request:{headers:o.z.object({"tenant-id":o.z.string()}),params:o.z.object({kid:o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Ia}},description:"The requested key"}}}),async t=>{const{kid:e}=t.req.valid("param"),r=(await t.env.data.keys.list()).find(i=>i.kid===e);if(!r)throw new z(404,{message:"Key not found"});return t.json(r)}).openapi(o.createRoute({tags:["keys"],method:"post",path:"/signing/rotate",request:{headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{description:"Status"}}}),async t=>{const e=await t.env.data.keys.list();for await(const r of e)await t.env.data.keys.update(r.kid,{revoked_at:new Date(Date.now()+cw).toISOString()});const n=await Jc({name:`CN=${t.env.ORGANIZATION_NAME}`});return await t.env.data.keys.create(n),t.text("OK",{status:201})}).openapi(o.createRoute({tags:["keys"],method:"put",path:"/signing/{kid}/revoke",request:{headers:o.z.object({"tenant-id":o.z.string()}),params:o.z.object({kid:o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{description:"Status"}}}),async t=>{const{kid:e}=t.req.valid("param");if(!await t.env.data.keys.update(e,{revoked_at:new Date().toISOString()}))throw new z(404,{message:"Key not found"});const r=await Jc({name:`CN=${t.env.ORGANIZATION_NAME}`});return await t.env.data.keys.create(r),t.text("OK")}),uw=new o.OpenAPIHono().openapi(o.createRoute({tags:["users"],method:"get",path:"/",request:{query:o.z.object({email:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:o.z.array(el)}},description:"List of users"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{email:n}=t.req.valid("query"),i=(await pl(t.env.data.users,e,n)).filter(s=>!s.linked_to);return t.json(i)}),dw=nn.extend({clients:o.z.array(mn)}),pw=new o.OpenAPIHono().openapi(o.createRoute({tags:["clients"],method:"get",path:"/",request:{query:Xt,headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:o.z.union([dw,o.z.array(mn)])}},description:"List of clients"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{page:n,per_page:r,include_totals:i,sort:s,q:a}=t.req.valid("query"),l=(await t.env.data.applications.list(e,{page:n,per_page:r,include_totals:i,sort:dr(s),q:a})).applications;return i?t.json({clients:l,start:0,limit:10,length:l.length}):t.json(l)}).openapi(o.createRoute({tags:["clients"],method:"get",path:"/{id}",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:mn}},description:"An application"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),i=(await t.env.data.applications.list(e,{page:1,per_page:0,include_totals:!1})).applications.find(s=>s.id===n);if(!i)throw new z(404);return t.json(i)}).openapi(o.createRoute({tags:["clients"],method:"delete",path:"/{id}",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param");if(!await t.env.data.applications.remove(e,n))throw new z(404,{message:"Application not found"});return t.text("OK")}).openapi(o.createRoute({tags:["clients"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:o.z.object(ns.shape).partial()}}},params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:mn}},description:"The update application"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),i=t.req.valid("json");await t.env.data.applications.update(e,n,i);const s=await t.env.data.applications.get(e,n);if(!s)throw new z(404,{message:"Application not found"});return t.json(s)}).openapi(o.createRoute({tags:["clients"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:o.z.object(ns.shape)}}},headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:o.z.object(mn.shape)}},description:"An application"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),r={...n,id:n.id||xe(),client_secret:n.client_secret||xe()},i=await t.env.data.applications.create(e,r);return t.json(i,{status:201})});o.z.object({start:o.z.number(),limit:o.z.number(),length:o.z.number()});Js.extend({email:o.z.string(),login_count:o.z.number(),multifactor:o.z.array(o.z.string()).optional(),last_ip:o.z.string().optional(),last_login:o.z.string().optional(),user_id:o.z.string()}).catchall(o.z.any());const fw=nn.extend({tenants:o.z.array(Fn)}),hw=new o.OpenAPIHono().openapi(o.createRoute({tags:["tenants"],method:"get",path:"/",request:{query:Xt},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:o.z.union([o.z.array(Fn),fw])}},description:"List of tenants"}}}),async t=>{const{page:e,per_page:n,include_totals:r,sort:i,q:s}=t.req.valid("query"),a=await t.env.data.tenants.list({page:e,per_page:n,include_totals:r,sort:dr(i),q:s});return r?t.json(a):t.json(a.tenants)}).openapi(o.createRoute({tags:["tenants"],method:"get",path:"/{id}",request:{params:o.z.object({id:o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:Fn}},description:"A tenant"}}}),async t=>{const{id:e}=t.req.valid("param"),n=await t.env.data.tenants.get(e);if(!n)throw new z(404);return t.json(n)}).openapi(o.createRoute({tags:["tenants"],method:"delete",path:"/{id}",request:{params:o.z.object({id:o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{const{id:e}=t.req.valid("param");return await t.env.data.tenants.remove(e),t.text("OK")}).openapi(o.createRoute({tags:["tenants"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:o.z.object(is.shape).partial()}}},params:o.z.object({id:o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{const{id:e}=t.req.valid("param"),n=t.req.valid("json");return await t.env.data.tenants.update(e,n),t.text("OK")}).openapi(o.createRoute({tags:["tenants"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:o.z.object(is.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"tenant/json":{schema:Fn}},description:"An tenant"}}}),async t=>{const e=t.req.valid("json"),n=await t.env.data.tenants.create(e);return t.json(n,{status:201})}),gw=nn.extend({logs:o.z.array(os)}),mw=new o.OpenAPIHono().openapi(o.createRoute({tags:["logs"],method:"get",path:"/",request:{query:Xt,headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:o.z.union([o.z.array(os),gw])}},description:"List of log rows"}}}),async t=>{const{page:e,per_page:n,include_totals:r,sort:i,q:s}=t.req.valid("query"),{"tenant-id":a}=t.req.valid("header"),c=await t.env.data.logs.list(a,{page:e,per_page:n,include_totals:r,sort:dr(i),q:s});return r?t.json(c):t.json(c.logs)}).openapi(o.createRoute({tags:["logs"],method:"get",path:"/{id}",request:{headers:o.z.object({"tenant-id":o.z.string()}),params:o.z.object({id:o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:os}},description:"A log entry"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),r=await t.env.data.logs.get(e,n);if(!r)throw new z(404);return t.json(r)}),_w=nn.extend({hooks:o.z.array(Dn)}),yw=new o.OpenAPIHono().openapi(o.createRoute({tags:["hooks"],method:"get",path:"/",request:{query:Xt,headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:o.z.union([o.z.array(Dn),_w])}},description:"List of hooks"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{page:n,per_page:r,include_totals:i,sort:s,q:a}=t.req.valid("query"),c=await t.env.data.hooks.list(e,{page:n,per_page:r,include_totals:i,sort:dr(s),q:a});return i?t.json(c):t.json(c.hooks)}).openapi(o.createRoute({tags:["hooks"],method:"post",path:"/",request:{headers:o.z.object({"tenant-id":o.z.string()}),body:{content:{"application/json":{schema:o.z.object(ss.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Dn}},description:"The created hook"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),r=await t.env.data.hooks.create(e,n);return t.json(r,{status:201})}).openapi(o.createRoute({tags:["hooks"],method:"patch",path:"/{hook_id}",request:{headers:o.z.object({"tenant-id":o.z.string()}),params:o.z.object({hook_id:o.z.string()}),body:{content:{"application/json":{schema:o.z.object(ss.shape).omit({hook_id:!0}).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Dn.shape}},description:"The updated hook"},404:{description:"Hook not found"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{hook_id:n}=t.req.valid("param"),r=t.req.valid("json");await t.env.data.hooks.update(e,n,r);const i=await t.env.data.hooks.get(e,n);if(!i)throw new z(404,{message:"Hook not found"});return t.json(i)}).openapi(o.createRoute({tags:["hooks"],method:"get",path:"/{hook_id}",request:{headers:o.z.object({"tenant-id":o.z.string()}),params:o.z.object({hook_id:o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Dn}},description:"A hook"},404:{description:"Hook not found"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{hook_id:n}=t.req.valid("param"),r=await t.env.data.hooks.get(e,n);if(!r)throw new z(404,{message:"Hook not found"});return t.json(r)}).openapi(o.createRoute({tags:["hooks"],method:"delete",path:"/{hook_id}",request:{headers:o.z.object({"tenant-id":o.z.string()}),params:o.z.object({hook_id:o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{description:"A hook"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{hook_id:n}=t.req.valid("param");if(!await t.env.data.hooks.remove(e,n))throw new z(404,{message:"Hook not found"});return t.text("OK")}),vw=nn.extend({connections:o.z.array(Ft)}),ww=new o.OpenAPIHono().openapi(o.createRoute({tags:["connections"],method:"get",path:"/",request:{query:Xt,headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:o.z.union([o.z.array(Ft),vw])}},description:"List of connectionss"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{page:n,per_page:r,include_totals:i=!1,sort:s,q:a}=t.req.valid("query"),c=await t.env.data.connections.list(e,{page:n,per_page:r,include_totals:i,sort:dr(s),q:a});return i?t.json(c):t.json(c.connections)}).openapi(o.createRoute({tags:["connections"],method:"get",path:"/{id}",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Ft}},description:"A connection"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),r=await t.env.data.connections.get(e,n);if(!r)throw new z(404);return t.json(r)}).openapi(o.createRoute({tags:["connections"],method:"delete",path:"/{id}",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param");if(!await t.env.data.connections.remove(e,n))throw new z(404,{message:"Connection not found"});return t.text("OK")}).openapi(o.createRoute({tags:["connections"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:o.z.object(rs.shape).partial()}}},params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Ft}},description:"The updated connection"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),r=t.req.valid("json");if(!await t.env.data.connections.update(e,n,r))throw new z(404,{message:"Connection not found"});const s=await t.env.data.connections.get(e,n);if(!s)throw new z(404,{message:"Connection not found"});return t.json(s)}).openapi(o.createRoute({tags:["connections"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:o.z.object(rs.shape)}}},headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Ft}},description:"A connection"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),r=await t.env.data.connections.create(e,n);return t.json(r,{status:201})}),bw=new o.OpenAPIHono().openapi(o.createRoute({tags:["prompts"],method:"get",path:"/",request:{headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Li}},description:"Branding settings"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=await t.env.data.promptSettings.get(e);return n?t.json(n):t.json(Li.parse({}))}).openapi(o.createRoute({tags:["prompts"],method:"patch",path:"/",request:{headers:o.z.object({"tenant-id":o.z.string()}),body:{content:{"application/json":{schema:o.z.object(Li.shape).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Prompts settings"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),r=await t.env.data.promptSettings.get(e);return Object.assign(r,n),await t.env.data.promptSettings.set(e,r),t.json(r)});let Ap=!1;function Tg(t){t.use(async(e,n)=>(Ap||(t.openAPIRegistry.registerComponent("securitySchemes","Bearer",{type:"oauth2",scheme:"bearer",flows:{implicit:{authorizationUrl:`${e.env.AUTH_URL}/authorize`,scopes:{openid:"Basic user information",email:"User email",profile:"User profile information"}}}}),Ap=!0),await n()))}o.z.object({alg:o.z.literal("RS256"),kty:o.z.literal("RSA"),use:o.z.literal("sig"),n:o.z.string(),e:o.z.string(),kid:o.z.string(),x5t:o.z.string(),x5c:o.z.array(o.z.string())});async function kw(t){try{const e=await t.JWKS_SERVICE.fetch(t.JWKS_URL);if(!e.ok)throw new Error("Failed to fetch jwks");return(await e.json()).keys}catch(e){throw new z(500,{message:`Failed to fetch jwks: ${e.message}`})}}async function xw(t,e){const r=new TextEncoder().encode([e.raw.header,e.raw.payload].join(".")),i=new Uint8Array(Array.from(e.signature).map(l=>l.charCodeAt(0))),a=(await kw(t.env)).find(l=>l.kid===e.header.kid);if(!a)return console.log("No matching kid found"),!1;const c=await crypto.subtle.importKey("jwk",a,{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},!1,["verify"]);return crypto.subtle.verify("RSASSA-PKCS1-v1_5",c,i,r)}function Sw(t){const[e,n,r]=t.split(".");if(!e||!n||!r)return null;const i=JSON.parse(atob(e)),s=JSON.parse(atob(n)),a=atob(r.replace(/-/g,"+").replace(/_/g,"/"));return{header:i,payload:s,signature:a,raw:{header:e,payload:n,signature:r}}}function Pg(t){return async(e,n)=>{var i,s,a;const r=t.openAPIRegistry.definitions.find(c=>"route"in c&&c.route.path===e.req.path&&c.route.method.toUpperCase()===e.req.method);if(r&&"route"in r){const c=(s=(i=r.route.security)==null?void 0:i[0])==null?void 0:s.Bearer;if(!(c!=null&&c.length))return await n();const l=e.req.header("authorization")||"",[u,p]=l.split(" ");if((u==null?void 0:u.toLowerCase())!=="bearer"||!p)throw new z(401,{message:"Missing bearer token"});const h=Sw(p);if(!h||!await xw(e,h))throw new z(403,{message:"Invalid JWT signature"});e.set("user_id",h.payload.sub),e.set("user",h.payload);const m=h.payload.permissions||[],v=((a=h.payload.scope)==null?void 0:a.split(" "))||[];if(c.length&&!(c.some(f=>m.includes(f))||c.some(f=>v.includes(f))))throw new z(403,{message:"Unauthorized"})}return await n()}}const Aw=new o.OpenAPIHono().openapi(o.createRoute({tags:["emails"],method:"get",path:"/",request:{headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Ui}},description:"Email provider"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=await t.env.data.emailProviders.get(e);if(!n)throw new z(404,{message:"Email provider not found"});return t.json(n)}).openapi(o.createRoute({tags:["emails"],method:"post",path:"/",request:{headers:o.z.object({"tenant-id":o.z.string()}),body:{content:{"application/json":{schema:o.z.object(Ui.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Branding settings"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json");return await t.env.data.emailProviders.create(e,n),t.text("OK",{status:201})}).openapi(o.createRoute({tags:["emails"],method:"patch",path:"/",request:{headers:o.z.object({"tenant-id":o.z.string()}),body:{content:{"application/json":{schema:o.z.object(Ui.shape).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Branding settings"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json");return await t.env.data.emailProviders.update(e,n),t.text("OK")}),Ew=new o.OpenAPIHono().openapi(o.createRoute({tags:["sessions"],method:"get",path:"/{id}",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Ys}},description:"A session"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),r=await t.env.data.sessions.get(e,n);if(!r)throw new z(404);return t.json(r)}).openapi(o.createRoute({tags:["sessions"],method:"delete",path:"/{id}",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param");if(!await t.env.data.sessions.remove(e,n))throw new z(404,{message:"Session not found"});return t.text("OK")}).openapi(o.createRoute({tags:["sessions"],method:"post",path:"/{id}/revoke",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{202:{description:"Sesssion deletion status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param");if(!await t.env.data.sessions.update(e,n,{revoked_at:new Date().toDateString()}))throw new z(404,{message:"Session not found"});return t.text("Session deletion request accepted.",{status:202})}),Iw=new o.OpenAPIHono().openapi(o.createRoute({tags:["refresh_tokens"],method:"get",path:"/{id}",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:il}},description:"A session"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),r=await t.env.data.refreshTokens.get(e,n);if(!r)throw new z(404);return t.json(r)}).openapi(o.createRoute({tags:["refresh_tokens"],method:"delete",path:"/{id}",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param");if(!await t.env.data.refreshTokens.remove(e,n))throw new z(404,{message:"Session not found"});return t.text("OK")}),zw=new o.OpenAPIHono().openapi(o.createRoute({tags:["custom-domains"],method:"get",path:"/",request:{query:Xt,headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:o.z.array(fn)}},description:"List of custom domains"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=await t.env.data.customDomains.list(e);return t.json(n)}).openapi(o.createRoute({tags:["custom-domains"],method:"get",path:"/{id}",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:fn}},description:"A connection"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),r=await t.env.data.customDomains.get(e,n);if(!r)throw new z(404);return t.json(r)}).openapi(o.createRoute({tags:["custom-domains"],method:"delete",path:"/{id}",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param");if(!await t.env.data.customDomains.remove(e,n))throw new z(404,{message:"Custom domain not found"});return t.text("OK")}).openapi(o.createRoute({tags:["custom-domains"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:o.z.object(fn.shape).partial()}}},params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:fn}},description:"The updated custom domain"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),r=t.req.valid("json");if(!await t.env.data.customDomains.update(e,n,r))throw new z(404);const s=await t.env.data.customDomains.get(e,n);if(!s)throw new z(404);return t.json(s)}).openapi(o.createRoute({tags:["custom-domains"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:o.z.object(nl.shape)}}},headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:fn}},description:"The created custom domain"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),r=await t.env.data.customDomains.create(e,n);return t.json(r,{status:201})}).openapi(o.createRoute({tags:["custom-domains"],method:"post",path:"/{id}/verify",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:fn}},description:"The custom domain"}}}),async()=>{throw new z(501,{message:"Not implemented"})});function Nw(t){const e=new o.OpenAPIHono;Tg(e),e.use(async(r,i)=>(r.env.data=no(r,t.dataAdapter),i())),e.use(Pg(e));const n=e.route("/branding",n_).route("/custom-domains",zw).route("/email/providers",Aw).route("/users",dy).route("/keys",lw).route("/users-by-email",uw).route("/clients",pw).route("/tenants",hw).route("/logs",mw).route("/hooks",yw).route("/connections",ww).route("/prompts",bw).route("/sessions",Ew).route("/refresh_tokens",Iw);return n.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Management api"},security:[{oauth2:["openid","email","profile"]}]}),n}function Cw(t,e){Object.keys(e).forEach(n=>{const r=e[n];r!=null&&r.length&&t.searchParams.set(n,r)})}var Ep;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(Ep||(Ep={}));var Ip;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(Ip||(Ip={}));function jw(t){return Lg(t,$w,ei.Include)}function Rg(t){return Lg(t,Ow,ei.None)}function Lg(t,e,n){let r="";for(let i=0;i<t.byteLength;i+=3){let s=0,a=0;for(let c=0;c<3&&i+c<t.byteLength;c++)s=s<<8|t[i+c],a+=8;for(let c=0;c<4;c++)a>=6?(r+=e[s>>a-6&63],a-=6):a>0?(r+=e[s<<6-a&63],a=0):n===ei.Include&&(r+="=")}return r}const $w="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ow="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";var ei;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(ei||(ei={}));var zp;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(zp||(zp={}));class Bw{uint8(e,n){if(e.byteLength<n+1)throw new TypeError("Insufficient bytes");return e[n]}uint16(e,n){if(e.byteLength<n+2)throw new TypeError("Insufficient bytes");return e[n]<<8|e[n+1]}uint32(e,n){if(e.byteLength<n+4)throw new TypeError("Insufficient bytes");let r=0;for(let i=0;i<4;i++)r|=e[n+i]<<24-i*8;return r}uint64(e,n){if(e.byteLength<n+8)throw new TypeError("Insufficient bytes");let r=0n;for(let i=0;i<8;i++)r|=BigInt(e[n+i])<<BigInt(56-i*8);return r}putUint8(e,n,r){if(e.length<r+1)throw new TypeError("Not enough space");if(n<0||n>255)throw new TypeError("Invalid uint8 value");e[r]=n}putUint16(e,n,r){if(e.length<r+2)throw new TypeError("Not enough space");if(n<0||n>65535)throw new TypeError("Invalid uint16 value");e[r]=n>>8,e[r+1]=n&255}putUint32(e,n,r){if(e.length<r+4)throw new TypeError("Not enough space");if(n<0||n>4294967295)throw new TypeError("Invalid uint32 value");for(let i=0;i<4;i++)e[r+i]=n>>(3-i)*8&255}putUint64(e,n,r){if(e.length<r+8)throw new TypeError("Not enough space");if(n<0||n>18446744073709551615n)throw new TypeError("Invalid uint64 value");for(let i=0;i<8;i++)e[r+i]=Number(n>>BigInt((7-i)*8)&0xffn)}}const Np=new Bw;function kt(t,e){return(t<<32-e|t>>>e)>>>0}function Tw(t){const e=new Pw;return e.update(t),e.digest()}class Pw{constructor(){te(this,"blockSize",64);te(this,"size",32);te(this,"blocks",new Uint8Array(64));te(this,"currentBlockSize",0);te(this,"H",new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]));te(this,"l",0n);te(this,"w",new Uint32Array(64))}update(e){if(this.l+=BigInt(e.byteLength)*8n,this.currentBlockSize+e.byteLength<64){this.blocks.set(e,this.currentBlockSize),this.currentBlockSize+=e.byteLength;return}let n=0;if(this.currentBlockSize>0){const r=e.slice(0,64-this.currentBlockSize);this.blocks.set(r,this.currentBlockSize),this.process(),n+=r.byteLength,this.currentBlockSize=0}for(;n+64<=e.byteLength;){const r=e.slice(n,n+64);this.blocks.set(r),this.process(),n+=64}if(e.byteLength-n>0){const r=e.slice(n);this.blocks.set(r),this.currentBlockSize=r.byteLength}}digest(){this.blocks[this.currentBlockSize]=128,this.currentBlockSize+=1,64-this.currentBlockSize<8&&(this.blocks.fill(0,this.currentBlockSize),this.process(),this.currentBlockSize=0),this.blocks.fill(0,this.currentBlockSize),Np.putUint64(this.blocks,this.l,this.blockSize-8),this.process();const e=new Uint8Array(32);for(let n=0;n<8;n++)Np.putUint32(e,this.H[n],n*4);return e}process(){for(let u=0;u<16;u++)this.w[u]=(this.blocks[u*4]<<24|this.blocks[u*4+1]<<16|this.blocks[u*4+2]<<8|this.blocks[u*4+3])>>>0;for(let u=16;u<64;u++){const p=(kt(this.w[u-2],17)^kt(this.w[u-2],19)^this.w[u-2]>>>10)>>>0,h=(kt(this.w[u-15],7)^kt(this.w[u-15],18)^this.w[u-15]>>>3)>>>0;this.w[u]=p+this.w[u-7]+h+this.w[u-16]|0}let e=this.H[0],n=this.H[1],r=this.H[2],i=this.H[3],s=this.H[4],a=this.H[5],c=this.H[6],l=this.H[7];for(let u=0;u<64;u++){const p=(kt(s,6)^kt(s,11)^kt(s,25))>>>0,h=(s&a^~s&c)>>>0,m=l+p+h+Rw[u]+this.w[u]|0,v=(kt(e,2)^kt(e,13)^kt(e,22))>>>0,f=(e&n^e&r^n&r)>>>0,_=v+f|0;l=c,c=a,a=s,s=i+m|0,i=r,r=n,n=e,e=m+_|0}this.H[0]=e+this.H[0]|0,this.H[1]=n+this.H[1]|0,this.H[2]=r+this.H[2]|0,this.H[3]=i+this.H[3]|0,this.H[4]=s+this.H[4]|0,this.H[5]=a+this.H[5]|0,this.H[6]=c+this.H[6]|0,this.H[7]=l+this.H[7]|0}}const Rw=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);new BigUint64Array([0x428a2f98d728ae22n,0x7137449123ef65cdn,0xb5c0fbcfec4d3b2fn,0xe9b5dba58189dbbcn,0x3956c25bf348b538n,0x59f111f1b605d019n,0x923f82a4af194f9bn,0xab1c5ed5da6d8118n,0xd807aa98a3030242n,0x12835b0145706fben,0x243185be4ee4b28cn,0x550c7dc3d5ffb4e2n,0x72be5d74f27b896fn,0x80deb1fe3b1696b1n,0x9bdc06a725c71235n,0xc19bf174cf692694n,0xe49b69c19ef14ad2n,0xefbe4786384f25e3n,0x0fc19dc68b8cd5b5n,0x240ca1cc77ac9c65n,0x2de92c6f592b0275n,0x4a7484aa6ea6e483n,0x5cb0a9dcbd41fbd4n,0x76f988da831153b5n,0x983e5152ee66dfabn,0xa831c66d2db43210n,0xb00327c898fb213fn,0xbf597fc7beef0ee4n,0xc6e00bf33da88fc2n,0xd5a79147930aa725n,0x06ca6351e003826fn,0x142929670a0e6e70n,0x27b70a8546d22ffcn,0x2e1b21385c26c926n,0x4d2c6dfc5ac42aedn,0x53380d139d95b3dfn,0x650a73548baf63den,0x766a0abb3c77b2a8n,0x81c2c92e47edaee6n,0x92722c851482353bn,0xa2bfe8a14cf10364n,0xa81a664bbc423001n,0xc24b8b70d0f89791n,0xc76c51a30654be30n,0xd192e819d6ef5218n,0xd69906245565a910n,0xf40e35855771202an,0x106aa07032bbd1b8n,0x19a4c116b8d2d0c8n,0x1e376c085141ab53n,0x2748774cdf8eeb99n,0x34b0bcb5e19b48a8n,0x391c0cb3c5c95a63n,0x4ed8aa4ae3418acbn,0x5b9cca4f7763e373n,0x682e6ff3d6b2b8a3n,0x748f82ee5defb2fcn,0x78a5636f43172f60n,0x84c87814a1f0ab72n,0x8cc702081a6439ecn,0x90befffa23631e28n,0xa4506cebde82bde9n,0xbef9a3f7b2c67915n,0xc67178f2e372532bn,0xca273eceea26619cn,0xd186b8c721c0c207n,0xeada7dd6cde0eb1en,0xf57d4f7fee6ed178n,0x06f067aa72176fban,0x0a637dc5a2c898a6n,0x113f9804bef90daen,0x1b710b35131c471bn,0x28db77f523047d84n,0x32caab7b40c72493n,0x3c9ebe0a15c9bebcn,0x431d67c49c100d4cn,0x4cc5d4becb3e42b6n,0x597f299cfc657e2an,0x5fcb6fab3ad6faecn,0x6c44198c4a475817n]);class Lw{constructor(e){te(this,"data");this.data=e}tokenType(){if("token_type"in this.data&&typeof this.data.token_type=="string")return this.data.token_type;throw new Error("Missing or invalid 'token_type' field")}accessToken(){if("access_token"in this.data&&typeof this.data.access_token=="string")return this.data.access_token;throw new Error("Missing or invalid 'access_token' field")}accessTokenExpiresInSeconds(){if("expires_in"in this.data&&typeof this.data.expires_in=="number")return this.data.expires_in;throw new Error("Missing or invalid 'expires_in' field")}accessTokenExpiresAt(){return new Date(Date.now()+this.accessTokenExpiresInSeconds()*1e3)}hasRefreshToken(){return"refresh_token"in this.data&&typeof this.data.refresh_token=="string"}refreshToken(){if("refresh_token"in this.data&&typeof this.data.refresh_token=="string")return this.data.refresh_token;throw new Error("Missing or invalid 'refresh_token' field")}hasScopes(){return"scope"in this.data&&typeof this.data.scope=="string"}scopes(){if("scope"in this.data&&typeof this.data.scope=="string")return this.data.scope.split(" ");throw new Error("Missing or invalid 'scope' field")}idToken(){if("id_token"in this.data&&typeof this.data.id_token=="string")return this.data.id_token;throw new Error("Missing or invalid field 'id_token'")}}function Uw(t){const e=Tw(new TextEncoder().encode(t));return Rg(e)}function Vw(){const t=new Uint8Array(32);return crypto.getRandomValues(t),Rg(t)}function Ur(t,e){const n=new TextEncoder().encode(e.toString()),r=new Request(t,{method:"POST",body:n});return r.headers.set("Content-Type","application/x-www-form-urlencoded"),r.headers.set("Accept","application/json"),r.headers.set("User-Agent","arctic"),r.headers.set("Content-Length",n.byteLength.toString()),r}function ha(t,e){const n=new TextEncoder().encode(`${t}:${e}`);return jw(n)}async function Hs(t){let e;try{e=await fetch(t)}catch(n){throw new Vg(n)}if(e.status===400||e.status===401){let n;try{n=await e.json()}catch{throw new Hi(e.status)}if(typeof n!="object"||n===null)throw new Gn(e.status,n);let r;try{r=Ug(n)}catch{throw new Gn(e.status,n)}throw r}if(e.status===200){let n;try{n=await e.json()}catch{throw new Hi(e.status)}if(typeof n!="object"||n===null)throw new Gn(e.status,n);return new Lw(n)}throw e.body!==null&&await e.body.cancel(),new Hi(e.status)}async function qw(t){let e;try{e=await fetch(t)}catch(n){throw new Vg(n)}if(e.status===400||e.status===401){let n;try{n=await e.json()}catch{throw new Gn(e.status,null)}if(typeof n!="object"||n===null)throw new Gn(e.status,n);let r;try{r=Ug(n)}catch{throw new Gn(e.status,n)}throw r}if(e.status===200){e.body!==null&&await e.body.cancel();return}throw e.body!==null&&await e.body.cancel(),new Hi(e.status)}function Ug(t){let e;if("error"in t&&typeof t.error=="string")e=t.error;else throw new Error("Invalid error response");let n=null,r=null,i=null;if("error_description"in t){if(typeof t.error_description!="string")throw new Error("Invalid data");n=t.error_description}if("error_uri"in t){if(typeof t.error_uri!="string")throw new Error("Invalid data");r=t.error_uri}if("state"in t){if(typeof t.state!="string")throw new Error("Invalid data");i=t.state}return new Mw(e,n,r,i)}class Vg extends Error{constructor(e){super("Failed to send request",{cause:e})}}class Mw extends Error{constructor(n,r,i,s){super(`OAuth request error: ${n}`);te(this,"code");te(this,"description");te(this,"uri");te(this,"state");this.code=n,this.description=r,this.uri=i,this.state=s}}class Hi extends Error{constructor(n){super("Unexpected error response");te(this,"status");this.status=n}}class Gn extends Error{constructor(n,r){super("Unexpected error response body");te(this,"status");te(this,"data");this.status=n,this.data=r}}class nu{constructor(e,n,r){te(this,"clientId");te(this,"clientPassword");te(this,"redirectURI");this.clientId=e,this.clientPassword=n,this.redirectURI=r}createAuthorizationURL(e,n,r){const i=new URL(e);return i.searchParams.set("response_type","code"),i.searchParams.set("client_id",this.clientId),this.redirectURI!==null&&i.searchParams.set("redirect_uri",this.redirectURI),i.searchParams.set("state",n),r.length>0&&i.searchParams.set("scope",r.join(" ")),i}createAuthorizationURLWithPKCE(e,n,r,i,s){const a=new URL(e);if(a.searchParams.set("response_type","code"),a.searchParams.set("client_id",this.clientId),this.redirectURI!==null&&a.searchParams.set("redirect_uri",this.redirectURI),a.searchParams.set("state",n),r===ti.S256){const c=Uw(i);a.searchParams.set("code_challenge_method","S256"),a.searchParams.set("code_challenge",c)}else r===ti.Plain&&(a.searchParams.set("code_challenge_method","plain"),a.searchParams.set("code_challenge",i));return s.length>0&&a.searchParams.set("scope",s.join(" ")),a}async validateAuthorizationCode(e,n,r){const i=new URLSearchParams;i.set("grant_type","authorization_code"),i.set("code",n),this.redirectURI!==null&&i.set("redirect_uri",this.redirectURI),r!==null&&i.set("code_verifier",r),this.clientPassword===null&&i.set("client_id",this.clientId);const s=Ur(e,i);if(this.clientPassword!==null){const c=ha(this.clientId,this.clientPassword);s.headers.set("Authorization",`Basic ${c}`)}return await Hs(s)}async refreshAccessToken(e,n,r){const i=new URLSearchParams;i.set("grant_type","refresh_token"),i.set("refresh_token",n),this.clientPassword===null&&i.set("client_id",this.clientId),r.length>0&&i.set("scope",r.join(" "));const s=Ur(e,i);if(this.clientPassword!==null){const c=ha(this.clientId,this.clientPassword);s.headers.set("Authorization",`Basic ${c}`)}return await Hs(s)}async revokeToken(e,n){const r=new URLSearchParams;r.set("token",n),this.clientPassword===null&&r.set("client_id",this.clientId);const i=Ur(e,r);if(this.clientPassword!==null){const s=ha(this.clientId,this.clientPassword);i.headers.set("Authorization",`Basic ${s}`)}await qw(i)}}var ti;(function(t){t[t.S256=0]="S256",t[t.Plain=1]="Plain"})(ti||(ti={}));var Cp;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(Cp||(Cp={}));var jp;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(jp||(jp={}));function Vr(t){return Dw(t,Hw,Fs.None)}function Dw(t,e,n){let r="";for(let i=0;i<t.byteLength;i+=3){let s=0,a=0;for(let c=0;c<3&&i+c<t.byteLength;c++)s=s<<8|t[i+c],a+=8;for(let c=0;c<4;c++)a>=6?(r+=e[s>>a-6&63],a-=6):a>0?(r+=e[s<<6-a&63],a=0):n===Fs.Include&&(r+="=")}return r}const Hw="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";var Fs;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(Fs||(Fs={}));var $p;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})($p||($p={}));function Fw(t,e,n){const r=Vr(new TextEncoder().encode(t)),i=Vr(new TextEncoder().encode(e)),s=Vr(n);return r+"."+i+"."+s}function Kw(t,e){const n=Vr(new TextEncoder().encode(t)),r=Vr(new TextEncoder().encode(e)),i=n+"."+r;return new TextEncoder().encode(i)}const Ww="https://appleid.apple.com/auth/authorize",Gw="https://appleid.apple.com/auth/token";class qg{constructor(e,n,r,i,s){te(this,"clientId");te(this,"teamId");te(this,"keyId");te(this,"pkcs8PrivateKey");te(this,"redirectURI");this.clientId=e,this.teamId=n,this.keyId=r,this.pkcs8PrivateKey=i,this.redirectURI=s}createAuthorizationURL(e,n){const r=new URL(Ww);return r.searchParams.set("response_type","code"),r.searchParams.set("client_id",this.clientId),r.searchParams.set("state",e),n.length>0&&r.searchParams.set("scope",n.join(" ")),r.searchParams.set("redirect_uri",this.redirectURI),r}async validateAuthorizationCode(e){const n=new URLSearchParams;n.set("grant_type","authorization_code"),n.set("code",e),n.set("redirect_uri",this.redirectURI),n.set("client_id",this.clientId);const r=await this.createClientSecret();n.set("client_secret",r);const i=Ur(Gw,n);return await Hs(i)}async createClientSecret(){const e=await crypto.subtle.importKey("pkcs8",this.pkcs8PrivateKey,{name:"ECDSA",namedCurve:"P-256"},!1,["sign"]),n=Math.floor(Date.now()/1e3),r=JSON.stringify({typ:"JWT",alg:"ES256",kid:this.keyId}),i=JSON.stringify({iss:this.teamId,exp:n+5*60,aud:["https://appleid.apple.com"],sub:this.clientId,iat:n}),s=new Uint8Array(await crypto.subtle.sign({name:"ECDSA",hash:"SHA-256"},e,Kw(r,i)));return Fw(r,i,s)}}const Jw="https://www.facebook.com/v16.0/dialog/oauth",Zw="https://graph.facebook.com/v16.0/oauth/access_token";class Mg{constructor(e,n,r){te(this,"clientId");te(this,"clientSecret");te(this,"redirectURI");this.clientId=e,this.clientSecret=n,this.redirectURI=r}createAuthorizationURL(e,n){const r=new URL(Jw);return r.searchParams.set("response_type","code"),r.searchParams.set("client_id",this.clientId),r.searchParams.set("state",e),n.length>0&&r.searchParams.set("scope",n.join(" ")),r.searchParams.set("redirect_uri",this.redirectURI),r}async validateAuthorizationCode(e){const n=new URLSearchParams;n.set("grant_type","authorization_code"),n.set("code",e),n.set("redirect_uri",this.redirectURI),n.set("client_id",this.clientId),n.set("client_secret",this.clientSecret);const r=Ur(Zw,n);return await Hs(r)}}const Yw="https://accounts.google.com/o/oauth2/v2/auth",Op="https://oauth2.googleapis.com/token",Xw="https://oauth2.googleapis.com/revoke";let Dg=class{constructor(e,n,r){te(this,"client");this.client=new nu(e,n,r)}createAuthorizationURL(e,n,r){return this.client.createAuthorizationURLWithPKCE(Yw,e,ti.S256,n,r)}async validateAuthorizationCode(e,n){return await this.client.validateAuthorizationCode(Op,e,n)}async refreshAccessToken(e){return await this.client.refreshAccessToken(Op,e,[])}async revokeToken(e){await this.client.revokeToken(Xw,e)}};const Jo=o.z.object({iss:o.z.string().url(),sub:o.z.string(),aud:o.z.string(),exp:o.z.number(),email:o.z.string().optional(),given_name:o.z.string().optional(),family_name:o.z.string().optional(),name:o.z.string().optional(),iat:o.z.number(),auth_time:o.z.number().optional(),nonce:o.z.string().optional(),acr:o.z.string().optional(),amr:o.z.array(o.z.string()).optional(),azp:o.z.string().optional(),at_hash:o.z.string().optional(),c_hash:o.z.string().optional()}).passthrough();Jo.omit({iat:!0,auth_time:!0,nonce:!0,acr:!0,amr:!0,azp:!0,at_hash:!0,c_hash:!0});function Qw(t){return t.ISSUER}function _t(t){return t.UNIVERSAL_LOGIN_URL||`${t.ISSUER}u/`}function je(t){return t.OAUTH_API_URL||t.ISSUER}function Hg(t){const{options:e}=t;if(!e||!e.client_id||!e.team_id||!e.kid||!e.app_secret)throw new Error("Missing required Apple authentication parameters");const n=Buffer.from(e.app_secret,"utf-8"),r=n.toString().replace(/-----BEGIN PRIVATE KEY-----|-----END PRIVATE KEY-----|\s/g,""),i=Uint8Array.from(Buffer.from(r,"base64"));return n.fill(0),{options:e,keyArray:i}}async function eb(t,e){var l,u;const{options:n,keyArray:r}=Hg(e),i=new qg(n.client_id,n.team_id,n.kid,r,`${je(t.env)}callback`),s=xe(),a=await i.createAuthorizationURL(s,((l=n.scope)==null?void 0:l.split(" "))||["name","email"]);return(((u=n.scope)==null?void 0:u.split(" "))||["name","email"]).some(p=>["email","name"].includes(p))&&a.searchParams.set("response_mode","form_post"),{redirectUrl:a.href,code:s}}async function tb(t,e,n){const{options:r,keyArray:i}=Hg(e),a=await new qg(r.client_id,r.team_id,r.kid,i,`${je(t.env)}callback`).validateAuthorizationCode(n),c=ol(a.idToken());if(!c)throw new Error("Invalid ID token");const l=Jo.parse(c.payload);return{sub:l.sub,email:l.email,given_name:l.given_name,family_name:l.family_name,name:l.name,picture:l.picture,locale:l.locale}}const nb=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:eb,validateAuthorizationCodeAndGetUser:tb},Symbol.toStringTag,{value:"Module"}));async function rb(t,e){var a;const{options:n}=e;if(!(n!=null&&n.client_id)||!n.client_secret)throw new Error("Missing required authentication parameters");const r=new Mg(n.client_id,n.client_secret,`${je(t.env)}callback`),i=xe();return{redirectUrl:r.createAuthorizationURL(i,((a=n.scope)==null?void 0:a.split(" "))||["email"]).href,code:i}}async function ib(t,e,n){const{options:r}=e;if(!(r!=null&&r.client_id)||!r.client_secret)throw new Error("Missing required authentication parameters");const s=await new Mg(r.client_id,r.client_secret,`${je(t.env)}callback`).validateAuthorizationCode(n),a=await fetch("https://graph.facebook.com/v16.0/me?fields=id,email,name",{headers:{Authorization:`Bearer ${s.accessToken()}`}});if(!a.ok)throw new Error("Failed to fetch user info");const c=await a.json();return t.set("log",`Userinfo: ${JSON.stringify(c)}`),{sub:c.id,email:c.email,name:c.name}}const sb=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:rb,validateAuthorizationCodeAndGetUser:ib},Symbol.toStringTag,{value:"Module"}));async function ob(t,e){var c;const{options:n}=e;if(!(n!=null&&n.client_id)||!n.client_secret)throw new Error("Missing required Google authentication parameters");const r=new Dg(n.client_id,n.client_secret,`${je(t.env)}callback`),i=xe(),s=Vw();return{redirectUrl:r.createAuthorizationURL(i,s,((c=n.scope)==null?void 0:c.split(" "))??["email","profile"]).href,code:i,codeVerifier:s}}async function ab(t,e,n,r){const{options:i}=e;if(!(i!=null&&i.client_id)||!i.client_secret||!r)throw new Error("Missing required authentication parameters");const a=await new Dg(i.client_id,i.client_secret,`${je(t.env)}callback`).validateAuthorizationCode(n,r),c=ol(a.idToken());if(!c)throw new Error("Invalid ID token");const l=Jo.parse(c.payload);return{sub:l.sub,email:l.email,given_name:l.given_name,family_name:l.family_name,name:l.name,picture:l.picture,locale:l.locale}}const cb=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:ob,validateAuthorizationCodeAndGetUser:ab},Symbol.toStringTag,{value:"Module"}));async function lb(t,e){var a;const{options:n}=e;if(!(n!=null&&n.client_id)||!n.client_secret)throw new Error("Missing required authentication parameters");const r=new nu(n.client_id,n.client_secret,`${je(t.env)}callback`),i=xe(),s=r.createAuthorizationURL("https://api.vipps.no/access-management-1.0/access/oauth2/auth",i,((a=n.scope)==null?void 0:a.split(" "))||["openid","email","phoneNumber","name","address","birthDate"]);return s.searchParams.set("response_type","code"),s.searchParams.set("response_mode","query"),{redirectUrl:s.href,code:i}}async function ub(t,e,n){const{options:r}=e;if(!(r!=null&&r.client_id)||!r.client_secret)throw new Error("Missing required authentication parameters");const s=await new nu(r.client_id,r.client_secret,`${je(t.env)}callback`).validateAuthorizationCode("https://api.vipps.no/access-management-1.0/access/oauth2/token",n,null),a=ol(s.idToken());if(!a)throw new Error("Invalid ID token");const c=Jo.parse(a.payload);if(typeof c.msn!="string")throw new Error("msn not available in id token");const l=await fetch("https://api.vipps.no/vipps-userinfo-api/userinfo",{headers:{Authorization:`Bearer ${s.accessToken()}`,"Merchant-Serial-Number":c.msn}});if(!l.ok)throw new z(400,{message:"Failed to get user from vipps"});return await l.json()}const db=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:lb,validateAuthorizationCodeAndGetUser:ub},Symbol.toStringTag,{value:"Module"}));function Fg(t,e){const n=t.env.STRATEGIES||{},i={apple:nb,facebook:sb,"google-oauth2":cb,vipps:db,...n}[e];if(!i)throw new Error(`Strategy ${e} not found`);return i}async function Zo(t,e){const n=await t.data.clients.get(e);if(!n)throw new z(403,{message:"Client not found"});const r=t.DEFAULT_CLIENT_ID?await t.data.clients.get(t.DEFAULT_CLIENT_ID):void 0,i=await t.data.connections.list(n.tenant.id),s=t.DEFAULT_TENANT_ID?await t.data.connections.list(t.DEFAULT_TENANT_ID):{connections:[]},a=i.connections.map(c=>{var p;const l=(p=s.connections)==null?void 0:p.find(h=>h.name===c.name);return l!=null&&l.options?Ft.parse({...l||{},...c,options:{...l.options||{},...c.options}}):c}).filter(c=>c);return{...n,web_origins:[...(r==null?void 0:r.web_origins)||[],...n.web_origins||[],`${_t(t)}login`],allowed_logout_urls:[...(r==null?void 0:r.allowed_logout_urls)||[],...n.allowed_logout_urls||[],t.ISSUER],callbacks:[...(r==null?void 0:r.callbacks)||[],...n.callbacks||[],`${_t(t)}info`],connections:a,tenant:{...(r==null?void 0:r.tenant)||{},...n.tenant}}}function Yo(t,e=[],n={}){try{const r=new URL(t);return e.some(i=>{try{return pb(r,new URL(i),n.allowPathWildcards)}catch{return!1}})}catch{return!1}}function pb(t,e,n){if(t.protocol!==e.protocol)return!1;if(n&&e.pathname.includes("*")){const r=e.pathname.replace(/\*/g,".*").replace(/\//g,"\\/");if(!new RegExp(`^${r}$`).test(t.pathname))return!1}else if(t.pathname!==e.pathname)return!1;if(e.hostname.startsWith("*.")&&e.hostname.split(".").length>2&&["http:","https:"].includes(e.protocol)){const r=e.hostname.split(".").slice(1).join(".");return t.hostname.endsWith(r)}return t.hostname===e.hostname}async function fb(t,e,n,r){if(!r.state)throw new z(400,{message:"State not found"});const i=e.connections.find(l=>l.name===n);if(!i){t.set("client_id",e.id);const l=ve(t,{type:he.FAILED_LOGIN,description:"Connection not found"});throw await t.env.data.logs.create(e.tenant.id,l),new z(403,{message:"Connection Not Found"})}let s=await t.env.data.loginSessions.get(e.tenant.id,r.state);s||(s=await t.env.data.loginSessions.create(e.tenant.id,{expires_at:new Date(Date.now()+Jn*1e3).toISOString(),authParams:r,csrf_token:xe(),...sn(t.req)}));const c=await Fg(t,i.strategy).getRedirect(t,i);return await t.env.data.codes.create(e.tenant.id,{login_id:s.id,code_id:c.code,code_type:"oauth2_state",connection_id:i.id,code_verifier:c.codeVerifier,expires_at:new Date(Date.now()+I_*1e3).toISOString()}),t.redirect(c.redirectUrl)}async function Bp(t,{code:e,state:n}){var f;const{env:r}=t,i=await r.data.codes.get(t.var.tenant_id||"",n,"oauth2_state");if(!i||!i.connection_id)throw new z(403,{message:"State not found"});const s=await r.data.loginSessions.get(t.var.tenant_id||"",i.login_id);if(!s)throw new z(403,{message:"Session not found"});const a=await Zo(r,s.authParams.client_id);t.set("client_id",a.id),t.set("tenant_id",a.tenant.id);const c=a.connections.find(_=>_.id===i.connection_id);if(!c){const _=ve(t,{type:he.FAILED_LOGIN,description:"Connection not found"});throw await r.data.logs.create(a.tenant.id,_),new z(403,{message:"Connection not found"})}if(t.set("connection",c.name),!s.authParams.redirect_uri){const _=ve(t,{type:he.FAILED_LOGIN,description:"Redirect URI not defined"});throw await r.data.logs.create(a.tenant.id,_),new z(403,{message:"Redirect URI not defined"})}if(!Yo(s.authParams.redirect_uri,a.callbacks||[],{allowPathWildcards:!0})){const _=`Invalid redirect URI - ${s.authParams.redirect_uri}`,w=ve(t,{type:he.FAILED_LOGIN,description:_});throw await r.data.logs.create(a.tenant.id,w),new z(403,{message:_})}const u=await Fg(t,c.strategy).validateAuthorizationCodeAndGetUser(t,c,e,i.code_verifier),{sub:p,...h}=u;t.set("user_id",p);const m=((f=u.email)==null?void 0:f.toLocaleLowerCase())||`${c.name}.${p}@${new URL(t.env.ISSUER).hostname}`;t.set("username",m);const v=await io(t,{client:a,email:m,provider:c.strategy,connection:c.name,userId:p,profileData:h,isSocial:!0,ip:t.req.header("x-real-ip")});return on(t,{client:a,authParams:s.authParams,loginSession:s,user:v})}async function Tp(t,e,n,r,i,s){const a=await t.env.data.codes.get(t.var.tenant_id||"",e,"oauth2_state");if(!a)throw new z(400,{message:"State not found"});const c=await t.env.data.loginSessions.get(t.var.tenant_id,a.login_id);if(!c)throw new z(400,{message:"Login not found"});const{redirect_uri:l}=c.authParams;if(!l)throw new z(400,{message:"Redirect uri not found"});const u=ve(t,{type:he.FAILED_LOGIN,description:`Failed connection login: ${i} ${n}, ${r}`});nt(t,t.env.data.logs.create(t.var.tenant_id,u));const p=new URL(l);return Cw(p,{error:n,error_description:r,error_reason:s,error_code:i,state:c.authParams.state}),t.redirect(`${_t(t.env)}enter-email?state=${c.id}&error=${n}`)}const hb=new o.OpenAPIHono().openapi(o.createRoute({tags:["oauth2"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string(),code:o.z.string().optional(),scope:o.z.string().optional(),hd:o.z.string().optional(),error:o.z.string().optional(),error_description:o.z.string().optional(),error_code:o.z.string().optional(),error_reason:o.z.string().optional()})},responses:{302:{description:"Redirect to the client's redirect uri"}}}),async t=>{const{state:e,code:n,error:r,error_description:i,error_code:s,error_reason:a}=t.req.valid("query");if(r)return Tp(t,e,r,i,s,a);if(!n)throw new z(400,{message:"Code is required"});return Bp(t,{code:n,state:e})}).openapi(o.createRoute({tags:["oauth2"],method:"post",path:"/",request:{body:{content:{"application/x-www-form-urlencoded":{schema:o.z.object({state:o.z.string(),code:o.z.string().optional(),scope:o.z.string().optional(),hd:o.z.string().optional(),error:o.z.string().optional(),error_description:o.z.string().optional(),error_code:o.z.string().optional(),error_reason:o.z.string().optional()})}}}},responses:{302:{description:"Redirect to the client's redirect uri"}}}),async t=>{const{state:e,code:n,error:r,error_description:i,error_code:s,error_reason:a}=t.req.valid("form");if(r)return Tp(t,e,r,i,s,a);if(!n)throw new z(400,{message:"Code is required"});return Bp(t,{code:n,state:e})}),gb=new o.OpenAPIHono().openapi(o.createRoute({tags:["oauth2"],method:"get",path:"/",request:{query:o.z.object({client_id:o.z.string(),returnTo:o.z.string().optional()}),header:o.z.object({cookie:o.z.string().optional()})},responses:{302:{description:"Log the user out"}}}),async t=>{const{client_id:e,returnTo:n}=t.req.valid("query"),r=await t.env.data.clients.get(e);if(!r)return t.text("OK");const i=await t.env.data.clients.get("DEFAULT_CLIENT");t.set("client_id",e),t.set("tenant_id",r.tenant.id);const s=n||t.req.header("referer");if(!s)return t.text("OK");if(!Yo(s,[...r.allowed_logout_urls||[],...(i==null?void 0:i.allowed_logout_urls)||[]],{allowPathWildcards:!0}))throw new z(400,{message:"Invalid redirect uri"});const a=t.req.header("cookie");if(a){const l=cs(r.tenant.id,a);if(l){const u=await t.env.data.sessions.get(r.tenant.id,l);if(u){const p=await t.env.data.users.get(r.tenant.id,u.user_id);p&&(t.set("user_id",p.user_id),t.set("connection",p.connection));const h=await t.env.data.refreshTokens.list(r.tenant.id,{q:`session_id=${l}`,page:0,per_page:100,include_totals:!1});await Promise.all(h.refresh_tokens.map(m=>t.env.data.refreshTokens.remove(r.tenant.id,m.id))),await t.env.data.sessions.update(r.tenant.id,l,{revoked_at:new Date().toISOString()})}}}const c=ve(t,{type:he.SUCCESS_LOGOUT,description:"User successfully logged out"});return await t.env.data.logs.create(r.tenant.id,c),new Response("Redirecting",{status:302,headers:{"set-cookie":$_(r.tenant.id,t.req.header("host")),location:s}})}),Pp=o.z.object({sub:o.z.string(),email:o.z.string().optional(),family_name:o.z.string().optional(),given_name:o.z.string().optional(),email_verified:o.z.boolean()}),mb=new o.OpenAPIHono().openapi(o.createRoute({tags:["oauth2"],method:"get",path:"/",request:{},security:[{Bearer:["openid"]}],responses:{200:{content:{"application/json":{schema:Pp}},description:"Userinfo"}}}),async t=>{if(!t.var.user)throw new z(404,{message:"User not found"});const e=await t.env.data.users.get(t.var.user.tenant_id,t.var.user.sub);if(!e)throw new z(404,{message:"User not found"});return t.json(Pp.parse({...e,sub:e.user_id}))}),_b=new o.OpenAPIHono().openapi(o.createRoute({tags:["well known"],method:"get",path:"/jwks.json",request:{},responses:{200:{content:{"application/json":{schema:hf}},description:"List of tenants"}}}),async t=>{const e=await t.env.data.keys.list(),n=await Promise.all(e.map(async r=>{const s=await new tu(r.cert).publicKey.export(),a=await crypto.subtle.exportKey("jwk",s);return rl.parse({...a,kid:r.kid})}));return t.json({keys:n},{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${ji}, stale-while-revalidate=${ji*2}, stale-if-error=86400`}})}).openapi(o.createRoute({tags:["well known"],method:"get",path:"/openid-configuration",request:{},responses:{200:{content:{"application/json":{schema:Ea}},description:"List of tenants"}}}),async t=>{const e=Ea.parse({issuer:Qw(t.env),authorization_endpoint:`${je(t.env)}authorize`,token_endpoint:`${je(t.env)}oauth/token`,device_authorization_endpoint:`${je(t.env)}oauth/device/code`,userinfo_endpoint:`${je(t.env)}userinfo`,mfa_challenge_endpoint:`${je(t.env)}mfa/challenge`,jwks_uri:`${je(t.env)}.well-known/jwks.json`,registration_endpoint:`${je(t.env)}oidc/register`,revocation_endpoint:`${je(t.env)}oauth/revoke`,scopes_supported:["openid","profile","offline_access","name","given_name","family_name","nickname","email","email_verified","picture","created_at","identities","phone","address"],response_types_supported:["code","token","id_token","code token","code id_token","token id_token","code token id_token"],code_challenge_methods_supported:["S256","plain"],response_modes_supported:["query","fragment","form_post"],subject_types_supported:["public"],id_token_signing_alg_values_supported:["RS256"],token_endpoint_auth_methods_supported:["client_secret_basic","client_secret_post"],claims_supported:["aud","auth_time","created_at","email","email_verified","exp","family_name","given_name","iat","identities","iss","name","nickname","phone_number","picture","sub"],request_uri_parameter_supported:!1,request_parameter_supported:!1,token_endpoint_auth_signing_alg_values_supported:["RS256","RS384","PS256"]});return t.json(e,{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${ji}, stale-while-revalidate=${ji*2}, stale-if-error=86400`}})});function Fi(t,e){if(!t||!e||t.length!==e.length)return!1;let n=0;for(let r=0;r<t.length;r++)n|=t.charCodeAt(r)^e.charCodeAt(r);return n===0}const Kg=o.z.object({grant_type:o.z.literal("client_credentials"),scope:o.z.string().optional(),client_secret:o.z.string(),client_id:o.z.string(),audience:o.z.string().optional()});async function yb(t,e){const n=await t.env.data.clients.get(e.client_id);if(!n)throw new z(403,{message:"Invalid client credentials"});if(n.client_secret&&!Fi(n.client_secret,e.client_secret))throw new z(403,{message:"Invalid client credentials"});const r={client_id:n.id,scope:e.scope,audience:e.audience},i=await to(t,{authParams:r,client:n});return t.json(i)}const vb=o.z.object({grant_type:o.z.literal("authorization_code"),client_id:o.z.string(),code:o.z.string(),redirect_uri:o.z.string().optional(),client_secret:o.z.string().optional(),code_verifier:o.z.string().optional()}).refine(t=>"client_secret"in t&&!("code_verifier"in t)||!("client_secret"in t)&&"code_verifier"in t,{message:"Must provide either client_secret (standard flow) or code_verifier/code_verifier_mode (PKCE flow), but not both"});async function wb(t,e){const n=await t.env.data.clients.get(e.client_id);if(!n)throw new z(403,{message:"Client not found"});const r=await t.env.data.codes.get(n.tenant.id,e.code,"authorization_code");if(!r||!r.user_id)throw new z(403,{message:"Invalid client credentials"});if(new Date(r.expires_at)<new Date)throw new z(403,{message:"Code expired"});if(r.used_at)throw new z(403,{message:"Code already used"});const i=await t.env.data.loginSessions.get(n.tenant.id,r.login_id);if(!i)throw new z(403,{message:"Invalid login"});if("client_secret"in e){const a=await t.env.data.clients.get("DEFAULT_CLIENT");if(!Fi(n.client_secret,e.client_secret)&&!Fi(a==null?void 0:a.client_secret,e.client_secret))throw new z(403,{message:"Invalid client credentials"})}else if("code_verifier"in e&&typeof e.code_verifier=="string"&&"code_challenge_method"in i.authParams&&typeof i.authParams.code_challenge_method=="string"){const a=await x_(e.code_verifier,i.authParams.code_challenge_method);if(!Fi(a,i.authParams.code_challenge||""))throw new z(403,{message:"Invalid client credentials"})}if(i.authParams.redirect_uri&&i.authParams.redirect_uri!==e.redirect_uri)throw new z(403,{message:"Invalid redirect uri"});const s=await t.env.data.users.get(n.tenant.id,r.user_id);if(!s)throw new z(403,{message:"User not found"});return await t.env.data.codes.used(n.tenant.id,e.code),on(t,{user:s,client:n,loginSession:i,authParams:{...i.authParams,response_mode:Yt.WEB_MESSAGE}})}const bb=o.z.object({grant_type:o.z.literal("refresh_token"),client_id:o.z.string(),redirect_uri:o.z.string().optional(),refresh_token:o.z.string()});async function kb(t,e){const n=await t.env.data.clients.get(e.client_id);if(!n)throw new z(403,{message:"Client not found"});const r=await t.env.data.refreshTokens.get(n.tenant.id,e.refresh_token);if(r){if(r.expires_at&&new Date(r.expires_at)<new Date||r.idle_expires_at&&new Date(r.idle_expires_at)<new Date)throw new z(403,{message:JSON.stringify({error:"invalid_grant",error_description:"Refresh token has expired"})})}else throw new z(403,{message:JSON.stringify({error:"invalid_grant",error_description:"Invalid refresh token"})});const i=await t.env.data.users.get(n.tenant.id,r.user_id);if(!i)throw new z(403,{message:"User not found"});const s=r.resource_servers[0];if(r.idle_expires_at){const a=new Date(Date.now()+2592e6);await t.env.data.refreshTokens.update(n.tenant.id,r.id,{idle_expires_at:a.toISOString(),last_exchanged_at:new Date().toISOString(),device:{...r.device,last_ip:t.req.header["x-real-ip"]||"",last_user_agent:t.req.header["user-agent"]||""}})}return on(t,{user:i,client:n,refreshToken:r.id,sessionId:r.session_id,authParams:{client_id:n.id,audience:s==null?void 0:s.audience,scope:s==null?void 0:s.scopes,response_mode:Yt.WEB_MESSAGE}})}const Rp=o.z.object({client_id:o.z.string().optional(),client_secret:o.z.string().optional()}),xb=o.z.union([Kg.extend(Rp.shape),o.z.object({grant_type:o.z.literal("authorization_code"),client_id:o.z.string(),code:o.z.string(),redirect_uri:o.z.string(),code_verifier:o.z.string().min(43).max(128)}),o.z.object({grant_type:o.z.literal("authorization_code"),code:o.z.string(),redirect_uri:o.z.string().optional(),...Rp.shape}),o.z.object({grant_type:o.z.literal("refresh_token"),client_id:o.z.string(),refresh_token:o.z.string(),redirect_uri:o.z.string().optional()})]);function Sb(t){if(!t)return{};const[e,n]=t.split(" ");if((e==null?void 0:e.toLowerCase())==="basic"&&n){const[r,i]=atob(n).split(":");return{client_id:r,client_secret:i}}return{}}const Ab=new o.OpenAPIHono().openapi(o.createRoute({tags:["oauth2"],method:"post",path:"/",request:{body:{content:{"application/x-www-form-urlencoded":{schema:xb}}}},responses:{200:{content:{"application/json":{schema:wf}},description:"Tokens"}}}),async t=>{const e=t.req.valid("form"),n=Sb(t.req.header("Authorization")),r={...e,...n};if(!r.client_id)throw new z(400,{message:"client_id is required"});switch(t.set("client_id",r.client_id),e.grant_type){case Br.AuthorizationCode:return wb(t,vb.parse(r));case Br.ClientCredential:return yb(t,Kg.parse(r));case Br.RefreshToken:return kb(t,bb.parse(r));default:throw new z(400,{message:"Not implemented"})}});var ru={exports:{}};const iu=[{id:0,value:"Too weak",minDiversity:0,minLength:0},{id:1,value:"Weak",minDiversity:2,minLength:6},{id:2,value:"Medium",minDiversity:4,minLength:8},{id:3,value:"Strong",minDiversity:4,minLength:10}],Wg=(t,e=iu,n="!\"#$%&'()*+,-./:;<=>?@[\\\\\\]^_`{|}~")=>{let r=t||"";e[0].minDiversity=0,e[0].minLength=0;const i=[{regex:"[a-z]",message:"lowercase"},{regex:"[A-Z]",message:"uppercase"},{regex:"[0-9]",message:"number"}];n&&i.push({regex:`[${n}]`,message:"symbol"});let s={};s.contains=i.filter(c=>new RegExp(`${c.regex}`).test(r)).map(c=>c.message),s.length=r.length;let a=e.filter(c=>s.contains.length>=c.minDiversity).filter(c=>s.length>=c.minLength).sort((c,l)=>l.id-c.id).map(c=>({id:c.id,value:c.value}));return Object.assign(s,a[0]),s};ru.exports={passwordStrength:Wg,defaultOptions:iu};var Eb=ru.exports.passwordStrength=Wg;ru.exports.defaultOptions=iu;function su(t){return Eb(t).id<2?!1:t.length>=8&&/[a-z]/.test(t)&&/[A-Z]/.test(t)&&/[0-9]/.test(t)&&/[^A-Za-z0-9]/.test(t)}async function Si(t,e){var i;const n=await t.env.data.emailProviders.get(t.var.tenant_id)||(t.env.DEFAULT_TENANT_ID?await t.env.data.emailProviders.get(t.env.DEFAULT_TENANT_ID):null);if(!n)throw new z(500,{message:"Email provider not found"});const r=(i=t.env.emailProviders)==null?void 0:i[n.name];if(!r)throw new z(500,{message:"Email provider not found"});await r({emailProvider:n,...e,from:n.default_from_address||`login@${t.env.ISSUER}`})}async function Gg(t,e,n,r){const i=await t.env.data.tenants.get(t.var.tenant_id);if(!i)throw new z(500,{message:"Tenant not found"});const s=`${_t(t.env)}reset-password?state=${r}&code=${n}`,a={vendorName:i.name,lng:i.language||"en"};await Si(t,{to:e,subject:se("reset_password_title",a),html:`Click here to reset your password: ${_t(t.env)}reset-password?state=${r}&code=${n}`,template:"auth-password-reset",data:{vendorName:i.name,logo:i.logo||"",passwordResetUrl:s,supportUrl:i.support_url||"https://support.sesamy.com",buttonColor:i.primary_color||"#7d68f4",passwordResetTitle:se("password_reset_title",a),resetPasswordEmailClickToReset:se("reset_password_email_click_to_reset",a),resetPasswordEmailReset:se("reset_password_email_reset",a),supportInfo:se("support_info",a),contactUs:se("contact_us",a),copyright:se("copyright",a)}})}async function Jg(t,e,n){const r=await t.env.data.tenants.get(t.var.tenant_id);if(!r)throw new z(500,{message:"Tenant not found"});const i={vendorName:r.name,code:n,lng:r.language||"en"};await Si(t,{to:e,subject:se("code_email_subject",i),html:`Click here to validate your email: ${_t(t.env)}validate-email`,template:"auth-code",data:{code:n,vendorName:r.name,logo:r.logo||"",supportUrl:r.support_url||"",buttonColor:r.primary_color||"",welcomeToYourAccount:se("welcome_to_your_account",i),linkEmailClickToLogin:se("link_email_click_to_login",i),linkEmailLogin:se("link_email_login",i),linkEmailOrEnterCode:se("link_email_or_enter_code",i),codeValid30Mins:se("code_valid_30_minutes",i),supportInfo:se("support_info",i),contactUs:se("contact_us",i),copyright:se("copyright",i)}});const s=ve(t,{type:he.CODE_LINK_SENT,description:e});nt(t,t.env.data.logs.create(r.id,s))}async function ou(t,e,n,r){const i=await t.env.data.tenants.get(t.var.tenant_id);if(!i)throw new z(500,{message:"Tenant not found"});if(!r.redirect_uri)throw new z(400,{message:"redirect_uri is required"});const s=new URL(je(t.env));s.pathname="passwordless/verify_redirect",s.searchParams.set("verification_code",n),s.searchParams.set("connection","email"),s.searchParams.set("client_id",r.client_id),s.searchParams.set("redirect_uri",r.redirect_uri),s.searchParams.set("email",e),r.response_type&&s.searchParams.set("response_type",r.response_type),r.scope&&s.searchParams.set("scope",r.scope),r.state&&s.searchParams.set("state",r.state),r.nonce&&s.searchParams.set("nonce",r.nonce),r.code_challenge&&s.searchParams.set("code_challenge",r.code_challenge),r.code_challenge_method&&s.searchParams.set("code_challenge_method",r.code_challenge_method),r.audience&&s.searchParams.set("audience",r.audience);const a={vendorName:i.name,code:n,lng:i.language||"en"};await Si(t,{to:e,subject:se("code_email_subject",a),html:`Click here to validate your email: ${_t(t.env)}validate-email`,template:"auth-link",data:{code:n,vendorName:i.name,logo:i.logo||"",supportUrl:i.support_url||"",magicLink:s.toString(),buttonColor:i.primary_color||"",welcomeToYourAccount:se("welcome_to_your_account",a),linkEmailClickToLogin:se("link_email_click_to_login",a),linkEmailLogin:se("link_email_login",a),linkEmailOrEnterCode:se("link_email_or_enter_code",a),codeValid30Mins:se("code_valid_30_minutes",a),supportInfo:se("support_info",a),contactUs:se("contact_us",a),copyright:se("copyright",a)}});const c=ve(t,{type:he.CODE_LINK_SENT,description:e});nt(t,t.env.data.logs.create(i.id,c))}async function au(t,e){const n=await t.env.data.tenants.get(t.var.tenant_id);if(!n)throw new z(500,{message:"Tenant not found"});const r={vendorName:n.name,lng:n.language||"en"};await Si(t,{to:e.email,subject:se("welcome_to_your_account",r),html:`Click here to validate your email: ${_t(t.env)}validate-email`,template:"auth-verify-email",data:{vendorName:n.name,logo:n.logo||"",emailValidationUrl:`${_t(t.env)}validate-email`,supportUrl:n.support_url||"https://support.sesamy.com",buttonColor:n.primary_color||"#7d68f4",welcomeToYourAccount:se("welcome_to_your_account",r),verifyEmailVerify:se("verify_email_verify",r),supportInfo:se("support_info",r),contactUs:se("contact_us",r),copyright:se("copyright",r)}})}async function Ib(t,e,n,r){const i=await t.env.data.tenants.get(t.var.tenant_id);if(!i)throw new z(500,{message:"Tenant not found"});const s={vendorName:i.name,lng:i.language||"en"},a=`${_t(t.env)}signup?state=${r}&code=${n}`;await Si(t,{to:e,subject:se("register_password_account",s),html:`Click here to register: ${a}`,template:"auth-pre-signup-verification",data:{vendorName:i.name,logo:i.logo||"",signupUrl:a,setPassword:se("set_password",s),registerPasswordAccount:se("register_password_account",s),clickToSignUpDescription:se("click_to_sign_up_description",s),supportUrl:i.support_url||"https://support.sesamy.com",buttonColor:i.primary_color||"#7d68f4",welcomeToYourAccount:se("welcome_to_your_account",s),verifyEmailVerify:se("verify_email_verify",s),supportInfo:se("support_info",s),contactUs:se("contact_us",s),copyright:se("copyright",s)}})}const zb=new o.OpenAPIHono().openapi(o.createRoute({tags:["dbconnections"],method:"post",path:"/signup",request:{body:{content:{"application/json":{schema:o.z.object({client_id:o.z.string(),connection:o.z.literal("Username-Password-Authentication"),email:o.z.string().transform(t=>t.toLowerCase()),password:o.z.string()})}}}},responses:{200:{content:{"application/json":{schema:o.z.object({_id:o.z.string(),email:o.z.string(),email_verified:o.z.boolean(),app_metadata:o.z.object({}),user_metadata:o.z.object({})})}},description:"Created user"}}}),async t=>{const{email:e,password:n,client_id:r}=t.req.valid("json"),i=await t.env.data.clients.get(r);if(!i)throw new z(400,{message:"Client not found"});if(t.set("client_id",i.id),t.set("tenant_id",i.tenant.id),!su(n))throw new z(400,{message:"Password does not meet the requirements"});if(await ls({userAdapter:t.env.data.users,tenant_id:i.tenant.id,email:e,provider:"auth2"}))throw new z(400,{message:"Invalid sign up"});const a=await t.env.data.users.create(i.tenant.id,{user_id:`auth2|${Xs()}`,email:e,email_verified:!1,provider:"auth2",connection:"Username-Password-Authentication",is_social:!1});t.set("user_id",a.user_id),t.set("username",a.email),t.set("connection",a.connection);const c=await si.hash(n,10);await t.env.data.passwords.create(i.tenant.id,{user_id:a.user_id,password:c,algorithm:"bcrypt"}),await au(t,a);const l=ve(t,{type:he.SUCCESS_SIGNUP,description:"Successful signup"});return await t.env.data.logs.create(i.tenant.id,l),t.json({_id:a.user_id,email:a.email,email_verified:!1,app_metadata:{},user_metadata:{}})}).openapi(o.createRoute({tags:["dbconnections"],method:"post",path:"/change_password",request:{body:{content:{"application/json":{schema:o.z.object({client_id:o.z.string(),connection:o.z.literal("Username-Password-Authentication"),email:o.z.string().transform(t=>t.toLowerCase())})}}}},responses:{200:{description:"Redirect to the client's redirect uri"}}}),async t=>{const{email:e,client_id:n}=t.req.valid("json"),r=await t.env.data.clients.get(n);if(!r)throw new z(400,{message:"Client not found"});if(t.set("client_id",r.id),t.set("tenant_id",r.tenant.id),!await ur({userAdapter:t.env.data.users,tenant_id:r.tenant.id,email:e,provider:"auth2"}))return t.html("If an account with that email exists, we've sent instructions to reset your password.");const s={client_id:n,username:e},a=await t.env.data.loginSessions.create(r.tenant.id,{expires_at:new Date(Date.now()+Jn*1e3).toISOString(),authParams:s,csrf_token:xe(),...sn(t.req)});return await Gg(t,e,a.id,a.authParams.state),t.html("If an account with that email exists, we've sent instructions to reset your password.")});function Tn(){const t="1234567890";let e="";for(let n=0;n<6;n+=1)e+=t[Math.floor(Math.random()*10)];return e.toString()}async function cu(t,e,n,r,i,s,a){const{env:c}=t,l=await c.data.codes.get(e.tenant.id,i,"otp");if(!l)throw new z(400,{message:"Code not found or expired"});if(l.expires_at<new Date().toISOString())throw new z(400,{message:"Code expired"});if(l.used_at)throw new z(400,{message:"Code already used"});const u=await c.data.loginSessions.get(e.tenant.id,l.login_id);if(!u||u.authParams.username!==r)throw new z(400,{message:"Code not found or expired"});const p=sn(t.req);if(a&&u.ip!==p.ip)return t.redirect(`${_t(t.env)}invalid-session?state=${u.id}`);if(n.redirect_uri&&!Yo(n.redirect_uri,e.callbacks,{allowPathWildcards:!0}))throw new z(400,{message:`Invalid redirect URI - ${n.redirect_uri}`});const h=await io(t,{client:e,email:r,provider:"email",connection:"email",isSocial:!1,ip:t.req.header("x-real-ip")});return await c.data.codes.used(e.tenant.id,i),on(t,{user:h,client:e,loginSession:u,authParams:n,ticketAuth:s})}const Nb=new o.OpenAPIHono().openapi(o.createRoute({tags:["passwordless"],method:"post",path:"/start",request:{body:{content:{"application/json":{schema:o.z.object({client_id:o.z.string(),connection:o.z.string(),email:o.z.string().transform(t=>t.toLowerCase()),send:o.z.enum(["link","code"]),authParams:tl.omit({client_id:!0})})}}}},responses:{200:{description:"Status"}}}),async t=>{const e=t.req.valid("json"),{env:n}=t,{client_id:r,email:i,send:s,authParams:a}=e,c=await t.env.data.clients.get(r);if(!c)throw new z(400,{message:"Client not found"});t.set("client_id",c.id),t.set("tenant_id",c.tenant.id);const l=await n.data.loginSessions.create(c.tenant.id,{authParams:{...a,client_id:r,username:i},expires_at:new Date(Date.now()+Na).toISOString(),csrf_token:xe(),...sn(t.req)}),u=await n.data.codes.create(c.tenant.id,{code_id:Tn(),code_type:"otp",login_id:l.id,expires_at:new Date(Date.now()+Na).toISOString()});return s==="link"?await ou(t,i,u.code_id,{...a,client_id:r}):await Jg(t,i,u.code_id),t.html("OK")}).openapi(o.createRoute({tags:["passwordless"],method:"get",path:"/verify_redirect",request:{query:o.z.object({scope:o.z.string(),response_type:o.z.nativeEnum(Pt),redirect_uri:o.z.string(),state:o.z.string(),nonce:o.z.string().optional(),verification_code:o.z.string(),connection:o.z.string(),client_id:o.z.string(),email:o.z.string().transform(t=>t.toLowerCase()),audience:o.z.string().optional()})},responses:{302:{description:"Status"}}}),async t=>{const{env:e}=t,{client_id:n,email:r,verification_code:i,redirect_uri:s,state:a,scope:c,audience:l,response_type:u,nonce:p}=t.req.valid("query"),h=await Zo(e,n);return t.set("client_id",h.id),t.set("tenant_id",h.tenant.id),t.set("connection","email"),cu(t,h,{client_id:n,redirect_uri:s,state:a,nonce:p,scope:c,audience:l,response_type:u},r,i,!1,!0)});class Nr extends z{constructor(n,r){super(n,r);te(this,"_code");this._code=r==null?void 0:r.code}get code(){return this._code}}async function lu(t,e,n,r,i){const{env:s}=t,a=n.username;if(t.set("username",a),!a)throw new z(400,{message:"Username is required"});const c=await ur({userAdapter:t.env.data.users,tenant_id:e.tenant.id,email:a,provider:"auth2"});if(!c){const f=ve(t,{type:he.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid user"});throw nt(t,t.env.data.logs.create(e.tenant.id,f)),new Nr(403,{message:"User not found",code:"USER_NOT_FOUND"})}const l=c.linked_to?await s.data.users.get(e.tenant.id,c.linked_to):c;if(!l)throw new Nr(403,{message:"User not found",code:"USER_NOT_FOUND"});t.set("connection",c.connection),t.set("user_id",l.user_id);const u=await s.data.passwords.get(e.tenant.id,c.user_id);if(!(u&&await si.compare(n.password,u.password))){const f=ve(t,{type:he.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid password"});throw nt(t,t.env.data.logs.create(e.tenant.id,f)),new Nr(403,{message:"Invalid password",code:"INVALID_PASSWORD"})}if((await s.data.logs.list(e.tenant.id,{page:0,per_page:10,include_totals:!1,q:`user_id:${l.user_id}`})).logs.filter(f=>f.type===he.FAILED_LOGIN_INCORRECT_PASSWORD&&new Date(f.date)>new Date(Date.now()-1e3*60*5)).length>=3){const f=ve(t,{type:he.FAILED_LOGIN,description:"Too many failed login attempts"});throw nt(t,t.env.data.logs.create(e.tenant.id,f)),new Nr(403,{message:"Too many failed login attempts",code:"TOO_MANY_FAILED_LOGINS"})}if(!c.email_verified&&e.email_validation==="enforced"){await au(t,c);const f=ve(t,{type:he.FAILED_LOGIN,description:"Email not verified"});throw await t.env.data.logs.create(e.tenant.id,f),new Nr(403,{message:"Email not verified",code:"EMAIL_NOT_VERIFIED"})}const v=ve(t,{type:he.SUCCESS_LOGIN,description:"Successful login",strategy_type:"Username-Password-Authentication",strategy:"Username-Password-Authentication"});return nt(t,t.env.data.logs.create(e.tenant.id,v)),on(t,{client:e,authParams:n,user:l,ticketAuth:i,loginSession:r})}async function Cb(t,e,n,r){await io(t,{client:e,email:n,provider:"auth2",connection:"Username-Password-Authentication",isSocial:!1,ip:t.req.header("x-real-ip")});let i=Tn(),s=await t.env.data.codes.get(e.tenant.id,i,"password_reset");for(;s;)i=Tn(),s=await t.env.data.codes.get(e.tenant.id,i,"password_reset");const a=await t.env.data.loginSessions.create(e.tenant.id,{expires_at:new Date(Date.now()+C_).toISOString(),authParams:{client_id:e.id,username:n},csrf_token:xe(),...sn(t.req)}),c=await t.env.data.codes.create(e.tenant.id,{code_id:i,code_type:"password_reset",login_id:a.id,expires_at:new Date(Date.now()+N_).toISOString()});await Gg(t,n,c.code_id,r)}const jb=new o.OpenAPIHono().openapi(o.createRoute({tags:["oauth"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:o.z.union([o.z.object({credential_type:o.z.literal("http://auth0.com/oauth/grant-type/passwordless/otp"),otp:o.z.string(),client_id:o.z.string(),username:o.z.string().transform(t=>t.toLowerCase()),realm:o.z.enum(["email"]),scope:o.z.string().optional()}),o.z.object({credential_type:o.z.literal("http://auth0.com/oauth/grant-type/password-realm"),client_id:o.z.string(),username:o.z.string().transform(t=>t.toLowerCase()),password:o.z.string(),realm:o.z.enum(["Username-Password-Authentication"]),scope:o.z.string().optional()})])}}}},responses:{200:{description:"List of tenants"}}}),async t=>{const e=t.req.valid("json"),{client_id:n,username:r}=e;t.set("username",r);const i=await t.env.data.clients.get(n);if(!i)throw new z(400,{message:"Client not found"});t.set("client_id",n),t.set("tenant_id",i.tenant.id);const s=r.toLocaleLowerCase();if("otp"in e)return cu(t,i,{client_id:n,username:s},s,e.otp,!0);if("password"in e){const a=await t.env.data.loginSessions.create(i.tenant.id,{expires_at:new Date(Date.now()+Jn*1e3).toISOString(),authParams:{client_id:n,username:s},csrf_token:xe(),...sn(t.req)});return lu(t,i,{username:s,password:e.password,client_id:n},a,!0)}else throw new z(400,{message:"Code or password required"})});function $b(t,e){var r,i,s;if(!t||e.length===0)return!1;const n=((r=ga(t))==null?void 0:r.host)??null;if(!n)return!1;for(const a of e){let c;if(a.startsWith("http://")||a.startsWith("https://")?c=((i=ga(a))==null?void 0:i.host)??null:c=((s=ga("https://"+a))==null?void 0:s.host)??null,n===c)return!0}return!1}function ga(t){try{return new URL(t)}catch{return null}}async function Ob({ctx:t,session:e,client:n,authParams:r,connection:i,login_hint:s}){const a=await t.env.data.loginSessions.create(n.tenant.id,{expires_at:new Date(Date.now()+Jn*1e3).toISOString(),authParams:r,csrf_token:xe(),authorization_url:t.req.url,...sn(t.req)});if(e&&s){const c=await t.env.data.users.get(n.tenant.id,e.user_id);if((c==null?void 0:c.email)===s)return on(t,{client:n,loginSession:a,authParams:r,user:c,sessionId:e.id})}if(i==="email"&&s){const c=Tn();return await t.env.data.codes.create(n.tenant.id,{code_id:c,code_type:"otp",login_id:a.id,expires_at:new Date(Date.now()+Jn*1e3).toISOString()}),await ou(t,s,c,r),t.redirect(`/u/enter-code?state=${a.id}`)}return e?t.redirect(`/u/check-account?state=${a.id}`):t.redirect(`/u/enter-email?state=${a.id}`)}function Bb(t){if(t==="Username-Password-Authentication")return"auth2";if(t==="email")return"email";throw new z(403,{message:"Invalid realm"})}async function Tb(t,e,n,r,i){var m;const{env:s}=t;t.set("connection",i);const a=await s.data.codes.get(e,n,"ticket");if(!a||a.used_at)throw new z(403,{message:"Ticket not found"});const c=await s.data.loginSessions.get(e,a.login_id);if(!c||!c.authParams.username)throw new z(403,{message:"Session not found"});const l=await s.data.clients.get(c.authParams.client_id);if(!l)throw new z(403,{message:"Client not found"});t.set("client_id",c.authParams.client_id),await s.data.codes.used(e,n);const u=Bb(i);let p=await io(t,{email:c.authParams.username,provider:u,client:l,connection:u==="auth2"?"Username-Password-Authentication":"email",isSocial:!1,ip:t.req.header("x-real-ip")});t.set("username",p.email),t.set("user_id",p.user_id);const h=await Df(t,{user:p,client:l,loginSession:c});return on(t,{authParams:{scope:(m=c.authParams)==null?void 0:m.scope,...r},loginSession:c,sessionId:h.id,user:p,client:l})}async function Lp(t,e){return`<!DOCTYPE html>
149
+ `,r}async function lw(t){const e=await t.publicKey.export(),n=await crypto.subtle.exportKey("jwk",e),r=JSON.stringify(n,Object.keys(n).sort()),s=new TextEncoder().encode(r);return za(await Cf(s))}const uw=1e3*60*60*24,dw=new o.OpenAPIHono().openapi(o.createRoute({tags:["keys"],method:"get",path:"/signing",request:{headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:o.z.array(Ia)}},description:"List of keys"}}}),async t=>{const n=(await t.env.data.keys.list()).filter(r=>"cert"in r).map(r=>r);return t.json(n)}).openapi(o.createRoute({tags:["keys"],method:"get",path:"/signing/{kid}",request:{headers:o.z.object({"tenant-id":o.z.string()}),params:o.z.object({kid:o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Ia}},description:"The requested key"}}}),async t=>{const{kid:e}=t.req.valid("param"),r=(await t.env.data.keys.list()).find(i=>i.kid===e);if(!r)throw new z(404,{message:"Key not found"});return t.json(r)}).openapi(o.createRoute({tags:["keys"],method:"post",path:"/signing/rotate",request:{headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{description:"Status"}}}),async t=>{const e=await t.env.data.keys.list();for await(const r of e)await t.env.data.keys.update(r.kid,{revoked_at:new Date(Date.now()+uw).toISOString()});const n=await Jc({name:`CN=${t.env.ORGANIZATION_NAME}`});return await t.env.data.keys.create(n),t.text("OK",{status:201})}).openapi(o.createRoute({tags:["keys"],method:"put",path:"/signing/{kid}/revoke",request:{headers:o.z.object({"tenant-id":o.z.string()}),params:o.z.object({kid:o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{description:"Status"}}}),async t=>{const{kid:e}=t.req.valid("param");if(!await t.env.data.keys.update(e,{revoked_at:new Date().toISOString()}))throw new z(404,{message:"Key not found"});const r=await Jc({name:`CN=${t.env.ORGANIZATION_NAME}`});return await t.env.data.keys.create(r),t.text("OK")}),pw=new o.OpenAPIHono().openapi(o.createRoute({tags:["users"],method:"get",path:"/",request:{query:o.z.object({email:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:o.z.array(el)}},description:"List of users"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{email:n}=t.req.valid("query"),i=(await pl(t.env.data.users,e,n)).filter(s=>!s.linked_to);return t.json(i)}),fw=rn.extend({clients:o.z.array(mn)}),hw=new o.OpenAPIHono().openapi(o.createRoute({tags:["clients"],method:"get",path:"/",request:{query:Qt,headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:o.z.union([fw,o.z.array(mn)])}},description:"List of clients"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{page:n,per_page:r,include_totals:i,sort:s,q:a}=t.req.valid("query"),l=(await t.env.data.applications.list(e,{page:n,per_page:r,include_totals:i,sort:dr(s),q:a})).applications;return i?t.json({clients:l,start:0,limit:10,length:l.length}):t.json(l)}).openapi(o.createRoute({tags:["clients"],method:"get",path:"/{id}",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:mn}},description:"An application"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),i=(await t.env.data.applications.list(e,{page:1,per_page:0,include_totals:!1})).applications.find(s=>s.id===n);if(!i)throw new z(404);return t.json(i)}).openapi(o.createRoute({tags:["clients"],method:"delete",path:"/{id}",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param");if(!await t.env.data.applications.remove(e,n))throw new z(404,{message:"Application not found"});return t.text("OK")}).openapi(o.createRoute({tags:["clients"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:o.z.object(ns.shape).partial()}}},params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:mn}},description:"The update application"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),i=t.req.valid("json");await t.env.data.applications.update(e,n,i);const s=await t.env.data.applications.get(e,n);if(!s)throw new z(404,{message:"Application not found"});return t.json(s)}).openapi(o.createRoute({tags:["clients"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:o.z.object(ns.shape)}}},headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:o.z.object(mn.shape)}},description:"An application"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),r={...n,id:n.id||xe(),client_secret:n.client_secret||xe()},i=await t.env.data.applications.create(e,r);return t.json(i,{status:201})});o.z.object({start:o.z.number(),limit:o.z.number(),length:o.z.number()});Js.extend({email:o.z.string(),login_count:o.z.number(),multifactor:o.z.array(o.z.string()).optional(),last_ip:o.z.string().optional(),last_login:o.z.string().optional(),user_id:o.z.string()}).catchall(o.z.any());const gw=rn.extend({tenants:o.z.array(Fn)}),mw=new o.OpenAPIHono().openapi(o.createRoute({tags:["tenants"],method:"get",path:"/",request:{query:Qt},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:o.z.union([o.z.array(Fn),gw])}},description:"List of tenants"}}}),async t=>{const{page:e,per_page:n,include_totals:r,sort:i,q:s}=t.req.valid("query"),a=await t.env.data.tenants.list({page:e,per_page:n,include_totals:r,sort:dr(i),q:s});return r?t.json(a):t.json(a.tenants)}).openapi(o.createRoute({tags:["tenants"],method:"get",path:"/{id}",request:{params:o.z.object({id:o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:Fn}},description:"A tenant"}}}),async t=>{const{id:e}=t.req.valid("param"),n=await t.env.data.tenants.get(e);if(!n)throw new z(404);return t.json(n)}).openapi(o.createRoute({tags:["tenants"],method:"delete",path:"/{id}",request:{params:o.z.object({id:o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{const{id:e}=t.req.valid("param");return await t.env.data.tenants.remove(e),t.text("OK")}).openapi(o.createRoute({tags:["tenants"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:o.z.object(is.shape).partial()}}},params:o.z.object({id:o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{const{id:e}=t.req.valid("param"),n=t.req.valid("json");return await t.env.data.tenants.update(e,n),t.text("OK")}).openapi(o.createRoute({tags:["tenants"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:o.z.object(is.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"tenant/json":{schema:Fn}},description:"An tenant"}}}),async t=>{const e=t.req.valid("json"),n=await t.env.data.tenants.create(e);return t.json(n,{status:201})}),_w=rn.extend({logs:o.z.array(os)}),yw=new o.OpenAPIHono().openapi(o.createRoute({tags:["logs"],method:"get",path:"/",request:{query:Qt,headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:o.z.union([o.z.array(os),_w])}},description:"List of log rows"}}}),async t=>{const{page:e,per_page:n,include_totals:r,sort:i,q:s}=t.req.valid("query"),{"tenant-id":a}=t.req.valid("header"),c=await t.env.data.logs.list(a,{page:e,per_page:n,include_totals:r,sort:dr(i),q:s});return r?t.json(c):t.json(c.logs)}).openapi(o.createRoute({tags:["logs"],method:"get",path:"/{id}",request:{headers:o.z.object({"tenant-id":o.z.string()}),params:o.z.object({id:o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:os}},description:"A log entry"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),r=await t.env.data.logs.get(e,n);if(!r)throw new z(404);return t.json(r)}),vw=rn.extend({hooks:o.z.array(Dn)}),ww=new o.OpenAPIHono().openapi(o.createRoute({tags:["hooks"],method:"get",path:"/",request:{query:Qt,headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:o.z.union([o.z.array(Dn),vw])}},description:"List of hooks"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{page:n,per_page:r,include_totals:i,sort:s,q:a}=t.req.valid("query"),c=await t.env.data.hooks.list(e,{page:n,per_page:r,include_totals:i,sort:dr(s),q:a});return i?t.json(c):t.json(c.hooks)}).openapi(o.createRoute({tags:["hooks"],method:"post",path:"/",request:{headers:o.z.object({"tenant-id":o.z.string()}),body:{content:{"application/json":{schema:o.z.object(ss.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Dn}},description:"The created hook"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),r=await t.env.data.hooks.create(e,n);return t.json(r,{status:201})}).openapi(o.createRoute({tags:["hooks"],method:"patch",path:"/{hook_id}",request:{headers:o.z.object({"tenant-id":o.z.string()}),params:o.z.object({hook_id:o.z.string()}),body:{content:{"application/json":{schema:o.z.object(ss.shape).omit({hook_id:!0}).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Dn.shape}},description:"The updated hook"},404:{description:"Hook not found"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{hook_id:n}=t.req.valid("param"),r=t.req.valid("json");await t.env.data.hooks.update(e,n,r);const i=await t.env.data.hooks.get(e,n);if(!i)throw new z(404,{message:"Hook not found"});return t.json(i)}).openapi(o.createRoute({tags:["hooks"],method:"get",path:"/{hook_id}",request:{headers:o.z.object({"tenant-id":o.z.string()}),params:o.z.object({hook_id:o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Dn}},description:"A hook"},404:{description:"Hook not found"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{hook_id:n}=t.req.valid("param"),r=await t.env.data.hooks.get(e,n);if(!r)throw new z(404,{message:"Hook not found"});return t.json(r)}).openapi(o.createRoute({tags:["hooks"],method:"delete",path:"/{hook_id}",request:{headers:o.z.object({"tenant-id":o.z.string()}),params:o.z.object({hook_id:o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{description:"A hook"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{hook_id:n}=t.req.valid("param");if(!await t.env.data.hooks.remove(e,n))throw new z(404,{message:"Hook not found"});return t.text("OK")}),bw=rn.extend({connections:o.z.array(Kt)}),kw=new o.OpenAPIHono().openapi(o.createRoute({tags:["connections"],method:"get",path:"/",request:{query:Qt,headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:o.z.union([o.z.array(Kt),bw])}},description:"List of connectionss"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{page:n,per_page:r,include_totals:i=!1,sort:s,q:a}=t.req.valid("query"),c=await t.env.data.connections.list(e,{page:n,per_page:r,include_totals:i,sort:dr(s),q:a});return i?t.json(c):t.json(c.connections)}).openapi(o.createRoute({tags:["connections"],method:"get",path:"/{id}",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Kt}},description:"A connection"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),r=await t.env.data.connections.get(e,n);if(!r)throw new z(404);return t.json(r)}).openapi(o.createRoute({tags:["connections"],method:"delete",path:"/{id}",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param");if(!await t.env.data.connections.remove(e,n))throw new z(404,{message:"Connection not found"});return t.text("OK")}).openapi(o.createRoute({tags:["connections"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:o.z.object(rs.shape).partial()}}},params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Kt}},description:"The updated connection"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),r=t.req.valid("json");if(!await t.env.data.connections.update(e,n,r))throw new z(404,{message:"Connection not found"});const s=await t.env.data.connections.get(e,n);if(!s)throw new z(404,{message:"Connection not found"});return t.json(s)}).openapi(o.createRoute({tags:["connections"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:o.z.object(rs.shape)}}},headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Kt}},description:"A connection"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),r=await t.env.data.connections.create(e,n);return t.json(r,{status:201})}),xw=new o.OpenAPIHono().openapi(o.createRoute({tags:["prompts"],method:"get",path:"/",request:{headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Li}},description:"Branding settings"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=await t.env.data.promptSettings.get(e);return n?t.json(n):t.json(Li.parse({}))}).openapi(o.createRoute({tags:["prompts"],method:"patch",path:"/",request:{headers:o.z.object({"tenant-id":o.z.string()}),body:{content:{"application/json":{schema:o.z.object(Li.shape).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Prompts settings"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),r=await t.env.data.promptSettings.get(e);return Object.assign(r,n),await t.env.data.promptSettings.set(e,r),t.json(r)});let Ep=!1;function Pg(t){t.use(async(e,n)=>(Ep||(t.openAPIRegistry.registerComponent("securitySchemes","Bearer",{type:"oauth2",scheme:"bearer",flows:{implicit:{authorizationUrl:`${e.env.AUTH_URL}/authorize`,scopes:{openid:"Basic user information",email:"User email",profile:"User profile information"}}}}),Ep=!0),await n()))}o.z.object({alg:o.z.literal("RS256"),kty:o.z.literal("RSA"),use:o.z.literal("sig"),n:o.z.string(),e:o.z.string(),kid:o.z.string(),x5t:o.z.string(),x5c:o.z.array(o.z.string())});async function Sw(t){try{const e=await t.JWKS_SERVICE.fetch(t.JWKS_URL);if(!e.ok)throw new Error("Failed to fetch jwks");return(await e.json()).keys}catch(e){throw new z(500,{message:`Failed to fetch jwks: ${e.message}`})}}async function Aw(t,e){const r=new TextEncoder().encode([e.raw.header,e.raw.payload].join(".")),i=new Uint8Array(Array.from(e.signature).map(l=>l.charCodeAt(0))),a=(await Sw(t.env)).find(l=>l.kid===e.header.kid);if(!a)return console.log("No matching kid found"),!1;const c=await crypto.subtle.importKey("jwk",a,{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},!1,["verify"]);return crypto.subtle.verify("RSASSA-PKCS1-v1_5",c,i,r)}function Ew(t){const[e,n,r]=t.split(".");if(!e||!n||!r)return null;const i=JSON.parse(atob(e)),s=JSON.parse(atob(n)),a=atob(r.replace(/-/g,"+").replace(/_/g,"/"));return{header:i,payload:s,signature:a,raw:{header:e,payload:n,signature:r}}}function Rg(t){return async(e,n)=>{var i,s,a;const r=t.openAPIRegistry.definitions.find(c=>"route"in c&&c.route.path===e.req.path&&c.route.method.toUpperCase()===e.req.method);if(r&&"route"in r){const c=(s=(i=r.route.security)==null?void 0:i[0])==null?void 0:s.Bearer;if(!(c!=null&&c.length))return await n();const l=e.req.header("authorization")||"",[u,p]=l.split(" ");if((u==null?void 0:u.toLowerCase())!=="bearer"||!p)throw new z(401,{message:"Missing bearer token"});const h=Ew(p);if(!h||!await Aw(e,h))throw new z(403,{message:"Invalid JWT signature"});e.set("user_id",h.payload.sub),e.set("user",h.payload);const m=h.payload.permissions||[],v=((a=h.payload.scope)==null?void 0:a.split(" "))||[];if(c.length&&!(c.some(f=>m.includes(f))||c.some(f=>v.includes(f))))throw new z(403,{message:"Unauthorized"})}return await n()}}const Iw=new o.OpenAPIHono().openapi(o.createRoute({tags:["emails"],method:"get",path:"/",request:{headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Ui}},description:"Email provider"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=await t.env.data.emailProviders.get(e);if(!n)throw new z(404,{message:"Email provider not found"});return t.json(n)}).openapi(o.createRoute({tags:["emails"],method:"post",path:"/",request:{headers:o.z.object({"tenant-id":o.z.string()}),body:{content:{"application/json":{schema:o.z.object(Ui.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Branding settings"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json");return await t.env.data.emailProviders.create(e,n),t.text("OK",{status:201})}).openapi(o.createRoute({tags:["emails"],method:"patch",path:"/",request:{headers:o.z.object({"tenant-id":o.z.string()}),body:{content:{"application/json":{schema:o.z.object(Ui.shape).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Branding settings"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json");return await t.env.data.emailProviders.update(e,n),t.text("OK")}),zw=new o.OpenAPIHono().openapi(o.createRoute({tags:["sessions"],method:"get",path:"/{id}",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Ys}},description:"A session"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),r=await t.env.data.sessions.get(e,n);if(!r)throw new z(404);return t.json(r)}).openapi(o.createRoute({tags:["sessions"],method:"delete",path:"/{id}",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param");if(!await t.env.data.sessions.remove(e,n))throw new z(404,{message:"Session not found"});return t.text("OK")}).openapi(o.createRoute({tags:["sessions"],method:"post",path:"/{id}/revoke",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{202:{description:"Sesssion deletion status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param");if(!await t.env.data.sessions.update(e,n,{revoked_at:new Date().toDateString()}))throw new z(404,{message:"Session not found"});return t.text("Session deletion request accepted.",{status:202})}),Nw=new o.OpenAPIHono().openapi(o.createRoute({tags:["refresh_tokens"],method:"get",path:"/{id}",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:il}},description:"A session"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),r=await t.env.data.refreshTokens.get(e,n);if(!r)throw new z(404);return t.json(r)}).openapi(o.createRoute({tags:["refresh_tokens"],method:"delete",path:"/{id}",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param");if(!await t.env.data.refreshTokens.remove(e,n))throw new z(404,{message:"Session not found"});return t.text("OK")}),Cw=new o.OpenAPIHono().openapi(o.createRoute({tags:["custom-domains"],method:"get",path:"/",request:{query:Qt,headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:o.z.array(Ft)}},description:"List of custom domains"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=await t.env.data.customDomains.list(e);return t.json(n)}).openapi(o.createRoute({tags:["custom-domains"],method:"get",path:"/{id}",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Ft}},description:"A connection"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),r=await t.env.data.customDomains.get(e,n);if(!r)throw new z(404);return t.json(r)}).openapi(o.createRoute({tags:["custom-domains"],method:"delete",path:"/{id}",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param");if(!await t.env.data.customDomains.remove(e,n))throw new z(404,{message:"Custom domain not found"});return t.text("OK")}).openapi(o.createRoute({tags:["custom-domains"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:o.z.object(Ft.shape).partial()}}},params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Ft}},description:"The updated custom domain"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),r=t.req.valid("json");if(!await t.env.data.customDomains.update(e,n,r))throw new z(404);const s=await t.env.data.customDomains.get(e,n);if(!s)throw new z(404);return t.json(s)}).openapi(o.createRoute({tags:["custom-domains"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:o.z.object(nl.shape)}}},headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Ft}},description:"The created custom domain"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),r=await t.env.data.customDomains.create(e,n);return t.json(r,{status:201})}).openapi(o.createRoute({tags:["custom-domains"],method:"post",path:"/{id}/verify",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Ft}},description:"The custom domain"}}}),async()=>{throw new z(501,{message:"Not implemented"})});async function nu(t,e){const n=t.req.header("x-forwarded-host");if(n){const i=await t.env.data.customDomains.getByDomain(n);if(i)return t.set("tenant_id",i.tenant_id),await e()}const r=t.req.header("host");if(r){const i=r.split(".");if(i.length>1&&typeof i[0]=="string"){const s=i[0];await t.env.data.tenants.get(s)&&t.set("tenant_id",s)}}return await e()}function jw(t){const e=new o.OpenAPIHono;Pg(e),e.use(async(r,i)=>(r.env.data=no(r,t.dataAdapter),i())),e.use(nu).use(Rg(e));const n=e.route("/branding",i_).route("/custom-domains",Cw).route("/email/providers",Iw).route("/users",fy).route("/keys",dw).route("/users-by-email",pw).route("/clients",hw).route("/tenants",mw).route("/logs",yw).route("/hooks",ww).route("/connections",kw).route("/prompts",xw).route("/sessions",zw).route("/refresh_tokens",Nw);return n.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Management api"},security:[{oauth2:["openid","email","profile"]}]}),n}function $w(t,e){Object.keys(e).forEach(n=>{const r=e[n];r!=null&&r.length&&t.searchParams.set(n,r)})}var Ip;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(Ip||(Ip={}));var zp;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(zp||(zp={}));function Ow(t){return Ug(t,Bw,ei.Include)}function Lg(t){return Ug(t,Tw,ei.None)}function Ug(t,e,n){let r="";for(let i=0;i<t.byteLength;i+=3){let s=0,a=0;for(let c=0;c<3&&i+c<t.byteLength;c++)s=s<<8|t[i+c],a+=8;for(let c=0;c<4;c++)a>=6?(r+=e[s>>a-6&63],a-=6):a>0?(r+=e[s<<6-a&63],a=0):n===ei.Include&&(r+="=")}return r}const Bw="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Tw="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";var ei;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(ei||(ei={}));var Np;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(Np||(Np={}));class Pw{uint8(e,n){if(e.byteLength<n+1)throw new TypeError("Insufficient bytes");return e[n]}uint16(e,n){if(e.byteLength<n+2)throw new TypeError("Insufficient bytes");return e[n]<<8|e[n+1]}uint32(e,n){if(e.byteLength<n+4)throw new TypeError("Insufficient bytes");let r=0;for(let i=0;i<4;i++)r|=e[n+i]<<24-i*8;return r}uint64(e,n){if(e.byteLength<n+8)throw new TypeError("Insufficient bytes");let r=0n;for(let i=0;i<8;i++)r|=BigInt(e[n+i])<<BigInt(56-i*8);return r}putUint8(e,n,r){if(e.length<r+1)throw new TypeError("Not enough space");if(n<0||n>255)throw new TypeError("Invalid uint8 value");e[r]=n}putUint16(e,n,r){if(e.length<r+2)throw new TypeError("Not enough space");if(n<0||n>65535)throw new TypeError("Invalid uint16 value");e[r]=n>>8,e[r+1]=n&255}putUint32(e,n,r){if(e.length<r+4)throw new TypeError("Not enough space");if(n<0||n>4294967295)throw new TypeError("Invalid uint32 value");for(let i=0;i<4;i++)e[r+i]=n>>(3-i)*8&255}putUint64(e,n,r){if(e.length<r+8)throw new TypeError("Not enough space");if(n<0||n>18446744073709551615n)throw new TypeError("Invalid uint64 value");for(let i=0;i<8;i++)e[r+i]=Number(n>>BigInt((7-i)*8)&0xffn)}}const Cp=new Pw;function kt(t,e){return(t<<32-e|t>>>e)>>>0}function Rw(t){const e=new Lw;return e.update(t),e.digest()}class Lw{constructor(){te(this,"blockSize",64);te(this,"size",32);te(this,"blocks",new Uint8Array(64));te(this,"currentBlockSize",0);te(this,"H",new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]));te(this,"l",0n);te(this,"w",new Uint32Array(64))}update(e){if(this.l+=BigInt(e.byteLength)*8n,this.currentBlockSize+e.byteLength<64){this.blocks.set(e,this.currentBlockSize),this.currentBlockSize+=e.byteLength;return}let n=0;if(this.currentBlockSize>0){const r=e.slice(0,64-this.currentBlockSize);this.blocks.set(r,this.currentBlockSize),this.process(),n+=r.byteLength,this.currentBlockSize=0}for(;n+64<=e.byteLength;){const r=e.slice(n,n+64);this.blocks.set(r),this.process(),n+=64}if(e.byteLength-n>0){const r=e.slice(n);this.blocks.set(r),this.currentBlockSize=r.byteLength}}digest(){this.blocks[this.currentBlockSize]=128,this.currentBlockSize+=1,64-this.currentBlockSize<8&&(this.blocks.fill(0,this.currentBlockSize),this.process(),this.currentBlockSize=0),this.blocks.fill(0,this.currentBlockSize),Cp.putUint64(this.blocks,this.l,this.blockSize-8),this.process();const e=new Uint8Array(32);for(let n=0;n<8;n++)Cp.putUint32(e,this.H[n],n*4);return e}process(){for(let u=0;u<16;u++)this.w[u]=(this.blocks[u*4]<<24|this.blocks[u*4+1]<<16|this.blocks[u*4+2]<<8|this.blocks[u*4+3])>>>0;for(let u=16;u<64;u++){const p=(kt(this.w[u-2],17)^kt(this.w[u-2],19)^this.w[u-2]>>>10)>>>0,h=(kt(this.w[u-15],7)^kt(this.w[u-15],18)^this.w[u-15]>>>3)>>>0;this.w[u]=p+this.w[u-7]+h+this.w[u-16]|0}let e=this.H[0],n=this.H[1],r=this.H[2],i=this.H[3],s=this.H[4],a=this.H[5],c=this.H[6],l=this.H[7];for(let u=0;u<64;u++){const p=(kt(s,6)^kt(s,11)^kt(s,25))>>>0,h=(s&a^~s&c)>>>0,m=l+p+h+Uw[u]+this.w[u]|0,v=(kt(e,2)^kt(e,13)^kt(e,22))>>>0,f=(e&n^e&r^n&r)>>>0,_=v+f|0;l=c,c=a,a=s,s=i+m|0,i=r,r=n,n=e,e=m+_|0}this.H[0]=e+this.H[0]|0,this.H[1]=n+this.H[1]|0,this.H[2]=r+this.H[2]|0,this.H[3]=i+this.H[3]|0,this.H[4]=s+this.H[4]|0,this.H[5]=a+this.H[5]|0,this.H[6]=c+this.H[6]|0,this.H[7]=l+this.H[7]|0}}const Uw=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);new BigUint64Array([0x428a2f98d728ae22n,0x7137449123ef65cdn,0xb5c0fbcfec4d3b2fn,0xe9b5dba58189dbbcn,0x3956c25bf348b538n,0x59f111f1b605d019n,0x923f82a4af194f9bn,0xab1c5ed5da6d8118n,0xd807aa98a3030242n,0x12835b0145706fben,0x243185be4ee4b28cn,0x550c7dc3d5ffb4e2n,0x72be5d74f27b896fn,0x80deb1fe3b1696b1n,0x9bdc06a725c71235n,0xc19bf174cf692694n,0xe49b69c19ef14ad2n,0xefbe4786384f25e3n,0x0fc19dc68b8cd5b5n,0x240ca1cc77ac9c65n,0x2de92c6f592b0275n,0x4a7484aa6ea6e483n,0x5cb0a9dcbd41fbd4n,0x76f988da831153b5n,0x983e5152ee66dfabn,0xa831c66d2db43210n,0xb00327c898fb213fn,0xbf597fc7beef0ee4n,0xc6e00bf33da88fc2n,0xd5a79147930aa725n,0x06ca6351e003826fn,0x142929670a0e6e70n,0x27b70a8546d22ffcn,0x2e1b21385c26c926n,0x4d2c6dfc5ac42aedn,0x53380d139d95b3dfn,0x650a73548baf63den,0x766a0abb3c77b2a8n,0x81c2c92e47edaee6n,0x92722c851482353bn,0xa2bfe8a14cf10364n,0xa81a664bbc423001n,0xc24b8b70d0f89791n,0xc76c51a30654be30n,0xd192e819d6ef5218n,0xd69906245565a910n,0xf40e35855771202an,0x106aa07032bbd1b8n,0x19a4c116b8d2d0c8n,0x1e376c085141ab53n,0x2748774cdf8eeb99n,0x34b0bcb5e19b48a8n,0x391c0cb3c5c95a63n,0x4ed8aa4ae3418acbn,0x5b9cca4f7763e373n,0x682e6ff3d6b2b8a3n,0x748f82ee5defb2fcn,0x78a5636f43172f60n,0x84c87814a1f0ab72n,0x8cc702081a6439ecn,0x90befffa23631e28n,0xa4506cebde82bde9n,0xbef9a3f7b2c67915n,0xc67178f2e372532bn,0xca273eceea26619cn,0xd186b8c721c0c207n,0xeada7dd6cde0eb1en,0xf57d4f7fee6ed178n,0x06f067aa72176fban,0x0a637dc5a2c898a6n,0x113f9804bef90daen,0x1b710b35131c471bn,0x28db77f523047d84n,0x32caab7b40c72493n,0x3c9ebe0a15c9bebcn,0x431d67c49c100d4cn,0x4cc5d4becb3e42b6n,0x597f299cfc657e2an,0x5fcb6fab3ad6faecn,0x6c44198c4a475817n]);class Vw{constructor(e){te(this,"data");this.data=e}tokenType(){if("token_type"in this.data&&typeof this.data.token_type=="string")return this.data.token_type;throw new Error("Missing or invalid 'token_type' field")}accessToken(){if("access_token"in this.data&&typeof this.data.access_token=="string")return this.data.access_token;throw new Error("Missing or invalid 'access_token' field")}accessTokenExpiresInSeconds(){if("expires_in"in this.data&&typeof this.data.expires_in=="number")return this.data.expires_in;throw new Error("Missing or invalid 'expires_in' field")}accessTokenExpiresAt(){return new Date(Date.now()+this.accessTokenExpiresInSeconds()*1e3)}hasRefreshToken(){return"refresh_token"in this.data&&typeof this.data.refresh_token=="string"}refreshToken(){if("refresh_token"in this.data&&typeof this.data.refresh_token=="string")return this.data.refresh_token;throw new Error("Missing or invalid 'refresh_token' field")}hasScopes(){return"scope"in this.data&&typeof this.data.scope=="string"}scopes(){if("scope"in this.data&&typeof this.data.scope=="string")return this.data.scope.split(" ");throw new Error("Missing or invalid 'scope' field")}idToken(){if("id_token"in this.data&&typeof this.data.id_token=="string")return this.data.id_token;throw new Error("Missing or invalid field 'id_token'")}}function qw(t){const e=Rw(new TextEncoder().encode(t));return Lg(e)}function Mw(){const t=new Uint8Array(32);return crypto.getRandomValues(t),Lg(t)}function Ur(t,e){const n=new TextEncoder().encode(e.toString()),r=new Request(t,{method:"POST",body:n});return r.headers.set("Content-Type","application/x-www-form-urlencoded"),r.headers.set("Accept","application/json"),r.headers.set("User-Agent","arctic"),r.headers.set("Content-Length",n.byteLength.toString()),r}function ha(t,e){const n=new TextEncoder().encode(`${t}:${e}`);return Ow(n)}async function Hs(t){let e;try{e=await fetch(t)}catch(n){throw new qg(n)}if(e.status===400||e.status===401){let n;try{n=await e.json()}catch{throw new Hi(e.status)}if(typeof n!="object"||n===null)throw new Gn(e.status,n);let r;try{r=Vg(n)}catch{throw new Gn(e.status,n)}throw r}if(e.status===200){let n;try{n=await e.json()}catch{throw new Hi(e.status)}if(typeof n!="object"||n===null)throw new Gn(e.status,n);return new Vw(n)}throw e.body!==null&&await e.body.cancel(),new Hi(e.status)}async function Dw(t){let e;try{e=await fetch(t)}catch(n){throw new qg(n)}if(e.status===400||e.status===401){let n;try{n=await e.json()}catch{throw new Gn(e.status,null)}if(typeof n!="object"||n===null)throw new Gn(e.status,n);let r;try{r=Vg(n)}catch{throw new Gn(e.status,n)}throw r}if(e.status===200){e.body!==null&&await e.body.cancel();return}throw e.body!==null&&await e.body.cancel(),new Hi(e.status)}function Vg(t){let e;if("error"in t&&typeof t.error=="string")e=t.error;else throw new Error("Invalid error response");let n=null,r=null,i=null;if("error_description"in t){if(typeof t.error_description!="string")throw new Error("Invalid data");n=t.error_description}if("error_uri"in t){if(typeof t.error_uri!="string")throw new Error("Invalid data");r=t.error_uri}if("state"in t){if(typeof t.state!="string")throw new Error("Invalid data");i=t.state}return new Hw(e,n,r,i)}class qg extends Error{constructor(e){super("Failed to send request",{cause:e})}}class Hw extends Error{constructor(n,r,i,s){super(`OAuth request error: ${n}`);te(this,"code");te(this,"description");te(this,"uri");te(this,"state");this.code=n,this.description=r,this.uri=i,this.state=s}}class Hi extends Error{constructor(n){super("Unexpected error response");te(this,"status");this.status=n}}class Gn extends Error{constructor(n,r){super("Unexpected error response body");te(this,"status");te(this,"data");this.status=n,this.data=r}}class ru{constructor(e,n,r){te(this,"clientId");te(this,"clientPassword");te(this,"redirectURI");this.clientId=e,this.clientPassword=n,this.redirectURI=r}createAuthorizationURL(e,n,r){const i=new URL(e);return i.searchParams.set("response_type","code"),i.searchParams.set("client_id",this.clientId),this.redirectURI!==null&&i.searchParams.set("redirect_uri",this.redirectURI),i.searchParams.set("state",n),r.length>0&&i.searchParams.set("scope",r.join(" ")),i}createAuthorizationURLWithPKCE(e,n,r,i,s){const a=new URL(e);if(a.searchParams.set("response_type","code"),a.searchParams.set("client_id",this.clientId),this.redirectURI!==null&&a.searchParams.set("redirect_uri",this.redirectURI),a.searchParams.set("state",n),r===ti.S256){const c=qw(i);a.searchParams.set("code_challenge_method","S256"),a.searchParams.set("code_challenge",c)}else r===ti.Plain&&(a.searchParams.set("code_challenge_method","plain"),a.searchParams.set("code_challenge",i));return s.length>0&&a.searchParams.set("scope",s.join(" ")),a}async validateAuthorizationCode(e,n,r){const i=new URLSearchParams;i.set("grant_type","authorization_code"),i.set("code",n),this.redirectURI!==null&&i.set("redirect_uri",this.redirectURI),r!==null&&i.set("code_verifier",r),this.clientPassword===null&&i.set("client_id",this.clientId);const s=Ur(e,i);if(this.clientPassword!==null){const c=ha(this.clientId,this.clientPassword);s.headers.set("Authorization",`Basic ${c}`)}return await Hs(s)}async refreshAccessToken(e,n,r){const i=new URLSearchParams;i.set("grant_type","refresh_token"),i.set("refresh_token",n),this.clientPassword===null&&i.set("client_id",this.clientId),r.length>0&&i.set("scope",r.join(" "));const s=Ur(e,i);if(this.clientPassword!==null){const c=ha(this.clientId,this.clientPassword);s.headers.set("Authorization",`Basic ${c}`)}return await Hs(s)}async revokeToken(e,n){const r=new URLSearchParams;r.set("token",n),this.clientPassword===null&&r.set("client_id",this.clientId);const i=Ur(e,r);if(this.clientPassword!==null){const s=ha(this.clientId,this.clientPassword);i.headers.set("Authorization",`Basic ${s}`)}await Dw(i)}}var ti;(function(t){t[t.S256=0]="S256",t[t.Plain=1]="Plain"})(ti||(ti={}));var jp;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(jp||(jp={}));var $p;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})($p||($p={}));function Vr(t){return Fw(t,Kw,Fs.None)}function Fw(t,e,n){let r="";for(let i=0;i<t.byteLength;i+=3){let s=0,a=0;for(let c=0;c<3&&i+c<t.byteLength;c++)s=s<<8|t[i+c],a+=8;for(let c=0;c<4;c++)a>=6?(r+=e[s>>a-6&63],a-=6):a>0?(r+=e[s<<6-a&63],a=0):n===Fs.Include&&(r+="=")}return r}const Kw="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";var Fs;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(Fs||(Fs={}));var Op;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(Op||(Op={}));function Ww(t,e,n){const r=Vr(new TextEncoder().encode(t)),i=Vr(new TextEncoder().encode(e)),s=Vr(n);return r+"."+i+"."+s}function Gw(t,e){const n=Vr(new TextEncoder().encode(t)),r=Vr(new TextEncoder().encode(e)),i=n+"."+r;return new TextEncoder().encode(i)}const Jw="https://appleid.apple.com/auth/authorize",Zw="https://appleid.apple.com/auth/token";class Mg{constructor(e,n,r,i,s){te(this,"clientId");te(this,"teamId");te(this,"keyId");te(this,"pkcs8PrivateKey");te(this,"redirectURI");this.clientId=e,this.teamId=n,this.keyId=r,this.pkcs8PrivateKey=i,this.redirectURI=s}createAuthorizationURL(e,n){const r=new URL(Jw);return r.searchParams.set("response_type","code"),r.searchParams.set("client_id",this.clientId),r.searchParams.set("state",e),n.length>0&&r.searchParams.set("scope",n.join(" ")),r.searchParams.set("redirect_uri",this.redirectURI),r}async validateAuthorizationCode(e){const n=new URLSearchParams;n.set("grant_type","authorization_code"),n.set("code",e),n.set("redirect_uri",this.redirectURI),n.set("client_id",this.clientId);const r=await this.createClientSecret();n.set("client_secret",r);const i=Ur(Zw,n);return await Hs(i)}async createClientSecret(){const e=await crypto.subtle.importKey("pkcs8",this.pkcs8PrivateKey,{name:"ECDSA",namedCurve:"P-256"},!1,["sign"]),n=Math.floor(Date.now()/1e3),r=JSON.stringify({typ:"JWT",alg:"ES256",kid:this.keyId}),i=JSON.stringify({iss:this.teamId,exp:n+5*60,aud:["https://appleid.apple.com"],sub:this.clientId,iat:n}),s=new Uint8Array(await crypto.subtle.sign({name:"ECDSA",hash:"SHA-256"},e,Gw(r,i)));return Ww(r,i,s)}}const Yw="https://www.facebook.com/v16.0/dialog/oauth",Xw="https://graph.facebook.com/v16.0/oauth/access_token";class Dg{constructor(e,n,r){te(this,"clientId");te(this,"clientSecret");te(this,"redirectURI");this.clientId=e,this.clientSecret=n,this.redirectURI=r}createAuthorizationURL(e,n){const r=new URL(Yw);return r.searchParams.set("response_type","code"),r.searchParams.set("client_id",this.clientId),r.searchParams.set("state",e),n.length>0&&r.searchParams.set("scope",n.join(" ")),r.searchParams.set("redirect_uri",this.redirectURI),r}async validateAuthorizationCode(e){const n=new URLSearchParams;n.set("grant_type","authorization_code"),n.set("code",e),n.set("redirect_uri",this.redirectURI),n.set("client_id",this.clientId),n.set("client_secret",this.clientSecret);const r=Ur(Xw,n);return await Hs(r)}}const Qw="https://accounts.google.com/o/oauth2/v2/auth",Bp="https://oauth2.googleapis.com/token",eb="https://oauth2.googleapis.com/revoke";let Hg=class{constructor(e,n,r){te(this,"client");this.client=new ru(e,n,r)}createAuthorizationURL(e,n,r){return this.client.createAuthorizationURLWithPKCE(Qw,e,ti.S256,n,r)}async validateAuthorizationCode(e,n){return await this.client.validateAuthorizationCode(Bp,e,n)}async refreshAccessToken(e){return await this.client.refreshAccessToken(Bp,e,[])}async revokeToken(e){await this.client.revokeToken(eb,e)}};const Jo=o.z.object({iss:o.z.string().url(),sub:o.z.string(),aud:o.z.string(),exp:o.z.number(),email:o.z.string().optional(),given_name:o.z.string().optional(),family_name:o.z.string().optional(),name:o.z.string().optional(),iat:o.z.number(),auth_time:o.z.number().optional(),nonce:o.z.string().optional(),acr:o.z.string().optional(),amr:o.z.array(o.z.string()).optional(),azp:o.z.string().optional(),at_hash:o.z.string().optional(),c_hash:o.z.string().optional()}).passthrough();Jo.omit({iat:!0,auth_time:!0,nonce:!0,acr:!0,amr:!0,azp:!0,at_hash:!0,c_hash:!0});function tb(t){return t.ISSUER}function _t(t){return t.UNIVERSAL_LOGIN_URL||`${t.ISSUER}u/`}function je(t){return t.OAUTH_API_URL||t.ISSUER}function Fg(t){const{options:e}=t;if(!e||!e.client_id||!e.team_id||!e.kid||!e.app_secret)throw new Error("Missing required Apple authentication parameters");const n=Buffer.from(e.app_secret,"utf-8"),r=n.toString().replace(/-----BEGIN PRIVATE KEY-----|-----END PRIVATE KEY-----|\s/g,""),i=Uint8Array.from(Buffer.from(r,"base64"));return n.fill(0),{options:e,keyArray:i}}async function nb(t,e){var l,u;const{options:n,keyArray:r}=Fg(e),i=new Mg(n.client_id,n.team_id,n.kid,r,`${je(t.env)}callback`),s=xe(),a=await i.createAuthorizationURL(s,((l=n.scope)==null?void 0:l.split(" "))||["name","email"]);return(((u=n.scope)==null?void 0:u.split(" "))||["name","email"]).some(p=>["email","name"].includes(p))&&a.searchParams.set("response_mode","form_post"),{redirectUrl:a.href,code:s}}async function rb(t,e,n){const{options:r,keyArray:i}=Fg(e),a=await new Mg(r.client_id,r.team_id,r.kid,i,`${je(t.env)}callback`).validateAuthorizationCode(n),c=ol(a.idToken());if(!c)throw new Error("Invalid ID token");const l=Jo.parse(c.payload);return{sub:l.sub,email:l.email,given_name:l.given_name,family_name:l.family_name,name:l.name,picture:l.picture,locale:l.locale}}const ib=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:nb,validateAuthorizationCodeAndGetUser:rb},Symbol.toStringTag,{value:"Module"}));async function sb(t,e){var a;const{options:n}=e;if(!(n!=null&&n.client_id)||!n.client_secret)throw new Error("Missing required authentication parameters");const r=new Dg(n.client_id,n.client_secret,`${je(t.env)}callback`),i=xe();return{redirectUrl:r.createAuthorizationURL(i,((a=n.scope)==null?void 0:a.split(" "))||["email"]).href,code:i}}async function ob(t,e,n){const{options:r}=e;if(!(r!=null&&r.client_id)||!r.client_secret)throw new Error("Missing required authentication parameters");const s=await new Dg(r.client_id,r.client_secret,`${je(t.env)}callback`).validateAuthorizationCode(n),a=await fetch("https://graph.facebook.com/v16.0/me?fields=id,email,name",{headers:{Authorization:`Bearer ${s.accessToken()}`}});if(!a.ok)throw new Error("Failed to fetch user info");const c=await a.json();return t.set("log",`Userinfo: ${JSON.stringify(c)}`),{sub:c.id,email:c.email,name:c.name}}const ab=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:sb,validateAuthorizationCodeAndGetUser:ob},Symbol.toStringTag,{value:"Module"}));async function cb(t,e){var c;const{options:n}=e;if(!(n!=null&&n.client_id)||!n.client_secret)throw new Error("Missing required Google authentication parameters");const r=new Hg(n.client_id,n.client_secret,`${je(t.env)}callback`),i=xe(),s=Mw();return{redirectUrl:r.createAuthorizationURL(i,s,((c=n.scope)==null?void 0:c.split(" "))??["email","profile"]).href,code:i,codeVerifier:s}}async function lb(t,e,n,r){const{options:i}=e;if(!(i!=null&&i.client_id)||!i.client_secret||!r)throw new Error("Missing required authentication parameters");const a=await new Hg(i.client_id,i.client_secret,`${je(t.env)}callback`).validateAuthorizationCode(n,r),c=ol(a.idToken());if(!c)throw new Error("Invalid ID token");const l=Jo.parse(c.payload);return{sub:l.sub,email:l.email,given_name:l.given_name,family_name:l.family_name,name:l.name,picture:l.picture,locale:l.locale}}const ub=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:cb,validateAuthorizationCodeAndGetUser:lb},Symbol.toStringTag,{value:"Module"}));async function db(t,e){var a;const{options:n}=e;if(!(n!=null&&n.client_id)||!n.client_secret)throw new Error("Missing required authentication parameters");const r=new ru(n.client_id,n.client_secret,`${je(t.env)}callback`),i=xe(),s=r.createAuthorizationURL("https://api.vipps.no/access-management-1.0/access/oauth2/auth",i,((a=n.scope)==null?void 0:a.split(" "))||["openid","email","phoneNumber","name","address","birthDate"]);return s.searchParams.set("response_type","code"),s.searchParams.set("response_mode","query"),{redirectUrl:s.href,code:i}}async function pb(t,e,n){const{options:r}=e;if(!(r!=null&&r.client_id)||!r.client_secret)throw new Error("Missing required authentication parameters");const s=await new ru(r.client_id,r.client_secret,`${je(t.env)}callback`).validateAuthorizationCode("https://api.vipps.no/access-management-1.0/access/oauth2/token",n,null),a=ol(s.idToken());if(!a)throw new Error("Invalid ID token");const c=Jo.parse(a.payload);if(typeof c.msn!="string")throw new Error("msn not available in id token");const l=await fetch("https://api.vipps.no/vipps-userinfo-api/userinfo",{headers:{Authorization:`Bearer ${s.accessToken()}`,"Merchant-Serial-Number":c.msn}});if(!l.ok)throw new z(400,{message:"Failed to get user from vipps"});return await l.json()}const fb=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:db,validateAuthorizationCodeAndGetUser:pb},Symbol.toStringTag,{value:"Module"}));function Kg(t,e){const n=t.env.STRATEGIES||{},i={apple:ib,facebook:ab,"google-oauth2":ub,vipps:fb,...n}[e];if(!i)throw new Error(`Strategy ${e} not found`);return i}async function Zo(t,e){const n=await t.data.clients.get(e);if(!n)throw new z(403,{message:"Client not found"});const r=t.DEFAULT_CLIENT_ID?await t.data.clients.get(t.DEFAULT_CLIENT_ID):void 0,i=await t.data.connections.list(n.tenant.id),s=t.DEFAULT_TENANT_ID?await t.data.connections.list(t.DEFAULT_TENANT_ID):{connections:[]},a=i.connections.map(c=>{var p;const l=(p=s.connections)==null?void 0:p.find(h=>h.name===c.name);return l!=null&&l.options?Kt.parse({...l||{},...c,options:{...l.options||{},...c.options}}):c}).filter(c=>c);return{...n,web_origins:[...(r==null?void 0:r.web_origins)||[],...n.web_origins||[],`${_t(t)}login`],allowed_logout_urls:[...(r==null?void 0:r.allowed_logout_urls)||[],...n.allowed_logout_urls||[],t.ISSUER],callbacks:[...(r==null?void 0:r.callbacks)||[],...n.callbacks||[],`${_t(t)}info`],connections:a,tenant:{...(r==null?void 0:r.tenant)||{},...n.tenant}}}function Yo(t,e=[],n={}){try{const r=new URL(t);return e.some(i=>{try{return hb(r,new URL(i),n.allowPathWildcards)}catch{return!1}})}catch{return!1}}function hb(t,e,n){if(t.protocol!==e.protocol)return!1;if(n&&e.pathname.includes("*")){const r=e.pathname.replace(/\*/g,".*").replace(/\//g,"\\/");if(!new RegExp(`^${r}$`).test(t.pathname))return!1}else if(t.pathname!==e.pathname)return!1;if(e.hostname.startsWith("*.")&&e.hostname.split(".").length>2&&["http:","https:"].includes(e.protocol)){const r=e.hostname.split(".").slice(1).join(".");return t.hostname.endsWith(r)}return t.hostname===e.hostname}async function gb(t,e,n,r){if(!r.state)throw new z(400,{message:"State not found"});const i=e.connections.find(l=>l.name===n);if(!i){t.set("client_id",e.id);const l=ve(t,{type:he.FAILED_LOGIN,description:"Connection not found"});throw await t.env.data.logs.create(e.tenant.id,l),new z(403,{message:"Connection Not Found"})}let s=await t.env.data.loginSessions.get(e.tenant.id,r.state);s||(s=await t.env.data.loginSessions.create(e.tenant.id,{expires_at:new Date(Date.now()+Jn*1e3).toISOString(),authParams:r,csrf_token:xe(),...on(t.req)}));const c=await Kg(t,i.strategy).getRedirect(t,i);return await t.env.data.codes.create(e.tenant.id,{login_id:s.id,code_id:c.code,code_type:"oauth2_state",connection_id:i.id,code_verifier:c.codeVerifier,expires_at:new Date(Date.now()+N_*1e3).toISOString()}),t.redirect(c.redirectUrl)}async function Tp(t,{code:e,state:n}){var f;const{env:r}=t,i=await r.data.codes.get(t.var.tenant_id||"",n,"oauth2_state");if(!i||!i.connection_id)throw new z(403,{message:"State not found"});const s=await r.data.loginSessions.get(t.var.tenant_id||"",i.login_id);if(!s)throw new z(403,{message:"Session not found"});const a=await Zo(r,s.authParams.client_id);t.set("client_id",a.id),t.set("tenant_id",a.tenant.id);const c=a.connections.find(_=>_.id===i.connection_id);if(!c){const _=ve(t,{type:he.FAILED_LOGIN,description:"Connection not found"});throw await r.data.logs.create(a.tenant.id,_),new z(403,{message:"Connection not found"})}if(t.set("connection",c.name),!s.authParams.redirect_uri){const _=ve(t,{type:he.FAILED_LOGIN,description:"Redirect URI not defined"});throw await r.data.logs.create(a.tenant.id,_),new z(403,{message:"Redirect URI not defined"})}if(!Yo(s.authParams.redirect_uri,a.callbacks||[],{allowPathWildcards:!0})){const _=`Invalid redirect URI - ${s.authParams.redirect_uri}`,w=ve(t,{type:he.FAILED_LOGIN,description:_});throw await r.data.logs.create(a.tenant.id,w),new z(403,{message:_})}const u=await Kg(t,c.strategy).validateAuthorizationCodeAndGetUser(t,c,e,i.code_verifier),{sub:p,...h}=u;t.set("user_id",p);const m=((f=u.email)==null?void 0:f.toLocaleLowerCase())||`${c.name}.${p}@${new URL(t.env.ISSUER).hostname}`;t.set("username",m);const v=await io(t,{client:a,email:m,provider:c.strategy,connection:c.name,userId:p,profileData:h,isSocial:!0,ip:t.req.header("x-real-ip")});return an(t,{client:a,authParams:s.authParams,loginSession:s,user:v})}async function Pp(t,e,n,r,i,s){const a=await t.env.data.codes.get(t.var.tenant_id||"",e,"oauth2_state");if(!a)throw new z(400,{message:"State not found"});const c=await t.env.data.loginSessions.get(t.var.tenant_id,a.login_id);if(!c)throw new z(400,{message:"Login not found"});const{redirect_uri:l}=c.authParams;if(!l)throw new z(400,{message:"Redirect uri not found"});const u=ve(t,{type:he.FAILED_LOGIN,description:`Failed connection login: ${i} ${n}, ${r}`});nt(t,t.env.data.logs.create(t.var.tenant_id,u));const p=new URL(l);return $w(p,{error:n,error_description:r,error_reason:s,error_code:i,state:c.authParams.state}),t.redirect(`${_t(t.env)}enter-email?state=${c.id}&error=${n}`)}const mb=new o.OpenAPIHono().openapi(o.createRoute({tags:["oauth2"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string(),code:o.z.string().optional(),scope:o.z.string().optional(),hd:o.z.string().optional(),error:o.z.string().optional(),error_description:o.z.string().optional(),error_code:o.z.string().optional(),error_reason:o.z.string().optional()})},responses:{302:{description:"Redirect to the client's redirect uri"}}}),async t=>{const{state:e,code:n,error:r,error_description:i,error_code:s,error_reason:a}=t.req.valid("query");if(r)return Pp(t,e,r,i,s,a);if(!n)throw new z(400,{message:"Code is required"});return Tp(t,{code:n,state:e})}).openapi(o.createRoute({tags:["oauth2"],method:"post",path:"/",request:{body:{content:{"application/x-www-form-urlencoded":{schema:o.z.object({state:o.z.string(),code:o.z.string().optional(),scope:o.z.string().optional(),hd:o.z.string().optional(),error:o.z.string().optional(),error_description:o.z.string().optional(),error_code:o.z.string().optional(),error_reason:o.z.string().optional()})}}}},responses:{302:{description:"Redirect to the client's redirect uri"}}}),async t=>{const{state:e,code:n,error:r,error_description:i,error_code:s,error_reason:a}=t.req.valid("form");if(r)return Pp(t,e,r,i,s,a);if(!n)throw new z(400,{message:"Code is required"});return Tp(t,{code:n,state:e})}),_b=new o.OpenAPIHono().openapi(o.createRoute({tags:["oauth2"],method:"get",path:"/",request:{query:o.z.object({client_id:o.z.string(),returnTo:o.z.string().optional()}),header:o.z.object({cookie:o.z.string().optional()})},responses:{302:{description:"Log the user out"}}}),async t=>{const{client_id:e,returnTo:n}=t.req.valid("query"),r=await t.env.data.clients.get(e);if(!r)return t.text("OK");const i=await t.env.data.clients.get("DEFAULT_CLIENT");t.set("client_id",e),t.set("tenant_id",r.tenant.id);const s=n||t.req.header("referer");if(!s)return t.text("OK");if(!Yo(s,[...r.allowed_logout_urls||[],...(i==null?void 0:i.allowed_logout_urls)||[]],{allowPathWildcards:!0}))throw new z(400,{message:"Invalid redirect uri"});const a=t.req.header("cookie");if(a){const l=cs(r.tenant.id,a);if(l){const u=await t.env.data.sessions.get(r.tenant.id,l);if(u){const p=await t.env.data.users.get(r.tenant.id,u.user_id);p&&(t.set("user_id",p.user_id),t.set("connection",p.connection));const h=await t.env.data.refreshTokens.list(r.tenant.id,{q:`session_id=${l}`,page:0,per_page:100,include_totals:!1});await Promise.all(h.refresh_tokens.map(m=>t.env.data.refreshTokens.remove(r.tenant.id,m.id))),await t.env.data.sessions.update(r.tenant.id,l,{revoked_at:new Date().toISOString()})}}}const c=ve(t,{type:he.SUCCESS_LOGOUT,description:"User successfully logged out"});return await t.env.data.logs.create(r.tenant.id,c),new Response("Redirecting",{status:302,headers:{"set-cookie":B_(r.tenant.id,t.req.header("host")),location:s}})}),Rp=o.z.object({sub:o.z.string(),email:o.z.string().optional(),family_name:o.z.string().optional(),given_name:o.z.string().optional(),email_verified:o.z.boolean()}),yb=new o.OpenAPIHono().openapi(o.createRoute({tags:["oauth2"],method:"get",path:"/",request:{},security:[{Bearer:["openid"]}],responses:{200:{content:{"application/json":{schema:Rp}},description:"Userinfo"}}}),async t=>{if(!t.var.user)throw new z(404,{message:"User not found"});const e=await t.env.data.users.get(t.var.user.tenant_id,t.var.user.sub);if(!e)throw new z(404,{message:"User not found"});return t.json(Rp.parse({...e,sub:e.user_id}))}),vb=new o.OpenAPIHono().openapi(o.createRoute({tags:["well known"],method:"get",path:"/jwks.json",request:{},responses:{200:{content:{"application/json":{schema:gf}},description:"List of tenants"}}}),async t=>{const e=await t.env.data.keys.list(),n=await Promise.all(e.map(async r=>{const s=await new tu(r.cert).publicKey.export(),a=await crypto.subtle.exportKey("jwk",s);return rl.parse({...a,kid:r.kid})}));return t.json({keys:n},{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${ji}, stale-while-revalidate=${ji*2}, stale-if-error=86400`}})}).openapi(o.createRoute({tags:["well known"],method:"get",path:"/openid-configuration",request:{},responses:{200:{content:{"application/json":{schema:Ea}},description:"List of tenants"}}}),async t=>{const e=Ea.parse({issuer:tb(t.env),authorization_endpoint:`${je(t.env)}authorize`,token_endpoint:`${je(t.env)}oauth/token`,device_authorization_endpoint:`${je(t.env)}oauth/device/code`,userinfo_endpoint:`${je(t.env)}userinfo`,mfa_challenge_endpoint:`${je(t.env)}mfa/challenge`,jwks_uri:`${je(t.env)}.well-known/jwks.json`,registration_endpoint:`${je(t.env)}oidc/register`,revocation_endpoint:`${je(t.env)}oauth/revoke`,scopes_supported:["openid","profile","offline_access","name","given_name","family_name","nickname","email","email_verified","picture","created_at","identities","phone","address"],response_types_supported:["code","token","id_token","code token","code id_token","token id_token","code token id_token"],code_challenge_methods_supported:["S256","plain"],response_modes_supported:["query","fragment","form_post"],subject_types_supported:["public"],id_token_signing_alg_values_supported:["RS256"],token_endpoint_auth_methods_supported:["client_secret_basic","client_secret_post"],claims_supported:["aud","auth_time","created_at","email","email_verified","exp","family_name","given_name","iat","identities","iss","name","nickname","phone_number","picture","sub"],request_uri_parameter_supported:!1,request_parameter_supported:!1,token_endpoint_auth_signing_alg_values_supported:["RS256","RS384","PS256"]});return t.json(e,{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${ji}, stale-while-revalidate=${ji*2}, stale-if-error=86400`}})});function Fi(t,e){if(!t||!e||t.length!==e.length)return!1;let n=0;for(let r=0;r<t.length;r++)n|=t.charCodeAt(r)^e.charCodeAt(r);return n===0}const Wg=o.z.object({grant_type:o.z.literal("client_credentials"),scope:o.z.string().optional(),client_secret:o.z.string(),client_id:o.z.string(),audience:o.z.string().optional()});async function wb(t,e){const n=await t.env.data.clients.get(e.client_id);if(!n)throw new z(403,{message:"Invalid client credentials"});if(n.client_secret&&!Fi(n.client_secret,e.client_secret))throw new z(403,{message:"Invalid client credentials"});const r={client_id:n.id,scope:e.scope,audience:e.audience},i=await to(t,{authParams:r,client:n});return t.json(i)}const bb=o.z.object({grant_type:o.z.literal("authorization_code"),client_id:o.z.string(),code:o.z.string(),redirect_uri:o.z.string().optional(),client_secret:o.z.string().optional(),code_verifier:o.z.string().optional()}).refine(t=>"client_secret"in t&&!("code_verifier"in t)||!("client_secret"in t)&&"code_verifier"in t,{message:"Must provide either client_secret (standard flow) or code_verifier/code_verifier_mode (PKCE flow), but not both"});async function kb(t,e){const n=await t.env.data.clients.get(e.client_id);if(!n)throw new z(403,{message:"Client not found"});const r=await t.env.data.codes.get(n.tenant.id,e.code,"authorization_code");if(!r||!r.user_id)throw new z(403,{message:"Invalid client credentials"});if(new Date(r.expires_at)<new Date)throw new z(403,{message:"Code expired"});if(r.used_at)throw new z(403,{message:"Code already used"});const i=await t.env.data.loginSessions.get(n.tenant.id,r.login_id);if(!i)throw new z(403,{message:"Invalid login"});if("client_secret"in e){const a=await t.env.data.clients.get("DEFAULT_CLIENT");if(!Fi(n.client_secret,e.client_secret)&&!Fi(a==null?void 0:a.client_secret,e.client_secret))throw new z(403,{message:"Invalid client credentials"})}else if("code_verifier"in e&&typeof e.code_verifier=="string"&&"code_challenge_method"in i.authParams&&typeof i.authParams.code_challenge_method=="string"){const a=await A_(e.code_verifier,i.authParams.code_challenge_method);if(!Fi(a,i.authParams.code_challenge||""))throw new z(403,{message:"Invalid client credentials"})}if(i.authParams.redirect_uri&&i.authParams.redirect_uri!==e.redirect_uri)throw new z(403,{message:"Invalid redirect uri"});const s=await t.env.data.users.get(n.tenant.id,r.user_id);if(!s)throw new z(403,{message:"User not found"});return await t.env.data.codes.used(n.tenant.id,e.code),an(t,{user:s,client:n,loginSession:i,authParams:{...i.authParams,response_mode:Xt.WEB_MESSAGE}})}const xb=o.z.object({grant_type:o.z.literal("refresh_token"),client_id:o.z.string(),redirect_uri:o.z.string().optional(),refresh_token:o.z.string()});async function Sb(t,e){const n=await t.env.data.clients.get(e.client_id);if(!n)throw new z(403,{message:"Client not found"});const r=await t.env.data.refreshTokens.get(n.tenant.id,e.refresh_token);if(r){if(r.expires_at&&new Date(r.expires_at)<new Date||r.idle_expires_at&&new Date(r.idle_expires_at)<new Date)throw new z(403,{message:JSON.stringify({error:"invalid_grant",error_description:"Refresh token has expired"})})}else throw new z(403,{message:JSON.stringify({error:"invalid_grant",error_description:"Invalid refresh token"})});const i=await t.env.data.users.get(n.tenant.id,r.user_id);if(!i)throw new z(403,{message:"User not found"});const s=r.resource_servers[0];if(r.idle_expires_at){const a=new Date(Date.now()+2592e6);await t.env.data.refreshTokens.update(n.tenant.id,r.id,{idle_expires_at:a.toISOString(),last_exchanged_at:new Date().toISOString(),device:{...r.device,last_ip:t.req.header["x-real-ip"]||"",last_user_agent:t.req.header["user-agent"]||""}})}return an(t,{user:i,client:n,refreshToken:r.id,sessionId:r.session_id,authParams:{client_id:n.id,audience:s==null?void 0:s.audience,scope:s==null?void 0:s.scopes,response_mode:Xt.WEB_MESSAGE}})}const Lp=o.z.object({client_id:o.z.string().optional(),client_secret:o.z.string().optional()}),Ab=o.z.union([Wg.extend(Lp.shape),o.z.object({grant_type:o.z.literal("authorization_code"),client_id:o.z.string(),code:o.z.string(),redirect_uri:o.z.string(),code_verifier:o.z.string().min(43).max(128)}),o.z.object({grant_type:o.z.literal("authorization_code"),code:o.z.string(),redirect_uri:o.z.string().optional(),...Lp.shape}),o.z.object({grant_type:o.z.literal("refresh_token"),client_id:o.z.string(),refresh_token:o.z.string(),redirect_uri:o.z.string().optional()})]);function Eb(t){if(!t)return{};const[e,n]=t.split(" ");if((e==null?void 0:e.toLowerCase())==="basic"&&n){const[r,i]=atob(n).split(":");return{client_id:r,client_secret:i}}return{}}const Ib=new o.OpenAPIHono().openapi(o.createRoute({tags:["oauth2"],method:"post",path:"/",request:{body:{content:{"application/x-www-form-urlencoded":{schema:Ab}}}},responses:{200:{content:{"application/json":{schema:bf}},description:"Tokens"}}}),async t=>{const e=t.req.valid("form"),n=Eb(t.req.header("Authorization")),r={...e,...n};if(!r.client_id)throw new z(400,{message:"client_id is required"});switch(t.set("client_id",r.client_id),e.grant_type){case Br.AuthorizationCode:return kb(t,bb.parse(r));case Br.ClientCredential:return wb(t,Wg.parse(r));case Br.RefreshToken:return Sb(t,xb.parse(r));default:throw new z(400,{message:"Not implemented"})}});var iu={exports:{}};const su=[{id:0,value:"Too weak",minDiversity:0,minLength:0},{id:1,value:"Weak",minDiversity:2,minLength:6},{id:2,value:"Medium",minDiversity:4,minLength:8},{id:3,value:"Strong",minDiversity:4,minLength:10}],Gg=(t,e=su,n="!\"#$%&'()*+,-./:;<=>?@[\\\\\\]^_`{|}~")=>{let r=t||"";e[0].minDiversity=0,e[0].minLength=0;const i=[{regex:"[a-z]",message:"lowercase"},{regex:"[A-Z]",message:"uppercase"},{regex:"[0-9]",message:"number"}];n&&i.push({regex:`[${n}]`,message:"symbol"});let s={};s.contains=i.filter(c=>new RegExp(`${c.regex}`).test(r)).map(c=>c.message),s.length=r.length;let a=e.filter(c=>s.contains.length>=c.minDiversity).filter(c=>s.length>=c.minLength).sort((c,l)=>l.id-c.id).map(c=>({id:c.id,value:c.value}));return Object.assign(s,a[0]),s};iu.exports={passwordStrength:Gg,defaultOptions:su};var zb=iu.exports.passwordStrength=Gg;iu.exports.defaultOptions=su;function ou(t){return zb(t).id<2?!1:t.length>=8&&/[a-z]/.test(t)&&/[A-Z]/.test(t)&&/[0-9]/.test(t)&&/[^A-Za-z0-9]/.test(t)}async function Si(t,e){var i;const n=await t.env.data.emailProviders.get(t.var.tenant_id)||(t.env.DEFAULT_TENANT_ID?await t.env.data.emailProviders.get(t.env.DEFAULT_TENANT_ID):null);if(!n)throw new z(500,{message:"Email provider not found"});const r=(i=t.env.emailProviders)==null?void 0:i[n.name];if(!r)throw new z(500,{message:"Email provider not found"});await r({emailProvider:n,...e,from:n.default_from_address||`login@${t.env.ISSUER}`})}async function Jg(t,e,n,r){const i=await t.env.data.tenants.get(t.var.tenant_id);if(!i)throw new z(500,{message:"Tenant not found"});const s=`${_t(t.env)}reset-password?state=${r}&code=${n}`,a={vendorName:i.name,lng:i.language||"en"};await Si(t,{to:e,subject:se("reset_password_title",a),html:`Click here to reset your password: ${_t(t.env)}reset-password?state=${r}&code=${n}`,template:"auth-password-reset",data:{vendorName:i.name,logo:i.logo||"",passwordResetUrl:s,supportUrl:i.support_url||"https://support.sesamy.com",buttonColor:i.primary_color||"#7d68f4",passwordResetTitle:se("password_reset_title",a),resetPasswordEmailClickToReset:se("reset_password_email_click_to_reset",a),resetPasswordEmailReset:se("reset_password_email_reset",a),supportInfo:se("support_info",a),contactUs:se("contact_us",a),copyright:se("copyright",a)}})}async function Zg(t,e,n){const r=await t.env.data.tenants.get(t.var.tenant_id);if(!r)throw new z(500,{message:"Tenant not found"});const i={vendorName:r.name,code:n,lng:r.language||"en"};await Si(t,{to:e,subject:se("code_email_subject",i),html:`Click here to validate your email: ${_t(t.env)}validate-email`,template:"auth-code",data:{code:n,vendorName:r.name,logo:r.logo||"",supportUrl:r.support_url||"",buttonColor:r.primary_color||"",welcomeToYourAccount:se("welcome_to_your_account",i),linkEmailClickToLogin:se("link_email_click_to_login",i),linkEmailLogin:se("link_email_login",i),linkEmailOrEnterCode:se("link_email_or_enter_code",i),codeValid30Mins:se("code_valid_30_minutes",i),supportInfo:se("support_info",i),contactUs:se("contact_us",i),copyright:se("copyright",i)}});const s=ve(t,{type:he.CODE_LINK_SENT,description:e});nt(t,t.env.data.logs.create(r.id,s))}async function au(t,e,n,r){const i=await t.env.data.tenants.get(t.var.tenant_id);if(!i)throw new z(500,{message:"Tenant not found"});if(!r.redirect_uri)throw new z(400,{message:"redirect_uri is required"});const s=new URL(je(t.env));s.pathname="passwordless/verify_redirect",s.searchParams.set("verification_code",n),s.searchParams.set("connection","email"),s.searchParams.set("client_id",r.client_id),s.searchParams.set("redirect_uri",r.redirect_uri),s.searchParams.set("email",e),r.response_type&&s.searchParams.set("response_type",r.response_type),r.scope&&s.searchParams.set("scope",r.scope),r.state&&s.searchParams.set("state",r.state),r.nonce&&s.searchParams.set("nonce",r.nonce),r.code_challenge&&s.searchParams.set("code_challenge",r.code_challenge),r.code_challenge_method&&s.searchParams.set("code_challenge_method",r.code_challenge_method),r.audience&&s.searchParams.set("audience",r.audience);const a={vendorName:i.name,code:n,lng:i.language||"en"};await Si(t,{to:e,subject:se("code_email_subject",a),html:`Click here to validate your email: ${_t(t.env)}validate-email`,template:"auth-link",data:{code:n,vendorName:i.name,logo:i.logo||"",supportUrl:i.support_url||"",magicLink:s.toString(),buttonColor:i.primary_color||"",welcomeToYourAccount:se("welcome_to_your_account",a),linkEmailClickToLogin:se("link_email_click_to_login",a),linkEmailLogin:se("link_email_login",a),linkEmailOrEnterCode:se("link_email_or_enter_code",a),codeValid30Mins:se("code_valid_30_minutes",a),supportInfo:se("support_info",a),contactUs:se("contact_us",a),copyright:se("copyright",a)}});const c=ve(t,{type:he.CODE_LINK_SENT,description:e});nt(t,t.env.data.logs.create(i.id,c))}async function cu(t,e){const n=await t.env.data.tenants.get(t.var.tenant_id);if(!n)throw new z(500,{message:"Tenant not found"});const r={vendorName:n.name,lng:n.language||"en"};await Si(t,{to:e.email,subject:se("welcome_to_your_account",r),html:`Click here to validate your email: ${_t(t.env)}validate-email`,template:"auth-verify-email",data:{vendorName:n.name,logo:n.logo||"",emailValidationUrl:`${_t(t.env)}validate-email`,supportUrl:n.support_url||"https://support.sesamy.com",buttonColor:n.primary_color||"#7d68f4",welcomeToYourAccount:se("welcome_to_your_account",r),verifyEmailVerify:se("verify_email_verify",r),supportInfo:se("support_info",r),contactUs:se("contact_us",r),copyright:se("copyright",r)}})}async function Nb(t,e,n,r){const i=await t.env.data.tenants.get(t.var.tenant_id);if(!i)throw new z(500,{message:"Tenant not found"});const s={vendorName:i.name,lng:i.language||"en"},a=`${_t(t.env)}signup?state=${r}&code=${n}`;await Si(t,{to:e,subject:se("register_password_account",s),html:`Click here to register: ${a}`,template:"auth-pre-signup-verification",data:{vendorName:i.name,logo:i.logo||"",signupUrl:a,setPassword:se("set_password",s),registerPasswordAccount:se("register_password_account",s),clickToSignUpDescription:se("click_to_sign_up_description",s),supportUrl:i.support_url||"https://support.sesamy.com",buttonColor:i.primary_color||"#7d68f4",welcomeToYourAccount:se("welcome_to_your_account",s),verifyEmailVerify:se("verify_email_verify",s),supportInfo:se("support_info",s),contactUs:se("contact_us",s),copyright:se("copyright",s)}})}const Cb=new o.OpenAPIHono().openapi(o.createRoute({tags:["dbconnections"],method:"post",path:"/signup",request:{body:{content:{"application/json":{schema:o.z.object({client_id:o.z.string(),connection:o.z.literal("Username-Password-Authentication"),email:o.z.string().transform(t=>t.toLowerCase()),password:o.z.string()})}}}},responses:{200:{content:{"application/json":{schema:o.z.object({_id:o.z.string(),email:o.z.string(),email_verified:o.z.boolean(),app_metadata:o.z.object({}),user_metadata:o.z.object({})})}},description:"Created user"}}}),async t=>{const{email:e,password:n,client_id:r}=t.req.valid("json"),i=await t.env.data.clients.get(r);if(!i)throw new z(400,{message:"Client not found"});if(t.set("client_id",i.id),t.set("tenant_id",i.tenant.id),!ou(n))throw new z(400,{message:"Password does not meet the requirements"});if(await ls({userAdapter:t.env.data.users,tenant_id:i.tenant.id,email:e,provider:"auth2"}))throw new z(400,{message:"Invalid sign up"});const a=await t.env.data.users.create(i.tenant.id,{user_id:`auth2|${Xs()}`,email:e,email_verified:!1,provider:"auth2",connection:"Username-Password-Authentication",is_social:!1});t.set("user_id",a.user_id),t.set("username",a.email),t.set("connection",a.connection);const c=await si.hash(n,10);await t.env.data.passwords.create(i.tenant.id,{user_id:a.user_id,password:c,algorithm:"bcrypt"}),await cu(t,a);const l=ve(t,{type:he.SUCCESS_SIGNUP,description:"Successful signup"});return await t.env.data.logs.create(i.tenant.id,l),t.json({_id:a.user_id,email:a.email,email_verified:!1,app_metadata:{},user_metadata:{}})}).openapi(o.createRoute({tags:["dbconnections"],method:"post",path:"/change_password",request:{body:{content:{"application/json":{schema:o.z.object({client_id:o.z.string(),connection:o.z.literal("Username-Password-Authentication"),email:o.z.string().transform(t=>t.toLowerCase())})}}}},responses:{200:{description:"Redirect to the client's redirect uri"}}}),async t=>{const{email:e,client_id:n}=t.req.valid("json"),r=await t.env.data.clients.get(n);if(!r)throw new z(400,{message:"Client not found"});if(t.set("client_id",r.id),t.set("tenant_id",r.tenant.id),!await ur({userAdapter:t.env.data.users,tenant_id:r.tenant.id,email:e,provider:"auth2"}))return t.html("If an account with that email exists, we've sent instructions to reset your password.");const s={client_id:n,username:e},a=await t.env.data.loginSessions.create(r.tenant.id,{expires_at:new Date(Date.now()+Jn*1e3).toISOString(),authParams:s,csrf_token:xe(),...on(t.req)});return await Jg(t,e,a.id,a.authParams.state),t.html("If an account with that email exists, we've sent instructions to reset your password.")});function Tn(){const t="1234567890";let e="";for(let n=0;n<6;n+=1)e+=t[Math.floor(Math.random()*10)];return e.toString()}async function lu(t,e,n,r,i,s,a){const{env:c}=t,l=await c.data.codes.get(e.tenant.id,i,"otp");if(!l)throw new z(400,{message:"Code not found or expired"});if(l.expires_at<new Date().toISOString())throw new z(400,{message:"Code expired"});if(l.used_at)throw new z(400,{message:"Code already used"});const u=await c.data.loginSessions.get(e.tenant.id,l.login_id);if(!u||u.authParams.username!==r)throw new z(400,{message:"Code not found or expired"});const p=on(t.req);if(a&&u.ip!==p.ip)return t.redirect(`${_t(t.env)}invalid-session?state=${u.id}`);if(n.redirect_uri&&!Yo(n.redirect_uri,e.callbacks,{allowPathWildcards:!0}))throw new z(400,{message:`Invalid redirect URI - ${n.redirect_uri}`});const h=await io(t,{client:e,email:r,provider:"email",connection:"email",isSocial:!1,ip:t.req.header("x-real-ip")});return await c.data.codes.used(e.tenant.id,i),an(t,{user:h,client:e,loginSession:u,authParams:n,ticketAuth:s})}const jb=new o.OpenAPIHono().openapi(o.createRoute({tags:["passwordless"],method:"post",path:"/start",request:{body:{content:{"application/json":{schema:o.z.object({client_id:o.z.string(),connection:o.z.string(),email:o.z.string().transform(t=>t.toLowerCase()),send:o.z.enum(["link","code"]),authParams:tl.omit({client_id:!0})})}}}},responses:{200:{description:"Status"}}}),async t=>{const e=t.req.valid("json"),{env:n}=t,{client_id:r,email:i,send:s,authParams:a}=e,c=await t.env.data.clients.get(r);if(!c)throw new z(400,{message:"Client not found"});t.set("client_id",c.id),t.set("tenant_id",c.tenant.id);const l=await n.data.loginSessions.create(c.tenant.id,{authParams:{...a,client_id:r,username:i},expires_at:new Date(Date.now()+Na).toISOString(),csrf_token:xe(),...on(t.req)}),u=await n.data.codes.create(c.tenant.id,{code_id:Tn(),code_type:"otp",login_id:l.id,expires_at:new Date(Date.now()+Na).toISOString()});return s==="link"?await au(t,i,u.code_id,{...a,client_id:r}):await Zg(t,i,u.code_id),t.html("OK")}).openapi(o.createRoute({tags:["passwordless"],method:"get",path:"/verify_redirect",request:{query:o.z.object({scope:o.z.string(),response_type:o.z.nativeEnum(Pt),redirect_uri:o.z.string(),state:o.z.string(),nonce:o.z.string().optional(),verification_code:o.z.string(),connection:o.z.string(),client_id:o.z.string(),email:o.z.string().transform(t=>t.toLowerCase()),audience:o.z.string().optional()})},responses:{302:{description:"Status"}}}),async t=>{const{env:e}=t,{client_id:n,email:r,verification_code:i,redirect_uri:s,state:a,scope:c,audience:l,response_type:u,nonce:p}=t.req.valid("query"),h=await Zo(e,n);return t.set("client_id",h.id),t.set("tenant_id",h.tenant.id),t.set("connection","email"),lu(t,h,{client_id:n,redirect_uri:s,state:a,nonce:p,scope:c,audience:l,response_type:u},r,i,!1,!0)});class Nr extends z{constructor(n,r){super(n,r);te(this,"_code");this._code=r==null?void 0:r.code}get code(){return this._code}}async function uu(t,e,n,r,i){const{env:s}=t,a=n.username;if(t.set("username",a),!a)throw new z(400,{message:"Username is required"});const c=await ur({userAdapter:t.env.data.users,tenant_id:e.tenant.id,email:a,provider:"auth2"});if(!c){const f=ve(t,{type:he.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid user"});throw nt(t,t.env.data.logs.create(e.tenant.id,f)),new Nr(403,{message:"User not found",code:"USER_NOT_FOUND"})}const l=c.linked_to?await s.data.users.get(e.tenant.id,c.linked_to):c;if(!l)throw new Nr(403,{message:"User not found",code:"USER_NOT_FOUND"});t.set("connection",c.connection),t.set("user_id",l.user_id);const u=await s.data.passwords.get(e.tenant.id,c.user_id);if(!(u&&await si.compare(n.password,u.password))){const f=ve(t,{type:he.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid password"});throw nt(t,t.env.data.logs.create(e.tenant.id,f)),new Nr(403,{message:"Invalid password",code:"INVALID_PASSWORD"})}if((await s.data.logs.list(e.tenant.id,{page:0,per_page:10,include_totals:!1,q:`user_id:${l.user_id}`})).logs.filter(f=>f.type===he.FAILED_LOGIN_INCORRECT_PASSWORD&&new Date(f.date)>new Date(Date.now()-1e3*60*5)).length>=3){const f=ve(t,{type:he.FAILED_LOGIN,description:"Too many failed login attempts"});throw nt(t,t.env.data.logs.create(e.tenant.id,f)),new Nr(403,{message:"Too many failed login attempts",code:"TOO_MANY_FAILED_LOGINS"})}if(!c.email_verified&&e.email_validation==="enforced"){await cu(t,c);const f=ve(t,{type:he.FAILED_LOGIN,description:"Email not verified"});throw await t.env.data.logs.create(e.tenant.id,f),new Nr(403,{message:"Email not verified",code:"EMAIL_NOT_VERIFIED"})}const v=ve(t,{type:he.SUCCESS_LOGIN,description:"Successful login",strategy_type:"Username-Password-Authentication",strategy:"Username-Password-Authentication"});return nt(t,t.env.data.logs.create(e.tenant.id,v)),an(t,{client:e,authParams:n,user:l,ticketAuth:i,loginSession:r})}async function $b(t,e,n,r){await io(t,{client:e,email:n,provider:"auth2",connection:"Username-Password-Authentication",isSocial:!1,ip:t.req.header("x-real-ip")});let i=Tn(),s=await t.env.data.codes.get(e.tenant.id,i,"password_reset");for(;s;)i=Tn(),s=await t.env.data.codes.get(e.tenant.id,i,"password_reset");const a=await t.env.data.loginSessions.create(e.tenant.id,{expires_at:new Date(Date.now()+$_).toISOString(),authParams:{client_id:e.id,username:n},csrf_token:xe(),...on(t.req)}),c=await t.env.data.codes.create(e.tenant.id,{code_id:i,code_type:"password_reset",login_id:a.id,expires_at:new Date(Date.now()+j_).toISOString()});await Jg(t,n,c.code_id,r)}const Ob=new o.OpenAPIHono().openapi(o.createRoute({tags:["oauth"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:o.z.union([o.z.object({credential_type:o.z.literal("http://auth0.com/oauth/grant-type/passwordless/otp"),otp:o.z.string(),client_id:o.z.string(),username:o.z.string().transform(t=>t.toLowerCase()),realm:o.z.enum(["email"]),scope:o.z.string().optional()}),o.z.object({credential_type:o.z.literal("http://auth0.com/oauth/grant-type/password-realm"),client_id:o.z.string(),username:o.z.string().transform(t=>t.toLowerCase()),password:o.z.string(),realm:o.z.enum(["Username-Password-Authentication"]),scope:o.z.string().optional()})])}}}},responses:{200:{description:"List of tenants"}}}),async t=>{const e=t.req.valid("json"),{client_id:n,username:r}=e;t.set("username",r);const i=await t.env.data.clients.get(n);if(!i)throw new z(400,{message:"Client not found"});t.set("client_id",n),t.set("tenant_id",i.tenant.id);const s=r.toLocaleLowerCase();if("otp"in e)return lu(t,i,{client_id:n,username:s},s,e.otp,!0);if("password"in e){const a=await t.env.data.loginSessions.create(i.tenant.id,{expires_at:new Date(Date.now()+Jn*1e3).toISOString(),authParams:{client_id:n,username:s},csrf_token:xe(),...on(t.req)});return uu(t,i,{username:s,password:e.password,client_id:n},a,!0)}else throw new z(400,{message:"Code or password required"})});function Bb(t,e){var r,i,s;if(!t||e.length===0)return!1;const n=((r=ga(t))==null?void 0:r.host)??null;if(!n)return!1;for(const a of e){let c;if(a.startsWith("http://")||a.startsWith("https://")?c=((i=ga(a))==null?void 0:i.host)??null:c=((s=ga("https://"+a))==null?void 0:s.host)??null,n===c)return!0}return!1}function ga(t){try{return new URL(t)}catch{return null}}async function Tb({ctx:t,session:e,client:n,authParams:r,connection:i,login_hint:s}){const a=await t.env.data.loginSessions.create(n.tenant.id,{expires_at:new Date(Date.now()+Jn*1e3).toISOString(),authParams:r,csrf_token:xe(),authorization_url:t.req.url,...on(t.req)});if(e&&s){const c=await t.env.data.users.get(n.tenant.id,e.user_id);if((c==null?void 0:c.email)===s)return an(t,{client:n,loginSession:a,authParams:r,user:c,sessionId:e.id})}if(i==="email"&&s){const c=Tn();return await t.env.data.codes.create(n.tenant.id,{code_id:c,code_type:"otp",login_id:a.id,expires_at:new Date(Date.now()+Jn*1e3).toISOString()}),await au(t,s,c,r),t.redirect(`/u/enter-code?state=${a.id}`)}return e?t.redirect(`/u/check-account?state=${a.id}`):t.redirect(`/u/enter-email?state=${a.id}`)}function Pb(t){if(t==="Username-Password-Authentication")return"auth2";if(t==="email")return"email";throw new z(403,{message:"Invalid realm"})}async function Rb(t,e,n,r,i){var m;const{env:s}=t;t.set("connection",i);const a=await s.data.codes.get(e,n,"ticket");if(!a||a.used_at)throw new z(403,{message:"Ticket not found"});const c=await s.data.loginSessions.get(e,a.login_id);if(!c||!c.authParams.username)throw new z(403,{message:"Session not found"});const l=await s.data.clients.get(c.authParams.client_id);if(!l)throw new z(403,{message:"Client not found"});t.set("client_id",c.authParams.client_id),await s.data.codes.used(e,n);const u=Pb(i);let p=await io(t,{email:c.authParams.username,provider:u,client:l,connection:u==="auth2"?"Username-Password-Authentication":"email",isSocial:!1,ip:t.req.header("x-real-ip")});t.set("username",p.email),t.set("user_id",p.user_id);const h=await Hf(t,{user:p,client:l,loginSession:c});return an(t,{authParams:{scope:(m=c.authParams)==null?void 0:m.scope,...r},loginSession:c,sessionId:h.id,user:p,client:l})}async function Up(t,e){return`<!DOCTYPE html>
150
150
  <html>
151
151
 
152
152
  <head>
@@ -189,17 +189,17 @@ PERFORMANCE OF THIS SOFTWARE.
189
189
  <\/script>
190
190
  </body>
191
191
 
192
- </html>`}async function Pb({ctx:t,client:e,session:n,redirect_uri:r,state:i,nonce:s,code_challenge_method:a,code_challenge:c,audience:l,scope:u,response_type:p}){const{env:h}=t,m=new URL(r),v=`${m.protocol}//${m.host}`;async function f(ce="Login required"){const le=ve(t,{type:he.FAILED_SILENT_AUTH,description:ce});return await t.env.data.logs.create(e.tenant.id,le),t.html(Lp(v,JSON.stringify({error:"login_required",error_description:ce,state:i})))}if(!n||(n==null?void 0:n.expires_at)&&new Date(n.expires_at)<new Date||(n==null?void 0:n.idle_expires_at)&&new Date(n.idle_expires_at)<new Date)return f();t.set("user_id",n.user_id);const w=await h.data.users.get(e.tenant.id,n.user_id);if(!w)return console.error("User not found",n.user_id),f("User not found");t.set("username",w.email),t.set("connection",w.connection);const S={client:e,authParams:{client_id:e.id,audience:l,code_challenge_method:a,code_challenge:c,scope:u,state:i,nonce:s,response_type:p},user:w,session_id:n.id},C=p===Pt.CODE?await Mf(t,S):await to(t,S);await h.data.sessions.update(e.tenant.id,n.id,{used_at:new Date().toISOString(),last_interaction_at:new Date().toISOString(),device:{...n.device,last_ip:t.req.header("x-real-ip")||"",last_user_agent:t.req.header("user-agent")||""},idle_expires_at:n.idle_expires_at?new Date(Date.now()+Qs*1e3).toISOString():void 0});const B=ve(t,{type:he.SUCCESS_SILENT_AUTH,description:"Successful silent authentication"});await t.env.data.logs.create(e.tenant.id,B);const L=new Headers;L.set("Server-Timing","cf-nel=0; no-cloudflare-insights=1");const Q=Bf(e.tenant.id,n.id,t.req.header("host"));return L.set("set-cookie",Q),t.html(Lp(v,JSON.stringify(C)),{headers:L})}const Rb=new o.OpenAPIHono().openapi(o.createRoute({tags:["oauth"],method:"get",path:"/",request:{query:o.z.object({client_id:o.z.string(),vendor_id:o.z.string().optional(),redirect_uri:o.z.string(),scope:o.z.string().optional(),state:o.z.string(),prompt:o.z.string().optional(),response_mode:o.z.nativeEnum(Yt).optional(),response_type:o.z.nativeEnum(Pt).optional(),audience:o.z.string().optional(),connection:o.z.string().optional(),nonce:o.z.string().optional(),max_age:o.z.string().optional(),login_ticket:o.z.string().optional(),code_challenge_method:o.z.nativeEnum(Zs).optional(),code_challenge:o.z.string().optional(),realm:o.z.string().optional(),auth0Client:o.z.string().optional(),organization:o.z.string().optional(),login_hint:o.z.string().optional(),ui_locales:o.z.string().optional()})},responses:{200:{description:"Silent authentication page"},302:{description:"Redirect to the client's redirect uri"}}}),async t=>{const{env:e}=t,{client_id:n,vendor_id:r,redirect_uri:i,scope:s,state:a,audience:c,nonce:l,connection:u,response_type:p,response_mode:h,code_challenge:m,code_challenge_method:v,prompt:f,login_ticket:_,realm:w,auth0Client:S,login_hint:C,ui_locales:B,organization:L}=t.req.valid("query");t.set("log","authorize");const Q=await Zo(e,n);t.set("client_id",Q.id),t.set("tenant_id",Q.tenant.id);const ce={redirect_uri:i,scope:s,state:a,client_id:n,vendor_id:r,audience:c,nonce:l,prompt:f,response_type:p,response_mode:h,code_challenge:m,code_challenge_method:v,username:C,ui_locales:B,organization:L},le=t.req.header("origin");if(le&&!$b(le,Q.web_origins||[]))throw new z(403,{message:`Origin ${le} not allowed`});if(ce.redirect_uri&&!Yo(ce.redirect_uri,Q.callbacks||[],{allowPathWildcards:!0}))throw new z(400,{message:`Invalid redirect URI - ${ce.redirect_uri}`});const De=cs(Q.tenant.id,t.req.header("cookie")),Ue=De?await e.data.sessions.get(Q.tenant.id,De):void 0,Re=Ue&&!Ue.revoked_at?Ue:void 0;if(f=="none"){if(!p)throw new z(400,{message:"Missing response_type"});return Pb({ctx:t,session:Re||void 0,redirect_uri:i,state:a,response_type:p,client:Q,nonce:l,code_challenge_method:v,code_challenge:m,audience:c,scope:s})}return u&&u!=="email"?fb(t,Q,u,ce):_?Tb(t,Q.tenant.id,_,ce,w):Ob({ctx:t,client:Q,auth0Client:S,authParams:ce,session:Re||void 0,connection:u,login_hint:C})});function Lb(t){const e=new o.OpenAPIHono;e.use(async(r,i)=>(r.env.data=no(r,t.dataAdapter),i())),e.use(Pg(e));const n=e.route("/v2/logout",gb).route("/userinfo",mb).route("/.well-known",_b).route("/oauth/token",Ab).route("/dbconnections",zb).route("/passwordless",Nb).route("/co/authenticate",jb).route("/authorize",Rb).route("/callback",hb);return n.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Oauth API"},security:[{oauth2:["openid","email","profile"]}]}),Tg(n),n}var Ub={Stringify:1,BeforeStream:2,Stream:3},gt=(t,e)=>{const n=new String(t);return n.isEscaped=!0,n.callbacks=e,n},Vb=/[&<>'"]/,Zg=async(t,e)=>{let n="";e||(e=[]);const r=await Promise.all(t);for(let i=r.length-1;n+=r[i],i--,!(i<0);i--){let s=r[i];typeof s=="object"&&e.push(...s.callbacks||[]);const a=s.isEscaped;if(s=await(typeof s=="object"?s.toString():s),typeof s=="object"&&e.push(...s.callbacks||[]),s.isEscaped??a)n+=s;else{const c=[n];Zt(s,c),n=c[0]}}return gt(n,e)},Zt=(t,e)=>{const n=t.search(Vb);if(n===-1){e[0]+=t;return}let r,i,s=0;for(i=n;i<t.length;i++){switch(t.charCodeAt(i)){case 34:r="&quot;";break;case 39:r="&#39;";break;case 38:r="&amp;";break;case 60:r="&lt;";break;case 62:r="&gt;";break;default:continue}e[0]+=t.substring(s,i)+r,s=i+1}e[0]+=t.substring(s,i)},Yg=t=>{const e=t.callbacks;if(!(e!=null&&e.length))return t;const n=[t],r={};return e.forEach(i=>i({phase:Ub.Stringify,buffer:n,context:r})),n[0]},qb=(t,...e)=>{const n=[""];for(let r=0,i=t.length-1;r<i;r++){n[0]+=t[r];const s=Array.isArray(e[r])?e[r].flat(1/0):[e[r]];for(let a=0,c=s.length;a<c;a++){const l=s[a];if(typeof l=="string")Zt(l,n);else if(typeof l=="number")n[0]+=l;else{if(typeof l=="boolean"||l===null||l===void 0)continue;if(typeof l=="object"&&l.isEscaped)if(l.callbacks)n.unshift("",l);else{const u=l.toString();u instanceof Promise?n.unshift("",u):n[0]+=u}else l instanceof Promise?n.unshift("",l):Zt(l.toString(),n)}}}return n[0]+=t[t.length-1],n.length===1?"callbacks"in n?gt(Yg(gt(n[0],n.callbacks))):gt(n[0]):Zg(n,n.callbacks)},uu=Symbol("RENDERER"),Zc=Symbol("ERROR_HANDLER"),Ae=Symbol("STASH"),Xg=Symbol("INTERNAL"),Mb=Symbol("MEMO"),Ks=Symbol("PERMALINK"),Up=t=>(t[Xg]=!0,t),Qg=t=>({value:e,children:n})=>{if(!n)return;const r={children:[{tag:Up(()=>{t.push(e)}),props:{}}]};Array.isArray(n)?r.children.push(...n.flat()):r.children.push(n),r.children.push({tag:Up(()=>{t.pop()}),props:{}});const i={tag:"",props:r,type:""};return i[Zc]=s=>{throw t.pop(),s},i},em=t=>{const e=[t],n=Qg(e);return n.values=e,n.Provider=n,ar.push(n),n},ar=[],Db=t=>{const e=[t],n=r=>{e.push(r.value);let i;try{i=r.children?(Array.isArray(r.children)?new im("",{},r.children):r.children).toString():""}finally{e.pop()}return i instanceof Promise?i.then(s=>gt(s,s.callbacks)):gt(i)};return n.values=e,n.Provider=n,n[uu]=Qg(e),ar.push(n),n},kr=t=>t.values.at(-1),Ki={title:[],script:["src"],style:["data-href"],link:["href"],meta:["name","httpEquiv","charset","itemProp"]},Yc={},Wi="data-precedence",Ai=t=>Array.isArray(t)?t:[t],Vp=new WeakMap,qp=(t,e,n,r)=>({buffer:i,context:s})=>{if(!i)return;const a=Vp.get(s)||{};Vp.set(s,a);const c=a[t]||(a[t]=[]);let l=!1;const u=Ki[t];if(u.length>0){e:for(const[,p]of c)for(const h of u)if(((p==null?void 0:p[h])??null)===(n==null?void 0:n[h])){l=!0;break e}}if(l?i[0]=i[0].replaceAll(e,""):u.length>0?c.push([e,n,r]):c.unshift([e,n,r]),i[0].indexOf("</head>")!==-1){let p;if(r===void 0)p=c.map(([h])=>h);else{const h=[];p=c.map(([m,,v])=>{let f=h.indexOf(v);return f===-1&&(h.push(v),f=h.length-1),[m,f]}).sort((m,v)=>m[1]-v[1]).map(([m])=>m)}p.forEach(h=>{i[0]=i[0].replaceAll(h,"")}),i[0]=i[0].replace(/(?=<\/head>)/,p.join(""))}},Ei=(t,e,n)=>gt(new mt(t,n,Ai(e??[])).toString()),Ii=(t,e,n,r)=>{if("itemProp"in n)return Ei(t,e,n);let{precedence:i,blocking:s,...a}=n;i=r?i??"":void 0,r&&(a[Wi]=i);const c=new mt(t,a,Ai(e||[])).toString();return c instanceof Promise?c.then(l=>gt(c,[...l.callbacks||[],qp(t,l,a,i)])):gt(c,[qp(t,c,a,i)])},Hb=({children:t,...e})=>{const n=du();if(n){const r=kr(n);if(r==="svg"||r==="head")return new mt("title",e,Ai(t??[]))}return Ii("title",t,e,!1)},Fb=({children:t,...e})=>{const n=du();return["src","async"].some(r=>!e[r])||n&&kr(n)==="head"?Ei("script",t,e):Ii("script",t,e,!1)},Kb=({children:t,...e})=>["href","precedence"].every(n=>n in e)?(e["data-href"]=e.href,delete e.href,Ii("style",t,e,!0)):Ei("style",t,e),Wb=({children:t,...e})=>["onLoad","onError"].some(n=>n in e)||e.rel==="stylesheet"&&(!("precedence"in e)||"disabled"in e)?Ei("link",t,e):Ii("link",t,e,"precedence"in e),Gb=({children:t,...e})=>{const n=du();return n&&kr(n)==="head"?Ei("meta",t,e):Ii("meta",t,e,!1)},tm=(t,{children:e,...n})=>new mt(t,n,Ai(e??[])),Jb=t=>(typeof t.action=="function"&&(t.action=Ks in t.action?t.action[Ks]:void 0),tm("form",t)),nm=(t,e)=>(typeof e.formAction=="function"&&(e.formAction=Ks in e.formAction?e.formAction[Ks]:void 0),tm(t,e)),Zb=t=>nm("input",t),Yb=t=>nm("button",t);const ma=Object.freeze(Object.defineProperty({__proto__:null,button:Yb,form:Jb,input:Zb,link:Wb,meta:Gb,script:Fb,style:Kb,title:Hb},Symbol.toStringTag,{value:"Module"}));var Xb=new Map([["className","class"],["htmlFor","for"],["crossOrigin","crossorigin"],["httpEquiv","http-equiv"],["itemProp","itemprop"],["fetchPriority","fetchpriority"],["noModule","nomodule"],["formAction","formaction"]]),Ws=t=>Xb.get(t)||t,rm=(t,e)=>{for(const[n,r]of Object.entries(t)){const i=n[0]==="-"||!/[A-Z]/.test(n)?n:n.replace(/[A-Z]/g,s=>`-${s.toLowerCase()}`);e(i,r==null?null:typeof r=="number"?i.match(/^(?:a|border-im|column(?:-c|s)|flex(?:$|-[^b])|grid-(?:ar|[^a])|font-w|li|or|sca|st|ta|wido|z)|ty$/)?`${r}`:`${r}px`:r)}},ni=void 0,du=()=>ni,Qb=t=>/[A-Z]/.test(t)&&t.match(/^(?:al|basel|clip(?:Path|Rule)$|co|do|fill|fl|fo|gl|let|lig|i|marker[EMS]|o|pai|pointe|sh|st[or]|text[^L]|tr|u|ve|w)/)?t.replace(/([A-Z])/g,"-$1").toLowerCase():t,e1=["area","base","br","col","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],t1=["allowfullscreen","async","autofocus","autoplay","checked","controls","default","defer","disabled","download","formnovalidate","hidden","inert","ismap","itemscope","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected"],pu=(t,e)=>{for(let n=0,r=t.length;n<r;n++){const i=t[n];if(typeof i=="string")Zt(i,e);else{if(typeof i=="boolean"||i===null||i===void 0)continue;i instanceof mt?i.toStringToBuffer(e):typeof i=="number"||i.isEscaped?e[0]+=i:i instanceof Promise?e.unshift("",i):pu(i,e)}}},mt=class{constructor(t,e,n){te(this,"tag");te(this,"props");te(this,"key");te(this,"children");te(this,"isEscaped",!0);te(this,"localContexts");this.tag=t,this.props=e,this.children=n}get type(){return this.tag}get ref(){return this.props.ref||null}toString(){var e,n;const t=[""];(e=this.localContexts)==null||e.forEach(([r,i])=>{r.values.push(i)});try{this.toStringToBuffer(t)}finally{(n=this.localContexts)==null||n.forEach(([r])=>{r.values.pop()})}return t.length===1?"callbacks"in t?Yg(gt(t[0],t.callbacks)).toString():t[0]:Zg(t,t.callbacks)}toStringToBuffer(t){const e=this.tag,n=this.props;let{children:r}=this;t[0]+=`<${e}`;const i=ni&&kr(ni)==="svg"?s=>Qb(Ws(s)):s=>Ws(s);for(let[s,a]of Object.entries(n))if(s=i(s),s!=="children"){if(s==="style"&&typeof a=="object"){let c="";rm(a,(l,u)=>{u!=null&&(c+=`${c?";":""}${l}:${u}`)}),t[0]+=' style="',Zt(c,t),t[0]+='"'}else if(typeof a=="string")t[0]+=` ${s}="`,Zt(a,t),t[0]+='"';else if(a!=null)if(typeof a=="number"||a.isEscaped)t[0]+=` ${s}="${a}"`;else if(typeof a=="boolean"&&t1.includes(s))a&&(t[0]+=` ${s}=""`);else if(s==="dangerouslySetInnerHTML"){if(r.length>0)throw"Can only set one of `children` or `props.dangerouslySetInnerHTML`.";r=[gt(a.__html)]}else if(a instanceof Promise)t[0]+=` ${s}="`,t.unshift('"',a);else if(typeof a=="function"){if(!s.startsWith("on"))throw`Invalid prop '${s}' of type 'function' supplied to '${e}'.`}else t[0]+=` ${s}="`,Zt(a.toString(),t),t[0]+='"'}if(e1.includes(e)&&r.length===0){t[0]+="/>";return}t[0]+=">",pu(r,t),t[0]+=`</${e}>`}},_a=class extends mt{toStringToBuffer(t){const{children:e}=this,n=this.tag.call(null,{...this.props,children:e.length<=1?e[0]:e});if(!(typeof n=="boolean"||n==null))if(n instanceof Promise)if(ar.length===0)t.unshift("",n);else{const r=ar.map(i=>[i,i.values.at(-1)]);t.unshift("",n.then(i=>(i instanceof mt&&(i.localContexts=r),i)))}else n instanceof mt?n.toStringToBuffer(t):typeof n=="number"||n.isEscaped?(t[0]+=n,n.callbacks&&(t.callbacks||(t.callbacks=[]),t.callbacks.push(...n.callbacks))):Zt(n,t)}},im=class extends mt{toStringToBuffer(t){pu(this.children,t)}},n1=(t,e,...n)=>{e??(e={}),n.length&&(e.children=n.length===1?n[0]:n);const r=e.key;delete e.key;const i=Gi(t,e,n);return i.key=r,i},Mp=!1,Gi=(t,e,n)=>{if(!Mp){for(const r in Yc)ma[r][uu]=Yc[r];Mp=!0}return typeof t=="function"?new _a(t,e,n):ma[t]?new _a(ma[t],e,n):t==="svg"||t==="head"?(ni||(ni=Db("")),new mt(t,e,[new _a(ni,{value:t},n)])):new mt(t,e,n)},fu=({children:t})=>new im("",{children:t},Array.isArray(t)?t:t?[t]:[]),r1=(t,e,...n)=>n1(t.tag,{...t.props,...e},...n);function y(t,e,n){let r;if(!e||!("children"in e))r=Gi(t,e,[]);else{const i=e.children;r=Array.isArray(i)?Gi(t,e,i):Gi(t,e,[i])}return r.key=n,r}const Dp={name:"sesamy",logoUrl:"https://assets.sesamy.com/static/images/email/sesamy-logo.png",style:{primaryColor:"#7D68F4",buttonTextColor:"#FFFFFF",primaryHoverColor:"#A091F2"},loginBackgroundImage:"",checkoutHideSocial:!1,supportEmail:"support@sesamy.com",supportUrl:"https://support.sesamy.com",siteUrl:"https://sesamy.com",termsAndConditionsUrl:"https://store.sesamy.com/pages/terms-of-service",manageSubscriptionsUrl:"https://account.sesamy.com/manage-subscriptions"};async function hu(t,e,n){if(!n&&!e)return Dp;const r=n||e;try{const i=await fetch(`${t.API_URL}/profile/vendors/${r}/style`);if(!i.ok)throw new Error("Failed to fetch vendor settings");const s=await i.json();return uf.parse(s)}catch(i){return console.error(i),Dp}}async function Ie(t,e,n=!1){var u;const{env:r}=t,i=await r.data.loginSessions.get(t.var.tenant_id||"",e);if(i)i.session_id;else throw new z(400,{message:"Login session not found"});t.set("loginSession",i);const s=await Zo(r,i.authParams.client_id);t.set("client_id",s.id),t.set("tenant_id",s.tenant.id);const a=await r.data.tenants.get(s.tenant.id);if(a){if(i.session_id&&!n)throw new z(400,{message:"Login session closed"})}else throw new z(400,{message:"Tenant not found"});const c=await hu(r,s.id,i.authParams.vendor_id),l=(u=i.authParams.ui_locales)==null?void 0:u.split(" ").map(p=>p.split("-")[0]).find(p=>{if(Array.isArray(P.options.supportedLngs))return P.options.supportedLngs.includes(p)});return await P.changeLanguage(l||a.language||"sv"),{vendorSettings:{...c,termsAndConditionsUrl:s.id==="fokus-app"?"https://www.fokus.se/kopvillkor-app/":c.termsAndConditionsUrl},client:s,tenant:a,loginSession:i}}async function i1(t,e,n,r){if(r!==void 0)return r==="password";const i=await ro({userAdapter:t.env.data.users,tenant_id:e.tenant.id,email:n});if(i){const a=await t.env.data.logs.list(e.tenant.id,{page:0,per_page:10,include_totals:!1,sort:{sort_by:"date",sort_order:"desc"},q:`type:${he.SUCCESS_LOGIN} user_id:${i.user_id}`}),[c]=a.logs.filter(l=>l.strategy&&["Username-Password-Authentication","passwordless","email"].includes(l.strategy));if(c)return c.strategy==="Username-Password-Authentication"}return(await t.env.data.promptSettings.get(e.tenant.id)).password_first}const s1=({vendorSettings:t})=>t!=null&&t.logoUrl?y("div",{className:"flex h-9 items-center",children:y("img",{src:t.logoUrl,className:"max-h-full",alt:"Vendor logo"})}):y(fu,{}),o1=({vendorSettings:t})=>{const{termsAndConditionsUrl:e}=t;return y("div",{className:"mt-8",children:e&&y("div",{className:"text-xs text-gray-300",children:[P.t("agree_to")," ",y("a",{href:e,className:"text-primary hover:underline",target:"_blank",rel:"noreferrer",children:P.t("terms")})]})})};var sm={exports:{}};/*!
192
+ </html>`}async function Lb({ctx:t,client:e,session:n,redirect_uri:r,state:i,nonce:s,code_challenge_method:a,code_challenge:c,audience:l,scope:u,response_type:p}){const{env:h}=t,m=new URL(r),v=`${m.protocol}//${m.host}`;async function f(ce="Login required"){const le=ve(t,{type:he.FAILED_SILENT_AUTH,description:ce});return await t.env.data.logs.create(e.tenant.id,le),t.html(Up(v,JSON.stringify({error:"login_required",error_description:ce,state:i})))}if(!n||(n==null?void 0:n.expires_at)&&new Date(n.expires_at)<new Date||(n==null?void 0:n.idle_expires_at)&&new Date(n.idle_expires_at)<new Date)return f();t.set("user_id",n.user_id);const w=await h.data.users.get(e.tenant.id,n.user_id);if(!w)return console.error("User not found",n.user_id),f("User not found");t.set("username",w.email),t.set("connection",w.connection);const S={client:e,authParams:{client_id:e.id,audience:l,code_challenge_method:a,code_challenge:c,scope:u,state:i,nonce:s,response_type:p},user:w,session_id:n.id},C=p===Pt.CODE?await Df(t,S):await to(t,S);await h.data.sessions.update(e.tenant.id,n.id,{used_at:new Date().toISOString(),last_interaction_at:new Date().toISOString(),device:{...n.device,last_ip:t.req.header("x-real-ip")||"",last_user_agent:t.req.header("user-agent")||""},idle_expires_at:n.idle_expires_at?new Date(Date.now()+Qs*1e3).toISOString():void 0});const B=ve(t,{type:he.SUCCESS_SILENT_AUTH,description:"Successful silent authentication"});await t.env.data.logs.create(e.tenant.id,B);const L=new Headers;L.set("Server-Timing","cf-nel=0; no-cloudflare-insights=1");const Q=Tf(e.tenant.id,n.id,t.req.header("host"));return L.set("set-cookie",Q),t.html(Up(v,JSON.stringify(C)),{headers:L})}const Ub=new o.OpenAPIHono().openapi(o.createRoute({tags:["oauth"],method:"get",path:"/",request:{query:o.z.object({client_id:o.z.string(),vendor_id:o.z.string().optional(),redirect_uri:o.z.string(),scope:o.z.string().optional(),state:o.z.string(),prompt:o.z.string().optional(),response_mode:o.z.nativeEnum(Xt).optional(),response_type:o.z.nativeEnum(Pt).optional(),audience:o.z.string().optional(),connection:o.z.string().optional(),nonce:o.z.string().optional(),max_age:o.z.string().optional(),login_ticket:o.z.string().optional(),code_challenge_method:o.z.nativeEnum(Zs).optional(),code_challenge:o.z.string().optional(),realm:o.z.string().optional(),auth0Client:o.z.string().optional(),organization:o.z.string().optional(),login_hint:o.z.string().optional(),ui_locales:o.z.string().optional()})},responses:{200:{description:"Silent authentication page"},302:{description:"Redirect to the client's redirect uri"}}}),async t=>{const{env:e}=t,{client_id:n,vendor_id:r,redirect_uri:i,scope:s,state:a,audience:c,nonce:l,connection:u,response_type:p,response_mode:h,code_challenge:m,code_challenge_method:v,prompt:f,login_ticket:_,realm:w,auth0Client:S,login_hint:C,ui_locales:B,organization:L}=t.req.valid("query");t.set("log","authorize");const Q=await Zo(e,n);t.set("client_id",Q.id),t.set("tenant_id",Q.tenant.id);const ce={redirect_uri:i,scope:s,state:a,client_id:n,vendor_id:r,audience:c,nonce:l,prompt:f,response_type:p,response_mode:h,code_challenge:m,code_challenge_method:v,username:C,ui_locales:B,organization:L},le=t.req.header("origin");if(le&&!Bb(le,Q.web_origins||[]))throw new z(403,{message:`Origin ${le} not allowed`});if(ce.redirect_uri&&!Yo(ce.redirect_uri,Q.callbacks||[],{allowPathWildcards:!0}))throw new z(400,{message:`Invalid redirect URI - ${ce.redirect_uri}`});const De=cs(Q.tenant.id,t.req.header("cookie")),Ue=De?await e.data.sessions.get(Q.tenant.id,De):void 0,Re=Ue&&!Ue.revoked_at?Ue:void 0;if(f=="none"){if(!p)throw new z(400,{message:"Missing response_type"});return Lb({ctx:t,session:Re||void 0,redirect_uri:i,state:a,response_type:p,client:Q,nonce:l,code_challenge_method:v,code_challenge:m,audience:c,scope:s})}return u&&u!=="email"?gb(t,Q,u,ce):_?Rb(t,Q.tenant.id,_,ce,w):Tb({ctx:t,client:Q,auth0Client:S,authParams:ce,session:Re||void 0,connection:u,login_hint:C})});function Vb(t){const e=new o.OpenAPIHono;e.use(async(r,i)=>(r.env.data=no(r,t.dataAdapter),i())),e.use(nu).use(Rg(e));const n=e.route("/v2/logout",_b).route("/userinfo",yb).route("/.well-known",vb).route("/oauth/token",Ib).route("/dbconnections",Cb).route("/passwordless",jb).route("/co/authenticate",Ob).route("/authorize",Ub).route("/callback",mb);return n.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Oauth API"},security:[{oauth2:["openid","email","profile"]}]}),Pg(n),n}var qb={Stringify:1,BeforeStream:2,Stream:3},gt=(t,e)=>{const n=new String(t);return n.isEscaped=!0,n.callbacks=e,n},Mb=/[&<>'"]/,Yg=async(t,e)=>{let n="";e||(e=[]);const r=await Promise.all(t);for(let i=r.length-1;n+=r[i],i--,!(i<0);i--){let s=r[i];typeof s=="object"&&e.push(...s.callbacks||[]);const a=s.isEscaped;if(s=await(typeof s=="object"?s.toString():s),typeof s=="object"&&e.push(...s.callbacks||[]),s.isEscaped??a)n+=s;else{const c=[n];Yt(s,c),n=c[0]}}return gt(n,e)},Yt=(t,e)=>{const n=t.search(Mb);if(n===-1){e[0]+=t;return}let r,i,s=0;for(i=n;i<t.length;i++){switch(t.charCodeAt(i)){case 34:r="&quot;";break;case 39:r="&#39;";break;case 38:r="&amp;";break;case 60:r="&lt;";break;case 62:r="&gt;";break;default:continue}e[0]+=t.substring(s,i)+r,s=i+1}e[0]+=t.substring(s,i)},Xg=t=>{const e=t.callbacks;if(!(e!=null&&e.length))return t;const n=[t],r={};return e.forEach(i=>i({phase:qb.Stringify,buffer:n,context:r})),n[0]},Db=(t,...e)=>{const n=[""];for(let r=0,i=t.length-1;r<i;r++){n[0]+=t[r];const s=Array.isArray(e[r])?e[r].flat(1/0):[e[r]];for(let a=0,c=s.length;a<c;a++){const l=s[a];if(typeof l=="string")Yt(l,n);else if(typeof l=="number")n[0]+=l;else{if(typeof l=="boolean"||l===null||l===void 0)continue;if(typeof l=="object"&&l.isEscaped)if(l.callbacks)n.unshift("",l);else{const u=l.toString();u instanceof Promise?n.unshift("",u):n[0]+=u}else l instanceof Promise?n.unshift("",l):Yt(l.toString(),n)}}}return n[0]+=t[t.length-1],n.length===1?"callbacks"in n?gt(Xg(gt(n[0],n.callbacks))):gt(n[0]):Yg(n,n.callbacks)},du=Symbol("RENDERER"),Zc=Symbol("ERROR_HANDLER"),Ae=Symbol("STASH"),Qg=Symbol("INTERNAL"),Hb=Symbol("MEMO"),Ks=Symbol("PERMALINK"),Vp=t=>(t[Qg]=!0,t),em=t=>({value:e,children:n})=>{if(!n)return;const r={children:[{tag:Vp(()=>{t.push(e)}),props:{}}]};Array.isArray(n)?r.children.push(...n.flat()):r.children.push(n),r.children.push({tag:Vp(()=>{t.pop()}),props:{}});const i={tag:"",props:r,type:""};return i[Zc]=s=>{throw t.pop(),s},i},tm=t=>{const e=[t],n=em(e);return n.values=e,n.Provider=n,ar.push(n),n},ar=[],Fb=t=>{const e=[t],n=r=>{e.push(r.value);let i;try{i=r.children?(Array.isArray(r.children)?new sm("",{},r.children):r.children).toString():""}finally{e.pop()}return i instanceof Promise?i.then(s=>gt(s,s.callbacks)):gt(i)};return n.values=e,n.Provider=n,n[du]=em(e),ar.push(n),n},kr=t=>t.values.at(-1),Ki={title:[],script:["src"],style:["data-href"],link:["href"],meta:["name","httpEquiv","charset","itemProp"]},Yc={},Wi="data-precedence",Ai=t=>Array.isArray(t)?t:[t],qp=new WeakMap,Mp=(t,e,n,r)=>({buffer:i,context:s})=>{if(!i)return;const a=qp.get(s)||{};qp.set(s,a);const c=a[t]||(a[t]=[]);let l=!1;const u=Ki[t];if(u.length>0){e:for(const[,p]of c)for(const h of u)if(((p==null?void 0:p[h])??null)===(n==null?void 0:n[h])){l=!0;break e}}if(l?i[0]=i[0].replaceAll(e,""):u.length>0?c.push([e,n,r]):c.unshift([e,n,r]),i[0].indexOf("</head>")!==-1){let p;if(r===void 0)p=c.map(([h])=>h);else{const h=[];p=c.map(([m,,v])=>{let f=h.indexOf(v);return f===-1&&(h.push(v),f=h.length-1),[m,f]}).sort((m,v)=>m[1]-v[1]).map(([m])=>m)}p.forEach(h=>{i[0]=i[0].replaceAll(h,"")}),i[0]=i[0].replace(/(?=<\/head>)/,p.join(""))}},Ei=(t,e,n)=>gt(new mt(t,n,Ai(e??[])).toString()),Ii=(t,e,n,r)=>{if("itemProp"in n)return Ei(t,e,n);let{precedence:i,blocking:s,...a}=n;i=r?i??"":void 0,r&&(a[Wi]=i);const c=new mt(t,a,Ai(e||[])).toString();return c instanceof Promise?c.then(l=>gt(c,[...l.callbacks||[],Mp(t,l,a,i)])):gt(c,[Mp(t,c,a,i)])},Kb=({children:t,...e})=>{const n=pu();if(n){const r=kr(n);if(r==="svg"||r==="head")return new mt("title",e,Ai(t??[]))}return Ii("title",t,e,!1)},Wb=({children:t,...e})=>{const n=pu();return["src","async"].some(r=>!e[r])||n&&kr(n)==="head"?Ei("script",t,e):Ii("script",t,e,!1)},Gb=({children:t,...e})=>["href","precedence"].every(n=>n in e)?(e["data-href"]=e.href,delete e.href,Ii("style",t,e,!0)):Ei("style",t,e),Jb=({children:t,...e})=>["onLoad","onError"].some(n=>n in e)||e.rel==="stylesheet"&&(!("precedence"in e)||"disabled"in e)?Ei("link",t,e):Ii("link",t,e,"precedence"in e),Zb=({children:t,...e})=>{const n=pu();return n&&kr(n)==="head"?Ei("meta",t,e):Ii("meta",t,e,!1)},nm=(t,{children:e,...n})=>new mt(t,n,Ai(e??[])),Yb=t=>(typeof t.action=="function"&&(t.action=Ks in t.action?t.action[Ks]:void 0),nm("form",t)),rm=(t,e)=>(typeof e.formAction=="function"&&(e.formAction=Ks in e.formAction?e.formAction[Ks]:void 0),nm(t,e)),Xb=t=>rm("input",t),Qb=t=>rm("button",t);const ma=Object.freeze(Object.defineProperty({__proto__:null,button:Qb,form:Yb,input:Xb,link:Jb,meta:Zb,script:Wb,style:Gb,title:Kb},Symbol.toStringTag,{value:"Module"}));var e1=new Map([["className","class"],["htmlFor","for"],["crossOrigin","crossorigin"],["httpEquiv","http-equiv"],["itemProp","itemprop"],["fetchPriority","fetchpriority"],["noModule","nomodule"],["formAction","formaction"]]),Ws=t=>e1.get(t)||t,im=(t,e)=>{for(const[n,r]of Object.entries(t)){const i=n[0]==="-"||!/[A-Z]/.test(n)?n:n.replace(/[A-Z]/g,s=>`-${s.toLowerCase()}`);e(i,r==null?null:typeof r=="number"?i.match(/^(?:a|border-im|column(?:-c|s)|flex(?:$|-[^b])|grid-(?:ar|[^a])|font-w|li|or|sca|st|ta|wido|z)|ty$/)?`${r}`:`${r}px`:r)}},ni=void 0,pu=()=>ni,t1=t=>/[A-Z]/.test(t)&&t.match(/^(?:al|basel|clip(?:Path|Rule)$|co|do|fill|fl|fo|gl|let|lig|i|marker[EMS]|o|pai|pointe|sh|st[or]|text[^L]|tr|u|ve|w)/)?t.replace(/([A-Z])/g,"-$1").toLowerCase():t,n1=["area","base","br","col","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],r1=["allowfullscreen","async","autofocus","autoplay","checked","controls","default","defer","disabled","download","formnovalidate","hidden","inert","ismap","itemscope","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected"],fu=(t,e)=>{for(let n=0,r=t.length;n<r;n++){const i=t[n];if(typeof i=="string")Yt(i,e);else{if(typeof i=="boolean"||i===null||i===void 0)continue;i instanceof mt?i.toStringToBuffer(e):typeof i=="number"||i.isEscaped?e[0]+=i:i instanceof Promise?e.unshift("",i):fu(i,e)}}},mt=class{constructor(t,e,n){te(this,"tag");te(this,"props");te(this,"key");te(this,"children");te(this,"isEscaped",!0);te(this,"localContexts");this.tag=t,this.props=e,this.children=n}get type(){return this.tag}get ref(){return this.props.ref||null}toString(){var e,n;const t=[""];(e=this.localContexts)==null||e.forEach(([r,i])=>{r.values.push(i)});try{this.toStringToBuffer(t)}finally{(n=this.localContexts)==null||n.forEach(([r])=>{r.values.pop()})}return t.length===1?"callbacks"in t?Xg(gt(t[0],t.callbacks)).toString():t[0]:Yg(t,t.callbacks)}toStringToBuffer(t){const e=this.tag,n=this.props;let{children:r}=this;t[0]+=`<${e}`;const i=ni&&kr(ni)==="svg"?s=>t1(Ws(s)):s=>Ws(s);for(let[s,a]of Object.entries(n))if(s=i(s),s!=="children"){if(s==="style"&&typeof a=="object"){let c="";im(a,(l,u)=>{u!=null&&(c+=`${c?";":""}${l}:${u}`)}),t[0]+=' style="',Yt(c,t),t[0]+='"'}else if(typeof a=="string")t[0]+=` ${s}="`,Yt(a,t),t[0]+='"';else if(a!=null)if(typeof a=="number"||a.isEscaped)t[0]+=` ${s}="${a}"`;else if(typeof a=="boolean"&&r1.includes(s))a&&(t[0]+=` ${s}=""`);else if(s==="dangerouslySetInnerHTML"){if(r.length>0)throw"Can only set one of `children` or `props.dangerouslySetInnerHTML`.";r=[gt(a.__html)]}else if(a instanceof Promise)t[0]+=` ${s}="`,t.unshift('"',a);else if(typeof a=="function"){if(!s.startsWith("on"))throw`Invalid prop '${s}' of type 'function' supplied to '${e}'.`}else t[0]+=` ${s}="`,Yt(a.toString(),t),t[0]+='"'}if(n1.includes(e)&&r.length===0){t[0]+="/>";return}t[0]+=">",fu(r,t),t[0]+=`</${e}>`}},_a=class extends mt{toStringToBuffer(t){const{children:e}=this,n=this.tag.call(null,{...this.props,children:e.length<=1?e[0]:e});if(!(typeof n=="boolean"||n==null))if(n instanceof Promise)if(ar.length===0)t.unshift("",n);else{const r=ar.map(i=>[i,i.values.at(-1)]);t.unshift("",n.then(i=>(i instanceof mt&&(i.localContexts=r),i)))}else n instanceof mt?n.toStringToBuffer(t):typeof n=="number"||n.isEscaped?(t[0]+=n,n.callbacks&&(t.callbacks||(t.callbacks=[]),t.callbacks.push(...n.callbacks))):Yt(n,t)}},sm=class extends mt{toStringToBuffer(t){fu(this.children,t)}},i1=(t,e,...n)=>{e??(e={}),n.length&&(e.children=n.length===1?n[0]:n);const r=e.key;delete e.key;const i=Gi(t,e,n);return i.key=r,i},Dp=!1,Gi=(t,e,n)=>{if(!Dp){for(const r in Yc)ma[r][du]=Yc[r];Dp=!0}return typeof t=="function"?new _a(t,e,n):ma[t]?new _a(ma[t],e,n):t==="svg"||t==="head"?(ni||(ni=Fb("")),new mt(t,e,[new _a(ni,{value:t},n)])):new mt(t,e,n)},hu=({children:t})=>new sm("",{children:t},Array.isArray(t)?t:t?[t]:[]),s1=(t,e,...n)=>i1(t.tag,{...t.props,...e},...n);function y(t,e,n){let r;if(!e||!("children"in e))r=Gi(t,e,[]);else{const i=e.children;r=Array.isArray(i)?Gi(t,e,i):Gi(t,e,[i])}return r.key=n,r}const Hp={name:"sesamy",logoUrl:"https://assets.sesamy.com/static/images/email/sesamy-logo.png",style:{primaryColor:"#7D68F4",buttonTextColor:"#FFFFFF",primaryHoverColor:"#A091F2"},loginBackgroundImage:"",checkoutHideSocial:!1,supportEmail:"support@sesamy.com",supportUrl:"https://support.sesamy.com",siteUrl:"https://sesamy.com",termsAndConditionsUrl:"https://store.sesamy.com/pages/terms-of-service",manageSubscriptionsUrl:"https://account.sesamy.com/manage-subscriptions"};async function gu(t,e,n){if(!n&&!e)return Hp;const r=n||e;try{const i=await fetch(`${t.API_URL}/profile/vendors/${r}/style`);if(!i.ok)throw new Error("Failed to fetch vendor settings");const s=await i.json();return df.parse(s)}catch(i){return console.error(i),Hp}}async function Ie(t,e,n=!1){var u;const{env:r}=t,i=await r.data.loginSessions.get(t.var.tenant_id||"",e);if(i)i.session_id;else throw new z(400,{message:"Login session not found"});t.set("loginSession",i);const s=await Zo(r,i.authParams.client_id);t.set("client_id",s.id),t.set("tenant_id",s.tenant.id);const a=await r.data.tenants.get(s.tenant.id);if(a){if(i.session_id&&!n)throw new z(400,{message:"Login session closed"})}else throw new z(400,{message:"Tenant not found"});const c=await gu(r,s.id,i.authParams.vendor_id),l=(u=i.authParams.ui_locales)==null?void 0:u.split(" ").map(p=>p.split("-")[0]).find(p=>{if(Array.isArray(P.options.supportedLngs))return P.options.supportedLngs.includes(p)});return await P.changeLanguage(l||a.language||"sv"),{vendorSettings:{...c,termsAndConditionsUrl:s.id==="fokus-app"?"https://www.fokus.se/kopvillkor-app/":c.termsAndConditionsUrl},client:s,tenant:a,loginSession:i}}async function o1(t,e,n,r){if(r!==void 0)return r==="password";const i=await ro({userAdapter:t.env.data.users,tenant_id:e.tenant.id,email:n});if(i){const a=await t.env.data.logs.list(e.tenant.id,{page:0,per_page:10,include_totals:!1,sort:{sort_by:"date",sort_order:"desc"},q:`type:${he.SUCCESS_LOGIN} user_id:${i.user_id}`}),[c]=a.logs.filter(l=>l.strategy&&["Username-Password-Authentication","passwordless","email"].includes(l.strategy));if(c)return c.strategy==="Username-Password-Authentication"}return(await t.env.data.promptSettings.get(e.tenant.id)).password_first}const a1=({vendorSettings:t})=>t!=null&&t.logoUrl?y("div",{className:"flex h-9 items-center",children:y("img",{src:t.logoUrl,className:"max-h-full",alt:"Vendor logo"})}):y(hu,{}),c1=({vendorSettings:t})=>{const{termsAndConditionsUrl:e}=t;return y("div",{className:"mt-8",children:e&&y("div",{className:"text-xs text-gray-300",children:[P.t("agree_to")," ",y("a",{href:e,className:"text-primary hover:underline",target:"_blank",rel:"noreferrer",children:P.t("terms")})]})})};var om={exports:{}};/*!
193
193
  Copyright (c) 2018 Jed Watson.
194
194
  Licensed under the MIT License (MIT), see
195
195
  http://jedwatson.github.io/classnames
196
- */(function(t){(function(){var e={}.hasOwnProperty;function n(){for(var s="",a=0;a<arguments.length;a++){var c=arguments[a];c&&(s=i(s,r(c)))}return s}function r(s){if(typeof s=="string"||typeof s=="number")return s;if(typeof s!="object")return"";if(Array.isArray(s))return n.apply(null,s);if(s.toString!==Object.prototype.toString&&!s.toString.toString().includes("[native code]"))return s.toString();var a="";for(var c in s)e.call(s,c)&&s[c]&&(a=i(a,c));return a}function i(s,a){return a?s?s+" "+a:s+a:s}t.exports?(n.default=n,t.exports=n):window.classNames=n})()})(sm);var a1=sm.exports;const It=If(a1),c1=t=>t==="small"?"text-base":t==="medium"?"text-2xl":t==="large"?"text-3xl":"",Qe=({name:t,size:e,className:n=""})=>{const r=c1(e);return y("span",{className:It(`uicon-${t}`,n,r)})};var Hp=Object.freeze,l1=Object.defineProperty,u1=(t,e)=>Hp(l1(t,"raw",{value:Hp(t.slice())})),Fp;const d1=t=>{const{style:e}=t;return`
196
+ */(function(t){(function(){var e={}.hasOwnProperty;function n(){for(var s="",a=0;a<arguments.length;a++){var c=arguments[a];c&&(s=i(s,r(c)))}return s}function r(s){if(typeof s=="string"||typeof s=="number")return s;if(typeof s!="object")return"";if(Array.isArray(s))return n.apply(null,s);if(s.toString!==Object.prototype.toString&&!s.toString.toString().includes("[native code]"))return s.toString();var a="";for(var c in s)e.call(s,c)&&s[c]&&(a=i(a,c));return a}function i(s,a){return a?s?s+" "+a:s+a:s}t.exports?(n.default=n,t.exports=n):window.classNames=n})()})(om);var l1=om.exports;const It=zf(l1),u1=t=>t==="small"?"text-base":t==="medium"?"text-2xl":t==="large"?"text-3xl":"",Qe=({name:t,size:e,className:n=""})=>{const r=u1(e);return y("span",{className:It(`uicon-${t}`,n,r)})};var Fp=Object.freeze,d1=Object.defineProperty,p1=(t,e)=>Fp(d1(t,"raw",{value:Fp(t.slice())})),Kp;const f1=t=>{const{style:e}=t;return`
197
197
  body {
198
198
  --primary-color: ${e.primaryColor};
199
199
  --primary-hover: ${e.primaryHoverColor};
200
200
  --text-on-primary: ${e.buttonTextColor};
201
201
  }
202
- `},p1="https://assets.sesamy.com/images/login-bg.jpg",Ze=({title:t,children:e,vendorSettings:n})=>{const r={backgroundImage:`url(${(n==null?void 0:n.loginBackgroundImage)||p1})`};return y("html",{lang:"en",children:[y("head",{children:[y("title",{children:t}),y("meta",{charset:"UTF-8"}),y("meta",{name:"robots",content:"noindex, follow"}),y("link",{rel:"preload",href:"https://assets.sesamy.com/fonts/khteka/WOFF2/KHTeka-Regular.woff2",as:"font",type:"font/woff2",crossOrigin:"anonymous"}),y("link",{rel:"preload",href:"https://assets.sesamy.com/fonts/khteka/WOFF2/KHTeka-Medium.woff2",as:"font",type:"font/woff2",crossOrigin:"anonymous"}),y("link",{rel:"preload",href:"https://assets.sesamy.com/fonts/khteka/WOFF2/KHTeka-Bold.woff2",as:"font",type:"font/woff2",crossOrigin:"anonymous"}),y("link",{rel:"stylesheet",href:"/css/tailwind.css"}),y("meta",{name:"viewport",content:"width=device-width, initial-scale=1, maximum-scale=1"}),y("style",{children:d1(n)}),y("meta",{name:"theme-color",content:"#000000"})]}),y("body",{children:y("div",{className:"row min-h-full w-full overflow-hidden bg-cover bg-center text-sm sm:bg-fixed sm:bg-left-top sm:pt-16 py-2",style:r,children:y("div",{className:"row-up-left w-[calc(100%-theme(space.2)-theme(space.2))] max-w-[1295px] !flex-nowrap sm:w-[calc(100%-theme(space.16)-theme(space.16))]",children:y("div",{className:"column-left w-full sm:w-auto",children:[y("div",{className:"relative flex w-full flex-col rounded-2xl bg-white px-5 py-10 dark:bg-gray-800 dark:text-white sm:min-h-[700px] sm:max-w-md sm:px-14 sm:py-14 md:min-w-[448px] short:min-h-[558px] min-h-[calc(100vh-83px)]",children:[y("div",{className:"mb-16",children:y(s1,{vendorSettings:n})}),y("div",{className:"flex flex-1 flex-col",children:[e,y(o1,{vendorSettings:n})]})]}),y("div",{className:"flex w-full items-center px-6 pb-8 pt-4 justify-between",children:[y("div",{className:"flex justify-center leading-[0]",children:y("a",{href:"https://sesamy.com",target:"_blank",rel:"noreferrer",children:y(Qe,{name:"sesamy",className:"text-xl text-white"})})}),y("div",{className:"flex justify-center space-x-2 text-xs text-white sm:justify-normal md:text-xs",children:[n.supportUrl&&y("a",{className:"text-xs text-white hover:underline md:text-xs",href:n.supportUrl,target:"_blank",rel:"noopener noreferrer",children:P.t("contact_support")}),y("span",{className:"text-gray-300",children:"|"})," ",y("span",{children:P.t("copyright_sesamy")})]})]})]})})})}),qb(Fp||(Fp=u1([`
202
+ `},h1="https://assets.sesamy.com/images/login-bg.jpg",Ze=({title:t,children:e,vendorSettings:n})=>{const r={backgroundImage:`url(${(n==null?void 0:n.loginBackgroundImage)||h1})`};return y("html",{lang:"en",children:[y("head",{children:[y("title",{children:t}),y("meta",{charset:"UTF-8"}),y("meta",{name:"robots",content:"noindex, follow"}),y("link",{rel:"preload",href:"https://assets.sesamy.com/fonts/khteka/WOFF2/KHTeka-Regular.woff2",as:"font",type:"font/woff2",crossOrigin:"anonymous"}),y("link",{rel:"preload",href:"https://assets.sesamy.com/fonts/khteka/WOFF2/KHTeka-Medium.woff2",as:"font",type:"font/woff2",crossOrigin:"anonymous"}),y("link",{rel:"preload",href:"https://assets.sesamy.com/fonts/khteka/WOFF2/KHTeka-Bold.woff2",as:"font",type:"font/woff2",crossOrigin:"anonymous"}),y("link",{rel:"stylesheet",href:"/css/tailwind.css"}),y("meta",{name:"viewport",content:"width=device-width, initial-scale=1, maximum-scale=1"}),y("style",{children:f1(n)}),y("meta",{name:"theme-color",content:"#000000"})]}),y("body",{children:y("div",{className:"row min-h-full w-full overflow-hidden bg-cover bg-center text-sm sm:bg-fixed sm:bg-left-top sm:pt-16 py-2",style:r,children:y("div",{className:"row-up-left w-[calc(100%-theme(space.2)-theme(space.2))] max-w-[1295px] !flex-nowrap sm:w-[calc(100%-theme(space.16)-theme(space.16))]",children:y("div",{className:"column-left w-full sm:w-auto",children:[y("div",{className:"relative flex w-full flex-col rounded-2xl bg-white px-5 py-10 dark:bg-gray-800 dark:text-white sm:min-h-[700px] sm:max-w-md sm:px-14 sm:py-14 md:min-w-[448px] short:min-h-[558px] min-h-[calc(100vh-83px)]",children:[y("div",{className:"mb-16",children:y(a1,{vendorSettings:n})}),y("div",{className:"flex flex-1 flex-col",children:[e,y(c1,{vendorSettings:n})]})]}),y("div",{className:"flex w-full items-center px-6 pb-8 pt-4 justify-between",children:[y("div",{className:"flex justify-center leading-[0]",children:y("a",{href:"https://sesamy.com",target:"_blank",rel:"noreferrer",children:y(Qe,{name:"sesamy",className:"text-xl text-white"})})}),y("div",{className:"flex justify-center space-x-2 text-xs text-white sm:justify-normal md:text-xs",children:[n.supportUrl&&y("a",{className:"text-xs text-white hover:underline md:text-xs",href:n.supportUrl,target:"_blank",rel:"noopener noreferrer",children:P.t("contact_support")}),y("span",{className:"text-gray-300",children:"|"})," ",y("span",{children:P.t("copyright_sesamy")})]})]})]})})})}),Db(Kp||(Kp=p1([`
203
203
  <script>
204
204
  function swapButtons() {
205
205
  document.getElementById("initial-btn").classList.add("hidden");
@@ -214,37 +214,37 @@ PERFORMANCE OF THIS SOFTWARE.
214
214
  };
215
215
  }
216
216
  <\/script>
217
- `])))]})},xr=({children:t})=>y("div",{className:"mb-2 text-sm text-red",children:t}),f1=t=>t==="small"?"text-base":t==="medium"?"text-2xl":t==="large"?"text-3xl":"",h1=({size:t})=>{const e=f1(t);return y("div",{className:"relative inline-block leading-[0]",children:[y(Qe,{className:It("text-gray-200 dark:text-[#201a41]",{[e]:e}),name:"spinner-circle"}),y(Qe,{className:It("absolute inset-0 animate-spin text-primary",{[e]:e}),name:"spinner-inner"})]})},cr=({children:t,className:e,Component:n="button",variant:r="primary",href:i,disabled:s,isLoading:a,id:c})=>{const l=n==="a"?{href:i}:{};return y(n,{class:It("relative w-full rounded-lg text-center",e,{"px-4 py-5":r!=="custom","bg-primary text-textOnPrimary hover:bg-primaryHover":r==="primary","border border-gray-300 bg-white text-black":r==="secondary","pointer-events-none cursor-not-allowed opacity-40":s},"focus:outline-none focus:ring"),type:"submit",disabled:s,id:c,...l,children:[y("span",{className:`
217
+ `])))]})},xr=({children:t})=>y("div",{className:"mb-2 text-sm text-red",children:t}),g1=t=>t==="small"?"text-base":t==="medium"?"text-2xl":t==="large"?"text-3xl":"",m1=({size:t})=>{const e=g1(t);return y("div",{className:"relative inline-block leading-[0]",children:[y(Qe,{className:It("text-gray-200 dark:text-[#201a41]",{[e]:e}),name:"spinner-circle"}),y(Qe,{className:It("absolute inset-0 animate-spin text-primary",{[e]:e}),name:"spinner-inner"})]})},cr=({children:t,className:e,Component:n="button",variant:r="primary",href:i,disabled:s,isLoading:a,id:c})=>{const l=n==="a"?{href:i}:{};return y(n,{class:It("relative w-full rounded-lg text-center",e,{"px-4 py-5":r!=="custom","bg-primary text-textOnPrimary hover:bg-primaryHover":r==="primary","border border-gray-300 bg-white text-black":r==="secondary","pointer-events-none cursor-not-allowed opacity-40":s},"focus:outline-none focus:ring"),type:"submit",disabled:s,id:c,...l,children:[y("span",{className:`
218
218
  flex items-center justify-center space-x-2
219
219
  ${a?"invisible h-0":"visible h-auto"}
220
- `,children:t}),a&&y("div",{className:"absolute left-0 top-0 flex h-full w-full items-center justify-center",children:y(h1,{size:"medium"})})]})},Pi=({connection:t,text:e,icon:n=null,canResize:r=!1,loginSession:i})=>{const s=new URLSearchParams({client_id:i.authParams.client_id,connection:t});i.authParams.response_type&&s.set("response_type",i.authParams.response_type),i.authParams.redirect_uri&&s.set("redirect_uri",i.authParams.redirect_uri),i.authParams.scope&&s.set("scope",i.authParams.scope),i.authParams.nonce&&s.set("nonce",i.authParams.nonce),i.authParams.response_type&&s.set("response_type",i.authParams.response_type),i.authParams.state&&s.set("state",i.id);const a=`/authorize?${s.toString()}`;return y(cr,{className:It("border border-gray-200 bg-white hover:bg-gray-100 dark:border-gray-400 dark:bg-black dark:hover:bg-black/90",{"px-0 py-3 sm:px-10 sm:py-4 short:px-0 short:py-3":r,"px-10 py-3":!r}),variant:"custom","aria-label":e,Component:"a",href:a,children:[n||"",y("div",{className:It("text-left text-black dark:text-white sm:text-base",{"hidden sm:inline short:hidden":r}),children:e})]})},g1=({...t})=>y("svg",{width:"45",height:"45",viewBox:"0 0 45 45",xmlns:"http://www.w3.org/2000/svg",...t,children:[y("path",{d:"M44.1035 23.0123C44.1054 21.4791 43.9758 19.9486 43.716 18.4375H22.498V27.1028H34.6507C34.4021 28.4868 33.8757 29.8061 33.1034 30.9812C32.3311 32.1562 31.3289 33.1628 30.1571 33.9401V39.5649H37.41C41.6567 35.6494 44.1035 29.859 44.1035 23.0123Z",fill:"#4285F4"}),y("path",{d:"M22.4982 44.9997C28.5698 44.9997 33.6821 43.0061 37.4101 39.5687L30.1573 33.9439C28.1386 35.3126 25.5387 36.0938 22.4982 36.0938C16.6296 36.0938 11.6485 32.1377 9.86736 26.8066H2.39575V32.6033C4.26839 36.3297 7.13989 39.4622 10.6896 41.6512C14.2394 43.8402 18.3277 44.9995 22.4982 44.9997Z",fill:"#34A853"}),y("path",{d:"M9.86737 26.8073C8.92572 24.0138 8.92572 20.9886 9.86737 18.1951V12.3984H2.39576C0.820432 15.5332 0 18.9929 0 22.5012C0 26.0095 0.820432 29.4692 2.39576 32.604L9.86737 26.8073Z",fill:"#FBBC04"}),y("path",{d:"M22.4982 8.90741C25.7068 8.85499 28.8071 10.0673 31.1291 12.2823L37.5507 5.86064C33.4788 2.03602 28.0843 -0.0637686 22.4982 0.00147616C18.3277 0.00166623 14.2394 1.16098 10.6896 3.34999C7.13989 5.539 4.26839 8.67155 2.39575 12.3979L9.86736 18.1946C11.6485 12.8635 16.6296 8.90741 22.4982 8.90741Z",fill:"#EA4335"})]}),un=({children:t,className:e})=>y(fu,{children:[y(cr,{className:e,id:"initial-btn",children:t}),y(cr,{className:It(e,"hidden"),isLoading:!0,id:"loading-btn",disabled:!0,children:" "})]}),dn=({children:t,className:e})=>y("form",{id:"form",method:"post",className:e,children:t}),m1=({...t})=>y("svg",{version:"1.1",id:"Layer_1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 48 48",enableBackground:"new 0 0 48 48",width:"45",height:"45",...t,children:[y("path",{fill:"#FF5B24",d:"M3.5,8h41c1.9,0,3.5,1.6,3.5,3.5v25c0,1.9-1.6,3.5-3.5,3.5h-41C1.6,40,0,38.4,0,36.5v-25C0,9.6,1.6,8,3.5,8z"}),y("path",{fillRule:"evenodd",clipRule:"evenodd",fill:"#FFFFFF",d:`M27.9,20.3c1.4,0,2.6-1,2.6-2.5h0c0-1.5-1.2-2.5-2.6-2.5c-1.4,0-2.6,1-2.6,2.5C25.3,19.2,26.5,20.3,27.9,20.3z
220
+ `,children:t}),a&&y("div",{className:"absolute left-0 top-0 flex h-full w-full items-center justify-center",children:y(m1,{size:"medium"})})]})},Pi=({connection:t,text:e,icon:n=null,canResize:r=!1,loginSession:i})=>{const s=new URLSearchParams({client_id:i.authParams.client_id,connection:t});i.authParams.response_type&&s.set("response_type",i.authParams.response_type),i.authParams.redirect_uri&&s.set("redirect_uri",i.authParams.redirect_uri),i.authParams.scope&&s.set("scope",i.authParams.scope),i.authParams.nonce&&s.set("nonce",i.authParams.nonce),i.authParams.response_type&&s.set("response_type",i.authParams.response_type),i.authParams.state&&s.set("state",i.id);const a=`/authorize?${s.toString()}`;return y(cr,{className:It("border border-gray-200 bg-white hover:bg-gray-100 dark:border-gray-400 dark:bg-black dark:hover:bg-black/90",{"px-0 py-3 sm:px-10 sm:py-4 short:px-0 short:py-3":r,"px-10 py-3":!r}),variant:"custom","aria-label":e,Component:"a",href:a,children:[n||"",y("div",{className:It("text-left text-black dark:text-white sm:text-base",{"hidden sm:inline short:hidden":r}),children:e})]})},_1=({...t})=>y("svg",{width:"45",height:"45",viewBox:"0 0 45 45",xmlns:"http://www.w3.org/2000/svg",...t,children:[y("path",{d:"M44.1035 23.0123C44.1054 21.4791 43.9758 19.9486 43.716 18.4375H22.498V27.1028H34.6507C34.4021 28.4868 33.8757 29.8061 33.1034 30.9812C32.3311 32.1562 31.3289 33.1628 30.1571 33.9401V39.5649H37.41C41.6567 35.6494 44.1035 29.859 44.1035 23.0123Z",fill:"#4285F4"}),y("path",{d:"M22.4982 44.9997C28.5698 44.9997 33.6821 43.0061 37.4101 39.5687L30.1573 33.9439C28.1386 35.3126 25.5387 36.0938 22.4982 36.0938C16.6296 36.0938 11.6485 32.1377 9.86736 26.8066H2.39575V32.6033C4.26839 36.3297 7.13989 39.4622 10.6896 41.6512C14.2394 43.8402 18.3277 44.9995 22.4982 44.9997Z",fill:"#34A853"}),y("path",{d:"M9.86737 26.8073C8.92572 24.0138 8.92572 20.9886 9.86737 18.1951V12.3984H2.39576C0.820432 15.5332 0 18.9929 0 22.5012C0 26.0095 0.820432 29.4692 2.39576 32.604L9.86737 26.8073Z",fill:"#FBBC04"}),y("path",{d:"M22.4982 8.90741C25.7068 8.85499 28.8071 10.0673 31.1291 12.2823L37.5507 5.86064C33.4788 2.03602 28.0843 -0.0637686 22.4982 0.00147616C18.3277 0.00166623 14.2394 1.16098 10.6896 3.34999C7.13989 5.539 4.26839 8.67155 2.39575 12.3979L9.86736 18.1946C11.6485 12.8635 16.6296 8.90741 22.4982 8.90741Z",fill:"#EA4335"})]}),dn=({children:t,className:e})=>y(hu,{children:[y(cr,{className:e,id:"initial-btn",children:t}),y(cr,{className:It(e,"hidden"),isLoading:!0,id:"loading-btn",disabled:!0,children:" "})]}),pn=({children:t,className:e})=>y("form",{id:"form",method:"post",className:e,children:t}),y1=({...t})=>y("svg",{version:"1.1",id:"Layer_1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 48 48",enableBackground:"new 0 0 48 48",width:"45",height:"45",...t,children:[y("path",{fill:"#FF5B24",d:"M3.5,8h41c1.9,0,3.5,1.6,3.5,3.5v25c0,1.9-1.6,3.5-3.5,3.5h-41C1.6,40,0,38.4,0,36.5v-25C0,9.6,1.6,8,3.5,8z"}),y("path",{fillRule:"evenodd",clipRule:"evenodd",fill:"#FFFFFF",d:`M27.9,20.3c1.4,0,2.6-1,2.6-2.5h0c0-1.5-1.2-2.5-2.6-2.5c-1.4,0-2.6,1-2.6,2.5C25.3,19.2,26.5,20.3,27.9,20.3z
221
221
  M31.2,24.4c-1.7,2.2-3.5,3.8-6.7,3.8h0c-3.2,0-5.8-2-7.7-4.8c-0.8-1.2-2-1.4-2.9-0.8c-0.8,0.6-1,1.8-0.3,2.9
222
- c2.7,4.1,6.5,6.6,10.9,6.6c4,0,7.2-2,9.6-5.2c0.9-1.2,0.9-2.5,0-3.1C33.3,22.9,32.1,23.2,31.2,24.4z`})]}),Kp=({error:t,vendorSettings:e,loginSession:n,email:r,client:i,impersonation:s})=>{const a=i.connections.map(({name:m})=>m),c=a.includes("facebook"),l=a.includes("google-oauth2"),u=a.includes("apple"),p=a.includes("vipps"),h=c||l||u||p;return y(Ze,{title:P.t("welcome"),vendorSettings:e,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:P.t("welcome")}),y("div",{className:"mb-8 text-gray-300",children:P.t("login_description")}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y(dn,{className:"mb-7",children:[y("input",{type:"email",name:"username",placeholder:P.t("email_placeholder"),className:It("mb-2 w-full rounded-lg border bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",{"border-red":t,"border-gray-100 dark:border-gray-500":!t}),required:!0,value:r||""}),s&&y("input",{type:"email",name:"act_as",placeholder:"Impersonate as",className:It("mb-2 w-full rounded-lg border bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",{"border-red":t,"border-gray-100 dark:border-gray-500":!t}),required:!0,value:""}),t&&y(xr,{children:t}),y(un,{className:"text-base sm:mt-4 md:text-base",children:y("div",{className:"flex items-center space-x-2",children:[y("span",{children:P.t("continue")}),y(Qe,{className:"text-xs",name:"arrow-right"})]})})]}),h&&y("div",{className:"relative mb-5 block text-center text-gray-300 dark:text-gray-300",children:[y("div",{className:"absolute left-0 right-0 top-1/2 border-b border-gray-200 dark:border-gray-600"}),y("div",{className:"relative inline-block bg-white px-2 dark:bg-gray-800",children:P.t("continue_social_login")})]}),y("div",{className:"flex space-x-4 sm:flex-col sm:space-x-0 sm:space-y-4 short:flex-row short:space-x-4 short:space-y-0",children:[c&&y(Pi,{connection:"facebook",text:P.t("continue_with",{provider:"Facebook"}),canResize:!0,icon:y(Qe,{className:"text-xl text-[#1196F5] sm:absolute sm:left-4 sm:top-1/2 sm:-translate-y-1/2 sm:text-2xl short:static short:left-auto short:top-auto short:translate-y-0 short:text-xl",name:"facebook"}),loginSession:n}),l&&y(Pi,{connection:"google-oauth2",text:P.t("continue_with",{provider:"Google"}),canResize:!0,icon:y(g1,{className:"h-5 w-5 sm:absolute sm:left-4 sm:top-1/2 sm:h-6 sm:w-6 sm:-translate-y-1/2 short:static short:left-auto short:top-auto short:h-5 short:w-5 short:translate-y-0"}),loginSession:n}),u&&y(Pi,{connection:"apple",text:P.t("continue_with",{provider:"Apple"}),canResize:!0,icon:y(Qe,{className:"text-xl text-black dark:text-white sm:absolute sm:left-4 sm:top-1/2 sm:-translate-y-1/2 sm:text-2xl short:static short:left-auto short:top-auto short:translate-y-0 short:text-xl",name:"apple"}),loginSession:n}),p&&y(Pi,{connection:"vipps",text:P.t("continue_with",{provider:"Vipps"}),canResize:!0,icon:y(m1,{className:"h-5 w-5 sm:absolute sm:left-4 sm:top-1/2 sm:h-6 sm:w-6 sm:-translate-y-1/2 short:static short:left-auto short:top-auto short:h-5 short:w-5 short:translate-y-0"}),loginSession:n})]})]})]})},_1=["Auth0.swift"];function y1(t){if(!t)return"code";const e=atob(t),n=JSON.parse(e);return _1.includes(n.name)?"code":"link"}const v1=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"}),impersonation:o.z.string().optional()})},responses:{200:{description:"Response"}}}),async t=>{const{state:e,impersonation:n}=t.req.valid("query"),{vendorSettings:r,loginSession:i,client:s}=await Ie(t,e);return t.html(y(Kp,{vendorSettings:r,loginSession:i,client:s,email:i.authParams.username,impersonation:n==="true"}))}).openapi(o.createRoute({tags:["login"],method:"post",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})}),body:{content:{"application/x-www-form-urlencoded":{schema:o.z.object({username:o.z.string().transform(t=>t.toLowerCase()),act_as:o.z.string().transform(t=>t.toLowerCase()).optional(),login_selection:o.z.enum(["code","password"]).optional()})}}}},responses:{200:{description:"Response"}}}),async t=>{const{env:e}=t,{state:n}=t.req.valid("query"),r=t.req.valid("form");t.set("body",r),t.set("username",r.username);const{client:i,loginSession:s,vendorSettings:a}=await Ie(t,n);t.set("client_id",i.id);const c=r.username,l=await ro({userAdapter:e.data.users,tenant_id:i.tenant.id,email:c});if(l&&t.set("user_id",l.user_id),!l)try{await ly(t,i,t.env.data,r.username)}catch{const v=ve(t,{type:he.FAILED_SIGNUP,description:"Public signup is disabled"});return await t.env.data.logs.create(i.tenant.id,v),t.html(y(Kp,{vendorSettings:a,loginSession:s,error:P.t("user_account_does_not_exist"),email:r.username,client:i}),400)}if(s.authParams.username=r.username,s.authParams.act_as=r.act_as,await e.data.loginSessions.update(i.tenant.id,s.id,s),await i1(t,i,r.username,r.login_selection))return t.redirect(`/u/enter-password?state=${n}`);let u=Tn(),p=await e.data.codes.get(i.tenant.id,u,"otp");for(;p;)u=Tn(),p=await e.data.codes.get(i.tenant.id,u,"otp");const h=await t.env.data.codes.create(i.tenant.id,{code_id:u,code_type:"otp",login_id:s.id,expires_at:new Date(Date.now()+Na).toISOString()});return y1(s.auth0Client)==="link"&&!r.username.includes("online.no")?nt(t,ou(t,r.username,h.code_id,s.authParams)):nt(t,Jg(t,r.username,h.code_id)),t.redirect(`/u/enter-code?state=${n}`)}),zt=t=>y("a",{className:"block text-primary hover:text-primaryHover text-center",href:`/u/enter-email?state=${t.state}`,children:P.t("go_back")});var ri="_hp",w1={Change:"Input",DoubleClick:"DblClick"},b1={svg:"2000/svg",math:"1998/Math/MathML"},ii=[],Xc=new WeakMap,lr=void 0,k1=()=>lr,$t=t=>"t"in t,ya={onClick:["click",!1]},Wp=t=>{if(!t.startsWith("on"))return;if(ya[t])return ya[t];const e=t.match(/^on([A-Z][a-zA-Z]+?(?:PointerCapture)?)(Capture)?$/);if(e){const[,n,r]=e;return ya[t]=[(w1[n]||n).toLowerCase(),!!r]}},Gp=(t,e)=>lr&&t instanceof SVGElement&&/[A-Z]/.test(e)&&(e in t.style||e.match(/^(?:o|pai|str|u|ve)/))?e.replace(/([A-Z])/g,"-$1").toLowerCase():e,x1=(t,e,n)=>{var r;e||(e={});for(let i in e){const s=e[i];if(i!=="children"&&(!n||n[i]!==s)){i=Ws(i);const a=Wp(i);if(a){if((n==null?void 0:n[i])!==s&&(n&&t.removeEventListener(a[0],n[i],a[1]),s!=null)){if(typeof s!="function")throw new Error(`Event handler for "${i}" is not a function`);t.addEventListener(a[0],s,a[1])}}else if(i==="dangerouslySetInnerHTML"&&s)t.innerHTML=s.__html;else if(i==="ref"){let c;typeof s=="function"?c=s(t)||(()=>s(null)):s&&"current"in s&&(s.current=t,c=()=>s.current=null),Xc.set(t,c)}else if(i==="style"){const c=t.style;typeof s=="string"?c.cssText=s:(c.cssText="",s!=null&&rm(s,c.setProperty.bind(c)))}else{if(i==="value"){const l=t.nodeName;if(l==="INPUT"||l==="TEXTAREA"||l==="SELECT"){if(t.value=s==null||s===!1?null:s,l==="TEXTAREA"){t.textContent=s;continue}else if(l==="SELECT"){t.selectedIndex===-1&&(t.selectedIndex=0);continue}}}else(i==="checked"&&t.nodeName==="INPUT"||i==="selected"&&t.nodeName==="OPTION")&&(t[i]=s);const c=Gp(t,i);s==null||s===!1?t.removeAttribute(c):s===!0?t.setAttribute(c,""):typeof s=="string"||typeof s=="number"?t.setAttribute(c,s):t.setAttribute(c,s.toString())}}}if(n)for(let i in n){const s=n[i];if(i!=="children"&&!(i in e)){i=Ws(i);const a=Wp(i);a?t.removeEventListener(a[0],s,a[1]):i==="ref"?(r=Xc.get(t))==null||r():t.removeAttribute(Gp(t,i))}}},S1=(t,e)=>{e[Ae][0]=0,ii.push([t,e]);const n=e.tag[uu]||e.tag,r=n.defaultProps?{...n.defaultProps,...e.props}:e.props;try{return[n.call(null,r)]}finally{ii.pop()}},om=(t,e,n,r,i)=>{var s,a;(s=t.vR)!=null&&s.length&&(r.push(...t.vR),delete t.vR),typeof t.tag=="function"&&((a=t[Ae][1][um])==null||a.forEach(c=>i.push(c))),t.vC.forEach(c=>{var l;if($t(c))n.push(c);else if(typeof c.tag=="function"||c.tag===""){c.c=e;const u=n.length;if(om(c,e,n,r,i),c.s){for(let p=u;p<n.length;p++)n[p].s=!0;c.s=!1}}else n.push(c),(l=c.vR)!=null&&l.length&&(r.push(...c.vR),delete c.vR)})},A1=t=>{for(;;t=t.tag===ri||!t.vC||!t.pP?t.nN:t.vC[0]){if(!t)return null;if(t.tag!==ri&&t.e)return t.e}},am=t=>{var e,n,r,i,s,a;$t(t)||((n=(e=t[Ae])==null?void 0:e[1][um])==null||n.forEach(c=>{var l;return(l=c[2])==null?void 0:l.call(c)}),(r=Xc.get(t.e))==null||r(),t.p===2&&((i=t.vC)==null||i.forEach(c=>c.p=2)),(s=t.vC)==null||s.forEach(am)),t.p||((a=t.e)==null||a.remove(),delete t.e),typeof t.tag=="function"&&($r.delete(t),Ji.delete(t),delete t[Ae][3],t.a=!0)},cm=(t,e,n)=>{t.c=e,lm(t,e,n)},Jp=(t,e)=>{if(e){for(let n=0,r=t.length;n<r;n++)if(t[n]===e)return n}},Zp=Symbol(),lm=(t,e,n)=>{var u;const r=[],i=[],s=[];om(t,e,r,i,s),i.forEach(am);const a=n?void 0:e.childNodes;let c,l=null;if(n)c=-1;else if(!a.length)c=0;else{const p=Jp(a,A1(t.nN));p!==void 0?(l=a[p],c=p):c=Jp(a,(u=r.find(h=>h.tag!==ri&&h.e))==null?void 0:u.e)??-1,c===-1&&(n=!0)}for(let p=0,h=r.length;p<h;p++,c++){const m=r[p];let v;if(m.s&&m.e)v=m.e,m.s=!1;else{const f=n||!m.e;$t(m)?(m.e&&m.d&&(m.e.textContent=m.t),m.d=!1,v=m.e||(m.e=document.createTextNode(m.t))):(v=m.e||(m.e=m.n?document.createElementNS(m.n,m.tag):document.createElement(m.tag)),x1(v,m.props,m.pP),lm(m,v,f))}m.tag===ri?c--:n?v.parentNode||e.appendChild(v):a[c]!==v&&a[c-1]!==v&&(a[c+1]===v?e.appendChild(a[c]):e.insertBefore(v,l||a[c]||null))}if(t.pP&&delete t.pP,s.length){const p=[],h=[];s.forEach(([,m,,v,f])=>{m&&p.push(m),v&&h.push(v),f==null||f()}),p.forEach(m=>m()),h.length&&requestAnimationFrame(()=>{h.forEach(m=>m())})}},Ji=new WeakMap,Qc=(t,e,n)=>{var s,a,c,l,u,p;const r=!n&&e.pC;n&&(e.pC||(e.pC=e.vC));let i;try{n||(n=typeof e.tag=="function"?S1(t,e):Ai(e.props.children)),((s=n[0])==null?void 0:s.tag)===""&&n[0][Zc]&&(i=n[0][Zc],t[5].push([t,i,e]));const h=r?[...e.pC]:e.vC?[...e.vC]:void 0,m=[];let v;for(let f=0;f<n.length;f++){Array.isArray(n[f])&&n.splice(f,1,...n[f].flat());let _=E1(n[f]);if(_){typeof _.tag=="function"&&!_.tag[Xg]&&(ar.length>0&&(_[Ae][2]=ar.map(S=>[S,S.values.at(-1)])),(a=t[5])!=null&&a.length&&(_[Ae][3]=t[5].at(-1)));let w;if(h&&h.length){const S=h.findIndex($t(_)?C=>$t(C):_.key!==void 0?C=>C.key===_.key&&C.tag===_.tag:C=>C.tag===_.tag);S!==-1&&(w=h[S],h.splice(S,1))}if(w)if($t(_))w.t!==_.t&&(w.t=_.t,w.d=!0),_=w;else{const S=w.pP=w.props;w.props=_.props,w.f||(w.f=_.f||e.f),typeof _.tag=="function"&&(w[Ae][2]=_[Ae][2]||[],w[Ae][3]=_[Ae][3],!w.f&&((w.o||w)===_.o||(l=(c=w.tag)[Mb])!=null&&l.call(c,S,w.props))&&(w.s=!0)),_=w}else if(!$t(_)&&lr){const S=kr(lr);S&&(_.n=S)}if(!$t(_)&&!_.s&&(Qc(t,_),delete _.f),m.push(_),v&&!v.s&&!_.s)for(let S=v;S&&!$t(S);S=(u=S.vC)==null?void 0:u.at(-1))S.nN=_;v=_}}e.vR=r?[...e.vC,...h||[]]:h||[],e.vC=m,r&&delete e.pC}catch(h){if(e.f=!0,h===Zp){if(i)return;throw h}const[m,v,f]=((p=e[Ae])==null?void 0:p[3])||[];if(v){const _=()=>Zi([0,!1,t[2]],f),w=Ji.get(f)||[];w.push(_),Ji.set(f,w);const S=v(h,()=>{const C=Ji.get(f);if(C){const B=C.indexOf(_);if(B!==-1)return C.splice(B,1),_()}});if(S){if(t[0]===1)t[1]=!0;else if(Qc(t,f,[S]),(v.length===1||t!==m)&&f.c){cm(f,f.c,!1);return}throw Zp}}throw h}finally{i&&t[5].pop()}},E1=t=>{if(!(t==null||typeof t=="boolean")){if(typeof t=="string"||typeof t=="number")return{t:t.toString(),d:!0};if("vR"in t&&(t={tag:t.tag,props:t.props,key:t.key,f:t.f,type:t.tag,ref:t.props.ref,o:t.o||t}),typeof t.tag=="function")t[Ae]=[0,[]];else{const e=b1[t.tag];e&&(lr||(lr=em("")),t.props.children=[{tag:lr,props:{value:t.n=`http://www.w3.org/${e}`,children:t.props.children}}])}return t}},Yp=(t,e)=>{var n,r;(n=e[Ae][2])==null||n.forEach(([i,s])=>{i.values.push(s)});try{Qc(t,e,void 0)}catch{return}if(e.a){delete e.a;return}(r=e[Ae][2])==null||r.forEach(([i])=>{i.values.pop()}),(t[0]!==1||!t[1])&&cm(e,e.c,!1)},$r=new WeakMap,Xp=[],Zi=async(t,e)=>{t[5]||(t[5]=[]);const n=$r.get(e);n&&n[0](void 0);let r;const i=new Promise(s=>r=s);if($r.set(e,[r,()=>{t[2]?t[2](t,e,s=>{Yp(s,e)}).then(()=>r(e)):(Yp(t,e),r(e))}]),Xp.length)Xp.at(-1).add(e);else{await Promise.resolve();const s=$r.get(e);s&&($r.delete(e),s[1]())}return i},I1=(t,e,n)=>({tag:ri,props:{children:t},key:n,e,p:1}),va=0,um=1,wa=2,ba=3,ka=new WeakMap,dm=(t,e)=>!t||!e||t.length!==e.length||e.some((n,r)=>n!==t[r]),z1=void 0,Qp=[],N1=t=>{var a;const e=()=>typeof t=="function"?t():t,n=ii.at(-1);if(!n)return[e(),()=>{}];const[,r]=n,i=(a=r[Ae][1])[va]||(a[va]=[]),s=r[Ae][0]++;return i[s]||(i[s]=[e(),c=>{const l=z1,u=i[s];if(typeof c=="function"&&(c=c(u[0])),!Object.is(c,u[0]))if(u[0]=c,Qp.length){const[p,h]=Qp.at(-1);Promise.all([p===3?r:Zi([p,!1,l],r),h]).then(([m])=>{if(!m||!(p===2||p===3))return;const v=m.vC;requestAnimationFrame(()=>{setTimeout(()=>{v===m.vC&&Zi([p===3?1:0,!1,l],m)})})})}else Zi([0,!1,l],r)}])},gu=(t,e)=>{var c;const n=ii.at(-1);if(!n)return t;const[,r]=n,i=(c=r[Ae][1])[wa]||(c[wa]=[]),s=r[Ae][0]++,a=i[s];return dm(a==null?void 0:a[1],e)?i[s]=[t,e]:t=i[s][0],t},C1=t=>{const e=ka.get(t);if(e){if(e.length===2)throw e[1];return e[0]}throw t.then(n=>ka.set(t,[n]),n=>ka.set(t,[void 0,n])),t},j1=(t,e)=>{var c;const n=ii.at(-1);if(!n)return t();const[,r]=n,i=(c=r[Ae][1])[ba]||(c[ba]=[]),s=r[Ae][0]++,a=i[s];return dm(a==null?void 0:a[1],e)&&(i[s]=[t(),e]),i[s][0]},$1=em({pending:!1,data:null,method:null,action:null}),ef=new Set,O1=t=>{ef.add(t),t.finally(()=>ef.delete(t))},mu=(t,e)=>j1(()=>n=>{let r;t&&(typeof t=="function"?r=t(n)||(()=>{t(null)}):t&&"current"in t&&(t.current=n,r=()=>{t.current=null}));const i=e(n);return()=>{i==null||i(),r==null||r()}},[t]),Mn=Object.create(null),Ri=Object.create(null),zi=(t,e,n,r,i)=>{if(e!=null&&e.itemProp)return{tag:t,props:e,type:t,ref:e.ref};const s=document.head;let{onLoad:a,onError:c,precedence:l,blocking:u,...p}=e,h=null,m=!1;const v=Ki[t];let f;if(v.length>0){const C=s.querySelectorAll(t);e:for(const B of C)for(const L of Ki[t])if(B.getAttribute(L)===e[L]){h=B;break e}if(!h){const B=v.reduce((L,Q)=>e[Q]===void 0?L:`${L}-${Q}-${e[Q]}`,t);m=!Ri[B],h=Ri[B]||(Ri[B]=(()=>{const L=document.createElement(t);for(const Q of v)e[Q]!==void 0&&L.setAttribute(Q,e[Q]),e.rel&&L.setAttribute("rel",e.rel);return L})())}}else f=s.querySelectorAll(t);l=r?l??"":void 0,r&&(p[Wi]=l);const _=gu(C=>{if(v.length>0){let B=!1;for(const L of s.querySelectorAll(t)){if(B&&L.getAttribute(Wi)!==l){s.insertBefore(C,L);return}L.getAttribute(Wi)===l&&(B=!0)}s.appendChild(C)}else if(f){let B=!1;for(const L of f)if(L===C){B=!0;break}B||s.insertBefore(C,s.contains(f[0])?f[0]:s.querySelector(t)),f=void 0}},[l]),w=mu(e.ref,C=>{var Q;const B=v[0];if(n===2&&(C.innerHTML=""),(m||f)&&_(C),!c&&!a)return;let L=Mn[Q=C.getAttribute(B)]||(Mn[Q]=new Promise((ce,le)=>{C.addEventListener("load",ce),C.addEventListener("error",le)}));a&&(L=L.then(a)),c&&(L=L.catch(c)),L.catch(()=>{})});if(i&&u==="render"){const C=Ki[t][0];if(e[C]){const B=e[C],L=Mn[B]||(Mn[B]=new Promise((Q,ce)=>{_(h),h.addEventListener("load",Q),h.addEventListener("error",ce)}));C1(L)}}const S={tag:t,type:t,props:{...p,ref:w},ref:w};return S.p=n,h&&(S.e=h),I1(S,s)},B1=t=>{const e=k1(),n=e&&kr(e);return n!=null&&n.endsWith("svg")?{tag:"title",props:t,type:"title",ref:t.ref}:zi("title",t,void 0,!1,!1)},T1=t=>!t||["src","async"].some(e=>!t[e])?{tag:"script",props:t,type:"script",ref:t.ref}:zi("script",t,1,!1,!0),P1=t=>!t||!["href","precedence"].every(e=>e in t)?{tag:"style",props:t,type:"style",ref:t.ref}:(t["data-href"]=t.href,delete t.href,zi("style",t,2,!0,!0)),R1=t=>!t||["onLoad","onError"].some(e=>e in t)||t.rel==="stylesheet"&&(!("precedence"in t)||"disabled"in t)?{tag:"link",props:t,type:"link",ref:t.ref}:zi("link",t,1,"precedence"in t,!0),L1=t=>zi("meta",t,void 0,!1,!1),pm=Symbol(),U1=t=>{const{action:e,...n}=t;typeof e!="function"&&(n.action=e);const[r,i]=N1([null,!1]),s=gu(async u=>{const p=u.isTrusted?e:u.detail[pm];if(typeof p!="function")return;u.preventDefault();const h=new FormData(u.target);i([h,!0]);const m=p(h);m instanceof Promise&&(O1(m),await m),i([null,!0])},[]),a=mu(t.ref,u=>(u.addEventListener("submit",s),()=>{u.removeEventListener("submit",s)})),[c,l]=r;return r[1]=!1,{tag:$1,props:{value:{pending:c!==null,data:c,method:c?"post":null,action:c?e:null},children:{tag:"form",props:{...n,ref:a},type:"form",ref:a}},f:l}},fm=(t,{formAction:e,...n})=>{if(typeof e=="function"){const r=gu(i=>{i.preventDefault(),i.currentTarget.form.dispatchEvent(new CustomEvent("submit",{detail:{[pm]:e}}))},[]);n.ref=mu(n.ref,i=>(i.addEventListener("click",r),()=>{i.removeEventListener("click",r)}))}return{tag:t,props:n,type:t,ref:n.ref}},V1=t=>fm("input",t),q1=t=>fm("button",t);Object.assign(Yc,{title:B1,script:T1,style:P1,link:R1,meta:L1,form:U1,input:V1,button:q1});new TextEncoder;const _u=t=>{const{i18nKey:e,values:n,components:r}=t,i=P.t(e,n),s=/<(\d+)>(.*?)<\/\d+>/g,a=[];let c=0,l;for(;(l=s.exec(i))!==null;){const[,u,p]=l,h=i.substring(c,l.index);h&&a.push(h);const m=parseInt(u,10);a.push(r1(r[m],{},p)),c=s.lastIndex}return c<i.length&&a.push(i.substring(c)),y(fu,{children:a})},tf=6,nf=({error:t,vendorSettings:e,email:n,state:r,client:i,hasPasswordLogin:s})=>{const a=new URLSearchParams({state:r}),l=i.connections.map(({name:u})=>u).includes("auth2");return y(Ze,{title:P.t("verify_your_email"),vendorSettings:e,children:[y("div",{className:"mb-4 text-2xl font-medium",children:P.t("verify_your_email")}),y("div",{className:"mb-8 text-gray-300",children:y(_u,{i18nKey:"we_sent_a_code_to",components:[y("span",{className:"text-black dark:text-white"},"span")],values:{email:n}})}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y(dn,{className:"pt-2",children:[y("input",{autoFocus:!0,type:"text",pattern:"[0-9]*",maxLength:tf,inputMode:"numeric",name:"code",placeholder:"******",className:It("mb-2 w-full rounded-lg border bg-gray-100 px-4 pb-2 pt-2.5 text-center indent-[5px] font-mono text-3xl placeholder:text-gray-300 dark:bg-gray-600 md:text-3xl",{"border-red":t,"border-gray-100 dark:border-gray-500":!t}),minLength:tf,required:!0,id:"code-input"}),t&&y(xr,{children:t}),y("div",{className:"text-center sm:mt-2",children:y(un,{className:"text-base sm:mt-4 md:text-base",children:y("div",{className:"flex items-center space-x-2",children:[y("span",{children:P.t("login")}),y(Qe,{className:"text-xs",name:"arrow-right"})]})})}),y("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[y(Qe,{className:"text-base",name:"info-bubble"}),y("div",{className:"text-sm text-gray-300 md:text-sm",children:P.t("sent_code_spam")})]}),l&&y("div",{className:"text-center mb-12",children:[y("div",{className:"relative mb-5 block text-center text-gray-300 dark:text-gray-300",children:[y("div",{className:"absolute left-0 right-0 top-1/2 border-b border-gray-200 dark:border-gray-600"}),y("div",{className:"relative inline-block bg-white px-2 dark:bg-gray-800",children:P.t("or")})]}),y(cr,{Component:"a",href:`/u/${s?"enter-password":"pre-signup"}?${a.toString()}`,variant:"secondary",className:"block",children:P.t("enter_your_password_btn")})]})]}),y(zt,{state:r})]})]})},M1=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,loginSession:r,client:i}=await Ie(t,e);if(!r.authParams.username)throw new z(400,{message:"Username not found in state"});const s=await ls({userAdapter:t.env.data.users,tenant_id:i.tenant.id,email:r.authParams.username,provider:"auth2"});return t.html(y(nf,{vendorSettings:n,email:r.authParams.username,state:e,client:i,hasPasswordLogin:!!s}))}).openapi(o.createRoute({tags:["login"],method:"post",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state"})}),body:{content:{"application/x-www-form-urlencoded":{schema:o.z.object({code:o.z.string()})}}}},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{code:n}=t.req.valid("form"),{loginSession:r,client:i,vendorSettings:s}=await Ie(t,e);if(t.set("client_id",i.id),!r.authParams.username)throw new z(400,{message:"Username not found in state"});try{return await cu(t,i,r.authParams,r.authParams.username,n)}catch(a){const c=a,l=await ls({userAdapter:t.env.data.users,tenant_id:i.tenant.id,email:r.authParams.username,provider:"auth2"});return t.html(y(nf,{vendorSettings:s,email:r.authParams.username,state:e,client:i,error:c.message,hasPasswordLogin:!!l}),400)}}),D1=t=>{const{vendorSettings:e,state:n}=t;return y(Ze,{title:P.t("unverified_email"),vendorSettings:e,children:[y("div",{className:"flex flex-1 flex-col justify-center",children:[y("p",{className:"mb-8 text-gray-300 text-lg",children:P.t("unverified_email")}),y("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[y(Qe,{className:"text-base",name:"info-bubble"}),y("div",{className:"text-sm text-gray-300 md:text-sm",children:P.t("sent_code_spam")})]}),y(zt,{state:n})]}),y(zt,{state:n})]})},xa=t=>{const{error:e,vendorSettings:n,email:r,state:i}=t,s=new URLSearchParams({state:i});return y(Ze,{title:P.t("enter_password"),vendorSettings:n,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:P.t("enter_password")}),y("div",{className:"mb-6 text-gray-300",children:P.t("enter_password_description")}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y(dn,{className:"mb-7",children:[y("input",{type:"text",name:"username",placeholder:P.t("email_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",value:r}),y("input",{type:"password",name:"password",placeholder:P.t("password")||"",className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",required:!0}),e&&y(xr,{children:e}),y(un,{className:"text-base sm:mt-4 md:text-base",children:y("div",{className:"flex items-center space-x-2",children:[y("span",{children:P.t("login")}),y(Qe,{className:"text-xs",name:"arrow-right"})]})})]}),y("a",{href:`/u/forgot-password?${s.toString()}`,className:"text-primary hover:underline mb-4",children:P.t("forgot_password_link")}),y("div",{className:"text-center mb-12",children:[y("div",{className:"relative mb-5 block text-center text-gray-300 dark:text-gray-300",children:[y("div",{className:"absolute left-0 right-0 top-1/2 border-b border-gray-200 dark:border-gray-600"}),y("div",{className:"relative inline-block bg-white px-2 dark:bg-gray-800",children:P.t("or")})]}),y("form",{method:"post",action:`/u/enter-email?${s.toString()}`,children:[y("input",{type:"hidden",name:"login_selection",value:"code"}),y("input",{type:"hidden",name:"username",value:r}),y(cr,{variant:"secondary",className:"block",children:P.t("enter_a_code_btn")})]})]}),y(zt,{state:i})]})]})},H1=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,client:r,loginSession:i}=await Ie(t,e);if(!i.authParams.username)throw new z(400,{message:"Username required"});return t.html(y(xa,{vendorSettings:n,email:i.authParams.username,state:e,client:r}))}).openapi(o.createRoute({tags:["login"],method:"post",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})}),body:{content:{"application/x-www-form-urlencoded":{schema:o.z.object({password:o.z.string()})}}}},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),n=t.req.valid("form"),{password:r}=n,{vendorSettings:i,client:s,loginSession:a}=await Ie(t,e),{username:c}=a.authParams;if(!c)throw new z(400,{message:"Username required"});try{return await lu(t,s,{...a.authParams,password:r},a)}catch(l){const u=l;return u.code==="INVALID_PASSWORD"||u.code==="USER_NOT_FOUND"?t.html(y(xa,{vendorSettings:i,email:c,error:P.t("invalid_password"),state:e,client:s}),400):u.code==="EMAIL_NOT_VERIFIED"?t.html(y(D1,{vendorSettings:i,state:e}),400):t.html(y(xa,{vendorSettings:i,email:c,error:u.message,state:e,client:s}),400)}}),Cr=t=>{const{state:e,error:n,vendorSettings:r,email:i,code:s}=t;return y(Ze,{title:P.t("create_account_title"),vendorSettings:r,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:P.t("create_account_title")}),y("div",{className:"mb-6 text-gray-300",children:P.t("create_account_description")}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y(dn,{children:[y("input",{type:"hidden",name:"code",value:s}),y("input",{type:"email",name:"username",placeholder:P.t("email_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",required:!0,value:i,disabled:!!i}),y("input",{type:"password",name:"password",placeholder:P.t("enter_new_password_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base"}),y("input",{type:"password",name:"re-enter-password",placeholder:P.t("reenter_new_password_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base"}),n&&y(xr,{children:n}),y(un,{className:"text-base sm:mt-2 md:text-base",children:P.t("continue")})]}),y(zt,{state:e})]})]})},yu=t=>{const{message:e,vendorSettings:n,pageTitle:r,state:i}=t;return y(Ze,{title:"Login",vendorSettings:n,children:[r?y("div",{className:"mb-6 text-gray-300",children:r}):"",y("div",{className:"flex flex-1 flex-col justify-center",children:e}),i?y(zt,{state:i}):""]})},F1=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"}),code:o.z.string().optional().openapi({description:"The code parameter from an email verification link"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e,code:n}=t.req.valid("query"),{vendorSettings:r,loginSession:i}=await Ie(t,e),{username:s}=i.authParams;if(!s)throw new z(400,{message:"Username required"});return n?t.html(y(Cr,{state:e,vendorSettings:r,email:s,code:n})):t.html(y(Cr,{state:e,vendorSettings:r,email:s}))}).openapi(o.createRoute({tags:["login"],method:"post",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})}),body:{content:{"application/x-www-form-urlencoded":{schema:o.z.object({password:o.z.string(),"re-enter-password":o.z.string(),code:o.z.string().optional()})}}}},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),n=t.req.valid("form"),{env:r}=t,{vendorSettings:i,client:s,loginSession:a}=await Ie(t,e),c="Username-Password-Authentication";t.set("client_id",s.id),t.set("connection",c);const l=a.authParams.username;if(!l)throw new z(400,{message:"Username required"});if(n.password!==n["re-enter-password"])return t.html(y(Cr,{state:e,code:n.code,vendorSettings:i,error:P.t("create_account_passwords_didnt_match"),email:a.authParams.username}),400);if(!su(n.password))return t.html(y(Cr,{state:e,code:n.code,vendorSettings:i,error:P.t("create_account_weak_password"),email:a.authParams.username}),400);const u=n.code?await r.data.codes.get(s.tenant.id,n.code,"email_verification"):void 0,p=u?await r.data.loginSessions.get(s.tenant.id,u.login_id):void 0;try{if(await ur({userAdapter:t.env.data.users,tenant_id:s.tenant.id,email:l,provider:"auth2"}))throw new z(400,{message:"Invalid sign up"});const m=(p==null?void 0:p.authParams.username)===l,v=await Hf(t).users.create(s.tenant.id,{user_id:`auth2|${Xs()}`,email:l,email_verified:m,provider:"auth2",connection:c,is_social:!1});return await r.data.passwords.create(s.tenant.id,{user_id:v.user_id,password:await si.hash(n.password,10),algorithm:"bcrypt"}),m?await lu(t,s,{...a.authParams,password:n.password},a):(await au(t,v),t.html(y(yu,{message:P.t("validate_email_body"),pageTitle:P.t("validate_email_title"),vendorSettings:i,state:e})))}catch(h){const m=await hu(r,s.id,a.authParams.vendor_id),v=h;return t.html(y(Cr,{state:e,vendorSettings:m,error:v.message,email:l}),400)}}),jr=t=>{const{error:e,vendorSettings:n,email:r}=t;return y(Ze,{title:P.t("reset_password_title"),vendorSettings:n,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:P.t("reset_password_title")}),y("div",{className:"mb-6 text-gray-300",children:`${P.t("reset_password_description")} ${r}`}),y("div",{className:"flex flex-1 flex-col justify-center",children:y(dn,{children:[y("input",{type:"password",name:"password",placeholder:P.t("enter_new_password_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base"}),y("input",{type:"password",name:"re-enter-password",placeholder:P.t("reenter_new_password_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base"}),e&&y(xr,{children:e}),y(un,{className:"text-base sm:mt-2 md:text-base",children:P.t("reset_password_cta")})]})})]})},K1=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"}),code:o.z.string().openapi({description:"The code parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,loginSession:r}=await Ie(t,e);if(!r.authParams.username)throw new z(400,{message:"Username required"});return t.html(y(jr,{vendorSettings:n,email:r.authParams.username}))}).openapi(o.createRoute({tags:["login"],method:"post",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"}),code:o.z.string().openapi({description:"The code parameter from the authorization request"})}),body:{content:{"application/x-www-form-urlencoded":{schema:o.z.object({password:o.z.string(),"re-enter-password":o.z.string()})}}}},responses:{200:{description:"Response"}}}),async t=>{const{state:e,code:n}=t.req.valid("query"),{password:r,"re-enter-password":i}=t.req.valid("form"),{env:s}=t,{vendorSettings:a,client:c,loginSession:l}=await Ie(t,e);if(!l.authParams.username)throw new z(400,{message:"Username required"});if(r!==i)return t.html(y(jr,{error:P.t("create_account_passwords_didnt_match"),vendorSettings:a,email:l.authParams.username}),400);if(!su(r))return t.html(y(jr,{error:P.t("create_account_weak_password"),vendorSettings:a,email:l.authParams.username}),400);const u=await ur({userAdapter:s.data.users,tenant_id:c.tenant.id,email:l.authParams.username,provider:"auth2"});if(!u)throw new z(400,{message:"User not found"});try{if(!await s.data.codes.get(c.tenant.id,n,"password_reset"))return t.html(y(jr,{error:"Code not found or expired",vendorSettings:a,email:l.authParams.username}),400);const h={user_id:u.user_id,password:await si.hash(r,10),algorithm:"bcrypt"};await s.data.passwords.get(c.tenant.id,u.user_id)?await s.data.passwords.update(c.tenant.id,h):await s.data.passwords.create(c.tenant.id,h),u.email_verified||await s.data.users.update(c.tenant.id,u.user_id,{email_verified:!0})}catch{return t.html(y(jr,{error:"The password could not be reset",vendorSettings:a,email:l.authParams.username}),400)}return t.html(y(yu,{message:P.t("password_has_been_reset"),vendorSettings:a,state:e}))}),W1=t=>{const{error:e,vendorSettings:n,email:r,state:i}=t;return y(Ze,{title:P.t("forgot_password_title"),vendorSettings:n,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:P.t("forgot_password_title")}),y("div",{className:"mb-6 text-gray-300",children:P.t("forgot_password_description")}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y(dn,{className:"pt-2",children:[y("input",{type:"email",name:"username",placeholder:P.t("email_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",value:r,disabled:!!r}),e&&y(xr,{children:e}),y(un,{className:"sm:mt-4",children:P.t("forgot_password_cta")})]}),y(zt,{state:i})]})]})},G1=t=>{const{vendorSettings:e,state:n}=t;return y(Ze,{title:"Login",vendorSettings:e,children:[y("div",{className:"flex flex-1 flex-col justify-center",children:[y("div",{children:P.t("forgot_password_email_sent")}),y("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[y(Qe,{className:"text-base",name:"info-bubble"}),y("div",{className:"text-sm text-gray-300 md:text-sm",children:P.t("sent_code_spam")})]})]}),y(zt,{state:n})]})},J1=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,loginSession:r}=await Ie(t,e);return t.html(y(W1,{vendorSettings:n,state:e,email:r.authParams.username}))}).openapi(o.createRoute({tags:["login"],method:"post",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,client:r,loginSession:i}=await Ie(t,e);return await Cb(t,r,i.authParams.username,i.id),t.html(y(G1,{vendorSettings:n,state:e}))}),Z1=({vendorSettings:t,state:e,user:n})=>y(Ze,{title:se("check_email_title"),vendorSettings:t,children:y("div",{className:"flex flex-1 flex-col justify-center",children:[y("div",{className:"mb-8 text-gray-700 dark:text-gray-300",children:[y(_u,{i18nKey:"currently_logged_in_as",components:[y("span",{className:"font-semibold text-gray-900 dark:text-white"},"span")],values:{email:n.email}}),y("br",{}),se("continue_with_sso_provider_headline")]}),y("div",{className:"space-y-6",children:[y(dn,{children:y(un,{className:"w-full text-base sm:mt-4 md:text-base",children:y("div",{className:"flex items-center justify-center space-x-2",children:y("span",{children:P.t("yes_continue_with_existing_account")})})})}),y("a",{className:"block text-center text-primary hover:text-primaryHover focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 dark:focus:ring-offset-gray-900",href:`/u/enter-email?state=${encodeURIComponent(e)}`,children:P.t("no_use_another")})]})]})}),Y1=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{env:e}=t,{state:n}=t.req.valid("query"),{vendorSettings:r,client:i}=await Ie(t,n),s=cs(i.tenant.id,t.req.header("cookie")),a=s?await e.data.sessions.get(i.tenant.id,s):null;if(!a)return t.redirect(`/u/enter-email?state=${n}`);const c=await e.data.users.get(i.tenant.id,a.user_id);return c?t.html(y(Z1,{vendorSettings:r,state:n,user:c})):t.redirect(`/u/enter-email?state=${n}`)}).openapi(o.createRoute({tags:["login"],method:"post",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{302:{description:"Redirect"}}}),async t=>{const{env:e}=t,{state:n}=t.req.valid("query"),{loginSession:r,client:i}=await Ie(t,n),s=cs(i.tenant.id,t.req.header("cookie")),a=s?await e.data.sessions.get(i.tenant.id,s):null;if(!a)return t.redirect(`/u/enter-email?state=${n}`);const c=await e.data.users.get(i.tenant.id,a.user_id);return c?on(t,{user:c,authParams:r.authParams,client:i,loginSession:r}):t.redirect(`/u/enter-email?state=${n}`)}),X1=t=>{const{vendorSettings:e,email:n,state:r}=t;return y(Ze,{title:P.t("create_password_account_title"),vendorSettings:e,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:P.t("create_password_account_title")}),y("div",{className:"mb-6 text-gray-300",children:P.t("enter_email_for_verification_description")}),y("div",{className:"flex flex-1 flex-col justify-center",children:y(dn,{className:"pt-2",children:[y("input",{type:"email",name:"username",placeholder:P.t("email_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",required:!0,value:n,disabled:!0}),y(un,{className:"text-base sm:mt-4 md:text-base",children:y("div",{className:"flex items-center space-x-2",children:y("span",{children:P.t("send")})})})]})}),y(zt,{state:r})]})},Q1=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,loginSession:r}=await Ie(t,e),{username:i}=r.authParams;if(!i)throw new z(400,{message:"Username required"});return t.html(y(X1,{state:e,vendorSettings:n,email:i}))}).openapi(o.createRoute({tags:["login"],method:"post",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{loginSession:n,client:r}=await Ie(t,e),{username:i}=n.authParams;if(!i)throw new z(400,{message:"Username required"});const s=await t.env.data.codes.create(r.tenant.id,{code_id:Tn(),code_type:"email_verification",login_id:n.id,expires_at:new Date(Date.now()+A_).toISOString()});return await Ib(t,i,s.code_id,n.id),t.redirect(`/u/pre-signup-sent?state=${e}`)}),ek=t=>{const{redirectUrl:e,vendorSettings:n}=t;return y(Ze,{title:P.t("invalid_session_title"),vendorSettings:n,children:[y("div",{className:"flex flex-1 flex-col justify-center",children:P.t("invalid_session_body")}),y("div",{className:"flex flex-1 flex-col justify-center",children:e&&y("a",{className:"block text-primary hover:text-primaryHover text-center",href:e,children:P.t("go_back")})})]})},tk=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string()})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,loginSession:r}=await Ie(t,e);let i;return r.authParams.redirect_uri&&r.authParams.state&&(i=new URL(r.authParams.redirect_uri),i.searchParams.set("state",r.authParams.state),i.searchParams.set("error","invalid_session"),i.searchParams.set("error_description",r.authParams.username||"")),t.html(y(ek,{redirectUrl:i==null?void 0:i.href,vendorSettings:n}))}),nk=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"}),code:o.z.string().openapi({description:"The code parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const e=await hu(t.env),{state:n}=t.req.valid("query");return t.html(y(yu,{message:"Not implemented",pageTitle:"User info",vendorSettings:e,state:n}))}),rk=({vendorSettings:t,state:e})=>{const n=new URLSearchParams({state:e});return y(Ze,{title:P.t("email_validated"),vendorSettings:t,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:P.t("email_validated")}),y("div",{className:"flex flex-1 flex-col justify-center mb-7",children:y(cr,{Component:"a",href:`/u/enter-password?${n}`,className:"text-base sm:mt-4 md:text-base",children:y("div",{className:"flex items-center space-x-2",children:[y("span",{children:P.t("email_validated_cta")}),y(Qe,{className:"text-xs",name:"arrow-right"})]})})})]})},ik=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"}),code:o.z.string().openapi({description:"The code parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{var m;const{state:e,code:n}=t.req.valid("query"),{env:r}=t,{client:i,loginSession:s,vendorSettings:a}=await Ie(t,e),c=s.authParams.username;if(!c)throw new z(400,{message:"Username not found in state"});const l=await ur({userAdapter:r.data.users,tenant_id:i.tenant.id,email:c,provider:"auth2"});if(!l)throw new z(500,{message:"No user found"});if(!await r.data.codes.get(i.tenant.id,n,"email_verification"))throw new z(400,{message:"Code not found or expired"});await r.data.users.update(i.tenant.id,l.user_id,{email_verified:!0});const h=(await pl(r.data.users,i.tenant.id,c)).filter(v=>v.provider!=="auth2");if(h.length>0){const v=h.filter(f=>!f.linked_to);v.length>1&&console.error("More than one primary user found for email",c),v.length===0&&console.error("No primary user found for email",c),v.length===1&&await r.data.users.update(i.tenant.id,l.user_id,{linked_to:(m=v[0])==null?void 0:m.user_id})}return t.html(y(rk,{vendorSettings:a,state:e}))}),sk=t=>{const{vendorSettings:e,email:n,state:r}=t;return y(Ze,{title:P.t("email_verification_for_signup_sent_title"),vendorSettings:e,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:P.t("email_verification_for_signup_sent_title")}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y("div",{className:"mb-6 text-gray-300",children:y(_u,{i18nKey:"email_verification_for_signup_sent_description",components:[y("span",{className:"text-black dark:text-white"},"span")],values:{email:n}})}),y("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[y(Qe,{className:"text-base",name:"info-bubble"}),y("div",{className:"text-sm text-gray-300 md:text-sm",children:P.t("sent_code_spam")})]})]}),y(zt,{state:r})]})},ok=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,loginSession:r}=await Ie(t,e),{username:i}=r.authParams;if(!i)throw new z(400,{message:"Username required"});return t.html(y(sk,{vendorSettings:n,state:e,email:i}))});function ak(t){const e=new o.OpenAPIHono;e.use(async(r,i)=>(r.env.data=no(r,t.dataAdapter),i()));const n=e.route("/info",nk).route("/check-account",Y1).route("/enter-email",v1).route("/enter-code",M1).route("/enter-password",H1).route("/invalid-session",tk).route("/pre-signup",Q1).route("/pre-signup-sent",ok).route("/reset-password",K1).route("/forgot-password",J1).route("/validate-email",ik).route("/signup",F1);return n.doc("/u/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Universal login"}}),n}const ck="Account detected",lk="We have detected that you have already created an account through",uk="By signing in, you agree to our",dk="and",pk="Callback URL mismatch",fk="The provided redirect_uri is not in the list of allowed callback URLs.",hk="continue with user",gk="Please click the button to create a new password account.",mk="Enter the code at {{vendorName}} to complete the login",_k="Welcome to {{vendorName}}! {{code}} is the login code",yk="Welcome to {{vendorName}}! {{code}} is the login code",vk="The code is valid for 30 minutes",wk="Confirm password",bk="Need Help?",kk="Contact us",xk="or continue with social account",Sk="Continue with {{provider}}",Ak="Would you like to continue with your existing account?",Ek="Copyright © 2023 SESAMY. All rights reserved.",Ik="©2023 Sesamy",zk="Choose a password with a mix of uppercase and lowercase letters, numbers, and symbols.",Nk="Please enter a valid email address.",Ck="The passwords didn't match. Try again.",jk="Choose password",$k="Password must be at least 8 characters long and contain at least one lowercase letter, one uppercase letter, one number and one symbol.",Ok="Create new account",Bk="Sign up with password",Tk="You are currently logged in as <0>{{email}}</0>",Pk="Email",Rk="Email address",Lk="Your email address has been validated",Uk="Now enter your password to login again",Vk="An email has been sent to <0>{{email}}</0> with a verification link. Please click the link to verify your email address and set a password.",qk="Email verification sent",Mk="Enter a code",Dk="We'll send you a verification link to ensure you own this email address.",Hk="Enter new password",Fk="Enter password",Kk="Enter your email address and password to login.",Wk="Enter your password",Gk="The magic link has expired. Please click on the button below to receive a new link in your inbox.",Jk="Hey! We updated our login experience. <0>Click here to learn more about it.</0>",Zk="Send password reset email",Yk="Click the button below and we’ll send instructions on how to reset your password.",Xk="Password reset email sent",Qk="Forgot password?",ex="Forgot password?",tx="Go back",nx="Invalid password",rx=`The link is no longer valid.
222
+ c2.7,4.1,6.5,6.6,10.9,6.6c4,0,7.2-2,9.6-5.2c0.9-1.2,0.9-2.5,0-3.1C33.3,22.9,32.1,23.2,31.2,24.4z`})]}),Wp=({error:t,vendorSettings:e,loginSession:n,email:r,client:i,impersonation:s})=>{const a=i.connections.map(({name:m})=>m),c=a.includes("facebook"),l=a.includes("google-oauth2"),u=a.includes("apple"),p=a.includes("vipps"),h=c||l||u||p;return y(Ze,{title:P.t("welcome"),vendorSettings:e,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:P.t("welcome")}),y("div",{className:"mb-8 text-gray-300",children:P.t("login_description")}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y(pn,{className:"mb-7",children:[y("input",{type:"email",name:"username",placeholder:P.t("email_placeholder"),className:It("mb-2 w-full rounded-lg border bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",{"border-red":t,"border-gray-100 dark:border-gray-500":!t}),required:!0,value:r||""}),s&&y("input",{type:"email",name:"act_as",placeholder:"Impersonate as",className:It("mb-2 w-full rounded-lg border bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",{"border-red":t,"border-gray-100 dark:border-gray-500":!t}),required:!0,value:""}),t&&y(xr,{children:t}),y(dn,{className:"text-base sm:mt-4 md:text-base",children:y("div",{className:"flex items-center space-x-2",children:[y("span",{children:P.t("continue")}),y(Qe,{className:"text-xs",name:"arrow-right"})]})})]}),h&&y("div",{className:"relative mb-5 block text-center text-gray-300 dark:text-gray-300",children:[y("div",{className:"absolute left-0 right-0 top-1/2 border-b border-gray-200 dark:border-gray-600"}),y("div",{className:"relative inline-block bg-white px-2 dark:bg-gray-800",children:P.t("continue_social_login")})]}),y("div",{className:"flex space-x-4 sm:flex-col sm:space-x-0 sm:space-y-4 short:flex-row short:space-x-4 short:space-y-0",children:[c&&y(Pi,{connection:"facebook",text:P.t("continue_with",{provider:"Facebook"}),canResize:!0,icon:y(Qe,{className:"text-xl text-[#1196F5] sm:absolute sm:left-4 sm:top-1/2 sm:-translate-y-1/2 sm:text-2xl short:static short:left-auto short:top-auto short:translate-y-0 short:text-xl",name:"facebook"}),loginSession:n}),l&&y(Pi,{connection:"google-oauth2",text:P.t("continue_with",{provider:"Google"}),canResize:!0,icon:y(_1,{className:"h-5 w-5 sm:absolute sm:left-4 sm:top-1/2 sm:h-6 sm:w-6 sm:-translate-y-1/2 short:static short:left-auto short:top-auto short:h-5 short:w-5 short:translate-y-0"}),loginSession:n}),u&&y(Pi,{connection:"apple",text:P.t("continue_with",{provider:"Apple"}),canResize:!0,icon:y(Qe,{className:"text-xl text-black dark:text-white sm:absolute sm:left-4 sm:top-1/2 sm:-translate-y-1/2 sm:text-2xl short:static short:left-auto short:top-auto short:translate-y-0 short:text-xl",name:"apple"}),loginSession:n}),p&&y(Pi,{connection:"vipps",text:P.t("continue_with",{provider:"Vipps"}),canResize:!0,icon:y(y1,{className:"h-5 w-5 sm:absolute sm:left-4 sm:top-1/2 sm:h-6 sm:w-6 sm:-translate-y-1/2 short:static short:left-auto short:top-auto short:h-5 short:w-5 short:translate-y-0"}),loginSession:n})]})]})]})},v1=["Auth0.swift"];function w1(t){if(!t)return"code";const e=atob(t),n=JSON.parse(e);return v1.includes(n.name)?"code":"link"}const b1=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"}),impersonation:o.z.string().optional()})},responses:{200:{description:"Response"}}}),async t=>{const{state:e,impersonation:n}=t.req.valid("query"),{vendorSettings:r,loginSession:i,client:s}=await Ie(t,e);return t.html(y(Wp,{vendorSettings:r,loginSession:i,client:s,email:i.authParams.username,impersonation:n==="true"}))}).openapi(o.createRoute({tags:["login"],method:"post",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})}),body:{content:{"application/x-www-form-urlencoded":{schema:o.z.object({username:o.z.string().transform(t=>t.toLowerCase()),act_as:o.z.string().transform(t=>t.toLowerCase()).optional(),login_selection:o.z.enum(["code","password"]).optional()})}}}},responses:{200:{description:"Response"}}}),async t=>{const{env:e}=t,{state:n}=t.req.valid("query"),r=t.req.valid("form");t.set("body",r),t.set("username",r.username);const{client:i,loginSession:s,vendorSettings:a}=await Ie(t,n);t.set("client_id",i.id);const c=r.username,l=await ro({userAdapter:e.data.users,tenant_id:i.tenant.id,email:c});if(l&&t.set("user_id",l.user_id),!l)try{await dy(t,i,t.env.data,r.username)}catch{const v=ve(t,{type:he.FAILED_SIGNUP,description:"Public signup is disabled"});return await t.env.data.logs.create(i.tenant.id,v),t.html(y(Wp,{vendorSettings:a,loginSession:s,error:P.t("user_account_does_not_exist"),email:r.username,client:i}),400)}if(s.authParams.username=r.username,s.authParams.act_as=r.act_as,await e.data.loginSessions.update(i.tenant.id,s.id,s),await o1(t,i,r.username,r.login_selection))return t.redirect(`/u/enter-password?state=${n}`);let u=Tn(),p=await e.data.codes.get(i.tenant.id,u,"otp");for(;p;)u=Tn(),p=await e.data.codes.get(i.tenant.id,u,"otp");const h=await t.env.data.codes.create(i.tenant.id,{code_id:u,code_type:"otp",login_id:s.id,expires_at:new Date(Date.now()+Na).toISOString()});return w1(s.auth0Client)==="link"&&!r.username.includes("online.no")?nt(t,au(t,r.username,h.code_id,s.authParams)):nt(t,Zg(t,r.username,h.code_id)),t.redirect(`/u/enter-code?state=${n}`)}),zt=t=>y("a",{className:"block text-primary hover:text-primaryHover text-center",href:`/u/enter-email?state=${t.state}`,children:P.t("go_back")});var ri="_hp",k1={Change:"Input",DoubleClick:"DblClick"},x1={svg:"2000/svg",math:"1998/Math/MathML"},ii=[],Xc=new WeakMap,lr=void 0,S1=()=>lr,$t=t=>"t"in t,ya={onClick:["click",!1]},Gp=t=>{if(!t.startsWith("on"))return;if(ya[t])return ya[t];const e=t.match(/^on([A-Z][a-zA-Z]+?(?:PointerCapture)?)(Capture)?$/);if(e){const[,n,r]=e;return ya[t]=[(k1[n]||n).toLowerCase(),!!r]}},Jp=(t,e)=>lr&&t instanceof SVGElement&&/[A-Z]/.test(e)&&(e in t.style||e.match(/^(?:o|pai|str|u|ve)/))?e.replace(/([A-Z])/g,"-$1").toLowerCase():e,A1=(t,e,n)=>{var r;e||(e={});for(let i in e){const s=e[i];if(i!=="children"&&(!n||n[i]!==s)){i=Ws(i);const a=Gp(i);if(a){if((n==null?void 0:n[i])!==s&&(n&&t.removeEventListener(a[0],n[i],a[1]),s!=null)){if(typeof s!="function")throw new Error(`Event handler for "${i}" is not a function`);t.addEventListener(a[0],s,a[1])}}else if(i==="dangerouslySetInnerHTML"&&s)t.innerHTML=s.__html;else if(i==="ref"){let c;typeof s=="function"?c=s(t)||(()=>s(null)):s&&"current"in s&&(s.current=t,c=()=>s.current=null),Xc.set(t,c)}else if(i==="style"){const c=t.style;typeof s=="string"?c.cssText=s:(c.cssText="",s!=null&&im(s,c.setProperty.bind(c)))}else{if(i==="value"){const l=t.nodeName;if(l==="INPUT"||l==="TEXTAREA"||l==="SELECT"){if(t.value=s==null||s===!1?null:s,l==="TEXTAREA"){t.textContent=s;continue}else if(l==="SELECT"){t.selectedIndex===-1&&(t.selectedIndex=0);continue}}}else(i==="checked"&&t.nodeName==="INPUT"||i==="selected"&&t.nodeName==="OPTION")&&(t[i]=s);const c=Jp(t,i);s==null||s===!1?t.removeAttribute(c):s===!0?t.setAttribute(c,""):typeof s=="string"||typeof s=="number"?t.setAttribute(c,s):t.setAttribute(c,s.toString())}}}if(n)for(let i in n){const s=n[i];if(i!=="children"&&!(i in e)){i=Ws(i);const a=Gp(i);a?t.removeEventListener(a[0],s,a[1]):i==="ref"?(r=Xc.get(t))==null||r():t.removeAttribute(Jp(t,i))}}},E1=(t,e)=>{e[Ae][0]=0,ii.push([t,e]);const n=e.tag[du]||e.tag,r=n.defaultProps?{...n.defaultProps,...e.props}:e.props;try{return[n.call(null,r)]}finally{ii.pop()}},am=(t,e,n,r,i)=>{var s,a;(s=t.vR)!=null&&s.length&&(r.push(...t.vR),delete t.vR),typeof t.tag=="function"&&((a=t[Ae][1][dm])==null||a.forEach(c=>i.push(c))),t.vC.forEach(c=>{var l;if($t(c))n.push(c);else if(typeof c.tag=="function"||c.tag===""){c.c=e;const u=n.length;if(am(c,e,n,r,i),c.s){for(let p=u;p<n.length;p++)n[p].s=!0;c.s=!1}}else n.push(c),(l=c.vR)!=null&&l.length&&(r.push(...c.vR),delete c.vR)})},I1=t=>{for(;;t=t.tag===ri||!t.vC||!t.pP?t.nN:t.vC[0]){if(!t)return null;if(t.tag!==ri&&t.e)return t.e}},cm=t=>{var e,n,r,i,s,a;$t(t)||((n=(e=t[Ae])==null?void 0:e[1][dm])==null||n.forEach(c=>{var l;return(l=c[2])==null?void 0:l.call(c)}),(r=Xc.get(t.e))==null||r(),t.p===2&&((i=t.vC)==null||i.forEach(c=>c.p=2)),(s=t.vC)==null||s.forEach(cm)),t.p||((a=t.e)==null||a.remove(),delete t.e),typeof t.tag=="function"&&($r.delete(t),Ji.delete(t),delete t[Ae][3],t.a=!0)},lm=(t,e,n)=>{t.c=e,um(t,e,n)},Zp=(t,e)=>{if(e){for(let n=0,r=t.length;n<r;n++)if(t[n]===e)return n}},Yp=Symbol(),um=(t,e,n)=>{var u;const r=[],i=[],s=[];am(t,e,r,i,s),i.forEach(cm);const a=n?void 0:e.childNodes;let c,l=null;if(n)c=-1;else if(!a.length)c=0;else{const p=Zp(a,I1(t.nN));p!==void 0?(l=a[p],c=p):c=Zp(a,(u=r.find(h=>h.tag!==ri&&h.e))==null?void 0:u.e)??-1,c===-1&&(n=!0)}for(let p=0,h=r.length;p<h;p++,c++){const m=r[p];let v;if(m.s&&m.e)v=m.e,m.s=!1;else{const f=n||!m.e;$t(m)?(m.e&&m.d&&(m.e.textContent=m.t),m.d=!1,v=m.e||(m.e=document.createTextNode(m.t))):(v=m.e||(m.e=m.n?document.createElementNS(m.n,m.tag):document.createElement(m.tag)),A1(v,m.props,m.pP),um(m,v,f))}m.tag===ri?c--:n?v.parentNode||e.appendChild(v):a[c]!==v&&a[c-1]!==v&&(a[c+1]===v?e.appendChild(a[c]):e.insertBefore(v,l||a[c]||null))}if(t.pP&&delete t.pP,s.length){const p=[],h=[];s.forEach(([,m,,v,f])=>{m&&p.push(m),v&&h.push(v),f==null||f()}),p.forEach(m=>m()),h.length&&requestAnimationFrame(()=>{h.forEach(m=>m())})}},Ji=new WeakMap,Qc=(t,e,n)=>{var s,a,c,l,u,p;const r=!n&&e.pC;n&&(e.pC||(e.pC=e.vC));let i;try{n||(n=typeof e.tag=="function"?E1(t,e):Ai(e.props.children)),((s=n[0])==null?void 0:s.tag)===""&&n[0][Zc]&&(i=n[0][Zc],t[5].push([t,i,e]));const h=r?[...e.pC]:e.vC?[...e.vC]:void 0,m=[];let v;for(let f=0;f<n.length;f++){Array.isArray(n[f])&&n.splice(f,1,...n[f].flat());let _=z1(n[f]);if(_){typeof _.tag=="function"&&!_.tag[Qg]&&(ar.length>0&&(_[Ae][2]=ar.map(S=>[S,S.values.at(-1)])),(a=t[5])!=null&&a.length&&(_[Ae][3]=t[5].at(-1)));let w;if(h&&h.length){const S=h.findIndex($t(_)?C=>$t(C):_.key!==void 0?C=>C.key===_.key&&C.tag===_.tag:C=>C.tag===_.tag);S!==-1&&(w=h[S],h.splice(S,1))}if(w)if($t(_))w.t!==_.t&&(w.t=_.t,w.d=!0),_=w;else{const S=w.pP=w.props;w.props=_.props,w.f||(w.f=_.f||e.f),typeof _.tag=="function"&&(w[Ae][2]=_[Ae][2]||[],w[Ae][3]=_[Ae][3],!w.f&&((w.o||w)===_.o||(l=(c=w.tag)[Hb])!=null&&l.call(c,S,w.props))&&(w.s=!0)),_=w}else if(!$t(_)&&lr){const S=kr(lr);S&&(_.n=S)}if(!$t(_)&&!_.s&&(Qc(t,_),delete _.f),m.push(_),v&&!v.s&&!_.s)for(let S=v;S&&!$t(S);S=(u=S.vC)==null?void 0:u.at(-1))S.nN=_;v=_}}e.vR=r?[...e.vC,...h||[]]:h||[],e.vC=m,r&&delete e.pC}catch(h){if(e.f=!0,h===Yp){if(i)return;throw h}const[m,v,f]=((p=e[Ae])==null?void 0:p[3])||[];if(v){const _=()=>Zi([0,!1,t[2]],f),w=Ji.get(f)||[];w.push(_),Ji.set(f,w);const S=v(h,()=>{const C=Ji.get(f);if(C){const B=C.indexOf(_);if(B!==-1)return C.splice(B,1),_()}});if(S){if(t[0]===1)t[1]=!0;else if(Qc(t,f,[S]),(v.length===1||t!==m)&&f.c){lm(f,f.c,!1);return}throw Yp}}throw h}finally{i&&t[5].pop()}},z1=t=>{if(!(t==null||typeof t=="boolean")){if(typeof t=="string"||typeof t=="number")return{t:t.toString(),d:!0};if("vR"in t&&(t={tag:t.tag,props:t.props,key:t.key,f:t.f,type:t.tag,ref:t.props.ref,o:t.o||t}),typeof t.tag=="function")t[Ae]=[0,[]];else{const e=x1[t.tag];e&&(lr||(lr=tm("")),t.props.children=[{tag:lr,props:{value:t.n=`http://www.w3.org/${e}`,children:t.props.children}}])}return t}},Xp=(t,e)=>{var n,r;(n=e[Ae][2])==null||n.forEach(([i,s])=>{i.values.push(s)});try{Qc(t,e,void 0)}catch{return}if(e.a){delete e.a;return}(r=e[Ae][2])==null||r.forEach(([i])=>{i.values.pop()}),(t[0]!==1||!t[1])&&lm(e,e.c,!1)},$r=new WeakMap,Qp=[],Zi=async(t,e)=>{t[5]||(t[5]=[]);const n=$r.get(e);n&&n[0](void 0);let r;const i=new Promise(s=>r=s);if($r.set(e,[r,()=>{t[2]?t[2](t,e,s=>{Xp(s,e)}).then(()=>r(e)):(Xp(t,e),r(e))}]),Qp.length)Qp.at(-1).add(e);else{await Promise.resolve();const s=$r.get(e);s&&($r.delete(e),s[1]())}return i},N1=(t,e,n)=>({tag:ri,props:{children:t},key:n,e,p:1}),va=0,dm=1,wa=2,ba=3,ka=new WeakMap,pm=(t,e)=>!t||!e||t.length!==e.length||e.some((n,r)=>n!==t[r]),C1=void 0,ef=[],j1=t=>{var a;const e=()=>typeof t=="function"?t():t,n=ii.at(-1);if(!n)return[e(),()=>{}];const[,r]=n,i=(a=r[Ae][1])[va]||(a[va]=[]),s=r[Ae][0]++;return i[s]||(i[s]=[e(),c=>{const l=C1,u=i[s];if(typeof c=="function"&&(c=c(u[0])),!Object.is(c,u[0]))if(u[0]=c,ef.length){const[p,h]=ef.at(-1);Promise.all([p===3?r:Zi([p,!1,l],r),h]).then(([m])=>{if(!m||!(p===2||p===3))return;const v=m.vC;requestAnimationFrame(()=>{setTimeout(()=>{v===m.vC&&Zi([p===3?1:0,!1,l],m)})})})}else Zi([0,!1,l],r)}])},mu=(t,e)=>{var c;const n=ii.at(-1);if(!n)return t;const[,r]=n,i=(c=r[Ae][1])[wa]||(c[wa]=[]),s=r[Ae][0]++,a=i[s];return pm(a==null?void 0:a[1],e)?i[s]=[t,e]:t=i[s][0],t},$1=t=>{const e=ka.get(t);if(e){if(e.length===2)throw e[1];return e[0]}throw t.then(n=>ka.set(t,[n]),n=>ka.set(t,[void 0,n])),t},O1=(t,e)=>{var c;const n=ii.at(-1);if(!n)return t();const[,r]=n,i=(c=r[Ae][1])[ba]||(c[ba]=[]),s=r[Ae][0]++,a=i[s];return pm(a==null?void 0:a[1],e)&&(i[s]=[t(),e]),i[s][0]},B1=tm({pending:!1,data:null,method:null,action:null}),tf=new Set,T1=t=>{tf.add(t),t.finally(()=>tf.delete(t))},_u=(t,e)=>O1(()=>n=>{let r;t&&(typeof t=="function"?r=t(n)||(()=>{t(null)}):t&&"current"in t&&(t.current=n,r=()=>{t.current=null}));const i=e(n);return()=>{i==null||i(),r==null||r()}},[t]),Mn=Object.create(null),Ri=Object.create(null),zi=(t,e,n,r,i)=>{if(e!=null&&e.itemProp)return{tag:t,props:e,type:t,ref:e.ref};const s=document.head;let{onLoad:a,onError:c,precedence:l,blocking:u,...p}=e,h=null,m=!1;const v=Ki[t];let f;if(v.length>0){const C=s.querySelectorAll(t);e:for(const B of C)for(const L of Ki[t])if(B.getAttribute(L)===e[L]){h=B;break e}if(!h){const B=v.reduce((L,Q)=>e[Q]===void 0?L:`${L}-${Q}-${e[Q]}`,t);m=!Ri[B],h=Ri[B]||(Ri[B]=(()=>{const L=document.createElement(t);for(const Q of v)e[Q]!==void 0&&L.setAttribute(Q,e[Q]),e.rel&&L.setAttribute("rel",e.rel);return L})())}}else f=s.querySelectorAll(t);l=r?l??"":void 0,r&&(p[Wi]=l);const _=mu(C=>{if(v.length>0){let B=!1;for(const L of s.querySelectorAll(t)){if(B&&L.getAttribute(Wi)!==l){s.insertBefore(C,L);return}L.getAttribute(Wi)===l&&(B=!0)}s.appendChild(C)}else if(f){let B=!1;for(const L of f)if(L===C){B=!0;break}B||s.insertBefore(C,s.contains(f[0])?f[0]:s.querySelector(t)),f=void 0}},[l]),w=_u(e.ref,C=>{var Q;const B=v[0];if(n===2&&(C.innerHTML=""),(m||f)&&_(C),!c&&!a)return;let L=Mn[Q=C.getAttribute(B)]||(Mn[Q]=new Promise((ce,le)=>{C.addEventListener("load",ce),C.addEventListener("error",le)}));a&&(L=L.then(a)),c&&(L=L.catch(c)),L.catch(()=>{})});if(i&&u==="render"){const C=Ki[t][0];if(e[C]){const B=e[C],L=Mn[B]||(Mn[B]=new Promise((Q,ce)=>{_(h),h.addEventListener("load",Q),h.addEventListener("error",ce)}));$1(L)}}const S={tag:t,type:t,props:{...p,ref:w},ref:w};return S.p=n,h&&(S.e=h),N1(S,s)},P1=t=>{const e=S1(),n=e&&kr(e);return n!=null&&n.endsWith("svg")?{tag:"title",props:t,type:"title",ref:t.ref}:zi("title",t,void 0,!1,!1)},R1=t=>!t||["src","async"].some(e=>!t[e])?{tag:"script",props:t,type:"script",ref:t.ref}:zi("script",t,1,!1,!0),L1=t=>!t||!["href","precedence"].every(e=>e in t)?{tag:"style",props:t,type:"style",ref:t.ref}:(t["data-href"]=t.href,delete t.href,zi("style",t,2,!0,!0)),U1=t=>!t||["onLoad","onError"].some(e=>e in t)||t.rel==="stylesheet"&&(!("precedence"in t)||"disabled"in t)?{tag:"link",props:t,type:"link",ref:t.ref}:zi("link",t,1,"precedence"in t,!0),V1=t=>zi("meta",t,void 0,!1,!1),fm=Symbol(),q1=t=>{const{action:e,...n}=t;typeof e!="function"&&(n.action=e);const[r,i]=j1([null,!1]),s=mu(async u=>{const p=u.isTrusted?e:u.detail[fm];if(typeof p!="function")return;u.preventDefault();const h=new FormData(u.target);i([h,!0]);const m=p(h);m instanceof Promise&&(T1(m),await m),i([null,!0])},[]),a=_u(t.ref,u=>(u.addEventListener("submit",s),()=>{u.removeEventListener("submit",s)})),[c,l]=r;return r[1]=!1,{tag:B1,props:{value:{pending:c!==null,data:c,method:c?"post":null,action:c?e:null},children:{tag:"form",props:{...n,ref:a},type:"form",ref:a}},f:l}},hm=(t,{formAction:e,...n})=>{if(typeof e=="function"){const r=mu(i=>{i.preventDefault(),i.currentTarget.form.dispatchEvent(new CustomEvent("submit",{detail:{[fm]:e}}))},[]);n.ref=_u(n.ref,i=>(i.addEventListener("click",r),()=>{i.removeEventListener("click",r)}))}return{tag:t,props:n,type:t,ref:n.ref}},M1=t=>hm("input",t),D1=t=>hm("button",t);Object.assign(Yc,{title:P1,script:R1,style:L1,link:U1,meta:V1,form:q1,input:M1,button:D1});new TextEncoder;const yu=t=>{const{i18nKey:e,values:n,components:r}=t,i=P.t(e,n),s=/<(\d+)>(.*?)<\/\d+>/g,a=[];let c=0,l;for(;(l=s.exec(i))!==null;){const[,u,p]=l,h=i.substring(c,l.index);h&&a.push(h);const m=parseInt(u,10);a.push(s1(r[m],{},p)),c=s.lastIndex}return c<i.length&&a.push(i.substring(c)),y(hu,{children:a})},nf=6,rf=({error:t,vendorSettings:e,email:n,state:r,client:i,hasPasswordLogin:s})=>{const a=new URLSearchParams({state:r}),l=i.connections.map(({name:u})=>u).includes("auth2");return y(Ze,{title:P.t("verify_your_email"),vendorSettings:e,children:[y("div",{className:"mb-4 text-2xl font-medium",children:P.t("verify_your_email")}),y("div",{className:"mb-8 text-gray-300",children:y(yu,{i18nKey:"we_sent_a_code_to",components:[y("span",{className:"text-black dark:text-white"},"span")],values:{email:n}})}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y(pn,{className:"pt-2",children:[y("input",{autoFocus:!0,type:"text",pattern:"[0-9]*",maxLength:nf,inputMode:"numeric",name:"code",placeholder:"******",className:It("mb-2 w-full rounded-lg border bg-gray-100 px-4 pb-2 pt-2.5 text-center indent-[5px] font-mono text-3xl placeholder:text-gray-300 dark:bg-gray-600 md:text-3xl",{"border-red":t,"border-gray-100 dark:border-gray-500":!t}),minLength:nf,required:!0,id:"code-input"}),t&&y(xr,{children:t}),y("div",{className:"text-center sm:mt-2",children:y(dn,{className:"text-base sm:mt-4 md:text-base",children:y("div",{className:"flex items-center space-x-2",children:[y("span",{children:P.t("login")}),y(Qe,{className:"text-xs",name:"arrow-right"})]})})}),y("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[y(Qe,{className:"text-base",name:"info-bubble"}),y("div",{className:"text-sm text-gray-300 md:text-sm",children:P.t("sent_code_spam")})]}),l&&y("div",{className:"text-center mb-12",children:[y("div",{className:"relative mb-5 block text-center text-gray-300 dark:text-gray-300",children:[y("div",{className:"absolute left-0 right-0 top-1/2 border-b border-gray-200 dark:border-gray-600"}),y("div",{className:"relative inline-block bg-white px-2 dark:bg-gray-800",children:P.t("or")})]}),y(cr,{Component:"a",href:`/u/${s?"enter-password":"pre-signup"}?${a.toString()}`,variant:"secondary",className:"block",children:P.t("enter_your_password_btn")})]})]}),y(zt,{state:r})]})]})},H1=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,loginSession:r,client:i}=await Ie(t,e);if(!r.authParams.username)throw new z(400,{message:"Username not found in state"});const s=await ls({userAdapter:t.env.data.users,tenant_id:i.tenant.id,email:r.authParams.username,provider:"auth2"});return t.html(y(rf,{vendorSettings:n,email:r.authParams.username,state:e,client:i,hasPasswordLogin:!!s}))}).openapi(o.createRoute({tags:["login"],method:"post",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state"})}),body:{content:{"application/x-www-form-urlencoded":{schema:o.z.object({code:o.z.string()})}}}},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{code:n}=t.req.valid("form"),{loginSession:r,client:i,vendorSettings:s}=await Ie(t,e);if(t.set("client_id",i.id),!r.authParams.username)throw new z(400,{message:"Username not found in state"});try{return await lu(t,i,r.authParams,r.authParams.username,n)}catch(a){const c=a,l=await ls({userAdapter:t.env.data.users,tenant_id:i.tenant.id,email:r.authParams.username,provider:"auth2"});return t.html(y(rf,{vendorSettings:s,email:r.authParams.username,state:e,client:i,error:c.message,hasPasswordLogin:!!l}),400)}}),F1=t=>{const{vendorSettings:e,state:n}=t;return y(Ze,{title:P.t("unverified_email"),vendorSettings:e,children:[y("div",{className:"flex flex-1 flex-col justify-center",children:[y("p",{className:"mb-8 text-gray-300 text-lg",children:P.t("unverified_email")}),y("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[y(Qe,{className:"text-base",name:"info-bubble"}),y("div",{className:"text-sm text-gray-300 md:text-sm",children:P.t("sent_code_spam")})]}),y(zt,{state:n})]}),y(zt,{state:n})]})},xa=t=>{const{error:e,vendorSettings:n,email:r,state:i}=t,s=new URLSearchParams({state:i});return y(Ze,{title:P.t("enter_password"),vendorSettings:n,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:P.t("enter_password")}),y("div",{className:"mb-6 text-gray-300",children:P.t("enter_password_description")}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y(pn,{className:"mb-7",children:[y("input",{type:"text",name:"username",placeholder:P.t("email_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",value:r}),y("input",{type:"password",name:"password",placeholder:P.t("password")||"",className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",required:!0}),e&&y(xr,{children:e}),y(dn,{className:"text-base sm:mt-4 md:text-base",children:y("div",{className:"flex items-center space-x-2",children:[y("span",{children:P.t("login")}),y(Qe,{className:"text-xs",name:"arrow-right"})]})})]}),y("a",{href:`/u/forgot-password?${s.toString()}`,className:"text-primary hover:underline mb-4",children:P.t("forgot_password_link")}),y("div",{className:"text-center mb-12",children:[y("div",{className:"relative mb-5 block text-center text-gray-300 dark:text-gray-300",children:[y("div",{className:"absolute left-0 right-0 top-1/2 border-b border-gray-200 dark:border-gray-600"}),y("div",{className:"relative inline-block bg-white px-2 dark:bg-gray-800",children:P.t("or")})]}),y("form",{method:"post",action:`/u/enter-email?${s.toString()}`,children:[y("input",{type:"hidden",name:"login_selection",value:"code"}),y("input",{type:"hidden",name:"username",value:r}),y(cr,{variant:"secondary",className:"block",children:P.t("enter_a_code_btn")})]})]}),y(zt,{state:i})]})]})},K1=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,client:r,loginSession:i}=await Ie(t,e);if(!i.authParams.username)throw new z(400,{message:"Username required"});return t.html(y(xa,{vendorSettings:n,email:i.authParams.username,state:e,client:r}))}).openapi(o.createRoute({tags:["login"],method:"post",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})}),body:{content:{"application/x-www-form-urlencoded":{schema:o.z.object({password:o.z.string()})}}}},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),n=t.req.valid("form"),{password:r}=n,{vendorSettings:i,client:s,loginSession:a}=await Ie(t,e),{username:c}=a.authParams;if(!c)throw new z(400,{message:"Username required"});try{return await uu(t,s,{...a.authParams,password:r},a)}catch(l){const u=l;return u.code==="INVALID_PASSWORD"||u.code==="USER_NOT_FOUND"?t.html(y(xa,{vendorSettings:i,email:c,error:P.t("invalid_password"),state:e,client:s}),400):u.code==="EMAIL_NOT_VERIFIED"?t.html(y(F1,{vendorSettings:i,state:e}),400):t.html(y(xa,{vendorSettings:i,email:c,error:u.message,state:e,client:s}),400)}}),Cr=t=>{const{state:e,error:n,vendorSettings:r,email:i,code:s}=t;return y(Ze,{title:P.t("create_account_title"),vendorSettings:r,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:P.t("create_account_title")}),y("div",{className:"mb-6 text-gray-300",children:P.t("create_account_description")}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y(pn,{children:[y("input",{type:"hidden",name:"code",value:s}),y("input",{type:"email",name:"username",placeholder:P.t("email_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",required:!0,value:i,disabled:!!i}),y("input",{type:"password",name:"password",placeholder:P.t("enter_new_password_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base"}),y("input",{type:"password",name:"re-enter-password",placeholder:P.t("reenter_new_password_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base"}),n&&y(xr,{children:n}),y(dn,{className:"text-base sm:mt-2 md:text-base",children:P.t("continue")})]}),y(zt,{state:e})]})]})},vu=t=>{const{message:e,vendorSettings:n,pageTitle:r,state:i}=t;return y(Ze,{title:"Login",vendorSettings:n,children:[r?y("div",{className:"mb-6 text-gray-300",children:r}):"",y("div",{className:"flex flex-1 flex-col justify-center",children:e}),i?y(zt,{state:i}):""]})},W1=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"}),code:o.z.string().optional().openapi({description:"The code parameter from an email verification link"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e,code:n}=t.req.valid("query"),{vendorSettings:r,loginSession:i}=await Ie(t,e),{username:s}=i.authParams;if(!s)throw new z(400,{message:"Username required"});return n?t.html(y(Cr,{state:e,vendorSettings:r,email:s,code:n})):t.html(y(Cr,{state:e,vendorSettings:r,email:s}))}).openapi(o.createRoute({tags:["login"],method:"post",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})}),body:{content:{"application/x-www-form-urlencoded":{schema:o.z.object({password:o.z.string(),"re-enter-password":o.z.string(),code:o.z.string().optional()})}}}},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),n=t.req.valid("form"),{env:r}=t,{vendorSettings:i,client:s,loginSession:a}=await Ie(t,e),c="Username-Password-Authentication";t.set("client_id",s.id),t.set("connection",c);const l=a.authParams.username;if(!l)throw new z(400,{message:"Username required"});if(n.password!==n["re-enter-password"])return t.html(y(Cr,{state:e,code:n.code,vendorSettings:i,error:P.t("create_account_passwords_didnt_match"),email:a.authParams.username}),400);if(!ou(n.password))return t.html(y(Cr,{state:e,code:n.code,vendorSettings:i,error:P.t("create_account_weak_password"),email:a.authParams.username}),400);const u=n.code?await r.data.codes.get(s.tenant.id,n.code,"email_verification"):void 0,p=u?await r.data.loginSessions.get(s.tenant.id,u.login_id):void 0;try{if(await ur({userAdapter:t.env.data.users,tenant_id:s.tenant.id,email:l,provider:"auth2"}))throw new z(400,{message:"Invalid sign up"});const m=(p==null?void 0:p.authParams.username)===l,v=await Ff(t).users.create(s.tenant.id,{user_id:`auth2|${Xs()}`,email:l,email_verified:m,provider:"auth2",connection:c,is_social:!1});return await r.data.passwords.create(s.tenant.id,{user_id:v.user_id,password:await si.hash(n.password,10),algorithm:"bcrypt"}),m?await uu(t,s,{...a.authParams,password:n.password},a):(await cu(t,v),t.html(y(vu,{message:P.t("validate_email_body"),pageTitle:P.t("validate_email_title"),vendorSettings:i,state:e})))}catch(h){const m=await gu(r,s.id,a.authParams.vendor_id),v=h;return t.html(y(Cr,{state:e,vendorSettings:m,error:v.message,email:l}),400)}}),jr=t=>{const{error:e,vendorSettings:n,email:r}=t;return y(Ze,{title:P.t("reset_password_title"),vendorSettings:n,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:P.t("reset_password_title")}),y("div",{className:"mb-6 text-gray-300",children:`${P.t("reset_password_description")} ${r}`}),y("div",{className:"flex flex-1 flex-col justify-center",children:y(pn,{children:[y("input",{type:"password",name:"password",placeholder:P.t("enter_new_password_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base"}),y("input",{type:"password",name:"re-enter-password",placeholder:P.t("reenter_new_password_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base"}),e&&y(xr,{children:e}),y(dn,{className:"text-base sm:mt-2 md:text-base",children:P.t("reset_password_cta")})]})})]})},G1=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"}),code:o.z.string().openapi({description:"The code parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,loginSession:r}=await Ie(t,e);if(!r.authParams.username)throw new z(400,{message:"Username required"});return t.html(y(jr,{vendorSettings:n,email:r.authParams.username}))}).openapi(o.createRoute({tags:["login"],method:"post",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"}),code:o.z.string().openapi({description:"The code parameter from the authorization request"})}),body:{content:{"application/x-www-form-urlencoded":{schema:o.z.object({password:o.z.string(),"re-enter-password":o.z.string()})}}}},responses:{200:{description:"Response"}}}),async t=>{const{state:e,code:n}=t.req.valid("query"),{password:r,"re-enter-password":i}=t.req.valid("form"),{env:s}=t,{vendorSettings:a,client:c,loginSession:l}=await Ie(t,e);if(!l.authParams.username)throw new z(400,{message:"Username required"});if(r!==i)return t.html(y(jr,{error:P.t("create_account_passwords_didnt_match"),vendorSettings:a,email:l.authParams.username}),400);if(!ou(r))return t.html(y(jr,{error:P.t("create_account_weak_password"),vendorSettings:a,email:l.authParams.username}),400);const u=await ur({userAdapter:s.data.users,tenant_id:c.tenant.id,email:l.authParams.username,provider:"auth2"});if(!u)throw new z(400,{message:"User not found"});try{if(!await s.data.codes.get(c.tenant.id,n,"password_reset"))return t.html(y(jr,{error:"Code not found or expired",vendorSettings:a,email:l.authParams.username}),400);const h={user_id:u.user_id,password:await si.hash(r,10),algorithm:"bcrypt"};await s.data.passwords.get(c.tenant.id,u.user_id)?await s.data.passwords.update(c.tenant.id,h):await s.data.passwords.create(c.tenant.id,h),u.email_verified||await s.data.users.update(c.tenant.id,u.user_id,{email_verified:!0})}catch{return t.html(y(jr,{error:"The password could not be reset",vendorSettings:a,email:l.authParams.username}),400)}return t.html(y(vu,{message:P.t("password_has_been_reset"),vendorSettings:a,state:e}))}),J1=t=>{const{error:e,vendorSettings:n,email:r,state:i}=t;return y(Ze,{title:P.t("forgot_password_title"),vendorSettings:n,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:P.t("forgot_password_title")}),y("div",{className:"mb-6 text-gray-300",children:P.t("forgot_password_description")}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y(pn,{className:"pt-2",children:[y("input",{type:"email",name:"username",placeholder:P.t("email_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",value:r,disabled:!!r}),e&&y(xr,{children:e}),y(dn,{className:"sm:mt-4",children:P.t("forgot_password_cta")})]}),y(zt,{state:i})]})]})},Z1=t=>{const{vendorSettings:e,state:n}=t;return y(Ze,{title:"Login",vendorSettings:e,children:[y("div",{className:"flex flex-1 flex-col justify-center",children:[y("div",{children:P.t("forgot_password_email_sent")}),y("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[y(Qe,{className:"text-base",name:"info-bubble"}),y("div",{className:"text-sm text-gray-300 md:text-sm",children:P.t("sent_code_spam")})]})]}),y(zt,{state:n})]})},Y1=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,loginSession:r}=await Ie(t,e);return t.html(y(J1,{vendorSettings:n,state:e,email:r.authParams.username}))}).openapi(o.createRoute({tags:["login"],method:"post",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,client:r,loginSession:i}=await Ie(t,e);return await $b(t,r,i.authParams.username,i.id),t.html(y(Z1,{vendorSettings:n,state:e}))}),X1=({vendorSettings:t,state:e,user:n})=>y(Ze,{title:se("check_email_title"),vendorSettings:t,children:y("div",{className:"flex flex-1 flex-col justify-center",children:[y("div",{className:"mb-8 text-gray-700 dark:text-gray-300",children:[y(yu,{i18nKey:"currently_logged_in_as",components:[y("span",{className:"font-semibold text-gray-900 dark:text-white"},"span")],values:{email:n.email}}),y("br",{}),se("continue_with_sso_provider_headline")]}),y("div",{className:"space-y-6",children:[y(pn,{children:y(dn,{className:"w-full text-base sm:mt-4 md:text-base",children:y("div",{className:"flex items-center justify-center space-x-2",children:y("span",{children:P.t("yes_continue_with_existing_account")})})})}),y("a",{className:"block text-center text-primary hover:text-primaryHover focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 dark:focus:ring-offset-gray-900",href:`/u/enter-email?state=${encodeURIComponent(e)}`,children:P.t("no_use_another")})]})]})}),Q1=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{env:e}=t,{state:n}=t.req.valid("query"),{vendorSettings:r,client:i}=await Ie(t,n),s=cs(i.tenant.id,t.req.header("cookie")),a=s?await e.data.sessions.get(i.tenant.id,s):null;if(!a)return t.redirect(`/u/enter-email?state=${n}`);const c=await e.data.users.get(i.tenant.id,a.user_id);return c?t.html(y(X1,{vendorSettings:r,state:n,user:c})):t.redirect(`/u/enter-email?state=${n}`)}).openapi(o.createRoute({tags:["login"],method:"post",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{302:{description:"Redirect"}}}),async t=>{const{env:e}=t,{state:n}=t.req.valid("query"),{loginSession:r,client:i}=await Ie(t,n),s=cs(i.tenant.id,t.req.header("cookie")),a=s?await e.data.sessions.get(i.tenant.id,s):null;if(!a)return t.redirect(`/u/enter-email?state=${n}`);const c=await e.data.users.get(i.tenant.id,a.user_id);return c?an(t,{user:c,authParams:r.authParams,client:i,loginSession:r}):t.redirect(`/u/enter-email?state=${n}`)}),ek=t=>{const{vendorSettings:e,email:n,state:r}=t;return y(Ze,{title:P.t("create_password_account_title"),vendorSettings:e,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:P.t("create_password_account_title")}),y("div",{className:"mb-6 text-gray-300",children:P.t("enter_email_for_verification_description")}),y("div",{className:"flex flex-1 flex-col justify-center",children:y(pn,{className:"pt-2",children:[y("input",{type:"email",name:"username",placeholder:P.t("email_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",required:!0,value:n,disabled:!0}),y(dn,{className:"text-base sm:mt-4 md:text-base",children:y("div",{className:"flex items-center space-x-2",children:y("span",{children:P.t("send")})})})]})}),y(zt,{state:r})]})},tk=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,loginSession:r}=await Ie(t,e),{username:i}=r.authParams;if(!i)throw new z(400,{message:"Username required"});return t.html(y(ek,{state:e,vendorSettings:n,email:i}))}).openapi(o.createRoute({tags:["login"],method:"post",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{loginSession:n,client:r}=await Ie(t,e),{username:i}=n.authParams;if(!i)throw new z(400,{message:"Username required"});const s=await t.env.data.codes.create(r.tenant.id,{code_id:Tn(),code_type:"email_verification",login_id:n.id,expires_at:new Date(Date.now()+I_).toISOString()});return await Nb(t,i,s.code_id,n.id),t.redirect(`/u/pre-signup-sent?state=${e}`)}),nk=t=>{const{redirectUrl:e,vendorSettings:n}=t;return y(Ze,{title:P.t("invalid_session_title"),vendorSettings:n,children:[y("div",{className:"flex flex-1 flex-col justify-center",children:P.t("invalid_session_body")}),y("div",{className:"flex flex-1 flex-col justify-center",children:e&&y("a",{className:"block text-primary hover:text-primaryHover text-center",href:e,children:P.t("go_back")})})]})},rk=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string()})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,loginSession:r}=await Ie(t,e);let i;return r.authParams.redirect_uri&&r.authParams.state&&(i=new URL(r.authParams.redirect_uri),i.searchParams.set("state",r.authParams.state),i.searchParams.set("error","invalid_session"),i.searchParams.set("error_description",r.authParams.username||"")),t.html(y(nk,{redirectUrl:i==null?void 0:i.href,vendorSettings:n}))}),ik=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"}),code:o.z.string().openapi({description:"The code parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const e=await gu(t.env),{state:n}=t.req.valid("query");return t.html(y(vu,{message:"Not implemented",pageTitle:"User info",vendorSettings:e,state:n}))}),sk=({vendorSettings:t,state:e})=>{const n=new URLSearchParams({state:e});return y(Ze,{title:P.t("email_validated"),vendorSettings:t,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:P.t("email_validated")}),y("div",{className:"flex flex-1 flex-col justify-center mb-7",children:y(cr,{Component:"a",href:`/u/enter-password?${n}`,className:"text-base sm:mt-4 md:text-base",children:y("div",{className:"flex items-center space-x-2",children:[y("span",{children:P.t("email_validated_cta")}),y(Qe,{className:"text-xs",name:"arrow-right"})]})})})]})},ok=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"}),code:o.z.string().openapi({description:"The code parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{var m;const{state:e,code:n}=t.req.valid("query"),{env:r}=t,{client:i,loginSession:s,vendorSettings:a}=await Ie(t,e),c=s.authParams.username;if(!c)throw new z(400,{message:"Username not found in state"});const l=await ur({userAdapter:r.data.users,tenant_id:i.tenant.id,email:c,provider:"auth2"});if(!l)throw new z(500,{message:"No user found"});if(!await r.data.codes.get(i.tenant.id,n,"email_verification"))throw new z(400,{message:"Code not found or expired"});await r.data.users.update(i.tenant.id,l.user_id,{email_verified:!0});const h=(await pl(r.data.users,i.tenant.id,c)).filter(v=>v.provider!=="auth2");if(h.length>0){const v=h.filter(f=>!f.linked_to);v.length>1&&console.error("More than one primary user found for email",c),v.length===0&&console.error("No primary user found for email",c),v.length===1&&await r.data.users.update(i.tenant.id,l.user_id,{linked_to:(m=v[0])==null?void 0:m.user_id})}return t.html(y(sk,{vendorSettings:a,state:e}))}),ak=t=>{const{vendorSettings:e,email:n,state:r}=t;return y(Ze,{title:P.t("email_verification_for_signup_sent_title"),vendorSettings:e,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:P.t("email_verification_for_signup_sent_title")}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y("div",{className:"mb-6 text-gray-300",children:y(yu,{i18nKey:"email_verification_for_signup_sent_description",components:[y("span",{className:"text-black dark:text-white"},"span")],values:{email:n}})}),y("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[y(Qe,{className:"text-base",name:"info-bubble"}),y("div",{className:"text-sm text-gray-300 md:text-sm",children:P.t("sent_code_spam")})]})]}),y(zt,{state:r})]})},ck=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,loginSession:r}=await Ie(t,e),{username:i}=r.authParams;if(!i)throw new z(400,{message:"Username required"});return t.html(y(ak,{vendorSettings:n,state:e,email:i}))});function lk(t){const e=new o.OpenAPIHono;e.use(nu).use(async(r,i)=>(r.env.data=no(r,t.dataAdapter),i()));const n=e.route("/info",ik).route("/check-account",Q1).route("/enter-email",b1).route("/enter-code",H1).route("/enter-password",K1).route("/invalid-session",rk).route("/pre-signup",tk).route("/pre-signup-sent",ck).route("/reset-password",G1).route("/forgot-password",Y1).route("/validate-email",ok).route("/signup",W1);return n.doc("/u/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Universal login"}}),n}const uk="Account detected",dk="We have detected that you have already created an account through",pk="By signing in, you agree to our",fk="and",hk="Callback URL mismatch",gk="The provided redirect_uri is not in the list of allowed callback URLs.",mk="continue with user",_k="Please click the button to create a new password account.",yk="Enter the code at {{vendorName}} to complete the login",vk="Welcome to {{vendorName}}! {{code}} is the login code",wk="Welcome to {{vendorName}}! {{code}} is the login code",bk="The code is valid for 30 minutes",kk="Confirm password",xk="Need Help?",Sk="Contact us",Ak="or continue with social account",Ek="Continue with {{provider}}",Ik="Would you like to continue with your existing account?",zk="Copyright © 2023 SESAMY. All rights reserved.",Nk="©2023 Sesamy",Ck="Choose a password with a mix of uppercase and lowercase letters, numbers, and symbols.",jk="Please enter a valid email address.",$k="The passwords didn't match. Try again.",Ok="Choose password",Bk="Password must be at least 8 characters long and contain at least one lowercase letter, one uppercase letter, one number and one symbol.",Tk="Create new account",Pk="Sign up with password",Rk="You are currently logged in as <0>{{email}}</0>",Lk="Email",Uk="Email address",Vk="Your email address has been validated",qk="Now enter your password to login again",Mk="An email has been sent to <0>{{email}}</0> with a verification link. Please click the link to verify your email address and set a password.",Dk="Email verification sent",Hk="Enter a code",Fk="We'll send you a verification link to ensure you own this email address.",Kk="Enter new password",Wk="Enter password",Gk="Enter your email address and password to login.",Jk="Enter your password",Zk="The magic link has expired. Please click on the button below to receive a new link in your inbox.",Yk="Hey! We updated our login experience. <0>Click here to learn more about it.</0>",Xk="Send password reset email",Qk="Click the button below and we’ll send instructions on how to reset your password.",ex="Password reset email sent",tx="Forgot password?",nx="Forgot password?",rx="Go back",ix="Invalid password",sx=`The link is no longer valid.
223
223
 
224
224
  Please make sure to open the login link in the same browser you started the login with.
225
225
 
226
- You can click the link below to start a new login.`,ix="Invalid link",sx="Click the button to log in",ox="Login",ax="Or enter the code at {{vendorName}} to complete the login.",cx="Enter your email address to unlock this show on {{service}}",lx="Link your account with {{service}}",ux="You are logged in as",dx="Login",px="Enter your email address to sign in.",fx="Enter your email address and we will send you a login code.",hx="Enter your email address and we will send you a login link.",gx="Log out",mx="No, I want to use another account",_x="or",yx="Password",vx="The password has been reset",wx="Success",bx="Change password for your {{vendorName}} account",kx="Change password for your {{vendorName}} account",xx="Privacy Policy",Sx="Redirecting",Ax="Confirm password",Ex="Register a new password",Ix="Resend code",zx="Change password",Nx="Enter your new password below for the email account: ",Cx="Click the button to reset your password",jx="Click the button to reset your password",$x="Reset your password",Ox="Change password for your {{vendorName}} account",Bx="Reset password",Tx="Send",Px="Send me a new magic link",Rx="Remember to check your spam folder if the email did not arrive.",Lx="Set password",Ux="Sign in",Vx="Signup",qx="Sign up successful",Mx="It appears that your Spotify account is currently linked to another Sesamy account. But fear not, we're here to guide you through the process to get this fixed.",Dx="Go to Spotify's Content Access page",Hx=`Let's start by unlinking your Spotify account. Click the button below to go to Spotify's Content Access page. After you've logged in to your Spotify account, find Sesamy on the list of connected platforms. Click "Unlink" next to the Sesamy logo.`,Fx="Step 1: Unlink Your Spotify Account",Kx="Once you've successfully unlinked your Spotify account, you can relink it to Sesamy. Simply repeat the steps you previously took that led you to this page.",Wx="Step 2: Relink Your Spotify Account to Sesamy",Gx="Oops! Your Spotify Account Is Already Linked",Jx="If you have questions or need assistance, you can contact our support team",Zx="Terms and Conditions",Yx="Your email address needs validating. We have sent a new email to your inbox",Xx="User account does not exist",Qx="User account does not exist",eS="We could not find a user with the provided email address. Please, try again.",tS="Try again.",nS="Validate code",rS="Check your inbox for email validation instructions.",iS="Signed up",sS="Click the button to verify your email address",oS="Validate your email address",aS="Validate your email address",cS="Verify account",lS="Verify your email",uS="Please check your email at <0>{{email}}</0> and enter the six-digit code that we've sent you.",dS="Welcome",pS="Welcome to your {{vendorName}} account!",fS="Continue with this account",hS="Yes, continue with {{text}}",gS="Yes, continue with existing account",mS={"Server error: Invalid code":"Invalid code","Wrong email or verification code":{"":"Wrong email or verification code."},account_detected:ck,account_with_sso_provider:lk,agree_to:uk,and:dk,callback_url_mismatch:pk,callback_url_not_allowed:fk,check_email_title:hk,click_to_sign_up_description:gk,code_email_enter_code:mk,code_email_subject:_k,code_email_title:yk,code_valid_30_minutes:vk,confirm_password:wk,contact_support:bk,contact_us:kk,continue:"Continue",continue_social_login:xk,continue_with:Sk,continue_with_sso_provider_headline:Ak,copyright:Ek,copyright_sesamy:Ik,create_account_description:zk,create_account_email_invalid:Nk,create_account_passwords_didnt_match:Ck,create_account_title:jk,create_account_weak_password:$k,create_new_account_link:Ok,create_password_account_title:Bk,currently_logged_in_as:Tk,email:Pk,email_placeholder:Rk,email_validated:Lk,email_validated_cta:Uk,email_verification_for_signup_sent_description:Vk,email_verification_for_signup_sent_title:qk,enter_a_code_btn:Mk,enter_email_for_verification_description:Dk,enter_new_password_placeholder:Hk,enter_password:Fk,enter_password_description:Kk,enter_your_password_btn:Wk,expired_code:Gk,fokus_info_message:Jk,forgot_password_cta:Zk,forgot_password_description:Yk,forgot_password_email_sent:Xk,forgot_password_link:Qk,forgot_password_title:ex,go_back:tx,"invalid-email":"Invalid email",invalid_password:nx,invalid_session_body:rx,invalid_session_title:ix,link_email_click_to_login:sx,link_email_login:ox,link_email_or_enter_code:ax,link_page_body:cx,link_page_headline:lx,logged_in_as:ux,login:dx,login_description:px,login_description_code:fx,login_description_link:hx,logout:gx,no_use_another:mx,or:_x,password:yx,password_has_been_reset:vx,password_has_been_reset_title:wx,password_reset_subject:bx,password_reset_title:kx,privacy_policy:xx,redirecting:Sx,reenter_new_password_placeholder:Ax,register_password_account:Ex,resend_code:Ix,reset_password_cta:zx,reset_password_description:Nx,reset_password_email_click_to_reset:Cx,reset_password_email_cta:jx,reset_password_email_reset:$x,reset_password_subject:Ox,reset_password_title:Bx,send:Tx,send_me_a_new_magic_link:Px,sent_code_spam:Rx,set_password:Lx,sign_in:Ux,signup:Vx,signup_success:qx,spotify_already_linked_body:Mx,spotify_already_linked_cta:Dx,spotify_already_linked_step1_body:Hx,spotify_already_linked_step1_title:Fx,spotify_already_linked_step2_body:Kx,spotify_already_linked_step2_title:Wx,spotify_already_linked_title:Gx,support_info:Jx,terms:Zx,unverified_email:Yx,user_account_does_not_exist:Xx,user_not_found:Qx,user_not_found_body:eS,user_not_found_cta:tS,validate_code:nS,validate_email_body:rS,validate_email_title:iS,verify_email_click_to_verify:sS,verify_email_subject:oS,verify_email_title:aS,verify_email_verify:cS,verify_your_email:lS,we_sent_a_code_to:uS,welcome:dS,welcome_to_your_account:pS,yes_continue:fS,yes_continue_with:hS,yes_continue_with_existing_account:gS},_S="Account rilevato",yS="Abbiamo rilevato che l'utente ha già creato un account tramite",vS="Effettuando l'accesso, l'utente accetta la nostra",wS="e",bS="Mancata corrispondenza dell'URL di callback",kS="Il redirect_uri fornito non è nell'elenco degli URL di callback consentiti.",xS="continuare con l'utente",SS="Fare clic sul pulsante per creare un nuovo account con password.",AS="Inserite il codice all'indirizzo {{vendorName}} per completare il login.",ES="Benvenuti su {{vendorName}}! {{code}} è il codice di accesso",IS="Benvenuti su {{vendorName}}! {{code}} è il codice di accesso",zS="Il codice è valido per 30 minuti",NS="Confermare la password",CS="Avete bisogno di aiuto?",jS="Contattateci",$S="o continuare con il conto sociale",OS="Continua con {{provider}}",BS="Desidera continuare a utilizzare l'account esistente?",TS="Copyright © 2023 SESAMY. Tutti i diritti riservati.",PS="©2023 Sesamy",RS="Scegliete una password con un mix di lettere maiuscole e minuscole, numeri e simboli.",LS="Inserire un indirizzo e-mail valido.",US="Le password non corrispondono. Riprovare.",VS="Scegliere la password",qS="La password deve essere lunga almeno 8 caratteri e contenere almeno una lettera minuscola, una lettera maiuscola, un numero e un simbolo.",MS="Creare un nuovo account",DS="Iscriviti con la password",HS="Attualmente si è connessi come <0>{{email}}</0>",FS="Email",KS="Indirizzo e-mail",WS="Il tuo indirizzo e-mail è stato convalidato",GS="Ora inserire la password per accedere nuovamente",JS="È stata inviata un'e-mail a <0>{{email}}</0> con un link di verifica. Fare clic sul link per verificare l'indirizzo e-mail e impostare una password.",ZS="Email di verifica inviata",YS="Inserire un codice",XS="Vi invieremo un link di verifica per assicurarvi di possedere questo indirizzo e-mail.",QS="Inserire la nuova password",e2="Inserire la password",t2="Inserire l'indirizzo e-mail e la password per accedere.",n2="Inserire la password",r2="Il link magico è scaduto. Cliccate sul pulsante sottostante per ricevere un nuovo link nella vostra casella di posta elettronica.",i2="Abbiamo aggiornato la nostra esperienza di accesso. <0>Clicca qui per saperne di più.</0>",s2="Inviare l'e-mail di reimpostazione della password",o2="Fare clic sul pulsante sottostante per ricevere le istruzioni su come reimpostare la password.",a2="Email di reimpostazione della password inviata",c2="Hai dimenticato la password?",l2="Hai dimenticato la password?",u2="Torna indietro",d2="Password non valida",p2=`Il link non è più valido.
226
+ You can click the link below to start a new login.`,ox="Invalid link",ax="Click the button to log in",cx="Login",lx="Or enter the code at {{vendorName}} to complete the login.",ux="Enter your email address to unlock this show on {{service}}",dx="Link your account with {{service}}",px="You are logged in as",fx="Login",hx="Enter your email address to sign in.",gx="Enter your email address and we will send you a login code.",mx="Enter your email address and we will send you a login link.",_x="Log out",yx="No, I want to use another account",vx="or",wx="Password",bx="The password has been reset",kx="Success",xx="Change password for your {{vendorName}} account",Sx="Change password for your {{vendorName}} account",Ax="Privacy Policy",Ex="Redirecting",Ix="Confirm password",zx="Register a new password",Nx="Resend code",Cx="Change password",jx="Enter your new password below for the email account: ",$x="Click the button to reset your password",Ox="Click the button to reset your password",Bx="Reset your password",Tx="Change password for your {{vendorName}} account",Px="Reset password",Rx="Send",Lx="Send me a new magic link",Ux="Remember to check your spam folder if the email did not arrive.",Vx="Set password",qx="Sign in",Mx="Signup",Dx="Sign up successful",Hx="It appears that your Spotify account is currently linked to another Sesamy account. But fear not, we're here to guide you through the process to get this fixed.",Fx="Go to Spotify's Content Access page",Kx=`Let's start by unlinking your Spotify account. Click the button below to go to Spotify's Content Access page. After you've logged in to your Spotify account, find Sesamy on the list of connected platforms. Click "Unlink" next to the Sesamy logo.`,Wx="Step 1: Unlink Your Spotify Account",Gx="Once you've successfully unlinked your Spotify account, you can relink it to Sesamy. Simply repeat the steps you previously took that led you to this page.",Jx="Step 2: Relink Your Spotify Account to Sesamy",Zx="Oops! Your Spotify Account Is Already Linked",Yx="If you have questions or need assistance, you can contact our support team",Xx="Terms and Conditions",Qx="Your email address needs validating. We have sent a new email to your inbox",eS="User account does not exist",tS="User account does not exist",nS="We could not find a user with the provided email address. Please, try again.",rS="Try again.",iS="Validate code",sS="Check your inbox for email validation instructions.",oS="Signed up",aS="Click the button to verify your email address",cS="Validate your email address",lS="Validate your email address",uS="Verify account",dS="Verify your email",pS="Please check your email at <0>{{email}}</0> and enter the six-digit code that we've sent you.",fS="Welcome",hS="Welcome to your {{vendorName}} account!",gS="Continue with this account",mS="Yes, continue with {{text}}",_S="Yes, continue with existing account",yS={"Server error: Invalid code":"Invalid code","Wrong email or verification code":{"":"Wrong email or verification code."},account_detected:uk,account_with_sso_provider:dk,agree_to:pk,and:fk,callback_url_mismatch:hk,callback_url_not_allowed:gk,check_email_title:mk,click_to_sign_up_description:_k,code_email_enter_code:yk,code_email_subject:vk,code_email_title:wk,code_valid_30_minutes:bk,confirm_password:kk,contact_support:xk,contact_us:Sk,continue:"Continue",continue_social_login:Ak,continue_with:Ek,continue_with_sso_provider_headline:Ik,copyright:zk,copyright_sesamy:Nk,create_account_description:Ck,create_account_email_invalid:jk,create_account_passwords_didnt_match:$k,create_account_title:Ok,create_account_weak_password:Bk,create_new_account_link:Tk,create_password_account_title:Pk,currently_logged_in_as:Rk,email:Lk,email_placeholder:Uk,email_validated:Vk,email_validated_cta:qk,email_verification_for_signup_sent_description:Mk,email_verification_for_signup_sent_title:Dk,enter_a_code_btn:Hk,enter_email_for_verification_description:Fk,enter_new_password_placeholder:Kk,enter_password:Wk,enter_password_description:Gk,enter_your_password_btn:Jk,expired_code:Zk,fokus_info_message:Yk,forgot_password_cta:Xk,forgot_password_description:Qk,forgot_password_email_sent:ex,forgot_password_link:tx,forgot_password_title:nx,go_back:rx,"invalid-email":"Invalid email",invalid_password:ix,invalid_session_body:sx,invalid_session_title:ox,link_email_click_to_login:ax,link_email_login:cx,link_email_or_enter_code:lx,link_page_body:ux,link_page_headline:dx,logged_in_as:px,login:fx,login_description:hx,login_description_code:gx,login_description_link:mx,logout:_x,no_use_another:yx,or:vx,password:wx,password_has_been_reset:bx,password_has_been_reset_title:kx,password_reset_subject:xx,password_reset_title:Sx,privacy_policy:Ax,redirecting:Ex,reenter_new_password_placeholder:Ix,register_password_account:zx,resend_code:Nx,reset_password_cta:Cx,reset_password_description:jx,reset_password_email_click_to_reset:$x,reset_password_email_cta:Ox,reset_password_email_reset:Bx,reset_password_subject:Tx,reset_password_title:Px,send:Rx,send_me_a_new_magic_link:Lx,sent_code_spam:Ux,set_password:Vx,sign_in:qx,signup:Mx,signup_success:Dx,spotify_already_linked_body:Hx,spotify_already_linked_cta:Fx,spotify_already_linked_step1_body:Kx,spotify_already_linked_step1_title:Wx,spotify_already_linked_step2_body:Gx,spotify_already_linked_step2_title:Jx,spotify_already_linked_title:Zx,support_info:Yx,terms:Xx,unverified_email:Qx,user_account_does_not_exist:eS,user_not_found:tS,user_not_found_body:nS,user_not_found_cta:rS,validate_code:iS,validate_email_body:sS,validate_email_title:oS,verify_email_click_to_verify:aS,verify_email_subject:cS,verify_email_title:lS,verify_email_verify:uS,verify_your_email:dS,we_sent_a_code_to:pS,welcome:fS,welcome_to_your_account:hS,yes_continue:gS,yes_continue_with:mS,yes_continue_with_existing_account:_S},vS="Account rilevato",wS="Abbiamo rilevato che l'utente ha già creato un account tramite",bS="Effettuando l'accesso, l'utente accetta la nostra",kS="e",xS="Mancata corrispondenza dell'URL di callback",SS="Il redirect_uri fornito non è nell'elenco degli URL di callback consentiti.",AS="continuare con l'utente",ES="Fare clic sul pulsante per creare un nuovo account con password.",IS="Inserite il codice all'indirizzo {{vendorName}} per completare il login.",zS="Benvenuti su {{vendorName}}! {{code}} è il codice di accesso",NS="Benvenuti su {{vendorName}}! {{code}} è il codice di accesso",CS="Il codice è valido per 30 minuti",jS="Confermare la password",$S="Avete bisogno di aiuto?",OS="Contattateci",BS="o continuare con il conto sociale",TS="Continua con {{provider}}",PS="Desidera continuare a utilizzare l'account esistente?",RS="Copyright © 2023 SESAMY. Tutti i diritti riservati.",LS="©2023 Sesamy",US="Scegliete una password con un mix di lettere maiuscole e minuscole, numeri e simboli.",VS="Inserire un indirizzo e-mail valido.",qS="Le password non corrispondono. Riprovare.",MS="Scegliere la password",DS="La password deve essere lunga almeno 8 caratteri e contenere almeno una lettera minuscola, una lettera maiuscola, un numero e un simbolo.",HS="Creare un nuovo account",FS="Iscriviti con la password",KS="Attualmente si è connessi come <0>{{email}}</0>",WS="Email",GS="Indirizzo e-mail",JS="Il tuo indirizzo e-mail è stato convalidato",ZS="Ora inserire la password per accedere nuovamente",YS="È stata inviata un'e-mail a <0>{{email}}</0> con un link di verifica. Fare clic sul link per verificare l'indirizzo e-mail e impostare una password.",XS="Email di verifica inviata",QS="Inserire un codice",e2="Vi invieremo un link di verifica per assicurarvi di possedere questo indirizzo e-mail.",t2="Inserire la nuova password",n2="Inserire la password",r2="Inserire l'indirizzo e-mail e la password per accedere.",i2="Inserire la password",s2="Il link magico è scaduto. Cliccate sul pulsante sottostante per ricevere un nuovo link nella vostra casella di posta elettronica.",o2="Abbiamo aggiornato la nostra esperienza di accesso. <0>Clicca qui per saperne di più.</0>",a2="Inviare l'e-mail di reimpostazione della password",c2="Fare clic sul pulsante sottostante per ricevere le istruzioni su come reimpostare la password.",l2="Email di reimpostazione della password inviata",u2="Hai dimenticato la password?",d2="Hai dimenticato la password?",p2="Torna indietro",f2="Password non valida",h2=`Il link non è più valido.
227
227
 
228
228
  Assicuratevi di aprire il link di accesso con lo stesso browser con cui avete iniziato l'accesso.
229
229
 
230
- Potete fare clic sul link sottostante per iniziare un nuovo accesso.`,f2="Collegamento non valido",h2="Fare clic sul pulsante per accedere",g2="Accedi",m2="Oppure inserire il codice all'indirizzo {{vendorName}} per completare il login.",_2="Inserisci il tuo indirizzo e-mail per sbloccare questo spettacolo su {{service}}",y2="Collegate il vostro account con {{service}}",v2="L'utente ha effettuato l'accesso come",w2="Accesso",b2="Inserire l'indirizzo e-mail per accedere.",k2="Inserite il vostro indirizzo e-mail e vi invieremo un codice di accesso.",x2="Inserite il vostro indirizzo e-mail e vi invieremo un link di accesso.",S2="Disconnettersi",A2="No, voglio usare un altro account",E2="o",I2="Password",z2="La password è stata reimpostata",N2="Il successo",C2="Modifica della password dell'account {{vendorName}}",j2="Modifica della password dell'account {{vendorName}} ",$2="Informativa sulla privacy",O2="Reindirizzamento",B2="Confermare la password",T2="Registrazione di una nuova password",P2="Reinvio del codice",R2="Modifica della password",L2="Immettere di seguito la nuova password per l'account e-mail: ",U2="Fare clic sul pulsante per reimpostare la password",V2="Fare clic sul pulsante per reimpostare la password",q2="Reimpostare la password",M2="Modifica della password dell'account {{vendorName}} ",D2="Reimpostare la password",H2="Inviare",F2="Inviami un nuovo link magico",K2="Ricordate di controllare la cartella spam se l'e-mail non è arrivata.",W2="Impostare la password",G2="Accedi",J2="Iscriviti",Z2="Iscriviti con successo",Y2="Sembra che il vostro account Spotify sia attualmente collegato a un altro account Sesamy. Ma non temete, siamo qui per guidarvi attraverso la procedura per risolvere il problema.",X2="Vai alla pagina di accesso ai contenuti di Spotify",Q2=`Cominciamo con lo scollegare il vostro account Spotify. Fare clic sul pulsante sottostante per accedere alla pagina di accesso ai contenuti di Spotify. Dopo aver effettuato l'accesso al vostro account Spotify, trovate Sesamy nell'elenco delle piattaforme collegate. Fate clic su "Unlink" accanto al logo di Sesamy.`,eA="Passo 1: Disconnettere l'account Spotify",tA="Dopo aver scollegato con successo il proprio account Spotify, è possibile ricollegarlo a Sesamy. È sufficiente ripetere i passaggi precedenti che vi hanno portato a questa pagina.",nA="Passo 2: ricollegare l'account Spotify a Sesamy",rA="Ops! Il tuo account Spotify è già collegato",iA="Se avete domande o bisogno di assistenza, potete contattare il nostro team di supporto",sA="Termini e condizioni",oA="Il tuo indirizzo e-mail deve essere convalidato. Abbiamo inviato una nuova e-mail alla tua casella di posta.",aA="L'account utente non esiste",cA="L'account utente non esiste",lA="Non è stato possibile trovare un utente con l'indirizzo e-mail fornito. Si prega di riprovare.",uA="Riprova.",dA="Convalida del codice",pA="Controllate la vostra casella di posta per le istruzioni di convalida dell'e-mail.",fA="Iscritta",hA="Fare clic sul pulsante per verificare l'indirizzo e-mail",gA="Convalidare l'indirizzo e-mail",mA="Convalidare l'indirizzo e-mail",_A="Verifica dell'account",yA="Verificare l'e-mail",vA="Controllate la vostra e-mail all'indirizzo <0>{{email}}</0> e inserisca il codice a sei cifre che le abbiamo inviato.",wA="Benvenuti",bA="Benvenuto nel tuo account {{vendorName}}!",kA="Continuare con questo account",xA="Sì, continuare con {{text}}",SA="Sì, continuare con l'account esistente",AA={"Server error: Invalid code":"Codice non valido","Wrong email or verification code":{"":"Email o codice di verifica errati."},account_detected:_S,account_with_sso_provider:yS,agree_to:vS,and:wS,callback_url_mismatch:bS,callback_url_not_allowed:kS,check_email_title:xS,click_to_sign_up_description:SS,code_email_enter_code:AS,code_email_subject:ES,code_email_title:IS,code_valid_30_minutes:zS,confirm_password:NS,contact_support:CS,contact_us:jS,continue:"Continua",continue_social_login:$S,continue_with:OS,continue_with_sso_provider_headline:BS,copyright:TS,copyright_sesamy:PS,create_account_description:RS,create_account_email_invalid:LS,create_account_passwords_didnt_match:US,create_account_title:VS,create_account_weak_password:qS,create_new_account_link:MS,create_password_account_title:DS,currently_logged_in_as:HS,email:FS,email_placeholder:KS,email_validated:WS,email_validated_cta:GS,email_verification_for_signup_sent_description:JS,email_verification_for_signup_sent_title:ZS,enter_a_code_btn:YS,enter_email_for_verification_description:XS,enter_new_password_placeholder:QS,enter_password:e2,enter_password_description:t2,enter_your_password_btn:n2,expired_code:r2,fokus_info_message:i2,forgot_password_cta:s2,forgot_password_description:o2,forgot_password_email_sent:a2,forgot_password_link:c2,forgot_password_title:l2,go_back:u2,"invalid-email":"Email non valida",invalid_password:d2,invalid_session_body:p2,invalid_session_title:f2,link_email_click_to_login:h2,link_email_login:g2,link_email_or_enter_code:m2,link_page_body:_2,link_page_headline:y2,logged_in_as:v2,login:w2,login_description:b2,login_description_code:k2,login_description_link:x2,logout:S2,no_use_another:A2,or:E2,password:I2,password_has_been_reset:z2,password_has_been_reset_title:N2,password_reset_subject:C2,password_reset_title:j2,privacy_policy:$2,redirecting:O2,reenter_new_password_placeholder:B2,register_password_account:T2,resend_code:P2,reset_password_cta:R2,reset_password_description:L2,reset_password_email_click_to_reset:U2,reset_password_email_cta:V2,reset_password_email_reset:q2,reset_password_subject:M2,reset_password_title:D2,send:H2,send_me_a_new_magic_link:F2,sent_code_spam:K2,set_password:W2,sign_in:G2,signup:J2,signup_success:Z2,spotify_already_linked_body:Y2,spotify_already_linked_cta:X2,spotify_already_linked_step1_body:Q2,spotify_already_linked_step1_title:eA,spotify_already_linked_step2_body:tA,spotify_already_linked_step2_title:nA,spotify_already_linked_title:rA,support_info:iA,terms:sA,unverified_email:oA,user_account_does_not_exist:aA,user_not_found:cA,user_not_found_body:lA,user_not_found_cta:uA,validate_code:dA,validate_email_body:pA,validate_email_title:fA,verify_email_click_to_verify:hA,verify_email_subject:gA,verify_email_title:mA,verify_email_verify:_A,verify_your_email:yA,we_sent_a_code_to:vA,welcome:wA,welcome_to_your_account:bA,yes_continue:kA,yes_continue_with:xA,yes_continue_with_existing_account:SA},EA="Konto oppdaget",IA="Vi har oppdaget at du allerede har opprettet en konto gjennom",zA="Ved å logge på godtar du vår",NA="og",CA="Callback-URLen samsvarer ikke",jA="Den oppgitte redirect_uri er ikke på listen over tillatte tilbakeringings-URLer.",$A="fortsett med bruker",OA="Klikk på knappen for å opprette en ny passordkonto.",BA="Skriv inn koden på {{vendorName}} for å fullføre påloggingen",TA="Velkommen til {{vendorName}} ! {{code}} er påloggingskoden",PA="Velkommen til {{vendorName}}! {{code}} er påloggingskoden",RA="Koden er gyldig i 30 minutter",LA="Bekreft passord",UA="Trenger hjelp?",VA="Kontakt oss",qA="eller fortsett med sosial konto",MA="Fortsett med {{provider}}",DA="Vil du fortsette med din eksisterende konto?",HA="Opphavsrett © 2023 SESAMY. Alle rettigheter forbeholdt.",FA="©2023 Sesamy",KA="Velg et passord med en blanding av store og små bokstaver, tall og symboler.",WA="Vennligst skriv inn en gyldig e-postadresse.",GA="Passordene stemte ikke overens. Prøv igjen.",JA="Velg passord",ZA="Passordet må være på minst 8 tegn og inneholde minst én liten bokstav, én stor bokstav, ett tall og ett symbol.",YA="Opprett ny konto",XA="Registrer deg med passord",QA="Du er logget på som <0> {{email}}</0>",e4="E-post",t4="E-postadresse",n4="E-postadressen din har blitt validert",r4="Skriv nå inn passordet ditt for å logge inn igjen",i4="En e-post har blitt sendt til <0>{{email}}</0> med en bekreftelseslenke. Klikk på lenken for å bekrefte e-postadressen din og angi et passord.",s4="E-postbekreftelse sendt",o4="Angi en kode",a4="Vi sender deg en bekreftelseskobling for å sikre at du eier denne e-postadressen.",c4="Skriv inn nytt passord",l4="Oppgi passord",u4="Skriv inn e-postadressen og passordet ditt for å logge inn.",d4="Skriv inn passordet ditt",p4="Den magiske lenken er utløpt. Vennligst klikk på knappen nedenfor for å motta en ny lenke i innboksen din.",f4="Hei! Vi oppdaterte påloggingsopplevelsen vår. <0>Klikk her for å lære mer om det.</0>",h4="Send e-post om tilbakestilling av passord",g4="Klikk på knappen nedenfor, så sender vi deg instruksjoner om hvordan du tilbakestiller passordet ditt.",m4="E-post om tilbakestilling av passord sendt",_4="Har du glemt passordet?",y4="Har du glemt passordet?",v4="Gå tilbake",w4="Ugyldig passord",b4=`Lenken er ikke lenger gyldig.
230
+ Potete fare clic sul link sottostante per iniziare un nuovo accesso.`,g2="Collegamento non valido",m2="Fare clic sul pulsante per accedere",_2="Accedi",y2="Oppure inserire il codice all'indirizzo {{vendorName}} per completare il login.",v2="Inserisci il tuo indirizzo e-mail per sbloccare questo spettacolo su {{service}}",w2="Collegate il vostro account con {{service}}",b2="L'utente ha effettuato l'accesso come",k2="Accesso",x2="Inserire l'indirizzo e-mail per accedere.",S2="Inserite il vostro indirizzo e-mail e vi invieremo un codice di accesso.",A2="Inserite il vostro indirizzo e-mail e vi invieremo un link di accesso.",E2="Disconnettersi",I2="No, voglio usare un altro account",z2="o",N2="Password",C2="La password è stata reimpostata",j2="Il successo",$2="Modifica della password dell'account {{vendorName}}",O2="Modifica della password dell'account {{vendorName}} ",B2="Informativa sulla privacy",T2="Reindirizzamento",P2="Confermare la password",R2="Registrazione di una nuova password",L2="Reinvio del codice",U2="Modifica della password",V2="Immettere di seguito la nuova password per l'account e-mail: ",q2="Fare clic sul pulsante per reimpostare la password",M2="Fare clic sul pulsante per reimpostare la password",D2="Reimpostare la password",H2="Modifica della password dell'account {{vendorName}} ",F2="Reimpostare la password",K2="Inviare",W2="Inviami un nuovo link magico",G2="Ricordate di controllare la cartella spam se l'e-mail non è arrivata.",J2="Impostare la password",Z2="Accedi",Y2="Iscriviti",X2="Iscriviti con successo",Q2="Sembra che il vostro account Spotify sia attualmente collegato a un altro account Sesamy. Ma non temete, siamo qui per guidarvi attraverso la procedura per risolvere il problema.",eA="Vai alla pagina di accesso ai contenuti di Spotify",tA=`Cominciamo con lo scollegare il vostro account Spotify. Fare clic sul pulsante sottostante per accedere alla pagina di accesso ai contenuti di Spotify. Dopo aver effettuato l'accesso al vostro account Spotify, trovate Sesamy nell'elenco delle piattaforme collegate. Fate clic su "Unlink" accanto al logo di Sesamy.`,nA="Passo 1: Disconnettere l'account Spotify",rA="Dopo aver scollegato con successo il proprio account Spotify, è possibile ricollegarlo a Sesamy. È sufficiente ripetere i passaggi precedenti che vi hanno portato a questa pagina.",iA="Passo 2: ricollegare l'account Spotify a Sesamy",sA="Ops! Il tuo account Spotify è già collegato",oA="Se avete domande o bisogno di assistenza, potete contattare il nostro team di supporto",aA="Termini e condizioni",cA="Il tuo indirizzo e-mail deve essere convalidato. Abbiamo inviato una nuova e-mail alla tua casella di posta.",lA="L'account utente non esiste",uA="L'account utente non esiste",dA="Non è stato possibile trovare un utente con l'indirizzo e-mail fornito. Si prega di riprovare.",pA="Riprova.",fA="Convalida del codice",hA="Controllate la vostra casella di posta per le istruzioni di convalida dell'e-mail.",gA="Iscritta",mA="Fare clic sul pulsante per verificare l'indirizzo e-mail",_A="Convalidare l'indirizzo e-mail",yA="Convalidare l'indirizzo e-mail",vA="Verifica dell'account",wA="Verificare l'e-mail",bA="Controllate la vostra e-mail all'indirizzo <0>{{email}}</0> e inserisca il codice a sei cifre che le abbiamo inviato.",kA="Benvenuti",xA="Benvenuto nel tuo account {{vendorName}}!",SA="Continuare con questo account",AA="Sì, continuare con {{text}}",EA="Sì, continuare con l'account esistente",IA={"Server error: Invalid code":"Codice non valido","Wrong email or verification code":{"":"Email o codice di verifica errati."},account_detected:vS,account_with_sso_provider:wS,agree_to:bS,and:kS,callback_url_mismatch:xS,callback_url_not_allowed:SS,check_email_title:AS,click_to_sign_up_description:ES,code_email_enter_code:IS,code_email_subject:zS,code_email_title:NS,code_valid_30_minutes:CS,confirm_password:jS,contact_support:$S,contact_us:OS,continue:"Continua",continue_social_login:BS,continue_with:TS,continue_with_sso_provider_headline:PS,copyright:RS,copyright_sesamy:LS,create_account_description:US,create_account_email_invalid:VS,create_account_passwords_didnt_match:qS,create_account_title:MS,create_account_weak_password:DS,create_new_account_link:HS,create_password_account_title:FS,currently_logged_in_as:KS,email:WS,email_placeholder:GS,email_validated:JS,email_validated_cta:ZS,email_verification_for_signup_sent_description:YS,email_verification_for_signup_sent_title:XS,enter_a_code_btn:QS,enter_email_for_verification_description:e2,enter_new_password_placeholder:t2,enter_password:n2,enter_password_description:r2,enter_your_password_btn:i2,expired_code:s2,fokus_info_message:o2,forgot_password_cta:a2,forgot_password_description:c2,forgot_password_email_sent:l2,forgot_password_link:u2,forgot_password_title:d2,go_back:p2,"invalid-email":"Email non valida",invalid_password:f2,invalid_session_body:h2,invalid_session_title:g2,link_email_click_to_login:m2,link_email_login:_2,link_email_or_enter_code:y2,link_page_body:v2,link_page_headline:w2,logged_in_as:b2,login:k2,login_description:x2,login_description_code:S2,login_description_link:A2,logout:E2,no_use_another:I2,or:z2,password:N2,password_has_been_reset:C2,password_has_been_reset_title:j2,password_reset_subject:$2,password_reset_title:O2,privacy_policy:B2,redirecting:T2,reenter_new_password_placeholder:P2,register_password_account:R2,resend_code:L2,reset_password_cta:U2,reset_password_description:V2,reset_password_email_click_to_reset:q2,reset_password_email_cta:M2,reset_password_email_reset:D2,reset_password_subject:H2,reset_password_title:F2,send:K2,send_me_a_new_magic_link:W2,sent_code_spam:G2,set_password:J2,sign_in:Z2,signup:Y2,signup_success:X2,spotify_already_linked_body:Q2,spotify_already_linked_cta:eA,spotify_already_linked_step1_body:tA,spotify_already_linked_step1_title:nA,spotify_already_linked_step2_body:rA,spotify_already_linked_step2_title:iA,spotify_already_linked_title:sA,support_info:oA,terms:aA,unverified_email:cA,user_account_does_not_exist:lA,user_not_found:uA,user_not_found_body:dA,user_not_found_cta:pA,validate_code:fA,validate_email_body:hA,validate_email_title:gA,verify_email_click_to_verify:mA,verify_email_subject:_A,verify_email_title:yA,verify_email_verify:vA,verify_your_email:wA,we_sent_a_code_to:bA,welcome:kA,welcome_to_your_account:xA,yes_continue:SA,yes_continue_with:AA,yes_continue_with_existing_account:EA},zA="Konto oppdaget",NA="Vi har oppdaget at du allerede har opprettet en konto gjennom",CA="Ved å logge på godtar du vår",jA="og",$A="Callback-URLen samsvarer ikke",OA="Den oppgitte redirect_uri er ikke på listen over tillatte tilbakeringings-URLer.",BA="fortsett med bruker",TA="Klikk på knappen for å opprette en ny passordkonto.",PA="Skriv inn koden på {{vendorName}} for å fullføre påloggingen",RA="Velkommen til {{vendorName}} ! {{code}} er påloggingskoden",LA="Velkommen til {{vendorName}}! {{code}} er påloggingskoden",UA="Koden er gyldig i 30 minutter",VA="Bekreft passord",qA="Trenger hjelp?",MA="Kontakt oss",DA="eller fortsett med sosial konto",HA="Fortsett med {{provider}}",FA="Vil du fortsette med din eksisterende konto?",KA="Opphavsrett © 2023 SESAMY. Alle rettigheter forbeholdt.",WA="©2023 Sesamy",GA="Velg et passord med en blanding av store og små bokstaver, tall og symboler.",JA="Vennligst skriv inn en gyldig e-postadresse.",ZA="Passordene stemte ikke overens. Prøv igjen.",YA="Velg passord",XA="Passordet må være på minst 8 tegn og inneholde minst én liten bokstav, én stor bokstav, ett tall og ett symbol.",QA="Opprett ny konto",e4="Registrer deg med passord",t4="Du er logget på som <0> {{email}}</0>",n4="E-post",r4="E-postadresse",i4="E-postadressen din har blitt validert",s4="Skriv nå inn passordet ditt for å logge inn igjen",o4="En e-post har blitt sendt til <0>{{email}}</0> med en bekreftelseslenke. Klikk på lenken for å bekrefte e-postadressen din og angi et passord.",a4="E-postbekreftelse sendt",c4="Angi en kode",l4="Vi sender deg en bekreftelseskobling for å sikre at du eier denne e-postadressen.",u4="Skriv inn nytt passord",d4="Oppgi passord",p4="Skriv inn e-postadressen og passordet ditt for å logge inn.",f4="Skriv inn passordet ditt",h4="Den magiske lenken er utløpt. Vennligst klikk på knappen nedenfor for å motta en ny lenke i innboksen din.",g4="Hei! Vi oppdaterte påloggingsopplevelsen vår. <0>Klikk her for å lære mer om det.</0>",m4="Send e-post om tilbakestilling av passord",_4="Klikk på knappen nedenfor, så sender vi deg instruksjoner om hvordan du tilbakestiller passordet ditt.",y4="E-post om tilbakestilling av passord sendt",v4="Har du glemt passordet?",w4="Har du glemt passordet?",b4="Gå tilbake",k4="Ugyldig passord",x4=`Lenken er ikke lenger gyldig.
231
231
 
232
232
  Sørg for å åpne påloggingslenken i samme nettleser som du startet påloggingen med.
233
233
 
234
- Du kan klikke på lenken nedenfor for å starte en ny pålogging.`,k4="Ugyldig lenke",x4="Klikk på knappen for å logge inn",S4="Logg inn",A4="Eller skriv inn koden på {{vendorName}} for å fullføre påloggingen.",E4="Skriv inn e-postadressen din for å låse opp dette programmet på {{service}}",I4="Koble kontoen din til {{service}}",z4="Du er innlogget som",N4="Logg inn",C4="Skriv inn e-postadressen din for å logge på.",j4="Skriv inn e-postadressen din og vi sender deg en påloggingskode.",$4="Skriv inn e-postadressen din og vi sender deg en påloggingslenke.",O4="Logg ut",B4="Nei, jeg vil bruke en annen konto",T4="eller",P4="Passord",R4="Passordet har blitt tilbakestilt",L4="Suksess",U4="Endre passord for {{vendorName}} kontoen din",V4="Endre passord for {{vendorName}} kontoen din",q4="Personvernerklæring",M4="Omdirigerer",D4="Bekreft passord",H4="Registrer et nytt passord",F4="Send kode på nytt",K4="Endre passord",W4="Skriv inn det nye passordet for e-postkontoen nedenfor: ",G4="Klikk på knappen for å tilbakestille passordet ditt",J4="Klikk på knappen for å tilbakestille passordet ditt",Z4="Tilbakestill passordet ditt",Y4="Endre passord for {{vendorName}} -kontoen din",X4="Tilbakestill passord",Q4="Send",eE="Send meg en ny magisk lenke",tE="Husk å sjekke søppelpostmappen din hvis e-posten ikke kom.",nE="Angi passord",rE="Logg inn",iE="Påmelding",sE="Vellykket registrering",oE="Det ser ut til at Spotify-kontoen din for øyeblikket er koblet til en annen Sesamy-konto. Men ikke vær redd, vi er her for å veilede deg gjennom prosessen for å få dette fikset.",aE="Gå til Spotifys innholdstilgangsside",cE='La oss starte med å koble fra Spotify-kontoen din. Klikk på knappen nedenfor for å gå til Spotifys innholdstilgang-side. Etter at du har logget på Spotify-kontoen din, finner du Sesamy på listen over tilkoblede plattformer. Klikk "Fjern kobling" ved siden av Sesamy-logoen.',lE="Trinn 1: Koble fra Spotify-kontoen din",uE="Når du har koblet fra Spotify-kontoen din, kan du koble den til Sesamy på nytt. Bare gjenta trinnene du tidligere tok som førte deg til denne siden.",dE="Trinn 2: Koble Spotify-kontoen din til Sesamy på nytt",pE="Oops! Spotify-kontoen din er allerede koblet",fE="Hvis du har spørsmål eller trenger hjelp, kan du kontakte supportteamet vårt",hE="vilkår",gE="E-postadressen din må bekreftes. Vi har sendt en ny e-post til innboksen din.",mE="Brukerkonto eksisterer ikke",_E="Brukerkonto eksisterer ikke",yE="Vi kunne ikke finne en bruker med den oppgitte e-postadressen. Vær så snill, prøv på nytt.",vE="Prøv igjen.",wE="Bekreft koden",bE="Sjekk innboksen din for instruksjoner om e-postvalidering.",kE="Registrerte seg",xE="Klikk på knappen for å bekrefte e-postadressen din",SE="Bekreft e-postadressen din",AE="Bekreft e-postadressen din",EE="Bekreft konto",IE="Bekreft e-posten din",zE="Vennligst sjekk e-posten din på <0>{{email}}</0> og skriv inn den sekssifrede koden som vi har sendt deg.",NE="Velkommen",CE="Velkommen til din brukerkonto hos {{vendorName}} !",jE="Fortsett med denne kontoen",$E="Ja, fortsett med {{text}}",OE="Ja, fortsett med eksisterende konto",BE={"Server error: Invalid code":"Ugyldig kode","Wrong email or verification code":{"":"Feil e-post eller bekreftelseskode."},account_detected:EA,account_with_sso_provider:IA,agree_to:zA,and:NA,callback_url_mismatch:CA,callback_url_not_allowed:jA,check_email_title:$A,click_to_sign_up_description:OA,code_email_enter_code:BA,code_email_subject:TA,code_email_title:PA,code_valid_30_minutes:RA,confirm_password:LA,contact_support:UA,contact_us:VA,continue:"Fortsette",continue_social_login:qA,continue_with:MA,continue_with_sso_provider_headline:DA,copyright:HA,copyright_sesamy:FA,create_account_description:KA,create_account_email_invalid:WA,create_account_passwords_didnt_match:GA,create_account_title:JA,create_account_weak_password:ZA,create_new_account_link:YA,create_password_account_title:XA,currently_logged_in_as:QA,email:e4,email_placeholder:t4,email_validated:n4,email_validated_cta:r4,email_verification_for_signup_sent_description:i4,email_verification_for_signup_sent_title:s4,enter_a_code_btn:o4,enter_email_for_verification_description:a4,enter_new_password_placeholder:c4,enter_password:l4,enter_password_description:u4,enter_your_password_btn:d4,expired_code:p4,fokus_info_message:f4,forgot_password_cta:h4,forgot_password_description:g4,forgot_password_email_sent:m4,forgot_password_link:_4,forgot_password_title:y4,go_back:v4,"invalid-email":"Ugyldig epost",invalid_password:w4,invalid_session_body:b4,invalid_session_title:k4,link_email_click_to_login:x4,link_email_login:S4,link_email_or_enter_code:A4,link_page_body:E4,link_page_headline:I4,logged_in_as:z4,login:N4,login_description:C4,login_description_code:j4,login_description_link:$4,logout:O4,no_use_another:B4,or:T4,password:P4,password_has_been_reset:R4,password_has_been_reset_title:L4,password_reset_subject:U4,password_reset_title:V4,privacy_policy:q4,redirecting:M4,reenter_new_password_placeholder:D4,register_password_account:H4,resend_code:F4,reset_password_cta:K4,reset_password_description:W4,reset_password_email_click_to_reset:G4,reset_password_email_cta:J4,reset_password_email_reset:Z4,reset_password_subject:Y4,reset_password_title:X4,send:Q4,send_me_a_new_magic_link:eE,sent_code_spam:tE,set_password:nE,sign_in:rE,signup:iE,signup_success:sE,spotify_already_linked_body:oE,spotify_already_linked_cta:aE,spotify_already_linked_step1_body:cE,spotify_already_linked_step1_title:lE,spotify_already_linked_step2_body:uE,spotify_already_linked_step2_title:dE,spotify_already_linked_title:pE,support_info:fE,terms:hE,unverified_email:gE,user_account_does_not_exist:mE,user_not_found:_E,user_not_found_body:yE,user_not_found_cta:vE,validate_code:wE,validate_email_body:bE,validate_email_title:kE,verify_email_click_to_verify:xE,verify_email_subject:SE,verify_email_title:AE,verify_email_verify:EE,verify_your_email:IE,we_sent_a_code_to:zE,welcome:NE,welcome_to_your_account:CE,yes_continue:jE,yes_continue_with:$E,yes_continue_with_existing_account:OE},TE="Fortsätt med existerande konto",PE="Det verkar som att du redan har skapat ett konto genom",RE="Genom att logga in godkänner du våra",LE="och",UE="Callback URL mismatch",VE="The provided redirect_uri is not in the list of allowed callback URLs.",qE="fortsätt med användaren",ME="Klicka på knappen för att skapa ett nytt lösenordskonto.",DE="Skriv in koden på {{vendorName}} för att slutföra inloggningen",HE="Välkommen till {{vendorName}}! {{code}} är koden för att logga in",FE="Välkommen till {{vendorName}}! {{code}} är koden för att logga in",KE="Koden är giltig i 30 minuter",WE="Bekräfta lösenord",GE="Behöver du hjälp?",JE="Kontakta oss",ZE="eller via sociala medier",YE="Fortsätt med {{provider}}",XE="Vill du fortsätta med det här kontot?",QE="Copyright © 2023 SESAMY. Alla rättigheter förbehållna.",eI="©2023 Sesamy",tI="Välj ett lösenord med en blandning av stora och små bokstäver, siffror och symboler.",nI="Ange en giltig e-postadress.",rI="Lösenorden stämde inte överens. Försök igen.",iI="Välj lösenord",sI="Lösenordet måste vara minst 8 tecken långt och innehålla minst en gemen bokstav, en versal bokstav, en siffra och en symbol.",oI="Skapa nytt konto",aI="Registrera dig med lösenord",cI="Du är inloggad som <0>{{email}}</0>",lI="E-postadress",uI="E-postadress",dI="Din e-postadress har validerats",pI="Ange nu ditt lösenord för att logga in igen",fI="Ett e-postmeddelande har skickats till <0>{{email}}</0> med en verifieringslänk. Vänligen klicka på länken för att verifiera din e-postadress och välja ett lösenord.",hI="E-postverifiering skickad",gI="Logga in med kod",mI="Vi skickar dig en verifieringslänk för att säkerställa att du äger den här e-postadressen.",_I="Ange nytt lösenord",yI="Ange lösenord",vI="Ange din e-postadress och ditt lösenord för att logga in.",wI="Logga in med lösenord",bI="Länken är inte längre giltig. Klicka på knappen för att skicka en ny länk till din epost.",kI="Vi har bytt inloggningssystem, <0>här kan du läsa mer om vad det innebär</0>",xI="Skicka",SI="Klicka på knappen nedan så skickar vi instruktioner om hur du återställer ditt lösenord.",AI="Vi har skickat ett e-postmeddelande med instruktioner om hur du återställer ditt lösenord till den e-postadress du angav.",EI="Har du glömt lösenordet?",II="Har du glömt lösenordet?",zI="Gå tillbaka",NI="Ogiltigt lösenord",CI=`Länken är inte längre giltig.
234
+ Du kan klikke på lenken nedenfor for å starte en ny pålogging.`,S4="Ugyldig lenke",A4="Klikk på knappen for å logge inn",E4="Logg inn",I4="Eller skriv inn koden på {{vendorName}} for å fullføre påloggingen.",z4="Skriv inn e-postadressen din for å låse opp dette programmet på {{service}}",N4="Koble kontoen din til {{service}}",C4="Du er innlogget som",j4="Logg inn",$4="Skriv inn e-postadressen din for å logge på.",O4="Skriv inn e-postadressen din og vi sender deg en påloggingskode.",B4="Skriv inn e-postadressen din og vi sender deg en påloggingslenke.",T4="Logg ut",P4="Nei, jeg vil bruke en annen konto",R4="eller",L4="Passord",U4="Passordet har blitt tilbakestilt",V4="Suksess",q4="Endre passord for {{vendorName}} kontoen din",M4="Endre passord for {{vendorName}} kontoen din",D4="Personvernerklæring",H4="Omdirigerer",F4="Bekreft passord",K4="Registrer et nytt passord",W4="Send kode på nytt",G4="Endre passord",J4="Skriv inn det nye passordet for e-postkontoen nedenfor: ",Z4="Klikk på knappen for å tilbakestille passordet ditt",Y4="Klikk på knappen for å tilbakestille passordet ditt",X4="Tilbakestill passordet ditt",Q4="Endre passord for {{vendorName}} -kontoen din",eE="Tilbakestill passord",tE="Send",nE="Send meg en ny magisk lenke",rE="Husk å sjekke søppelpostmappen din hvis e-posten ikke kom.",iE="Angi passord",sE="Logg inn",oE="Påmelding",aE="Vellykket registrering",cE="Det ser ut til at Spotify-kontoen din for øyeblikket er koblet til en annen Sesamy-konto. Men ikke vær redd, vi er her for å veilede deg gjennom prosessen for å få dette fikset.",lE="Gå til Spotifys innholdstilgangsside",uE='La oss starte med å koble fra Spotify-kontoen din. Klikk på knappen nedenfor for å gå til Spotifys innholdstilgang-side. Etter at du har logget på Spotify-kontoen din, finner du Sesamy på listen over tilkoblede plattformer. Klikk "Fjern kobling" ved siden av Sesamy-logoen.',dE="Trinn 1: Koble fra Spotify-kontoen din",pE="Når du har koblet fra Spotify-kontoen din, kan du koble den til Sesamy på nytt. Bare gjenta trinnene du tidligere tok som førte deg til denne siden.",fE="Trinn 2: Koble Spotify-kontoen din til Sesamy på nytt",hE="Oops! Spotify-kontoen din er allerede koblet",gE="Hvis du har spørsmål eller trenger hjelp, kan du kontakte supportteamet vårt",mE="vilkår",_E="E-postadressen din må bekreftes. Vi har sendt en ny e-post til innboksen din.",yE="Brukerkonto eksisterer ikke",vE="Brukerkonto eksisterer ikke",wE="Vi kunne ikke finne en bruker med den oppgitte e-postadressen. Vær så snill, prøv på nytt.",bE="Prøv igjen.",kE="Bekreft koden",xE="Sjekk innboksen din for instruksjoner om e-postvalidering.",SE="Registrerte seg",AE="Klikk på knappen for å bekrefte e-postadressen din",EE="Bekreft e-postadressen din",IE="Bekreft e-postadressen din",zE="Bekreft konto",NE="Bekreft e-posten din",CE="Vennligst sjekk e-posten din på <0>{{email}}</0> og skriv inn den sekssifrede koden som vi har sendt deg.",jE="Velkommen",$E="Velkommen til din brukerkonto hos {{vendorName}} !",OE="Fortsett med denne kontoen",BE="Ja, fortsett med {{text}}",TE="Ja, fortsett med eksisterende konto",PE={"Server error: Invalid code":"Ugyldig kode","Wrong email or verification code":{"":"Feil e-post eller bekreftelseskode."},account_detected:zA,account_with_sso_provider:NA,agree_to:CA,and:jA,callback_url_mismatch:$A,callback_url_not_allowed:OA,check_email_title:BA,click_to_sign_up_description:TA,code_email_enter_code:PA,code_email_subject:RA,code_email_title:LA,code_valid_30_minutes:UA,confirm_password:VA,contact_support:qA,contact_us:MA,continue:"Fortsette",continue_social_login:DA,continue_with:HA,continue_with_sso_provider_headline:FA,copyright:KA,copyright_sesamy:WA,create_account_description:GA,create_account_email_invalid:JA,create_account_passwords_didnt_match:ZA,create_account_title:YA,create_account_weak_password:XA,create_new_account_link:QA,create_password_account_title:e4,currently_logged_in_as:t4,email:n4,email_placeholder:r4,email_validated:i4,email_validated_cta:s4,email_verification_for_signup_sent_description:o4,email_verification_for_signup_sent_title:a4,enter_a_code_btn:c4,enter_email_for_verification_description:l4,enter_new_password_placeholder:u4,enter_password:d4,enter_password_description:p4,enter_your_password_btn:f4,expired_code:h4,fokus_info_message:g4,forgot_password_cta:m4,forgot_password_description:_4,forgot_password_email_sent:y4,forgot_password_link:v4,forgot_password_title:w4,go_back:b4,"invalid-email":"Ugyldig epost",invalid_password:k4,invalid_session_body:x4,invalid_session_title:S4,link_email_click_to_login:A4,link_email_login:E4,link_email_or_enter_code:I4,link_page_body:z4,link_page_headline:N4,logged_in_as:C4,login:j4,login_description:$4,login_description_code:O4,login_description_link:B4,logout:T4,no_use_another:P4,or:R4,password:L4,password_has_been_reset:U4,password_has_been_reset_title:V4,password_reset_subject:q4,password_reset_title:M4,privacy_policy:D4,redirecting:H4,reenter_new_password_placeholder:F4,register_password_account:K4,resend_code:W4,reset_password_cta:G4,reset_password_description:J4,reset_password_email_click_to_reset:Z4,reset_password_email_cta:Y4,reset_password_email_reset:X4,reset_password_subject:Q4,reset_password_title:eE,send:tE,send_me_a_new_magic_link:nE,sent_code_spam:rE,set_password:iE,sign_in:sE,signup:oE,signup_success:aE,spotify_already_linked_body:cE,spotify_already_linked_cta:lE,spotify_already_linked_step1_body:uE,spotify_already_linked_step1_title:dE,spotify_already_linked_step2_body:pE,spotify_already_linked_step2_title:fE,spotify_already_linked_title:hE,support_info:gE,terms:mE,unverified_email:_E,user_account_does_not_exist:yE,user_not_found:vE,user_not_found_body:wE,user_not_found_cta:bE,validate_code:kE,validate_email_body:xE,validate_email_title:SE,verify_email_click_to_verify:AE,verify_email_subject:EE,verify_email_title:IE,verify_email_verify:zE,verify_your_email:NE,we_sent_a_code_to:CE,welcome:jE,welcome_to_your_account:$E,yes_continue:OE,yes_continue_with:BE,yes_continue_with_existing_account:TE},RE="Fortsätt med existerande konto",LE="Det verkar som att du redan har skapat ett konto genom",UE="Genom att logga in godkänner du våra",VE="och",qE="Callback URL mismatch",ME="The provided redirect_uri is not in the list of allowed callback URLs.",DE="fortsätt med användaren",HE="Klicka på knappen för att skapa ett nytt lösenordskonto.",FE="Skriv in koden på {{vendorName}} för att slutföra inloggningen",KE="Välkommen till {{vendorName}}! {{code}} är koden för att logga in",WE="Välkommen till {{vendorName}}! {{code}} är koden för att logga in",GE="Koden är giltig i 30 minuter",JE="Bekräfta lösenord",ZE="Behöver du hjälp?",YE="Kontakta oss",XE="eller via sociala medier",QE="Fortsätt med {{provider}}",eI="Vill du fortsätta med det här kontot?",tI="Copyright © 2023 SESAMY. Alla rättigheter förbehållna.",nI="©2023 Sesamy",rI="Välj ett lösenord med en blandning av stora och små bokstäver, siffror och symboler.",iI="Ange en giltig e-postadress.",sI="Lösenorden stämde inte överens. Försök igen.",oI="Välj lösenord",aI="Lösenordet måste vara minst 8 tecken långt och innehålla minst en gemen bokstav, en versal bokstav, en siffra och en symbol.",cI="Skapa nytt konto",lI="Registrera dig med lösenord",uI="Du är inloggad som <0>{{email}}</0>",dI="E-postadress",pI="E-postadress",fI="Din e-postadress har validerats",hI="Ange nu ditt lösenord för att logga in igen",gI="Ett e-postmeddelande har skickats till <0>{{email}}</0> med en verifieringslänk. Vänligen klicka på länken för att verifiera din e-postadress och välja ett lösenord.",mI="E-postverifiering skickad",_I="Logga in med kod",yI="Vi skickar dig en verifieringslänk för att säkerställa att du äger den här e-postadressen.",vI="Ange nytt lösenord",wI="Ange lösenord",bI="Ange din e-postadress och ditt lösenord för att logga in.",kI="Logga in med lösenord",xI="Länken är inte längre giltig. Klicka på knappen för att skicka en ny länk till din epost.",SI="Vi har bytt inloggningssystem, <0>här kan du läsa mer om vad det innebär</0>",AI="Skicka",EI="Klicka på knappen nedan så skickar vi instruktioner om hur du återställer ditt lösenord.",II="Vi har skickat ett e-postmeddelande med instruktioner om hur du återställer ditt lösenord till den e-postadress du angav.",zI="Har du glömt lösenordet?",NI="Har du glömt lösenordet?",CI="Gå tillbaka",jI="Ogiltigt lösenord",$I=`Länken är inte längre giltig.
235
235
 
236
236
  Vänligen se till att öppna inloggningslänken i samma webbläsare som du startade inloggningen med.
237
237
 
238
- Du kan klicka på länken nedan för att starta en ny inloggning.`,jI="Ogiltig länk",$I="Klicka på knappen för att logga in",OI="Logga in",BI="Eller skriv in koden på {{vendorName}} för att slutföra inloggningen.",TI="Ange din epost för att låsa upp den här showen på {{service}}",PI="Koppla ditt konto till {{service}}",RI="Du är inloggad som",LI="Logga in",UI="Ange din e-postadress för att logga in.",VI="Ange din mejladress, så skickar vi en kod till dig som du kan logga in med.",qI="Ange din mejladress, så skickar vi en länk till dig som du kan logga in med.",MI="Logga ut",DI="Nej, jag vill använda ett annat konto",HI="eller",FI="Lösenord",KI="Lösenordet har återställts",WI="Framgång",GI="Byt lösenord för ditt {{vendorName}} konto",JI="Byt lösenord för ditt {{vendorName}} konto",ZI="Integritetspolicy",YI="Du skickas vidare",XI="Bekräfta lösenord",QI="Registrera ett nytt lösenord",e3="Skicka koden igen",t3="Ändra lösenord",n3="Ange ditt nya lösenord nedan för e-postkontot: ",r3="Klicka på knappen för att återställa ditt lösenord",i3="Klicka på knappen för att återställa ditt lösenord",s3="Återställ ditt lösenord",o3="Byt lösenord för ditt {{vendorName}} konto",a3="Återställ lösenord",c3="Skicka",l3="Skicka en ny inloggninglänk",u3="Kom ihåg att kontrollera din skräppost om du inte kan hitta mailet vi har skickat.",d3="Välj lösenord",p3="Logga in",f3="Registrera dig",h3="Registrera dig framgångsrik",g3="Det verkar som att ditt Spotify-konto för närvarande är kopplat till ett annat Sesamy-konto. Ingen fara, vi är här för att guida dig genom processen för att lösa detta.",m3="Gå till Spotify's Content Access sida",_3=`Vi börjar med att avlänka ditt Spotify-konto. Klicka på knappen nedan för att komma till Spotify's Content Access sida. När du har loggat in på ditt Spotify-konto, leta upp Sesamy i listan över anslutna plattformar. Klicka på "Unlink" bredvid Sesamys logotyp.`,y3="Steg 1: Avlänka ditt Spotify-konto",v3="När du har avlänkat ditt Spotify-konto kan du koppla det till Sesamy igen. Upprepa helt enkelt de steg du tog som ledde dig till den här sidan.",w3="Steg 2: Koppla ditt Spotify-konto till Sesamy igen",b3="Oj! Ditt Spotify-konto är redan kopplat",k3="Om du har frågor eller behöver hjälp kan du kontakta vårt supportteam",x3="Villkor",S3="Din e-postadress behöver valideras. Vi har skickat ett nytt e-postmeddelande till din inkorg",A3="Kontot existerar inte",E3="Kontot extisterar inte",I3="Vi kan inte hitta en användare med denna eposten. Vänligen försök igen.",z3="Försök igen.",N3="Validera kod",C3="Kontrollera din inkorg för instruktioner om validering av e-post.",j3="Registrerad",$3="Klicka på knappen för att verifiera din e-postadress",O3="Bekräfta din e-postadress",B3="Bekräfta din e-postadress",T3="Verifiera konto",P3="Ange engångskod",R3="Vänligen kontrollera din e-post för <0>{{email}}</0> och ange den sexsiffriga koden som vi har skickat till dig.",L3="Välkommen",U3="Välkommen till ditt {{vendorName}}-konto!",V3="Fortsätt med konto",q3="Ja, fortsätt med {{text}}",M3="Ja, fortsätt med detta kontot",D3={"Server error: Invalid code":"Koden är inte giltig","Wrong email or verification code":{"":"Fel e-post eller verifieringskod."},account_detected:TE,account_with_sso_provider:PE,agree_to:RE,and:LE,callback_url_mismatch:UE,callback_url_not_allowed:VE,check_email_title:qE,click_to_sign_up_description:ME,code_email_enter_code:DE,code_email_subject:HE,code_email_title:FE,code_valid_30_minutes:KE,confirm_password:WE,contact_support:GE,contact_us:JE,continue:"Fortsätt",continue_social_login:ZE,continue_with:YE,continue_with_sso_provider_headline:XE,copyright:QE,copyright_sesamy:eI,create_account_description:tI,create_account_email_invalid:nI,create_account_passwords_didnt_match:rI,create_account_title:iI,create_account_weak_password:sI,create_new_account_link:oI,create_password_account_title:aI,currently_logged_in_as:cI,email:lI,email_placeholder:uI,email_validated:dI,email_validated_cta:pI,email_verification_for_signup_sent_description:fI,email_verification_for_signup_sent_title:hI,enter_a_code_btn:gI,enter_email_for_verification_description:mI,enter_new_password_placeholder:_I,enter_password:yI,enter_password_description:vI,enter_your_password_btn:wI,expired_code:bI,fokus_info_message:kI,forgot_password_cta:xI,forgot_password_description:SI,forgot_password_email_sent:AI,forgot_password_link:EI,forgot_password_title:II,go_back:zI,"invalid-email":"Ogiltig e-postadress",invalid_password:NI,invalid_session_body:CI,invalid_session_title:jI,link_email_click_to_login:$I,link_email_login:OI,link_email_or_enter_code:BI,link_page_body:TI,link_page_headline:PI,logged_in_as:RI,login:LI,login_description:UI,login_description_code:VI,login_description_link:qI,logout:MI,no_use_another:DI,or:HI,password:FI,password_has_been_reset:KI,password_has_been_reset_title:WI,password_reset_subject:GI,password_reset_title:JI,privacy_policy:ZI,redirecting:YI,reenter_new_password_placeholder:XI,register_password_account:QI,resend_code:e3,reset_password_cta:t3,reset_password_description:n3,reset_password_email_click_to_reset:r3,reset_password_email_cta:i3,reset_password_email_reset:s3,reset_password_subject:o3,reset_password_title:a3,send:c3,send_me_a_new_magic_link:l3,sent_code_spam:u3,set_password:d3,sign_in:p3,signup:f3,signup_success:h3,spotify_already_linked_body:g3,spotify_already_linked_cta:m3,spotify_already_linked_step1_body:_3,spotify_already_linked_step1_title:y3,spotify_already_linked_step2_body:v3,spotify_already_linked_step2_title:w3,spotify_already_linked_title:b3,support_info:k3,terms:x3,unverified_email:S3,user_account_does_not_exist:A3,user_not_found:E3,user_not_found_body:I3,user_not_found_cta:z3,validate_code:N3,validate_email_body:C3,validate_email_title:j3,verify_email_click_to_verify:$3,verify_email_subject:O3,verify_email_title:B3,verify_email_verify:T3,verify_your_email:P3,we_sent_a_code_to:R3,welcome:L3,welcome_to_your_account:U3,yes_continue:V3,yes_continue_with:q3,yes_continue_with_existing_account:M3},H3="Wykryto konto",F3="Wykryliśmy, że użytkownik utworzył już konto za pośrednictwem",K3="Logując się, wyrażasz zgodę na nasze",W3="i",G3="Niezgodność adresu URL wywołania zwrotnego",J3="Podany adres redirect_uri nie znajduje się na liście dozwolonych adresów URL wywołania zwrotnego.",Z3="kontynuować z użytkownikiem",Y3="Kliknij przycisk, aby utworzyć nowe konto z hasłem.",X3="Wpisz kod na stronie {{vendorName}}, aby się zalogować.",Q3="Witamy na {{vendorName}}! {{code}} to kod logowania do Twojego konta.",ez="Witamy na {{vendorName}}! {{code}} to kod logowania.",tz="Kod jest ważny przez 30 minut",nz="Potwierdź hasło",rz="Potrzebujesz pomocy?",iz="Skontaktuj się z nami",sz="lub kontynuować korzystanie z konta społecznościowego",oz="Kontynuuj {{provider}}",az="Czy chcesz kontynuować korzystanie z istniejącego konta?",cz="Copyright © 2023 SESAMY. Wszelkie prawa zastrzeżone.",lz="©2023 Sesamy",uz="Wybierz hasło składające się z małych i wielkich liter, cyfr i symboli.",dz="Wprowadź prawidłowy adres e-mail.",pz="Hasła nie są zgodne. Spróbuj ponownie.",fz="Wybierz hasło",hz="Hasło musi mieć co najmniej 8 znaków i zawierać co najmniej jedną małą literę, jedną wielką literę, jedną cyfrę i jeden symbol.",gz="Utwórz nowe konto",mz="Zarejestruj się przy użyciu hasła",_z="Jesteś obecnie zalogowany jako <0>{{email}}</0>",yz="E-mail",vz="Adres e-mail",wz="Twój adres e-mail został zweryfikowany",bz="Teraz wprowadź hasło, aby zalogować się ponownie",kz="Wiadomość e-mail została wysłana do <0>{{email}}</0> z linkiem weryfikacyjnym. Kliknij łącze, aby zweryfikować swój adres e-mail i ustawić hasło.",xz="Wysłano weryfikację e-mail",Sz="Wprowadź kod",Az="Wyślemy Ci link weryfikacyjny, aby upewnić się, że posiadasz ten adres e-mail.",Ez="Wprowadź nowe hasło",Iz="Wprowadź hasło",zz="Wprowadź swój adres e-mail i hasło, aby się zalogować.",Nz="Wprowadź hasło",Cz="Magiczny link wygasł. Kliknij poniższy przycisk, aby otrzymać nowy link w skrzynce odbiorczej.",jz="Zaktualizowaliśmy sposób logowania. <0>Kliknij tutaj, aby dowiedzieć się więcej.</0>",$z="Wyślij wiadomość e-mail z resetem hasła",Oz="Kliknij poniższy przycisk, a my wyślemy Ci instrukcje, jak zresetować hasło.",Bz="Wysłano wiadomość e-mail z resetem hasła",Tz="Zapomniałeś hasła?",Pz="Zapomniałeś hasła?",Rz="Wróć",Lz="Nieprawidłowe hasło",Uz=`Link jest już nieaktualny.
238
+ Du kan klicka på länken nedan för att starta en ny inloggning.`,OI="Ogiltig länk",BI="Klicka på knappen för att logga in",TI="Logga in",PI="Eller skriv in koden på {{vendorName}} för att slutföra inloggningen.",RI="Ange din epost för att låsa upp den här showen på {{service}}",LI="Koppla ditt konto till {{service}}",UI="Du är inloggad som",VI="Logga in",qI="Ange din e-postadress för att logga in.",MI="Ange din mejladress, så skickar vi en kod till dig som du kan logga in med.",DI="Ange din mejladress, så skickar vi en länk till dig som du kan logga in med.",HI="Logga ut",FI="Nej, jag vill använda ett annat konto",KI="eller",WI="Lösenord",GI="Lösenordet har återställts",JI="Framgång",ZI="Byt lösenord för ditt {{vendorName}} konto",YI="Byt lösenord för ditt {{vendorName}} konto",XI="Integritetspolicy",QI="Du skickas vidare",e3="Bekräfta lösenord",t3="Registrera ett nytt lösenord",n3="Skicka koden igen",r3="Ändra lösenord",i3="Ange ditt nya lösenord nedan för e-postkontot: ",s3="Klicka på knappen för att återställa ditt lösenord",o3="Klicka på knappen för att återställa ditt lösenord",a3="Återställ ditt lösenord",c3="Byt lösenord för ditt {{vendorName}} konto",l3="Återställ lösenord",u3="Skicka",d3="Skicka en ny inloggninglänk",p3="Kom ihåg att kontrollera din skräppost om du inte kan hitta mailet vi har skickat.",f3="Välj lösenord",h3="Logga in",g3="Registrera dig",m3="Registrera dig framgångsrik",_3="Det verkar som att ditt Spotify-konto för närvarande är kopplat till ett annat Sesamy-konto. Ingen fara, vi är här för att guida dig genom processen för att lösa detta.",y3="Gå till Spotify's Content Access sida",v3=`Vi börjar med att avlänka ditt Spotify-konto. Klicka på knappen nedan för att komma till Spotify's Content Access sida. När du har loggat in på ditt Spotify-konto, leta upp Sesamy i listan över anslutna plattformar. Klicka på "Unlink" bredvid Sesamys logotyp.`,w3="Steg 1: Avlänka ditt Spotify-konto",b3="När du har avlänkat ditt Spotify-konto kan du koppla det till Sesamy igen. Upprepa helt enkelt de steg du tog som ledde dig till den här sidan.",k3="Steg 2: Koppla ditt Spotify-konto till Sesamy igen",x3="Oj! Ditt Spotify-konto är redan kopplat",S3="Om du har frågor eller behöver hjälp kan du kontakta vårt supportteam",A3="Villkor",E3="Din e-postadress behöver valideras. Vi har skickat ett nytt e-postmeddelande till din inkorg",I3="Kontot existerar inte",z3="Kontot extisterar inte",N3="Vi kan inte hitta en användare med denna eposten. Vänligen försök igen.",C3="Försök igen.",j3="Validera kod",$3="Kontrollera din inkorg för instruktioner om validering av e-post.",O3="Registrerad",B3="Klicka på knappen för att verifiera din e-postadress",T3="Bekräfta din e-postadress",P3="Bekräfta din e-postadress",R3="Verifiera konto",L3="Ange engångskod",U3="Vänligen kontrollera din e-post för <0>{{email}}</0> och ange den sexsiffriga koden som vi har skickat till dig.",V3="Välkommen",q3="Välkommen till ditt {{vendorName}}-konto!",M3="Fortsätt med konto",D3="Ja, fortsätt med {{text}}",H3="Ja, fortsätt med detta kontot",F3={"Server error: Invalid code":"Koden är inte giltig","Wrong email or verification code":{"":"Fel e-post eller verifieringskod."},account_detected:RE,account_with_sso_provider:LE,agree_to:UE,and:VE,callback_url_mismatch:qE,callback_url_not_allowed:ME,check_email_title:DE,click_to_sign_up_description:HE,code_email_enter_code:FE,code_email_subject:KE,code_email_title:WE,code_valid_30_minutes:GE,confirm_password:JE,contact_support:ZE,contact_us:YE,continue:"Fortsätt",continue_social_login:XE,continue_with:QE,continue_with_sso_provider_headline:eI,copyright:tI,copyright_sesamy:nI,create_account_description:rI,create_account_email_invalid:iI,create_account_passwords_didnt_match:sI,create_account_title:oI,create_account_weak_password:aI,create_new_account_link:cI,create_password_account_title:lI,currently_logged_in_as:uI,email:dI,email_placeholder:pI,email_validated:fI,email_validated_cta:hI,email_verification_for_signup_sent_description:gI,email_verification_for_signup_sent_title:mI,enter_a_code_btn:_I,enter_email_for_verification_description:yI,enter_new_password_placeholder:vI,enter_password:wI,enter_password_description:bI,enter_your_password_btn:kI,expired_code:xI,fokus_info_message:SI,forgot_password_cta:AI,forgot_password_description:EI,forgot_password_email_sent:II,forgot_password_link:zI,forgot_password_title:NI,go_back:CI,"invalid-email":"Ogiltig e-postadress",invalid_password:jI,invalid_session_body:$I,invalid_session_title:OI,link_email_click_to_login:BI,link_email_login:TI,link_email_or_enter_code:PI,link_page_body:RI,link_page_headline:LI,logged_in_as:UI,login:VI,login_description:qI,login_description_code:MI,login_description_link:DI,logout:HI,no_use_another:FI,or:KI,password:WI,password_has_been_reset:GI,password_has_been_reset_title:JI,password_reset_subject:ZI,password_reset_title:YI,privacy_policy:XI,redirecting:QI,reenter_new_password_placeholder:e3,register_password_account:t3,resend_code:n3,reset_password_cta:r3,reset_password_description:i3,reset_password_email_click_to_reset:s3,reset_password_email_cta:o3,reset_password_email_reset:a3,reset_password_subject:c3,reset_password_title:l3,send:u3,send_me_a_new_magic_link:d3,sent_code_spam:p3,set_password:f3,sign_in:h3,signup:g3,signup_success:m3,spotify_already_linked_body:_3,spotify_already_linked_cta:y3,spotify_already_linked_step1_body:v3,spotify_already_linked_step1_title:w3,spotify_already_linked_step2_body:b3,spotify_already_linked_step2_title:k3,spotify_already_linked_title:x3,support_info:S3,terms:A3,unverified_email:E3,user_account_does_not_exist:I3,user_not_found:z3,user_not_found_body:N3,user_not_found_cta:C3,validate_code:j3,validate_email_body:$3,validate_email_title:O3,verify_email_click_to_verify:B3,verify_email_subject:T3,verify_email_title:P3,verify_email_verify:R3,verify_your_email:L3,we_sent_a_code_to:U3,welcome:V3,welcome_to_your_account:q3,yes_continue:M3,yes_continue_with:D3,yes_continue_with_existing_account:H3},K3="Wykryto konto",W3="Wykryliśmy, że użytkownik utworzył już konto za pośrednictwem",G3="Logując się, wyrażasz zgodę na nasze",J3="i",Z3="Niezgodność adresu URL wywołania zwrotnego",Y3="Podany adres redirect_uri nie znajduje się na liście dozwolonych adresów URL wywołania zwrotnego.",X3="kontynuować z użytkownikiem",Q3="Kliknij przycisk, aby utworzyć nowe konto z hasłem.",ez="Wpisz kod na stronie {{vendorName}}, aby się zalogować.",tz="Witamy na {{vendorName}}! {{code}} to kod logowania do Twojego konta.",nz="Witamy na {{vendorName}}! {{code}} to kod logowania.",rz="Kod jest ważny przez 30 minut",iz="Potwierdź hasło",sz="Potrzebujesz pomocy?",oz="Skontaktuj się z nami",az="lub kontynuować korzystanie z konta społecznościowego",cz="Kontynuuj {{provider}}",lz="Czy chcesz kontynuować korzystanie z istniejącego konta?",uz="Copyright © 2023 SESAMY. Wszelkie prawa zastrzeżone.",dz="©2023 Sesamy",pz="Wybierz hasło składające się z małych i wielkich liter, cyfr i symboli.",fz="Wprowadź prawidłowy adres e-mail.",hz="Hasła nie są zgodne. Spróbuj ponownie.",gz="Wybierz hasło",mz="Hasło musi mieć co najmniej 8 znaków i zawierać co najmniej jedną małą literę, jedną wielką literę, jedną cyfrę i jeden symbol.",_z="Utwórz nowe konto",yz="Zarejestruj się przy użyciu hasła",vz="Jesteś obecnie zalogowany jako <0>{{email}}</0>",wz="E-mail",bz="Adres e-mail",kz="Twój adres e-mail został zweryfikowany",xz="Teraz wprowadź hasło, aby zalogować się ponownie",Sz="Wiadomość e-mail została wysłana do <0>{{email}}</0> z linkiem weryfikacyjnym. Kliknij łącze, aby zweryfikować swój adres e-mail i ustawić hasło.",Az="Wysłano weryfikację e-mail",Ez="Wprowadź kod",Iz="Wyślemy Ci link weryfikacyjny, aby upewnić się, że posiadasz ten adres e-mail.",zz="Wprowadź nowe hasło",Nz="Wprowadź hasło",Cz="Wprowadź swój adres e-mail i hasło, aby się zalogować.",jz="Wprowadź hasło",$z="Magiczny link wygasł. Kliknij poniższy przycisk, aby otrzymać nowy link w skrzynce odbiorczej.",Oz="Zaktualizowaliśmy sposób logowania. <0>Kliknij tutaj, aby dowiedzieć się więcej.</0>",Bz="Wyślij wiadomość e-mail z resetem hasła",Tz="Kliknij poniższy przycisk, a my wyślemy Ci instrukcje, jak zresetować hasło.",Pz="Wysłano wiadomość e-mail z resetem hasła",Rz="Zapomniałeś hasła?",Lz="Zapomniałeś hasła?",Uz="Wróć",Vz="Nieprawidłowe hasło",qz=`Link jest już nieaktualny.
239
239
 
240
240
  Upewnij się, że otworzyłeś link logowania w tej samej przeglądarce, w której rozpocząłeś logowanie.
241
241
 
242
- Możesz kliknąć poniższy link, aby rozpocząć nowe logowanie.`,Vz="Nieprawidłowy link",qz="Kliknij przycisk, aby się zalogować",Mz="Zaloguj się",Dz="Lub wprowadź kod na stronie {{vendorName}}, aby dokończyć logowanie.",Hz="Wprowadź swój adres e-mail, aby odblokować ten program na {{service}}",Fz="Połącz swoje konto z {{service}}",Kz="Jesteś zalogowany jako",Wz="Logowanie",Gz="Wprowadź swój adres e-mail, aby się zalogować.",Jz="Wprowadź swój adres e-mail, a my wyślemy Ci kod logowania.",Zz="Wprowadź swój adres e-mail, a my wyślemy Ci link do logowania.",Yz="Wylogowanie",Xz="Nie, chcę użyć innego konta",Qz="lub",e6="Hasło",t6="Hasło zostało zresetowane",n6="Sukces",r6="Zmień hasło do konta {{vendorName}} ",i6="Zmiana hasła do konta {{vendorName}} ",s6="Polityka prywatności",o6="Przekierowanie",a6="Potwierdź hasło",c6="Zarejestruj nowe hasło",l6="Wyślij ponownie kod",u6="Zmiana hasła",d6="Wprowadź poniżej nowe hasło do konta e-mail: ",p6="Kliknij przycisk, aby zresetować hasło",f6="Kliknij przycisk, aby zresetować hasło",h6="Zmień hasło",g6="Zmiana hasła do konta {{vendorName}} ",m6="Resetowanie hasła",_6="Wyślij",y6="Wyślij mi nowy magiczny link",v6="Pamiętaj, aby sprawdzić folder spamu, jeśli wiadomość e-mail nie dotarła.",w6="Ustaw hasło",b6="Zaloguj się",k6="Rejestracja",x6="Rejestracja zakończona sukcesem",S6="Wygląda na to, że Twoje konto Spotify jest obecnie połączone z innym kontem Sesamy. Ale nie martw się, jesteśmy tutaj, aby poprowadzić Cię przez proces, aby to naprawić.",A6="Przejdź do strony dostępu do treści Spotify",E6='Zacznijmy od odłączenia konta Spotify. Kliknij poniższy przycisk, aby przejść do strony dostępu do treści Spotify. Po zalogowaniu się na swoje konto Spotify, znajdź Sesamy na liście połączonych platform. Kliknij "Odłącz" obok logo Sesamy.',I6="Krok 1: Odłącz swoje konto Spotify",z6="Po pomyślnym odłączeniu konta Spotify możesz ponownie połączyć je z Sesamy. Wystarczy powtórzyć poprzednie kroki, które doprowadziły Cię do tej strony.",N6="Krok 2: Połącz ponownie swoje konto Spotify z Sesamy",C6="Ups! Twoje konto Spotify jest już połączone",j6="Jeśli masz pytania lub potrzebujesz pomocy, skontaktuj się z nami",$6="Zasady i warunki",O6="Twój adres e-mail wymaga weryfikacji. Wysłaliśmy nową wiadomość e-mail na Twoją skrzynkę odbiorczą",B6="Konto użytkownika nie istnieje",T6="Konto użytkownika nie istnieje",P6="Nie mogliśmy znaleźć użytkownika o podanym adresie e-mail. Spróbuj ponownie.",R6="Spróbuj ponownie.",L6="Sprawdź poprawność kodu",U6="Sprawdź swoją skrzynkę odbiorczą, aby uzyskać instrukcje dotyczące weryfikacji wiadomości e-mail.",V6="Zarejestrowany",q6="Kliknij przycisk, aby zweryfikować swój adres e-mail",M6="Potwierdź swój adres e-mail",D6="Potwierdź swój adres e-mail",H6="Zweryfikuj konto",F6="Zweryfikuj swój adres e-mail",K6="Sprawdź swoją skrzynkę e-mail pod adresem <0>{{email}}</0> i wprowadź sześciocyfrowy kod, który wysłaliśmy.",W6="Witamy",G6="Witamy na koncie {{vendorName}}!",J6="Kontynuuj korzystanie z tego konta",Z6="Tak, kontynuuj {{text}}",Y6="Tak, kontynuuj korzystanie z istniejącego konta",X6={"Server error: Invalid code":"Nieprawidłowy kod","Wrong email or verification code":{"":"Nieprawidłowy adres e-mail lub kod weryfikacyjny."},account_detected:H3,account_with_sso_provider:F3,agree_to:K3,and:W3,callback_url_mismatch:G3,callback_url_not_allowed:J3,check_email_title:Z3,click_to_sign_up_description:Y3,code_email_enter_code:X3,code_email_subject:Q3,code_email_title:ez,code_valid_30_minutes:tz,confirm_password:nz,contact_support:rz,contact_us:iz,continue:"Kontynuuj",continue_social_login:sz,continue_with:oz,continue_with_sso_provider_headline:az,copyright:cz,copyright_sesamy:lz,create_account_description:uz,create_account_email_invalid:dz,create_account_passwords_didnt_match:pz,create_account_title:fz,create_account_weak_password:hz,create_new_account_link:gz,create_password_account_title:mz,currently_logged_in_as:_z,email:yz,email_placeholder:vz,email_validated:wz,email_validated_cta:bz,email_verification_for_signup_sent_description:kz,email_verification_for_signup_sent_title:xz,enter_a_code_btn:Sz,enter_email_for_verification_description:Az,enter_new_password_placeholder:Ez,enter_password:Iz,enter_password_description:zz,enter_your_password_btn:Nz,expired_code:Cz,fokus_info_message:jz,forgot_password_cta:$z,forgot_password_description:Oz,forgot_password_email_sent:Bz,forgot_password_link:Tz,forgot_password_title:Pz,go_back:Rz,"invalid-email":"Nieprawidłowy adres e-mail",invalid_password:Lz,invalid_session_body:Uz,invalid_session_title:Vz,link_email_click_to_login:qz,link_email_login:Mz,link_email_or_enter_code:Dz,link_page_body:Hz,link_page_headline:Fz,logged_in_as:Kz,login:Wz,login_description:Gz,login_description_code:Jz,login_description_link:Zz,logout:Yz,no_use_another:Xz,or:Qz,password:e6,password_has_been_reset:t6,password_has_been_reset_title:n6,password_reset_subject:r6,password_reset_title:i6,privacy_policy:s6,redirecting:o6,reenter_new_password_placeholder:a6,register_password_account:c6,resend_code:l6,reset_password_cta:u6,reset_password_description:d6,reset_password_email_click_to_reset:p6,reset_password_email_cta:f6,reset_password_email_reset:h6,reset_password_subject:g6,reset_password_title:m6,send:_6,send_me_a_new_magic_link:y6,sent_code_spam:v6,set_password:w6,sign_in:b6,signup:k6,signup_success:x6,spotify_already_linked_body:S6,spotify_already_linked_cta:A6,spotify_already_linked_step1_body:E6,spotify_already_linked_step1_title:I6,spotify_already_linked_step2_body:z6,spotify_already_linked_step2_title:N6,spotify_already_linked_title:C6,support_info:j6,terms:$6,unverified_email:O6,user_account_does_not_exist:B6,user_not_found:T6,user_not_found_body:P6,user_not_found_cta:R6,validate_code:L6,validate_email_body:U6,validate_email_title:V6,verify_email_click_to_verify:q6,verify_email_subject:M6,verify_email_title:D6,verify_email_verify:H6,verify_your_email:F6,we_sent_a_code_to:K6,welcome:W6,welcome_to_your_account:G6,yes_continue:J6,yes_continue_with:Z6,yes_continue_with_existing_account:Y6},Q6="Zjištěný účet",eN="Zjistili jsme, že jste si již vytvořili účet prostřednictvím",tN="Přihlášením souhlasíte s našimi",nN="a",rN="Neshoda adresy URL zpětného volání",iN="Zadané redirect_uri není v seznamu povolených zpětných adres URL.",sN="pokračovat s uživatelem",oN="Klikněte na tlačítko pro vytvoření nového účtu s heslem.",aN="Pro dokončení přihlášení zadejte kód na adrese {{vendorName}}.",cN="Vítejte na {{vendorName}}! {{code}} je přihlašovací kód.",lN="Vítejte na {{vendorName}}! {{code}} je přihlašovací kód.",uN="Kód je platný po dobu 30 minut",dN="Potvrzení hesla",pN="Potřebujete pomoc?",fN="Kontaktujte nás",hN="nebo pokračovat v sociálním účtu",gN="Pokračovat s {{provider}}",mN="Chcete pokračovat ve svém stávajícím účtu?",_N="Copyright © 2023 SESAMY. Všechna práva vyhrazena.",yN="©2023 Sesamy",vN="Zvolte heslo složené z velkých a malých písmen, číslic a symbolů.",wN="Zadejte prosím platnou e-mailovou adresu.",bN="Hesla se neshodovala. Zkuste to znovu.",kN="Zvolte heslo",xN="Heslo musí mít alespoň 8 znaků a obsahovat alespoň jedno malé písmeno, jedno velké písmeno, jednu číslici a jeden symbol.",SN="Vytvořit nový účet",AN="Zaregistrujte se pomocí hesla",EN="V současné době jste přihlášeni jako <0>{{email}}</0>",IN="E-mail",zN="E-mailová adresa",NN="Vaše e-mailová adresa byla ověřena",CN="Nyní zadejte své heslo a znovu se přihlaste",jN="E-mail byl odeslán na adresu <0>{{email}}</0> s ověřovacím odkazem. Kliknutím na odkaz ověřte svou e-mailovou adresu a nastavte heslo.",$N="Ověření e-mailem odesláno",ON="Zadejte kód",BN="Pošleme vám ověřovací odkaz, abychom se ujistili, že tuto e-mailovou adresu vlastníte.",TN="Zadejte nové heslo",PN="Zadejte heslo",RN="Pro přihlášení zadejte svou e-mailovou adresu a heslo.",LN="Zadejte své heslo",UN="Platnost kouzelného odkazu vypršela. Klikněte na tlačítko níže, abyste obdrželi nový odkaz do své e-mailové schránky.",VN="Ahoj! Aktualizovali jsme naše přihlašovací prostředí. <0>Klikněte sem a dozvíte se o něm více.</0>",qN="Odeslání e-mailu pro obnovení hesla",MN="Klikněte na tlačítko níže a my vám zašleme pokyny k obnovení hesla.",DN="Odeslání e-mailu s žádostí o obnovení hesla",HN="Zapomněli jste heslo?",FN="Zapomněli jste heslo?",KN="Vrátit se zpět",WN="Neplatné heslo",GN=`Odkaz již není platný.
242
+ Możesz kliknąć poniższy link, aby rozpocząć nowe logowanie.`,Mz="Nieprawidłowy link",Dz="Kliknij przycisk, aby się zalogować",Hz="Zaloguj się",Fz="Lub wprowadź kod na stronie {{vendorName}}, aby dokończyć logowanie.",Kz="Wprowadź swój adres e-mail, aby odblokować ten program na {{service}}",Wz="Połącz swoje konto z {{service}}",Gz="Jesteś zalogowany jako",Jz="Logowanie",Zz="Wprowadź swój adres e-mail, aby się zalogować.",Yz="Wprowadź swój adres e-mail, a my wyślemy Ci kod logowania.",Xz="Wprowadź swój adres e-mail, a my wyślemy Ci link do logowania.",Qz="Wylogowanie",e6="Nie, chcę użyć innego konta",t6="lub",n6="Hasło",r6="Hasło zostało zresetowane",i6="Sukces",s6="Zmień hasło do konta {{vendorName}} ",o6="Zmiana hasła do konta {{vendorName}} ",a6="Polityka prywatności",c6="Przekierowanie",l6="Potwierdź hasło",u6="Zarejestruj nowe hasło",d6="Wyślij ponownie kod",p6="Zmiana hasła",f6="Wprowadź poniżej nowe hasło do konta e-mail: ",h6="Kliknij przycisk, aby zresetować hasło",g6="Kliknij przycisk, aby zresetować hasło",m6="Zmień hasło",_6="Zmiana hasła do konta {{vendorName}} ",y6="Resetowanie hasła",v6="Wyślij",w6="Wyślij mi nowy magiczny link",b6="Pamiętaj, aby sprawdzić folder spamu, jeśli wiadomość e-mail nie dotarła.",k6="Ustaw hasło",x6="Zaloguj się",S6="Rejestracja",A6="Rejestracja zakończona sukcesem",E6="Wygląda na to, że Twoje konto Spotify jest obecnie połączone z innym kontem Sesamy. Ale nie martw się, jesteśmy tutaj, aby poprowadzić Cię przez proces, aby to naprawić.",I6="Przejdź do strony dostępu do treści Spotify",z6='Zacznijmy od odłączenia konta Spotify. Kliknij poniższy przycisk, aby przejść do strony dostępu do treści Spotify. Po zalogowaniu się na swoje konto Spotify, znajdź Sesamy na liście połączonych platform. Kliknij "Odłącz" obok logo Sesamy.',N6="Krok 1: Odłącz swoje konto Spotify",C6="Po pomyślnym odłączeniu konta Spotify możesz ponownie połączyć je z Sesamy. Wystarczy powtórzyć poprzednie kroki, które doprowadziły Cię do tej strony.",j6="Krok 2: Połącz ponownie swoje konto Spotify z Sesamy",$6="Ups! Twoje konto Spotify jest już połączone",O6="Jeśli masz pytania lub potrzebujesz pomocy, skontaktuj się z nami",B6="Zasady i warunki",T6="Twój adres e-mail wymaga weryfikacji. Wysłaliśmy nową wiadomość e-mail na Twoją skrzynkę odbiorczą",P6="Konto użytkownika nie istnieje",R6="Konto użytkownika nie istnieje",L6="Nie mogliśmy znaleźć użytkownika o podanym adresie e-mail. Spróbuj ponownie.",U6="Spróbuj ponownie.",V6="Sprawdź poprawność kodu",q6="Sprawdź swoją skrzynkę odbiorczą, aby uzyskać instrukcje dotyczące weryfikacji wiadomości e-mail.",M6="Zarejestrowany",D6="Kliknij przycisk, aby zweryfikować swój adres e-mail",H6="Potwierdź swój adres e-mail",F6="Potwierdź swój adres e-mail",K6="Zweryfikuj konto",W6="Zweryfikuj swój adres e-mail",G6="Sprawdź swoją skrzynkę e-mail pod adresem <0>{{email}}</0> i wprowadź sześciocyfrowy kod, który wysłaliśmy.",J6="Witamy",Z6="Witamy na koncie {{vendorName}}!",Y6="Kontynuuj korzystanie z tego konta",X6="Tak, kontynuuj {{text}}",Q6="Tak, kontynuuj korzystanie z istniejącego konta",eN={"Server error: Invalid code":"Nieprawidłowy kod","Wrong email or verification code":{"":"Nieprawidłowy adres e-mail lub kod weryfikacyjny."},account_detected:K3,account_with_sso_provider:W3,agree_to:G3,and:J3,callback_url_mismatch:Z3,callback_url_not_allowed:Y3,check_email_title:X3,click_to_sign_up_description:Q3,code_email_enter_code:ez,code_email_subject:tz,code_email_title:nz,code_valid_30_minutes:rz,confirm_password:iz,contact_support:sz,contact_us:oz,continue:"Kontynuuj",continue_social_login:az,continue_with:cz,continue_with_sso_provider_headline:lz,copyright:uz,copyright_sesamy:dz,create_account_description:pz,create_account_email_invalid:fz,create_account_passwords_didnt_match:hz,create_account_title:gz,create_account_weak_password:mz,create_new_account_link:_z,create_password_account_title:yz,currently_logged_in_as:vz,email:wz,email_placeholder:bz,email_validated:kz,email_validated_cta:xz,email_verification_for_signup_sent_description:Sz,email_verification_for_signup_sent_title:Az,enter_a_code_btn:Ez,enter_email_for_verification_description:Iz,enter_new_password_placeholder:zz,enter_password:Nz,enter_password_description:Cz,enter_your_password_btn:jz,expired_code:$z,fokus_info_message:Oz,forgot_password_cta:Bz,forgot_password_description:Tz,forgot_password_email_sent:Pz,forgot_password_link:Rz,forgot_password_title:Lz,go_back:Uz,"invalid-email":"Nieprawidłowy adres e-mail",invalid_password:Vz,invalid_session_body:qz,invalid_session_title:Mz,link_email_click_to_login:Dz,link_email_login:Hz,link_email_or_enter_code:Fz,link_page_body:Kz,link_page_headline:Wz,logged_in_as:Gz,login:Jz,login_description:Zz,login_description_code:Yz,login_description_link:Xz,logout:Qz,no_use_another:e6,or:t6,password:n6,password_has_been_reset:r6,password_has_been_reset_title:i6,password_reset_subject:s6,password_reset_title:o6,privacy_policy:a6,redirecting:c6,reenter_new_password_placeholder:l6,register_password_account:u6,resend_code:d6,reset_password_cta:p6,reset_password_description:f6,reset_password_email_click_to_reset:h6,reset_password_email_cta:g6,reset_password_email_reset:m6,reset_password_subject:_6,reset_password_title:y6,send:v6,send_me_a_new_magic_link:w6,sent_code_spam:b6,set_password:k6,sign_in:x6,signup:S6,signup_success:A6,spotify_already_linked_body:E6,spotify_already_linked_cta:I6,spotify_already_linked_step1_body:z6,spotify_already_linked_step1_title:N6,spotify_already_linked_step2_body:C6,spotify_already_linked_step2_title:j6,spotify_already_linked_title:$6,support_info:O6,terms:B6,unverified_email:T6,user_account_does_not_exist:P6,user_not_found:R6,user_not_found_body:L6,user_not_found_cta:U6,validate_code:V6,validate_email_body:q6,validate_email_title:M6,verify_email_click_to_verify:D6,verify_email_subject:H6,verify_email_title:F6,verify_email_verify:K6,verify_your_email:W6,we_sent_a_code_to:G6,welcome:J6,welcome_to_your_account:Z6,yes_continue:Y6,yes_continue_with:X6,yes_continue_with_existing_account:Q6},tN="Zjištěný účet",nN="Zjistili jsme, že jste si již vytvořili účet prostřednictvím",rN="Přihlášením souhlasíte s našimi",iN="a",sN="Neshoda adresy URL zpětného volání",oN="Zadané redirect_uri není v seznamu povolených zpětných adres URL.",aN="pokračovat s uživatelem",cN="Klikněte na tlačítko pro vytvoření nového účtu s heslem.",lN="Pro dokončení přihlášení zadejte kód na adrese {{vendorName}}.",uN="Vítejte na {{vendorName}}! {{code}} je přihlašovací kód.",dN="Vítejte na {{vendorName}}! {{code}} je přihlašovací kód.",pN="Kód je platný po dobu 30 minut",fN="Potvrzení hesla",hN="Potřebujete pomoc?",gN="Kontaktujte nás",mN="nebo pokračovat v sociálním účtu",_N="Pokračovat s {{provider}}",yN="Chcete pokračovat ve svém stávajícím účtu?",vN="Copyright © 2023 SESAMY. Všechna práva vyhrazena.",wN="©2023 Sesamy",bN="Zvolte heslo složené z velkých a malých písmen, číslic a symbolů.",kN="Zadejte prosím platnou e-mailovou adresu.",xN="Hesla se neshodovala. Zkuste to znovu.",SN="Zvolte heslo",AN="Heslo musí mít alespoň 8 znaků a obsahovat alespoň jedno malé písmeno, jedno velké písmeno, jednu číslici a jeden symbol.",EN="Vytvořit nový účet",IN="Zaregistrujte se pomocí hesla",zN="V současné době jste přihlášeni jako <0>{{email}}</0>",NN="E-mail",CN="E-mailová adresa",jN="Vaše e-mailová adresa byla ověřena",$N="Nyní zadejte své heslo a znovu se přihlaste",ON="E-mail byl odeslán na adresu <0>{{email}}</0> s ověřovacím odkazem. Kliknutím na odkaz ověřte svou e-mailovou adresu a nastavte heslo.",BN="Ověření e-mailem odesláno",TN="Zadejte kód",PN="Pošleme vám ověřovací odkaz, abychom se ujistili, že tuto e-mailovou adresu vlastníte.",RN="Zadejte nové heslo",LN="Zadejte heslo",UN="Pro přihlášení zadejte svou e-mailovou adresu a heslo.",VN="Zadejte své heslo",qN="Platnost kouzelného odkazu vypršela. Klikněte na tlačítko níže, abyste obdrželi nový odkaz do své e-mailové schránky.",MN="Ahoj! Aktualizovali jsme naše přihlašovací prostředí. <0>Klikněte sem a dozvíte se o něm více.</0>",DN="Odeslání e-mailu pro obnovení hesla",HN="Klikněte na tlačítko níže a my vám zašleme pokyny k obnovení hesla.",FN="Odeslání e-mailu s žádostí o obnovení hesla",KN="Zapomněli jste heslo?",WN="Zapomněli jste heslo?",GN="Vrátit se zpět",JN="Neplatné heslo",ZN=`Odkaz již není platný.
243
243
 
244
244
  Ujistěte se, že jste odkaz na přihlášení otevřeli ve stejném prohlížeči, ve kterém jste přihlášení zahájili.
245
245
 
246
- Kliknutím na odkaz níže můžete zahájit nové přihlášení.`,JN="Neplatný odkaz",ZN="Kliknutím na tlačítko se přihlásíte",YN="Přihlášení",XN="Nebo zadejte kód na adrese {{vendorName}} a dokončete přihlášení.",QN="Zadejte svou e-mailovou adresu pro odemknutí tohoto pořadu na {{service}}",eC="Propojte svůj účet s {{service}}",tC="Jste přihlášeni jako",nC="Přihlášení",rC="Pro přihlášení zadejte svou e-mailovou adresu.",iC="Zadejte svou e-mailovou adresu a my vám zašleme přihlašovací kód.",sC="Zadejte svou e-mailovou adresu a my vám zašleme odkaz pro přihlášení.",oC="Odhlášení",aC="Ne, chci použít jiný účet",cC="nebo",lC="Heslo",uC="Heslo bylo resetováno",dC="Úspěch",pC="Změna hesla k účtu {{vendorName}} ",fC="Změna hesla k účtu {{vendorName}} ",hC="Zásady ochrany osobních údajů",gC="Přesměrování",mC="Potvrzení hesla",_C="Registrace nového hesla",yC="Opětovné odeslání kódu",vC="Změna hesla",wC="Níže zadejte nové heslo k e-mailovému účtu: ",bC="Kliknutím na tlačítko obnovíte své heslo",kC="Kliknutím na tlačítko obnovíte své heslo",xC="Obnovení hesla",SC="Změna hesla k účtu {{vendorName}} ",AC="Obnovení hesla",EC="Odeslat",IC="Pošlete mi nový kouzelný odkaz",zC="Pokud e-mail nedorazil, nezapomeňte zkontrolovat složku nevyžádané pošty.",NC="Nastavení hesla",CC="Přihlásit se",jC="Registrace",$C="Úspěšná registrace",OC="Zdá se, že váš účet Spotify je v současné době propojen s jiným účtem Sesamy. Ale nebojte se, jsme tu, abychom vás provedli procesem, jak to napravit.",BC="Přejděte na stránku Spotify pro přístup k obsahu",TC='Začněme odpojením účtu Spotify. Kliknutím na tlačítko níže přejděte na stránku přístupu k obsahu služby Spotify. Po přihlášení k účtu Spotify najděte v seznamu připojených platforem položku Sesamy. Klikněte na tlačítko "Unlink" vedle loga Sesamy.',PC="Krok 1: Odpojení účtu Spotify",RC="Po úspěšném odpojení účtu Spotify jej můžete znovu propojit se službou Sesamy. Stačí zopakovat předchozí kroky, které vás přivedly na tuto stránku.",LC="Krok 2: Propojení účtu Spotify s aplikací Sesamy",UC="Ups! Váš účet Spotify je již propojen",VC="Pokud máte dotazy nebo potřebujete pomoc, můžete se obrátit na náš tým podpory.",qC="Podmínky a pravidla",MC="Vaši e-mailovou adresu je třeba ověřit. Do vaší e-mailové schránky jsme odeslali nový e-mail.",DC="Uživatelský účet neexistuje",HC="Uživatelský účet neexistuje",FC="Nepodařilo se nám najít uživatele se zadanou e-mailovou adresou. Zkuste to prosím znovu.",KC="Zkuste to znovu.",WC="Ověření kódu",GC="Pokyny k ověření e-mailu najdete ve své e-mailové schránce.",JC="Zaregistrovali jste se",ZC="Klikněte na tlačítko pro ověření e-mailové adresy",YC="Ověřte svou e-mailovou adresu",XC="Ověřte svou e-mailovou adresu",QC="Ověření účtu",ej="Ověření e-mailu",tj="Zkontrolujte si prosím svůj e-mail na adrese <0>{{email}}</0> a zadejte šestimístný kód, který jsme vám zaslali.",nj="Vítejte na",rj="Vítejte na svém účtu {{vendorName}}!",ij="Pokračujte s tímto účtem",sj="Ano, pokračujte {{text}}",oj="Ano, pokračujte ve stávajícím účtu",aj={"Server error: Invalid code":"Neplatný kód","Wrong email or verification code":{"":"Špatný e-mail nebo ověřovací kód."},account_detected:Q6,account_with_sso_provider:eN,agree_to:tN,and:nN,callback_url_mismatch:rN,callback_url_not_allowed:iN,check_email_title:sN,click_to_sign_up_description:oN,code_email_enter_code:aN,code_email_subject:cN,code_email_title:lN,code_valid_30_minutes:uN,confirm_password:dN,contact_support:pN,contact_us:fN,continue:"Pokračovat",continue_social_login:hN,continue_with:gN,continue_with_sso_provider_headline:mN,copyright:_N,copyright_sesamy:yN,create_account_description:vN,create_account_email_invalid:wN,create_account_passwords_didnt_match:bN,create_account_title:kN,create_account_weak_password:xN,create_new_account_link:SN,create_password_account_title:AN,currently_logged_in_as:EN,email:IN,email_placeholder:zN,email_validated:NN,email_validated_cta:CN,email_verification_for_signup_sent_description:jN,email_verification_for_signup_sent_title:$N,enter_a_code_btn:ON,enter_email_for_verification_description:BN,enter_new_password_placeholder:TN,enter_password:PN,enter_password_description:RN,enter_your_password_btn:LN,expired_code:UN,fokus_info_message:VN,forgot_password_cta:qN,forgot_password_description:MN,forgot_password_email_sent:DN,forgot_password_link:HN,forgot_password_title:FN,go_back:KN,"invalid-email":"Neplatný e-mail",invalid_password:WN,invalid_session_body:GN,invalid_session_title:JN,link_email_click_to_login:ZN,link_email_login:YN,link_email_or_enter_code:XN,link_page_body:QN,link_page_headline:eC,logged_in_as:tC,login:nC,login_description:rC,login_description_code:iC,login_description_link:sC,logout:oC,no_use_another:aC,or:cC,password:lC,password_has_been_reset:uC,password_has_been_reset_title:dC,password_reset_subject:pC,password_reset_title:fC,privacy_policy:hC,redirecting:gC,reenter_new_password_placeholder:mC,register_password_account:_C,resend_code:yC,reset_password_cta:vC,reset_password_description:wC,reset_password_email_click_to_reset:bC,reset_password_email_cta:kC,reset_password_email_reset:xC,reset_password_subject:SC,reset_password_title:AC,send:EC,send_me_a_new_magic_link:IC,sent_code_spam:zC,set_password:NC,sign_in:CC,signup:jC,signup_success:$C,spotify_already_linked_body:OC,spotify_already_linked_cta:BC,spotify_already_linked_step1_body:TC,spotify_already_linked_step1_title:PC,spotify_already_linked_step2_body:RC,spotify_already_linked_step2_title:LC,spotify_already_linked_title:UC,support_info:VC,terms:qC,unverified_email:MC,user_account_does_not_exist:DC,user_not_found:HC,user_not_found_body:FC,user_not_found_cta:KC,validate_code:WC,validate_email_body:GC,validate_email_title:JC,verify_email_click_to_verify:ZC,verify_email_subject:YC,verify_email_title:XC,verify_email_verify:QC,verify_your_email:ej,we_sent_a_code_to:tj,welcome:nj,welcome_to_your_account:rj,yes_continue:ij,yes_continue_with:sj,yes_continue_with_existing_account:oj},cj="Tili havaittu",lj="Olemme havainneet, että olet jo luonut tilin kautta",uj="Kirjautumalla sisään hyväksyt",dj="ja",pj="Takaisinkutsun URL-osoite ei vastaa toisiaan",fj="Annettu redirect_uri ei ole sallittujen takaisinsoitto-URL-osoitteiden luettelossa.",hj="jatka käyttäjän kanssa",gj="Klikkaa painiketta luodaksesi uuden salasanatilin.",mj="Kirjoita koodi osoitteessa {{vendorName}} kirjautumisen loppuun saattamiseksi.",_j="Tervetuloa osoitteeseen {{vendorName}}! {{code}} on kirjautumiskoodi.",yj="Tervetuloa osoitteeseen {{vendorName}}! {{code}} on kirjautumiskoodi.",vj="Koodi on voimassa 30 minuuttia",wj="Vahvista salasana",bj="Tarvitsetko apua?",kj="Ota yhteyttä",xj="tai jatka sosiaalisella tilillä",Sj="Jatka {{provider}}",Aj="Haluatko jatkaa olemassa olevalla tililläsi?",Ej="Copyright © 2023 SESAMY. Kaikki oikeudet pidätetään.",Ij="©2023 Sesamy",zj="Valitse salasana, jossa on isoja ja pieniä kirjaimia, numeroita ja symboleja.",Nj="Kirjoita voimassa oleva sähköpostiosoite.",Cj="Salasanat eivät vastanneet toisiaan. Yritä uudelleen.",jj="Valitse salasana",$j="Salasanan on oltava vähintään 8 merkkiä pitkä ja sisällettävä vähintään yksi pieni kirjain, yksi iso kirjain, yksi numero ja yksi symboli.",Oj="Luo uusi tili",Bj="Rekisteröidy salasanalla",Tj="Olet tällä hetkellä kirjautuneena sisään nimellä <0>{{email}}</0>",Pj="Sähköposti",Rj="Sähköpostiosoite",Lj="Sähköpostiosoitteesi on vahvistettu",Uj="Kirjoita nyt salasanasi kirjautuaksesi uudelleen",Vj="Sähköposti on lähetetty osoitteeseen <0>{{email}}</0> jossa on vahvistuslinkki. Klikkaa linkkiä vahvistaaksesi sähköpostiosoitteesi ja asettaaksesi salasanan.",qj="Sähköpostivarmennus lähetetty",Mj="Syötä koodi",Dj="Lähetämme sinulle vahvistuslinkin varmistaaksemme, että omistat tämän sähköpostiosoitteen.",Hj="Anna uusi salasana",Fj="Anna salasana",Kj="Anna sähköpostiosoitteesi ja salasanasi kirjautuaksesi sisään.",Wj="Syötä salasanasi",Gj="Taikalinkki on vanhentunut. Klikkaa alla olevaa painiketta saadaksesi uuden linkin sähköpostiisi.",Jj="Hei! Päivitimme kirjautumiskokemuksemme. <0>Klikkaa tästä saadaksesi lisätietoja siitä.</0>",Zj="Lähetä salasanan palautussähköposti",Yj="Napsauta alla olevaa painiketta, niin lähetämme ohjeet salasanasi palauttamiseen.",Xj="Salasanan palautussähköposti lähetetty",Qj="Unohditko salasanan?",e$="Unohditko salasanan?",t$="Palaa takaisin",n$="Virheellinen salasana",r$=`Linkki ei ole enää voimassa.
246
+ Kliknutím na odkaz níže můžete zahájit nové přihlášení.`,YN="Neplatný odkaz",XN="Kliknutím na tlačítko se přihlásíte",QN="Přihlášení",eC="Nebo zadejte kód na adrese {{vendorName}} a dokončete přihlášení.",tC="Zadejte svou e-mailovou adresu pro odemknutí tohoto pořadu na {{service}}",nC="Propojte svůj účet s {{service}}",rC="Jste přihlášeni jako",iC="Přihlášení",sC="Pro přihlášení zadejte svou e-mailovou adresu.",oC="Zadejte svou e-mailovou adresu a my vám zašleme přihlašovací kód.",aC="Zadejte svou e-mailovou adresu a my vám zašleme odkaz pro přihlášení.",cC="Odhlášení",lC="Ne, chci použít jiný účet",uC="nebo",dC="Heslo",pC="Heslo bylo resetováno",fC="Úspěch",hC="Změna hesla k účtu {{vendorName}} ",gC="Změna hesla k účtu {{vendorName}} ",mC="Zásady ochrany osobních údajů",_C="Přesměrování",yC="Potvrzení hesla",vC="Registrace nového hesla",wC="Opětovné odeslání kódu",bC="Změna hesla",kC="Níže zadejte nové heslo k e-mailovému účtu: ",xC="Kliknutím na tlačítko obnovíte své heslo",SC="Kliknutím na tlačítko obnovíte své heslo",AC="Obnovení hesla",EC="Změna hesla k účtu {{vendorName}} ",IC="Obnovení hesla",zC="Odeslat",NC="Pošlete mi nový kouzelný odkaz",CC="Pokud e-mail nedorazil, nezapomeňte zkontrolovat složku nevyžádané pošty.",jC="Nastavení hesla",$C="Přihlásit se",OC="Registrace",BC="Úspěšná registrace",TC="Zdá se, že váš účet Spotify je v současné době propojen s jiným účtem Sesamy. Ale nebojte se, jsme tu, abychom vás provedli procesem, jak to napravit.",PC="Přejděte na stránku Spotify pro přístup k obsahu",RC='Začněme odpojením účtu Spotify. Kliknutím na tlačítko níže přejděte na stránku přístupu k obsahu služby Spotify. Po přihlášení k účtu Spotify najděte v seznamu připojených platforem položku Sesamy. Klikněte na tlačítko "Unlink" vedle loga Sesamy.',LC="Krok 1: Odpojení účtu Spotify",UC="Po úspěšném odpojení účtu Spotify jej můžete znovu propojit se službou Sesamy. Stačí zopakovat předchozí kroky, které vás přivedly na tuto stránku.",VC="Krok 2: Propojení účtu Spotify s aplikací Sesamy",qC="Ups! Váš účet Spotify je již propojen",MC="Pokud máte dotazy nebo potřebujete pomoc, můžete se obrátit na náš tým podpory.",DC="Podmínky a pravidla",HC="Vaši e-mailovou adresu je třeba ověřit. Do vaší e-mailové schránky jsme odeslali nový e-mail.",FC="Uživatelský účet neexistuje",KC="Uživatelský účet neexistuje",WC="Nepodařilo se nám najít uživatele se zadanou e-mailovou adresou. Zkuste to prosím znovu.",GC="Zkuste to znovu.",JC="Ověření kódu",ZC="Pokyny k ověření e-mailu najdete ve své e-mailové schránce.",YC="Zaregistrovali jste se",XC="Klikněte na tlačítko pro ověření e-mailové adresy",QC="Ověřte svou e-mailovou adresu",ej="Ověřte svou e-mailovou adresu",tj="Ověření účtu",nj="Ověření e-mailu",rj="Zkontrolujte si prosím svůj e-mail na adrese <0>{{email}}</0> a zadejte šestimístný kód, který jsme vám zaslali.",ij="Vítejte na",sj="Vítejte na svém účtu {{vendorName}}!",oj="Pokračujte s tímto účtem",aj="Ano, pokračujte {{text}}",cj="Ano, pokračujte ve stávajícím účtu",lj={"Server error: Invalid code":"Neplatný kód","Wrong email or verification code":{"":"Špatný e-mail nebo ověřovací kód."},account_detected:tN,account_with_sso_provider:nN,agree_to:rN,and:iN,callback_url_mismatch:sN,callback_url_not_allowed:oN,check_email_title:aN,click_to_sign_up_description:cN,code_email_enter_code:lN,code_email_subject:uN,code_email_title:dN,code_valid_30_minutes:pN,confirm_password:fN,contact_support:hN,contact_us:gN,continue:"Pokračovat",continue_social_login:mN,continue_with:_N,continue_with_sso_provider_headline:yN,copyright:vN,copyright_sesamy:wN,create_account_description:bN,create_account_email_invalid:kN,create_account_passwords_didnt_match:xN,create_account_title:SN,create_account_weak_password:AN,create_new_account_link:EN,create_password_account_title:IN,currently_logged_in_as:zN,email:NN,email_placeholder:CN,email_validated:jN,email_validated_cta:$N,email_verification_for_signup_sent_description:ON,email_verification_for_signup_sent_title:BN,enter_a_code_btn:TN,enter_email_for_verification_description:PN,enter_new_password_placeholder:RN,enter_password:LN,enter_password_description:UN,enter_your_password_btn:VN,expired_code:qN,fokus_info_message:MN,forgot_password_cta:DN,forgot_password_description:HN,forgot_password_email_sent:FN,forgot_password_link:KN,forgot_password_title:WN,go_back:GN,"invalid-email":"Neplatný e-mail",invalid_password:JN,invalid_session_body:ZN,invalid_session_title:YN,link_email_click_to_login:XN,link_email_login:QN,link_email_or_enter_code:eC,link_page_body:tC,link_page_headline:nC,logged_in_as:rC,login:iC,login_description:sC,login_description_code:oC,login_description_link:aC,logout:cC,no_use_another:lC,or:uC,password:dC,password_has_been_reset:pC,password_has_been_reset_title:fC,password_reset_subject:hC,password_reset_title:gC,privacy_policy:mC,redirecting:_C,reenter_new_password_placeholder:yC,register_password_account:vC,resend_code:wC,reset_password_cta:bC,reset_password_description:kC,reset_password_email_click_to_reset:xC,reset_password_email_cta:SC,reset_password_email_reset:AC,reset_password_subject:EC,reset_password_title:IC,send:zC,send_me_a_new_magic_link:NC,sent_code_spam:CC,set_password:jC,sign_in:$C,signup:OC,signup_success:BC,spotify_already_linked_body:TC,spotify_already_linked_cta:PC,spotify_already_linked_step1_body:RC,spotify_already_linked_step1_title:LC,spotify_already_linked_step2_body:UC,spotify_already_linked_step2_title:VC,spotify_already_linked_title:qC,support_info:MC,terms:DC,unverified_email:HC,user_account_does_not_exist:FC,user_not_found:KC,user_not_found_body:WC,user_not_found_cta:GC,validate_code:JC,validate_email_body:ZC,validate_email_title:YC,verify_email_click_to_verify:XC,verify_email_subject:QC,verify_email_title:ej,verify_email_verify:tj,verify_your_email:nj,we_sent_a_code_to:rj,welcome:ij,welcome_to_your_account:sj,yes_continue:oj,yes_continue_with:aj,yes_continue_with_existing_account:cj},uj="Tili havaittu",dj="Olemme havainneet, että olet jo luonut tilin kautta",pj="Kirjautumalla sisään hyväksyt",fj="ja",hj="Takaisinkutsun URL-osoite ei vastaa toisiaan",gj="Annettu redirect_uri ei ole sallittujen takaisinsoitto-URL-osoitteiden luettelossa.",mj="jatka käyttäjän kanssa",_j="Klikkaa painiketta luodaksesi uuden salasanatilin.",yj="Kirjoita koodi osoitteessa {{vendorName}} kirjautumisen loppuun saattamiseksi.",vj="Tervetuloa osoitteeseen {{vendorName}}! {{code}} on kirjautumiskoodi.",wj="Tervetuloa osoitteeseen {{vendorName}}! {{code}} on kirjautumiskoodi.",bj="Koodi on voimassa 30 minuuttia",kj="Vahvista salasana",xj="Tarvitsetko apua?",Sj="Ota yhteyttä",Aj="tai jatka sosiaalisella tilillä",Ej="Jatka {{provider}}",Ij="Haluatko jatkaa olemassa olevalla tililläsi?",zj="Copyright © 2023 SESAMY. Kaikki oikeudet pidätetään.",Nj="©2023 Sesamy",Cj="Valitse salasana, jossa on isoja ja pieniä kirjaimia, numeroita ja symboleja.",jj="Kirjoita voimassa oleva sähköpostiosoite.",$j="Salasanat eivät vastanneet toisiaan. Yritä uudelleen.",Oj="Valitse salasana",Bj="Salasanan on oltava vähintään 8 merkkiä pitkä ja sisällettävä vähintään yksi pieni kirjain, yksi iso kirjain, yksi numero ja yksi symboli.",Tj="Luo uusi tili",Pj="Rekisteröidy salasanalla",Rj="Olet tällä hetkellä kirjautuneena sisään nimellä <0>{{email}}</0>",Lj="Sähköposti",Uj="Sähköpostiosoite",Vj="Sähköpostiosoitteesi on vahvistettu",qj="Kirjoita nyt salasanasi kirjautuaksesi uudelleen",Mj="Sähköposti on lähetetty osoitteeseen <0>{{email}}</0> jossa on vahvistuslinkki. Klikkaa linkkiä vahvistaaksesi sähköpostiosoitteesi ja asettaaksesi salasanan.",Dj="Sähköpostivarmennus lähetetty",Hj="Syötä koodi",Fj="Lähetämme sinulle vahvistuslinkin varmistaaksemme, että omistat tämän sähköpostiosoitteen.",Kj="Anna uusi salasana",Wj="Anna salasana",Gj="Anna sähköpostiosoitteesi ja salasanasi kirjautuaksesi sisään.",Jj="Syötä salasanasi",Zj="Taikalinkki on vanhentunut. Klikkaa alla olevaa painiketta saadaksesi uuden linkin sähköpostiisi.",Yj="Hei! Päivitimme kirjautumiskokemuksemme. <0>Klikkaa tästä saadaksesi lisätietoja siitä.</0>",Xj="Lähetä salasanan palautussähköposti",Qj="Napsauta alla olevaa painiketta, niin lähetämme ohjeet salasanasi palauttamiseen.",e$="Salasanan palautussähköposti lähetetty",t$="Unohditko salasanan?",n$="Unohditko salasanan?",r$="Palaa takaisin",i$="Virheellinen salasana",s$=`Linkki ei ole enää voimassa.
247
247
 
248
248
  Varmista, että avaat kirjautumislinkin samalla selaimella, jolla aloitit kirjautumisen.
249
249
 
250
- Voit aloittaa uuden kirjautumisen klikkaamalla alla olevaa linkkiä.`,i$="Virheellinen linkki",s$="Kirjaudu sisään napsauttamalla painiketta",o$="Kirjaudu sisään",a$="Tai kirjoita koodi osoitteessa {{vendorName}} kirjautumisen loppuun saattamiseksi.",c$="Kirjoita sähköpostiosoitteesi avataksesi tämän ohjelman osoitteessa {{service}}",l$="Yhdistä tilisi {{service}}",u$="Olet kirjautunut sisään nimellä",d$="Kirjaudu sisään",p$="Kirjoita sähköpostiosoitteesi kirjautuaksesi sisään.",f$="Anna sähköpostiosoitteesi, niin lähetämme sinulle kirjautumiskoodin.",h$="Anna sähköpostiosoitteesi, niin lähetämme sinulle kirjautumislinkin.",g$="Kirjaudu ulos",m$="Ei, haluan käyttää toista tiliä",_$="tai",y$="Salasana",v$="Salasana on nollattu",w$="Menestys",b$="Vaihda salasana tilillesi {{vendorName}} ",k$="Vaihda salasana tilillesi {{vendorName}} ",x$="Tietosuojakäytäntö",S$="Uudelleenohjaus",A$="Vahvista salasana",E$="Rekisteröi uusi salasana",I$="Lähetä koodi uudelleen",z$="Vaihda salasana",N$="Kirjoita alla oleva uusi salasanasi sähköpostitiliä varten: ",C$="Napsauta painiketta salasanasi palauttamiseksi",j$="Napsauta painiketta salasanasi palauttamiseksi",$$="Nollaa salasanasi",O$="Vaihda salasana tilillesi {{vendorName}} ",B$="Nollaa salasana",T$="Lähetä",P$="Lähetä minulle uusi maaginen linkki",R$="Muista tarkistaa roskapostikansiosi, jos sähköposti ei ole saapunut.",L$="Aseta salasana",U$="Kirjaudu sisään",V$="Rekisteröityminen",q$="Rekisteröidy onnistuneesti",M$="Näyttää siltä, että Spotify-tilisi on tällä hetkellä yhdistetty toiseen Sesamy-tiliin. Mutta älä pelkää, me opastamme sinua prosessin läpi, jotta saat tämän korjattua.",D$="Siirry Spotifyn Content Access -sivulle",H$='Aloitetaan poistamalla Spotify-tilisi linkitys. Klikkaa alla olevaa painiketta siirtyäksesi Spotifyn Content Access -sivulle. Kun olet kirjautunut sisään Spotify-tilillesi, etsi Sesamy yhdistettyjen alustojen luettelosta. Napsauta "Unlink" Sesamyn logon vieressä.',F$="Vaihe 1: Poista Spotify-tilisi linkitys",K$="Kun olet onnistuneesti irrottanut Spotify-tilisi, voit yhdistää sen uudelleen Sesamyn kanssa. Toista vain aiemmin tekemäsi vaiheet, jotka johtivat sinut tälle sivulle.",W$="Vaihe 2: Yhdistä Spotify-tilisi uudelleen Sesamyn kanssa",G$="Hups! Spotify-tilisi on jo linkitetty",J$="Jos sinulla on kysyttävää tai tarvitset apua, voit ottaa yhteyttä tukitiimiimme.",Z$="Ehdot ja edellytykset",Y$="Sähköpostiosoitteesi on vahvistettava. Olemme lähettäneet uuden sähköpostiviestin sähköpostiisi.",X$="Käyttäjätiliä ei ole olemassa",Q$="Käyttäjätiliä ei ole olemassa",e8="Emme löytäneet käyttäjää, jolla on annettu sähköpostiosoite. Yritä uudelleen.",t8="Yritä uudelleen.",n8="Validoi koodi",r8="Tarkista sähköpostin vahvistusohjeet postilaatikostasi.",i8="Rekisteröitynyt",s8="Vahvista sähköpostiosoitteesi napsauttamalla painiketta",o8="Vahvista sähköpostiosoitteesi",a8="Vahvista sähköpostiosoitteesi",c8="Vahvista tili",l8="Vahvista sähköpostiosoitteesi",u8="Tarkista sähköpostisi osoitteesta <0>{{email}}</0> ja syötä lähettämämme kuusinumeroinen koodi.",d8="Tervetuloa",p8="Tervetuloa tilillesi {{vendorName}}!",f8="Jatka tällä tilillä",h8="Kyllä, jatka {{text}}",g8="Kyllä, jatka olemassa olevalla tilillä",m8={"Server error: Invalid code":"Virheellinen koodi","Wrong email or verification code":{"":"Väärä sähköpostiosoite tai vahvistuskoodi."},account_detected:cj,account_with_sso_provider:lj,agree_to:uj,and:dj,callback_url_mismatch:pj,callback_url_not_allowed:fj,check_email_title:hj,click_to_sign_up_description:gj,code_email_enter_code:mj,code_email_subject:_j,code_email_title:yj,code_valid_30_minutes:vj,confirm_password:wj,contact_support:bj,contact_us:kj,continue:"Jatka",continue_social_login:xj,continue_with:Sj,continue_with_sso_provider_headline:Aj,copyright:Ej,copyright_sesamy:Ij,create_account_description:zj,create_account_email_invalid:Nj,create_account_passwords_didnt_match:Cj,create_account_title:jj,create_account_weak_password:$j,create_new_account_link:Oj,create_password_account_title:Bj,currently_logged_in_as:Tj,email:Pj,email_placeholder:Rj,email_validated:Lj,email_validated_cta:Uj,email_verification_for_signup_sent_description:Vj,email_verification_for_signup_sent_title:qj,enter_a_code_btn:Mj,enter_email_for_verification_description:Dj,enter_new_password_placeholder:Hj,enter_password:Fj,enter_password_description:Kj,enter_your_password_btn:Wj,expired_code:Gj,fokus_info_message:Jj,forgot_password_cta:Zj,forgot_password_description:Yj,forgot_password_email_sent:Xj,forgot_password_link:Qj,forgot_password_title:e$,go_back:t$,"invalid-email":"Virheellinen sähköpostiosoite",invalid_password:n$,invalid_session_body:r$,invalid_session_title:i$,link_email_click_to_login:s$,link_email_login:o$,link_email_or_enter_code:a$,link_page_body:c$,link_page_headline:l$,logged_in_as:u$,login:d$,login_description:p$,login_description_code:f$,login_description_link:h$,logout:g$,no_use_another:m$,or:_$,password:y$,password_has_been_reset:v$,password_has_been_reset_title:w$,password_reset_subject:b$,password_reset_title:k$,privacy_policy:x$,redirecting:S$,reenter_new_password_placeholder:A$,register_password_account:E$,resend_code:I$,reset_password_cta:z$,reset_password_description:N$,reset_password_email_click_to_reset:C$,reset_password_email_cta:j$,reset_password_email_reset:$$,reset_password_subject:O$,reset_password_title:B$,send:T$,send_me_a_new_magic_link:P$,sent_code_spam:R$,set_password:L$,sign_in:U$,signup:V$,signup_success:q$,spotify_already_linked_body:M$,spotify_already_linked_cta:D$,spotify_already_linked_step1_body:H$,spotify_already_linked_step1_title:F$,spotify_already_linked_step2_body:K$,spotify_already_linked_step2_title:W$,spotify_already_linked_title:G$,support_info:J$,terms:Z$,unverified_email:Y$,user_account_does_not_exist:X$,user_not_found:Q$,user_not_found_body:e8,user_not_found_cta:t8,validate_code:n8,validate_email_body:r8,validate_email_title:i8,verify_email_click_to_verify:s8,verify_email_subject:o8,verify_email_title:a8,verify_email_verify:c8,verify_your_email:l8,we_sent_a_code_to:u8,welcome:d8,welcome_to_your_account:p8,yes_continue:f8,yes_continue_with:h8,yes_continue_with_existing_account:g8};P.init({supportedLngs:["en","it","nb","sv","pl","cs","fi"],fallbackLng:"en",resources:{en:{translation:mS},it:{translation:AA},nb:{translation:BE},sv:{translation:D3},pl:{translation:X6},cs:{translation:aj},fi:{translation:m8}}});function _8(t){const e=new o.OpenAPIHono;e.get("/",s=>s.json({name:"authhero"}));const n=Nw(t);e.route("/api/v2",n);const r=Lb(t);e.route("/",r);const i=ak(t);return e.route("/u",i),{app:e,managementApp:n,oauthApp:r,universalApp:i,createX509Certificate:Jc}}exports.Auth0Client=mf;exports.AuthorizationResponseMode=Yt;exports.AuthorizationResponseType=Pt;exports.CodeChallengeMethod=Zs;exports.GrantType=Br;exports.LogTypes=he;exports.applicationInsertSchema=ns;exports.applicationSchema=mn;exports.auth0UserResponseSchema=xt;exports.authParamsSchema=tl;exports.baseUserSchema=Js;exports.bordersSchema=bf;exports.brandingSchema=Aa;exports.codeInsertSchema=pf;exports.codeSchema=Jm;exports.codeTypeSchema=df;exports.colorsSchema=kf;exports.connectionInsertSchema=rs;exports.connectionSchema=Ft;exports.customDomainInsertSchema=nl;exports.customDomainSchema=fn;exports.emailProviderSchema=Ui;exports.fontDetailsSchema=hn;exports.fontsSchema=xf;exports.hookInsertSchema=ss;exports.hookSchema=Dn;exports.identitySchema=cf;exports.init=_8;exports.jwksKeySchema=hf;exports.jwksSchema=rl;exports.logSchema=os;exports.loginSessionInsertSchema=gf;exports.loginSessionSchema=Zm;exports.openIDConfigurationSchema=Ea;exports.pageBackgroundSchema=Sf;exports.parseUserId=t_;exports.passwordInsertSchema=_f;exports.passwordSchema=Xm;exports.profileDataSchema=af;exports.promptSettingSchema=Li;exports.refreshTokenInsertSchema=il;exports.refreshTokenSchema=e_;exports.samlpAddon=lf;exports.sessionInsertSchema=vf;exports.sessionSchema=Ys;exports.signingKeySchema=Ia;exports.tenantInsertSchema=is;exports.tenantSchema=Fn;exports.themeInsertSchema=Ef;exports.themeSchema=Qm;exports.tokenResponseSchema=wf;exports.totalsSchema=nn;exports.userInsertSchema=ts;exports.userResponseSchema=Km;exports.userSchema=el;exports.vendorSettingsSchema=uf;exports.verificationMethodsSchema=ff;exports.widgetSchema=Af;
250
+ Voit aloittaa uuden kirjautumisen klikkaamalla alla olevaa linkkiä.`,o$="Virheellinen linkki",a$="Kirjaudu sisään napsauttamalla painiketta",c$="Kirjaudu sisään",l$="Tai kirjoita koodi osoitteessa {{vendorName}} kirjautumisen loppuun saattamiseksi.",u$="Kirjoita sähköpostiosoitteesi avataksesi tämän ohjelman osoitteessa {{service}}",d$="Yhdistä tilisi {{service}}",p$="Olet kirjautunut sisään nimellä",f$="Kirjaudu sisään",h$="Kirjoita sähköpostiosoitteesi kirjautuaksesi sisään.",g$="Anna sähköpostiosoitteesi, niin lähetämme sinulle kirjautumiskoodin.",m$="Anna sähköpostiosoitteesi, niin lähetämme sinulle kirjautumislinkin.",_$="Kirjaudu ulos",y$="Ei, haluan käyttää toista tiliä",v$="tai",w$="Salasana",b$="Salasana on nollattu",k$="Menestys",x$="Vaihda salasana tilillesi {{vendorName}} ",S$="Vaihda salasana tilillesi {{vendorName}} ",A$="Tietosuojakäytäntö",E$="Uudelleenohjaus",I$="Vahvista salasana",z$="Rekisteröi uusi salasana",N$="Lähetä koodi uudelleen",C$="Vaihda salasana",j$="Kirjoita alla oleva uusi salasanasi sähköpostitiliä varten: ",$$="Napsauta painiketta salasanasi palauttamiseksi",O$="Napsauta painiketta salasanasi palauttamiseksi",B$="Nollaa salasanasi",T$="Vaihda salasana tilillesi {{vendorName}} ",P$="Nollaa salasana",R$="Lähetä",L$="Lähetä minulle uusi maaginen linkki",U$="Muista tarkistaa roskapostikansiosi, jos sähköposti ei ole saapunut.",V$="Aseta salasana",q$="Kirjaudu sisään",M$="Rekisteröityminen",D$="Rekisteröidy onnistuneesti",H$="Näyttää siltä, että Spotify-tilisi on tällä hetkellä yhdistetty toiseen Sesamy-tiliin. Mutta älä pelkää, me opastamme sinua prosessin läpi, jotta saat tämän korjattua.",F$="Siirry Spotifyn Content Access -sivulle",K$='Aloitetaan poistamalla Spotify-tilisi linkitys. Klikkaa alla olevaa painiketta siirtyäksesi Spotifyn Content Access -sivulle. Kun olet kirjautunut sisään Spotify-tilillesi, etsi Sesamy yhdistettyjen alustojen luettelosta. Napsauta "Unlink" Sesamyn logon vieressä.',W$="Vaihe 1: Poista Spotify-tilisi linkitys",G$="Kun olet onnistuneesti irrottanut Spotify-tilisi, voit yhdistää sen uudelleen Sesamyn kanssa. Toista vain aiemmin tekemäsi vaiheet, jotka johtivat sinut tälle sivulle.",J$="Vaihe 2: Yhdistä Spotify-tilisi uudelleen Sesamyn kanssa",Z$="Hups! Spotify-tilisi on jo linkitetty",Y$="Jos sinulla on kysyttävää tai tarvitset apua, voit ottaa yhteyttä tukitiimiimme.",X$="Ehdot ja edellytykset",Q$="Sähköpostiosoitteesi on vahvistettava. Olemme lähettäneet uuden sähköpostiviestin sähköpostiisi.",e8="Käyttäjätiliä ei ole olemassa",t8="Käyttäjätiliä ei ole olemassa",n8="Emme löytäneet käyttäjää, jolla on annettu sähköpostiosoite. Yritä uudelleen.",r8="Yritä uudelleen.",i8="Validoi koodi",s8="Tarkista sähköpostin vahvistusohjeet postilaatikostasi.",o8="Rekisteröitynyt",a8="Vahvista sähköpostiosoitteesi napsauttamalla painiketta",c8="Vahvista sähköpostiosoitteesi",l8="Vahvista sähköpostiosoitteesi",u8="Vahvista tili",d8="Vahvista sähköpostiosoitteesi",p8="Tarkista sähköpostisi osoitteesta <0>{{email}}</0> ja syötä lähettämämme kuusinumeroinen koodi.",f8="Tervetuloa",h8="Tervetuloa tilillesi {{vendorName}}!",g8="Jatka tällä tilillä",m8="Kyllä, jatka {{text}}",_8="Kyllä, jatka olemassa olevalla tilillä",y8={"Server error: Invalid code":"Virheellinen koodi","Wrong email or verification code":{"":"Väärä sähköpostiosoite tai vahvistuskoodi."},account_detected:uj,account_with_sso_provider:dj,agree_to:pj,and:fj,callback_url_mismatch:hj,callback_url_not_allowed:gj,check_email_title:mj,click_to_sign_up_description:_j,code_email_enter_code:yj,code_email_subject:vj,code_email_title:wj,code_valid_30_minutes:bj,confirm_password:kj,contact_support:xj,contact_us:Sj,continue:"Jatka",continue_social_login:Aj,continue_with:Ej,continue_with_sso_provider_headline:Ij,copyright:zj,copyright_sesamy:Nj,create_account_description:Cj,create_account_email_invalid:jj,create_account_passwords_didnt_match:$j,create_account_title:Oj,create_account_weak_password:Bj,create_new_account_link:Tj,create_password_account_title:Pj,currently_logged_in_as:Rj,email:Lj,email_placeholder:Uj,email_validated:Vj,email_validated_cta:qj,email_verification_for_signup_sent_description:Mj,email_verification_for_signup_sent_title:Dj,enter_a_code_btn:Hj,enter_email_for_verification_description:Fj,enter_new_password_placeholder:Kj,enter_password:Wj,enter_password_description:Gj,enter_your_password_btn:Jj,expired_code:Zj,fokus_info_message:Yj,forgot_password_cta:Xj,forgot_password_description:Qj,forgot_password_email_sent:e$,forgot_password_link:t$,forgot_password_title:n$,go_back:r$,"invalid-email":"Virheellinen sähköpostiosoite",invalid_password:i$,invalid_session_body:s$,invalid_session_title:o$,link_email_click_to_login:a$,link_email_login:c$,link_email_or_enter_code:l$,link_page_body:u$,link_page_headline:d$,logged_in_as:p$,login:f$,login_description:h$,login_description_code:g$,login_description_link:m$,logout:_$,no_use_another:y$,or:v$,password:w$,password_has_been_reset:b$,password_has_been_reset_title:k$,password_reset_subject:x$,password_reset_title:S$,privacy_policy:A$,redirecting:E$,reenter_new_password_placeholder:I$,register_password_account:z$,resend_code:N$,reset_password_cta:C$,reset_password_description:j$,reset_password_email_click_to_reset:$$,reset_password_email_cta:O$,reset_password_email_reset:B$,reset_password_subject:T$,reset_password_title:P$,send:R$,send_me_a_new_magic_link:L$,sent_code_spam:U$,set_password:V$,sign_in:q$,signup:M$,signup_success:D$,spotify_already_linked_body:H$,spotify_already_linked_cta:F$,spotify_already_linked_step1_body:K$,spotify_already_linked_step1_title:W$,spotify_already_linked_step2_body:G$,spotify_already_linked_step2_title:J$,spotify_already_linked_title:Z$,support_info:Y$,terms:X$,unverified_email:Q$,user_account_does_not_exist:e8,user_not_found:t8,user_not_found_body:n8,user_not_found_cta:r8,validate_code:i8,validate_email_body:s8,validate_email_title:o8,verify_email_click_to_verify:a8,verify_email_subject:c8,verify_email_title:l8,verify_email_verify:u8,verify_your_email:d8,we_sent_a_code_to:p8,welcome:f8,welcome_to_your_account:h8,yes_continue:g8,yes_continue_with:m8,yes_continue_with_existing_account:_8};P.init({supportedLngs:["en","it","nb","sv","pl","cs","fi"],fallbackLng:"en",resources:{en:{translation:yS},it:{translation:IA},nb:{translation:PE},sv:{translation:F3},pl:{translation:eN},cs:{translation:lj},fi:{translation:y8}}});function v8(t){const e=new o.OpenAPIHono;e.get("/",s=>s.json({name:"authhero"}));const n=jw(t);e.route("/api/v2",n);const r=Vb(t);e.route("/",r);const i=lk(t);return e.route("/u",i),{app:e,managementApp:n,oauthApp:r,universalApp:i,createX509Certificate:Jc}}exports.Auth0Client=_f;exports.AuthorizationResponseMode=Xt;exports.AuthorizationResponseType=Pt;exports.CodeChallengeMethod=Zs;exports.GrantType=Br;exports.LogTypes=he;exports.applicationInsertSchema=ns;exports.applicationSchema=mn;exports.auth0UserResponseSchema=xt;exports.authParamsSchema=tl;exports.baseUserSchema=Js;exports.bordersSchema=kf;exports.brandingSchema=Aa;exports.codeInsertSchema=ff;exports.codeSchema=Zm;exports.codeTypeSchema=pf;exports.colorsSchema=xf;exports.connectionInsertSchema=rs;exports.connectionSchema=Kt;exports.customDomainInsertSchema=nl;exports.customDomainSchema=Ft;exports.customDomainWithTenantIdSchema=Ym;exports.emailProviderSchema=Ui;exports.fontDetailsSchema=hn;exports.fontsSchema=Sf;exports.hookInsertSchema=ss;exports.hookSchema=Dn;exports.identitySchema=lf;exports.init=v8;exports.jwksKeySchema=gf;exports.jwksSchema=rl;exports.logSchema=os;exports.loginSessionInsertSchema=mf;exports.loginSessionSchema=Xm;exports.openIDConfigurationSchema=Ea;exports.pageBackgroundSchema=Af;exports.parseUserId=r_;exports.passwordInsertSchema=yf;exports.passwordSchema=e_;exports.profileDataSchema=cf;exports.promptSettingSchema=Li;exports.refreshTokenInsertSchema=il;exports.refreshTokenSchema=n_;exports.samlpAddon=uf;exports.sessionInsertSchema=wf;exports.sessionSchema=Ys;exports.signingKeySchema=Ia;exports.tenantInsertSchema=is;exports.tenantSchema=Fn;exports.themeInsertSchema=If;exports.themeSchema=t_;exports.tokenResponseSchema=bf;exports.totalsSchema=rn;exports.userInsertSchema=ts;exports.userResponseSchema=Wm;exports.userSchema=el;exports.vendorSettingsSchema=df;exports.verificationMethodsSchema=hf;exports.widgetSchema=Ef;