authhero 0.76.0 → 0.78.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 +51 -51
- package/dist/authhero.d.ts +10 -10
- package/dist/authhero.mjs +15320 -15349
- package/package.json +2 -2
package/dist/authhero.cjs
CHANGED
|
@@ -1,8 +1,32 @@
|
|
|
1
|
-
"use strict";var bm=Object.defineProperty;var km=(t,e,n)=>e in t?bm(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var ee=(t,e,n)=>km(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@hono/zod-openapi"),ne=t=>typeof t=="string",Sr=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},xu=t=>t==null?"":""+t,xm=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},Sm=/###/g,Su=t=>t&&t.indexOf("###")>-1?t.replace(Sm,"."):t,Au=t=>!t||ne(t),$r=(t,e,n)=>{const r=ne(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(Au(t))return{};const s=Su(r[i]);!t[s]&&n&&(t[s]=new n),Object.prototype.hasOwnProperty.call(t,s)?t=t[s]:t={},++i}return Au(t)?{}:{obj:t,k:Su(r[i])}},Eu=(t,e,n)=>{const{obj:r,k:i}=$r(t,e,Object);if(r!==void 0||e.length===1){r[i]=n;return}let s=e[e.length-1],o=e.slice(0,e.length-1),c=$r(t,o,Object);for(;c.obj===void 0&&o.length;)s=`${o[o.length-1]}.${s}`,o=o.slice(0,o.length-1),c=$r(t,o,Object),c!=null&&c.obj&&typeof c.obj[`${c.k}.${s}`]<"u"&&(c.obj=void 0);c.obj[`${c.k}.${s}`]=n},Am=(t,e,n,r)=>{const{obj:i,k:s}=$r(t,e,Object);i[s]=i[s]||[],i[s].push(n)},Xi=(t,e)=>{const{obj:n,k:r}=$r(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},Em=(t,e,n)=>{const r=Xi(t,n);return r!==void 0?r:Xi(e,n)},Xp=(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]):Xp(t[r],e[r],n):t[r]=e[r]);return t},Ln=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Im={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const zm=t=>ne(t)?t.replace(/[&<>"'\/]/g,e=>Im[e]):t;class Cm{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 Nm=[" ",",","?","!",";"],jm=new Cm(20),$m=(t,e,n)=>{e=e||"",n=n||"";const r=Nm.filter(o=>e.indexOf(o)<0&&n.indexOf(o)<0);if(r.length===0)return!0;const i=jm.getRegExp(`(${r.map(o=>o==="?"?"\\?":o).join("|")})`);let s=!i.test(t);if(!s){const o=t.indexOf(n);o>0&&!i.test(t.substring(0,o))&&(s=!0)}return s},xa=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 o,c="";for(let l=s;l<r.length;++l)if(l!==s&&(c+=n),c+=r[l],o=i[c],o!==void 0){if(["string","number","boolean"].indexOf(typeof o)>-1&&l<r.length-1)continue;s+=l-s+1;break}i=o}return i},Qi=t=>t==null?void 0:t.replace("_","-"),Om={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 es{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||Om,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 es(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new es(this.logger,e)}}var kt=new es;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(o=>{let[c,l]=o;for(let u=0;u<l;u++)c(...r)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(o=>{let[c,l]=o;for(let u=0;u<l;u++)c.apply(c,[e,...r])})}}class Iu 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,o=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=Xi(this.data,c);return!l&&!n&&!r&&e.indexOf(".")>-1&&(e=c[0],n=c[1],r=c.slice(2).join(".")),l||!o||!ne(r)?l:xa((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 o=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator;let c=[e,n];r&&(c=c.concat(o?r.split(o):r)),e.indexOf(".")>-1&&(c=e.split("."),i=n,n=c[1]),this.addNamespaces(n),Eu(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 o=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=Xi(this.data,c)||{};o.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?Xp(l,r,s):l={...l,...r},Eu(this.data,c,l),o.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 Qp={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,n,r,i){return t.forEach(s=>{var o;e=((o=this.processors[s])==null?void 0:o.process(e,n,r,i))??e}),e}};const zu={};class ts extends Gs{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),xm(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=kt.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 o=r&&e.indexOf(r)>-1,c=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!$m(e,r,i);if(o&&!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:o,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 R=n.nsSeparator||this.options.nsSeparator;return i?{res:`${l}${R}${o}`,usedKey:o,exactUsedKey:o,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:`${l}${R}${o}`}return i?{res:o,usedKey:o,exactUsedKey:o,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:o}const h=this.resolve(e,n);let m=h==null?void 0:h.res;const v=(h==null?void 0:h.usedKey)||o,f=(h==null?void 0:h.exactUsedKey)||o,_=Object.prototype.toString.apply(m),w=["[object Number]","[object Function]","[object RegExp]"],S=n.joinArrays!==void 0?n.joinArrays:this.options.joinArrays,N=!this.i18nFormat||this.i18nFormat.handleAsObject,B=!ne(m)&&typeof m!="boolean"&&typeof m!="number";if(N&&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 R=this.options.returnedObjectHandler?this.options.returnedObjectHandler(v,m,{...n,ns:c}):`key '${o} (${this.language})' returned an object instead of string.`;return i?(h.res=R,h.usedParams=this.getUsedParamsDetails(n),h):R}if(s){const R=Array.isArray(m),te=R?[]:{},fe=R?f:v;for(const le in m)if(Object.prototype.hasOwnProperty.call(m,le)){const Ve=`${fe}${s}${le}`;te[le]=this.translate(Ve,{...n,joinArrays:!1,ns:c}),te[le]===Ve&&(te[le]=m[le])}m=te}}else if(N&&ne(S)&&Array.isArray(m))m=m.join(S),m&&(m=this.extendTranslation(m,e,n,r));else{let R=!1,te=!1;const fe=n.count!==void 0&&!ne(n.count),le=ts.hasDefaultValue(n),Ve=fe?this.pluralResolver.getSuffix(u,n.count,n):"",at=n.ordinal&&fe?this.pluralResolver.getSuffix(u,n.count,{ordinal:!1}):"",Ge=fe&&!n.ordinal&&n.count===0,j=Ge&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${Ve}`]||n[`defaultValue${at}`]||n.defaultValue;!this.isValidLookup(m)&&le&&(R=!0,m=j),this.isValidLookup(m)||(te=!0,m=o);const E=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&te?void 0:m,x=le&&j!==m&&this.options.updateMissing;if(te||R||x){if(this.logger.log(x?"updateKey":"missingKey",u,l,o,x?j:m),s){const X=this.resolve(o,{...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 L=(X,G,ie)=>{var H;const ce=le&&ie!==m?ie:E;this.options.missingKeyHandler?this.options.missingKeyHandler(X,l,G,ce,x,n):(H=this.backendConnector)!=null&&H.saveMissing&&this.backendConnector.saveMissing(X,l,G,ce,x,n),this.emit("missingKey",X,l,G,m)};this.options.saveMissing&&(this.options.saveMissingPlurals&&fe?k.forEach(X=>{const G=this.pluralResolver.getSuffixes(X,n);Ge&&n[`defaultValue${this.options.pluralSeparator}zero`]&&G.indexOf(`${this.options.pluralSeparator}zero`)<0&&G.push(`${this.options.pluralSeparator}zero`),G.forEach(ie=>{L([X],o+ie,n[`defaultValue${ie}`]||j)})}):L(k,o,j))}m=this.extendTranslation(m,e,n,h,r),te&&m===o&&this.options.appendNamespaceToMissingKey&&(m=`${l}:${o}`),(te||R)&&this.options.parseMissingKeyHandler&&(m=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}:${o}`:o,R?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 o=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?(o.logger.warn(`It seems you are nesting recursively key: ${_[0]} in key: ${n[0]}`),null):o.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=Qp.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,o,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,N;this.isValidLookup(r)||(c=w,!zu[`${_[0]}-${w}`]&&((S=this.utils)!=null&&S.hasLoadedNamespace)&&!((N=this.utils)!=null&&N.hasLoadedNamespace(c))&&(zu[`${_[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 fe;if(this.isValidLookup(r))return;o=B;const R=[p];if((fe=this.i18nFormat)!=null&&fe.addLookupKeys)this.i18nFormat.addLookupKeys(R,p,B,w,n);else{let le;m&&(le=this.pluralResolver.getSuffix(B,n.count,n));const Ve=`${this.options.pluralSeparator}zero`,at=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(R.push(p+le),n.ordinal&&le.indexOf(at)===0&&R.push(p+le.replace(at,this.options.pluralSeparator)),v&&R.push(p+Ve)),f){const Ge=`${p}${this.options.contextSeparator}${n.context}`;R.push(Ge),m&&(R.push(Ge+le),n.ordinal&&le.indexOf(at)===0&&R.push(Ge+le.replace(at,this.options.pluralSeparator)),v&&R.push(Ge+Ve))}}let te;for(;te=R.pop();)this.isValidLookup(r)||(s=te,r=this.getResource(B,w,te,n))}))})}),{res:r,usedKey:i,exactUsedKey:s,usedLng:o,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 Cu{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=kt.create("languageUtils")}getScriptPartFromCode(e){if(e=Qi(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=Qi(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=o=>{o&&(this.isSupportedCode(o)?i.push(o):this.logger.warn(`rejecting language code not found in supportedLngs: ${o}`))};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(o=>{i.indexOf(o)<0&&s(this.formatLanguageCode(o))}),i}}const Nu={zero:0,one:1,two:2,few:3,many:4,other:5},ju={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Bm{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=e,this.options=n,this.logger=kt.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=Qi(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 o;try{o=new Intl.PluralRules(r,{type:i})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),ju;if(!e.match(/-|_/))return ju;const l=this.languageUtils.getLanguagePartFromCode(e);o=this.getRule(l,n)}return this.pluralRulesCache[s]=o,o}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)=>Nu[i]-Nu[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 $u=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=Em(t,e,n);return!s&&i&&ne(n)&&(s=xa(t,n,r),s===void 0&&(s=xa(e,n,r))),s},ea=t=>t.replace(/\$/g,"$$$$");class Tm{constructor(){var n;let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=kt.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:o,suffix:c,suffixEscaped:l,formatSeparator:u,unescapeSuffix:p,unescapePrefix:h,nestingPrefix:m,nestingPrefixEscaped:v,nestingSuffix:f,nestingSuffixEscaped:_,nestingOptionsSeparator:w,maxReplaces:S,alwaysFormat:N}=e.interpolation;this.escape=n!==void 0?n:zm,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=s?Ln(s):o||"{{",this.suffix=c?Ln(c):l||"}}",this.formatSeparator=u||",",this.unescapePrefix=p?"":h||"-",this.unescapeSuffix=this.unescapePrefix?"":p||"",this.nestingPrefix=m?Ln(m):v||Ln("$t("),this.nestingSuffix=f?Ln(f):_||Ln(")"),this.nestingOptionsSeparator=w||",",this.maxReplaces=S||1e3,this.alwaysFormat=N!==void 0?N:!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,o,c;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=f=>{if(f.indexOf(this.formatSeparator)<0){const N=$u(n,l,f,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(N,void 0,r,{...i,...n,interpolationkey:f}):N}const _=f.split(this.formatSeparator),w=_.shift().trim(),S=_.join(this.formatSeparator).trim();return this.format($u(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=>ea(f)},{regex:this.regexp,safeValue:f=>this.escapeValue?ea(this.escape(f)):ea(f)}].forEach(f=>{for(c=0;s=f.regex.exec(e);){const _=s[1].trim();if(o=u(_),o===void 0)if(typeof p=="function"){const S=p(e,s,i);o=ne(S)?S:""}else if(i&&Object.prototype.hasOwnProperty.call(i,_))o="";else if(h){o=s[0];continue}else this.logger.warn(`missed to pass in variable ${_} for interpolating ${e}`),o="";else!ne(o)&&!this.useRawValueToEscape&&(o=xu(o));const w=f.safeValue(o);if(e=e.replace(s[0],w),h?(f.regex.lastIndex+=o.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,o;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,o);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{o=JSON.parse(m),u&&(o={...u,...o})}catch(_){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,_),`${l}${p}${m}`}return o.defaultValue&&o.defaultValue.indexOf(this.prefix)>-1&&delete o.defaultValue,l};for(;i=this.nestingRegexp.exec(e);){let l=[];o={...r},o=o.replace&&!ne(o.replace)?o.replace:o,o.applyPostProcessor=!1,delete o.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(),o),o),s&&i[0]===e&&!ne(s))return s;ne(s)||(s=xu(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 Pm=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(o=>{if(o){const[c,...l]=o.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}},Un=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 o=r+JSON.stringify(s);let c=e[o];return c||(c=t(Qi(r),i),e[o]=c),c(n)}};class Rm{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=kt.create("formatter"),this.options=e,this.formats={number:Un((n,r)=>{const i=new Intl.NumberFormat(n,{...r});return s=>i.format(s)}),currency:Un((n,r)=>{const i=new Intl.NumberFormat(n,{...r,style:"currency"});return s=>i.format(s)}),datetime:Un((n,r)=>{const i=new Intl.DateTimeFormat(n,{...r});return s=>i.format(s)}),relativetime:Un((n,r)=>{const i=new Intl.RelativeTimeFormat(n,{...r});return s=>i.format(s,r.range||"day")}),list:Un((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()]=Un(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}=Pm(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 Lm=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class Um extends Gs{constructor(e,n,r){var s,o;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=kt.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=[],(o=(s=this.backend)==null?void 0:s.init)==null||o.call(s,r,i.backend,i)}queueLoad(e,n,r,i){const s={},o={},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?o[m]===void 0&&(o[m]=!0):(this.state[m]=1,p=!1,o[m]===void 0&&(o[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(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(s),pending:Object.keys(o),toLoadLanguages:Object.keys(c),toLoadNamespaces:Object.keys(l)}}loaded(e,n,r){const i=e.split("|"),s=i[0],o=i[1];n&&this.emit("failedLoading",s,o,n),!n&&r&&this.store.addResourceBundle(s,o,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=>{Am(l.loaded,[s],o),Lm(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,o=arguments.length>5?arguments[5]:void 0;if(!e.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:n,fcName:r,tried:i,wait:s,callback:o});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,o)},s);return}o(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(o=>{this.loadOne(o)})}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,(o,c)=>{o&&this.logger.warn(`${n}loading namespace ${s} for language ${i} failed`,o),!o&&c&&this.logger.log(`${n}loaded namespace ${s} for language ${i}`,c),this.loaded(e,o,c)})}saveMissing(e,n,r,i,s){var l,u,p,h,m;let o=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={...o,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 Ou=()=>({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}}),Bu=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},ji=()=>{},Vm=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class Vr 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=Bu(e),this.services={},this.logger=kt,this.modules={external:[]},Vm(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=Ou();this.options={...i,...this.options,...Bu(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?kt.init(s(this.modules.logger),this.options):kt.init(null,this.options);let p;this.modules.formatter?p=this.modules.formatter:p=Rm;const h=new Cu(this.options);this.store=new Iu(this.options.resources,this.options);const m=this.services;m.logger=kt,m.resourceStore=this.store,m.languageUtils=h,m.pluralResolver=new Bm(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 Tm(this.options),m.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},m.backendConnector=new Um(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 ts(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=ji),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=Sr(),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,o;let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:ji;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)),(o=(s=this.options.preload)==null?void 0:s.forEach)==null||o.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=Sr();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=ji),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"&&Qp.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=Sr();this.emit("languageChanging",e);const s=l=>{this.language=l,this.languages=this.services.languageUtils.toResolveHierarchy(l),this.resolvedLanguage=void 0,this.setResolvedLanguage(l)},o=(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=>{o(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(o,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([o,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(o)?v=o.map(f=>`${l.keyPrefix}${m}${f}`):v=l.keyPrefix?`${l.keyPrefix}${m}${o}`:o,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 o=(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,o);if(c!==void 0)return c}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||o(r,e)&&(!i||o(s,e)))}loadNamespaces(e,n){const r=Sr();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=Sr();ne(e)&&(e=[e]);const i=this.options.preload||[],s=e.filter(o=>i.indexOf(o)<0&&this.services.languageUtils.isSupportedCode(o));return s.length?(this.options.preload=i.concat(s),this.loadResources(o=>{r.resolve(),n&&n(o)}),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 Cu(Ou());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 Vr(e,n)}cloneInstance(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:ji;const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},s=new Vr(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 Iu(c,i),s.services.resourceStore=s.store}return s.translator=new ts(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 U=Vr.createInstance();U.createInstance=Vr.createInstance;U.createInstance;U.dir;U.init;U.loadResources;U.reloadResources;U.use;U.changeLanguage;U.getFixedT;const de=U.t;U.exists;U.setDefaultNamespace;U.hasLoadedNamespace;U.loadNamespaces;U.loadLanguages;const nn=a.z.object({start:a.z.number(),limit:a.z.number(),length:a.z.number()}),ef=a.z.object({created_at:a.z.string(),updated_at:a.z.string()}),tf=a.z.object({email:a.z.string().optional(),email_verified:a.z.boolean().optional(),name:a.z.string().optional(),username:a.z.string().optional(),given_name:a.z.string().optional(),phone_number:a.z.string().optional(),phone_verified:a.z.boolean().optional(),family_name:a.z.string().optional()}).catchall(a.z.any()),nf=a.z.object({connection:a.z.string(),user_id:a.z.string(),provider:a.z.string(),isSocial:a.z.boolean(),access_token:a.z.string().optional(),access_token_secret:a.z.string().optional(),refresh_token:a.z.string().optional(),profileData:tf.optional()}),Js=a.z.object({email:a.z.string().optional(),username:a.z.string().optional(),given_name:a.z.string().optional(),family_name:a.z.string().optional(),nickname:a.z.string().optional(),name:a.z.string().optional(),picture:a.z.string().optional(),locale:a.z.string().optional(),linked_to:a.z.string().optional(),profileData:a.z.string().optional(),user_id:a.z.string().optional(),app_metadata:a.z.any().default({}).optional(),user_metadata:a.z.any().default({}).optional()}),ns=Js.extend({email_verified:a.z.boolean().default(!1),verify_email:a.z.boolean().optional(),last_ip:a.z.string().optional(),last_login:a.z.string().optional(),user_id:a.z.string().optional(),provider:a.z.string().default("email"),connection:a.z.string().default("email"),is_social:a.z.boolean().optional()}),Qc=a.z.object({...ns.shape,...ef.shape,user_id:a.z.string(),is_social:a.z.boolean(),email:a.z.string(),login_count:a.z.number(),identities:a.z.array(nf).optional()}),bt=Qc,Mm=Js.extend({email:a.z.string(),login_count:a.z.number(),multifactor:a.z.array(a.z.string()).optional(),last_ip:a.z.string().optional(),last_login:a.z.string().optional(),user_id:a.z.string()}).catchall(a.z.any()),qm="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Dm=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=qm[n[t]&63];return e};const rf=a.z.object({audience:a.z.string().optional(),recipient:a.z.string().optional(),createUpnClaim:a.z.boolean().optional(),mapUnknownClaimsAsIs:a.z.boolean().optional(),passthroughClaimsWithNoMapping:a.z.boolean().optional(),mapIdentities:a.z.boolean().optional(),signatureAlgorithm:a.z.string().optional(),digestAlgorithm:a.z.string().optional(),issuer:a.z.string().optional(),destination:a.z.string().optional(),lifetimeInSeconds:a.z.number().optional(),signResponse:a.z.boolean().optional(),nameIdentifierFormat:a.z.string().optional(),nameIdentifierProbes:a.z.array(a.z.string()).optional(),authnContextClassRef:a.z.string().optional(),mappings:a.z.record(a.z.string()).optional()}),rs=a.z.object({id:a.z.string(),name:a.z.string(),callbacks:a.z.array(a.z.string()).default([]).optional().openapi({description:"Comma-separated list of URLs whitelisted to use as a callback to the client after authentication."}),allowed_origins:a.z.array(a.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:a.z.array(a.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:a.z.array(a.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:a.z.array(a.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:a.z.object({samlp:rf.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:a.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:a.z.string().default(()=>Dm()).optional(),disable_sign_ups:a.z.boolean().optional().default(!1).openapi({description:"Prevents users from signing up using the hosted login page. This is not available in auth0"})}),pn=a.z.object({created_at:a.z.string().transform(t=>t===null?"":t),updated_at:a.z.string().transform(t=>t===null?"":t),...rs.shape});var Jt=(t=>(t.TOKEN="token",t.TOKEN_ID_TOKEN="token id_token",t.CODE="code",t))(Jt||{}),Zt=(t=>(t.QUERY="query",t.FRAGMENT="fragment",t.FORM_POST="form_post",t.WEB_MESSAGE="web_message",t.SAML_POST="saml_post",t))(Zt||{}),Zs=(t=>(t.S256="S256",t.Plain="plain",t))(Zs||{});const el=a.z.object({client_id:a.z.string(),vendor_id:a.z.string().optional(),act_as:a.z.string().optional(),response_type:a.z.nativeEnum(Jt).optional(),response_mode:a.z.nativeEnum(Zt).optional(),redirect_uri:a.z.string().optional(),audience:a.z.string().optional(),state:a.z.string().optional(),nonce:a.z.string().optional(),scope:a.z.string().optional(),prompt:a.z.string().optional(),code_challenge_method:a.z.nativeEnum(Zs).optional(),code_challenge:a.z.string().optional(),username:a.z.string().optional(),ui_locales:a.z.string().optional()}),Sa=a.z.object({colors:a.z.object({primary:a.z.string(),page_background:a.z.object({type:a.z.string().optional(),start:a.z.string().optional(),end:a.z.string().optional(),angle_deg:a.z.number().optional()}).optional()}).optional(),logo_url:a.z.string().optional(),favicon_url:a.z.string().optional(),font:a.z.object({url:a.z.string()}).optional()}),is=a.z.object({id:a.z.string().optional(),name:a.z.string(),strategy:a.z.string(),options:a.z.object({kid:a.z.string().optional(),team_id:a.z.string().optional(),realms:a.z.string().optional(),client_id:a.z.string().optional(),client_secret:a.z.string().optional(),app_secret:a.z.string().optional(),scope:a.z.string().optional(),authorization_endpoint:a.z.string().default("").optional(),token_endpoint:a.z.string().default("").optional(),userinfo_endpoint:a.z.string().default("").optional(),jwks_uri:a.z.string().default("").optional(),discovery_url:a.z.string().default("").optional(),issuer:a.z.string().default("").optional()}).default({}).optional(),enabled_clients:a.z.array(a.z.string()).default([]).optional(),response_type:a.z.custom().optional(),response_mode:a.z.custom().optional()}),Dt=a.z.object({id:a.z.string(),created_at:a.z.string().transform(t=>t===null?"":t),updated_at:a.z.string().transform(t=>t===null?"":t)}).extend(is.shape),ss=a.z.object({name:a.z.string(),audience:a.z.string(),sender_email:a.z.string().email(),sender_name:a.z.string(),support_url:a.z.string().url().optional(),logo:a.z.string().url().optional(),primary_color:a.z.string().optional(),secondary_color:a.z.string().optional(),language:a.z.string().optional(),id:a.z.string().optional()}),Fn=a.z.object({created_at:a.z.string().transform(t=>t===null?"":t),updated_at:a.z.string().transform(t=>t===null?"":t),...ss.shape,id:a.z.string()}),sf=a.z.object({logoUrl:a.z.string(),loginBackgroundImage:a.z.string().nullish(),style:a.z.object({primaryColor:a.z.string(),buttonTextColor:a.z.string(),primaryHoverColor:a.z.string()}),supportEmail:a.z.string().nullable(),supportUrl:a.z.string().nullable(),name:a.z.string(),showGreyishBackground:a.z.boolean().optional(),termsAndConditionsUrl:a.z.string().nullable(),companyName:a.z.string().optional(),checkoutHideSocial:a.z.boolean().optional(),siteUrl:a.z.string().nullable(),manageSubscriptionsUrl:a.z.string().optional()});a.z.object({...pn.shape,tenant:Fn,connections:a.z.array(Dt)});const of=a.z.enum(["password_reset","email_verification","otp","authorization_code","oauth2_state","ticket"]),af=a.z.object({code_id:a.z.string().openapi({description:"The code that will be used in for instance an email verification flow"}),login_id:a.z.string().openapi({description:"The id of the login session that the code is connected to"}),connection_id:a.z.string().optional().openapi({description:"The connection that the code is connected to"}),code_type:of,code_verifier:a.z.string().optional().openapi({description:"The code verifier used in PKCE in outbound flows"}),expires_at:a.z.string(),used_at:a.z.string().optional(),user_id:a.z.string().optional()}),Hm=a.z.object({...af.shape,created_at:a.z.string()}),tl=a.z.object({domain:a.z.string(),type:a.z.enum(["auth0_managed_certs","self_managed_certs"]),verification_method:a.z.enum(["txt"]).optional(),tls_policy:a.z.enum(["recommended"]).optional(),custom_client_ip_header:a.z.enum(["true-client-ip","cf-connecting-ip","x-forwarded-for","x-azure-clientip","null"]).optional(),domain_metadata:a.z.record(a.z.string().max(255)).optional()}),qn=a.z.object({...tl.shape,custom_domain_id:a.z.string(),primary:a.z.boolean(),status:a.z.enum(["disabled","pending","pending_verification","ready"]),origin_domain_name:a.z.string().optional(),verification:a.z.object({}).optional(),tls_policy:a.z.string().optional()}),os=a.z.object({trigger_id:a.z.enum(["pre-user-signup","post-user-registration","post-user-login"]),enabled:a.z.boolean().default(!1),url:a.z.string(),hook_id:a.z.string().optional(),synchronous:a.z.boolean().default(!1),priority:a.z.number().optional()}),Dn=os.extend({...ef.shape,hook_id:a.z.string()}),nl=a.z.object({alg:a.z.enum(["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512"]),e:a.z.string(),kid:a.z.string(),kty:a.z.enum(["RSA","EC","oct"]),n:a.z.string(),x5t:a.z.string().optional(),x5c:a.z.array(a.z.string()).optional(),use:a.z.enum(["sig","enc"]).optional()}),cf=a.z.object({keys:a.z.array(nl)}),Aa=a.z.object({issuer:a.z.string(),authorization_endpoint:a.z.string(),token_endpoint:a.z.string(),device_authorization_endpoint:a.z.string(),userinfo_endpoint:a.z.string(),mfa_challenge_endpoint:a.z.string(),jwks_uri:a.z.string(),registration_endpoint:a.z.string(),revocation_endpoint:a.z.string(),scopes_supported:a.z.array(a.z.string()),response_types_supported:a.z.array(a.z.string()),code_challenge_methods_supported:a.z.array(a.z.string()),response_modes_supported:a.z.array(a.z.string()),subject_types_supported:a.z.array(a.z.string()),id_token_signing_alg_values_supported:a.z.array(a.z.string()),token_endpoint_auth_methods_supported:a.z.array(a.z.string()),claims_supported:a.z.array(a.z.string()),request_uri_parameter_supported:a.z.boolean(),request_parameter_supported:a.z.boolean(),token_endpoint_auth_signing_alg_values_supported:a.z.array(a.z.string())}),lf=a.z.object({auth0Client:a.z.string().optional(),authParams:el,expires_at:a.z.string(),deleted_at:a.z.string().optional(),ip:a.z.string().optional(),useragent:a.z.string().optional()}).openapi({description:"This represents a login sesion"}),Fm=a.z.object({...lf.shape,login_id:a.z.string().openapi({description:"This is is used as the state in the universal login"}),created_at:a.z.string(),updated_at:a.z.string()});var me=(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))(me||{});const Km=a.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"]),uf=a.z.object({name:a.z.string(),version:a.z.string(),env:a.z.object({node:a.z.string().optional()}).optional()}),as=a.z.object({type:Km,date:a.z.string(),description:a.z.string().optional(),log_id:a.z.string().optional(),_id:a.z.string().optional(),ip:a.z.string(),user_agent:a.z.string(),details:a.z.any().optional(),isMobile:a.z.boolean(),user_id:a.z.string().optional(),user_name:a.z.string().optional(),connection:a.z.string().optional(),connection_id:a.z.string().optional(),client_id:a.z.string().optional(),client_name:a.z.string().optional(),audience:a.z.string().optional(),scope:a.z.array(a.z.string()).optional(),strategy:a.z.string().optional(),strategy_type:a.z.string().optional(),hostname:a.z.string().optional(),auth0_client:uf.optional()}),df=a.z.object({user_id:a.z.string(),password:a.z.string(),algorithm:a.z.enum(["bcrypt","argon2id"]).default("argon2id")}),Wm=a.z.object({...df.shape,created_at:a.z.string(),updated_at:a.z.string()}),pf=a.z.object({initial_user_agent:a.z.string().describe("First user agent of the device from which this user logged in"),initial_ip:a.z.string().describe("First IP address associated with this session"),initial_asn:a.z.string().describe("First autonomous system number associated with this session"),last_user_agent:a.z.string().describe("Last user agent of the device from which this user logged in"),last_ip:a.z.string().describe("Last IP address from which this user logged in"),last_asn:a.z.string().describe("Last autonomous system number from which this user logged in")}),ff=a.z.object({id:a.z.string(),revoked_at:a.z.string().optional(),used_at:a.z.string().optional(),user_id:a.z.string().describe("The user ID associated with the session"),expires_at:a.z.string().optional(),idle_expires_at:a.z.string().optional(),device:pf.describe("Metadata related to the device used in the session"),clients:a.z.array(a.z.string()).describe("List of client details for the session")}),Ys=a.z.object({created_at:a.z.string(),updated_at:a.z.string(),authenticated_at:a.z.string(),last_interaction_at:a.z.string(),...ff.shape}),Ea=a.z.object({kid:a.z.string().openapi({description:"The key id of the signing key"}),cert:a.z.string().openapi({description:"The public certificate of the signing key"}),fingerprint:a.z.string().openapi({description:"The cert fingerprint"}),thumbprint:a.z.string().openapi({description:"The cert thumbprint"}),pkcs7:a.z.string().optional().openapi({description:"The private key in pkcs7 format"}),current:a.z.boolean().optional().openapi({description:"True if the key is the current key"}),next:a.z.boolean().optional().openapi({description:"True if the key is the next key"}),previous:a.z.boolean().optional().openapi({description:"True if the key is the previous key"}),current_since:a.z.string().optional().openapi({description:"The date and time when the key became the current key"}),current_until:a.z.string().optional().openapi({description:"The date and time when the current key was rotated"}),revoked:a.z.boolean().optional().openapi({description:"True if the key is revoked"}),revoked_at:a.z.string().optional().openapi({description:"The date and time when the key was revoked"})});var Or=(t=>(t.RefreshToken="refresh_token",t.AuthorizationCode="authorization_code",t.ClientCredential="client_credentials",t.Passwordless="passwordless",t.Password="password",t))(Or||{});const hf=a.z.object({access_token:a.z.string(),id_token:a.z.string().optional(),scope:a.z.string().optional(),state:a.z.string().optional(),refresh_token:a.z.string().optional(),token_type:a.z.string(),expires_in:a.z.number()});a.z.object({code:a.z.string(),state:a.z.string().optional()});const gf=a.z.object({button_border_radius:a.z.number(),button_border_weight:a.z.number(),buttons_style:a.z.enum(["pill"]),input_border_radius:a.z.number(),input_border_weight:a.z.number(),inputs_style:a.z.enum(["pill"]),show_widget_shadow:a.z.boolean(),widget_border_weight:a.z.number(),widget_corner_radius:a.z.number()}),mf=a.z.object({base_focus_color:a.z.string(),base_hover_color:a.z.string(),body_text:a.z.string(),captcha_widget_theme:a.z.enum(["auto"]),error:a.z.string(),header:a.z.string(),icons:a.z.string(),input_background:a.z.string(),input_border:a.z.string(),input_filled_text:a.z.string(),input_labels_placeholders:a.z.string(),links_focused_components:a.z.string(),primary_button:a.z.string(),primary_button_label:a.z.string(),secondary_button_border:a.z.string(),secondary_button_label:a.z.string(),success:a.z.string(),widget_background:a.z.string(),widget_border:a.z.string()}),un=a.z.object({bold:a.z.boolean(),size:a.z.number()}),_f=a.z.object({body_text:un,buttons_text:un,font_url:a.z.string(),input_labels:un,links:un,links_style:a.z.enum(["normal"]),reference_text_size:a.z.number(),subtitle:un,title:un}),yf=a.z.object({background_color:a.z.string(),background_image_url:a.z.string(),page_layout:a.z.enum(["center"])}),vf=a.z.object({header_text_alignment:a.z.enum(["center"]),logo_height:a.z.number(),logo_position:a.z.enum(["center"]),logo_url:a.z.string(),social_buttons_layout:a.z.enum(["bottom"])}),wf=a.z.object({borders:gf,colors:mf,displayName:a.z.string(),fonts:_f,page_background:yf,widget:vf}),Gm=wf.extend({themeId:a.z.string()}),Ui=a.z.object({universal_login_experience:a.z.enum(["new","classic"]).default("new"),identifier_first:a.z.boolean().default(!0),password_first:a.z.boolean().default(!1),webauthn_platform_first_factor:a.z.boolean()}),Vi=a.z.object({name:a.z.string(),enabled:a.z.boolean().optional().default(!0),default_from_address:a.z.string().optional(),credentials:a.z.union([a.z.object({accessKeyId:a.z.string(),secretAccessKey:a.z.string(),region:a.z.string()}),a.z.object({smtp_host:a.z.array(a.z.string()),smtp_port:a.z.number(),smtp_user:a.z.string(),smtp_pass:a.z.string()}),a.z.object({api_key:a.z.string(),domain:a.z.string().optional()}),a.z.object({connectionString:a.z.string()}),a.z.object({tenantId:a.z.string(),clientId:a.z.string(),clientSecret:a.z.string()})]),settings:a.z.object({}).optional()}),rl=a.z.object({id:a.z.string(),session_id:a.z.string(),user_id:a.z.string(),client_id:a.z.string(),expires_at:a.z.string().optional(),idle_expires_at:a.z.string().optional(),last_exchanged_at:a.z.string().optional(),device:pf,resource_servers:a.z.array(a.z.object({audience:a.z.string(),scopes:a.z.string()})),rotating:a.z.boolean()}),Jm=a.z.object({created_at:a.z.string(),...rl.shape});function Zm(t){const[e,n]=t.split("|");if(!e||!n)throw new Error(`Invalid user_id: ${t}`);return{connection:e,id:n}}const Ym=new a.OpenAPIHono().openapi(a.createRoute({tags:["branding"],method:"get",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Sa}},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(a.createRoute({tags:["branding"],method:"patch",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.object(Sa.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 C=class extends Error{constructor(e=500,n){super(n==null?void 0:n.message,{cause:n==null?void 0:n.cause});ee(this,"res");ee(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})}},cs=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function bf(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Xm(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 Qm(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 kf={exports:{}};const e_={},t_=Object.freeze(Object.defineProperty({__proto__:null,default:e_},Symbol.toStringTag,{value:"Module"})),n_=Xm(t_);(function(t){/**
|
|
1
|
+
"use strict";var xm=Object.defineProperty;var Sm=(t,e,n)=>e in t?xm(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var ee=(t,e,n)=>Sm(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@hono/zod-openapi"),ne=t=>typeof t=="string",kr=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},xu=t=>t==null?"":""+t,Am=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},Em=/###/g,Su=t=>t&&t.indexOf("###")>-1?t.replace(Em,"."):t,Au=t=>!t||ne(t),Nr=(t,e,n)=>{const r=ne(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(Au(t))return{};const s=Su(r[i]);!t[s]&&n&&(t[s]=new n),Object.prototype.hasOwnProperty.call(t,s)?t=t[s]:t={},++i}return Au(t)?{}:{obj:t,k:Su(r[i])}},Eu=(t,e,n)=>{const{obj:r,k:i}=Nr(t,e,Object);if(r!==void 0||e.length===1){r[i]=n;return}let s=e[e.length-1],o=e.slice(0,e.length-1),c=Nr(t,o,Object);for(;c.obj===void 0&&o.length;)s=`${o[o.length-1]}.${s}`,o=o.slice(0,o.length-1),c=Nr(t,o,Object),c!=null&&c.obj&&typeof c.obj[`${c.k}.${s}`]<"u"&&(c.obj=void 0);c.obj[`${c.k}.${s}`]=n},Im=(t,e,n,r)=>{const{obj:i,k:s}=Nr(t,e,Object);i[s]=i[s]||[],i[s].push(n)},Zi=(t,e)=>{const{obj:n,k:r}=Nr(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},zm=(t,e,n)=>{const r=Zi(t,n);return r!==void 0?r:Zi(e,n)},Xp=(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]):Xp(t[r],e[r],n):t[r]=e[r]);return t},Rn=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Cm={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const Nm=t=>ne(t)?t.replace(/[&<>"'\/]/g,e=>Cm[e]):t;class jm{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 $m=[" ",",","?","!",";"],Om=new jm(20),Bm=(t,e,n)=>{e=e||"",n=n||"";const r=$m.filter(o=>e.indexOf(o)<0&&n.indexOf(o)<0);if(r.length===0)return!0;const i=Om.getRegExp(`(${r.map(o=>o==="?"?"\\?":o).join("|")})`);let s=!i.test(t);if(!s){const o=t.indexOf(n);o>0&&!i.test(t.substring(0,o))&&(s=!0)}return s},xa=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 o,c="";for(let l=s;l<r.length;++l)if(l!==s&&(c+=n),c+=r[l],o=i[c],o!==void 0){if(["string","number","boolean"].indexOf(typeof o)>-1&&l<r.length-1)continue;s+=l-s+1;break}i=o}return i},Yi=t=>t==null?void 0:t.replace("_","-"),Tm={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 Xi{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||Tm,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 Xi(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new Xi(this.logger,e)}}var kt=new Xi;class Ws{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(o=>{let[c,l]=o;for(let u=0;u<l;u++)c(...r)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(o=>{let[c,l]=o;for(let u=0;u<l;u++)c.apply(c,[e,...r])})}}class Iu extends Ws{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,o=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=Zi(this.data,c);return!l&&!n&&!r&&e.indexOf(".")>-1&&(e=c[0],n=c[1],r=c.slice(2).join(".")),l||!o||!ne(r)?l:xa((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 o=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator;let c=[e,n];r&&(c=c.concat(o?r.split(o):r)),e.indexOf(".")>-1&&(c=e.split("."),i=n,n=c[1]),this.addNamespaces(n),Eu(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 o=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=Zi(this.data,c)||{};o.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?Xp(l,r,s):l={...l,...r},Eu(this.data,c,l),o.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 Qp={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,n,r,i){return t.forEach(s=>{var o;e=((o=this.processors[s])==null?void 0:o.process(e,n,r,i))??e}),e}};const zu={};class Qi extends Ws{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Am(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=kt.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 o=r&&e.indexOf(r)>-1,c=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!Bm(e,r,i);if(o&&!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:o,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 R=n.nsSeparator||this.options.nsSeparator;return i?{res:`${l}${R}${o}`,usedKey:o,exactUsedKey:o,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:`${l}${R}${o}`}return i?{res:o,usedKey:o,exactUsedKey:o,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:o}const h=this.resolve(e,n);let m=h==null?void 0:h.res;const v=(h==null?void 0:h.usedKey)||o,f=(h==null?void 0:h.exactUsedKey)||o,_=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 R=this.options.returnedObjectHandler?this.options.returnedObjectHandler(v,m,{...n,ns:c}):`key '${o} (${this.language})' returned an object instead of string.`;return i?(h.res=R,h.usedParams=this.getUsedParamsDetails(n),h):R}if(s){const R=Array.isArray(m),te=R?[]:{},fe=R?f:v;for(const le in m)if(Object.prototype.hasOwnProperty.call(m,le)){const Ue=`${fe}${s}${le}`;te[le]=this.translate(Ue,{...n,joinArrays:!1,ns:c}),te[le]===Ue&&(te[le]=m[le])}m=te}}else if(C&&ne(S)&&Array.isArray(m))m=m.join(S),m&&(m=this.extendTranslation(m,e,n,r));else{let R=!1,te=!1;const fe=n.count!==void 0&&!ne(n.count),le=Qi.hasDefaultValue(n),Ue=fe?this.pluralResolver.getSuffix(u,n.count,n):"",at=n.ordinal&&fe?this.pluralResolver.getSuffix(u,n.count,{ordinal:!1}):"",Ge=fe&&!n.ordinal&&n.count===0,j=Ge&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${Ue}`]||n[`defaultValue${at}`]||n.defaultValue;!this.isValidLookup(m)&&le&&(R=!0,m=j),this.isValidLookup(m)||(te=!0,m=o);const E=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&te?void 0:m,x=le&&j!==m&&this.options.updateMissing;if(te||R||x){if(this.logger.log(x?"updateKey":"missingKey",u,l,o,x?j:m),s){const X=this.resolve(o,{...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 L=(X,G,ie)=>{var H;const ce=le&&ie!==m?ie:E;this.options.missingKeyHandler?this.options.missingKeyHandler(X,l,G,ce,x,n):(H=this.backendConnector)!=null&&H.saveMissing&&this.backendConnector.saveMissing(X,l,G,ce,x,n),this.emit("missingKey",X,l,G,m)};this.options.saveMissing&&(this.options.saveMissingPlurals&&fe?k.forEach(X=>{const G=this.pluralResolver.getSuffixes(X,n);Ge&&n[`defaultValue${this.options.pluralSeparator}zero`]&&G.indexOf(`${this.options.pluralSeparator}zero`)<0&&G.push(`${this.options.pluralSeparator}zero`),G.forEach(ie=>{L([X],o+ie,n[`defaultValue${ie}`]||j)})}):L(k,o,j))}m=this.extendTranslation(m,e,n,h,r),te&&m===o&&this.options.appendNamespaceToMissingKey&&(m=`${l}:${o}`),(te||R)&&this.options.parseMissingKeyHandler&&(m=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}:${o}`:o,R?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 o=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?(o.logger.warn(`It seems you are nesting recursively key: ${_[0]} in key: ${n[0]}`),null):o.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=Qp.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,o,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,!zu[`${_[0]}-${w}`]&&((S=this.utils)!=null&&S.hasLoadedNamespace)&&!((C=this.utils)!=null&&C.hasLoadedNamespace(c))&&(zu[`${_[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 fe;if(this.isValidLookup(r))return;o=B;const R=[p];if((fe=this.i18nFormat)!=null&&fe.addLookupKeys)this.i18nFormat.addLookupKeys(R,p,B,w,n);else{let le;m&&(le=this.pluralResolver.getSuffix(B,n.count,n));const Ue=`${this.options.pluralSeparator}zero`,at=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(R.push(p+le),n.ordinal&&le.indexOf(at)===0&&R.push(p+le.replace(at,this.options.pluralSeparator)),v&&R.push(p+Ue)),f){const Ge=`${p}${this.options.contextSeparator}${n.context}`;R.push(Ge),m&&(R.push(Ge+le),n.ordinal&&le.indexOf(at)===0&&R.push(Ge+le.replace(at,this.options.pluralSeparator)),v&&R.push(Ge+Ue))}}let te;for(;te=R.pop();)this.isValidLookup(r)||(s=te,r=this.getResource(B,w,te,n))}))})}),{res:r,usedKey:i,exactUsedKey:s,usedLng:o,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 Cu{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=kt.create("languageUtils")}getScriptPartFromCode(e){if(e=Yi(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=Yi(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=o=>{o&&(this.isSupportedCode(o)?i.push(o):this.logger.warn(`rejecting language code not found in supportedLngs: ${o}`))};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(o=>{i.indexOf(o)<0&&s(this.formatLanguageCode(o))}),i}}const Nu={zero:0,one:1,two:2,few:3,many:4,other:5},ju={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Pm{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=e,this.options=n,this.logger=kt.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=Yi(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 o;try{o=new Intl.PluralRules(r,{type:i})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),ju;if(!e.match(/-|_/))return ju;const l=this.languageUtils.getLanguagePartFromCode(e);o=this.getRule(l,n)}return this.pluralRulesCache[s]=o,o}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)=>Nu[i]-Nu[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 $u=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=zm(t,e,n);return!s&&i&&ne(n)&&(s=xa(t,n,r),s===void 0&&(s=xa(e,n,r))),s},ea=t=>t.replace(/\$/g,"$$$$");class Rm{constructor(){var n;let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=kt.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:o,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:Nm,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=s?Rn(s):o||"{{",this.suffix=c?Rn(c):l||"}}",this.formatSeparator=u||",",this.unescapePrefix=p?"":h||"-",this.unescapeSuffix=this.unescapePrefix?"":p||"",this.nestingPrefix=m?Rn(m):v||Rn("$t("),this.nestingSuffix=f?Rn(f):_||Rn(")"),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,o,c;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=f=>{if(f.indexOf(this.formatSeparator)<0){const C=$u(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($u(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=>ea(f)},{regex:this.regexp,safeValue:f=>this.escapeValue?ea(this.escape(f)):ea(f)}].forEach(f=>{for(c=0;s=f.regex.exec(e);){const _=s[1].trim();if(o=u(_),o===void 0)if(typeof p=="function"){const S=p(e,s,i);o=ne(S)?S:""}else if(i&&Object.prototype.hasOwnProperty.call(i,_))o="";else if(h){o=s[0];continue}else this.logger.warn(`missed to pass in variable ${_} for interpolating ${e}`),o="";else!ne(o)&&!this.useRawValueToEscape&&(o=xu(o));const w=f.safeValue(o);if(e=e.replace(s[0],w),h?(f.regex.lastIndex+=o.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,o;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,o);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{o=JSON.parse(m),u&&(o={...u,...o})}catch(_){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,_),`${l}${p}${m}`}return o.defaultValue&&o.defaultValue.indexOf(this.prefix)>-1&&delete o.defaultValue,l};for(;i=this.nestingRegexp.exec(e);){let l=[];o={...r},o=o.replace&&!ne(o.replace)?o.replace:o,o.applyPostProcessor=!1,delete o.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(),o),o),s&&i[0]===e&&!ne(s))return s;ne(s)||(s=xu(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 Lm=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(o=>{if(o){const[c,...l]=o.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}},Ln=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 o=r+JSON.stringify(s);let c=e[o];return c||(c=t(Yi(r),i),e[o]=c),c(n)}};class Um{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=kt.create("formatter"),this.options=e,this.formats={number:Ln((n,r)=>{const i=new Intl.NumberFormat(n,{...r});return s=>i.format(s)}),currency:Ln((n,r)=>{const i=new Intl.NumberFormat(n,{...r,style:"currency"});return s=>i.format(s)}),datetime:Ln((n,r)=>{const i=new Intl.DateTimeFormat(n,{...r});return s=>i.format(s)}),relativetime:Ln((n,r)=>{const i=new Intl.RelativeTimeFormat(n,{...r});return s=>i.format(s,r.range||"day")}),list:Ln((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()]=Ln(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}=Lm(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 Vm=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class Mm extends Ws{constructor(e,n,r){var s,o;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=kt.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=[],(o=(s=this.backend)==null?void 0:s.init)==null||o.call(s,r,i.backend,i)}queueLoad(e,n,r,i){const s={},o={},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?o[m]===void 0&&(o[m]=!0):(this.state[m]=1,p=!1,o[m]===void 0&&(o[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(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(s),pending:Object.keys(o),toLoadLanguages:Object.keys(c),toLoadNamespaces:Object.keys(l)}}loaded(e,n,r){const i=e.split("|"),s=i[0],o=i[1];n&&this.emit("failedLoading",s,o,n),!n&&r&&this.store.addResourceBundle(s,o,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=>{Im(l.loaded,[s],o),Vm(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,o=arguments.length>5?arguments[5]:void 0;if(!e.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:n,fcName:r,tried:i,wait:s,callback:o});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,o)},s);return}o(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(o=>{this.loadOne(o)})}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,(o,c)=>{o&&this.logger.warn(`${n}loading namespace ${s} for language ${i} failed`,o),!o&&c&&this.logger.log(`${n}loaded namespace ${s} for language ${i}`,c),this.loaded(e,o,c)})}saveMissing(e,n,r,i,s){var l,u,p,h,m;let o=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={...o,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 Ou=()=>({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}}),Bu=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=()=>{},qm=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class Lr extends Ws{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(super(),this.options=Bu(e),this.services={},this.logger=kt,this.modules={external:[]},qm(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=Ou();this.options={...i,...this.options,...Bu(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?kt.init(s(this.modules.logger),this.options):kt.init(null,this.options);let p;this.modules.formatter?p=this.modules.formatter:p=Um;const h=new Cu(this.options);this.store=new Iu(this.options.resources,this.options);const m=this.services;m.logger=kt,m.resourceStore=this.store,m.languageUtils=h,m.pluralResolver=new Pm(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 Rm(this.options),m.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},m.backendConnector=new Mm(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 Qi(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=kr(),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,o;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)),(o=(s=this.options.preload)==null?void 0:s.forEach)==null||o.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=kr();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"&&Qp.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=kr();this.emit("languageChanging",e);const s=l=>{this.language=l,this.languages=this.services.languageUtils.toResolveHierarchy(l),this.resolvedLanguage=void 0,this.setResolvedLanguage(l)},o=(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=>{o(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(o,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([o,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(o)?v=o.map(f=>`${l.keyPrefix}${m}${f}`):v=l.keyPrefix?`${l.keyPrefix}${m}${o}`:o,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 o=(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,o);if(c!==void 0)return c}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||o(r,e)&&(!i||o(s,e)))}loadNamespaces(e,n){const r=kr();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=kr();ne(e)&&(e=[e]);const i=this.options.preload||[],s=e.filter(o=>i.indexOf(o)<0&&this.services.languageUtils.isSupportedCode(o));return s.length?(this.options.preload=i.concat(s),this.loadResources(o=>{r.resolve(),n&&n(o)}),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 Cu(Ou());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 Lr(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 Lr(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 Iu(c,i),s.services.resourceStore=s.store}return s.translator=new Qi(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 U=Lr.createInstance();U.createInstance=Lr.createInstance;U.createInstance;U.dir;U.init;U.loadResources;U.reloadResources;U.use;U.changeLanguage;U.getFixedT;const de=U.t;U.exists;U.setDefaultNamespace;U.hasLoadedNamespace;U.loadNamespaces;U.loadLanguages;const nn=a.z.object({start:a.z.number(),limit:a.z.number(),length:a.z.number()}),ef=a.z.object({created_at:a.z.string(),updated_at:a.z.string()}),tf=a.z.object({email:a.z.string().optional(),email_verified:a.z.boolean().optional(),name:a.z.string().optional(),username:a.z.string().optional(),given_name:a.z.string().optional(),phone_number:a.z.string().optional(),phone_verified:a.z.boolean().optional(),family_name:a.z.string().optional()}).catchall(a.z.any()),nf=a.z.object({connection:a.z.string(),user_id:a.z.string(),provider:a.z.string(),isSocial:a.z.boolean(),access_token:a.z.string().optional(),access_token_secret:a.z.string().optional(),refresh_token:a.z.string().optional(),profileData:tf.optional()}),Gs=a.z.object({email:a.z.string().optional(),username:a.z.string().optional(),given_name:a.z.string().optional(),family_name:a.z.string().optional(),nickname:a.z.string().optional(),name:a.z.string().optional(),picture:a.z.string().optional(),locale:a.z.string().optional(),linked_to:a.z.string().optional(),profileData:a.z.string().optional(),user_id:a.z.string().optional(),app_metadata:a.z.any().default({}).optional(),user_metadata:a.z.any().default({}).optional()}),es=Gs.extend({email_verified:a.z.boolean().default(!1),verify_email:a.z.boolean().optional(),last_ip:a.z.string().optional(),last_login:a.z.string().optional(),user_id:a.z.string().optional(),provider:a.z.string().default("email"),connection:a.z.string().default("email"),is_social:a.z.boolean().optional()}),Qc=a.z.object({...es.shape,...ef.shape,user_id:a.z.string(),is_social:a.z.boolean(),email:a.z.string(),login_count:a.z.number(),identities:a.z.array(nf).optional()}),bt=Qc,Dm=Gs.extend({email:a.z.string(),login_count:a.z.number(),multifactor:a.z.array(a.z.string()).optional(),last_ip:a.z.string().optional(),last_login:a.z.string().optional(),user_id:a.z.string()}).catchall(a.z.any()),Hm="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Fm=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=Hm[n[t]&63];return e};const rf=a.z.object({audience:a.z.string().optional(),recipient:a.z.string().optional(),createUpnClaim:a.z.boolean().optional(),mapUnknownClaimsAsIs:a.z.boolean().optional(),passthroughClaimsWithNoMapping:a.z.boolean().optional(),mapIdentities:a.z.boolean().optional(),signatureAlgorithm:a.z.string().optional(),digestAlgorithm:a.z.string().optional(),issuer:a.z.string().optional(),destination:a.z.string().optional(),lifetimeInSeconds:a.z.number().optional(),signResponse:a.z.boolean().optional(),nameIdentifierFormat:a.z.string().optional(),nameIdentifierProbes:a.z.array(a.z.string()).optional(),authnContextClassRef:a.z.string().optional(),mappings:a.z.record(a.z.string()).optional()}),ts=a.z.object({id:a.z.string(),name:a.z.string(),callbacks:a.z.array(a.z.string()).default([]).optional().openapi({description:"Comma-separated list of URLs whitelisted to use as a callback to the client after authentication."}),allowed_origins:a.z.array(a.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:a.z.array(a.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:a.z.array(a.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:a.z.array(a.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:a.z.object({samlp:rf.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:a.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:a.z.string().default(()=>Fm()).optional(),disable_sign_ups:a.z.boolean().optional().default(!1).openapi({description:"Prevents users from signing up using the hosted login page. This is not available in auth0"})}),pn=a.z.object({created_at:a.z.string().transform(t=>t===null?"":t),updated_at:a.z.string().transform(t=>t===null?"":t),...ts.shape});var Jt=(t=>(t.TOKEN="token",t.TOKEN_ID_TOKEN="token id_token",t.CODE="code",t))(Jt||{}),Zt=(t=>(t.QUERY="query",t.FRAGMENT="fragment",t.FORM_POST="form_post",t.WEB_MESSAGE="web_message",t.SAML_POST="saml_post",t))(Zt||{}),Js=(t=>(t.S256="S256",t.Plain="plain",t))(Js||{});const el=a.z.object({client_id:a.z.string(),vendor_id:a.z.string().optional(),act_as:a.z.string().optional(),response_type:a.z.nativeEnum(Jt).optional(),response_mode:a.z.nativeEnum(Zt).optional(),redirect_uri:a.z.string().optional(),audience:a.z.string().optional(),state:a.z.string().optional(),nonce:a.z.string().optional(),scope:a.z.string().optional(),prompt:a.z.string().optional(),code_challenge_method:a.z.nativeEnum(Js).optional(),code_challenge:a.z.string().optional(),username:a.z.string().optional(),ui_locales:a.z.string().optional()}),Sa=a.z.object({colors:a.z.object({primary:a.z.string(),page_background:a.z.object({type:a.z.string().optional(),start:a.z.string().optional(),end:a.z.string().optional(),angle_deg:a.z.number().optional()}).optional()}).optional(),logo_url:a.z.string().optional(),favicon_url:a.z.string().optional(),font:a.z.object({url:a.z.string()}).optional()}),ns=a.z.object({id:a.z.string().optional(),name:a.z.string(),strategy:a.z.string(),options:a.z.object({kid:a.z.string().optional(),team_id:a.z.string().optional(),realms:a.z.string().optional(),client_id:a.z.string().optional(),client_secret:a.z.string().optional(),app_secret:a.z.string().optional(),scope:a.z.string().optional(),authorization_endpoint:a.z.string().default("").optional(),token_endpoint:a.z.string().default("").optional(),userinfo_endpoint:a.z.string().default("").optional(),jwks_uri:a.z.string().default("").optional(),discovery_url:a.z.string().default("").optional(),issuer:a.z.string().default("").optional()}).default({}).optional(),enabled_clients:a.z.array(a.z.string()).default([]).optional(),response_type:a.z.custom().optional(),response_mode:a.z.custom().optional()}),Dt=a.z.object({id:a.z.string(),created_at:a.z.string().transform(t=>t===null?"":t),updated_at:a.z.string().transform(t=>t===null?"":t)}).extend(ns.shape),rs=a.z.object({name:a.z.string(),audience:a.z.string(),sender_email:a.z.string().email(),sender_name:a.z.string(),support_url:a.z.string().url().optional(),logo:a.z.string().url().optional(),primary_color:a.z.string().optional(),secondary_color:a.z.string().optional(),language:a.z.string().optional(),id:a.z.string().optional()}),Hn=a.z.object({created_at:a.z.string().transform(t=>t===null?"":t),updated_at:a.z.string().transform(t=>t===null?"":t),...rs.shape,id:a.z.string()}),sf=a.z.object({logoUrl:a.z.string(),loginBackgroundImage:a.z.string().nullish(),style:a.z.object({primaryColor:a.z.string(),buttonTextColor:a.z.string(),primaryHoverColor:a.z.string()}),supportEmail:a.z.string().nullable(),supportUrl:a.z.string().nullable(),name:a.z.string(),showGreyishBackground:a.z.boolean().optional(),termsAndConditionsUrl:a.z.string().nullable(),companyName:a.z.string().optional(),checkoutHideSocial:a.z.boolean().optional(),siteUrl:a.z.string().nullable(),manageSubscriptionsUrl:a.z.string().optional()});a.z.object({...pn.shape,tenant:Hn,connections:a.z.array(Dt)});const of=a.z.enum(["password_reset","email_verification","otp","authorization_code","oauth2_state","ticket"]),af=a.z.object({code_id:a.z.string().openapi({description:"The code that will be used in for instance an email verification flow"}),login_id:a.z.string().openapi({description:"The id of the login session that the code is connected to"}),connection_id:a.z.string().optional().openapi({description:"The connection that the code is connected to"}),code_type:of,code_verifier:a.z.string().optional().openapi({description:"The code verifier used in PKCE in outbound flows"}),expires_at:a.z.string(),used_at:a.z.string().optional(),user_id:a.z.string().optional()}),Km=a.z.object({...af.shape,created_at:a.z.string()}),tl=a.z.object({domain:a.z.string(),type:a.z.enum(["auth0_managed_certs","self_managed_certs"]),verification_method:a.z.enum(["txt"]).optional(),tls_policy:a.z.enum(["recommended"]).optional(),custom_client_ip_header:a.z.enum(["true-client-ip","cf-connecting-ip","x-forwarded-for","x-azure-clientip","null"]).optional(),domain_metadata:a.z.record(a.z.string().max(255)).optional()}),Mn=a.z.object({...tl.shape,custom_domain_id:a.z.string(),primary:a.z.boolean(),status:a.z.enum(["disabled","pending","pending_verification","ready"]),origin_domain_name:a.z.string().optional(),verification:a.z.object({}).optional(),tls_policy:a.z.string().optional()}),is=a.z.object({trigger_id:a.z.enum(["pre-user-signup","post-user-registration","post-user-login"]),enabled:a.z.boolean().default(!1),url:a.z.string(),hook_id:a.z.string().optional(),synchronous:a.z.boolean().default(!1),priority:a.z.number().optional()}),qn=is.extend({...ef.shape,hook_id:a.z.string()}),nl=a.z.object({alg:a.z.enum(["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512"]),e:a.z.string(),kid:a.z.string(),kty:a.z.enum(["RSA","EC","oct"]),n:a.z.string(),x5t:a.z.string().optional(),x5c:a.z.array(a.z.string()).optional(),use:a.z.enum(["sig","enc"]).optional()}),cf=a.z.object({keys:a.z.array(nl)}),Aa=a.z.object({issuer:a.z.string(),authorization_endpoint:a.z.string(),token_endpoint:a.z.string(),device_authorization_endpoint:a.z.string(),userinfo_endpoint:a.z.string(),mfa_challenge_endpoint:a.z.string(),jwks_uri:a.z.string(),registration_endpoint:a.z.string(),revocation_endpoint:a.z.string(),scopes_supported:a.z.array(a.z.string()),response_types_supported:a.z.array(a.z.string()),code_challenge_methods_supported:a.z.array(a.z.string()),response_modes_supported:a.z.array(a.z.string()),subject_types_supported:a.z.array(a.z.string()),id_token_signing_alg_values_supported:a.z.array(a.z.string()),token_endpoint_auth_methods_supported:a.z.array(a.z.string()),claims_supported:a.z.array(a.z.string()),request_uri_parameter_supported:a.z.boolean(),request_parameter_supported:a.z.boolean(),token_endpoint_auth_signing_alg_values_supported:a.z.array(a.z.string())}),lf=a.z.object({auth0Client:a.z.string().optional(),authParams:el,expires_at:a.z.string(),deleted_at:a.z.string().optional(),ip:a.z.string().optional(),useragent:a.z.string().optional()}).openapi({description:"This represents a login sesion"}),Wm=a.z.object({...lf.shape,login_id:a.z.string().openapi({description:"This is is used as the state in the universal login"}),created_at:a.z.string(),updated_at:a.z.string()});var me=(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))(me||{});const Gm=a.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"]),uf=a.z.object({name:a.z.string(),version:a.z.string(),env:a.z.object({node:a.z.string().optional()}).optional()}),ss=a.z.object({type:Gm,date:a.z.string(),description:a.z.string().optional(),log_id:a.z.string().optional(),_id:a.z.string().optional(),ip:a.z.string(),user_agent:a.z.string(),details:a.z.any().optional(),isMobile:a.z.boolean(),user_id:a.z.string().optional(),user_name:a.z.string().optional(),connection:a.z.string().optional(),connection_id:a.z.string().optional(),client_id:a.z.string().optional(),client_name:a.z.string().optional(),audience:a.z.string().optional(),scope:a.z.array(a.z.string()).optional(),strategy:a.z.string().optional(),strategy_type:a.z.string().optional(),hostname:a.z.string().optional(),auth0_client:uf.optional()}),df=a.z.object({user_id:a.z.string(),password:a.z.string(),algorithm:a.z.enum(["bcrypt","argon2id"]).default("argon2id")}),Jm=a.z.object({...df.shape,created_at:a.z.string(),updated_at:a.z.string()}),pf=a.z.object({initial_user_agent:a.z.string().describe("First user agent of the device from which this user logged in"),initial_ip:a.z.string().describe("First IP address associated with this session"),initial_asn:a.z.string().describe("First autonomous system number associated with this session"),last_user_agent:a.z.string().describe("Last user agent of the device from which this user logged in"),last_ip:a.z.string().describe("Last IP address from which this user logged in"),last_asn:a.z.string().describe("Last autonomous system number from which this user logged in")}),ff=a.z.object({id:a.z.string(),revoked_at:a.z.string().optional(),used_at:a.z.string().optional(),user_id:a.z.string().describe("The user ID associated with the session"),expires_at:a.z.string().optional(),idle_expires_at:a.z.string().optional(),device:pf.describe("Metadata related to the device used in the session"),clients:a.z.array(a.z.string()).describe("List of client details for the session")}),Zs=a.z.object({created_at:a.z.string(),updated_at:a.z.string(),authenticated_at:a.z.string(),last_interaction_at:a.z.string(),...ff.shape}),Ea=a.z.object({kid:a.z.string().openapi({description:"The key id of the signing key"}),cert:a.z.string().openapi({description:"The public certificate of the signing key"}),fingerprint:a.z.string().openapi({description:"The cert fingerprint"}),thumbprint:a.z.string().openapi({description:"The cert thumbprint"}),pkcs7:a.z.string().optional().openapi({description:"The private key in pkcs7 format"}),current:a.z.boolean().optional().openapi({description:"True if the key is the current key"}),next:a.z.boolean().optional().openapi({description:"True if the key is the next key"}),previous:a.z.boolean().optional().openapi({description:"True if the key is the previous key"}),current_since:a.z.string().optional().openapi({description:"The date and time when the key became the current key"}),current_until:a.z.string().optional().openapi({description:"The date and time when the current key was rotated"}),revoked:a.z.boolean().optional().openapi({description:"True if the key is revoked"}),revoked_at:a.z.string().optional().openapi({description:"The date and time when the key was revoked"})});var jr=(t=>(t.RefreshToken="refresh_token",t.AuthorizationCode="authorization_code",t.ClientCredential="client_credentials",t.Passwordless="passwordless",t.Password="password",t))(jr||{});const hf=a.z.object({access_token:a.z.string(),id_token:a.z.string().optional(),scope:a.z.string().optional(),state:a.z.string().optional(),refresh_token:a.z.string().optional(),token_type:a.z.string(),expires_in:a.z.number()});a.z.object({code:a.z.string(),state:a.z.string().optional()});const gf=a.z.object({button_border_radius:a.z.number(),button_border_weight:a.z.number(),buttons_style:a.z.enum(["pill"]),input_border_radius:a.z.number(),input_border_weight:a.z.number(),inputs_style:a.z.enum(["pill"]),show_widget_shadow:a.z.boolean(),widget_border_weight:a.z.number(),widget_corner_radius:a.z.number()}),mf=a.z.object({base_focus_color:a.z.string(),base_hover_color:a.z.string(),body_text:a.z.string(),captcha_widget_theme:a.z.enum(["auto"]),error:a.z.string(),header:a.z.string(),icons:a.z.string(),input_background:a.z.string(),input_border:a.z.string(),input_filled_text:a.z.string(),input_labels_placeholders:a.z.string(),links_focused_components:a.z.string(),primary_button:a.z.string(),primary_button_label:a.z.string(),secondary_button_border:a.z.string(),secondary_button_label:a.z.string(),success:a.z.string(),widget_background:a.z.string(),widget_border:a.z.string()}),un=a.z.object({bold:a.z.boolean(),size:a.z.number()}),_f=a.z.object({body_text:un,buttons_text:un,font_url:a.z.string(),input_labels:un,links:un,links_style:a.z.enum(["normal"]),reference_text_size:a.z.number(),subtitle:un,title:un}),yf=a.z.object({background_color:a.z.string(),background_image_url:a.z.string(),page_layout:a.z.enum(["center"])}),vf=a.z.object({header_text_alignment:a.z.enum(["center"]),logo_height:a.z.number(),logo_position:a.z.enum(["center"]),logo_url:a.z.string(),social_buttons_layout:a.z.enum(["bottom"])}),wf=a.z.object({borders:gf,colors:mf,displayName:a.z.string(),fonts:_f,page_background:yf,widget:vf}),Zm=wf.extend({themeId:a.z.string()}),Ri=a.z.object({universal_login_experience:a.z.enum(["new","classic"]).default("new"),identifier_first:a.z.boolean().default(!0),password_first:a.z.boolean().default(!1),webauthn_platform_first_factor:a.z.boolean()}),Li=a.z.object({name:a.z.string(),enabled:a.z.boolean().optional().default(!0),default_from_address:a.z.string().optional(),credentials:a.z.union([a.z.object({accessKeyId:a.z.string(),secretAccessKey:a.z.string(),region:a.z.string()}),a.z.object({smtp_host:a.z.array(a.z.string()),smtp_port:a.z.number(),smtp_user:a.z.string(),smtp_pass:a.z.string()}),a.z.object({api_key:a.z.string(),domain:a.z.string().optional()}),a.z.object({connectionString:a.z.string()}),a.z.object({tenantId:a.z.string(),clientId:a.z.string(),clientSecret:a.z.string()})]),settings:a.z.object({}).optional()}),rl=a.z.object({id:a.z.string(),session_id:a.z.string(),user_id:a.z.string(),client_id:a.z.string(),expires_at:a.z.string().optional(),idle_expires_at:a.z.string().optional(),last_exchanged_at:a.z.string().optional(),device:pf,resource_servers:a.z.array(a.z.object({audience:a.z.string(),scopes:a.z.string()})),rotating:a.z.boolean()}),Ym=a.z.object({created_at:a.z.string(),...rl.shape});function Xm(t){const[e,n]=t.split("|");if(!e||!n)throw new Error(`Invalid user_id: ${t}`);return{connection:e,id:n}}const Qm=new a.OpenAPIHono().openapi(a.createRoute({tags:["branding"],method:"get",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Sa}},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(a.createRoute({tags:["branding"],method:"patch",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.object(Sa.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 N=class extends Error{constructor(e=500,n){super(n==null?void 0:n.message,{cause:n==null?void 0:n.cause});ee(this,"res");ee(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})}},os=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function bf(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function e_(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 t_(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 kf={exports:{}};const n_={},r_=Object.freeze(Object.defineProperty({__proto__:null,default:n_},Symbol.toStringTag,{value:"Module"})),i_=e_(r_);(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 Qm=="function"&&t&&t.exports?t.exports=n():(e.dcodeIO=e.dcodeIO||{}).bcrypt=n()})(cs,function(){var e={},n=null;function r(j){if(t&&t.exports)try{return n_.randomBytes(j)}catch{}try{var z;return(self.crypto||self.msCrypto).getRandomValues(z=new Uint32Array(j)),Array.prototype.slice.call(z)}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,z){if(j=j||_,typeof j!="number")throw Error("Illegal arguments: "+typeof j+", "+typeof z);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,z,E){if(typeof z=="function"&&(E=z,z=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){o(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(L,X){if(L){$(L);return}k(X)})})},e.hashSync=function(j,z){if(typeof z>"u"&&(z=_),typeof z=="number"&&(z=e.genSaltSync(z)),typeof j!="string"||typeof z!="string")throw Error("Illegal arguments: "+typeof j+", "+typeof z);return Ge(j,z)},e.hash=function(j,z,E,x){function k($){typeof j=="string"&&typeof z=="number"?e.genSalt(z,function(L,X){Ge(j,X,$,x)}):typeof j=="string"&&typeof z=="string"?Ge(j,z,$,x):o($.bind(this,Error("Illegal arguments: "+typeof j+", "+typeof z)))}if(E){if(typeof E!="function")throw Error("Illegal callback: "+typeof E);k(E)}else return new Promise(function($,L){k(function(X,G){if(X){L(X);return}$(G)})})};function s(j,z){for(var E=0,x=0,k=0,$=j.length;k<$;++k)j.charCodeAt(k)===z.charCodeAt(k)?++E:++x;return E<0?!1:x===0}e.compareSync=function(j,z){if(typeof j!="string"||typeof z!="string")throw Error("Illegal arguments: "+typeof j+", "+typeof z);return z.length!==60?!1:s(e.hashSync(j,z.substr(0,z.length-31)),z)},e.compare=function(j,z,E,x){function k($){if(typeof j!="string"||typeof z!="string"){o($.bind(this,Error("Illegal arguments: "+typeof j+", "+typeof z)));return}if(z.length!==60){o($.bind(this,null,!1));return}e.hash(j,z.substr(0,29),function(L,X){L?$(L):$(null,s(X,z))},x)}if(E){if(typeof E!="function")throw Error("Illegal callback: "+typeof E);k(E)}else return new Promise(function($,L){k(function(X,G){if(X){L(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 o=typeof process<"u"&&process&&typeof process.nextTick=="function"?typeof setImmediate=="function"?setImmediate:process.nextTick:setTimeout;function c(j){var z=[],E=0;return v.encodeUTF16toUTF8(function(){return E>=j.length?null:j.charCodeAt(E++)},function(x){z.push(x)}),z}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,z){var E=0,x=[],k,$;if(z<=0||z>j.length)throw Error("Illegal len: "+z);for(;E<z;){if(k=j[E++]&255,x.push(l[k>>2&63]),k=(k&3)<<4,E>=z){x.push(l[k&63]);break}if($=j[E++]&255,k|=$>>4&15,x.push(l[k&63]),k=($&15)<<2,E>=z){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,z){var E=0,x=j.length,k=0,$=[],L,X,G,ie,ce,H;if(z<=0)throw Error("Illegal len: "+z);for(;E<x-1&&k<z&&(H=j.charCodeAt(E++),L=H<u.length?u[H]:-1,H=j.charCodeAt(E++),X=H<u.length?u[H]:-1,!(L==-1||X==-1||(ce=L<<2>>>0,ce|=(X&48)>>4,$.push(p(ce)),++k>=z||E>=x)||(H=j.charCodeAt(E++),G=H<u.length?u[H]:-1,G==-1)||(ce=(X&15)<<4>>>0,ce|=(G&60)>>2,$.push(p(ce)),++k>=z||E>=x)));)H=j.charCodeAt(E++),ie=H<u.length?u[H]:-1,ce=(G&3)<<6>>>0,ce|=ie,$.push(p(ce)),++k;var Ie=[];for(E=0;E<k;E++)Ie.push($[E].charCodeAt(0));return Ie}var v=function(){var j={};return j.MAX_CODEPOINT=1114111,j.encodeUTF8=function(z,E){var x=null;for(typeof z=="number"&&(x=z,z=function(){return null});x!==null||(x=z())!==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(z,E){for(var x,k,$,L,X=function(G){G=G.slice(0,G.indexOf(null));var ie=Error(G.toString());throw ie.name="TruncatedError",ie.bytes=G,ie};(x=z())!==null;)if(!(x&128))E(x);else if((x&224)===192)(k=z())===null&&X([x,k]),E((x&31)<<6|k&63);else if((x&240)===224)((k=z())===null||($=z())===null)&&X([x,k,$]),E((x&15)<<12|(k&63)<<6|$&63);else if((x&248)===240)((k=z())===null||($=z())===null||(L=z())===null)&&X([x,k,$,L]),E((x&7)<<18|(k&63)<<12|($&63)<<6|L&63);else throw RangeError("Illegal starting byte: "+x)},j.UTF16toUTF8=function(z,E){for(var x,k=null;(x=k!==null?k:z())!==null;){if(x>=55296&&x<=57343&&(k=z())!==null&&k>=56320&&k<=57343){E((x-55296)*1024+k-56320+65536),k=null;continue}E(x)}k!==null&&E(k)},j.UTF8toUTF16=function(z,E){var x=null;for(typeof z=="number"&&(x=z,z=function(){return null});x!==null||(x=z())!==null;)x<=65535?E(x):(x-=65536,E((x>>10)+55296),E(x%1024+56320)),x=null},j.encodeUTF16toUTF8=function(z,E){j.UTF16toUTF8(z,function(x){j.encodeUTF8(x,E)})},j.decodeUTF8toUTF16=function(z,E){j.decodeUTF8(z,function(x){j.UTF8toUTF16(x,E)})},j.calculateCodePoint=function(z){return z<128?1:z<2048?2:z<65536?3:4},j.calculateUTF8=function(z){for(var E,x=0;(E=z())!==null;)x+=j.calculateCodePoint(E);return x},j.calculateUTF16asUTF8=function(z){var E=0,x=0;return j.UTF16toUTF8(z,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,N=[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],R=[1332899944,1700884034,1701343084,1684370003,1668446532,1869963892];function te(j,z,E,x){var k,$=j[z],L=j[z+1];return $^=E[0],k=x[$>>>24],k+=x[256|$>>16&255],k^=x[512|$>>8&255],k+=x[768|$&255],L^=k^E[1],k=x[L>>>24],k+=x[256|L>>16&255],k^=x[512|L>>8&255],k+=x[768|L&255],$^=k^E[2],k=x[$>>>24],k+=x[256|$>>16&255],k^=x[512|$>>8&255],k+=x[768|$&255],L^=k^E[3],k=x[L>>>24],k+=x[256|L>>16&255],k^=x[512|L>>8&255],k+=x[768|L&255],$^=k^E[4],k=x[$>>>24],k+=x[256|$>>16&255],k^=x[512|$>>8&255],k+=x[768|$&255],L^=k^E[5],k=x[L>>>24],k+=x[256|L>>16&255],k^=x[512|L>>8&255],k+=x[768|L&255],$^=k^E[6],k=x[$>>>24],k+=x[256|$>>16&255],k^=x[512|$>>8&255],k+=x[768|$&255],L^=k^E[7],k=x[L>>>24],k+=x[256|L>>16&255],k^=x[512|L>>8&255],k+=x[768|L&255],$^=k^E[8],k=x[$>>>24],k+=x[256|$>>16&255],k^=x[512|$>>8&255],k+=x[768|$&255],L^=k^E[9],k=x[L>>>24],k+=x[256|L>>16&255],k^=x[512|L>>8&255],k+=x[768|L&255],$^=k^E[10],k=x[$>>>24],k+=x[256|$>>16&255],k^=x[512|$>>8&255],k+=x[768|$&255],L^=k^E[11],k=x[L>>>24],k+=x[256|L>>16&255],k^=x[512|L>>8&255],k+=x[768|L&255],$^=k^E[12],k=x[$>>>24],k+=x[256|$>>16&255],k^=x[512|$>>8&255],k+=x[768|$&255],L^=k^E[13],k=x[L>>>24],k+=x[256|L>>16&255],k^=x[512|L>>8&255],k+=x[768|L&255],$^=k^E[14],k=x[$>>>24],k+=x[256|$>>16&255],k^=x[512|$>>8&255],k+=x[768|$&255],L^=k^E[15],k=x[L>>>24],k+=x[256|L>>16&255],k^=x[512|L>>8&255],k+=x[768|L&255],$^=k^E[16],j[z]=L^E[w+1],j[z+1]=$,j}function fe(j,z){for(var E=0,x=0;E<4;++E)x=x<<8|j[z]&255,z=(z+1)%j.length;return{key:x,offp:z}}function le(j,z,E){for(var x=0,k=[0,0],$=z.length,L=E.length,X,G=0;G<$;G++)X=fe(j,x),x=X.offp,z[G]=z[G]^X.key;for(G=0;G<$;G+=2)k=te(k,0,z,E),z[G]=k[0],z[G+1]=k[1];for(G=0;G<L;G+=2)k=te(k,0,z,E),E[G]=k[0],E[G+1]=k[1]}function Ve(j,z,E,x){for(var k=0,$=[0,0],L=E.length,X=x.length,G,ie=0;ie<L;ie++)G=fe(z,k),k=G.offp,E[ie]=E[ie]^G.key;for(k=0,ie=0;ie<L;ie+=2)G=fe(j,k),k=G.offp,$[0]^=G.key,G=fe(j,k),k=G.offp,$[1]^=G.key,$=te($,0,E,x),E[ie]=$[0],E[ie+1]=$[1];for(ie=0;ie<X;ie+=2)G=fe(j,k),k=G.offp,$[0]^=G.key,G=fe(j,k),k=G.offp,$[1]^=G.key,$=te($,0,E,x),x[ie]=$[0],x[ie+1]=$[1]}function at(j,z,E,x,k){var $=R.slice(),L=$.length,X;if(E<4||E>31)if(X=Error("Illegal number of rounds (4-31): "+E),x){o(x.bind(this,X));return}else throw X;if(z.length!==f)if(X=Error("Illegal salt length: "+z.length+" != "+f),x){o(x.bind(this,X));return}else throw X;E=1<<E>>>0;var G,ie,ce=0,H;Int32Array?(G=new Int32Array(N),ie=new Int32Array(B)):(G=N.slice(),ie=B.slice()),Ve(z,j,G,ie);function Ie(){if(k&&k(ce/E),ce<E)for(var he=Date.now();ce<E&&(ce=ce+1,le(j,G,ie),le(z,G,ie),!(Date.now()-he>S)););else{for(ce=0;ce<64;ce++)for(H=0;H<L>>1;H++)te($,H<<1,G,ie);var xe=[];for(ce=0;ce<L;ce++)xe.push(($[ce]>>24&255)>>>0),xe.push(($[ce]>>16&255)>>>0),xe.push(($[ce]>>8&255)>>>0),xe.push(($[ce]&255)>>>0);if(x){x(null,xe);return}else return xe}x&&o(Ie)}if(typeof x<"u")Ie();else for(var ln;;)if(typeof(ln=Ie())<"u")return ln||[]}function Ge(j,z,E,x){var k;if(typeof j!="string"||typeof z!="string")if(k=Error("Invalid string / salt: Not a string"),E){o(E.bind(this,k));return}else throw k;var $,L;if(z.charAt(0)!=="$"||z.charAt(1)!=="2")if(k=Error("Invalid salt version: "+z.substring(0,2)),E){o(E.bind(this,k));return}else throw k;if(z.charAt(2)==="$")$="\0",L=3;else{if($=z.charAt(2),$!=="a"&&$!=="b"&&$!=="y"||z.charAt(3)!=="$")if(k=Error("Invalid salt revision: "+z.substring(2,4)),E){o(E.bind(this,k));return}else throw k;L=4}if(z.charAt(L+2)>"$")if(k=Error("Missing salt rounds"),E){o(E.bind(this,k));return}else throw k;var X=parseInt(z.substring(L,L+1),10)*10,G=parseInt(z.substring(L+1,L+2),10),ie=X+G,ce=z.substring(L+3,L+25);j+=$>="a"?"\0":"";var H=c(j),Ie=m(ce,f);function ln(he){var xe=[];return xe.push("$2"),$>="a"&&xe.push($),xe.push("$"),ie<10&&xe.push("0"),xe.push(ie.toString()),xe.push("$"),xe.push(h(Ie,Ie.length)),xe.push(h(he,R.length*4-1)),xe.join("")}if(typeof E>"u")return ln(at(H,Ie,ie));at(H,Ie,ie,function(he,xe){he?E(he,null):E(null,ln(xe))},x)}return e.encodeBase64=h,e.decodeBase64=m,e})})(kf);var r_=kf.exports;const oi=bf(r_),i_="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let s_=t=>crypto.getRandomValues(new Uint8Array(t)),o_=(t,e,n)=>{let r=(2<<Math.log2(t.length-1))-1,i=-~(1.6*r*e/t.length);return(s=e)=>{let o="";for(;;){let c=n(i),l=i;for(;l--;)if(o+=t[c[l]&r]||"",o.length===s)return o}}},a_=(t,e=21)=>o_(t,e,s_),Re=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=i_[n[t]&63];return e};const c_=24;function ai(){return a_("0123456789abcdef",c_)()}function Tu(t){if(!t.includes("|"))return console.error("Invalid user_id format"),t;const[,e]=t.split("|");return e}async function Xs(t,e,n){return(await t.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${n}`})).users}async function Jn({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 Qs({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 o=await t.get(e,(c=i[0])==null?void 0:c.linked_to);if(!o)throw new Error("Primary account not found");return o}async function vn({userAdapter:t,tenant_id:e,email:n,provider:r}){const i=await Jn({userAdapter:t,tenant_id:e,email:n,provider:r});return i?i.linked_to?t.get(e,i.linked_to):i:null}const Yt=a.z.object({page:a.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:a.z.string().min(1).optional().default("10").transform(t=>parseInt(t,10)).openapi({description:"The number of items per page"}),include_totals:a.z.string().optional().default("false").transform(t=>t==="true").openapi({description:"If the total number of items should be included in the response"}),sort:a.z.string().regex(/^.+:(-1|1)$/).optional().openapi({description:"A property that should have the format 'string:-1' or 'string:1'"}),q:a.z.string().optional().openapi({description:"A lucene query string used to filter the results"})});function ur(t){if(!t)return;const[e,n]=t.split(":"),r=n==="1"?"asc":"desc";if(!(!e||!r))return{sort_by:e,sort_order:r}}function be(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:[]}}var l_={deno:"Deno",bun:"Bun",workerd:"Cloudflare-Workers",node:"Node.js"},u_=()=>{var n,r;const t=globalThis;if(typeof navigator<"u"&&typeof navigator.userAgent=="string"){for(const[i,s]of Object.entries(l_))if(d_(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"},d_=t=>navigator.userAgent.startsWith(t);function Qe(t,e){u_()==="workerd"&&t.executionCtx.waitUntil(e)}const Pu=nn.extend({users:a.z.array(bt)}),p_=nn.extend({sessions:a.z.array(Ys)}),f_=new a.OpenAPIHono().openapi(a.createRoute({tags:["users"],method:"get",path:"/",request:{query:Yt,headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:a.z.union([a.z.array(bt),Pu])}},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":o}=t.req.valid("header");if(s!=null&&s.includes("identities.profileData.email")){const p=s.split("=")[1],m=(await t.env.data.users.list(o,{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(o,v.linked_to);if(!f)throw new C(500,{message:"Primary account not found"});return t.json([bt.parse(f)])}const c=["-_exists_:linked_to"];s&&c.push(s);const l=await t.env.data.users.list(o,{page:e,per_page:n,include_totals:r,sort:ur(i),q:c.join(" ")}),u=l.users.filter(p=>!p.linked_to);return r?t.json(Pu.parse({users:u,length:l.length,start:l.start,limit:l.limit})):t.json(a.z.array(bt).parse(u))}).openapi(a.createRoute({tags:["users"],method:"get",path:"/{user_id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({user_id:a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:bt}},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 C(404);if(r.linked_to)throw new C(404,{message:"User is linked to another user"});return t.json(r)}).openapi(a.createRoute({tags:["users"],method:"delete",path:"/{user_id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({user_id:a.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 C(404);return t.text("OK")}).openapi(a.createRoute({tags:["users"],method:"post",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.object({...ns.shape})}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:bt}},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 C(400,{message:"Email is required"});const i=r.toLowerCase(),s=`${n.provider}|${n.user_id||ai()}`;try{const o=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",o.user_id);const c=be(t,{type:me.SUCCESS_API_OPERATION,description:"User created"});Qe(t,t.env.data.logs.create(e,c));const l={...o,identities:[{connection:o.connection,provider:o.provider,user_id:Tu(o.user_id),isSocial:o.is_social}]};return t.json(bt.parse(l),{status:201})}catch(o){throw o.message==="User already exists"?new C(409,{message:"User already exists"}):o}}).openapi(a.createRoute({tags:["users"],method:"patch",path:"/{user_id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.object({...ns.shape,verify_email:a.z.boolean(),password:a.z.string()}).partial()}}},params:a.z.object({user_id:a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{var u;const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),{user_id:r}=t.req.valid("param"),{verify_email:i,password:s,...o}=n,c=await t.env.data.users.get(e,r);if(!c)throw new C(404);if(o.email&&o.email!==c.email){const p=await Xs(t.env.data.users,e,o.email);if(p.length&&p.some(h=>h.user_id!==r))throw new C(409,{message:"Another user with the same email address already exists."})}if(c.linked_to)throw new C(404,{message:"User is linked to another user"});if(await t.env.data.users.update(e,r,o),s){const p=(u=c.identities)==null?void 0:u.find(h=>h.connection==="Username-Password-Authentication");if(!p)throw new C(400,{message:"User does not have a password identity"});await t.env.data.passwords.update(e,{user_id:`${p.provider}|${p.user_id}`,password:oi.hashSync(s,10),algorithm:"bcrypt"})}const l=await t.env.data.users.get(e,r);if(!l)throw new C(500);return t.json(l)}).openapi(a.createRoute({tags:["users"],method:"post",path:"/{user_id}/identities",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.union([a.z.object({link_with:a.z.string()}),a.z.object({user_id:a.z.string(),provider:a.z.string(),connection:a.z.string().optional()})])}}},params:a.z.object({user_id:a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:a.z.array(a.z.object({connection:a.z.string(),provider:a.z.string(),user_id:a.z.string(),isSocial:a.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 C(400,{message:"Linking an inexistent identity is not allowed."});await t.env.data.users.update(e,i,{linked_to:r});const o=await t.env.data.users.list(e,{page:0,per_page:10,include_totals:!1,q:`linked_to:${r}`}),c=[s,...o.users].map(l=>({connection:l.connection,provider:l.provider,user_id:Tu(l.user_id),isSocial:l.is_social}));return t.json(c,{status:201})}).openapi(a.createRoute({tags:["users"],method:"delete",path:"/{user_id}/identities/{provider}/{linked_user_id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({user_id:a.z.string(),provider:a.z.string(),linked_user_id:a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:a.z.array(bt)}},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 C(404);return t.json([bt.parse(s)])}).openapi(a.createRoute({tags:["users"],method:"get",path:"/{user_id}/sessions",request:{query:Yt,headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({user_id:a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:a.z.union([a.z.array(Ys),p_])}},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)});/*! *****************************************************************************
|
|
5
|
+
*/(function(e,n){typeof t_=="function"&&t&&t.exports?t.exports=n():(e.dcodeIO=e.dcodeIO||{}).bcrypt=n()})(os,function(){var e={},n=null;function r(j){if(t&&t.exports)try{return i_.randomBytes(j)}catch{}try{var z;return(self.crypto||self.msCrypto).getRandomValues(z=new Uint32Array(j)),Array.prototype.slice.call(z)}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,z){if(j=j||_,typeof j!="number")throw Error("Illegal arguments: "+typeof j+", "+typeof z);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,z,E){if(typeof z=="function"&&(E=z,z=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){o(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(L,X){if(L){$(L);return}k(X)})})},e.hashSync=function(j,z){if(typeof z>"u"&&(z=_),typeof z=="number"&&(z=e.genSaltSync(z)),typeof j!="string"||typeof z!="string")throw Error("Illegal arguments: "+typeof j+", "+typeof z);return Ge(j,z)},e.hash=function(j,z,E,x){function k($){typeof j=="string"&&typeof z=="number"?e.genSalt(z,function(L,X){Ge(j,X,$,x)}):typeof j=="string"&&typeof z=="string"?Ge(j,z,$,x):o($.bind(this,Error("Illegal arguments: "+typeof j+", "+typeof z)))}if(E){if(typeof E!="function")throw Error("Illegal callback: "+typeof E);k(E)}else return new Promise(function($,L){k(function(X,G){if(X){L(X);return}$(G)})})};function s(j,z){for(var E=0,x=0,k=0,$=j.length;k<$;++k)j.charCodeAt(k)===z.charCodeAt(k)?++E:++x;return E<0?!1:x===0}e.compareSync=function(j,z){if(typeof j!="string"||typeof z!="string")throw Error("Illegal arguments: "+typeof j+", "+typeof z);return z.length!==60?!1:s(e.hashSync(j,z.substr(0,z.length-31)),z)},e.compare=function(j,z,E,x){function k($){if(typeof j!="string"||typeof z!="string"){o($.bind(this,Error("Illegal arguments: "+typeof j+", "+typeof z)));return}if(z.length!==60){o($.bind(this,null,!1));return}e.hash(j,z.substr(0,29),function(L,X){L?$(L):$(null,s(X,z))},x)}if(E){if(typeof E!="function")throw Error("Illegal callback: "+typeof E);k(E)}else return new Promise(function($,L){k(function(X,G){if(X){L(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 o=typeof process<"u"&&process&&typeof process.nextTick=="function"?typeof setImmediate=="function"?setImmediate:process.nextTick:setTimeout;function c(j){var z=[],E=0;return v.encodeUTF16toUTF8(function(){return E>=j.length?null:j.charCodeAt(E++)},function(x){z.push(x)}),z}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,z){var E=0,x=[],k,$;if(z<=0||z>j.length)throw Error("Illegal len: "+z);for(;E<z;){if(k=j[E++]&255,x.push(l[k>>2&63]),k=(k&3)<<4,E>=z){x.push(l[k&63]);break}if($=j[E++]&255,k|=$>>4&15,x.push(l[k&63]),k=($&15)<<2,E>=z){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,z){var E=0,x=j.length,k=0,$=[],L,X,G,ie,ce,H;if(z<=0)throw Error("Illegal len: "+z);for(;E<x-1&&k<z&&(H=j.charCodeAt(E++),L=H<u.length?u[H]:-1,H=j.charCodeAt(E++),X=H<u.length?u[H]:-1,!(L==-1||X==-1||(ce=L<<2>>>0,ce|=(X&48)>>4,$.push(p(ce)),++k>=z||E>=x)||(H=j.charCodeAt(E++),G=H<u.length?u[H]:-1,G==-1)||(ce=(X&15)<<4>>>0,ce|=(G&60)>>2,$.push(p(ce)),++k>=z||E>=x)));)H=j.charCodeAt(E++),ie=H<u.length?u[H]:-1,ce=(G&3)<<6>>>0,ce|=ie,$.push(p(ce)),++k;var Ie=[];for(E=0;E<k;E++)Ie.push($[E].charCodeAt(0));return Ie}var v=function(){var j={};return j.MAX_CODEPOINT=1114111,j.encodeUTF8=function(z,E){var x=null;for(typeof z=="number"&&(x=z,z=function(){return null});x!==null||(x=z())!==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(z,E){for(var x,k,$,L,X=function(G){G=G.slice(0,G.indexOf(null));var ie=Error(G.toString());throw ie.name="TruncatedError",ie.bytes=G,ie};(x=z())!==null;)if(!(x&128))E(x);else if((x&224)===192)(k=z())===null&&X([x,k]),E((x&31)<<6|k&63);else if((x&240)===224)((k=z())===null||($=z())===null)&&X([x,k,$]),E((x&15)<<12|(k&63)<<6|$&63);else if((x&248)===240)((k=z())===null||($=z())===null||(L=z())===null)&&X([x,k,$,L]),E((x&7)<<18|(k&63)<<12|($&63)<<6|L&63);else throw RangeError("Illegal starting byte: "+x)},j.UTF16toUTF8=function(z,E){for(var x,k=null;(x=k!==null?k:z())!==null;){if(x>=55296&&x<=57343&&(k=z())!==null&&k>=56320&&k<=57343){E((x-55296)*1024+k-56320+65536),k=null;continue}E(x)}k!==null&&E(k)},j.UTF8toUTF16=function(z,E){var x=null;for(typeof z=="number"&&(x=z,z=function(){return null});x!==null||(x=z())!==null;)x<=65535?E(x):(x-=65536,E((x>>10)+55296),E(x%1024+56320)),x=null},j.encodeUTF16toUTF8=function(z,E){j.UTF16toUTF8(z,function(x){j.encodeUTF8(x,E)})},j.decodeUTF8toUTF16=function(z,E){j.decodeUTF8(z,function(x){j.UTF8toUTF16(x,E)})},j.calculateCodePoint=function(z){return z<128?1:z<2048?2:z<65536?3:4},j.calculateUTF8=function(z){for(var E,x=0;(E=z())!==null;)x+=j.calculateCodePoint(E);return x},j.calculateUTF16asUTF8=function(z){var E=0,x=0;return j.UTF16toUTF8(z,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],R=[1332899944,1700884034,1701343084,1684370003,1668446532,1869963892];function te(j,z,E,x){var k,$=j[z],L=j[z+1];return $^=E[0],k=x[$>>>24],k+=x[256|$>>16&255],k^=x[512|$>>8&255],k+=x[768|$&255],L^=k^E[1],k=x[L>>>24],k+=x[256|L>>16&255],k^=x[512|L>>8&255],k+=x[768|L&255],$^=k^E[2],k=x[$>>>24],k+=x[256|$>>16&255],k^=x[512|$>>8&255],k+=x[768|$&255],L^=k^E[3],k=x[L>>>24],k+=x[256|L>>16&255],k^=x[512|L>>8&255],k+=x[768|L&255],$^=k^E[4],k=x[$>>>24],k+=x[256|$>>16&255],k^=x[512|$>>8&255],k+=x[768|$&255],L^=k^E[5],k=x[L>>>24],k+=x[256|L>>16&255],k^=x[512|L>>8&255],k+=x[768|L&255],$^=k^E[6],k=x[$>>>24],k+=x[256|$>>16&255],k^=x[512|$>>8&255],k+=x[768|$&255],L^=k^E[7],k=x[L>>>24],k+=x[256|L>>16&255],k^=x[512|L>>8&255],k+=x[768|L&255],$^=k^E[8],k=x[$>>>24],k+=x[256|$>>16&255],k^=x[512|$>>8&255],k+=x[768|$&255],L^=k^E[9],k=x[L>>>24],k+=x[256|L>>16&255],k^=x[512|L>>8&255],k+=x[768|L&255],$^=k^E[10],k=x[$>>>24],k+=x[256|$>>16&255],k^=x[512|$>>8&255],k+=x[768|$&255],L^=k^E[11],k=x[L>>>24],k+=x[256|L>>16&255],k^=x[512|L>>8&255],k+=x[768|L&255],$^=k^E[12],k=x[$>>>24],k+=x[256|$>>16&255],k^=x[512|$>>8&255],k+=x[768|$&255],L^=k^E[13],k=x[L>>>24],k+=x[256|L>>16&255],k^=x[512|L>>8&255],k+=x[768|L&255],$^=k^E[14],k=x[$>>>24],k+=x[256|$>>16&255],k^=x[512|$>>8&255],k+=x[768|$&255],L^=k^E[15],k=x[L>>>24],k+=x[256|L>>16&255],k^=x[512|L>>8&255],k+=x[768|L&255],$^=k^E[16],j[z]=L^E[w+1],j[z+1]=$,j}function fe(j,z){for(var E=0,x=0;E<4;++E)x=x<<8|j[z]&255,z=(z+1)%j.length;return{key:x,offp:z}}function le(j,z,E){for(var x=0,k=[0,0],$=z.length,L=E.length,X,G=0;G<$;G++)X=fe(j,x),x=X.offp,z[G]=z[G]^X.key;for(G=0;G<$;G+=2)k=te(k,0,z,E),z[G]=k[0],z[G+1]=k[1];for(G=0;G<L;G+=2)k=te(k,0,z,E),E[G]=k[0],E[G+1]=k[1]}function Ue(j,z,E,x){for(var k=0,$=[0,0],L=E.length,X=x.length,G,ie=0;ie<L;ie++)G=fe(z,k),k=G.offp,E[ie]=E[ie]^G.key;for(k=0,ie=0;ie<L;ie+=2)G=fe(j,k),k=G.offp,$[0]^=G.key,G=fe(j,k),k=G.offp,$[1]^=G.key,$=te($,0,E,x),E[ie]=$[0],E[ie+1]=$[1];for(ie=0;ie<X;ie+=2)G=fe(j,k),k=G.offp,$[0]^=G.key,G=fe(j,k),k=G.offp,$[1]^=G.key,$=te($,0,E,x),x[ie]=$[0],x[ie+1]=$[1]}function at(j,z,E,x,k){var $=R.slice(),L=$.length,X;if(E<4||E>31)if(X=Error("Illegal number of rounds (4-31): "+E),x){o(x.bind(this,X));return}else throw X;if(z.length!==f)if(X=Error("Illegal salt length: "+z.length+" != "+f),x){o(x.bind(this,X));return}else throw X;E=1<<E>>>0;var G,ie,ce=0,H;Int32Array?(G=new Int32Array(C),ie=new Int32Array(B)):(G=C.slice(),ie=B.slice()),Ue(z,j,G,ie);function Ie(){if(k&&k(ce/E),ce<E)for(var he=Date.now();ce<E&&(ce=ce+1,le(j,G,ie),le(z,G,ie),!(Date.now()-he>S)););else{for(ce=0;ce<64;ce++)for(H=0;H<L>>1;H++)te($,H<<1,G,ie);var xe=[];for(ce=0;ce<L;ce++)xe.push(($[ce]>>24&255)>>>0),xe.push(($[ce]>>16&255)>>>0),xe.push(($[ce]>>8&255)>>>0),xe.push(($[ce]&255)>>>0);if(x){x(null,xe);return}else return xe}x&&o(Ie)}if(typeof x<"u")Ie();else for(var ln;;)if(typeof(ln=Ie())<"u")return ln||[]}function Ge(j,z,E,x){var k;if(typeof j!="string"||typeof z!="string")if(k=Error("Invalid string / salt: Not a string"),E){o(E.bind(this,k));return}else throw k;var $,L;if(z.charAt(0)!=="$"||z.charAt(1)!=="2")if(k=Error("Invalid salt version: "+z.substring(0,2)),E){o(E.bind(this,k));return}else throw k;if(z.charAt(2)==="$")$="\0",L=3;else{if($=z.charAt(2),$!=="a"&&$!=="b"&&$!=="y"||z.charAt(3)!=="$")if(k=Error("Invalid salt revision: "+z.substring(2,4)),E){o(E.bind(this,k));return}else throw k;L=4}if(z.charAt(L+2)>"$")if(k=Error("Missing salt rounds"),E){o(E.bind(this,k));return}else throw k;var X=parseInt(z.substring(L,L+1),10)*10,G=parseInt(z.substring(L+1,L+2),10),ie=X+G,ce=z.substring(L+3,L+25);j+=$>="a"?"\0":"";var H=c(j),Ie=m(ce,f);function ln(he){var xe=[];return xe.push("$2"),$>="a"&&xe.push($),xe.push("$"),ie<10&&xe.push("0"),xe.push(ie.toString()),xe.push("$"),xe.push(h(Ie,Ie.length)),xe.push(h(he,R.length*4-1)),xe.join("")}if(typeof E>"u")return ln(at(H,Ie,ie));at(H,Ie,ie,function(he,xe){he?E(he,null):E(null,ln(xe))},x)}return e.encodeBase64=h,e.decodeBase64=m,e})})(kf);var s_=kf.exports;const ii=bf(s_),o_="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let a_=t=>crypto.getRandomValues(new Uint8Array(t)),c_=(t,e,n)=>{let r=(2<<Math.log2(t.length-1))-1,i=-~(1.6*r*e/t.length);return(s=e)=>{let o="";for(;;){let c=n(i),l=i;for(;l--;)if(o+=t[c[l]&r]||"",o.length===s)return o}}},l_=(t,e=21)=>c_(t,e,a_),qe=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=o_[n[t]&63];return e};const u_=24;function Ys(){return l_("0123456789abcdef",u_)()}function Tu(t){if(!t.includes("|"))return console.error("Invalid user_id format"),t;const[,e]=t.split("|");return e}function d_(t){return async(e,n)=>{if(console.log("got here"),!n.email||!n.email_verified)return t.users.create(e,n);const r=await to({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 be(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 il{constructor(e,n){ee(this,"value");ee(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 il(Math.round(this.milliseconds()*e),"ms")}}class p_{constructor(e){ee(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 xf(t){return await crypto.subtle.digest("SHA-256",t)}const Pu="0123456789abcdef";function Ia(t){const e=new Uint8Array(t);let n="";for(let r=0;r<e.length;r++){const i=e[r]>>4;n+=Pu[i];const s=e[r]&15;n+=Pu[s]}return n}class Sf{constructor(e,n){ee(this,"alphabet");ee(this,"padding");ee(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 o=0;o<i;o++){let c=0;const l=[];for(let p=0;p<8;p++){const h=e[o*8+p];if(h==="="){if(o+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 Sf("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567");new Sf("0123456789ABCDEFGHIJKLMNOPQRSTUV");class Af{constructor(e,n){ee(this,"alphabet");ee(this,"padding");ee(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 o=0;o<i;o++){let c=0,l=0;for(let u=0;u<4;u++){const p=e[o*4+u];if(p==="="){if(o+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 f_=new Af("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),mn=new Af("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_");async function Ru(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 o=new TextEncoder,c=mn.encode(o.encode(JSON.stringify(i)),{includePadding:!1}),l=mn.encode(o.encode(JSON.stringify(s)),{includePadding:!1}),u=o.encode([c,l].join(".")),p=await g_(t).sign(e,u),h=mn.encode(new Uint8Array(p),{includePadding:!1});return[c,l,h].join(".")}function h_(t){const e=t.split(".");return e.length!==3?null:e}function sl(t){const e=h_(t);if(!e)return null;const n=new TextDecoder,r=mn.decode(e[0],{strict:!1}),i=mn.decode(e[1],{strict:!1}),s=JSON.parse(n.decode(r));if(typeof s!="object"||s===null||!("alg"in s)||!m_(s.alg)||"typ"in s&&s.typ!=="JWT")return null;const o=JSON.parse(n.decode(i));if(typeof o!="object"||o===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 o){if(typeof o.exp!="number")return null;c.expiresAt=new Date(o.exp*1e3)}if("iss"in o){if(typeof o.iss!="string")return null;c.issuer=o.iss}if("sub"in o){if(typeof o.sub!="string")return null;c.subject=o.sub}if("aud"in o)if(Array.isArray(o.aud)){for(const l of o.aud)if(typeof l!="string")return null;c.audiences=o.aud}else{if(typeof o.aud!="string")return null;c.audiences=[o.aud]}if("nbf"in o){if(typeof o.nbf!="number")return null;c.notBefore=new Date(o.nbf*1e3)}if("iat"in o){if(typeof o.iat!="number")return null;c.issuedAt=new Date(o.iat*1e3)}if("jti"in o){if(typeof o.jti!="string")return null;c.jwtId=o.jti}return{value:t,header:{...s,typ:"JWT",alg:s.alg},payload:{...o},parts:e,...c}}function g_(t){return new p_(__[t])}function m_(t){return typeof t!="string"?!1:["HS256","HS384","HS512","RS256","RS384","RS512","ES256","ES384","ES512","PS256","PS384","PS512"].includes(t)}const __={RS256:"SHA-256",RS384:"SHA-384",RS512:"SHA-512"};function y_(){const t=new Uint8Array(32);return crypto.getRandomValues(t),mn.encode(t,{includePadding:!1})}function v_(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 w_(t,e){if(e==="plain")return t;const n=new TextEncoder().encode(t),r=await xf(n);return mn.encode(new Uint8Array(r),{includePadding:!1})}const Ni=60*5,Xs=30*24*60*60,Ur=24*60*60,b_="auth-token",za=30*60*1e3,k_=5*60,x_=5*60,S_=30*60*1e3,A_=30*60*1e3,E_=24*60*60*1e3;function Ef(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 I_(t){const e=new Map,n=t.split("; ");for(const r of n){const i=r.split("="),s=i[0],o=i[1]??"";s&&e.set(decodeURIComponent(s),decodeURIComponent(o))}return e}function ol(t){return`${t}-${b_}`}function as(t,e){return e?I_(e).get(ol(t)):void 0}function z_(t){const e={path:"/",httpOnly:!0,secure:!0,maxAge:0};return Ef(ol(t),"",{...e,sameSite:"none"})}function If(t,e){const n={path:"/",httpOnly:!0,secure:!0,maxAge:Xs};return Ef(ol(t),e,{...n,sameSite:"none"})}var al={},Qs={};(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},o=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=o,t.getAllMatches=s,t.nameRegexp=r})(Qs);const cl=Qs,C_={allowBooleanAttributes:!1,unpairedTags:[]};al.validate=function(t,e){e=Object.assign({},C_,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=Uu(t,s),s.err)return s}else if(t[s]==="<"){let o=s;if(s++,t[s]==="!"){s=Vu(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--),!R_(l)){let h;return l.trim().length===0?h="Invalid space after '<'.":h="Tag '"+l+"' is an invalid name.",we("InvalidTag",h,Pe(t,s))}const u=$_(t,s);if(u===!1)return we("InvalidAttr","Attributes for '"+l+"' have open quote.",Pe(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=Mu(p,e);if(m===!0)r=!0;else return we(m.err.code,m.err.msg,Pe(t,h+m.err.line))}else if(c)if(u.tagClosed){if(p.trim().length>0)return we("InvalidTag","Closing tag '"+l+"' can't have attributes or invalid starting.",Pe(t,o));if(n.length===0)return we("InvalidTag","Closing tag '"+l+"' has not been opened.",Pe(t,o));{const h=n.pop();if(l!==h.tagName){let m=Pe(t,h.tagStartPos);return we("InvalidTag","Expected closing tag '"+h.tagName+"' (opened in line "+m.line+", col "+m.col+") instead of closing tag '"+l+"'.",Pe(t,o))}n.length==0&&(i=!0)}}else return we("InvalidTag","Closing tag '"+l+"' doesn't have proper closing.",Pe(t,s));else{const h=Mu(p,e);if(h!==!0)return we(h.err.code,h.err.msg,Pe(t,s-p.length+h.err.line));if(i===!0)return we("InvalidXml","Multiple possible root nodes found.",Pe(t,s));e.unpairedTags.indexOf(l)!==-1||n.push({tagName:l,tagStartPos:o}),r=!0}for(s++;s<t.length;s++)if(t[s]==="<")if(t[s+1]==="!"){s++,s=Vu(t,s);continue}else if(t[s+1]==="?"){if(s=Uu(t,++s),s.err)return s}else break;else if(t[s]==="&"){const h=T_(t,s);if(h==-1)return we("InvalidChar","char '&' is not expected.",Pe(t,s));s=h}else if(i===!0&&!Lu(t[s]))return we("InvalidXml","Extra text at the end",Pe(t,s));t[s]==="<"&&s--}}else{if(Lu(t[s]))continue;return we("InvalidChar","char '"+t[s]+"' is not expected.",Pe(t,s))}if(r){if(n.length==1)return we("InvalidTag","Unclosed tag '"+n[0].tagName+"'.",Pe(t,n[0].tagStartPos));if(n.length>0)return we("InvalidXml","Invalid '"+JSON.stringify(n.map(s=>s.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1})}else return we("InvalidXml","Start tag expected.",1);return!0};function Lu(t){return t===" "||t===" "||t===`
|
|
7
|
+
`||t==="\r"}function Uu(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 we("InvalidXml","XML declaration allowed only at the start of the document.",Pe(t,e));if(t[e]=="?"&&t[e+1]==">"){e++;break}else continue}return e}function Vu(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 N_='"',j_="'";function $_(t,e){let n="",r="",i=!1;for(;e<t.length;e++){if(t[e]===N_||t[e]===j_)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 O_=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function Mu(t,e){const n=cl.getAllMatches(t,O_),r={};for(let i=0;i<n.length;i++){if(n[i][1].length===0)return we("InvalidAttr","Attribute '"+n[i][2]+"' has no space in starting.",xr(n[i]));if(n[i][3]!==void 0&&n[i][4]===void 0)return we("InvalidAttr","Attribute '"+n[i][2]+"' is without value.",xr(n[i]));if(n[i][3]===void 0&&!e.allowBooleanAttributes)return we("InvalidAttr","boolean attribute '"+n[i][2]+"' is not allowed.",xr(n[i]));const s=n[i][2];if(!P_(s))return we("InvalidAttr","Attribute '"+s+"' is an invalid name.",xr(n[i]));if(!r.hasOwnProperty(s))r[s]=1;else return we("InvalidAttr","Attribute '"+s+"' is repeated.",xr(n[i]))}return!0}function B_(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 T_(t,e){if(e++,t[e]===";")return-1;if(t[e]==="#")return e++,B_(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 we(t,e,n){return{err:{code:t,msg:e,line:n.line||n,col:n.col}}}function P_(t){return cl.isName(t)}function R_(t){return cl.isName(t)}function Pe(t,e){const n=t.substring(0,e).split(/\r?\n/);return{line:n.length,col:n[n.length-1].length+1}}function xr(t){return t.startIndex+t[1].length}var ll={};const zf={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}},L_=function(t){return Object.assign({},zf,t)};ll.buildOptions=L_;ll.defaultOptions=zf;class U_{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 V_=U_;const M_=Qs;function q_(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,o="";for(;e<t.length;e++)if(t[e]==="<"&&!s){if(i&&F_(t,e)){e+=7;let c,l;[c,l,e]=D_(t,e+1),l.indexOf("&")===-1&&(n[J_(c)]={regx:RegExp(`&${c};`,"g"),val:l})}else if(i&&K_(t,e))e+=8;else if(i&&W_(t,e))e+=8;else if(i&&G_(t,e))e+=9;else if(H_)s=!0;else throw new Error("Invalid DOCTYPE");r++,o=""}else if(t[e]===">"){if(s?t[e-1]==="-"&&t[e-2]==="-"&&(s=!1,r--):r--,r===0)break}else t[e]==="["?i=!0:o+=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 D_(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 H_(t,e){return t[e+1]==="!"&&t[e+2]==="-"&&t[e+3]==="-"}function F_(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 K_(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 W_(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 G_(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 J_(t){if(M_.isName(t))return t;throw new Error(`Invalid entity name ${t}`)}var Z_=q_;const Y_=/^[-+]?0x[a-fA-F0-9]+$/,X_=/^([\-\+])?(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 Q_={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};function e0(t,e={}){if(e=Object.assign({},Q_,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&&Y_.test(n))return Number.parseInt(n,16);{const r=X_.exec(n);if(r){const i=r[1],s=r[2];let o=t0(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"&&o===""||u===o||i&&u==="-"+o?l:t:s?o===u||i+o===u?l:t:n===u||n===i+u?l:t}}else return t}}function t0(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 n0=e0;function r0(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 Cf=r0;const Nf=Qs,Sr=V_,i0=Z_,s0=n0,o0=Cf;let a0=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=c0,this.parseXml=f0,this.parseTextData=l0,this.resolveNameSpace=u0,this.buildAttributesMap=p0,this.isItStopNode=_0,this.replaceEntitiesValue=g0,this.readStopNodeData=v0,this.saveTextToParentTag=m0,this.addChild=h0,this.ignoreAttributesFn=o0(this.options.ignoreAttributes)}};function c0(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 l0(t,e,n,r,i,s,o){if(t!==void 0&&(this.options.trimValues&&!r&&(t=t.trim()),t.length>0)){o||(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?Na(t,this.options.parseTagValue,this.options.numberParseOptions):t.trim()===t?Na(t,this.options.parseTagValue,this.options.numberParseOptions):t}}function u0(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 d0=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function p0(t,e,n){if(this.options.ignoreAttributes!==!0&&typeof t=="string"){const r=Nf.getAllMatches(t,d0),i=r.length,s={};for(let o=0;o<i;o++){const c=this.resolveNameSpace(r[o][1]);if(this.ignoreAttributesFn(c,e))continue;let l=r[o][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]=Na(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 o={};return o[this.options.attributesGroupName]=s,o}return s}}const f0=function(t){t=t.replace(/\r\n?/g,`
|
|
8
|
+
`);const e=new Sr("!xml");let n=e,r="",i="";for(let s=0;s<t.length;s++)if(t[s]==="<")if(t[s+1]==="/"){const c=fn(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 Sr(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=fn(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=i0(t,s);this.docTypeEntities=c.entities,s=c.i}else if(t.substr(s+1,2)==="!["){const c=fn(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 Sr(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 Sr(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 Sr(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 h0(t,e,n){const r=this.options.updateTag(e.tagname,n,e[":@"]);r===!1||(typeof r=="string"&&(e.tagname=r),t.addChild(e))}const g0=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 m0(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 _0(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 y0(t,e,n=">"){let r,i="";for(let s=e;s<t.length;s++){let o=t[s];if(r)o===r&&(r="");else if(o==='"'||o==="'")r=o;else if(o===n[0])if(n[1]){if(t[s+1]===n[1])return{data:i,index:s}}else return{data:i,index:s};else o===" "&&(o=" ");i+=o}}function fn(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=y0(t,e+1,r);if(!i)return;let s=i.data;const o=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:o,attrExpPresent:u,rawTagName:p}}function v0(t,e,n){const r=n;let i=1;for(;n<t.length;n++)if(t[n]==="<")if(t[n+1]==="/"){const s=fn(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=fn(t,"?>",n+1,"StopNode is not closed.");else if(t.substr(n+1,3)==="!--")n=fn(t,"-->",n+3,"StopNode is not closed.");else if(t.substr(n+1,2)==="![")n=fn(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 Na(t,e,n){if(e&&typeof t=="string"){const r=t.trim();return r==="true"?!0:r==="false"?!1:s0(t,n)}else return Nf.isExist(t)?t:""}var w0=a0,jf={};function b0(t,e){return $f(t,e)}function $f(t,e,n){let r;const i={};for(let s=0;s<t.length;s++){const o=t[s],c=k0(o);let l="";if(n===void 0?l=c:l=n+"."+c,c===e.textNodeName)r===void 0?r=o[c]:r+=""+o[c];else{if(c===void 0)continue;if(o[c]){let u=$f(o[c],e,l);const p=S0(u,e);o[":@"]?x0(u,o[":@"],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 k0(t){const e=Object.keys(t);for(let n=0;n<e.length;n++){const r=e[n];if(r!==":@")return r}}function x0(t,e,n,r){if(e){const i=Object.keys(e),s=i.length;for(let o=0;o<s;o++){const c=i[o];r.isArray(c,n+"."+c,!0,!0)?t[c]=[e[c]]:t[c]=e[c]}}}function S0(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))}jf.prettify=b0;const{buildOptions:A0}=ll,E0=w0,{prettify:I0}=jf,z0=al;let C0=class{constructor(e){this.externalEntities={},this.options=A0(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=z0.validate(e,n);if(s!==!0)throw Error(`${s.err.msg}:${s.err.line}:${s.err.col}`)}const r=new E0(this.options);r.addExternalEntities(this.externalEntities);const i=r.parseXml(e);return this.options.preserveOrder||i===void 0?i:I0(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 '
'");if(n==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[e]=n}};var N0=C0;const j0=`
|
|
9
|
+
`;function $0(t,e){let n="";return e.format&&e.indentBy.length>0&&(n=j0),Of(t,e,"",n)}function Of(t,e,n,r){let i="",s=!1;for(let o=0;o<t.length;o++){const c=t[o],l=O0(c);if(l===void 0)continue;let u="";if(n.length===0?u=l:u=`${n}.${l}`,l===e.textNodeName){let f=c[l];B0(u,e)||(f=e.tagValueProcessor(l,f),f=Bf(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=qu(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=qu(c[":@"],e),m=r+`<${l}${h}`,v=Of(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 O0(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 qu(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=Bf(i,e),i===!0&&e.suppressBooleanAttributes?n+=` ${r.substr(e.attributeNamePrefix.length)}`:n+=` ${r.substr(e.attributeNamePrefix.length)}="${i}"`}return n}function B0(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 Bf(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 T0=$0;const P0=T0,R0=Cf,L0={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:"&"},{regex:new RegExp(">","g"),val:">"},{regex:new RegExp("<","g"),val:"<"},{regex:new RegExp("'","g"),val:"'"},{regex:new RegExp('"',"g"),val:"""}],processEntities:!0,stopNodes:[],oneListGroup:!1};function rn(t){this.options=Object.assign({},L0,t),this.options.ignoreAttributes===!0||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn=R0(this.options.ignoreAttributes),this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=M0),this.processTextOrObjNode=U0,this.options.format?(this.indentate=V0,this.tagEndChar=`>
|
|
10
|
+
`,this.newLine=`
|
|
11
|
+
`):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}rn.prototype.build=function(t){return this.options.preserveOrder?P0(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 o in t)if(Object.prototype.hasOwnProperty.call(t,o))if(typeof t[o]>"u")this.isAttribute(o)&&(i+="");else if(t[o]===null)this.isAttribute(o)?i+="":o[0]==="?"?i+=this.indentate(e)+"<"+o+"?"+this.tagEndChar:i+=this.indentate(e)+"<"+o+"/"+this.tagEndChar;else if(t[o]instanceof Date)i+=this.buildTextValNode(t[o],o,"",e);else if(typeof t[o]!="object"){const c=this.isAttribute(o);if(c&&!this.ignoreAttributesFn(c,s))r+=this.buildAttrPairStr(c,""+t[o]);else if(!c)if(o===this.options.textNodeName){let l=this.options.tagValueProcessor(o,""+t[o]);i+=this.replaceEntitiesValue(l)}else i+=this.buildTextValNode(t[o],o,"",e)}else if(Array.isArray(t[o])){const c=t[o].length;let l="",u="";for(let p=0;p<c;p++){const h=t[o][p];if(!(typeof h>"u"))if(h===null)o[0]==="?"?i+=this.indentate(e)+"<"+o+"?"+this.tagEndChar:i+=this.indentate(e)+"<"+o+"/"+this.tagEndChar;else if(typeof h=="object")if(this.options.oneListGroup){const m=this.j2x(h,e+1,n.concat(o));l+=m.val,this.options.attributesGroupName&&h.hasOwnProperty(this.options.attributesGroupName)&&(u+=m.attrStr)}else l+=this.processTextOrObjNode(h,o,e,n);else if(this.options.oneListGroup){let m=this.options.tagValueProcessor(o,h);m=this.replaceEntitiesValue(m),l+=m}else l+=this.buildTextValNode(h,o,"",e)}this.options.oneListGroup&&(l=this.buildObjectNode(l,o,u,e)),i+=l}else if(this.options.attributesGroupName&&o===this.options.attributesGroupName){const c=Object.keys(t[o]),l=c.length;for(let u=0;u<l;u++)r+=this.buildAttrPairStr(c[u],""+t[o][c[u]])}else i+=this.processTextOrObjNode(t[o],o,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 U0(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 V0(t){return this.options.indentBy.repeat(t)}function M0(t){return t.startsWith(this.options.attributeNamePrefix)&&t!==this.options.textNodeName?t.substr(this.attrPrefixLen):!1}var q0=rn;const D0=al,H0=N0,F0=q0;var K0={XMLParser:H0,XMLValidator:D0,XMLBuilder:F0};function W0(t,e,n){const r=n?`<input type="hidden" name="RelayState" value="${n}" />`:"",i=`
|
|
12
|
+
<!DOCTYPE html>
|
|
13
|
+
<html>
|
|
14
|
+
<body onload="document.forms[0].submit()">
|
|
15
|
+
<noscript>
|
|
16
|
+
<p>Your browser has JavaScript disabled. Please click the button below to continue:</p>
|
|
17
|
+
<input type="submit" value="Continue">
|
|
18
|
+
</noscript>
|
|
19
|
+
<form method="post" action="${t}">
|
|
20
|
+
<input type="hidden" name="SAMLResponse" value="${e}" />
|
|
21
|
+
${r}
|
|
22
|
+
</form>
|
|
23
|
+
<script>
|
|
24
|
+
window.onload = function() {{
|
|
25
|
+
document.forms[0].submit();
|
|
26
|
+
}};
|
|
27
|
+
<\/script>
|
|
28
|
+
</body>
|
|
29
|
+
</html>`;return new Response(i,{headers:{"Content-Type":"text/html"}})}async function G0(t,e,n,r,i){var m,v,f;if(!n.redirect_uri)throw new N(400,{message:"Missing redirect_uri in authParams"});const[s]=await t.env.data.keys.list();if(!s)throw new N(500,{message:"No signing key found"});if(!((m=e.addons)!=null&&m.samlp))throw new N(400,{message:`SAML Addon is not enabled for client ${e.id}`});const{recipient:o,audience:c}=e.addons.samlp,l=n.state||"";if(!o||!l||!r||!n.state)throw new N(400,{message:"Missing recipient or inResponseTo"});const u=JSON.parse(n.state),p=new URL(n.redirect_uri),h=await J0(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 W0(p.toString(),h,u.relayState)}async function J0(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,o=e.responseId||`_${qe()}`,c=e.assertionId||`_${qe()}`,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":o,"@_InResponseTo":e.inResponseTo,"@_IssueInstant":i,"@_Version":"2.0"}}];let p=new K0.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 Z0={deno:"Deno",bun:"Bun",workerd:"Cloudflare-Workers",node:"Node.js"},Y0=()=>{var n,r;const t=globalThis;if(typeof navigator<"u"&&typeof navigator.userAgent=="string"){for(const[i,s]of Object.entries(Z0))if(X0(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"},X0=t=>navigator.userAgent.startsWith(t);function Qe(t,e){Y0()==="workerd"&&t.executionCtx.waitUntil(e)}const Du=["sub","iss","aud","exp","nbf","iat","jti"];async function eo(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 N(500,{message:"No signing key available"});const u=v_(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,scope:n.scope||"",grant_type:""},{accessToken:{setCustomClaim:(S,C)=>{if(Du.includes(S))throw new Error(`Cannot overwrite reserved claim '${S}'`);p[S]=C}},idToken:{setCustomClaim:(S,C)=>{if(Du.includes(S))throw new Error(`Cannot overwrite reserved claim '${S}'`);h&&(h[S]=C)}},access:{deny:S=>{throw new N(400,{message:`Access denied: ${S}`})}}});const m={includeIssuedTimestamp:!0,expiresIn:new il(1,"d"),headers:{kid:l.kid}},v=await Ru("RS256",u,p,m),f=h?await Ru("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 Q0(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:qe(),session_id:s,client_id:n.id,expires_at:new Date(Date.now()+Xs*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 Tf(t,e){const{user:n,client:r,scope:i,audience:s}=e,o=await t.env.data.sessions.create(r.tenant.id,{id:qe(),user_id:n.user_id,idle_expires_at:new Date(Date.now()+Xs*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:[r.id]}),c=i!=null&&i.split(" ").includes("offline_access")?await Q0(t,{...e,session_id:o.id,scope:i,audience:s}):void 0;return{...o,refresh_token:c}}async function sn(t,e){var v;const{authParams:n,user:r,client:i,ticketAuth:s}=e,o=be(t,{type:me.SUCCESS_LOGIN,description:`Successful login for ${r.user_id}`,userId:r.user_id});if(Qe(t,t.env.data.logs.create(i.tenant.id,o)),Qe(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 N(500,{message:"Login session not found"});const f=y_(),_=qe(12),w=await t.env.data.codes.create(i.tenant.id,{code_id:qe(),code_type:"ticket",login_id:e.loginSession.login_id,expires_at:new Date(Date.now()+S_).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){u=await ry(t,t.env.data)(i.tenant.id,r);const f=await Tf(t,{user:r,client:i,scope:n.scope,audience:n.audience});l=f.id,c=(v=f.refresh_token)==null?void 0:v.id}if(e.authParams.response_mode===Zt.SAML_POST)return G0(t,e.client,e.authParams,u,l);const p=await eo(t,{authParams:n,user:u,client:i,session_id:l,refresh_token:c}),h=new Headers({"set-cookie":If(i.tenant.id,l)});if(n.response_mode===Zt.WEB_MESSAGE)return t.json(p,{headers:h});if((n.response_type||Jt.CODE)===Jt.CODE){if(!e.loginSession)throw new N(500,{message:"Login session not found"});const f=await t.env.data.codes.create(i.tenant.id,{code_id:qe(),user_id:r.user_id,code_type:"authorization_code",login_id:e.loginSession.login_id,expires_at:new Date(Date.now()+k_*1e3).toISOString()});if(!n.redirect_uri)throw new N(400,{message:"Redirect uri not found"});const _=new URL(n.redirect_uri);_.searchParams.set("code",f.code_id),n.state&&_.searchParams.set("state",n.state),h.set("location",_.toString())}return new Response("Redirecting",{status:302,headers:h})}async function ey(t,e,n){const r=await t.env.data.tenants.get(e);if(!r)throw new Error(`Tenant not found: ${e}`);return eo(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:Jt.TOKEN,scope:n}})}async function ul(t,e,n){const r=await ey(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 o=be(t,{type:me.FAILED_HOOK,description:`Failed to invoke hook ${i.hook_id}`});await t.env.data.logs.create(n.tenant_id,o)}}function ty(t,e){return async(n,r)=>{const{hooks:i}=await e.hooks.list(n);return await ul(t,i,{tenant_id:n,user:r,trigger_id:"post-user-registration"}),r}}function ny(t,e){return async(n,r)=>{const{hooks:i}=await e.hooks.list(n,{q:"trigger_id:pre-user-signup",page:0,per_page:100,include_totals:!1});await ul(t,i,{tenant_id:n,email:r,trigger_id:"pre-user-signup"})}}function ry(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 ul(t,i,{tenant_id:n,user:r,trigger_id:"post-user-login"}),r}}function iy(t,e){return async(n,r)=>{let i=await d_(e)(n,r);return await ty(t,e)(n,i),i}}async function sy(t,e,n,r){if(e.disable_sign_ups&&!await to({userAdapter:t.env.data.users,tenant_id:e.tenant.id,email:r})){const s=be(t,{type:me.FAILED_SIGNUP,description:"Public signup is disabled"});throw await t.env.data.logs.create(e.tenant.id,s),new N(400,{message:"Signups are disabled for this client"})}await ny(t,n)(t.var.tenant_id||"",r)}function Pf(t,e){return{...e,users:{...e.users,create:iy(t,e)}}}function Rf(t){return Pf(t,t.env.data)}async function Lf(t,e,n){return(await t.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${n}`})).users}async function si({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 to({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 o=await t.get(e,(c=i[0])==null?void 0:c.linked_to);if(!o)throw new Error("Primary account not found");return o}async function cs({userAdapter:t,tenant_id:e,email:n,provider:r}){const i=await si({userAdapter:t,tenant_id:e,email:n,provider:r});return i?i.linked_to?t.get(e,i.linked_to):i:null}async function no(t,e){const{email:n,provider:r,connection:i,client:s,userId:o,isSocial:c,profileData:l={},ip:u=""}=e;let p=await cs({userAdapter:t.env.data.users,tenant_id:e.client.tenant.id,email:n,provider:r});if(!p){const h={user_id:`${r}|${o||Ys()}`,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 Rf(t).users.create(s.tenant.id,h),t.set("user_id",p.user_id)}return p}const Yt=a.z.object({page:a.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:a.z.string().min(1).optional().default("10").transform(t=>parseInt(t,10)).openapi({description:"The number of items per page"}),include_totals:a.z.string().optional().default("false").transform(t=>t==="true").openapi({description:"If the total number of items should be included in the response"}),sort:a.z.string().regex(/^.+:(-1|1)$/).optional().openapi({description:"A property that should have the format 'string:-1' or 'string:1'"}),q:a.z.string().optional().openapi({description:"A lucene query string used to filter the results"})});function cr(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 Hu=nn.extend({users:a.z.array(bt)}),oy=nn.extend({sessions:a.z.array(Zs)}),ay=new a.OpenAPIHono().openapi(a.createRoute({tags:["users"],method:"get",path:"/",request:{query:Yt,headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:a.z.union([a.z.array(bt),Hu])}},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":o}=t.req.valid("header");if(s!=null&&s.includes("identities.profileData.email")){const p=s.split("=")[1],m=(await t.env.data.users.list(o,{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(o,v.linked_to);if(!f)throw new N(500,{message:"Primary account not found"});return t.json([bt.parse(f)])}const c=["-_exists_:linked_to"];s&&c.push(s);const l=await t.env.data.users.list(o,{page:e,per_page:n,include_totals:r,sort:cr(i),q:c.join(" ")}),u=l.users.filter(p=>!p.linked_to);return r?t.json(Hu.parse({users:u,length:l.length,start:l.start,limit:l.limit})):t.json(a.z.array(bt).parse(u))}).openapi(a.createRoute({tags:["users"],method:"get",path:"/{user_id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({user_id:a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:bt}},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 N(404);if(r.linked_to)throw new N(404,{message:"User is linked to another user"});return t.json(r)}).openapi(a.createRoute({tags:["users"],method:"delete",path:"/{user_id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({user_id:a.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 N(404);return t.text("OK")}).openapi(a.createRoute({tags:["users"],method:"post",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.object({...es.shape})}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:bt}},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 N(400,{message:"Email is required"});const i=r.toLowerCase(),s=`${n.provider}|${n.user_id||Ys()}`;try{const o=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",o.user_id);const c=be(t,{type:me.SUCCESS_API_OPERATION,description:"User created"});Qe(t,t.env.data.logs.create(e,c));const l={...o,identities:[{connection:o.connection,provider:o.provider,user_id:Tu(o.user_id),isSocial:o.is_social}]};return t.json(bt.parse(l),{status:201})}catch(o){throw o.message==="User already exists"?new N(409,{message:"User already exists"}):o}}).openapi(a.createRoute({tags:["users"],method:"patch",path:"/{user_id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.object({...es.shape,verify_email:a.z.boolean(),password:a.z.string()}).partial()}}},params:a.z.object({user_id:a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{var u;const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),{user_id:r}=t.req.valid("param"),{verify_email:i,password:s,...o}=n,c=await t.env.data.users.get(e,r);if(!c)throw new N(404);if(o.email&&o.email!==c.email){const p=await Lf(t.env.data.users,e,o.email);if(p.length&&p.some(h=>h.user_id!==r))throw new N(409,{message:"Another user with the same email address already exists."})}if(c.linked_to)throw new N(404,{message:"User is linked to another user"});if(await t.env.data.users.update(e,r,o),s){const p=(u=c.identities)==null?void 0:u.find(h=>h.connection==="Username-Password-Authentication");if(!p)throw new N(400,{message:"User does not have a password identity"});await t.env.data.passwords.update(e,{user_id:`${p.provider}|${p.user_id}`,password:ii.hashSync(s,10),algorithm:"bcrypt"})}const l=await t.env.data.users.get(e,r);if(!l)throw new N(500);return t.json(l)}).openapi(a.createRoute({tags:["users"],method:"post",path:"/{user_id}/identities",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.union([a.z.object({link_with:a.z.string()}),a.z.object({user_id:a.z.string(),provider:a.z.string(),connection:a.z.string().optional()})])}}},params:a.z.object({user_id:a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:a.z.array(a.z.object({connection:a.z.string(),provider:a.z.string(),user_id:a.z.string(),isSocial:a.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 N(400,{message:"Linking an inexistent identity is not allowed."});await t.env.data.users.update(e,i,{linked_to:r});const o=await t.env.data.users.list(e,{page:0,per_page:10,include_totals:!1,q:`linked_to:${r}`}),c=[s,...o.users].map(l=>({connection:l.connection,provider:l.provider,user_id:Tu(l.user_id),isSocial:l.is_social}));return t.json(c,{status:201})}).openapi(a.createRoute({tags:["users"],method:"delete",path:"/{user_id}/identities/{provider}/{linked_user_id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({user_id:a.z.string(),provider:a.z.string(),linked_user_id:a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:a.z.array(bt)}},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 N(404);return t.json([bt.parse(s)])}).openapi(a.createRoute({tags:["users"],method:"get",path:"/{user_id}/sessions",request:{query:Yt,headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({user_id:a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:a.z.union([a.z.array(Zs),oy])}},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)});/*! *****************************************************************************
|
|
6
30
|
Copyright (C) Microsoft. All rights reserved.
|
|
7
31
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
8
32
|
this file except in compliance with the License. You may obtain a copy of the
|
|
@@ -15,7 +39,7 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
|
15
39
|
|
|
16
40
|
See the Apache Version 2.0 License for specific language governing permissions
|
|
17
41
|
and limitations under the License.
|
|
18
|
-
***************************************************************************** */var Ru;(function(t){(function(e){var n=typeof globalThis=="object"?globalThis:typeof cs=="object"?cs: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 o(){try{return(0,eval)("(function() { return this; })()")}catch{}}function c(){return s()||o()}})(function(e,n){var r=Object.prototype.hasOwnProperty,i=typeof Symbol=="function",s=i&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",o=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 Qo(Object.create(null))}:l?function(){return Qo({__proto__:null})}:function(){return Qo({})},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:mm(),v=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:_m(),f=typeof WeakMap=="function"?WeakMap:ym(),_=i?Symbol.for("@reflect-metadata:registry"):void 0,w=fm(),S=hm(w);function N(A,I,O,V){if(H(O)){if(!gu(A))throw new TypeError;if(!mu(I))throw new TypeError;return z(A,I)}else{if(!gu(A))throw new TypeError;if(!he(I))throw new TypeError;if(!he(V)&&!H(V)&&!Ie(V))throw new TypeError;return Ie(V)&&(V=void 0),O=yt(O),E(A,I,O,V)}}e("decorate",N);function B(A,I){function O(V,Q){if(!he(V))throw new TypeError;if(!H(Q)&&!dm(Q))throw new TypeError;X(A,I,V,Q)}return O}e("metadata",B);function R(A,I,O,V){if(!he(O))throw new TypeError;return H(V)||(V=yt(V)),X(A,I,O,V)}e("defineMetadata",R);function te(A,I,O){if(!he(I))throw new TypeError;return H(O)||(O=yt(O)),x(A,I,O)}e("hasMetadata",te);function fe(A,I,O){if(!he(I))throw new TypeError;return H(O)||(O=yt(O)),k(A,I,O)}e("hasOwnMetadata",fe);function le(A,I,O){if(!he(I))throw new TypeError;return H(O)||(O=yt(O)),$(A,I,O)}e("getMetadata",le);function Ve(A,I,O){if(!he(I))throw new TypeError;return H(O)||(O=yt(O)),L(A,I,O)}e("getOwnMetadata",Ve);function at(A,I){if(!he(A))throw new TypeError;return H(I)||(I=yt(I)),G(A,I)}e("getMetadataKeys",at);function Ge(A,I){if(!he(A))throw new TypeError;return H(I)||(I=yt(I)),ie(A,I)}e("getOwnMetadataKeys",Ge);function j(A,I,O){if(!he(I))throw new TypeError;if(H(O)||(O=yt(O)),!he(I))throw new TypeError;H(O)||(O=yt(O));var V=xr(I,O,!1);return H(V)?!1:V.OrdinaryDeleteMetadata(A,I,O)}e("deleteMetadata",j);function z(A,I){for(var O=A.length-1;O>=0;--O){var V=A[O],Q=V(I);if(!H(Q)&&!Ie(Q)){if(!mu(Q))throw new TypeError;I=Q}}return I}function E(A,I,O,V){for(var Q=A.length-1;Q>=0;--Q){var ze=A[Q],Ae=ze(I,O,V);if(!H(Ae)&&!Ie(Ae)){if(!he(Ae))throw new TypeError;V=Ae}}return V}function x(A,I,O){var V=k(A,I,O);if(V)return!0;var Q=Xo(I);return Ie(Q)?!1:x(A,Q,O)}function k(A,I,O){var V=xr(I,O,!1);return H(V)?!1:hu(V.OrdinaryHasOwnMetadata(A,I,O))}function $(A,I,O){var V=k(A,I,O);if(V)return L(A,I,O);var Q=Xo(I);if(!Ie(Q))return $(A,Q,O)}function L(A,I,O){var V=xr(I,O,!1);if(!H(V))return V.OrdinaryGetOwnMetadata(A,I,O)}function X(A,I,O,V){var Q=xr(O,V,!0);Q.OrdinaryDefineOwnMetadata(A,I,O,V)}function G(A,I){var O=ie(A,I),V=Xo(A);if(V===null)return O;var Q=G(V,I);if(Q.length<=0)return O;if(O.length<=0)return Q;for(var ze=new v,Ae=[],se=0,D=O;se<D.length;se++){var W=D[se],Z=ze.has(W);Z||(ze.add(W),Ae.push(W))}for(var Y=0,oe=Q;Y<oe.length;Y++){var W=oe[Y],Z=ze.has(W);Z||(ze.add(W),Ae.push(W))}return Ae}function ie(A,I){var O=xr(A,I,!1);return O?O.OrdinaryOwnMetadataKeys(A,I):[]}function ce(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 Ie(A){return A===null}function ln(A){return typeof A=="symbol"}function he(A){return typeof A=="object"?A!==null:typeof A=="function"}function xe(A,I){switch(ce(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=_u(A,s);if(V!==void 0){var Q=V.call(A,O);if(he(Q))throw new TypeError;return Q}return lm(A)}function lm(A,I){var O,V;{var Q=A.toString;if(Ni(Q)){var V=Q.call(A);if(!he(V))return V}var O=A.valueOf;if(Ni(O)){var V=O.call(A);if(!he(V))return V}}throw new TypeError}function hu(A){return!!A}function um(A){return""+A}function yt(A){var I=xe(A);return ln(I)?I:um(I)}function gu(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 mu(A){return typeof A=="function"}function dm(A){switch(ce(A)){case 3:return!0;case 4:return!0;default:return!1}}function Yo(A,I){return A===I||A!==A&&I!==I}function _u(A,I){var O=A[I];if(O!=null){if(!Ni(O))throw new TypeError;return O}}function yu(A){var I=_u(A,o);if(!Ni(I))throw new TypeError;var O=I.call(A);if(!he(O))throw new TypeError;return O}function vu(A){return A.value}function wu(A){var I=A.next();return I.done?!1:I}function bu(A){var I=A.return;I&&I.call(A)}function Xo(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 Q=V.constructor;return typeof Q!="function"||Q===A?I:Q}function pm(){var A;!H(_)&&typeof n.Reflect<"u"&&!(_ in n.Reflect)&&typeof n.Reflect.defineMetadata=="function"&&(A=gm(n.Reflect));var I,O,V,Q=new f,ze={registerProvider:Ae,getProvider:D,setProvider:Z};return ze;function Ae(Y){if(!Object.isExtensible(ze))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 se(Y,oe){if(!H(I)){if(I.isProviderFor(Y,oe))return I;if(!H(O)){if(O.isProviderFor(Y,oe))return I;if(!H(V))for(var ge=yu(V);;){var ve=wu(ge);if(!ve)return;var ct=vu(ve);if(ct.isProviderFor(Y,oe))return bu(ge),ct}}}if(!H(A)&&A.isProviderFor(Y,oe))return A}function D(Y,oe){var ge=Q.get(Y),ve;return H(ge)||(ve=ge.get(oe)),H(ve)&&(ve=se(Y,oe),H(ve)||(H(ge)&&(ge=new m,Q.set(Y,ge)),ge.set(oe,ve))),ve}function W(Y){if(H(Y))throw new TypeError;return I===Y||O===Y||!H(V)&&V.has(Y)}function Z(Y,oe,ge){if(!W(ge))throw new Error("Metadata provider not registered.");var ve=D(Y,oe);if(ve!==ge){if(!H(ve))return!1;var ct=Q.get(Y);H(ct)&&(ct=new m,Q.set(Y,ct)),ct.set(oe,ge)}return!0}}function fm(){var A;return!H(_)&&he(n.Reflect)&&Object.isExtensible(n.Reflect)&&(A=n.Reflect[_]),H(A)&&(A=pm()),!H(_)&&he(n.Reflect)&&Object.isExtensible(n.Reflect)&&Object.defineProperty(n.Reflect,_,{enumerable:!1,configurable:!1,writable:!1,value:A}),A}function hm(A){var I=new f,O={isProviderFor:function(W,Z){var Y=I.get(W);return H(Y)?!1:Y.has(Z)},OrdinaryDefineOwnMetadata:Ae,OrdinaryHasOwnMetadata:Q,OrdinaryGetOwnMetadata:ze,OrdinaryOwnMetadataKeys:se,OrdinaryDeleteMetadata:D};return w.registerProvider(O),O;function V(W,Z,Y){var oe=I.get(W),ge=!1;if(H(oe)){if(!Y)return;oe=new m,I.set(W,oe),ge=!0}var ve=oe.get(Z);if(H(ve)){if(!Y)return;if(ve=new m,oe.set(Z,ve),!A.setProvider(W,Z,O))throw oe.delete(Z),ge&&I.delete(W),new Error("Wrong provider for target.")}return ve}function Q(W,Z,Y){var oe=V(Z,Y,!1);return H(oe)?!1:hu(oe.has(W))}function ze(W,Z,Y){var oe=V(Z,Y,!1);if(!H(oe))return oe.get(W)}function Ae(W,Z,Y,oe){var ge=V(Y,oe,!0);ge.set(W,Z)}function se(W,Z){var Y=[],oe=V(W,Z,!1);if(H(oe))return Y;for(var ge=oe.keys(),ve=yu(ge),ct=0;;){var ku=wu(ve);if(!ku)return Y.length=ct,Y;var vm=vu(ku);try{Y[ct]=vm}catch(wm){try{bu(ve)}finally{throw wm}}ct++}}function D(W,Z,Y){var oe=V(Z,Y,!1);if(H(oe)||!oe.delete(W))return!1;if(oe.size===0){var ge=I.get(Z);H(ge)||(ge.delete(Y),ge.size===0&&I.delete(ge))}return!0}}function gm(A){var I=A.defineMetadata,O=A.hasOwnMetadata,V=A.getOwnMetadata,Q=A.getOwnMetadataKeys,ze=A.deleteMetadata,Ae=new f,se={isProviderFor:function(D,W){var Z=Ae.get(D);return!H(Z)&&Z.has(W)?!0:Q(D,W).length?(H(Z)&&(Z=new v,Ae.set(D,Z)),Z.add(W),!0):!1},OrdinaryDefineOwnMetadata:I,OrdinaryHasOwnMetadata:O,OrdinaryGetOwnMetadata:V,OrdinaryOwnMetadataKeys:Q,OrdinaryDeleteMetadata:ze};return se}function xr(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 mm(){var A={},I=[],O=function(){function se(D,W,Z){this._index=0,this._keys=D,this._values=W,this._selector=Z}return se.prototype["@@iterator"]=function(){return this},se.prototype[o]=function(){return this},se.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}},se.prototype.throw=function(D){throw this._index>=0&&(this._index=-1,this._keys=I,this._values=I),D},se.prototype.return=function(D){return this._index>=0&&(this._index=-1,this._keys=I,this._values=I),{value:D,done:!0}},se}(),V=function(){function se(){this._keys=[],this._values=[],this._cacheKey=A,this._cacheIndex=-2}return Object.defineProperty(se.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),se.prototype.has=function(D){return this._find(D,!1)>=0},se.prototype.get=function(D){var W=this._find(D,!1);return W>=0?this._values[W]:void 0},se.prototype.set=function(D,W){var Z=this._find(D,!0);return this._values[Z]=W,this},se.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--,Yo(D,this._cacheKey)&&(this._cacheKey=A,this._cacheIndex=-2),!0}return!1},se.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=A,this._cacheIndex=-2},se.prototype.keys=function(){return new O(this._keys,this._values,Q)},se.prototype.values=function(){return new O(this._keys,this._values,ze)},se.prototype.entries=function(){return new O(this._keys,this._values,Ae)},se.prototype["@@iterator"]=function(){return this.entries()},se.prototype[o]=function(){return this.entries()},se.prototype._find=function(D,W){if(!Yo(this._cacheKey,D)){this._cacheIndex=-1;for(var Z=0;Z<this._keys.length;Z++)if(Yo(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},se}();return V;function Q(se,D){return se}function ze(se,D){return D}function Ae(se,D){return[se,D]}}function _m(){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[o]=function(){return this.keys()},I}();return A}function ym(){var A=16,I=p.create(),O=V();return function(){function D(){this._key=V()}return D.prototype.has=function(W){var Z=Q(W,!1);return Z!==void 0?p.has(Z,this._key):!1},D.prototype.get=function(W){var Z=Q(W,!1);return Z!==void 0?p.get(Z,this._key):void 0},D.prototype.set=function(W,Z){var Y=Q(W,!0);return Y[this._key]=Z,this},D.prototype.delete=function(W){var Z=Q(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@@"+se();while(p.has(I,D));return I[D]=!0,D}function Q(D,W){if(!r.call(D,O)){if(!W)return;Object.defineProperty(D,O,{value:p.create()})}return D[O]}function ze(D,W){for(var Z=0;Z<W;++Z)D[Z]=Math.random()*255|0;return D}function Ae(D){if(typeof Uint8Array=="function"){var W=new Uint8Array(D);return typeof crypto<"u"?crypto.getRandomValues(W):typeof msCrypto<"u"?msCrypto.getRandomValues(W):ze(W,D),W}return ze(new Array(D),D)}function se(){var D=Ae(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 Qo(A){return A.__=void 0,delete A.__,A}})})(Ru||(Ru={}));/*!
|
|
42
|
+
***************************************************************************** */var Fu;(function(t){(function(e){var n=typeof globalThis=="object"?globalThis:typeof os=="object"?os: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 o(){try{return(0,eval)("(function() { return this; })()")}catch{}}function c(){return s()||o()}})(function(e,n){var r=Object.prototype.hasOwnProperty,i=typeof Symbol=="function",s=i&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",o=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 Qo(Object.create(null))}:l?function(){return Qo({__proto__:null})}:function(){return Qo({})},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:ym(),v=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:vm(),f=typeof WeakMap=="function"?WeakMap:wm(),_=i?Symbol.for("@reflect-metadata:registry"):void 0,w=gm(),S=mm(w);function C(A,I,O,V){if(H(O)){if(!gu(A))throw new TypeError;if(!mu(I))throw new TypeError;return z(A,I)}else{if(!gu(A))throw new TypeError;if(!he(I))throw new TypeError;if(!he(V)&&!H(V)&&!Ie(V))throw new TypeError;return Ie(V)&&(V=void 0),O=yt(O),E(A,I,O,V)}}e("decorate",C);function B(A,I){function O(V,Q){if(!he(V))throw new TypeError;if(!H(Q)&&!fm(Q))throw new TypeError;X(A,I,V,Q)}return O}e("metadata",B);function R(A,I,O,V){if(!he(O))throw new TypeError;return H(V)||(V=yt(V)),X(A,I,O,V)}e("defineMetadata",R);function te(A,I,O){if(!he(I))throw new TypeError;return H(O)||(O=yt(O)),x(A,I,O)}e("hasMetadata",te);function fe(A,I,O){if(!he(I))throw new TypeError;return H(O)||(O=yt(O)),k(A,I,O)}e("hasOwnMetadata",fe);function le(A,I,O){if(!he(I))throw new TypeError;return H(O)||(O=yt(O)),$(A,I,O)}e("getMetadata",le);function Ue(A,I,O){if(!he(I))throw new TypeError;return H(O)||(O=yt(O)),L(A,I,O)}e("getOwnMetadata",Ue);function at(A,I){if(!he(A))throw new TypeError;return H(I)||(I=yt(I)),G(A,I)}e("getMetadataKeys",at);function Ge(A,I){if(!he(A))throw new TypeError;return H(I)||(I=yt(I)),ie(A,I)}e("getOwnMetadataKeys",Ge);function j(A,I,O){if(!he(I))throw new TypeError;if(H(O)||(O=yt(O)),!he(I))throw new TypeError;H(O)||(O=yt(O));var V=br(I,O,!1);return H(V)?!1:V.OrdinaryDeleteMetadata(A,I,O)}e("deleteMetadata",j);function z(A,I){for(var O=A.length-1;O>=0;--O){var V=A[O],Q=V(I);if(!H(Q)&&!Ie(Q)){if(!mu(Q))throw new TypeError;I=Q}}return I}function E(A,I,O,V){for(var Q=A.length-1;Q>=0;--Q){var ze=A[Q],Ae=ze(I,O,V);if(!H(Ae)&&!Ie(Ae)){if(!he(Ae))throw new TypeError;V=Ae}}return V}function x(A,I,O){var V=k(A,I,O);if(V)return!0;var Q=Xo(I);return Ie(Q)?!1:x(A,Q,O)}function k(A,I,O){var V=br(I,O,!1);return H(V)?!1:hu(V.OrdinaryHasOwnMetadata(A,I,O))}function $(A,I,O){var V=k(A,I,O);if(V)return L(A,I,O);var Q=Xo(I);if(!Ie(Q))return $(A,Q,O)}function L(A,I,O){var V=br(I,O,!1);if(!H(V))return V.OrdinaryGetOwnMetadata(A,I,O)}function X(A,I,O,V){var Q=br(O,V,!0);Q.OrdinaryDefineOwnMetadata(A,I,O,V)}function G(A,I){var O=ie(A,I),V=Xo(A);if(V===null)return O;var Q=G(V,I);if(Q.length<=0)return O;if(O.length<=0)return Q;for(var ze=new v,Ae=[],se=0,D=O;se<D.length;se++){var W=D[se],Z=ze.has(W);Z||(ze.add(W),Ae.push(W))}for(var Y=0,oe=Q;Y<oe.length;Y++){var W=oe[Y],Z=ze.has(W);Z||(ze.add(W),Ae.push(W))}return Ae}function ie(A,I){var O=br(A,I,!1);return O?O.OrdinaryOwnMetadataKeys(A,I):[]}function ce(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 Ie(A){return A===null}function ln(A){return typeof A=="symbol"}function he(A){return typeof A=="object"?A!==null:typeof A=="function"}function xe(A,I){switch(ce(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=_u(A,s);if(V!==void 0){var Q=V.call(A,O);if(he(Q))throw new TypeError;return Q}return dm(A)}function dm(A,I){var O,V;{var Q=A.toString;if(zi(Q)){var V=Q.call(A);if(!he(V))return V}var O=A.valueOf;if(zi(O)){var V=O.call(A);if(!he(V))return V}}throw new TypeError}function hu(A){return!!A}function pm(A){return""+A}function yt(A){var I=xe(A);return ln(I)?I:pm(I)}function gu(A){return Array.isArray?Array.isArray(A):A instanceof Object?A instanceof Array:Object.prototype.toString.call(A)==="[object Array]"}function zi(A){return typeof A=="function"}function mu(A){return typeof A=="function"}function fm(A){switch(ce(A)){case 3:return!0;case 4:return!0;default:return!1}}function Yo(A,I){return A===I||A!==A&&I!==I}function _u(A,I){var O=A[I];if(O!=null){if(!zi(O))throw new TypeError;return O}}function yu(A){var I=_u(A,o);if(!zi(I))throw new TypeError;var O=I.call(A);if(!he(O))throw new TypeError;return O}function vu(A){return A.value}function wu(A){var I=A.next();return I.done?!1:I}function bu(A){var I=A.return;I&&I.call(A)}function Xo(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 Q=V.constructor;return typeof Q!="function"||Q===A?I:Q}function hm(){var A;!H(_)&&typeof n.Reflect<"u"&&!(_ in n.Reflect)&&typeof n.Reflect.defineMetadata=="function"&&(A=_m(n.Reflect));var I,O,V,Q=new f,ze={registerProvider:Ae,getProvider:D,setProvider:Z};return ze;function Ae(Y){if(!Object.isExtensible(ze))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 se(Y,oe){if(!H(I)){if(I.isProviderFor(Y,oe))return I;if(!H(O)){if(O.isProviderFor(Y,oe))return I;if(!H(V))for(var ge=yu(V);;){var ve=wu(ge);if(!ve)return;var ct=vu(ve);if(ct.isProviderFor(Y,oe))return bu(ge),ct}}}if(!H(A)&&A.isProviderFor(Y,oe))return A}function D(Y,oe){var ge=Q.get(Y),ve;return H(ge)||(ve=ge.get(oe)),H(ve)&&(ve=se(Y,oe),H(ve)||(H(ge)&&(ge=new m,Q.set(Y,ge)),ge.set(oe,ve))),ve}function W(Y){if(H(Y))throw new TypeError;return I===Y||O===Y||!H(V)&&V.has(Y)}function Z(Y,oe,ge){if(!W(ge))throw new Error("Metadata provider not registered.");var ve=D(Y,oe);if(ve!==ge){if(!H(ve))return!1;var ct=Q.get(Y);H(ct)&&(ct=new m,Q.set(Y,ct)),ct.set(oe,ge)}return!0}}function gm(){var A;return!H(_)&&he(n.Reflect)&&Object.isExtensible(n.Reflect)&&(A=n.Reflect[_]),H(A)&&(A=hm()),!H(_)&&he(n.Reflect)&&Object.isExtensible(n.Reflect)&&Object.defineProperty(n.Reflect,_,{enumerable:!1,configurable:!1,writable:!1,value:A}),A}function mm(A){var I=new f,O={isProviderFor:function(W,Z){var Y=I.get(W);return H(Y)?!1:Y.has(Z)},OrdinaryDefineOwnMetadata:Ae,OrdinaryHasOwnMetadata:Q,OrdinaryGetOwnMetadata:ze,OrdinaryOwnMetadataKeys:se,OrdinaryDeleteMetadata:D};return w.registerProvider(O),O;function V(W,Z,Y){var oe=I.get(W),ge=!1;if(H(oe)){if(!Y)return;oe=new m,I.set(W,oe),ge=!0}var ve=oe.get(Z);if(H(ve)){if(!Y)return;if(ve=new m,oe.set(Z,ve),!A.setProvider(W,Z,O))throw oe.delete(Z),ge&&I.delete(W),new Error("Wrong provider for target.")}return ve}function Q(W,Z,Y){var oe=V(Z,Y,!1);return H(oe)?!1:hu(oe.has(W))}function ze(W,Z,Y){var oe=V(Z,Y,!1);if(!H(oe))return oe.get(W)}function Ae(W,Z,Y,oe){var ge=V(Y,oe,!0);ge.set(W,Z)}function se(W,Z){var Y=[],oe=V(W,Z,!1);if(H(oe))return Y;for(var ge=oe.keys(),ve=yu(ge),ct=0;;){var ku=wu(ve);if(!ku)return Y.length=ct,Y;var bm=vu(ku);try{Y[ct]=bm}catch(km){try{bu(ve)}finally{throw km}}ct++}}function D(W,Z,Y){var oe=V(Z,Y,!1);if(H(oe)||!oe.delete(W))return!1;if(oe.size===0){var ge=I.get(Z);H(ge)||(ge.delete(Y),ge.size===0&&I.delete(ge))}return!0}}function _m(A){var I=A.defineMetadata,O=A.hasOwnMetadata,V=A.getOwnMetadata,Q=A.getOwnMetadataKeys,ze=A.deleteMetadata,Ae=new f,se={isProviderFor:function(D,W){var Z=Ae.get(D);return!H(Z)&&Z.has(W)?!0:Q(D,W).length?(H(Z)&&(Z=new v,Ae.set(D,Z)),Z.add(W),!0):!1},OrdinaryDefineOwnMetadata:I,OrdinaryHasOwnMetadata:O,OrdinaryGetOwnMetadata:V,OrdinaryOwnMetadataKeys:Q,OrdinaryDeleteMetadata:ze};return se}function br(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 ym(){var A={},I=[],O=function(){function se(D,W,Z){this._index=0,this._keys=D,this._values=W,this._selector=Z}return se.prototype["@@iterator"]=function(){return this},se.prototype[o]=function(){return this},se.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}},se.prototype.throw=function(D){throw this._index>=0&&(this._index=-1,this._keys=I,this._values=I),D},se.prototype.return=function(D){return this._index>=0&&(this._index=-1,this._keys=I,this._values=I),{value:D,done:!0}},se}(),V=function(){function se(){this._keys=[],this._values=[],this._cacheKey=A,this._cacheIndex=-2}return Object.defineProperty(se.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),se.prototype.has=function(D){return this._find(D,!1)>=0},se.prototype.get=function(D){var W=this._find(D,!1);return W>=0?this._values[W]:void 0},se.prototype.set=function(D,W){var Z=this._find(D,!0);return this._values[Z]=W,this},se.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--,Yo(D,this._cacheKey)&&(this._cacheKey=A,this._cacheIndex=-2),!0}return!1},se.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=A,this._cacheIndex=-2},se.prototype.keys=function(){return new O(this._keys,this._values,Q)},se.prototype.values=function(){return new O(this._keys,this._values,ze)},se.prototype.entries=function(){return new O(this._keys,this._values,Ae)},se.prototype["@@iterator"]=function(){return this.entries()},se.prototype[o]=function(){return this.entries()},se.prototype._find=function(D,W){if(!Yo(this._cacheKey,D)){this._cacheIndex=-1;for(var Z=0;Z<this._keys.length;Z++)if(Yo(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},se}();return V;function Q(se,D){return se}function ze(se,D){return D}function Ae(se,D){return[se,D]}}function vm(){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[o]=function(){return this.keys()},I}();return A}function wm(){var A=16,I=p.create(),O=V();return function(){function D(){this._key=V()}return D.prototype.has=function(W){var Z=Q(W,!1);return Z!==void 0?p.has(Z,this._key):!1},D.prototype.get=function(W){var Z=Q(W,!1);return Z!==void 0?p.get(Z,this._key):void 0},D.prototype.set=function(W,Z){var Y=Q(W,!0);return Y[this._key]=Z,this},D.prototype.delete=function(W){var Z=Q(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@@"+se();while(p.has(I,D));return I[D]=!0,D}function Q(D,W){if(!r.call(D,O)){if(!W)return;Object.defineProperty(D,O,{value:p.create()})}return D[O]}function ze(D,W){for(var Z=0;Z<W;++Z)D[Z]=Math.random()*255|0;return D}function Ae(D){if(typeof Uint8Array=="function"){var W=new Uint8Array(D);return typeof crypto<"u"?crypto.getRandomValues(W):typeof msCrypto<"u"?msCrypto.getRandomValues(W):ze(W,D),W}return ze(new Array(D),D)}function se(){var D=Ae(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 Qo(A){return A.__=void 0,delete A.__,A}})})(Fu||(Fu={}));/*!
|
|
19
43
|
* MIT License
|
|
20
44
|
*
|
|
21
45
|
* Copyright (c) 2017-2022 Peculiar Ventures, LLC
|
|
@@ -38,9 +62,9 @@ and limitations under the License.
|
|
|
38
62
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
39
63
|
* SOFTWARE.
|
|
40
64
|
*
|
|
41
|
-
*/const
|
|
65
|
+
*/const cy="[object ArrayBuffer]";class q{static isArrayBuffer(e){return Object.prototype.toString.call(e)===cy}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=q.toUint8Array(e),i=q.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 o of n)r+=o.byteLength;const i=new Uint8Array(r);let s=0;for(const o of n){const c=this.toUint8Array(o);i.set(c,s),s+=c.length}return e[e.length-1]instanceof Function?this.toView(i,e[e.length-1]):i.buffer}}const ta="string",ly=/^[0-9a-f]+$/i,uy=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,dy=/^[a-zA-Z0-9-_]+$/;class Ku{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=q.toUint8Array(e);let r="";for(let s=0;s<n.length;s++)r+=String.fromCharCode(n[s]);return decodeURIComponent(escape(r))}}class vt{static toString(e,n=!1){const r=q.toArrayBuffer(e),i=new DataView(r);let s="";for(let o=0;o<r.byteLength;o+=2){const c=i.getUint16(o,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===ta&&ly.test(e)}static isBase64(e){return typeof e===ta&&uy.test(e)}static isBase64Url(e){return typeof e===ta&&dy.test(e)}static ToString(e,n="utf8"){const r=q.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 vt.toString(r,!0);case"utf16":case"utf16be":return vt.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 vt.fromString(e,!0);case"utf16":case"utf16be":return vt.fromString(e);default:throw new Error(`Unknown type of encoding '${n}'`)}}static ToBase64(e){const n=q.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 Ku.fromString(e);case"utf16":case"utf16be":return vt.fromString(e);case"utf16le":case"usc2":return vt.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 Ku.toString(e);case"utf16":case"utf16be":return vt.toString(e);case"utf16le":case"usc2":return vt.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=q.toUint8Array(e);let r="";for(let i=0;i<n.length;i++)r+=String.fromCharCode(n[i]);return r}static ToHex(e){const n=q.toUint8Array(e);let r="";const i=n.length;for(let s=0;s<i;s++){const o=n[s];o<16&&(r+="0"),r+=o.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 vt.toString(e,n)}static FromUtf16String(e,n=!1){return vt.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 py(...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 Uf(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}/*!
|
|
42
66
|
Copyright (c) Peculiar Ventures, LLC
|
|
43
|
-
*/function
|
|
67
|
+
*/function Gn(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 vn(t,e,n=-1){const r=n;let i=t,s=0,o=Math.pow(2,e);for(let c=1;c<8;c++){if(t<o){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}o*=Math.pow(2,e)}return new ArrayBuffer(0)}function ja(...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 Vf(){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=Gn(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,Gn(s,8)-r}function fy(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 o=n-e,c=vn(o,8,r),l=new Uint8Array(c);return l[0]|=128,c}let i=vn(e,8,r),s=new Uint8Array(i);if(s[0]&128){const o=i.slice(0),c=new Uint8Array(o);i=new ArrayBuffer(i.byteLength+1),s=new Uint8Array(i);for(let l=0;l<o.byteLength;l++)s[l+1]=c[l];s[0]=0}return i}n*=Math.pow(2,8)}return new ArrayBuffer(0)}function hy(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 Je(t,e){const n=t.toString(10);if(e<n.length)return"";const r=e-n.length,i=new Array(r);for(let o=0;o<r;o++)i[o]="0";return i.join("").concat(n)}/*!
|
|
44
68
|
* Copyright (c) 2014, GMO GlobalSign
|
|
45
69
|
* Copyright (c) 2015-2022, Peculiar Ventures
|
|
46
70
|
* All rights reserved.
|
|
@@ -72,11 +96,11 @@ and limitations under the License.
|
|
|
72
96
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
73
97
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
74
98
|
*
|
|
75
|
-
*/function ls(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function il(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 Vt(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 eo{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return il(this.items)}}const Ar=[new Uint8Array([1])],Uu="0123456789",na="name",Vu="valueHexView",b_="isHexOnly",k_="idBlock",x_="tagClass",S_="tagNumber",A_="isConstructed",E_="fromBER",I_="toBER",z_="local",qe="",mt=new ArrayBuffer(0),to=new Uint8Array(0),Mr="EndOfContent",Af="OCTET STRING",Ef="BIT STRING";function It(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?q.toUint8Array(s.valueHex):to}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(r){this.valueHexView=new Uint8Array(r)}fromBER(r,i,s){const o=r instanceof ArrayBuffer?new Uint8Array(r):r;if(!Vt(this,o,i,s))return-1;const c=i+s;return this.valueHexView=o.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",mt)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:J.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}class $n{constructor({blockLength:e=0,error:n=qe,warnings:r=[],valueBeforeDecode:i=to}={}){this.blockLength=e,this.error=n,this.warnings=r,this.valueBeforeDecodeView=q.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)}}}$n.NAME="baseBlock";class Ue extends $n{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'")}}Ue.NAME="valueBlock";class If extends It($n){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?q.toUint8Array(e.valueHex):to,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",mt}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=wn(this.tagNumber,7),s=new Uint8Array(i),o=i.byteLength,c=new Uint8Array(o+1);if(c[0]=n|31,!e){for(let l=0;l<o-1;l++)c[l+1]=s[l]|128;c[o]=s[o-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=q.toUint8Array(e);if(!Vt(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}}}If.NAME="identificationBlock";class zf extends $n{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=q.toUint8Array(e);if(!Vt(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 o=s[0]&127;if(o>8)return this.error="Too big integer",-1;if(o+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+o);return l[o-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=o+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=wn(this.length,8);if(i.byteLength>127)return this.error="Too big length",mt;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 o=0;o<i.byteLength;o++)r[o+1]=s[o];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 $e extends $n{constructor({name:e=qe,optional:n=!1,primitiveSchema:r,...i}={},s){super(i),this.name=e,this.optional=n,r&&(this.primitiveSchema=r),this.idBlock=new If(i),this.lenBlock=new zf(i),this.valueBlock=s?new s(i):new Ue(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 eo;n||Cf(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 o=this.lenBlock.toBER(e);r.write(o),r.write(s)}return n?mt: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 w_(n,r)}}$e.NAME="BaseBlock";function Cf(t){if(t instanceof K.Constructed)for(const e of t.valueBlock.value)Cf(e)&&(t.lenBlock.isIndefiniteForm=!0);return!!t.lenBlock.isIndefiniteForm}class sl extends $e{constructor({value:e=qe,...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}'`}}sl.NAME="BaseStringBlock";class Nf extends It(Ue){constructor({isHexOnly:e=!0,...n}={}){super(n),this.isHexOnly=e}}Nf.NAME="PrimitiveValueBlock";var jf;class ci extends $e{constructor(e={}){super(e,Nf),this.idBlock.isConstructed=!1}}jf=ci;K.Primitive=jf;ci.NAME="PRIMITIVE";function C_(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 dr(t,e=0,n=t.length){const r=e;let i=new $e({},Ue);const s=new $n;if(!Vt(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=$e;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=C_(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 $e({},Ue);return e.error="Input buffer has zero length",{offset:-1,result:e}}return dr(q.toUint8Array(t).slice(),0,t.byteLength)}function N_(t,e){return t?1:e}class Kt extends Ue{constructor({value:e=[],isIndefiniteForm:n=!1,...r}={}){super(r),this.value=e,this.isIndefiniteForm=n}fromBER(e,n,r){const i=q.toUint8Array(e);if(!Vt(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(;N_(this.isIndefiniteForm,r)>0;){const o=dr(i,s,r);if(o.offset===-1)return this.error=o.result.error,this.warnings.concat(o.result.warnings),-1;if(s=o.offset,this.blockLength+=o.result.blockLength,r-=o.result.blockLength,this.value.push(o.result),this.isIndefiniteForm&&o.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 eo;for(let i=0;i<this.value.length;i++)this.value[i].toBER(e,r);return n?mt:r.final()}toJSON(){const e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(const n of this.value)e.value.push(n.toJSON());return e}}Kt.NAME="ConstructedValueBlock";var $f;class De extends $e{constructor(e={}){super(e,Kt),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 ls(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function dl(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 Vt(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 ro{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return dl(this.items)}}const Ar=[new Uint8Array([1])],Wu="0123456789",na="name",Gu="valueHexView",gy="isHexOnly",my="idBlock",_y="tagClass",yy="tagNumber",vy="isConstructed",wy="fromBER",by="toBER",ky="local",Me="",mt=new ArrayBuffer(0),io=new Uint8Array(0),Vr="EndOfContent",Mf="OCTET STRING",qf="BIT STRING";function It(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?q.toUint8Array(s.valueHex):io}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(r){this.valueHexView=new Uint8Array(r)}fromBER(r,i,s){const o=r instanceof ArrayBuffer?new Uint8Array(r):r;if(!Vt(this,o,i,s))return-1;const c=i+s;return this.valueHexView=o.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",mt)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:J.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}class jn{constructor({blockLength:e=0,error:n=Me,warnings:r=[],valueBeforeDecode:i=io}={}){this.blockLength=e,this.error=n,this.warnings=r,this.valueBeforeDecodeView=q.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)}}}jn.NAME="baseBlock";class Le extends jn{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'")}}Le.NAME="valueBlock";class Df extends It(jn){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?q.toUint8Array(e.valueHex):io,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",mt}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=vn(this.tagNumber,7),s=new Uint8Array(i),o=i.byteLength,c=new Uint8Array(o+1);if(c[0]=n|31,!e){for(let l=0;l<o-1;l++)c[l+1]=s[l]|128;c[o]=s[o-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=q.toUint8Array(e);if(!Vt(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=Gn(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}}}Df.NAME="identificationBlock";class Hf extends jn{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=q.toUint8Array(e);if(!Vt(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 o=s[0]&127;if(o>8)return this.error="Too big integer",-1;if(o+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+o);return l[o-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=Gn(l,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=o+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=vn(this.length,8);if(i.byteLength>127)return this.error="Too big length",mt;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 o=0;o<i.byteLength;o++)r[o+1]=s[o];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}}}Hf.NAME="lengthBlock";const K={};class $e extends jn{constructor({name:e=Me,optional:n=!1,primitiveSchema:r,...i}={},s){super(i),this.name=e,this.optional=n,r&&(this.primitiveSchema=r),this.idBlock=new Df(i),this.lenBlock=new Hf(i),this.valueBlock=s?new s(i):new Le(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 ro;n||Ff(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 o=this.lenBlock.toBER(e);r.write(o),r.write(s)}return n?mt: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 hy(n,r)}}$e.NAME="BaseBlock";function Ff(t){if(t instanceof K.Constructed)for(const e of t.valueBlock.value)Ff(e)&&(t.lenBlock.isIndefiniteForm=!0);return!!t.lenBlock.isIndefiniteForm}class pl extends $e{constructor({value:e=Me,...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}'`}}pl.NAME="BaseStringBlock";class Kf extends It(Le){constructor({isHexOnly:e=!0,...n}={}){super(n),this.isHexOnly=e}}Kf.NAME="PrimitiveValueBlock";var Wf;class oi extends $e{constructor(e={}){super(e,Kf),this.idBlock.isConstructed=!1}}Wf=oi;K.Primitive=Wf;oi.NAME="PRIMITIVE";function xy(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 lr(t,e=0,n=t.length){const r=e;let i=new $e({},Le);const s=new jn;if(!Vt(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=$e;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=xy(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 Fn(t){if(!t.byteLength){const e=new $e({},Le);return e.error="Input buffer has zero length",{offset:-1,result:e}}return lr(q.toUint8Array(t).slice(),0,t.byteLength)}function Sy(t,e){return t?1:e}class Kt extends Le{constructor({value:e=[],isIndefiniteForm:n=!1,...r}={}){super(r),this.value=e,this.isIndefiniteForm=n}fromBER(e,n,r){const i=q.toUint8Array(e);if(!Vt(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(;Sy(this.isIndefiniteForm,r)>0;){const o=lr(i,s,r);if(o.offset===-1)return this.error=o.result.error,this.warnings.concat(o.result.warnings),-1;if(s=o.offset,this.blockLength+=o.result.blockLength,r-=o.result.blockLength,this.value.push(o.result),this.isIndefiniteForm&&o.result.constructor.NAME===Vr)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===Vr?this.value.pop():this.warnings.push("No EndOfContent block encoded")),s}toBER(e,n){const r=n||new ro;for(let i=0;i<this.value.length;i++)this.value[i].toBER(e,r);return n?mt:r.final()}toJSON(){const e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(const n of this.value)e.value.push(n.toJSON());return e}}Kt.NAME="ConstructedValueBlock";var Gf;class De extends $e{constructor(e={}){super(e,Kt),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(`
|
|
76
100
|
`).map(i=>` ${i}`).join(`
|
|
77
101
|
`));const n=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${n} :
|
|
78
102
|
${e.join(`
|
|
79
|
-
`)}`:`${n} :`}}$f=De;K.Constructed=$f;De.NAME="CONSTRUCTED";class Of extends Ue{fromBER(e,n,r){return n}toBER(e){return mt}}Of.override="EndOfContentValueBlock";var Bf;class ol extends $e{constructor(e={}){super(e,Of),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}Bf=ol;K.EndOfContent=Bf;ol.NAME=Mr;var Tf;class bn extends $e{constructor(e={}){super(e,Ue),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}`}}Tf=bn;K.Null=Tf;bn.NAME="NULL";class Pf extends It(Ue){constructor({value:e,...n}={}){super(n),n.valueHex?this.valueHexView=q.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=q.toUint8Array(e);return Vt(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,Sf.call(this),this.blockLength=r,n+r):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}Pf.NAME="BooleanValueBlock";var Rf;class no extends $e{constructor(e={}){super(e,Pf),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}`}}Rf=no;K.Boolean=Rf;no.NAME="BOOLEAN";class Lf extends It(Kt){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=Kt.prototype.fromBER.call(this,e,n,r),i===-1)return i;for(let s=0;s<this.value.length;s++){const o=this.value[s].constructor.NAME;if(o===Mr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(o!==Af)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?Kt.prototype.toBER.call(this,e,n):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}}Lf.NAME="OctetStringValueBlock";var Uf;let mn=class Vf extends $e{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},Lf),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 o=dr(s,0,s.byteLength);o.offset!==-1&&o.offset===r&&(this.valueBlock.value=[o.result])}}catch{}}return super.fromBER(e,n,r)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?De.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 Vf&&e.push(n.valueBlock.valueHexView);return q.concat(e)}};Uf=mn;K.OctetString=Uf;mn.NAME=Af;class Mf extends It(Kt){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=Kt.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!==Ef)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=q.toUint8Array(e);if(!Vt(this,s,n,r))return-1;const o=s.subarray(n,n+r);if(this.unusedBits=o[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){const c=o.subarray(1);try{if(c.byteLength){const l=dr(c,0,c.byteLength);l.offset!==-1&&l.offset===r-1&&(this.value=[l.result])}}catch{}}return this.valueHexView=o.subarray(1),this.blockLength=o.length,n+r}toBER(e,n){if(this.isConstructed)return Kt.prototype.toBER.call(this,e,n);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return mt;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}}}Mf.NAME="BitStringValueBlock";var qf;let _n=class extends $e{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},Mf),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 De.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)}`}}};qf=_n;K.BitString=qf;_n.NAME=Ef;var Df;function j_(t,e){const n=new Uint8Array([0]),r=new Uint8Array(t),i=new Uint8Array(e);let s=r.slice(0);const o=s.length-1,c=i.slice(0),l=c.length-1;let u=0;const p=l<o?o:l;let h=0;for(let m=p;m>=0;m--,h++){switch(!0){case h<c.length:u=s[o-h]+c[l-h]+n[0];break;default:u=s[o-h]+n[0]}switch(n[0]=u/10,!0){case h>=s.length:s=Ia(new Uint8Array([u%10]),s);break;default:s[o-h]=u%10}}return n[0]>0&&(s=Ia(n,s)),s}function Mu(t){if(t>=Ar.length)for(let e=Ar.length;e<=t;e++){const n=new Uint8Array([0]);let r=Ar[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=Ia(n,r)),Ar.push(r)}return Ar[t]}function $_(t,e){let n=0;const r=new Uint8Array(t),i=new Uint8Array(e),s=r.slice(0),o=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[o-p]-c[l-p]-n,!0){case u<0:n=1,s[o-p]=u+10;break;default:n=0,s[o-p]=u}if(n>0)for(let h=o-l+1;h>=0;h--,p++)if(u=s[o-p]-n,u<0)n=1,s[o-p]=u+10;else{n=0,s[o-p]=u;break}return s.slice()}class al extends It(Ue){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=Sf.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(v_(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 o=this.valueHexView;return o[0]===0&&o[1]&128?this.valueHexView=o.subarray(1):i!==0&&o.length<i&&(i-o.length>1&&(i=o.length+1),this.valueHexView=o.subarray(i-o.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 o="",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=$_(Mu(r),n),o="-";break;default:n=j_(n,Mu(r))}r++,i>>=1}}for(let l=0;l<n.length;l++)n[l]&&(c=!0),c&&(o+=Uu.charAt(n[l]));return c===!1&&(o+=Uu.charAt(0)),o}}Df=al;al.NAME="IntegerValueBlock";Object.defineProperty(Df.prototype,"valueHex",{set:function(t){this.valueHexView=new Uint8Array(t),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var Hf;class xt extends $e{constructor(e={}){super(e,al),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return ls(),BigInt(this.valueBlock.toString())}static fromBigInt(e){ls();const n=BigInt(e),r=new eo,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=q.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 xt({valueHex:r.final()})}convertToDER(){const e=new xt({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new xt({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}}Hf=xt;K.Integer=Hf;xt.NAME="INTEGER";var Ff;class ro extends xt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}Ff=ro;K.Enumerated=Ff;ro.NAME="ENUMERATED";class za extends It(Ue){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=q.toUint8Array(e);if(!Vt(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 o=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)o[c]=this.valueHexView[c];return this.valueHexView=o,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){ls();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 o=0;o<this.blockLength-1;o++)s[o]=i[o]|128;return s[this.blockLength-1]=i[this.blockLength-1],s.buffer}const n=wn(this.valueDec,7);if(n.byteLength===0)return this.error="Error during encoding SID value",mt;const r=new Uint8Array(n.byteLength);if(!e){const i=new Uint8Array(n),s=n.byteLength-1;for(let o=0;o<s;o++)r[o]=i[o]|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}}}za.NAME="sidBlock";class Kf extends Ue{constructor({value:e=qe,...n}={}){super(n),this.value=[],e&&this.fromString(e)}fromBER(e,n,r){let i=n;for(;r>0;){const s=new za;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,mt;n.push(i)}return il(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 o=this.value[0];let c=0;switch(o.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;o.valueDec=l+c,s=!1}else{const o=new za;if(i>Number.MAX_SAFE_INTEGER){ls();const c=BigInt(i);o.valueBigInt=c}else if(o.valueDec=parseInt(i,10),isNaN(o.valueDec))return;this.value.length||(o.isFirstSid=!0,s=!0),this.value.push(o)}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}}Kf.NAME="ObjectIdentifierValueBlock";var Wf;class io extends $e{constructor(e={}){super(e,Kf),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()}}}Wf=io;K.ObjectIdentifier=Wf;io.NAME="OBJECT IDENTIFIER";class Ca extends It($n){constructor({valueDec:e=0,...n}={}){super(n),this.valueDec=e}fromBER(e,n,r){if(r===0)return n;const i=q.toUint8Array(e);if(!Vt(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 o=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)o[c]=this.valueHexView[c];return this.valueHexView=o,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 o=0;o<this.blockLength-1;o++)s[o]=i[o]|128;return s[this.blockLength-1]=i[this.blockLength-1],s.buffer}const n=wn(this.valueDec,7);if(n.byteLength===0)return this.error="Error during encoding SID value",mt;const r=new Uint8Array(n.byteLength);if(!e){const i=new Uint8Array(n),s=n.byteLength-1;for(let o=0;o<s;o++)r[o]=i[o]|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}}}Ca.NAME="relativeSidBlock";class Gf extends Ue{constructor({value:e=qe,...n}={}){super(n),this.value=[],e&&this.fromString(e)}fromBER(e,n,r){let i=n;for(;r>0;){const s=new Ca;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,mt;r.push(s)}return il(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 Ca;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}}Gf.NAME="RelativeObjectIdentifierValueBlock";var Jf;class cl extends $e{constructor(e={}){super(e,Gf),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()}}}Jf=cl;K.RelativeObjectIdentifier=Jf;cl.NAME="RelativeObjectIdentifier";var Zf;class Ot extends De{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}Zf=Ot;K.Sequence=Zf;Ot.NAME="SEQUENCE";var Yf;let Bt=class extends De{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};Yf=Bt;K.Set=Yf;Bt.NAME="SET";class Xf extends It(Ue){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=qe}toJSON(){return{...super.toJSON(),value:this.value}}}Xf.NAME="StringValueBlock";class Qf extends Xf{}Qf.NAME="SimpleStringValueBlock";class Ye extends sl{constructor({...e}={}){super(e,Qf)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,q.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}}Ye.NAME="SIMPLE STRING";class eh extends Ye{fromBuffer(e){this.valueBlock.valueHexView=q.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}}eh.NAME="Utf8StringValueBlock";var th;class Mt extends eh{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}th=Mt;K.Utf8String=th;Mt.NAME="UTF8String";class nh extends Ye{fromBuffer(e){this.valueBlock.value=J.ToUtf16String(e),this.valueBlock.valueHexView=q.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(J.FromUtf16String(e))}}nh.NAME="BmpStringValueBlock";var rh;class so extends nh{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}rh=so;K.BmpString=rh;so.NAME="BMPString";class ih extends Ye{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=wn(e.charCodeAt(i),8),o=new Uint8Array(s);if(o.length>4)continue;const c=4-o.length;for(let l=o.length-1;l>=0;l--)r[i*4+l+c]=o[l]}this.valueBlock.value=e}}ih.NAME="UniversalStringValueBlock";var sh;class oo extends ih{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}sh=oo;K.UniversalString=sh;oo.NAME="UniversalString";var oh;class ao extends Ye{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}oh=ao;K.NumericString=oh;ao.NAME="NumericString";var ah;class co extends Ye{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}ah=co;K.PrintableString=ah;co.NAME="PrintableString";var ch;class lo extends Ye{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}ch=lo;K.TeletexString=ch;lo.NAME="TeletexString";var lh;class uo extends Ye{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}lh=uo;K.VideotexString=lh;uo.NAME="VideotexString";var uh;class po extends Ye{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}uh=po;K.IA5String=uh;po.NAME="IA5String";var dh;class fo extends Ye{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}dh=fo;K.GraphicString=dh;fo.NAME="GraphicString";var ph;class li extends Ye{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}ph=li;K.VisibleString=ph;li.NAME="VisibleString";var fh;class ho extends Ye{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}fh=ho;K.GeneralString=fh;ho.NAME="GeneralString";var hh;class go extends Ye{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}hh=go;K.CharacterString=hh;go.NAME="CharacterString";var gh;class ui extends li{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,q.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]=Je(this.year<2e3?this.year-1900:this.year-2e3,2),n[1]=Je(this.month,2),n[2]=Je(this.day,2),n[3]=Je(this.hour,2),n[4]=Je(this.minute,2),n[5]=Je(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}}}gh=ui;K.UTCTime=gh;ui.NAME="UTCTime";var mh;class mo extends ui{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,o,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(o=/(\d{4})(\d{2})(\d{2})/ig,u!==-1)throw new Error("Wrong input string for conversion");break;case i.length===10:if(o=/(\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(o=/(\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(o=/(\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=o.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(Je(this.year,4)),n.push(Je(this.month,2)),n.push(Je(this.day,2)),n.push(Je(this.hour,2)),n.push(Je(this.minute,2)),n.push(Je(this.second,2)),this.millisecond!==0&&(n.push("."),n.push(Je(this.millisecond,3))),n.push("Z"),n.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}}mh=mo;K.GeneralizedTime=mh;mo.NAME="GeneralizedTime";var _h;class ll extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}_h=ll;K.DATE=_h;ll.NAME="DATE";var yh;class ul extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}yh=ul;K.TimeOfDay=yh;ul.NAME="TimeOfDay";var vh;class dl extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}vh=dl;K.DateTime=vh;dl.NAME="DateTime";var wh;class pl extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}wh=pl;K.Duration=wh;pl.NAME="Duration";var bh;class fl extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}bh=fl;K.TIME=bh;fl.NAME="TIME";class kn{constructor({name:e=qe,optional:n=!1}={}){this.name=e,this.optional=n}}class hl extends kn{constructor({value:e=[],...n}={}){super(n),this.value=e}}class us extends kn{constructor({value:e=new kn,local:n=!1,...r}={}){super(r),this.value=e,this.local=n}}class O_{constructor({data:e=to}={}){this.dataView=q.toUint8Array(e)}get data(){return this.dataView.slice().buffer}set data(e){this.dataView=q.toUint8Array(e)}fromBER(e,n,r){const i=n+r;return this.dataView=q.toUint8Array(e).subarray(n,i),i}toBER(e){return this.dataView.slice().buffer}}function fn(t,e,n){if(n instanceof hl){for(let s=0;s<n.value.length;s++)if(fn(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(na)&&(s.name=n.name),s}}if(n instanceof kn)return n.hasOwnProperty(na)&&(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(!(k_ in n))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(E_ in n.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(I_ 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(x_)===!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(S_)===!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(A_)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(n.idBlock.isConstructed!==e.idBlock.isConstructed)return{verified:!1,result:t};if(!(b_ 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(!(Vu in n.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const s=n.idBlock.valueHexView,o=e.idBlock.valueHexView;if(s.length!==o.length)return{verified:!1,result:t};for(let c=0;c<s.length;c++)if(s[c]!==o[1])return{verified:!1,result:t}}if(n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,qe),n.name&&(t[n.name]=e)),n instanceof K.Constructed){let s=0,o={verified:!1,result:{error:"Unknown error"}},c=n.valueBlock.value.length;if(c>0&&n.valueBlock.value[0]instanceof us&&(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,qe),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,qe),n.name&&(delete t[n.name],u.name=n.name)),u}}else if(n.valueBlock.value[0]instanceof us){if(o=fn(t,e.valueBlock.value[l],n.valueBlock.value[0].value),o.verified===!1)if(n.valueBlock.value[0].optional)s++;else return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,qe),n.name&&delete t[n.name]),o;if(na in n.valueBlock.value[0]&&n.valueBlock.value[0].name.length>0){let u={};z_ 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(o=fn(t,e.valueBlock.value[l-s],n.valueBlock.value[l]),o.verified===!1)if(n.valueBlock.value[l].optional)s++;else return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,qe),n.name&&delete t[n.name]),o;if(o.verified===!1){const l={verified:!1,result:t};return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,qe),n.name&&(delete t[n.name],l.name=n.name)),l}return{verified:!0,result:t}}if(n.primitiveSchema&&Vu in e.valueBlock){const s=dr(e.valueBlock.valueHexView);if(s.offset===-1){const o={verified:!1,result:s.result};return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,qe),n.name&&(delete t[n.name],o.name=n.name)),o}return fn(t,s.result,n.primitiveSchema)}return{verified:!0,result:t}}function B_(t,e){if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};const n=dr(q.toUint8Array(t));return n.offset===-1?{verified:!1,result:n.result}:fn(n.result,n.result,e)}const kh=Object.freeze(Object.defineProperty({__proto__:null,Any:kn,BaseBlock:$e,BaseStringBlock:sl,BitString:_n,BmpString:so,Boolean:no,CharacterString:go,Choice:hl,Constructed:De,DATE:ll,DateTime:dl,Duration:pl,EndOfContent:ol,Enumerated:ro,GeneralString:ho,GeneralizedTime:mo,GraphicString:fo,HexBlock:It,IA5String:po,Integer:xt,Null:bn,NumericString:ao,ObjectIdentifier:io,OctetString:mn,Primitive:ci,PrintableString:co,RawData:O_,RelativeObjectIdentifier:cl,Repeated:us,Sequence:Ot,Set:Bt,TIME:fl,TeletexString:lo,TimeOfDay:ul,UTCTime:ui,UniversalString:oo,Utf8String:Mt,ValueBlock:Ue,VideotexString:uo,ViewWriter:eo,VisibleString:li,compareSchema:fn,fromBER:Kn,verifySchema:B_},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 _o{constructor(e,n=0){if(this.unusedBits=0,this.value=new ArrayBuffer(0),e)if(typeof e=="number")this.fromNumber(e);else if(q.isBufferSource(e))this.unusedBits=n,this.value=q.toArrayBuffer(e);else throw TypeError("Unsupported type of 'params' argument for BitString")}fromASN(e){if(!(e instanceof _n))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 _n({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new _n({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 ae{get byteLength(){return this.buffer.byteLength}get byteOffset(){return 0}constructor(e){typeof e=="number"?this.buffer=new ArrayBuffer(e):q.isBufferSource(e)?this.buffer=q.toArrayBuffer(e):Array.isArray(e)?this.buffer=new Uint8Array(e):this.buffer=new ArrayBuffer(0)}fromASN(e){if(!(e instanceof mn))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=e.valueBlock.valueHex,this}toASN(){return new mn({valueHex:this.buffer})}toSchema(e){return new mn({name:e})}}const T_={fromASN:t=>t instanceof bn?null:t.valueBeforeDecodeView,toASN:t=>{if(t===null)return new bn;const e=Kn(t);if(e.result.error)throw new Error(e.result.error);return e.result}},P_={fromASN:t=>t.valueBlock.valueHexView.byteLength>=4?t.valueBlock.toString():t.valueBlock.valueDec,toASN:t=>new xt({value:+t})},R_={fromASN:t=>t.valueBlock.valueDec,toASN:t=>new ro({value:t})},_e={fromASN:t=>t.valueBlock.valueHexView,toASN:t=>new xt({valueHex:t})},L_={fromASN:t=>t.valueBlock.valueHexView,toASN:t=>new _n({valueHex:t})},U_={fromASN:t=>t.valueBlock.toString(),toASN:t=>new io({value:t})},V_={fromASN:t=>t.valueBlock.value,toASN:t=>new no({value:t})},ds={fromASN:t=>t.valueBlock.valueHexView,toASN:t=>new mn({valueHex:t})},M_={fromASN:t=>new ae(t.getValue()),toASN:t=>t.toASN()};function it(t){return{fromASN:e=>e.valueBlock.value,toASN:e=>new t({value:e})}}const xh=it(Mt),q_=it(so),D_=it(oo),H_=it(ao),F_=it(co),K_=it(lo),W_=it(uo),G_=it(po),J_=it(fo),Z_=it(li),Y_=it(ho),X_=it(go),Q_={fromASN:t=>t.toDate(),toASN:t=>new ui({valueDate:t})},e0={fromASN:t=>t.toDate(),toASN:t=>new mo({valueDate:t})},t0={fromASN:()=>null,toASN:()=>new bn};function gl(t){switch(t){case b.Any:return T_;case b.BitString:return L_;case b.BmpString:return q_;case b.Boolean:return V_;case b.CharacterString:return X_;case b.Enumerated:return R_;case b.GeneralString:return Y_;case b.GeneralizedTime:return e0;case b.GraphicString:return J_;case b.IA5String:return G_;case b.Integer:return P_;case b.Null:return t0;case b.NumericString:return H_;case b.ObjectIdentifier:return U_;case b.OctetString:return ds;case b.PrintableString:return F_;case b.TeletexString:return K_;case b.UTCTime:return Q_;case b.UniversalString:return D_;case b.Utf8String:return xh;case b.VideotexString:return W_;case b.VisibleString:return Z_;default:return null}}function $t(t){return typeof t=="function"&&t.prototype?t.prototype.toASN&&t.prototype.fromASN?!0:$t(t.prototype):!!(t&&typeof t=="object"&&"toASN"in t&&"fromASN"in t)}function Sh(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:Sh(n)}return!1}function n0(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 r0{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 o=r.items[s],c=n?s:"";let l;if(typeof o.type=="number"){const p=b[o.type],h=kh[p];if(!h)throw new Error(`Cannot get ASN1 class by name '${p}'`);l=new h({name:c})}else $t(o.type)?l=new o.type().toSchema(c):o.optional?this.get(o.type).type===T.Choice?l=new kn({name:c}):(l=this.create(o.type,!1),l.name=c):l=new kn({name:c});const u=!!o.optional||o.defaultValue!==void 0;if(o.repeated){l.name="";const p=o.repeated==="set"?Bt:Ot;l=new p({name:"",value:[new us({name:c,value:l})]})}if(o.context!==null&&o.context!==void 0)if(o.implicit)if(typeof o.type=="number"||$t(o.type)){const p=o.repeated?De:ci;i.push(new p({name:c,optional:u,idBlock:{tagClass:3,tagNumber:o.context}}))}else{this.cache(o.type);const p=!!o.repeated;let h=p?l:this.get(o.type,!0).schema;h="valueBlock"in h?h.valueBlock.value:h.value,i.push(new De({name:p?"":c,optional:u,idBlock:{tagClass:3,tagNumber:o.context},value:h}))}else i.push(new De({optional:u,idBlock:{tagClass:3,tagNumber:o.context},value:[l]}));else l.optional=u,i.push(l)}switch(r.type){case T.Sequence:return new Ot({value:i,name:""});case T.Set:return new Bt({value:i,name:""});case T.Choice:return new hl({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 et=new r0,P=t=>e=>{let n;et.has(e)?n=et.get(e):(n=et.createDefault(e),et.set(e,n)),Object.assign(n,t)},g=t=>(e,n)=>{let r;et.has(e.constructor)?r=et.get(e.constructor):(r=et.createDefault(e.constructor),et.set(e.constructor,r));const i=Object.assign({},t);if(typeof i.type=="number"&&!i.converter){const s=gl(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 qu extends Error{constructor(){super(...arguments),this.schemas=[]}}class i0{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($t(n))return new n().fromASN(e);const i=et.get(n);et.cache(n);let s=i.schema;if(e.constructor===De&&i.type!==T.Choice){s=new De({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:i.schema.valueBlock.value});for(const l in i.items)delete e[l]}const o=fn({},e,s);if(!o.verified)throw new qu(`Data does not match to ${n.name} ASN1 schema. ${o.result.error}`);const c=new n;if(Sh(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=gl(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=o.result[l];if(!u)continue;const p=i.items[l],h=p.type;if(typeof h=="number"||$t(h)){const m=(r=p.converter)!==null&&r!==void 0?r:$t(h)?new h:null;if(!m)throw new Error("Converter is empty");if(p.repeated)if(p.implicit){const v=p.repeated==="sequence"?Ot:Bt,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($t(h))f=new h().toSchema("");else{const _=b[h],w=kh[_];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 qu&&i.schemas.push(n.name),i}}}class ml{static serialize(e){return e instanceof $e?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&typeof e=="object"&&$t(e))return e.toASN();if(!(e&&typeof e=="object"))throw new TypeError("Parameter 1 should be type of Object.");const n=e.constructor,r=et.get(n);et.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 o=gl(r.itemType);if(!o)throw new Error(`Cannot get default converter for array item of ${n.name} ASN1 schema`);i=e.map(c=>o.toASN(c))}else i=e.map(o=>this.toAsnItem({type:r.itemType},"[]",n,o))}else for(const o in r.items){const c=r.items[o],l=e[o];if(l===void 0||c.defaultValue===l||typeof c.defaultValue=="object"&&typeof l=="object"&&n0(this.serialize(c.defaultValue),this.serialize(l)))continue;const u=ml.toAsnItem(c,o,n,l);if(typeof c.context=="number")if(c.implicit)if(!c.repeated&&(typeof c.type=="number"||$t(c.type))){const p={};p.valueHex=u instanceof bn?u.valueBeforeDecodeView:u.valueBlock.toBER(),i.push(new ci({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},...p}))}else i.push(new De({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:u.valueBlock.value}));else i.push(new De({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 Ot({value:i});break;case T.Set:s=new Bt({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 o=e.converter;if(!o)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=>o.toASN(u)),l=e.repeated==="sequence"?Ot:Bt;s=new l({value:c})}else s=o.toASN(i)}else if(e.repeated){if(!Array.isArray(i))throw new TypeError("Parameter 'objProp' should be type of Array.");const o=Array.from(i,l=>this.toASN(l)),c=e.repeated==="sequence"?Ot:Bt;s=new c({value:o})}else s=this.toASN(i);return s}}class pe extends Array{constructor(e=[]){if(typeof e=="number")super(e);else{super();for(const n of e)this.push(n)}}}class M{static serialize(e){return ml.serialize(e)}static parse(e,n){return i0.parse(e,n)}static toString(e){const n=q.isBufferSource(e)?q.toArrayBuffer(e):M.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,o;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--)(o=t[c])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s}var Ah={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"),o="%[0-9a-z]{1,}",c="(?:[0-9a-f]+::?)+",l={zoneIndex:new RegExp(o,"i"),native:new RegExp(`^(::)?(${c})?([0-9a-f]+)?(::)?(${o})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${n}\\.${n}\\.${n}\\.${n}(${o})?)$`,"i"),transitional:new RegExp(`^((?:${c})|(?:::)(?:${c})?)${n}\\.${n}\\.${n}\\.${n}(${o})?$`,"i")};function u(f,_){if(f.indexOf("::")!==f.lastIndexOf("::"))return null;let w=0,S=-1,N=(f.match(l.zoneIndex)||[])[0],B,R;for(N&&(N=N.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(R=_-w,B=":";R--;)B+="0:";return f=f.replace("::",B),f[0]===":"&&(f=f.slice(1)),f[f.length-1]===":"&&(f=f.slice(0,-1)),_=function(){const te=f.split(":"),fe=[];for(let le=0;le<te.length;le++)fe.push(parseInt(te[le],16));return fe}(),{parts:_,zoneId:N}}function p(f,_,w,S){if(f.length!==_.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let N=0,B;for(;S>0;){if(B=w-S,B<0&&(B=0),f[N]>>B!==_[N]>>B)return!1;S-=w,N+=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 N,B,R;for(N=3;N>=0;N-=1)if(B=this.octets[N],B in S){if(R=S[B],w&&R!==0)return null;R!==8&&(w=!0),_+=R}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(),N=[];let B=0;for(;B<4;)N.push(parseInt(w[B],10)|parseInt(S[B],10)^255),B++;return new this(N)}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,N,B;try{for(_=this.parseCIDR(f),S=_[0].toByteArray(),B=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),N=[],w=0;w<4;)N.push(parseInt(S[w],10)&parseInt(B[w],10)),w++;return new this(N)}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 N=_.slice(1,6),B=[];for(let R=0;R<N.length;R++)w=N[R],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 N=[];let B;for(B=0;B<=24;B+=8)N.push(S>>B&255);return N}().reverse()}else return(_=f.match(r.twoOctet))?function(){const N=_.slice(1,4),B=[];if(S=h(N[1]),S>16777215||S<0)throw new Error("ipaddr: address outside defined range");return B.push(h(N[0])),B.push(S>>16&255),B.push(S>>8&255),B.push(S&255),B}():(_=f.match(r.threeOctet))?function(){const N=_.slice(1,5),B=[];if(S=h(N[2]),S>65535||S<0)throw new Error("ipaddr: address outside defined range");return B.push(h(N[0])),B.push(h(N[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,N;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(N=this.parts[S],!(0<=N&&N<=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 N,B;for(let R=7;R>=0;R-=1)if(N=this.parts[R],N in S){if(B=S[N],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 N=0;N<S.length;N++)_=S[N],w.push(_>>8),w.push(_&255);return w},f.prototype.toFixedLengthString=function(){const _=(function(){const S=[];for(let N=0;N<this.parts.length;N++)S.push(m(this.parts[N].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 N=0;N<this.parts.length;N++)S.push(this.parts[N].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,N=-1,B;for(;B=_.exec(w);)B[0].length>N&&(S=B.index,N=B[0].length);return N<0?w:`${w.substring(0,S)}::${w.substring(S+N)}`},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(),N=[];let B=0;for(;B<16;)N.push(parseInt(w[B],10)|parseInt(S[B],10)^255),B++;return new this(N)}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,N,B;try{for(_=this.parseCIDR(f),S=_[0].toByteArray(),B=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),N=[],w=0;w<16;)N.push(parseInt(S[w],10)&parseInt(B[w],10)),w++;return new this(N)}catch(R){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${R})`)}},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,N,B,R;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))&&(R=S[6]||"",_=S[1],S[1].endsWith("::")||(_=_.slice(0,-1)),_=u(_+R,6),_.parts)){for(B=[parseInt(S[2]),parseInt(S[3]),parseInt(S[4]),parseInt(S[5])],w=0;w<B.length;w++)if(N=B[w],!(0<=N&&N<=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,N,B,R;w==null&&(w="unicast");for(N in _)if(Object.prototype.hasOwnProperty.call(_,N)){for(B=_[N],B[0]&&!(B[0]instanceof Array)&&(B=[B]),S=0;S<B.length;S++)if(R=B[S],f.kind()===R[0].kind()&&f.match.apply(f,R))return N}return w},t.exports?t.exports=v:e.ipaddr=v})(cs)})(Ah);var Du=Ah.exports;class Hu{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 Du.fromByteArray(Array.from(n)).toString()}return this.decodeIP(J.ToHex(e))}static fromString(e){const n=Du.parse(e);return new Uint8Array(n.toByteArray()).buffer}}var Na,ja,$a;let Oe=class{constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};d([g({type:b.TeletexString})],Oe.prototype,"teletexString",void 0);d([g({type:b.PrintableString})],Oe.prototype,"printableString",void 0);d([g({type:b.UniversalString})],Oe.prototype,"universalString",void 0);d([g({type:b.Utf8String})],Oe.prototype,"utf8String",void 0);d([g({type:b.BmpString})],Oe.prototype,"bmpString",void 0);Oe=d([P({type:T.Choice})],Oe);let Yn=class extends Oe{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([P({type:T.Choice})],Yn);class yo{constructor(e={}){this.type="",this.value=new Yn,Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],yo.prototype,"type",void 0);d([g({type:Yn})],yo.prototype,"value",void 0);let Xn=Na=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Na.prototype)}};Xn=Na=d([P({type:T.Set,itemType:yo})],Xn);let Oa=ja=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,ja.prototype)}};Oa=ja=d([P({type:T.Sequence,itemType:Xn})],Oa);let ke=$a=class extends Oa{constructor(e){super(e),Object.setPrototypeOf(this,$a.prototype)}};ke=$a=d([P({type:T.Sequence})],ke);const s0={fromASN:t=>Hu.toString(ds.fromASN(t)),toASN:t=>ds.toASN(Hu.fromString(t))};class qr{constructor(e={}){this.typeId="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],qr.prototype,"typeId",void 0);d([g({type:b.Any,context:0})],qr.prototype,"value",void 0);class _l{constructor(e={}){this.partyName=new Oe,Object.assign(this,e)}}d([g({type:Oe,optional:!0,context:0,implicit:!0})],_l.prototype,"nameAssigner",void 0);d([g({type:Oe,context:1,implicit:!0})],_l.prototype,"partyName",void 0);let re=class{constructor(e={}){Object.assign(this,e)}};d([g({type:qr,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:_l,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:s0})],re.prototype,"iPAddress",void 0);d([g({type:b.ObjectIdentifier,context:8,implicit:!0})],re.prototype,"registeredID",void 0);re=d([P({type:T.Choice})],re);const yl="1.3.6.1.5.5.7",o0=`${yl}.1`,pr=`${yl}.3`,vo=`${yl}.48`,Fu=`${vo}.1`,Ku=`${vo}.2`,Wu=`${vo}.3`,Gu=`${vo}.5`,rn="2.5.29";var Ba;const Ta=`${o0}.1`;class di{constructor(e={}){this.accessMethod="",this.accessLocation=new re,Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],di.prototype,"accessMethod",void 0);d([g({type:re})],di.prototype,"accessLocation",void 0);let Hn=Ba=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Ba.prototype)}};Hn=Ba=d([P({type:T.Sequence,itemType:di})],Hn);const Pa=`${rn}.35`;class vl extends ae{}class hn{constructor(e={}){e&&Object.assign(this,e)}}d([g({type:vl,context:0,optional:!0,implicit:!0})],hn.prototype,"keyIdentifier",void 0);d([g({type:re,context:1,optional:!0,implicit:!0,repeated:"sequence"})],hn.prototype,"authorityCertIssuer",void 0);d([g({type:b.Integer,context:2,optional:!0,implicit:!0,converter:_e})],hn.prototype,"authorityCertSerialNumber",void 0);const Eh=`${rn}.19`;class ps{constructor(e={}){this.cA=!1,Object.assign(this,e)}}d([g({type:b.Boolean,defaultValue:!1})],ps.prototype,"cA",void 0);d([g({type:b.Integer,optional:!0})],ps.prototype,"pathLenConstraint",void 0);var Ra;let Le=Ra=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Ra.prototype)}};Le=Ra=d([P({type:T.Sequence,itemType:re})],Le);var La;let Ju=La=class extends Le{constructor(e){super(e),Object.setPrototypeOf(this,La.prototype)}};Ju=La=d([P({type:T.Sequence})],Ju);var Ua;const Ih=`${rn}.32`;let Tt=class{constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};d([g({type:b.IA5String})],Tt.prototype,"ia5String",void 0);d([g({type:b.VisibleString})],Tt.prototype,"visibleString",void 0);d([g({type:b.BmpString})],Tt.prototype,"bmpString",void 0);d([g({type:b.Utf8String})],Tt.prototype,"utf8String",void 0);Tt=d([P({type:T.Choice})],Tt);class wl{constructor(e={}){this.organization=new Tt,this.noticeNumbers=[],Object.assign(this,e)}}d([g({type:Tt})],wl.prototype,"organization",void 0);d([g({type:b.Integer,repeated:"sequence"})],wl.prototype,"noticeNumbers",void 0);class bl{constructor(e={}){Object.assign(this,e)}}d([g({type:wl,optional:!0})],bl.prototype,"noticeRef",void 0);d([g({type:Tt,optional:!0})],bl.prototype,"explicitText",void 0);let fs=class{constructor(e={}){Object.assign(this,e)}};d([g({type:b.IA5String})],fs.prototype,"cPSuri",void 0);d([g({type:bl})],fs.prototype,"userNotice",void 0);fs=d([P({type:T.Choice})],fs);class kl{constructor(e={}){this.policyQualifierId="",this.qualifier=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],kl.prototype,"policyQualifierId",void 0);d([g({type:b.Any})],kl.prototype,"qualifier",void 0);class wo{constructor(e={}){this.policyIdentifier="",Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],wo.prototype,"policyIdentifier",void 0);d([g({type:kl,repeated:"sequence",optional:!0})],wo.prototype,"policyQualifiers",void 0);let hs=Ua=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Ua.prototype)}};hs=Ua=d([P({type:T.Sequence,itemType:wo})],hs);let gs=class{constructor(e=0){this.value=e}};d([g({type:b.Integer})],gs.prototype,"value",void 0);gs=d([P({type:T.Choice})],gs);let Zu=class extends gs{};Zu=d([P({type:T.Choice})],Zu);var Va;const Ma=`${rn}.31`;var lt;(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"})(lt||(lt={}));class zh extends _o{toJSON(){const e=[],n=this.toNumber();return n<.aACompromise&&e.push("aACompromise"),n<.affiliationChanged&&e.push("affiliationChanged"),n<.cACompromise&&e.push("cACompromise"),n<.certificateHold&&e.push("certificateHold"),n<.cessationOfOperation&&e.push("cessationOfOperation"),n<.keyCompromise&&e.push("keyCompromise"),n<.privilegeWithdrawn&&e.push("privilegeWithdrawn"),n<.superseded&&e.push("superseded"),n<.unused&&e.push("unused"),e}toString(){return`[${this.toJSON().join(", ")}]`}}let xn=class{constructor(e={}){Object.assign(this,e)}};d([g({type:re,context:0,repeated:"sequence",implicit:!0})],xn.prototype,"fullName",void 0);d([g({type:Xn,context:1,implicit:!0})],xn.prototype,"nameRelativeToCRLIssuer",void 0);xn=d([P({type:T.Choice})],xn);class fr{constructor(e={}){Object.assign(this,e)}}d([g({type:xn,context:0,optional:!0})],fr.prototype,"distributionPoint",void 0);d([g({type:zh,context:1,optional:!0,implicit:!0})],fr.prototype,"reasons",void 0);d([g({type:re,context:2,optional:!0,repeated:"sequence",implicit:!0})],fr.prototype,"cRLIssuer",void 0);let Wn=Va=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Va.prototype)}};Wn=Va=d([P({type:T.Sequence,itemType:fr})],Wn);var qa;let Yu=qa=class extends Wn{constructor(e){super(e),Object.setPrototypeOf(this,qa.prototype)}};Yu=qa=d([P({type:T.Sequence,itemType:fr})],Yu);class Te{constructor(e={}){this.onlyContainsUserCerts=Te.ONLY,this.onlyContainsCACerts=Te.ONLY,this.indirectCRL=Te.ONLY,this.onlyContainsAttributeCerts=Te.ONLY,Object.assign(this,e)}}Te.ONLY=!1;d([g({type:xn,context:0,optional:!0})],Te.prototype,"distributionPoint",void 0);d([g({type:b.Boolean,context:1,defaultValue:Te.ONLY,implicit:!0})],Te.prototype,"onlyContainsUserCerts",void 0);d([g({type:b.Boolean,context:2,defaultValue:Te.ONLY,implicit:!0})],Te.prototype,"onlyContainsCACerts",void 0);d([g({type:zh,context:3,optional:!0,implicit:!0})],Te.prototype,"onlySomeReasons",void 0);d([g({type:b.Boolean,context:4,defaultValue:Te.ONLY,implicit:!0})],Te.prototype,"indirectCRL",void 0);d([g({type:b.Boolean,context:5,defaultValue:Te.ONLY,implicit:!0})],Te.prototype,"onlyContainsAttributeCerts",void 0);var Br;(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"})(Br||(Br={}));let Da=class{constructor(e=Br.unspecified){this.reason=Br.unspecified,this.reason=e}toJSON(){return Br[this.reason]}toString(){return this.toJSON()}};d([g({type:b.Enumerated})],Da.prototype,"reason",void 0);Da=d([P({type:T.Choice})],Da);var Ha;const Ch=`${rn}.37`;let ms=Ha=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Ha.prototype)}};ms=Ha=d([P({type:T.Sequence,itemType:b.ObjectIdentifier})],ms);const a0=`${pr}.1`,c0=`${pr}.2`,l0=`${pr}.3`,u0=`${pr}.4`,d0=`${pr}.8`,p0=`${pr}.9`;let Fa=class{constructor(e=new ArrayBuffer(0)){this.value=e}};d([g({type:b.Integer,converter:_e})],Fa.prototype,"value",void 0);Fa=d([P({type:T.Choice})],Fa);let Ka=class{constructor(e){this.value=new Date,e&&(this.value=e)}};d([g({type:b.GeneralizedTime})],Ka.prototype,"value",void 0);Ka=d([P({type:T.Choice})],Ka);var Wa;let Xu=Wa=class extends Le{constructor(e){super(e),Object.setPrototypeOf(this,Wa.prototype)}};Xu=Wa=d([P({type:T.Sequence})],Xu);const Nh=`${rn}.15`;var ut;(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"})(ut||(ut={}));class ra extends _o{toJSON(){const e=this.toNumber(),n=[];return e&ut.cRLSign&&n.push("crlSign"),e&ut.dataEncipherment&&n.push("dataEncipherment"),e&ut.decipherOnly&&n.push("decipherOnly"),e&ut.digitalSignature&&n.push("digitalSignature"),e&ut.encipherOnly&&n.push("encipherOnly"),e&ut.keyAgreement&&n.push("keyAgreement"),e&ut.keyCertSign&&n.push("keyCertSign"),e&ut.keyEncipherment&&n.push("keyEncipherment"),e&ut.nonRepudiation&&n.push("nonRepudiation"),n}toString(){return`[${this.toJSON().join(", ")}]`}}var Ga;class bo{constructor(e={}){this.base=new re,this.minimum=0,Object.assign(this,e)}}d([g({type:re})],bo.prototype,"base",void 0);d([g({type:b.Integer,context:0,defaultValue:0,implicit:!0})],bo.prototype,"minimum",void 0);d([g({type:b.Integer,context:1,optional:!0,implicit:!0})],bo.prototype,"maximum",void 0);let _s=Ga=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Ga.prototype)}};_s=Ga=d([P({type:T.Sequence,itemType:bo})],_s);class jh{constructor(e={}){Object.assign(this,e)}}d([g({type:_s,context:0,optional:!0,implicit:!0})],jh.prototype,"permittedSubtrees",void 0);d([g({type:_s,context:1,optional:!0,implicit:!0})],jh.prototype,"excludedSubtrees",void 0);class $h{constructor(e={}){Object.assign(this,e)}}d([g({type:b.Integer,context:0,implicit:!0,optional:!0,converter:_e})],$h.prototype,"requireExplicitPolicy",void 0);d([g({type:b.Integer,context:1,implicit:!0,optional:!0,converter:_e})],$h.prototype,"inhibitPolicyMapping",void 0);var Ja;class xl{constructor(e={}){this.issuerDomainPolicy="",this.subjectDomainPolicy="",Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],xl.prototype,"issuerDomainPolicy",void 0);d([g({type:b.ObjectIdentifier})],xl.prototype,"subjectDomainPolicy",void 0);let Qu=Ja=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Ja.prototype)}};Qu=Ja=d([P({type:T.Sequence,itemType:xl})],Qu);var Za;const Oh=`${rn}.17`;let Ya=Za=class extends Le{constructor(e){super(e),Object.setPrototypeOf(this,Za.prototype)}};Ya=Za=d([P({type:T.Sequence})],Ya);let Pt=class{constructor(e={}){this.type="",this.values=[],Object.assign(this,e)}};d([g({type:b.ObjectIdentifier})],Pt.prototype,"type",void 0);d([g({type:b.Any,repeated:"set"})],Pt.prototype,"values",void 0);var Xa;let ed=Xa=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Xa.prototype)}};ed=Xa=d([P({type:T.Sequence,itemType:Pt})],ed);const Bh=`${rn}.14`;class Wt extends vl{}class Th{constructor(e={}){Object.assign(this,e)}}d([g({type:b.GeneralizedTime,context:0,implicit:!0,optional:!0})],Th.prototype,"notBefore",void 0);d([g({type:b.GeneralizedTime,context:1,implicit:!0,optional:!0})],Th.prototype,"notAfter",void 0);var Tr;(function(t){t[t.keyUpdateAllowed=1]="keyUpdateAllowed",t[t.newExtensions=2]="newExtensions",t[t.pKIXCertificate=4]="pKIXCertificate"})(Tr||(Tr={}));class Ph extends _o{toJSON(){const e=[],n=this.toNumber();return n&Tr.pKIXCertificate&&e.push("pKIXCertificate"),n&Tr.newExtensions&&e.push("newExtensions"),n&Tr.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return`[${this.toJSON().join(", ")}]`}}class Rh{constructor(e={}){this.entrustVers="",this.entrustInfoFlags=new Ph,Object.assign(this,e)}}d([g({type:b.GeneralString})],Rh.prototype,"entrustVers",void 0);d([g({type:Ph})],Rh.prototype,"entrustInfoFlags",void 0);var Qa;let td=Qa=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Qa.prototype)}};td=Qa=d([P({type:T.Sequence,itemType:di})],td);class F{constructor(e={}){this.algorithm="",Object.assign(this,e)}isEqual(e){return e instanceof F&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&xf(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 dt{constructor(e={}){this.algorithm=new F,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:F})],dt.prototype,"algorithm",void 0);d([g({type:b.BitString})],dt.prototype,"subjectPublicKey",void 0);let je=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})],je.prototype,"utcTime",void 0);d([g({type:b.GeneralizedTime})],je.prototype,"generalTime",void 0);je=d([P({type:T.Choice})],je);class pi{constructor(e){this.notBefore=new je(new Date),this.notAfter=new je(new Date),e&&(this.notBefore=new je(e.notBefore),this.notAfter=new je(e.notAfter))}}d([g({type:je})],pi.prototype,"notBefore",void 0);d([g({type:je})],pi.prototype,"notAfter",void 0);var ec;let rt=class Lh{constructor(e={}){this.extnID="",this.critical=Lh.CRITICAL,this.extnValue=new ae,Object.assign(this,e)}};rt.CRITICAL=!1;d([g({type:b.ObjectIdentifier})],rt.prototype,"extnID",void 0);d([g({type:b.Boolean,defaultValue:rt.CRITICAL})],rt.prototype,"critical",void 0);d([g({type:ae})],rt.prototype,"extnValue",void 0);let Xt=ec=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,ec.prototype)}};Xt=ec=d([P({type:T.Sequence,itemType:rt})],Xt);var Sn;(function(t){t[t.v1=0]="v1",t[t.v2=1]="v2",t[t.v3=2]="v3"})(Sn||(Sn={}));class Xe{constructor(e={}){this.version=Sn.v1,this.serialNumber=new ArrayBuffer(0),this.signature=new F,this.issuer=new ke,this.validity=new pi,this.subject=new ke,this.subjectPublicKeyInfo=new dt,Object.assign(this,e)}}d([g({type:b.Integer,context:0,defaultValue:Sn.v1})],Xe.prototype,"version",void 0);d([g({type:b.Integer,converter:_e})],Xe.prototype,"serialNumber",void 0);d([g({type:F})],Xe.prototype,"signature",void 0);d([g({type:ke})],Xe.prototype,"issuer",void 0);d([g({type:pi})],Xe.prototype,"validity",void 0);d([g({type:ke})],Xe.prototype,"subject",void 0);d([g({type:dt})],Xe.prototype,"subjectPublicKeyInfo",void 0);d([g({type:b.BitString,context:1,implicit:!0,optional:!0})],Xe.prototype,"issuerUniqueID",void 0);d([g({type:b.BitString,context:2,implicit:!0,optional:!0})],Xe.prototype,"subjectUniqueID",void 0);d([g({type:Xt,context:3,optional:!0})],Xe.prototype,"extensions",void 0);class An{constructor(e={}){this.tbsCertificate=new Xe,this.signatureAlgorithm=new F,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:Xe})],An.prototype,"tbsCertificate",void 0);d([g({type:F})],An.prototype,"signatureAlgorithm",void 0);d([g({type:b.BitString})],An.prototype,"signatureValue",void 0);class ko{constructor(e={}){this.userCertificate=new ArrayBuffer(0),this.revocationDate=new je,Object.assign(this,e)}}d([g({type:b.Integer,converter:_e})],ko.prototype,"userCertificate",void 0);d([g({type:je})],ko.prototype,"revocationDate",void 0);d([g({type:rt,optional:!0,repeated:"sequence"})],ko.prototype,"crlEntryExtensions",void 0);class qt{constructor(e={}){this.signature=new F,this.issuer=new ke,this.thisUpdate=new je,Object.assign(this,e)}}d([g({type:b.Integer,optional:!0})],qt.prototype,"version",void 0);d([g({type:F})],qt.prototype,"signature",void 0);d([g({type:ke})],qt.prototype,"issuer",void 0);d([g({type:je})],qt.prototype,"thisUpdate",void 0);d([g({type:je,optional:!0})],qt.prototype,"nextUpdate",void 0);d([g({type:ko,repeated:"sequence",optional:!0})],qt.prototype,"revokedCertificates",void 0);d([g({type:rt,optional:!0,context:0,repeated:"sequence"})],qt.prototype,"crlExtensions",void 0);class Sl{constructor(e={}){this.tbsCertList=new qt,this.signatureAlgorithm=new F,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:qt})],Sl.prototype,"tbsCertList",void 0);d([g({type:F})],Sl.prototype,"signatureAlgorithm",void 0);d([g({type:b.BitString})],Sl.prototype,"signature",void 0);class hr{constructor(e={}){this.issuer=new ke,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:ke})],hr.prototype,"issuer",void 0);d([g({type:b.Integer,converter:_e})],hr.prototype,"serialNumber",void 0);let Qn=class{constructor(e={}){Object.assign(this,e)}};d([g({type:Wt,context:0,implicit:!0})],Qn.prototype,"subjectKeyIdentifier",void 0);d([g({type:hr})],Qn.prototype,"issuerAndSerialNumber",void 0);Qn=d([P({type:T.Choice})],Qn);var Rt;(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"})(Rt||(Rt={}));let Dr=class extends F{};Dr=d([P({type:T.Sequence})],Dr);let ys=class extends F{};ys=d([P({type:T.Sequence})],ys);let St=class extends F{};St=d([P({type:T.Sequence})],St);let vs=class extends F{};vs=d([P({type:T.Sequence})],vs);let nd=class extends F{};nd=d([P({type:T.Sequence})],nd);let tc=class extends F{};tc=d([P({type:T.Sequence})],tc);let gr=class{constructor(e={}){this.attrType="",this.attrValues=[],Object.assign(this,e)}};d([g({type:b.ObjectIdentifier})],gr.prototype,"attrType",void 0);d([g({type:b.Any,repeated:"set"})],gr.prototype,"attrValues",void 0);var nc;class zt{constructor(e={}){this.version=Rt.v0,this.sid=new Qn,this.digestAlgorithm=new Dr,this.signatureAlgorithm=new ys,this.signature=new ae,Object.assign(this,e)}}d([g({type:b.Integer})],zt.prototype,"version",void 0);d([g({type:Qn})],zt.prototype,"sid",void 0);d([g({type:Dr})],zt.prototype,"digestAlgorithm",void 0);d([g({type:gr,repeated:"set",context:0,implicit:!0,optional:!0})],zt.prototype,"signedAttrs",void 0);d([g({type:ys})],zt.prototype,"signatureAlgorithm",void 0);d([g({type:ae})],zt.prototype,"signature",void 0);d([g({type:gr,repeated:"set",context:1,implicit:!0,optional:!0})],zt.prototype,"unsignedAttrs",void 0);let ws=nc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,nc.prototype)}};ws=nc=d([P({type:T.Set,itemType:zt})],ws);let rd=class extends je{};rd=d([P({type:T.Choice})],rd);let id=class extends zt{};id=d([P({type:T.Sequence})],id);class Al{constructor(e={}){this.acIssuer=new re,this.acSerial=0,this.attrs=[],Object.assign(this,e)}}d([g({type:re})],Al.prototype,"acIssuer",void 0);d([g({type:b.Integer})],Al.prototype,"acSerial",void 0);d([g({type:Pt,repeated:"sequence"})],Al.prototype,"attrs",void 0);var rc;let bs=rc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,rc.prototype)}};bs=rc=d([P({type:T.Sequence,itemType:b.ObjectIdentifier})],bs);class xo{constructor(e={}){this.permitUnSpecified=!0,Object.assign(this,e)}}d([g({type:b.Integer,optional:!0})],xo.prototype,"pathLenConstraint",void 0);d([g({type:bs,implicit:!0,context:0,optional:!0})],xo.prototype,"permittedAttrs",void 0);d([g({type:bs,implicit:!0,context:1,optional:!0})],xo.prototype,"excludedAttrs",void 0);d([g({type:b.Boolean,defaultValue:!0})],xo.prototype,"permitUnSpecified",void 0);class On{constructor(e={}){this.issuer=new Le,this.serial=new ArrayBuffer(0),this.issuerUID=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:Le})],On.prototype,"issuer",void 0);d([g({type:b.Integer,converter:_e})],On.prototype,"serial",void 0);d([g({type:b.BitString,optional:!0})],On.prototype,"issuerUID",void 0);var ic;(function(t){t[t.publicKey=0]="publicKey",t[t.publicKeyCert=1]="publicKeyCert",t[t.otherObjectTypes=2]="otherObjectTypes"})(ic||(ic={}));class Bn{constructor(e={}){this.digestedObjectType=ic.publicKey,this.digestAlgorithm=new F,this.objectDigest=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.Enumerated})],Bn.prototype,"digestedObjectType",void 0);d([g({type:b.ObjectIdentifier,optional:!0})],Bn.prototype,"otherObjectTypeID",void 0);d([g({type:F})],Bn.prototype,"digestAlgorithm",void 0);d([g({type:b.BitString})],Bn.prototype,"objectDigest",void 0);class So{constructor(e={}){Object.assign(this,e)}}d([g({type:Le,optional:!0})],So.prototype,"issuerName",void 0);d([g({type:On,context:0,implicit:!0,optional:!0})],So.prototype,"baseCertificateID",void 0);d([g({type:Bn,context:1,implicit:!0,optional:!0})],So.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:So,context:0,implicit:!0})],er.prototype,"v2Form",void 0);er=d([P({type:T.Choice})],er);class Ao{constructor(e={}){this.notBeforeTime=new Date,this.notAfterTime=new Date,Object.assign(this,e)}}d([g({type:b.GeneralizedTime})],Ao.prototype,"notBeforeTime",void 0);d([g({type:b.GeneralizedTime})],Ao.prototype,"notAfterTime",void 0);class fi{constructor(e={}){Object.assign(this,e)}}d([g({type:On,implicit:!0,context:0,optional:!0})],fi.prototype,"baseCertificateID",void 0);d([g({type:Le,implicit:!0,context:1,optional:!0})],fi.prototype,"entityName",void 0);d([g({type:Bn,implicit:!0,context:2,optional:!0})],fi.prototype,"objectDigestInfo",void 0);var sc;(function(t){t[t.v2=1]="v2"})(sc||(sc={}));class _t{constructor(e={}){this.version=sc.v2,this.holder=new fi,this.issuer=new er,this.signature=new F,this.serialNumber=new ArrayBuffer(0),this.attrCertValidityPeriod=new Ao,this.attributes=[],Object.assign(this,e)}}d([g({type:b.Integer})],_t.prototype,"version",void 0);d([g({type:fi})],_t.prototype,"holder",void 0);d([g({type:er})],_t.prototype,"issuer",void 0);d([g({type:F})],_t.prototype,"signature",void 0);d([g({type:b.Integer,converter:_e})],_t.prototype,"serialNumber",void 0);d([g({type:Ao})],_t.prototype,"attrCertValidityPeriod",void 0);d([g({type:Pt,repeated:"sequence"})],_t.prototype,"attributes",void 0);d([g({type:b.BitString,optional:!0})],_t.prototype,"issuerUniqueID",void 0);d([g({type:Xt,optional:!0})],_t.prototype,"extensions",void 0);class Eo{constructor(e={}){this.acinfo=new _t,this.signatureAlgorithm=new F,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:_t})],Eo.prototype,"acinfo",void 0);d([g({type:F})],Eo.prototype,"signatureAlgorithm",void 0);d([g({type:b.BitString})],Eo.prototype,"signatureValue",void 0);var ks;(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"})(ks||(ks={}));class oc extends _o{}class El{constructor(e={}){this.type="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier,implicit:!0,context:0})],El.prototype,"type",void 0);d([g({type:b.Any,implicit:!0,context:1})],El.prototype,"value",void 0);class Il{constructor(e={}){this.policyId="",this.classList=new oc(ks.unclassified),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],Il.prototype,"policyId",void 0);d([g({type:oc,defaultValue:new oc(ks.unclassified)})],Il.prototype,"classList",void 0);d([g({type:El,repeated:"set"})],Il.prototype,"securityCategories",void 0);class Io{constructor(e={}){Object.assign(this,e)}}d([g({type:ae})],Io.prototype,"cotets",void 0);d([g({type:b.ObjectIdentifier})],Io.prototype,"oid",void 0);d([g({type:b.Utf8String})],Io.prototype,"string",void 0);class Uh{constructor(e={}){this.values=[],Object.assign(this,e)}}d([g({type:Le,implicit:!0,context:0,optional:!0})],Uh.prototype,"policyAuthority",void 0);d([g({type:Io,repeated:"sequence"})],Uh.prototype,"values",void 0);var ac;class zo{constructor(e={}){this.targetCertificate=new On,Object.assign(this,e)}}d([g({type:On})],zo.prototype,"targetCertificate",void 0);d([g({type:re,optional:!0})],zo.prototype,"targetName",void 0);d([g({type:Bn,optional:!0})],zo.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:zo,context:2,implicit:!0})],tr.prototype,"targetCert",void 0);tr=d([P({type:T.Choice})],tr);let cc=ac=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,ac.prototype)}};cc=ac=d([P({type:T.Sequence,itemType:tr})],cc);var lc;let sd=lc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,lc.prototype)}};sd=lc=d([P({type:T.Sequence,itemType:cc})],sd);class Vh{constructor(e={}){Object.assign(this,e)}}d([g({type:Le,implicit:!0,context:0,optional:!0})],Vh.prototype,"roleAuthority",void 0);d([g({type:re,implicit:!0,context:1})],Vh.prototype,"roleName",void 0);class zl{constructor(e={}){this.service=new re,this.ident=new re,Object.assign(this,e)}}d([g({type:re})],zl.prototype,"service",void 0);d([g({type:re})],zl.prototype,"ident",void 0);d([g({type:ae,optional:!0})],zl.prototype,"authInfo",void 0);var uc;class Cl{constructor(e={}){this.otherCertFormat="",this.otherCert=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],Cl.prototype,"otherCertFormat",void 0);d([g({type:b.Any})],Cl.prototype,"otherCert",void 0);let nr=class{constructor(e={}){Object.assign(this,e)}};d([g({type:An})],nr.prototype,"certificate",void 0);d([g({type:Eo,context:2,implicit:!0})],nr.prototype,"v2AttrCert",void 0);d([g({type:Cl,context:3,implicit:!0})],nr.prototype,"other",void 0);nr=d([P({type:T.Choice})],nr);let xs=uc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,uc.prototype)}};xs=uc=d([P({type:T.Set,itemType:nr})],xs);class mr{constructor(e={}){this.contentType="",this.content=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],mr.prototype,"contentType",void 0);d([g({type:b.Any,context:0})],mr.prototype,"content",void 0);let Hr=class{constructor(e={}){Object.assign(this,e)}};d([g({type:ae})],Hr.prototype,"single",void 0);d([g({type:b.Any})],Hr.prototype,"any",void 0);Hr=d([P({type:T.Choice})],Hr);class Co{constructor(e={}){this.eContentType="",Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],Co.prototype,"eContentType",void 0);d([g({type:Hr,context:0,optional:!0})],Co.prototype,"eContent",void 0);let Fr=class{constructor(e={}){Object.assign(this,e)}};d([g({type:ae,context:0,implicit:!0,optional:!0})],Fr.prototype,"value",void 0);d([g({type:ae,converter:M_,context:0,implicit:!0,optional:!0,repeated:"sequence"})],Fr.prototype,"constructedValue",void 0);Fr=d([P({type:T.Choice})],Fr);class hi{constructor(e={}){this.contentType="",this.contentEncryptionAlgorithm=new vs,Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],hi.prototype,"contentType",void 0);d([g({type:vs})],hi.prototype,"contentEncryptionAlgorithm",void 0);d([g({type:Fr,optional:!0})],hi.prototype,"encryptedContent",void 0);class No{constructor(e={}){this.keyAttrId="",Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],No.prototype,"keyAttrId",void 0);d([g({type:b.Any,optional:!0})],No.prototype,"keyAttr",void 0);var dc;class jo{constructor(e={}){this.subjectKeyIdentifier=new Wt,Object.assign(this,e)}}d([g({type:Wt})],jo.prototype,"subjectKeyIdentifier",void 0);d([g({type:b.GeneralizedTime,optional:!0})],jo.prototype,"date",void 0);d([g({type:No,optional:!0})],jo.prototype,"other",void 0);let rr=class{constructor(e={}){Object.assign(this,e)}};d([g({type:jo,context:0,implicit:!0,optional:!0})],rr.prototype,"rKeyId",void 0);d([g({type:hr,optional:!0})],rr.prototype,"issuerAndSerialNumber",void 0);rr=d([P({type:T.Choice})],rr);class Nl{constructor(e={}){this.rid=new rr,this.encryptedKey=new ae,Object.assign(this,e)}}d([g({type:rr})],Nl.prototype,"rid",void 0);d([g({type:ae})],Nl.prototype,"encryptedKey",void 0);let Ss=dc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,dc.prototype)}};Ss=dc=d([P({type:T.Sequence,itemType:Nl})],Ss);class jl{constructor(e={}){this.algorithm=new F,this.publicKey=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:F})],jl.prototype,"algorithm",void 0);d([g({type:b.BitString})],jl.prototype,"publicKey",void 0);let En=class{constructor(e={}){Object.assign(this,e)}};d([g({type:Wt,context:0,implicit:!0,optional:!0})],En.prototype,"subjectKeyIdentifier",void 0);d([g({type:jl,context:1,implicit:!0,optional:!0})],En.prototype,"originatorKey",void 0);d([g({type:hr,optional:!0})],En.prototype,"issuerAndSerialNumber",void 0);En=d([P({type:T.Choice})],En);class _r{constructor(e={}){this.version=Rt.v3,this.originator=new En,this.keyEncryptionAlgorithm=new St,this.recipientEncryptedKeys=new Ss,Object.assign(this,e)}}d([g({type:b.Integer})],_r.prototype,"version",void 0);d([g({type:En,context:0})],_r.prototype,"originator",void 0);d([g({type:ae,context:1,optional:!0})],_r.prototype,"ukm",void 0);d([g({type:St})],_r.prototype,"keyEncryptionAlgorithm",void 0);d([g({type:Ss})],_r.prototype,"recipientEncryptedKeys",void 0);let ir=class{constructor(e={}){Object.assign(this,e)}};d([g({type:Wt,context:0,implicit:!0})],ir.prototype,"subjectKeyIdentifier",void 0);d([g({type:hr})],ir.prototype,"issuerAndSerialNumber",void 0);ir=d([P({type:T.Choice})],ir);class gi{constructor(e={}){this.version=Rt.v0,this.rid=new ir,this.keyEncryptionAlgorithm=new St,this.encryptedKey=new ae,Object.assign(this,e)}}d([g({type:b.Integer})],gi.prototype,"version",void 0);d([g({type:ir})],gi.prototype,"rid",void 0);d([g({type:St})],gi.prototype,"keyEncryptionAlgorithm",void 0);d([g({type:ae})],gi.prototype,"encryptedKey",void 0);class mi{constructor(e={}){this.keyIdentifier=new ae,Object.assign(this,e)}}d([g({type:ae})],mi.prototype,"keyIdentifier",void 0);d([g({type:b.GeneralizedTime,optional:!0})],mi.prototype,"date",void 0);d([g({type:No,optional:!0})],mi.prototype,"other",void 0);class _i{constructor(e={}){this.version=Rt.v4,this.kekid=new mi,this.keyEncryptionAlgorithm=new St,this.encryptedKey=new ae,Object.assign(this,e)}}d([g({type:b.Integer})],_i.prototype,"version",void 0);d([g({type:mi})],_i.prototype,"kekid",void 0);d([g({type:St})],_i.prototype,"keyEncryptionAlgorithm",void 0);d([g({type:ae})],_i.prototype,"encryptedKey",void 0);class yi{constructor(e={}){this.version=Rt.v0,this.keyEncryptionAlgorithm=new St,this.encryptedKey=new ae,Object.assign(this,e)}}d([g({type:b.Integer})],yi.prototype,"version",void 0);d([g({type:tc,context:0,optional:!0})],yi.prototype,"keyDerivationAlgorithm",void 0);d([g({type:St})],yi.prototype,"keyEncryptionAlgorithm",void 0);d([g({type:ae})],yi.prototype,"encryptedKey",void 0);class $l{constructor(e={}){this.oriType="",this.oriValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],$l.prototype,"oriType",void 0);d([g({type:b.Any})],$l.prototype,"oriValue",void 0);let Qt=class{constructor(e={}){Object.assign(this,e)}};d([g({type:gi,optional:!0})],Qt.prototype,"ktri",void 0);d([g({type:_r,context:1,implicit:!0,optional:!0})],Qt.prototype,"kari",void 0);d([g({type:_i,context:2,implicit:!0,optional:!0})],Qt.prototype,"kekri",void 0);d([g({type:yi,context:3,implicit:!0,optional:!0})],Qt.prototype,"pwri",void 0);d([g({type:$l,context:4,implicit:!0,optional:!0})],Qt.prototype,"ori",void 0);Qt=d([P({type:T.Choice})],Qt);var pc;let As=pc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,pc.prototype)}};As=pc=d([P({type:T.Set,itemType:Qt})],As);var fc;class $o{constructor(e={}){this.otherRevInfoFormat="",this.otherRevInfo=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],$o.prototype,"otherRevInfoFormat",void 0);d([g({type:b.Any})],$o.prototype,"otherRevInfo",void 0);let Es=class{constructor(e={}){this.other=new $o,Object.assign(this,e)}};d([g({type:$o,context:1,implicit:!0})],Es.prototype,"other",void 0);Es=d([P({type:T.Choice})],Es);let Is=fc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,fc.prototype)}};Is=fc=d([P({type:T.Set,itemType:Es})],Is);class Ol{constructor(e={}){Object.assign(this,e)}}d([g({type:xs,context:0,implicit:!0,optional:!0})],Ol.prototype,"certs",void 0);d([g({type:Is,context:1,implicit:!0,optional:!0})],Ol.prototype,"crls",void 0);var hc;let gc=hc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,hc.prototype)}};gc=hc=d([P({type:T.Set,itemType:gr})],gc);class vi{constructor(e={}){this.version=Rt.v0,this.recipientInfos=new As,this.encryptedContentInfo=new hi,Object.assign(this,e)}}d([g({type:b.Integer})],vi.prototype,"version",void 0);d([g({type:Ol,context:0,implicit:!0,optional:!0})],vi.prototype,"originatorInfo",void 0);d([g({type:As})],vi.prototype,"recipientInfos",void 0);d([g({type:hi})],vi.prototype,"encryptedContentInfo",void 0);d([g({type:gc,context:1,implicit:!0,optional:!0})],vi.prototype,"unprotectedAttrs",void 0);const f0="1.2.840.113549.1.7.2";var mc;let zs=mc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,mc.prototype)}};zs=mc=d([P({type:T.Set,itemType:Dr})],zs);class yr{constructor(e={}){this.version=Rt.v0,this.digestAlgorithms=new zs,this.encapContentInfo=new Co,this.signerInfos=new ws,Object.assign(this,e)}}d([g({type:b.Integer})],yr.prototype,"version",void 0);d([g({type:zs})],yr.prototype,"digestAlgorithms",void 0);d([g({type:Co})],yr.prototype,"encapContentInfo",void 0);d([g({type:xs,context:0,implicit:!0,optional:!0})],yr.prototype,"certificates",void 0);d([g({type:Is,context:1,implicit:!0,optional:!0})],yr.prototype,"crls",void 0);d([g({type:ws})],yr.prototype,"signerInfos",void 0);const Kr="1.2.840.10045.2.1",Bl="1.2.840.10045.4.1",Mh="1.2.840.10045.4.3.1",Tl="1.2.840.10045.4.3.2",Pl="1.2.840.10045.4.3.3",Rl="1.2.840.10045.4.3.4",od="1.2.840.10045.3.1.7",ad="1.3.132.0.34",cd="1.3.132.0.35";function wi(t){return new F({algorithm:t})}const h0=wi(Bl);wi(Mh);const g0=wi(Tl),m0=wi(Pl),_0=wi(Rl);let Wr=class{constructor(e={}){Object.assign(this,e)}};d([g({type:b.ObjectIdentifier})],Wr.prototype,"fieldType",void 0);d([g({type:b.Any})],Wr.prototype,"parameters",void 0);Wr=d([P({type:T.Sequence})],Wr);class y0 extends ae{}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([P({type:T.Sequence})],sr);var _c;(function(t){t[t.ecpVer1=1]="ecpVer1"})(_c||(_c={}));let Lt=class{constructor(e={}){this.version=_c.ecpVer1,Object.assign(this,e)}};d([g({type:b.Integer})],Lt.prototype,"version",void 0);d([g({type:Wr})],Lt.prototype,"fieldID",void 0);d([g({type:sr})],Lt.prototype,"curve",void 0);d([g({type:y0})],Lt.prototype,"base",void 0);d([g({type:b.Integer,converter:_e})],Lt.prototype,"order",void 0);d([g({type:b.Integer,optional:!0})],Lt.prototype,"cofactor",void 0);Lt=d([P({type:T.Sequence})],Lt);let en=class{constructor(e={}){Object.assign(this,e)}};d([g({type:b.ObjectIdentifier})],en.prototype,"namedCurve",void 0);d([g({type:b.Null})],en.prototype,"implicitCurve",void 0);d([g({type:Lt})],en.prototype,"specifiedCurve",void 0);en=d([P({type:T.Choice})],en);class Oo{constructor(e={}){this.version=1,this.privateKey=new ae,Object.assign(this,e)}}d([g({type:b.Integer})],Oo.prototype,"version",void 0);d([g({type:ae})],Oo.prototype,"privateKey",void 0);d([g({type:en,context:0,optional:!0})],Oo.prototype,"parameters",void 0);d([g({type:b.BitString,context:1,optional:!0})],Oo.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 Ke="1.2.840.113549.1.1",In=`${Ke}.1`,v0=`${Ke}.7`,w0=`${Ke}.9`,Pr=`${Ke}.10`,b0=`${Ke}.2`,k0=`${Ke}.4`,Ns=`${Ke}.5`,x0=`${Ke}.14`,yc=`${Ke}.11`,js=`${Ke}.12`,$s=`${Ke}.13`,qh=`${Ke}.15`,Dh=`${Ke}.16`,Os="1.3.14.3.2.26",Hh="2.16.840.1.101.3.4.2.4",Bs="2.16.840.1.101.3.4.2.1",Ts="2.16.840.1.101.3.4.2.2",Ps="2.16.840.1.101.3.4.2.3",S0="2.16.840.1.101.3.4.2.5",A0="2.16.840.1.101.3.4.2.6",E0="1.2.840.113549.2.2",I0="1.2.840.113549.2.5",Bo=`${Ke}.8`;function Ee(t){return new F({algorithm:t,parameters:null})}Ee(E0);Ee(I0);const zn=Ee(Os);Ee(Hh);Ee(Bs);Ee(Ts);Ee(Ps);Ee(S0);Ee(A0);const Fh=new F({algorithm:Bo,parameters:M.serialize(zn)}),Kh=new F({algorithm:w0,parameters:M.serialize(ds.toASN(new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer))});Ee(In);Ee(b0);Ee(k0);Ee(Ns);Ee(qh);Ee(Dh);Ee(js);Ee($s);Ee(qh);Ee(Dh);class To{constructor(e={}){this.hashAlgorithm=new F(zn),this.maskGenAlgorithm=new F({algorithm:Bo,parameters:M.serialize(zn)}),this.pSourceAlgorithm=new F(Kh),Object.assign(this,e)}}d([g({type:F,context:0,defaultValue:zn})],To.prototype,"hashAlgorithm",void 0);d([g({type:F,context:1,defaultValue:Fh})],To.prototype,"maskGenAlgorithm",void 0);d([g({type:F,context:2,defaultValue:Kh})],To.prototype,"pSourceAlgorithm",void 0);new F({algorithm:v0,parameters:M.serialize(new To)});class Cn{constructor(e={}){this.hashAlgorithm=new F(zn),this.maskGenAlgorithm=new F({algorithm:Bo,parameters:M.serialize(zn)}),this.saltLength=20,this.trailerField=1,Object.assign(this,e)}}d([g({type:F,context:0,defaultValue:zn})],Cn.prototype,"hashAlgorithm",void 0);d([g({type:F,context:1,defaultValue:Fh})],Cn.prototype,"maskGenAlgorithm",void 0);d([g({type:b.Integer,context:2,defaultValue:20})],Cn.prototype,"saltLength",void 0);d([g({type:b.Integer,context:3,defaultValue:1})],Cn.prototype,"trailerField",void 0);new F({algorithm:Pr,parameters:M.serialize(new Cn)});class Po{constructor(e={}){this.digestAlgorithm=new F,this.digest=new ae,Object.assign(this,e)}}d([g({type:F})],Po.prototype,"digestAlgorithm",void 0);d([g({type:ae})],Po.prototype,"digest",void 0);var vc;class Ro{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})],Ro.prototype,"prime",void 0);d([g({type:b.Integer,converter:_e})],Ro.prototype,"exponent",void 0);d([g({type:b.Integer,converter:_e})],Ro.prototype,"coefficient",void 0);let wc=vc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,vc.prototype)}};wc=vc=d([P({type:T.Sequence,itemType:Ro})],wc);class Ct{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})],Ct.prototype,"version",void 0);d([g({type:b.Integer,converter:_e})],Ct.prototype,"modulus",void 0);d([g({type:b.Integer,converter:_e})],Ct.prototype,"publicExponent",void 0);d([g({type:b.Integer,converter:_e})],Ct.prototype,"privateExponent",void 0);d([g({type:b.Integer,converter:_e})],Ct.prototype,"prime1",void 0);d([g({type:b.Integer,converter:_e})],Ct.prototype,"prime2",void 0);d([g({type:b.Integer,converter:_e})],Ct.prototype,"exponent1",void 0);d([g({type:b.Integer,converter:_e})],Ct.prototype,"exponent2",void 0);d([g({type:b.Integer,converter:_e})],Ct.prototype,"coefficient",void 0);d([g({type:wc,optional:!0})],Ct.prototype,"otherPrimeInfos",void 0);class Ll{constructor(e={}){this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.Integer,converter:_e})],Ll.prototype,"modulus",void 0);d([g({type:b.Integer,converter:_e})],Ll.prototype,"publicExponent",void 0);var bc;(function(t){t[t.Transient=0]="Transient",t[t.Singleton=1]="Singleton",t[t.ResolutionScoped=2]="ResolutionScoped",t[t.ContainerScoped=3]="ContainerScoped"})(bc||(bc={}));const Me=bc;/*! *****************************************************************************
|
|
103
|
+
`)}`:`${n} :`}}Gf=De;K.Constructed=Gf;De.NAME="CONSTRUCTED";class Jf extends Le{fromBER(e,n,r){return n}toBER(e){return mt}}Jf.override="EndOfContentValueBlock";var Zf;class fl extends $e{constructor(e={}){super(e,Jf),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}Zf=fl;K.EndOfContent=Zf;fl.NAME=Vr;var Yf;class wn extends $e{constructor(e={}){super(e,Le),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}`}}Yf=wn;K.Null=Yf;wn.NAME="NULL";class Xf extends It(Le){constructor({value:e,...n}={}){super(n),n.valueHex?this.valueHexView=q.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=q.toUint8Array(e);return Vt(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,Vf.call(this),this.blockLength=r,n+r):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}Xf.NAME="BooleanValueBlock";var Qf;class so extends $e{constructor(e={}){super(e,Xf),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}`}}Qf=so;K.Boolean=Qf;so.NAME="BOOLEAN";class eh extends It(Kt){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=Kt.prototype.fromBER.call(this,e,n,r),i===-1)return i;for(let s=0;s<this.value.length;s++){const o=this.value[s].constructor.NAME;if(o===Vr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(o!==Mf)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?Kt.prototype.toBER.call(this,e,n):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}}eh.NAME="OctetStringValueBlock";var th;let _n=class nh extends $e{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},eh),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 o=lr(s,0,s.byteLength);o.offset!==-1&&o.offset===r&&(this.valueBlock.value=[o.result])}}catch{}}return super.fromBER(e,n,r)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?De.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 nh&&e.push(n.valueBlock.valueHexView);return q.concat(e)}};th=_n;K.OctetString=th;_n.NAME=Mf;class rh extends It(Kt){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=Kt.prototype.fromBER.call(this,e,n,r),i===-1)return i;for(const c of this.value){const l=c.constructor.NAME;if(l===Vr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(l!==qf)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=q.toUint8Array(e);if(!Vt(this,s,n,r))return-1;const o=s.subarray(n,n+r);if(this.unusedBits=o[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){const c=o.subarray(1);try{if(c.byteLength){const l=lr(c,0,c.byteLength);l.offset!==-1&&l.offset===r-1&&(this.value=[l.result])}}catch{}}return this.valueHexView=o.subarray(1),this.blockLength=o.length,n+r}toBER(e,n){if(this.isConstructed)return Kt.prototype.toBER.call(this,e,n);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return mt;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}}}rh.NAME="BitStringValueBlock";var ih;let yn=class extends $e{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},rh),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 De.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)}`}}};ih=yn;K.BitString=ih;yn.NAME=qf;var sh;function Ay(t,e){const n=new Uint8Array([0]),r=new Uint8Array(t),i=new Uint8Array(e);let s=r.slice(0);const o=s.length-1,c=i.slice(0),l=c.length-1;let u=0;const p=l<o?o:l;let h=0;for(let m=p;m>=0;m--,h++){switch(!0){case h<c.length:u=s[o-h]+c[l-h]+n[0];break;default:u=s[o-h]+n[0]}switch(n[0]=u/10,!0){case h>=s.length:s=ja(new Uint8Array([u%10]),s);break;default:s[o-h]=u%10}}return n[0]>0&&(s=ja(n,s)),s}function Ju(t){if(t>=Ar.length)for(let e=Ar.length;e<=t;e++){const n=new Uint8Array([0]);let r=Ar[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=ja(n,r)),Ar.push(r)}return Ar[t]}function Ey(t,e){let n=0;const r=new Uint8Array(t),i=new Uint8Array(e),s=r.slice(0),o=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[o-p]-c[l-p]-n,!0){case u<0:n=1,s[o-p]=u+10;break;default:n=0,s[o-p]=u}if(n>0)for(let h=o-l+1;h>=0;h--,p++)if(u=s[o-p]-n,u<0)n=1,s[o-p]=u+10;else{n=0,s[o-p]=u;break}return s.slice()}class hl extends It(Le){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=Vf.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(fy(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 o=this.valueHexView;return o[0]===0&&o[1]&128?this.valueHexView=o.subarray(1):i!==0&&o.length<i&&(i-o.length>1&&(i=o.length+1),this.valueHexView=o.subarray(i-o.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 o="",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=Ey(Ju(r),n),o="-";break;default:n=Ay(n,Ju(r))}r++,i>>=1}}for(let l=0;l<n.length;l++)n[l]&&(c=!0),c&&(o+=Wu.charAt(n[l]));return c===!1&&(o+=Wu.charAt(0)),o}}sh=hl;hl.NAME="IntegerValueBlock";Object.defineProperty(sh.prototype,"valueHex",{set:function(t){this.valueHexView=new Uint8Array(t),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var oh;class xt extends $e{constructor(e={}){super(e,hl),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return ls(),BigInt(this.valueBlock.toString())}static fromBigInt(e){ls();const n=BigInt(e),r=new ro,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=q.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 xt({valueHex:r.final()})}convertToDER(){const e=new xt({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new xt({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}}oh=xt;K.Integer=oh;xt.NAME="INTEGER";var ah;class oo extends xt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}ah=oo;K.Enumerated=ah;oo.NAME="ENUMERATED";class $a extends It(Le){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=q.toUint8Array(e);if(!Vt(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 o=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)o[c]=this.valueHexView[c];return this.valueHexView=o,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=Gn(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),n+this.blockLength)}set valueBigInt(e){ls();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 o=0;o<this.blockLength-1;o++)s[o]=i[o]|128;return s[this.blockLength-1]=i[this.blockLength-1],s.buffer}const n=vn(this.valueDec,7);if(n.byteLength===0)return this.error="Error during encoding SID value",mt;const r=new Uint8Array(n.byteLength);if(!e){const i=new Uint8Array(n),s=n.byteLength-1;for(let o=0;o<s;o++)r[o]=i[o]|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}}}$a.NAME="sidBlock";class ch extends Le{constructor({value:e=Me,...n}={}){super(n),this.value=[],e&&this.fromString(e)}fromBER(e,n,r){let i=n;for(;r>0;){const s=new $a;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,mt;n.push(i)}return dl(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 o=this.value[0];let c=0;switch(o.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;o.valueDec=l+c,s=!1}else{const o=new $a;if(i>Number.MAX_SAFE_INTEGER){ls();const c=BigInt(i);o.valueBigInt=c}else if(o.valueDec=parseInt(i,10),isNaN(o.valueDec))return;this.value.length||(o.isFirstSid=!0,s=!0),this.value.push(o)}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}}ch.NAME="ObjectIdentifierValueBlock";var lh;class ao extends $e{constructor(e={}){super(e,ch),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()}}}lh=ao;K.ObjectIdentifier=lh;ao.NAME="OBJECT IDENTIFIER";class Oa extends It(jn){constructor({valueDec:e=0,...n}={}){super(n),this.valueDec=e}fromBER(e,n,r){if(r===0)return n;const i=q.toUint8Array(e);if(!Vt(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 o=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)o[c]=this.valueHexView[c];return this.valueHexView=o,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=Gn(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 o=0;o<this.blockLength-1;o++)s[o]=i[o]|128;return s[this.blockLength-1]=i[this.blockLength-1],s.buffer}const n=vn(this.valueDec,7);if(n.byteLength===0)return this.error="Error during encoding SID value",mt;const r=new Uint8Array(n.byteLength);if(!e){const i=new Uint8Array(n),s=n.byteLength-1;for(let o=0;o<s;o++)r[o]=i[o]|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}}}Oa.NAME="relativeSidBlock";class uh extends Le{constructor({value:e=Me,...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.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,mt;r.push(s)}return dl(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 Oa;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}}uh.NAME="RelativeObjectIdentifierValueBlock";var dh;class gl extends $e{constructor(e={}){super(e,uh),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()}}}dh=gl;K.RelativeObjectIdentifier=dh;gl.NAME="RelativeObjectIdentifier";var ph;class Ot extends De{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}ph=Ot;K.Sequence=ph;Ot.NAME="SEQUENCE";var fh;let Bt=class extends De{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};fh=Bt;K.Set=fh;Bt.NAME="SET";class hh extends It(Le){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=Me}toJSON(){return{...super.toJSON(),value:this.value}}}hh.NAME="StringValueBlock";class gh extends hh{}gh.NAME="SimpleStringValueBlock";class Ye extends pl{constructor({...e}={}){super(e,gh)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,q.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}}Ye.NAME="SIMPLE STRING";class mh extends Ye{fromBuffer(e){this.valueBlock.valueHexView=q.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}}mh.NAME="Utf8StringValueBlock";var _h;class Mt extends mh{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}_h=Mt;K.Utf8String=_h;Mt.NAME="UTF8String";class yh extends Ye{fromBuffer(e){this.valueBlock.value=J.ToUtf16String(e),this.valueBlock.valueHexView=q.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(J.FromUtf16String(e))}}yh.NAME="BmpStringValueBlock";var vh;class co extends yh{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}vh=co;K.BmpString=vh;co.NAME="BMPString";class wh extends Ye{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=vn(e.charCodeAt(i),8),o=new Uint8Array(s);if(o.length>4)continue;const c=4-o.length;for(let l=o.length-1;l>=0;l--)r[i*4+l+c]=o[l]}this.valueBlock.value=e}}wh.NAME="UniversalStringValueBlock";var bh;class lo extends wh{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}bh=lo;K.UniversalString=bh;lo.NAME="UniversalString";var kh;class uo extends Ye{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}kh=uo;K.NumericString=kh;uo.NAME="NumericString";var xh;class po extends Ye{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}xh=po;K.PrintableString=xh;po.NAME="PrintableString";var Sh;class fo extends Ye{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}Sh=fo;K.TeletexString=Sh;fo.NAME="TeletexString";var Ah;class ho extends Ye{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}Ah=ho;K.VideotexString=Ah;ho.NAME="VideotexString";var Eh;class go extends Ye{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}Eh=go;K.IA5String=Eh;go.NAME="IA5String";var Ih;class mo extends Ye{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}Ih=mo;K.GraphicString=Ih;mo.NAME="GraphicString";var zh;class ai extends Ye{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}zh=ai;K.VisibleString=zh;ai.NAME="VisibleString";var Ch;class _o extends Ye{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}Ch=_o;K.GeneralString=Ch;_o.NAME="GeneralString";var Nh;class yo extends Ye{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}Nh=yo;K.CharacterString=Nh;yo.NAME="CharacterString";var jh;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,q.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]=Je(this.year<2e3?this.year-1900:this.year-2e3,2),n[1]=Je(this.month,2),n[2]=Je(this.day,2),n[3]=Je(this.hour,2),n[4]=Je(this.minute,2),n[5]=Je(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}}}jh=ci;K.UTCTime=jh;ci.NAME="UTCTime";var $h;class vo 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,o,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(o=/(\d{4})(\d{2})(\d{2})/ig,u!==-1)throw new Error("Wrong input string for conversion");break;case i.length===10:if(o=/(\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(o=/(\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(o=/(\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=o.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(Je(this.year,4)),n.push(Je(this.month,2)),n.push(Je(this.day,2)),n.push(Je(this.hour,2)),n.push(Je(this.minute,2)),n.push(Je(this.second,2)),this.millisecond!==0&&(n.push("."),n.push(Je(this.millisecond,3))),n.push("Z"),n.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}}$h=vo;K.GeneralizedTime=$h;vo.NAME="GeneralizedTime";var Oh;class ml extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}Oh=ml;K.DATE=Oh;ml.NAME="DATE";var Bh;class _l extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}Bh=_l;K.TimeOfDay=Bh;_l.NAME="TimeOfDay";var Th;class yl extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}Th=yl;K.DateTime=Th;yl.NAME="DateTime";var Ph;class vl extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}Ph=vl;K.Duration=Ph;vl.NAME="Duration";var Rh;class wl extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}Rh=wl;K.TIME=Rh;wl.NAME="TIME";class bn{constructor({name:e=Me,optional:n=!1}={}){this.name=e,this.optional=n}}class bl extends bn{constructor({value:e=[],...n}={}){super(n),this.value=e}}class us extends bn{constructor({value:e=new bn,local:n=!1,...r}={}){super(r),this.value=e,this.local=n}}class Iy{constructor({data:e=io}={}){this.dataView=q.toUint8Array(e)}get data(){return this.dataView.slice().buffer}set data(e){this.dataView=q.toUint8Array(e)}fromBER(e,n,r){const i=n+r;return this.dataView=q.toUint8Array(e).subarray(n,i),i}toBER(e){return this.dataView.slice().buffer}}function hn(t,e,n){if(n instanceof bl){for(let s=0;s<n.value.length;s++)if(hn(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(na)&&(s.name=n.name),s}}if(n instanceof bn)return n.hasOwnProperty(na)&&(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(!(my in n))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(wy in n.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(by 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(_y)===!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(yy)===!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(vy)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(n.idBlock.isConstructed!==e.idBlock.isConstructed)return{verified:!1,result:t};if(!(gy 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(!(Gu in n.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const s=n.idBlock.valueHexView,o=e.idBlock.valueHexView;if(s.length!==o.length)return{verified:!1,result:t};for(let c=0;c<s.length;c++)if(s[c]!==o[1])return{verified:!1,result:t}}if(n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Me),n.name&&(t[n.name]=e)),n instanceof K.Constructed){let s=0,o={verified:!1,result:{error:"Unknown error"}},c=n.valueBlock.value.length;if(c>0&&n.valueBlock.value[0]instanceof us&&(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,Me),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,Me),n.name&&(delete t[n.name],u.name=n.name)),u}}else if(n.valueBlock.value[0]instanceof us){if(o=hn(t,e.valueBlock.value[l],n.valueBlock.value[0].value),o.verified===!1)if(n.valueBlock.value[0].optional)s++;else return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Me),n.name&&delete t[n.name]),o;if(na in n.valueBlock.value[0]&&n.valueBlock.value[0].name.length>0){let u={};ky 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(o=hn(t,e.valueBlock.value[l-s],n.valueBlock.value[l]),o.verified===!1)if(n.valueBlock.value[l].optional)s++;else return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Me),n.name&&delete t[n.name]),o;if(o.verified===!1){const l={verified:!1,result:t};return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Me),n.name&&(delete t[n.name],l.name=n.name)),l}return{verified:!0,result:t}}if(n.primitiveSchema&&Gu in e.valueBlock){const s=lr(e.valueBlock.valueHexView);if(s.offset===-1){const o={verified:!1,result:s.result};return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Me),n.name&&(delete t[n.name],o.name=n.name)),o}return hn(t,s.result,n.primitiveSchema)}return{verified:!0,result:t}}function zy(t,e){if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};const n=lr(q.toUint8Array(t));return n.offset===-1?{verified:!1,result:n.result}:hn(n.result,n.result,e)}const Lh=Object.freeze(Object.defineProperty({__proto__:null,Any:bn,BaseBlock:$e,BaseStringBlock:pl,BitString:yn,BmpString:co,Boolean:so,CharacterString:yo,Choice:bl,Constructed:De,DATE:ml,DateTime:yl,Duration:vl,EndOfContent:fl,Enumerated:oo,GeneralString:_o,GeneralizedTime:vo,GraphicString:mo,HexBlock:It,IA5String:go,Integer:xt,Null:wn,NumericString:uo,ObjectIdentifier:ao,OctetString:_n,Primitive:oi,PrintableString:po,RawData:Iy,RelativeObjectIdentifier:gl,Repeated:us,Sequence:Ot,Set:Bt,TIME:wl,TeletexString:fo,TimeOfDay:_l,UTCTime:ci,UniversalString:lo,Utf8String:Mt,ValueBlock:Le,VideotexString:ho,ViewWriter:ro,VisibleString:ai,compareSchema:hn,fromBER:Fn,verifySchema:zy},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 wo{constructor(e,n=0){if(this.unusedBits=0,this.value=new ArrayBuffer(0),e)if(typeof e=="number")this.fromNumber(e);else if(q.isBufferSource(e))this.unusedBits=n,this.value=q.toArrayBuffer(e);else throw TypeError("Unsupported type of 'params' argument for BitString")}fromASN(e){if(!(e instanceof yn))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 yn({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new yn({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 ae{get byteLength(){return this.buffer.byteLength}get byteOffset(){return 0}constructor(e){typeof e=="number"?this.buffer=new ArrayBuffer(e):q.isBufferSource(e)?this.buffer=q.toArrayBuffer(e):Array.isArray(e)?this.buffer=new Uint8Array(e):this.buffer=new ArrayBuffer(0)}fromASN(e){if(!(e instanceof _n))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=e.valueBlock.valueHex,this}toASN(){return new _n({valueHex:this.buffer})}toSchema(e){return new _n({name:e})}}const Cy={fromASN:t=>t instanceof wn?null:t.valueBeforeDecodeView,toASN:t=>{if(t===null)return new wn;const e=Fn(t);if(e.result.error)throw new Error(e.result.error);return e.result}},Ny={fromASN:t=>t.valueBlock.valueHexView.byteLength>=4?t.valueBlock.toString():t.valueBlock.valueDec,toASN:t=>new xt({value:+t})},jy={fromASN:t=>t.valueBlock.valueDec,toASN:t=>new oo({value:t})},_e={fromASN:t=>t.valueBlock.valueHexView,toASN:t=>new xt({valueHex:t})},$y={fromASN:t=>t.valueBlock.valueHexView,toASN:t=>new yn({valueHex:t})},Oy={fromASN:t=>t.valueBlock.toString(),toASN:t=>new ao({value:t})},By={fromASN:t=>t.valueBlock.value,toASN:t=>new so({value:t})},ds={fromASN:t=>t.valueBlock.valueHexView,toASN:t=>new _n({valueHex:t})},Ty={fromASN:t=>new ae(t.getValue()),toASN:t=>t.toASN()};function it(t){return{fromASN:e=>e.valueBlock.value,toASN:e=>new t({value:e})}}const Uh=it(Mt),Py=it(co),Ry=it(lo),Ly=it(uo),Uy=it(po),Vy=it(fo),My=it(ho),qy=it(go),Dy=it(mo),Hy=it(ai),Fy=it(_o),Ky=it(yo),Wy={fromASN:t=>t.toDate(),toASN:t=>new ci({valueDate:t})},Gy={fromASN:t=>t.toDate(),toASN:t=>new vo({valueDate:t})},Jy={fromASN:()=>null,toASN:()=>new wn};function kl(t){switch(t){case b.Any:return Cy;case b.BitString:return $y;case b.BmpString:return Py;case b.Boolean:return By;case b.CharacterString:return Ky;case b.Enumerated:return jy;case b.GeneralString:return Fy;case b.GeneralizedTime:return Gy;case b.GraphicString:return Dy;case b.IA5String:return qy;case b.Integer:return Ny;case b.Null:return Jy;case b.NumericString:return Ly;case b.ObjectIdentifier:return Oy;case b.OctetString:return ds;case b.PrintableString:return Uy;case b.TeletexString:return Vy;case b.UTCTime:return Wy;case b.UniversalString:return Ry;case b.Utf8String:return Uh;case b.VideotexString:return My;case b.VisibleString:return Hy;default:return null}}function $t(t){return typeof t=="function"&&t.prototype?t.prototype.toASN&&t.prototype.fromASN?!0:$t(t.prototype):!!(t&&typeof t=="object"&&"toASN"in t&&"fromASN"in t)}function Vh(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:Vh(n)}return!1}function Zy(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 Yy{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 o=r.items[s],c=n?s:"";let l;if(typeof o.type=="number"){const p=b[o.type],h=Lh[p];if(!h)throw new Error(`Cannot get ASN1 class by name '${p}'`);l=new h({name:c})}else $t(o.type)?l=new o.type().toSchema(c):o.optional?this.get(o.type).type===T.Choice?l=new bn({name:c}):(l=this.create(o.type,!1),l.name=c):l=new bn({name:c});const u=!!o.optional||o.defaultValue!==void 0;if(o.repeated){l.name="";const p=o.repeated==="set"?Bt:Ot;l=new p({name:"",value:[new us({name:c,value:l})]})}if(o.context!==null&&o.context!==void 0)if(o.implicit)if(typeof o.type=="number"||$t(o.type)){const p=o.repeated?De:oi;i.push(new p({name:c,optional:u,idBlock:{tagClass:3,tagNumber:o.context}}))}else{this.cache(o.type);const p=!!o.repeated;let h=p?l:this.get(o.type,!0).schema;h="valueBlock"in h?h.valueBlock.value:h.value,i.push(new De({name:p?"":c,optional:u,idBlock:{tagClass:3,tagNumber:o.context},value:h}))}else i.push(new De({optional:u,idBlock:{tagClass:3,tagNumber:o.context},value:[l]}));else l.optional=u,i.push(l)}switch(r.type){case T.Sequence:return new Ot({value:i,name:""});case T.Set:return new Bt({value:i,name:""});case T.Choice:return new bl({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 et=new Yy,P=t=>e=>{let n;et.has(e)?n=et.get(e):(n=et.createDefault(e),et.set(e,n)),Object.assign(n,t)},g=t=>(e,n)=>{let r;et.has(e.constructor)?r=et.get(e.constructor):(r=et.createDefault(e.constructor),et.set(e.constructor,r));const i=Object.assign({},t);if(typeof i.type=="number"&&!i.converter){const s=kl(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 Zu extends Error{constructor(){super(...arguments),this.schemas=[]}}class Xy{static parse(e,n){const r=Fn(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($t(n))return new n().fromASN(e);const i=et.get(n);et.cache(n);let s=i.schema;if(e.constructor===De&&i.type!==T.Choice){s=new De({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:i.schema.valueBlock.value});for(const l in i.items)delete e[l]}const o=hn({},e,s);if(!o.verified)throw new Zu(`Data does not match to ${n.name} ASN1 schema. ${o.result.error}`);const c=new n;if(Vh(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=kl(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=o.result[l];if(!u)continue;const p=i.items[l],h=p.type;if(typeof h=="number"||$t(h)){const m=(r=p.converter)!==null&&r!==void 0?r:$t(h)?new h:null;if(!m)throw new Error("Converter is empty");if(p.repeated)if(p.implicit){const v=p.repeated==="sequence"?Ot:Bt,f=new v;f.valueBlock=u.valueBlock;const _=Fn(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($t(h))f=new h().toSchema("");else{const _=b[h],w=Lh[_];if(!w)throw new Error(`Cannot get '${_}' class from asn1js module`);f=new w}f.valueBlock=v.valueBlock,v=Fn(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 Zu&&i.schemas.push(n.name),i}}}class xl{static serialize(e){return e instanceof $e?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&typeof e=="object"&&$t(e))return e.toASN();if(!(e&&typeof e=="object"))throw new TypeError("Parameter 1 should be type of Object.");const n=e.constructor,r=et.get(n);et.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 o=kl(r.itemType);if(!o)throw new Error(`Cannot get default converter for array item of ${n.name} ASN1 schema`);i=e.map(c=>o.toASN(c))}else i=e.map(o=>this.toAsnItem({type:r.itemType},"[]",n,o))}else for(const o in r.items){const c=r.items[o],l=e[o];if(l===void 0||c.defaultValue===l||typeof c.defaultValue=="object"&&typeof l=="object"&&Zy(this.serialize(c.defaultValue),this.serialize(l)))continue;const u=xl.toAsnItem(c,o,n,l);if(typeof c.context=="number")if(c.implicit)if(!c.repeated&&(typeof c.type=="number"||$t(c.type))){const p={};p.valueHex=u instanceof wn?u.valueBeforeDecodeView:u.valueBlock.toBER(),i.push(new oi({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},...p}))}else i.push(new De({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:u.valueBlock.value}));else i.push(new De({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 Ot({value:i});break;case T.Set:s=new Bt({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 o=e.converter;if(!o)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=>o.toASN(u)),l=e.repeated==="sequence"?Ot:Bt;s=new l({value:c})}else s=o.toASN(i)}else if(e.repeated){if(!Array.isArray(i))throw new TypeError("Parameter 'objProp' should be type of Array.");const o=Array.from(i,l=>this.toASN(l)),c=e.repeated==="sequence"?Ot:Bt;s=new c({value:o})}else s=this.toASN(i);return s}}class pe extends Array{constructor(e=[]){if(typeof e=="number")super(e);else{super();for(const n of e)this.push(n)}}}class M{static serialize(e){return xl.serialize(e)}static parse(e,n){return Xy.parse(e,n)}static toString(e){const n=q.isBufferSource(e)?q.toArrayBuffer(e):M.serialize(e),r=Fn(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,o;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--)(o=t[c])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s}var Mh={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"),o="%[0-9a-z]{1,}",c="(?:[0-9a-f]+::?)+",l={zoneIndex:new RegExp(o,"i"),native:new RegExp(`^(::)?(${c})?([0-9a-f]+)?(::)?(${o})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${n}\\.${n}\\.${n}\\.${n}(${o})?)$`,"i"),transitional:new RegExp(`^((?:${c})|(?:::)(?:${c})?)${n}\\.${n}\\.${n}\\.${n}(${o})?$`,"i")};function u(f,_){if(f.indexOf("::")!==f.lastIndexOf("::"))return null;let w=0,S=-1,C=(f.match(l.zoneIndex)||[])[0],B,R;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(R=_-w,B=":";R--;)B+="0:";return f=f.replace("::",B),f[0]===":"&&(f=f.slice(1)),f[f.length-1]===":"&&(f=f.slice(0,-1)),_=function(){const te=f.split(":"),fe=[];for(let le=0;le<te.length;le++)fe.push(parseInt(te[le],16));return fe}(),{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,R;for(C=3;C>=0;C-=1)if(B=this.octets[C],B in S){if(R=S[B],w&&R!==0)return null;R!==8&&(w=!0),_+=R}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 R=0;R<C.length;R++)w=C[R],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 R=7;R>=0;R-=1)if(C=this.parts[R],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(R){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${R})`)}},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,R;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))&&(R=S[6]||"",_=S[1],S[1].endsWith("::")||(_=_.slice(0,-1)),_=u(_+R,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,R;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(R=B[S],f.kind()===R[0].kind()&&f.match.apply(f,R))return C}return w},t.exports?t.exports=v:e.ipaddr=v})(os)})(Mh);var Yu=Mh.exports;class Xu{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 Yu.fromByteArray(Array.from(n)).toString()}return this.decodeIP(J.ToHex(e))}static fromString(e){const n=Yu.parse(e);return new Uint8Array(n.toByteArray()).buffer}}var Ba,Ta,Pa;let Oe=class{constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};d([g({type:b.TeletexString})],Oe.prototype,"teletexString",void 0);d([g({type:b.PrintableString})],Oe.prototype,"printableString",void 0);d([g({type:b.UniversalString})],Oe.prototype,"universalString",void 0);d([g({type:b.Utf8String})],Oe.prototype,"utf8String",void 0);d([g({type:b.BmpString})],Oe.prototype,"bmpString",void 0);Oe=d([P({type:T.Choice})],Oe);let Jn=class extends Oe{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})],Jn.prototype,"ia5String",void 0);d([g({type:b.Any})],Jn.prototype,"anyValue",void 0);Jn=d([P({type:T.Choice})],Jn);class bo{constructor(e={}){this.type="",this.value=new Jn,Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],bo.prototype,"type",void 0);d([g({type:Jn})],bo.prototype,"value",void 0);let Zn=Ba=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Ba.prototype)}};Zn=Ba=d([P({type:T.Set,itemType:bo})],Zn);let Ra=Ta=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Ta.prototype)}};Ra=Ta=d([P({type:T.Sequence,itemType:Zn})],Ra);let ke=Pa=class extends Ra{constructor(e){super(e),Object.setPrototypeOf(this,Pa.prototype)}};ke=Pa=d([P({type:T.Sequence})],ke);const Qy={fromASN:t=>Xu.toString(ds.fromASN(t)),toASN:t=>ds.toASN(Xu.fromString(t))};class Mr{constructor(e={}){this.typeId="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],Mr.prototype,"typeId",void 0);d([g({type:b.Any,context:0})],Mr.prototype,"value",void 0);class Sl{constructor(e={}){this.partyName=new Oe,Object.assign(this,e)}}d([g({type:Oe,optional:!0,context:0,implicit:!0})],Sl.prototype,"nameAssigner",void 0);d([g({type:Oe,context:1,implicit:!0})],Sl.prototype,"partyName",void 0);let re=class{constructor(e={}){Object.assign(this,e)}};d([g({type:Mr,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:Sl,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:Qy})],re.prototype,"iPAddress",void 0);d([g({type:b.ObjectIdentifier,context:8,implicit:!0})],re.prototype,"registeredID",void 0);re=d([P({type:T.Choice})],re);const Al="1.3.6.1.5.5.7",ev=`${Al}.1`,ur=`${Al}.3`,ko=`${Al}.48`,Qu=`${ko}.1`,ed=`${ko}.2`,td=`${ko}.3`,nd=`${ko}.5`,on="2.5.29";var La;const Ua=`${ev}.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 Dn=La=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,La.prototype)}};Dn=La=d([P({type:T.Sequence,itemType:li})],Dn);const Va=`${on}.35`;class El extends ae{}class gn{constructor(e={}){e&&Object.assign(this,e)}}d([g({type:El,context:0,optional:!0,implicit:!0})],gn.prototype,"keyIdentifier",void 0);d([g({type:re,context:1,optional:!0,implicit:!0,repeated:"sequence"})],gn.prototype,"authorityCertIssuer",void 0);d([g({type:b.Integer,context:2,optional:!0,implicit:!0,converter:_e})],gn.prototype,"authorityCertSerialNumber",void 0);const qh=`${on}.19`;class ps{constructor(e={}){this.cA=!1,Object.assign(this,e)}}d([g({type:b.Boolean,defaultValue:!1})],ps.prototype,"cA",void 0);d([g({type:b.Integer,optional:!0})],ps.prototype,"pathLenConstraint",void 0);var Ma;let Re=Ma=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Ma.prototype)}};Re=Ma=d([P({type:T.Sequence,itemType:re})],Re);var qa;let rd=qa=class extends Re{constructor(e){super(e),Object.setPrototypeOf(this,qa.prototype)}};rd=qa=d([P({type:T.Sequence})],rd);var Da;const Dh=`${on}.32`;let Tt=class{constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};d([g({type:b.IA5String})],Tt.prototype,"ia5String",void 0);d([g({type:b.VisibleString})],Tt.prototype,"visibleString",void 0);d([g({type:b.BmpString})],Tt.prototype,"bmpString",void 0);d([g({type:b.Utf8String})],Tt.prototype,"utf8String",void 0);Tt=d([P({type:T.Choice})],Tt);class Il{constructor(e={}){this.organization=new Tt,this.noticeNumbers=[],Object.assign(this,e)}}d([g({type:Tt})],Il.prototype,"organization",void 0);d([g({type:b.Integer,repeated:"sequence"})],Il.prototype,"noticeNumbers",void 0);class zl{constructor(e={}){Object.assign(this,e)}}d([g({type:Il,optional:!0})],zl.prototype,"noticeRef",void 0);d([g({type:Tt,optional:!0})],zl.prototype,"explicitText",void 0);let fs=class{constructor(e={}){Object.assign(this,e)}};d([g({type:b.IA5String})],fs.prototype,"cPSuri",void 0);d([g({type:zl})],fs.prototype,"userNotice",void 0);fs=d([P({type:T.Choice})],fs);class Cl{constructor(e={}){this.policyQualifierId="",this.qualifier=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],Cl.prototype,"policyQualifierId",void 0);d([g({type:b.Any})],Cl.prototype,"qualifier",void 0);class xo{constructor(e={}){this.policyIdentifier="",Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],xo.prototype,"policyIdentifier",void 0);d([g({type:Cl,repeated:"sequence",optional:!0})],xo.prototype,"policyQualifiers",void 0);let hs=Da=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Da.prototype)}};hs=Da=d([P({type:T.Sequence,itemType:xo})],hs);let gs=class{constructor(e=0){this.value=e}};d([g({type:b.Integer})],gs.prototype,"value",void 0);gs=d([P({type:T.Choice})],gs);let id=class extends gs{};id=d([P({type:T.Choice})],id);var Ha;const Fa=`${on}.31`;var lt;(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"})(lt||(lt={}));class Hh extends wo{toJSON(){const e=[],n=this.toNumber();return n<.aACompromise&&e.push("aACompromise"),n<.affiliationChanged&&e.push("affiliationChanged"),n<.cACompromise&&e.push("cACompromise"),n<.certificateHold&&e.push("certificateHold"),n<.cessationOfOperation&&e.push("cessationOfOperation"),n<.keyCompromise&&e.push("keyCompromise"),n<.privilegeWithdrawn&&e.push("privilegeWithdrawn"),n<.superseded&&e.push("superseded"),n<.unused&&e.push("unused"),e}toString(){return`[${this.toJSON().join(", ")}]`}}let kn=class{constructor(e={}){Object.assign(this,e)}};d([g({type:re,context:0,repeated:"sequence",implicit:!0})],kn.prototype,"fullName",void 0);d([g({type:Zn,context:1,implicit:!0})],kn.prototype,"nameRelativeToCRLIssuer",void 0);kn=d([P({type:T.Choice})],kn);class dr{constructor(e={}){Object.assign(this,e)}}d([g({type:kn,context:0,optional:!0})],dr.prototype,"distributionPoint",void 0);d([g({type:Hh,context:1,optional:!0,implicit:!0})],dr.prototype,"reasons",void 0);d([g({type:re,context:2,optional:!0,repeated:"sequence",implicit:!0})],dr.prototype,"cRLIssuer",void 0);let Kn=Ha=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Ha.prototype)}};Kn=Ha=d([P({type:T.Sequence,itemType:dr})],Kn);var Ka;let sd=Ka=class extends Kn{constructor(e){super(e),Object.setPrototypeOf(this,Ka.prototype)}};sd=Ka=d([P({type:T.Sequence,itemType:dr})],sd);class Te{constructor(e={}){this.onlyContainsUserCerts=Te.ONLY,this.onlyContainsCACerts=Te.ONLY,this.indirectCRL=Te.ONLY,this.onlyContainsAttributeCerts=Te.ONLY,Object.assign(this,e)}}Te.ONLY=!1;d([g({type:kn,context:0,optional:!0})],Te.prototype,"distributionPoint",void 0);d([g({type:b.Boolean,context:1,defaultValue:Te.ONLY,implicit:!0})],Te.prototype,"onlyContainsUserCerts",void 0);d([g({type:b.Boolean,context:2,defaultValue:Te.ONLY,implicit:!0})],Te.prototype,"onlyContainsCACerts",void 0);d([g({type:Hh,context:3,optional:!0,implicit:!0})],Te.prototype,"onlySomeReasons",void 0);d([g({type:b.Boolean,context:4,defaultValue:Te.ONLY,implicit:!0})],Te.prototype,"indirectCRL",void 0);d([g({type:b.Boolean,context:5,defaultValue:Te.ONLY,implicit:!0})],Te.prototype,"onlyContainsAttributeCerts",void 0);var $r;(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"})($r||($r={}));let Wa=class{constructor(e=$r.unspecified){this.reason=$r.unspecified,this.reason=e}toJSON(){return $r[this.reason]}toString(){return this.toJSON()}};d([g({type:b.Enumerated})],Wa.prototype,"reason",void 0);Wa=d([P({type:T.Choice})],Wa);var Ga;const Fh=`${on}.37`;let ms=Ga=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Ga.prototype)}};ms=Ga=d([P({type:T.Sequence,itemType:b.ObjectIdentifier})],ms);const tv=`${ur}.1`,nv=`${ur}.2`,rv=`${ur}.3`,iv=`${ur}.4`,sv=`${ur}.8`,ov=`${ur}.9`;let Ja=class{constructor(e=new ArrayBuffer(0)){this.value=e}};d([g({type:b.Integer,converter:_e})],Ja.prototype,"value",void 0);Ja=d([P({type:T.Choice})],Ja);let Za=class{constructor(e){this.value=new Date,e&&(this.value=e)}};d([g({type:b.GeneralizedTime})],Za.prototype,"value",void 0);Za=d([P({type:T.Choice})],Za);var Ya;let od=Ya=class extends Re{constructor(e){super(e),Object.setPrototypeOf(this,Ya.prototype)}};od=Ya=d([P({type:T.Sequence})],od);const Kh=`${on}.15`;var ut;(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"})(ut||(ut={}));class ra extends wo{toJSON(){const e=this.toNumber(),n=[];return e&ut.cRLSign&&n.push("crlSign"),e&ut.dataEncipherment&&n.push("dataEncipherment"),e&ut.decipherOnly&&n.push("decipherOnly"),e&ut.digitalSignature&&n.push("digitalSignature"),e&ut.encipherOnly&&n.push("encipherOnly"),e&ut.keyAgreement&&n.push("keyAgreement"),e&ut.keyCertSign&&n.push("keyCertSign"),e&ut.keyEncipherment&&n.push("keyEncipherment"),e&ut.nonRepudiation&&n.push("nonRepudiation"),n}toString(){return`[${this.toJSON().join(", ")}]`}}var Xa;class So{constructor(e={}){this.base=new re,this.minimum=0,Object.assign(this,e)}}d([g({type:re})],So.prototype,"base",void 0);d([g({type:b.Integer,context:0,defaultValue:0,implicit:!0})],So.prototype,"minimum",void 0);d([g({type:b.Integer,context:1,optional:!0,implicit:!0})],So.prototype,"maximum",void 0);let _s=Xa=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Xa.prototype)}};_s=Xa=d([P({type:T.Sequence,itemType:So})],_s);class Wh{constructor(e={}){Object.assign(this,e)}}d([g({type:_s,context:0,optional:!0,implicit:!0})],Wh.prototype,"permittedSubtrees",void 0);d([g({type:_s,context:1,optional:!0,implicit:!0})],Wh.prototype,"excludedSubtrees",void 0);class Gh{constructor(e={}){Object.assign(this,e)}}d([g({type:b.Integer,context:0,implicit:!0,optional:!0,converter:_e})],Gh.prototype,"requireExplicitPolicy",void 0);d([g({type:b.Integer,context:1,implicit:!0,optional:!0,converter:_e})],Gh.prototype,"inhibitPolicyMapping",void 0);var Qa;class Nl{constructor(e={}){this.issuerDomainPolicy="",this.subjectDomainPolicy="",Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],Nl.prototype,"issuerDomainPolicy",void 0);d([g({type:b.ObjectIdentifier})],Nl.prototype,"subjectDomainPolicy",void 0);let ad=Qa=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Qa.prototype)}};ad=Qa=d([P({type:T.Sequence,itemType:Nl})],ad);var ec;const Jh=`${on}.17`;let tc=ec=class extends Re{constructor(e){super(e),Object.setPrototypeOf(this,ec.prototype)}};tc=ec=d([P({type:T.Sequence})],tc);let Pt=class{constructor(e={}){this.type="",this.values=[],Object.assign(this,e)}};d([g({type:b.ObjectIdentifier})],Pt.prototype,"type",void 0);d([g({type:b.Any,repeated:"set"})],Pt.prototype,"values",void 0);var nc;let cd=nc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,nc.prototype)}};cd=nc=d([P({type:T.Sequence,itemType:Pt})],cd);const Zh=`${on}.14`;class Wt extends El{}class Yh{constructor(e={}){Object.assign(this,e)}}d([g({type:b.GeneralizedTime,context:0,implicit:!0,optional:!0})],Yh.prototype,"notBefore",void 0);d([g({type:b.GeneralizedTime,context:1,implicit:!0,optional:!0})],Yh.prototype,"notAfter",void 0);var Or;(function(t){t[t.keyUpdateAllowed=1]="keyUpdateAllowed",t[t.newExtensions=2]="newExtensions",t[t.pKIXCertificate=4]="pKIXCertificate"})(Or||(Or={}));class Xh extends wo{toJSON(){const e=[],n=this.toNumber();return n&Or.pKIXCertificate&&e.push("pKIXCertificate"),n&Or.newExtensions&&e.push("newExtensions"),n&Or.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return`[${this.toJSON().join(", ")}]`}}class Qh{constructor(e={}){this.entrustVers="",this.entrustInfoFlags=new Xh,Object.assign(this,e)}}d([g({type:b.GeneralString})],Qh.prototype,"entrustVers",void 0);d([g({type:Xh})],Qh.prototype,"entrustInfoFlags",void 0);var rc;let ld=rc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,rc.prototype)}};ld=rc=d([P({type:T.Sequence,itemType:li})],ld);class F{constructor(e={}){this.algorithm="",Object.assign(this,e)}isEqual(e){return e instanceof F&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&Uf(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 dt{constructor(e={}){this.algorithm=new F,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:F})],dt.prototype,"algorithm",void 0);d([g({type:b.BitString})],dt.prototype,"subjectPublicKey",void 0);let je=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})],je.prototype,"utcTime",void 0);d([g({type:b.GeneralizedTime})],je.prototype,"generalTime",void 0);je=d([P({type:T.Choice})],je);class ui{constructor(e){this.notBefore=new je(new Date),this.notAfter=new je(new Date),e&&(this.notBefore=new je(e.notBefore),this.notAfter=new je(e.notAfter))}}d([g({type:je})],ui.prototype,"notBefore",void 0);d([g({type:je})],ui.prototype,"notAfter",void 0);var ic;let rt=class eg{constructor(e={}){this.extnID="",this.critical=eg.CRITICAL,this.extnValue=new ae,Object.assign(this,e)}};rt.CRITICAL=!1;d([g({type:b.ObjectIdentifier})],rt.prototype,"extnID",void 0);d([g({type:b.Boolean,defaultValue:rt.CRITICAL})],rt.prototype,"critical",void 0);d([g({type:ae})],rt.prototype,"extnValue",void 0);let Xt=ic=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,ic.prototype)}};Xt=ic=d([P({type:T.Sequence,itemType:rt})],Xt);var xn;(function(t){t[t.v1=0]="v1",t[t.v2=1]="v2",t[t.v3=2]="v3"})(xn||(xn={}));class Xe{constructor(e={}){this.version=xn.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 dt,Object.assign(this,e)}}d([g({type:b.Integer,context:0,defaultValue:xn.v1})],Xe.prototype,"version",void 0);d([g({type:b.Integer,converter:_e})],Xe.prototype,"serialNumber",void 0);d([g({type:F})],Xe.prototype,"signature",void 0);d([g({type:ke})],Xe.prototype,"issuer",void 0);d([g({type:ui})],Xe.prototype,"validity",void 0);d([g({type:ke})],Xe.prototype,"subject",void 0);d([g({type:dt})],Xe.prototype,"subjectPublicKeyInfo",void 0);d([g({type:b.BitString,context:1,implicit:!0,optional:!0})],Xe.prototype,"issuerUniqueID",void 0);d([g({type:b.BitString,context:2,implicit:!0,optional:!0})],Xe.prototype,"subjectUniqueID",void 0);d([g({type:Xt,context:3,optional:!0})],Xe.prototype,"extensions",void 0);class Sn{constructor(e={}){this.tbsCertificate=new Xe,this.signatureAlgorithm=new F,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:Xe})],Sn.prototype,"tbsCertificate",void 0);d([g({type:F})],Sn.prototype,"signatureAlgorithm",void 0);d([g({type:b.BitString})],Sn.prototype,"signatureValue",void 0);class Ao{constructor(e={}){this.userCertificate=new ArrayBuffer(0),this.revocationDate=new je,Object.assign(this,e)}}d([g({type:b.Integer,converter:_e})],Ao.prototype,"userCertificate",void 0);d([g({type:je})],Ao.prototype,"revocationDate",void 0);d([g({type:rt,optional:!0,repeated:"sequence"})],Ao.prototype,"crlEntryExtensions",void 0);class qt{constructor(e={}){this.signature=new F,this.issuer=new ke,this.thisUpdate=new je,Object.assign(this,e)}}d([g({type:b.Integer,optional:!0})],qt.prototype,"version",void 0);d([g({type:F})],qt.prototype,"signature",void 0);d([g({type:ke})],qt.prototype,"issuer",void 0);d([g({type:je})],qt.prototype,"thisUpdate",void 0);d([g({type:je,optional:!0})],qt.prototype,"nextUpdate",void 0);d([g({type:Ao,repeated:"sequence",optional:!0})],qt.prototype,"revokedCertificates",void 0);d([g({type:rt,optional:!0,context:0,repeated:"sequence"})],qt.prototype,"crlExtensions",void 0);class jl{constructor(e={}){this.tbsCertList=new qt,this.signatureAlgorithm=new F,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:qt})],jl.prototype,"tbsCertList",void 0);d([g({type:F})],jl.prototype,"signatureAlgorithm",void 0);d([g({type:b.BitString})],jl.prototype,"signature",void 0);class pr{constructor(e={}){this.issuer=new ke,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:ke})],pr.prototype,"issuer",void 0);d([g({type:b.Integer,converter:_e})],pr.prototype,"serialNumber",void 0);let Yn=class{constructor(e={}){Object.assign(this,e)}};d([g({type:Wt,context:0,implicit:!0})],Yn.prototype,"subjectKeyIdentifier",void 0);d([g({type:pr})],Yn.prototype,"issuerAndSerialNumber",void 0);Yn=d([P({type:T.Choice})],Yn);var Rt;(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"})(Rt||(Rt={}));let qr=class extends F{};qr=d([P({type:T.Sequence})],qr);let ys=class extends F{};ys=d([P({type:T.Sequence})],ys);let St=class extends F{};St=d([P({type:T.Sequence})],St);let vs=class extends F{};vs=d([P({type:T.Sequence})],vs);let ud=class extends F{};ud=d([P({type:T.Sequence})],ud);let sc=class extends F{};sc=d([P({type:T.Sequence})],sc);let fr=class{constructor(e={}){this.attrType="",this.attrValues=[],Object.assign(this,e)}};d([g({type:b.ObjectIdentifier})],fr.prototype,"attrType",void 0);d([g({type:b.Any,repeated:"set"})],fr.prototype,"attrValues",void 0);var oc;class zt{constructor(e={}){this.version=Rt.v0,this.sid=new Yn,this.digestAlgorithm=new qr,this.signatureAlgorithm=new ys,this.signature=new ae,Object.assign(this,e)}}d([g({type:b.Integer})],zt.prototype,"version",void 0);d([g({type:Yn})],zt.prototype,"sid",void 0);d([g({type:qr})],zt.prototype,"digestAlgorithm",void 0);d([g({type:fr,repeated:"set",context:0,implicit:!0,optional:!0})],zt.prototype,"signedAttrs",void 0);d([g({type:ys})],zt.prototype,"signatureAlgorithm",void 0);d([g({type:ae})],zt.prototype,"signature",void 0);d([g({type:fr,repeated:"set",context:1,implicit:!0,optional:!0})],zt.prototype,"unsignedAttrs",void 0);let ws=oc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,oc.prototype)}};ws=oc=d([P({type:T.Set,itemType:zt})],ws);let dd=class extends je{};dd=d([P({type:T.Choice})],dd);let pd=class extends zt{};pd=d([P({type:T.Sequence})],pd);class $l{constructor(e={}){this.acIssuer=new re,this.acSerial=0,this.attrs=[],Object.assign(this,e)}}d([g({type:re})],$l.prototype,"acIssuer",void 0);d([g({type:b.Integer})],$l.prototype,"acSerial",void 0);d([g({type:Pt,repeated:"sequence"})],$l.prototype,"attrs",void 0);var ac;let bs=ac=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,ac.prototype)}};bs=ac=d([P({type:T.Sequence,itemType:b.ObjectIdentifier})],bs);class Eo{constructor(e={}){this.permitUnSpecified=!0,Object.assign(this,e)}}d([g({type:b.Integer,optional:!0})],Eo.prototype,"pathLenConstraint",void 0);d([g({type:bs,implicit:!0,context:0,optional:!0})],Eo.prototype,"permittedAttrs",void 0);d([g({type:bs,implicit:!0,context:1,optional:!0})],Eo.prototype,"excludedAttrs",void 0);d([g({type:b.Boolean,defaultValue:!0})],Eo.prototype,"permitUnSpecified",void 0);class $n{constructor(e={}){this.issuer=new Re,this.serial=new ArrayBuffer(0),this.issuerUID=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:Re})],$n.prototype,"issuer",void 0);d([g({type:b.Integer,converter:_e})],$n.prototype,"serial",void 0);d([g({type:b.BitString,optional:!0})],$n.prototype,"issuerUID",void 0);var cc;(function(t){t[t.publicKey=0]="publicKey",t[t.publicKeyCert=1]="publicKeyCert",t[t.otherObjectTypes=2]="otherObjectTypes"})(cc||(cc={}));class On{constructor(e={}){this.digestedObjectType=cc.publicKey,this.digestAlgorithm=new F,this.objectDigest=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.Enumerated})],On.prototype,"digestedObjectType",void 0);d([g({type:b.ObjectIdentifier,optional:!0})],On.prototype,"otherObjectTypeID",void 0);d([g({type:F})],On.prototype,"digestAlgorithm",void 0);d([g({type:b.BitString})],On.prototype,"objectDigest",void 0);class Io{constructor(e={}){Object.assign(this,e)}}d([g({type:Re,optional:!0})],Io.prototype,"issuerName",void 0);d([g({type:$n,context:0,implicit:!0,optional:!0})],Io.prototype,"baseCertificateID",void 0);d([g({type:On,context:1,implicit:!0,optional:!0})],Io.prototype,"objectDigestInfo",void 0);let Xn=class{constructor(e={}){Object.assign(this,e)}};d([g({type:re,repeated:"sequence"})],Xn.prototype,"v1Form",void 0);d([g({type:Io,context:0,implicit:!0})],Xn.prototype,"v2Form",void 0);Xn=d([P({type:T.Choice})],Xn);class zo{constructor(e={}){this.notBeforeTime=new Date,this.notAfterTime=new Date,Object.assign(this,e)}}d([g({type:b.GeneralizedTime})],zo.prototype,"notBeforeTime",void 0);d([g({type:b.GeneralizedTime})],zo.prototype,"notAfterTime",void 0);class di{constructor(e={}){Object.assign(this,e)}}d([g({type:$n,implicit:!0,context:0,optional:!0})],di.prototype,"baseCertificateID",void 0);d([g({type:Re,implicit:!0,context:1,optional:!0})],di.prototype,"entityName",void 0);d([g({type:On,implicit:!0,context:2,optional:!0})],di.prototype,"objectDigestInfo",void 0);var lc;(function(t){t[t.v2=1]="v2"})(lc||(lc={}));class _t{constructor(e={}){this.version=lc.v2,this.holder=new di,this.issuer=new Xn,this.signature=new F,this.serialNumber=new ArrayBuffer(0),this.attrCertValidityPeriod=new zo,this.attributes=[],Object.assign(this,e)}}d([g({type:b.Integer})],_t.prototype,"version",void 0);d([g({type:di})],_t.prototype,"holder",void 0);d([g({type:Xn})],_t.prototype,"issuer",void 0);d([g({type:F})],_t.prototype,"signature",void 0);d([g({type:b.Integer,converter:_e})],_t.prototype,"serialNumber",void 0);d([g({type:zo})],_t.prototype,"attrCertValidityPeriod",void 0);d([g({type:Pt,repeated:"sequence"})],_t.prototype,"attributes",void 0);d([g({type:b.BitString,optional:!0})],_t.prototype,"issuerUniqueID",void 0);d([g({type:Xt,optional:!0})],_t.prototype,"extensions",void 0);class Co{constructor(e={}){this.acinfo=new _t,this.signatureAlgorithm=new F,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:_t})],Co.prototype,"acinfo",void 0);d([g({type:F})],Co.prototype,"signatureAlgorithm",void 0);d([g({type:b.BitString})],Co.prototype,"signatureValue",void 0);var ks;(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"})(ks||(ks={}));class uc extends wo{}class Ol{constructor(e={}){this.type="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier,implicit:!0,context:0})],Ol.prototype,"type",void 0);d([g({type:b.Any,implicit:!0,context:1})],Ol.prototype,"value",void 0);class Bl{constructor(e={}){this.policyId="",this.classList=new uc(ks.unclassified),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],Bl.prototype,"policyId",void 0);d([g({type:uc,defaultValue:new uc(ks.unclassified)})],Bl.prototype,"classList",void 0);d([g({type:Ol,repeated:"set"})],Bl.prototype,"securityCategories",void 0);class No{constructor(e={}){Object.assign(this,e)}}d([g({type:ae})],No.prototype,"cotets",void 0);d([g({type:b.ObjectIdentifier})],No.prototype,"oid",void 0);d([g({type:b.Utf8String})],No.prototype,"string",void 0);class tg{constructor(e={}){this.values=[],Object.assign(this,e)}}d([g({type:Re,implicit:!0,context:0,optional:!0})],tg.prototype,"policyAuthority",void 0);d([g({type:No,repeated:"sequence"})],tg.prototype,"values",void 0);var dc;class jo{constructor(e={}){this.targetCertificate=new $n,Object.assign(this,e)}}d([g({type:$n})],jo.prototype,"targetCertificate",void 0);d([g({type:re,optional:!0})],jo.prototype,"targetName",void 0);d([g({type:On,optional:!0})],jo.prototype,"certDigestInfo",void 0);let Qn=class{constructor(e={}){Object.assign(this,e)}};d([g({type:re,context:0,implicit:!0})],Qn.prototype,"targetName",void 0);d([g({type:re,context:1,implicit:!0})],Qn.prototype,"targetGroup",void 0);d([g({type:jo,context:2,implicit:!0})],Qn.prototype,"targetCert",void 0);Qn=d([P({type:T.Choice})],Qn);let pc=dc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,dc.prototype)}};pc=dc=d([P({type:T.Sequence,itemType:Qn})],pc);var fc;let fd=fc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,fc.prototype)}};fd=fc=d([P({type:T.Sequence,itemType:pc})],fd);class ng{constructor(e={}){Object.assign(this,e)}}d([g({type:Re,implicit:!0,context:0,optional:!0})],ng.prototype,"roleAuthority",void 0);d([g({type:re,implicit:!0,context:1})],ng.prototype,"roleName",void 0);class Tl{constructor(e={}){this.service=new re,this.ident=new re,Object.assign(this,e)}}d([g({type:re})],Tl.prototype,"service",void 0);d([g({type:re})],Tl.prototype,"ident",void 0);d([g({type:ae,optional:!0})],Tl.prototype,"authInfo",void 0);var hc;class Pl{constructor(e={}){this.otherCertFormat="",this.otherCert=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],Pl.prototype,"otherCertFormat",void 0);d([g({type:b.Any})],Pl.prototype,"otherCert",void 0);let er=class{constructor(e={}){Object.assign(this,e)}};d([g({type:Sn})],er.prototype,"certificate",void 0);d([g({type:Co,context:2,implicit:!0})],er.prototype,"v2AttrCert",void 0);d([g({type:Pl,context:3,implicit:!0})],er.prototype,"other",void 0);er=d([P({type:T.Choice})],er);let xs=hc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,hc.prototype)}};xs=hc=d([P({type:T.Set,itemType:er})],xs);class hr{constructor(e={}){this.contentType="",this.content=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],hr.prototype,"contentType",void 0);d([g({type:b.Any,context:0})],hr.prototype,"content",void 0);let Dr=class{constructor(e={}){Object.assign(this,e)}};d([g({type:ae})],Dr.prototype,"single",void 0);d([g({type:b.Any})],Dr.prototype,"any",void 0);Dr=d([P({type:T.Choice})],Dr);class $o{constructor(e={}){this.eContentType="",Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],$o.prototype,"eContentType",void 0);d([g({type:Dr,context:0,optional:!0})],$o.prototype,"eContent",void 0);let Hr=class{constructor(e={}){Object.assign(this,e)}};d([g({type:ae,context:0,implicit:!0,optional:!0})],Hr.prototype,"value",void 0);d([g({type:ae,converter:Ty,context:0,implicit:!0,optional:!0,repeated:"sequence"})],Hr.prototype,"constructedValue",void 0);Hr=d([P({type:T.Choice})],Hr);class pi{constructor(e={}){this.contentType="",this.contentEncryptionAlgorithm=new vs,Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],pi.prototype,"contentType",void 0);d([g({type:vs})],pi.prototype,"contentEncryptionAlgorithm",void 0);d([g({type:Hr,optional:!0})],pi.prototype,"encryptedContent",void 0);class Oo{constructor(e={}){this.keyAttrId="",Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],Oo.prototype,"keyAttrId",void 0);d([g({type:b.Any,optional:!0})],Oo.prototype,"keyAttr",void 0);var gc;class Bo{constructor(e={}){this.subjectKeyIdentifier=new Wt,Object.assign(this,e)}}d([g({type:Wt})],Bo.prototype,"subjectKeyIdentifier",void 0);d([g({type:b.GeneralizedTime,optional:!0})],Bo.prototype,"date",void 0);d([g({type:Oo,optional:!0})],Bo.prototype,"other",void 0);let tr=class{constructor(e={}){Object.assign(this,e)}};d([g({type:Bo,context:0,implicit:!0,optional:!0})],tr.prototype,"rKeyId",void 0);d([g({type:pr,optional:!0})],tr.prototype,"issuerAndSerialNumber",void 0);tr=d([P({type:T.Choice})],tr);class Rl{constructor(e={}){this.rid=new tr,this.encryptedKey=new ae,Object.assign(this,e)}}d([g({type:tr})],Rl.prototype,"rid",void 0);d([g({type:ae})],Rl.prototype,"encryptedKey",void 0);let Ss=gc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,gc.prototype)}};Ss=gc=d([P({type:T.Sequence,itemType:Rl})],Ss);class Ll{constructor(e={}){this.algorithm=new F,this.publicKey=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:F})],Ll.prototype,"algorithm",void 0);d([g({type:b.BitString})],Ll.prototype,"publicKey",void 0);let An=class{constructor(e={}){Object.assign(this,e)}};d([g({type:Wt,context:0,implicit:!0,optional:!0})],An.prototype,"subjectKeyIdentifier",void 0);d([g({type:Ll,context:1,implicit:!0,optional:!0})],An.prototype,"originatorKey",void 0);d([g({type:pr,optional:!0})],An.prototype,"issuerAndSerialNumber",void 0);An=d([P({type:T.Choice})],An);class gr{constructor(e={}){this.version=Rt.v3,this.originator=new An,this.keyEncryptionAlgorithm=new St,this.recipientEncryptedKeys=new Ss,Object.assign(this,e)}}d([g({type:b.Integer})],gr.prototype,"version",void 0);d([g({type:An,context:0})],gr.prototype,"originator",void 0);d([g({type:ae,context:1,optional:!0})],gr.prototype,"ukm",void 0);d([g({type:St})],gr.prototype,"keyEncryptionAlgorithm",void 0);d([g({type:Ss})],gr.prototype,"recipientEncryptedKeys",void 0);let nr=class{constructor(e={}){Object.assign(this,e)}};d([g({type:Wt,context:0,implicit:!0})],nr.prototype,"subjectKeyIdentifier",void 0);d([g({type:pr})],nr.prototype,"issuerAndSerialNumber",void 0);nr=d([P({type:T.Choice})],nr);class fi{constructor(e={}){this.version=Rt.v0,this.rid=new nr,this.keyEncryptionAlgorithm=new St,this.encryptedKey=new ae,Object.assign(this,e)}}d([g({type:b.Integer})],fi.prototype,"version",void 0);d([g({type:nr})],fi.prototype,"rid",void 0);d([g({type:St})],fi.prototype,"keyEncryptionAlgorithm",void 0);d([g({type:ae})],fi.prototype,"encryptedKey",void 0);class hi{constructor(e={}){this.keyIdentifier=new ae,Object.assign(this,e)}}d([g({type:ae})],hi.prototype,"keyIdentifier",void 0);d([g({type:b.GeneralizedTime,optional:!0})],hi.prototype,"date",void 0);d([g({type:Oo,optional:!0})],hi.prototype,"other",void 0);class gi{constructor(e={}){this.version=Rt.v4,this.kekid=new hi,this.keyEncryptionAlgorithm=new St,this.encryptedKey=new ae,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:St})],gi.prototype,"keyEncryptionAlgorithm",void 0);d([g({type:ae})],gi.prototype,"encryptedKey",void 0);class mi{constructor(e={}){this.version=Rt.v0,this.keyEncryptionAlgorithm=new St,this.encryptedKey=new ae,Object.assign(this,e)}}d([g({type:b.Integer})],mi.prototype,"version",void 0);d([g({type:sc,context:0,optional:!0})],mi.prototype,"keyDerivationAlgorithm",void 0);d([g({type:St})],mi.prototype,"keyEncryptionAlgorithm",void 0);d([g({type:ae})],mi.prototype,"encryptedKey",void 0);class Ul{constructor(e={}){this.oriType="",this.oriValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],Ul.prototype,"oriType",void 0);d([g({type:b.Any})],Ul.prototype,"oriValue",void 0);let Qt=class{constructor(e={}){Object.assign(this,e)}};d([g({type:fi,optional:!0})],Qt.prototype,"ktri",void 0);d([g({type:gr,context:1,implicit:!0,optional:!0})],Qt.prototype,"kari",void 0);d([g({type:gi,context:2,implicit:!0,optional:!0})],Qt.prototype,"kekri",void 0);d([g({type:mi,context:3,implicit:!0,optional:!0})],Qt.prototype,"pwri",void 0);d([g({type:Ul,context:4,implicit:!0,optional:!0})],Qt.prototype,"ori",void 0);Qt=d([P({type:T.Choice})],Qt);var mc;let As=mc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,mc.prototype)}};As=mc=d([P({type:T.Set,itemType:Qt})],As);var _c;class To{constructor(e={}){this.otherRevInfoFormat="",this.otherRevInfo=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],To.prototype,"otherRevInfoFormat",void 0);d([g({type:b.Any})],To.prototype,"otherRevInfo",void 0);let Es=class{constructor(e={}){this.other=new To,Object.assign(this,e)}};d([g({type:To,context:1,implicit:!0})],Es.prototype,"other",void 0);Es=d([P({type:T.Choice})],Es);let Is=_c=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,_c.prototype)}};Is=_c=d([P({type:T.Set,itemType:Es})],Is);class Vl{constructor(e={}){Object.assign(this,e)}}d([g({type:xs,context:0,implicit:!0,optional:!0})],Vl.prototype,"certs",void 0);d([g({type:Is,context:1,implicit:!0,optional:!0})],Vl.prototype,"crls",void 0);var yc;let vc=yc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,yc.prototype)}};vc=yc=d([P({type:T.Set,itemType:fr})],vc);class _i{constructor(e={}){this.version=Rt.v0,this.recipientInfos=new As,this.encryptedContentInfo=new pi,Object.assign(this,e)}}d([g({type:b.Integer})],_i.prototype,"version",void 0);d([g({type:Vl,context:0,implicit:!0,optional:!0})],_i.prototype,"originatorInfo",void 0);d([g({type:As})],_i.prototype,"recipientInfos",void 0);d([g({type:pi})],_i.prototype,"encryptedContentInfo",void 0);d([g({type:vc,context:1,implicit:!0,optional:!0})],_i.prototype,"unprotectedAttrs",void 0);const av="1.2.840.113549.1.7.2";var wc;let zs=wc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,wc.prototype)}};zs=wc=d([P({type:T.Set,itemType:qr})],zs);class mr{constructor(e={}){this.version=Rt.v0,this.digestAlgorithms=new zs,this.encapContentInfo=new $o,this.signerInfos=new ws,Object.assign(this,e)}}d([g({type:b.Integer})],mr.prototype,"version",void 0);d([g({type:zs})],mr.prototype,"digestAlgorithms",void 0);d([g({type:$o})],mr.prototype,"encapContentInfo",void 0);d([g({type:xs,context:0,implicit:!0,optional:!0})],mr.prototype,"certificates",void 0);d([g({type:Is,context:1,implicit:!0,optional:!0})],mr.prototype,"crls",void 0);d([g({type:ws})],mr.prototype,"signerInfos",void 0);const Fr="1.2.840.10045.2.1",Ml="1.2.840.10045.4.1",rg="1.2.840.10045.4.3.1",ql="1.2.840.10045.4.3.2",Dl="1.2.840.10045.4.3.3",Hl="1.2.840.10045.4.3.4",hd="1.2.840.10045.3.1.7",gd="1.3.132.0.34",md="1.3.132.0.35";function yi(t){return new F({algorithm:t})}const cv=yi(Ml);yi(rg);const lv=yi(ql),uv=yi(Dl),dv=yi(Hl);let Kr=class{constructor(e={}){Object.assign(this,e)}};d([g({type:b.ObjectIdentifier})],Kr.prototype,"fieldType",void 0);d([g({type:b.Any})],Kr.prototype,"parameters",void 0);Kr=d([P({type:T.Sequence})],Kr);class pv extends ae{}let rr=class{constructor(e={}){Object.assign(this,e)}};d([g({type:b.OctetString})],rr.prototype,"a",void 0);d([g({type:b.OctetString})],rr.prototype,"b",void 0);d([g({type:b.BitString,optional:!0})],rr.prototype,"seed",void 0);rr=d([P({type:T.Sequence})],rr);var bc;(function(t){t[t.ecpVer1=1]="ecpVer1"})(bc||(bc={}));let Lt=class{constructor(e={}){this.version=bc.ecpVer1,Object.assign(this,e)}};d([g({type:b.Integer})],Lt.prototype,"version",void 0);d([g({type:Kr})],Lt.prototype,"fieldID",void 0);d([g({type:rr})],Lt.prototype,"curve",void 0);d([g({type:pv})],Lt.prototype,"base",void 0);d([g({type:b.Integer,converter:_e})],Lt.prototype,"order",void 0);d([g({type:b.Integer,optional:!0})],Lt.prototype,"cofactor",void 0);Lt=d([P({type:T.Sequence})],Lt);let en=class{constructor(e={}){Object.assign(this,e)}};d([g({type:b.ObjectIdentifier})],en.prototype,"namedCurve",void 0);d([g({type:b.Null})],en.prototype,"implicitCurve",void 0);d([g({type:Lt})],en.prototype,"specifiedCurve",void 0);en=d([P({type:T.Choice})],en);class Po{constructor(e={}){this.version=1,this.privateKey=new ae,Object.assign(this,e)}}d([g({type:b.Integer})],Po.prototype,"version",void 0);d([g({type:ae})],Po.prototype,"privateKey",void 0);d([g({type:en,context:0,optional:!0})],Po.prototype,"parameters",void 0);d([g({type:b.BitString,context:1,optional:!0})],Po.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 Ke="1.2.840.113549.1.1",En=`${Ke}.1`,fv=`${Ke}.7`,hv=`${Ke}.9`,Br=`${Ke}.10`,gv=`${Ke}.2`,mv=`${Ke}.4`,Ns=`${Ke}.5`,_v=`${Ke}.14`,kc=`${Ke}.11`,js=`${Ke}.12`,$s=`${Ke}.13`,ig=`${Ke}.15`,sg=`${Ke}.16`,Os="1.3.14.3.2.26",og="2.16.840.1.101.3.4.2.4",Bs="2.16.840.1.101.3.4.2.1",Ts="2.16.840.1.101.3.4.2.2",Ps="2.16.840.1.101.3.4.2.3",yv="2.16.840.1.101.3.4.2.5",vv="2.16.840.1.101.3.4.2.6",wv="1.2.840.113549.2.2",bv="1.2.840.113549.2.5",Ro=`${Ke}.8`;function Ee(t){return new F({algorithm:t,parameters:null})}Ee(wv);Ee(bv);const In=Ee(Os);Ee(og);Ee(Bs);Ee(Ts);Ee(Ps);Ee(yv);Ee(vv);const ag=new F({algorithm:Ro,parameters:M.serialize(In)}),cg=new F({algorithm:hv,parameters:M.serialize(ds.toASN(new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer))});Ee(En);Ee(gv);Ee(mv);Ee(Ns);Ee(ig);Ee(sg);Ee(js);Ee($s);Ee(ig);Ee(sg);class Lo{constructor(e={}){this.hashAlgorithm=new F(In),this.maskGenAlgorithm=new F({algorithm:Ro,parameters:M.serialize(In)}),this.pSourceAlgorithm=new F(cg),Object.assign(this,e)}}d([g({type:F,context:0,defaultValue:In})],Lo.prototype,"hashAlgorithm",void 0);d([g({type:F,context:1,defaultValue:ag})],Lo.prototype,"maskGenAlgorithm",void 0);d([g({type:F,context:2,defaultValue:cg})],Lo.prototype,"pSourceAlgorithm",void 0);new F({algorithm:fv,parameters:M.serialize(new Lo)});class zn{constructor(e={}){this.hashAlgorithm=new F(In),this.maskGenAlgorithm=new F({algorithm:Ro,parameters:M.serialize(In)}),this.saltLength=20,this.trailerField=1,Object.assign(this,e)}}d([g({type:F,context:0,defaultValue:In})],zn.prototype,"hashAlgorithm",void 0);d([g({type:F,context:1,defaultValue:ag})],zn.prototype,"maskGenAlgorithm",void 0);d([g({type:b.Integer,context:2,defaultValue:20})],zn.prototype,"saltLength",void 0);d([g({type:b.Integer,context:3,defaultValue:1})],zn.prototype,"trailerField",void 0);new F({algorithm:Br,parameters:M.serialize(new zn)});class Uo{constructor(e={}){this.digestAlgorithm=new F,this.digest=new ae,Object.assign(this,e)}}d([g({type:F})],Uo.prototype,"digestAlgorithm",void 0);d([g({type:ae})],Uo.prototype,"digest",void 0);var xc;class Vo{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})],Vo.prototype,"prime",void 0);d([g({type:b.Integer,converter:_e})],Vo.prototype,"exponent",void 0);d([g({type:b.Integer,converter:_e})],Vo.prototype,"coefficient",void 0);let Sc=xc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,xc.prototype)}};Sc=xc=d([P({type:T.Sequence,itemType:Vo})],Sc);class Ct{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})],Ct.prototype,"version",void 0);d([g({type:b.Integer,converter:_e})],Ct.prototype,"modulus",void 0);d([g({type:b.Integer,converter:_e})],Ct.prototype,"publicExponent",void 0);d([g({type:b.Integer,converter:_e})],Ct.prototype,"privateExponent",void 0);d([g({type:b.Integer,converter:_e})],Ct.prototype,"prime1",void 0);d([g({type:b.Integer,converter:_e})],Ct.prototype,"prime2",void 0);d([g({type:b.Integer,converter:_e})],Ct.prototype,"exponent1",void 0);d([g({type:b.Integer,converter:_e})],Ct.prototype,"exponent2",void 0);d([g({type:b.Integer,converter:_e})],Ct.prototype,"coefficient",void 0);d([g({type:Sc,optional:!0})],Ct.prototype,"otherPrimeInfos",void 0);class Fl{constructor(e={}){this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.Integer,converter:_e})],Fl.prototype,"modulus",void 0);d([g({type:b.Integer,converter:_e})],Fl.prototype,"publicExponent",void 0);var Ac;(function(t){t[t.Transient=0]="Transient",t[t.Singleton=1]="Singleton",t[t.ResolutionScoped=2]="ResolutionScoped",t[t.ContainerScoped=3]="ContainerScoped"})(Ac||(Ac={}));const Ve=Ac;/*! *****************************************************************************
|
|
80
104
|
Copyright (c) Microsoft Corporation.
|
|
81
105
|
|
|
82
106
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -89,9 +113,9 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
|
89
113
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
90
114
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
91
115
|
PERFORMANCE OF THIS SOFTWARE.
|
|
92
|
-
***************************************************************************** */var
|
|
116
|
+
***************************************************************************** */var Ec=function(t,e){return Ec=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])},Ec(t,e)};function Kl(t,e){Ec(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}function kv(t,e,n,r){function i(s){return s instanceof n?s:new n(function(o){o(s)})}return new(n||(n=Promise))(function(s,o){function c(p){try{u(r.next(p))}catch(h){o(h)}}function l(p){try{u(r.throw(p))}catch(h){o(h)}}function u(p){p.done?s(p.value):i(p.value).then(c,l)}u((r=r.apply(t,[])).next())})}function xv(t,e){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,i,s,o;return o={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;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 ji(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 Rs(t,e){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var r=n.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=r.next()).done;)s.push(i.value)}catch(c){o={error:c}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return s}function dn(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Rs(arguments[e]));return t}var Sv="injectionTokens";function Av(t){var e=Reflect.getMetadata("design:paramtypes",t)||[],n=Reflect.getOwnMetadata(Sv,t)||{};return Object.keys(n).forEach(function(r){e[+r]=n[r]}),e}function lg(t){return!!t.useClass}function Ic(t){return!!t.useFactory}var ug=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,o=function(){return i||(s=e(n.wrap()),i=!0),s};return new Proxy(r,this.createHandler(o))},t.prototype.createHandler=function(e){var n={},r=function(i){n[i]=function(){for(var s=[],o=0;o<arguments.length;o++)s[o]=arguments[o];s[0]=e();var c=Reflect[i];return c.apply(void 0,dn(s))}};return this.reflectMethods.forEach(r),n},t}();function Un(t){return typeof t=="string"||typeof t=="symbol"}function Ev(t){return typeof t=="object"&&"token"in t&&"multiple"in t}function _d(t){return typeof t=="object"&&"token"in t&&"transform"in t}function Iv(t){return typeof t=="function"||t instanceof ug}function Ui(t){return!!t.useToken}function Vi(t){return t.useValue!=null}function zv(t){return lg(t)||Vi(t)||Ui(t)||Ic(t)}var Wl=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}(),Cv=function(t){Kl(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(Wl),yd=function(){function t(){this.scopedResolutions=new Map}return t}();function Nv(t,e){if(t===null)return"at position #"+e;var n=t.split(",")[e].trim();return'"'+n+'" at position #'+e}function jv(t,e,n){return n===void 0&&(n=" "),dn([t],e.message.split(`
|
|
93
117
|
`).map(function(r){return n+r})).join(`
|
|
94
|
-
`)}function L0(t,e,n){var r=Rs(t.toString().match(/constructor\(([\w, ]+)\)/)||[],2),i=r[1],s=i===void 0?null:i,o=P0(s,e);return R0("Cannot inject the dependency "+o+' of "'+t.name+'" constructor. Reason:',n)}function U0(t){if(typeof t.dispose!="function")return!1;var e=t.dispose;return!(e.length>0)}var V0=function(t){Ul(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(Vl),M0=function(t){Ul(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(Vl),q0=function(){function t(){this.preResolution=new V0,this.postResolution=new M0}return t}(),Jh=new Map,D0=function(){function t(e){this.parent=e,this._registry=new T0,this.interceptors=new q0,this.disposed=!1,this.disposables=new Set}return t.prototype.register=function(e,n,r){r===void 0&&(r={lifecycle:Me.Transient}),this.ensureNotDisposed();var i;if(B0(n)?i=n:i={useClass:n},Mi(i))for(var s=[e],o=i;o!=null;){var c=o.useToken;if(s.includes(c))throw new Error("Token registration cycle detected! "+dn(s,[c]).join(" -> "));s.push(c);var l=this._registry.get(c);l&&Mi(l.provider)?o=l.provider:o=null}if((r.lifecycle===Me.Singleton||r.lifecycle==Me.ContainerScoped||r.lifecycle==Me.ResolutionScoped)&&(qi(i)||xc(i)))throw new Error('Cannot use lifecycle "'+Me[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(),Vn(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(),Vn(e)){if(Vn(n))return this.register(e,{useToken:n},{lifecycle:Me.Singleton});if(n)return this.register(e,{useClass:n},{lifecycle:Me.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var r=e;return n&&!Vn(n)&&(r=n),this.register(e,{useClass:r},{lifecycle:Me.Singleton})},t.prototype.resolve=function(e,n){n===void 0&&(n=new ud),this.ensureNotDisposed();var r=this.getRegistration(e);if(!r&&Vn(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(O0(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 o=$i(this.interceptors.preResolution.getAll(e)),c=o.next();!c.done;c=o.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=o.return)&&i.call(o)}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 o=[];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"&&o.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,o)}},t.prototype.resolveRegistration=function(e,n){if(this.ensureNotDisposed(),e.options.lifecycle===Me.ResolutionScoped&&n.scopedResolutions.has(e))return n.scopedResolutions.get(e);var r=e.options.lifecycle===Me.Singleton,i=e.options.lifecycle===Me.ContainerScoped,s=r||i,o;return qi(e.provider)?o=e.provider.useValue:Mi(e.provider)?o=s?e.instance||(e.instance=this.resolve(e.provider.useToken,n)):this.resolve(e.provider.useToken,n):Wh(e.provider)?o=s?e.instance||(e.instance=this.construct(e.provider.useClass,n)):this.construct(e.provider.useClass,n):xc(e.provider)?o=e.provider.useFactory(this):o=this.construct(e.provider,n),e.options.lifecycle===Me.ResolutionScoped&&n.scopedResolutions.set(e,o),o},t.prototype.resolveAll=function(e,n){var r=this;n===void 0&&(n=new ud),this.ensureNotDisposed();var i=this.getAllRegistrations(e);if(!i&&Vn(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 o=[this.construct(e,n)];return this.executePostResolutionInterceptor(e,o,"All"),o},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=Rs(i.value,2),o=s[0],c=s[1];this._registry.setAll(o,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 o=Rs(s.value,2),c=o[0],l=o[1];l.some(function(u){var p=u.options;return p.lifecycle===Me.ContainerScoped})&&r._registry.setAll(c,l.map(function(u){return u.options.lifecycle===Me.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 z0(this,void 0,void 0,function(){var e;return C0(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 Gh)return e.createProxy(function(s){return r.resolve(s,n)});var i=function(){var s=Jh.get(e);if(!s||s.length===0){if(e.length===0)return new e;throw new Error('TypeInfo not known for "'+e.name+'"')}var o=s.map(r.resolveParams(n,e));return new(e.bind.apply(e,dn([void 0],o)))}();return U0(i)&&this.disposables.add(i),i},t.prototype.resolveParams=function(e,n){var r=this;return function(i,s){var o,c,l;try{return $0(i)?ld(i)?i.multiple?(o=r.resolve(i.transform)).transform.apply(o,dn([r.resolveAll(i.token)],i.transformArgs)):(c=r.resolve(i.transform)).transform.apply(c,dn([r.resolve(i.token,e)],i.transformArgs)):i.multiple?r.resolveAll(i.token):r.resolve(i.token,e):ld(i)?(l=r.resolve(i.transform,e)).transform.apply(l,dn([r.resolve(i.token,e)],i.transformArgs)):r.resolve(i,e)}catch(u){throw new Error(L0(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}(),Be=new D0;function Lo(){return function(t){Jh.set(t,j0(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 Sc;class Uo{constructor(e={}){this.attrId="",this.attrValues=[],Object.assign(e)}}d([g({type:b.ObjectIdentifier})],Uo.prototype,"attrId",void 0);d([g({type:b.Any,repeated:"set"})],Uo.prototype,"attrValues",void 0);let dd=Sc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Sc.prototype)}};dd=Sc=d([P({type:T.Sequence,itemType:Uo})],dd);var Ac;let pd=Ac=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Ac.prototype)}};pd=Ac=d([P({type:T.Sequence,itemType:mr})],pd);class Zh{constructor(e={}){this.certId="",this.certValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],Zh.prototype,"certId",void 0);d([g({type:b.Any,context:0})],Zh.prototype,"certValue",void 0);class Yh{constructor(e={}){this.crlId="",this.crltValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],Yh.prototype,"crlId",void 0);d([g({type:b.Any,context:0})],Yh.prototype,"crltValue",void 0);class Xh extends ae{}let Vo=class{constructor(e={}){this.encryptionAlgorithm=new F,this.encryptedData=new Xh,Object.assign(this,e)}};d([g({type:F})],Vo.prototype,"encryptionAlgorithm",void 0);d([g({type:Xh})],Vo.prototype,"encryptedData",void 0);var Ec,Ic;(function(t){t[t.v1=0]="v1"})(Ic||(Ic={}));class Qh extends ae{}let zc=Ec=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Ec.prototype)}};zc=Ec=d([P({type:T.Sequence,itemType:Pt})],zc);class bi{constructor(e={}){this.version=Ic.v1,this.privateKeyAlgorithm=new F,this.privateKey=new Qh,Object.assign(this,e)}}d([g({type:b.Integer})],bi.prototype,"version",void 0);d([g({type:F})],bi.prototype,"privateKeyAlgorithm",void 0);d([g({type:Qh})],bi.prototype,"privateKey",void 0);d([g({type:zc,implicit:!0,context:0,optional:!0})],bi.prototype,"attributes",void 0);let fd=class extends bi{};fd=d([P({type:T.Sequence})],fd);let hd=class extends Vo{};hd=d([P({type:T.Sequence})],hd);class eg{constructor(e={}){this.secretTypeId="",this.secretValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],eg.prototype,"secretTypeId",void 0);d([g({type:b.Any,context:0})],eg.prototype,"secretValue",void 0);class ki{constructor(e={}){this.mac=new Po,this.macSalt=new ae,this.iterations=1,Object.assign(this,e)}}d([g({type:Po})],ki.prototype,"mac",void 0);d([g({type:ae})],ki.prototype,"macSalt",void 0);d([g({type:b.Integer,defaultValue:1})],ki.prototype,"iterations",void 0);class Mo{constructor(e={}){this.version=3,this.authSafe=new mr,this.macData=new ki,Object.assign(this,e)}}d([g({type:b.Integer})],Mo.prototype,"version",void 0);d([g({type:mr})],Mo.prototype,"authSafe",void 0);d([g({type:ki,optional:!0})],Mo.prototype,"macData",void 0);var Cc;class qo{constructor(e={}){this.bagId="",this.bagValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],qo.prototype,"bagId",void 0);d([g({type:b.Any,context:0})],qo.prototype,"bagValue",void 0);d([g({type:Uo,repeated:"set",optional:!0})],qo.prototype,"bagAttributes",void 0);let gd=Cc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Cc.prototype)}};gd=Cc=d([P({type:T.Sequence,itemType:qo})],gd);var Nc,jc,$c;const tg="1.2.840.113549.1.9",ng=`${tg}.7`,Ml=`${tg}.14`;let Ls=class extends Oe{constructor(e={}){super(e)}toString(){return this.ia5String||super.toString()}};d([g({type:b.IA5String})],Ls.prototype,"ia5String",void 0);Ls=d([P({type:T.Choice})],Ls);let md=class extends mr{};md=d([P({type:T.Sequence})],md);let _d=class extends Mo{};_d=d([P({type:T.Sequence})],_d);let yd=class extends Vo{};yd=d([P({type:T.Sequence})],yd);let Oc=class{constructor(e=""){this.value=e}toString(){return this.value}};d([g({type:b.IA5String})],Oc.prototype,"value",void 0);Oc=d([P({type:T.Choice})],Oc);let vd=class extends Ls{};vd=d([P({type:T.Choice})],vd);let wd=class extends Oe{};wd=d([P({type:T.Choice})],wd);let Bc=class{constructor(e=new Date){this.value=e}};d([g({type:b.GeneralizedTime})],Bc.prototype,"value",void 0);Bc=d([P({type:T.Choice})],Bc);let bd=class extends Oe{};bd=d([P({type:T.Choice})],bd);let Tc=class{constructor(e="M"){this.value=e}toString(){return this.value}};d([g({type:b.PrintableString})],Tc.prototype,"value",void 0);Tc=d([P({type:T.Choice})],Tc);let Us=class{constructor(e=""){this.value=e}toString(){return this.value}};d([g({type:b.PrintableString})],Us.prototype,"value",void 0);Us=d([P({type:T.Choice})],Us);let kd=class extends Us{};kd=d([P({type:T.Choice})],kd);let xd=class extends Oe{};xd=d([P({type:T.Choice})],xd);let Pc=class{constructor(e=""){this.value=e}toString(){return this.value}};d([g({type:b.ObjectIdentifier})],Pc.prototype,"value",void 0);Pc=d([P({type:T.Choice})],Pc);let Sd=class extends je{};Sd=d([P({type:T.Choice})],Sd);let Rc=class{constructor(e=0){this.value=e}toString(){return this.value.toString()}};d([g({type:b.Integer})],Rc.prototype,"value",void 0);Rc=d([P({type:T.Choice})],Rc);let Ad=class extends zt{};Ad=d([P({type:T.Sequence})],Ad);let Vs=class extends Oe{};Vs=d([P({type:T.Choice})],Vs);let Ed=Nc=class extends Xt{constructor(e){super(e),Object.setPrototypeOf(this,Nc.prototype)}};Ed=Nc=d([P({type:T.Sequence})],Ed);let Id=jc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,jc.prototype)}};Id=jc=d([P({type:T.Set,itemType:gr})],Id);let Lc=class{constructor(e=""){this.value=e}toString(){return this.value}};d([g({type:b.BmpString})],Lc.prototype,"value",void 0);Lc=d([P({type:T.Choice})],Lc);let Uc=class extends F{};Uc=d([P({type:T.Sequence})],Uc);let zd=$c=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,$c.prototype)}};zd=$c=d([P({type:T.Sequence,itemType:Uc})],zd);var Vc;let Ms=Vc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Vc.prototype)}};Ms=Vc=d([P({type:T.Sequence,itemType:Pt})],Ms);class vr{constructor(e={}){this.version=0,this.subject=new ke,this.subjectPKInfo=new dt,this.attributes=new Ms,Object.assign(this,e)}}d([g({type:b.Integer})],vr.prototype,"version",void 0);d([g({type:ke})],vr.prototype,"subject",void 0);d([g({type:dt})],vr.prototype,"subjectPKInfo",void 0);d([g({type:Ms,implicit:!0,context:0})],vr.prototype,"attributes",void 0);class Gr{constructor(e={}){this.certificationRequestInfo=new vr,this.signatureAlgorithm=new F,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:vr})],Gr.prototype,"certificationRequestInfo",void 0);d([g({type:F})],Gr.prototype,"signatureAlgorithm",void 0);d([g({type:b.BitString})],Gr.prototype,"signature",void 0);/*!
|
|
118
|
+
`)}function $v(t,e,n){var r=Rs(t.toString().match(/constructor\(([\w, ]+)\)/)||[],2),i=r[1],s=i===void 0?null:i,o=Nv(s,e);return jv("Cannot inject the dependency "+o+' of "'+t.name+'" constructor. Reason:',n)}function Ov(t){if(typeof t.dispose!="function")return!1;var e=t.dispose;return!(e.length>0)}var Bv=function(t){Kl(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(Wl),Tv=function(t){Kl(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(Wl),Pv=function(){function t(){this.preResolution=new Bv,this.postResolution=new Tv}return t}(),dg=new Map,Rv=function(){function t(e){this.parent=e,this._registry=new Cv,this.interceptors=new Pv,this.disposed=!1,this.disposables=new Set}return t.prototype.register=function(e,n,r){r===void 0&&(r={lifecycle:Ve.Transient}),this.ensureNotDisposed();var i;if(zv(n)?i=n:i={useClass:n},Ui(i))for(var s=[e],o=i;o!=null;){var c=o.useToken;if(s.includes(c))throw new Error("Token registration cycle detected! "+dn(s,[c]).join(" -> "));s.push(c);var l=this._registry.get(c);l&&Ui(l.provider)?o=l.provider:o=null}if((r.lifecycle===Ve.Singleton||r.lifecycle==Ve.ContainerScoped||r.lifecycle==Ve.ResolutionScoped)&&(Vi(i)||Ic(i)))throw new Error('Cannot use lifecycle "'+Ve[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(),Un(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(),Un(e)){if(Un(n))return this.register(e,{useToken:n},{lifecycle:Ve.Singleton});if(n)return this.register(e,{useClass:n},{lifecycle:Ve.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var r=e;return n&&!Un(n)&&(r=n),this.register(e,{useClass:r},{lifecycle:Ve.Singleton})},t.prototype.resolve=function(e,n){n===void 0&&(n=new yd),this.ensureNotDisposed();var r=this.getRegistration(e);if(!r&&Un(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(Iv(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 o=ji(this.interceptors.preResolution.getAll(e)),c=o.next();!c.done;c=o.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=o.return)&&i.call(o)}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 o=[];try{for(var c=ji(this.interceptors.postResolution.getAll(e)),l=c.next();!l.done;l=c.next()){var u=l.value;u.options.frequency!="Once"&&o.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,o)}},t.prototype.resolveRegistration=function(e,n){if(this.ensureNotDisposed(),e.options.lifecycle===Ve.ResolutionScoped&&n.scopedResolutions.has(e))return n.scopedResolutions.get(e);var r=e.options.lifecycle===Ve.Singleton,i=e.options.lifecycle===Ve.ContainerScoped,s=r||i,o;return Vi(e.provider)?o=e.provider.useValue:Ui(e.provider)?o=s?e.instance||(e.instance=this.resolve(e.provider.useToken,n)):this.resolve(e.provider.useToken,n):lg(e.provider)?o=s?e.instance||(e.instance=this.construct(e.provider.useClass,n)):this.construct(e.provider.useClass,n):Ic(e.provider)?o=e.provider.useFactory(this):o=this.construct(e.provider,n),e.options.lifecycle===Ve.ResolutionScoped&&n.scopedResolutions.set(e,o),o},t.prototype.resolveAll=function(e,n){var r=this;n===void 0&&(n=new yd),this.ensureNotDisposed();var i=this.getAllRegistrations(e);if(!i&&Un(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 o=[this.construct(e,n)];return this.executePostResolutionInterceptor(e,o,"All"),o},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=ji(this._registry.entries()),i=r.next();!i.done;i=r.next()){var s=Rs(i.value,2),o=s[0],c=s[1];this._registry.setAll(o,c.filter(function(l){return!Vi(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=ji(this._registry.entries()),s=i.next();!s.done;s=i.next()){var o=Rs(s.value,2),c=o[0],l=o[1];l.some(function(u){var p=u.options;return p.lifecycle===Ve.ContainerScoped})&&r._registry.setAll(c,l.map(function(u){return u.options.lifecycle===Ve.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 kv(this,void 0,void 0,function(){var e;return xv(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 ug)return e.createProxy(function(s){return r.resolve(s,n)});var i=function(){var s=dg.get(e);if(!s||s.length===0){if(e.length===0)return new e;throw new Error('TypeInfo not known for "'+e.name+'"')}var o=s.map(r.resolveParams(n,e));return new(e.bind.apply(e,dn([void 0],o)))}();return Ov(i)&&this.disposables.add(i),i},t.prototype.resolveParams=function(e,n){var r=this;return function(i,s){var o,c,l;try{return Ev(i)?_d(i)?i.multiple?(o=r.resolve(i.transform)).transform.apply(o,dn([r.resolveAll(i.token)],i.transformArgs)):(c=r.resolve(i.transform)).transform.apply(c,dn([r.resolve(i.token,e)],i.transformArgs)):i.multiple?r.resolveAll(i.token):r.resolve(i.token,e):_d(i)?(l=r.resolve(i.transform,e)).transform.apply(l,dn([r.resolve(i.token,e)],i.transformArgs)):r.resolve(i,e)}catch(u){throw new Error($v(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}(),Be=new Rv;function Mo(){return function(t){dg.set(t,Av(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 zc;class qo{constructor(e={}){this.attrId="",this.attrValues=[],Object.assign(e)}}d([g({type:b.ObjectIdentifier})],qo.prototype,"attrId",void 0);d([g({type:b.Any,repeated:"set"})],qo.prototype,"attrValues",void 0);let vd=zc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,zc.prototype)}};vd=zc=d([P({type:T.Sequence,itemType:qo})],vd);var Cc;let wd=Cc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Cc.prototype)}};wd=Cc=d([P({type:T.Sequence,itemType:hr})],wd);class pg{constructor(e={}){this.certId="",this.certValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],pg.prototype,"certId",void 0);d([g({type:b.Any,context:0})],pg.prototype,"certValue",void 0);class fg{constructor(e={}){this.crlId="",this.crltValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],fg.prototype,"crlId",void 0);d([g({type:b.Any,context:0})],fg.prototype,"crltValue",void 0);class hg extends ae{}let Do=class{constructor(e={}){this.encryptionAlgorithm=new F,this.encryptedData=new hg,Object.assign(this,e)}};d([g({type:F})],Do.prototype,"encryptionAlgorithm",void 0);d([g({type:hg})],Do.prototype,"encryptedData",void 0);var Nc,jc;(function(t){t[t.v1=0]="v1"})(jc||(jc={}));class gg extends ae{}let $c=Nc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Nc.prototype)}};$c=Nc=d([P({type:T.Sequence,itemType:Pt})],$c);class vi{constructor(e={}){this.version=jc.v1,this.privateKeyAlgorithm=new F,this.privateKey=new gg,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:gg})],vi.prototype,"privateKey",void 0);d([g({type:$c,implicit:!0,context:0,optional:!0})],vi.prototype,"attributes",void 0);let bd=class extends vi{};bd=d([P({type:T.Sequence})],bd);let kd=class extends Do{};kd=d([P({type:T.Sequence})],kd);class mg{constructor(e={}){this.secretTypeId="",this.secretValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],mg.prototype,"secretTypeId",void 0);d([g({type:b.Any,context:0})],mg.prototype,"secretValue",void 0);class wi{constructor(e={}){this.mac=new Uo,this.macSalt=new ae,this.iterations=1,Object.assign(this,e)}}d([g({type:Uo})],wi.prototype,"mac",void 0);d([g({type:ae})],wi.prototype,"macSalt",void 0);d([g({type:b.Integer,defaultValue:1})],wi.prototype,"iterations",void 0);class Ho{constructor(e={}){this.version=3,this.authSafe=new hr,this.macData=new wi,Object.assign(this,e)}}d([g({type:b.Integer})],Ho.prototype,"version",void 0);d([g({type:hr})],Ho.prototype,"authSafe",void 0);d([g({type:wi,optional:!0})],Ho.prototype,"macData",void 0);var Oc;class Fo{constructor(e={}){this.bagId="",this.bagValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:b.ObjectIdentifier})],Fo.prototype,"bagId",void 0);d([g({type:b.Any,context:0})],Fo.prototype,"bagValue",void 0);d([g({type:qo,repeated:"set",optional:!0})],Fo.prototype,"bagAttributes",void 0);let xd=Oc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Oc.prototype)}};xd=Oc=d([P({type:T.Sequence,itemType:Fo})],xd);var Bc,Tc,Pc;const _g="1.2.840.113549.1.9",yg=`${_g}.7`,Gl=`${_g}.14`;let Ls=class extends Oe{constructor(e={}){super(e)}toString(){return this.ia5String||super.toString()}};d([g({type:b.IA5String})],Ls.prototype,"ia5String",void 0);Ls=d([P({type:T.Choice})],Ls);let Sd=class extends hr{};Sd=d([P({type:T.Sequence})],Sd);let Ad=class extends Ho{};Ad=d([P({type:T.Sequence})],Ad);let Ed=class extends Do{};Ed=d([P({type:T.Sequence})],Ed);let Rc=class{constructor(e=""){this.value=e}toString(){return this.value}};d([g({type:b.IA5String})],Rc.prototype,"value",void 0);Rc=d([P({type:T.Choice})],Rc);let Id=class extends Ls{};Id=d([P({type:T.Choice})],Id);let zd=class extends Oe{};zd=d([P({type:T.Choice})],zd);let Lc=class{constructor(e=new Date){this.value=e}};d([g({type:b.GeneralizedTime})],Lc.prototype,"value",void 0);Lc=d([P({type:T.Choice})],Lc);let Cd=class extends Oe{};Cd=d([P({type:T.Choice})],Cd);let Uc=class{constructor(e="M"){this.value=e}toString(){return this.value}};d([g({type:b.PrintableString})],Uc.prototype,"value",void 0);Uc=d([P({type:T.Choice})],Uc);let Us=class{constructor(e=""){this.value=e}toString(){return this.value}};d([g({type:b.PrintableString})],Us.prototype,"value",void 0);Us=d([P({type:T.Choice})],Us);let Nd=class extends Us{};Nd=d([P({type:T.Choice})],Nd);let jd=class extends Oe{};jd=d([P({type:T.Choice})],jd);let Vc=class{constructor(e=""){this.value=e}toString(){return this.value}};d([g({type:b.ObjectIdentifier})],Vc.prototype,"value",void 0);Vc=d([P({type:T.Choice})],Vc);let $d=class extends je{};$d=d([P({type:T.Choice})],$d);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([P({type:T.Choice})],Mc);let Od=class extends zt{};Od=d([P({type:T.Sequence})],Od);let Vs=class extends Oe{};Vs=d([P({type:T.Choice})],Vs);let Bd=Bc=class extends Xt{constructor(e){super(e),Object.setPrototypeOf(this,Bc.prototype)}};Bd=Bc=d([P({type:T.Sequence})],Bd);let Td=Tc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Tc.prototype)}};Td=Tc=d([P({type:T.Set,itemType:fr})],Td);let qc=class{constructor(e=""){this.value=e}toString(){return this.value}};d([g({type:b.BmpString})],qc.prototype,"value",void 0);qc=d([P({type:T.Choice})],qc);let Dc=class extends F{};Dc=d([P({type:T.Sequence})],Dc);let Pd=Pc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Pc.prototype)}};Pd=Pc=d([P({type:T.Sequence,itemType:Dc})],Pd);var Hc;let Ms=Hc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Hc.prototype)}};Ms=Hc=d([P({type:T.Sequence,itemType:Pt})],Ms);class _r{constructor(e={}){this.version=0,this.subject=new ke,this.subjectPKInfo=new dt,this.attributes=new Ms,Object.assign(this,e)}}d([g({type:b.Integer})],_r.prototype,"version",void 0);d([g({type:ke})],_r.prototype,"subject",void 0);d([g({type:dt})],_r.prototype,"subjectPKInfo",void 0);d([g({type:Ms,implicit:!0,context:0})],_r.prototype,"attributes",void 0);class Wr{constructor(e={}){this.certificationRequestInfo=new _r,this.signatureAlgorithm=new F,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:_r})],Wr.prototype,"certificationRequestInfo",void 0);d([g({type:F})],Wr.prototype,"signatureAlgorithm",void 0);d([g({type:b.BitString})],Wr.prototype,"signature",void 0);/*!
|
|
95
119
|
* MIT License
|
|
96
120
|
*
|
|
97
121
|
* Copyright (c) Peculiar Ventures. All rights reserved.
|
|
@@ -114,39 +138,15 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
114
138
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
115
139
|
* SOFTWARE.
|
|
116
140
|
*
|
|
117
|
-
*/const
|
|
118
|
-
`)}static pad(e=0){return"".padStart(2*e," ")}static serializeObj(e,n=0){const r=[];let i=this.pad(n++),s="";const o=e[ue.VALUE];o&&(s=` ${o}`),r.push(`${i}${e[ue.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[ue.NAME]=c,r.push(...this.serializeObj(p,n));else if(l instanceof ue)l[ue.NAME]=c,r.push(...this.serializeObj(l,n));else if(q.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[ue.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=q.toUint8Array(e),s=[];for(let o=0;o<i.length;){const c=[];for(let l=0;l<16&&o<i.length;l++){l===8&&c.push("");const u=i[o++].toString(16).padStart(2,"0");c.push(u)}s.push(`${r}${c.join(" ")}`)}return s}static serializeAlgorithm(e){return this.algorithmSerializer.toTextObject(e)}}
|
|
119
|
-
`).replace(/\\0d/ig,"\r").replace(/\\0g/ig," ").replace(/\\(.)/g,"$1")}toArrayBuffer(){return M.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]||Ne.get()):r=e[0]||Ne.get(),await r.subtle.digest(i,this.toArrayBuffer())}}const
|
|
141
|
+
*/const bi="crypto.algorithm";class Lv{getAlgorithms(){return Be.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 Cn="crypto.algorithmProvider";Be.registerSingleton(Cn,Lv);var Mi;const We="1.3.36.3.3.2.8.1.1",Rd=`${We}.1`,Ld=`${We}.2`,Ud=`${We}.3`,Vd=`${We}.4`,Md=`${We}.5`,qd=`${We}.6`,Dd=`${We}.7`,Hd=`${We}.8`,Fd=`${We}.9`,Kd=`${We}.10`,Wd=`${We}.11`,Gd=`${We}.12`,Jd=`${We}.13`,Zd=`${We}.14`,Yd="brainpoolP160r1",Xd="brainpoolP160t1",Qd="brainpoolP192r1",ep="brainpoolP192t1",tp="brainpoolP224r1",np="brainpoolP224t1",rp="brainpoolP256r1",ip="brainpoolP256t1",sp="brainpoolP320r1",op="brainpoolP320t1",ap="brainpoolP384r1",cp="brainpoolP384t1",lp="brainpoolP512r1",up="brainpoolP512t1",ye="ECDSA";let Gr=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 cv;case"sha-256":return lv;case"sha-384":return uv;case"sha-512":return dv}else if("namedCurve"in e){let n="";switch(e.namedCurve){case"P-256":n=hd;break;case"K-256":n=Mi.SECP256K1;break;case"P-384":n=gd;break;case"P-521":n=md;break;case Yd:n=Rd;break;case Xd:n=Ld;break;case Qd:n=Ud;break;case ep:n=Vd;break;case tp:n=Md;break;case np:n=qd;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}if(n)return new F({algorithm:Fr,parameters:M.serialize(new en({namedCurve:n}))})}}return null}toWebAlgorithm(e){switch(e.algorithm){case Ml:return{name:ye,hash:{name:"SHA-1"}};case ql:return{name:ye,hash:{name:"SHA-256"}};case Dl:return{name:ye,hash:{name:"SHA-384"}};case Hl:return{name:ye,hash:{name:"SHA-512"}};case Fr:{if(!e.parameters)throw new TypeError("Cannot get required parameters from EC algorithm");switch(M.parse(e.parameters,en).namedCurve){case hd:return{name:ye,namedCurve:"P-256"};case Mi.SECP256K1:return{name:ye,namedCurve:"K-256"};case gd:return{name:ye,namedCurve:"P-384"};case md:return{name:ye,namedCurve:"P-521"};case Rd:return{name:ye,namedCurve:Yd};case Ld:return{name:ye,namedCurve:Xd};case Ud:return{name:ye,namedCurve:Qd};case Vd:return{name:ye,namedCurve:ep};case Md:return{name:ye,namedCurve:tp};case qd: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}}}}return null}};Gr.SECP256K1="1.3.132.0.10";Gr=Mi=d([Mo()],Gr);Be.registerSingleton(bi,Gr);const vg=Symbol("name"),wg=Symbol("value");class ue{constructor(e,n={},r=""){this[vg]=e,this[wg]=r;for(const i in n)this[i]=n[i]}}ue.NAME=vg;ue.VALUE=wg;class Uv{static toTextObject(e){const n=new ue("Algorithm Identifier",{},an.toString(e.algorithm));if(e.parameters)switch(e.algorithm){case Fr:{const r=new Gr().toWebAlgorithm(e);r&&"namedCurve"in r?n["Named Curve"]=r.namedCurve:n.Parameters=e.parameters;break}default:n.Parameters=e.parameters}return n}}class an{static toString(e){const n=this.items[e];return n||e}}an.items={[Os]:"sha1",[og]:"sha224",[Bs]:"sha256",[Ts]:"sha384",[Ps]:"sha512",[En]:"rsaEncryption",[Ns]:"sha1WithRSAEncryption",[_v]:"sha224WithRSAEncryption",[kc]:"sha256WithRSAEncryption",[js]:"sha384WithRSAEncryption",[$s]:"sha512WithRSAEncryption",[Fr]:"ecPublicKey",[Ml]:"ecdsaWithSHA1",[rg]:"ecdsaWithSHA224",[ql]:"ecdsaWithSHA256",[Dl]:"ecdsaWithSHA384",[Hl]:"ecdsaWithSHA512",[tv]:"TLS WWW server authentication",[nv]:"TLS WWW client authentication",[rv]:"Code Signing",[iv]:"E-mail Protection",[sv]:"Time Stamping",[ov]:"OCSP Signing",[av]:"Signed Data"};class Nn{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 o=e[ue.VALUE];o&&(s=` ${o}`),r.push(`${i}${e[ue.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[ue.NAME]=c,r.push(...this.serializeObj(p,n));else if(l instanceof ue)l[ue.NAME]=c,r.push(...this.serializeObj(l,n));else if(q.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[ue.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=q.toUint8Array(e),s=[];for(let o=0;o<i.length;){const c=[];for(let l=0;l<16&&o<i.length;l++){l===8&&c.push("");const u=i[o++].toString(16).padStart(2,"0");c.push(u)}s.push(`${r}${c.join(" ")}`)}return s}static serializeAlgorithm(e){return this.algorithmSerializer.toTextObject(e)}}Nn.oidSerializer=an;Nn.algorithmSerializer=Uv;class cn{constructor(...e){if(e.length===1){const n=e[0];this.rawData=M.serialize(n),this.onInit(n)}else{const n=M.parse(e[0],e[1]);this.rawData=q.toArrayBuffer(e[0]),this.onInit(n)}}equal(e){return e instanceof cn?Uf(e.rawData,this.rawData):!1}toString(e="text"){switch(e){case"asn":return M.toString(this.rawData);case"text":return Nn.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 ue(this.getTextName(),{},e)}}cn.NAME="ASN";class st extends cn{constructor(...e){let n;q.isBufferSource(e[0])?n=q.toArrayBuffer(e[0]):n=M.serialize(new rt({extnID:e[0],critical:e[1],extnValue:new ae(q.toArrayBuffer(e[2]))})),super(n,rt)}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[ue.NAME]===st.NAME&&(e[ue.NAME]=an.toString(this.type)),e}}var bg;class Ht{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[bg]="CryptoProvider",typeof self<"u"&&typeof crypto<"u"?this.set(Ht.DEFAULT,crypto):typeof global<"u"&&global.crypto&&global.crypto.subtle&&this.set(Ht.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=Ht.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(Ht.DEFAULT,e);return this}}bg=Symbol.toStringTag;Ht.DEFAULT="default";const Ne=new Ht,Vv=/^[0-2](?:\.[1-9][0-9]*)+$/;function Mv(t){return new RegExp(Vv).test(t)}class kg{constructor(e={}){this.items={};for(const n in e)this.register(n,e[n])}get(e){return this.items[e]||null}findId(e){return Mv(e)?e:this.get(e)}register(e,n){this.items[e]=n,this.items[n]=e}}const He=new kg;He.register("CN","2.5.4.3");He.register("L","2.5.4.7");He.register("ST","2.5.4.8");He.register("O","2.5.4.10");He.register("OU","2.5.4.11");He.register("C","2.5.4.6");He.register("DC","0.9.2342.19200300.100.1.25");He.register("E","1.2.840.113549.1.9.1");He.register("G","2.5.4.42");He.register("I","2.5.4.43");He.register("SN","2.5.4.4");He.register("T","2.5.4.12");function qv(t,e){return`\\${J.ToHex(J.FromUtf8String(e)).toUpperCase()}`}function Dv(t){return t.replace(/([,+"\\<>;])/g,"\\$1").replace(/^([ #])/,"\\$1").replace(/([ ]$)/,"\\$1").replace(/([\r\n\t])/,qv)}class tt{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 kg,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:q.isBufferSource(e)?this.asn=M.parse(e,ke):this.asn=this.fromJSON(e)}getField(e){const n=this.extraNames.findId(e)||He.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)||He.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)}`:Dv(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 o=this.getName(s.type)||s.type;(e=i[o])!==null&&e!==void 0||(i[o]=[]),i[o].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[,o,c]=i;const l=c[c.length-1];(l===","||l==="+")&&(c=c.slice(0,c.length-1),i[3]=l);const u=i[3];o=this.getTypeOid(o);const p=this.createAttribute(o,c);s==="+"?n[n.length-1].push(p):n.push(new Zn([p])),s=u}return n}fromJSON(e){const n=new ke;for(const r of e){const i=new Zn;for(const s in r){const o=this.getTypeOid(s),c=r[s];for(const l of c){const u=this.createAttribute(o,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 bo({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:tt.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 M.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]||Ne.get()):r=e[0]||Ne.get(),await r.subtle.digest(i,this.toArrayBuffer())}}const xg="Cannot initialize GeneralName from ASN.1 data.",dp=`${xg} Unsupported string format in use.`,Hv=`${xg} Value doesn't match to GUID regular expression.`,pp=/^([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})$/i,fp="1.3.6.1.4.1.311.25.1",hp="1.3.6.1.4.1.311.20.2.3",ia="dns",sa="dn",oa="email",aa="ip",ca="url",la="guid",ua="upn",$i="id";class Ft extends cn{constructor(...e){let n;if(e.length===2)switch(e[0]){case sa:{const r=new tt(e[1]).toArrayBuffer(),i=M.parse(r,ke);n=new re({directoryName:i});break}case ia:n=new re({dNSName:e[1]});break;case oa:n=new re({rfc822Name:e[1]});break;case la:{const r=new RegExp(pp,"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,o)=>o<3?J.ToHex(new Uint8Array(J.FromHex(s)).reverse()):s).join("");n=new re({otherName:new Mr({typeId:fp,value:M.serialize(new ae(J.FromHex(i)))})});break}case aa:n=new re({iPAddress:e[1]});break;case $i:n=new re({registeredID:e[1]});break;case ua:{n=new re({otherName:new Mr({typeId:hp,value:M.serialize(Uh.toASN(e[1]))})});break}case ca:n=new re({uniformResourceIdentifier:e[1]});break;default:throw new Error("Cannot create GeneralName. Unsupported type of the name")}else q.isBufferSource(e[0])?n=M.parse(e[0],re):n=e[0];super(n)}onInit(e){if(e.dNSName!=null)this.type=ia,this.value=e.dNSName;else if(e.rfc822Name!=null)this.type=oa,this.value=e.rfc822Name;else if(e.iPAddress!=null)this.type=aa,this.value=e.iPAddress;else if(e.uniformResourceIdentifier!=null)this.type=ca,this.value=e.uniformResourceIdentifier;else if(e.registeredID!=null)this.type=$i,this.value=e.registeredID;else if(e.directoryName!=null)this.type=sa,this.value=new tt(e.directoryName).toString();else if(e.otherName!=null)if(e.otherName.typeId===fp){this.type=la;const n=M.parse(e.otherName.value,ae),r=new RegExp(pp,"i").exec(J.ToHex(n));if(!r)throw new Error(Hv);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===hp)this.type=ua,this.value=M.parse(e.otherName.value,Oe).toString();else throw new Error(dp);else throw new Error(dp)}toJSON(){return{type:this.type,value:this.value}}toTextObject(){let e;switch(this.type){case sa:case ia:case la:case aa:case $i:case ua:case ca:e=this.type.toUpperCase();break;case oa:e="Email";break;default:throw new Error("Unsupported GeneralName type")}let n=this.value;return this.type===$i&&(n=an.toString(n)),new ue(e,void 0,n)}}class Jr extends cn{constructor(e){let n;if(e instanceof Re)n=e;else if(Array.isArray(e)){const r=[];for(const i of e)if(i instanceof re)r.push(i);else{const s=M.parse(new Ft(i.type,i.value).rawData,re);r.push(s)}n=new Re(r)}else if(q.isBufferSource(e))n=M.parse(e,Re);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 Ft(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[ue.NAME]];Array.isArray(i)||(i=[],e[r[ue.NAME]]=i),i.push(r)}return e}}Jr.NAME="GeneralNames";const Tr="-{5}",Zr="\\n",Fv=`[^${Zr}]+`,Kv=`${Tr}BEGIN (${Fv}(?=${Tr}))${Tr}`,Wv=`${Tr}END \\1${Tr}`,ir="\\n",Gv=`[^:${Zr}]+`,Jv=`(?:[^${Zr}]+${ir}(?: +[^${Zr}]+${ir})*)`,Zv="[a-zA-Z0-9=+/]+",Yv=`(?:${Zv}${ir})+`,gp=`${Kv}${ir}(?:((?:${Gv}: ${Jv})+))?${ir}?(${Yv})${Wv}`;class Ze{static isPem(e){return typeof e=="string"&&new RegExp(gp,"g").test(e)}static decodeWithHeaders(e){e=e.replace(/\r/g,"");const n=new RegExp(gp,"g"),r=[];let i=null;for(;i=n.exec(e);){const s=i[3].replace(new RegExp(`[${Zr}]+`,"g"),""),o={type:i[1],headers:[],rawData:J.FromBase64(s)},c=i[2];if(c){const l=c.split(new RegExp(ir,"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&&o.headers.push(u),u={key:h,value:m.trim()}}u&&o.headers.push(u)}r.push(o)}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(!q.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:q.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(`
|
|
120
144
|
`)}else{if(!n)throw new Error("Required argument 'tag' is missed");return this.encodeStruct({type:n,rawData:q.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 o,c=0;const l=Array();for(;c<s.length&&(s.length-c<64?o=s.substring(c):(o=s.substring(c,c+64),c+=64),o.length!==0);)if(l.push(o),o.length<64)break;return i.push(...l),i.push(`-----END ${r}-----`),i.join(`
|
|
121
|
-
`)}}Ze.CertificateTag="CERTIFICATE";Ze.CrlTag="CRL";Ze.CertificateRequestTag="CERTIFICATE REQUEST";Ze.PublicKeyTag="PUBLIC KEY";Ze.PrivateKeyTag="PRIVATE KEY";class Ut extends on{static isAsnEncoded(e){return q.isBufferSource(e)||typeof e=="string"}static toArrayBuffer(e){if(typeof e=="string"){if(Ze.isPem(e))return Ze.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 Ze.isPem(n)?Ze.decode(n)[0]:J.isHex(n)?J.FromHex(n):J.isBase64(n)?J.FromBase64(n):J.isBase64Url(n)?J.FromBase64Url(n):q.toArrayBuffer(e)}}constructor(...e){Ut.isAsnEncoded(e[0])?super(Ut.toArrayBuffer(e[0]),e[1]):super(e[0])}toString(e="pem"){switch(e){case"pem":return Ze.encode(this.rawData,this.tag);default:return super.toString(e)}}}class pt extends Ut{static async create(e,n=Ne.get()){if(e instanceof pt)return e;if(Ht.isCryptoKey(e)){if(e.type!=="public")throw new TypeError("Public key is required");const r=await n.subtle.exportKey("spki",e);return new pt(r)}else{if(e.publicKey)return e.publicKey;if(q.isBufferSource(e))return new pt(e);throw new TypeError("Unsupported PublicKeyType")}}constructor(e){Ut.isAsnEncoded(e)?super(e,dt):super(e),this.tag=Ze.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]||Ne.get()):n=e[0]||Ne.get();let s=this.rawData;const o=M.parse(this.rawData,dt);return o.algorithm.algorithm===Pr&&(s=iy(o,s)),n.subtle.importKey("spki",s,i,!0,r)}onInit(e){const n=Be.resolve(Nn),r=this.algorithm=n.toWebAlgorithm(e.algorithm);switch(e.algorithm.algorithm){case In:{const i=M.parse(e.subjectPublicKey,Ll),s=q.toUint8Array(i.modulus);r.publicExponent=q.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]||Ne.get()):r=e[0]||Ne.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=Ne.get()):n=e[0]:e.length===2?(r=e[0],n=e[1]):n=Ne.get();const i=M.parse(this.rawData,dt);return await n.subtle.digest(r,i.subjectPublicKey)}toTextObject(){const e=this.toTextObjectEmpty(),n=M.parse(this.rawData,dt);switch(e.Algorithm=jn.serializeAlgorithm(n.algorithm),n.algorithm.algorithm){case Kr:e["EC Point"]=n.subjectPublicKey;break;case In:default:e["Raw Data"]=n.subjectPublicKey}return e}}function iy(t,e){return t.algorithm=new F({algorithm:In,parameters:null}),e=M.serialize(t),e}class Xr extends st{static async create(e,n=!1,r=Ne.get()){if("name"in e&&"serialNumber"in e)return new Xr(e,n);const s=await(await pt.create(e,r)).getKeyIdentifier(r);return new Xr(J.ToHex(s),n)}constructor(...e){if(q.isBufferSource(e[0]))super(e[0]);else if(typeof e[0]=="string"){const n=new hn({keyIdentifier:new vl(J.FromHex(e[0]))});super(Pa,e[1],M.serialize(n))}else{const n=e[0],r=n.name instanceof Zr?M.parse(n.name.rawData,Le):n.name,i=new hn({authorityCertIssuer:r,authorityCertSerialNumber:J.FromHex(n.serialNumber)});super(Pa,e[1],M.serialize(i))}}onInit(e){super.onInit(e);const n=M.parse(e.extnValue,hn);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=M.parse(this.value,hn);return n.authorityCertIssuer&&(e["Authority Issuer"]=new Zr(n.authorityCertIssuer).toTextObject()),n.authorityCertSerialNumber&&(e["Authority Serial Number"]=n.authorityCertSerialNumber),n.keyIdentifier&&(e[""]=n.keyIdentifier),e}}Xr.NAME="Authority Key Identifier";class ql extends st{constructor(...e){if(q.isBufferSource(e[0])){super(e[0]);const n=M.parse(this.value,ps);this.ca=n.cA,this.pathLength=n.pathLenConstraint}else{const n=new ps({cA:e[0],pathLenConstraint:e[1]});super(Eh,e[2],M.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}}ql.NAME="Basic Constraints";var cp;(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"})(cp||(cp={}));class Dl extends st{constructor(...e){if(q.isBufferSource(e[0])){super(e[0]);const n=M.parse(this.value,ms);this.usages=n.map(r=>r)}else{const n=new ms(e[0]);super(Ch,e[1],M.serialize(n)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.usages.map(n=>sn.toString(n)).join(", "),e}}Dl.NAME="Extended Key Usages";var qs;(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"})(qs||(qs={}));class Hl extends st{constructor(...e){if(q.isBufferSource(e[0])){super(e[0]);const n=M.parse(this.value,ra);this.usages=n.toNumber()}else{const n=new ra(e[0]);super(Nh,e[1],M.serialize(n)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue(),n=M.parse(this.value,ra);return e[""]=n.toJSON().join(", "),e}}Hl.NAME="Key Usages";class Si extends st{static async create(e,n=!1,r=Ne.get()){const s=await(await pt.create(e,r)).getKeyIdentifier(r);return new Si(J.ToHex(s),n)}constructor(...e){if(q.isBufferSource(e[0])){super(e[0]);const n=M.parse(this.value,Wt);this.keyId=J.ToHex(n)}else{const n=typeof e[0]=="string"?J.FromHex(e[0]):e[0],r=new Wt(n);super(Bh,e[1],M.serialize(r)),this.keyId=J.ToHex(n)}}toTextObject(){const e=this.toTextObjectWithoutValue(),n=M.parse(this.value,Wt);return e[""]=n,e}}Si.NAME="Subject Key Identifier";class cg extends st{constructor(...e){q.isBufferSource(e[0])?super(e[0]):super(Oh,e[1],new Zr(e[0]||[]).rawData)}onInit(e){super.onInit(e);const n=M.parse(e.extnValue,Ya);this.names=new Zr(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 ot{static register(e,n){this.items.set(e,n)}static create(e){const n=new st(e),r=this.items.get(n.type);return r?new r(e):n}}ot.items=new Map;class lg extends st{constructor(...e){var n;if(q.isBufferSource(e[0])){super(e[0]);const r=M.parse(this.value,hs);this.policies=r.map(i=>i.policyIdentifier)}else{const r=e[0],i=(n=e[1])!==null&&n!==void 0?n:!1,s=new hs(r.map(o=>new wo({policyIdentifier:o})));super(Ih,i,M.serialize(s)),this.policies=r}}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map(n=>new ue("",{},sn.toString(n))),e}}lg.NAME="Certificate Policies";ot.register(Ih,lg);class ug extends st{constructor(...e){var n;if(q.isBufferSource(e[0]))super(e[0]);else if(Array.isArray(e[0])&&typeof e[0][0]=="string"){const i=e[0].map(o=>new fr({distributionPoint:new xn({fullName:[new re({uniformResourceIdentifier:o})]})})),s=new Wn(i);super(Ma,e[1],M.serialize(s))}else{const r=new Wn(e[0]);super(Ma,e[1],M.serialize(r))}(n=this.distributionPoints)!==null&&n!==void 0||(this.distributionPoints=[])}onInit(e){super.onInit(e);const n=M.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 Ft(s).toString()).join(", ")),n.reasons&&(i.Reasons=n.reasons.toString()),n.cRLIssuer&&(i["CRL Issuer"]=n.cRLIssuer.map(s=>s.toString()).join(", ")),i}),e}}ug.NAME="CRL Distribution Points";class dg extends st{constructor(...e){var n,r,i,s;if(q.isBufferSource(e[0]))super(e[0]);else if(e[0]instanceof Hn){const o=new Hn(e[0]);super(Ta,e[1],M.serialize(o))}else{const o=e[0],c=new Hn;Ti(c,o,Fu,"ocsp"),Ti(c,o,Ku,"caIssuers"),Ti(c,o,Wu,"timeStamping"),Ti(c,o,Gu,"caRepository"),super(Ta,e[1],M.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=[],M.parse(e.extnValue,Hn).forEach(r=>{switch(r.accessMethod){case Fu:this.ocsp.push(new Ft(r.accessLocation));break;case Ku:this.caIssuers.push(new Ft(r.accessLocation));break;case Wu:this.timeStamping.push(new Ft(r.accessLocation));break;case Gu:this.caRepository.push(new Ft(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}}dg.NAME="Authority Info Access";function Bi(t,e,n){if(n.length===1)t[e]=n[0].toTextObject();else{const r=new ue("");n.forEach((i,s)=>{const o=i.toTextObject(),c=`${o[ue.NAME]} ${s+1}`;let l=r[c];Array.isArray(l)||(l=[],r[c]=l),l.push(o)}),t[e]=r}}function Ti(t,e,n,r){const i=e[r];i&&(Array.isArray(i)?i:[i]).forEach(o=>{typeof o=="string"&&(o=new Ft("url",o)),t.push(new di({accessMethod:n,accessLocation:M.parse(o.rawData,re)}))})}class wr extends on{constructor(...e){let n;if(q.isBufferSource(e[0]))n=q.toArrayBuffer(e[0]);else{const r=e[0],i=Array.isArray(e[1])?e[1].map(s=>q.toArrayBuffer(s)):[];n=M.serialize(new Pt({type:r,values:i}))}super(n,Pt)}onInit(e){this.type=e.type,this.values=e.values}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Value=this.values.map(n=>new ue("",{"":n})),e}toTextObjectWithoutValue(){const e=this.toTextObjectEmpty();return e[ue.NAME]===wr.NAME&&(e[ue.NAME]=sn.toString(this.type)),e}}wr.NAME="Attribute";class pg extends wr{constructor(...e){var n;if(q.isBufferSource(e[0]))super(e[0]);else{const r=new Vs({printableString:e[0]});super(ng,[M.serialize(r)])}(n=this.password)!==null&&n!==void 0||(this.password="")}onInit(e){if(super.onInit(e),this.values[0]){const n=M.parse(this.values[0],Vs);this.password=n.toString()}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[ue.VALUE]=this.password,e}}pg.NAME="Challenge Password";class Fl extends wr{constructor(...e){var n;if(q.isBufferSource(e[0]))super(e[0]);else{const r=e[0],i=new Xt;for(const s of r)i.push(M.parse(s.rawData,rt));super(Ml,[M.serialize(i)])}(n=this.items)!==null&&n!==void 0||(this.items=[])}onInit(e){if(super.onInit(e),this.values[0]){const n=M.parse(this.values[0],Xt);this.items=n.map(r=>ot.create(M.serialize(r)))}}toTextObject(){const e=this.toTextObjectWithoutValue(),n=this.items.map(r=>r.toTextObject());for(const r of n)e[r[ue.NAME]]=r;return e}}Fl.NAME="Extensions";class Do{static register(e,n){this.items.set(e,n)}static create(e){const n=new wr(e),r=this.items.get(n.type);return r?new r(e):n}}Do.items=new Map;const Ai="crypto.signatureFormatter";class sy{toAsnSignature(e,n){return q.toArrayBuffer(n)}toWebSignature(e,n){return q.toArrayBuffer(n)}}var Hi;let Mc=Hi=class{static createPssParams(e,n){const r=Hi.getHashAlgorithm(e);return r?new Cn({hashAlgorithm:r,maskGenAlgorithm:new F({algorithm:Bo,parameters:M.serialize(r)}),saltLength:n}):null}static getHashAlgorithm(e){const n=Be.resolve(Nn);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:Ns,parameters:null});case"sha-256":return new F({algorithm:yc,parameters:null});case"sha-384":return new F({algorithm:js,parameters:null});case"sha-512":return new F({algorithm:$s,parameters:null})}}else return new F({algorithm:In,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=Hi.createPssParams(e.hash,e.saltLength);if(!n)throw new Error("Cannot create PSS parameters");return new F({algorithm:Pr,parameters:M.serialize(n)})}else return new F({algorithm:Pr,parameters:null})}return null}toWebAlgorithm(e){switch(e.algorithm){case In:return{name:"RSASSA-PKCS1-v1_5"};case Ns:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case yc:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case js:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case $s:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}};case Pr:if(e.parameters){const n=M.parse(e.parameters,Cn);return{name:"RSA-PSS",hash:Be.resolve(Nn).toWebAlgorithm(n.hashAlgorithm),saltLength:n.saltLength}}else return{name:"RSA-PSS"}}return null}};Mc=Hi=d([Lo()],Mc);Be.registerSingleton(xi,Mc);let qc=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"sha-1":return new F({algorithm:Os});case"sha-256":return new F({algorithm:Bs});case"sha-384":return new F({algorithm:Ts});case"sha-512":return new F({algorithm:Ps})}return null}toWebAlgorithm(e){switch(e.algorithm){case Os:return{name:"SHA-1"};case Bs:return{name:"SHA-256"};case Ts:return{name:"SHA-384"};case Ps:return{name:"SHA-512"}}return null}};qc=d([Lo()],qc);Be.registerSingleton(xi,qc);class nt{addPadding(e,n){const r=q.toUint8Array(n),i=new Uint8Array(e);return i.set(r,e-r.length),i}removePadding(e,n=!1){let r=q.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=nt.namedCurveSize.get(r)||nt.defaultNamedCurveSize,s=new Cs,o=q.toUint8Array(n);return s.r=this.removePadding(o.slice(0,i),!0),s.s=this.removePadding(o.slice(i,i+i),!0),M.serialize(s)}return null}toWebSignature(e,n){if(e.name==="ECDSA"){const r=M.parse(n,Cs),i=e.namedCurve,s=nt.namedCurveSize.get(i)||nt.defaultNamedCurveSize,o=this.addPadding(s,this.removePadding(r.r)),c=this.addPadding(s,this.removePadding(r.s));return y_(o,c)}return null}}nt.namedCurveSize=new Map;nt.defaultNamedCurveSize=32;const da="1.3.101.110",lp="1.3.101.111",pa="1.3.101.112",up="1.3.101.113";let Dc=class{toAsnAlgorithm(e){let n=null;switch(e.name.toLowerCase()){case"ed25519":n=pa;break;case"x25519":n=da;break;case"eddsa":switch(e.namedCurve.toLowerCase()){case"ed25519":n=pa;break;case"ed448":n=up;break}break;case"ecdh-es":switch(e.namedCurve.toLowerCase()){case"x25519":n=da;break;case"x448":n=lp;break}}return n?new F({algorithm:n}):null}toWebAlgorithm(e){switch(e.algorithm){case pa:return{name:"Ed25519"};case up:return{name:"EdDSA",namedCurve:"Ed448"};case da:return{name:"X25519"};case lp:return{name:"ECDH-ES",namedCurve:"X448"}}return null}};Dc=d([Lo()],Dc);Be.registerSingleton(xi,Dc);class oy extends Ut{constructor(e){Ut.isAsnEncoded(e)?super(e,Gr):super(e),this.tag=Ze.CertificateRequestTag}onInit(e){this.tbs=M.serialize(e.certificationRequestInfo),this.publicKey=new pt(e.certificationRequestInfo.subjectPKInfo);const n=Be.resolve(Nn);this.signatureAlgorithm=n.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signature,this.attributes=e.certificationRequestInfo.attributes.map(i=>Do.create(M.serialize(i)));const r=this.getAttribute(Ml);this.extensions=[],r instanceof Fl&&(this.extensions=r.items),this.subjectName=new tt(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=Ne.get()){const n={...this.publicKey.algorithm,...this.signatureAlgorithm},r=await this.publicKey.export(n,["verify"],e),i=Be.resolveAll(Ai).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=M.parse(this.rawData,Gr),r=n.certificationRequestInfo,i=new ue("",{Version:`${Sn[r.version]} (${r.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){const s=new ue("");for(const o of this.attributes){const c=o.toTextObject();s[c[ue.NAME]]=c}i.Attributes=s}return e.Data=i,e.Signature=new ue("",{Algorithm:jn.serializeAlgorithm(n.signatureAlgorithm),"":n.signature}),e}}oy.NAME="PKCS#10 Certificate Request";class Kl extends Ut{constructor(e){Ut.isAsnEncoded(e)?super(e,An):super(e),this.tag=Ze.CertificateTag}onInit(e){const n=e.tbsCertificate;this.tbs=M.serialize(n),this.serialNumber=J.ToHex(n.serialNumber),this.subjectName=new tt(n.subject),this.subject=new tt(n.subject).toString(),this.issuerName=new tt(n.issuer),this.issuer=this.issuerName.toString();const r=Be.resolve(Nn);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(o=>ot.create(M.serialize(o)))),this.publicKey=new pt(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=Ne.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 pt)r={...s.algorithm,...this.signatureAlgorithm},i=await s.export(r,["verify"],n);else if(q.isBufferSource(s)){const u=new pt(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 o=Be.resolveAll(Ai).reverse();let c=null;for(const u of o)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=Ne.get()),await n.subtle.digest(r,this.rawData)}async isSelfSigned(e=Ne.get()){return this.subject===this.issuer&&await this.verify({signatureOnly:!0},e)}toTextObject(){const e=this.toTextObjectEmpty(),n=M.parse(this.rawData,An),r=n.tbsCertificate,i=new ue("",{Version:`${Sn[r.version]} (${r.version})`,"Serial Number":r.serialNumber,"Signature Algorithm":jn.serializeAlgorithm(r.signature),Issuer:this.issuer,Validity:new ue("",{"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 ue("");for(const o of this.extensions){const c=o.toTextObject();s[c[ue.NAME]]=c}i.Extensions=s}return e.Data=i,e.Signature=new ue("",{Algorithm:jn.serializeAlgorithm(n.signatureAlgorithm),"":n.signatureValue}),e}}Kl.NAME="Certificate";class ay{static async createSelfSigned(e,n=Ne.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=Ne.get()){var r;let i;e.publicKey instanceof pt?i=e.publicKey.rawData:"publicKey"in e.publicKey?i=e.publicKey.publicKey.rawData:q.isBufferSource(e.publicKey)?i=e.publicKey:i=await n.subtle.exportKey("spki",e.publicKey);const s=e.serialNumber?q.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 o=e.notBefore||new Date,c=e.notAfter||new Date(o.getTime()+31536e6),l=new An({tbsCertificate:new Xe({version:Sn.v3,serialNumber:s,validity:new pi({notBefore:o,notAfter:c}),extensions:new Xt(((r=e.extensions)===null||r===void 0?void 0:r.map(w=>M.parse(w.rawData,rt)))||[]),subjectPublicKeyInfo:M.parse(i,dt)})});if(e.subject){const w=e.subject instanceof tt?e.subject:new tt(e.subject);l.tbsCertificate.subject=M.parse(w.toArrayBuffer(),ke)}if(e.issuer){const w=e.issuer instanceof tt?e.issuer:new tt(e.issuer);l.tbsCertificate.issuer=M.parse(w.toArrayBuffer(),ke)}const u={hash:"SHA-256"},p="signingKey"in e?{...u,...e.signingAlgorithm,...e.signingKey.algorithm}:{...u,...e.signingAlgorithm},h=Be.resolve(Nn);l.tbsCertificate.signature=l.signatureAlgorithm=h.toAsnAlgorithm(p);const m=M.serialize(l.tbsCertificate),v="signingKey"in e?await n.subtle.sign(p,e.signingKey,m):e.signature,f=Be.resolveAll(Ai).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 Kl(M.serialize(l))}}var dp;(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"})(dp||(dp={}));ot.register(Eh,ql);ot.register(Ch,Dl);ot.register(Nh,Hl);ot.register(Bh,Si);ot.register(Pa,Xr);ot.register(Oh,cg);ot.register(Ma,ug);ot.register(Ta,dg);Do.register(ng,pg);Do.register(Ml,Fl);Be.registerSingleton(Ai,sy);Be.registerSingleton(Ai,nt);nt.namedCurveSize.set("P-256",32);nt.namedCurveSize.set("K-256",32);nt.namedCurveSize.set("P-384",48);nt.namedCurveSize.set("P-521",66);const pp="0123456789abcdef";function Hc(t){const e=new Uint8Array(t);let n="";for(let r=0;r<e.length;r++){const i=e[r]>>4;n+=pp[i];const s=e[r]&15;n+=pp[s]}return n}class fg{constructor(e,n){ee(this,"alphabet");ee(this,"padding");ee(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 o=0;o<i;o++){let c=0;const l=[];for(let p=0;p<8;p++){const h=e[o*8+p];if(h==="="){if(o+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 fg("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567");new fg("0123456789ABCDEFGHIJKLMNOPQRSTUV");class hg{constructor(e,n){ee(this,"alphabet");ee(this,"padding");ee(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 o=0;o<i;o++){let c=0,l=0;for(let u=0;u<4;u++){const p=e[o*4+u];if(p==="="){if(o+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 cy=new hg("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),yn=new hg("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_");class ly{constructor(e){ee(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 gg(t){return await crypto.subtle.digest("SHA-256",t)}async function Fc(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=Re(),i=Hc(new TextEncoder().encode(r)),s=await ay.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 ql(!0,2,!0),new Dl(["1.3.6.1.5.5.7.3.1"],!0),new Hl(qs.keyCertSign|qs.cRLSign,!0),await Si.create(n.publicKey)]}),o=await crypto.subtle.exportKey("pkcs8",n.privateKey),c=s.toString("pem"),l=await dy(s),u=Hc(await s.getThumbprint()),p=uy("PRIVATE",o);return{kid:s.serialNumber,cert:c,thumbprint:u,fingerprint:l,pkcs7:p}}function uy(t,e){const n=cy.encode(new Uint8Array(e));let r=`-----BEGIN ${t} KEY-----\r
|
|
145
|
+
`)}}Ze.CertificateTag="CERTIFICATE";Ze.CrlTag="CRL";Ze.CertificateRequestTag="CERTIFICATE REQUEST";Ze.PublicKeyTag="PUBLIC KEY";Ze.PrivateKeyTag="PRIVATE KEY";class Ut extends cn{static isAsnEncoded(e){return q.isBufferSource(e)||typeof e=="string"}static toArrayBuffer(e){if(typeof e=="string"){if(Ze.isPem(e))return Ze.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 Ze.isPem(n)?Ze.decode(n)[0]:J.isHex(n)?J.FromHex(n):J.isBase64(n)?J.FromBase64(n):J.isBase64Url(n)?J.FromBase64Url(n):q.toArrayBuffer(e)}}constructor(...e){Ut.isAsnEncoded(e[0])?super(Ut.toArrayBuffer(e[0]),e[1]):super(e[0])}toString(e="pem"){switch(e){case"pem":return Ze.encode(this.rawData,this.tag);default:return super.toString(e)}}}class pt extends Ut{static async create(e,n=Ne.get()){if(e instanceof pt)return e;if(Ht.isCryptoKey(e)){if(e.type!=="public")throw new TypeError("Public key is required");const r=await n.subtle.exportKey("spki",e);return new pt(r)}else{if(e.publicKey)return e.publicKey;if(q.isBufferSource(e))return new pt(e);throw new TypeError("Unsupported PublicKeyType")}}constructor(e){Ut.isAsnEncoded(e)?super(e,dt):super(e),this.tag=Ze.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]||Ne.get()):n=e[0]||Ne.get();let s=this.rawData;const o=M.parse(this.rawData,dt);return o.algorithm.algorithm===Br&&(s=Xv(o,s)),n.subtle.importKey("spki",s,i,!0,r)}onInit(e){const n=Be.resolve(Cn),r=this.algorithm=n.toWebAlgorithm(e.algorithm);switch(e.algorithm.algorithm){case En:{const i=M.parse(e.subjectPublicKey,Fl),s=q.toUint8Array(i.modulus);r.publicExponent=q.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]||Ne.get()):r=e[0]||Ne.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=Ne.get()):n=e[0]:e.length===2?(r=e[0],n=e[1]):n=Ne.get();const i=M.parse(this.rawData,dt);return await n.subtle.digest(r,i.subjectPublicKey)}toTextObject(){const e=this.toTextObjectEmpty(),n=M.parse(this.rawData,dt);switch(e.Algorithm=Nn.serializeAlgorithm(n.algorithm),n.algorithm.algorithm){case Fr:e["EC Point"]=n.subjectPublicKey;break;case En:default:e["Raw Data"]=n.subjectPublicKey}return e}}function Xv(t,e){return t.algorithm=new F({algorithm:En,parameters:null}),e=M.serialize(t),e}class Yr extends st{static async create(e,n=!1,r=Ne.get()){if("name"in e&&"serialNumber"in e)return new Yr(e,n);const s=await(await pt.create(e,r)).getKeyIdentifier(r);return new Yr(J.ToHex(s),n)}constructor(...e){if(q.isBufferSource(e[0]))super(e[0]);else if(typeof e[0]=="string"){const n=new gn({keyIdentifier:new El(J.FromHex(e[0]))});super(Va,e[1],M.serialize(n))}else{const n=e[0],r=n.name instanceof Jr?M.parse(n.name.rawData,Re):n.name,i=new gn({authorityCertIssuer:r,authorityCertSerialNumber:J.FromHex(n.serialNumber)});super(Va,e[1],M.serialize(i))}}onInit(e){super.onInit(e);const n=M.parse(e.extnValue,gn);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=M.parse(this.value,gn);return n.authorityCertIssuer&&(e["Authority Issuer"]=new Jr(n.authorityCertIssuer).toTextObject()),n.authorityCertSerialNumber&&(e["Authority Serial Number"]=n.authorityCertSerialNumber),n.keyIdentifier&&(e[""]=n.keyIdentifier),e}}Yr.NAME="Authority Key Identifier";class Jl extends st{constructor(...e){if(q.isBufferSource(e[0])){super(e[0]);const n=M.parse(this.value,ps);this.ca=n.cA,this.pathLength=n.pathLenConstraint}else{const n=new ps({cA:e[0],pathLenConstraint:e[1]});super(qh,e[2],M.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}}Jl.NAME="Basic Constraints";var mp;(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"})(mp||(mp={}));class Zl extends st{constructor(...e){if(q.isBufferSource(e[0])){super(e[0]);const n=M.parse(this.value,ms);this.usages=n.map(r=>r)}else{const n=new ms(e[0]);super(Fh,e[1],M.serialize(n)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.usages.map(n=>an.toString(n)).join(", "),e}}Zl.NAME="Extended Key Usages";var qs;(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"})(qs||(qs={}));class Yl extends st{constructor(...e){if(q.isBufferSource(e[0])){super(e[0]);const n=M.parse(this.value,ra);this.usages=n.toNumber()}else{const n=new ra(e[0]);super(Kh,e[1],M.serialize(n)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue(),n=M.parse(this.value,ra);return e[""]=n.toJSON().join(", "),e}}Yl.NAME="Key Usages";class ki extends st{static async create(e,n=!1,r=Ne.get()){const s=await(await pt.create(e,r)).getKeyIdentifier(r);return new ki(J.ToHex(s),n)}constructor(...e){if(q.isBufferSource(e[0])){super(e[0]);const n=M.parse(this.value,Wt);this.keyId=J.ToHex(n)}else{const n=typeof e[0]=="string"?J.FromHex(e[0]):e[0],r=new Wt(n);super(Zh,e[1],M.serialize(r)),this.keyId=J.ToHex(n)}}toTextObject(){const e=this.toTextObjectWithoutValue(),n=M.parse(this.value,Wt);return e[""]=n,e}}ki.NAME="Subject Key Identifier";class Sg extends st{constructor(...e){q.isBufferSource(e[0])?super(e[0]):super(Jh,e[1],new Jr(e[0]||[]).rawData)}onInit(e){super.onInit(e);const n=M.parse(e.extnValue,tc);this.names=new Jr(n)}toTextObject(){const e=this.toTextObjectWithoutValue(),n=this.names.toTextObject();for(const r in n)e[r]=n[r];return e}}Sg.NAME="Subject Alternative Name";class ot{static register(e,n){this.items.set(e,n)}static create(e){const n=new st(e),r=this.items.get(n.type);return r?new r(e):n}}ot.items=new Map;class Ag extends st{constructor(...e){var n;if(q.isBufferSource(e[0])){super(e[0]);const r=M.parse(this.value,hs);this.policies=r.map(i=>i.policyIdentifier)}else{const r=e[0],i=(n=e[1])!==null&&n!==void 0?n:!1,s=new hs(r.map(o=>new xo({policyIdentifier:o})));super(Dh,i,M.serialize(s)),this.policies=r}}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map(n=>new ue("",{},an.toString(n))),e}}Ag.NAME="Certificate Policies";ot.register(Dh,Ag);class Eg extends st{constructor(...e){var n;if(q.isBufferSource(e[0]))super(e[0]);else if(Array.isArray(e[0])&&typeof e[0][0]=="string"){const i=e[0].map(o=>new dr({distributionPoint:new kn({fullName:[new re({uniformResourceIdentifier:o})]})})),s=new Kn(i);super(Fa,e[1],M.serialize(s))}else{const r=new Kn(e[0]);super(Fa,e[1],M.serialize(r))}(n=this.distributionPoints)!==null&&n!==void 0||(this.distributionPoints=[])}onInit(e){super.onInit(e);const n=M.parse(e.extnValue,Kn);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 Ft(s).toString()).join(", ")),n.reasons&&(i.Reasons=n.reasons.toString()),n.cRLIssuer&&(i["CRL Issuer"]=n.cRLIssuer.map(s=>s.toString()).join(", ")),i}),e}}Eg.NAME="CRL Distribution Points";class Ig extends st{constructor(...e){var n,r,i,s;if(q.isBufferSource(e[0]))super(e[0]);else if(e[0]instanceof Dn){const o=new Dn(e[0]);super(Ua,e[1],M.serialize(o))}else{const o=e[0],c=new Dn;Bi(c,o,Qu,"ocsp"),Bi(c,o,ed,"caIssuers"),Bi(c,o,td,"timeStamping"),Bi(c,o,nd,"caRepository"),super(Ua,e[1],M.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=[],M.parse(e.extnValue,Dn).forEach(r=>{switch(r.accessMethod){case Qu:this.ocsp.push(new Ft(r.accessLocation));break;case ed:this.caIssuers.push(new Ft(r.accessLocation));break;case td:this.timeStamping.push(new Ft(r.accessLocation));break;case nd:this.caRepository.push(new Ft(r.accessLocation));break}})}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ocsp.length&&Oi(e,"OCSP",this.ocsp),this.caIssuers.length&&Oi(e,"CA Issuers",this.caIssuers),this.timeStamping.length&&Oi(e,"Time Stamping",this.timeStamping),this.caRepository.length&&Oi(e,"CA Repository",this.caRepository),e}}Ig.NAME="Authority Info Access";function Oi(t,e,n){if(n.length===1)t[e]=n[0].toTextObject();else{const r=new ue("");n.forEach((i,s)=>{const o=i.toTextObject(),c=`${o[ue.NAME]} ${s+1}`;let l=r[c];Array.isArray(l)||(l=[],r[c]=l),l.push(o)}),t[e]=r}}function Bi(t,e,n,r){const i=e[r];i&&(Array.isArray(i)?i:[i]).forEach(o=>{typeof o=="string"&&(o=new Ft("url",o)),t.push(new li({accessMethod:n,accessLocation:M.parse(o.rawData,re)}))})}class yr extends cn{constructor(...e){let n;if(q.isBufferSource(e[0]))n=q.toArrayBuffer(e[0]);else{const r=e[0],i=Array.isArray(e[1])?e[1].map(s=>q.toArrayBuffer(s)):[];n=M.serialize(new Pt({type:r,values:i}))}super(n,Pt)}onInit(e){this.type=e.type,this.values=e.values}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Value=this.values.map(n=>new ue("",{"":n})),e}toTextObjectWithoutValue(){const e=this.toTextObjectEmpty();return e[ue.NAME]===yr.NAME&&(e[ue.NAME]=an.toString(this.type)),e}}yr.NAME="Attribute";class zg extends yr{constructor(...e){var n;if(q.isBufferSource(e[0]))super(e[0]);else{const r=new Vs({printableString:e[0]});super(yg,[M.serialize(r)])}(n=this.password)!==null&&n!==void 0||(this.password="")}onInit(e){if(super.onInit(e),this.values[0]){const n=M.parse(this.values[0],Vs);this.password=n.toString()}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[ue.VALUE]=this.password,e}}zg.NAME="Challenge Password";class Xl extends yr{constructor(...e){var n;if(q.isBufferSource(e[0]))super(e[0]);else{const r=e[0],i=new Xt;for(const s of r)i.push(M.parse(s.rawData,rt));super(Gl,[M.serialize(i)])}(n=this.items)!==null&&n!==void 0||(this.items=[])}onInit(e){if(super.onInit(e),this.values[0]){const n=M.parse(this.values[0],Xt);this.items=n.map(r=>ot.create(M.serialize(r)))}}toTextObject(){const e=this.toTextObjectWithoutValue(),n=this.items.map(r=>r.toTextObject());for(const r of n)e[r[ue.NAME]]=r;return e}}Xl.NAME="Extensions";class Ko{static register(e,n){this.items.set(e,n)}static create(e){const n=new yr(e),r=this.items.get(n.type);return r?new r(e):n}}Ko.items=new Map;const xi="crypto.signatureFormatter";class Qv{toAsnSignature(e,n){return q.toArrayBuffer(n)}toWebSignature(e,n){return q.toArrayBuffer(n)}}var qi;let Fc=qi=class{static createPssParams(e,n){const r=qi.getHashAlgorithm(e);return r?new zn({hashAlgorithm:r,maskGenAlgorithm:new F({algorithm:Ro,parameters:M.serialize(r)}),saltLength:n}):null}static getHashAlgorithm(e){const n=Be.resolve(Cn);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:Ns,parameters:null});case"sha-256":return new F({algorithm:kc,parameters:null});case"sha-384":return new F({algorithm:js,parameters:null});case"sha-512":return new F({algorithm:$s,parameters:null})}}else return new F({algorithm:En,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=qi.createPssParams(e.hash,e.saltLength);if(!n)throw new Error("Cannot create PSS parameters");return new F({algorithm:Br,parameters:M.serialize(n)})}else return new F({algorithm:Br,parameters:null})}return null}toWebAlgorithm(e){switch(e.algorithm){case En:return{name:"RSASSA-PKCS1-v1_5"};case Ns:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case kc:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case js:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case $s:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}};case Br:if(e.parameters){const n=M.parse(e.parameters,zn);return{name:"RSA-PSS",hash:Be.resolve(Cn).toWebAlgorithm(n.hashAlgorithm),saltLength:n.saltLength}}else return{name:"RSA-PSS"}}return null}};Fc=qi=d([Mo()],Fc);Be.registerSingleton(bi,Fc);let Kc=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"sha-1":return new F({algorithm:Os});case"sha-256":return new F({algorithm:Bs});case"sha-384":return new F({algorithm:Ts});case"sha-512":return new F({algorithm:Ps})}return null}toWebAlgorithm(e){switch(e.algorithm){case Os:return{name:"SHA-1"};case Bs:return{name:"SHA-256"};case Ts:return{name:"SHA-384"};case Ps:return{name:"SHA-512"}}return null}};Kc=d([Mo()],Kc);Be.registerSingleton(bi,Kc);class nt{addPadding(e,n){const r=q.toUint8Array(n),i=new Uint8Array(e);return i.set(r,e-r.length),i}removePadding(e,n=!1){let r=q.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=nt.namedCurveSize.get(r)||nt.defaultNamedCurveSize,s=new Cs,o=q.toUint8Array(n);return s.r=this.removePadding(o.slice(0,i),!0),s.s=this.removePadding(o.slice(i,i+i),!0),M.serialize(s)}return null}toWebSignature(e,n){if(e.name==="ECDSA"){const r=M.parse(n,Cs),i=e.namedCurve,s=nt.namedCurveSize.get(i)||nt.defaultNamedCurveSize,o=this.addPadding(s,this.removePadding(r.r)),c=this.addPadding(s,this.removePadding(r.s));return py(o,c)}return null}}nt.namedCurveSize=new Map;nt.defaultNamedCurveSize=32;const da="1.3.101.110",_p="1.3.101.111",pa="1.3.101.112",yp="1.3.101.113";let Wc=class{toAsnAlgorithm(e){let n=null;switch(e.name.toLowerCase()){case"ed25519":n=pa;break;case"x25519":n=da;break;case"eddsa":switch(e.namedCurve.toLowerCase()){case"ed25519":n=pa;break;case"ed448":n=yp;break}break;case"ecdh-es":switch(e.namedCurve.toLowerCase()){case"x25519":n=da;break;case"x448":n=_p;break}}return n?new F({algorithm:n}):null}toWebAlgorithm(e){switch(e.algorithm){case pa:return{name:"Ed25519"};case yp:return{name:"EdDSA",namedCurve:"Ed448"};case da:return{name:"X25519"};case _p:return{name:"ECDH-ES",namedCurve:"X448"}}return null}};Wc=d([Mo()],Wc);Be.registerSingleton(bi,Wc);class ew extends Ut{constructor(e){Ut.isAsnEncoded(e)?super(e,Wr):super(e),this.tag=Ze.CertificateRequestTag}onInit(e){this.tbs=M.serialize(e.certificationRequestInfo),this.publicKey=new pt(e.certificationRequestInfo.subjectPKInfo);const n=Be.resolve(Cn);this.signatureAlgorithm=n.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signature,this.attributes=e.certificationRequestInfo.attributes.map(i=>Ko.create(M.serialize(i)));const r=this.getAttribute(Gl);this.extensions=[],r instanceof Xl&&(this.extensions=r.items),this.subjectName=new tt(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=Ne.get()){const n={...this.publicKey.algorithm,...this.signatureAlgorithm},r=await this.publicKey.export(n,["verify"],e),i=Be.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=M.parse(this.rawData,Wr),r=n.certificationRequestInfo,i=new ue("",{Version:`${xn[r.version]} (${r.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){const s=new ue("");for(const o of this.attributes){const c=o.toTextObject();s[c[ue.NAME]]=c}i.Attributes=s}return e.Data=i,e.Signature=new ue("",{Algorithm:Nn.serializeAlgorithm(n.signatureAlgorithm),"":n.signature}),e}}ew.NAME="PKCS#10 Certificate Request";class Ql extends Ut{constructor(e){Ut.isAsnEncoded(e)?super(e,Sn):super(e),this.tag=Ze.CertificateTag}onInit(e){const n=e.tbsCertificate;this.tbs=M.serialize(n),this.serialNumber=J.ToHex(n.serialNumber),this.subjectName=new tt(n.subject),this.subject=new tt(n.subject).toString(),this.issuerName=new tt(n.issuer),this.issuer=this.issuerName.toString();const r=Be.resolve(Cn);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(o=>ot.create(M.serialize(o)))),this.publicKey=new pt(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=Ne.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 pt)r={...s.algorithm,...this.signatureAlgorithm},i=await s.export(r,["verify"],n);else if(q.isBufferSource(s)){const u=new pt(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 o=Be.resolveAll(xi).reverse();let c=null;for(const u of o)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=Ne.get()),await n.subtle.digest(r,this.rawData)}async isSelfSigned(e=Ne.get()){return this.subject===this.issuer&&await this.verify({signatureOnly:!0},e)}toTextObject(){const e=this.toTextObjectEmpty(),n=M.parse(this.rawData,Sn),r=n.tbsCertificate,i=new ue("",{Version:`${xn[r.version]} (${r.version})`,"Serial Number":r.serialNumber,"Signature Algorithm":Nn.serializeAlgorithm(r.signature),Issuer:this.issuer,Validity:new ue("",{"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 ue("");for(const o of this.extensions){const c=o.toTextObject();s[c[ue.NAME]]=c}i.Extensions=s}return e.Data=i,e.Signature=new ue("",{Algorithm:Nn.serializeAlgorithm(n.signatureAlgorithm),"":n.signatureValue}),e}}Ql.NAME="Certificate";class tw{static async createSelfSigned(e,n=Ne.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=Ne.get()){var r;let i;e.publicKey instanceof pt?i=e.publicKey.rawData:"publicKey"in e.publicKey?i=e.publicKey.publicKey.rawData:q.isBufferSource(e.publicKey)?i=e.publicKey:i=await n.subtle.exportKey("spki",e.publicKey);const s=e.serialNumber?q.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 o=e.notBefore||new Date,c=e.notAfter||new Date(o.getTime()+31536e6),l=new Sn({tbsCertificate:new Xe({version:xn.v3,serialNumber:s,validity:new ui({notBefore:o,notAfter:c}),extensions:new Xt(((r=e.extensions)===null||r===void 0?void 0:r.map(w=>M.parse(w.rawData,rt)))||[]),subjectPublicKeyInfo:M.parse(i,dt)})});if(e.subject){const w=e.subject instanceof tt?e.subject:new tt(e.subject);l.tbsCertificate.subject=M.parse(w.toArrayBuffer(),ke)}if(e.issuer){const w=e.issuer instanceof tt?e.issuer:new tt(e.issuer);l.tbsCertificate.issuer=M.parse(w.toArrayBuffer(),ke)}const u={hash:"SHA-256"},p="signingKey"in e?{...u,...e.signingAlgorithm,...e.signingKey.algorithm}:{...u,...e.signingAlgorithm},h=Be.resolve(Cn);l.tbsCertificate.signature=l.signatureAlgorithm=h.toAsnAlgorithm(p);const m=M.serialize(l.tbsCertificate),v="signingKey"in e?await n.subtle.sign(p,e.signingKey,m):e.signature,f=Be.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 Ql(M.serialize(l))}}var vp;(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"})(vp||(vp={}));ot.register(qh,Jl);ot.register(Fh,Zl);ot.register(Kh,Yl);ot.register(Zh,ki);ot.register(Va,Yr);ot.register(Jh,Sg);ot.register(Fa,Eg);ot.register(Ua,Ig);Ko.register(yg,zg);Ko.register(Gl,Xl);Be.registerSingleton(xi,Qv);Be.registerSingleton(xi,nt);nt.namedCurveSize.set("P-256",32);nt.namedCurveSize.set("K-256",32);nt.namedCurveSize.set("P-384",48);nt.namedCurveSize.set("P-521",66);async function Gc(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=qe(),i=Ia(new TextEncoder().encode(r)),s=await tw.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 Jl(!0,2,!0),new Zl(["1.3.6.1.5.5.7.3.1"],!0),new Yl(qs.keyCertSign|qs.cRLSign,!0),await ki.create(n.publicKey)]}),o=await crypto.subtle.exportKey("pkcs8",n.privateKey),c=s.toString("pem"),l=await rw(s),u=Ia(await s.getThumbprint()),p=nw("PRIVATE",o);return{kid:s.serialNumber,cert:c,thumbprint:u,fingerprint:l,pkcs7:p}}function nw(t,e){const n=f_.encode(new Uint8Array(e));let r=`-----BEGIN ${t} KEY-----\r
|
|
122
146
|
`,i=0;for(;i<n.length;)i+64<=n.length?r+=n.substr(i,64)+`\r
|
|
123
147
|
`:r+=n.substr(i)+`\r
|
|
124
148
|
`,i+=64;return r+=`-----END ${t} KEY-----\r
|
|
125
|
-
`,r}async function dy(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 Hc(await gg(s))}const py=1e3*60*60*24,fy=new a.OpenAPIHono().openapi(a.createRoute({tags:["keys"],method:"get",path:"/signing",request:{headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:a.z.array(Ea)}},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(a.createRoute({tags:["keys"],method:"get",path:"/signing/{kid}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({kid:a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Ea}},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 C(404,{message:"Key not found"});return t.json(r)}).openapi(a.createRoute({tags:["keys"],method:"post",path:"/signing/rotate",request:{headers:a.z.object({"tenant-id":a.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()+py).toISOString()});const n=await Fc({name:`CN=${t.env.ORGANIZATION_NAME}`});return await t.env.data.keys.create(n),t.text("OK",{status:201})}).openapi(a.createRoute({tags:["keys"],method:"put",path:"/signing/{kid}/revoke",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({kid:a.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 C(404,{message:"Key not found"});const r=await Fc({name:`CN=${t.env.ORGANIZATION_NAME}`});return await t.env.data.keys.create(r),t.text("OK")}),hy=new a.OpenAPIHono().openapi(a.createRoute({tags:["users"],method:"get",path:"/",request:{query:a.z.object({email:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:a.z.array(Qc)}},description:"List of users"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{email:n}=t.req.valid("query"),i=(await Xs(t.env.data.users,e,n)).filter(s=>!s.linked_to);return t.json(i)}),gy=nn.extend({clients:a.z.array(pn)}),my=new a.OpenAPIHono().openapi(a.createRoute({tags:["clients"],method:"get",path:"/",request:{query:Yt,headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:a.z.union([gy,a.z.array(pn)])}},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:o}=t.req.valid("query"),l=(await t.env.data.applications.list(e,{page:n,per_page:r,include_totals:i,sort:ur(s),q:o})).applications;return i?t.json({clients:l,start:0,limit:10,length:l.length}):t.json(l)}).openapi(a.createRoute({tags:["clients"],method:"get",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:pn}},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 C(404);return t.json(i)}).openapi(a.createRoute({tags:["clients"],method:"delete",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.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 C(404,{message:"Application not found"});return t.text("OK")}).openapi(a.createRoute({tags:["clients"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:a.z.object(rs.shape).partial()}}},params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:pn}},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 C(404,{message:"Application not found"});return t.json(s)}).openapi(a.createRoute({tags:["clients"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:a.z.object(rs.shape)}}},headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:a.z.object(pn.shape)}},description:"An application"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),r={...n,id:n.id||Re(),client_secret:n.client_secret||Re()},i=await t.env.data.applications.create(e,r);return t.json(i,{status:201})});a.z.object({start:a.z.number(),limit:a.z.number(),length:a.z.number()});Js.extend({email:a.z.string(),login_count:a.z.number(),multifactor:a.z.array(a.z.string()).optional(),last_ip:a.z.string().optional(),last_login:a.z.string().optional(),user_id:a.z.string()}).catchall(a.z.any());const _y=nn.extend({tenants:a.z.array(Fn)}),yy=new a.OpenAPIHono().openapi(a.createRoute({tags:["tenants"],method:"get",path:"/",request:{query:Yt},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:a.z.union([a.z.array(Fn),_y])}},description:"List of tenants"}}}),async t=>{const{page:e,per_page:n,include_totals:r,sort:i,q:s}=t.req.valid("query"),o=await t.env.data.tenants.list({page:e,per_page:n,include_totals:r,sort:ur(i),q:s});return r?t.json(o):t.json(o.tenants)}).openapi(a.createRoute({tags:["tenants"],method:"get",path:"/{id}",request:{params:a.z.object({id:a.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 C(404);return t.json(n)}).openapi(a.createRoute({tags:["tenants"],method:"delete",path:"/{id}",request:{params:a.z.object({id:a.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(a.createRoute({tags:["tenants"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:a.z.object(ss.shape).partial()}}},params:a.z.object({id:a.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(a.createRoute({tags:["tenants"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:a.z.object(ss.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})}),vy=nn.extend({logs:a.z.array(as)}),wy=new a.OpenAPIHono().openapi(a.createRoute({tags:["logs"],method:"get",path:"/",request:{query:Yt,headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:a.z.union([a.z.array(as),vy])}},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":o}=t.req.valid("header"),c=await t.env.data.logs.list(o,{page:e,per_page:n,include_totals:r,sort:ur(i),q:s});return r?t.json(c):t.json(c.logs)}).openapi(a.createRoute({tags:["logs"],method:"get",path:"/{id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({id:a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:as}},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 C(404);return t.json(r)}),by=nn.extend({hooks:a.z.array(Dn)}),ky=new a.OpenAPIHono().openapi(a.createRoute({tags:["hooks"],method:"get",path:"/",request:{query:Yt,headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:a.z.union([a.z.array(Dn),by])}},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:o}=t.req.valid("query"),c=await t.env.data.hooks.list(e,{page:n,per_page:r,include_totals:i,sort:ur(s),q:o});return i?t.json(c):t.json(c.hooks)}).openapi(a.createRoute({tags:["hooks"],method:"post",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.object(os.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(a.createRoute({tags:["hooks"],method:"patch",path:"/{hook_id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({hook_id:a.z.string()}),body:{content:{"application/json":{schema:a.z.object(os.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 C(404,{message:"Hook not found"});return t.json(i)}).openapi(a.createRoute({tags:["hooks"],method:"get",path:"/{hook_id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({hook_id:a.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 C(404,{message:"Hook not found"});return t.json(r)}).openapi(a.createRoute({tags:["hooks"],method:"delete",path:"/{hook_id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({hook_id:a.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 C(404,{message:"Hook not found"});return t.text("OK")}),xy=nn.extend({connections:a.z.array(Dt)}),Sy=new a.OpenAPIHono().openapi(a.createRoute({tags:["connections"],method:"get",path:"/",request:{query:Yt,headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:a.z.union([a.z.array(Dt),xy])}},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:o}=t.req.valid("query"),c=await t.env.data.connections.list(e,{page:n,per_page:r,include_totals:i,sort:ur(s),q:o});return i?t.json(c):t.json(c.connections)}).openapi(a.createRoute({tags:["connections"],method:"get",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Dt}},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 C(404);return t.json(r)}).openapi(a.createRoute({tags:["connections"],method:"delete",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.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 C(404,{message:"Connection not found"});return t.text("OK")}).openapi(a.createRoute({tags:["connections"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:a.z.object(is.shape).partial()}}},params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Dt}},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 C(404,{message:"Connection not found"});const s=await t.env.data.connections.get(e,n);if(!s)throw new C(404,{message:"Connection not found"});return t.json(s)}).openapi(a.createRoute({tags:["connections"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:a.z.object(is.shape)}}},headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Dt}},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})}),Ay=new a.OpenAPIHono().openapi(a.createRoute({tags:["prompts"],method:"get",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Ui}},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(Ui.parse({}))}).openapi(a.createRoute({tags:["prompts"],method:"patch",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.object(Ui.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 fp=!1;function mg(t){t.use(async(e,n)=>(fp||(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"}}}}),fp=!0),await n()))}a.z.object({alg:a.z.literal("RS256"),kty:a.z.literal("RSA"),use:a.z.literal("sig"),n:a.z.string(),e:a.z.string(),kid:a.z.string(),x5t:a.z.string(),x5c:a.z.array(a.z.string())});async function Ey(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 C(500,{message:`Failed to fetch jwks: ${e.message}`})}}async function Iy(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))),o=(await Ey(t.env)).find(l=>l.kid===e.header.kid);if(!o)return console.log("No matching kid found"),!1;const c=await crypto.subtle.importKey("jwk",o,{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},!1,["verify"]);return crypto.subtle.verify("RSASSA-PKCS1-v1_5",c,i,r)}function zy(t){const[e,n,r]=t.split(".");if(!e||!n||!r)return null;const i=JSON.parse(atob(e)),s=JSON.parse(atob(n)),o=atob(r.replace(/-/g,"+").replace(/_/g,"/"));return{header:i,payload:s,signature:o,raw:{header:e,payload:n,signature:r}}}function _g(t){return async(e,n)=>{var i,s,o;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 C(401,{message:"Missing bearer token"});const h=zy(p);if(!h||!await Iy(e,h))throw new C(403,{message:"Invalid JWT signature"});e.set("user_id",h.payload.sub),e.set("user",h.payload);const m=h.payload.permissions||[],v=((o=h.payload.scope)==null?void 0:o.split(" "))||[];if(c.length&&!(c.some(f=>m.includes(f))||c.some(f=>v.includes(f))))throw new C(403,{message:"Unauthorized"})}return await n()}}const Cy=new a.OpenAPIHono().openapi(a.createRoute({tags:["emails"],method:"get",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Vi}},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 C(404,{message:"Email provider not found"});return t.json(n)}).openapi(a.createRoute({tags:["emails"],method:"post",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.object(Vi.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(a.createRoute({tags:["emails"],method:"patch",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.object(Vi.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")}),Ny=new a.OpenAPIHono().openapi(a.createRoute({tags:["sessions"],method:"get",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.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 C(404);return t.json(r)}).openapi(a.createRoute({tags:["sessions"],method:"delete",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.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 C(404,{message:"Session not found"});return t.text("OK")}).openapi(a.createRoute({tags:["sessions"],method:"post",path:"/{id}/revoke",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.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 C(404,{message:"Session not found"});return t.text("Session deletion request accepted.",{status:202})}),jy=new a.OpenAPIHono().openapi(a.createRoute({tags:["refresh_tokens"],method:"get",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:rl}},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 C(404);return t.json(r)}).openapi(a.createRoute({tags:["refresh_tokens"],method:"delete",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.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 C(404,{message:"Session not found"});return t.text("OK")}),$y=new a.OpenAPIHono().openapi(a.createRoute({tags:["custom-domains"],method:"get",path:"/",request:{query:Yt,headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:a.z.array(qn)}},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(a.createRoute({tags:["custom-domains"],method:"get",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:qn}},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 C(404);return t.json(r)}).openapi(a.createRoute({tags:["custom-domains"],method:"delete",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.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 C(404,{message:"Custom domain not found"});return t.text("OK")}).openapi(a.createRoute({tags:["custom-domains"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:a.z.object(qn.shape).partial()}}},params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:qn}},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 C(404);const s=await t.env.data.customDomains.get(e,n);if(!s)throw new C(404);return t.json(s)}).openapi(a.createRoute({tags:["custom-domains"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:a.z.object(tl.shape)}}},headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:qn}},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})});function Oy(){const t=new a.OpenAPIHono;mg(t),t.use(_g(t));const e=t.route("/branding",Ym).route("/custom-domains",$y).route("/email/providers",Cy).route("/users",f_).route("/keys",fy).route("/users-by-email",hy).route("/clients",my).route("/tenants",yy).route("/logs",wy).route("/hooks",ky).route("/connections",Sy).route("/prompts",Ay).route("/sessions",Ny).route("/refresh_tokens",jy);return e.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Management api"},security:[{oauth2:["openid","email","profile"]}]}),e}function By(t,e){Object.keys(e).forEach(n=>{const r=e[n];r!=null&&r.length&&t.searchParams.set(n,r)})}function Tn(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 Pi=60*5,Ho=30*24*60*60,Qr=24*60*60,Ty="auth-token",Kc=30*60*1e3,Py=5*60,Ry=5*60,Ly=30*60*1e3,Uy=30*60*1e3,Vy=24*60*60*1e3;var hp;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(hp||(hp={}));var gp;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(gp||(gp={}));function My(t){return vg(t,qy,ei.Include)}function yg(t){return vg(t,Dy,ei.None)}function vg(t,e,n){let r="";for(let i=0;i<t.byteLength;i+=3){let s=0,o=0;for(let c=0;c<3&&i+c<t.byteLength;c++)s=s<<8|t[i+c],o+=8;for(let c=0;c<4;c++)o>=6?(r+=e[s>>o-6&63],o-=6):o>0?(r+=e[s<<6-o&63],o=0):n===ei.Include&&(r+="=")}return r}const qy="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Dy="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";var ei;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(ei||(ei={}));var mp;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(mp||(mp={}));class Hy{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 _p=new Hy;function wt(t,e){return(t<<32-e|t>>>e)>>>0}function Fy(t){const e=new Ky;return e.update(t),e.digest()}class Ky{constructor(){ee(this,"blockSize",64);ee(this,"size",32);ee(this,"blocks",new Uint8Array(64));ee(this,"currentBlockSize",0);ee(this,"H",new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]));ee(this,"l",0n);ee(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),_p.putUint64(this.blocks,this.l,this.blockSize-8),this.process();const e=new Uint8Array(32);for(let n=0;n<8;n++)_p.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=(wt(this.w[u-2],17)^wt(this.w[u-2],19)^this.w[u-2]>>>10)>>>0,h=(wt(this.w[u-15],7)^wt(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],o=this.H[5],c=this.H[6],l=this.H[7];for(let u=0;u<64;u++){const p=(wt(s,6)^wt(s,11)^wt(s,25))>>>0,h=(s&o^~s&c)>>>0,m=l+p+h+Wy[u]+this.w[u]|0,v=(wt(e,2)^wt(e,13)^wt(e,22))>>>0,f=(e&n^e&r^n&r)>>>0,_=v+f|0;l=c,c=o,o=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]=o+this.H[5]|0,this.H[6]=c+this.H[6]|0,this.H[7]=l+this.H[7]|0}}const Wy=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 Gy{constructor(e){ee(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 Jy(t){const e=Fy(new TextEncoder().encode(t));return yg(e)}function Zy(){const t=new Uint8Array(32);return crypto.getRandomValues(t),yg(t)}function Lr(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 fa(t,e){const n=new TextEncoder().encode(`${t}:${e}`);return My(n)}async function Ds(t){let e;try{e=await fetch(t)}catch(n){throw new bg(n)}if(e.status===400||e.status===401){let n;try{n=await e.json()}catch{throw new Fi(e.status)}if(typeof n!="object"||n===null)throw new Gn(e.status,n);let r;try{r=wg(n)}catch{throw new Gn(e.status,n)}throw r}if(e.status===200){let n;try{n=await e.json()}catch{throw new Fi(e.status)}if(typeof n!="object"||n===null)throw new Gn(e.status,n);return new Gy(n)}throw e.body!==null&&await e.body.cancel(),new Fi(e.status)}async function Yy(t){let e;try{e=await fetch(t)}catch(n){throw new bg(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=wg(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 Fi(e.status)}function wg(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 Xy(e,n,r,i)}class bg extends Error{constructor(e){super("Failed to send request",{cause:e})}}class Xy extends Error{constructor(n,r,i,s){super(`OAuth request error: ${n}`);ee(this,"code");ee(this,"description");ee(this,"uri");ee(this,"state");this.code=n,this.description=r,this.uri=i,this.state=s}}class Fi extends Error{constructor(n){super("Unexpected error response");ee(this,"status");this.status=n}}class Gn extends Error{constructor(n,r){super("Unexpected error response body");ee(this,"status");ee(this,"data");this.status=n,this.data=r}}class Wl{constructor(e,n,r){ee(this,"clientId");ee(this,"clientPassword");ee(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 o=new URL(e);if(o.searchParams.set("response_type","code"),o.searchParams.set("client_id",this.clientId),this.redirectURI!==null&&o.searchParams.set("redirect_uri",this.redirectURI),o.searchParams.set("state",n),r===ti.S256){const c=Jy(i);o.searchParams.set("code_challenge_method","S256"),o.searchParams.set("code_challenge",c)}else r===ti.Plain&&(o.searchParams.set("code_challenge_method","plain"),o.searchParams.set("code_challenge",i));return s.length>0&&o.searchParams.set("scope",s.join(" ")),o}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=Lr(e,i);if(this.clientPassword!==null){const c=fa(this.clientId,this.clientPassword);s.headers.set("Authorization",`Basic ${c}`)}return await Ds(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=Lr(e,i);if(this.clientPassword!==null){const c=fa(this.clientId,this.clientPassword);s.headers.set("Authorization",`Basic ${c}`)}return await Ds(s)}async revokeToken(e,n){const r=new URLSearchParams;r.set("token",n),this.clientPassword===null&&r.set("client_id",this.clientId);const i=Lr(e,r);if(this.clientPassword!==null){const s=fa(this.clientId,this.clientPassword);i.headers.set("Authorization",`Basic ${s}`)}await Yy(i)}}var ti;(function(t){t[t.S256=0]="S256",t[t.Plain=1]="Plain"})(ti||(ti={}));var yp;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(yp||(yp={}));var vp;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(vp||(vp={}));function Ur(t){return Qy(t,ev,Hs.None)}function Qy(t,e,n){let r="";for(let i=0;i<t.byteLength;i+=3){let s=0,o=0;for(let c=0;c<3&&i+c<t.byteLength;c++)s=s<<8|t[i+c],o+=8;for(let c=0;c<4;c++)o>=6?(r+=e[s>>o-6&63],o-=6):o>0?(r+=e[s<<6-o&63],o=0):n===Hs.Include&&(r+="=")}return r}const ev="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";var Hs;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(Hs||(Hs={}));var wp;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(wp||(wp={}));function tv(t,e,n){const r=Ur(new TextEncoder().encode(t)),i=Ur(new TextEncoder().encode(e)),s=Ur(n);return r+"."+i+"."+s}function nv(t,e){const n=Ur(new TextEncoder().encode(t)),r=Ur(new TextEncoder().encode(e)),i=n+"."+r;return new TextEncoder().encode(i)}const rv="https://appleid.apple.com/auth/authorize",iv="https://appleid.apple.com/auth/token";class kg{constructor(e,n,r,i,s){ee(this,"clientId");ee(this,"teamId");ee(this,"keyId");ee(this,"pkcs8PrivateKey");ee(this,"redirectURI");this.clientId=e,this.teamId=n,this.keyId=r,this.pkcs8PrivateKey=i,this.redirectURI=s}createAuthorizationURL(e,n){const r=new URL(rv);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=Lr(iv,n);return await Ds(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,nv(r,i)));return tv(r,i,s)}}const sv="https://www.facebook.com/v16.0/dialog/oauth",ov="https://graph.facebook.com/v16.0/oauth/access_token";class xg{constructor(e,n,r){ee(this,"clientId");ee(this,"clientSecret");ee(this,"redirectURI");this.clientId=e,this.clientSecret=n,this.redirectURI=r}createAuthorizationURL(e,n){const r=new URL(sv);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=Lr(ov,n);return await Ds(r)}}const av="https://accounts.google.com/o/oauth2/v2/auth",bp="https://oauth2.googleapis.com/token",cv="https://oauth2.googleapis.com/revoke";let Sg=class{constructor(e,n,r){ee(this,"client");this.client=new Wl(e,n,r)}createAuthorizationURL(e,n,r){return this.client.createAuthorizationURLWithPKCE(av,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(cv,e)}};class Gl{constructor(e,n){ee(this,"value");ee(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 Gl(Math.round(this.milliseconds()*e),"ms")}}async function kp(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 o=new TextEncoder,c=yn.encode(o.encode(JSON.stringify(i)),{includePadding:!1}),l=yn.encode(o.encode(JSON.stringify(s)),{includePadding:!1}),u=o.encode([c,l].join(".")),p=await uv(t).sign(e,u),h=yn.encode(new Uint8Array(p),{includePadding:!1});return[c,l,h].join(".")}function lv(t){const e=t.split(".");return e.length!==3?null:e}function Jl(t){const e=lv(t);if(!e)return null;const n=new TextDecoder,r=yn.decode(e[0],{strict:!1}),i=yn.decode(e[1],{strict:!1}),s=JSON.parse(n.decode(r));if(typeof s!="object"||s===null||!("alg"in s)||!dv(s.alg)||"typ"in s&&s.typ!=="JWT")return null;const o=JSON.parse(n.decode(i));if(typeof o!="object"||o===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 o){if(typeof o.exp!="number")return null;c.expiresAt=new Date(o.exp*1e3)}if("iss"in o){if(typeof o.iss!="string")return null;c.issuer=o.iss}if("sub"in o){if(typeof o.sub!="string")return null;c.subject=o.sub}if("aud"in o)if(Array.isArray(o.aud)){for(const l of o.aud)if(typeof l!="string")return null;c.audiences=o.aud}else{if(typeof o.aud!="string")return null;c.audiences=[o.aud]}if("nbf"in o){if(typeof o.nbf!="number")return null;c.notBefore=new Date(o.nbf*1e3)}if("iat"in o){if(typeof o.iat!="number")return null;c.issuedAt=new Date(o.iat*1e3)}if("jti"in o){if(typeof o.jti!="string")return null;c.jwtId=o.jti}return{value:t,header:{...s,typ:"JWT",alg:s.alg},payload:{...o},parts:e,...c}}function uv(t){return new ly(pv[t])}function dv(t){return typeof t!="string"?!1:["HS256","HS384","HS512","RS256","RS384","RS512","ES256","ES384","ES512","PS256","PS384","PS512"].includes(t)}const pv={RS256:"SHA-256",RS384:"SHA-384",RS512:"SHA-512"},Fo=a.z.object({iss:a.z.string().url(),sub:a.z.string(),aud:a.z.string(),exp:a.z.number(),email:a.z.string().optional(),given_name:a.z.string().optional(),family_name:a.z.string().optional(),name:a.z.string().optional(),iat:a.z.number(),auth_time:a.z.number().optional(),nonce:a.z.string().optional(),acr:a.z.string().optional(),amr:a.z.array(a.z.string()).optional(),azp:a.z.string().optional(),at_hash:a.z.string().optional(),c_hash:a.z.string().optional()}).passthrough();Fo.omit({iat:!0,auth_time:!0,nonce:!0,acr:!0,amr:!0,azp:!0,at_hash:!0,c_hash:!0});function fv(t){return t.ISSUER}function At(t){return t.UNIVERSAL_LOGIN_URL||`${t.ISSUER}u/`}function Ce(t){return t.OAUTH_API_URL||t.ISSUER}function Ag(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 hv(t,e){var l,u;const{options:n,keyArray:r}=Ag(e),i=new kg(n.client_id,n.team_id,n.kid,r,`${Ce(t.env)}callback`),s=Re(),o=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))&&o.searchParams.set("response_mode","form_post"),{redirectUrl:o.href,code:s}}async function gv(t,e,n){const{options:r,keyArray:i}=Ag(e),o=await new kg(r.client_id,r.team_id,r.kid,i,`${Ce(t.env)}callback`).validateAuthorizationCode(n),c=Jl(o.idToken());if(!c)throw new Error("Invalid ID token");const l=Fo.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 mv=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:hv,validateAuthorizationCodeAndGetUser:gv},Symbol.toStringTag,{value:"Module"}));async function _v(t,e){var o;const{options:n}=e;if(!(n!=null&&n.client_id)||!n.client_secret)throw new Error("Missing required authentication parameters");const r=new xg(n.client_id,n.client_secret,`${Ce(t.env)}callback`),i=Re();return{redirectUrl:r.createAuthorizationURL(i,((o=n.scope)==null?void 0:o.split(" "))||["email"]).href,code:i}}async function yv(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 xg(r.client_id,r.client_secret,`${Ce(t.env)}callback`).validateAuthorizationCode(n),o=await fetch("https://graph.facebook.com/v16.0/me?fields=id,email,name",{headers:{Authorization:`Bearer ${s.accessToken()}`}});if(!o.ok)throw new Error("Failed to fetch user info");const c=await o.json();return t.set("log",`Userinfo: ${JSON.stringify(c)}`),{sub:c.id,email:c.email,name:c.name}}const vv=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:_v,validateAuthorizationCodeAndGetUser:yv},Symbol.toStringTag,{value:"Module"}));async function wv(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 Sg(n.client_id,n.client_secret,`${Ce(t.env)}callback`),i=Re(),s=Zy();return{redirectUrl:r.createAuthorizationURL(i,s,((c=n.scope)==null?void 0:c.split(" "))??["email","profile"]).href,code:i,codeVerifier:s}}async function bv(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 o=await new Sg(i.client_id,i.client_secret,`${Ce(t.env)}callback`).validateAuthorizationCode(n,r);console.log("got here");const c=Jl(o.idToken());if(!c)throw new Error("Invalid ID token");const l=Fo.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 kv=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:wv,validateAuthorizationCodeAndGetUser:bv},Symbol.toStringTag,{value:"Module"}));async function xv(t,e){var o;const{options:n}=e;if(!(n!=null&&n.client_id)||!n.client_secret)throw new Error("Missing required authentication parameters");const r=new Wl(n.client_id,n.client_secret,`${Ce(t.env)}callback`),i=Re(),s=r.createAuthorizationURL("https://api.vipps.no/access-management-1.0/access/oauth2/auth",i,((o=n.scope)==null?void 0:o.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 Sv(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 Wl(r.client_id,r.client_secret,`${Ce(t.env)}callback`).validateAuthorizationCode("https://api.vipps.no/access-management-1.0/access/oauth2/token",n,null),o=Jl(s.idToken());if(!o)throw new Error("Invalid ID token");const c=Fo.parse(o.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 C(400,{message:"Failed to get user from vipps"});return await l.json()}const Av=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:xv,validateAuthorizationCodeAndGetUser:Sv},Symbol.toStringTag,{value:"Module"}));function Eg(t,e){const n=t.env.STRATEGIES||{},i={apple:mv,facebook:vv,"google-oauth2":kv,vipps:Av,...n}[e];if(!i)throw new Error(`Strategy ${e} not found`);return i}async function Ko(t,e){const n=await t.data.clients.get(e);if(!n)throw new C(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:[]},o=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?Dt.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||[],`${At(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||[],`${At(t)}info`],connections:o,tenant:{...(r==null?void 0:r.tenant)||{},...n.tenant}}}function Wo(t,e=[],n={}){try{const r=new URL(t);return e.some(i=>{try{return Ev(r,new URL(i),n.allowPathWildcards)}catch{return!1}})}catch{return!1}}function Ev(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}function Iv(){const t=new Uint8Array(32);return crypto.getRandomValues(t),yn.encode(t,{includePadding:!1})}function zv(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 Cv(t,e){if(e==="plain")return t;const n=new TextEncoder().encode(t),r=await gg(n);return yn.encode(new Uint8Array(r),{includePadding:!1})}function Ig(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 Nv(t){const e=new Map,n=t.split("; ");for(const r of n){const i=r.split("="),s=i[0],o=i[1]??"";s&&e.set(decodeURIComponent(s),decodeURIComponent(o))}return e}function Zl(t){return`${t}-${Ty}`}function Fs(t,e){return e?Nv(e).get(Zl(t)):void 0}function jv(t){const e={path:"/",httpOnly:!0,secure:!0,maxAge:0};return Ig(Zl(t),"",{...e,sameSite:"none"})}function zg(t,e){const n={path:"/",httpOnly:!0,secure:!0,maxAge:Ho};return Ig(Zl(t),e,{...n,sameSite:"none"})}var Yl={},Go={};(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},o=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=o,t.getAllMatches=s,t.nameRegexp=r})(Go);const Xl=Go,$v={allowBooleanAttributes:!1,unpairedTags:[]};Yl.validate=function(t,e){e=Object.assign({},$v,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=Sp(t,s),s.err)return s}else if(t[s]==="<"){let o=s;if(s++,t[s]==="!"){s=Ap(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]!==`
|
|
126
|
-
`&&t[s]!=="\r";s++)l+=t[s];if(l=l.trim(),l[l.length-1]==="/"&&(l=l.substring(0,l.length-1),s--),!Vv(l)){let h;return l.trim().length===0?h="Invalid space after '<'.":h="Tag '"+l+"' is an invalid name.",we("InvalidTag",h,Pe(t,s))}const u=Tv(t,s);if(u===!1)return we("InvalidAttr","Attributes for '"+l+"' have open quote.",Pe(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=Ep(p,e);if(m===!0)r=!0;else return we(m.err.code,m.err.msg,Pe(t,h+m.err.line))}else if(c)if(u.tagClosed){if(p.trim().length>0)return we("InvalidTag","Closing tag '"+l+"' can't have attributes or invalid starting.",Pe(t,o));if(n.length===0)return we("InvalidTag","Closing tag '"+l+"' has not been opened.",Pe(t,o));{const h=n.pop();if(l!==h.tagName){let m=Pe(t,h.tagStartPos);return we("InvalidTag","Expected closing tag '"+h.tagName+"' (opened in line "+m.line+", col "+m.col+") instead of closing tag '"+l+"'.",Pe(t,o))}n.length==0&&(i=!0)}}else return we("InvalidTag","Closing tag '"+l+"' doesn't have proper closing.",Pe(t,s));else{const h=Ep(p,e);if(h!==!0)return we(h.err.code,h.err.msg,Pe(t,s-p.length+h.err.line));if(i===!0)return we("InvalidXml","Multiple possible root nodes found.",Pe(t,s));e.unpairedTags.indexOf(l)!==-1||n.push({tagName:l,tagStartPos:o}),r=!0}for(s++;s<t.length;s++)if(t[s]==="<")if(t[s+1]==="!"){s++,s=Ap(t,s);continue}else if(t[s+1]==="?"){if(s=Sp(t,++s),s.err)return s}else break;else if(t[s]==="&"){const h=Lv(t,s);if(h==-1)return we("InvalidChar","char '&' is not expected.",Pe(t,s));s=h}else if(i===!0&&!xp(t[s]))return we("InvalidXml","Extra text at the end",Pe(t,s));t[s]==="<"&&s--}}else{if(xp(t[s]))continue;return we("InvalidChar","char '"+t[s]+"' is not expected.",Pe(t,s))}if(r){if(n.length==1)return we("InvalidTag","Unclosed tag '"+n[0].tagName+"'.",Pe(t,n[0].tagStartPos));if(n.length>0)return we("InvalidXml","Invalid '"+JSON.stringify(n.map(s=>s.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1})}else return we("InvalidXml","Start tag expected.",1);return!0};function xp(t){return t===" "||t===" "||t===`
|
|
127
|
-
`||t==="\r"}function Sp(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 we("InvalidXml","XML declaration allowed only at the start of the document.",Pe(t,e));if(t[e]=="?"&&t[e+1]==">"){e++;break}else continue}return e}function Ap(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 Ov='"',Bv="'";function Tv(t,e){let n="",r="",i=!1;for(;e<t.length;e++){if(t[e]===Ov||t[e]===Bv)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 Pv=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function Ep(t,e){const n=Xl.getAllMatches(t,Pv),r={};for(let i=0;i<n.length;i++){if(n[i][1].length===0)return we("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 we("InvalidAttr","Attribute '"+n[i][2]+"' is without value.",Er(n[i]));if(n[i][3]===void 0&&!e.allowBooleanAttributes)return we("InvalidAttr","boolean attribute '"+n[i][2]+"' is not allowed.",Er(n[i]));const s=n[i][2];if(!Uv(s))return we("InvalidAttr","Attribute '"+s+"' is an invalid name.",Er(n[i]));if(!r.hasOwnProperty(s))r[s]=1;else return we("InvalidAttr","Attribute '"+s+"' is repeated.",Er(n[i]))}return!0}function Rv(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 Lv(t,e){if(e++,t[e]===";")return-1;if(t[e]==="#")return e++,Rv(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 we(t,e,n){return{err:{code:t,msg:e,line:n.line||n,col:n.col}}}function Uv(t){return Xl.isName(t)}function Vv(t){return Xl.isName(t)}function Pe(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 Ql={};const Cg={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}},Mv=function(t){return Object.assign({},Cg,t)};Ql.buildOptions=Mv;Ql.defaultOptions=Cg;class qv{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 Dv=qv;const Hv=Go;function Fv(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,o="";for(;e<t.length;e++)if(t[e]==="<"&&!s){if(i&&Gv(t,e)){e+=7;let c,l;[c,l,e]=Kv(t,e+1),l.indexOf("&")===-1&&(n[Xv(c)]={regx:RegExp(`&${c};`,"g"),val:l})}else if(i&&Jv(t,e))e+=8;else if(i&&Zv(t,e))e+=8;else if(i&&Yv(t,e))e+=9;else if(Wv)s=!0;else throw new Error("Invalid DOCTYPE");r++,o=""}else if(t[e]===">"){if(s?t[e-1]==="-"&&t[e-2]==="-"&&(s=!1,r--):r--,r===0)break}else t[e]==="["?i=!0:o+=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 Kv(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 Wv(t,e){return t[e+1]==="!"&&t[e+2]==="-"&&t[e+3]==="-"}function Gv(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 Jv(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 Zv(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 Yv(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 Xv(t){if(Hv.isName(t))return t;throw new Error(`Invalid entity name ${t}`)}var Qv=Fv;const ew=/^[-+]?0x[a-fA-F0-9]+$/,tw=/^([\-\+])?(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 nw={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};function rw(t,e={}){if(e=Object.assign({},nw,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&&ew.test(n))return Number.parseInt(n,16);{const r=tw.exec(n);if(r){const i=r[1],s=r[2];let o=iw(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"&&o===""||u===o||i&&u==="-"+o?l:t:s?o===u||i+o===u?l:t:n===u||n===i+u?l:t}}else return t}}function iw(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 sw=rw;function ow(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 Ng=ow;const jg=Go,Ir=Dv,aw=Qv,cw=sw,lw=Ng;let uw=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=dw,this.parseXml=mw,this.parseTextData=pw,this.resolveNameSpace=fw,this.buildAttributesMap=gw,this.isItStopNode=ww,this.replaceEntitiesValue=yw,this.readStopNodeData=kw,this.saveTextToParentTag=vw,this.addChild=_w,this.ignoreAttributesFn=lw(this.options.ignoreAttributes)}};function dw(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 pw(t,e,n,r,i,s,o){if(t!==void 0&&(this.options.trimValues&&!r&&(t=t.trim()),t.length>0)){o||(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?Gc(t,this.options.parseTagValue,this.options.numberParseOptions):t.trim()===t?Gc(t,this.options.parseTagValue,this.options.numberParseOptions):t}}function fw(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 hw=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function gw(t,e,n){if(this.options.ignoreAttributes!==!0&&typeof t=="string"){const r=jg.getAllMatches(t,hw),i=r.length,s={};for(let o=0;o<i;o++){const c=this.resolveNameSpace(r[o][1]);if(this.ignoreAttributesFn(c,e))continue;let l=r[o][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]=Gc(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 o={};return o[this.options.attributesGroupName]=s,o}return s}}const mw=function(t){t=t.replace(/\r\n?/g,`
|
|
128
|
-
`);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=gn(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=Wc(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=gn(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=aw(t,s);this.docTypeEntities=c.entities,s=c.i}else if(t.substr(s+1,2)==="!["){const c=gn(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=Wc(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 _w(t,e,n){const r=this.options.updateTag(e.tagname,n,e[":@"]);r===!1||(typeof r=="string"&&(e.tagname=r),t.addChild(e))}const yw=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 vw(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 ww(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 bw(t,e,n=">"){let r,i="";for(let s=e;s<t.length;s++){let o=t[s];if(r)o===r&&(r="");else if(o==='"'||o==="'")r=o;else if(o===n[0])if(n[1]){if(t[s+1]===n[1])return{data:i,index:s}}else return{data:i,index:s};else o===" "&&(o=" ");i+=o}}function gn(t,e,n,r){const i=t.indexOf(e,n);if(i===-1)throw new Error(r);return i+e.length-1}function Wc(t,e,n,r=">"){const i=bw(t,e+1,r);if(!i)return;let s=i.data;const o=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:o,attrExpPresent:u,rawTagName:p}}function kw(t,e,n){const r=n;let i=1;for(;n<t.length;n++)if(t[n]==="<")if(t[n+1]==="/"){const s=gn(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=gn(t,"?>",n+1,"StopNode is not closed.");else if(t.substr(n+1,3)==="!--")n=gn(t,"-->",n+3,"StopNode is not closed.");else if(t.substr(n+1,2)==="![")n=gn(t,"]]>",n,"StopNode is not closed.")-2;else{const s=Wc(t,n,">");s&&((s&&s.tagName)===e&&s.tagExp[s.tagExp.length-1]!=="/"&&i++,n=s.closeIndex)}}function Gc(t,e,n){if(e&&typeof t=="string"){const r=t.trim();return r==="true"?!0:r==="false"?!1:cw(t,n)}else return jg.isExist(t)?t:""}var xw=uw,$g={};function Sw(t,e){return Og(t,e)}function Og(t,e,n){let r;const i={};for(let s=0;s<t.length;s++){const o=t[s],c=Aw(o);let l="";if(n===void 0?l=c:l=n+"."+c,c===e.textNodeName)r===void 0?r=o[c]:r+=""+o[c];else{if(c===void 0)continue;if(o[c]){let u=Og(o[c],e,l);const p=Iw(u,e);o[":@"]?Ew(u,o[":@"],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 Aw(t){const e=Object.keys(t);for(let n=0;n<e.length;n++){const r=e[n];if(r!==":@")return r}}function Ew(t,e,n,r){if(e){const i=Object.keys(e),s=i.length;for(let o=0;o<s;o++){const c=i[o];r.isArray(c,n+"."+c,!0,!0)?t[c]=[e[c]]:t[c]=e[c]}}}function Iw(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))}$g.prettify=Sw;const{buildOptions:zw}=Ql,Cw=xw,{prettify:Nw}=$g,jw=Yl;let $w=class{constructor(e){this.externalEntities={},this.options=zw(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=jw.validate(e,n);if(s!==!0)throw Error(`${s.err.msg}:${s.err.line}:${s.err.col}`)}const r=new Cw(this.options);r.addExternalEntities(this.externalEntities);const i=r.parseXml(e);return this.options.preserveOrder||i===void 0?i:Nw(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 '
'");if(n==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[e]=n}};var Ow=$w;const Bw=`
|
|
129
|
-
`;function Tw(t,e){let n="";return e.format&&e.indentBy.length>0&&(n=Bw),Bg(t,e,"",n)}function Bg(t,e,n,r){let i="",s=!1;for(let o=0;o<t.length;o++){const c=t[o],l=Pw(c);if(l===void 0)continue;let u="";if(n.length===0?u=l:u=`${n}.${l}`,l===e.textNodeName){let f=c[l];Rw(u,e)||(f=e.tagValueProcessor(l,f),f=Tg(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=Ip(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=Ip(c[":@"],e),m=r+`<${l}${h}`,v=Bg(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 Pw(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 Ip(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=Tg(i,e),i===!0&&e.suppressBooleanAttributes?n+=` ${r.substr(e.attributeNamePrefix.length)}`:n+=` ${r.substr(e.attributeNamePrefix.length)}="${i}"`}return n}function Rw(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 Tg(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 Lw=Tw;const Uw=Lw,Vw=Ng,Mw={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:"&"},{regex:new RegExp(">","g"),val:">"},{regex:new RegExp("<","g"),val:"<"},{regex:new RegExp("'","g"),val:"'"},{regex:new RegExp('"',"g"),val:"""}],processEntities:!0,stopNodes:[],oneListGroup:!1};function an(t){this.options=Object.assign({},Mw,t),this.options.ignoreAttributes===!0||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn=Vw(this.options.ignoreAttributes),this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=Hw),this.processTextOrObjNode=qw,this.options.format?(this.indentate=Dw,this.tagEndChar=`>
|
|
130
|
-
`,this.newLine=`
|
|
131
|
-
`):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}an.prototype.build=function(t){return this.options.preserveOrder?Uw(t,this.options):(Array.isArray(t)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(t={[this.options.arrayNodeName]:t}),this.j2x(t,0,[]).val)};an.prototype.j2x=function(t,e,n){let r="",i="";const s=n.join(".");for(let o in t)if(Object.prototype.hasOwnProperty.call(t,o))if(typeof t[o]>"u")this.isAttribute(o)&&(i+="");else if(t[o]===null)this.isAttribute(o)?i+="":o[0]==="?"?i+=this.indentate(e)+"<"+o+"?"+this.tagEndChar:i+=this.indentate(e)+"<"+o+"/"+this.tagEndChar;else if(t[o]instanceof Date)i+=this.buildTextValNode(t[o],o,"",e);else if(typeof t[o]!="object"){const c=this.isAttribute(o);if(c&&!this.ignoreAttributesFn(c,s))r+=this.buildAttrPairStr(c,""+t[o]);else if(!c)if(o===this.options.textNodeName){let l=this.options.tagValueProcessor(o,""+t[o]);i+=this.replaceEntitiesValue(l)}else i+=this.buildTextValNode(t[o],o,"",e)}else if(Array.isArray(t[o])){const c=t[o].length;let l="",u="";for(let p=0;p<c;p++){const h=t[o][p];if(!(typeof h>"u"))if(h===null)o[0]==="?"?i+=this.indentate(e)+"<"+o+"?"+this.tagEndChar:i+=this.indentate(e)+"<"+o+"/"+this.tagEndChar;else if(typeof h=="object")if(this.options.oneListGroup){const m=this.j2x(h,e+1,n.concat(o));l+=m.val,this.options.attributesGroupName&&h.hasOwnProperty(this.options.attributesGroupName)&&(u+=m.attrStr)}else l+=this.processTextOrObjNode(h,o,e,n);else if(this.options.oneListGroup){let m=this.options.tagValueProcessor(o,h);m=this.replaceEntitiesValue(m),l+=m}else l+=this.buildTextValNode(h,o,"",e)}this.options.oneListGroup&&(l=this.buildObjectNode(l,o,u,e)),i+=l}else if(this.options.attributesGroupName&&o===this.options.attributesGroupName){const c=Object.keys(t[o]),l=c.length;for(let u=0;u<l;u++)r+=this.buildAttrPairStr(c[u],""+t[o][c[u]])}else i+=this.processTextOrObjNode(t[o],o,e,n);return{attrStr:r,val:i}};an.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 qw(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)}an.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}};an.prototype.closeTag=function(t){let e="";return this.options.unpairedTags.indexOf(t)!==-1?this.options.suppressUnpairedNode||(e="/"):this.options.suppressEmptyNode?e="/":e=`></${t}`,e};an.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}};an.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 Dw(t){return this.options.indentBy.repeat(t)}function Hw(t){return t.startsWith(this.options.attributeNamePrefix)&&t!==this.options.textNodeName?t.substr(this.attrPrefixLen):!1}var Fw=an;const Kw=Yl,Ww=Ow,Gw=Fw;var Jw={XMLParser:Ww,XMLValidator:Kw,XMLBuilder:Gw};function Zw(t,e,n){const r=n?`<input type="hidden" name="RelayState" value="${n}" />`:"",i=`
|
|
132
|
-
<!DOCTYPE html>
|
|
133
|
-
<html>
|
|
134
|
-
<body onload="document.forms[0].submit()">
|
|
135
|
-
<noscript>
|
|
136
|
-
<p>Your browser has JavaScript disabled. Please click the button below to continue:</p>
|
|
137
|
-
<input type="submit" value="Continue">
|
|
138
|
-
</noscript>
|
|
139
|
-
<form method="post" action="${t}">
|
|
140
|
-
<input type="hidden" name="SAMLResponse" value="${e}" />
|
|
141
|
-
${r}
|
|
142
|
-
</form>
|
|
143
|
-
<script>
|
|
144
|
-
window.onload = function() {{
|
|
145
|
-
document.forms[0].submit();
|
|
146
|
-
}};
|
|
147
|
-
<\/script>
|
|
148
|
-
</body>
|
|
149
|
-
</html>`;return new Response(i,{headers:{"Content-Type":"text/html"}})}async function Yw(t,e,n,r,i){var m,v,f;if(!n.redirect_uri)throw new C(400,{message:"Missing redirect_uri in authParams"});const[s]=await t.env.data.keys.list();if(!s)throw new C(500,{message:"No signing key found"});if(!((m=e.addons)!=null&&m.samlp))throw new C(400,{message:`SAML Addon is not enabled for client ${e.id}`});const{recipient:o,audience:c}=e.addons.samlp,l=n.state||"";if(!o||!l||!r||!n.state)throw new C(400,{message:"Missing recipient or inResponseTo"});const u=JSON.parse(n.state),p=new URL(n.redirect_uri),h=await Xw(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 Zw(p.toString(),h,u.relayState)}async function Xw(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,o=e.responseId||`_${Re()}`,c=e.assertionId||`_${Re()}`,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":o,"@_InResponseTo":e.inResponseTo,"@_IssueInstant":i,"@_Version":"2.0"}}];let p=new Jw.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)}async function Qw(t,e,n){const r=await t.env.data.tenants.get(e);if(!r)throw new Error(`Tenant not found: ${e}`);return Jo(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:Jt.TOKEN,scope:n}})}async function eu(t,e,n){const r=await Qw(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 o=be(t,{type:me.FAILED_HOOK,description:`Failed to invoke hook ${i.hook_id}`});await t.env.data.logs.create(n.tenant_id,o)}}function eb(t,e){return async(n,r)=>{const{hooks:i}=await e.hooks.list(n);return await eu(t,i,{tenant_id:n,user:r,trigger_id:"post-user-registration"}),r}}function tb(t,e){return async(n,r)=>{const{hooks:i}=await e.hooks.list(n,{q:"trigger_id:pre-user-signup",page:0,per_page:100,include_totals:!1});await eu(t,i,{tenant_id:n,email:r,trigger_id:"pre-user-signup"})}}function nb(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 eu(t,i,{tenant_id:n,user:r,trigger_id:"post-user-login"}),r}}const zp=["sub","iss","aud","exp","nbf","iat","jti"];async function Jo(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 C(500,{message:"No signing key available"});const u=zv(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,scope:n.scope||"",grant_type:""},{accessToken:{setCustomClaim:(S,N)=>{if(zp.includes(S))throw new Error(`Cannot overwrite reserved claim '${S}'`);p[S]=N}},idToken:{setCustomClaim:(S,N)=>{if(zp.includes(S))throw new Error(`Cannot overwrite reserved claim '${S}'`);h&&(h[S]=N)}},access:{deny:S=>{throw new C(400,{message:`Access denied: ${S}`})}}});const m={includeIssuedTimestamp:!0,expiresIn:new Gl(1,"d"),headers:{kid:l.kid}},v=await kp("RS256",u,p,m),f=h?await kp("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 rb(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:Re(),session_id:s,client_id:n.id,expires_at:new Date(Date.now()+Ho*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 Pg(t,e){const{user:n,client:r,scope:i,audience:s}=e,o=await t.env.data.sessions.create(r.tenant.id,{id:Re(),user_id:n.user_id,idle_expires_at:new Date(Date.now()+Ho*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:[r.id]}),c=i!=null&&i.split(" ").includes("offline_access")?await rb(t,{...e,session_id:o.id,scope:i,audience:s}):void 0;return{...o,refresh_token:c}}async function cn(t,e){var v;const{authParams:n,user:r,client:i,ticketAuth:s}=e,o=be(t,{type:me.SUCCESS_LOGIN,description:`Successful login for ${r.user_id}`,userId:r.user_id});if(Qe(t,t.env.data.logs.create(i.tenant.id,o)),Qe(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 C(500,{message:"Login session not found"});const f=Iv(),_=Re(12),w=await t.env.data.codes.create(i.tenant.id,{code_id:Re(),code_type:"ticket",login_id:e.loginSession.login_id,expires_at:new Date(Date.now()+Ly).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){u=await nb(t,t.env.data)(i.tenant.id,r);const f=await Pg(t,{user:r,client:i,scope:n.scope,audience:n.audience});l=f.id,c=(v=f.refresh_token)==null?void 0:v.id}if(e.authParams.response_mode===Zt.SAML_POST)return Yw(t,e.client,e.authParams,u,l);const p=await Jo(t,{authParams:n,user:u,client:i,session_id:l,refresh_token:c}),h=new Headers({"set-cookie":zg(i.tenant.id,l)});if(n.response_mode===Zt.WEB_MESSAGE)return t.json(p,{headers:h});if((n.response_type||Jt.CODE)===Jt.CODE){if(!e.loginSession)throw new C(500,{message:"Login session not found"});const f=await t.env.data.codes.create(i.tenant.id,{code_id:Re(),user_id:r.user_id,code_type:"authorization_code",login_id:e.loginSession.login_id,expires_at:new Date(Date.now()+Py*1e3).toISOString()});if(!n.redirect_uri)throw new C(400,{message:"Redirect uri not found"});const _=new URL(n.redirect_uri);_.searchParams.set("code",f.code_id),n.state&&_.searchParams.set("state",n.state),h.set("location",_.toString())}return new Response("Redirecting",{status:302,headers:h})}function ib(t){return async(e,n)=>{if(!n.email||!n.email_verified)return t.users.create(e,n);const r=await Qs({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 sb(t,e){return async(n,r)=>{let i=await ib(e)(n,r);return await eb(t,e)(n,i),i}}async function Rg(t,e,n,r){if(e.disable_sign_ups&&!await Qs({userAdapter:t.env.data.users,tenant_id:e.tenant.id,email:r})){const s=be(t,{type:me.FAILED_SIGNUP,description:"Public signup is disabled"});throw await t.env.data.logs.create(e.tenant.id,s),new C(400,{message:"Signups are disabled for this client"})}await tb(t,n)(t.var.tenant_id||"",r)}function ob(t,e){return{...e,users:{...e.users,create:sb(t,e)}}}async function ab(t,e,n,r){if(!r.state)throw new C(400,{message:"State not found"});const i=e.connections.find(l=>l.name===n);if(!i){t.set("client_id",e.id);const l=be(t,{type:me.FAILED_LOGIN,description:"Connection not found"});throw await t.env.data.logs.create(e.tenant.id,l),new C(403,{message:"Connection Not Found"})}let s=await t.env.data.logins.get(e.tenant.id,r.state);s||(s=await t.env.data.logins.create(e.tenant.id,{expires_at:new Date(Date.now()+Qr*1e3).toISOString(),authParams:r,...Tn(t.req)}));const c=await Eg(t,i.strategy).getRedirect(t,i);return await t.env.data.codes.create(e.tenant.id,{login_id:s.login_id,code_id:c.code,code_type:"oauth2_state",connection_id:i.id,code_verifier:c.codeVerifier,expires_at:new Date(Date.now()+Ry*1e3).toISOString()}),t.redirect(c.redirectUrl)}async function Cp(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 C(403,{message:"State not found"});const s=await r.data.logins.get(t.var.tenant_id||"",i.login_id);if(!s)throw new C(403,{message:"Session not found"});const o=await Ko(r,s.authParams.client_id);t.set("client_id",o.id),t.set("tenant_id",o.tenant.id);const c=o.connections.find(_=>_.id===i.connection_id);if(!c){const _=be(t,{type:me.FAILED_LOGIN,description:"Connection not found"});throw await r.data.logs.create(o.tenant.id,_),new C(403,{message:"Connection not found"})}if(t.set("connection",c.name),!s.authParams.redirect_uri){const _=be(t,{type:me.FAILED_LOGIN,description:"Redirect URI not defined"});throw await r.data.logs.create(o.tenant.id,_),new C(403,{message:"Redirect URI not defined"})}if(!Wo(s.authParams.redirect_uri,o.callbacks||[],{allowPathWildcards:!0})){const _=`Invalid redirect URI - ${s.authParams.redirect_uri}`,w=be(t,{type:me.FAILED_LOGIN,description:_});throw await r.data.logs.create(o.tenant.id,w),new C(403,{message:_})}const u=await Eg(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);let v=await vn({userAdapter:r.data.users,tenant_id:o.tenant.id,email:m,provider:c.name});if(!v){try{await Rg(t,o,t.env.data,m)}catch(_){const w=_;throw new C(500,{message:`Failed to run preUserSignupHook: ${w.message}`})}v=await r.data.users.create(o.tenant.id,{user_id:`${c.name}|${p}`,email:m,name:m,provider:c.name,connection:c.name,email_verified:!0,last_ip:"",is_social:!0,last_login:new Date().toISOString(),profileData:JSON.stringify(h)}),t.set("user_id",v.user_id)}return cn(t,{client:o,authParams:s.authParams,loginSession:s,user:v})}async function Np(t,e,n,r,i,s){const o=await t.env.data.codes.get(t.var.tenant_id||"",e,"oauth2_state");if(!o)throw new C(400,{message:"State not found"});const c=await t.env.data.logins.get(t.var.tenant_id,o.login_id);if(!c)throw new C(400,{message:"Login not found"});const{redirect_uri:l}=c.authParams;if(!l)throw new C(400,{message:"Redirect uri not found"});const u=be(t,{type:me.FAILED_LOGIN,description:`Failed connection login: ${i} ${n}, ${r}`});Qe(t,t.env.data.logs.create(t.var.tenant_id,u));const p=new URL(l);return By(p,{error:n,error_description:r,error_reason:s,error_code:i,state:c.authParams.state}),t.redirect(`${At(t.env)}enter-email?state=${c.login_id}&error=${n}`)}const cb=new a.OpenAPIHono().openapi(a.createRoute({tags:["oauth2"],method:"get",path:"/",request:{query:a.z.object({state:a.z.string(),code:a.z.string().optional(),scope:a.z.string().optional(),hd:a.z.string().optional(),error:a.z.string().optional(),error_description:a.z.string().optional(),error_code:a.z.string().optional(),error_reason:a.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:o}=t.req.valid("query");if(r)return Np(t,e,r,i,s,o);if(!n)throw new C(400,{message:"Code is required"});return Cp(t,{code:n,state:e})}).openapi(a.createRoute({tags:["oauth2"],method:"post",path:"/",request:{body:{content:{"application/x-www-form-urlencoded":{schema:a.z.object({state:a.z.string(),code:a.z.string().optional(),scope:a.z.string().optional(),hd:a.z.string().optional(),error:a.z.string().optional(),error_description:a.z.string().optional(),error_code:a.z.string().optional(),error_reason:a.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:o}=t.req.valid("form");if(r)return Np(t,e,r,i,s,o);if(!n)throw new C(400,{message:"Code is required"});return Cp(t,{code:n,state:e})}),lb=new a.OpenAPIHono().openapi(a.createRoute({tags:["oauth2"],method:"get",path:"/",request:{query:a.z.object({client_id:a.z.string(),returnTo:a.z.string().optional()}),header:a.z.object({cookie:a.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(!Wo(s,[...r.allowed_logout_urls||[],...(i==null?void 0:i.allowed_logout_urls)||[]],{allowPathWildcards:!0}))throw new C(400,{message:"Invalid redirect uri"});const o=t.req.header("cookie");if(o){const l=Fs(r.tenant.id,o);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))}await t.env.data.sessions.remove(r.tenant.id,l)}}const c=be(t,{type:me.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":jv(r.tenant.id),location:s}})}),jp=a.z.object({sub:a.z.string(),email:a.z.string().optional(),family_name:a.z.string().optional(),given_name:a.z.string().optional(),email_verified:a.z.boolean()}),ub=new a.OpenAPIHono().openapi(a.createRoute({tags:["oauth2"],method:"get",path:"/",request:{},security:[{Bearer:["openid"]}],responses:{200:{content:{"application/json":{schema:jp}},description:"Userinfo"}}}),async t=>{if(!t.var.user)throw new C(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 C(404,{message:"User not found"});return t.json(jp.parse({...e,sub:e.user_id}))}),db=new a.OpenAPIHono().openapi(a.createRoute({tags:["well known"],method:"get",path:"/jwks.json",request:{},responses:{200:{content:{"application/json":{schema:cf}},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 Kl(r.cert).publicKey.export(),o=await crypto.subtle.exportKey("jwk",s);return nl.parse({...o,kid:r.kid})}));return t.json({keys:n},{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${Pi}, stale-while-revalidate=${Pi*2}, stale-if-error=86400`}})}).openapi(a.createRoute({tags:["well known"],method:"get",path:"/openid-configuration",request:{},responses:{200:{content:{"application/json":{schema:Aa}},description:"List of tenants"}}}),async t=>{const e=Aa.parse({issuer:fv(t.env),authorization_endpoint:`${Ce(t.env)}authorize`,token_endpoint:`${Ce(t.env)}oauth/token`,device_authorization_endpoint:`${Ce(t.env)}oauth/device/code`,userinfo_endpoint:`${Ce(t.env)}userinfo`,mfa_challenge_endpoint:`${Ce(t.env)}mfa/challenge`,jwks_uri:`${Ce(t.env)}.well-known/jwks.json`,registration_endpoint:`${Ce(t.env)}oidc/register`,revocation_endpoint:`${Ce(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=${Pi}, stale-while-revalidate=${Pi*2}, stale-if-error=86400`}})});function Ki(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 Lg=a.z.object({grant_type:a.z.literal("client_credentials"),scope:a.z.string().optional(),client_secret:a.z.string(),client_id:a.z.string(),audience:a.z.string().optional()});async function pb(t,e){const n=await t.env.data.clients.get(e.client_id);if(!n)throw new C(403,{message:"Invalid client credentials"});if(n.client_secret&&!Ki(n.client_secret,e.client_secret))throw new C(403,{message:"Invalid client credentials"});const r={client_id:n.id,scope:e.scope,audience:e.audience},i=await Jo(t,{authParams:r,client:n});return t.json(i)}const fb=a.z.object({grant_type:a.z.literal("authorization_code"),client_id:a.z.string(),code:a.z.string(),redirect_uri:a.z.string().optional(),client_secret:a.z.string().optional(),code_verifier:a.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 hb(t,e){const n=await t.env.data.clients.get(e.client_id);if(!n)throw new C(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 C(403,{message:"Invalid client credentials"});if(new Date(r.expires_at)<new Date)throw new C(403,{message:"Code expired"});if(r.used_at)throw new C(403,{message:"Code already used"});const i=await t.env.data.logins.get(n.tenant.id,r.login_id);if(!i)throw new C(403,{message:"Invalid login"});if("client_secret"in e){const o=await t.env.data.clients.get("DEFAULT_CLIENT");if(!Ki(n.client_secret,e.client_secret)&&!Ki(o==null?void 0:o.client_secret,e.client_secret))throw new C(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 o=await Cv(e.code_verifier,i.authParams.code_challenge_method);if(!Ki(o,i.authParams.code_challenge||""))throw new C(403,{message:"Invalid client credentials"})}if(i.authParams.redirect_uri&&i.authParams.redirect_uri!==e.redirect_uri)throw new C(403,{message:"Invalid redirect uri"});const s=await t.env.data.users.get(n.tenant.id,r.user_id);if(!s)throw new C(403,{message:"User not found"});return await t.env.data.codes.used(n.tenant.id,e.code),cn(t,{user:s,client:n,loginSession:i,authParams:{...i.authParams,response_mode:Zt.WEB_MESSAGE}})}const gb=a.z.object({grant_type:a.z.literal("refresh_token"),client_id:a.z.string(),redirect_uri:a.z.string().optional(),refresh_token:a.z.string()});async function mb(t,e){const n=await t.env.data.clients.get(e.client_id);if(!n)throw new C(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 C(403,{message:JSON.stringify({error:"invalid_grant",error_description:"Refresh token has expired"})})}else throw new C(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 C(403,{message:"User not found"});const s=r.resource_servers[0];if(r.idle_expires_at){const o=new Date(Date.now()+2592e6);await t.env.data.refreshTokens.update(n.tenant.id,r.id,{idle_expires_at:o.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 cn(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:Zt.WEB_MESSAGE}})}const $p=a.z.object({client_id:a.z.string().optional(),client_secret:a.z.string().optional()}),_b=a.z.union([Lg.extend($p.shape),a.z.object({grant_type:a.z.literal("authorization_code"),client_id:a.z.string(),code:a.z.string(),redirect_uri:a.z.string(),code_verifier:a.z.string().min(43).max(128)}),a.z.object({grant_type:a.z.literal("authorization_code"),code:a.z.string(),redirect_uri:a.z.string().optional(),...$p.shape}),a.z.object({grant_type:a.z.literal("refresh_token"),client_id:a.z.string(),refresh_token:a.z.string(),redirect_uri:a.z.string().optional()})]);function yb(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 vb=new a.OpenAPIHono().openapi(a.createRoute({tags:["oauth2"],method:"post",path:"/",request:{body:{content:{"application/x-www-form-urlencoded":{schema:_b}}}},responses:{200:{content:{"application/json":{schema:hf}},description:"Tokens"}}}),async t=>{const e=t.req.valid("form"),n=yb(t.req.header("Authorization")),r={...e,...n};if(!r.client_id)throw new C(400,{message:"client_id is required"});switch(e.grant_type){case Or.AuthorizationCode:return hb(t,fb.parse(r));case Or.ClientCredential:return pb(t,Lg.parse(r));case Or.RefreshToken:return mb(t,gb.parse(r));default:throw new C(400,{message:"Not implemented"})}});var tu={exports:{}};const nu=[{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}],Ug=(t,e=nu,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 o=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,o[0]),s};tu.exports={passwordStrength:Ug,defaultOptions:nu};var wb=tu.exports.passwordStrength=Ug;tu.exports.defaultOptions=nu;function ru(t){return wb(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 Zo(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 C(500,{message:"Email provider not found"});const r=(i=t.env.emailProviders)==null?void 0:i[n.name];if(!r)throw new C(500,{message:"Email provider not found"});await r({emailProvider:n,...e,from:n.default_from_address||`login@${t.env.ISSUER}`})}async function Vg(t,e,n,r){const i=await t.env.data.tenants.get(t.var.tenant_id);if(!i)throw new C(500,{message:"Tenant not found"});const s=`${At(t.env)}reset-password?state=${r}&code=${n}`,o={vendorName:i.name,lng:i.language||"en"};await Zo(t,{to:e,subject:"Reset your password",html:`Click here to reset your password: ${At(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:de("password_reset_title",o),resetPasswordEmailClickToReset:de("reset_password_email_click_to_reset",o),resetPasswordEmailReset:de("reset_password_email_reset",o),supportInfo:de("support_info",o),contactUs:de("contact_us",o),copyright:de("copyright",o)}})}async function Mg(t,e,n){const r=await t.env.data.tenants.get(t.var.tenant_id);if(!r)throw new C(500,{message:"Tenant not found"});const i={vendorName:r.name,code:n,lng:r.language||"en"};await Zo(t,{to:e,subject:de("code_email_subject",i),html:`Click here to validate your email: ${At(t.env)}validate-email`,template:"auth-link",data:{code:n,vendorName:r.name,logo:r.logo||"",supportUrl:r.support_url||"",magicLink:`${Ce(t.env)}passwordless/verify_redirect?ticket=${n}`,buttonColor:r.primary_color||"",welcomeToYourAccount:de("welcome_to_your_account",i),linkEmailClickToLogin:de("link_email_click_to_login",i),linkEmailLogin:de("link_email_login",i),linkEmailOrEnterCode:de("link_email_or_enter_code",i),codeValid30Mins:de("code_valid_30_minutes",i),supportInfo:de("support_info",i),contactUs:de("contact_us",i),copyright:de("copyright",i)}});const s=be(t,{type:me.CODE_LINK_SENT,description:e});Qe(t,t.env.data.logs.create(r.id,s))}async function iu(t,e,n,r){const i=await t.env.data.tenants.get(t.var.tenant_id);if(!i)throw new C(500,{message:"Tenant not found"});if(!r.redirect_uri)throw new C(400,{message:"redirect_uri is required"});const s=new URL(Ce(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 o={vendorName:i.name,code:n,lng:i.language||"en"};await Zo(t,{to:e,subject:de("code_email_subject",o),html:`Click here to validate your email: ${At(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:de("welcome_to_your_account",o),linkEmailClickToLogin:de("link_email_click_to_login",o),linkEmailLogin:de("link_email_login",o),linkEmailOrEnterCode:de("link_email_or_enter_code",o),codeValid30Mins:de("code_valid_30_minutes",o),supportInfo:de("support_info",o),contactUs:de("contact_us",o),copyright:de("copyright",o)}});const c=be(t,{type:me.CODE_LINK_SENT,description:e});Qe(t,t.env.data.logs.create(i.id,c))}async function su(t,e){const n=await t.env.data.tenants.get(t.var.tenant_id);if(!n)throw new C(500,{message:"Tenant not found"});const r={vendorName:n.name,lng:n.language||"en"};await Zo(t,{to:e.email,subject:"Validate your email address",html:`Click here to validate your email: ${At(t.env)}validate-email`,template:"auth-verify-email",data:{vendorName:n.name,logo:n.logo||"",emailValidationUrl:`${At(t.env)}validate-email`,supportUrl:n.support_url||"https://support.sesamy.com",buttonColor:n.primary_color||"#7d68f4",welcomeToYourAccount:de("welcome_to_your_account",r),verifyEmailVerify:de("verify_email_verify",r),supportInfo:de("support_info",r),contactUs:de("contact_us",r),copyright:de("copyright",r)}})}const bb=new a.OpenAPIHono().openapi(a.createRoute({tags:["dbconnections"],method:"post",path:"/signup",request:{body:{content:{"application/json":{schema:a.z.object({client_id:a.z.string(),connection:a.z.literal("Username-Password-Authentication"),email:a.z.string().transform(t=>t.toLowerCase()),password:a.z.string()})}}}},responses:{200:{content:{"application/json":{schema:a.z.object({_id:a.z.string(),email:a.z.string(),email_verified:a.z.boolean(),app_metadata:a.z.object({}),user_metadata:a.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 C(400,{message:"Client not found"});if(t.set("client_id",i.id),t.set("tenant_id",i.tenant.id),!ru(n))throw new C(400,{message:"Password does not meet the requirements"});if(await vn({userAdapter:t.env.data.users,tenant_id:i.tenant.id,email:e,provider:"auth2"}))throw new C(400,{message:"Invalid sign up"});const o=await t.env.data.users.create(i.tenant.id,{user_id:`auth2|${ai()}`,email:e,email_verified:!1,provider:"auth2",connection:"Username-Password-Authentication",is_social:!1});t.set("user_id",o.user_id),t.set("username",o.email),t.set("connection",o.connection);const c=await oi.hash(n,10);await t.env.data.passwords.create(i.tenant.id,{user_id:o.user_id,password:c,algorithm:"bcrypt"}),await su(t,o);const l=be(t,{type:me.SUCCESS_SIGNUP,description:"Successful signup"});return await t.env.data.logs.create(i.tenant.id,l),t.json({_id:o.user_id,email:o.email,email_verified:!1,app_metadata:{},user_metadata:{}})}).openapi(a.createRoute({tags:["dbconnections"],method:"post",path:"/change_password",request:{body:{content:{"application/json":{schema:a.z.object({client_id:a.z.string(),connection:a.z.literal("Username-Password-Authentication"),email:a.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 C(400,{message:"Client not found"});if(t.set("client_id",r.id),t.set("tenant_id",r.tenant.id),!await Jn({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},o=await t.env.data.logins.create(r.tenant.id,{expires_at:new Date(Date.now()+Qr*1e3).toISOString(),authParams:s,...Tn(t.req)});return await Vg(t,e,o.login_id,o.authParams.state),t.html("If an account with that email exists, we've sent instructions to reset your password.")});function ar(){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 ou(t,e,n,r,i,s){const{env:o}=t,c=await o.data.codes.get(e.tenant.id,i,"otp");if(!c)throw new C(400,{message:"Code not found or expired"});if(c.expires_at<new Date().toISOString())throw new C(400,{message:"Code expired"});if(c.used_at)throw new C(400,{message:"Code already used"});const l=await o.data.logins.get(e.tenant.id,c.login_id);if(!l||l.authParams.username!==r)throw new C(400,{message:"Code not found or expired"});const u=Tn(t.req);if(l.ip!==u.ip)return t.redirect(`${At(t.env)}invalid-session?state=${l.login_id}`);if(n.redirect_uri&&!Wo(n.redirect_uri,e.callbacks,{allowPathWildcards:!0}))throw new C(400,{message:`Invalid redirect URI - ${n.redirect_uri}`});let p=await vn({userAdapter:o.data.users,tenant_id:e.tenant.id,email:r,provider:"email"});if(!p){if(e.disable_sign_ups&&!(await Xs(t.env.data.users,e.tenant.id,r)).length)throw new C(400,{message:"User not found"});p=await o.data.users.create(e.tenant.id,{email:r,email_verified:!0,connection:"email",provider:"email",is_social:!1,user_id:`email|${Re()}`})}return await o.data.codes.used(e.tenant.id,i),cn(t,{user:p,client:e,loginSession:l,authParams:n,ticketAuth:s})}const kb=new a.OpenAPIHono().openapi(a.createRoute({tags:["passwordless"],method:"post",path:"/start",request:{body:{content:{"application/json":{schema:a.z.object({client_id:a.z.string(),connection:a.z.string(),email:a.z.string().transform(t=>t.toLowerCase()),send:a.z.enum(["link","code"]),authParams:el.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:o}=e,c=await t.env.data.clients.get(r);if(!c)throw new C(400,{message:"Client not found"});t.set("client_id",c.id),t.set("tenant_id",c.tenant.id);const l=await n.data.logins.create(c.tenant.id,{authParams:{...o,client_id:r,username:i},expires_at:new Date(Date.now()+Kc).toISOString(),...Tn(t.req)}),u=await n.data.codes.create(c.tenant.id,{code_id:ar(),code_type:"otp",login_id:l.login_id,expires_at:new Date(Date.now()+Kc).toISOString()});return s==="link"?await iu(t,i,u.code_id,{...o,client_id:r}):await Mg(t,i,u.code_id),t.html("OK")}).openapi(a.createRoute({tags:["passwordless"],method:"get",path:"/verify_redirect",request:{query:a.z.object({scope:a.z.string(),response_type:a.z.nativeEnum(Jt),redirect_uri:a.z.string(),state:a.z.string(),nonce:a.z.string().optional(),verification_code:a.z.string(),connection:a.z.string(),client_id:a.z.string(),email:a.z.string().transform(t=>t.toLowerCase()),audience:a.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:o,scope:c,audience:l,response_type:u,nonce:p}=t.req.valid("query"),h=await Ko(e,n);return t.set("client_id",h.id),t.set("tenant_id",h.tenant.id),t.set("connection","email"),ou(t,h,{client_id:n,redirect_uri:s,state:o,nonce:p,scope:c,audience:l,response_type:u},r,i)});class zr extends C{constructor(n,r){super(n,r);ee(this,"_code");this._code=r==null?void 0:r.code}get code(){return this._code}}async function au(t,e,n,r,i){const{env:s}=t,o=n.username;if(t.set("username",o),!o)throw new C(400,{message:"Username is required"});const c=await Jn({userAdapter:t.env.data.users,tenant_id:e.tenant.id,email:o,provider:"auth2"});if(!c){const f=be(t,{type:me.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid user"});throw Qe(t,t.env.data.logs.create(e.tenant.id,f)),new zr(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 zr(403,{message:"User not found",code:"USER_NOT_FOUND"});t.set("connection",c.connection),t.set("user_id",l.user_id);const{password:u}=await s.data.passwords.get(e.tenant.id,c.user_id);if(!await oi.compare(n.password,u)){const f=be(t,{type:me.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid password"});throw Qe(t,t.env.data.logs.create(e.tenant.id,f)),new zr(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===me.FAILED_LOGIN_INCORRECT_PASSWORD&&new Date(f.date)>new Date(Date.now()-1e3*60*5)).length>=3){const f=be(t,{type:me.FAILED_LOGIN,description:"Too many failed login attempts"});throw Qe(t,t.env.data.logs.create(e.tenant.id,f)),new zr(403,{message:"Too many failed login attempts",code:"TOO_MANY_FAILED_LOGINS"})}if(!c.email_verified&&e.email_validation==="enforced"){await su(t,c);const f=be(t,{type:me.FAILED_LOGIN,description:"Email not verified"});throw await t.env.data.logs.create(e.tenant.id,f),new zr(403,{message:"Email not verified",code:"EMAIL_NOT_VERIFIED"})}const v=be(t,{type:me.SUCCESS_LOGIN,description:"Successful login",strategy_type:"Username-Password-Authentication",strategy:"Username-Password-Authentication"});return Qe(t,t.env.data.logs.create(e.tenant.id,v)),cn(t,{client:e,authParams:n,user:l,ticketAuth:i,loginSession:r})}async function xb(t,e,n,r){let i=await vn({userAdapter:t.env.data.users,tenant_id:e.tenant.id,email:n,provider:"auth2"});if(!i){if(!(await Xs(t.env.data.users,e.tenant.id,n)).length)return;i=await t.env.data.users.create(e.tenant.id,{user_id:`email|${ai()}`,email:n,email_verified:!1,is_social:!1,provider:"auth2",connection:"Username-Password-Authentication"})}const s=await t.env.data.logins.create(e.tenant.id,{expires_at:new Date(Date.now()+Vy).toISOString(),authParams:{client_id:e.id,username:n},...Tn(t.req)});let o=ar(),c=await t.env.data.codes.get(e.tenant.id,o,"password_reset");for(;c;)o=ar(),c=await t.env.data.codes.get(e.tenant.id,o,"password_reset");const l=await t.env.data.codes.create(e.tenant.id,{code_id:o,code_type:"password_reset",login_id:s.login_id,expires_at:new Date(Date.now()+Uy).toISOString()});await Vg(t,n,l.code_id,r)}const Sb=new a.OpenAPIHono().openapi(a.createRoute({tags:["oauth"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:a.z.union([a.z.object({credential_type:a.z.literal("http://auth0.com/oauth/grant-type/passwordless/otp"),otp:a.z.string(),client_id:a.z.string(),username:a.z.string().transform(t=>t.toLowerCase()),realm:a.z.enum(["email"]),scope:a.z.string().optional()}),a.z.object({credential_type:a.z.literal("http://auth0.com/oauth/grant-type/password-realm"),client_id:a.z.string(),username:a.z.string().transform(t=>t.toLowerCase()),password:a.z.string(),realm:a.z.enum(["Username-Password-Authentication"]),scope:a.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 C(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 ou(t,i,{client_id:n,username:s},s,e.otp,!0);if("password"in e){const o=await t.env.data.logins.create(i.tenant.id,{expires_at:new Date(Date.now()+Qr*1e3).toISOString(),authParams:{client_id:n,username:s},...Tn(t.req)});return au(t,i,{username:s,password:e.password,client_id:n},o,!0)}else throw new C(400,{message:"Code or password required"})});function Ab(t,e){var r,i,s;if(!t||e.length===0)return!1;const n=((r=ha(t))==null?void 0:r.host)??null;if(!n)return!1;for(const o of e){let c;if(o.startsWith("http://")||o.startsWith("https://")?c=((i=ha(o))==null?void 0:i.host)??null:c=((s=ha("https://"+o))==null?void 0:s.host)??null,n===c)return!0}return!1}function ha(t){try{return new URL(t)}catch{return null}}async function Eb({ctx:t,session:e,client:n,authParams:r,connection:i,login_hint:s}){const o=await t.env.data.logins.create(n.tenant.id,{expires_at:new Date(Date.now()+Qr*1e3).toISOString(),authParams:r,...Tn(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 cn(t,{client:n,loginSession:o,authParams:r,user:c,sessionId:e.id})}if(i==="email"&&s){const c=ar();return await t.env.data.codes.create(n.tenant.id,{code_id:c,code_type:"otp",login_id:o.login_id,expires_at:new Date(Date.now()+Qr*1e3).toISOString()}),await iu(t,s,c,r),t.redirect(`/u/enter-code?state=${o.login_id}`)}return e?t.redirect(`/u/check-account?state=${o.login_id}`):t.redirect(`/u/enter-email?state=${o.login_id}`)}function Ib(t){if(t==="Username-Password-Authentication")return"auth2";if(t==="email")return"email";throw new C(403,{message:"Invalid realm"})}async function zb(t,e,n,r,i){var m;const{env:s}=t;t.set("connection",i);const o=await s.data.codes.get(e,n,"ticket");if(!o||o.used_at)throw new C(403,{message:"Ticket not found"});const c=await s.data.logins.get(e,o.login_id);if(!c||!c.authParams.username)throw new C(403,{message:"Session not found"});const l=await s.data.clients.get(c.authParams.client_id);if(!l)throw new C(403,{message:"Client not found"});t.set("client_id",c.authParams.client_id),await s.data.codes.used(e,n);const u=Ib(i);let p=await vn({userAdapter:s.data.users,tenant_id:e,email:c.authParams.username,provider:u});p||(p=await s.data.users.create(e,{user_id:`email|${ai()}`,email:c.authParams.username,name:c.authParams.username,provider:"email",connection:"email",email_verified:!0,is_social:!1,last_ip:"",last_login:new Date().toISOString()})),t.set("username",p.email),t.set("user_id",p.user_id);const h=await Pg(t,{user:p,client:l,scope:r.scope,audience:r.audience});return cn(t,{authParams:{scope:(m=c.authParams)==null?void 0:m.scope,...r},loginSession:c,sessionId:h.id,user:p,client:l})}async function Op(t,e){return`<!DOCTYPE html>
|
|
149
|
+
`,r}async function rw(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 Ia(await xf(s))}const iw=1e3*60*60*24,sw=new a.OpenAPIHono().openapi(a.createRoute({tags:["keys"],method:"get",path:"/signing",request:{headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:a.z.array(Ea)}},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(a.createRoute({tags:["keys"],method:"get",path:"/signing/{kid}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({kid:a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Ea}},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 N(404,{message:"Key not found"});return t.json(r)}).openapi(a.createRoute({tags:["keys"],method:"post",path:"/signing/rotate",request:{headers:a.z.object({"tenant-id":a.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()+iw).toISOString()});const n=await Gc({name:`CN=${t.env.ORGANIZATION_NAME}`});return await t.env.data.keys.create(n),t.text("OK",{status:201})}).openapi(a.createRoute({tags:["keys"],method:"put",path:"/signing/{kid}/revoke",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({kid:a.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 N(404,{message:"Key not found"});const r=await Gc({name:`CN=${t.env.ORGANIZATION_NAME}`});return await t.env.data.keys.create(r),t.text("OK")}),ow=new a.OpenAPIHono().openapi(a.createRoute({tags:["users"],method:"get",path:"/",request:{query:a.z.object({email:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:a.z.array(Qc)}},description:"List of users"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{email:n}=t.req.valid("query"),i=(await Lf(t.env.data.users,e,n)).filter(s=>!s.linked_to);return t.json(i)}),aw=nn.extend({clients:a.z.array(pn)}),cw=new a.OpenAPIHono().openapi(a.createRoute({tags:["clients"],method:"get",path:"/",request:{query:Yt,headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:a.z.union([aw,a.z.array(pn)])}},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:o}=t.req.valid("query"),l=(await t.env.data.applications.list(e,{page:n,per_page:r,include_totals:i,sort:cr(s),q:o})).applications;return i?t.json({clients:l,start:0,limit:10,length:l.length}):t.json(l)}).openapi(a.createRoute({tags:["clients"],method:"get",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:pn}},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 N(404);return t.json(i)}).openapi(a.createRoute({tags:["clients"],method:"delete",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.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 N(404,{message:"Application not found"});return t.text("OK")}).openapi(a.createRoute({tags:["clients"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:a.z.object(ts.shape).partial()}}},params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:pn}},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 N(404,{message:"Application not found"});return t.json(s)}).openapi(a.createRoute({tags:["clients"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:a.z.object(ts.shape)}}},headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:a.z.object(pn.shape)}},description:"An application"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),r={...n,id:n.id||qe(),client_secret:n.client_secret||qe()},i=await t.env.data.applications.create(e,r);return t.json(i,{status:201})});a.z.object({start:a.z.number(),limit:a.z.number(),length:a.z.number()});Gs.extend({email:a.z.string(),login_count:a.z.number(),multifactor:a.z.array(a.z.string()).optional(),last_ip:a.z.string().optional(),last_login:a.z.string().optional(),user_id:a.z.string()}).catchall(a.z.any());const lw=nn.extend({tenants:a.z.array(Hn)}),uw=new a.OpenAPIHono().openapi(a.createRoute({tags:["tenants"],method:"get",path:"/",request:{query:Yt},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:a.z.union([a.z.array(Hn),lw])}},description:"List of tenants"}}}),async t=>{const{page:e,per_page:n,include_totals:r,sort:i,q:s}=t.req.valid("query"),o=await t.env.data.tenants.list({page:e,per_page:n,include_totals:r,sort:cr(i),q:s});return r?t.json(o):t.json(o.tenants)}).openapi(a.createRoute({tags:["tenants"],method:"get",path:"/{id}",request:{params:a.z.object({id:a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:Hn}},description:"A tenant"}}}),async t=>{const{id:e}=t.req.valid("param"),n=await t.env.data.tenants.get(e);if(!n)throw new N(404);return t.json(n)}).openapi(a.createRoute({tags:["tenants"],method:"delete",path:"/{id}",request:{params:a.z.object({id:a.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(a.createRoute({tags:["tenants"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:a.z.object(rs.shape).partial()}}},params:a.z.object({id:a.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(a.createRoute({tags:["tenants"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:a.z.object(rs.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"tenant/json":{schema:Hn}},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})}),dw=nn.extend({logs:a.z.array(ss)}),pw=new a.OpenAPIHono().openapi(a.createRoute({tags:["logs"],method:"get",path:"/",request:{query:Yt,headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:a.z.union([a.z.array(ss),dw])}},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":o}=t.req.valid("header"),c=await t.env.data.logs.list(o,{page:e,per_page:n,include_totals:r,sort:cr(i),q:s});return r?t.json(c):t.json(c.logs)}).openapi(a.createRoute({tags:["logs"],method:"get",path:"/{id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({id:a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:ss}},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 N(404);return t.json(r)}),fw=nn.extend({hooks:a.z.array(qn)}),hw=new a.OpenAPIHono().openapi(a.createRoute({tags:["hooks"],method:"get",path:"/",request:{query:Yt,headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:a.z.union([a.z.array(qn),fw])}},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:o}=t.req.valid("query"),c=await t.env.data.hooks.list(e,{page:n,per_page:r,include_totals:i,sort:cr(s),q:o});return i?t.json(c):t.json(c.hooks)}).openapi(a.createRoute({tags:["hooks"],method:"post",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.object(is.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:qn}},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(a.createRoute({tags:["hooks"],method:"patch",path:"/{hook_id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({hook_id:a.z.string()}),body:{content:{"application/json":{schema:a.z.object(is.shape).omit({hook_id:!0}).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:qn.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 N(404,{message:"Hook not found"});return t.json(i)}).openapi(a.createRoute({tags:["hooks"],method:"get",path:"/{hook_id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({hook_id:a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:qn}},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 N(404,{message:"Hook not found"});return t.json(r)}).openapi(a.createRoute({tags:["hooks"],method:"delete",path:"/{hook_id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({hook_id:a.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 N(404,{message:"Hook not found"});return t.text("OK")}),gw=nn.extend({connections:a.z.array(Dt)}),mw=new a.OpenAPIHono().openapi(a.createRoute({tags:["connections"],method:"get",path:"/",request:{query:Yt,headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:a.z.union([a.z.array(Dt),gw])}},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:o}=t.req.valid("query"),c=await t.env.data.connections.list(e,{page:n,per_page:r,include_totals:i,sort:cr(s),q:o});return i?t.json(c):t.json(c.connections)}).openapi(a.createRoute({tags:["connections"],method:"get",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Dt}},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 N(404);return t.json(r)}).openapi(a.createRoute({tags:["connections"],method:"delete",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.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 N(404,{message:"Connection not found"});return t.text("OK")}).openapi(a.createRoute({tags:["connections"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:a.z.object(ns.shape).partial()}}},params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Dt}},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 N(404,{message:"Connection not found"});const s=await t.env.data.connections.get(e,n);if(!s)throw new N(404,{message:"Connection not found"});return t.json(s)}).openapi(a.createRoute({tags:["connections"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:a.z.object(ns.shape)}}},headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Dt}},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})}),_w=new a.OpenAPIHono().openapi(a.createRoute({tags:["prompts"],method:"get",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Ri}},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(Ri.parse({}))}).openapi(a.createRoute({tags:["prompts"],method:"patch",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.object(Ri.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 wp=!1;function Cg(t){t.use(async(e,n)=>(wp||(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"}}}}),wp=!0),await n()))}a.z.object({alg:a.z.literal("RS256"),kty:a.z.literal("RSA"),use:a.z.literal("sig"),n:a.z.string(),e:a.z.string(),kid:a.z.string(),x5t:a.z.string(),x5c:a.z.array(a.z.string())});async function yw(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 N(500,{message:`Failed to fetch jwks: ${e.message}`})}}async function vw(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))),o=(await yw(t.env)).find(l=>l.kid===e.header.kid);if(!o)return console.log("No matching kid found"),!1;const c=await crypto.subtle.importKey("jwk",o,{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},!1,["verify"]);return crypto.subtle.verify("RSASSA-PKCS1-v1_5",c,i,r)}function ww(t){const[e,n,r]=t.split(".");if(!e||!n||!r)return null;const i=JSON.parse(atob(e)),s=JSON.parse(atob(n)),o=atob(r.replace(/-/g,"+").replace(/_/g,"/"));return{header:i,payload:s,signature:o,raw:{header:e,payload:n,signature:r}}}function Ng(t){return async(e,n)=>{var i,s,o;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 N(401,{message:"Missing bearer token"});const h=ww(p);if(!h||!await vw(e,h))throw new N(403,{message:"Invalid JWT signature"});e.set("user_id",h.payload.sub),e.set("user",h.payload);const m=h.payload.permissions||[],v=((o=h.payload.scope)==null?void 0:o.split(" "))||[];if(c.length&&!(c.some(f=>m.includes(f))||c.some(f=>v.includes(f))))throw new N(403,{message:"Unauthorized"})}return await n()}}const bw=new a.OpenAPIHono().openapi(a.createRoute({tags:["emails"],method:"get",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Li}},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 N(404,{message:"Email provider not found"});return t.json(n)}).openapi(a.createRoute({tags:["emails"],method:"post",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.object(Li.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(a.createRoute({tags:["emails"],method:"patch",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.object(Li.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")}),kw=new a.OpenAPIHono().openapi(a.createRoute({tags:["sessions"],method:"get",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Zs}},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 N(404);return t.json(r)}).openapi(a.createRoute({tags:["sessions"],method:"delete",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.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 N(404,{message:"Session not found"});return t.text("OK")}).openapi(a.createRoute({tags:["sessions"],method:"post",path:"/{id}/revoke",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.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 N(404,{message:"Session not found"});return t.text("Session deletion request accepted.",{status:202})}),xw=new a.OpenAPIHono().openapi(a.createRoute({tags:["refresh_tokens"],method:"get",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:rl}},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 N(404);return t.json(r)}).openapi(a.createRoute({tags:["refresh_tokens"],method:"delete",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.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 N(404,{message:"Session not found"});return t.text("OK")}),Sw=new a.OpenAPIHono().openapi(a.createRoute({tags:["custom-domains"],method:"get",path:"/",request:{query:Yt,headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:a.z.array(Mn)}},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(a.createRoute({tags:["custom-domains"],method:"get",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Mn}},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 N(404);return t.json(r)}).openapi(a.createRoute({tags:["custom-domains"],method:"delete",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.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 N(404,{message:"Custom domain not found"});return t.text("OK")}).openapi(a.createRoute({tags:["custom-domains"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:a.z.object(Mn.shape).partial()}}},params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Mn}},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 N(404);const s=await t.env.data.customDomains.get(e,n);if(!s)throw new N(404);return t.json(s)}).openapi(a.createRoute({tags:["custom-domains"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:a.z.object(tl.shape)}}},headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Mn}},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})});function Aw(){const t=new a.OpenAPIHono;Cg(t),t.use(Ng(t));const e=t.route("/branding",Qm).route("/custom-domains",Sw).route("/email/providers",bw).route("/users",ay).route("/keys",sw).route("/users-by-email",ow).route("/clients",cw).route("/tenants",uw).route("/logs",pw).route("/hooks",hw).route("/connections",mw).route("/prompts",_w).route("/sessions",kw).route("/refresh_tokens",xw);return e.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Management api"},security:[{oauth2:["openid","email","profile"]}]}),e}function Ew(t,e){Object.keys(e).forEach(n=>{const r=e[n];r!=null&&r.length&&t.searchParams.set(n,r)})}function Bn(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)}}var bp;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(bp||(bp={}));var kp;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(kp||(kp={}));function Iw(t){return $g(t,zw,Xr.Include)}function jg(t){return $g(t,Cw,Xr.None)}function $g(t,e,n){let r="";for(let i=0;i<t.byteLength;i+=3){let s=0,o=0;for(let c=0;c<3&&i+c<t.byteLength;c++)s=s<<8|t[i+c],o+=8;for(let c=0;c<4;c++)o>=6?(r+=e[s>>o-6&63],o-=6):o>0?(r+=e[s<<6-o&63],o=0):n===Xr.Include&&(r+="=")}return r}const zw="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Cw="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";var Xr;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(Xr||(Xr={}));var xp;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(xp||(xp={}));class Nw{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 Sp=new Nw;function wt(t,e){return(t<<32-e|t>>>e)>>>0}function jw(t){const e=new $w;return e.update(t),e.digest()}class $w{constructor(){ee(this,"blockSize",64);ee(this,"size",32);ee(this,"blocks",new Uint8Array(64));ee(this,"currentBlockSize",0);ee(this,"H",new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]));ee(this,"l",0n);ee(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),Sp.putUint64(this.blocks,this.l,this.blockSize-8),this.process();const e=new Uint8Array(32);for(let n=0;n<8;n++)Sp.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=(wt(this.w[u-2],17)^wt(this.w[u-2],19)^this.w[u-2]>>>10)>>>0,h=(wt(this.w[u-15],7)^wt(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],o=this.H[5],c=this.H[6],l=this.H[7];for(let u=0;u<64;u++){const p=(wt(s,6)^wt(s,11)^wt(s,25))>>>0,h=(s&o^~s&c)>>>0,m=l+p+h+Ow[u]+this.w[u]|0,v=(wt(e,2)^wt(e,13)^wt(e,22))>>>0,f=(e&n^e&r^n&r)>>>0,_=v+f|0;l=c,c=o,o=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]=o+this.H[5]|0,this.H[6]=c+this.H[6]|0,this.H[7]=l+this.H[7]|0}}const Ow=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 Bw{constructor(e){ee(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 Tw(t){const e=jw(new TextEncoder().encode(t));return jg(e)}function Pw(){const t=new Uint8Array(32);return crypto.getRandomValues(t),jg(t)}function Pr(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 fa(t,e){const n=new TextEncoder().encode(`${t}:${e}`);return Iw(n)}async function Ds(t){let e;try{e=await fetch(t)}catch(n){throw new Bg(n)}if(e.status===400||e.status===401){let n;try{n=await e.json()}catch{throw new Di(e.status)}if(typeof n!="object"||n===null)throw new Wn(e.status,n);let r;try{r=Og(n)}catch{throw new Wn(e.status,n)}throw r}if(e.status===200){let n;try{n=await e.json()}catch{throw new Di(e.status)}if(typeof n!="object"||n===null)throw new Wn(e.status,n);return new Bw(n)}throw e.body!==null&&await e.body.cancel(),new Di(e.status)}async function Rw(t){let e;try{e=await fetch(t)}catch(n){throw new Bg(n)}if(e.status===400||e.status===401){let n;try{n=await e.json()}catch{throw new Wn(e.status,null)}if(typeof n!="object"||n===null)throw new Wn(e.status,n);let r;try{r=Og(n)}catch{throw new Wn(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 Di(e.status)}function Og(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 Lw(e,n,r,i)}class Bg extends Error{constructor(e){super("Failed to send request",{cause:e})}}class Lw extends Error{constructor(n,r,i,s){super(`OAuth request error: ${n}`);ee(this,"code");ee(this,"description");ee(this,"uri");ee(this,"state");this.code=n,this.description=r,this.uri=i,this.state=s}}class Di extends Error{constructor(n){super("Unexpected error response");ee(this,"status");this.status=n}}class Wn extends Error{constructor(n,r){super("Unexpected error response body");ee(this,"status");ee(this,"data");this.status=n,this.data=r}}class eu{constructor(e,n,r){ee(this,"clientId");ee(this,"clientPassword");ee(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 o=new URL(e);if(o.searchParams.set("response_type","code"),o.searchParams.set("client_id",this.clientId),this.redirectURI!==null&&o.searchParams.set("redirect_uri",this.redirectURI),o.searchParams.set("state",n),r===Qr.S256){const c=Tw(i);o.searchParams.set("code_challenge_method","S256"),o.searchParams.set("code_challenge",c)}else r===Qr.Plain&&(o.searchParams.set("code_challenge_method","plain"),o.searchParams.set("code_challenge",i));return s.length>0&&o.searchParams.set("scope",s.join(" ")),o}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=Pr(e,i);if(this.clientPassword!==null){const c=fa(this.clientId,this.clientPassword);s.headers.set("Authorization",`Basic ${c}`)}return await Ds(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=Pr(e,i);if(this.clientPassword!==null){const c=fa(this.clientId,this.clientPassword);s.headers.set("Authorization",`Basic ${c}`)}return await Ds(s)}async revokeToken(e,n){const r=new URLSearchParams;r.set("token",n),this.clientPassword===null&&r.set("client_id",this.clientId);const i=Pr(e,r);if(this.clientPassword!==null){const s=fa(this.clientId,this.clientPassword);i.headers.set("Authorization",`Basic ${s}`)}await Rw(i)}}var Qr;(function(t){t[t.S256=0]="S256",t[t.Plain=1]="Plain"})(Qr||(Qr={}));var Ap;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(Ap||(Ap={}));var Ep;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(Ep||(Ep={}));function Rr(t){return Uw(t,Vw,Hs.None)}function Uw(t,e,n){let r="";for(let i=0;i<t.byteLength;i+=3){let s=0,o=0;for(let c=0;c<3&&i+c<t.byteLength;c++)s=s<<8|t[i+c],o+=8;for(let c=0;c<4;c++)o>=6?(r+=e[s>>o-6&63],o-=6):o>0?(r+=e[s<<6-o&63],o=0):n===Hs.Include&&(r+="=")}return r}const Vw="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";var Hs;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(Hs||(Hs={}));var Ip;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(Ip||(Ip={}));function Mw(t,e,n){const r=Rr(new TextEncoder().encode(t)),i=Rr(new TextEncoder().encode(e)),s=Rr(n);return r+"."+i+"."+s}function qw(t,e){const n=Rr(new TextEncoder().encode(t)),r=Rr(new TextEncoder().encode(e)),i=n+"."+r;return new TextEncoder().encode(i)}const Dw="https://appleid.apple.com/auth/authorize",Hw="https://appleid.apple.com/auth/token";class Tg{constructor(e,n,r,i,s){ee(this,"clientId");ee(this,"teamId");ee(this,"keyId");ee(this,"pkcs8PrivateKey");ee(this,"redirectURI");this.clientId=e,this.teamId=n,this.keyId=r,this.pkcs8PrivateKey=i,this.redirectURI=s}createAuthorizationURL(e,n){const r=new URL(Dw);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=Pr(Hw,n);return await Ds(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,qw(r,i)));return Mw(r,i,s)}}const Fw="https://www.facebook.com/v16.0/dialog/oauth",Kw="https://graph.facebook.com/v16.0/oauth/access_token";class Pg{constructor(e,n,r){ee(this,"clientId");ee(this,"clientSecret");ee(this,"redirectURI");this.clientId=e,this.clientSecret=n,this.redirectURI=r}createAuthorizationURL(e,n){const r=new URL(Fw);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=Pr(Kw,n);return await Ds(r)}}const Ww="https://accounts.google.com/o/oauth2/v2/auth",zp="https://oauth2.googleapis.com/token",Gw="https://oauth2.googleapis.com/revoke";let Rg=class{constructor(e,n,r){ee(this,"client");this.client=new eu(e,n,r)}createAuthorizationURL(e,n,r){return this.client.createAuthorizationURLWithPKCE(Ww,e,Qr.S256,n,r)}async validateAuthorizationCode(e,n){return await this.client.validateAuthorizationCode(zp,e,n)}async refreshAccessToken(e){return await this.client.refreshAccessToken(zp,e,[])}async revokeToken(e){await this.client.revokeToken(Gw,e)}};const Wo=a.z.object({iss:a.z.string().url(),sub:a.z.string(),aud:a.z.string(),exp:a.z.number(),email:a.z.string().optional(),given_name:a.z.string().optional(),family_name:a.z.string().optional(),name:a.z.string().optional(),iat:a.z.number(),auth_time:a.z.number().optional(),nonce:a.z.string().optional(),acr:a.z.string().optional(),amr:a.z.array(a.z.string()).optional(),azp:a.z.string().optional(),at_hash:a.z.string().optional(),c_hash:a.z.string().optional()}).passthrough();Wo.omit({iat:!0,auth_time:!0,nonce:!0,acr:!0,amr:!0,azp:!0,at_hash:!0,c_hash:!0});function Jw(t){return t.ISSUER}function At(t){return t.UNIVERSAL_LOGIN_URL||`${t.ISSUER}u/`}function Ce(t){return t.OAUTH_API_URL||t.ISSUER}function Lg(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 Zw(t,e){var l,u;const{options:n,keyArray:r}=Lg(e),i=new Tg(n.client_id,n.team_id,n.kid,r,`${Ce(t.env)}callback`),s=qe(),o=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))&&o.searchParams.set("response_mode","form_post"),{redirectUrl:o.href,code:s}}async function Yw(t,e,n){const{options:r,keyArray:i}=Lg(e),o=await new Tg(r.client_id,r.team_id,r.kid,i,`${Ce(t.env)}callback`).validateAuthorizationCode(n),c=sl(o.idToken());if(!c)throw new Error("Invalid ID token");const l=Wo.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 Xw=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:Zw,validateAuthorizationCodeAndGetUser:Yw},Symbol.toStringTag,{value:"Module"}));async function Qw(t,e){var o;const{options:n}=e;if(!(n!=null&&n.client_id)||!n.client_secret)throw new Error("Missing required authentication parameters");const r=new Pg(n.client_id,n.client_secret,`${Ce(t.env)}callback`),i=qe();return{redirectUrl:r.createAuthorizationURL(i,((o=n.scope)==null?void 0:o.split(" "))||["email"]).href,code:i}}async function eb(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 Pg(r.client_id,r.client_secret,`${Ce(t.env)}callback`).validateAuthorizationCode(n),o=await fetch("https://graph.facebook.com/v16.0/me?fields=id,email,name",{headers:{Authorization:`Bearer ${s.accessToken()}`}});if(!o.ok)throw new Error("Failed to fetch user info");const c=await o.json();return t.set("log",`Userinfo: ${JSON.stringify(c)}`),{sub:c.id,email:c.email,name:c.name}}const tb=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:Qw,validateAuthorizationCodeAndGetUser:eb},Symbol.toStringTag,{value:"Module"}));async function nb(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 Rg(n.client_id,n.client_secret,`${Ce(t.env)}callback`),i=qe(),s=Pw();return{redirectUrl:r.createAuthorizationURL(i,s,((c=n.scope)==null?void 0:c.split(" "))??["email","profile"]).href,code:i,codeVerifier:s}}async function rb(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 o=await new Rg(i.client_id,i.client_secret,`${Ce(t.env)}callback`).validateAuthorizationCode(n,r),c=sl(o.idToken());if(!c)throw new Error("Invalid ID token");const l=Wo.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 o;const{options:n}=e;if(!(n!=null&&n.client_id)||!n.client_secret)throw new Error("Missing required authentication parameters");const r=new eu(n.client_id,n.client_secret,`${Ce(t.env)}callback`),i=qe(),s=r.createAuthorizationURL("https://api.vipps.no/access-management-1.0/access/oauth2/auth",i,((o=n.scope)==null?void 0:o.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 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 eu(r.client_id,r.client_secret,`${Ce(t.env)}callback`).validateAuthorizationCode("https://api.vipps.no/access-management-1.0/access/oauth2/token",n,null),o=sl(s.idToken());if(!o)throw new Error("Invalid ID token");const c=Wo.parse(o.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 N(400,{message:"Failed to get user from vipps"});return await l.json()}const ab=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:sb,validateAuthorizationCodeAndGetUser:ob},Symbol.toStringTag,{value:"Module"}));function Ug(t,e){const n=t.env.STRATEGIES||{},i={apple:Xw,facebook:tb,"google-oauth2":ib,vipps:ab,...n}[e];if(!i)throw new Error(`Strategy ${e} not found`);return i}async function Go(t,e){const n=await t.data.clients.get(e);if(!n)throw new N(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:[]},o=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?Dt.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||[],`${At(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||[],`${At(t)}info`],connections:o,tenant:{...(r==null?void 0:r.tenant)||{},...n.tenant}}}function Jo(t,e=[],n={}){try{const r=new URL(t);return e.some(i=>{try{return cb(r,new URL(i),n.allowPathWildcards)}catch{return!1}})}catch{return!1}}function cb(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 lb(t,e,n,r){if(!r.state)throw new N(400,{message:"State not found"});const i=e.connections.find(l=>l.name===n);if(!i){t.set("client_id",e.id);const l=be(t,{type:me.FAILED_LOGIN,description:"Connection not found"});throw await t.env.data.logs.create(e.tenant.id,l),new N(403,{message:"Connection Not Found"})}let s=await t.env.data.logins.get(e.tenant.id,r.state);s||(s=await t.env.data.logins.create(e.tenant.id,{expires_at:new Date(Date.now()+Ur*1e3).toISOString(),authParams:r,...Bn(t.req)}));const c=await Ug(t,i.strategy).getRedirect(t,i);return await t.env.data.codes.create(e.tenant.id,{login_id:s.login_id,code_id:c.code,code_type:"oauth2_state",connection_id:i.id,code_verifier:c.codeVerifier,expires_at:new Date(Date.now()+x_*1e3).toISOString()}),t.redirect(c.redirectUrl)}async function Cp(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 N(403,{message:"State not found"});const s=await r.data.logins.get(t.var.tenant_id||"",i.login_id);if(!s)throw new N(403,{message:"Session not found"});const o=await Go(r,s.authParams.client_id);t.set("client_id",o.id),t.set("tenant_id",o.tenant.id);const c=o.connections.find(_=>_.id===i.connection_id);if(!c){const _=be(t,{type:me.FAILED_LOGIN,description:"Connection not found"});throw await r.data.logs.create(o.tenant.id,_),new N(403,{message:"Connection not found"})}if(t.set("connection",c.name),!s.authParams.redirect_uri){const _=be(t,{type:me.FAILED_LOGIN,description:"Redirect URI not defined"});throw await r.data.logs.create(o.tenant.id,_),new N(403,{message:"Redirect URI not defined"})}if(!Jo(s.authParams.redirect_uri,o.callbacks||[],{allowPathWildcards:!0})){const _=`Invalid redirect URI - ${s.authParams.redirect_uri}`,w=be(t,{type:me.FAILED_LOGIN,description:_});throw await r.data.logs.create(o.tenant.id,w),new N(403,{message:_})}const u=await Ug(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 no(t,{client:o,email:m,provider:c.strategy,connection:c.name,userId:p,profileData:h,isSocial:!0,ip:t.req.header("x-real-ip")});return sn(t,{client:o,authParams:s.authParams,loginSession:s,user:v})}async function Np(t,e,n,r,i,s){const o=await t.env.data.codes.get(t.var.tenant_id||"",e,"oauth2_state");if(!o)throw new N(400,{message:"State not found"});const c=await t.env.data.logins.get(t.var.tenant_id,o.login_id);if(!c)throw new N(400,{message:"Login not found"});const{redirect_uri:l}=c.authParams;if(!l)throw new N(400,{message:"Redirect uri not found"});const u=be(t,{type:me.FAILED_LOGIN,description:`Failed connection login: ${i} ${n}, ${r}`});Qe(t,t.env.data.logs.create(t.var.tenant_id,u));const p=new URL(l);return Ew(p,{error:n,error_description:r,error_reason:s,error_code:i,state:c.authParams.state}),t.redirect(`${At(t.env)}enter-email?state=${c.login_id}&error=${n}`)}const ub=new a.OpenAPIHono().openapi(a.createRoute({tags:["oauth2"],method:"get",path:"/",request:{query:a.z.object({state:a.z.string(),code:a.z.string().optional(),scope:a.z.string().optional(),hd:a.z.string().optional(),error:a.z.string().optional(),error_description:a.z.string().optional(),error_code:a.z.string().optional(),error_reason:a.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:o}=t.req.valid("query");if(r)return Np(t,e,r,i,s,o);if(!n)throw new N(400,{message:"Code is required"});return Cp(t,{code:n,state:e})}).openapi(a.createRoute({tags:["oauth2"],method:"post",path:"/",request:{body:{content:{"application/x-www-form-urlencoded":{schema:a.z.object({state:a.z.string(),code:a.z.string().optional(),scope:a.z.string().optional(),hd:a.z.string().optional(),error:a.z.string().optional(),error_description:a.z.string().optional(),error_code:a.z.string().optional(),error_reason:a.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:o}=t.req.valid("form");if(r)return Np(t,e,r,i,s,o);if(!n)throw new N(400,{message:"Code is required"});return Cp(t,{code:n,state:e})}),db=new a.OpenAPIHono().openapi(a.createRoute({tags:["oauth2"],method:"get",path:"/",request:{query:a.z.object({client_id:a.z.string(),returnTo:a.z.string().optional()}),header:a.z.object({cookie:a.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(!Jo(s,[...r.allowed_logout_urls||[],...(i==null?void 0:i.allowed_logout_urls)||[]],{allowPathWildcards:!0}))throw new N(400,{message:"Invalid redirect uri"});const o=t.req.header("cookie");if(o){const l=as(r.tenant.id,o);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))}await t.env.data.sessions.remove(r.tenant.id,l)}}const c=be(t,{type:me.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":z_(r.tenant.id),location:s}})}),jp=a.z.object({sub:a.z.string(),email:a.z.string().optional(),family_name:a.z.string().optional(),given_name:a.z.string().optional(),email_verified:a.z.boolean()}),pb=new a.OpenAPIHono().openapi(a.createRoute({tags:["oauth2"],method:"get",path:"/",request:{},security:[{Bearer:["openid"]}],responses:{200:{content:{"application/json":{schema:jp}},description:"Userinfo"}}}),async t=>{if(!t.var.user)throw new N(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 N(404,{message:"User not found"});return t.json(jp.parse({...e,sub:e.user_id}))}),fb=new a.OpenAPIHono().openapi(a.createRoute({tags:["well known"],method:"get",path:"/jwks.json",request:{},responses:{200:{content:{"application/json":{schema:cf}},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 Ql(r.cert).publicKey.export(),o=await crypto.subtle.exportKey("jwk",s);return nl.parse({...o,kid:r.kid})}));return t.json({keys:n},{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${Ni}, stale-while-revalidate=${Ni*2}, stale-if-error=86400`}})}).openapi(a.createRoute({tags:["well known"],method:"get",path:"/openid-configuration",request:{},responses:{200:{content:{"application/json":{schema:Aa}},description:"List of tenants"}}}),async t=>{const e=Aa.parse({issuer:Jw(t.env),authorization_endpoint:`${Ce(t.env)}authorize`,token_endpoint:`${Ce(t.env)}oauth/token`,device_authorization_endpoint:`${Ce(t.env)}oauth/device/code`,userinfo_endpoint:`${Ce(t.env)}userinfo`,mfa_challenge_endpoint:`${Ce(t.env)}mfa/challenge`,jwks_uri:`${Ce(t.env)}.well-known/jwks.json`,registration_endpoint:`${Ce(t.env)}oidc/register`,revocation_endpoint:`${Ce(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=${Ni}, stale-while-revalidate=${Ni*2}, stale-if-error=86400`}})});function Hi(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 Vg=a.z.object({grant_type:a.z.literal("client_credentials"),scope:a.z.string().optional(),client_secret:a.z.string(),client_id:a.z.string(),audience:a.z.string().optional()});async function hb(t,e){const n=await t.env.data.clients.get(e.client_id);if(!n)throw new N(403,{message:"Invalid client credentials"});if(n.client_secret&&!Hi(n.client_secret,e.client_secret))throw new N(403,{message:"Invalid client credentials"});const r={client_id:n.id,scope:e.scope,audience:e.audience},i=await eo(t,{authParams:r,client:n});return t.json(i)}const gb=a.z.object({grant_type:a.z.literal("authorization_code"),client_id:a.z.string(),code:a.z.string(),redirect_uri:a.z.string().optional(),client_secret:a.z.string().optional(),code_verifier:a.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 mb(t,e){const n=await t.env.data.clients.get(e.client_id);if(!n)throw new N(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 N(403,{message:"Invalid client credentials"});if(new Date(r.expires_at)<new Date)throw new N(403,{message:"Code expired"});if(r.used_at)throw new N(403,{message:"Code already used"});const i=await t.env.data.logins.get(n.tenant.id,r.login_id);if(!i)throw new N(403,{message:"Invalid login"});if("client_secret"in e){const o=await t.env.data.clients.get("DEFAULT_CLIENT");if(!Hi(n.client_secret,e.client_secret)&&!Hi(o==null?void 0:o.client_secret,e.client_secret))throw new N(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 o=await w_(e.code_verifier,i.authParams.code_challenge_method);if(!Hi(o,i.authParams.code_challenge||""))throw new N(403,{message:"Invalid client credentials"})}if(i.authParams.redirect_uri&&i.authParams.redirect_uri!==e.redirect_uri)throw new N(403,{message:"Invalid redirect uri"});const s=await t.env.data.users.get(n.tenant.id,r.user_id);if(!s)throw new N(403,{message:"User not found"});return await t.env.data.codes.used(n.tenant.id,e.code),sn(t,{user:s,client:n,loginSession:i,authParams:{...i.authParams,response_mode:Zt.WEB_MESSAGE}})}const _b=a.z.object({grant_type:a.z.literal("refresh_token"),client_id:a.z.string(),redirect_uri:a.z.string().optional(),refresh_token:a.z.string()});async function yb(t,e){const n=await t.env.data.clients.get(e.client_id);if(!n)throw new N(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 N(403,{message:JSON.stringify({error:"invalid_grant",error_description:"Refresh token has expired"})})}else throw new N(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 N(403,{message:"User not found"});const s=r.resource_servers[0];if(r.idle_expires_at){const o=new Date(Date.now()+2592e6);await t.env.data.refreshTokens.update(n.tenant.id,r.id,{idle_expires_at:o.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 sn(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:Zt.WEB_MESSAGE}})}const $p=a.z.object({client_id:a.z.string().optional(),client_secret:a.z.string().optional()}),vb=a.z.union([Vg.extend($p.shape),a.z.object({grant_type:a.z.literal("authorization_code"),client_id:a.z.string(),code:a.z.string(),redirect_uri:a.z.string(),code_verifier:a.z.string().min(43).max(128)}),a.z.object({grant_type:a.z.literal("authorization_code"),code:a.z.string(),redirect_uri:a.z.string().optional(),...$p.shape}),a.z.object({grant_type:a.z.literal("refresh_token"),client_id:a.z.string(),refresh_token:a.z.string(),redirect_uri:a.z.string().optional()})]);function wb(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 bb=new a.OpenAPIHono().openapi(a.createRoute({tags:["oauth2"],method:"post",path:"/",request:{body:{content:{"application/x-www-form-urlencoded":{schema:vb}}}},responses:{200:{content:{"application/json":{schema:hf}},description:"Tokens"}}}),async t=>{const e=t.req.valid("form"),n=wb(t.req.header("Authorization")),r={...e,...n};if(!r.client_id)throw new N(400,{message:"client_id is required"});switch(e.grant_type){case jr.AuthorizationCode:return mb(t,gb.parse(r));case jr.ClientCredential:return hb(t,Vg.parse(r));case jr.RefreshToken:return yb(t,_b.parse(r));default:throw new N(400,{message:"Not implemented"})}});var tu={exports:{}};const nu=[{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}],Mg=(t,e=nu,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 o=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,o[0]),s};tu.exports={passwordStrength:Mg,defaultOptions:nu};var kb=tu.exports.passwordStrength=Mg;tu.exports.defaultOptions=nu;function ru(t){return kb(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 Zo(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 N(500,{message:"Email provider not found"});const r=(i=t.env.emailProviders)==null?void 0:i[n.name];if(!r)throw new N(500,{message:"Email provider not found"});await r({emailProvider:n,...e,from:n.default_from_address||`login@${t.env.ISSUER}`})}async function qg(t,e,n,r){const i=await t.env.data.tenants.get(t.var.tenant_id);if(!i)throw new N(500,{message:"Tenant not found"});const s=`${At(t.env)}reset-password?state=${r}&code=${n}`,o={vendorName:i.name,lng:i.language||"en"};await Zo(t,{to:e,subject:"Reset your password",html:`Click here to reset your password: ${At(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:de("password_reset_title",o),resetPasswordEmailClickToReset:de("reset_password_email_click_to_reset",o),resetPasswordEmailReset:de("reset_password_email_reset",o),supportInfo:de("support_info",o),contactUs:de("contact_us",o),copyright:de("copyright",o)}})}async function Dg(t,e,n){const r=await t.env.data.tenants.get(t.var.tenant_id);if(!r)throw new N(500,{message:"Tenant not found"});const i={vendorName:r.name,code:n,lng:r.language||"en"};await Zo(t,{to:e,subject:de("code_email_subject",i),html:`Click here to validate your email: ${At(t.env)}validate-email`,template:"auth-link",data:{code:n,vendorName:r.name,logo:r.logo||"",supportUrl:r.support_url||"",magicLink:`${Ce(t.env)}passwordless/verify_redirect?ticket=${n}`,buttonColor:r.primary_color||"",welcomeToYourAccount:de("welcome_to_your_account",i),linkEmailClickToLogin:de("link_email_click_to_login",i),linkEmailLogin:de("link_email_login",i),linkEmailOrEnterCode:de("link_email_or_enter_code",i),codeValid30Mins:de("code_valid_30_minutes",i),supportInfo:de("support_info",i),contactUs:de("contact_us",i),copyright:de("copyright",i)}});const s=be(t,{type:me.CODE_LINK_SENT,description:e});Qe(t,t.env.data.logs.create(r.id,s))}async function iu(t,e,n,r){const i=await t.env.data.tenants.get(t.var.tenant_id);if(!i)throw new N(500,{message:"Tenant not found"});if(!r.redirect_uri)throw new N(400,{message:"redirect_uri is required"});const s=new URL(Ce(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 o={vendorName:i.name,code:n,lng:i.language||"en"};await Zo(t,{to:e,subject:de("code_email_subject",o),html:`Click here to validate your email: ${At(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:de("welcome_to_your_account",o),linkEmailClickToLogin:de("link_email_click_to_login",o),linkEmailLogin:de("link_email_login",o),linkEmailOrEnterCode:de("link_email_or_enter_code",o),codeValid30Mins:de("code_valid_30_minutes",o),supportInfo:de("support_info",o),contactUs:de("contact_us",o),copyright:de("copyright",o)}});const c=be(t,{type:me.CODE_LINK_SENT,description:e});Qe(t,t.env.data.logs.create(i.id,c))}async function su(t,e){const n=await t.env.data.tenants.get(t.var.tenant_id);if(!n)throw new N(500,{message:"Tenant not found"});const r={vendorName:n.name,lng:n.language||"en"};await Zo(t,{to:e.email,subject:"Validate your email address",html:`Click here to validate your email: ${At(t.env)}validate-email`,template:"auth-verify-email",data:{vendorName:n.name,logo:n.logo||"",emailValidationUrl:`${At(t.env)}validate-email`,supportUrl:n.support_url||"https://support.sesamy.com",buttonColor:n.primary_color||"#7d68f4",welcomeToYourAccount:de("welcome_to_your_account",r),verifyEmailVerify:de("verify_email_verify",r),supportInfo:de("support_info",r),contactUs:de("contact_us",r),copyright:de("copyright",r)}})}const xb=new a.OpenAPIHono().openapi(a.createRoute({tags:["dbconnections"],method:"post",path:"/signup",request:{body:{content:{"application/json":{schema:a.z.object({client_id:a.z.string(),connection:a.z.literal("Username-Password-Authentication"),email:a.z.string().transform(t=>t.toLowerCase()),password:a.z.string()})}}}},responses:{200:{content:{"application/json":{schema:a.z.object({_id:a.z.string(),email:a.z.string(),email_verified:a.z.boolean(),app_metadata:a.z.object({}),user_metadata:a.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 N(400,{message:"Client not found"});if(t.set("client_id",i.id),t.set("tenant_id",i.tenant.id),!ru(n))throw new N(400,{message:"Password does not meet the requirements"});if(await cs({userAdapter:t.env.data.users,tenant_id:i.tenant.id,email:e,provider:"auth2"}))throw new N(400,{message:"Invalid sign up"});const o=await t.env.data.users.create(i.tenant.id,{user_id:`auth2|${Ys()}`,email:e,email_verified:!1,provider:"auth2",connection:"Username-Password-Authentication",is_social:!1});t.set("user_id",o.user_id),t.set("username",o.email),t.set("connection",o.connection);const c=await ii.hash(n,10);await t.env.data.passwords.create(i.tenant.id,{user_id:o.user_id,password:c,algorithm:"bcrypt"}),await su(t,o);const l=be(t,{type:me.SUCCESS_SIGNUP,description:"Successful signup"});return await t.env.data.logs.create(i.tenant.id,l),t.json({_id:o.user_id,email:o.email,email_verified:!1,app_metadata:{},user_metadata:{}})}).openapi(a.createRoute({tags:["dbconnections"],method:"post",path:"/change_password",request:{body:{content:{"application/json":{schema:a.z.object({client_id:a.z.string(),connection:a.z.literal("Username-Password-Authentication"),email:a.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 N(400,{message:"Client not found"});if(t.set("client_id",r.id),t.set("tenant_id",r.tenant.id),!await si({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},o=await t.env.data.logins.create(r.tenant.id,{expires_at:new Date(Date.now()+Ur*1e3).toISOString(),authParams:s,...Bn(t.req)});return await qg(t,e,o.login_id,o.authParams.state),t.html("If an account with that email exists, we've sent instructions to reset your password.")});function sr(){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 ou(t,e,n,r,i,s){const{env:o}=t,c=await o.data.codes.get(e.tenant.id,i,"otp");if(!c)throw new N(400,{message:"Code not found or expired"});if(c.expires_at<new Date().toISOString())throw new N(400,{message:"Code expired"});if(c.used_at)throw new N(400,{message:"Code already used"});const l=await o.data.logins.get(e.tenant.id,c.login_id);if(!l||l.authParams.username!==r)throw new N(400,{message:"Code not found or expired"});const u=Bn(t.req);if(l.ip!==u.ip)return t.redirect(`${At(t.env)}invalid-session?state=${l.login_id}`);if(n.redirect_uri&&!Jo(n.redirect_uri,e.callbacks,{allowPathWildcards:!0}))throw new N(400,{message:`Invalid redirect URI - ${n.redirect_uri}`});const p=await no(t,{client:e,email:r,provider:"email",connection:"email",isSocial:!1,ip:t.req.header("x-real-ip")});return await o.data.codes.used(e.tenant.id,i),sn(t,{user:p,client:e,loginSession:l,authParams:n,ticketAuth:s})}const Sb=new a.OpenAPIHono().openapi(a.createRoute({tags:["passwordless"],method:"post",path:"/start",request:{body:{content:{"application/json":{schema:a.z.object({client_id:a.z.string(),connection:a.z.string(),email:a.z.string().transform(t=>t.toLowerCase()),send:a.z.enum(["link","code"]),authParams:el.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:o}=e,c=await t.env.data.clients.get(r);if(!c)throw new N(400,{message:"Client not found"});t.set("client_id",c.id),t.set("tenant_id",c.tenant.id);const l=await n.data.logins.create(c.tenant.id,{authParams:{...o,client_id:r,username:i},expires_at:new Date(Date.now()+za).toISOString(),...Bn(t.req)}),u=await n.data.codes.create(c.tenant.id,{code_id:sr(),code_type:"otp",login_id:l.login_id,expires_at:new Date(Date.now()+za).toISOString()});return s==="link"?await iu(t,i,u.code_id,{...o,client_id:r}):await Dg(t,i,u.code_id),t.html("OK")}).openapi(a.createRoute({tags:["passwordless"],method:"get",path:"/verify_redirect",request:{query:a.z.object({scope:a.z.string(),response_type:a.z.nativeEnum(Jt),redirect_uri:a.z.string(),state:a.z.string(),nonce:a.z.string().optional(),verification_code:a.z.string(),connection:a.z.string(),client_id:a.z.string(),email:a.z.string().transform(t=>t.toLowerCase()),audience:a.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:o,scope:c,audience:l,response_type:u,nonce:p}=t.req.valid("query"),h=await Go(e,n);return t.set("client_id",h.id),t.set("tenant_id",h.tenant.id),t.set("connection","email"),ou(t,h,{client_id:n,redirect_uri:s,state:o,nonce:p,scope:c,audience:l,response_type:u},r,i)});class Er extends N{constructor(n,r){super(n,r);ee(this,"_code");this._code=r==null?void 0:r.code}get code(){return this._code}}async function au(t,e,n,r,i){const{env:s}=t,o=n.username;if(t.set("username",o),!o)throw new N(400,{message:"Username is required"});const c=await si({userAdapter:t.env.data.users,tenant_id:e.tenant.id,email:o,provider:"auth2"});if(!c){const f=be(t,{type:me.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid user"});throw Qe(t,t.env.data.logs.create(e.tenant.id,f)),new Er(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 Er(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 ii.compare(n.password,u.password))){const f=be(t,{type:me.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid password"});throw Qe(t,t.env.data.logs.create(e.tenant.id,f)),new Er(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===me.FAILED_LOGIN_INCORRECT_PASSWORD&&new Date(f.date)>new Date(Date.now()-1e3*60*5)).length>=3){const f=be(t,{type:me.FAILED_LOGIN,description:"Too many failed login attempts"});throw Qe(t,t.env.data.logs.create(e.tenant.id,f)),new Er(403,{message:"Too many failed login attempts",code:"TOO_MANY_FAILED_LOGINS"})}if(!c.email_verified&&e.email_validation==="enforced"){await su(t,c);const f=be(t,{type:me.FAILED_LOGIN,description:"Email not verified"});throw await t.env.data.logs.create(e.tenant.id,f),new Er(403,{message:"Email not verified",code:"EMAIL_NOT_VERIFIED"})}const v=be(t,{type:me.SUCCESS_LOGIN,description:"Successful login",strategy_type:"Username-Password-Authentication",strategy:"Username-Password-Authentication"});return Qe(t,t.env.data.logs.create(e.tenant.id,v)),sn(t,{client:e,authParams:n,user:l,ticketAuth:i,loginSession:r})}async function Ab(t,e,n,r){await no(t,{client:e,email:n,provider:"auth2",connection:"Username-Password-Authentication",isSocial:!1,ip:t.req.header("x-real-ip")});let i=sr(),s=await t.env.data.codes.get(e.tenant.id,i,"password_reset");for(;s;)i=sr(),s=await t.env.data.codes.get(e.tenant.id,i,"password_reset");const o=await t.env.data.logins.create(e.tenant.id,{expires_at:new Date(Date.now()+E_).toISOString(),authParams:{client_id:e.id,username:n},...Bn(t.req)}),c=await t.env.data.codes.create(e.tenant.id,{code_id:i,code_type:"password_reset",login_id:o.login_id,expires_at:new Date(Date.now()+A_).toISOString()});await qg(t,n,c.code_id,r)}const Eb=new a.OpenAPIHono().openapi(a.createRoute({tags:["oauth"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:a.z.union([a.z.object({credential_type:a.z.literal("http://auth0.com/oauth/grant-type/passwordless/otp"),otp:a.z.string(),client_id:a.z.string(),username:a.z.string().transform(t=>t.toLowerCase()),realm:a.z.enum(["email"]),scope:a.z.string().optional()}),a.z.object({credential_type:a.z.literal("http://auth0.com/oauth/grant-type/password-realm"),client_id:a.z.string(),username:a.z.string().transform(t=>t.toLowerCase()),password:a.z.string(),realm:a.z.enum(["Username-Password-Authentication"]),scope:a.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 N(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 ou(t,i,{client_id:n,username:s},s,e.otp,!0);if("password"in e){const o=await t.env.data.logins.create(i.tenant.id,{expires_at:new Date(Date.now()+Ur*1e3).toISOString(),authParams:{client_id:n,username:s},...Bn(t.req)});return au(t,i,{username:s,password:e.password,client_id:n},o,!0)}else throw new N(400,{message:"Code or password required"})});function Ib(t,e){var r,i,s;if(!t||e.length===0)return!1;const n=((r=ha(t))==null?void 0:r.host)??null;if(!n)return!1;for(const o of e){let c;if(o.startsWith("http://")||o.startsWith("https://")?c=((i=ha(o))==null?void 0:i.host)??null:c=((s=ha("https://"+o))==null?void 0:s.host)??null,n===c)return!0}return!1}function ha(t){try{return new URL(t)}catch{return null}}async function zb({ctx:t,session:e,client:n,authParams:r,connection:i,login_hint:s}){const o=await t.env.data.logins.create(n.tenant.id,{expires_at:new Date(Date.now()+Ur*1e3).toISOString(),authParams:r,...Bn(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 sn(t,{client:n,loginSession:o,authParams:r,user:c,sessionId:e.id})}if(i==="email"&&s){const c=sr();return await t.env.data.codes.create(n.tenant.id,{code_id:c,code_type:"otp",login_id:o.login_id,expires_at:new Date(Date.now()+Ur*1e3).toISOString()}),await iu(t,s,c,r),t.redirect(`/u/enter-code?state=${o.login_id}`)}return e?t.redirect(`/u/check-account?state=${o.login_id}`):t.redirect(`/u/enter-email?state=${o.login_id}`)}function Cb(t){if(t==="Username-Password-Authentication")return"auth2";if(t==="email")return"email";throw new N(403,{message:"Invalid realm"})}async function Nb(t,e,n,r,i){var m;const{env:s}=t;t.set("connection",i);const o=await s.data.codes.get(e,n,"ticket");if(!o||o.used_at)throw new N(403,{message:"Ticket not found"});const c=await s.data.logins.get(e,o.login_id);if(!c||!c.authParams.username)throw new N(403,{message:"Session not found"});const l=await s.data.clients.get(c.authParams.client_id);if(!l)throw new N(403,{message:"Client not found"});t.set("client_id",c.authParams.client_id),await s.data.codes.used(e,n);const u=Cb(i);let p=await no(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 Tf(t,{user:p,client:l,scope:r.scope,audience:r.audience});return sn(t,{authParams:{scope:(m=c.authParams)==null?void 0:m.scope,...r},loginSession:c,sessionId:h.id,user:p,client:l})}async function Op(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 Cb({ctx:t,client:e,session:n,redirect_uri:r,state:i,nonce:s,code_challenge_method:o,code_challenge:c,audience:l,scope:u,response_type:p}){const{env:h}=t,m=new URL(r);if(n!=null&&n.expires_at&&new Date(n.expires_at)>new Date){t.set("user_id",n.user_id);const f=new Headers,_=zg(e.tenant.id,n.id);f.set("set-cookie",_);const w=await h.data.users.get(e.tenant.id,n.user_id);if(w){t.set("username",w.email),t.set("connection",w.connection);const S=await Jo(t,{client:e,authParams:{client_id:e.id,audience:l,code_challenge_method:o,code_challenge:c,scope:u,state:i,nonce:s,response_type:p},user:w,session_id:n.id});await h.data.sessions.update(e.tenant.id,n.id,{used_at:new Date().toISOString(),expires_at:new Date(Date.now()+Ho*1e3).toISOString()});const N=be(t,{type:me.SUCCESS_SILENT_AUTH,description:"Successful silent authentication"});return await t.env.data.logs.create(e.tenant.id,N),t.html(Op(`${m.protocol}//${m.host}`,JSON.stringify(S)),{headers:f})}}const v=be(t,{type:me.FAILED_SILENT_AUTH,description:"Login required"});return await t.env.data.logs.create(e.tenant.id,v),t.html(Op(`${m.protocol}//${m.host}`,JSON.stringify({error:"login_required",error_description:"Login required",state:i})))}const Nb=new a.OpenAPIHono().openapi(a.createRoute({tags:["oauth"],method:"get",path:"/",request:{query:a.z.object({client_id:a.z.string(),vendor_id:a.z.string().optional(),redirect_uri:a.z.string(),scope:a.z.string().optional(),state:a.z.string(),prompt:a.z.string().optional(),response_mode:a.z.nativeEnum(Zt).optional(),response_type:a.z.nativeEnum(Jt).optional(),audience:a.z.string().optional(),connection:a.z.string().optional(),nonce:a.z.string().optional(),max_age:a.z.string().optional(),login_ticket:a.z.string().optional(),code_challenge_method:a.z.nativeEnum(Zs).optional(),code_challenge:a.z.string().optional(),realm:a.z.string().optional(),auth0Client:a.z.string().optional(),login_hint:a.z.string().optional(),ui_locales:a.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:o,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:N,ui_locales:B}=t.req.valid("query");t.set("log","authorize");const R=await Ko(e,n);t.set("client_id",R.id),t.set("tenant_id",R.tenant.id);const te={redirect_uri:i,scope:s,state:o,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:N,ui_locales:B},fe=t.req.header("origin");if(fe&&!Ab(fe,R.web_origins||[]))throw new C(403,{message:`Origin ${fe} not allowed`});if(te.redirect_uri&&!Wo(te.redirect_uri,R.callbacks||[],{allowPathWildcards:!0}))throw new C(400,{message:`Invalid redirect URI - ${te.redirect_uri}`});const le=Fs(R.tenant.id,t.req.header("cookie")),Ve=le?await e.data.sessions.get(R.tenant.id,le):void 0;if(f=="none"){if(!p)throw new C(400,{message:"Missing response_type"});return Cb({ctx:t,session:Ve||void 0,redirect_uri:i,state:o,response_type:p,client:R,nonce:l,code_challenge_method:v,code_challenge:m,audience:c,scope:s})}return u&&u!=="email"?ab(t,R,u,te):_?zb(t,R.tenant.id,_,te,w):Eb({ctx:t,client:R,auth0Client:S,authParams:te,session:Ve||void 0,connection:u,login_hint:N})});function jb(){const t=new a.OpenAPIHono;t.use(_g(t));const e=t.route("/v2/logout",lb).route("/userinfo",ub).route("/.well-known",db).route("/oauth/token",vb).route("/dbconnections",bb).route("/passwordless",kb).route("/co/authenticate",Sb).route("/authorize",Nb).route("/callback",cb);return e.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Oauth API"},security:[{oauth2:["openid","email","profile"]}]}),mg(e),e}var $b={Stringify:1,BeforeStream:2,Stream:3},ft=(t,e)=>{const n=new String(t);return n.isEscaped=!0,n.callbacks=e,n},Ob=/[&<>'"]/,qg=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 o=s.isEscaped;if(s=await(typeof s=="object"?s.toString():s),typeof s=="object"&&e.push(...s.callbacks||[]),s.isEscaped??o)n+=s;else{const c=[n];Gt(s,c),n=c[0]}}return ft(n,e)},Gt=(t,e)=>{const n=t.search(Ob);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=""";break;case 39:r="'";break;case 38:r="&";break;case 60:r="<";break;case 62:r=">";break;default:continue}e[0]+=t.substring(s,i)+r,s=i+1}e[0]+=t.substring(s,i)},Dg=t=>{const e=t.callbacks;if(!(e!=null&&e.length))return t;const n=[t],r={};return e.forEach(i=>i({phase:$b.Stringify,buffer:n,context:r})),n[0]},Bb=(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 o=0,c=s.length;o<c;o++){const l=s[o];if(typeof l=="string")Gt(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):Gt(l.toString(),n)}}}return n[0]+=t[t.length-1],n.length===1?"callbacks"in n?ft(Dg(ft(n[0],n.callbacks))):ft(n[0]):qg(n,n.callbacks)},cu=Symbol("RENDERER"),Jc=Symbol("ERROR_HANDLER"),Se=Symbol("STASH"),Hg=Symbol("INTERNAL"),Tb=Symbol("MEMO"),Ks=Symbol("PERMALINK"),Bp=t=>(t[Hg]=!0,t),Fg=t=>({value:e,children:n})=>{if(!n)return;const r={children:[{tag:Bp(()=>{t.push(e)}),props:{}}]};Array.isArray(n)?r.children.push(...n.flat()):r.children.push(n),r.children.push({tag:Bp(()=>{t.pop()}),props:{}});const i={tag:"",props:r,type:""};return i[Jc]=s=>{throw t.pop(),s},i},Kg=t=>{const e=[t],n=Fg(e);return n.values=e,n.Provider=n,cr.push(n),n},cr=[],Pb=t=>{const e=[t],n=r=>{e.push(r.value);let i;try{i=r.children?(Array.isArray(r.children)?new Zg("",{},r.children):r.children).toString():""}finally{e.pop()}return i instanceof Promise?i.then(s=>ft(s,s.callbacks)):ft(i)};return n.values=e,n.Provider=n,n[cu]=Fg(e),cr.push(n),n},br=t=>t.values.at(-1),Wi={title:[],script:["src"],style:["data-href"],link:["href"],meta:["name","httpEquiv","charset","itemProp"]},Zc={},Gi="data-precedence",Ei=t=>Array.isArray(t)?t:[t],Tp=new WeakMap,Pp=(t,e,n,r)=>({buffer:i,context:s})=>{if(!i)return;const o=Tp.get(s)||{};Tp.set(s,o);const c=o[t]||(o[t]=[]);let l=!1;const u=Wi[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(""))}},Ii=(t,e,n)=>ft(new ht(t,n,Ei(e??[])).toString()),zi=(t,e,n,r)=>{if("itemProp"in n)return Ii(t,e,n);let{precedence:i,blocking:s,...o}=n;i=r?i??"":void 0,r&&(o[Gi]=i);const c=new ht(t,o,Ei(e||[])).toString();return c instanceof Promise?c.then(l=>ft(c,[...l.callbacks||[],Pp(t,l,o,i)])):ft(c,[Pp(t,c,o,i)])},Rb=({children:t,...e})=>{const n=lu();if(n){const r=br(n);if(r==="svg"||r==="head")return new ht("title",e,Ei(t??[]))}return zi("title",t,e,!1)},Lb=({children:t,...e})=>{const n=lu();return["src","async"].some(r=>!e[r])||n&&br(n)==="head"?Ii("script",t,e):zi("script",t,e,!1)},Ub=({children:t,...e})=>["href","precedence"].every(n=>n in e)?(e["data-href"]=e.href,delete e.href,zi("style",t,e,!0)):Ii("style",t,e),Vb=({children:t,...e})=>["onLoad","onError"].some(n=>n in e)||e.rel==="stylesheet"&&(!("precedence"in e)||"disabled"in e)?Ii("link",t,e):zi("link",t,e,"precedence"in e),Mb=({children:t,...e})=>{const n=lu();return n&&br(n)==="head"?Ii("meta",t,e):zi("meta",t,e,!1)},Wg=(t,{children:e,...n})=>new ht(t,n,Ei(e??[])),qb=t=>(typeof t.action=="function"&&(t.action=Ks in t.action?t.action[Ks]:void 0),Wg("form",t)),Gg=(t,e)=>(typeof e.formAction=="function"&&(e.formAction=Ks in e.formAction?e.formAction[Ks]:void 0),Wg(t,e)),Db=t=>Gg("input",t),Hb=t=>Gg("button",t);const ga=Object.freeze(Object.defineProperty({__proto__:null,button:Hb,form:qb,input:Db,link:Vb,meta:Mb,script:Lb,style:Ub,title:Rb},Symbol.toStringTag,{value:"Module"}));var Fb=new Map([["className","class"],["htmlFor","for"],["crossOrigin","crossorigin"],["httpEquiv","http-equiv"],["itemProp","itemprop"],["fetchPriority","fetchpriority"],["noModule","nomodule"],["formAction","formaction"]]),Ws=t=>Fb.get(t)||t,Jg=(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,lu=()=>ni,Kb=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,Wb=["area","base","br","col","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],Gb=["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"],uu=(t,e)=>{for(let n=0,r=t.length;n<r;n++){const i=t[n];if(typeof i=="string")Gt(i,e);else{if(typeof i=="boolean"||i===null||i===void 0)continue;i instanceof ht?i.toStringToBuffer(e):typeof i=="number"||i.isEscaped?e[0]+=i:i instanceof Promise?e.unshift("",i):uu(i,e)}}},ht=class{constructor(t,e,n){ee(this,"tag");ee(this,"props");ee(this,"key");ee(this,"children");ee(this,"isEscaped",!0);ee(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?Dg(ft(t[0],t.callbacks)).toString():t[0]:qg(t,t.callbacks)}toStringToBuffer(t){const e=this.tag,n=this.props;let{children:r}=this;t[0]+=`<${e}`;const i=ni&&br(ni)==="svg"?s=>Kb(Ws(s)):s=>Ws(s);for(let[s,o]of Object.entries(n))if(s=i(s),s!=="children"){if(s==="style"&&typeof o=="object"){let c="";Jg(o,(l,u)=>{u!=null&&(c+=`${c?";":""}${l}:${u}`)}),t[0]+=' style="',Gt(c,t),t[0]+='"'}else if(typeof o=="string")t[0]+=` ${s}="`,Gt(o,t),t[0]+='"';else if(o!=null)if(typeof o=="number"||o.isEscaped)t[0]+=` ${s}="${o}"`;else if(typeof o=="boolean"&&Gb.includes(s))o&&(t[0]+=` ${s}=""`);else if(s==="dangerouslySetInnerHTML"){if(r.length>0)throw"Can only set one of `children` or `props.dangerouslySetInnerHTML`.";r=[ft(o.__html)]}else if(o instanceof Promise)t[0]+=` ${s}="`,t.unshift('"',o);else if(typeof o=="function"){if(!s.startsWith("on"))throw`Invalid prop '${s}' of type 'function' supplied to '${e}'.`}else t[0]+=` ${s}="`,Gt(o.toString(),t),t[0]+='"'}if(Wb.includes(e)&&r.length===0){t[0]+="/>";return}t[0]+=">",uu(r,t),t[0]+=`</${e}>`}},ma=class extends ht{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(cr.length===0)t.unshift("",n);else{const r=cr.map(i=>[i,i.values.at(-1)]);t.unshift("",n.then(i=>(i instanceof ht&&(i.localContexts=r),i)))}else n instanceof ht?n.toStringToBuffer(t):typeof n=="number"||n.isEscaped?(t[0]+=n,n.callbacks&&(t.callbacks||(t.callbacks=[]),t.callbacks.push(...n.callbacks))):Gt(n,t)}},Zg=class extends ht{toStringToBuffer(t){uu(this.children,t)}},Jb=(t,e,...n)=>{e??(e={}),n.length&&(e.children=n.length===1?n[0]:n);const r=e.key;delete e.key;const i=Ji(t,e,n);return i.key=r,i},Rp=!1,Ji=(t,e,n)=>{if(!Rp){for(const r in Zc)ga[r][cu]=Zc[r];Rp=!0}return typeof t=="function"?new ma(t,e,n):ga[t]?new ma(ga[t],e,n):t==="svg"||t==="head"?(ni||(ni=Pb("")),new ht(t,e,[new ma(ni,{value:t},n)])):new ht(t,e,n)},du=({children:t})=>new Zg("",{children:t},Array.isArray(t)?t:t?[t]:[]),Zb=(t,e,...n)=>Jb(t.tag,{...t.props,...e},...n);function y(t,e,n){let r;if(!e||!("children"in e))r=Ji(t,e,[]);else{const i=e.children;r=Array.isArray(i)?Ji(t,e,i):Ji(t,e,[i])}return r.key=n,r}const Lp={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 Yg(t,e,n){if(!n&&!e)return Lp;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 sf.parse(s)}catch(i){return console.error(i),Lp}}async function Fe(t,e){var l;const{env:n}=t,r=await n.data.logins.get(t.var.tenant_id||"",e);if(!r)throw new C(400,{message:"Session not found"});t.set("login",r);const i=await Ko(n,r.authParams.client_id);t.set("client_id",i.id),t.set("tenant_id",i.tenant.id);const s=await n.data.tenants.get(i.tenant.id);if(!s)throw new C(400,{message:"Tenant not found"});const o=await Yg(n,i.id,r.authParams.vendor_id),c=(l=r.authParams.ui_locales)==null?void 0:l.split(" ").map(u=>u.split("-")[0]).find(u=>{if(Array.isArray(U.options.supportedLngs))return U.options.supportedLngs.includes(u)});return await U.changeLanguage(c||s.language||"sv"),{vendorSettings:{...o,termsAndConditionsUrl:i.id==="fokus-app"?"https://www.fokus.se/kopvillkor-app/":o.termsAndConditionsUrl},client:i,tenant:s,session:r}}async function Yb(t,e,n,r){if(r!==void 0)return r==="password";const i=await Qs({userAdapter:t.env.data.users,tenant_id:e.tenant.id,email:n});if(i){const o=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:${me.SUCCESS_LOGIN} user_id:${i.user_id}`}),[c]=o.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 Xb=({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(du,{}),Qb=({vendorSettings:t})=>{const{termsAndConditionsUrl:e}=t;return y("div",{className:"mt-8",children:e&&y("div",{className:"text-xs text-gray-300",children:[U.t("agree_to")," ",y("a",{href:e,className:"text-primary hover:underline",target:"_blank",rel:"noreferrer",children:U.t("terms")})]})})};var Xg={exports:{}};/*!
|
|
192
|
+
</html>`}async function jb({ctx:t,client:e,session:n,redirect_uri:r,state:i,nonce:s,code_challenge_method:o,code_challenge:c,audience:l,scope:u,response_type:p}){const{env:h}=t,m=new URL(r);if(n!=null&&n.expires_at&&new Date(n.expires_at)>new Date){t.set("user_id",n.user_id);const f=new Headers,_=If(e.tenant.id,n.id);f.set("set-cookie",_);const w=await h.data.users.get(e.tenant.id,n.user_id);if(w){t.set("username",w.email),t.set("connection",w.connection);const S=await eo(t,{client:e,authParams:{client_id:e.id,audience:l,code_challenge_method:o,code_challenge:c,scope:u,state:i,nonce:s,response_type:p},user:w,session_id:n.id});await h.data.sessions.update(e.tenant.id,n.id,{used_at:new Date().toISOString(),expires_at:new Date(Date.now()+Xs*1e3).toISOString()});const C=be(t,{type:me.SUCCESS_SILENT_AUTH,description:"Successful silent authentication"});return await t.env.data.logs.create(e.tenant.id,C),t.html(Op(`${m.protocol}//${m.host}`,JSON.stringify(S)),{headers:f})}}const v=be(t,{type:me.FAILED_SILENT_AUTH,description:"Login required"});return await t.env.data.logs.create(e.tenant.id,v),t.html(Op(`${m.protocol}//${m.host}`,JSON.stringify({error:"login_required",error_description:"Login required",state:i})))}const $b=new a.OpenAPIHono().openapi(a.createRoute({tags:["oauth"],method:"get",path:"/",request:{query:a.z.object({client_id:a.z.string(),vendor_id:a.z.string().optional(),redirect_uri:a.z.string(),scope:a.z.string().optional(),state:a.z.string(),prompt:a.z.string().optional(),response_mode:a.z.nativeEnum(Zt).optional(),response_type:a.z.nativeEnum(Jt).optional(),audience:a.z.string().optional(),connection:a.z.string().optional(),nonce:a.z.string().optional(),max_age:a.z.string().optional(),login_ticket:a.z.string().optional(),code_challenge_method:a.z.nativeEnum(Js).optional(),code_challenge:a.z.string().optional(),realm:a.z.string().optional(),auth0Client:a.z.string().optional(),login_hint:a.z.string().optional(),ui_locales:a.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:o,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}=t.req.valid("query");t.set("log","authorize");const R=await Go(e,n);t.set("client_id",R.id),t.set("tenant_id",R.tenant.id);const te={redirect_uri:i,scope:s,state:o,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},fe=t.req.header("origin");if(fe&&!Ib(fe,R.web_origins||[]))throw new N(403,{message:`Origin ${fe} not allowed`});if(te.redirect_uri&&!Jo(te.redirect_uri,R.callbacks||[],{allowPathWildcards:!0}))throw new N(400,{message:`Invalid redirect URI - ${te.redirect_uri}`});const le=as(R.tenant.id,t.req.header("cookie")),Ue=le?await e.data.sessions.get(R.tenant.id,le):void 0;if(f=="none"){if(!p)throw new N(400,{message:"Missing response_type"});return jb({ctx:t,session:Ue||void 0,redirect_uri:i,state:o,response_type:p,client:R,nonce:l,code_challenge_method:v,code_challenge:m,audience:c,scope:s})}return u&&u!=="email"?lb(t,R,u,te):_?Nb(t,R.tenant.id,_,te,w):zb({ctx:t,client:R,auth0Client:S,authParams:te,session:Ue||void 0,connection:u,login_hint:C})});function Ob(){const t=new a.OpenAPIHono;t.use(Ng(t));const e=t.route("/v2/logout",db).route("/userinfo",pb).route("/.well-known",fb).route("/oauth/token",bb).route("/dbconnections",xb).route("/passwordless",Sb).route("/co/authenticate",Eb).route("/authorize",$b).route("/callback",ub);return e.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Oauth API"},security:[{oauth2:["openid","email","profile"]}]}),Cg(e),e}var Bb={Stringify:1,BeforeStream:2,Stream:3},ft=(t,e)=>{const n=new String(t);return n.isEscaped=!0,n.callbacks=e,n},Tb=/[&<>'"]/,Hg=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 o=s.isEscaped;if(s=await(typeof s=="object"?s.toString():s),typeof s=="object"&&e.push(...s.callbacks||[]),s.isEscaped??o)n+=s;else{const c=[n];Gt(s,c),n=c[0]}}return ft(n,e)},Gt=(t,e)=>{const n=t.search(Tb);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=""";break;case 39:r="'";break;case 38:r="&";break;case 60:r="<";break;case 62:r=">";break;default:continue}e[0]+=t.substring(s,i)+r,s=i+1}e[0]+=t.substring(s,i)},Fg=t=>{const e=t.callbacks;if(!(e!=null&&e.length))return t;const n=[t],r={};return e.forEach(i=>i({phase:Bb.Stringify,buffer:n,context:r})),n[0]},Pb=(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 o=0,c=s.length;o<c;o++){const l=s[o];if(typeof l=="string")Gt(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):Gt(l.toString(),n)}}}return n[0]+=t[t.length-1],n.length===1?"callbacks"in n?ft(Fg(ft(n[0],n.callbacks))):ft(n[0]):Hg(n,n.callbacks)},cu=Symbol("RENDERER"),Jc=Symbol("ERROR_HANDLER"),Se=Symbol("STASH"),Kg=Symbol("INTERNAL"),Rb=Symbol("MEMO"),Fs=Symbol("PERMALINK"),Bp=t=>(t[Kg]=!0,t),Wg=t=>({value:e,children:n})=>{if(!n)return;const r={children:[{tag:Bp(()=>{t.push(e)}),props:{}}]};Array.isArray(n)?r.children.push(...n.flat()):r.children.push(n),r.children.push({tag:Bp(()=>{t.pop()}),props:{}});const i={tag:"",props:r,type:""};return i[Jc]=s=>{throw t.pop(),s},i},Gg=t=>{const e=[t],n=Wg(e);return n.values=e,n.Provider=n,or.push(n),n},or=[],Lb=t=>{const e=[t],n=r=>{e.push(r.value);let i;try{i=r.children?(Array.isArray(r.children)?new Xg("",{},r.children):r.children).toString():""}finally{e.pop()}return i instanceof Promise?i.then(s=>ft(s,s.callbacks)):ft(i)};return n.values=e,n.Provider=n,n[cu]=Wg(e),or.push(n),n},vr=t=>t.values.at(-1),Fi={title:[],script:["src"],style:["data-href"],link:["href"],meta:["name","httpEquiv","charset","itemProp"]},Zc={},Ki="data-precedence",Si=t=>Array.isArray(t)?t:[t],Tp=new WeakMap,Pp=(t,e,n,r)=>({buffer:i,context:s})=>{if(!i)return;const o=Tp.get(s)||{};Tp.set(s,o);const c=o[t]||(o[t]=[]);let l=!1;const u=Fi[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(""))}},Ai=(t,e,n)=>ft(new ht(t,n,Si(e??[])).toString()),Ei=(t,e,n,r)=>{if("itemProp"in n)return Ai(t,e,n);let{precedence:i,blocking:s,...o}=n;i=r?i??"":void 0,r&&(o[Ki]=i);const c=new ht(t,o,Si(e||[])).toString();return c instanceof Promise?c.then(l=>ft(c,[...l.callbacks||[],Pp(t,l,o,i)])):ft(c,[Pp(t,c,o,i)])},Ub=({children:t,...e})=>{const n=lu();if(n){const r=vr(n);if(r==="svg"||r==="head")return new ht("title",e,Si(t??[]))}return Ei("title",t,e,!1)},Vb=({children:t,...e})=>{const n=lu();return["src","async"].some(r=>!e[r])||n&&vr(n)==="head"?Ai("script",t,e):Ei("script",t,e,!1)},Mb=({children:t,...e})=>["href","precedence"].every(n=>n in e)?(e["data-href"]=e.href,delete e.href,Ei("style",t,e,!0)):Ai("style",t,e),qb=({children:t,...e})=>["onLoad","onError"].some(n=>n in e)||e.rel==="stylesheet"&&(!("precedence"in e)||"disabled"in e)?Ai("link",t,e):Ei("link",t,e,"precedence"in e),Db=({children:t,...e})=>{const n=lu();return n&&vr(n)==="head"?Ai("meta",t,e):Ei("meta",t,e,!1)},Jg=(t,{children:e,...n})=>new ht(t,n,Si(e??[])),Hb=t=>(typeof t.action=="function"&&(t.action=Fs in t.action?t.action[Fs]:void 0),Jg("form",t)),Zg=(t,e)=>(typeof e.formAction=="function"&&(e.formAction=Fs in e.formAction?e.formAction[Fs]:void 0),Jg(t,e)),Fb=t=>Zg("input",t),Kb=t=>Zg("button",t);const ga=Object.freeze(Object.defineProperty({__proto__:null,button:Kb,form:Hb,input:Fb,link:qb,meta:Db,script:Vb,style:Mb,title:Ub},Symbol.toStringTag,{value:"Module"}));var Wb=new Map([["className","class"],["htmlFor","for"],["crossOrigin","crossorigin"],["httpEquiv","http-equiv"],["itemProp","itemprop"],["fetchPriority","fetchpriority"],["noModule","nomodule"],["formAction","formaction"]]),Ks=t=>Wb.get(t)||t,Yg=(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)}},ei=void 0,lu=()=>ei,Gb=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,Jb=["area","base","br","col","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],Zb=["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"],uu=(t,e)=>{for(let n=0,r=t.length;n<r;n++){const i=t[n];if(typeof i=="string")Gt(i,e);else{if(typeof i=="boolean"||i===null||i===void 0)continue;i instanceof ht?i.toStringToBuffer(e):typeof i=="number"||i.isEscaped?e[0]+=i:i instanceof Promise?e.unshift("",i):uu(i,e)}}},ht=class{constructor(t,e,n){ee(this,"tag");ee(this,"props");ee(this,"key");ee(this,"children");ee(this,"isEscaped",!0);ee(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?Fg(ft(t[0],t.callbacks)).toString():t[0]:Hg(t,t.callbacks)}toStringToBuffer(t){const e=this.tag,n=this.props;let{children:r}=this;t[0]+=`<${e}`;const i=ei&&vr(ei)==="svg"?s=>Gb(Ks(s)):s=>Ks(s);for(let[s,o]of Object.entries(n))if(s=i(s),s!=="children"){if(s==="style"&&typeof o=="object"){let c="";Yg(o,(l,u)=>{u!=null&&(c+=`${c?";":""}${l}:${u}`)}),t[0]+=' style="',Gt(c,t),t[0]+='"'}else if(typeof o=="string")t[0]+=` ${s}="`,Gt(o,t),t[0]+='"';else if(o!=null)if(typeof o=="number"||o.isEscaped)t[0]+=` ${s}="${o}"`;else if(typeof o=="boolean"&&Zb.includes(s))o&&(t[0]+=` ${s}=""`);else if(s==="dangerouslySetInnerHTML"){if(r.length>0)throw"Can only set one of `children` or `props.dangerouslySetInnerHTML`.";r=[ft(o.__html)]}else if(o instanceof Promise)t[0]+=` ${s}="`,t.unshift('"',o);else if(typeof o=="function"){if(!s.startsWith("on"))throw`Invalid prop '${s}' of type 'function' supplied to '${e}'.`}else t[0]+=` ${s}="`,Gt(o.toString(),t),t[0]+='"'}if(Jb.includes(e)&&r.length===0){t[0]+="/>";return}t[0]+=">",uu(r,t),t[0]+=`</${e}>`}},ma=class extends ht{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(or.length===0)t.unshift("",n);else{const r=or.map(i=>[i,i.values.at(-1)]);t.unshift("",n.then(i=>(i instanceof ht&&(i.localContexts=r),i)))}else n instanceof ht?n.toStringToBuffer(t):typeof n=="number"||n.isEscaped?(t[0]+=n,n.callbacks&&(t.callbacks||(t.callbacks=[]),t.callbacks.push(...n.callbacks))):Gt(n,t)}},Xg=class extends ht{toStringToBuffer(t){uu(this.children,t)}},Yb=(t,e,...n)=>{e??(e={}),n.length&&(e.children=n.length===1?n[0]:n);const r=e.key;delete e.key;const i=Wi(t,e,n);return i.key=r,i},Rp=!1,Wi=(t,e,n)=>{if(!Rp){for(const r in Zc)ga[r][cu]=Zc[r];Rp=!0}return typeof t=="function"?new ma(t,e,n):ga[t]?new ma(ga[t],e,n):t==="svg"||t==="head"?(ei||(ei=Lb("")),new ht(t,e,[new ma(ei,{value:t},n)])):new ht(t,e,n)},du=({children:t})=>new Xg("",{children:t},Array.isArray(t)?t:t?[t]:[]),Xb=(t,e,...n)=>Yb(t.tag,{...t.props,...e},...n);function y(t,e,n){let r;if(!e||!("children"in e))r=Wi(t,e,[]);else{const i=e.children;r=Array.isArray(i)?Wi(t,e,i):Wi(t,e,[i])}return r.key=n,r}const Lp={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 Qg(t,e,n){if(!n&&!e)return Lp;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 sf.parse(s)}catch(i){return console.error(i),Lp}}async function Fe(t,e){var l;const{env:n}=t,r=await n.data.logins.get(t.var.tenant_id||"",e);if(!r)throw new N(400,{message:"Session not found"});t.set("login",r);const i=await Go(n,r.authParams.client_id);t.set("client_id",i.id),t.set("tenant_id",i.tenant.id);const s=await n.data.tenants.get(i.tenant.id);if(!s)throw new N(400,{message:"Tenant not found"});const o=await Qg(n,i.id,r.authParams.vendor_id),c=(l=r.authParams.ui_locales)==null?void 0:l.split(" ").map(u=>u.split("-")[0]).find(u=>{if(Array.isArray(U.options.supportedLngs))return U.options.supportedLngs.includes(u)});return await U.changeLanguage(c||s.language||"sv"),{vendorSettings:{...o,termsAndConditionsUrl:i.id==="fokus-app"?"https://www.fokus.se/kopvillkor-app/":o.termsAndConditionsUrl},client:i,tenant:s,session:r}}async function Qb(t,e,n,r){if(r!==void 0)return r==="password";const i=await to({userAdapter:t.env.data.users,tenant_id:e.tenant.id,email:n});if(i){const o=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:${me.SUCCESS_LOGIN} user_id:${i.user_id}`}),[c]=o.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 e1=({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(du,{}),t1=({vendorSettings:t})=>{const{termsAndConditionsUrl:e}=t;return y("div",{className:"mt-8",children:e&&y("div",{className:"text-xs text-gray-300",children:[U.t("agree_to")," ",y("a",{href:e,className:"text-primary hover:underline",target:"_blank",rel:"noreferrer",children:U.t("terms")})]})})};var em={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="",o=0;o<arguments.length;o++){var c=arguments[o];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 o="";for(var c in s)e.call(s,c)&&s[c]&&(o=i(o,c));return o}function i(s,o){return o?s?s+" "+o:s+o:s}t.exports?(n.default=n,t.exports=n):window.classNames=n})()})(
|
|
196
|
+
*/(function(t){(function(){var e={}.hasOwnProperty;function n(){for(var s="",o=0;o<arguments.length;o++){var c=arguments[o];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 o="";for(var c in s)e.call(s,c)&&s[c]&&(o=i(o,c));return o}function i(s,o){return o?s?s+" "+o:s+o:s}t.exports?(n.default=n,t.exports=n):window.classNames=n})()})(em);var n1=em.exports;const Et=bf(n1),r1=t=>t==="small"?"text-base":t==="medium"?"text-2xl":t==="large"?"text-3xl":"",gt=({name:t,size:e,className:n=""})=>{const r=r1(e);return y("span",{className:Et(`uicon-${t}`,n,r)})};var Up=Object.freeze,i1=Object.defineProperty,s1=(t,e)=>Up(i1(t,"raw",{value:Up(t.slice())})),Vp;const o1=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
|
-
`},
|
|
202
|
+
`},a1="https://assets.sesamy.com/images/login-bg.jpg",Nt=({title:t,children:e,vendorSettings:n})=>{const r={backgroundImage:`url(${(n==null?void 0:n.loginBackgroundImage)||a1})`};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:o1(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(e1,{vendorSettings:n})}),y("div",{className:"flex flex-1 flex-col",children:[e,y(t1,{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(gt,{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:U.t("contact_support")}),y("span",{className:"text-gray-300",children:"|"})," ",y("span",{children:U.t("copyright_sesamy")})]})]})]})})})}),Pb(Vp||(Vp=s1([`
|
|
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
|
-
`])))]})},
|
|
217
|
+
`])))]})},wr=({children:t})=>y("div",{className:"mb-2 text-sm text-red",children:t}),c1=t=>t==="small"?"text-base":t==="medium"?"text-2xl":t==="large"?"text-3xl":"",l1=({size:t})=>{const e=c1(t);return y("div",{className:"relative inline-block leading-[0]",children:[y(gt,{className:Et("text-gray-200 dark:text-[#201a41]",{[e]:e}),name:"spinner-circle"}),y(gt,{className:Et("absolute inset-0 animate-spin text-primary",{[e]:e}),name:"spinner-inner"})]})},ti=({children:t,className:e,Component:n="button",variant:r="primary",href:i,disabled:s,isLoading:o,id:c})=>{const l=n==="a"?{href:i}:{};return y(n,{class:Et("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
|
${o?"invisible h-0":"visible h-auto"}
|
|
220
|
-
`,children:t}),o&&y("div",{className:"absolute left-0 top-0 flex h-full w-full items-center justify-center",children:y(
|
|
220
|
+
`,children:t}),o&&y("div",{className:"absolute left-0 top-0 flex h-full w-full items-center justify-center",children:y(l1,{size:"medium"})})]})},Ti=({connection:t,text:e,icon:n=null,canResize:r=!1,session: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.login_id);const o=`/authorize?${s.toString()}`;return y(ti,{className:Et("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:o,children:[n||"",y("div",{className:Et("text-left text-black dark:text-white sm:text-base",{"hidden sm:inline short:hidden":r}),children:e})]})},u1=({...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"})]}),Tn=({children:t,className:e})=>y(du,{children:[y(ti,{className:e,id:"initial-btn",children:t}),y(ti,{className:Et(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}),d1=({...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`})]}),Mp=({error:t,vendorSettings:e,session:n,email:r,client:i,impersonation:s})=>{const o=i.connections.map(({name:m})=>m),c=o.includes("facebook"),l=o.includes("google-oauth2"),u=o.includes("apple"),p=o.includes("vipps"),h=c||l||u||p;return y(Nt,{title:U.t("welcome"),vendorSettings:e,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:U.t("welcome")}),y("div",{className:"mb-8 text-gray-300",children:U.t("login_description")}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y(Rn,{className:"mb-7",children:[y("input",{type:"email",name:"username",placeholder:U.t("email_placeholder"),className:Et("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:Et("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(kr,{children:t}),y(Pn,{className:"text-base sm:mt-4 md:text-base",children:y("div",{className:"flex items-center space-x-2",children:[y("span",{children:U.t("continue")}),y(gt,{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:U.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(Ri,{connection:"facebook",text:U.t("continue_with",{provider:"Facebook"}),canResize:!0,icon:y(gt,{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"}),session:n}),l&&y(Ri,{connection:"google-oauth2",text:U.t("continue_with",{provider:"Google"}),canResize:!0,icon:y(c1,{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"}),session:n}),u&&y(Ri,{connection:"apple",text:U.t("continue_with",{provider:"Apple"}),canResize:!0,icon:y(gt,{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"}),session:n}),p&&y(Ri,{connection:"vipps",text:U.t("continue_with",{provider:"Vipps"}),canResize:!0,icon:y(l1,{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"}),session:n})]})]})]})},u1=["Auth0.swift"];function d1(t){if(!t)return"link";const e=atob(t),n=JSON.parse(e);return u1.includes(n.name)?"code":"link"}const p1=new a.OpenAPIHono().openapi(a.createRoute({tags:["login"],method:"get",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"}),impersonation:a.z.string().optional()})},responses:{200:{description:"Response"}}}),async t=>{const{state:e,impersonation:n}=t.req.valid("query"),{vendorSettings:r,session:i,client:s}=await Fe(t,e);return t.html(y(Mp,{vendorSettings:r,session:i,client:s,email:i.authParams.username,impersonation:n==="true"}))}).openapi(a.createRoute({tags:["login"],method:"post",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"})}),body:{content:{"application/x-www-form-urlencoded":{schema:a.z.object({username:a.z.string().transform(t=>t.toLowerCase()),act_as:a.z.string().transform(t=>t.toLowerCase()).optional(),login_selection:a.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,session:s,vendorSettings:o}=await Fe(t,n);t.set("client_id",i.id);const c=r.username,l=await Qs({userAdapter:e.data.users,tenant_id:i.tenant.id,email:c});if(l&&t.set("user_id",l.user_id),!l)try{await Rg(t,i,t.env.data,r.username)}catch{const v=be(t,{type:me.FAILED_SIGNUP,description:"Public signup is disabled"});return await t.env.data.logs.create(i.tenant.id,v),t.html(y(Mp,{vendorSettings:o,session:s,error:U.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.logins.update(i.tenant.id,s.login_id,s),await Yb(t,i,r.username,r.login_selection))return t.redirect(`/u/enter-password?state=${n}`);let u=ar(),p=await e.data.codes.get(i.tenant.id,u,"otp");for(;p;)u=ar(),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.login_id,expires_at:new Date(Date.now()+Kc).toISOString()});return d1(s.auth0Client)==="link"&&!r.username.includes("online.no")?Qe(t,iu(t,r.username,h.code_id,s.authParams)):Qe(t,Mg(t,r.username,h.code_id)),t.redirect(`/u/enter-code?state=${n}`)}),tn=t=>y("a",{className:"block text-primary hover:text-primaryHover text-center",href:`/u/enter-email?state=${t.state}`,children:U.t("go_back")});var ii="_hp",f1={Change:"Input",DoubleClick:"DblClick"},h1={svg:"2000/svg",math:"1998/Math/MathML"},si=[],Yc=new WeakMap,lr=void 0,g1=()=>lr,jt=t=>"t"in t,_a={onClick:["click",!1]},qp=t=>{if(!t.startsWith("on"))return;if(_a[t])return _a[t];const e=t.match(/^on([A-Z][a-zA-Z]+?(?:PointerCapture)?)(Capture)?$/);if(e){const[,n,r]=e;return _a[t]=[(f1[n]||n).toLowerCase(),!!r]}},Dp=(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,m1=(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 o=qp(i);if(o){if((n==null?void 0:n[i])!==s&&(n&&t.removeEventListener(o[0],n[i],o[1]),s!=null)){if(typeof s!="function")throw new Error(`Event handler for "${i}" is not a function`);t.addEventListener(o[0],s,o[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),Yc.set(t,c)}else if(i==="style"){const c=t.style;typeof s=="string"?c.cssText=s:(c.cssText="",s!=null&&Jg(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=Dp(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 o=qp(i);o?t.removeEventListener(o[0],s,o[1]):i==="ref"?(r=Yc.get(t))==null||r():t.removeAttribute(Dp(t,i))}}},_1=(t,e)=>{e[Se][0]=0,si.push([t,e]);const n=e.tag[cu]||e.tag,r=n.defaultProps?{...n.defaultProps,...e.props}:e.props;try{return[n.call(null,r)]}finally{si.pop()}},Qg=(t,e,n,r,i)=>{var s,o;(s=t.vR)!=null&&s.length&&(r.push(...t.vR),delete t.vR),typeof t.tag=="function"&&((o=t[Se][1][rm])==null||o.forEach(c=>i.push(c))),t.vC.forEach(c=>{var l;if(jt(c))n.push(c);else if(typeof c.tag=="function"||c.tag===""){c.c=e;const u=n.length;if(Qg(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)})},y1=t=>{for(;;t=t.tag===ii||!t.vC||!t.pP?t.nN:t.vC[0]){if(!t)return null;if(t.tag!==ii&&t.e)return t.e}},em=t=>{var e,n,r,i,s,o;jt(t)||((n=(e=t[Se])==null?void 0:e[1][rm])==null||n.forEach(c=>{var l;return(l=c[2])==null?void 0:l.call(c)}),(r=Yc.get(t.e))==null||r(),t.p===2&&((i=t.vC)==null||i.forEach(c=>c.p=2)),(s=t.vC)==null||s.forEach(em)),t.p||((o=t.e)==null||o.remove(),delete t.e),typeof t.tag=="function"&&(jr.delete(t),Zi.delete(t),delete t[Se][3],t.a=!0)},tm=(t,e,n)=>{t.c=e,nm(t,e,n)},Hp=(t,e)=>{if(e){for(let n=0,r=t.length;n<r;n++)if(t[n]===e)return n}},Fp=Symbol(),nm=(t,e,n)=>{var u;const r=[],i=[],s=[];Qg(t,e,r,i,s),i.forEach(em);const o=n?void 0:e.childNodes;let c,l=null;if(n)c=-1;else if(!o.length)c=0;else{const p=Hp(o,y1(t.nN));p!==void 0?(l=o[p],c=p):c=Hp(o,(u=r.find(h=>h.tag!==ii&&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;jt(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)),m1(v,m.props,m.pP),nm(m,v,f))}m.tag===ii?c--:n?v.parentNode||e.appendChild(v):o[c]!==v&&o[c-1]!==v&&(o[c+1]===v?e.appendChild(o[c]):e.insertBefore(v,l||o[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())})}},Zi=new WeakMap,Xc=(t,e,n)=>{var s,o,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"?_1(t,e):Ei(e.props.children)),((s=n[0])==null?void 0:s.tag)===""&&n[0][Jc]&&(i=n[0][Jc],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 _=v1(n[f]);if(_){typeof _.tag=="function"&&!_.tag[Hg]&&(cr.length>0&&(_[Se][2]=cr.map(S=>[S,S.values.at(-1)])),(o=t[5])!=null&&o.length&&(_[Se][3]=t[5].at(-1)));let w;if(h&&h.length){const S=h.findIndex(jt(_)?N=>jt(N):_.key!==void 0?N=>N.key===_.key&&N.tag===_.tag:N=>N.tag===_.tag);S!==-1&&(w=h[S],h.splice(S,1))}if(w)if(jt(_))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[Se][2]=_[Se][2]||[],w[Se][3]=_[Se][3],!w.f&&((w.o||w)===_.o||(l=(c=w.tag)[Tb])!=null&&l.call(c,S,w.props))&&(w.s=!0)),_=w}else if(!jt(_)&&lr){const S=br(lr);S&&(_.n=S)}if(!jt(_)&&!_.s&&(Xc(t,_),delete _.f),m.push(_),v&&!v.s&&!_.s)for(let S=v;S&&!jt(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===Fp){if(i)return;throw h}const[m,v,f]=((p=e[Se])==null?void 0:p[3])||[];if(v){const _=()=>Yi([0,!1,t[2]],f),w=Zi.get(f)||[];w.push(_),Zi.set(f,w);const S=v(h,()=>{const N=Zi.get(f);if(N){const B=N.indexOf(_);if(B!==-1)return N.splice(B,1),_()}});if(S){if(t[0]===1)t[1]=!0;else if(Xc(t,f,[S]),(v.length===1||t!==m)&&f.c){tm(f,f.c,!1);return}throw Fp}}throw h}finally{i&&t[5].pop()}},v1=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[Se]=[0,[]];else{const e=h1[t.tag];e&&(lr||(lr=Kg("")),t.props.children=[{tag:lr,props:{value:t.n=`http://www.w3.org/${e}`,children:t.props.children}}])}return t}},Kp=(t,e)=>{var n,r;(n=e[Se][2])==null||n.forEach(([i,s])=>{i.values.push(s)});try{Xc(t,e,void 0)}catch{return}if(e.a){delete e.a;return}(r=e[Se][2])==null||r.forEach(([i])=>{i.values.pop()}),(t[0]!==1||!t[1])&&tm(e,e.c,!1)},jr=new WeakMap,Wp=[],Yi=async(t,e)=>{t[5]||(t[5]=[]);const n=jr.get(e);n&&n[0](void 0);let r;const i=new Promise(s=>r=s);if(jr.set(e,[r,()=>{t[2]?t[2](t,e,s=>{Kp(s,e)}).then(()=>r(e)):(Kp(t,e),r(e))}]),Wp.length)Wp.at(-1).add(e);else{await Promise.resolve();const s=jr.get(e);s&&(jr.delete(e),s[1]())}return i},w1=(t,e,n)=>({tag:ii,props:{children:t},key:n,e,p:1}),ya=0,rm=1,va=2,wa=3,ba=new WeakMap,im=(t,e)=>!t||!e||t.length!==e.length||e.some((n,r)=>n!==t[r]),b1=void 0,Gp=[],k1=t=>{var o;const e=()=>typeof t=="function"?t():t,n=si.at(-1);if(!n)return[e(),()=>{}];const[,r]=n,i=(o=r[Se][1])[ya]||(o[ya]=[]),s=r[Se][0]++;return i[s]||(i[s]=[e(),c=>{const l=b1,u=i[s];if(typeof c=="function"&&(c=c(u[0])),!Object.is(c,u[0]))if(u[0]=c,Gp.length){const[p,h]=Gp.at(-1);Promise.all([p===3?r:Yi([p,!1,l],r),h]).then(([m])=>{if(!m||!(p===2||p===3))return;const v=m.vC;requestAnimationFrame(()=>{setTimeout(()=>{v===m.vC&&Yi([p===3?1:0,!1,l],m)})})})}else Yi([0,!1,l],r)}])},pu=(t,e)=>{var c;const n=si.at(-1);if(!n)return t;const[,r]=n,i=(c=r[Se][1])[va]||(c[va]=[]),s=r[Se][0]++,o=i[s];return im(o==null?void 0:o[1],e)?i[s]=[t,e]:t=i[s][0],t},x1=t=>{const e=ba.get(t);if(e){if(e.length===2)throw e[1];return e[0]}throw t.then(n=>ba.set(t,[n]),n=>ba.set(t,[void 0,n])),t},S1=(t,e)=>{var c;const n=si.at(-1);if(!n)return t();const[,r]=n,i=(c=r[Se][1])[wa]||(c[wa]=[]),s=r[Se][0]++,o=i[s];return im(o==null?void 0:o[1],e)&&(i[s]=[t(),e]),i[s][0]},A1=Kg({pending:!1,data:null,method:null,action:null}),Jp=new Set,E1=t=>{Jp.add(t),t.finally(()=>Jp.delete(t))},fu=(t,e)=>S1(()=>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),Li=Object.create(null),Ci=(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:o,onError:c,precedence:l,blocking:u,...p}=e,h=null,m=!1;const v=Wi[t];let f;if(v.length>0){const N=s.querySelectorAll(t);e:for(const B of N)for(const R of Wi[t])if(B.getAttribute(R)===e[R]){h=B;break e}if(!h){const B=v.reduce((R,te)=>e[te]===void 0?R:`${R}-${te}-${e[te]}`,t);m=!Li[B],h=Li[B]||(Li[B]=(()=>{const R=document.createElement(t);for(const te of v)e[te]!==void 0&&R.setAttribute(te,e[te]),e.rel&&R.setAttribute("rel",e.rel);return R})())}}else f=s.querySelectorAll(t);l=r?l??"":void 0,r&&(p[Gi]=l);const _=pu(N=>{if(v.length>0){let B=!1;for(const R of s.querySelectorAll(t)){if(B&&R.getAttribute(Gi)!==l){s.insertBefore(N,R);return}R.getAttribute(Gi)===l&&(B=!0)}s.appendChild(N)}else if(f){let B=!1;for(const R of f)if(R===N){B=!0;break}B||s.insertBefore(N,s.contains(f[0])?f[0]:s.querySelector(t)),f=void 0}},[l]),w=fu(e.ref,N=>{var te;const B=v[0];if(n===2&&(N.innerHTML=""),(m||f)&&_(N),!c&&!o)return;let R=Mn[te=N.getAttribute(B)]||(Mn[te]=new Promise((fe,le)=>{N.addEventListener("load",fe),N.addEventListener("error",le)}));o&&(R=R.then(o)),c&&(R=R.catch(c)),R.catch(()=>{})});if(i&&u==="render"){const N=Wi[t][0];if(e[N]){const B=e[N],R=Mn[B]||(Mn[B]=new Promise((te,fe)=>{_(h),h.addEventListener("load",te),h.addEventListener("error",fe)}));x1(R)}}const S={tag:t,type:t,props:{...p,ref:w},ref:w};return S.p=n,h&&(S.e=h),w1(S,s)},I1=t=>{const e=g1(),n=e&&br(e);return n!=null&&n.endsWith("svg")?{tag:"title",props:t,type:"title",ref:t.ref}:Ci("title",t,void 0,!1,!1)},z1=t=>!t||["src","async"].some(e=>!t[e])?{tag:"script",props:t,type:"script",ref:t.ref}:Ci("script",t,1,!1,!0),C1=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,Ci("style",t,2,!0,!0)),N1=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}:Ci("link",t,1,"precedence"in t,!0),j1=t=>Ci("meta",t,void 0,!1,!1),sm=Symbol(),$1=t=>{const{action:e,...n}=t;typeof e!="function"&&(n.action=e);const[r,i]=k1([null,!1]),s=pu(async u=>{const p=u.isTrusted?e:u.detail[sm];if(typeof p!="function")return;u.preventDefault();const h=new FormData(u.target);i([h,!0]);const m=p(h);m instanceof Promise&&(E1(m),await m),i([null,!0])},[]),o=fu(t.ref,u=>(u.addEventListener("submit",s),()=>{u.removeEventListener("submit",s)})),[c,l]=r;return r[1]=!1,{tag:A1,props:{value:{pending:c!==null,data:c,method:c?"post":null,action:c?e:null},children:{tag:"form",props:{...n,ref:o},type:"form",ref:o}},f:l}},om=(t,{formAction:e,...n})=>{if(typeof e=="function"){const r=pu(i=>{i.preventDefault(),i.currentTarget.form.dispatchEvent(new CustomEvent("submit",{detail:{[sm]:e}}))},[]);n.ref=fu(n.ref,i=>(i.addEventListener("click",r),()=>{i.removeEventListener("click",r)}))}return{tag:t,props:n,type:t,ref:n.ref}},O1=t=>om("input",t),B1=t=>om("button",t);Object.assign(Zc,{title:I1,script:z1,style:C1,link:N1,meta:j1,form:$1,input:O1,button:B1});new TextEncoder;const am=t=>{const{i18nKey:e,values:n,components:r}=t,i=U.t(e,n),s=/<(\d+)>(.*?)<\/\d+>/g,o=[];let c=0,l;for(;(l=s.exec(i))!==null;){const[,u,p]=l,h=i.substring(c,l.index);h&&o.push(h);const m=parseInt(u,10);o.push(Zb(r[m],{},p)),c=s.lastIndex}return c<i.length&&o.push(i.substring(c)),y(du,{children:o})},Zp=6,Yp=({error:t,vendorSettings:e,email:n,state:r,client:i,hasPasswordLogin:s})=>{const o=new URLSearchParams({state:r}),l=i.connections.map(({name:u})=>u).includes("auth2");return y(Nt,{title:U.t("verify_your_email"),vendorSettings:e,children:[y("div",{className:"mb-4 text-2xl font-medium",children:U.t("verify_your_email")}),y("div",{className:"mb-8 text-gray-300",children:y(am,{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(Rn,{className:"pt-2",children:[y("input",{autoFocus:!0,type:"text",pattern:"[0-9]*",maxLength:Zp,inputMode:"numeric",name:"code",placeholder:"******",className:Et("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:Zp,required:!0,id:"code-input"}),t&&y(kr,{children:t}),y("div",{className:"text-center sm:mt-2",children:y(Pn,{className:"text-base sm:mt-4 md:text-base",children:y("div",{className:"flex items-center space-x-2",children:[y("span",{children:U.t("login")}),y(gt,{className:"text-xs",name:"arrow-right"})]})})}),y("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[y(gt,{className:"text-base",name:"info-bubble"}),y("div",{className:"text-sm text-gray-300 md:text-sm",children:U.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:U.t("or")})]}),y(ri,{Component:"a",href:`/u/${s?"enter-password":"pre-signup"}?${o.toString()}`,variant:"secondary",className:"block",children:U.t("enter_your_password_btn")})]})]}),y(tn,{state:r})]})]})},T1=new a.OpenAPIHono().openapi(a.createRoute({tags:["login"],method:"get",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,session:r,client:i}=await Fe(t,e);if(!r.authParams.username)throw new C(400,{message:"Username not found in state"});const s=await vn({userAdapter:t.env.data.users,tenant_id:i.tenant.id,email:r.authParams.username,provider:"auth2"});return t.html(y(Yp,{vendorSettings:n,email:r.authParams.username,state:e,client:i,hasPasswordLogin:!!s}))}).openapi(a.createRoute({tags:["login"],method:"post",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state"})}),body:{content:{"application/x-www-form-urlencoded":{schema:a.z.object({code:a.z.string()})}}}},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{code:n}=t.req.valid("form"),{session:r,client:i,vendorSettings:s}=await Fe(t,e);if(t.set("client_id",i.id),!r.authParams.username)throw new C(400,{message:"Username not found in state"});try{return await ou(t,i,r.authParams,r.authParams.username,n)}catch(o){const c=o,l=await vn({userAdapter:t.env.data.users,tenant_id:i.tenant.id,email:r.authParams.username,provider:"auth2"});return t.html(y(Yp,{vendorSettings:s,email:r.authParams.username,state:e,client:i,error:c.message,hasPasswordLogin:!!l}),400)}}),P1=t=>{const{vendorSettings:e,state:n}=t;return y(Nt,{title:U.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:U.t("unverified_email")}),y("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[y(gt,{className:"text-base",name:"info-bubble"}),y("div",{className:"text-sm text-gray-300 md:text-sm",children:U.t("sent_code_spam")})]}),y(tn,{state:n})]}),y(tn,{state:n})]})},ka=t=>{const{error:e,vendorSettings:n,email:r,state:i}=t,s=new URLSearchParams({state:i});return y(Nt,{title:U.t("enter_password"),vendorSettings:n,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:U.t("enter_password")}),y("div",{className:"mb-6 text-gray-300",children:U.t("enter_password_description")}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y(Rn,{className:"mb-7",children:[y("input",{type:"text",name:"username",placeholder:U.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:U.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(kr,{children:e}),y(Pn,{className:"text-base sm:mt-4 md:text-base",children:y("div",{className:"flex items-center space-x-2",children:[y("span",{children:U.t("login")}),y(gt,{className:"text-xs",name:"arrow-right"})]})})]}),y("a",{href:`/u/forgot-password?${s.toString()}`,className:"text-primary hover:underline mb-4",children:U.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:U.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(ri,{variant:"secondary",className:"block",children:U.t("enter_a_code_btn")})]})]}),y(tn,{state:i})]})]})},R1=new a.OpenAPIHono().openapi(a.createRoute({tags:["login"],method:"get",path:"/",request:{query:a.z.object({state:a.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,session:i}=await Fe(t,e);if(!i.authParams.username)throw new C(400,{message:"Username required"});return t.html(y(ka,{vendorSettings:n,email:i.authParams.username,state:e,client:r}))}).openapi(a.createRoute({tags:["login"],method:"post",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"})}),body:{content:{"application/x-www-form-urlencoded":{schema:a.z.object({password:a.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,session:o}=await Fe(t,e),{username:c}=o.authParams;if(!c)throw new C(400,{message:"Username required"});try{return await au(t,s,{...o.authParams,password:r},o)}catch(l){const u=l;return u.code==="INVALID_PASSWORD"||u.code==="USER_NOT_FOUND"?t.html(y(ka,{vendorSettings:i,email:c,error:U.t("invalid_password"),state:e,client:s}),400):u.code==="EMAIL_NOT_VERIFIED"?t.html(y(P1,{vendorSettings:i,state:e}),400):t.html(y(ka,{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(Nt,{title:U.t("create_account_title"),vendorSettings:r,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:U.t("create_account_title")}),y("div",{className:"mb-6 text-gray-300",children:U.t("create_account_description")}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y(Rn,{children:[y("input",{type:"hidden",name:"code",value:s}),y("input",{type:"email",name:"username",placeholder:U.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:U.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:U.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(kr,{children:n}),y(Pn,{className:"text-base sm:mt-2 md:text-base",children:U.t("continue")})]}),y(tn,{state:e})]})]})},cm=t=>{const{message:e,vendorSettings:n,pageTitle:r,state:i}=t;return y(Nt,{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(tn,{state:i}):""]})},L1=new a.OpenAPIHono().openapi(a.createRoute({tags:["login"],method:"get",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"}),code:a.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,session:i}=await Fe(t,e),{username:s}=i.authParams;if(!s)throw new C(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(a.createRoute({tags:["login"],method:"post",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"})}),body:{content:{"application/x-www-form-urlencoded":{schema:a.z.object({password:a.z.string(),"re-enter-password":a.z.string(),code:a.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,session:o}=await Fe(t,e),c="Username-Password-Authentication";t.set("client_id",s.id),t.set("connection",c);const l=o.authParams.username;if(!l)throw new C(400,{message:"Username required"});if(n.password!==n["re-enter-password"])return t.html(y(Cr,{state:e,code:n.code,vendorSettings:i,error:U.t("create_account_passwords_didnt_match"),email:o.authParams.username}),400);if(!ru(n.password))return t.html(y(Cr,{state:e,code:n.code,vendorSettings:i,error:U.t("create_account_weak_password"),email:o.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.logins.get(s.tenant.id,u.login_id):void 0;try{if(await Jn({userAdapter:t.env.data.users,tenant_id:s.tenant.id,email:l,provider:"auth2"}))throw new C(400,{message:"Invalid sign up"});const m=(p==null?void 0:p.authParams.username)===l,v=await t.env.data.users.create(s.tenant.id,{user_id:`auth2|${ai()}`,email:l,email_verified:m,provider:"auth2",connection:c,is_social:!1}),f=await Jn({userAdapter:t.env.data.users,tenant_id:s.tenant.id,email:l,provider:"auth2"});if(!f)throw new C(400,{message:"Invalid sign up"});return await r.data.passwords.create(s.tenant.id,{user_id:f.user_id,password:await oi.hash(n.password,10),algorithm:"bcrypt"}),m?await au(t,s,{...o.authParams,password:n.password},o):(await su(t,v),t.html(y(cm,{message:U.t("validate_email_body"),pageTitle:U.t("validate_email_title"),vendorSettings:i,state:e})))}catch(h){const m=await Yg(r,s.id,o.authParams.vendor_id),v=h;return t.html(y(Cr,{state:e,vendorSettings:m,error:v.message,email:l}),400)}}),Nr=t=>{const{error:e,vendorSettings:n,email:r}=t;return y(Nt,{title:U.t("reset_password_title"),vendorSettings:n,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:U.t("reset_password_title")}),y("div",{className:"mb-6 text-gray-300",children:`${U.t("reset_password_description")} ${r}`}),y("div",{className:"flex flex-1 flex-col justify-center",children:y(Rn,{children:[y("input",{type:"password",name:"password",placeholder:U.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:U.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(kr,{children:e}),y(Pn,{className:"text-base sm:mt-2 md:text-base",children:U.t("reset_password_cta")})]})})]})},U1=new a.OpenAPIHono().openapi(a.createRoute({tags:["login"],method:"get",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"}),code:a.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,session:r}=await Fe(t,e);if(!r.authParams.username)throw new C(400,{message:"Username required"});return t.html(y(Nr,{vendorSettings:n,email:r.authParams.username}))}).openapi(a.createRoute({tags:["login"],method:"post",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"}),code:a.z.string().openapi({description:"The code parameter from the authorization request"})}),body:{content:{"application/x-www-form-urlencoded":{schema:a.z.object({password:a.z.string(),"re-enter-password":a.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:o,client:c,session:l}=await Fe(t,e);if(!l.authParams.username)throw new C(400,{message:"Username required"});if(r!==i)return t.html(y(Nr,{error:U.t("create_account_passwords_didnt_match"),vendorSettings:o,email:l.authParams.username}),400);if(!ru(r))return t.html(y(Nr,{error:U.t("create_account_weak_password"),vendorSettings:o,email:l.authParams.username}),400);const u=await Jn({userAdapter:s.data.users,tenant_id:c.tenant.id,email:l.authParams.username,provider:"auth2"});if(!u)throw new C(400,{message:"User not found"});try{if(!await s.data.codes.get(c.tenant.id,n,"password_reset"))return t.html(y(Nr,{error:"Code not found or expired",vendorSettings:o,email:l.authParams.username}),400);console.log("got here");const h={user_id:u.user_id,password:await oi.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(Nr,{error:"The password could not be reset",vendorSettings:o,email:l.authParams.username}),400)}return t.html(y(cm,{message:U.t("password_has_been_reset"),vendorSettings:o,state:e}))}),V1=t=>{const{error:e,vendorSettings:n,email:r,state:i}=t;return y(Nt,{title:U.t("forgot_password_title"),vendorSettings:n,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:U.t("forgot_password_title")}),y("div",{className:"mb-6 text-gray-300",children:U.t("forgot_password_description")}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y(Rn,{className:"pt-2",children:[y("input",{type:"email",name:"username",placeholder:U.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(kr,{children:e}),y(Pn,{className:"sm:mt-4",children:U.t("forgot_password_cta")})]}),y(tn,{state:i})]})]})},M1=t=>{const{vendorSettings:e,state:n}=t;return y(Nt,{title:"Login",vendorSettings:e,children:[y("div",{className:"flex flex-1 flex-col justify-center",children:[y("div",{children:U.t("forgot_password_email_sent")}),y("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[y(gt,{className:"text-base",name:"info-bubble"}),y("div",{className:"text-sm text-gray-300 md:text-sm",children:U.t("sent_code_spam")})]})]}),y(tn,{state:n})]})},q1=new a.OpenAPIHono().openapi(a.createRoute({tags:["login"],method:"get",path:"/",request:{query:a.z.object({state:a.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,session:r}=await Fe(t,e);return t.html(y(V1,{vendorSettings:n,state:e,email:r.authParams.username}))}).openapi(a.createRoute({tags:["login"],method:"post",path:"/",request:{query:a.z.object({state:a.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,session:i}=await Fe(t,e);return await xb(t,r,i.authParams.username,i.login_id),t.html(y(M1,{vendorSettings:n,state:e}))}),D1=({vendorSettings:t,state:e,user:n})=>y(Nt,{title:de("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(am,{i18nKey:"currently_logged_in_as",components:[y("span",{className:"font-semibold text-gray-900 dark:text-white"},"span")],values:{email:n.email}}),y("br",{}),de("continue_with_sso_provider_headline")]}),y("div",{className:"space-y-6",children:[y(Rn,{children:y(Pn,{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:U.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:U.t("no_use_another")})]})]})}),H1=new a.OpenAPIHono().openapi(a.createRoute({tags:["login"],method:"get",path:"/",request:{query:a.z.object({state:a.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 Fe(t,n),s=Fs(i.tenant.id,t.req.header("cookie")),o=s?await e.data.sessions.get(i.tenant.id,s):null;if(!o)return t.redirect(`/u/enter-email?state=${n}`);const c=await e.data.users.get(i.tenant.id,o.user_id);return c?t.html(y(D1,{vendorSettings:r,state:n,user:c})):t.redirect(`/u/enter-email?state=${n}`)}).openapi(a.createRoute({tags:["login"],method:"post",path:"/",request:{query:a.z.object({state:a.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"),{session:r,client:i}=await Fe(t,n),s=Fs(i.tenant.id,t.req.header("cookie")),o=s?await e.data.sessions.get(i.tenant.id,s):null;if(!o)return t.redirect(`/u/enter-email?state=${n}`);const c=await e.data.users.get(i.tenant.id,o.user_id);return c?cn(t,{user:c,authParams:r.authParams,client:i,loginSession:r}):t.redirect(`/u/enter-email?state=${n}`)});function F1(){const e=new a.OpenAPIHono().route("/check-account",H1).route("/enter-email",p1).route("/enter-code",T1).route("/enter-password",R1).route("/reset-password",U1).route("/forgot-password",q1).route("/signup",L1);return e.doc("/u/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Universal login"}}),e}const K1="Account detected",W1="We have detected that you have already created an account through",G1="By signing in, you agree to our",J1="and",Z1="Callback URL mismatch",Y1="The provided redirect_uri is not in the list of allowed callback URLs.",X1="continue with user",Q1="Please click the button to create a new password account.",ek="Enter the code at {{vendorName}} to complete the login",tk="Welcome to {{vendorName}}! {{code}} is the login code",nk="Welcome to {{vendorName}}! {{code}} is the login code",rk="The code is valid for 30 minutes",ik="Confirm password",sk="Need Help?",ok="Contact us",ak="or continue with social account",ck="Continue with {{provider}}",lk="Would you like to continue with your existing account?",uk="Copyright © 2023 SESAMY. All rights reserved.",dk="©2023 Sesamy",pk="Choose a password with a mix of uppercase and lowercase letters, numbers, and symbols.",fk="Please enter a valid email address.",hk="The passwords didn't match. Try again.",gk="Choose password",mk="Password must be at least 8 characters long and contain at least one lowercase letter, one uppercase letter, one number and one symbol.",_k="Create new account",yk="Sign up with password",vk="You are currently logged in as <0>{{email}}</0>",wk="Email",bk="Email address",kk="Your email address has been validated",xk="Now enter your password to login again",Sk="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.",Ak="Email verification sent",Ek="Enter a code",Ik="We'll send you a verification link to ensure you own this email address.",zk="Enter new password",Ck="Enter password",Nk="Enter your email address and password to login.",jk="Enter your password",$k="The magic link has expired. Please click on the button below to receive a new link in your inbox.",Ok="Hey! We updated our login experience. <0>Click here to learn more about it.</0>",Bk="Send password reset email",Tk="Click the button below and we’ll send instructions on how to reset your password.",Pk="Password reset email sent",Rk="Forgot password?",Lk="Forgot password?",Uk="Go back",Vk="Invalid password",Mk=`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`})]}),Mp=({error:t,vendorSettings:e,session:n,email:r,client:i,impersonation:s})=>{const o=i.connections.map(({name:m})=>m),c=o.includes("facebook"),l=o.includes("google-oauth2"),u=o.includes("apple"),p=o.includes("vipps"),h=c||l||u||p;return y(Nt,{title:U.t("welcome"),vendorSettings:e,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:U.t("welcome")}),y("div",{className:"mb-8 text-gray-300",children:U.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:U.t("email_placeholder"),className:Et("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:Et("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(wr,{children:t}),y(Tn,{className:"text-base sm:mt-4 md:text-base",children:y("div",{className:"flex items-center space-x-2",children:[y("span",{children:U.t("continue")}),y(gt,{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:U.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(Ti,{connection:"facebook",text:U.t("continue_with",{provider:"Facebook"}),canResize:!0,icon:y(gt,{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"}),session:n}),l&&y(Ti,{connection:"google-oauth2",text:U.t("continue_with",{provider:"Google"}),canResize:!0,icon:y(u1,{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"}),session:n}),u&&y(Ti,{connection:"apple",text:U.t("continue_with",{provider:"Apple"}),canResize:!0,icon:y(gt,{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"}),session:n}),p&&y(Ti,{connection:"vipps",text:U.t("continue_with",{provider:"Vipps"}),canResize:!0,icon:y(d1,{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"}),session:n})]})]})]})},p1=["Auth0.swift"];function f1(t){if(!t)return"link";const e=atob(t),n=JSON.parse(e);return p1.includes(n.name)?"code":"link"}const h1=new a.OpenAPIHono().openapi(a.createRoute({tags:["login"],method:"get",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"}),impersonation:a.z.string().optional()})},responses:{200:{description:"Response"}}}),async t=>{const{state:e,impersonation:n}=t.req.valid("query"),{vendorSettings:r,session:i,client:s}=await Fe(t,e);return t.html(y(Mp,{vendorSettings:r,session:i,client:s,email:i.authParams.username,impersonation:n==="true"}))}).openapi(a.createRoute({tags:["login"],method:"post",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"})}),body:{content:{"application/x-www-form-urlencoded":{schema:a.z.object({username:a.z.string().transform(t=>t.toLowerCase()),act_as:a.z.string().transform(t=>t.toLowerCase()).optional(),login_selection:a.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,session:s,vendorSettings:o}=await Fe(t,n);t.set("client_id",i.id);const c=r.username,l=await to({userAdapter:e.data.users,tenant_id:i.tenant.id,email:c});if(l&&t.set("user_id",l.user_id),!l)try{await sy(t,i,t.env.data,r.username)}catch{const v=be(t,{type:me.FAILED_SIGNUP,description:"Public signup is disabled"});return await t.env.data.logs.create(i.tenant.id,v),t.html(y(Mp,{vendorSettings:o,session:s,error:U.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.logins.update(i.tenant.id,s.login_id,s),await Qb(t,i,r.username,r.login_selection))return t.redirect(`/u/enter-password?state=${n}`);let u=sr(),p=await e.data.codes.get(i.tenant.id,u,"otp");for(;p;)u=sr(),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.login_id,expires_at:new Date(Date.now()+za).toISOString()});return f1(s.auth0Client)==="link"&&!r.username.includes("online.no")?Qe(t,iu(t,r.username,h.code_id,s.authParams)):Qe(t,Dg(t,r.username,h.code_id)),t.redirect(`/u/enter-code?state=${n}`)}),tn=t=>y("a",{className:"block text-primary hover:text-primaryHover text-center",href:`/u/enter-email?state=${t.state}`,children:U.t("go_back")});var ni="_hp",g1={Change:"Input",DoubleClick:"DblClick"},m1={svg:"2000/svg",math:"1998/Math/MathML"},ri=[],Yc=new WeakMap,ar=void 0,_1=()=>ar,jt=t=>"t"in t,_a={onClick:["click",!1]},qp=t=>{if(!t.startsWith("on"))return;if(_a[t])return _a[t];const e=t.match(/^on([A-Z][a-zA-Z]+?(?:PointerCapture)?)(Capture)?$/);if(e){const[,n,r]=e;return _a[t]=[(g1[n]||n).toLowerCase(),!!r]}},Dp=(t,e)=>ar&&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,y1=(t,e,n)=>{var r;e||(e={});for(let i in e){const s=e[i];if(i!=="children"&&(!n||n[i]!==s)){i=Ks(i);const o=qp(i);if(o){if((n==null?void 0:n[i])!==s&&(n&&t.removeEventListener(o[0],n[i],o[1]),s!=null)){if(typeof s!="function")throw new Error(`Event handler for "${i}" is not a function`);t.addEventListener(o[0],s,o[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),Yc.set(t,c)}else if(i==="style"){const c=t.style;typeof s=="string"?c.cssText=s:(c.cssText="",s!=null&&Yg(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=Dp(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=Ks(i);const o=qp(i);o?t.removeEventListener(o[0],s,o[1]):i==="ref"?(r=Yc.get(t))==null||r():t.removeAttribute(Dp(t,i))}}},v1=(t,e)=>{e[Se][0]=0,ri.push([t,e]);const n=e.tag[cu]||e.tag,r=n.defaultProps?{...n.defaultProps,...e.props}:e.props;try{return[n.call(null,r)]}finally{ri.pop()}},tm=(t,e,n,r,i)=>{var s,o;(s=t.vR)!=null&&s.length&&(r.push(...t.vR),delete t.vR),typeof t.tag=="function"&&((o=t[Se][1][sm])==null||o.forEach(c=>i.push(c))),t.vC.forEach(c=>{var l;if(jt(c))n.push(c);else if(typeof c.tag=="function"||c.tag===""){c.c=e;const u=n.length;if(tm(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)})},w1=t=>{for(;;t=t.tag===ni||!t.vC||!t.pP?t.nN:t.vC[0]){if(!t)return null;if(t.tag!==ni&&t.e)return t.e}},nm=t=>{var e,n,r,i,s,o;jt(t)||((n=(e=t[Se])==null?void 0:e[1][sm])==null||n.forEach(c=>{var l;return(l=c[2])==null?void 0:l.call(c)}),(r=Yc.get(t.e))==null||r(),t.p===2&&((i=t.vC)==null||i.forEach(c=>c.p=2)),(s=t.vC)==null||s.forEach(nm)),t.p||((o=t.e)==null||o.remove(),delete t.e),typeof t.tag=="function"&&(Cr.delete(t),Gi.delete(t),delete t[Se][3],t.a=!0)},rm=(t,e,n)=>{t.c=e,im(t,e,n)},Hp=(t,e)=>{if(e){for(let n=0,r=t.length;n<r;n++)if(t[n]===e)return n}},Fp=Symbol(),im=(t,e,n)=>{var u;const r=[],i=[],s=[];tm(t,e,r,i,s),i.forEach(nm);const o=n?void 0:e.childNodes;let c,l=null;if(n)c=-1;else if(!o.length)c=0;else{const p=Hp(o,w1(t.nN));p!==void 0?(l=o[p],c=p):c=Hp(o,(u=r.find(h=>h.tag!==ni&&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;jt(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)),y1(v,m.props,m.pP),im(m,v,f))}m.tag===ni?c--:n?v.parentNode||e.appendChild(v):o[c]!==v&&o[c-1]!==v&&(o[c+1]===v?e.appendChild(o[c]):e.insertBefore(v,l||o[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())})}},Gi=new WeakMap,Xc=(t,e,n)=>{var s,o,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"?v1(t,e):Si(e.props.children)),((s=n[0])==null?void 0:s.tag)===""&&n[0][Jc]&&(i=n[0][Jc],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 _=b1(n[f]);if(_){typeof _.tag=="function"&&!_.tag[Kg]&&(or.length>0&&(_[Se][2]=or.map(S=>[S,S.values.at(-1)])),(o=t[5])!=null&&o.length&&(_[Se][3]=t[5].at(-1)));let w;if(h&&h.length){const S=h.findIndex(jt(_)?C=>jt(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(jt(_))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[Se][2]=_[Se][2]||[],w[Se][3]=_[Se][3],!w.f&&((w.o||w)===_.o||(l=(c=w.tag)[Rb])!=null&&l.call(c,S,w.props))&&(w.s=!0)),_=w}else if(!jt(_)&&ar){const S=vr(ar);S&&(_.n=S)}if(!jt(_)&&!_.s&&(Xc(t,_),delete _.f),m.push(_),v&&!v.s&&!_.s)for(let S=v;S&&!jt(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===Fp){if(i)return;throw h}const[m,v,f]=((p=e[Se])==null?void 0:p[3])||[];if(v){const _=()=>Ji([0,!1,t[2]],f),w=Gi.get(f)||[];w.push(_),Gi.set(f,w);const S=v(h,()=>{const C=Gi.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(Xc(t,f,[S]),(v.length===1||t!==m)&&f.c){rm(f,f.c,!1);return}throw Fp}}throw h}finally{i&&t[5].pop()}},b1=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[Se]=[0,[]];else{const e=m1[t.tag];e&&(ar||(ar=Gg("")),t.props.children=[{tag:ar,props:{value:t.n=`http://www.w3.org/${e}`,children:t.props.children}}])}return t}},Kp=(t,e)=>{var n,r;(n=e[Se][2])==null||n.forEach(([i,s])=>{i.values.push(s)});try{Xc(t,e,void 0)}catch{return}if(e.a){delete e.a;return}(r=e[Se][2])==null||r.forEach(([i])=>{i.values.pop()}),(t[0]!==1||!t[1])&&rm(e,e.c,!1)},Cr=new WeakMap,Wp=[],Ji=async(t,e)=>{t[5]||(t[5]=[]);const n=Cr.get(e);n&&n[0](void 0);let r;const i=new Promise(s=>r=s);if(Cr.set(e,[r,()=>{t[2]?t[2](t,e,s=>{Kp(s,e)}).then(()=>r(e)):(Kp(t,e),r(e))}]),Wp.length)Wp.at(-1).add(e);else{await Promise.resolve();const s=Cr.get(e);s&&(Cr.delete(e),s[1]())}return i},k1=(t,e,n)=>({tag:ni,props:{children:t},key:n,e,p:1}),ya=0,sm=1,va=2,wa=3,ba=new WeakMap,om=(t,e)=>!t||!e||t.length!==e.length||e.some((n,r)=>n!==t[r]),x1=void 0,Gp=[],S1=t=>{var o;const e=()=>typeof t=="function"?t():t,n=ri.at(-1);if(!n)return[e(),()=>{}];const[,r]=n,i=(o=r[Se][1])[ya]||(o[ya]=[]),s=r[Se][0]++;return i[s]||(i[s]=[e(),c=>{const l=x1,u=i[s];if(typeof c=="function"&&(c=c(u[0])),!Object.is(c,u[0]))if(u[0]=c,Gp.length){const[p,h]=Gp.at(-1);Promise.all([p===3?r:Ji([p,!1,l],r),h]).then(([m])=>{if(!m||!(p===2||p===3))return;const v=m.vC;requestAnimationFrame(()=>{setTimeout(()=>{v===m.vC&&Ji([p===3?1:0,!1,l],m)})})})}else Ji([0,!1,l],r)}])},pu=(t,e)=>{var c;const n=ri.at(-1);if(!n)return t;const[,r]=n,i=(c=r[Se][1])[va]||(c[va]=[]),s=r[Se][0]++,o=i[s];return om(o==null?void 0:o[1],e)?i[s]=[t,e]:t=i[s][0],t},A1=t=>{const e=ba.get(t);if(e){if(e.length===2)throw e[1];return e[0]}throw t.then(n=>ba.set(t,[n]),n=>ba.set(t,[void 0,n])),t},E1=(t,e)=>{var c;const n=ri.at(-1);if(!n)return t();const[,r]=n,i=(c=r[Se][1])[wa]||(c[wa]=[]),s=r[Se][0]++,o=i[s];return om(o==null?void 0:o[1],e)&&(i[s]=[t(),e]),i[s][0]},I1=Gg({pending:!1,data:null,method:null,action:null}),Jp=new Set,z1=t=>{Jp.add(t),t.finally(()=>Jp.delete(t))},fu=(t,e)=>E1(()=>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]),Vn=Object.create(null),Pi=Object.create(null),Ii=(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:o,onError:c,precedence:l,blocking:u,...p}=e,h=null,m=!1;const v=Fi[t];let f;if(v.length>0){const C=s.querySelectorAll(t);e:for(const B of C)for(const R of Fi[t])if(B.getAttribute(R)===e[R]){h=B;break e}if(!h){const B=v.reduce((R,te)=>e[te]===void 0?R:`${R}-${te}-${e[te]}`,t);m=!Pi[B],h=Pi[B]||(Pi[B]=(()=>{const R=document.createElement(t);for(const te of v)e[te]!==void 0&&R.setAttribute(te,e[te]),e.rel&&R.setAttribute("rel",e.rel);return R})())}}else f=s.querySelectorAll(t);l=r?l??"":void 0,r&&(p[Ki]=l);const _=pu(C=>{if(v.length>0){let B=!1;for(const R of s.querySelectorAll(t)){if(B&&R.getAttribute(Ki)!==l){s.insertBefore(C,R);return}R.getAttribute(Ki)===l&&(B=!0)}s.appendChild(C)}else if(f){let B=!1;for(const R of f)if(R===C){B=!0;break}B||s.insertBefore(C,s.contains(f[0])?f[0]:s.querySelector(t)),f=void 0}},[l]),w=fu(e.ref,C=>{var te;const B=v[0];if(n===2&&(C.innerHTML=""),(m||f)&&_(C),!c&&!o)return;let R=Vn[te=C.getAttribute(B)]||(Vn[te]=new Promise((fe,le)=>{C.addEventListener("load",fe),C.addEventListener("error",le)}));o&&(R=R.then(o)),c&&(R=R.catch(c)),R.catch(()=>{})});if(i&&u==="render"){const C=Fi[t][0];if(e[C]){const B=e[C],R=Vn[B]||(Vn[B]=new Promise((te,fe)=>{_(h),h.addEventListener("load",te),h.addEventListener("error",fe)}));A1(R)}}const S={tag:t,type:t,props:{...p,ref:w},ref:w};return S.p=n,h&&(S.e=h),k1(S,s)},C1=t=>{const e=_1(),n=e&&vr(e);return n!=null&&n.endsWith("svg")?{tag:"title",props:t,type:"title",ref:t.ref}:Ii("title",t,void 0,!1,!1)},N1=t=>!t||["src","async"].some(e=>!t[e])?{tag:"script",props:t,type:"script",ref:t.ref}:Ii("script",t,1,!1,!0),j1=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,Ii("style",t,2,!0,!0)),$1=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}:Ii("link",t,1,"precedence"in t,!0),O1=t=>Ii("meta",t,void 0,!1,!1),am=Symbol(),B1=t=>{const{action:e,...n}=t;typeof e!="function"&&(n.action=e);const[r,i]=S1([null,!1]),s=pu(async u=>{const p=u.isTrusted?e:u.detail[am];if(typeof p!="function")return;u.preventDefault();const h=new FormData(u.target);i([h,!0]);const m=p(h);m instanceof Promise&&(z1(m),await m),i([null,!0])},[]),o=fu(t.ref,u=>(u.addEventListener("submit",s),()=>{u.removeEventListener("submit",s)})),[c,l]=r;return r[1]=!1,{tag:I1,props:{value:{pending:c!==null,data:c,method:c?"post":null,action:c?e:null},children:{tag:"form",props:{...n,ref:o},type:"form",ref:o}},f:l}},cm=(t,{formAction:e,...n})=>{if(typeof e=="function"){const r=pu(i=>{i.preventDefault(),i.currentTarget.form.dispatchEvent(new CustomEvent("submit",{detail:{[am]:e}}))},[]);n.ref=fu(n.ref,i=>(i.addEventListener("click",r),()=>{i.removeEventListener("click",r)}))}return{tag:t,props:n,type:t,ref:n.ref}},T1=t=>cm("input",t),P1=t=>cm("button",t);Object.assign(Zc,{title:C1,script:N1,style:j1,link:$1,meta:O1,form:B1,input:T1,button:P1});new TextEncoder;const lm=t=>{const{i18nKey:e,values:n,components:r}=t,i=U.t(e,n),s=/<(\d+)>(.*?)<\/\d+>/g,o=[];let c=0,l;for(;(l=s.exec(i))!==null;){const[,u,p]=l,h=i.substring(c,l.index);h&&o.push(h);const m=parseInt(u,10);o.push(Xb(r[m],{},p)),c=s.lastIndex}return c<i.length&&o.push(i.substring(c)),y(du,{children:o})},Zp=6,Yp=({error:t,vendorSettings:e,email:n,state:r,client:i,hasPasswordLogin:s})=>{const o=new URLSearchParams({state:r}),l=i.connections.map(({name:u})=>u).includes("auth2");return y(Nt,{title:U.t("verify_your_email"),vendorSettings:e,children:[y("div",{className:"mb-4 text-2xl font-medium",children:U.t("verify_your_email")}),y("div",{className:"mb-8 text-gray-300",children:y(lm,{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:Zp,inputMode:"numeric",name:"code",placeholder:"******",className:Et("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:Zp,required:!0,id:"code-input"}),t&&y(wr,{children:t}),y("div",{className:"text-center sm:mt-2",children:y(Tn,{className:"text-base sm:mt-4 md:text-base",children:y("div",{className:"flex items-center space-x-2",children:[y("span",{children:U.t("login")}),y(gt,{className:"text-xs",name:"arrow-right"})]})})}),y("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[y(gt,{className:"text-base",name:"info-bubble"}),y("div",{className:"text-sm text-gray-300 md:text-sm",children:U.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:U.t("or")})]}),y(ti,{Component:"a",href:`/u/${s?"enter-password":"pre-signup"}?${o.toString()}`,variant:"secondary",className:"block",children:U.t("enter_your_password_btn")})]})]}),y(tn,{state:r})]})]})},R1=new a.OpenAPIHono().openapi(a.createRoute({tags:["login"],method:"get",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,session:r,client:i}=await Fe(t,e);if(!r.authParams.username)throw new N(400,{message:"Username not found in state"});const s=await cs({userAdapter:t.env.data.users,tenant_id:i.tenant.id,email:r.authParams.username,provider:"auth2"});return t.html(y(Yp,{vendorSettings:n,email:r.authParams.username,state:e,client:i,hasPasswordLogin:!!s}))}).openapi(a.createRoute({tags:["login"],method:"post",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state"})}),body:{content:{"application/x-www-form-urlencoded":{schema:a.z.object({code:a.z.string()})}}}},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{code:n}=t.req.valid("form"),{session:r,client:i,vendorSettings:s}=await Fe(t,e);if(t.set("client_id",i.id),!r.authParams.username)throw new N(400,{message:"Username not found in state"});try{return await ou(t,i,r.authParams,r.authParams.username,n)}catch(o){const c=o,l=await cs({userAdapter:t.env.data.users,tenant_id:i.tenant.id,email:r.authParams.username,provider:"auth2"});return t.html(y(Yp,{vendorSettings:s,email:r.authParams.username,state:e,client:i,error:c.message,hasPasswordLogin:!!l}),400)}}),L1=t=>{const{vendorSettings:e,state:n}=t;return y(Nt,{title:U.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:U.t("unverified_email")}),y("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[y(gt,{className:"text-base",name:"info-bubble"}),y("div",{className:"text-sm text-gray-300 md:text-sm",children:U.t("sent_code_spam")})]}),y(tn,{state:n})]}),y(tn,{state:n})]})},ka=t=>{const{error:e,vendorSettings:n,email:r,state:i}=t,s=new URLSearchParams({state:i});return y(Nt,{title:U.t("enter_password"),vendorSettings:n,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:U.t("enter_password")}),y("div",{className:"mb-6 text-gray-300",children:U.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:U.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:U.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(wr,{children:e}),y(Tn,{className:"text-base sm:mt-4 md:text-base",children:y("div",{className:"flex items-center space-x-2",children:[y("span",{children:U.t("login")}),y(gt,{className:"text-xs",name:"arrow-right"})]})})]}),y("a",{href:`/u/forgot-password?${s.toString()}`,className:"text-primary hover:underline mb-4",children:U.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:U.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(ti,{variant:"secondary",className:"block",children:U.t("enter_a_code_btn")})]})]}),y(tn,{state:i})]})]})},U1=new a.OpenAPIHono().openapi(a.createRoute({tags:["login"],method:"get",path:"/",request:{query:a.z.object({state:a.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,session:i}=await Fe(t,e);if(!i.authParams.username)throw new N(400,{message:"Username required"});return t.html(y(ka,{vendorSettings:n,email:i.authParams.username,state:e,client:r}))}).openapi(a.createRoute({tags:["login"],method:"post",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"})}),body:{content:{"application/x-www-form-urlencoded":{schema:a.z.object({password:a.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,session:o}=await Fe(t,e),{username:c}=o.authParams;if(!c)throw new N(400,{message:"Username required"});try{return await au(t,s,{...o.authParams,password:r},o)}catch(l){const u=l;return u.code==="INVALID_PASSWORD"||u.code==="USER_NOT_FOUND"?t.html(y(ka,{vendorSettings:i,email:c,error:U.t("invalid_password"),state:e,client:s}),400):u.code==="EMAIL_NOT_VERIFIED"?t.html(y(L1,{vendorSettings:i,state:e}),400):t.html(y(ka,{vendorSettings:i,email:c,error:u.message,state:e,client:s}),400)}}),Ir=t=>{const{state:e,error:n,vendorSettings:r,email:i,code:s}=t;return y(Nt,{title:U.t("create_account_title"),vendorSettings:r,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:U.t("create_account_title")}),y("div",{className:"mb-6 text-gray-300",children:U.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:U.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:U.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:U.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(wr,{children:n}),y(Tn,{className:"text-base sm:mt-2 md:text-base",children:U.t("continue")})]}),y(tn,{state:e})]})]})},um=t=>{const{message:e,vendorSettings:n,pageTitle:r,state:i}=t;return y(Nt,{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(tn,{state:i}):""]})},V1=new a.OpenAPIHono().openapi(a.createRoute({tags:["login"],method:"get",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"}),code:a.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,session:i}=await Fe(t,e),{username:s}=i.authParams;if(!s)throw new N(400,{message:"Username required"});return n?t.html(y(Ir,{state:e,vendorSettings:r,email:s,code:n})):t.html(y(Ir,{state:e,vendorSettings:r,email:s}))}).openapi(a.createRoute({tags:["login"],method:"post",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"})}),body:{content:{"application/x-www-form-urlencoded":{schema:a.z.object({password:a.z.string(),"re-enter-password":a.z.string(),code:a.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,session:o}=await Fe(t,e),c="Username-Password-Authentication";t.set("client_id",s.id),t.set("connection",c);const l=o.authParams.username;if(!l)throw new N(400,{message:"Username required"});if(n.password!==n["re-enter-password"])return t.html(y(Ir,{state:e,code:n.code,vendorSettings:i,error:U.t("create_account_passwords_didnt_match"),email:o.authParams.username}),400);if(!ru(n.password))return t.html(y(Ir,{state:e,code:n.code,vendorSettings:i,error:U.t("create_account_weak_password"),email:o.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.logins.get(s.tenant.id,u.login_id):void 0;try{if(await si({userAdapter:t.env.data.users,tenant_id:s.tenant.id,email:l,provider:"auth2"}))throw new N(400,{message:"Invalid sign up"});const m=(p==null?void 0:p.authParams.username)===l,v=await Rf(t).users.create(s.tenant.id,{user_id:`auth2|${Ys()}`,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 ii.hash(n.password,10),algorithm:"bcrypt"}),m?await au(t,s,{...o.authParams,password:n.password},o):(await su(t,v),t.html(y(um,{message:U.t("validate_email_body"),pageTitle:U.t("validate_email_title"),vendorSettings:i,state:e})))}catch(h){const m=await Qg(r,s.id,o.authParams.vendor_id),v=h;return t.html(y(Ir,{state:e,vendorSettings:m,error:v.message,email:l}),400)}}),zr=t=>{const{error:e,vendorSettings:n,email:r}=t;return y(Nt,{title:U.t("reset_password_title"),vendorSettings:n,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:U.t("reset_password_title")}),y("div",{className:"mb-6 text-gray-300",children:`${U.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:U.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:U.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(wr,{children:e}),y(Tn,{className:"text-base sm:mt-2 md:text-base",children:U.t("reset_password_cta")})]})})]})},M1=new a.OpenAPIHono().openapi(a.createRoute({tags:["login"],method:"get",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"}),code:a.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,session:r}=await Fe(t,e);if(!r.authParams.username)throw new N(400,{message:"Username required"});return t.html(y(zr,{vendorSettings:n,email:r.authParams.username}))}).openapi(a.createRoute({tags:["login"],method:"post",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"}),code:a.z.string().openapi({description:"The code parameter from the authorization request"})}),body:{content:{"application/x-www-form-urlencoded":{schema:a.z.object({password:a.z.string(),"re-enter-password":a.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:o,client:c,session:l}=await Fe(t,e);if(!l.authParams.username)throw new N(400,{message:"Username required"});if(r!==i)return t.html(y(zr,{error:U.t("create_account_passwords_didnt_match"),vendorSettings:o,email:l.authParams.username}),400);if(!ru(r))return t.html(y(zr,{error:U.t("create_account_weak_password"),vendorSettings:o,email:l.authParams.username}),400);const u=await si({userAdapter:s.data.users,tenant_id:c.tenant.id,email:l.authParams.username,provider:"auth2"});if(!u)throw new N(400,{message:"User not found"});try{if(!await s.data.codes.get(c.tenant.id,n,"password_reset"))return t.html(y(zr,{error:"Code not found or expired",vendorSettings:o,email:l.authParams.username}),400);const h={user_id:u.user_id,password:await ii.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(zr,{error:"The password could not be reset",vendorSettings:o,email:l.authParams.username}),400)}return t.html(y(um,{message:U.t("password_has_been_reset"),vendorSettings:o,state:e}))}),q1=t=>{const{error:e,vendorSettings:n,email:r,state:i}=t;return y(Nt,{title:U.t("forgot_password_title"),vendorSettings:n,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:U.t("forgot_password_title")}),y("div",{className:"mb-6 text-gray-300",children:U.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:U.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(wr,{children:e}),y(Tn,{className:"sm:mt-4",children:U.t("forgot_password_cta")})]}),y(tn,{state:i})]})]})},D1=t=>{const{vendorSettings:e,state:n}=t;return y(Nt,{title:"Login",vendorSettings:e,children:[y("div",{className:"flex flex-1 flex-col justify-center",children:[y("div",{children:U.t("forgot_password_email_sent")}),y("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[y(gt,{className:"text-base",name:"info-bubble"}),y("div",{className:"text-sm text-gray-300 md:text-sm",children:U.t("sent_code_spam")})]})]}),y(tn,{state:n})]})},H1=new a.OpenAPIHono().openapi(a.createRoute({tags:["login"],method:"get",path:"/",request:{query:a.z.object({state:a.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,session:r}=await Fe(t,e);return t.html(y(q1,{vendorSettings:n,state:e,email:r.authParams.username}))}).openapi(a.createRoute({tags:["login"],method:"post",path:"/",request:{query:a.z.object({state:a.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,session:i}=await Fe(t,e);return await Ab(t,r,i.authParams.username,i.login_id),t.html(y(D1,{vendorSettings:n,state:e}))}),F1=({vendorSettings:t,state:e,user:n})=>y(Nt,{title:de("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(lm,{i18nKey:"currently_logged_in_as",components:[y("span",{className:"font-semibold text-gray-900 dark:text-white"},"span")],values:{email:n.email}}),y("br",{}),de("continue_with_sso_provider_headline")]}),y("div",{className:"space-y-6",children:[y(Pn,{children:y(Tn,{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:U.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:U.t("no_use_another")})]})]})}),K1=new a.OpenAPIHono().openapi(a.createRoute({tags:["login"],method:"get",path:"/",request:{query:a.z.object({state:a.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 Fe(t,n),s=as(i.tenant.id,t.req.header("cookie")),o=s?await e.data.sessions.get(i.tenant.id,s):null;if(!o)return t.redirect(`/u/enter-email?state=${n}`);const c=await e.data.users.get(i.tenant.id,o.user_id);return c?t.html(y(F1,{vendorSettings:r,state:n,user:c})):t.redirect(`/u/enter-email?state=${n}`)}).openapi(a.createRoute({tags:["login"],method:"post",path:"/",request:{query:a.z.object({state:a.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"),{session:r,client:i}=await Fe(t,n),s=as(i.tenant.id,t.req.header("cookie")),o=s?await e.data.sessions.get(i.tenant.id,s):null;if(!o)return t.redirect(`/u/enter-email?state=${n}`);const c=await e.data.users.get(i.tenant.id,o.user_id);return c?sn(t,{user:c,authParams:r.authParams,client:i,loginSession:r}):t.redirect(`/u/enter-email?state=${n}`)});function W1(){const e=new a.OpenAPIHono().route("/check-account",K1).route("/enter-email",h1).route("/enter-code",R1).route("/enter-password",U1).route("/reset-password",M1).route("/forgot-password",H1).route("/signup",V1);return e.doc("/u/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Universal login"}}),e}const G1="Account detected",J1="We have detected that you have already created an account through",Z1="By signing in, you agree to our",Y1="and",X1="Callback URL mismatch",Q1="The provided redirect_uri is not in the list of allowed callback URLs.",ek="continue with user",tk="Please click the button to create a new password account.",nk="Enter the code at {{vendorName}} to complete the login",rk="Welcome to {{vendorName}}! {{code}} is the login code",ik="Welcome to {{vendorName}}! {{code}} is the login code",sk="The code is valid for 30 minutes",ok="Confirm password",ak="Need Help?",ck="Contact us",lk="or continue with social account",uk="Continue with {{provider}}",dk="Would you like to continue with your existing account?",pk="Copyright © 2023 SESAMY. All rights reserved.",fk="©2023 Sesamy",hk="Choose a password with a mix of uppercase and lowercase letters, numbers, and symbols.",gk="Please enter a valid email address.",mk="The passwords didn't match. Try again.",_k="Choose password",yk="Password must be at least 8 characters long and contain at least one lowercase letter, one uppercase letter, one number and one symbol.",vk="Create new account",wk="Sign up with password",bk="You are currently logged in as <0>{{email}}</0>",kk="Email",xk="Email address",Sk="Your email address has been validated",Ak="Now enter your password to login again",Ek="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.",Ik="Email verification sent",zk="Enter a code",Ck="We'll send you a verification link to ensure you own this email address.",Nk="Enter new password",jk="Enter password",$k="Enter your email address and password to login.",Ok="Enter your password",Bk="The magic link has expired. Please click on the button below to receive a new link in your inbox.",Tk="Hey! We updated our login experience. <0>Click here to learn more about it.</0>",Pk="Send password reset email",Rk="Click the button below and we’ll send instructions on how to reset your password.",Lk="Password reset email sent",Uk="Forgot password?",Vk="Forgot password?",Mk="Go back",qk="Invalid password",Dk=`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.`,
|
|
226
|
+
You can click the link below to start a new login.`,Hk="Invalid link",Fk="Click the button to log in",Kk="Login",Wk="Or enter the code at {{vendorName}} to complete the login.",Gk="Enter your email address to unlock this show on {{service}}",Jk="Link your account with {{service}}",Zk="You are logged in as",Yk="Login",Xk="Enter your email address to sign in.",Qk="Enter your email address and we will send you a login code.",ex="Enter your email address and we will send you a login link.",tx="Log out",nx="No, I want to use another account",rx="or",ix="Password",sx="The password has been reset",ox="Success",ax="Change password for your {{vendorName}} account",cx="Change password for your {{vendorName}} account",lx="Privacy Policy",ux="Redirecting",dx="Confirm password",px="Register a new password",fx="Resend code",hx="Change password",gx="Enter your new password below for the email account: ",mx="Click the button to reset your password",_x="Click the button to reset your password",yx="Reset your password",vx="Change password for your {{vendorName}} account",wx="Reset password",bx="Send",kx="Send me a new magic link",xx="Remember to check your spam folder if the email did not arrive.",Sx="Set password",Ax="Sign in",Ex="Signup",Ix="Sign up successful",zx="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.",Cx="Go to Spotify's Content Access page",Nx=`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.`,jx="Step 1: Unlink Your Spotify Account",$x="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.",Ox="Step 2: Relink Your Spotify Account to Sesamy",Bx="Oops! Your Spotify Account Is Already Linked",Tx="If you have questions or need assistance, you can contact our support team",Px="Terms and Conditions",Rx="Your email address needs validating. We have sent a new email to your inbox",Lx="User account does not exist",Ux="User account does not exist",Vx="We could not find a user with the provided email address. Please, try again.",Mx="Try again.",qx="Validate code",Dx="Check your inbox for email validation instructions.",Hx="Signed up",Fx="Click the button to verify your email address",Kx="Validate your email address",Wx="Validate your email address",Gx="Verify account",Jx="Verify your email",Zx="Please check your email at <0>{{email}}</0> and enter the six-digit code that we've sent you.",Yx="Welcome",Xx="Welcome to your {{vendorName}} account!",Qx="Continue with this account",eS="Yes, continue with {{text}}",tS="Yes, continue with existing account",nS={"Server error: Invalid code":"Invalid code","Wrong email or verification code":{"":"Wrong email or verification code."},account_detected:G1,account_with_sso_provider:J1,agree_to:Z1,and:Y1,callback_url_mismatch:X1,callback_url_not_allowed:Q1,check_email_title:ek,click_to_sign_up_description:tk,code_email_enter_code:nk,code_email_subject:rk,code_email_title:ik,code_valid_30_minutes:sk,confirm_password:ok,contact_support:ak,contact_us:ck,continue:"Continue",continue_social_login:lk,continue_with:uk,continue_with_sso_provider_headline:dk,copyright:pk,copyright_sesamy:fk,create_account_description:hk,create_account_email_invalid:gk,create_account_passwords_didnt_match:mk,create_account_title:_k,create_account_weak_password:yk,create_new_account_link:vk,create_password_account_title:wk,currently_logged_in_as:bk,email:kk,email_placeholder:xk,email_validated:Sk,email_validated_cta:Ak,email_verification_for_signup_sent_description:Ek,email_verification_for_signup_sent_title:Ik,enter_a_code_btn:zk,enter_email_for_verification_description:Ck,enter_new_password_placeholder:Nk,enter_password:jk,enter_password_description:$k,enter_your_password_btn:Ok,expired_code:Bk,fokus_info_message:Tk,forgot_password_cta:Pk,forgot_password_description:Rk,forgot_password_email_sent:Lk,forgot_password_link:Uk,forgot_password_title:Vk,go_back:Mk,"invalid-email":"Invalid email",invalid_password:qk,invalid_session_body:Dk,invalid_session_title:Hk,link_email_click_to_login:Fk,link_email_login:Kk,link_email_or_enter_code:Wk,link_page_body:Gk,link_page_headline:Jk,logged_in_as:Zk,login:Yk,login_description:Xk,login_description_code:Qk,login_description_link:ex,logout:tx,no_use_another:nx,or:rx,password:ix,password_has_been_reset:sx,password_has_been_reset_title:ox,password_reset_subject:ax,password_reset_title:cx,privacy_policy:lx,redirecting:ux,reenter_new_password_placeholder:dx,register_password_account:px,resend_code:fx,reset_password_cta:hx,reset_password_description:gx,reset_password_email_click_to_reset:mx,reset_password_email_cta:_x,reset_password_email_reset:yx,reset_password_subject:vx,reset_password_title:wx,send:bx,send_me_a_new_magic_link:kx,sent_code_spam:xx,set_password:Sx,sign_in:Ax,signup:Ex,signup_success:Ix,spotify_already_linked_body:zx,spotify_already_linked_cta:Cx,spotify_already_linked_step1_body:Nx,spotify_already_linked_step1_title:jx,spotify_already_linked_step2_body:$x,spotify_already_linked_step2_title:Ox,spotify_already_linked_title:Bx,support_info:Tx,terms:Px,unverified_email:Rx,user_account_does_not_exist:Lx,user_not_found:Ux,user_not_found_body:Vx,user_not_found_cta:Mx,validate_code:qx,validate_email_body:Dx,validate_email_title:Hx,verify_email_click_to_verify:Fx,verify_email_subject:Kx,verify_email_title:Wx,verify_email_verify:Gx,verify_your_email:Jx,we_sent_a_code_to:Zx,welcome:Yx,welcome_to_your_account:Xx,yes_continue:Qx,yes_continue_with:eS,yes_continue_with_existing_account:tS},rS="Account rilevato",iS="Abbiamo rilevato che l'utente ha già creato un account tramite",sS="Effettuando l'accesso, l'utente accetta la nostra",oS="e",aS="Mancata corrispondenza dell'URL di callback",cS="Il redirect_uri fornito non è nell'elenco degli URL di callback consentiti.",lS="continuare con l'utente",uS="Fare clic sul pulsante per creare un nuovo account con password.",dS="Inserite il codice all'indirizzo {{vendorName}} per completare il login.",pS="Benvenuti su {{vendorName}}! {{code}} è il codice di accesso",fS="Benvenuti su {{vendorName}}! {{code}} è il codice di accesso",hS="Il codice è valido per 30 minuti",gS="Confermare la password",mS="Avete bisogno di aiuto?",_S="Contattateci",yS="o continuare con il conto sociale",vS="Continua con {{provider}}",wS="Desidera continuare a utilizzare l'account esistente?",bS="Copyright © 2023 SESAMY. Tutti i diritti riservati.",kS="©2023 Sesamy",xS="Scegliete una password con un mix di lettere maiuscole e minuscole, numeri e simboli.",SS="Inserire un indirizzo e-mail valido.",AS="Le password non corrispondono. Riprovare.",ES="Scegliere la password",IS="La password deve essere lunga almeno 8 caratteri e contenere almeno una lettera minuscola, una lettera maiuscola, un numero e un simbolo.",zS="Creare un nuovo account",CS="Iscriviti con la password",NS="Attualmente si è connessi come <0>{{email}}</0>",jS="Email",$S="Indirizzo e-mail",OS="Il tuo indirizzo e-mail è stato convalidato",BS="Ora inserire la password per accedere nuovamente",TS="È 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.",PS="Email di verifica inviata",RS="Inserire un codice",LS="Vi invieremo un link di verifica per assicurarvi di possedere questo indirizzo e-mail.",US="Inserire la nuova password",VS="Inserire la password",MS="Inserire l'indirizzo e-mail e la password per accedere.",qS="Inserire la password",DS="Il link magico è scaduto. Cliccate sul pulsante sottostante per ricevere un nuovo link nella vostra casella di posta elettronica.",HS="Abbiamo aggiornato la nostra esperienza di accesso. <0>Clicca qui per saperne di più.</0>",FS="Inviare l'e-mail di reimpostazione della password",KS="Fare clic sul pulsante sottostante per ricevere le istruzioni su come reimpostare la password.",WS="Email di reimpostazione della password inviata",GS="Hai dimenticato la password?",JS="Hai dimenticato la password?",ZS="Torna indietro",YS="Password non valida",XS=`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.`,
|
|
230
|
+
Potete fare clic sul link sottostante per iniziare un nuovo accesso.`,QS="Collegamento non valido",e2="Fare clic sul pulsante per accedere",t2="Accedi",n2="Oppure inserire il codice all'indirizzo {{vendorName}} per completare il login.",r2="Inserisci il tuo indirizzo e-mail per sbloccare questo spettacolo su {{service}}",i2="Collegate il vostro account con {{service}}",s2="L'utente ha effettuato l'accesso come",o2="Accesso",a2="Inserire l'indirizzo e-mail per accedere.",c2="Inserite il vostro indirizzo e-mail e vi invieremo un codice di accesso.",l2="Inserite il vostro indirizzo e-mail e vi invieremo un link di accesso.",u2="Disconnettersi",d2="No, voglio usare un altro account",p2="o",f2="Password",h2="La password è stata reimpostata",g2="Il successo",m2="Modifica della password dell'account {{vendorName}}",_2="Modifica della password dell'account {{vendorName}} ",y2="Informativa sulla privacy",v2="Reindirizzamento",w2="Confermare la password",b2="Registrazione di una nuova password",k2="Reinvio del codice",x2="Modifica della password",S2="Immettere di seguito la nuova password per l'account e-mail: ",A2="Fare clic sul pulsante per reimpostare la password",E2="Fare clic sul pulsante per reimpostare la password",I2="Reimpostare la password",z2="Modifica della password dell'account {{vendorName}} ",C2="Reimpostare la password",N2="Inviare",j2="Inviami un nuovo link magico",$2="Ricordate di controllare la cartella spam se l'e-mail non è arrivata.",O2="Impostare la password",B2="Accedi",T2="Iscriviti",P2="Iscriviti con successo",R2="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.",L2="Vai alla pagina di accesso ai contenuti di Spotify",U2=`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.`,V2="Passo 1: Disconnettere l'account Spotify",M2="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.",q2="Passo 2: ricollegare l'account Spotify a Sesamy",D2="Ops! Il tuo account Spotify è già collegato",H2="Se avete domande o bisogno di assistenza, potete contattare il nostro team di supporto",F2="Termini e condizioni",K2="Il tuo indirizzo e-mail deve essere convalidato. Abbiamo inviato una nuova e-mail alla tua casella di posta.",W2="L'account utente non esiste",G2="L'account utente non esiste",J2="Non è stato possibile trovare un utente con l'indirizzo e-mail fornito. Si prega di riprovare.",Z2="Riprova.",Y2="Convalida del codice",X2="Controllate la vostra casella di posta per le istruzioni di convalida dell'e-mail.",Q2="Iscritta",eA="Fare clic sul pulsante per verificare l'indirizzo e-mail",tA="Convalidare l'indirizzo e-mail",nA="Convalidare l'indirizzo e-mail",rA="Verifica dell'account",iA="Verificare l'e-mail",sA="Controllate la vostra e-mail all'indirizzo <0>{{email}}</0> e inserisca il codice a sei cifre che le abbiamo inviato.",oA="Benvenuti",aA="Benvenuto nel tuo account {{vendorName}}!",cA="Continuare con questo account",lA="Sì, continuare con {{text}}",uA="Sì, continuare con l'account esistente",dA={"Server error: Invalid code":"Codice non valido","Wrong email or verification code":{"":"Email o codice di verifica errati."},account_detected:rS,account_with_sso_provider:iS,agree_to:sS,and:oS,callback_url_mismatch:aS,callback_url_not_allowed:cS,check_email_title:lS,click_to_sign_up_description:uS,code_email_enter_code:dS,code_email_subject:pS,code_email_title:fS,code_valid_30_minutes:hS,confirm_password:gS,contact_support:mS,contact_us:_S,continue:"Continua",continue_social_login:yS,continue_with:vS,continue_with_sso_provider_headline:wS,copyright:bS,copyright_sesamy:kS,create_account_description:xS,create_account_email_invalid:SS,create_account_passwords_didnt_match:AS,create_account_title:ES,create_account_weak_password:IS,create_new_account_link:zS,create_password_account_title:CS,currently_logged_in_as:NS,email:jS,email_placeholder:$S,email_validated:OS,email_validated_cta:BS,email_verification_for_signup_sent_description:TS,email_verification_for_signup_sent_title:PS,enter_a_code_btn:RS,enter_email_for_verification_description:LS,enter_new_password_placeholder:US,enter_password:VS,enter_password_description:MS,enter_your_password_btn:qS,expired_code:DS,fokus_info_message:HS,forgot_password_cta:FS,forgot_password_description:KS,forgot_password_email_sent:WS,forgot_password_link:GS,forgot_password_title:JS,go_back:ZS,"invalid-email":"Email non valida",invalid_password:YS,invalid_session_body:XS,invalid_session_title:QS,link_email_click_to_login:e2,link_email_login:t2,link_email_or_enter_code:n2,link_page_body:r2,link_page_headline:i2,logged_in_as:s2,login:o2,login_description:a2,login_description_code:c2,login_description_link:l2,logout:u2,no_use_another:d2,or:p2,password:f2,password_has_been_reset:h2,password_has_been_reset_title:g2,password_reset_subject:m2,password_reset_title:_2,privacy_policy:y2,redirecting:v2,reenter_new_password_placeholder:w2,register_password_account:b2,resend_code:k2,reset_password_cta:x2,reset_password_description:S2,reset_password_email_click_to_reset:A2,reset_password_email_cta:E2,reset_password_email_reset:I2,reset_password_subject:z2,reset_password_title:C2,send:N2,send_me_a_new_magic_link:j2,sent_code_spam:$2,set_password:O2,sign_in:B2,signup:T2,signup_success:P2,spotify_already_linked_body:R2,spotify_already_linked_cta:L2,spotify_already_linked_step1_body:U2,spotify_already_linked_step1_title:V2,spotify_already_linked_step2_body:M2,spotify_already_linked_step2_title:q2,spotify_already_linked_title:D2,support_info:H2,terms:F2,unverified_email:K2,user_account_does_not_exist:W2,user_not_found:G2,user_not_found_body:J2,user_not_found_cta:Z2,validate_code:Y2,validate_email_body:X2,validate_email_title:Q2,verify_email_click_to_verify:eA,verify_email_subject:tA,verify_email_title:nA,verify_email_verify:rA,verify_your_email:iA,we_sent_a_code_to:sA,welcome:oA,welcome_to_your_account:aA,yes_continue:cA,yes_continue_with:lA,yes_continue_with_existing_account:uA},pA="Konto oppdaget",fA="Vi har oppdaget at du allerede har opprettet en konto gjennom",hA="Ved å logge på godtar du vår",gA="og",mA="Callback-URLen samsvarer ikke",_A="Den oppgitte redirect_uri er ikke på listen over tillatte tilbakeringings-URLer.",yA="fortsett med bruker",vA="Klikk på knappen for å opprette en ny passordkonto.",wA="Skriv inn koden på {{vendorName}} for å fullføre påloggingen",bA="Velkommen til {{vendorName}} ! {{code}} er påloggingskoden",kA="Velkommen til {{vendorName}}! {{code}} er påloggingskoden",xA="Koden er gyldig i 30 minutter",SA="Bekreft passord",AA="Trenger hjelp?",EA="Kontakt oss",IA="eller fortsett med sosial konto",zA="Fortsett med {{provider}}",CA="Vil du fortsette med din eksisterende konto?",NA="Opphavsrett © 2023 SESAMY. Alle rettigheter forbeholdt.",jA="©2023 Sesamy",$A="Velg et passord med en blanding av store og små bokstaver, tall og symboler.",OA="Vennligst skriv inn en gyldig e-postadresse.",BA="Passordene stemte ikke overens. Prøv igjen.",TA="Velg passord",PA="Passordet må være på minst 8 tegn og inneholde minst én liten bokstav, én stor bokstav, ett tall og ett symbol.",RA="Opprett ny konto",LA="Registrer deg med passord",UA="Du er logget på som <0> {{email}}</0>",VA="E-post",MA="E-postadresse",qA="E-postadressen din har blitt validert",DA="Skriv nå inn passordet ditt for å logge inn igjen",HA="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.",FA="E-postbekreftelse sendt",KA="Angi en kode",WA="Vi sender deg en bekreftelseskobling for å sikre at du eier denne e-postadressen.",GA="Skriv inn nytt passord",JA="Oppgi passord",ZA="Skriv inn e-postadressen og passordet ditt for å logge inn.",YA="Skriv inn passordet ditt",XA="Den magiske lenken er utløpt. Vennligst klikk på knappen nedenfor for å motta en ny lenke i innboksen din.",QA="Hei! Vi oppdaterte påloggingsopplevelsen vår. <0>Klikk her for å lære mer om det.</0>",e4="Send e-post om tilbakestilling av passord",t4="Klikk på knappen nedenfor, så sender vi deg instruksjoner om hvordan du tilbakestiller passordet ditt.",n4="E-post om tilbakestilling av passord sendt",r4="Har du glemt passordet?",i4="Har du glemt passordet?",s4="Gå tilbake",o4="Ugyldig passord",a4=`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.`,
|
|
234
|
+
Du kan klikke på lenken nedenfor for å starte en ny pålogging.`,c4="Ugyldig lenke",l4="Klikk på knappen for å logge inn",u4="Logg inn",d4="Eller skriv inn koden på {{vendorName}} for å fullføre påloggingen.",p4="Skriv inn e-postadressen din for å låse opp dette programmet på {{service}}",f4="Koble kontoen din til {{service}}",h4="Du er innlogget som",g4="Logg inn",m4="Skriv inn e-postadressen din for å logge på.",_4="Skriv inn e-postadressen din og vi sender deg en påloggingskode.",y4="Skriv inn e-postadressen din og vi sender deg en påloggingslenke.",v4="Logg ut",w4="Nei, jeg vil bruke en annen konto",b4="eller",k4="Passord",x4="Passordet har blitt tilbakestilt",S4="Suksess",A4="Endre passord for {{vendorName}} kontoen din",E4="Endre passord for {{vendorName}} kontoen din",I4="Personvernerklæring",z4="Omdirigerer",C4="Bekreft passord",N4="Registrer et nytt passord",j4="Send kode på nytt",$4="Endre passord",O4="Skriv inn det nye passordet for e-postkontoen nedenfor: ",B4="Klikk på knappen for å tilbakestille passordet ditt",T4="Klikk på knappen for å tilbakestille passordet ditt",P4="Tilbakestill passordet ditt",R4="Endre passord for {{vendorName}} -kontoen din",L4="Tilbakestill passord",U4="Send",V4="Send meg en ny magisk lenke",M4="Husk å sjekke søppelpostmappen din hvis e-posten ikke kom.",q4="Angi passord",D4="Logg inn",H4="Påmelding",F4="Vellykket registrering",K4="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.",W4="Gå til Spotifys innholdstilgangsside",G4='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.',J4="Trinn 1: Koble fra Spotify-kontoen din",Z4="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.",Y4="Trinn 2: Koble Spotify-kontoen din til Sesamy på nytt",X4="Oops! Spotify-kontoen din er allerede koblet",Q4="Hvis du har spørsmål eller trenger hjelp, kan du kontakte supportteamet vårt",eE="vilkår",tE="E-postadressen din må bekreftes. Vi har sendt en ny e-post til innboksen din.",nE="Brukerkonto eksisterer ikke",rE="Brukerkonto eksisterer ikke",iE="Vi kunne ikke finne en bruker med den oppgitte e-postadressen. Vær så snill, prøv på nytt.",sE="Prøv igjen.",oE="Bekreft koden",aE="Sjekk innboksen din for instruksjoner om e-postvalidering.",cE="Registrerte seg",lE="Klikk på knappen for å bekrefte e-postadressen din",uE="Bekreft e-postadressen din",dE="Bekreft e-postadressen din",pE="Bekreft konto",fE="Bekreft e-posten din",hE="Vennligst sjekk e-posten din på <0>{{email}}</0> og skriv inn den sekssifrede koden som vi har sendt deg.",gE="Velkommen",mE="Velkommen til din brukerkonto hos {{vendorName}} !",_E="Fortsett med denne kontoen",yE="Ja, fortsett med {{text}}",vE="Ja, fortsett med eksisterende konto",wE={"Server error: Invalid code":"Ugyldig kode","Wrong email or verification code":{"":"Feil e-post eller bekreftelseskode."},account_detected:pA,account_with_sso_provider:fA,agree_to:hA,and:gA,callback_url_mismatch:mA,callback_url_not_allowed:_A,check_email_title:yA,click_to_sign_up_description:vA,code_email_enter_code:wA,code_email_subject:bA,code_email_title:kA,code_valid_30_minutes:xA,confirm_password:SA,contact_support:AA,contact_us:EA,continue:"Fortsette",continue_social_login:IA,continue_with:zA,continue_with_sso_provider_headline:CA,copyright:NA,copyright_sesamy:jA,create_account_description:$A,create_account_email_invalid:OA,create_account_passwords_didnt_match:BA,create_account_title:TA,create_account_weak_password:PA,create_new_account_link:RA,create_password_account_title:LA,currently_logged_in_as:UA,email:VA,email_placeholder:MA,email_validated:qA,email_validated_cta:DA,email_verification_for_signup_sent_description:HA,email_verification_for_signup_sent_title:FA,enter_a_code_btn:KA,enter_email_for_verification_description:WA,enter_new_password_placeholder:GA,enter_password:JA,enter_password_description:ZA,enter_your_password_btn:YA,expired_code:XA,fokus_info_message:QA,forgot_password_cta:e4,forgot_password_description:t4,forgot_password_email_sent:n4,forgot_password_link:r4,forgot_password_title:i4,go_back:s4,"invalid-email":"Ugyldig epost",invalid_password:o4,invalid_session_body:a4,invalid_session_title:c4,link_email_click_to_login:l4,link_email_login:u4,link_email_or_enter_code:d4,link_page_body:p4,link_page_headline:f4,logged_in_as:h4,login:g4,login_description:m4,login_description_code:_4,login_description_link:y4,logout:v4,no_use_another:w4,or:b4,password:k4,password_has_been_reset:x4,password_has_been_reset_title:S4,password_reset_subject:A4,password_reset_title:E4,privacy_policy:I4,redirecting:z4,reenter_new_password_placeholder:C4,register_password_account:N4,resend_code:j4,reset_password_cta:$4,reset_password_description:O4,reset_password_email_click_to_reset:B4,reset_password_email_cta:T4,reset_password_email_reset:P4,reset_password_subject:R4,reset_password_title:L4,send:U4,send_me_a_new_magic_link:V4,sent_code_spam:M4,set_password:q4,sign_in:D4,signup:H4,signup_success:F4,spotify_already_linked_body:K4,spotify_already_linked_cta:W4,spotify_already_linked_step1_body:G4,spotify_already_linked_step1_title:J4,spotify_already_linked_step2_body:Z4,spotify_already_linked_step2_title:Y4,spotify_already_linked_title:X4,support_info:Q4,terms:eE,unverified_email:tE,user_account_does_not_exist:nE,user_not_found:rE,user_not_found_body:iE,user_not_found_cta:sE,validate_code:oE,validate_email_body:aE,validate_email_title:cE,verify_email_click_to_verify:lE,verify_email_subject:uE,verify_email_title:dE,verify_email_verify:pE,verify_your_email:fE,we_sent_a_code_to:hE,welcome:gE,welcome_to_your_account:mE,yes_continue:_E,yes_continue_with:yE,yes_continue_with_existing_account:vE},bE="Fortsätt med existerande konto",kE="Det verkar som att du redan har skapat ett konto genom",xE="Genom att logga in godkänner du våra",SE="och",AE="Callback URL mismatch",EE="The provided redirect_uri is not in the list of allowed callback URLs.",IE="fortsätt med användaren",zE="Klicka på knappen för att skapa ett nytt lösenordskonto.",CE="Skriv in koden på {{vendorName}} för att slutföra inloggningen",NE="Välkommen till {{vendorName}}! {{code}} är koden för att logga in",jE="Välkommen till {{vendorName}}! {{code}} är koden för att logga in",$E="Koden är giltig i 30 minuter",OE="Bekräfta lösenord",BE="Behöver du hjälp?",TE="Kontakta oss",PE="eller via sociala medier",RE="Fortsätt med {{provider}}",LE="Vill du fortsätta med det här kontot?",UE="Copyright © 2023 SESAMY. Alla rättigheter förbehållna.",VE="©2023 Sesamy",ME="Välj ett lösenord med en blandning av stora och små bokstäver, siffror och symboler.",qE="Ange en giltig e-postadress.",DE="Lösenorden stämde inte överens. Försök igen.",HE="Välj lösenord",FE="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.",KE="Skapa nytt konto",WE="Registrera dig med lösenord",GE="Du är inloggad som <0>{{email}}</0>",JE="E-postadress",ZE="E-postadress",YE="Din e-postadress har validerats",XE="Ange nu ditt lösenord för att logga in igen",QE="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.",eI="E-postverifiering skickad",tI="Logga in med kod",nI="Vi skickar dig en verifieringslänk för att säkerställa att du äger den här e-postadressen.",rI="Ange nytt lösenord",iI="Ange lösenord",sI="Ange din e-postadress och ditt lösenord för att logga in.",oI="Logga in med lösenord",aI="Länken är inte längre giltig. Klicka på knappen för att skicka en ny länk till din epost.",cI="Vi har bytt inloggningssystem, <0>här kan du läsa mer om vad det innebär</0>",lI="Skicka",uI="Klicka på knappen nedan så skickar vi instruktioner om hur du återställer ditt lösenord.",dI="Vi har skickat ett e-postmeddelande med instruktioner om hur du återställer ditt lösenord till den e-postadress du angav.",pI="Har du glömt lösenordet?",fI="Har du glömt lösenordet?",hI="Gå tillbaka",gI="Ogiltigt lösenord",mI=`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.`,
|
|
238
|
+
Du kan klicka på länken nedan för att starta en ny inloggning.`,_I="Ogiltig länk",yI="Klicka på knappen för att logga in",vI="Logga in",wI="Eller skriv in koden på {{vendorName}} för att slutföra inloggningen.",bI="Ange din epost för att låsa upp den här showen på {{service}}",kI="Koppla ditt konto till {{service}}",xI="Du är inloggad som",SI="Logga in",AI="Ange din e-postadress för att logga in.",EI="Ange din mejladress, så skickar vi en kod till dig som du kan logga in med.",II="Ange din mejladress, så skickar vi en länk till dig som du kan logga in med.",zI="Logga ut",CI="Nej, jag vill använda ett annat konto",NI="eller",jI="Lösenord",$I="Lösenordet har återställts",OI="Framgång",BI="Byt lösenord för ditt {{vendorName}} konto",TI="Byt lösenord för ditt {{vendorName}} konto",PI="Integritetspolicy",RI="Du skickas vidare",LI="Bekräfta lösenord",UI="Registrera ett nytt lösenord",VI="Skicka koden igen",MI="Ändra lösenord",qI="Ange ditt nya lösenord nedan för e-postkontot: ",DI="Klicka på knappen för att återställa ditt lösenord",HI="Klicka på knappen för att återställa ditt lösenord",FI="Återställ ditt lösenord",KI="Byt lösenord för ditt {{vendorName}} konto",WI="Återställ lösenord",GI="Skicka",JI="Skicka en ny inloggninglänk",ZI="Kom ihåg att kontrollera din skräppost om du inte kan hitta mailet vi har skickat.",YI="Välj lösenord",XI="Logga in",QI="Registrera dig",e3="Registrera dig framgångsrik",t3="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.",n3="Gå till Spotify's Content Access sida",r3=`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.`,i3="Steg 1: Avlänka ditt Spotify-konto",s3="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.",o3="Steg 2: Koppla ditt Spotify-konto till Sesamy igen",a3="Oj! Ditt Spotify-konto är redan kopplat",c3="Om du har frågor eller behöver hjälp kan du kontakta vårt supportteam",l3="Villkor",u3="Din e-postadress behöver valideras. Vi har skickat ett nytt e-postmeddelande till din inkorg",d3="Kontot existerar inte",p3="Kontot extisterar inte",f3="Vi kan inte hitta en användare med denna eposten. Vänligen försök igen.",h3="Försök igen.",g3="Validera kod",m3="Kontrollera din inkorg för instruktioner om validering av e-post.",_3="Registrerad",y3="Klicka på knappen för att verifiera din e-postadress",v3="Bekräfta din e-postadress",w3="Bekräfta din e-postadress",b3="Verifiera konto",k3="Ange engångskod",x3="Vänligen kontrollera din e-post för <0>{{email}}</0> och ange den sexsiffriga koden som vi har skickat till dig.",S3="Välkommen",A3="Välkommen till ditt {{vendorName}}-konto!",E3="Fortsätt med konto",I3="Ja, fortsätt med {{text}}",z3="Ja, fortsätt med detta kontot",C3={"Server error: Invalid code":"Koden är inte giltig","Wrong email or verification code":{"":"Fel e-post eller verifieringskod."},account_detected:bE,account_with_sso_provider:kE,agree_to:xE,and:SE,callback_url_mismatch:AE,callback_url_not_allowed:EE,check_email_title:IE,click_to_sign_up_description:zE,code_email_enter_code:CE,code_email_subject:NE,code_email_title:jE,code_valid_30_minutes:$E,confirm_password:OE,contact_support:BE,contact_us:TE,continue:"Fortsätt",continue_social_login:PE,continue_with:RE,continue_with_sso_provider_headline:LE,copyright:UE,copyright_sesamy:VE,create_account_description:ME,create_account_email_invalid:qE,create_account_passwords_didnt_match:DE,create_account_title:HE,create_account_weak_password:FE,create_new_account_link:KE,create_password_account_title:WE,currently_logged_in_as:GE,email:JE,email_placeholder:ZE,email_validated:YE,email_validated_cta:XE,email_verification_for_signup_sent_description:QE,email_verification_for_signup_sent_title:eI,enter_a_code_btn:tI,enter_email_for_verification_description:nI,enter_new_password_placeholder:rI,enter_password:iI,enter_password_description:sI,enter_your_password_btn:oI,expired_code:aI,fokus_info_message:cI,forgot_password_cta:lI,forgot_password_description:uI,forgot_password_email_sent:dI,forgot_password_link:pI,forgot_password_title:fI,go_back:hI,"invalid-email":"Ogiltig e-postadress",invalid_password:gI,invalid_session_body:mI,invalid_session_title:_I,link_email_click_to_login:yI,link_email_login:vI,link_email_or_enter_code:wI,link_page_body:bI,link_page_headline:kI,logged_in_as:xI,login:SI,login_description:AI,login_description_code:EI,login_description_link:II,logout:zI,no_use_another:CI,or:NI,password:jI,password_has_been_reset:$I,password_has_been_reset_title:OI,password_reset_subject:BI,password_reset_title:TI,privacy_policy:PI,redirecting:RI,reenter_new_password_placeholder:LI,register_password_account:UI,resend_code:VI,reset_password_cta:MI,reset_password_description:qI,reset_password_email_click_to_reset:DI,reset_password_email_cta:HI,reset_password_email_reset:FI,reset_password_subject:KI,reset_password_title:WI,send:GI,send_me_a_new_magic_link:JI,sent_code_spam:ZI,set_password:YI,sign_in:XI,signup:QI,signup_success:e3,spotify_already_linked_body:t3,spotify_already_linked_cta:n3,spotify_already_linked_step1_body:r3,spotify_already_linked_step1_title:i3,spotify_already_linked_step2_body:s3,spotify_already_linked_step2_title:o3,spotify_already_linked_title:a3,support_info:c3,terms:l3,unverified_email:u3,user_account_does_not_exist:d3,user_not_found:p3,user_not_found_body:f3,user_not_found_cta:h3,validate_code:g3,validate_email_body:m3,validate_email_title:_3,verify_email_click_to_verify:y3,verify_email_subject:v3,verify_email_title:w3,verify_email_verify:b3,verify_your_email:k3,we_sent_a_code_to:x3,welcome:S3,welcome_to_your_account:A3,yes_continue:E3,yes_continue_with:I3,yes_continue_with_existing_account:z3},N3="Wykryto konto",j3="Wykryliśmy, że użytkownik utworzył już konto za pośrednictwem",$3="Logując się, wyrażasz zgodę na nasze",O3="i",B3="Niezgodność adresu URL wywołania zwrotnego",T3="Podany adres redirect_uri nie znajduje się na liście dozwolonych adresów URL wywołania zwrotnego.",P3="kontynuować z użytkownikiem",R3="Kliknij przycisk, aby utworzyć nowe konto z hasłem.",L3="Wpisz kod na stronie {{vendorName}}, aby się zalogować.",U3="Witamy na {{vendorName}}! {{code}} to kod logowania do Twojego konta.",V3="Witamy na {{vendorName}}! {{code}} to kod logowania.",M3="Kod jest ważny przez 30 minut",q3="Potwierdź hasło",D3="Potrzebujesz pomocy?",H3="Skontaktuj się z nami",F3="lub kontynuować korzystanie z konta społecznościowego",K3="Kontynuuj {{provider}}",W3="Czy chcesz kontynuować korzystanie z istniejącego konta?",G3="Copyright © 2023 SESAMY. Wszelkie prawa zastrzeżone.",J3="©2023 Sesamy",Z3="Wybierz hasło składające się z małych i wielkich liter, cyfr i symboli.",Y3="Wprowadź prawidłowy adres e-mail.",X3="Hasła nie są zgodne. Spróbuj ponownie.",Q3="Wybierz hasło",e6="Hasło musi mieć co najmniej 8 znaków i zawierać co najmniej jedną małą literę, jedną wielką literę, jedną cyfrę i jeden symbol.",t6="Utwórz nowe konto",n6="Zarejestruj się przy użyciu hasła",r6="Jesteś obecnie zalogowany jako <0>{{email}}</0>",i6="E-mail",s6="Adres e-mail",o6="Twój adres e-mail został zweryfikowany",a6="Teraz wprowadź hasło, aby zalogować się ponownie",c6="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.",l6="Wysłano weryfikację e-mail",u6="Wprowadź kod",d6="Wyślemy Ci link weryfikacyjny, aby upewnić się, że posiadasz ten adres e-mail.",p6="Wprowadź nowe hasło",f6="Wprowadź hasło",h6="Wprowadź swój adres e-mail i hasło, aby się zalogować.",g6="Wprowadź hasło",m6="Magiczny link wygasł. Kliknij poniższy przycisk, aby otrzymać nowy link w skrzynce odbiorczej.",_6="Zaktualizowaliśmy sposób logowania. <0>Kliknij tutaj, aby dowiedzieć się więcej.</0>",y6="Wyślij wiadomość e-mail z resetem hasła",v6="Kliknij poniższy przycisk, a my wyślemy Ci instrukcje, jak zresetować hasło.",w6="Wysłano wiadomość e-mail z resetem hasła",b6="Zapomniałeś hasła?",k6="Zapomniałeś hasła?",x6="Wróć",S6="Nieprawidłowe hasło",A6=`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.`,
|
|
242
|
+
Możesz kliknąć poniższy link, aby rozpocząć nowe logowanie.`,E6="Nieprawidłowy link",I6="Kliknij przycisk, aby się zalogować",z6="Zaloguj się",C6="Lub wprowadź kod na stronie {{vendorName}}, aby dokończyć logowanie.",N6="Wprowadź swój adres e-mail, aby odblokować ten program na {{service}}",j6="Połącz swoje konto z {{service}}",$6="Jesteś zalogowany jako",O6="Logowanie",B6="Wprowadź swój adres e-mail, aby się zalogować.",T6="Wprowadź swój adres e-mail, a my wyślemy Ci kod logowania.",P6="Wprowadź swój adres e-mail, a my wyślemy Ci link do logowania.",R6="Wylogowanie",L6="Nie, chcę użyć innego konta",U6="lub",V6="Hasło",M6="Hasło zostało zresetowane",q6="Sukces",D6="Zmień hasło do konta {{vendorName}} ",H6="Zmiana hasła do konta {{vendorName}} ",F6="Polityka prywatności",K6="Przekierowanie",W6="Potwierdź hasło",G6="Zarejestruj nowe hasło",J6="Wyślij ponownie kod",Z6="Zmiana hasła",Y6="Wprowadź poniżej nowe hasło do konta e-mail: ",X6="Kliknij przycisk, aby zresetować hasło",Q6="Kliknij przycisk, aby zresetować hasło",ez="Zmień hasło",tz="Zmiana hasła do konta {{vendorName}} ",nz="Resetowanie hasła",rz="Wyślij",iz="Wyślij mi nowy magiczny link",sz="Pamiętaj, aby sprawdzić folder spamu, jeśli wiadomość e-mail nie dotarła.",oz="Ustaw hasło",az="Zaloguj się",cz="Rejestracja",lz="Rejestracja zakończona sukcesem",uz="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ć.",dz="Przejdź do strony dostępu do treści Spotify",pz='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.',fz="Krok 1: Odłącz swoje konto Spotify",hz="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.",gz="Krok 2: Połącz ponownie swoje konto Spotify z Sesamy",mz="Ups! Twoje konto Spotify jest już połączone",_z="Jeśli masz pytania lub potrzebujesz pomocy, skontaktuj się z nami",yz="Zasady i warunki",vz="Twój adres e-mail wymaga weryfikacji. Wysłaliśmy nową wiadomość e-mail na Twoją skrzynkę odbiorczą",wz="Konto użytkownika nie istnieje",bz="Konto użytkownika nie istnieje",kz="Nie mogliśmy znaleźć użytkownika o podanym adresie e-mail. Spróbuj ponownie.",xz="Spróbuj ponownie.",Sz="Sprawdź poprawność kodu",Az="Sprawdź swoją skrzynkę odbiorczą, aby uzyskać instrukcje dotyczące weryfikacji wiadomości e-mail.",Ez="Zarejestrowany",Iz="Kliknij przycisk, aby zweryfikować swój adres e-mail",zz="Potwierdź swój adres e-mail",Cz="Potwierdź swój adres e-mail",Nz="Zweryfikuj konto",jz="Zweryfikuj swój adres e-mail",$z="Sprawdź swoją skrzynkę e-mail pod adresem <0>{{email}}</0> i wprowadź sześciocyfrowy kod, który wysłaliśmy.",Oz="Witamy",Bz="Witamy na koncie {{vendorName}}!",Tz="Kontynuuj korzystanie z tego konta",Pz="Tak, kontynuuj {{text}}",Rz="Tak, kontynuuj korzystanie z istniejącego konta",Lz={"Server error: Invalid code":"Nieprawidłowy kod","Wrong email or verification code":{"":"Nieprawidłowy adres e-mail lub kod weryfikacyjny."},account_detected:N3,account_with_sso_provider:j3,agree_to:$3,and:O3,callback_url_mismatch:B3,callback_url_not_allowed:T3,check_email_title:P3,click_to_sign_up_description:R3,code_email_enter_code:L3,code_email_subject:U3,code_email_title:V3,code_valid_30_minutes:M3,confirm_password:q3,contact_support:D3,contact_us:H3,continue:"Kontynuuj",continue_social_login:F3,continue_with:K3,continue_with_sso_provider_headline:W3,copyright:G3,copyright_sesamy:J3,create_account_description:Z3,create_account_email_invalid:Y3,create_account_passwords_didnt_match:X3,create_account_title:Q3,create_account_weak_password:e6,create_new_account_link:t6,create_password_account_title:n6,currently_logged_in_as:r6,email:i6,email_placeholder:s6,email_validated:o6,email_validated_cta:a6,email_verification_for_signup_sent_description:c6,email_verification_for_signup_sent_title:l6,enter_a_code_btn:u6,enter_email_for_verification_description:d6,enter_new_password_placeholder:p6,enter_password:f6,enter_password_description:h6,enter_your_password_btn:g6,expired_code:m6,fokus_info_message:_6,forgot_password_cta:y6,forgot_password_description:v6,forgot_password_email_sent:w6,forgot_password_link:b6,forgot_password_title:k6,go_back:x6,"invalid-email":"Nieprawidłowy adres e-mail",invalid_password:S6,invalid_session_body:A6,invalid_session_title:E6,link_email_click_to_login:I6,link_email_login:z6,link_email_or_enter_code:C6,link_page_body:N6,link_page_headline:j6,logged_in_as:$6,login:O6,login_description:B6,login_description_code:T6,login_description_link:P6,logout:R6,no_use_another:L6,or:U6,password:V6,password_has_been_reset:M6,password_has_been_reset_title:q6,password_reset_subject:D6,password_reset_title:H6,privacy_policy:F6,redirecting:K6,reenter_new_password_placeholder:W6,register_password_account:G6,resend_code:J6,reset_password_cta:Z6,reset_password_description:Y6,reset_password_email_click_to_reset:X6,reset_password_email_cta:Q6,reset_password_email_reset:ez,reset_password_subject:tz,reset_password_title:nz,send:rz,send_me_a_new_magic_link:iz,sent_code_spam:sz,set_password:oz,sign_in:az,signup:cz,signup_success:lz,spotify_already_linked_body:uz,spotify_already_linked_cta:dz,spotify_already_linked_step1_body:pz,spotify_already_linked_step1_title:fz,spotify_already_linked_step2_body:hz,spotify_already_linked_step2_title:gz,spotify_already_linked_title:mz,support_info:_z,terms:yz,unverified_email:vz,user_account_does_not_exist:wz,user_not_found:bz,user_not_found_body:kz,user_not_found_cta:xz,validate_code:Sz,validate_email_body:Az,validate_email_title:Ez,verify_email_click_to_verify:Iz,verify_email_subject:zz,verify_email_title:Cz,verify_email_verify:Nz,verify_your_email:jz,we_sent_a_code_to:$z,welcome:Oz,welcome_to_your_account:Bz,yes_continue:Tz,yes_continue_with:Pz,yes_continue_with_existing_account:Rz},Uz="Zjištěný účet",Vz="Zjistili jsme, že jste si již vytvořili účet prostřednictvím",Mz="Přihlášením souhlasíte s našimi",qz="a",Dz="Neshoda adresy URL zpětného volání",Hz="Zadané redirect_uri není v seznamu povolených zpětných adres URL.",Fz="pokračovat s uživatelem",Kz="Klikněte na tlačítko pro vytvoření nového účtu s heslem.",Wz="Pro dokončení přihlášení zadejte kód na adrese {{vendorName}}.",Gz="Vítejte na {{vendorName}}! {{code}} je přihlašovací kód.",Jz="Vítejte na {{vendorName}}! {{code}} je přihlašovací kód.",Zz="Kód je platný po dobu 30 minut",Yz="Potvrzení hesla",Xz="Potřebujete pomoc?",Qz="Kontaktujte nás",eC="nebo pokračovat v sociálním účtu",tC="Pokračovat s {{provider}}",nC="Chcete pokračovat ve svém stávajícím účtu?",rC="Copyright © 2023 SESAMY. Všechna práva vyhrazena.",iC="©2023 Sesamy",sC="Zvolte heslo složené z velkých a malých písmen, číslic a symbolů.",oC="Zadejte prosím platnou e-mailovou adresu.",aC="Hesla se neshodovala. Zkuste to znovu.",cC="Zvolte heslo",lC="Heslo musí mít alespoň 8 znaků a obsahovat alespoň jedno malé písmeno, jedno velké písmeno, jednu číslici a jeden symbol.",uC="Vytvořit nový účet",dC="Zaregistrujte se pomocí hesla",pC="V současné době jste přihlášeni jako <0>{{email}}</0>",fC="E-mail",hC="E-mailová adresa",gC="Vaše e-mailová adresa byla ověřena",mC="Nyní zadejte své heslo a znovu se přihlaste",_C="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.",yC="Ověření e-mailem odesláno",vC="Zadejte kód",wC="Pošleme vám ověřovací odkaz, abychom se ujistili, že tuto e-mailovou adresu vlastníte.",bC="Zadejte nové heslo",kC="Zadejte heslo",xC="Pro přihlášení zadejte svou e-mailovou adresu a heslo.",SC="Zadejte své heslo",AC="Platnost kouzelného odkazu vypršela. Klikněte na tlačítko níže, abyste obdrželi nový odkaz do své e-mailové schránky.",EC="Ahoj! Aktualizovali jsme naše přihlašovací prostředí. <0>Klikněte sem a dozvíte se o něm více.</0>",IC="Odeslání e-mailu pro obnovení hesla",zC="Klikněte na tlačítko níže a my vám zašleme pokyny k obnovení hesla.",CC="Odeslání e-mailu s žádostí o obnovení hesla",NC="Zapomněli jste heslo?",jC="Zapomněli jste heslo?",$C="Vrátit se zpět",OC="Neplatné heslo",BC=`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í.`,
|
|
246
|
+
Kliknutím na odkaz níže můžete zahájit nové přihlášení.`,TC="Neplatný odkaz",PC="Kliknutím na tlačítko se přihlásíte",RC="Přihlášení",LC="Nebo zadejte kód na adrese {{vendorName}} a dokončete přihlášení.",UC="Zadejte svou e-mailovou adresu pro odemknutí tohoto pořadu na {{service}}",VC="Propojte svůj účet s {{service}}",MC="Jste přihlášeni jako",qC="Přihlášení",DC="Pro přihlášení zadejte svou e-mailovou adresu.",HC="Zadejte svou e-mailovou adresu a my vám zašleme přihlašovací kód.",FC="Zadejte svou e-mailovou adresu a my vám zašleme odkaz pro přihlášení.",KC="Odhlášení",WC="Ne, chci použít jiný účet",GC="nebo",JC="Heslo",ZC="Heslo bylo resetováno",YC="Úspěch",XC="Změna hesla k účtu {{vendorName}} ",QC="Změna hesla k účtu {{vendorName}} ",eN="Zásady ochrany osobních údajů",tN="Přesměrování",nN="Potvrzení hesla",rN="Registrace nového hesla",iN="Opětovné odeslání kódu",sN="Změna hesla",oN="Níže zadejte nové heslo k e-mailovému účtu: ",aN="Kliknutím na tlačítko obnovíte své heslo",cN="Kliknutím na tlačítko obnovíte své heslo",lN="Obnovení hesla",uN="Změna hesla k účtu {{vendorName}} ",dN="Obnovení hesla",pN="Odeslat",fN="Pošlete mi nový kouzelný odkaz",hN="Pokud e-mail nedorazil, nezapomeňte zkontrolovat složku nevyžádané pošty.",gN="Nastavení hesla",mN="Přihlásit se",_N="Registrace",yN="Úspěšná registrace",vN="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.",wN="Přejděte na stránku Spotify pro přístup k obsahu",bN='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.',kN="Krok 1: Odpojení účtu Spotify",xN="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.",SN="Krok 2: Propojení účtu Spotify s aplikací Sesamy",AN="Ups! Váš účet Spotify je již propojen",EN="Pokud máte dotazy nebo potřebujete pomoc, můžete se obrátit na náš tým podpory.",IN="Podmínky a pravidla",zN="Vaši e-mailovou adresu je třeba ověřit. Do vaší e-mailové schránky jsme odeslali nový e-mail.",CN="Uživatelský účet neexistuje",NN="Uživatelský účet neexistuje",jN="Nepodařilo se nám najít uživatele se zadanou e-mailovou adresou. Zkuste to prosím znovu.",$N="Zkuste to znovu.",ON="Ověření kódu",BN="Pokyny k ověření e-mailu najdete ve své e-mailové schránce.",TN="Zaregistrovali jste se",PN="Klikněte na tlačítko pro ověření e-mailové adresy",RN="Ověřte svou e-mailovou adresu",LN="Ověřte svou e-mailovou adresu",UN="Ověření účtu",VN="Ověření e-mailu",MN="Zkontrolujte si prosím svůj e-mail na adrese <0>{{email}}</0> a zadejte šestimístný kód, který jsme vám zaslali.",qN="Vítejte na",DN="Vítejte na svém účtu {{vendorName}}!",HN="Pokračujte s tímto účtem",FN="Ano, pokračujte {{text}}",KN="Ano, pokračujte ve stávajícím účtu",WN={"Server error: Invalid code":"Neplatný kód","Wrong email or verification code":{"":"Špatný e-mail nebo ověřovací kód."},account_detected:Uz,account_with_sso_provider:Vz,agree_to:Mz,and:qz,callback_url_mismatch:Dz,callback_url_not_allowed:Hz,check_email_title:Fz,click_to_sign_up_description:Kz,code_email_enter_code:Wz,code_email_subject:Gz,code_email_title:Jz,code_valid_30_minutes:Zz,confirm_password:Yz,contact_support:Xz,contact_us:Qz,continue:"Pokračovat",continue_social_login:eC,continue_with:tC,continue_with_sso_provider_headline:nC,copyright:rC,copyright_sesamy:iC,create_account_description:sC,create_account_email_invalid:oC,create_account_passwords_didnt_match:aC,create_account_title:cC,create_account_weak_password:lC,create_new_account_link:uC,create_password_account_title:dC,currently_logged_in_as:pC,email:fC,email_placeholder:hC,email_validated:gC,email_validated_cta:mC,email_verification_for_signup_sent_description:_C,email_verification_for_signup_sent_title:yC,enter_a_code_btn:vC,enter_email_for_verification_description:wC,enter_new_password_placeholder:bC,enter_password:kC,enter_password_description:xC,enter_your_password_btn:SC,expired_code:AC,fokus_info_message:EC,forgot_password_cta:IC,forgot_password_description:zC,forgot_password_email_sent:CC,forgot_password_link:NC,forgot_password_title:jC,go_back:$C,"invalid-email":"Neplatný e-mail",invalid_password:OC,invalid_session_body:BC,invalid_session_title:TC,link_email_click_to_login:PC,link_email_login:RC,link_email_or_enter_code:LC,link_page_body:UC,link_page_headline:VC,logged_in_as:MC,login:qC,login_description:DC,login_description_code:HC,login_description_link:FC,logout:KC,no_use_another:WC,or:GC,password:JC,password_has_been_reset:ZC,password_has_been_reset_title:YC,password_reset_subject:XC,password_reset_title:QC,privacy_policy:eN,redirecting:tN,reenter_new_password_placeholder:nN,register_password_account:rN,resend_code:iN,reset_password_cta:sN,reset_password_description:oN,reset_password_email_click_to_reset:aN,reset_password_email_cta:cN,reset_password_email_reset:lN,reset_password_subject:uN,reset_password_title:dN,send:pN,send_me_a_new_magic_link:fN,sent_code_spam:hN,set_password:gN,sign_in:mN,signup:_N,signup_success:yN,spotify_already_linked_body:vN,spotify_already_linked_cta:wN,spotify_already_linked_step1_body:bN,spotify_already_linked_step1_title:kN,spotify_already_linked_step2_body:xN,spotify_already_linked_step2_title:SN,spotify_already_linked_title:AN,support_info:EN,terms:IN,unverified_email:zN,user_account_does_not_exist:CN,user_not_found:NN,user_not_found_body:jN,user_not_found_cta:$N,validate_code:ON,validate_email_body:BN,validate_email_title:TN,verify_email_click_to_verify:PN,verify_email_subject:RN,verify_email_title:LN,verify_email_verify:UN,verify_your_email:VN,we_sent_a_code_to:MN,welcome:qN,welcome_to_your_account:DN,yes_continue:HN,yes_continue_with:FN,yes_continue_with_existing_account:KN},GN="Tili havaittu",JN="Olemme havainneet, että olet jo luonut tilin kautta",ZN="Kirjautumalla sisään hyväksyt",YN="ja",XN="Takaisinkutsun URL-osoite ei vastaa toisiaan",QN="Annettu redirect_uri ei ole sallittujen takaisinsoitto-URL-osoitteiden luettelossa.",ej="jatka käyttäjän kanssa",tj="Klikkaa painiketta luodaksesi uuden salasanatilin.",nj="Kirjoita koodi osoitteessa {{vendorName}} kirjautumisen loppuun saattamiseksi.",rj="Tervetuloa osoitteeseen {{vendorName}}! {{code}} on kirjautumiskoodi.",ij="Tervetuloa osoitteeseen {{vendorName}}! {{code}} on kirjautumiskoodi.",sj="Koodi on voimassa 30 minuuttia",oj="Vahvista salasana",aj="Tarvitsetko apua?",cj="Ota yhteyttä",lj="tai jatka sosiaalisella tilillä",uj="Jatka {{provider}}",dj="Haluatko jatkaa olemassa olevalla tililläsi?",pj="Copyright © 2023 SESAMY. Kaikki oikeudet pidätetään.",fj="©2023 Sesamy",hj="Valitse salasana, jossa on isoja ja pieniä kirjaimia, numeroita ja symboleja.",gj="Kirjoita voimassa oleva sähköpostiosoite.",mj="Salasanat eivät vastanneet toisiaan. Yritä uudelleen.",_j="Valitse salasana",yj="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.",vj="Luo uusi tili",wj="Rekisteröidy salasanalla",bj="Olet tällä hetkellä kirjautuneena sisään nimellä <0>{{email}}</0>",kj="Sähköposti",xj="Sähköpostiosoite",Sj="Sähköpostiosoitteesi on vahvistettu",Aj="Kirjoita nyt salasanasi kirjautuaksesi uudelleen",Ej="Sähköposti on lähetetty osoitteeseen <0>{{email}}</0> jossa on vahvistuslinkki. Klikkaa linkkiä vahvistaaksesi sähköpostiosoitteesi ja asettaaksesi salasanan.",Ij="Sähköpostivarmennus lähetetty",zj="Syötä koodi",Cj="Lähetämme sinulle vahvistuslinkin varmistaaksemme, että omistat tämän sähköpostiosoitteen.",Nj="Anna uusi salasana",jj="Anna salasana",$j="Anna sähköpostiosoitteesi ja salasanasi kirjautuaksesi sisään.",Oj="Syötä salasanasi",Bj="Taikalinkki on vanhentunut. Klikkaa alla olevaa painiketta saadaksesi uuden linkin sähköpostiisi.",Tj="Hei! Päivitimme kirjautumiskokemuksemme. <0>Klikkaa tästä saadaksesi lisätietoja siitä.</0>",Pj="Lähetä salasanan palautussähköposti",Rj="Napsauta alla olevaa painiketta, niin lähetämme ohjeet salasanasi palauttamiseen.",Lj="Salasanan palautussähköposti lähetetty",Uj="Unohditko salasanan?",Vj="Unohditko salasanan?",Mj="Palaa takaisin",qj="Virheellinen salasana",Dj=`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ä.`,
|
|
250
|
+
Voit aloittaa uuden kirjautumisen klikkaamalla alla olevaa linkkiä.`,Hj="Virheellinen linkki",Fj="Kirjaudu sisään napsauttamalla painiketta",Kj="Kirjaudu sisään",Wj="Tai kirjoita koodi osoitteessa {{vendorName}} kirjautumisen loppuun saattamiseksi.",Gj="Kirjoita sähköpostiosoitteesi avataksesi tämän ohjelman osoitteessa {{service}}",Jj="Yhdistä tilisi {{service}}",Zj="Olet kirjautunut sisään nimellä",Yj="Kirjaudu sisään",Xj="Kirjoita sähköpostiosoitteesi kirjautuaksesi sisään.",Qj="Anna sähköpostiosoitteesi, niin lähetämme sinulle kirjautumiskoodin.",e$="Anna sähköpostiosoitteesi, niin lähetämme sinulle kirjautumislinkin.",t$="Kirjaudu ulos",n$="Ei, haluan käyttää toista tiliä",r$="tai",i$="Salasana",s$="Salasana on nollattu",o$="Menestys",a$="Vaihda salasana tilillesi {{vendorName}} ",c$="Vaihda salasana tilillesi {{vendorName}} ",l$="Tietosuojakäytäntö",u$="Uudelleenohjaus",d$="Vahvista salasana",p$="Rekisteröi uusi salasana",f$="Lähetä koodi uudelleen",h$="Vaihda salasana",g$="Kirjoita alla oleva uusi salasanasi sähköpostitiliä varten: ",m$="Napsauta painiketta salasanasi palauttamiseksi",_$="Napsauta painiketta salasanasi palauttamiseksi",y$="Nollaa salasanasi",v$="Vaihda salasana tilillesi {{vendorName}} ",w$="Nollaa salasana",b$="Lähetä",k$="Lähetä minulle uusi maaginen linkki",x$="Muista tarkistaa roskapostikansiosi, jos sähköposti ei ole saapunut.",S$="Aseta salasana",A$="Kirjaudu sisään",E$="Rekisteröityminen",I$="Rekisteröidy onnistuneesti",z$="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.",C$="Siirry Spotifyn Content Access -sivulle",N$='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ä.',j$="Vaihe 1: Poista Spotify-tilisi linkitys",$$="Kun olet onnistuneesti irrottanut Spotify-tilisi, voit yhdistää sen uudelleen Sesamyn kanssa. Toista vain aiemmin tekemäsi vaiheet, jotka johtivat sinut tälle sivulle.",O$="Vaihe 2: Yhdistä Spotify-tilisi uudelleen Sesamyn kanssa",B$="Hups! Spotify-tilisi on jo linkitetty",T$="Jos sinulla on kysyttävää tai tarvitset apua, voit ottaa yhteyttä tukitiimiimme.",P$="Ehdot ja edellytykset",R$="Sähköpostiosoitteesi on vahvistettava. Olemme lähettäneet uuden sähköpostiviestin sähköpostiisi.",L$="Käyttäjätiliä ei ole olemassa",U$="Käyttäjätiliä ei ole olemassa",V$="Emme löytäneet käyttäjää, jolla on annettu sähköpostiosoite. Yritä uudelleen.",M$="Yritä uudelleen.",q$="Validoi koodi",D$="Tarkista sähköpostin vahvistusohjeet postilaatikostasi.",H$="Rekisteröitynyt",F$="Vahvista sähköpostiosoitteesi napsauttamalla painiketta",K$="Vahvista sähköpostiosoitteesi",W$="Vahvista sähköpostiosoitteesi",G$="Vahvista tili",J$="Vahvista sähköpostiosoitteesi",Z$="Tarkista sähköpostisi osoitteesta <0>{{email}}</0> ja syötä lähettämämme kuusinumeroinen koodi.",Y$="Tervetuloa",X$="Tervetuloa tilillesi {{vendorName}}!",Q$="Jatka tällä tilillä",e8="Kyllä, jatka {{text}}",t8="Kyllä, jatka olemassa olevalla tilillä",n8={"Server error: Invalid code":"Virheellinen koodi","Wrong email or verification code":{"":"Väärä sähköpostiosoite tai vahvistuskoodi."},account_detected:GN,account_with_sso_provider:JN,agree_to:ZN,and:YN,callback_url_mismatch:XN,callback_url_not_allowed:QN,check_email_title:ej,click_to_sign_up_description:tj,code_email_enter_code:nj,code_email_subject:rj,code_email_title:ij,code_valid_30_minutes:sj,confirm_password:oj,contact_support:aj,contact_us:cj,continue:"Jatka",continue_social_login:lj,continue_with:uj,continue_with_sso_provider_headline:dj,copyright:pj,copyright_sesamy:fj,create_account_description:hj,create_account_email_invalid:gj,create_account_passwords_didnt_match:mj,create_account_title:_j,create_account_weak_password:yj,create_new_account_link:vj,create_password_account_title:wj,currently_logged_in_as:bj,email:kj,email_placeholder:xj,email_validated:Sj,email_validated_cta:Aj,email_verification_for_signup_sent_description:Ej,email_verification_for_signup_sent_title:Ij,enter_a_code_btn:zj,enter_email_for_verification_description:Cj,enter_new_password_placeholder:Nj,enter_password:jj,enter_password_description:$j,enter_your_password_btn:Oj,expired_code:Bj,fokus_info_message:Tj,forgot_password_cta:Pj,forgot_password_description:Rj,forgot_password_email_sent:Lj,forgot_password_link:Uj,forgot_password_title:Vj,go_back:Mj,"invalid-email":"Virheellinen sähköpostiosoite",invalid_password:qj,invalid_session_body:Dj,invalid_session_title:Hj,link_email_click_to_login:Fj,link_email_login:Kj,link_email_or_enter_code:Wj,link_page_body:Gj,link_page_headline:Jj,logged_in_as:Zj,login:Yj,login_description:Xj,login_description_code:Qj,login_description_link:e$,logout:t$,no_use_another:n$,or:r$,password:i$,password_has_been_reset:s$,password_has_been_reset_title:o$,password_reset_subject:a$,password_reset_title:c$,privacy_policy:l$,redirecting:u$,reenter_new_password_placeholder:d$,register_password_account:p$,resend_code:f$,reset_password_cta:h$,reset_password_description:g$,reset_password_email_click_to_reset:m$,reset_password_email_cta:_$,reset_password_email_reset:y$,reset_password_subject:v$,reset_password_title:w$,send:b$,send_me_a_new_magic_link:k$,sent_code_spam:x$,set_password:S$,sign_in:A$,signup:E$,signup_success:I$,spotify_already_linked_body:z$,spotify_already_linked_cta:C$,spotify_already_linked_step1_body:N$,spotify_already_linked_step1_title:j$,spotify_already_linked_step2_body:$$,spotify_already_linked_step2_title:O$,spotify_already_linked_title:B$,support_info:T$,terms:P$,unverified_email:R$,user_account_does_not_exist:L$,user_not_found:U$,user_not_found_body:V$,user_not_found_cta:M$,validate_code:q$,validate_email_body:D$,validate_email_title:H$,verify_email_click_to_verify:F$,verify_email_subject:K$,verify_email_title:W$,verify_email_verify:G$,verify_your_email:J$,we_sent_a_code_to:Z$,welcome:Y$,welcome_to_your_account:X$,yes_continue:Q$,yes_continue_with:e8,yes_continue_with_existing_account:t8};U.init({supportedLngs:["en","it","nb","sv","pl","cs","fi"],fallbackLng:"en",resources:{en:{translation:nS},it:{translation:dA},nb:{translation:wE},sv:{translation:C3},pl:{translation:Lz},cs:{translation:WN},fi:{translation:n8}}});function r8(t){const e=new a.OpenAPIHono;e.use(async(s,o)=>(s.env.data=Pf(s,t.dataAdapter),o())),e.get("/",s=>s.json({name:"authhero"}));const n=Aw();e.route("/api/v2",n);const r=Ob();e.route("/",r);const i=W1();return e.route("/u",i),{app:e,managementApp:n,oauthApp:r,universalApp:i,createX509Certificate:Gc}}exports.Auth0Client=uf;exports.AuthorizationResponseMode=Zt;exports.AuthorizationResponseType=Jt;exports.CodeChallengeMethod=Js;exports.GrantType=jr;exports.LogTypes=me;exports.applicationInsertSchema=ts;exports.applicationSchema=pn;exports.auth0UserResponseSchema=bt;exports.authParamsSchema=el;exports.baseUserSchema=Gs;exports.bordersSchema=gf;exports.brandingSchema=Sa;exports.codeInsertSchema=af;exports.codeSchema=Km;exports.codeTypeSchema=of;exports.colorsSchema=mf;exports.connectionInsertSchema=ns;exports.connectionSchema=Dt;exports.customDomainInsertSchema=tl;exports.customDomainSchema=Mn;exports.emailProviderSchema=Li;exports.fontDetailsSchema=un;exports.fontsSchema=_f;exports.hookInsertSchema=is;exports.hookSchema=qn;exports.identitySchema=nf;exports.init=r8;exports.jwksKeySchema=cf;exports.jwksSchema=nl;exports.logSchema=ss;exports.loginInsertSchema=lf;exports.loginSchema=Wm;exports.openIDConfigurationSchema=Aa;exports.pageBackgroundSchema=yf;exports.parseUserId=Xm;exports.passwordInsertSchema=df;exports.passwordSchema=Jm;exports.profileDataSchema=tf;exports.promptSettingSchema=Ri;exports.refreshTokenInsertSchema=rl;exports.refreshTokenSchema=Ym;exports.samlpAddon=rf;exports.sessionInsertSchema=ff;exports.sessionSchema=Zs;exports.signingKeySchema=Ea;exports.tenantInsertSchema=rs;exports.tenantSchema=Hn;exports.themeInsertSchema=wf;exports.themeSchema=Zm;exports.tokenResponseSchema=hf;exports.totalsSchema=nn;exports.userInsertSchema=es;exports.userResponseSchema=Dm;exports.userSchema=Qc;exports.vendorSettingsSchema=sf;exports.widgetSchema=vf;
|