authhero 0.125.0 → 0.128.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/authhero.cjs CHANGED
@@ -1,14 +1,14 @@
1
- "use strict";var t1=Object.defineProperty;var n1=(t,e,n)=>e in t?t1(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var te=(t,e,n)=>n1(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",jr=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},cu=t=>t==null?"":""+t,r1=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},i1=/###/g,du=t=>t&&t.indexOf("###")>-1?t.replace(i1,"."):t,lu=t=>!t||ne(t),Fr=(t,e,n)=>{const r=ne(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(lu(t))return{};const s=du(r[i]);!t[s]&&n&&(t[s]=new n),Object.prototype.hasOwnProperty.call(t,s)?t=t[s]:t={},++i}return lu(t)?{}:{obj:t,k:du(r[i])}},uu=(t,e,n)=>{const{obj:r,k:i}=Fr(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=Fr(t,o,Object);for(;c.obj===void 0&&o.length;)s=`${o[o.length-1]}.${s}`,o=o.slice(0,o.length-1),c=Fr(t,o,Object),c!=null&&c.obj&&typeof c.obj[`${c.k}.${s}`]<"u"&&(c.obj=void 0);c.obj[`${c.k}.${s}`]=n},s1=(t,e,n,r)=>{const{obj:i,k:s}=Fr(t,e,Object);i[s]=i[s]||[],i[s].push(n)},ls=(t,e)=>{const{obj:n,k:r}=Fr(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},o1=(t,e,n)=>{const r=ls(t,n);return r!==void 0?r:ls(e,n)},a0=(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]):a0(t[r],e[r],n):t[r]=e[r]);return t},Hn=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var a1={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const c1=t=>ne(t)?t.replace(/[&<>"'\/]/g,e=>a1[e]):t;class d1{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 l1=[" ",",","?","!",";"],u1=new d1(20),f1=(t,e,n)=>{e=e||"",n=n||"";const r=l1.filter(o=>e.indexOf(o)<0&&n.indexOf(o)<0);if(r.length===0)return!0;const i=u1.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},Da=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 d=s;d<r.length;++d)if(d!==s&&(c+=n),c+=r[d],o=i[c],o!==void 0){if(["string","number","boolean"].indexOf(typeof o)>-1&&d<r.length-1)continue;s+=d-s+1;break}i=o}return i},us=t=>t==null?void 0:t.replace("_","-"),p1={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 fs{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||p1,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 fs(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new fs(this.logger,e)}}var Et=new fs;class lo{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,d]=o;for(let l=0;l<d;l++)c(...r)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(o=>{let[c,d]=o;for(let l=0;l<d;l++)c.apply(c,[e,...r])})}}class fu extends lo{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 l,u;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 d=ls(this.data,c);return!d&&!n&&!r&&e.indexOf(".")>-1&&(e=c[0],n=c[1],r=c.slice(2).join(".")),d||!o||!ne(r)?d:Da((u=(l=this.data)==null?void 0:l[e])==null?void 0:u[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),uu(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 d=ls(this.data,c)||{};o.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?a0(d,r,s):d={...d,...r},uu(this.data,c,d),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 c0={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 pu={};class ps extends lo{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),r1(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Et.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&&!f1(e,r,i);if(o&&!c){const d=e.match(this.interpolator.nestingRegexp);if(d&&d.length>0)return{key:e,namespaces:ne(s)?[s]:s};const l=e.split(r);(r!==i||r===i&&this.options.ns.indexOf(l[0])>-1)&&(s=l.shift()),e=l.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),d=c[c.length-1],l=n.lng||this.language,u=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if((l==null?void 0:l.toLowerCase())==="cimode"){if(u){const L=n.nsSeparator||this.options.nsSeparator;return i?{res:`${d}${L}${o}`,usedKey:o,exactUsedKey:o,usedLng:l,usedNS:d,usedParams:this.getUsedParamsDetails(n)}:`${d}${L}${o}`}return i?{res:o,usedKey:o,exactUsedKey:o,usedLng:l,usedNS:d,usedParams:this.getUsedParamsDetails(n)}:o}const p=this.resolve(e,n);let m=p==null?void 0:p.res;const w=(p==null?void 0:p.usedKey)||o,h=(p==null?void 0:p.exactUsedKey)||o,_=Object.prototype.toString.apply(m),v=["[object Number]","[object Function]","[object RegExp]"],k=n.joinArrays!==void 0?n.joinArrays:this.options.joinArrays,I=!this.i18nFormat||this.i18nFormat.handleAsObject,O=!ne(m)&&typeof m!="boolean"&&typeof m!="number";if(I&&m&&O&&v.indexOf(_)<0&&!(ne(k)&&Array.isArray(m))){if(!n.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const L=this.options.returnedObjectHandler?this.options.returnedObjectHandler(w,m,{...n,ns:c}):`key '${o} (${this.language})' returned an object instead of string.`;return i?(p.res=L,p.usedParams=this.getUsedParamsDetails(n),p):L}if(s){const L=Array.isArray(m),Y=L?[]:{},oe=L?h:w;for(const ae in m)if(Object.prototype.hasOwnProperty.call(m,ae)){const ke=`${oe}${s}${ae}`;Y[ae]=this.translate(ke,{...n,joinArrays:!1,ns:c}),Y[ae]===ke&&(Y[ae]=m[ae])}m=Y}}else if(I&&ne(k)&&Array.isArray(m))m=m.join(k),m&&(m=this.extendTranslation(m,e,n,r));else{let L=!1,Y=!1;const oe=n.count!==void 0&&!ne(n.count),ae=ps.hasDefaultValue(n),ke=oe?this.pluralResolver.getSuffix(l,n.count,n):"",Ee=n.ordinal&&oe?this.pluralResolver.getSuffix(l,n.count,{ordinal:!1}):"",ze=oe&&!n.ordinal&&n.count===0,z=ze&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${ke}`]||n[`defaultValue${Ee}`]||n.defaultValue;!this.isValidLookup(m)&&ae&&(L=!0,m=z),this.isValidLookup(m)||(Y=!0,m=o);const A=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&Y?void 0:m,x=ae&&z!==m&&this.options.updateMissing;if(Y||L||x){if(this.logger.log(x?"updateKey":"missingKey",l,d,o,x?z:m),s){const Q=this.resolve(o,{...n,keySeparator:!1});Q&&Q.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 $=[];const P=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if(this.options.saveMissingTo==="fallback"&&P&&P[0])for(let Q=0;Q<P.length;Q++)$.push(P[Q]);else this.options.saveMissingTo==="all"?$=this.languageUtils.toResolveHierarchy(n.lng||this.language):$.push(n.lng||this.language);const U=(Q,W,se)=>{var q;const ue=ae&&se!==m?se:A;this.options.missingKeyHandler?this.options.missingKeyHandler(Q,d,W,ue,x,n):(q=this.backendConnector)!=null&&q.saveMissing&&this.backendConnector.saveMissing(Q,d,W,ue,x,n),this.emit("missingKey",Q,d,W,m)};this.options.saveMissing&&(this.options.saveMissingPlurals&&oe?$.forEach(Q=>{const W=this.pluralResolver.getSuffixes(Q,n);ze&&n[`defaultValue${this.options.pluralSeparator}zero`]&&W.indexOf(`${this.options.pluralSeparator}zero`)<0&&W.push(`${this.options.pluralSeparator}zero`),W.forEach(se=>{U([Q],o+se,n[`defaultValue${se}`]||z)})}):U($,o,z))}m=this.extendTranslation(m,e,n,p,r),Y&&m===o&&this.options.appendNamespaceToMissingKey&&(m=`${d}:${o}`),(Y||L)&&this.options.parseMissingKeyHandler&&(m=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${d}:${o}`:o,L?m:void 0))}return i?(p.res=m,p.usedParams=this.getUsedParamsDetails(n),p):m}extendTranslation(e,n,r,i,s){var l,u;var o=this;if((l=this.i18nFormat)!=null&&l.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 p=ne(e)&&(((u=r==null?void 0:r.interpolation)==null?void 0:u.skipOnVariables)!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let m;if(p){const h=e.match(this.interpolator.nestingRegexp);m=h&&h.length}let w=r.replace&&!ne(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(w={...this.options.interpolation.defaultVariables,...w}),e=this.interpolator.interpolate(e,w,r.lng||this.language||i.usedLng,r),p){const h=e.match(this.interpolator.nestingRegexp),_=h&&h.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 h=arguments.length,_=new Array(h),v=0;v<h;v++)_[v]=arguments[v];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,d=ne(c)?[c]:c;return e!=null&&(d!=null&&d.length)&&r.applyPostProcessor!==!1&&(e=c0.handle(d,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(d=>{if(this.isValidLookup(r))return;const l=this.extractFromKey(d,n),u=l.key;i=u;let p=l.namespaces;this.options.fallbackNS&&(p=p.concat(this.options.fallbackNS));const m=n.count!==void 0&&!ne(n.count),w=m&&!n.ordinal&&n.count===0,h=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);p.forEach(v=>{var k,I;this.isValidLookup(r)||(c=v,!pu[`${_[0]}-${v}`]&&((k=this.utils)!=null&&k.hasLoadedNamespace)&&!((I=this.utils)!=null&&I.hasLoadedNamespace(c))&&(pu[`${_[0]}-${v}`]=!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(O=>{var oe;if(this.isValidLookup(r))return;o=O;const L=[u];if((oe=this.i18nFormat)!=null&&oe.addLookupKeys)this.i18nFormat.addLookupKeys(L,u,O,v,n);else{let ae;m&&(ae=this.pluralResolver.getSuffix(O,n.count,n));const ke=`${this.options.pluralSeparator}zero`,Ee=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(L.push(u+ae),n.ordinal&&ae.indexOf(Ee)===0&&L.push(u+ae.replace(Ee,this.options.pluralSeparator)),w&&L.push(u+ke)),h){const ze=`${u}${this.options.contextSeparator}${n.context}`;L.push(ze),m&&(L.push(ze+ae),n.ordinal&&ae.indexOf(Ee)===0&&L.push(ze+ae.replace(Ee,this.options.pluralSeparator)),w&&L.push(ze+ke))}}let Y;for(;Y=L.pop();)this.isValidLookup(r)||(s=Y,r=this.getResource(O,v,Y,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 hu{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Et.create("languageUtils")}getScriptPartFromCode(e){if(e=us(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=us(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 gu={zero:0,one:1,two:2,few:3,many:4,other:5},mu={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class h1{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=e,this.options=n,this.logger=Et.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=us(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!"),mu;if(!e.match(/-|_/))return mu;const d=this.languageUtils.getLanguagePartFromCode(e);o=this.getRule(d,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)=>gu[i]-gu[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=o1(t,e,n);return!s&&i&&ne(n)&&(s=Da(t,n,r),s===void 0&&(s=Da(e,n,r))),s},wa=t=>t.replace(/\$/g,"$$$$");class g1{constructor(){var n;let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Et.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:d,formatSeparator:l,unescapeSuffix:u,unescapePrefix:p,nestingPrefix:m,nestingPrefixEscaped:w,nestingSuffix:h,nestingSuffixEscaped:_,nestingOptionsSeparator:v,maxReplaces:k,alwaysFormat:I}=e.interpolation;this.escape=n!==void 0?n:c1,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=s?Hn(s):o||"{{",this.suffix=c?Hn(c):d||"}}",this.formatSeparator=l||",",this.unescapePrefix=u?"":p||"-",this.unescapeSuffix=this.unescapePrefix?"":u||"",this.nestingPrefix=m?Hn(m):w||Hn("$t("),this.nestingSuffix=h?Hn(h):_||Hn(")"),this.nestingOptionsSeparator=v||",",this.maxReplaces=k||1e3,this.alwaysFormat=I!==void 0?I:!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 w;let s,o,c;const d=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},l=h=>{if(h.indexOf(this.formatSeparator)<0){const I=_u(n,d,h,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(I,void 0,r,{...i,...n,interpolationkey:h}):I}const _=h.split(this.formatSeparator),v=_.shift().trim(),k=_.join(this.formatSeparator).trim();return this.format(_u(n,d,v,this.options.keySeparator,this.options.ignoreJSONStructure),k,r,{...i,...n,interpolationkey:v})};this.resetRegExp();const u=(i==null?void 0:i.missingInterpolationHandler)||this.options.missingInterpolationHandler,p=((w=i==null?void 0:i.interpolation)==null?void 0:w.skipOnVariables)!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:h=>wa(h)},{regex:this.regexp,safeValue:h=>this.escapeValue?wa(this.escape(h)):wa(h)}].forEach(h=>{for(c=0;s=h.regex.exec(e);){const _=s[1].trim();if(o=l(_),o===void 0)if(typeof u=="function"){const k=u(e,s,i);o=ne(k)?k:""}else if(i&&Object.prototype.hasOwnProperty.call(i,_))o="";else if(p){o=s[0];continue}else this.logger.warn(`missed to pass in variable ${_} for interpolating ${e}`),o="";else!ne(o)&&!this.useRawValueToEscape&&(o=cu(o));const v=h.safeValue(o);if(e=e.replace(s[0],v),p?(h.regex.lastIndex+=o.length,h.regex.lastIndex-=s[0].length):h.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=(d,l)=>{const u=this.nestingOptionsSeparator;if(d.indexOf(u)<0)return d;const p=d.split(new RegExp(`${u}[ ]*{`));let m=`{${p[1]}`;d=p[0],m=this.interpolate(m,o);const w=m.match(/'/g),h=m.match(/"/g);(((w==null?void 0:w.length)??0)%2===0&&!h||h.length%2!==0)&&(m=m.replace(/'/g,'"'));try{o=JSON.parse(m),l&&(o={...l,...o})}catch(_){return this.logger.warn(`failed parsing options string in nesting for key ${d}`,_),`${d}${u}${m}`}return o.defaultValue&&o.defaultValue.indexOf(this.prefix)>-1&&delete o.defaultValue,d};for(;i=this.nestingRegexp.exec(e);){let d=[];o={...r},o=o.replace&&!ne(o.replace)?o.replace:o,o.applyPostProcessor=!1,delete o.defaultValue;let l=!1;if(i[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(i[1])){const u=i[1].split(this.formatSeparator).map(p=>p.trim());i[1]=u.shift(),d=u,l=!0}if(s=n(c.call(this,i[1].trim(),o),o),s&&i[0]===e&&!ne(s))return s;ne(s)||(s=cu(s)),s||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),s=""),l&&(s=d.reduce((u,p)=>this.format(u,p,r.lng,{...r,interpolationkey:i[1].trim()}),s.trim())),e=e.replace(i[0],s),this.regexp.lastIndex=0}return e}}const m1=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,...d]=o.split(":"),l=d.join(":").trim().replace(/^'+|'+$/g,""),u=c.trim();n[u]||(n[u]=l),l==="false"&&(n[u]=!1),l==="true"&&(n[u]=!0),isNaN(l)||(n[u]=parseInt(l,10))}})}return{formatName:e,formatOptions:n}},Kn=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(us(r),i),e[o]=c),c(n)}};class _1{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Et.create("formatter"),this.options=e,this.formats={number:Kn((n,r)=>{const i=new Intl.NumberFormat(n,{...r});return s=>i.format(s)}),currency:Kn((n,r)=>{const i=new Intl.NumberFormat(n,{...r,style:"currency"});return s=>i.format(s)}),datetime:Kn((n,r)=>{const i=new Intl.DateTimeFormat(n,{...r});return s=>i.format(s)}),relativetime:Kn((n,r)=>{const i=new Intl.RelativeTimeFormat(n,{...r});return s=>i.format(s,r.range||"day")}),list:Kn((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()]=Kn(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(d=>d.indexOf(")")>-1);s[0]=[s[0],...s.splice(1,c)].join(this.formatSeparator)}return s.reduce((c,d)=>{var p;const{formatName:l,formatOptions:u}=m1(d);if(this.formats[l]){let m=c;try{const w=((p=i==null?void 0:i.formatParams)==null?void 0:p[i.interpolationkey])||{},h=w.locale||w.lng||i.locale||i.lng||r;m=this.formats[l](c,h,{...u,...i,...w})}catch(w){this.logger.warn(w)}return m}else this.logger.warn(`there was no format function for ${l}`);return c},e)}}const y1=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class w1 extends lo{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=Et.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={},d={};return e.forEach(l=>{let u=!0;n.forEach(p=>{const m=`${l}|${p}`;!r.reload&&this.store.hasResourceBundle(l,p)?this.state[m]=2:this.state[m]<0||(this.state[m]===1?o[m]===void 0&&(o[m]=!0):(this.state[m]=1,u=!1,o[m]===void 0&&(o[m]=!0),s[m]===void 0&&(s[m]=!0),d[p]===void 0&&(d[p]=!0)))}),u||(c[l]=!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(d)}}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(d=>{s1(d.loaded,[s],o),y1(d,e),n&&d.errors.push(n),d.pendingCount===0&&!d.done&&(Object.keys(d.loaded).forEach(l=>{c[l]||(c[l]={});const u=d.loaded[l];u.length&&u.forEach(p=>{c[l][p]===void 0&&(c[l][p]=!0)})}),d.done=!0,d.errors.length?d.callback(d.errors):d.callback())}),this.emit("loaded",c),this.queue=this.queue.filter(d=>!d.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=(l,u)=>{if(this.readingCalls--,this.waitingReads.length>0){const p=this.waitingReads.shift();this.read(p.lng,p.ns,p.fcName,p.tried,p.wait,p.callback)}if(l&&u&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,e,n,r,i+1,s*2,o)},s);return}o(l,u)},d=this.backend[r].bind(this.backend);if(d.length===2){try{const l=d(e,n);l&&typeof l.then=="function"?l.then(u=>c(null,u)).catch(c):c(null,l)}catch(l){c(l)}return}return d(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 d,l,u,p,m;let o=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{},c=arguments.length>6&&arguments[6]!==void 0?arguments[6]:()=>{};if((l=(d=this.services)==null?void 0:d.utils)!=null&&l.hasLoadedNamespace&&!((p=(u=this.services)==null?void 0:u.utils)!=null&&p.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 w={...o,isUpdate:s},h=this.backend.create.bind(this.backend);if(h.length<6)try{let _;h.length===5?_=h(e,n,r,i,w):_=h(e,n,r,i),_&&typeof _.then=="function"?_.then(v=>c(null,v)).catch(c):c(null,_)}catch(_){c(_)}else h(e,n,r,i,c,w)}!e||!e[0]||this.store.addResource(e[0],n,r,i)}}}const yu=()=>({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}}),wu=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},Fi=()=>{},v1=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class Wr extends lo{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(super(),this.options=wu(e),this.services={},this.logger=Et,this.modules={external:[]},v1(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=yu();this.options={...i,...this.options,...wu(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=u=>u?typeof u=="function"?new u:u:null;if(!this.options.isClone){this.modules.logger?Et.init(s(this.modules.logger),this.options):Et.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=_1;const p=new hu(this.options);this.store=new fu(this.options.resources,this.options);const m=this.services;m.logger=Et,m.resourceStore=this.store,m.languageUtils=p,m.pluralResolver=new h1(p,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),u&&(!this.options.interpolation.format||this.options.interpolation.format===i.interpolation.format)&&(m.formatter=s(u),m.formatter.init(m,this.options),this.options.interpolation.format=m.formatter.format.bind(m.formatter)),m.interpolator=new g1(this.options),m.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},m.backendConnector=new w1(s(this.modules.backend),m.resourceStore,m,this.options),m.backendConnector.on("*",function(w){for(var h=arguments.length,_=new Array(h>1?h-1:0),v=1;v<h;v++)_[v-1]=arguments[v];e.emit(w,..._)}),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 ps(this.services,this.options),this.translator.on("*",function(w){for(var h=arguments.length,_=new Array(h>1?h-1:0),v=1;v<h;v++)_[v-1]=arguments[v];e.emit(w,..._)}),this.modules.external.forEach(w=>{w.init&&w.init(this)})}if(this.format=this.options.interpolation.format,r||(r=Fi),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const u=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);u.length>0&&u[0]!=="dev"&&(this.options.lng=u[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(u=>{this[u]=function(){return e.store[u](...arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(u=>{this[u]=function(){return e.store[u](...arguments),e}});const d=jr(),l=()=>{const u=(p,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),d.resolve(m),r(p,m)};if(this.languages&&!this.isInitialized)return u(null,this.t.bind(this));this.changeLanguage(this.options.lng,u)};return this.options.resources||!this.options.initAsync?l():setTimeout(l,0),d}loadResources(e){var s,o;let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Fi;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=[],d=l=>{if(!l||l==="cimode")return;this.services.languageUtils.toResolveHierarchy(l).forEach(p=>{p!=="cimode"&&c.indexOf(p)<0&&c.push(p)})};i?d(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(u=>d(u)),(o=(s=this.options.preload)==null?void 0:s.forEach)==null||o.call(s,l=>d(l)),this.services.backendConnector.load(c,this.options.ns,l=>{!l&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(l)})}else r(null)}reloadResources(e,n,r){const i=jr();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=Fi),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"&&c0.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=jr();this.emit("languageChanging",e);const s=d=>{this.language=d,this.languages=this.services.languageUtils.toResolveHierarchy(d),this.resolvedLanguage=void 0,this.setResolvedLanguage(d)},o=(d,l)=>{l?(s(l),this.translator.changeLanguage(l),this.isLanguageChangingTo=void 0,this.emit("languageChanged",l),this.logger.log("languageChanged",l)):this.isLanguageChangingTo=void 0,i.resolve(function(){return r.t(...arguments)}),n&&n(d,function(){return r.t(...arguments)})},c=d=>{var u,p;!e&&!d&&this.services.languageDetector&&(d=[]);const l=ne(d)?d:this.services.languageUtils.getBestMatchFromCodes(d);l&&(this.language||s(l),this.translator.language||this.translator.changeLanguage(l),(p=(u=this.services.languageDetector)==null?void 0:u.cacheUserLanguage)==null||p.call(u,l)),this.loadResources(l,m=>{o(m,l)})};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 d;if(typeof c!="object"){for(var l=arguments.length,u=new Array(l>2?l-2:0),p=2;p<l;p++)u[p-2]=arguments[p];d=i.options.overloadTranslationOptionHandler([o,c].concat(u))}else d={...c};d.lng=d.lng||s.lng,d.lngs=d.lngs||s.lngs,d.ns=d.ns||s.ns,d.keyPrefix!==""&&(d.keyPrefix=d.keyPrefix||r||s.keyPrefix);const m=i.options.keySeparator||".";let w;return d.keyPrefix&&Array.isArray(o)?w=o.map(h=>`${d.keyPrefix}${m}${h}`):w=d.keyPrefix?`${d.keyPrefix}${m}${o}`:o,i.t(w,d)};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,d)=>{const l=this.services.backendConnector.state[`${c}|${d}`];return l===-1||l===0||l===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=jr();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=jr();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 hu(yu());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 Wr(e,n)}cloneInstance(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Fi;const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},s=new Wr(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((d,l)=>(d[l]={...this.store.data[l]},Object.keys(d[l]).reduce((u,p)=>(u[p]={...d[l][p]},u),{})),{});s.store=new fu(c,i),s.services.resourceStore=s.store}return s.translator=new ps(s.services,i),s.translator.on("*",function(c){for(var d=arguments.length,l=new Array(d>1?d-1:0),u=1;u<d;u++)l[u-1]=arguments[u];s.emit(c,...l)}),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 T=Wr.createInstance();T.createInstance=Wr.createInstance;T.createInstance;T.dir;T.init;T.loadResources;T.reloadResources;T.use;T.changeLanguage;T.getFixedT;const re=T.t;T.exists;T.setDefaultNamespace;T.hasLoadedNamespace;T.loadNamespaces;T.loadLanguages;var d0=t=>{const n={...{origin:"*",allowMethods:["GET","HEAD","PUT","POST","DELETE","PATCH"],allowHeaders:[],exposeHeaders:[]},...t},r=(i=>typeof i=="string"?i==="*"?()=>i:s=>i===s?s:null:typeof i=="function"?i:s=>i.includes(s)?s:null)(n.origin);return async function(s,o){var l,u;function c(p,m){s.res.headers.set(p,m)}const d=r(s.req.header("origin")||"",s);if(d&&c("Access-Control-Allow-Origin",d),n.origin!=="*"){const p=s.req.header("Vary");p?c("Vary",p):c("Vary","Origin")}if(n.credentials&&c("Access-Control-Allow-Credentials","true"),(l=n.exposeHeaders)!=null&&l.length&&c("Access-Control-Expose-Headers",n.exposeHeaders.join(",")),s.req.method==="OPTIONS"){n.maxAge!=null&&c("Access-Control-Max-Age",n.maxAge.toString()),(u=n.allowMethods)!=null&&u.length&&c("Access-Control-Allow-Methods",n.allowMethods.join(","));let p=n.allowHeaders;if(!(p!=null&&p.length)){const m=s.req.header("Access-Control-Request-Headers");m&&(p=m.split(/\s*,\s*/))}return p!=null&&p.length&&(c("Access-Control-Allow-Headers",p.join(",")),s.res.headers.append("Vary","Access-Control-Request-Headers")),s.res.headers.delete("Content-Length"),s.res.headers.delete("Content-Type"),new Response(null,{headers:s.res.headers,status:204,statusText:"No Content"})}await o()}};const un=a.z.object({start:a.z.number(),limit:a.z.number(),length:a.z.number()}),l0=a.z.object({created_at:a.z.string(),updated_at:a.z.string()}),u0=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()),f0=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:u0.optional()}),uo=a.z.object({email:a.z.string().optional(),username:a.z.string().optional(),phone_number: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()}),hs=uo.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()}),Id=a.z.object({...hs.shape,...l0.shape,user_id:a.z.string(),is_social:a.z.boolean(),email:a.z.string().optional(),login_count:a.z.number(),identities:a.z.array(f0).optional()}),At=Id,b1=uo.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()),$1="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let x1=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=$1[n[t]&63];return e};const p0=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()}),gs=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:p0.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(()=>x1()).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"})}),bn=a.z.object({created_at:a.z.string().transform(t=>t===null?"":t),updated_at:a.z.string().transform(t=>t===null?"":t),...gs.shape});var Ct=(t=>(t.TOKEN="token",t.TOKEN_ID_TOKEN="token id_token",t.CODE="code",t))(Ct||{}),Ft=(t=>(t.QUERY="query",t.FRAGMENT="fragment",t.FORM_POST="form_post",t.WEB_MESSAGE="web_message",t.SAML_POST="saml_post",t))(Ft||{}),fo=(t=>(t.S256="S256",t.Plain="plain",t))(fo||{});const Jr=a.z.object({client_id:a.z.string(),act_as:a.z.string().optional(),response_type:a.z.nativeEnum(Ct).optional(),response_mode:a.z.nativeEnum(Ft).optional(),redirect_uri:a.z.string().optional(),audience:a.z.string().optional(),organization: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(fo).optional(),code_challenge:a.z.string().optional(),username:a.z.string().optional(),ui_locales:a.z.string().optional(),vendor_id:a.z.string().optional()}),qa=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()}),Nd=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().optional(),token_endpoint:a.z.string().optional(),userinfo_endpoint:a.z.string().optional(),jwks_uri:a.z.string().optional(),discovery_url:a.z.string().optional(),issuer:a.z.string().optional(),provider:a.z.string().optional(),from:a.z.string().optional(),twilio_sid:a.z.string().optional(),twilio_token:a.z.string().optional()}),ms=a.z.object({id:a.z.string().optional(),name:a.z.string(),strategy:a.z.string(),options:Nd.default({}),enabled_clients:a.z.array(a.z.string()).default([]).optional(),response_type:a.z.custom().optional(),response_mode:a.z.custom().optional()}),Qt=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(ms.shape),_s=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()}),tr=a.z.object({created_at:a.z.string().transform(t=>t===null?"":t),updated_at:a.z.string().transform(t=>t===null?"":t),..._s.shape,id:a.z.string()}),h0=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({...bn.shape,tenant:tr,connections:a.z.array(Qt)});const g0=a.z.enum(["password_reset","email_verification","otp","authorization_code","oauth2_state","ticket"]),m0=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:g0,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()}),k1=a.z.object({...m0.shape,created_at:a.z.string()}),Cd=a.z.object({domain:a.z.string(),custom_domain_id:a.z.string().optional(),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()}),_0=a.z.object({name:a.z.literal("txt"),record:a.z.string(),domain:a.z.string()}),Yt=a.z.object({...Cd.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({methods:a.z.array(_0)}).optional(),tls_policy:a.z.string().optional()}),S1=Yt.extend({tenant_id:a.z.string()}),ys=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()}),Yn=ys.extend({...l0.shape,hook_id:a.z.string()}),zd=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()}),y0=a.z.object({keys:a.z.array(zd)}),Ha=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())}),w0=a.z.object({csrf_token:a.z.string(),auth0Client:a.z.string().optional(),authParams:Jr,expires_at:a.z.string(),deleted_at:a.z.string().optional(),ip:a.z.string().optional(),useragent:a.z.string().optional(),session_id:a.z.string().optional(),authorization_url:a.z.string().optional()}).openapi({description:"This represents a login sesion"}),A1=a.z.object({...w0.shape,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 ge=(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))(ge||{});const E1=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"]),v0=a.z.object({name:a.z.string(),version:a.z.string(),env:a.z.object({node:a.z.string().optional()}).optional()}),ws=a.z.object({type:E1,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:v0.optional()}),b0=a.z.object({user_id:a.z.string(),password:a.z.string(),algorithm:a.z.enum(["bcrypt","argon2id"]).default("argon2id")}),I1=a.z.object({...b0.shape,created_at:a.z.string(),updated_at:a.z.string()}),$0=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")}),x0=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:$0.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")}),po=a.z.object({created_at:a.z.string(),updated_at:a.z.string(),authenticated_at:a.z.string(),last_interaction_at:a.z.string(),...x0.shape}),Ka=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 Qn=(t=>(t.RefreshToken="refresh_token",t.AuthorizationCode="authorization_code",t.ClientCredential="client_credentials",t.Passwordless="passwordless",t.Password="password",t.OTP="http://auth0.com/oauth/grant-type/passwordless/otp",t))(Qn||{});const k0=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 S0=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()}),A0=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()}),yn=a.z.object({bold:a.z.boolean(),size:a.z.number()}),E0=a.z.object({body_text:yn,buttons_text:yn,font_url:a.z.string(),input_labels:yn,links:yn,links_style:a.z.enum(["normal"]),reference_text_size:a.z.number(),subtitle:yn,title:yn}),I0=a.z.object({background_color:a.z.string(),background_image_url:a.z.string(),page_layout:a.z.enum(["center"])}),N0=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"])}),C0=a.z.object({borders:S0,colors:A0,displayName:a.z.string(),fonts:E0,page_background:I0,widget:N0}),N1=C0.extend({themeId:a.z.string()}),Wi=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()}),Ji=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()}),Od=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:$0,resource_servers:a.z.array(a.z.object({audience:a.z.string(),scopes:a.z.string()})),rotating:a.z.boolean()}),C1=a.z.object({created_at:a.z.string(),...Od.shape}),z1=a.z.object({to:a.z.string(),message:a.z.string()}),O1=a.z.object({name:a.z.string(),options:a.z.object({})});function P1(t){const[e,n]=t.split("|");if(!e||!n)throw new Error(`Invalid user_id: ${t}`);return{connection:e,id:n}}const j1=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:qa}},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(qa.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});te(this,"res");te(this,"status");this.res=n==null?void 0:n.res,this.status=e}getResponse(){return this.res?new Response(this.res.body,{status:this.status,headers:this.res.headers}):new Response(this.message,{status:this.status})}},vs=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function z0(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function T1(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 R1(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 O0={exports:{}};const B1={},L1=Object.freeze(Object.defineProperty({__proto__:null,default:B1},Symbol.toStringTag,{value:"Module"})),U1=T1(L1);(function(t){/**
1
+ "use strict";var n1=Object.defineProperty;var r1=(t,e,n)=>e in t?n1(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var te=(t,e,n)=>r1(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",jr=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},cu=t=>t==null?"":""+t,i1=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},s1=/###/g,du=t=>t&&t.indexOf("###")>-1?t.replace(s1,"."):t,lu=t=>!t||ne(t),Fr=(t,e,n)=>{const r=ne(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(lu(t))return{};const s=du(r[i]);!t[s]&&n&&(t[s]=new n),Object.prototype.hasOwnProperty.call(t,s)?t=t[s]:t={},++i}return lu(t)?{}:{obj:t,k:du(r[i])}},uu=(t,e,n)=>{const{obj:r,k:i}=Fr(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=Fr(t,o,Object);for(;c.obj===void 0&&o.length;)s=`${o[o.length-1]}.${s}`,o=o.slice(0,o.length-1),c=Fr(t,o,Object),c!=null&&c.obj&&typeof c.obj[`${c.k}.${s}`]<"u"&&(c.obj=void 0);c.obj[`${c.k}.${s}`]=n},o1=(t,e,n,r)=>{const{obj:i,k:s}=Fr(t,e,Object);i[s]=i[s]||[],i[s].push(n)},us=(t,e)=>{const{obj:n,k:r}=Fr(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},a1=(t,e,n)=>{const r=us(t,n);return r!==void 0?r:us(e,n)},a0=(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]):a0(t[r],e[r],n):t[r]=e[r]);return t},Hn=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var c1={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const d1=t=>ne(t)?t.replace(/[&<>"'\/]/g,e=>c1[e]):t;class l1{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 u1=[" ",",","?","!",";"],f1=new l1(20),p1=(t,e,n)=>{e=e||"",n=n||"";const r=u1.filter(o=>e.indexOf(o)<0&&n.indexOf(o)<0);if(r.length===0)return!0;const i=f1.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},Da=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 d=s;d<r.length;++d)if(d!==s&&(c+=n),c+=r[d],o=i[c],o!==void 0){if(["string","number","boolean"].indexOf(typeof o)>-1&&d<r.length-1)continue;s+=d-s+1;break}i=o}return i},fs=t=>t==null?void 0:t.replace("_","-"),h1={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 ps{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||h1,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 ps(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new ps(this.logger,e)}}var Et=new ps;class uo{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,d]=o;for(let l=0;l<d;l++)c(...r)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(o=>{let[c,d]=o;for(let l=0;l<d;l++)c.apply(c,[e,...r])})}}class fu extends uo{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 l,u;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 d=us(this.data,c);return!d&&!n&&!r&&e.indexOf(".")>-1&&(e=c[0],n=c[1],r=c.slice(2).join(".")),d||!o||!ne(r)?d:Da((u=(l=this.data)==null?void 0:l[e])==null?void 0:u[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),uu(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 d=us(this.data,c)||{};o.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?a0(d,r,s):d={...d,...r},uu(this.data,c,d),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 c0={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 pu={};class hs extends uo{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),i1(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Et.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&&!p1(e,r,i);if(o&&!c){const d=e.match(this.interpolator.nestingRegexp);if(d&&d.length>0)return{key:e,namespaces:ne(s)?[s]:s};const l=e.split(r);(r!==i||r===i&&this.options.ns.indexOf(l[0])>-1)&&(s=l.shift()),e=l.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),d=c[c.length-1],l=n.lng||this.language,u=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if((l==null?void 0:l.toLowerCase())==="cimode"){if(u){const L=n.nsSeparator||this.options.nsSeparator;return i?{res:`${d}${L}${o}`,usedKey:o,exactUsedKey:o,usedLng:l,usedNS:d,usedParams:this.getUsedParamsDetails(n)}:`${d}${L}${o}`}return i?{res:o,usedKey:o,exactUsedKey:o,usedLng:l,usedNS:d,usedParams:this.getUsedParamsDetails(n)}:o}const p=this.resolve(e,n);let m=p==null?void 0:p.res;const w=(p==null?void 0:p.usedKey)||o,h=(p==null?void 0:p.exactUsedKey)||o,_=Object.prototype.toString.apply(m),v=["[object Number]","[object Function]","[object RegExp]"],k=n.joinArrays!==void 0?n.joinArrays:this.options.joinArrays,I=!this.i18nFormat||this.i18nFormat.handleAsObject,O=!ne(m)&&typeof m!="boolean"&&typeof m!="number";if(I&&m&&O&&v.indexOf(_)<0&&!(ne(k)&&Array.isArray(m))){if(!n.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const L=this.options.returnedObjectHandler?this.options.returnedObjectHandler(w,m,{...n,ns:c}):`key '${o} (${this.language})' returned an object instead of string.`;return i?(p.res=L,p.usedParams=this.getUsedParamsDetails(n),p):L}if(s){const L=Array.isArray(m),Y=L?[]:{},oe=L?h:w;for(const ae in m)if(Object.prototype.hasOwnProperty.call(m,ae)){const ke=`${oe}${s}${ae}`;Y[ae]=this.translate(ke,{...n,joinArrays:!1,ns:c}),Y[ae]===ke&&(Y[ae]=m[ae])}m=Y}}else if(I&&ne(k)&&Array.isArray(m))m=m.join(k),m&&(m=this.extendTranslation(m,e,n,r));else{let L=!1,Y=!1;const oe=n.count!==void 0&&!ne(n.count),ae=hs.hasDefaultValue(n),ke=oe?this.pluralResolver.getSuffix(l,n.count,n):"",Ee=n.ordinal&&oe?this.pluralResolver.getSuffix(l,n.count,{ordinal:!1}):"",ze=oe&&!n.ordinal&&n.count===0,z=ze&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${ke}`]||n[`defaultValue${Ee}`]||n.defaultValue;!this.isValidLookup(m)&&ae&&(L=!0,m=z),this.isValidLookup(m)||(Y=!0,m=o);const A=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&Y?void 0:m,x=ae&&z!==m&&this.options.updateMissing;if(Y||L||x){if(this.logger.log(x?"updateKey":"missingKey",l,d,o,x?z:m),s){const Q=this.resolve(o,{...n,keySeparator:!1});Q&&Q.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 $=[];const P=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if(this.options.saveMissingTo==="fallback"&&P&&P[0])for(let Q=0;Q<P.length;Q++)$.push(P[Q]);else this.options.saveMissingTo==="all"?$=this.languageUtils.toResolveHierarchy(n.lng||this.language):$.push(n.lng||this.language);const U=(Q,W,se)=>{var q;const ue=ae&&se!==m?se:A;this.options.missingKeyHandler?this.options.missingKeyHandler(Q,d,W,ue,x,n):(q=this.backendConnector)!=null&&q.saveMissing&&this.backendConnector.saveMissing(Q,d,W,ue,x,n),this.emit("missingKey",Q,d,W,m)};this.options.saveMissing&&(this.options.saveMissingPlurals&&oe?$.forEach(Q=>{const W=this.pluralResolver.getSuffixes(Q,n);ze&&n[`defaultValue${this.options.pluralSeparator}zero`]&&W.indexOf(`${this.options.pluralSeparator}zero`)<0&&W.push(`${this.options.pluralSeparator}zero`),W.forEach(se=>{U([Q],o+se,n[`defaultValue${se}`]||z)})}):U($,o,z))}m=this.extendTranslation(m,e,n,p,r),Y&&m===o&&this.options.appendNamespaceToMissingKey&&(m=`${d}:${o}`),(Y||L)&&this.options.parseMissingKeyHandler&&(m=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${d}:${o}`:o,L?m:void 0))}return i?(p.res=m,p.usedParams=this.getUsedParamsDetails(n),p):m}extendTranslation(e,n,r,i,s){var l,u;var o=this;if((l=this.i18nFormat)!=null&&l.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 p=ne(e)&&(((u=r==null?void 0:r.interpolation)==null?void 0:u.skipOnVariables)!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let m;if(p){const h=e.match(this.interpolator.nestingRegexp);m=h&&h.length}let w=r.replace&&!ne(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(w={...this.options.interpolation.defaultVariables,...w}),e=this.interpolator.interpolate(e,w,r.lng||this.language||i.usedLng,r),p){const h=e.match(this.interpolator.nestingRegexp),_=h&&h.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 h=arguments.length,_=new Array(h),v=0;v<h;v++)_[v]=arguments[v];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,d=ne(c)?[c]:c;return e!=null&&(d!=null&&d.length)&&r.applyPostProcessor!==!1&&(e=c0.handle(d,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(d=>{if(this.isValidLookup(r))return;const l=this.extractFromKey(d,n),u=l.key;i=u;let p=l.namespaces;this.options.fallbackNS&&(p=p.concat(this.options.fallbackNS));const m=n.count!==void 0&&!ne(n.count),w=m&&!n.ordinal&&n.count===0,h=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);p.forEach(v=>{var k,I;this.isValidLookup(r)||(c=v,!pu[`${_[0]}-${v}`]&&((k=this.utils)!=null&&k.hasLoadedNamespace)&&!((I=this.utils)!=null&&I.hasLoadedNamespace(c))&&(pu[`${_[0]}-${v}`]=!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(O=>{var oe;if(this.isValidLookup(r))return;o=O;const L=[u];if((oe=this.i18nFormat)!=null&&oe.addLookupKeys)this.i18nFormat.addLookupKeys(L,u,O,v,n);else{let ae;m&&(ae=this.pluralResolver.getSuffix(O,n.count,n));const ke=`${this.options.pluralSeparator}zero`,Ee=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(L.push(u+ae),n.ordinal&&ae.indexOf(Ee)===0&&L.push(u+ae.replace(Ee,this.options.pluralSeparator)),w&&L.push(u+ke)),h){const ze=`${u}${this.options.contextSeparator}${n.context}`;L.push(ze),m&&(L.push(ze+ae),n.ordinal&&ae.indexOf(Ee)===0&&L.push(ze+ae.replace(Ee,this.options.pluralSeparator)),w&&L.push(ze+ke))}}let Y;for(;Y=L.pop();)this.isValidLookup(r)||(s=Y,r=this.getResource(O,v,Y,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 hu{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Et.create("languageUtils")}getScriptPartFromCode(e){if(e=fs(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=fs(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 gu={zero:0,one:1,two:2,few:3,many:4,other:5},mu={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class g1{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=e,this.options=n,this.logger=Et.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=fs(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!"),mu;if(!e.match(/-|_/))return mu;const d=this.languageUtils.getLanguagePartFromCode(e);o=this.getRule(d,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)=>gu[i]-gu[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=a1(t,e,n);return!s&&i&&ne(n)&&(s=Da(t,n,r),s===void 0&&(s=Da(e,n,r))),s},wa=t=>t.replace(/\$/g,"$$$$");class m1{constructor(){var n;let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Et.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:d,formatSeparator:l,unescapeSuffix:u,unescapePrefix:p,nestingPrefix:m,nestingPrefixEscaped:w,nestingSuffix:h,nestingSuffixEscaped:_,nestingOptionsSeparator:v,maxReplaces:k,alwaysFormat:I}=e.interpolation;this.escape=n!==void 0?n:d1,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=s?Hn(s):o||"{{",this.suffix=c?Hn(c):d||"}}",this.formatSeparator=l||",",this.unescapePrefix=u?"":p||"-",this.unescapeSuffix=this.unescapePrefix?"":u||"",this.nestingPrefix=m?Hn(m):w||Hn("$t("),this.nestingSuffix=h?Hn(h):_||Hn(")"),this.nestingOptionsSeparator=v||",",this.maxReplaces=k||1e3,this.alwaysFormat=I!==void 0?I:!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 w;let s,o,c;const d=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},l=h=>{if(h.indexOf(this.formatSeparator)<0){const I=_u(n,d,h,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(I,void 0,r,{...i,...n,interpolationkey:h}):I}const _=h.split(this.formatSeparator),v=_.shift().trim(),k=_.join(this.formatSeparator).trim();return this.format(_u(n,d,v,this.options.keySeparator,this.options.ignoreJSONStructure),k,r,{...i,...n,interpolationkey:v})};this.resetRegExp();const u=(i==null?void 0:i.missingInterpolationHandler)||this.options.missingInterpolationHandler,p=((w=i==null?void 0:i.interpolation)==null?void 0:w.skipOnVariables)!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:h=>wa(h)},{regex:this.regexp,safeValue:h=>this.escapeValue?wa(this.escape(h)):wa(h)}].forEach(h=>{for(c=0;s=h.regex.exec(e);){const _=s[1].trim();if(o=l(_),o===void 0)if(typeof u=="function"){const k=u(e,s,i);o=ne(k)?k:""}else if(i&&Object.prototype.hasOwnProperty.call(i,_))o="";else if(p){o=s[0];continue}else this.logger.warn(`missed to pass in variable ${_} for interpolating ${e}`),o="";else!ne(o)&&!this.useRawValueToEscape&&(o=cu(o));const v=h.safeValue(o);if(e=e.replace(s[0],v),p?(h.regex.lastIndex+=o.length,h.regex.lastIndex-=s[0].length):h.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=(d,l)=>{const u=this.nestingOptionsSeparator;if(d.indexOf(u)<0)return d;const p=d.split(new RegExp(`${u}[ ]*{`));let m=`{${p[1]}`;d=p[0],m=this.interpolate(m,o);const w=m.match(/'/g),h=m.match(/"/g);(((w==null?void 0:w.length)??0)%2===0&&!h||h.length%2!==0)&&(m=m.replace(/'/g,'"'));try{o=JSON.parse(m),l&&(o={...l,...o})}catch(_){return this.logger.warn(`failed parsing options string in nesting for key ${d}`,_),`${d}${u}${m}`}return o.defaultValue&&o.defaultValue.indexOf(this.prefix)>-1&&delete o.defaultValue,d};for(;i=this.nestingRegexp.exec(e);){let d=[];o={...r},o=o.replace&&!ne(o.replace)?o.replace:o,o.applyPostProcessor=!1,delete o.defaultValue;let l=!1;if(i[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(i[1])){const u=i[1].split(this.formatSeparator).map(p=>p.trim());i[1]=u.shift(),d=u,l=!0}if(s=n(c.call(this,i[1].trim(),o),o),s&&i[0]===e&&!ne(s))return s;ne(s)||(s=cu(s)),s||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),s=""),l&&(s=d.reduce((u,p)=>this.format(u,p,r.lng,{...r,interpolationkey:i[1].trim()}),s.trim())),e=e.replace(i[0],s),this.regexp.lastIndex=0}return e}}const _1=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,...d]=o.split(":"),l=d.join(":").trim().replace(/^'+|'+$/g,""),u=c.trim();n[u]||(n[u]=l),l==="false"&&(n[u]=!1),l==="true"&&(n[u]=!0),isNaN(l)||(n[u]=parseInt(l,10))}})}return{formatName:e,formatOptions:n}},Kn=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(fs(r),i),e[o]=c),c(n)}};class y1{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Et.create("formatter"),this.options=e,this.formats={number:Kn((n,r)=>{const i=new Intl.NumberFormat(n,{...r});return s=>i.format(s)}),currency:Kn((n,r)=>{const i=new Intl.NumberFormat(n,{...r,style:"currency"});return s=>i.format(s)}),datetime:Kn((n,r)=>{const i=new Intl.DateTimeFormat(n,{...r});return s=>i.format(s)}),relativetime:Kn((n,r)=>{const i=new Intl.RelativeTimeFormat(n,{...r});return s=>i.format(s,r.range||"day")}),list:Kn((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()]=Kn(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(d=>d.indexOf(")")>-1);s[0]=[s[0],...s.splice(1,c)].join(this.formatSeparator)}return s.reduce((c,d)=>{var p;const{formatName:l,formatOptions:u}=_1(d);if(this.formats[l]){let m=c;try{const w=((p=i==null?void 0:i.formatParams)==null?void 0:p[i.interpolationkey])||{},h=w.locale||w.lng||i.locale||i.lng||r;m=this.formats[l](c,h,{...u,...i,...w})}catch(w){this.logger.warn(w)}return m}else this.logger.warn(`there was no format function for ${l}`);return c},e)}}const w1=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class v1 extends uo{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=Et.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={},d={};return e.forEach(l=>{let u=!0;n.forEach(p=>{const m=`${l}|${p}`;!r.reload&&this.store.hasResourceBundle(l,p)?this.state[m]=2:this.state[m]<0||(this.state[m]===1?o[m]===void 0&&(o[m]=!0):(this.state[m]=1,u=!1,o[m]===void 0&&(o[m]=!0),s[m]===void 0&&(s[m]=!0),d[p]===void 0&&(d[p]=!0)))}),u||(c[l]=!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(d)}}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(d=>{o1(d.loaded,[s],o),w1(d,e),n&&d.errors.push(n),d.pendingCount===0&&!d.done&&(Object.keys(d.loaded).forEach(l=>{c[l]||(c[l]={});const u=d.loaded[l];u.length&&u.forEach(p=>{c[l][p]===void 0&&(c[l][p]=!0)})}),d.done=!0,d.errors.length?d.callback(d.errors):d.callback())}),this.emit("loaded",c),this.queue=this.queue.filter(d=>!d.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=(l,u)=>{if(this.readingCalls--,this.waitingReads.length>0){const p=this.waitingReads.shift();this.read(p.lng,p.ns,p.fcName,p.tried,p.wait,p.callback)}if(l&&u&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,e,n,r,i+1,s*2,o)},s);return}o(l,u)},d=this.backend[r].bind(this.backend);if(d.length===2){try{const l=d(e,n);l&&typeof l.then=="function"?l.then(u=>c(null,u)).catch(c):c(null,l)}catch(l){c(l)}return}return d(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 d,l,u,p,m;let o=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{},c=arguments.length>6&&arguments[6]!==void 0?arguments[6]:()=>{};if((l=(d=this.services)==null?void 0:d.utils)!=null&&l.hasLoadedNamespace&&!((p=(u=this.services)==null?void 0:u.utils)!=null&&p.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 w={...o,isUpdate:s},h=this.backend.create.bind(this.backend);if(h.length<6)try{let _;h.length===5?_=h(e,n,r,i,w):_=h(e,n,r,i),_&&typeof _.then=="function"?_.then(v=>c(null,v)).catch(c):c(null,_)}catch(_){c(_)}else h(e,n,r,i,c,w)}!e||!e[0]||this.store.addResource(e[0],n,r,i)}}}const yu=()=>({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}}),wu=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},Vi=()=>{},b1=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class Wr extends uo{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(super(),this.options=wu(e),this.services={},this.logger=Et,this.modules={external:[]},b1(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=yu();this.options={...i,...this.options,...wu(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=u=>u?typeof u=="function"?new u:u:null;if(!this.options.isClone){this.modules.logger?Et.init(s(this.modules.logger),this.options):Et.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=y1;const p=new hu(this.options);this.store=new fu(this.options.resources,this.options);const m=this.services;m.logger=Et,m.resourceStore=this.store,m.languageUtils=p,m.pluralResolver=new g1(p,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),u&&(!this.options.interpolation.format||this.options.interpolation.format===i.interpolation.format)&&(m.formatter=s(u),m.formatter.init(m,this.options),this.options.interpolation.format=m.formatter.format.bind(m.formatter)),m.interpolator=new m1(this.options),m.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},m.backendConnector=new v1(s(this.modules.backend),m.resourceStore,m,this.options),m.backendConnector.on("*",function(w){for(var h=arguments.length,_=new Array(h>1?h-1:0),v=1;v<h;v++)_[v-1]=arguments[v];e.emit(w,..._)}),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 hs(this.services,this.options),this.translator.on("*",function(w){for(var h=arguments.length,_=new Array(h>1?h-1:0),v=1;v<h;v++)_[v-1]=arguments[v];e.emit(w,..._)}),this.modules.external.forEach(w=>{w.init&&w.init(this)})}if(this.format=this.options.interpolation.format,r||(r=Vi),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const u=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);u.length>0&&u[0]!=="dev"&&(this.options.lng=u[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(u=>{this[u]=function(){return e.store[u](...arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(u=>{this[u]=function(){return e.store[u](...arguments),e}});const d=jr(),l=()=>{const u=(p,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),d.resolve(m),r(p,m)};if(this.languages&&!this.isInitialized)return u(null,this.t.bind(this));this.changeLanguage(this.options.lng,u)};return this.options.resources||!this.options.initAsync?l():setTimeout(l,0),d}loadResources(e){var s,o;let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Vi;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=[],d=l=>{if(!l||l==="cimode")return;this.services.languageUtils.toResolveHierarchy(l).forEach(p=>{p!=="cimode"&&c.indexOf(p)<0&&c.push(p)})};i?d(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(u=>d(u)),(o=(s=this.options.preload)==null?void 0:s.forEach)==null||o.call(s,l=>d(l)),this.services.backendConnector.load(c,this.options.ns,l=>{!l&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(l)})}else r(null)}reloadResources(e,n,r){const i=jr();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=Vi),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"&&c0.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=jr();this.emit("languageChanging",e);const s=d=>{this.language=d,this.languages=this.services.languageUtils.toResolveHierarchy(d),this.resolvedLanguage=void 0,this.setResolvedLanguage(d)},o=(d,l)=>{l?(s(l),this.translator.changeLanguage(l),this.isLanguageChangingTo=void 0,this.emit("languageChanged",l),this.logger.log("languageChanged",l)):this.isLanguageChangingTo=void 0,i.resolve(function(){return r.t(...arguments)}),n&&n(d,function(){return r.t(...arguments)})},c=d=>{var u,p;!e&&!d&&this.services.languageDetector&&(d=[]);const l=ne(d)?d:this.services.languageUtils.getBestMatchFromCodes(d);l&&(this.language||s(l),this.translator.language||this.translator.changeLanguage(l),(p=(u=this.services.languageDetector)==null?void 0:u.cacheUserLanguage)==null||p.call(u,l)),this.loadResources(l,m=>{o(m,l)})};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 d;if(typeof c!="object"){for(var l=arguments.length,u=new Array(l>2?l-2:0),p=2;p<l;p++)u[p-2]=arguments[p];d=i.options.overloadTranslationOptionHandler([o,c].concat(u))}else d={...c};d.lng=d.lng||s.lng,d.lngs=d.lngs||s.lngs,d.ns=d.ns||s.ns,d.keyPrefix!==""&&(d.keyPrefix=d.keyPrefix||r||s.keyPrefix);const m=i.options.keySeparator||".";let w;return d.keyPrefix&&Array.isArray(o)?w=o.map(h=>`${d.keyPrefix}${m}${h}`):w=d.keyPrefix?`${d.keyPrefix}${m}${o}`:o,i.t(w,d)};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,d)=>{const l=this.services.backendConnector.state[`${c}|${d}`];return l===-1||l===0||l===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=jr();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=jr();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 hu(yu());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 Wr(e,n)}cloneInstance(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Vi;const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},s=new Wr(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((d,l)=>(d[l]={...this.store.data[l]},Object.keys(d[l]).reduce((u,p)=>(u[p]={...d[l][p]},u),{})),{});s.store=new fu(c,i),s.services.resourceStore=s.store}return s.translator=new hs(s.services,i),s.translator.on("*",function(c){for(var d=arguments.length,l=new Array(d>1?d-1:0),u=1;u<d;u++)l[u-1]=arguments[u];s.emit(c,...l)}),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 T=Wr.createInstance();T.createInstance=Wr.createInstance;T.createInstance;T.dir;T.init;T.loadResources;T.reloadResources;T.use;T.changeLanguage;T.getFixedT;const re=T.t;T.exists;T.setDefaultNamespace;T.hasLoadedNamespace;T.loadNamespaces;T.loadLanguages;var d0=t=>{const n={...{origin:"*",allowMethods:["GET","HEAD","PUT","POST","DELETE","PATCH"],allowHeaders:[],exposeHeaders:[]},...t},r=(i=>typeof i=="string"?i==="*"?()=>i:s=>i===s?s:null:typeof i=="function"?i:s=>i.includes(s)?s:null)(n.origin);return async function(s,o){var l,u;function c(p,m){s.res.headers.set(p,m)}const d=r(s.req.header("origin")||"",s);if(d&&c("Access-Control-Allow-Origin",d),n.origin!=="*"){const p=s.req.header("Vary");p?c("Vary",p):c("Vary","Origin")}if(n.credentials&&c("Access-Control-Allow-Credentials","true"),(l=n.exposeHeaders)!=null&&l.length&&c("Access-Control-Expose-Headers",n.exposeHeaders.join(",")),s.req.method==="OPTIONS"){n.maxAge!=null&&c("Access-Control-Max-Age",n.maxAge.toString()),(u=n.allowMethods)!=null&&u.length&&c("Access-Control-Allow-Methods",n.allowMethods.join(","));let p=n.allowHeaders;if(!(p!=null&&p.length)){const m=s.req.header("Access-Control-Request-Headers");m&&(p=m.split(/\s*,\s*/))}return p!=null&&p.length&&(c("Access-Control-Allow-Headers",p.join(",")),s.res.headers.append("Vary","Access-Control-Request-Headers")),s.res.headers.delete("Content-Length"),s.res.headers.delete("Content-Type"),new Response(null,{headers:s.res.headers,status:204,statusText:"No Content"})}await o()}};const un=a.z.object({start:a.z.number(),limit:a.z.number(),length:a.z.number()}),l0=a.z.object({created_at:a.z.string(),updated_at:a.z.string()}),u0=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()),f0=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:u0.optional()}),fo=a.z.object({email:a.z.string().optional(),username:a.z.string().optional(),phone_number: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()}),gs=fo.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()}),Id=a.z.object({...gs.shape,...l0.shape,user_id:a.z.string(),is_social:a.z.boolean(),email:a.z.string().optional(),login_count:a.z.number(),identities:a.z.array(f0).optional()}),At=Id,$1=fo.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()),x1="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let k1=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=x1[n[t]&63];return e};const p0=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()}),ms=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:p0.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(()=>k1()).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"})}),bn=a.z.object({created_at:a.z.string().transform(t=>t===null?"":t),updated_at:a.z.string().transform(t=>t===null?"":t),...ms.shape});var Ct=(t=>(t.TOKEN="token",t.TOKEN_ID_TOKEN="token id_token",t.CODE="code",t))(Ct||{}),Ft=(t=>(t.QUERY="query",t.FRAGMENT="fragment",t.FORM_POST="form_post",t.WEB_MESSAGE="web_message",t.SAML_POST="saml_post",t))(Ft||{}),po=(t=>(t.S256="S256",t.Plain="plain",t))(po||{});const Jr=a.z.object({client_id:a.z.string(),act_as:a.z.string().optional(),response_type:a.z.nativeEnum(Ct).optional(),response_mode:a.z.nativeEnum(Ft).optional(),redirect_uri:a.z.string().optional(),audience:a.z.string().optional(),organization: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(po).optional(),code_challenge:a.z.string().optional(),username:a.z.string().optional(),ui_locales:a.z.string().optional(),vendor_id:a.z.string().optional()}),qa=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()}),Nd=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().optional(),token_endpoint:a.z.string().optional(),userinfo_endpoint:a.z.string().optional(),jwks_uri:a.z.string().optional(),discovery_url:a.z.string().optional(),issuer:a.z.string().optional(),provider:a.z.string().optional(),from:a.z.string().optional(),twilio_sid:a.z.string().optional(),twilio_token:a.z.string().optional()}),_s=a.z.object({id:a.z.string().optional(),name:a.z.string(),strategy:a.z.string(),options:Nd.default({}),enabled_clients:a.z.array(a.z.string()).default([]).optional(),response_type:a.z.custom().optional(),response_mode:a.z.custom().optional()}),Qt=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(_s.shape),ys=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()}),tr=a.z.object({created_at:a.z.string().transform(t=>t===null?"":t),updated_at:a.z.string().transform(t=>t===null?"":t),...ys.shape,id:a.z.string()}),h0=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({...bn.shape,tenant:tr,connections:a.z.array(Qt)});const g0=a.z.enum(["password_reset","email_verification","otp","authorization_code","oauth2_state","ticket"]),m0=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:g0,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()}),S1=a.z.object({...m0.shape,created_at:a.z.string()}),Cd=a.z.object({domain:a.z.string(),custom_domain_id:a.z.string().optional(),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()}),_0=a.z.object({name:a.z.literal("txt"),record:a.z.string(),domain:a.z.string()}),Yt=a.z.object({...Cd.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({methods:a.z.array(_0)}).optional(),tls_policy:a.z.string().optional()}),A1=Yt.extend({tenant_id:a.z.string()}),ws=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()}),Yn=ws.extend({...l0.shape,hook_id:a.z.string()}),zd=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()}),y0=a.z.object({keys:a.z.array(zd)}),Ha=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())}),w0=a.z.object({csrf_token:a.z.string(),auth0Client:a.z.string().optional(),authParams:Jr,expires_at:a.z.string(),deleted_at:a.z.string().optional(),ip:a.z.string().optional(),useragent:a.z.string().optional(),session_id:a.z.string().optional(),authorization_url:a.z.string().optional()}).openapi({description:"This represents a login sesion"}),E1=a.z.object({...w0.shape,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 ge=(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))(ge||{});const I1=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"]),v0=a.z.object({name:a.z.string(),version:a.z.string(),env:a.z.object({node:a.z.string().optional()}).optional()}),vs=a.z.object({type:I1,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:v0.optional()}),b0=a.z.object({user_id:a.z.string(),password:a.z.string(),algorithm:a.z.enum(["bcrypt","argon2id"]).default("argon2id")}),N1=a.z.object({...b0.shape,created_at:a.z.string(),updated_at:a.z.string()}),$0=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")}),x0=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:$0.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")}),ho=a.z.object({created_at:a.z.string(),updated_at:a.z.string(),authenticated_at:a.z.string(),last_interaction_at:a.z.string(),...x0.shape}),Ka=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 Qn=(t=>(t.RefreshToken="refresh_token",t.AuthorizationCode="authorization_code",t.ClientCredential="client_credentials",t.Passwordless="passwordless",t.Password="password",t.OTP="http://auth0.com/oauth/grant-type/passwordless/otp",t))(Qn||{});const k0=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 S0=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()}),A0=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()}),yn=a.z.object({bold:a.z.boolean(),size:a.z.number()}),E0=a.z.object({body_text:yn,buttons_text:yn,font_url:a.z.string(),input_labels:yn,links:yn,links_style:a.z.enum(["normal"]),reference_text_size:a.z.number(),subtitle:yn,title:yn}),I0=a.z.object({background_color:a.z.string(),background_image_url:a.z.string(),page_layout:a.z.enum(["center"])}),N0=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"])}),C0=a.z.object({borders:S0,colors:A0,displayName:a.z.string(),fonts:E0,page_background:I0,widget:N0}),C1=C0.extend({themeId:a.z.string()}),Ji=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()}),Zi=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()}),Od=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:$0,resource_servers:a.z.array(a.z.object({audience:a.z.string(),scopes:a.z.string()})),rotating:a.z.boolean()}),z1=a.z.object({created_at:a.z.string(),...Od.shape}),O1=a.z.object({to:a.z.string(),message:a.z.string()}),P1=a.z.object({name:a.z.string(),options:a.z.object({})});function j1(t){const[e,n]=t.split("|");if(!e||!n)throw new Error(`Invalid user_id: ${t}`);return{connection:e,id:n}}const T1=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:qa}},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(qa.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});te(this,"res");te(this,"status");this.res=n==null?void 0:n.res,this.status=e}getResponse(){return this.res?new Response(this.res.body,{status:this.status,headers:this.res.headers}):new Response(this.message,{status:this.status})}},bs=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function z0(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function R1(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 B1(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 O0={exports:{}};const L1={},U1=Object.freeze(Object.defineProperty({__proto__:null,default:L1},Symbol.toStringTag,{value:"Module"})),M1=R1(U1);(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 R1=="function"&&t&&t.exports?t.exports=n():(e.dcodeIO=e.dcodeIO||{}).bcrypt=n()})(vs,function(){var e={},n=null;function r(z){if(t&&t.exports)try{return U1.randomBytes(z)}catch{}try{var C;return(self.crypto||self.msCrypto).getRandomValues(C=new Uint32Array(z)),Array.prototype.slice.call(C)}catch{}if(!n)throw Error("Neither WebCryptoAPI nor a crypto module is available. Use bcrypt.setRandomFallback to set an alternative");return n(z)}var i=!1;try{r(1),i=!0}catch{}n=null,e.setRandomFallback=function(z){n=z},e.genSaltSync=function(z,C){if(z=z||_,typeof z!="number")throw Error("Illegal arguments: "+typeof z+", "+typeof C);z<4?z=4:z>31&&(z=31);var A=[];return A.push("$2a$"),z<10&&A.push("0"),A.push(z.toString()),A.push("$"),A.push(p(r(h),h)),A.join("")},e.genSalt=function(z,C,A){if(typeof C=="function"&&(A=C,C=void 0),typeof z=="function"&&(A=z,z=void 0),typeof z>"u")z=_;else if(typeof z!="number")throw Error("illegal arguments: "+typeof z);function x($){o(function(){try{$(null,e.genSaltSync(z))}catch(P){$(P)}})}if(A){if(typeof A!="function")throw Error("Illegal callback: "+typeof A);x(A)}else return new Promise(function($,P){x(function(U,Q){if(U){P(U);return}$(Q)})})},e.hashSync=function(z,C){if(typeof C>"u"&&(C=_),typeof C=="number"&&(C=e.genSaltSync(C)),typeof z!="string"||typeof C!="string")throw Error("Illegal arguments: "+typeof z+", "+typeof C);return ze(z,C)},e.hash=function(z,C,A,x){function $(P){typeof z=="string"&&typeof C=="number"?e.genSalt(C,function(U,Q){ze(z,Q,P,x)}):typeof z=="string"&&typeof C=="string"?ze(z,C,P,x):o(P.bind(this,Error("Illegal arguments: "+typeof z+", "+typeof C)))}if(A){if(typeof A!="function")throw Error("Illegal callback: "+typeof A);$(A)}else return new Promise(function(P,U){$(function(Q,W){if(Q){U(Q);return}P(W)})})};function s(z,C){for(var A=0,x=0,$=0,P=z.length;$<P;++$)z.charCodeAt($)===C.charCodeAt($)?++A:++x;return A<0?!1:x===0}e.compareSync=function(z,C){if(typeof z!="string"||typeof C!="string")throw Error("Illegal arguments: "+typeof z+", "+typeof C);return C.length!==60?!1:s(e.hashSync(z,C.substr(0,C.length-31)),C)},e.compare=function(z,C,A,x){function $(P){if(typeof z!="string"||typeof C!="string"){o(P.bind(this,Error("Illegal arguments: "+typeof z+", "+typeof C)));return}if(C.length!==60){o(P.bind(this,null,!1));return}e.hash(z,C.substr(0,29),function(U,Q){U?P(U):P(null,s(Q,C))},x)}if(A){if(typeof A!="function")throw Error("Illegal callback: "+typeof A);$(A)}else return new Promise(function(P,U){$(function(Q,W){if(Q){U(Q);return}P(W)})})},e.getRounds=function(z){if(typeof z!="string")throw Error("Illegal arguments: "+typeof z);return parseInt(z.split("$")[2],10)},e.getSalt=function(z){if(typeof z!="string")throw Error("Illegal arguments: "+typeof z);if(z.length!==60)throw Error("Illegal hash length: "+z.length+" != 60");return z.substring(0,29)};var o=typeof process<"u"&&process&&typeof process.nextTick=="function"?typeof setImmediate=="function"?setImmediate:process.nextTick:setTimeout;function c(z){var C=[],A=0;return w.encodeUTF16toUTF8(function(){return A>=z.length?null:z.charCodeAt(A++)},function(x){C.push(x)}),C}var d="./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),l=[-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],u=String.fromCharCode;function p(z,C){var A=0,x=[],$,P;if(C<=0||C>z.length)throw Error("Illegal len: "+C);for(;A<C;){if($=z[A++]&255,x.push(d[$>>2&63]),$=($&3)<<4,A>=C){x.push(d[$&63]);break}if(P=z[A++]&255,$|=P>>4&15,x.push(d[$&63]),$=(P&15)<<2,A>=C){x.push(d[$&63]);break}P=z[A++]&255,$|=P>>6&3,x.push(d[$&63]),x.push(d[P&63])}return x.join("")}function m(z,C){var A=0,x=z.length,$=0,P=[],U,Q,W,se,ue,q;if(C<=0)throw Error("Illegal len: "+C);for(;A<x-1&&$<C&&(q=z.charCodeAt(A++),U=q<l.length?l[q]:-1,q=z.charCodeAt(A++),Q=q<l.length?l[q]:-1,!(U==-1||Q==-1||(ue=U<<2>>>0,ue|=(Q&48)>>4,P.push(u(ue)),++$>=C||A>=x)||(q=z.charCodeAt(A++),W=q<l.length?l[q]:-1,W==-1)||(ue=(Q&15)<<4>>>0,ue|=(W&60)>>2,P.push(u(ue)),++$>=C||A>=x)));)q=z.charCodeAt(A++),se=q<l.length?l[q]:-1,ue=(W&3)<<6>>>0,ue|=se,P.push(u(ue)),++$;var Oe=[];for(A=0;A<$;A++)Oe.push(P[A].charCodeAt(0));return Oe}var w=function(){var z={};return z.MAX_CODEPOINT=1114111,z.encodeUTF8=function(C,A){var x=null;for(typeof C=="number"&&(x=C,C=function(){return null});x!==null||(x=C())!==null;)x<128?A(x&127):x<2048?(A(x>>6&31|192),A(x&63|128)):x<65536?(A(x>>12&15|224),A(x>>6&63|128),A(x&63|128)):(A(x>>18&7|240),A(x>>12&63|128),A(x>>6&63|128),A(x&63|128)),x=null},z.decodeUTF8=function(C,A){for(var x,$,P,U,Q=function(W){W=W.slice(0,W.indexOf(null));var se=Error(W.toString());throw se.name="TruncatedError",se.bytes=W,se};(x=C())!==null;)if(!(x&128))A(x);else if((x&224)===192)($=C())===null&&Q([x,$]),A((x&31)<<6|$&63);else if((x&240)===224)(($=C())===null||(P=C())===null)&&Q([x,$,P]),A((x&15)<<12|($&63)<<6|P&63);else if((x&248)===240)(($=C())===null||(P=C())===null||(U=C())===null)&&Q([x,$,P,U]),A((x&7)<<18|($&63)<<12|(P&63)<<6|U&63);else throw RangeError("Illegal starting byte: "+x)},z.UTF16toUTF8=function(C,A){for(var x,$=null;(x=$!==null?$:C())!==null;){if(x>=55296&&x<=57343&&($=C())!==null&&$>=56320&&$<=57343){A((x-55296)*1024+$-56320+65536),$=null;continue}A(x)}$!==null&&A($)},z.UTF8toUTF16=function(C,A){var x=null;for(typeof C=="number"&&(x=C,C=function(){return null});x!==null||(x=C())!==null;)x<=65535?A(x):(x-=65536,A((x>>10)+55296),A(x%1024+56320)),x=null},z.encodeUTF16toUTF8=function(C,A){z.UTF16toUTF8(C,function(x){z.encodeUTF8(x,A)})},z.decodeUTF8toUTF16=function(C,A){z.decodeUTF8(C,function(x){z.UTF8toUTF16(x,A)})},z.calculateCodePoint=function(C){return C<128?1:C<2048?2:C<65536?3:4},z.calculateUTF8=function(C){for(var A,x=0;(A=C())!==null;)x+=z.calculateCodePoint(A);return x},z.calculateUTF16asUTF8=function(C){var A=0,x=0;return z.UTF16toUTF8(C,function($){++A,x+=z.calculateCodePoint($)}),[A,x]},z}();Date.now=Date.now||function(){return+new Date};var h=16,_=10,v=16,k=100,I=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731],O=[3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,1904987480,2182433518,2069144605,3260701109,2620446009,720527379,3318853667,677414384,3393288472,3101374703,2390351024,1614419982,1822297739,2954791486,3608508353,3174124327,2024746970,1432378464,3864339955,2857741204,1464375394,1676153920,1439316330,715854006,3033291828,289532110,2706671279,2087905683,3018724369,1668267050,732546397,1947742710,3462151702,2609353502,2950085171,1814351708,2050118529,680887927,999245976,1800124847,3300911131,1713906067,1641548236,4213287313,1216130144,1575780402,4018429277,3917837745,3693486850,3949271944,596196993,3549867205,258830323,2213823033,772490370,2760122372,1774776394,2652871518,566650946,4142492826,1728879713,2882767088,1783734482,3629395816,2517608232,2874225571,1861159788,326777828,3124490320,2130389656,2716951837,967770486,1724537150,2185432712,2364442137,1164943284,2105845187,998989502,3765401048,2244026483,1075463327,1455516326,1322494562,910128902,469688178,1117454909,936433444,3490320968,3675253459,1240580251,122909385,2157517691,634681816,4142456567,3825094682,3061402683,2540495037,79693498,3249098678,1084186820,1583128258,426386531,1761308591,1047286709,322548459,995290223,1845252383,2603652396,3431023940,2942221577,3202600964,3727903485,1712269319,422464435,3234572375,1170764815,3523960633,3117677531,1434042557,442511882,3600875718,1076654713,1738483198,4213154764,2393238008,3677496056,1014306527,4251020053,793779912,2902807211,842905082,4246964064,1395751752,1040244610,2656851899,3396308128,445077038,3742853595,3577915638,679411651,2892444358,2354009459,1767581616,3150600392,3791627101,3102740896,284835224,4246832056,1258075500,768725851,2589189241,3069724005,3532540348,1274779536,3789419226,2764799539,1660621633,3471099624,4011903706,913787905,3497959166,737222580,2514213453,2928710040,3937242737,1804850592,3499020752,2949064160,2386320175,2390070455,2415321851,4061277028,2290661394,2416832540,1336762016,1754252060,3520065937,3014181293,791618072,3188594551,3933548030,2332172193,3852520463,3043980520,413987798,3465142937,3030929376,4245938359,2093235073,3534596313,375366246,2157278981,2479649556,555357303,3870105701,2008414854,3344188149,4221384143,3956125452,2067696032,3594591187,2921233993,2428461,544322398,577241275,1471733935,610547355,4027169054,1432588573,1507829418,2025931657,3646575487,545086370,48609733,2200306550,1653985193,298326376,1316178497,3007786442,2064951626,458293330,2589141269,3591329599,3164325604,727753846,2179363840,146436021,1461446943,4069977195,705550613,3059967265,3887724982,4281599278,3313849956,1404054877,2845806497,146425753,1854211946,1266315497,3048417604,3681880366,3289982499,290971e4,1235738493,2632868024,2414719590,3970600049,1771706367,1449415276,3266420449,422970021,1963543593,2690192192,3826793022,1062508698,1531092325,1804592342,2583117782,2714934279,4024971509,1294809318,4028980673,1289560198,2221992742,1669523910,35572830,157838143,1052438473,1016535060,1802137761,1753167236,1386275462,3080475397,2857371447,1040679964,2145300060,2390574316,1461121720,2956646967,4031777805,4028374788,33600511,2920084762,1018524850,629373528,3691585981,3515945977,2091462646,2486323059,586499841,988145025,935516892,3367335476,2599673255,2839830854,265290510,3972581182,2759138881,3795373465,1005194799,847297441,406762289,1314163512,1332590856,1866599683,4127851711,750260880,613907577,1450815602,3165620655,3734664991,3650291728,3012275730,3704569646,1427272223,778793252,1343938022,2676280711,2052605720,1946737175,3164576444,3914038668,3967478842,3682934266,1661551462,3294938066,4011595847,840292616,3712170807,616741398,312560963,711312465,1351876610,322626781,1910503582,271666773,2175563734,1594956187,70604529,3617834859,1007753275,1495573769,4069517037,2549218298,2663038764,504708206,2263041392,3941167025,2249088522,1514023603,1998579484,1312622330,694541497,2582060303,2151582166,1382467621,776784248,2618340202,3323268794,2497899128,2784771155,503983604,4076293799,907881277,423175695,432175456,1378068232,4145222326,3954048622,3938656102,3820766613,2793130115,2977904593,26017576,3274890735,3194772133,1700274565,1756076034,4006520079,3677328699,720338349,1533947780,354530856,688349552,3973924725,1637815568,332179504,3949051286,53804574,2852348879,3044236432,1282449977,3583942155,3416972820,4006381244,1617046695,2628476075,3002303598,1686838959,431878346,2686675385,1700445008,1080580658,1009431731,832498133,3223435511,2605976345,2271191193,2516031870,1648197032,4164389018,2548247927,300782431,375919233,238389289,3353747414,2531188641,2019080857,1475708069,455242339,2609103871,448939670,3451063019,1395535956,2413381860,1841049896,1491858159,885456874,4264095073,4001119347,1565136089,3898914787,1108368660,540939232,1173283510,2745871338,3681308437,4207628240,3343053890,4016749493,1699691293,1103962373,3625875870,2256883143,3830138730,1031889488,3479347698,1535977030,4236805024,3251091107,2132092099,1774941330,1199868427,1452454533,157007616,2904115357,342012276,595725824,1480756522,206960106,497939518,591360097,863170706,2375253569,3596610801,1814182875,2094937945,3421402208,1082520231,3463918190,2785509508,435703966,3908032597,1641649973,2842273706,3305899714,1510255612,2148256476,2655287854,3276092548,4258621189,236887753,3681803219,274041037,1734335097,3815195456,3317970021,1899903192,1026095262,4050517792,356393447,2410691914,3873677099,3682840055,3913112168,2491498743,4132185628,2489919796,1091903735,1979897079,3170134830,3567386728,3557303409,857797738,1136121015,1342202287,507115054,2535736646,337727348,3213592640,1301675037,2528481711,1895095763,1721773893,3216771564,62756741,2142006736,835421444,2531993523,1442658625,3659876326,2882144922,676362277,1392781812,170690266,3921047035,1759253602,3611846912,1745797284,664899054,1329594018,3901205900,3045908486,2062866102,2865634940,3543621612,3464012697,1080764994,553557557,3656615353,3996768171,991055499,499776247,1265440854,648242737,3940784050,980351604,3713745714,1749149687,3396870395,4211799374,3640570775,1161844396,3125318951,1431517754,545492359,4268468663,3499529547,1437099964,2702547544,3433638243,2581715763,2787789398,1060185593,1593081372,2418618748,4260947970,69676912,2159744348,86519011,2512459080,3838209314,1220612927,3339683548,133810670,1090789135,1078426020,1569222167,845107691,3583754449,4072456591,1091646820,628848692,1613405280,3757631651,526609435,236106946,48312990,2942717905,3402727701,1797494240,859738849,992217954,4005476642,2243076622,3870952857,3732016268,765654824,3490871365,2511836413,1685915746,3888969200,1414112111,2273134842,3281911079,4080962846,172450625,2569994100,980381355,4109958455,2819808352,2716589560,2568741196,3681446669,3329971472,1835478071,660984891,3704678404,4045999559,3422617507,3040415634,1762651403,1719377915,3470491036,2693910283,3642056355,3138596744,1364962596,2073328063,1983633131,926494387,3423689081,2150032023,4096667949,1749200295,3328846651,309677260,2016342300,1779581495,3079819751,111262694,1274766160,443224088,298511866,1025883608,3806446537,1145181785,168956806,3641502830,3584813610,1689216846,3666258015,3200248200,1692713982,2646376535,4042768518,1618508792,1610833997,3523052358,4130873264,2001055236,3610705100,2202168115,4028541809,2961195399,1006657119,2006996926,3186142756,1430667929,3210227297,1314452623,4074634658,4101304120,2273951170,1399257539,3367210612,3027628629,1190975929,2062231137,2333990788,2221543033,2438960610,1181637006,548689776,2362791313,3372408396,3104550113,3145860560,296247880,1970579870,3078560182,3769228297,1714227617,3291629107,3898220290,166772364,1251581989,493813264,448347421,195405023,2709975567,677966185,3703036547,1463355134,2715995803,1338867538,1343315457,2802222074,2684532164,233230375,2599980071,2000651841,3277868038,1638401717,4028070440,3237316320,6314154,819756386,300326615,590932579,1405279636,3267499572,3150704214,2428286686,3959192993,3461946742,1862657033,1266418056,963775037,2089974820,2263052895,1917689273,448879540,3550394620,3981727096,150775221,3627908307,1303187396,508620638,2975983352,2726630617,1817252668,1876281319,1457606340,908771278,3720792119,3617206836,2455994898,1729034894,1080033504,976866871,3556439503,2881648439,1522871579,1555064734,1336096578,3548522304,2579274686,3574697629,3205460757,3593280638,3338716283,3079412587,564236357,2993598910,1781952180,1464380207,3163844217,3332601554,1699332808,1393555694,1183702653,3581086237,1288719814,691649499,2847557200,2895455976,3193889540,2717570544,1781354906,1676643554,2592534050,3230253752,1126444790,2770207658,2633158820,2210423226,2615765581,2414155088,3127139286,673620729,2805611233,1269405062,4015350505,3341807571,4149409754,1057255273,2012875353,2162469141,2276492801,2601117357,993977747,3918593370,2654263191,753973209,36408145,2530585658,25011837,3520020182,2088578344,530523599,2918365339,1524020338,1518925132,3760827505,3759777254,1202760957,3985898139,3906192525,674977740,4174734889,2031300136,2019492241,3983892565,4153806404,3822280332,352677332,2297720250,60907813,90501309,3286998549,1016092578,2535922412,2839152426,457141659,509813237,4120667899,652014361,1966332200,2975202805,55981186,2327461051,676427537,3255491064,2882294119,3433927263,1307055953,942726286,933058658,2468411793,3933900994,4215176142,1361170020,2001714738,2830558078,3274259782,1222529897,1679025792,2729314320,3714953764,1770335741,151462246,3013232138,1682292957,1483529935,471910574,1539241949,458788160,3436315007,1807016891,3718408830,978976581,1043663428,3165965781,1927990952,4200891579,2372276910,3208408903,3533431907,1412390302,2931980059,4132332400,1947078029,3881505623,4168226417,2941484381,1077988104,1320477388,886195818,18198404,3786409e3,2509781533,112762804,3463356488,1866414978,891333506,18488651,661792760,1628790961,3885187036,3141171499,876946877,2693282273,1372485963,791857591,2686433993,3759982718,3167212022,3472953795,2716379847,445679433,3561995674,3504004811,3574258232,54117162,3331405415,2381918588,3769707343,4154350007,1140177722,4074052095,668550556,3214352940,367459370,261225585,2610173221,4209349473,3468074219,3265815641,314222801,3066103646,3808782860,282218597,3406013506,3773591054,379116347,1285071038,846784868,2669647154,3771962079,3550491691,2305946142,453669953,1268987020,3317592352,3279303384,3744833421,2610507566,3859509063,266596637,3847019092,517658769,3462560207,3443424879,370717030,4247526661,2224018117,4143653529,4112773975,2788324899,2477274417,1456262402,2901442914,1517677493,1846949527,2295493580,3734397586,2176403920,1280348187,1908823572,3871786941,846861322,1172426758,3287448474,3383383037,1655181056,3139813346,901632758,1897031941,2986607138,3066810236,3447102507,1393639104,373351379,950779232,625454576,3124240540,4148612726,2007998917,544563296,2244738638,2330496472,2058025392,1291430526,424198748,50039436,29584100,3605783033,2429876329,2791104160,1057563949,3255363231,3075367218,3463963227,1469046755,985887462],L=[1332899944,1700884034,1701343084,1684370003,1668446532,1869963892];function Y(z,C,A,x){var $,P=z[C],U=z[C+1];return P^=A[0],$=x[P>>>24],$+=x[256|P>>16&255],$^=x[512|P>>8&255],$+=x[768|P&255],U^=$^A[1],$=x[U>>>24],$+=x[256|U>>16&255],$^=x[512|U>>8&255],$+=x[768|U&255],P^=$^A[2],$=x[P>>>24],$+=x[256|P>>16&255],$^=x[512|P>>8&255],$+=x[768|P&255],U^=$^A[3],$=x[U>>>24],$+=x[256|U>>16&255],$^=x[512|U>>8&255],$+=x[768|U&255],P^=$^A[4],$=x[P>>>24],$+=x[256|P>>16&255],$^=x[512|P>>8&255],$+=x[768|P&255],U^=$^A[5],$=x[U>>>24],$+=x[256|U>>16&255],$^=x[512|U>>8&255],$+=x[768|U&255],P^=$^A[6],$=x[P>>>24],$+=x[256|P>>16&255],$^=x[512|P>>8&255],$+=x[768|P&255],U^=$^A[7],$=x[U>>>24],$+=x[256|U>>16&255],$^=x[512|U>>8&255],$+=x[768|U&255],P^=$^A[8],$=x[P>>>24],$+=x[256|P>>16&255],$^=x[512|P>>8&255],$+=x[768|P&255],U^=$^A[9],$=x[U>>>24],$+=x[256|U>>16&255],$^=x[512|U>>8&255],$+=x[768|U&255],P^=$^A[10],$=x[P>>>24],$+=x[256|P>>16&255],$^=x[512|P>>8&255],$+=x[768|P&255],U^=$^A[11],$=x[U>>>24],$+=x[256|U>>16&255],$^=x[512|U>>8&255],$+=x[768|U&255],P^=$^A[12],$=x[P>>>24],$+=x[256|P>>16&255],$^=x[512|P>>8&255],$+=x[768|P&255],U^=$^A[13],$=x[U>>>24],$+=x[256|U>>16&255],$^=x[512|U>>8&255],$+=x[768|U&255],P^=$^A[14],$=x[P>>>24],$+=x[256|P>>16&255],$^=x[512|P>>8&255],$+=x[768|P&255],U^=$^A[15],$=x[U>>>24],$+=x[256|U>>16&255],$^=x[512|U>>8&255],$+=x[768|U&255],P^=$^A[16],z[C]=U^A[v+1],z[C+1]=P,z}function oe(z,C){for(var A=0,x=0;A<4;++A)x=x<<8|z[C]&255,C=(C+1)%z.length;return{key:x,offp:C}}function ae(z,C,A){for(var x=0,$=[0,0],P=C.length,U=A.length,Q,W=0;W<P;W++)Q=oe(z,x),x=Q.offp,C[W]=C[W]^Q.key;for(W=0;W<P;W+=2)$=Y($,0,C,A),C[W]=$[0],C[W+1]=$[1];for(W=0;W<U;W+=2)$=Y($,0,C,A),A[W]=$[0],A[W+1]=$[1]}function ke(z,C,A,x){for(var $=0,P=[0,0],U=A.length,Q=x.length,W,se=0;se<U;se++)W=oe(C,$),$=W.offp,A[se]=A[se]^W.key;for($=0,se=0;se<U;se+=2)W=oe(z,$),$=W.offp,P[0]^=W.key,W=oe(z,$),$=W.offp,P[1]^=W.key,P=Y(P,0,A,x),A[se]=P[0],A[se+1]=P[1];for(se=0;se<Q;se+=2)W=oe(z,$),$=W.offp,P[0]^=W.key,W=oe(z,$),$=W.offp,P[1]^=W.key,P=Y(P,0,A,x),x[se]=P[0],x[se+1]=P[1]}function Ee(z,C,A,x,$){var P=L.slice(),U=P.length,Q;if(A<4||A>31)if(Q=Error("Illegal number of rounds (4-31): "+A),x){o(x.bind(this,Q));return}else throw Q;if(C.length!==h)if(Q=Error("Illegal salt length: "+C.length+" != "+h),x){o(x.bind(this,Q));return}else throw Q;A=1<<A>>>0;var W,se,ue=0,q;Int32Array?(W=new Int32Array(I),se=new Int32Array(O)):(W=I.slice(),se=O.slice()),ke(C,z,W,se);function Oe(){if($&&$(ue/A),ue<A)for(var he=Date.now();ue<A&&(ue=ue+1,ae(z,W,se),ae(C,W,se),!(Date.now()-he>k)););else{for(ue=0;ue<64;ue++)for(q=0;q<U>>1;q++)Y(P,q<<1,W,se);var Se=[];for(ue=0;ue<U;ue++)Se.push((P[ue]>>24&255)>>>0),Se.push((P[ue]>>16&255)>>>0),Se.push((P[ue]>>8&255)>>>0),Se.push((P[ue]&255)>>>0);if(x){x(null,Se);return}else return Se}x&&o(Oe)}if(typeof x<"u")Oe();else for(var _n;;)if(typeof(_n=Oe())<"u")return _n||[]}function ze(z,C,A,x){var $;if(typeof z!="string"||typeof C!="string")if($=Error("Invalid string / salt: Not a string"),A){o(A.bind(this,$));return}else throw $;var P,U;if(C.charAt(0)!=="$"||C.charAt(1)!=="2")if($=Error("Invalid salt version: "+C.substring(0,2)),A){o(A.bind(this,$));return}else throw $;if(C.charAt(2)==="$")P="\0",U=3;else{if(P=C.charAt(2),P!=="a"&&P!=="b"&&P!=="y"||C.charAt(3)!=="$")if($=Error("Invalid salt revision: "+C.substring(2,4)),A){o(A.bind(this,$));return}else throw $;U=4}if(C.charAt(U+2)>"$")if($=Error("Missing salt rounds"),A){o(A.bind(this,$));return}else throw $;var Q=parseInt(C.substring(U,U+1),10)*10,W=parseInt(C.substring(U+1,U+2),10),se=Q+W,ue=C.substring(U+3,U+25);z+=P>="a"?"\0":"";var q=c(z),Oe=m(ue,h);function _n(he){var Se=[];return Se.push("$2"),P>="a"&&Se.push(P),Se.push("$"),se<10&&Se.push("0"),Se.push(se.toString()),Se.push("$"),Se.push(p(Oe,Oe.length)),Se.push(p(he,L.length*4-1)),Se.join("")}if(typeof A>"u")return _n(Ee(q,Oe,se));Ee(q,Oe,se,function(he,Se){he?A(he,null):A(null,_n(Se))},x)}return e.encodeBase64=p,e.decodeBase64=m,e})})(O0);var M1=O0.exports;const gi=z0(M1),F1="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let V1=t=>crypto.getRandomValues(new Uint8Array(t)),D1=(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),d=i;for(;d--;)if(o+=t[c[d]&r]||"",o.length===s)return o}}},q1=(t,e=21)=>D1(t,e,V1),xe=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=F1[n[t]&63];return e};const H1=24;function ho(){return q1("0123456789abcdef",H1)()}function vu(t){if(!t.includes("|"))return console.error("Invalid user_id format"),t;const[,e]=t.split("|");return e}function K1(t){return async(e,n)=>{if(!n.email||!n.email_verified)return t.users.create(e,n);const r=await wo({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 we(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 Pd{constructor(e,n){te(this,"value");te(this,"unit");this.value=e,this.unit=n}milliseconds(){return this.unit==="ms"?this.value:this.unit==="s"?this.value*1e3:this.unit==="m"?this.value*1e3*60:this.unit==="h"?this.value*1e3*60*60:this.unit==="d"?this.value*1e3*60*60*24:this.value*1e3*60*60*24*7}seconds(){return this.milliseconds()/1e3}transform(e){return new Pd(Math.round(this.milliseconds()*e),"ms")}}class G1{constructor(e){te(this,"hash");this.hash=e}async verify(e,n,r){const i=await crypto.subtle.importKey("spki",e,{name:"RSASSA-PKCS1-v1_5",hash:this.hash},!1,["verify"]);return await crypto.subtle.verify("RSASSA-PKCS1-v1_5",i,n,r)}async sign(e,n){const r=await crypto.subtle.importKey("pkcs8",e,{name:"RSASSA-PKCS1-v1_5",hash:this.hash},!1,["sign"]);return await crypto.subtle.sign("RSASSA-PKCS1-v1_5",r,n)}async generateKeyPair(e){const n=await crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",hash:this.hash,modulusLength:e??2048,publicExponent:new Uint8Array([1,0,1])},!0,["sign"]),r=await crypto.subtle.exportKey("pkcs8",n.privateKey),i=await crypto.subtle.exportKey("spki",n.publicKey);return{privateKey:r,publicKey:i}}}async function P0(t){return await crypto.subtle.digest("SHA-256",t)}const bu="0123456789abcdef";function Ga(t){const e=new Uint8Array(t);let n="";for(let r=0;r<e.length;r++){const i=e[r]>>4;n+=bu[i];const s=e[r]&15;n+=bu[s]}return n}class j0{constructor(e,n){te(this,"alphabet");te(this,"padding");te(this,"decodeMap",new Map);if(e.length!==32)throw new Error("Invalid alphabet");if(this.alphabet=e,this.padding=(n==null?void 0:n.padding)??"=",this.alphabet.includes(this.padding)||this.padding.length!==1)throw new Error("Invalid padding");for(let r=0;r<e.length;r++)this.decodeMap.set(e[r],r)}encode(e,n){let r="",i=0,s=0;for(let c=0;c<e.length;c++)for(i=i<<8|e[c],s+=8;s>=5;)s-=5,r+=this.alphabet[i>>s&31];if(s>0&&(r+=this.alphabet[i<<5-s&31]),(n==null?void 0:n.includePadding)??!0){const c=(8-r.length%8)%8;for(let d=0;d<c;d++)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 d=[];for(let u=0;u<8;u++){const p=e[o*8+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 m=this.decodeMap.get(p)??null;if(m===null)throw new Error(`Invalid character: ${p}`);d.push(m)}if(c===8||c===7||c===5||c===2)throw new Error("Invalid padding");const l=(d[0]<<3)+(d[1]>>2);if(s.push(l),c<6){const u=((d[1]&3)<<6)+(d[2]<<1)+(d[3]>>4);s.push(u)}if(c<4){const u=((d[3]&255)<<4)+(d[4]>>1);s.push(u)}if(c<3){const u=((d[4]&1)<<7)+(d[5]<<2)+(d[6]>>3);s.push(u)}if(c<1){const u=((d[6]&7)<<5)+d[7];s.push(u)}}return Uint8Array.from(s)}}new j0("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567");new j0("0123456789ABCDEFGHIJKLMNOPQRSTUV");class T0{constructor(e,n){te(this,"alphabet");te(this,"padding");te(this,"decodeMap",new Map);if(e.length!==64)throw new Error("Invalid alphabet");if(this.alphabet=e,this.padding=(n==null?void 0:n.padding)??"=",this.alphabet.includes(this.padding)||this.padding.length!==1)throw new Error("Invalid padding");for(let r=0;r<e.length;r++)this.decodeMap.set(e[r],r)}encode(e,n){let r="",i=0,s=0;for(let c=0;c<e.length;c++)for(i=i<<8|e[c],s+=8;s>=6;)s+=-6,r+=this.alphabet[i>>s&63];if(s>0&&(r+=this.alphabet[i<<6-s&63]),(n==null?void 0:n.includePadding)??!0){const c=(4-r.length%4)%4;for(let d=0;d<c;d++)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,d=0;for(let l=0;l<4;l++){const u=e[o*4+l];if(u==="="){if(o+1!==i)throw new Error(`Invalid character: ${u}`);c+=1;continue}if(u===void 0){if(r)throw new Error("Invalid data");c+=1;continue}const p=this.decodeMap.get(u)??null;if(p===null)throw new Error(`Invalid character: ${u}`);d+=p<<6*(3-l)}s.push(d>>16&255),c<2&&s.push(d>>8&255),c<1&&s.push(d&255)}return Uint8Array.from(s)}}const W1=new T0("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Sn=new T0("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_");async function $u(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=Sn.encode(o.encode(JSON.stringify(i)),{includePadding:!1}),d=Sn.encode(o.encode(JSON.stringify(s)),{includePadding:!1}),l=o.encode([c,d].join(".")),u=await Z1(t).sign(e,l),p=Sn.encode(new Uint8Array(u),{includePadding:!1});return[c,d,p].join(".")}function J1(t){const e=t.split(".");return e.length!==3?null:e}function jd(t){const e=J1(t);if(!e)return null;const n=new TextDecoder,r=Sn.decode(e[0],{strict:!1}),i=Sn.decode(e[1],{strict:!1}),s=JSON.parse(n.decode(r));if(typeof s!="object"||s===null||!("alg"in s)||!X1(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 d of o.aud)if(typeof d!="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 Z1(t){return new G1(Y1[t])}function X1(t){return typeof t!="string"?!1:["HS256","HS384","HS512","RS256","RS384","RS512","ES256","ES384","ES512","PS256","PS384","PS512"].includes(t)}const Y1={RS256:"SHA-256",RS384:"SHA-384",RS512:"SHA-512"};function Q1(){const t=new Uint8Array(32);return crypto.getRandomValues(t),Sn.encode(t,{includePadding:!1})}function e_(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 t_(t,e){if(e==="plain")return t;const n=new TextEncoder().encode(t),r=await P0(n);return Sn.encode(new Uint8Array(r),{includePadding:!1})}const Vi=60*5,go=30*24*60*60,or=24*60*60,n_="auth-token",Wa=30*60*1e3,r_=7*24*60*60*1e3,i_=5*60,s_=5*60,o_=30*60*1e3,a_=30*60*1e3,c_=24*60*60*1e3;function R0(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 d_(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 Td(t){return`${t}-${n_}`}function B0(t){if(!t)return;if(t==="localhost"||/^(\d{1,3}\.){3}\d{1,3}$/.test(t))return t;const e=t.split(".");return e.length>2?`.${e.slice(-2).join(".")}`:`.${t}`}function bs(t,e){return e?d_(e).get(Td(t)):void 0}function l_(t,e){return R0(Td(t),"",{path:"/",httpOnly:!0,secure:!0,maxAge:0,sameSite:"none",domain:e?B0(e):void 0})}function L0(t,e,n){return R0(Td(t),e,{path:"/",httpOnly:!0,secure:!0,maxAge:go,sameSite:"none",domain:n?B0(n):void 0})}var Rd={},mo={};(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,d){const l=[];let u=d.exec(c);for(;u;){const p=[];p.startIndex=d.lastIndex-u[0].length;const m=u.length;for(let w=0;w<m;w++)p.push(u[w]);l.push(p),u=d.exec(c)}return l},o=function(c){const d=i.exec(c);return!(d===null||typeof d>"u")};t.isExist=function(c){return typeof c<"u"},t.isEmptyObject=function(c){return Object.keys(c).length===0},t.merge=function(c,d,l){if(d){const u=Object.keys(d),p=u.length;for(let m=0;m<p;m++)l==="strict"?c[u[m]]=[d[u[m]]]:c[u[m]]=d[u[m]]}},t.getValue=function(c){return t.isExist(c)?c:""},t.isName=o,t.getAllMatches=s,t.nameRegexp=r})(mo);const Bd=mo,u_={allowBooleanAttributes:!1,unpairedTags:[]};Rd.validate=function(t,e){e=Object.assign({},u_,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=ku(t,s),s.err)return s}else if(t[s]==="<"){let o=s;if(s++,t[s]==="!"){s=Su(t,s);continue}else{let c=!1;t[s]==="/"&&(c=!0,s++);let d="";for(;s<t.length&&t[s]!==">"&&t[s]!==" "&&t[s]!==" "&&t[s]!==`
6
- `&&t[s]!=="\r";s++)d+=t[s];if(d=d.trim(),d[d.length-1]==="/"&&(d=d.substring(0,d.length-1),s--),!w_(d)){let p;return d.trim().length===0?p="Invalid space after '<'.":p="Tag '"+d+"' is an invalid name.",be("InvalidTag",p,Ve(t,s))}const l=h_(t,s);if(l===!1)return be("InvalidAttr","Attributes for '"+d+"' have open quote.",Ve(t,s));let u=l.value;if(s=l.index,u[u.length-1]==="/"){const p=s-u.length;u=u.substring(0,u.length-1);const m=Au(u,e);if(m===!0)r=!0;else return be(m.err.code,m.err.msg,Ve(t,p+m.err.line))}else if(c)if(l.tagClosed){if(u.trim().length>0)return be("InvalidTag","Closing tag '"+d+"' can't have attributes or invalid starting.",Ve(t,o));if(n.length===0)return be("InvalidTag","Closing tag '"+d+"' has not been opened.",Ve(t,o));{const p=n.pop();if(d!==p.tagName){let m=Ve(t,p.tagStartPos);return be("InvalidTag","Expected closing tag '"+p.tagName+"' (opened in line "+m.line+", col "+m.col+") instead of closing tag '"+d+"'.",Ve(t,o))}n.length==0&&(i=!0)}}else return be("InvalidTag","Closing tag '"+d+"' doesn't have proper closing.",Ve(t,s));else{const p=Au(u,e);if(p!==!0)return be(p.err.code,p.err.msg,Ve(t,s-u.length+p.err.line));if(i===!0)return be("InvalidXml","Multiple possible root nodes found.",Ve(t,s));e.unpairedTags.indexOf(d)!==-1||n.push({tagName:d,tagStartPos:o}),r=!0}for(s++;s<t.length;s++)if(t[s]==="<")if(t[s+1]==="!"){s++,s=Su(t,s);continue}else if(t[s+1]==="?"){if(s=ku(t,++s),s.err)return s}else break;else if(t[s]==="&"){const p=__(t,s);if(p==-1)return be("InvalidChar","char '&' is not expected.",Ve(t,s));s=p}else if(i===!0&&!xu(t[s]))return be("InvalidXml","Extra text at the end",Ve(t,s));t[s]==="<"&&s--}}else{if(xu(t[s]))continue;return be("InvalidChar","char '"+t[s]+"' is not expected.",Ve(t,s))}if(r){if(n.length==1)return be("InvalidTag","Unclosed tag '"+n[0].tagName+"'.",Ve(t,n[0].tagStartPos));if(n.length>0)return be("InvalidXml","Invalid '"+JSON.stringify(n.map(s=>s.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1})}else return be("InvalidXml","Start tag expected.",1);return!0};function xu(t){return t===" "||t===" "||t===`
7
- `||t==="\r"}function ku(t,e){const n=e;for(;e<t.length;e++)if(t[e]=="?"||t[e]==" "){const r=t.substr(n,e-n);if(e>5&&r==="xml")return be("InvalidXml","XML declaration allowed only at the start of the document.",Ve(t,e));if(t[e]=="?"&&t[e+1]==">"){e++;break}else continue}return e}function Su(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 f_='"',p_="'";function h_(t,e){let n="",r="",i=!1;for(;e<t.length;e++){if(t[e]===f_||t[e]===p_)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 g_=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function Au(t,e){const n=Bd.getAllMatches(t,g_),r={};for(let i=0;i<n.length;i++){if(n[i][1].length===0)return be("InvalidAttr","Attribute '"+n[i][2]+"' has no space in starting.",Tr(n[i]));if(n[i][3]!==void 0&&n[i][4]===void 0)return be("InvalidAttr","Attribute '"+n[i][2]+"' is without value.",Tr(n[i]));if(n[i][3]===void 0&&!e.allowBooleanAttributes)return be("InvalidAttr","boolean attribute '"+n[i][2]+"' is not allowed.",Tr(n[i]));const s=n[i][2];if(!y_(s))return be("InvalidAttr","Attribute '"+s+"' is an invalid name.",Tr(n[i]));if(!r.hasOwnProperty(s))r[s]=1;else return be("InvalidAttr","Attribute '"+s+"' is repeated.",Tr(n[i]))}return!0}function m_(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,e){if(e++,t[e]===";")return-1;if(t[e]==="#")return e++,m_(t,e);let n=0;for(;e<t.length;e++,n++)if(!(t[e].match(/\w/)&&n<20)){if(t[e]===";")break;return-1}return e}function be(t,e,n){return{err:{code:t,msg:e,line:n.line||n,col:n.col}}}function y_(t){return Bd.isName(t)}function w_(t){return Bd.isName(t)}function Ve(t,e){const n=t.substring(0,e).split(/\r?\n/);return{line:n.length,col:n[n.length-1].length+1}}function Tr(t){return t.startIndex+t[1].length}var Ld={};const U0={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}},v_=function(t){return Object.assign({},U0,t)};Ld.buildOptions=v_;Ld.defaultOptions=U0;class b_{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 $_=b_;const x_=mo;function k_(t,e){const n={};if(t[e+3]==="O"&&t[e+4]==="C"&&t[e+5]==="T"&&t[e+6]==="Y"&&t[e+7]==="P"&&t[e+8]==="E"){e=e+9;let r=1,i=!1,s=!1,o="";for(;e<t.length;e++)if(t[e]==="<"&&!s){if(i&&E_(t,e)){e+=7;let c,d;[c,d,e]=S_(t,e+1),d.indexOf("&")===-1&&(n[z_(c)]={regx:RegExp(`&${c};`,"g"),val:d})}else if(i&&I_(t,e))e+=8;else if(i&&N_(t,e))e+=8;else if(i&&C_(t,e))e+=9;else if(A_)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 S_(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 A_(t,e){return t[e+1]==="!"&&t[e+2]==="-"&&t[e+3]==="-"}function E_(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 I_(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 N_(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 C_(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 z_(t){if(x_.isName(t))return t;throw new Error(`Invalid entity name ${t}`)}var O_=k_;const P_=/^[-+]?0x[a-fA-F0-9]+$/,j_=/^([\-\+])?(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 T_={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};function R_(t,e={}){if(e=Object.assign({},T_,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&&P_.test(n))return Number.parseInt(n,16);{const r=j_.exec(n);if(r){const i=r[1],s=r[2];let o=B_(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 d=Number(n),l=""+d;return l.search(/[eE]/)!==-1||c?e.eNotation?d:t:n.indexOf(".")!==-1?l==="0"&&o===""||l===o||i&&l==="-"+o?d:t:s?o===l||i+o===l?d:t:n===l||n===i+l?d:t}}else return t}}function B_(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 L_=R_;function U_(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 M0=U_;const F0=mo,Rr=$_,M_=O_,F_=L_,V_=M0;let D_=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=q_,this.parseXml=J_,this.parseTextData=H_,this.resolveNameSpace=K_,this.buildAttributesMap=W_,this.isItStopNode=Q_,this.replaceEntitiesValue=X_,this.readStopNodeData=ty,this.saveTextToParentTag=Y_,this.addChild=Z_,this.ignoreAttributesFn=V_(this.options.ignoreAttributes)}};function q_(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 H_(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?Za(t,this.options.parseTagValue,this.options.numberParseOptions):t.trim()===t?Za(t,this.options.parseTagValue,this.options.numberParseOptions):t}}function K_(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 G_=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function W_(t,e,n){if(this.options.ignoreAttributes!==!0&&typeof t=="string"){const r=F0.getAllMatches(t,G_),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 d=r[o][4],l=this.options.attributeNamePrefix+c;if(c.length)if(this.options.transformAttributeName&&(l=this.options.transformAttributeName(l)),l==="__proto__"&&(l="#__proto__"),d!==void 0){this.options.trimValues&&(d=d.trim()),d=this.replaceEntitiesValue(d);const u=this.options.attributeValueProcessor(c,d,e);u==null?s[l]=d:typeof u!=typeof d||u!==d?s[l]=u:s[l]=Za(d,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(s[l]=!0)}if(!Object.keys(s).length)return;if(this.options.attributesGroupName){const o={};return o[this.options.attributesGroupName]=s,o}return s}}const J_=function(t){t=t.replace(/\r\n?/g,`
8
- `);const e=new Rr("!xml");let n=e,r="",i="";for(let s=0;s<t.length;s++)if(t[s]==="<")if(t[s+1]==="/"){const c=$n(t,">",s,"Closing Tag is not closed.");let d=t.substring(s+2,c).trim();if(this.options.removeNSPrefix){const p=d.indexOf(":");p!==-1&&(d=d.substr(p+1))}this.options.transformTagName&&(d=this.options.transformTagName(d)),n&&(r=this.saveTextToParentTag(r,n,i));const l=i.substring(i.lastIndexOf(".")+1);if(d&&this.options.unpairedTags.indexOf(d)!==-1)throw new Error(`Unpaired tag can not be used as closing tag: </${d}>`);let u=0;l&&this.options.unpairedTags.indexOf(l)!==-1?(u=i.lastIndexOf(".",i.lastIndexOf(".")-1),this.tagsNodeStack.pop()):u=i.lastIndexOf("."),i=i.substring(0,u),n=this.tagsNodeStack.pop(),r="",s=c}else if(t[s+1]==="?"){let c=Ja(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 d=new Rr(c.tagName);d.add(this.options.textNodeName,""),c.tagName!==c.tagExp&&c.attrExpPresent&&(d[":@"]=this.buildAttributesMap(c.tagExp,i,c.tagName)),this.addChild(n,d,i)}s=c.closeIndex+1}else if(t.substr(s+1,3)==="!--"){const c=$n(t,"-->",s+4,"Comment is not closed.");if(this.options.commentPropName){const d=t.substring(s+4,c-2);r=this.saveTextToParentTag(r,n,i),n.add(this.options.commentPropName,[{[this.options.textNodeName]:d}])}s=c}else if(t.substr(s+1,2)==="!D"){const c=M_(t,s);this.docTypeEntities=c.entities,s=c.i}else if(t.substr(s+1,2)==="!["){const c=$n(t,"]]>",s,"CDATA is not closed.")-2,d=t.substring(s+9,c);r=this.saveTextToParentTag(r,n,i);let l=this.parseTextData(d,n.tagname,i,!0,!1,!0,!0);l==null&&(l=""),this.options.cdataPropName?n.add(this.options.cdataPropName,[{[this.options.textNodeName]:d}]):n.add(this.options.textNodeName,l),s=c+2}else{let c=Ja(t,s,this.options.removeNSPrefix),d=c.tagName;const l=c.rawTagName;let u=c.tagExp,p=c.attrExpPresent,m=c.closeIndex;this.options.transformTagName&&(d=this.options.transformTagName(d)),n&&r&&n.tagname!=="!xml"&&(r=this.saveTextToParentTag(r,n,i,!1));const w=n;if(w&&this.options.unpairedTags.indexOf(w.tagname)!==-1&&(n=this.tagsNodeStack.pop(),i=i.substring(0,i.lastIndexOf("."))),d!==e.tagname&&(i+=i?"."+d:d),this.isItStopNode(this.options.stopNodes,i,d)){let h="";if(u.length>0&&u.lastIndexOf("/")===u.length-1)d[d.length-1]==="/"?(d=d.substr(0,d.length-1),i=i.substr(0,i.length-1),u=d):u=u.substr(0,u.length-1),s=c.closeIndex;else if(this.options.unpairedTags.indexOf(d)!==-1)s=c.closeIndex;else{const v=this.readStopNodeData(t,l,m+1);if(!v)throw new Error(`Unexpected end of ${l}`);s=v.i,h=v.tagContent}const _=new Rr(d);d!==u&&p&&(_[":@"]=this.buildAttributesMap(u,i,d)),h&&(h=this.parseTextData(h,d,i,!0,p,!0,!0)),i=i.substr(0,i.lastIndexOf(".")),_.add(this.options.textNodeName,h),this.addChild(n,_,i)}else{if(u.length>0&&u.lastIndexOf("/")===u.length-1){d[d.length-1]==="/"?(d=d.substr(0,d.length-1),i=i.substr(0,i.length-1),u=d):u=u.substr(0,u.length-1),this.options.transformTagName&&(d=this.options.transformTagName(d));const h=new Rr(d);d!==u&&p&&(h[":@"]=this.buildAttributesMap(u,i,d)),this.addChild(n,h,i),i=i.substr(0,i.lastIndexOf("."))}else{const h=new Rr(d);this.tagsNodeStack.push(n),d!==u&&p&&(h[":@"]=this.buildAttributesMap(u,i,d)),this.addChild(n,h,i),n=h}r="",s=m}}else r+=t[s];return e.child};function Z_(t,e,n){const r=this.options.updateTag(e.tagname,n,e[":@"]);r===!1||(typeof r=="string"&&(e.tagname=r),t.addChild(e))}const X_=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 Y_(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 Q_(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 ey(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 $n(t,e,n,r){const i=t.indexOf(e,n);if(i===-1)throw new Error(r);return i+e.length-1}function Ja(t,e,n,r=">"){const i=ey(t,e+1,r);if(!i)return;let s=i.data;const o=i.index,c=s.search(/\s/);let d=s,l=!0;c!==-1&&(d=s.substring(0,c),s=s.substring(c+1).trimStart());const u=d;if(n){const p=d.indexOf(":");p!==-1&&(d=d.substr(p+1),l=d!==i.data.substr(p+1))}return{tagName:d,tagExp:s,closeIndex:o,attrExpPresent:l,rawTagName:u}}function ty(t,e,n){const r=n;let i=1;for(;n<t.length;n++)if(t[n]==="<")if(t[n+1]==="/"){const s=$n(t,">",n,`${e} is not closed`);if(t.substring(n+2,s).trim()===e&&(i--,i===0))return{tagContent:t.substring(r,n),i:s};n=s}else if(t[n+1]==="?")n=$n(t,"?>",n+1,"StopNode is not closed.");else if(t.substr(n+1,3)==="!--")n=$n(t,"-->",n+3,"StopNode is not closed.");else if(t.substr(n+1,2)==="![")n=$n(t,"]]>",n,"StopNode is not closed.")-2;else{const s=Ja(t,n,">");s&&((s&&s.tagName)===e&&s.tagExp[s.tagExp.length-1]!=="/"&&i++,n=s.closeIndex)}}function Za(t,e,n){if(e&&typeof t=="string"){const r=t.trim();return r==="true"?!0:r==="false"?!1:F_(t,n)}else return F0.isExist(t)?t:""}var ny=D_,V0={};function ry(t,e){return D0(t,e)}function D0(t,e,n){let r;const i={};for(let s=0;s<t.length;s++){const o=t[s],c=iy(o);let d="";if(n===void 0?d=c:d=n+"."+c,c===e.textNodeName)r===void 0?r=o[c]:r+=""+o[c];else{if(c===void 0)continue;if(o[c]){let l=D0(o[c],e,d);const u=oy(l,e);o[":@"]?sy(l,o[":@"],d,e):Object.keys(l).length===1&&l[e.textNodeName]!==void 0&&!e.alwaysCreateTextNode?l=l[e.textNodeName]:Object.keys(l).length===0&&(e.alwaysCreateTextNode?l[e.textNodeName]="":l=""),i[c]!==void 0&&i.hasOwnProperty(c)?(Array.isArray(i[c])||(i[c]=[i[c]]),i[c].push(l)):e.isArray(c,d,u)?i[c]=[l]:i[c]=l}}}return typeof r=="string"?r.length>0&&(i[e.textNodeName]=r):r!==void 0&&(i[e.textNodeName]=r),i}function iy(t){const e=Object.keys(t);for(let n=0;n<e.length;n++){const r=e[n];if(r!==":@")return r}}function sy(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 oy(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))}V0.prettify=ry;const{buildOptions:ay}=Ld,cy=ny,{prettify:dy}=V0,ly=Rd;let uy=class{constructor(e){this.externalEntities={},this.options=ay(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=ly.validate(e,n);if(s!==!0)throw Error(`${s.err.msg}:${s.err.line}:${s.err.col}`)}const r=new cy(this.options);r.addExternalEntities(this.externalEntities);const i=r.parseXml(e);return this.options.preserveOrder||i===void 0?i:dy(i,this.options)}addEntity(e,n){if(n.indexOf("&")!==-1)throw new Error("Entity value can't have '&'");if(e.indexOf("&")!==-1||e.indexOf(";")!==-1)throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");if(n==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[e]=n}};var fy=uy;const py=`
9
- `;function hy(t,e){let n="";return e.format&&e.indentBy.length>0&&(n=py),q0(t,e,"",n)}function q0(t,e,n,r){let i="",s=!1;for(let o=0;o<t.length;o++){const c=t[o],d=gy(c);if(d===void 0)continue;let l="";if(n.length===0?l=d:l=`${n}.${d}`,d===e.textNodeName){let h=c[d];my(l,e)||(h=e.tagValueProcessor(d,h),h=H0(h,e)),s&&(i+=r),i+=h,s=!1;continue}else if(d===e.cdataPropName){s&&(i+=r),i+=`<![CDATA[${c[d][0][e.textNodeName]}]]>`,s=!1;continue}else if(d===e.commentPropName){i+=r+`<!--${c[d][0][e.textNodeName]}-->`,s=!0;continue}else if(d[0]==="?"){const h=Eu(c[":@"],e),_=d==="?xml"?"":r;let v=c[d][0][e.textNodeName];v=v.length!==0?" "+v:"",i+=_+`<${d}${v}${h}?>`,s=!0;continue}let u=r;u!==""&&(u+=e.indentBy);const p=Eu(c[":@"],e),m=r+`<${d}${p}`,w=q0(c[d],e,l,u);e.unpairedTags.indexOf(d)!==-1?e.suppressUnpairedNode?i+=m+">":i+=m+"/>":(!w||w.length===0)&&e.suppressEmptyNode?i+=m+"/>":w&&w.endsWith(">")?i+=m+`>${w}${r}</${d}>`:(i+=m+">",w&&r!==""&&(w.includes("/>")||w.includes("</"))?i+=r+e.indentBy+w+r:i+=w,i+=`</${d}>`),s=!0}return i}function gy(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 Eu(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=H0(i,e),i===!0&&e.suppressBooleanAttributes?n+=` ${r.substr(e.attributeNamePrefix.length)}`:n+=` ${r.substr(e.attributeNamePrefix.length)}="${i}"`}return n}function my(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 H0(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 _y=hy;const yy=_y,wy=M0,vy={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp("&","g"),val:"&amp;"},{regex:new RegExp(">","g"),val:"&gt;"},{regex:new RegExp("<","g"),val:"&lt;"},{regex:new RegExp("'","g"),val:"&apos;"},{regex:new RegExp('"',"g"),val:"&quot;"}],processEntities:!0,stopNodes:[],oneListGroup:!1};function fn(t){this.options=Object.assign({},vy,t),this.options.ignoreAttributes===!0||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn=wy(this.options.ignoreAttributes),this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=xy),this.processTextOrObjNode=by,this.options.format?(this.indentate=$y,this.tagEndChar=`>
5
+ */(function(e,n){typeof B1=="function"&&t&&t.exports?t.exports=n():(e.dcodeIO=e.dcodeIO||{}).bcrypt=n()})(bs,function(){var e={},n=null;function r(z){if(t&&t.exports)try{return M1.randomBytes(z)}catch{}try{var C;return(self.crypto||self.msCrypto).getRandomValues(C=new Uint32Array(z)),Array.prototype.slice.call(C)}catch{}if(!n)throw Error("Neither WebCryptoAPI nor a crypto module is available. Use bcrypt.setRandomFallback to set an alternative");return n(z)}var i=!1;try{r(1),i=!0}catch{}n=null,e.setRandomFallback=function(z){n=z},e.genSaltSync=function(z,C){if(z=z||_,typeof z!="number")throw Error("Illegal arguments: "+typeof z+", "+typeof C);z<4?z=4:z>31&&(z=31);var A=[];return A.push("$2a$"),z<10&&A.push("0"),A.push(z.toString()),A.push("$"),A.push(p(r(h),h)),A.join("")},e.genSalt=function(z,C,A){if(typeof C=="function"&&(A=C,C=void 0),typeof z=="function"&&(A=z,z=void 0),typeof z>"u")z=_;else if(typeof z!="number")throw Error("illegal arguments: "+typeof z);function x($){o(function(){try{$(null,e.genSaltSync(z))}catch(P){$(P)}})}if(A){if(typeof A!="function")throw Error("Illegal callback: "+typeof A);x(A)}else return new Promise(function($,P){x(function(U,Q){if(U){P(U);return}$(Q)})})},e.hashSync=function(z,C){if(typeof C>"u"&&(C=_),typeof C=="number"&&(C=e.genSaltSync(C)),typeof z!="string"||typeof C!="string")throw Error("Illegal arguments: "+typeof z+", "+typeof C);return ze(z,C)},e.hash=function(z,C,A,x){function $(P){typeof z=="string"&&typeof C=="number"?e.genSalt(C,function(U,Q){ze(z,Q,P,x)}):typeof z=="string"&&typeof C=="string"?ze(z,C,P,x):o(P.bind(this,Error("Illegal arguments: "+typeof z+", "+typeof C)))}if(A){if(typeof A!="function")throw Error("Illegal callback: "+typeof A);$(A)}else return new Promise(function(P,U){$(function(Q,W){if(Q){U(Q);return}P(W)})})};function s(z,C){for(var A=0,x=0,$=0,P=z.length;$<P;++$)z.charCodeAt($)===C.charCodeAt($)?++A:++x;return A<0?!1:x===0}e.compareSync=function(z,C){if(typeof z!="string"||typeof C!="string")throw Error("Illegal arguments: "+typeof z+", "+typeof C);return C.length!==60?!1:s(e.hashSync(z,C.substr(0,C.length-31)),C)},e.compare=function(z,C,A,x){function $(P){if(typeof z!="string"||typeof C!="string"){o(P.bind(this,Error("Illegal arguments: "+typeof z+", "+typeof C)));return}if(C.length!==60){o(P.bind(this,null,!1));return}e.hash(z,C.substr(0,29),function(U,Q){U?P(U):P(null,s(Q,C))},x)}if(A){if(typeof A!="function")throw Error("Illegal callback: "+typeof A);$(A)}else return new Promise(function(P,U){$(function(Q,W){if(Q){U(Q);return}P(W)})})},e.getRounds=function(z){if(typeof z!="string")throw Error("Illegal arguments: "+typeof z);return parseInt(z.split("$")[2],10)},e.getSalt=function(z){if(typeof z!="string")throw Error("Illegal arguments: "+typeof z);if(z.length!==60)throw Error("Illegal hash length: "+z.length+" != 60");return z.substring(0,29)};var o=typeof process<"u"&&process&&typeof process.nextTick=="function"?typeof setImmediate=="function"?setImmediate:process.nextTick:setTimeout;function c(z){var C=[],A=0;return w.encodeUTF16toUTF8(function(){return A>=z.length?null:z.charCodeAt(A++)},function(x){C.push(x)}),C}var d="./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),l=[-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],u=String.fromCharCode;function p(z,C){var A=0,x=[],$,P;if(C<=0||C>z.length)throw Error("Illegal len: "+C);for(;A<C;){if($=z[A++]&255,x.push(d[$>>2&63]),$=($&3)<<4,A>=C){x.push(d[$&63]);break}if(P=z[A++]&255,$|=P>>4&15,x.push(d[$&63]),$=(P&15)<<2,A>=C){x.push(d[$&63]);break}P=z[A++]&255,$|=P>>6&3,x.push(d[$&63]),x.push(d[P&63])}return x.join("")}function m(z,C){var A=0,x=z.length,$=0,P=[],U,Q,W,se,ue,q;if(C<=0)throw Error("Illegal len: "+C);for(;A<x-1&&$<C&&(q=z.charCodeAt(A++),U=q<l.length?l[q]:-1,q=z.charCodeAt(A++),Q=q<l.length?l[q]:-1,!(U==-1||Q==-1||(ue=U<<2>>>0,ue|=(Q&48)>>4,P.push(u(ue)),++$>=C||A>=x)||(q=z.charCodeAt(A++),W=q<l.length?l[q]:-1,W==-1)||(ue=(Q&15)<<4>>>0,ue|=(W&60)>>2,P.push(u(ue)),++$>=C||A>=x)));)q=z.charCodeAt(A++),se=q<l.length?l[q]:-1,ue=(W&3)<<6>>>0,ue|=se,P.push(u(ue)),++$;var Oe=[];for(A=0;A<$;A++)Oe.push(P[A].charCodeAt(0));return Oe}var w=function(){var z={};return z.MAX_CODEPOINT=1114111,z.encodeUTF8=function(C,A){var x=null;for(typeof C=="number"&&(x=C,C=function(){return null});x!==null||(x=C())!==null;)x<128?A(x&127):x<2048?(A(x>>6&31|192),A(x&63|128)):x<65536?(A(x>>12&15|224),A(x>>6&63|128),A(x&63|128)):(A(x>>18&7|240),A(x>>12&63|128),A(x>>6&63|128),A(x&63|128)),x=null},z.decodeUTF8=function(C,A){for(var x,$,P,U,Q=function(W){W=W.slice(0,W.indexOf(null));var se=Error(W.toString());throw se.name="TruncatedError",se.bytes=W,se};(x=C())!==null;)if(!(x&128))A(x);else if((x&224)===192)($=C())===null&&Q([x,$]),A((x&31)<<6|$&63);else if((x&240)===224)(($=C())===null||(P=C())===null)&&Q([x,$,P]),A((x&15)<<12|($&63)<<6|P&63);else if((x&248)===240)(($=C())===null||(P=C())===null||(U=C())===null)&&Q([x,$,P,U]),A((x&7)<<18|($&63)<<12|(P&63)<<6|U&63);else throw RangeError("Illegal starting byte: "+x)},z.UTF16toUTF8=function(C,A){for(var x,$=null;(x=$!==null?$:C())!==null;){if(x>=55296&&x<=57343&&($=C())!==null&&$>=56320&&$<=57343){A((x-55296)*1024+$-56320+65536),$=null;continue}A(x)}$!==null&&A($)},z.UTF8toUTF16=function(C,A){var x=null;for(typeof C=="number"&&(x=C,C=function(){return null});x!==null||(x=C())!==null;)x<=65535?A(x):(x-=65536,A((x>>10)+55296),A(x%1024+56320)),x=null},z.encodeUTF16toUTF8=function(C,A){z.UTF16toUTF8(C,function(x){z.encodeUTF8(x,A)})},z.decodeUTF8toUTF16=function(C,A){z.decodeUTF8(C,function(x){z.UTF8toUTF16(x,A)})},z.calculateCodePoint=function(C){return C<128?1:C<2048?2:C<65536?3:4},z.calculateUTF8=function(C){for(var A,x=0;(A=C())!==null;)x+=z.calculateCodePoint(A);return x},z.calculateUTF16asUTF8=function(C){var A=0,x=0;return z.UTF16toUTF8(C,function($){++A,x+=z.calculateCodePoint($)}),[A,x]},z}();Date.now=Date.now||function(){return+new Date};var h=16,_=10,v=16,k=100,I=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731],O=[3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,1904987480,2182433518,2069144605,3260701109,2620446009,720527379,3318853667,677414384,3393288472,3101374703,2390351024,1614419982,1822297739,2954791486,3608508353,3174124327,2024746970,1432378464,3864339955,2857741204,1464375394,1676153920,1439316330,715854006,3033291828,289532110,2706671279,2087905683,3018724369,1668267050,732546397,1947742710,3462151702,2609353502,2950085171,1814351708,2050118529,680887927,999245976,1800124847,3300911131,1713906067,1641548236,4213287313,1216130144,1575780402,4018429277,3917837745,3693486850,3949271944,596196993,3549867205,258830323,2213823033,772490370,2760122372,1774776394,2652871518,566650946,4142492826,1728879713,2882767088,1783734482,3629395816,2517608232,2874225571,1861159788,326777828,3124490320,2130389656,2716951837,967770486,1724537150,2185432712,2364442137,1164943284,2105845187,998989502,3765401048,2244026483,1075463327,1455516326,1322494562,910128902,469688178,1117454909,936433444,3490320968,3675253459,1240580251,122909385,2157517691,634681816,4142456567,3825094682,3061402683,2540495037,79693498,3249098678,1084186820,1583128258,426386531,1761308591,1047286709,322548459,995290223,1845252383,2603652396,3431023940,2942221577,3202600964,3727903485,1712269319,422464435,3234572375,1170764815,3523960633,3117677531,1434042557,442511882,3600875718,1076654713,1738483198,4213154764,2393238008,3677496056,1014306527,4251020053,793779912,2902807211,842905082,4246964064,1395751752,1040244610,2656851899,3396308128,445077038,3742853595,3577915638,679411651,2892444358,2354009459,1767581616,3150600392,3791627101,3102740896,284835224,4246832056,1258075500,768725851,2589189241,3069724005,3532540348,1274779536,3789419226,2764799539,1660621633,3471099624,4011903706,913787905,3497959166,737222580,2514213453,2928710040,3937242737,1804850592,3499020752,2949064160,2386320175,2390070455,2415321851,4061277028,2290661394,2416832540,1336762016,1754252060,3520065937,3014181293,791618072,3188594551,3933548030,2332172193,3852520463,3043980520,413987798,3465142937,3030929376,4245938359,2093235073,3534596313,375366246,2157278981,2479649556,555357303,3870105701,2008414854,3344188149,4221384143,3956125452,2067696032,3594591187,2921233993,2428461,544322398,577241275,1471733935,610547355,4027169054,1432588573,1507829418,2025931657,3646575487,545086370,48609733,2200306550,1653985193,298326376,1316178497,3007786442,2064951626,458293330,2589141269,3591329599,3164325604,727753846,2179363840,146436021,1461446943,4069977195,705550613,3059967265,3887724982,4281599278,3313849956,1404054877,2845806497,146425753,1854211946,1266315497,3048417604,3681880366,3289982499,290971e4,1235738493,2632868024,2414719590,3970600049,1771706367,1449415276,3266420449,422970021,1963543593,2690192192,3826793022,1062508698,1531092325,1804592342,2583117782,2714934279,4024971509,1294809318,4028980673,1289560198,2221992742,1669523910,35572830,157838143,1052438473,1016535060,1802137761,1753167236,1386275462,3080475397,2857371447,1040679964,2145300060,2390574316,1461121720,2956646967,4031777805,4028374788,33600511,2920084762,1018524850,629373528,3691585981,3515945977,2091462646,2486323059,586499841,988145025,935516892,3367335476,2599673255,2839830854,265290510,3972581182,2759138881,3795373465,1005194799,847297441,406762289,1314163512,1332590856,1866599683,4127851711,750260880,613907577,1450815602,3165620655,3734664991,3650291728,3012275730,3704569646,1427272223,778793252,1343938022,2676280711,2052605720,1946737175,3164576444,3914038668,3967478842,3682934266,1661551462,3294938066,4011595847,840292616,3712170807,616741398,312560963,711312465,1351876610,322626781,1910503582,271666773,2175563734,1594956187,70604529,3617834859,1007753275,1495573769,4069517037,2549218298,2663038764,504708206,2263041392,3941167025,2249088522,1514023603,1998579484,1312622330,694541497,2582060303,2151582166,1382467621,776784248,2618340202,3323268794,2497899128,2784771155,503983604,4076293799,907881277,423175695,432175456,1378068232,4145222326,3954048622,3938656102,3820766613,2793130115,2977904593,26017576,3274890735,3194772133,1700274565,1756076034,4006520079,3677328699,720338349,1533947780,354530856,688349552,3973924725,1637815568,332179504,3949051286,53804574,2852348879,3044236432,1282449977,3583942155,3416972820,4006381244,1617046695,2628476075,3002303598,1686838959,431878346,2686675385,1700445008,1080580658,1009431731,832498133,3223435511,2605976345,2271191193,2516031870,1648197032,4164389018,2548247927,300782431,375919233,238389289,3353747414,2531188641,2019080857,1475708069,455242339,2609103871,448939670,3451063019,1395535956,2413381860,1841049896,1491858159,885456874,4264095073,4001119347,1565136089,3898914787,1108368660,540939232,1173283510,2745871338,3681308437,4207628240,3343053890,4016749493,1699691293,1103962373,3625875870,2256883143,3830138730,1031889488,3479347698,1535977030,4236805024,3251091107,2132092099,1774941330,1199868427,1452454533,157007616,2904115357,342012276,595725824,1480756522,206960106,497939518,591360097,863170706,2375253569,3596610801,1814182875,2094937945,3421402208,1082520231,3463918190,2785509508,435703966,3908032597,1641649973,2842273706,3305899714,1510255612,2148256476,2655287854,3276092548,4258621189,236887753,3681803219,274041037,1734335097,3815195456,3317970021,1899903192,1026095262,4050517792,356393447,2410691914,3873677099,3682840055,3913112168,2491498743,4132185628,2489919796,1091903735,1979897079,3170134830,3567386728,3557303409,857797738,1136121015,1342202287,507115054,2535736646,337727348,3213592640,1301675037,2528481711,1895095763,1721773893,3216771564,62756741,2142006736,835421444,2531993523,1442658625,3659876326,2882144922,676362277,1392781812,170690266,3921047035,1759253602,3611846912,1745797284,664899054,1329594018,3901205900,3045908486,2062866102,2865634940,3543621612,3464012697,1080764994,553557557,3656615353,3996768171,991055499,499776247,1265440854,648242737,3940784050,980351604,3713745714,1749149687,3396870395,4211799374,3640570775,1161844396,3125318951,1431517754,545492359,4268468663,3499529547,1437099964,2702547544,3433638243,2581715763,2787789398,1060185593,1593081372,2418618748,4260947970,69676912,2159744348,86519011,2512459080,3838209314,1220612927,3339683548,133810670,1090789135,1078426020,1569222167,845107691,3583754449,4072456591,1091646820,628848692,1613405280,3757631651,526609435,236106946,48312990,2942717905,3402727701,1797494240,859738849,992217954,4005476642,2243076622,3870952857,3732016268,765654824,3490871365,2511836413,1685915746,3888969200,1414112111,2273134842,3281911079,4080962846,172450625,2569994100,980381355,4109958455,2819808352,2716589560,2568741196,3681446669,3329971472,1835478071,660984891,3704678404,4045999559,3422617507,3040415634,1762651403,1719377915,3470491036,2693910283,3642056355,3138596744,1364962596,2073328063,1983633131,926494387,3423689081,2150032023,4096667949,1749200295,3328846651,309677260,2016342300,1779581495,3079819751,111262694,1274766160,443224088,298511866,1025883608,3806446537,1145181785,168956806,3641502830,3584813610,1689216846,3666258015,3200248200,1692713982,2646376535,4042768518,1618508792,1610833997,3523052358,4130873264,2001055236,3610705100,2202168115,4028541809,2961195399,1006657119,2006996926,3186142756,1430667929,3210227297,1314452623,4074634658,4101304120,2273951170,1399257539,3367210612,3027628629,1190975929,2062231137,2333990788,2221543033,2438960610,1181637006,548689776,2362791313,3372408396,3104550113,3145860560,296247880,1970579870,3078560182,3769228297,1714227617,3291629107,3898220290,166772364,1251581989,493813264,448347421,195405023,2709975567,677966185,3703036547,1463355134,2715995803,1338867538,1343315457,2802222074,2684532164,233230375,2599980071,2000651841,3277868038,1638401717,4028070440,3237316320,6314154,819756386,300326615,590932579,1405279636,3267499572,3150704214,2428286686,3959192993,3461946742,1862657033,1266418056,963775037,2089974820,2263052895,1917689273,448879540,3550394620,3981727096,150775221,3627908307,1303187396,508620638,2975983352,2726630617,1817252668,1876281319,1457606340,908771278,3720792119,3617206836,2455994898,1729034894,1080033504,976866871,3556439503,2881648439,1522871579,1555064734,1336096578,3548522304,2579274686,3574697629,3205460757,3593280638,3338716283,3079412587,564236357,2993598910,1781952180,1464380207,3163844217,3332601554,1699332808,1393555694,1183702653,3581086237,1288719814,691649499,2847557200,2895455976,3193889540,2717570544,1781354906,1676643554,2592534050,3230253752,1126444790,2770207658,2633158820,2210423226,2615765581,2414155088,3127139286,673620729,2805611233,1269405062,4015350505,3341807571,4149409754,1057255273,2012875353,2162469141,2276492801,2601117357,993977747,3918593370,2654263191,753973209,36408145,2530585658,25011837,3520020182,2088578344,530523599,2918365339,1524020338,1518925132,3760827505,3759777254,1202760957,3985898139,3906192525,674977740,4174734889,2031300136,2019492241,3983892565,4153806404,3822280332,352677332,2297720250,60907813,90501309,3286998549,1016092578,2535922412,2839152426,457141659,509813237,4120667899,652014361,1966332200,2975202805,55981186,2327461051,676427537,3255491064,2882294119,3433927263,1307055953,942726286,933058658,2468411793,3933900994,4215176142,1361170020,2001714738,2830558078,3274259782,1222529897,1679025792,2729314320,3714953764,1770335741,151462246,3013232138,1682292957,1483529935,471910574,1539241949,458788160,3436315007,1807016891,3718408830,978976581,1043663428,3165965781,1927990952,4200891579,2372276910,3208408903,3533431907,1412390302,2931980059,4132332400,1947078029,3881505623,4168226417,2941484381,1077988104,1320477388,886195818,18198404,3786409e3,2509781533,112762804,3463356488,1866414978,891333506,18488651,661792760,1628790961,3885187036,3141171499,876946877,2693282273,1372485963,791857591,2686433993,3759982718,3167212022,3472953795,2716379847,445679433,3561995674,3504004811,3574258232,54117162,3331405415,2381918588,3769707343,4154350007,1140177722,4074052095,668550556,3214352940,367459370,261225585,2610173221,4209349473,3468074219,3265815641,314222801,3066103646,3808782860,282218597,3406013506,3773591054,379116347,1285071038,846784868,2669647154,3771962079,3550491691,2305946142,453669953,1268987020,3317592352,3279303384,3744833421,2610507566,3859509063,266596637,3847019092,517658769,3462560207,3443424879,370717030,4247526661,2224018117,4143653529,4112773975,2788324899,2477274417,1456262402,2901442914,1517677493,1846949527,2295493580,3734397586,2176403920,1280348187,1908823572,3871786941,846861322,1172426758,3287448474,3383383037,1655181056,3139813346,901632758,1897031941,2986607138,3066810236,3447102507,1393639104,373351379,950779232,625454576,3124240540,4148612726,2007998917,544563296,2244738638,2330496472,2058025392,1291430526,424198748,50039436,29584100,3605783033,2429876329,2791104160,1057563949,3255363231,3075367218,3463963227,1469046755,985887462],L=[1332899944,1700884034,1701343084,1684370003,1668446532,1869963892];function Y(z,C,A,x){var $,P=z[C],U=z[C+1];return P^=A[0],$=x[P>>>24],$+=x[256|P>>16&255],$^=x[512|P>>8&255],$+=x[768|P&255],U^=$^A[1],$=x[U>>>24],$+=x[256|U>>16&255],$^=x[512|U>>8&255],$+=x[768|U&255],P^=$^A[2],$=x[P>>>24],$+=x[256|P>>16&255],$^=x[512|P>>8&255],$+=x[768|P&255],U^=$^A[3],$=x[U>>>24],$+=x[256|U>>16&255],$^=x[512|U>>8&255],$+=x[768|U&255],P^=$^A[4],$=x[P>>>24],$+=x[256|P>>16&255],$^=x[512|P>>8&255],$+=x[768|P&255],U^=$^A[5],$=x[U>>>24],$+=x[256|U>>16&255],$^=x[512|U>>8&255],$+=x[768|U&255],P^=$^A[6],$=x[P>>>24],$+=x[256|P>>16&255],$^=x[512|P>>8&255],$+=x[768|P&255],U^=$^A[7],$=x[U>>>24],$+=x[256|U>>16&255],$^=x[512|U>>8&255],$+=x[768|U&255],P^=$^A[8],$=x[P>>>24],$+=x[256|P>>16&255],$^=x[512|P>>8&255],$+=x[768|P&255],U^=$^A[9],$=x[U>>>24],$+=x[256|U>>16&255],$^=x[512|U>>8&255],$+=x[768|U&255],P^=$^A[10],$=x[P>>>24],$+=x[256|P>>16&255],$^=x[512|P>>8&255],$+=x[768|P&255],U^=$^A[11],$=x[U>>>24],$+=x[256|U>>16&255],$^=x[512|U>>8&255],$+=x[768|U&255],P^=$^A[12],$=x[P>>>24],$+=x[256|P>>16&255],$^=x[512|P>>8&255],$+=x[768|P&255],U^=$^A[13],$=x[U>>>24],$+=x[256|U>>16&255],$^=x[512|U>>8&255],$+=x[768|U&255],P^=$^A[14],$=x[P>>>24],$+=x[256|P>>16&255],$^=x[512|P>>8&255],$+=x[768|P&255],U^=$^A[15],$=x[U>>>24],$+=x[256|U>>16&255],$^=x[512|U>>8&255],$+=x[768|U&255],P^=$^A[16],z[C]=U^A[v+1],z[C+1]=P,z}function oe(z,C){for(var A=0,x=0;A<4;++A)x=x<<8|z[C]&255,C=(C+1)%z.length;return{key:x,offp:C}}function ae(z,C,A){for(var x=0,$=[0,0],P=C.length,U=A.length,Q,W=0;W<P;W++)Q=oe(z,x),x=Q.offp,C[W]=C[W]^Q.key;for(W=0;W<P;W+=2)$=Y($,0,C,A),C[W]=$[0],C[W+1]=$[1];for(W=0;W<U;W+=2)$=Y($,0,C,A),A[W]=$[0],A[W+1]=$[1]}function ke(z,C,A,x){for(var $=0,P=[0,0],U=A.length,Q=x.length,W,se=0;se<U;se++)W=oe(C,$),$=W.offp,A[se]=A[se]^W.key;for($=0,se=0;se<U;se+=2)W=oe(z,$),$=W.offp,P[0]^=W.key,W=oe(z,$),$=W.offp,P[1]^=W.key,P=Y(P,0,A,x),A[se]=P[0],A[se+1]=P[1];for(se=0;se<Q;se+=2)W=oe(z,$),$=W.offp,P[0]^=W.key,W=oe(z,$),$=W.offp,P[1]^=W.key,P=Y(P,0,A,x),x[se]=P[0],x[se+1]=P[1]}function Ee(z,C,A,x,$){var P=L.slice(),U=P.length,Q;if(A<4||A>31)if(Q=Error("Illegal number of rounds (4-31): "+A),x){o(x.bind(this,Q));return}else throw Q;if(C.length!==h)if(Q=Error("Illegal salt length: "+C.length+" != "+h),x){o(x.bind(this,Q));return}else throw Q;A=1<<A>>>0;var W,se,ue=0,q;Int32Array?(W=new Int32Array(I),se=new Int32Array(O)):(W=I.slice(),se=O.slice()),ke(C,z,W,se);function Oe(){if($&&$(ue/A),ue<A)for(var he=Date.now();ue<A&&(ue=ue+1,ae(z,W,se),ae(C,W,se),!(Date.now()-he>k)););else{for(ue=0;ue<64;ue++)for(q=0;q<U>>1;q++)Y(P,q<<1,W,se);var Se=[];for(ue=0;ue<U;ue++)Se.push((P[ue]>>24&255)>>>0),Se.push((P[ue]>>16&255)>>>0),Se.push((P[ue]>>8&255)>>>0),Se.push((P[ue]&255)>>>0);if(x){x(null,Se);return}else return Se}x&&o(Oe)}if(typeof x<"u")Oe();else for(var _n;;)if(typeof(_n=Oe())<"u")return _n||[]}function ze(z,C,A,x){var $;if(typeof z!="string"||typeof C!="string")if($=Error("Invalid string / salt: Not a string"),A){o(A.bind(this,$));return}else throw $;var P,U;if(C.charAt(0)!=="$"||C.charAt(1)!=="2")if($=Error("Invalid salt version: "+C.substring(0,2)),A){o(A.bind(this,$));return}else throw $;if(C.charAt(2)==="$")P="\0",U=3;else{if(P=C.charAt(2),P!=="a"&&P!=="b"&&P!=="y"||C.charAt(3)!=="$")if($=Error("Invalid salt revision: "+C.substring(2,4)),A){o(A.bind(this,$));return}else throw $;U=4}if(C.charAt(U+2)>"$")if($=Error("Missing salt rounds"),A){o(A.bind(this,$));return}else throw $;var Q=parseInt(C.substring(U,U+1),10)*10,W=parseInt(C.substring(U+1,U+2),10),se=Q+W,ue=C.substring(U+3,U+25);z+=P>="a"?"\0":"";var q=c(z),Oe=m(ue,h);function _n(he){var Se=[];return Se.push("$2"),P>="a"&&Se.push(P),Se.push("$"),se<10&&Se.push("0"),Se.push(se.toString()),Se.push("$"),Se.push(p(Oe,Oe.length)),Se.push(p(he,L.length*4-1)),Se.join("")}if(typeof A>"u")return _n(Ee(q,Oe,se));Ee(q,Oe,se,function(he,Se){he?A(he,null):A(null,_n(Se))},x)}return e.encodeBase64=p,e.decodeBase64=m,e})})(O0);var F1=O0.exports;const mi=z0(F1),V1="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let D1=t=>crypto.getRandomValues(new Uint8Array(t)),q1=(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),d=i;for(;d--;)if(o+=t[c[d]&r]||"",o.length===s)return o}}},H1=(t,e=21)=>q1(t,e,D1),xe=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=V1[n[t]&63];return e};const K1=24;function go(){return H1("0123456789abcdef",K1)()}function vu(t){if(!t.includes("|"))return console.error("Invalid user_id format"),t;const[,e]=t.split("|");return e}function G1(t){return async(e,n)=>{if(!n.email||!n.email_verified)return t.users.create(e,n);const r=await vo({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 we(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 Pd{constructor(e,n){te(this,"value");te(this,"unit");this.value=e,this.unit=n}milliseconds(){return this.unit==="ms"?this.value:this.unit==="s"?this.value*1e3:this.unit==="m"?this.value*1e3*60:this.unit==="h"?this.value*1e3*60*60:this.unit==="d"?this.value*1e3*60*60*24:this.value*1e3*60*60*24*7}seconds(){return this.milliseconds()/1e3}transform(e){return new Pd(Math.round(this.milliseconds()*e),"ms")}}class W1{constructor(e){te(this,"hash");this.hash=e}async verify(e,n,r){const i=await crypto.subtle.importKey("spki",e,{name:"RSASSA-PKCS1-v1_5",hash:this.hash},!1,["verify"]);return await crypto.subtle.verify("RSASSA-PKCS1-v1_5",i,n,r)}async sign(e,n){const r=await crypto.subtle.importKey("pkcs8",e,{name:"RSASSA-PKCS1-v1_5",hash:this.hash},!1,["sign"]);return await crypto.subtle.sign("RSASSA-PKCS1-v1_5",r,n)}async generateKeyPair(e){const n=await crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",hash:this.hash,modulusLength:e??2048,publicExponent:new Uint8Array([1,0,1])},!0,["sign"]),r=await crypto.subtle.exportKey("pkcs8",n.privateKey),i=await crypto.subtle.exportKey("spki",n.publicKey);return{privateKey:r,publicKey:i}}}async function P0(t){return await crypto.subtle.digest("SHA-256",t)}const bu="0123456789abcdef";function Ga(t){const e=new Uint8Array(t);let n="";for(let r=0;r<e.length;r++){const i=e[r]>>4;n+=bu[i];const s=e[r]&15;n+=bu[s]}return n}class j0{constructor(e,n){te(this,"alphabet");te(this,"padding");te(this,"decodeMap",new Map);if(e.length!==32)throw new Error("Invalid alphabet");if(this.alphabet=e,this.padding=(n==null?void 0:n.padding)??"=",this.alphabet.includes(this.padding)||this.padding.length!==1)throw new Error("Invalid padding");for(let r=0;r<e.length;r++)this.decodeMap.set(e[r],r)}encode(e,n){let r="",i=0,s=0;for(let c=0;c<e.length;c++)for(i=i<<8|e[c],s+=8;s>=5;)s-=5,r+=this.alphabet[i>>s&31];if(s>0&&(r+=this.alphabet[i<<5-s&31]),(n==null?void 0:n.includePadding)??!0){const c=(8-r.length%8)%8;for(let d=0;d<c;d++)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 d=[];for(let u=0;u<8;u++){const p=e[o*8+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 m=this.decodeMap.get(p)??null;if(m===null)throw new Error(`Invalid character: ${p}`);d.push(m)}if(c===8||c===7||c===5||c===2)throw new Error("Invalid padding");const l=(d[0]<<3)+(d[1]>>2);if(s.push(l),c<6){const u=((d[1]&3)<<6)+(d[2]<<1)+(d[3]>>4);s.push(u)}if(c<4){const u=((d[3]&255)<<4)+(d[4]>>1);s.push(u)}if(c<3){const u=((d[4]&1)<<7)+(d[5]<<2)+(d[6]>>3);s.push(u)}if(c<1){const u=((d[6]&7)<<5)+d[7];s.push(u)}}return Uint8Array.from(s)}}new j0("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567");new j0("0123456789ABCDEFGHIJKLMNOPQRSTUV");class T0{constructor(e,n){te(this,"alphabet");te(this,"padding");te(this,"decodeMap",new Map);if(e.length!==64)throw new Error("Invalid alphabet");if(this.alphabet=e,this.padding=(n==null?void 0:n.padding)??"=",this.alphabet.includes(this.padding)||this.padding.length!==1)throw new Error("Invalid padding");for(let r=0;r<e.length;r++)this.decodeMap.set(e[r],r)}encode(e,n){let r="",i=0,s=0;for(let c=0;c<e.length;c++)for(i=i<<8|e[c],s+=8;s>=6;)s+=-6,r+=this.alphabet[i>>s&63];if(s>0&&(r+=this.alphabet[i<<6-s&63]),(n==null?void 0:n.includePadding)??!0){const c=(4-r.length%4)%4;for(let d=0;d<c;d++)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,d=0;for(let l=0;l<4;l++){const u=e[o*4+l];if(u==="="){if(o+1!==i)throw new Error(`Invalid character: ${u}`);c+=1;continue}if(u===void 0){if(r)throw new Error("Invalid data");c+=1;continue}const p=this.decodeMap.get(u)??null;if(p===null)throw new Error(`Invalid character: ${u}`);d+=p<<6*(3-l)}s.push(d>>16&255),c<2&&s.push(d>>8&255),c<1&&s.push(d&255)}return Uint8Array.from(s)}}const J1=new T0("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Sn=new T0("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_");async function $u(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=Sn.encode(o.encode(JSON.stringify(i)),{includePadding:!1}),d=Sn.encode(o.encode(JSON.stringify(s)),{includePadding:!1}),l=o.encode([c,d].join(".")),u=await X1(t).sign(e,l),p=Sn.encode(new Uint8Array(u),{includePadding:!1});return[c,d,p].join(".")}function Z1(t){const e=t.split(".");return e.length!==3?null:e}function jd(t){const e=Z1(t);if(!e)return null;const n=new TextDecoder,r=Sn.decode(e[0],{strict:!1}),i=Sn.decode(e[1],{strict:!1}),s=JSON.parse(n.decode(r));if(typeof s!="object"||s===null||!("alg"in s)||!Y1(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 d of o.aud)if(typeof d!="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 X1(t){return new W1(Q1[t])}function Y1(t){return typeof t!="string"?!1:["HS256","HS384","HS512","RS256","RS384","RS512","ES256","ES384","ES512","PS256","PS384","PS512"].includes(t)}const Q1={RS256:"SHA-256",RS384:"SHA-384",RS512:"SHA-512"};function e_(){const t=new Uint8Array(32);return crypto.getRandomValues(t),Sn.encode(t,{includePadding:!1})}function t_(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 n_(t,e){if(e==="plain")return t;const n=new TextEncoder().encode(t),r=await P0(n);return Sn.encode(new Uint8Array(r),{includePadding:!1})}const Di=60*5,mo=30*24*60*60,or=24*60*60,r_="auth-token",Wa=30*60*1e3,i_=7*24*60*60*1e3,s_=5*60,o_=5*60,a_=30*60*1e3,c_=30*60*1e3,d_=24*60*60*1e3;function R0(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 l_(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 Td(t){return`${t}-${r_}`}function B0(t){if(!t)return;if(t==="localhost"||/^(\d{1,3}\.){3}\d{1,3}$/.test(t))return t;const e=t.split(".");return e.length>2?`.${e.slice(-2).join(".")}`:`.${t}`}function $s(t,e){return e?l_(e).get(Td(t)):void 0}function u_(t,e){return R0(Td(t),"",{path:"/",httpOnly:!0,secure:!0,maxAge:0,sameSite:"none",domain:e?B0(e):void 0})}function L0(t,e,n){return R0(Td(t),e,{path:"/",httpOnly:!0,secure:!0,maxAge:mo,sameSite:"none",domain:n?B0(n):void 0})}var Rd={},_o={};(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,d){const l=[];let u=d.exec(c);for(;u;){const p=[];p.startIndex=d.lastIndex-u[0].length;const m=u.length;for(let w=0;w<m;w++)p.push(u[w]);l.push(p),u=d.exec(c)}return l},o=function(c){const d=i.exec(c);return!(d===null||typeof d>"u")};t.isExist=function(c){return typeof c<"u"},t.isEmptyObject=function(c){return Object.keys(c).length===0},t.merge=function(c,d,l){if(d){const u=Object.keys(d),p=u.length;for(let m=0;m<p;m++)l==="strict"?c[u[m]]=[d[u[m]]]:c[u[m]]=d[u[m]]}},t.getValue=function(c){return t.isExist(c)?c:""},t.isName=o,t.getAllMatches=s,t.nameRegexp=r})(_o);const Bd=_o,f_={allowBooleanAttributes:!1,unpairedTags:[]};Rd.validate=function(t,e){e=Object.assign({},f_,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=ku(t,s),s.err)return s}else if(t[s]==="<"){let o=s;if(s++,t[s]==="!"){s=Su(t,s);continue}else{let c=!1;t[s]==="/"&&(c=!0,s++);let d="";for(;s<t.length&&t[s]!==">"&&t[s]!==" "&&t[s]!==" "&&t[s]!==`
6
+ `&&t[s]!=="\r";s++)d+=t[s];if(d=d.trim(),d[d.length-1]==="/"&&(d=d.substring(0,d.length-1),s--),!v_(d)){let p;return d.trim().length===0?p="Invalid space after '<'.":p="Tag '"+d+"' is an invalid name.",be("InvalidTag",p,Ve(t,s))}const l=g_(t,s);if(l===!1)return be("InvalidAttr","Attributes for '"+d+"' have open quote.",Ve(t,s));let u=l.value;if(s=l.index,u[u.length-1]==="/"){const p=s-u.length;u=u.substring(0,u.length-1);const m=Au(u,e);if(m===!0)r=!0;else return be(m.err.code,m.err.msg,Ve(t,p+m.err.line))}else if(c)if(l.tagClosed){if(u.trim().length>0)return be("InvalidTag","Closing tag '"+d+"' can't have attributes or invalid starting.",Ve(t,o));if(n.length===0)return be("InvalidTag","Closing tag '"+d+"' has not been opened.",Ve(t,o));{const p=n.pop();if(d!==p.tagName){let m=Ve(t,p.tagStartPos);return be("InvalidTag","Expected closing tag '"+p.tagName+"' (opened in line "+m.line+", col "+m.col+") instead of closing tag '"+d+"'.",Ve(t,o))}n.length==0&&(i=!0)}}else return be("InvalidTag","Closing tag '"+d+"' doesn't have proper closing.",Ve(t,s));else{const p=Au(u,e);if(p!==!0)return be(p.err.code,p.err.msg,Ve(t,s-u.length+p.err.line));if(i===!0)return be("InvalidXml","Multiple possible root nodes found.",Ve(t,s));e.unpairedTags.indexOf(d)!==-1||n.push({tagName:d,tagStartPos:o}),r=!0}for(s++;s<t.length;s++)if(t[s]==="<")if(t[s+1]==="!"){s++,s=Su(t,s);continue}else if(t[s+1]==="?"){if(s=ku(t,++s),s.err)return s}else break;else if(t[s]==="&"){const p=y_(t,s);if(p==-1)return be("InvalidChar","char '&' is not expected.",Ve(t,s));s=p}else if(i===!0&&!xu(t[s]))return be("InvalidXml","Extra text at the end",Ve(t,s));t[s]==="<"&&s--}}else{if(xu(t[s]))continue;return be("InvalidChar","char '"+t[s]+"' is not expected.",Ve(t,s))}if(r){if(n.length==1)return be("InvalidTag","Unclosed tag '"+n[0].tagName+"'.",Ve(t,n[0].tagStartPos));if(n.length>0)return be("InvalidXml","Invalid '"+JSON.stringify(n.map(s=>s.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1})}else return be("InvalidXml","Start tag expected.",1);return!0};function xu(t){return t===" "||t===" "||t===`
7
+ `||t==="\r"}function ku(t,e){const n=e;for(;e<t.length;e++)if(t[e]=="?"||t[e]==" "){const r=t.substr(n,e-n);if(e>5&&r==="xml")return be("InvalidXml","XML declaration allowed only at the start of the document.",Ve(t,e));if(t[e]=="?"&&t[e+1]==">"){e++;break}else continue}return e}function Su(t,e){if(t.length>e+5&&t[e+1]==="-"&&t[e+2]==="-"){for(e+=3;e<t.length;e++)if(t[e]==="-"&&t[e+1]==="-"&&t[e+2]===">"){e+=2;break}}else if(t.length>e+8&&t[e+1]==="D"&&t[e+2]==="O"&&t[e+3]==="C"&&t[e+4]==="T"&&t[e+5]==="Y"&&t[e+6]==="P"&&t[e+7]==="E"){let n=1;for(e+=8;e<t.length;e++)if(t[e]==="<")n++;else if(t[e]===">"&&(n--,n===0))break}else if(t.length>e+9&&t[e+1]==="["&&t[e+2]==="C"&&t[e+3]==="D"&&t[e+4]==="A"&&t[e+5]==="T"&&t[e+6]==="A"&&t[e+7]==="["){for(e+=8;e<t.length;e++)if(t[e]==="]"&&t[e+1]==="]"&&t[e+2]===">"){e+=2;break}}return e}const p_='"',h_="'";function g_(t,e){let n="",r="",i=!1;for(;e<t.length;e++){if(t[e]===p_||t[e]===h_)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 m_=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function Au(t,e){const n=Bd.getAllMatches(t,m_),r={};for(let i=0;i<n.length;i++){if(n[i][1].length===0)return be("InvalidAttr","Attribute '"+n[i][2]+"' has no space in starting.",Tr(n[i]));if(n[i][3]!==void 0&&n[i][4]===void 0)return be("InvalidAttr","Attribute '"+n[i][2]+"' is without value.",Tr(n[i]));if(n[i][3]===void 0&&!e.allowBooleanAttributes)return be("InvalidAttr","boolean attribute '"+n[i][2]+"' is not allowed.",Tr(n[i]));const s=n[i][2];if(!w_(s))return be("InvalidAttr","Attribute '"+s+"' is an invalid name.",Tr(n[i]));if(!r.hasOwnProperty(s))r[s]=1;else return be("InvalidAttr","Attribute '"+s+"' is repeated.",Tr(n[i]))}return!0}function __(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 y_(t,e){if(e++,t[e]===";")return-1;if(t[e]==="#")return e++,__(t,e);let n=0;for(;e<t.length;e++,n++)if(!(t[e].match(/\w/)&&n<20)){if(t[e]===";")break;return-1}return e}function be(t,e,n){return{err:{code:t,msg:e,line:n.line||n,col:n.col}}}function w_(t){return Bd.isName(t)}function v_(t){return Bd.isName(t)}function Ve(t,e){const n=t.substring(0,e).split(/\r?\n/);return{line:n.length,col:n[n.length-1].length+1}}function Tr(t){return t.startIndex+t[1].length}var Ld={};const U0={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}},b_=function(t){return Object.assign({},U0,t)};Ld.buildOptions=b_;Ld.defaultOptions=U0;class $_{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 x_=$_;const k_=_o;function S_(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&&I_(t,e)){e+=7;let c,d;[c,d,e]=A_(t,e+1),d.indexOf("&")===-1&&(n[O_(c)]={regx:RegExp(`&${c};`,"g"),val:d})}else if(i&&N_(t,e))e+=8;else if(i&&C_(t,e))e+=8;else if(i&&z_(t,e))e+=9;else if(E_)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 A_(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 E_(t,e){return t[e+1]==="!"&&t[e+2]==="-"&&t[e+3]==="-"}function I_(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 N_(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 C_(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 z_(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 O_(t){if(k_.isName(t))return t;throw new Error(`Invalid entity name ${t}`)}var P_=S_;const j_=/^[-+]?0x[a-fA-F0-9]+$/,T_=/^([\-\+])?(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 R_={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};function B_(t,e={}){if(e=Object.assign({},R_,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&&j_.test(n))return Number.parseInt(n,16);{const r=T_.exec(n);if(r){const i=r[1],s=r[2];let o=L_(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 d=Number(n),l=""+d;return l.search(/[eE]/)!==-1||c?e.eNotation?d:t:n.indexOf(".")!==-1?l==="0"&&o===""||l===o||i&&l==="-"+o?d:t:s?o===l||i+o===l?d:t:n===l||n===i+l?d:t}}else return t}}function L_(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 U_=B_;function M_(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 M0=M_;const F0=_o,Rr=x_,F_=P_,V_=U_,D_=M0;let q_=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=H_,this.parseXml=Z_,this.parseTextData=K_,this.resolveNameSpace=G_,this.buildAttributesMap=J_,this.isItStopNode=ey,this.replaceEntitiesValue=Y_,this.readStopNodeData=ny,this.saveTextToParentTag=Q_,this.addChild=X_,this.ignoreAttributesFn=D_(this.options.ignoreAttributes)}};function H_(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 K_(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?Za(t,this.options.parseTagValue,this.options.numberParseOptions):t.trim()===t?Za(t,this.options.parseTagValue,this.options.numberParseOptions):t}}function G_(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 W_=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function J_(t,e,n){if(this.options.ignoreAttributes!==!0&&typeof t=="string"){const r=F0.getAllMatches(t,W_),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 d=r[o][4],l=this.options.attributeNamePrefix+c;if(c.length)if(this.options.transformAttributeName&&(l=this.options.transformAttributeName(l)),l==="__proto__"&&(l="#__proto__"),d!==void 0){this.options.trimValues&&(d=d.trim()),d=this.replaceEntitiesValue(d);const u=this.options.attributeValueProcessor(c,d,e);u==null?s[l]=d:typeof u!=typeof d||u!==d?s[l]=u:s[l]=Za(d,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(s[l]=!0)}if(!Object.keys(s).length)return;if(this.options.attributesGroupName){const o={};return o[this.options.attributesGroupName]=s,o}return s}}const Z_=function(t){t=t.replace(/\r\n?/g,`
8
+ `);const e=new Rr("!xml");let n=e,r="",i="";for(let s=0;s<t.length;s++)if(t[s]==="<")if(t[s+1]==="/"){const c=$n(t,">",s,"Closing Tag is not closed.");let d=t.substring(s+2,c).trim();if(this.options.removeNSPrefix){const p=d.indexOf(":");p!==-1&&(d=d.substr(p+1))}this.options.transformTagName&&(d=this.options.transformTagName(d)),n&&(r=this.saveTextToParentTag(r,n,i));const l=i.substring(i.lastIndexOf(".")+1);if(d&&this.options.unpairedTags.indexOf(d)!==-1)throw new Error(`Unpaired tag can not be used as closing tag: </${d}>`);let u=0;l&&this.options.unpairedTags.indexOf(l)!==-1?(u=i.lastIndexOf(".",i.lastIndexOf(".")-1),this.tagsNodeStack.pop()):u=i.lastIndexOf("."),i=i.substring(0,u),n=this.tagsNodeStack.pop(),r="",s=c}else if(t[s+1]==="?"){let c=Ja(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 d=new Rr(c.tagName);d.add(this.options.textNodeName,""),c.tagName!==c.tagExp&&c.attrExpPresent&&(d[":@"]=this.buildAttributesMap(c.tagExp,i,c.tagName)),this.addChild(n,d,i)}s=c.closeIndex+1}else if(t.substr(s+1,3)==="!--"){const c=$n(t,"-->",s+4,"Comment is not closed.");if(this.options.commentPropName){const d=t.substring(s+4,c-2);r=this.saveTextToParentTag(r,n,i),n.add(this.options.commentPropName,[{[this.options.textNodeName]:d}])}s=c}else if(t.substr(s+1,2)==="!D"){const c=F_(t,s);this.docTypeEntities=c.entities,s=c.i}else if(t.substr(s+1,2)==="!["){const c=$n(t,"]]>",s,"CDATA is not closed.")-2,d=t.substring(s+9,c);r=this.saveTextToParentTag(r,n,i);let l=this.parseTextData(d,n.tagname,i,!0,!1,!0,!0);l==null&&(l=""),this.options.cdataPropName?n.add(this.options.cdataPropName,[{[this.options.textNodeName]:d}]):n.add(this.options.textNodeName,l),s=c+2}else{let c=Ja(t,s,this.options.removeNSPrefix),d=c.tagName;const l=c.rawTagName;let u=c.tagExp,p=c.attrExpPresent,m=c.closeIndex;this.options.transformTagName&&(d=this.options.transformTagName(d)),n&&r&&n.tagname!=="!xml"&&(r=this.saveTextToParentTag(r,n,i,!1));const w=n;if(w&&this.options.unpairedTags.indexOf(w.tagname)!==-1&&(n=this.tagsNodeStack.pop(),i=i.substring(0,i.lastIndexOf("."))),d!==e.tagname&&(i+=i?"."+d:d),this.isItStopNode(this.options.stopNodes,i,d)){let h="";if(u.length>0&&u.lastIndexOf("/")===u.length-1)d[d.length-1]==="/"?(d=d.substr(0,d.length-1),i=i.substr(0,i.length-1),u=d):u=u.substr(0,u.length-1),s=c.closeIndex;else if(this.options.unpairedTags.indexOf(d)!==-1)s=c.closeIndex;else{const v=this.readStopNodeData(t,l,m+1);if(!v)throw new Error(`Unexpected end of ${l}`);s=v.i,h=v.tagContent}const _=new Rr(d);d!==u&&p&&(_[":@"]=this.buildAttributesMap(u,i,d)),h&&(h=this.parseTextData(h,d,i,!0,p,!0,!0)),i=i.substr(0,i.lastIndexOf(".")),_.add(this.options.textNodeName,h),this.addChild(n,_,i)}else{if(u.length>0&&u.lastIndexOf("/")===u.length-1){d[d.length-1]==="/"?(d=d.substr(0,d.length-1),i=i.substr(0,i.length-1),u=d):u=u.substr(0,u.length-1),this.options.transformTagName&&(d=this.options.transformTagName(d));const h=new Rr(d);d!==u&&p&&(h[":@"]=this.buildAttributesMap(u,i,d)),this.addChild(n,h,i),i=i.substr(0,i.lastIndexOf("."))}else{const h=new Rr(d);this.tagsNodeStack.push(n),d!==u&&p&&(h[":@"]=this.buildAttributesMap(u,i,d)),this.addChild(n,h,i),n=h}r="",s=m}}else r+=t[s];return e.child};function X_(t,e,n){const r=this.options.updateTag(e.tagname,n,e[":@"]);r===!1||(typeof r=="string"&&(e.tagname=r),t.addChild(e))}const Y_=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 Q_(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 ey(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 ty(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 $n(t,e,n,r){const i=t.indexOf(e,n);if(i===-1)throw new Error(r);return i+e.length-1}function Ja(t,e,n,r=">"){const i=ty(t,e+1,r);if(!i)return;let s=i.data;const o=i.index,c=s.search(/\s/);let d=s,l=!0;c!==-1&&(d=s.substring(0,c),s=s.substring(c+1).trimStart());const u=d;if(n){const p=d.indexOf(":");p!==-1&&(d=d.substr(p+1),l=d!==i.data.substr(p+1))}return{tagName:d,tagExp:s,closeIndex:o,attrExpPresent:l,rawTagName:u}}function ny(t,e,n){const r=n;let i=1;for(;n<t.length;n++)if(t[n]==="<")if(t[n+1]==="/"){const s=$n(t,">",n,`${e} is not closed`);if(t.substring(n+2,s).trim()===e&&(i--,i===0))return{tagContent:t.substring(r,n),i:s};n=s}else if(t[n+1]==="?")n=$n(t,"?>",n+1,"StopNode is not closed.");else if(t.substr(n+1,3)==="!--")n=$n(t,"-->",n+3,"StopNode is not closed.");else if(t.substr(n+1,2)==="![")n=$n(t,"]]>",n,"StopNode is not closed.")-2;else{const s=Ja(t,n,">");s&&((s&&s.tagName)===e&&s.tagExp[s.tagExp.length-1]!=="/"&&i++,n=s.closeIndex)}}function Za(t,e,n){if(e&&typeof t=="string"){const r=t.trim();return r==="true"?!0:r==="false"?!1:V_(t,n)}else return F0.isExist(t)?t:""}var ry=q_,V0={};function iy(t,e){return D0(t,e)}function D0(t,e,n){let r;const i={};for(let s=0;s<t.length;s++){const o=t[s],c=sy(o);let d="";if(n===void 0?d=c:d=n+"."+c,c===e.textNodeName)r===void 0?r=o[c]:r+=""+o[c];else{if(c===void 0)continue;if(o[c]){let l=D0(o[c],e,d);const u=ay(l,e);o[":@"]?oy(l,o[":@"],d,e):Object.keys(l).length===1&&l[e.textNodeName]!==void 0&&!e.alwaysCreateTextNode?l=l[e.textNodeName]:Object.keys(l).length===0&&(e.alwaysCreateTextNode?l[e.textNodeName]="":l=""),i[c]!==void 0&&i.hasOwnProperty(c)?(Array.isArray(i[c])||(i[c]=[i[c]]),i[c].push(l)):e.isArray(c,d,u)?i[c]=[l]:i[c]=l}}}return typeof r=="string"?r.length>0&&(i[e.textNodeName]=r):r!==void 0&&(i[e.textNodeName]=r),i}function sy(t){const e=Object.keys(t);for(let n=0;n<e.length;n++){const r=e[n];if(r!==":@")return r}}function oy(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 ay(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))}V0.prettify=iy;const{buildOptions:cy}=Ld,dy=ry,{prettify:ly}=V0,uy=Rd;let fy=class{constructor(e){this.externalEntities={},this.options=cy(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=uy.validate(e,n);if(s!==!0)throw Error(`${s.err.msg}:${s.err.line}:${s.err.col}`)}const r=new dy(this.options);r.addExternalEntities(this.externalEntities);const i=r.parseXml(e);return this.options.preserveOrder||i===void 0?i:ly(i,this.options)}addEntity(e,n){if(n.indexOf("&")!==-1)throw new Error("Entity value can't have '&'");if(e.indexOf("&")!==-1||e.indexOf(";")!==-1)throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");if(n==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[e]=n}};var py=fy;const hy=`
9
+ `;function gy(t,e){let n="";return e.format&&e.indentBy.length>0&&(n=hy),q0(t,e,"",n)}function q0(t,e,n,r){let i="",s=!1;for(let o=0;o<t.length;o++){const c=t[o],d=my(c);if(d===void 0)continue;let l="";if(n.length===0?l=d:l=`${n}.${d}`,d===e.textNodeName){let h=c[d];_y(l,e)||(h=e.tagValueProcessor(d,h),h=H0(h,e)),s&&(i+=r),i+=h,s=!1;continue}else if(d===e.cdataPropName){s&&(i+=r),i+=`<![CDATA[${c[d][0][e.textNodeName]}]]>`,s=!1;continue}else if(d===e.commentPropName){i+=r+`<!--${c[d][0][e.textNodeName]}-->`,s=!0;continue}else if(d[0]==="?"){const h=Eu(c[":@"],e),_=d==="?xml"?"":r;let v=c[d][0][e.textNodeName];v=v.length!==0?" "+v:"",i+=_+`<${d}${v}${h}?>`,s=!0;continue}let u=r;u!==""&&(u+=e.indentBy);const p=Eu(c[":@"],e),m=r+`<${d}${p}`,w=q0(c[d],e,l,u);e.unpairedTags.indexOf(d)!==-1?e.suppressUnpairedNode?i+=m+">":i+=m+"/>":(!w||w.length===0)&&e.suppressEmptyNode?i+=m+"/>":w&&w.endsWith(">")?i+=m+`>${w}${r}</${d}>`:(i+=m+">",w&&r!==""&&(w.includes("/>")||w.includes("</"))?i+=r+e.indentBy+w+r:i+=w,i+=`</${d}>`),s=!0}return i}function my(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 Eu(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=H0(i,e),i===!0&&e.suppressBooleanAttributes?n+=` ${r.substr(e.attributeNamePrefix.length)}`:n+=` ${r.substr(e.attributeNamePrefix.length)}="${i}"`}return n}function _y(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 H0(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 yy=gy;const wy=yy,vy=M0,by={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp("&","g"),val:"&amp;"},{regex:new RegExp(">","g"),val:"&gt;"},{regex:new RegExp("<","g"),val:"&lt;"},{regex:new RegExp("'","g"),val:"&apos;"},{regex:new RegExp('"',"g"),val:"&quot;"}],processEntities:!0,stopNodes:[],oneListGroup:!1};function fn(t){this.options=Object.assign({},by,t),this.options.ignoreAttributes===!0||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn=vy(this.options.ignoreAttributes),this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=ky),this.processTextOrObjNode=$y,this.options.format?(this.indentate=xy,this.tagEndChar=`>
10
10
  `,this.newLine=`
11
- `):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}fn.prototype.build=function(t){return this.options.preserveOrder?yy(t,this.options):(Array.isArray(t)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(t={[this.options.arrayNodeName]:t}),this.j2x(t,0,[]).val)};fn.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 d=this.options.tagValueProcessor(o,""+t[o]);i+=this.replaceEntitiesValue(d)}else i+=this.buildTextValNode(t[o],o,"",e)}else if(Array.isArray(t[o])){const c=t[o].length;let d="",l="";for(let u=0;u<c;u++){const p=t[o][u];if(!(typeof p>"u"))if(p===null)o[0]==="?"?i+=this.indentate(e)+"<"+o+"?"+this.tagEndChar:i+=this.indentate(e)+"<"+o+"/"+this.tagEndChar;else if(typeof p=="object")if(this.options.oneListGroup){const m=this.j2x(p,e+1,n.concat(o));d+=m.val,this.options.attributesGroupName&&p.hasOwnProperty(this.options.attributesGroupName)&&(l+=m.attrStr)}else d+=this.processTextOrObjNode(p,o,e,n);else if(this.options.oneListGroup){let m=this.options.tagValueProcessor(o,p);m=this.replaceEntitiesValue(m),d+=m}else d+=this.buildTextValNode(p,o,"",e)}this.options.oneListGroup&&(d=this.buildObjectNode(d,o,l,e)),i+=d}else if(this.options.attributesGroupName&&o===this.options.attributesGroupName){const c=Object.keys(t[o]),d=c.length;for(let l=0;l<d;l++)r+=this.buildAttrPairStr(c[l],""+t[o][c[l]])}else i+=this.processTextOrObjNode(t[o],o,e,n);return{attrStr:r,val:i}};fn.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 by(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)}fn.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}};fn.prototype.closeTag=function(t){let e="";return this.options.unpairedTags.indexOf(t)!==-1?this.options.suppressUnpairedNode||(e="/"):this.options.suppressEmptyNode?e="/":e=`></${t}`,e};fn.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}};fn.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 $y(t){return this.options.indentBy.repeat(t)}function xy(t){return t.startsWith(this.options.attributeNamePrefix)&&t!==this.options.textNodeName?t.substr(this.attrPrefixLen):!1}var ky=fn;const Sy=Rd,Ay=fy,Ey=ky;var Iy={XMLParser:Ay,XMLValidator:Sy,XMLBuilder:Ey};function Ny(t,e,n){const r=n?`<input type="hidden" name="RelayState" value="${n}" />`:"",i=`
11
+ `):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}fn.prototype.build=function(t){return this.options.preserveOrder?wy(t,this.options):(Array.isArray(t)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(t={[this.options.arrayNodeName]:t}),this.j2x(t,0,[]).val)};fn.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 d=this.options.tagValueProcessor(o,""+t[o]);i+=this.replaceEntitiesValue(d)}else i+=this.buildTextValNode(t[o],o,"",e)}else if(Array.isArray(t[o])){const c=t[o].length;let d="",l="";for(let u=0;u<c;u++){const p=t[o][u];if(!(typeof p>"u"))if(p===null)o[0]==="?"?i+=this.indentate(e)+"<"+o+"?"+this.tagEndChar:i+=this.indentate(e)+"<"+o+"/"+this.tagEndChar;else if(typeof p=="object")if(this.options.oneListGroup){const m=this.j2x(p,e+1,n.concat(o));d+=m.val,this.options.attributesGroupName&&p.hasOwnProperty(this.options.attributesGroupName)&&(l+=m.attrStr)}else d+=this.processTextOrObjNode(p,o,e,n);else if(this.options.oneListGroup){let m=this.options.tagValueProcessor(o,p);m=this.replaceEntitiesValue(m),d+=m}else d+=this.buildTextValNode(p,o,"",e)}this.options.oneListGroup&&(d=this.buildObjectNode(d,o,l,e)),i+=d}else if(this.options.attributesGroupName&&o===this.options.attributesGroupName){const c=Object.keys(t[o]),d=c.length;for(let l=0;l<d;l++)r+=this.buildAttrPairStr(c[l],""+t[o][c[l]])}else i+=this.processTextOrObjNode(t[o],o,e,n);return{attrStr:r,val:i}};fn.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 $y(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)}fn.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}};fn.prototype.closeTag=function(t){let e="";return this.options.unpairedTags.indexOf(t)!==-1?this.options.suppressUnpairedNode||(e="/"):this.options.suppressEmptyNode?e="/":e=`></${t}`,e};fn.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}};fn.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 xy(t){return this.options.indentBy.repeat(t)}function ky(t){return t.startsWith(this.options.attributeNamePrefix)&&t!==this.options.textNodeName?t.substr(this.attrPrefixLen):!1}var Sy=fn;const Ay=Rd,Ey=py,Iy=Sy;var Ny={XMLParser:Ey,XMLValidator:Ay,XMLBuilder:Iy};function Cy(t,e,n){const r=n?`<input type="hidden" name="RelayState" value="${n}" />`:"",i=`
12
12
  <!DOCTYPE html>
13
13
  <html>
14
14
  <body onload="document.forms[0].submit()">
@@ -26,7 +26,7 @@
26
26
  }};
27
27
  <\/script>
28
28
  </body>
29
- </html>`;return new Response(i,{headers:{"Content-Type":"text/html"}})}async function Cy(t,e,n,r,i){var m,w,h;if(!n.redirect_uri)throw new N(400,{message:"Missing redirect_uri in authParams"});if(!r.email)throw new N(400,{message:"Missing email in user"});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,d=n.state||"";if(!o||!d||!r||!n.state)throw new N(400,{message:"Missing recipient or inResponseTo"});const l=JSON.parse(n.state),u=new URL(n.redirect_uri),p=await zy(t,{issuer:t.env.ISSUER,audience:c||n.client_id,destination:u.toString(),inResponseTo:l.requestId,userId:((h=(w=r.app_metadata)==null?void 0:w.vimeo)==null?void 0:h.user_id)||r.user_id,email:r.email,sessionIndex:i,signature:{privateKeyPem:s.pkcs7,cert:s.cert,kid:s.kid}});return Ny(u.toString(),p,l.relayState)}async function zy(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||`_${xe()}`,c=e.assertionId||`_${xe()}`,d=[{"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 u=new Iy.XMLBuilder({ignoreAttributes:!1,suppressEmptyNode:!0,preserveOrder:!0}).build(d);if(e.signature){const m=await fetch(t.env.SAML_SIGN_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({xmlContent:u,privateKey:e.signature.privateKeyPem,publicCert:e.signature.cert})});if(!m.ok)throw new Error(`Failed to sign SAML response: ${m.status}`);u=await m.text()}return e.encode===!1?u:btoa(u)}var Oy={deno:"Deno",bun:"Bun",workerd:"Cloudflare-Workers",node:"Node.js"},Py=()=>{var n,r;const t=globalThis;if(typeof navigator<"u"&&typeof navigator.userAgent=="string"){for(const[i,s]of Object.entries(Oy))if(jy(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"},jy=t=>navigator.userAgent.startsWith(t);function It(t,e){Py()==="workerd"&&t.executionCtx.waitUntil(e)}function Ot(t){var e,n,r,i;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),countryCode:(i=t.header("cf-ipcountry"))==null?void 0:i.slice(0,2)}}const Iu=["sub","iss","aud","exp","nbf","iat","jti"];async function _o(t,e){var v,k;const{authParams:n,user:r,client:i,session_id:s}=e,c=(await t.env.data.keys.list()).filter(I=>!I.revoked_at||new Date(I.revoked_at)>new Date),d=c[c.length-1];if(!(d!=null&&d.pkcs7))throw new N(500,{message:"No signing key available"});const l=e_(d.pkcs7),u=t.var.custom_domain?`https://${t.var.custom_domain}/`:t.env.ISSUER,p={aud:n.audience||"default",scope:n.scope||"",sub:(r==null?void 0:r.user_id)||n.client_id,iss:u,tenant_id:t.var.tenant_id,sid:s},m=r&&((v=n.scope)!=null&&v.split(" ").includes("openid"))?{aud:n.client_id,sub:r.user_id,iss:u,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;(k=t.env.hooks)!=null&&k.onExecuteCredentialsExchange&&await t.env.hooks.onExecuteCredentialsExchange({client:i,user:r,request:{ip:t.req.header("x-real-ip")||"",user_agent:t.req.header("user-agent")||"",method:t.req.method,url:t.req.url},scope:n.scope||"",grant_type:""},{accessToken:{setCustomClaim:(I,O)=>{if(Iu.includes(I))throw new Error(`Cannot overwrite reserved claim '${I}'`);p[I]=O}},idToken:{setCustomClaim:(I,O)=>{if(Iu.includes(I))throw new Error(`Cannot overwrite reserved claim '${I}'`);m&&(m[I]=O)}},access:{deny:I=>{throw new N(400,{message:`Access denied: ${I}`})}}});const w={includeIssuedTimestamp:!0,expiresIn:new Pd(1,"d"),headers:{kid:d.kid}},h=await $u("RS256",l,p,w),_=m?await $u("RS256",l,m,w):void 0;return{access_token:h,refresh_token:e.refresh_token,id_token:_,token_type:"Bearer",expires_in:86400}}async function K0(t,e){return e.loginSession||(e.loginSession=await t.env.data.loginSessions.create(e.client.tenant.id,{expires_at:new Date(Date.now()+or*1e3).toISOString(),authParams:e.authParams,authorization_url:t.req.url,csrf_token:xe(),...Ot(t.req)})),{code:(await t.env.data.codes.create(e.client.tenant.id,{code_id:xe(),user_id:e.user.user_id,code_type:"authorization_code",login_id:e.loginSession.id,expires_at:new Date(Date.now()+i_*1e3).toISOString()})).code_id,state:e.authParams.state}}async function Ty(t,e){const{client:n,scope:r,audience:i=n.tenant.audience,session_id:s}=e,o=Ot(t.req);return await t.env.data.refreshTokens.create(n.tenant.id,{id:xe(),session_id:s,client_id:n.id,idle_expires_at:new Date(Date.now()+go*1e3).toISOString(),user_id:e.user.user_id,device:{last_ip:o.ip||"",initial_ip:o.ip||"",last_user_agent:o.useragent||"",initial_user_agent:o.useragent||"",initial_asn:"",last_asn:""},resource_servers:[{audience:i,scopes:r}],rotating:!1})}async function G0(t,{user:e,client:n,loginSession:r}){const i=await t.env.data.sessions.create(n.tenant.id,{id:xe(),user_id:e.user_id,idle_expires_at:new Date(Date.now()+go*1e3).toISOString(),device:{last_ip:t.req.header("x-real-ip")||"",initial_ip:t.req.header("x-real-ip")||"",last_user_agent:t.req.header("user-agent")||"",initial_user_agent:t.req.header("user-agent")||"",initial_asn:"",last_asn:""},clients:[n.id]});await t.env.data.loginSessions.update(n.tenant.id,r.id,{session_id:i.id});const{scope:s,audience:o}=r.authParams,c=s!=null&&s.split(" ").includes("offline_access")?await Ty(t,{session_id:i.id,user:e,client:n,scope:s,audience:o}):void 0;return{...i,refresh_token:c}}async function pn(t,e){var w,h;const{authParams:n,user:r,client:i,ticketAuth:s}=e,o=we(t,{type:ge.SUCCESS_LOGIN,description:`Successful login for ${r.user_id}`,userId:r.user_id});if(It(t,t.env.data.logs.create(i.tenant.id,o)),It(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 _=Q1(),v=xe(12),k=await t.env.data.codes.create(i.tenant.id,{code_id:xe(),code_type:"ticket",login_id:e.loginSession.id,expires_at:new Date(Date.now()+o_).toISOString(),code_verifier:[v,_].join("|")});return t.json({login_ticket:k.code_id,co_verifier:_,co_id:v})}let c=e.refreshToken,d=e.sessionId,l=r;if(!d&&((w=e.loginSession)!=null&&w.session_id)){d=e.loginSession.session_id;const _=await t.env.data.sessions.get(i.tenant.id,d);_&&!_.clients.includes(i.id)&&await t.env.data.sessions.update(i.tenant.id,d,{clients:[..._.clients,i.id]})}else if(!d){if(!e.loginSession)throw new N(500,{message:"Login session not found"});l=await Uy(t,t.env.data)(i.tenant.id,r);const _=await G0(t,{user:r,client:i,loginSession:e.loginSession});d=_.id,c=(h=_.refresh_token)==null?void 0:h.id}if(e.authParams.response_mode===Ft.SAML_POST)return Cy(t,e.client,e.authParams,l,d);const u=await _o(t,{authParams:n,user:l,client:i,session_id:d,refresh_token:c}),p=new Headers({"set-cookie":L0(i.tenant.id,d,t.var.custom_domain||t.req.header("host"))});if(n.response_mode===Ft.WEB_MESSAGE)return t.json(u,{headers:p});if((n.response_type||Ct.CODE)===Ct.CODE){const _=await K0(t,e);if(!n.redirect_uri)throw new N(400,{message:"Redirect uri not found"});const v=new URL(n.redirect_uri);v.searchParams.set("code",_.code),_.state&&v.searchParams.set("state",_.state),p.set("location",v.toString())}return new Response("Redirecting",{status:302,headers:p})}async function Ry(t,e,n){const r=await t.env.data.tenants.get(e);if(!r)throw new Error(`Tenant not found: ${e}`);return _o(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:Ct.TOKEN,scope:n}})}async function Ud(t,e,n){const r=await Ry(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=we(t,{type:ge.FAILED_HOOK,description:`Failed to invoke hook ${i.hook_id}`});await t.env.data.logs.create(n.tenant_id,o)}}function By(t){return async(e,n)=>{const{hooks:r}=await t.env.data.hooks.list(e);return await Ud(t,r,{tenant_id:e,user:n,trigger_id:"post-user-registration"}),n}}function Ly(t){return async(e,n)=>{const{hooks:r}=await t.env.data.hooks.list(e,{q:"trigger_id:pre-user-signup",page:0,per_page:100,include_totals:!1});await Ud(t,r,{tenant_id:e,email:n,trigger_id:"pre-user-signup"})}}function Uy(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 Ud(t,i,{tenant_id:n,user:r,trigger_id:"post-user-login"}),r}}function My(t,e){return async(n,r)=>{var o,c,d;const i={method:t.req.method,ip:t.req.query("x-real-ip")||"",user_agent:t.req.query("user-agent"),url:((o=t.var.loginSession)==null?void 0:o.authorization_url)||t.req.url};if((c=t.env.hooks)!=null&&c.onExecutePreUserRegistration)try{await t.env.hooks.onExecutePreUserRegistration({user:r,request:i},{user:{setUserMetadata:async(l,u)=>{r[l]=u}}})}catch{const u=we(t,{type:ge.FAILED_SIGNUP,description:"Pre user registration hook failed"});await e.logs.create(n,u)}let s=await K1(e)(n,r);if((d=t.env.hooks)!=null&&d.onExecutePostUserRegistration)try{await t.env.hooks.onExecutePostUserRegistration({user:r,request:i},{user:{}})}catch{const u=we(t,{type:ge.FAILED_SIGNUP,description:"Post user registration hook failed"});await t.env.data.logs.create(n,u)}return await By(t)(n,s),s}}async function Fy(t,e,n,r){var i;if(e.disable_sign_ups){const s=(i=t.var.loginSession)==null?void 0:i.authorization_url;if(!(s&&new URL(s).searchParams.get("screen_hint")==="signup")&&!await wo({userAdapter:n.users,tenant_id:e.tenant.id,email:r})){const d=we(t,{type:ge.FAILED_SIGNUP,description:"Public signup is disabled"});throw await n.logs.create(e.tenant.id,d),new N(400,{message:"Signups are disabled for this client"})}}await Ly(t)(t.var.tenant_id||"",r)}function yo(t,e){return{...e,users:{...e.users,create:My(t,e)}}}function W0(t){return yo(t,t.env.data)}async function Md(t,e,n){return(await t.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${n}`})).users}async function vr({userAdapter:t,tenant_id:e,username:n,provider:r}){const i=r==="sms"?`phone_number:${n}`:`email:${n}`,{users:s}=await t.list(e,{page:0,per_page:10,include_totals:!1,q:`${i} provider:${r}`});return s.length>1&&console.error("More than one user found for same email and provider"),s[0]||null}async function wo({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(d=>!(d.provider==="auth2"&&!d.email_verified));if(i.length===0)return;const s=i.filter(d=>!d.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 $s({userAdapter:t,tenant_id:e,username:n,provider:r}){const i=await vr({userAdapter:t,tenant_id:e,username:n,provider:r});return i?i.linked_to?t.get(e,i.linked_to):i:null}async function vo(t,e){const{username:n,provider:r,connection:i,client:s,userId:o,isSocial:c,profileData:d={},ip:l=""}=e;let u=await $s({userAdapter:t.env.data.users,tenant_id:e.client.tenant.id,username:n,provider:r});if(!u){const p={user_id:`${r}|${o||ho()}`,email:i!=="sms"?n:void 0,phone_number:i==="sms"?n:void 0,name:n,provider:r,connection:i,email_verified:!0,last_ip:l,is_social:c,last_login:new Date().toISOString(),profileData:JSON.stringify(d)};u=await W0(t).users.create(s.tenant.id,p),t.set("user_id",u.user_id)}return u}const on=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 br(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 Nu=un.extend({users:a.z.array(At)}),Vy=un.extend({sessions:a.z.array(po)}),Dy=new a.OpenAPIHono().openapi(a.createRoute({tags:["users"],method:"get",path:"/",request:{query:on,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(At),Nu])}},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 u=s.split("=")[1],m=(await t.env.data.users.list(o,{page:e,per_page:n,include_totals:r,q:`email:${u}`})).users.filter(_=>_.linked_to),[w]=m;if(!w)return t.json([]);const h=await t.env.data.users.get(o,w.linked_to);if(!h)throw new N(500,{message:"Primary account not found"});return t.json([At.parse(h)])}const c=["-_exists_:linked_to"];s&&c.push(s);const d=await t.env.data.users.list(o,{page:e,per_page:n,include_totals:r,sort:br(i),q:c.join(" ")}),l=d.users.filter(u=>!u.linked_to);return r?t.json(Nu.parse({users:l,length:d.length,start:d.start,limit:d.limit})):t.json(a.z.array(At).parse(l))}).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:At}},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({...hs.shape})}}}},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:At}},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||ho()}`;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=we(t,{type:ge.SUCCESS_API_OPERATION,description:"User created"});It(t,t.env.data.logs.create(e,c));const d={...o,identities:[{connection:o.connection,provider:o.provider,user_id:vu(o.user_id),isSocial:o.is_social}]};return t.json(At.parse(d),{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({...hs.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{data:e}=t.env,{"tenant-id":n}=t.req.valid("header"),r=t.req.valid("json"),{user_id:i}=t.req.valid("param"),{verify_email:s,password:o,...c}=r,d=await e.users.get(n,i);if(!d)throw new N(404);if(c.email&&c.email!==d.email){const p=await Md(t.env.data.users,n,c.email);if(p.length&&p.some(m=>m.user_id!==i))throw new N(409,{message:"Another user with the same email address already exists."})}if(d.linked_to)throw new N(404,{message:"User is linked to another user"});if(await t.env.data.users.update(n,i,c),o){const p=(u=d.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"});const m={user_id:p.user_id,password:await gi.hash(o,10),algorithm:"bcrypt"};await e.passwords.get(n,p.user_id)?await e.passwords.update(n,m):await e.passwords.create(n,m)}const l=await t.env.data.users.get(n,i);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:{201:{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(d=>({connection:d.connection,provider:d.provider,user_id:vu(d.user_id),isSocial:d.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(At)}},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([At.parse(s)])}).openapi(a.createRoute({tags:["users"],method:"get",path:"/{user_id}/sessions",request:{query:on,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(po),Vy])}},description:"List of sessions"}}}),async t=>{const{user_id:e}=t.req.valid("param"),{include_totals:n}=t.req.valid("query"),{"tenant-id":r}=t.req.valid("header"),i=await t.env.data.sessions.list(r,{page:0,per_page:10,include_totals:!1,q:`user_id:${e}`});return n?t.json(i):t.json(i.sessions)});/*! *****************************************************************************
29
+ </html>`;return new Response(i,{headers:{"Content-Type":"text/html"}})}async function zy(t,e,n,r,i){var m,w,h;if(!n.redirect_uri)throw new N(400,{message:"Missing redirect_uri in authParams"});if(!r.email)throw new N(400,{message:"Missing email in user"});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,d=n.state||"";if(!o||!d||!r||!n.state)throw new N(400,{message:"Missing recipient or inResponseTo"});const l=JSON.parse(n.state),u=new URL(n.redirect_uri),p=await Oy(t,{issuer:t.env.ISSUER,audience:c||n.client_id,destination:u.toString(),inResponseTo:l.requestId,userId:((h=(w=r.app_metadata)==null?void 0:w.vimeo)==null?void 0:h.user_id)||r.user_id,email:r.email,sessionIndex:i,signature:{privateKeyPem:s.pkcs7,cert:s.cert,kid:s.kid}});return Cy(u.toString(),p,l.relayState)}async function Oy(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||`_${xe()}`,c=e.assertionId||`_${xe()}`,d=[{"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 u=new Ny.XMLBuilder({ignoreAttributes:!1,suppressEmptyNode:!0,preserveOrder:!0}).build(d);if(e.signature){const m=await fetch(t.env.SAML_SIGN_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({xmlContent:u,privateKey:e.signature.privateKeyPem,publicCert:e.signature.cert})});if(!m.ok)throw new Error(`Failed to sign SAML response: ${m.status}`);u=await m.text()}return e.encode===!1?u:btoa(u)}var Py={deno:"Deno",bun:"Bun",workerd:"Cloudflare-Workers",node:"Node.js"},jy=()=>{var n,r;const t=globalThis;if(typeof navigator<"u"&&typeof navigator.userAgent=="string"){for(const[i,s]of Object.entries(Py))if(Ty(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"},Ty=t=>navigator.userAgent.startsWith(t);function It(t,e){jy()==="workerd"&&t.executionCtx.waitUntil(e)}function Ot(t){var e,n,r,i;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),countryCode:(i=t.header("cf-ipcountry"))==null?void 0:i.slice(0,2)}}const Iu=["sub","iss","aud","exp","nbf","iat","jti"];async function yo(t,e){var v,k;const{authParams:n,user:r,client:i,session_id:s}=e,c=(await t.env.data.keys.list()).filter(I=>!I.revoked_at||new Date(I.revoked_at)>new Date),d=c[c.length-1];if(!(d!=null&&d.pkcs7))throw new N(500,{message:"No signing key available"});const l=t_(d.pkcs7),u=t.var.custom_domain?`https://${t.var.custom_domain}/`:t.env.ISSUER,p={aud:n.audience||"default",scope:n.scope||"",sub:(r==null?void 0:r.user_id)||n.client_id,iss:u,tenant_id:t.var.tenant_id,sid:s},m=r&&((v=n.scope)!=null&&v.split(" ").includes("openid"))?{aud:n.client_id,sub:r.user_id,iss:u,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;(k=t.env.hooks)!=null&&k.onExecuteCredentialsExchange&&await t.env.hooks.onExecuteCredentialsExchange({client:i,user:r,request:{ip:t.req.header("x-real-ip")||"",user_agent:t.req.header("user-agent")||"",method:t.req.method,url:t.req.url},scope:n.scope||"",grant_type:""},{accessToken:{setCustomClaim:(I,O)=>{if(Iu.includes(I))throw new Error(`Cannot overwrite reserved claim '${I}'`);p[I]=O}},idToken:{setCustomClaim:(I,O)=>{if(Iu.includes(I))throw new Error(`Cannot overwrite reserved claim '${I}'`);m&&(m[I]=O)}},access:{deny:I=>{throw new N(400,{message:`Access denied: ${I}`})}}});const w={includeIssuedTimestamp:!0,expiresIn:new Pd(1,"d"),headers:{kid:d.kid}},h=await $u("RS256",l,p,w),_=m?await $u("RS256",l,m,w):void 0;return{access_token:h,refresh_token:e.refresh_token,id_token:_,token_type:"Bearer",expires_in:86400}}async function K0(t,e){return e.loginSession||(e.loginSession=await t.env.data.loginSessions.create(e.client.tenant.id,{expires_at:new Date(Date.now()+or*1e3).toISOString(),authParams:e.authParams,authorization_url:t.req.url,csrf_token:xe(),...Ot(t.req)})),{code:(await t.env.data.codes.create(e.client.tenant.id,{code_id:xe(),user_id:e.user.user_id,code_type:"authorization_code",login_id:e.loginSession.id,expires_at:new Date(Date.now()+s_*1e3).toISOString()})).code_id,state:e.authParams.state}}async function Ry(t,e){const{client:n,scope:r,audience:i=n.tenant.audience,session_id:s}=e,o=Ot(t.req);return await t.env.data.refreshTokens.create(n.tenant.id,{id:xe(),session_id:s,client_id:n.id,idle_expires_at:new Date(Date.now()+mo*1e3).toISOString(),user_id:e.user.user_id,device:{last_ip:o.ip||"",initial_ip:o.ip||"",last_user_agent:o.useragent||"",initial_user_agent:o.useragent||"",initial_asn:"",last_asn:""},resource_servers:[{audience:i,scopes:r}],rotating:!1})}async function G0(t,{user:e,client:n,loginSession:r}){const i=await t.env.data.sessions.create(n.tenant.id,{id:xe(),user_id:e.user_id,idle_expires_at:new Date(Date.now()+mo*1e3).toISOString(),device:{last_ip:t.req.header("x-real-ip")||"",initial_ip:t.req.header("x-real-ip")||"",last_user_agent:t.req.header("user-agent")||"",initial_user_agent:t.req.header("user-agent")||"",initial_asn:"",last_asn:""},clients:[n.id]});await t.env.data.loginSessions.update(n.tenant.id,r.id,{session_id:i.id});const{scope:s,audience:o}=r.authParams,c=s!=null&&s.split(" ").includes("offline_access")?await Ry(t,{session_id:i.id,user:e,client:n,scope:s,audience:o}):void 0;return{...i,refresh_token:c}}async function pn(t,e){var w,h;const{authParams:n,user:r,client:i,ticketAuth:s}=e,o=we(t,{type:ge.SUCCESS_LOGIN,description:`Successful login for ${r.user_id}`,userId:r.user_id});if(It(t,t.env.data.logs.create(i.tenant.id,o)),It(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 _=e_(),v=xe(12),k=await t.env.data.codes.create(i.tenant.id,{code_id:xe(),code_type:"ticket",login_id:e.loginSession.id,expires_at:new Date(Date.now()+a_).toISOString(),code_verifier:[v,_].join("|")});return t.json({login_ticket:k.code_id,co_verifier:_,co_id:v})}let c=e.refreshToken,d=e.sessionId,l=r;if(!d&&((w=e.loginSession)!=null&&w.session_id)){d=e.loginSession.session_id;const _=await t.env.data.sessions.get(i.tenant.id,d);_&&!_.clients.includes(i.id)&&await t.env.data.sessions.update(i.tenant.id,d,{clients:[..._.clients,i.id]})}else if(!d){if(!e.loginSession)throw new N(500,{message:"Login session not found"});l=await My(t,t.env.data)(i.tenant.id,r);const _=await G0(t,{user:r,client:i,loginSession:e.loginSession});d=_.id,c=(h=_.refresh_token)==null?void 0:h.id}if(e.authParams.response_mode===Ft.SAML_POST)return zy(t,e.client,e.authParams,l,d);const u=await yo(t,{authParams:n,user:l,client:i,session_id:d,refresh_token:c}),p=new Headers({"set-cookie":L0(i.tenant.id,d,t.var.custom_domain||t.req.header("host"))});if(n.response_mode===Ft.WEB_MESSAGE)return t.json(u,{headers:p});if((n.response_type||Ct.CODE)===Ct.CODE){const _=await K0(t,e);if(!n.redirect_uri)throw new N(400,{message:"Redirect uri not found"});const v=new URL(n.redirect_uri);v.searchParams.set("code",_.code),_.state&&v.searchParams.set("state",_.state),p.set("location",v.toString())}return new Response("Redirecting",{status:302,headers:p})}async function By(t,e,n){const r=await t.env.data.tenants.get(e);if(!r)throw new Error(`Tenant not found: ${e}`);return yo(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:Ct.TOKEN,scope:n}})}async function Ud(t,e,n){const r=await By(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=we(t,{type:ge.FAILED_HOOK,description:`Failed to invoke hook ${i.hook_id}`});await t.env.data.logs.create(n.tenant_id,o)}}function Ly(t){return async(e,n)=>{const{hooks:r}=await t.env.data.hooks.list(e);return await Ud(t,r,{tenant_id:e,user:n,trigger_id:"post-user-registration"}),n}}function Uy(t){return async(e,n)=>{const{hooks:r}=await t.env.data.hooks.list(e,{q:"trigger_id:pre-user-signup",page:0,per_page:100,include_totals:!1});await Ud(t,r,{tenant_id:e,email:n,trigger_id:"pre-user-signup"})}}function My(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 Ud(t,i,{tenant_id:n,user:r,trigger_id:"post-user-login"}),r}}function Fy(t,e){return async(n,r)=>{var o,c,d;const i={method:t.req.method,ip:t.req.query("x-real-ip")||"",user_agent:t.req.query("user-agent"),url:((o=t.var.loginSession)==null?void 0:o.authorization_url)||t.req.url};if((c=t.env.hooks)!=null&&c.onExecutePreUserRegistration)try{await t.env.hooks.onExecutePreUserRegistration({user:r,request:i},{user:{setUserMetadata:async(l,u)=>{r[l]=u}}})}catch{const u=we(t,{type:ge.FAILED_SIGNUP,description:"Pre user registration hook failed"});await e.logs.create(n,u)}let s=await G1(e)(n,r);if((d=t.env.hooks)!=null&&d.onExecutePostUserRegistration)try{await t.env.hooks.onExecutePostUserRegistration({user:r,request:i},{user:{}})}catch{const u=we(t,{type:ge.FAILED_SIGNUP,description:"Post user registration hook failed"});await t.env.data.logs.create(n,u)}return await Ly(t)(n,s),s}}async function Vy(t,e,n,r){var i;if(e.disable_sign_ups){const s=(i=t.var.loginSession)==null?void 0:i.authorization_url;if(!(s&&new URL(s).searchParams.get("screen_hint")==="signup")&&!await vo({userAdapter:n.users,tenant_id:e.tenant.id,email:r})){const d=we(t,{type:ge.FAILED_SIGNUP,description:"Public signup is disabled"});throw await n.logs.create(e.tenant.id,d),new N(400,{message:"Signups are disabled for this client"})}}await Uy(t)(t.var.tenant_id||"",r)}function wo(t,e){return{...e,users:{...e.users,create:Fy(t,e)}}}function W0(t){return wo(t,t.env.data)}async function Md(t,e,n){return(await t.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${n}`})).users}async function vr({userAdapter:t,tenant_id:e,username:n,provider:r}){const i=r==="sms"?`phone_number:${n}`:`email:${n}`,{users:s}=await t.list(e,{page:0,per_page:10,include_totals:!1,q:`${i} provider:${r}`});return s.length>1&&console.error("More than one user found for same email and provider"),s[0]||null}async function vo({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(d=>!(d.provider==="auth2"&&!d.email_verified));if(i.length===0)return;const s=i.filter(d=>!d.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 xs({userAdapter:t,tenant_id:e,username:n,provider:r}){const i=await vr({userAdapter:t,tenant_id:e,username:n,provider:r});return i?i.linked_to?t.get(e,i.linked_to):i:null}async function bo(t,e){const{username:n,provider:r,connection:i,client:s,userId:o,isSocial:c,profileData:d={},ip:l=""}=e;let u=await xs({userAdapter:t.env.data.users,tenant_id:e.client.tenant.id,username:n,provider:r});if(!u){const p={user_id:`${r}|${o||go()}`,email:i!=="sms"?n:void 0,phone_number:i==="sms"?n:void 0,name:n,provider:r,connection:i,email_verified:!0,last_ip:l,is_social:c,last_login:new Date().toISOString(),profileData:JSON.stringify(d)};u=await W0(t).users.create(s.tenant.id,p),t.set("user_id",u.user_id)}return u}const on=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 br(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 Nu=un.extend({users:a.z.array(At)}),Dy=un.extend({sessions:a.z.array(ho)}),qy=new a.OpenAPIHono().openapi(a.createRoute({tags:["users"],method:"get",path:"/",request:{query:on,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(At),Nu])}},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 u=s.split("=")[1],m=(await t.env.data.users.list(o,{page:e,per_page:n,include_totals:r,q:`email:${u}`})).users.filter(_=>_.linked_to),[w]=m;if(!w)return t.json([]);const h=await t.env.data.users.get(o,w.linked_to);if(!h)throw new N(500,{message:"Primary account not found"});return t.json([At.parse(h)])}const c=["-_exists_:linked_to"];s&&c.push(s);const d=await t.env.data.users.list(o,{page:e,per_page:n,include_totals:r,sort:br(i),q:c.join(" ")}),l=d.users.filter(u=>!u.linked_to);return r?t.json(Nu.parse({users:l,length:d.length,start:d.start,limit:d.limit})):t.json(a.z.array(At).parse(l))}).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:At}},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({...gs.shape})}}}},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:At}},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||go()}`;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=we(t,{type:ge.SUCCESS_API_OPERATION,description:"User created"});It(t,t.env.data.logs.create(e,c));const d={...o,identities:[{connection:o.connection,provider:o.provider,user_id:vu(o.user_id),isSocial:o.is_social}]};return t.json(At.parse(d),{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({...gs.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{data:e}=t.env,{"tenant-id":n}=t.req.valid("header"),r=t.req.valid("json"),{user_id:i}=t.req.valid("param"),{verify_email:s,password:o,...c}=r,d=await e.users.get(n,i);if(!d)throw new N(404);if(c.email&&c.email!==d.email){const p=await Md(t.env.data.users,n,c.email);if(p.length&&p.some(m=>m.user_id!==i))throw new N(409,{message:"Another user with the same email address already exists."})}if(d.linked_to)throw new N(404,{message:"User is linked to another user"});if(await t.env.data.users.update(n,i,c),o){const p=(u=d.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"});const m={user_id:p.user_id,password:await mi.hash(o,10),algorithm:"bcrypt"};await e.passwords.get(n,p.user_id)?await e.passwords.update(n,m):await e.passwords.create(n,m)}const l=await t.env.data.users.get(n,i);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:{201:{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(d=>({connection:d.connection,provider:d.provider,user_id:vu(d.user_id),isSocial:d.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(At)}},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([At.parse(s)])}).openapi(a.createRoute({tags:["users"],method:"get",path:"/{user_id}/sessions",request:{query:on,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(ho),Dy])}},description:"List of sessions"}}}),async t=>{const{user_id:e}=t.req.valid("param"),{include_totals:n}=t.req.valid("query"),{"tenant-id":r}=t.req.valid("header"),i=await t.env.data.sessions.list(r,{page:0,per_page:10,include_totals:!1,q:`user_id:${e}`});return n?t.json(i):t.json(i.sessions)});/*! *****************************************************************************
30
30
  Copyright (C) Microsoft. All rights reserved.
31
31
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use
32
32
  this file except in compliance with the License. You may obtain a copy of the
@@ -39,7 +39,7 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
39
39
 
40
40
  See the Apache Version 2.0 License for specific language governing permissions
41
41
  and limitations under the License.
42
- ***************************************************************************** */var Cu;(function(t){(function(e){var n=typeof globalThis=="object"?globalThis:typeof vs=="object"?vs: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(d,l){return function(u,p){Object.defineProperty(d,u,{configurable:!0,writable:!0,value:p}),l&&l(u,p)}}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",d={__proto__:[]}instanceof Array,l=!c&&!d,u={create:c?function(){return ya(Object.create(null))}:d?function(){return ya({__proto__:null})}:function(){return ya({})},has:l?function(S,E){return r.call(S,E)}:function(S,E){return E in S},get:l?function(S,E){return r.call(S,E)?S[E]:void 0}:function(S,E){return S[E]}},p=Object.getPrototypeOf(Function),m=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:Zm(),w=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:Xm(),h=typeof WeakMap=="function"?WeakMap:Ym(),_=i?Symbol.for("@reflect-metadata:registry"):void 0,v=Gm(),k=Wm(v);function I(S,E,j,M){if(q(j)){if(!eu(S))throw new TypeError;if(!tu(E))throw new TypeError;return C(S,E)}else{if(!eu(S))throw new TypeError;if(!he(E))throw new TypeError;if(!he(M)&&!q(M)&&!Oe(M))throw new TypeError;return Oe(M)&&(M=void 0),j=xt(j),A(S,E,j,M)}}e("decorate",I);function O(S,E){function j(M,ee){if(!he(M))throw new TypeError;if(!q(ee)&&!Hm(ee))throw new TypeError;Q(S,E,M,ee)}return j}e("metadata",O);function L(S,E,j,M){if(!he(j))throw new TypeError;return q(M)||(M=xt(M)),Q(S,E,j,M)}e("defineMetadata",L);function Y(S,E,j){if(!he(E))throw new TypeError;return q(j)||(j=xt(j)),x(S,E,j)}e("hasMetadata",Y);function oe(S,E,j){if(!he(E))throw new TypeError;return q(j)||(j=xt(j)),$(S,E,j)}e("hasOwnMetadata",oe);function ae(S,E,j){if(!he(E))throw new TypeError;return q(j)||(j=xt(j)),P(S,E,j)}e("getMetadata",ae);function ke(S,E,j){if(!he(E))throw new TypeError;return q(j)||(j=xt(j)),U(S,E,j)}e("getOwnMetadata",ke);function Ee(S,E){if(!he(S))throw new TypeError;return q(E)||(E=xt(E)),W(S,E)}e("getMetadataKeys",Ee);function ze(S,E){if(!he(S))throw new TypeError;return q(E)||(E=xt(E)),se(S,E)}e("getOwnMetadataKeys",ze);function z(S,E,j){if(!he(E))throw new TypeError;if(q(j)||(j=xt(j)),!he(E))throw new TypeError;q(j)||(j=xt(j));var M=Pr(E,j,!1);return q(M)?!1:M.OrdinaryDeleteMetadata(S,E,j)}e("deleteMetadata",z);function C(S,E){for(var j=S.length-1;j>=0;--j){var M=S[j],ee=M(E);if(!q(ee)&&!Oe(ee)){if(!tu(ee))throw new TypeError;E=ee}}return E}function A(S,E,j,M){for(var ee=S.length-1;ee>=0;--ee){var Pe=S[ee],Ie=Pe(E,j,M);if(!q(Ie)&&!Oe(Ie)){if(!he(Ie))throw new TypeError;M=Ie}}return M}function x(S,E,j){var M=$(S,E,j);if(M)return!0;var ee=_a(E);return Oe(ee)?!1:x(S,ee,j)}function $(S,E,j){var M=Pr(E,j,!1);return q(M)?!1:Ql(M.OrdinaryHasOwnMetadata(S,E,j))}function P(S,E,j){var M=$(S,E,j);if(M)return U(S,E,j);var ee=_a(E);if(!Oe(ee))return P(S,ee,j)}function U(S,E,j){var M=Pr(E,j,!1);if(!q(M))return M.OrdinaryGetOwnMetadata(S,E,j)}function Q(S,E,j,M){var ee=Pr(j,M,!0);ee.OrdinaryDefineOwnMetadata(S,E,j,M)}function W(S,E){var j=se(S,E),M=_a(S);if(M===null)return j;var ee=W(M,E);if(ee.length<=0)return j;if(j.length<=0)return ee;for(var Pe=new w,Ie=[],ce=0,D=j;ce<D.length;ce++){var G=D[ce],Z=Pe.has(G);Z||(Pe.add(G),Ie.push(G))}for(var X=0,de=ee;X<de.length;X++){var G=de[X],Z=Pe.has(G);Z||(Pe.add(G),Ie.push(G))}return Ie}function se(S,E){var j=Pr(S,E,!1);return j?j.OrdinaryOwnMetadataKeys(S,E):[]}function ue(S){if(S===null)return 1;switch(typeof S){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return S===null?1:6;default:return 6}}function q(S){return S===void 0}function Oe(S){return S===null}function _n(S){return typeof S=="symbol"}function he(S){return typeof S=="object"?S!==null:typeof S=="function"}function Se(S,E){switch(ue(S)){case 0:return S;case 1:return S;case 2:return S;case 3:return S;case 4:return S;case 5:return S}var j="string",M=nu(S,s);if(M!==void 0){var ee=M.call(S,j);if(he(ee))throw new TypeError;return ee}return Dm(S)}function Dm(S,E){var j,M;{var ee=S.toString;if(Mi(ee)){var M=ee.call(S);if(!he(M))return M}var j=S.valueOf;if(Mi(j)){var M=j.call(S);if(!he(M))return M}}throw new TypeError}function Ql(S){return!!S}function qm(S){return""+S}function xt(S){var E=Se(S);return _n(E)?E:qm(E)}function eu(S){return Array.isArray?Array.isArray(S):S instanceof Object?S instanceof Array:Object.prototype.toString.call(S)==="[object Array]"}function Mi(S){return typeof S=="function"}function tu(S){return typeof S=="function"}function Hm(S){switch(ue(S)){case 3:return!0;case 4:return!0;default:return!1}}function ma(S,E){return S===E||S!==S&&E!==E}function nu(S,E){var j=S[E];if(j!=null){if(!Mi(j))throw new TypeError;return j}}function ru(S){var E=nu(S,o);if(!Mi(E))throw new TypeError;var j=E.call(S);if(!he(j))throw new TypeError;return j}function iu(S){return S.value}function su(S){var E=S.next();return E.done?!1:E}function ou(S){var E=S.return;E&&E.call(S)}function _a(S){var E=Object.getPrototypeOf(S);if(typeof S!="function"||S===p||E!==p)return E;var j=S.prototype,M=j&&Object.getPrototypeOf(j);if(M==null||M===Object.prototype)return E;var ee=M.constructor;return typeof ee!="function"||ee===S?E:ee}function Km(){var S;!q(_)&&typeof n.Reflect<"u"&&!(_ in n.Reflect)&&typeof n.Reflect.defineMetadata=="function"&&(S=Jm(n.Reflect));var E,j,M,ee=new h,Pe={registerProvider:Ie,getProvider:D,setProvider:Z};return Pe;function Ie(X){if(!Object.isExtensible(Pe))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case S===X:break;case q(E):E=X;break;case E===X:break;case q(j):j=X;break;case j===X:break;default:M===void 0&&(M=new w),M.add(X);break}}function ce(X,de){if(!q(E)){if(E.isProviderFor(X,de))return E;if(!q(j)){if(j.isProviderFor(X,de))return E;if(!q(M))for(var me=ru(M);;){var ve=su(me);if(!ve)return;var ft=iu(ve);if(ft.isProviderFor(X,de))return ou(me),ft}}}if(!q(S)&&S.isProviderFor(X,de))return S}function D(X,de){var me=ee.get(X),ve;return q(me)||(ve=me.get(de)),q(ve)&&(ve=ce(X,de),q(ve)||(q(me)&&(me=new m,ee.set(X,me)),me.set(de,ve))),ve}function G(X){if(q(X))throw new TypeError;return E===X||j===X||!q(M)&&M.has(X)}function Z(X,de,me){if(!G(me))throw new Error("Metadata provider not registered.");var ve=D(X,de);if(ve!==me){if(!q(ve))return!1;var ft=ee.get(X);q(ft)&&(ft=new m,ee.set(X,ft)),ft.set(de,me)}return!0}}function Gm(){var S;return!q(_)&&he(n.Reflect)&&Object.isExtensible(n.Reflect)&&(S=n.Reflect[_]),q(S)&&(S=Km()),!q(_)&&he(n.Reflect)&&Object.isExtensible(n.Reflect)&&Object.defineProperty(n.Reflect,_,{enumerable:!1,configurable:!1,writable:!1,value:S}),S}function Wm(S){var E=new h,j={isProviderFor:function(G,Z){var X=E.get(G);return q(X)?!1:X.has(Z)},OrdinaryDefineOwnMetadata:Ie,OrdinaryHasOwnMetadata:ee,OrdinaryGetOwnMetadata:Pe,OrdinaryOwnMetadataKeys:ce,OrdinaryDeleteMetadata:D};return v.registerProvider(j),j;function M(G,Z,X){var de=E.get(G),me=!1;if(q(de)){if(!X)return;de=new m,E.set(G,de),me=!0}var ve=de.get(Z);if(q(ve)){if(!X)return;if(ve=new m,de.set(Z,ve),!S.setProvider(G,Z,j))throw de.delete(Z),me&&E.delete(G),new Error("Wrong provider for target.")}return ve}function ee(G,Z,X){var de=M(Z,X,!1);return q(de)?!1:Ql(de.has(G))}function Pe(G,Z,X){var de=M(Z,X,!1);if(!q(de))return de.get(G)}function Ie(G,Z,X,de){var me=M(X,de,!0);me.set(G,Z)}function ce(G,Z){var X=[],de=M(G,Z,!1);if(q(de))return X;for(var me=de.keys(),ve=ru(me),ft=0;;){var au=su(ve);if(!au)return X.length=ft,X;var Qm=iu(au);try{X[ft]=Qm}catch(e1){try{ou(ve)}finally{throw e1}}ft++}}function D(G,Z,X){var de=M(Z,X,!1);if(q(de)||!de.delete(G))return!1;if(de.size===0){var me=E.get(Z);q(me)||(me.delete(X),me.size===0&&E.delete(me))}return!0}}function Jm(S){var E=S.defineMetadata,j=S.hasOwnMetadata,M=S.getOwnMetadata,ee=S.getOwnMetadataKeys,Pe=S.deleteMetadata,Ie=new h,ce={isProviderFor:function(D,G){var Z=Ie.get(D);return!q(Z)&&Z.has(G)?!0:ee(D,G).length?(q(Z)&&(Z=new w,Ie.set(D,Z)),Z.add(G),!0):!1},OrdinaryDefineOwnMetadata:E,OrdinaryHasOwnMetadata:j,OrdinaryGetOwnMetadata:M,OrdinaryOwnMetadataKeys:ee,OrdinaryDeleteMetadata:Pe};return ce}function Pr(S,E,j){var M=v.getProvider(S,E);if(!q(M))return M;if(j){if(v.setProvider(S,E,k))return k;throw new Error("Illegal state.")}}function Zm(){var S={},E=[],j=function(){function ce(D,G,Z){this._index=0,this._keys=D,this._values=G,this._selector=Z}return ce.prototype["@@iterator"]=function(){return this},ce.prototype[o]=function(){return this},ce.prototype.next=function(){var D=this._index;if(D>=0&&D<this._keys.length){var G=this._selector(this._keys[D],this._values[D]);return D+1>=this._keys.length?(this._index=-1,this._keys=E,this._values=E):this._index++,{value:G,done:!1}}return{value:void 0,done:!0}},ce.prototype.throw=function(D){throw this._index>=0&&(this._index=-1,this._keys=E,this._values=E),D},ce.prototype.return=function(D){return this._index>=0&&(this._index=-1,this._keys=E,this._values=E),{value:D,done:!0}},ce}(),M=function(){function ce(){this._keys=[],this._values=[],this._cacheKey=S,this._cacheIndex=-2}return Object.defineProperty(ce.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),ce.prototype.has=function(D){return this._find(D,!1)>=0},ce.prototype.get=function(D){var G=this._find(D,!1);return G>=0?this._values[G]:void 0},ce.prototype.set=function(D,G){var Z=this._find(D,!0);return this._values[Z]=G,this},ce.prototype.delete=function(D){var G=this._find(D,!1);if(G>=0){for(var Z=this._keys.length,X=G+1;X<Z;X++)this._keys[X-1]=this._keys[X],this._values[X-1]=this._values[X];return this._keys.length--,this._values.length--,ma(D,this._cacheKey)&&(this._cacheKey=S,this._cacheIndex=-2),!0}return!1},ce.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=S,this._cacheIndex=-2},ce.prototype.keys=function(){return new j(this._keys,this._values,ee)},ce.prototype.values=function(){return new j(this._keys,this._values,Pe)},ce.prototype.entries=function(){return new j(this._keys,this._values,Ie)},ce.prototype["@@iterator"]=function(){return this.entries()},ce.prototype[o]=function(){return this.entries()},ce.prototype._find=function(D,G){if(!ma(this._cacheKey,D)){this._cacheIndex=-1;for(var Z=0;Z<this._keys.length;Z++)if(ma(this._keys[Z],D)){this._cacheIndex=Z;break}}return this._cacheIndex<0&&G&&(this._cacheIndex=this._keys.length,this._keys.push(D),this._values.push(void 0)),this._cacheIndex},ce}();return M;function ee(ce,D){return ce}function Pe(ce,D){return D}function Ie(ce,D){return[ce,D]}}function Xm(){var S=function(){function E(){this._map=new m}return Object.defineProperty(E.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),E.prototype.has=function(j){return this._map.has(j)},E.prototype.add=function(j){return this._map.set(j,j),this},E.prototype.delete=function(j){return this._map.delete(j)},E.prototype.clear=function(){this._map.clear()},E.prototype.keys=function(){return this._map.keys()},E.prototype.values=function(){return this._map.keys()},E.prototype.entries=function(){return this._map.entries()},E.prototype["@@iterator"]=function(){return this.keys()},E.prototype[o]=function(){return this.keys()},E}();return S}function Ym(){var S=16,E=u.create(),j=M();return function(){function D(){this._key=M()}return D.prototype.has=function(G){var Z=ee(G,!1);return Z!==void 0?u.has(Z,this._key):!1},D.prototype.get=function(G){var Z=ee(G,!1);return Z!==void 0?u.get(Z,this._key):void 0},D.prototype.set=function(G,Z){var X=ee(G,!0);return X[this._key]=Z,this},D.prototype.delete=function(G){var Z=ee(G,!1);return Z!==void 0?delete Z[this._key]:!1},D.prototype.clear=function(){this._key=M()},D}();function M(){var D;do D="@@WeakMap@@"+ce();while(u.has(E,D));return E[D]=!0,D}function ee(D,G){if(!r.call(D,j)){if(!G)return;Object.defineProperty(D,j,{value:u.create()})}return D[j]}function Pe(D,G){for(var Z=0;Z<G;++Z)D[Z]=Math.random()*255|0;return D}function Ie(D){if(typeof Uint8Array=="function"){var G=new Uint8Array(D);return typeof crypto<"u"?crypto.getRandomValues(G):typeof msCrypto<"u"?msCrypto.getRandomValues(G):Pe(G,D),G}return Pe(new Array(D),D)}function ce(){var D=Ie(S);D[6]=D[6]&79|64,D[8]=D[8]&191|128;for(var G="",Z=0;Z<S;++Z){var X=D[Z];(Z===4||Z===6||Z===8)&&(G+="-"),X<16&&(G+="0"),G+=X.toString(16).toLowerCase()}return G}}function ya(S){return S.__=void 0,delete S.__,S}})})(Cu||(Cu={}));/*!
42
+ ***************************************************************************** */var Cu;(function(t){(function(e){var n=typeof globalThis=="object"?globalThis:typeof bs=="object"?bs: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(d,l){return function(u,p){Object.defineProperty(d,u,{configurable:!0,writable:!0,value:p}),l&&l(u,p)}}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",d={__proto__:[]}instanceof Array,l=!c&&!d,u={create:c?function(){return ya(Object.create(null))}:d?function(){return ya({__proto__:null})}:function(){return ya({})},has:l?function(S,E){return r.call(S,E)}:function(S,E){return E in S},get:l?function(S,E){return r.call(S,E)?S[E]:void 0}:function(S,E){return S[E]}},p=Object.getPrototypeOf(Function),m=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:Xm(),w=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:Ym(),h=typeof WeakMap=="function"?WeakMap:Qm(),_=i?Symbol.for("@reflect-metadata:registry"):void 0,v=Wm(),k=Jm(v);function I(S,E,j,M){if(q(j)){if(!eu(S))throw new TypeError;if(!tu(E))throw new TypeError;return C(S,E)}else{if(!eu(S))throw new TypeError;if(!he(E))throw new TypeError;if(!he(M)&&!q(M)&&!Oe(M))throw new TypeError;return Oe(M)&&(M=void 0),j=xt(j),A(S,E,j,M)}}e("decorate",I);function O(S,E){function j(M,ee){if(!he(M))throw new TypeError;if(!q(ee)&&!Km(ee))throw new TypeError;Q(S,E,M,ee)}return j}e("metadata",O);function L(S,E,j,M){if(!he(j))throw new TypeError;return q(M)||(M=xt(M)),Q(S,E,j,M)}e("defineMetadata",L);function Y(S,E,j){if(!he(E))throw new TypeError;return q(j)||(j=xt(j)),x(S,E,j)}e("hasMetadata",Y);function oe(S,E,j){if(!he(E))throw new TypeError;return q(j)||(j=xt(j)),$(S,E,j)}e("hasOwnMetadata",oe);function ae(S,E,j){if(!he(E))throw new TypeError;return q(j)||(j=xt(j)),P(S,E,j)}e("getMetadata",ae);function ke(S,E,j){if(!he(E))throw new TypeError;return q(j)||(j=xt(j)),U(S,E,j)}e("getOwnMetadata",ke);function Ee(S,E){if(!he(S))throw new TypeError;return q(E)||(E=xt(E)),W(S,E)}e("getMetadataKeys",Ee);function ze(S,E){if(!he(S))throw new TypeError;return q(E)||(E=xt(E)),se(S,E)}e("getOwnMetadataKeys",ze);function z(S,E,j){if(!he(E))throw new TypeError;if(q(j)||(j=xt(j)),!he(E))throw new TypeError;q(j)||(j=xt(j));var M=Pr(E,j,!1);return q(M)?!1:M.OrdinaryDeleteMetadata(S,E,j)}e("deleteMetadata",z);function C(S,E){for(var j=S.length-1;j>=0;--j){var M=S[j],ee=M(E);if(!q(ee)&&!Oe(ee)){if(!tu(ee))throw new TypeError;E=ee}}return E}function A(S,E,j,M){for(var ee=S.length-1;ee>=0;--ee){var Pe=S[ee],Ie=Pe(E,j,M);if(!q(Ie)&&!Oe(Ie)){if(!he(Ie))throw new TypeError;M=Ie}}return M}function x(S,E,j){var M=$(S,E,j);if(M)return!0;var ee=_a(E);return Oe(ee)?!1:x(S,ee,j)}function $(S,E,j){var M=Pr(E,j,!1);return q(M)?!1:Ql(M.OrdinaryHasOwnMetadata(S,E,j))}function P(S,E,j){var M=$(S,E,j);if(M)return U(S,E,j);var ee=_a(E);if(!Oe(ee))return P(S,ee,j)}function U(S,E,j){var M=Pr(E,j,!1);if(!q(M))return M.OrdinaryGetOwnMetadata(S,E,j)}function Q(S,E,j,M){var ee=Pr(j,M,!0);ee.OrdinaryDefineOwnMetadata(S,E,j,M)}function W(S,E){var j=se(S,E),M=_a(S);if(M===null)return j;var ee=W(M,E);if(ee.length<=0)return j;if(j.length<=0)return ee;for(var Pe=new w,Ie=[],ce=0,D=j;ce<D.length;ce++){var G=D[ce],Z=Pe.has(G);Z||(Pe.add(G),Ie.push(G))}for(var X=0,de=ee;X<de.length;X++){var G=de[X],Z=Pe.has(G);Z||(Pe.add(G),Ie.push(G))}return Ie}function se(S,E){var j=Pr(S,E,!1);return j?j.OrdinaryOwnMetadataKeys(S,E):[]}function ue(S){if(S===null)return 1;switch(typeof S){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return S===null?1:6;default:return 6}}function q(S){return S===void 0}function Oe(S){return S===null}function _n(S){return typeof S=="symbol"}function he(S){return typeof S=="object"?S!==null:typeof S=="function"}function Se(S,E){switch(ue(S)){case 0:return S;case 1:return S;case 2:return S;case 3:return S;case 4:return S;case 5:return S}var j="string",M=nu(S,s);if(M!==void 0){var ee=M.call(S,j);if(he(ee))throw new TypeError;return ee}return qm(S)}function qm(S,E){var j,M;{var ee=S.toString;if(Fi(ee)){var M=ee.call(S);if(!he(M))return M}var j=S.valueOf;if(Fi(j)){var M=j.call(S);if(!he(M))return M}}throw new TypeError}function Ql(S){return!!S}function Hm(S){return""+S}function xt(S){var E=Se(S);return _n(E)?E:Hm(E)}function eu(S){return Array.isArray?Array.isArray(S):S instanceof Object?S instanceof Array:Object.prototype.toString.call(S)==="[object Array]"}function Fi(S){return typeof S=="function"}function tu(S){return typeof S=="function"}function Km(S){switch(ue(S)){case 3:return!0;case 4:return!0;default:return!1}}function ma(S,E){return S===E||S!==S&&E!==E}function nu(S,E){var j=S[E];if(j!=null){if(!Fi(j))throw new TypeError;return j}}function ru(S){var E=nu(S,o);if(!Fi(E))throw new TypeError;var j=E.call(S);if(!he(j))throw new TypeError;return j}function iu(S){return S.value}function su(S){var E=S.next();return E.done?!1:E}function ou(S){var E=S.return;E&&E.call(S)}function _a(S){var E=Object.getPrototypeOf(S);if(typeof S!="function"||S===p||E!==p)return E;var j=S.prototype,M=j&&Object.getPrototypeOf(j);if(M==null||M===Object.prototype)return E;var ee=M.constructor;return typeof ee!="function"||ee===S?E:ee}function Gm(){var S;!q(_)&&typeof n.Reflect<"u"&&!(_ in n.Reflect)&&typeof n.Reflect.defineMetadata=="function"&&(S=Zm(n.Reflect));var E,j,M,ee=new h,Pe={registerProvider:Ie,getProvider:D,setProvider:Z};return Pe;function Ie(X){if(!Object.isExtensible(Pe))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case S===X:break;case q(E):E=X;break;case E===X:break;case q(j):j=X;break;case j===X:break;default:M===void 0&&(M=new w),M.add(X);break}}function ce(X,de){if(!q(E)){if(E.isProviderFor(X,de))return E;if(!q(j)){if(j.isProviderFor(X,de))return E;if(!q(M))for(var me=ru(M);;){var ve=su(me);if(!ve)return;var ft=iu(ve);if(ft.isProviderFor(X,de))return ou(me),ft}}}if(!q(S)&&S.isProviderFor(X,de))return S}function D(X,de){var me=ee.get(X),ve;return q(me)||(ve=me.get(de)),q(ve)&&(ve=ce(X,de),q(ve)||(q(me)&&(me=new m,ee.set(X,me)),me.set(de,ve))),ve}function G(X){if(q(X))throw new TypeError;return E===X||j===X||!q(M)&&M.has(X)}function Z(X,de,me){if(!G(me))throw new Error("Metadata provider not registered.");var ve=D(X,de);if(ve!==me){if(!q(ve))return!1;var ft=ee.get(X);q(ft)&&(ft=new m,ee.set(X,ft)),ft.set(de,me)}return!0}}function Wm(){var S;return!q(_)&&he(n.Reflect)&&Object.isExtensible(n.Reflect)&&(S=n.Reflect[_]),q(S)&&(S=Gm()),!q(_)&&he(n.Reflect)&&Object.isExtensible(n.Reflect)&&Object.defineProperty(n.Reflect,_,{enumerable:!1,configurable:!1,writable:!1,value:S}),S}function Jm(S){var E=new h,j={isProviderFor:function(G,Z){var X=E.get(G);return q(X)?!1:X.has(Z)},OrdinaryDefineOwnMetadata:Ie,OrdinaryHasOwnMetadata:ee,OrdinaryGetOwnMetadata:Pe,OrdinaryOwnMetadataKeys:ce,OrdinaryDeleteMetadata:D};return v.registerProvider(j),j;function M(G,Z,X){var de=E.get(G),me=!1;if(q(de)){if(!X)return;de=new m,E.set(G,de),me=!0}var ve=de.get(Z);if(q(ve)){if(!X)return;if(ve=new m,de.set(Z,ve),!S.setProvider(G,Z,j))throw de.delete(Z),me&&E.delete(G),new Error("Wrong provider for target.")}return ve}function ee(G,Z,X){var de=M(Z,X,!1);return q(de)?!1:Ql(de.has(G))}function Pe(G,Z,X){var de=M(Z,X,!1);if(!q(de))return de.get(G)}function Ie(G,Z,X,de){var me=M(X,de,!0);me.set(G,Z)}function ce(G,Z){var X=[],de=M(G,Z,!1);if(q(de))return X;for(var me=de.keys(),ve=ru(me),ft=0;;){var au=su(ve);if(!au)return X.length=ft,X;var e1=iu(au);try{X[ft]=e1}catch(t1){try{ou(ve)}finally{throw t1}}ft++}}function D(G,Z,X){var de=M(Z,X,!1);if(q(de)||!de.delete(G))return!1;if(de.size===0){var me=E.get(Z);q(me)||(me.delete(X),me.size===0&&E.delete(me))}return!0}}function Zm(S){var E=S.defineMetadata,j=S.hasOwnMetadata,M=S.getOwnMetadata,ee=S.getOwnMetadataKeys,Pe=S.deleteMetadata,Ie=new h,ce={isProviderFor:function(D,G){var Z=Ie.get(D);return!q(Z)&&Z.has(G)?!0:ee(D,G).length?(q(Z)&&(Z=new w,Ie.set(D,Z)),Z.add(G),!0):!1},OrdinaryDefineOwnMetadata:E,OrdinaryHasOwnMetadata:j,OrdinaryGetOwnMetadata:M,OrdinaryOwnMetadataKeys:ee,OrdinaryDeleteMetadata:Pe};return ce}function Pr(S,E,j){var M=v.getProvider(S,E);if(!q(M))return M;if(j){if(v.setProvider(S,E,k))return k;throw new Error("Illegal state.")}}function Xm(){var S={},E=[],j=function(){function ce(D,G,Z){this._index=0,this._keys=D,this._values=G,this._selector=Z}return ce.prototype["@@iterator"]=function(){return this},ce.prototype[o]=function(){return this},ce.prototype.next=function(){var D=this._index;if(D>=0&&D<this._keys.length){var G=this._selector(this._keys[D],this._values[D]);return D+1>=this._keys.length?(this._index=-1,this._keys=E,this._values=E):this._index++,{value:G,done:!1}}return{value:void 0,done:!0}},ce.prototype.throw=function(D){throw this._index>=0&&(this._index=-1,this._keys=E,this._values=E),D},ce.prototype.return=function(D){return this._index>=0&&(this._index=-1,this._keys=E,this._values=E),{value:D,done:!0}},ce}(),M=function(){function ce(){this._keys=[],this._values=[],this._cacheKey=S,this._cacheIndex=-2}return Object.defineProperty(ce.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),ce.prototype.has=function(D){return this._find(D,!1)>=0},ce.prototype.get=function(D){var G=this._find(D,!1);return G>=0?this._values[G]:void 0},ce.prototype.set=function(D,G){var Z=this._find(D,!0);return this._values[Z]=G,this},ce.prototype.delete=function(D){var G=this._find(D,!1);if(G>=0){for(var Z=this._keys.length,X=G+1;X<Z;X++)this._keys[X-1]=this._keys[X],this._values[X-1]=this._values[X];return this._keys.length--,this._values.length--,ma(D,this._cacheKey)&&(this._cacheKey=S,this._cacheIndex=-2),!0}return!1},ce.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=S,this._cacheIndex=-2},ce.prototype.keys=function(){return new j(this._keys,this._values,ee)},ce.prototype.values=function(){return new j(this._keys,this._values,Pe)},ce.prototype.entries=function(){return new j(this._keys,this._values,Ie)},ce.prototype["@@iterator"]=function(){return this.entries()},ce.prototype[o]=function(){return this.entries()},ce.prototype._find=function(D,G){if(!ma(this._cacheKey,D)){this._cacheIndex=-1;for(var Z=0;Z<this._keys.length;Z++)if(ma(this._keys[Z],D)){this._cacheIndex=Z;break}}return this._cacheIndex<0&&G&&(this._cacheIndex=this._keys.length,this._keys.push(D),this._values.push(void 0)),this._cacheIndex},ce}();return M;function ee(ce,D){return ce}function Pe(ce,D){return D}function Ie(ce,D){return[ce,D]}}function Ym(){var S=function(){function E(){this._map=new m}return Object.defineProperty(E.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),E.prototype.has=function(j){return this._map.has(j)},E.prototype.add=function(j){return this._map.set(j,j),this},E.prototype.delete=function(j){return this._map.delete(j)},E.prototype.clear=function(){this._map.clear()},E.prototype.keys=function(){return this._map.keys()},E.prototype.values=function(){return this._map.keys()},E.prototype.entries=function(){return this._map.entries()},E.prototype["@@iterator"]=function(){return this.keys()},E.prototype[o]=function(){return this.keys()},E}();return S}function Qm(){var S=16,E=u.create(),j=M();return function(){function D(){this._key=M()}return D.prototype.has=function(G){var Z=ee(G,!1);return Z!==void 0?u.has(Z,this._key):!1},D.prototype.get=function(G){var Z=ee(G,!1);return Z!==void 0?u.get(Z,this._key):void 0},D.prototype.set=function(G,Z){var X=ee(G,!0);return X[this._key]=Z,this},D.prototype.delete=function(G){var Z=ee(G,!1);return Z!==void 0?delete Z[this._key]:!1},D.prototype.clear=function(){this._key=M()},D}();function M(){var D;do D="@@WeakMap@@"+ce();while(u.has(E,D));return E[D]=!0,D}function ee(D,G){if(!r.call(D,j)){if(!G)return;Object.defineProperty(D,j,{value:u.create()})}return D[j]}function Pe(D,G){for(var Z=0;Z<G;++Z)D[Z]=Math.random()*255|0;return D}function Ie(D){if(typeof Uint8Array=="function"){var G=new Uint8Array(D);return typeof crypto<"u"?crypto.getRandomValues(G):typeof msCrypto<"u"?msCrypto.getRandomValues(G):Pe(G,D),G}return Pe(new Array(D),D)}function ce(){var D=Ie(S);D[6]=D[6]&79|64,D[8]=D[8]&191|128;for(var G="",Z=0;Z<S;++Z){var X=D[Z];(Z===4||Z===6||Z===8)&&(G+="-"),X<16&&(G+="0"),G+=X.toString(16).toLowerCase()}return G}}function ya(S){return S.__=void 0,delete S.__,S}})})(Cu||(Cu={}));/*!
43
43
  * MIT License
44
44
  *
45
45
  * Copyright (c) 2017-2022 Peculiar Ventures, LLC
@@ -62,9 +62,9 @@ and limitations under the License.
62
62
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
63
63
  * SOFTWARE.
64
64
  *
65
- */const qy="[object ArrayBuffer]";class V{static isArrayBuffer(e){return Object.prototype.toString.call(e)===qy}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=V.toUint8Array(e),i=V.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 va="string",Hy=/^[0-9a-f]+$/i,Ky=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,Gy=/^[a-zA-Z0-9-_]+$/;class zu{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=V.toUint8Array(e);let r="";for(let s=0;s<n.length;s++)r+=String.fromCharCode(n[s]);return decodeURIComponent(escape(r))}}class kt{static toString(e,n=!1){const r=V.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===va&&Hy.test(e)}static isBase64(e){return typeof e===va&&Ky.test(e)}static isBase64Url(e){return typeof e===va&&Gy.test(e)}static ToString(e,n="utf8"){const r=V.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 kt.toString(r,!0);case"utf16":case"utf16be":return kt.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 kt.fromString(e,!0);case"utf16":case"utf16be":return kt.fromString(e);default:throw new Error(`Unknown type of encoding '${n}'`)}}static ToBase64(e){const n=V.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 zu.fromString(e);case"utf16":case"utf16be":return kt.fromString(e);case"utf16le":case"usc2":return kt.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 zu.toString(e);case"utf16":case"utf16be":return kt.toString(e);case"utf16le":case"usc2":return kt.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=V.toUint8Array(e);let r="";for(let i=0;i<n.length;i++)r+=String.fromCharCode(n[i]);return r}static ToHex(e){const n=V.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 kt.toString(e,n)}static FromUtf16String(e,n=!1){return kt.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 Wy(...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 J0(t,e){if(!(t&&e)||t.byteLength!==e.byteLength)return!1;const n=new Uint8Array(t),r=new Uint8Array(e);for(let i=0;i<t.byteLength;i++)if(n[i]!==r[i])return!1;return!0}/*!
65
+ */const Hy="[object ArrayBuffer]";class V{static isArrayBuffer(e){return Object.prototype.toString.call(e)===Hy}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,n){if(e.constructor===n)return e;if(this.isArrayBuffer(e))return new n(e);if(this.isArrayBufferView(e))return new n(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(e,n){const r=V.toUint8Array(e),i=V.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 va="string",Ky=/^[0-9a-f]+$/i,Gy=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,Wy=/^[a-zA-Z0-9-_]+$/;class zu{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=V.toUint8Array(e);let r="";for(let s=0;s<n.length;s++)r+=String.fromCharCode(n[s]);return decodeURIComponent(escape(r))}}class kt{static toString(e,n=!1){const r=V.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===va&&Ky.test(e)}static isBase64(e){return typeof e===va&&Gy.test(e)}static isBase64Url(e){return typeof e===va&&Wy.test(e)}static ToString(e,n="utf8"){const r=V.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 kt.toString(r,!0);case"utf16":case"utf16be":return kt.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 kt.fromString(e,!0);case"utf16":case"utf16be":return kt.fromString(e);default:throw new Error(`Unknown type of encoding '${n}'`)}}static ToBase64(e){const n=V.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 zu.fromString(e);case"utf16":case"utf16be":return kt.fromString(e);case"utf16le":case"usc2":return kt.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 zu.toString(e);case"utf16":case"utf16be":return kt.toString(e);case"utf16le":case"usc2":return kt.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=V.toUint8Array(e);let r="";for(let i=0;i<n.length;i++)r+=String.fromCharCode(n[i]);return r}static ToHex(e){const n=V.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 kt.toString(e,n)}static FromUtf16String(e,n=!1){return kt.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 Jy(...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 J0(t,e){if(!(t&&e)||t.byteLength!==e.byteLength)return!1;const n=new Uint8Array(t),r=new Uint8Array(e);for(let i=0;i<t.byteLength;i++)if(n[i]!==r[i])return!1;return!0}/*!
66
66
  Copyright (c) Peculiar Ventures, LLC
67
- */function ar(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 In(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 d;if(r<0)d=new ArrayBuffer(c),s=c;else{if(r<c)return new ArrayBuffer(0);d=new ArrayBuffer(r),s=r}const l=new Uint8Array(d);for(let u=c-1;u>=0;u--){const p=Math.pow(2,u*e);l[s-u-1]=Math.floor(i/p),i-=l[s-u-1]*p}return d}o*=Math.pow(2,e)}return new ArrayBuffer(0)}function Xa(...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 Z0(){const t=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){const c=t[0]===255&&t[1]&128,d=t[0]===0&&(t[1]&128)===0;(c||d)&&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=ar(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,ar(s,8)-r}function Jy(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=In(o,8,r),d=new Uint8Array(c);return d[0]|=128,c}let i=In(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 d=0;d<o.byteLength;d++)s[d+1]=c[d];s[0]=0}return i}n*=Math.pow(2,8)}return new ArrayBuffer(0)}function Zy(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 et(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)}/*!
67
+ */function ar(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 In(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 d;if(r<0)d=new ArrayBuffer(c),s=c;else{if(r<c)return new ArrayBuffer(0);d=new ArrayBuffer(r),s=r}const l=new Uint8Array(d);for(let u=c-1;u>=0;u--){const p=Math.pow(2,u*e);l[s-u-1]=Math.floor(i/p),i-=l[s-u-1]*p}return d}o*=Math.pow(2,e)}return new ArrayBuffer(0)}function Xa(...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 Z0(){const t=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){const c=t[0]===255&&t[1]&128,d=t[0]===0&&(t[1]&128)===0;(c||d)&&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=ar(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,ar(s,8)-r}function Zy(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=In(o,8,r),d=new Uint8Array(c);return d[0]|=128,c}let i=In(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 d=0;d<o.byteLength;d++)s[d+1]=c[d];s[0]=0}return i}n*=Math.pow(2,8)}return new ArrayBuffer(0)}function Xy(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 et(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)}/*!
68
68
  * Copyright (c) 2014, GMO GlobalSign
69
69
  * Copyright (c) 2015-2022, Peculiar Ventures
70
70
  * All rights reserved.
@@ -96,11 +96,11 @@ and limitations under the License.
96
96
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
97
97
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
98
98
  *
99
- */function xs(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function Fd(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 Wt(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 bo{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return Fd(this.items)}}const Br=[new Uint8Array([1])],Ou="0123456789",ba="name",Pu="valueHexView",Xy="isHexOnly",Yy="idBlock",Qy="tagClass",e2="tagNumber",t2="isConstructed",n2="fromBER",r2="toBER",i2="local",Ge="",bt=new ArrayBuffer(0),$o=new Uint8Array(0),Zr="EndOfContent",X0="OCTET STRING",Y0="BIT STRING";function Pt(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?V.toUint8Array(s.valueHex):$o}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(!Wt(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",bt)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:J.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}class Fn{constructor({blockLength:e=0,error:n=Ge,warnings:r=[],valueBeforeDecode:i=$o}={}){this.blockLength=e,this.error=n,this.warnings=r,this.valueBeforeDecodeView=V.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)}}}Fn.NAME="baseBlock";class qe extends Fn{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'")}}qe.NAME="valueBlock";class Q0 extends Pt(Fn){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?V.toUint8Array(e.valueHex):$o,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",bt}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=In(this.tagNumber,7),s=new Uint8Array(i),o=i.byteLength,c=new Uint8Array(o+1);if(c[0]=n|31,!e){for(let d=0;d<o-1;d++)c[d+1]=s[d]|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=V.toUint8Array(e);if(!Wt(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 d=1,l=this.valueHexView=new Uint8Array(255),u=255;for(;s[d]&128;){if(l[d-1]=s[d]&127,d++,d>=s.length)return this.error="End of input reached before message was fully decoded",-1;if(d===u){u+=255;const m=new Uint8Array(u);for(let w=0;w<l.length;w++)m[w]=l[w];l=this.valueHexView=new Uint8Array(u)}}this.blockLength=d+1,l[d-1]=s[d]&127;const p=new Uint8Array(d);for(let m=0;m<d;m++)p[m]=l[m];l=this.valueHexView=new Uint8Array(d),l.set(p),this.blockLength<=9?this.tagNumber=ar(l,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}}}Q0.NAME="identificationBlock";class eh extends Fn{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=V.toUint8Array(e);if(!Wt(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,d=i.subarray(c,c+o);return d[o-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=ar(d,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=In(this.length,8);if(i.byteLength>127)return this.error="Too big length",bt;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}}}eh.NAME="lengthBlock";const K={};class Be extends Fn{constructor({name:e=Ge,optional:n=!1,primitiveSchema:r,...i}={},s){super(i),this.name=e,this.optional=n,r&&(this.primitiveSchema=r),this.idBlock=new Q0(i),this.lenBlock=new eh(i),this.valueBlock=s?new s(i):new qe(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 bo;n||th(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?bt: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 Zy(n,r)}}Be.NAME="BaseBlock";function th(t){if(t instanceof K.Constructed)for(const e of t.valueBlock.value)th(e)&&(t.lenBlock.isIndefiniteForm=!0);return!!t.lenBlock.isIndefiniteForm}class Vd extends Be{constructor({value:e=Ge,...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}'`}}Vd.NAME="BaseStringBlock";class nh extends Pt(qe){constructor({isHexOnly:e=!0,...n}={}){super(n),this.isHexOnly=e}}nh.NAME="PrimitiveValueBlock";var rh;class mi extends Be{constructor(e={}){super(e,nh),this.idBlock.isConstructed=!1}}rh=mi;K.Primitive=rh;mi.NAME="PRIMITIVE";function s2(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 $r(t,e=0,n=t.length){const r=e;let i=new Be({},qe);const s=new Fn;if(!Wt(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 d=Be;switch(i.idBlock.tagClass){case 1:if(i.idBlock.tagNumber>=37&&i.idBlock.isHexOnly===!1)return i.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:i};switch(i.idBlock.tagNumber){case 0:if(i.idBlock.isConstructed&&i.lenBlock.length>0)return i.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:i};d=K.EndOfContent;break;case 1:d=K.Boolean;break;case 2:d=K.Integer;break;case 3:d=K.BitString;break;case 4:d=K.OctetString;break;case 5:d=K.Null;break;case 6:d=K.ObjectIdentifier;break;case 10:d=K.Enumerated;break;case 12:d=K.Utf8String;break;case 13:d=K.RelativeObjectIdentifier;break;case 14:d=K.TIME;break;case 15:return i.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:i};case 16:d=K.Sequence;break;case 17:d=K.Set;break;case 18:d=K.NumericString;break;case 19:d=K.PrintableString;break;case 20:d=K.TeletexString;break;case 21:d=K.VideotexString;break;case 22:d=K.IA5String;break;case 23:d=K.UTCTime;break;case 24:d=K.GeneralizedTime;break;case 25:d=K.GraphicString;break;case 26:d=K.VisibleString;break;case 27:d=K.GeneralString;break;case 28:d=K.UniversalString;break;case 29:d=K.CharacterString;break;case 30:d=K.BmpString;break;case 31:d=K.DATE;break;case 32:d=K.TimeOfDay;break;case 33:d=K.DateTime;break;case 34:d=K.Duration;break;default:{const l=i.idBlock.isConstructed?new K.Constructed:new K.Primitive;l.idBlock=i.idBlock,l.lenBlock=i.lenBlock,l.warnings=i.warnings,i=l}}break;case 2:case 3:case 4:default:d=i.idBlock.isConstructed?K.Constructed:K.Primitive}return i=s2(i,d),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 nr(t){if(!t.byteLength){const e=new Be({},qe);return e.error="Input buffer has zero length",{offset:-1,result:e}}return $r(V.toUint8Array(t).slice(),0,t.byteLength)}function o2(t,e){return t?1:e}class nn extends qe{constructor({value:e=[],isIndefiniteForm:n=!1,...r}={}){super(r),this.value=e,this.isIndefiniteForm=n}fromBER(e,n,r){const i=V.toUint8Array(e);if(!Wt(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(;o2(this.isIndefiniteForm,r)>0;){const o=$r(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===Zr)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===Zr?this.value.pop():this.warnings.push("No EndOfContent block encoded")),s}toBER(e,n){const r=n||new bo;for(let i=0;i<this.value.length;i++)this.value[i].toBER(e,r);return n?bt:r.final()}toJSON(){const e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(const n of this.value)e.value.push(n.toJSON());return e}}nn.NAME="ConstructedValueBlock";var ih;class We extends Be{constructor(e={}){super(e,nn),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 ks(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function Fd(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 Wt(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 $o{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return Fd(this.items)}}const Br=[new Uint8Array([1])],Ou="0123456789",ba="name",Pu="valueHexView",Yy="isHexOnly",Qy="idBlock",e2="tagClass",t2="tagNumber",n2="isConstructed",r2="fromBER",i2="toBER",s2="local",Ge="",bt=new ArrayBuffer(0),xo=new Uint8Array(0),Zr="EndOfContent",X0="OCTET STRING",Y0="BIT STRING";function Pt(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?V.toUint8Array(s.valueHex):xo}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(!Wt(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",bt)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:J.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}class Fn{constructor({blockLength:e=0,error:n=Ge,warnings:r=[],valueBeforeDecode:i=xo}={}){this.blockLength=e,this.error=n,this.warnings=r,this.valueBeforeDecodeView=V.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)}}}Fn.NAME="baseBlock";class qe extends Fn{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'")}}qe.NAME="valueBlock";class Q0 extends Pt(Fn){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?V.toUint8Array(e.valueHex):xo,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",bt}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=In(this.tagNumber,7),s=new Uint8Array(i),o=i.byteLength,c=new Uint8Array(o+1);if(c[0]=n|31,!e){for(let d=0;d<o-1;d++)c[d+1]=s[d]|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=V.toUint8Array(e);if(!Wt(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 d=1,l=this.valueHexView=new Uint8Array(255),u=255;for(;s[d]&128;){if(l[d-1]=s[d]&127,d++,d>=s.length)return this.error="End of input reached before message was fully decoded",-1;if(d===u){u+=255;const m=new Uint8Array(u);for(let w=0;w<l.length;w++)m[w]=l[w];l=this.valueHexView=new Uint8Array(u)}}this.blockLength=d+1,l[d-1]=s[d]&127;const p=new Uint8Array(d);for(let m=0;m<d;m++)p[m]=l[m];l=this.valueHexView=new Uint8Array(d),l.set(p),this.blockLength<=9?this.tagNumber=ar(l,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}}}Q0.NAME="identificationBlock";class eh extends Fn{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=V.toUint8Array(e);if(!Wt(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,d=i.subarray(c,c+o);return d[o-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=ar(d,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=In(this.length,8);if(i.byteLength>127)return this.error="Too big length",bt;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}}}eh.NAME="lengthBlock";const K={};class Be extends Fn{constructor({name:e=Ge,optional:n=!1,primitiveSchema:r,...i}={},s){super(i),this.name=e,this.optional=n,r&&(this.primitiveSchema=r),this.idBlock=new Q0(i),this.lenBlock=new eh(i),this.valueBlock=s?new s(i):new qe(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 $o;n||th(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?bt: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 Xy(n,r)}}Be.NAME="BaseBlock";function th(t){if(t instanceof K.Constructed)for(const e of t.valueBlock.value)th(e)&&(t.lenBlock.isIndefiniteForm=!0);return!!t.lenBlock.isIndefiniteForm}class Vd extends Be{constructor({value:e=Ge,...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}'`}}Vd.NAME="BaseStringBlock";class nh extends Pt(qe){constructor({isHexOnly:e=!0,...n}={}){super(n),this.isHexOnly=e}}nh.NAME="PrimitiveValueBlock";var rh;class _i extends Be{constructor(e={}){super(e,nh),this.idBlock.isConstructed=!1}}rh=_i;K.Primitive=rh;_i.NAME="PRIMITIVE";function o2(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 $r(t,e=0,n=t.length){const r=e;let i=new Be({},qe);const s=new Fn;if(!Wt(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 d=Be;switch(i.idBlock.tagClass){case 1:if(i.idBlock.tagNumber>=37&&i.idBlock.isHexOnly===!1)return i.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:i};switch(i.idBlock.tagNumber){case 0:if(i.idBlock.isConstructed&&i.lenBlock.length>0)return i.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:i};d=K.EndOfContent;break;case 1:d=K.Boolean;break;case 2:d=K.Integer;break;case 3:d=K.BitString;break;case 4:d=K.OctetString;break;case 5:d=K.Null;break;case 6:d=K.ObjectIdentifier;break;case 10:d=K.Enumerated;break;case 12:d=K.Utf8String;break;case 13:d=K.RelativeObjectIdentifier;break;case 14:d=K.TIME;break;case 15:return i.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:i};case 16:d=K.Sequence;break;case 17:d=K.Set;break;case 18:d=K.NumericString;break;case 19:d=K.PrintableString;break;case 20:d=K.TeletexString;break;case 21:d=K.VideotexString;break;case 22:d=K.IA5String;break;case 23:d=K.UTCTime;break;case 24:d=K.GeneralizedTime;break;case 25:d=K.GraphicString;break;case 26:d=K.VisibleString;break;case 27:d=K.GeneralString;break;case 28:d=K.UniversalString;break;case 29:d=K.CharacterString;break;case 30:d=K.BmpString;break;case 31:d=K.DATE;break;case 32:d=K.TimeOfDay;break;case 33:d=K.DateTime;break;case 34:d=K.Duration;break;default:{const l=i.idBlock.isConstructed?new K.Constructed:new K.Primitive;l.idBlock=i.idBlock,l.lenBlock=i.lenBlock,l.warnings=i.warnings,i=l}}break;case 2:case 3:case 4:default:d=i.idBlock.isConstructed?K.Constructed:K.Primitive}return i=o2(i,d),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 nr(t){if(!t.byteLength){const e=new Be({},qe);return e.error="Input buffer has zero length",{offset:-1,result:e}}return $r(V.toUint8Array(t).slice(),0,t.byteLength)}function a2(t,e){return t?1:e}class nn extends qe{constructor({value:e=[],isIndefiniteForm:n=!1,...r}={}){super(r),this.value=e,this.isIndefiniteForm=n}fromBER(e,n,r){const i=V.toUint8Array(e);if(!Wt(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(;a2(this.isIndefiniteForm,r)>0;){const o=$r(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===Zr)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===Zr?this.value.pop():this.warnings.push("No EndOfContent block encoded")),s}toBER(e,n){const r=n||new $o;for(let i=0;i<this.value.length;i++)this.value[i].toBER(e,r);return n?bt:r.final()}toJSON(){const e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(const n of this.value)e.value.push(n.toJSON());return e}}nn.NAME="ConstructedValueBlock";var ih;class We extends Be{constructor(e={}){super(e,nn),this.idBlock.isConstructed=!0}fromBER(e,n,r){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;const i=this.valueBlock.fromBER(e,n,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}onAsciiEncoding(){const e=[];for(const r of this.valueBlock.value)e.push(r.toString("ascii").split(`
100
100
  `).map(i=>` ${i}`).join(`
101
101
  `));const n=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${n} :
102
102
  ${e.join(`
103
- `)}`:`${n} :`}}ih=We;K.Constructed=ih;We.NAME="CONSTRUCTED";class sh extends qe{fromBER(e,n,r){return n}toBER(e){return bt}}sh.override="EndOfContentValueBlock";var oh;class Dd extends Be{constructor(e={}){super(e,sh),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}oh=Dd;K.EndOfContent=oh;Dd.NAME=Zr;var ah;class Nn extends Be{constructor(e={}){super(e,qe),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}`}}ah=Nn;K.Null=ah;Nn.NAME="NULL";class ch extends Pt(qe){constructor({value:e,...n}={}){super(n),n.valueHex?this.valueHexView=V.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=V.toUint8Array(e);return Wt(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,Z0.call(this),this.blockLength=r,n+r):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}ch.NAME="BooleanValueBlock";var dh;let xo=class extends Be{constructor(e={}){super(e,ch),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}`}};dh=xo;K.Boolean=dh;xo.NAME="BOOLEAN";class lh extends Pt(nn){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=nn.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===Zr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(o!==X0)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?nn.prototype.toBER.call(this,e,n):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}}lh.NAME="OctetStringValueBlock";var uh;let An=class fh extends Be{constructor({idBlock:e={},lenBlock:n={},...r}={}){var i,s;(i=r.isConstructed)!==null&&i!==void 0||(r.isConstructed=!!(!((s=r.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:r.isConstructed,...e},lenBlock:{...n,isIndefiniteForm:!!r.isIndefiniteForm},...r},lh),this.idBlock.tagClass=1,this.idBlock.tagNumber=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=$r(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?We.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 fh&&e.push(n.valueBlock.valueHexView);return V.concat(e)}};uh=An;K.OctetString=uh;An.NAME=X0;class ph extends Pt(nn){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=nn.prototype.fromBER.call(this,e,n,r),i===-1)return i;for(const c of this.value){const d=c.constructor.NAME;if(d===Zr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(d!==Y0)return this.error="BIT STRING may consists of BIT STRINGs only",-1;const l=c.valueBlock;if(this.unusedBits>0&&l.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=l.unusedBits}return i}const s=V.toUint8Array(e);if(!Wt(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 d=$r(c,0,c.byteLength);d.offset!==-1&&d.offset===r-1&&(this.value=[d.result])}}catch{}}return this.valueHexView=o.subarray(1),this.blockLength=o.length,n+r}toBER(e,n){if(this.isConstructed)return nn.prototype.toBER.call(this,e,n);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return bt;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}}}ph.NAME="BitStringValueBlock";var hh;let En=class extends Be{constructor({idBlock:e={},lenBlock:n={},...r}={}){var i,s;(i=r.isConstructed)!==null&&i!==void 0||(r.isConstructed=!!(!((s=r.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:r.isConstructed,...e},lenBlock:{...n,isIndefiniteForm:!!r.isIndefiniteForm},...r},ph),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 We.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)}`}}};hh=En;K.BitString=hh;En.NAME=Y0;var gh;function a2(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),d=c.length-1;let l=0;const u=d<o?o:d;let p=0;for(let m=u;m>=0;m--,p++){switch(!0){case p<c.length:l=s[o-p]+c[d-p]+n[0];break;default:l=s[o-p]+n[0]}switch(n[0]=l/10,!0){case p>=s.length:s=Xa(new Uint8Array([l%10]),s);break;default:s[o-p]=l%10}}return n[0]>0&&(s=Xa(n,s)),s}function ju(t){if(t>=Br.length)for(let e=Br.length;e<=t;e++){const n=new Uint8Array([0]);let r=Br[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=Xa(n,r)),Br.push(r)}return Br[t]}function c2(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),d=c.length-1;let l,u=0;for(let p=d;p>=0;p--,u++)switch(l=s[o-u]-c[d-u]-n,!0){case l<0:n=1,s[o-u]=l+10;break;default:n=0,s[o-u]=l}if(n>0)for(let p=o-d+1;p>=0;p--,u++)if(l=s[o-u]-n,l<0)n=1,s[o-u]=l+10;else{n=0,s[o-u]=l;break}return s.slice()}class qd extends Pt(qe){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=Z0.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(Jy(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 d=s.byteLength-1;d>=0;d--){i=s[d];for(let l=0;l<8;l++){if((i&1)===1)switch(r){case e:n=c2(ju(r),n),o="-";break;default:n=a2(n,ju(r))}r++,i>>=1}}for(let d=0;d<n.length;d++)n[d]&&(c=!0),c&&(o+=Ou.charAt(n[d]));return c===!1&&(o+=Ou.charAt(0)),o}}gh=qd;qd.NAME="IntegerValueBlock";Object.defineProperty(gh.prototype,"valueHex",{set:function(t){this.valueHexView=new Uint8Array(t),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var mh;class Nt extends Be{constructor(e={}){super(e,qd),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return xs(),BigInt(this.valueBlock.toString())}static fromBigInt(e){xs();const n=BigInt(e),r=new bo,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 l=BigInt(`0x${J.ToHex(c)}`)+n,u=V.toUint8Array(J.FromHex(l.toString(16)));u[0]|=128,r.write(u)}else s[0]&128&&r.write(new Uint8Array([0])),r.write(s);return new Nt({valueHex:r.final()})}convertToDER(){const e=new Nt({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new Nt({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}}mh=Nt;K.Integer=mh;Nt.NAME="INTEGER";var _h;class ko extends Nt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}_h=ko;K.Enumerated=_h;ko.NAME="ENUMERATED";class Ya extends Pt(qe){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=V.toUint8Array(e);if(!Wt(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=ar(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),n+this.blockLength)}set valueBigInt(e){xs();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=In(this.valueDec,7);if(n.byteLength===0)return this.error="Error during encoding SID value",bt;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}}}Ya.NAME="sidBlock";class yh extends qe{constructor({value:e=Ge,...n}={}){super(n),this.value=[],e&&this.fromString(e)}fromBER(e,n,r){let i=n;for(;r>0;){const s=new Ya;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,bt;n.push(i)}return Fd(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 d=parseInt(i,10);if(isNaN(d))return;o.valueDec=d+c,s=!1}else{const o=new Ya;if(i>Number.MAX_SAFE_INTEGER){xs();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}}yh.NAME="ObjectIdentifierValueBlock";var wh;class So extends Be{constructor(e={}){super(e,yh),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()}}}wh=So;K.ObjectIdentifier=wh;So.NAME="OBJECT IDENTIFIER";class Qa extends Pt(Fn){constructor({valueDec:e=0,...n}={}){super(n),this.valueDec=e}fromBER(e,n,r){if(r===0)return n;const i=V.toUint8Array(e);if(!Wt(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=ar(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=In(this.valueDec,7);if(n.byteLength===0)return this.error="Error during encoding SID value",bt;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}}}Qa.NAME="relativeSidBlock";class vh extends qe{constructor({value:e=Ge,...n}={}){super(n),this.value=[],e&&this.fromString(e)}fromBER(e,n,r){let i=n;for(;r>0;){const s=new Qa;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,bt;r.push(s)}return Fd(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 Qa;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}}vh.NAME="RelativeObjectIdentifierValueBlock";var bh;class Hd extends Be{constructor(e={}){super(e,vh),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()}}}bh=Hd;K.RelativeObjectIdentifier=bh;Hd.NAME="RelativeObjectIdentifier";var $h;class Ut extends We{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}$h=Ut;K.Sequence=$h;Ut.NAME="SEQUENCE";var xh;let Mt=class extends We{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};xh=Mt;K.Set=xh;Mt.NAME="SET";class kh extends Pt(qe){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=Ge}toJSON(){return{...super.toJSON(),value:this.value}}}kh.NAME="StringValueBlock";class Sh extends kh{}Sh.NAME="SimpleStringValueBlock";class nt extends Vd{constructor({...e}={}){super(e,Sh)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,V.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}}nt.NAME="SIMPLE STRING";class Ah extends nt{fromBuffer(e){this.valueBlock.valueHexView=V.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}}Ah.NAME="Utf8StringValueBlock";var Eh;class Jt extends Ah{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}Eh=Jt;K.Utf8String=Eh;Jt.NAME="UTF8String";class Ih extends nt{fromBuffer(e){this.valueBlock.value=J.ToUtf16String(e),this.valueBlock.valueHexView=V.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(J.FromUtf16String(e))}}Ih.NAME="BmpStringValueBlock";var Nh;class Ao extends Ih{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}Nh=Ao;K.BmpString=Nh;Ao.NAME="BMPString";class Ch extends nt{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=In(e.charCodeAt(i),8),o=new Uint8Array(s);if(o.length>4)continue;const c=4-o.length;for(let d=o.length-1;d>=0;d--)r[i*4+d+c]=o[d]}this.valueBlock.value=e}}Ch.NAME="UniversalStringValueBlock";var zh;class Eo extends Ch{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}zh=Eo;K.UniversalString=zh;Eo.NAME="UniversalString";var Oh;class Io extends nt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}Oh=Io;K.NumericString=Oh;Io.NAME="NumericString";var Ph;class No extends nt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}Ph=No;K.PrintableString=Ph;No.NAME="PrintableString";var jh;class Co extends nt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}jh=Co;K.TeletexString=jh;Co.NAME="TeletexString";var Th;class zo extends nt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}Th=zo;K.VideotexString=Th;zo.NAME="VideotexString";var Rh;class Oo extends nt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}Rh=Oo;K.IA5String=Rh;Oo.NAME="IA5String";var Bh;class Po extends nt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}Bh=Po;K.GraphicString=Bh;Po.NAME="GraphicString";var Lh;class _i extends nt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}Lh=_i;K.VisibleString=Lh;_i.NAME="VisibleString";var Uh;class jo extends nt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}Uh=jo;K.GeneralString=Uh;jo.NAME="GeneralString";var Mh;class To extends nt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}Mh=To;K.CharacterString=Mh;To.NAME="CharacterString";var Fh;class yi extends _i{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,V.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]=et(this.year<2e3?this.year-1900:this.year-2e3,2),n[1]=et(this.month,2),n[2]=et(this.day,2),n[3]=et(this.hour,2),n[4]=et(this.minute,2),n[5]=et(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}}}Fh=yi;K.UTCTime=Fh;yi.NAME="UTCTime";var Vh;class Ro extends yi{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,d=0;if(e[e.length-1]==="Z")r=e.substring(0,e.length-1),n=!0;else{const p=new Number(e[e.length-1]);if(isNaN(p.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 p=1,m=r.indexOf("+"),w="";if(m===-1&&(m=r.indexOf("-"),p=-1),m!==-1){if(w=r.substring(m+1),r=r.substring(0,m),w.length!==2&&w.length!==4)throw new Error("Wrong input string for conversion");let h=parseInt(w.substring(0,2),10);if(isNaN(h.valueOf()))throw new Error("Wrong input string for conversion");if(c=p*h,w.length===4){if(h=parseInt(w.substring(2,4),10),isNaN(h.valueOf()))throw new Error("Wrong input string for conversion");d=p*h}}}let l=r.indexOf(".");if(l===-1&&(l=r.indexOf(",")),l!==-1){const p=new Number(`0${r.substring(l)}`);if(isNaN(p.valueOf()))throw new Error("Wrong input string for conversion");s=p.valueOf(),i=r.substring(0,l)}else i=r;switch(!0){case i.length===8:if(o=/(\d{4})(\d{2})(\d{2})/ig,l!==-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,l!==-1){let p=60*s;this.minute=Math.floor(p),p=60*(p-this.minute),this.second=Math.floor(p),p=1e3*(p-this.second),this.millisecond=Math.floor(p)}break;case i.length===12:if(o=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,l!==-1){let p=60*s;this.second=Math.floor(p),p=1e3*(p-this.second),this.millisecond=Math.floor(p)}break;case i.length===14:if(o=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,l!==-1){const p=1e3*s;this.millisecond=Math.floor(p)}break;default:throw new Error("Wrong input string for conversion")}const u=o.exec(i);if(u===null)throw new Error("Wrong input string for conversion");for(let p=1;p<u.length;p++)switch(p){case 1:this.year=parseInt(u[p],10);break;case 2:this.month=parseInt(u[p],10);break;case 3:this.day=parseInt(u[p],10);break;case 4:this.hour=parseInt(u[p],10)+c;break;case 5:this.minute=parseInt(u[p],10)+d;break;case 6:this.second=parseInt(u[p],10);break;default:throw new Error("Wrong input string for conversion")}if(n===!1){const p=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=p.getUTCFullYear(),this.month=p.getUTCMonth(),this.day=p.getUTCDay(),this.hour=p.getUTCHours(),this.minute=p.getUTCMinutes(),this.second=p.getUTCSeconds(),this.millisecond=p.getUTCMilliseconds()}}toString(e="iso"){if(e==="iso"){const n=[];return n.push(et(this.year,4)),n.push(et(this.month,2)),n.push(et(this.day,2)),n.push(et(this.hour,2)),n.push(et(this.minute,2)),n.push(et(this.second,2)),this.millisecond!==0&&(n.push("."),n.push(et(this.millisecond,3))),n.push("Z"),n.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}}Vh=Ro;K.GeneralizedTime=Vh;Ro.NAME="GeneralizedTime";var Dh;class Kd extends Jt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}Dh=Kd;K.DATE=Dh;Kd.NAME="DATE";var qh;class Gd extends Jt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}qh=Gd;K.TimeOfDay=qh;Gd.NAME="TimeOfDay";var Hh;class Wd extends Jt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}Hh=Wd;K.DateTime=Hh;Wd.NAME="DateTime";var Kh;class Jd extends Jt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}Kh=Jd;K.Duration=Kh;Jd.NAME="Duration";var Gh;class Zd extends Jt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}Gh=Zd;K.TIME=Gh;Zd.NAME="TIME";class Cn{constructor({name:e=Ge,optional:n=!1}={}){this.name=e,this.optional=n}}class Xd extends Cn{constructor({value:e=[],...n}={}){super(n),this.value=e}}class ks extends Cn{constructor({value:e=new Cn,local:n=!1,...r}={}){super(r),this.value=e,this.local=n}}class d2{constructor({data:e=$o}={}){this.dataView=V.toUint8Array(e)}get data(){return this.dataView.slice().buffer}set data(e){this.dataView=V.toUint8Array(e)}fromBER(e,n,r){const i=n+r;return this.dataView=V.toUint8Array(e).subarray(n,i),i}toBER(e){return this.dataView.slice().buffer}}function xn(t,e,n){if(n instanceof Xd){for(let s=0;s<n.value.length;s++)if(xn(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(ba)&&(s.name=n.name),s}}if(n instanceof Cn)return n.hasOwnProperty(ba)&&(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(!(Yy in n))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(n2 in n.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(r2 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(Qy)===!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(e2)===!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(t2)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(n.idBlock.isConstructed!==e.idBlock.isConstructed)return{verified:!1,result:t};if(!(Xy 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(!(Pu 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,Ge),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 ks&&(c=e.valueBlock.value.length),c===0)return{verified:!0,result:t};if(e.valueBlock.value.length===0&&n.valueBlock.value.length!==0){let d=!0;for(let l=0;l<n.valueBlock.value.length;l++)d=d&&(n.valueBlock.value[l].optional||!1);return d?{verified:!0,result:t}:(n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Ge),n.name&&delete t[n.name]),t.error="Inconsistent object length",{verified:!1,result:t})}for(let d=0;d<c;d++)if(d-s>=e.valueBlock.value.length){if(n.valueBlock.value[d].optional===!1){const l={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,Ge),n.name&&(delete t[n.name],l.name=n.name)),l}}else if(n.valueBlock.value[0]instanceof ks){if(o=xn(t,e.valueBlock.value[d],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,Ge),n.name&&delete t[n.name]),o;if(ba in n.valueBlock.value[0]&&n.valueBlock.value[0].name.length>0){let l={};i2 in n.valueBlock.value[0]&&n.valueBlock.value[0].local?l=e:l=t,typeof l[n.valueBlock.value[0].name]>"u"&&(l[n.valueBlock.value[0].name]=[]),l[n.valueBlock.value[0].name].push(e.valueBlock.value[d])}}else if(o=xn(t,e.valueBlock.value[d-s],n.valueBlock.value[d]),o.verified===!1)if(n.valueBlock.value[d].optional)s++;else return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Ge),n.name&&delete t[n.name]),o;if(o.verified===!1){const d={verified:!1,result:t};return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Ge),n.name&&(delete t[n.name],d.name=n.name)),d}return{verified:!0,result:t}}if(n.primitiveSchema&&Pu in e.valueBlock){const s=$r(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,Ge),n.name&&(delete t[n.name],o.name=n.name)),o}return xn(t,s.result,n.primitiveSchema)}return{verified:!0,result:t}}function l2(t,e){if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};const n=$r(V.toUint8Array(t));return n.offset===-1?{verified:!1,result:n.result}:xn(n.result,n.result,e)}const Wh=Object.freeze(Object.defineProperty({__proto__:null,Any:Cn,BaseBlock:Be,BaseStringBlock:Vd,BitString:En,BmpString:Ao,Boolean:xo,CharacterString:To,Choice:Xd,Constructed:We,DATE:Kd,DateTime:Wd,Duration:Jd,EndOfContent:Dd,Enumerated:ko,GeneralString:jo,GeneralizedTime:Ro,GraphicString:Po,HexBlock:Pt,IA5String:Oo,Integer:Nt,Null:Nn,NumericString:Io,ObjectIdentifier:So,OctetString:An,Primitive:mi,PrintableString:No,RawData:d2,RelativeObjectIdentifier:Hd,Repeated:ks,Sequence:Ut,Set:Mt,TIME:Zd,TeletexString:Co,TimeOfDay:Gd,UTCTime:yi,UniversalString:Eo,Utf8String:Jt,ValueBlock:qe,VideotexString:zo,ViewWriter:bo,VisibleString:_i,compareSchema:xn,fromBER:nr,verifySchema:l2},Symbol.toStringTag,{value:"Module"}));var R;(function(t){t[t.Sequence=0]="Sequence",t[t.Set=1]="Set",t[t.Choice=2]="Choice"})(R||(R={}));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 Bo{constructor(e,n=0){if(this.unusedBits=0,this.value=new ArrayBuffer(0),e)if(typeof e=="number")this.fromNumber(e);else if(V.isBufferSource(e))this.unusedBits=n,this.value=V.toArrayBuffer(e);else throw TypeError("Unsupported type of 'params' argument for BitString")}fromASN(e){if(!(e instanceof En))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 En({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new En({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 le{get byteLength(){return this.buffer.byteLength}get byteOffset(){return 0}constructor(e){typeof e=="number"?this.buffer=new ArrayBuffer(e):V.isBufferSource(e)?this.buffer=V.toArrayBuffer(e):Array.isArray(e)?this.buffer=new Uint8Array(e):this.buffer=new ArrayBuffer(0)}fromASN(e){if(!(e instanceof An))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=e.valueBlock.valueHex,this}toASN(){return new An({valueHex:this.buffer})}toSchema(e){return new An({name:e})}}const u2={fromASN:t=>t instanceof Nn?null:t.valueBeforeDecodeView,toASN:t=>{if(t===null)return new Nn;const e=nr(t);if(e.result.error)throw new Error(e.result.error);return e.result}},f2={fromASN:t=>t.valueBlock.valueHexView.byteLength>=4?t.valueBlock.toString():t.valueBlock.valueDec,toASN:t=>new Nt({value:+t})},p2={fromASN:t=>t.valueBlock.valueDec,toASN:t=>new ko({value:t})},_e={fromASN:t=>t.valueBlock.valueHexView,toASN:t=>new Nt({valueHex:t})},h2={fromASN:t=>t.valueBlock.valueHexView,toASN:t=>new En({valueHex:t})},g2={fromASN:t=>t.valueBlock.toString(),toASN:t=>new So({value:t})},m2={fromASN:t=>t.valueBlock.value,toASN:t=>new xo({value:t})},Ss={fromASN:t=>t.valueBlock.valueHexView,toASN:t=>new An({valueHex:t})},_2={fromASN:t=>new le(t.getValue()),toASN:t=>t.toASN()};function dt(t){return{fromASN:e=>e.valueBlock.value,toASN:e=>new t({value:e})}}const Jh=dt(Jt),y2=dt(Ao),w2=dt(Eo),v2=dt(Io),b2=dt(No),$2=dt(Co),x2=dt(zo),k2=dt(Oo),S2=dt(Po),A2=dt(_i),E2=dt(jo),I2=dt(To),N2={fromASN:t=>t.toDate(),toASN:t=>new yi({valueDate:t})},C2={fromASN:t=>t.toDate(),toASN:t=>new Ro({valueDate:t})},z2={fromASN:()=>null,toASN:()=>new Nn};function Yd(t){switch(t){case b.Any:return u2;case b.BitString:return h2;case b.BmpString:return y2;case b.Boolean:return m2;case b.CharacterString:return I2;case b.Enumerated:return p2;case b.GeneralString:return E2;case b.GeneralizedTime:return C2;case b.GraphicString:return S2;case b.IA5String:return k2;case b.Integer:return f2;case b.Null:return z2;case b.NumericString:return v2;case b.ObjectIdentifier:return g2;case b.OctetString:return Ss;case b.PrintableString:return b2;case b.TeletexString:return $2;case b.UTCTime:return N2;case b.UniversalString:return w2;case b.Utf8String:return Jh;case b.VideotexString:return x2;case b.VisibleString:return A2;default:return null}}function Lt(t){return typeof t=="function"&&t.prototype?t.prototype.toASN&&t.prototype.fromASN?!0:Lt(t.prototype):!!(t&&typeof t=="object"&&"toASN"in t&&"fromASN"in t)}function Zh(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:Zh(n)}return!1}function O2(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 P2{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:R.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 d;if(typeof o.type=="number"){const u=b[o.type],p=Wh[u];if(!p)throw new Error(`Cannot get ASN1 class by name '${u}'`);d=new p({name:c})}else Lt(o.type)?d=new o.type().toSchema(c):o.optional?this.get(o.type).type===R.Choice?d=new Cn({name:c}):(d=this.create(o.type,!1),d.name=c):d=new Cn({name:c});const l=!!o.optional||o.defaultValue!==void 0;if(o.repeated){d.name="";const u=o.repeated==="set"?Mt:Ut;d=new u({name:"",value:[new ks({name:c,value:d})]})}if(o.context!==null&&o.context!==void 0)if(o.implicit)if(typeof o.type=="number"||Lt(o.type)){const u=o.repeated?We:mi;i.push(new u({name:c,optional:l,idBlock:{tagClass:3,tagNumber:o.context}}))}else{this.cache(o.type);const u=!!o.repeated;let p=u?d:this.get(o.type,!0).schema;p="valueBlock"in p?p.valueBlock.value:p.value,i.push(new We({name:u?"":c,optional:l,idBlock:{tagClass:3,tagNumber:o.context},value:p}))}else i.push(new We({optional:l,idBlock:{tagClass:3,tagNumber:o.context},value:[d]}));else d.optional=l,i.push(d)}switch(r.type){case R.Sequence:return new Ut({value:i,name:""});case R.Set:return new Mt({value:i,name:""});case R.Choice:return new Xd({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 it=new P2,B=t=>e=>{let n;it.has(e)?n=it.get(e):(n=it.createDefault(e),it.set(e,n)),Object.assign(n,t)},g=t=>(e,n)=>{let r;it.has(e.constructor)?r=it.get(e.constructor):(r=it.createDefault(e.constructor),it.set(e.constructor,r));const i=Object.assign({},t);if(typeof i.type=="number"&&!i.converter){const s=Yd(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 Tu extends Error{constructor(){super(...arguments),this.schemas=[]}}class j2{static parse(e,n){const r=nr(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(Lt(n))return new n().fromASN(e);const i=it.get(n);it.cache(n);let s=i.schema;if(e.constructor===We&&i.type!==R.Choice){s=new We({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:i.schema.valueBlock.value});for(const d in i.items)delete e[d]}const o=xn({},e,s);if(!o.verified)throw new Tu(`Data does not match to ${n.name} ASN1 schema. ${o.result.error}`);const c=new n;if(Zh(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 d=i.itemType;if(typeof d=="number"){const l=Yd(d);if(!l)throw new Error(`Cannot get default converter for array item of ${n.name} ASN1 schema`);return n.from(e.valueBlock.value,u=>l.fromASN(u))}else return n.from(e.valueBlock.value,l=>this.fromASN(l,d))}for(const d in i.items){const l=o.result[d];if(!l)continue;const u=i.items[d],p=u.type;if(typeof p=="number"||Lt(p)){const m=(r=u.converter)!==null&&r!==void 0?r:Lt(p)?new p:null;if(!m)throw new Error("Converter is empty");if(u.repeated)if(u.implicit){const w=u.repeated==="sequence"?Ut:Mt,h=new w;h.valueBlock=l.valueBlock;const _=nr(h.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 v=_.result.valueBlock.value;c[d]=Array.from(v,k=>m.fromASN(k))}else c[d]=Array.from(l,w=>m.fromASN(w));else{let w=l;if(u.implicit){let h;if(Lt(p))h=new p().toSchema("");else{const _=b[p],v=Wh[_];if(!v)throw new Error(`Cannot get '${_}' class from asn1js module`);h=new v}h.valueBlock=w.valueBlock,w=nr(h.toBER(!1)).result}c[d]=m.fromASN(w)}}else if(u.repeated){if(!Array.isArray(l))throw new Error("Cannot get list of items from the ASN.1 parsed value. ASN.1 value should be iterable.");c[d]=Array.from(l,m=>this.fromASN(m,p))}else c[d]=this.fromASN(l,p)}return c}catch(i){throw i instanceof Tu&&i.schemas.push(n.name),i}}}class Qd{static serialize(e){return e instanceof Be?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&typeof e=="object"&&Lt(e))return e.toASN();if(!(e&&typeof e=="object"))throw new TypeError("Parameter 1 should be type of Object.");const n=e.constructor,r=it.get(n);it.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=Yd(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],d=e[o];if(d===void 0||c.defaultValue===d||typeof c.defaultValue=="object"&&typeof d=="object"&&O2(this.serialize(c.defaultValue),this.serialize(d)))continue;const l=Qd.toAsnItem(c,o,n,d);if(typeof c.context=="number")if(c.implicit)if(!c.repeated&&(typeof c.type=="number"||Lt(c.type))){const u={};u.valueHex=l instanceof Nn?l.valueBeforeDecodeView:l.valueBlock.toBER(),i.push(new mi({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},...u}))}else i.push(new We({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:l.valueBlock.value}));else i.push(new We({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:[l]}));else c.repeated?i=i.concat(l):i.push(l)}let s;switch(r.type){case R.Sequence:s=new Ut({value:i});break;case R.Set:s=new Mt({value:i});break;case R.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,l=>o.toASN(l)),d=e.repeated==="sequence"?Ut:Mt;s=new d({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,d=>this.toASN(d)),c=e.repeated==="sequence"?Ut:Mt;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 F{static serialize(e){return Qd.serialize(e)}static parse(e,n){return j2.parse(e,n)}static toString(e){const n=V.isBufferSource(e)?V.toArrayBuffer(e):F.serialize(e),r=nr(n);if(r.offset===-1)throw new Error(`Cannot decode ASN.1 data. ${r.result.error}`);return r.result.toString()}}function f(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 Xh={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]+::?)+",d={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 l(h,_){if(h.indexOf("::")!==h.lastIndexOf("::"))return null;let v=0,k=-1,I=(h.match(d.zoneIndex)||[])[0],O,L;for(I&&(I=I.substring(1),h=h.replace(/%.+$/,""));(k=h.indexOf(":",k+1))>=0;)v++;if(h.substr(0,2)==="::"&&v--,h.substr(-2,2)==="::"&&v--,v>_)return null;for(L=_-v,O=":";L--;)O+="0:";return h=h.replace("::",O),h[0]===":"&&(h=h.slice(1)),h[h.length-1]===":"&&(h=h.slice(0,-1)),_=function(){const Y=h.split(":"),oe=[];for(let ae=0;ae<Y.length;ae++)oe.push(parseInt(Y[ae],16));return oe}(),{parts:_,zoneId:I}}function u(h,_,v,k){if(h.length!==_.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let I=0,O;for(;k>0;){if(O=v-k,O<0&&(O=0),h[I]>>O!==_[I]>>O)return!1;k-=v,I+=1}return!0}function p(h){if(s.test(h))return parseInt(h,16);if(h[0]==="0"&&!isNaN(parseInt(h[1],10))){if(i.test(h))return parseInt(h,8);throw new Error(`ipaddr: cannot parse ${h} as octal`)}return parseInt(h,10)}function m(h,_){for(;h.length<_;)h=`0${h}`;return h}const w={};w.IPv4=function(){function h(_){if(_.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let v,k;for(v=0;v<_.length;v++)if(k=_[v],!(0<=k&&k<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=_}return h.prototype.SpecialRanges={unspecified:[[new h([0,0,0,0]),8]],broadcast:[[new h([255,255,255,255]),32]],multicast:[[new h([224,0,0,0]),4]],linkLocal:[[new h([169,254,0,0]),16]],loopback:[[new h([127,0,0,0]),8]],carrierGradeNat:[[new h([100,64,0,0]),10]],private:[[new h([10,0,0,0]),8],[new h([172,16,0,0]),12],[new h([192,168,0,0]),16]],reserved:[[new h([192,0,0,0]),24],[new h([192,0,2,0]),24],[new h([192,88,99,0]),24],[new h([198,18,0,0]),15],[new h([198,51,100,0]),24],[new h([203,0,113,0]),24],[new h([240,0,0,0]),4]],as112:[[new h([192,175,48,0]),24],[new h([192,31,196,0]),24]],amt:[[new h([192,52,193,0]),24]]},h.prototype.kind=function(){return"ipv4"},h.prototype.match=function(_,v){let k;if(v===void 0&&(k=_,_=k[0],v=k[1]),_.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return u(this.octets,_.octets,8,v)},h.prototype.prefixLengthFromSubnetMask=function(){let _=0,v=!1;const k={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0};let I,O,L;for(I=3;I>=0;I-=1)if(O=this.octets[I],O in k){if(L=k[O],v&&L!==0)return null;L!==8&&(v=!0),_+=L}else return null;return 32-_},h.prototype.range=function(){return w.subnetMatch(this,this.SpecialRanges)},h.prototype.toByteArray=function(){return this.octets.slice(0)},h.prototype.toIPv4MappedAddress=function(){return w.IPv6.parse(`::ffff:${this.toString()}`)},h.prototype.toNormalizedString=function(){return this.toString()},h.prototype.toString=function(){return this.octets.join(".")},h}(),w.IPv4.broadcastAddressFromCIDR=function(h){try{const _=this.parseCIDR(h),v=_[0].toByteArray(),k=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),I=[];let O=0;for(;O<4;)I.push(parseInt(v[O],10)|parseInt(k[O],10)^255),O++;return new this(I)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},w.IPv4.isIPv4=function(h){return this.parser(h)!==null},w.IPv4.isValid=function(h){try{return new this(this.parser(h)),!0}catch{return!1}},w.IPv4.isValidCIDR=function(h){try{return this.parseCIDR(h),!0}catch{return!1}},w.IPv4.isValidFourPartDecimal=function(h){return!!(w.IPv4.isValid(h)&&h.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},w.IPv4.networkAddressFromCIDR=function(h){let _,v,k,I,O;try{for(_=this.parseCIDR(h),k=_[0].toByteArray(),O=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),I=[],v=0;v<4;)I.push(parseInt(k[v],10)&parseInt(O[v],10)),v++;return new this(I)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},w.IPv4.parse=function(h){const _=this.parser(h);if(_===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(_)},w.IPv4.parseCIDR=function(h){let _;if(_=h.match(/^(.+)\/(\d+)$/)){const v=parseInt(_[2]);if(v>=0&&v<=32){const k=[this.parse(_[1]),v];return Object.defineProperty(k,"toString",{value:function(){return this.join("/")}}),k}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},w.IPv4.parser=function(h){let _,v,k;if(_=h.match(r.fourOctet))return function(){const I=_.slice(1,6),O=[];for(let L=0;L<I.length;L++)v=I[L],O.push(p(v));return O}();if(_=h.match(r.longValue)){if(k=p(_[1]),k>4294967295||k<0)throw new Error("ipaddr: address outside defined range");return function(){const I=[];let O;for(O=0;O<=24;O+=8)I.push(k>>O&255);return I}().reverse()}else return(_=h.match(r.twoOctet))?function(){const I=_.slice(1,4),O=[];if(k=p(I[1]),k>16777215||k<0)throw new Error("ipaddr: address outside defined range");return O.push(p(I[0])),O.push(k>>16&255),O.push(k>>8&255),O.push(k&255),O}():(_=h.match(r.threeOctet))?function(){const I=_.slice(1,5),O=[];if(k=p(I[2]),k>65535||k<0)throw new Error("ipaddr: address outside defined range");return O.push(p(I[0])),O.push(p(I[1])),O.push(k>>8&255),O.push(k&255),O}():null},w.IPv4.subnetMaskFromPrefixLength=function(h){if(h=parseInt(h),h<0||h>32)throw new Error("ipaddr: invalid IPv4 prefix length");const _=[0,0,0,0];let v=0;const k=Math.floor(h/8);for(;v<k;)_[v]=255,v++;return k<4&&(_[k]=Math.pow(2,h%8)-1<<8-h%8),new this(_)},w.IPv6=function(){function h(_,v){let k,I;if(_.length===16)for(this.parts=[],k=0;k<=14;k+=2)this.parts.push(_[k]<<8|_[k+1]);else if(_.length===8)this.parts=_;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(k=0;k<this.parts.length;k++)if(I=this.parts[k],!(0<=I&&I<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");v&&(this.zoneId=v)}return h.prototype.SpecialRanges={unspecified:[new h([0,0,0,0,0,0,0,0]),128],linkLocal:[new h([65152,0,0,0,0,0,0,0]),10],multicast:[new h([65280,0,0,0,0,0,0,0]),8],loopback:[new h([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new h([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new h([0,0,0,0,0,65535,0,0]),96],discard:[new h([256,0,0,0,0,0,0,0]),64],rfc6145:[new h([0,0,0,0,65535,0,0,0]),96],rfc6052:[new h([100,65435,0,0,0,0,0,0]),96],"6to4":[new h([8194,0,0,0,0,0,0,0]),16],teredo:[new h([8193,0,0,0,0,0,0,0]),32],benchmarking:[new h([8193,2,0,0,0,0,0,0]),48],amt:[new h([8193,3,0,0,0,0,0,0]),32],as112v6:[[new h([8193,4,274,0,0,0,0,0]),48],[new h([9760,79,32768,0,0,0,0,0]),48]],deprecated:[new h([8193,16,0,0,0,0,0,0]),28],orchid2:[new h([8193,32,0,0,0,0,0,0]),28],droneRemoteIdProtocolEntityTags:[new h([8193,48,0,0,0,0,0,0]),28],reserved:[[new h([8193,0,0,0,0,0,0,0]),23],[new h([8193,3512,0,0,0,0,0,0]),32]]},h.prototype.isIPv4MappedAddress=function(){return this.range()==="ipv4Mapped"},h.prototype.kind=function(){return"ipv6"},h.prototype.match=function(_,v){let k;if(v===void 0&&(k=_,_=k[0],v=k[1]),_.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return u(this.parts,_.parts,16,v)},h.prototype.prefixLengthFromSubnetMask=function(){let _=0,v=!1;const k={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 I,O;for(let L=7;L>=0;L-=1)if(I=this.parts[L],I in k){if(O=k[I],v&&O!==0)return null;O!==16&&(v=!0),_+=O}else return null;return 128-_},h.prototype.range=function(){return w.subnetMatch(this,this.SpecialRanges)},h.prototype.toByteArray=function(){let _;const v=[],k=this.parts;for(let I=0;I<k.length;I++)_=k[I],v.push(_>>8),v.push(_&255);return v},h.prototype.toFixedLengthString=function(){const _=(function(){const k=[];for(let I=0;I<this.parts.length;I++)k.push(m(this.parts[I].toString(16),4));return k}).call(this).join(":");let v="";return this.zoneId&&(v=`%${this.zoneId}`),_+v},h.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");const _=this.parts.slice(-2),v=_[0],k=_[1];return new w.IPv4([v>>8,v&255,k>>8,k&255])},h.prototype.toNormalizedString=function(){const _=(function(){const k=[];for(let I=0;I<this.parts.length;I++)k.push(this.parts[I].toString(16));return k}).call(this).join(":");let v="";return this.zoneId&&(v=`%${this.zoneId}`),_+v},h.prototype.toRFC5952String=function(){const _=/((^|:)(0(:|$)){2,})/g,v=this.toNormalizedString();let k=0,I=-1,O;for(;O=_.exec(v);)O[0].length>I&&(k=O.index,I=O[0].length);return I<0?v:`${v.substring(0,k)}::${v.substring(k+I)}`},h.prototype.toString=function(){return this.toRFC5952String()},h}(),w.IPv6.broadcastAddressFromCIDR=function(h){try{const _=this.parseCIDR(h),v=_[0].toByteArray(),k=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),I=[];let O=0;for(;O<16;)I.push(parseInt(v[O],10)|parseInt(k[O],10)^255),O++;return new this(I)}catch(_){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${_})`)}},w.IPv6.isIPv6=function(h){return this.parser(h)!==null},w.IPv6.isValid=function(h){if(typeof h=="string"&&h.indexOf(":")===-1)return!1;try{const _=this.parser(h);return new this(_.parts,_.zoneId),!0}catch{return!1}},w.IPv6.isValidCIDR=function(h){if(typeof h=="string"&&h.indexOf(":")===-1)return!1;try{return this.parseCIDR(h),!0}catch{return!1}},w.IPv6.networkAddressFromCIDR=function(h){let _,v,k,I,O;try{for(_=this.parseCIDR(h),k=_[0].toByteArray(),O=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),I=[],v=0;v<16;)I.push(parseInt(k[v],10)&parseInt(O[v],10)),v++;return new this(I)}catch(L){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${L})`)}},w.IPv6.parse=function(h){const _=this.parser(h);if(_.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(_.parts,_.zoneId)},w.IPv6.parseCIDR=function(h){let _,v,k;if((v=h.match(/^(.+)\/(\d+)$/))&&(_=parseInt(v[2]),_>=0&&_<=128))return k=[this.parse(v[1]),_],Object.defineProperty(k,"toString",{value:function(){return this.join("/")}}),k;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},w.IPv6.parser=function(h){let _,v,k,I,O,L;if(k=h.match(d.deprecatedTransitional))return this.parser(`::ffff:${k[1]}`);if(d.native.test(h))return l(h,8);if((k=h.match(d.transitional))&&(L=k[6]||"",_=k[1],k[1].endsWith("::")||(_=_.slice(0,-1)),_=l(_+L,6),_.parts)){for(O=[parseInt(k[2]),parseInt(k[3]),parseInt(k[4]),parseInt(k[5])],v=0;v<O.length;v++)if(I=O[v],!(0<=I&&I<=255))return null;return _.parts.push(O[0]<<8|O[1]),_.parts.push(O[2]<<8|O[3]),{parts:_.parts,zoneId:_.zoneId}}return null},w.IPv6.subnetMaskFromPrefixLength=function(h){if(h=parseInt(h),h<0||h>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 v=0;const k=Math.floor(h/8);for(;v<k;)_[v]=255,v++;return k<16&&(_[k]=Math.pow(2,h%8)-1<<8-h%8),new this(_)},w.fromByteArray=function(h){const _=h.length;if(_===4)return new w.IPv4(h);if(_===16)return new w.IPv6(h);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},w.isValid=function(h){return w.IPv6.isValid(h)||w.IPv4.isValid(h)},w.isValidCIDR=function(h){return w.IPv6.isValidCIDR(h)||w.IPv4.isValidCIDR(h)},w.parse=function(h){if(w.IPv6.isValid(h))return w.IPv6.parse(h);if(w.IPv4.isValid(h))return w.IPv4.parse(h);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},w.parseCIDR=function(h){try{return w.IPv6.parseCIDR(h)}catch{try{return w.IPv4.parseCIDR(h)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},w.process=function(h){const _=this.parse(h);return _.kind()==="ipv6"&&_.isIPv4MappedAddress()?_.toIPv4Address():_},w.subnetMatch=function(h,_,v){let k,I,O,L;v==null&&(v="unicast");for(I in _)if(Object.prototype.hasOwnProperty.call(_,I)){for(O=_[I],O[0]&&!(O[0]instanceof Array)&&(O=[O]),k=0;k<O.length;k++)if(L=O[k],h.kind()===L[0].kind()&&h.match.apply(h,L))return I}return v},t.exports?t.exports=w:e.ipaddr=w})(vs)})(Xh);var Ru=Xh.exports;class Bu{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 Ru.fromByteArray(Array.from(n)).toString()}return this.decodeIP(J.ToHex(e))}static fromString(e){const n=Ru.parse(e);return new Uint8Array(n.toByteArray()).buffer}}var ec,tc,nc;let Le=class{constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};f([g({type:b.TeletexString})],Le.prototype,"teletexString",void 0);f([g({type:b.PrintableString})],Le.prototype,"printableString",void 0);f([g({type:b.UniversalString})],Le.prototype,"universalString",void 0);f([g({type:b.Utf8String})],Le.prototype,"utf8String",void 0);f([g({type:b.BmpString})],Le.prototype,"bmpString",void 0);Le=f([B({type:R.Choice})],Le);let cr=class extends Le{constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?J.ToHex(this.anyValue):super.toString())}};f([g({type:b.IA5String})],cr.prototype,"ia5String",void 0);f([g({type:b.Any})],cr.prototype,"anyValue",void 0);cr=f([B({type:R.Choice})],cr);class Lo{constructor(e={}){this.type="",this.value=new cr,Object.assign(this,e)}}f([g({type:b.ObjectIdentifier})],Lo.prototype,"type",void 0);f([g({type:cr})],Lo.prototype,"value",void 0);let dr=ec=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,ec.prototype)}};dr=ec=f([B({type:R.Set,itemType:Lo})],dr);let rc=tc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,tc.prototype)}};rc=tc=f([B({type:R.Sequence,itemType:dr})],rc);let $e=nc=class extends rc{constructor(e){super(e),Object.setPrototypeOf(this,nc.prototype)}};$e=nc=f([B({type:R.Sequence})],$e);const T2={fromASN:t=>Bu.toString(Ss.fromASN(t)),toASN:t=>Ss.toASN(Bu.fromString(t))};class Xr{constructor(e={}){this.typeId="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:b.ObjectIdentifier})],Xr.prototype,"typeId",void 0);f([g({type:b.Any,context:0})],Xr.prototype,"value",void 0);class el{constructor(e={}){this.partyName=new Le,Object.assign(this,e)}}f([g({type:Le,optional:!0,context:0,implicit:!0})],el.prototype,"nameAssigner",void 0);f([g({type:Le,context:1,implicit:!0})],el.prototype,"partyName",void 0);let ie=class{constructor(e={}){Object.assign(this,e)}};f([g({type:Xr,context:0,implicit:!0})],ie.prototype,"otherName",void 0);f([g({type:b.IA5String,context:1,implicit:!0})],ie.prototype,"rfc822Name",void 0);f([g({type:b.IA5String,context:2,implicit:!0})],ie.prototype,"dNSName",void 0);f([g({type:b.Any,context:3,implicit:!0})],ie.prototype,"x400Address",void 0);f([g({type:$e,context:4,implicit:!1})],ie.prototype,"directoryName",void 0);f([g({type:el,context:5})],ie.prototype,"ediPartyName",void 0);f([g({type:b.IA5String,context:6,implicit:!0})],ie.prototype,"uniformResourceIdentifier",void 0);f([g({type:b.OctetString,context:7,implicit:!0,converter:T2})],ie.prototype,"iPAddress",void 0);f([g({type:b.ObjectIdentifier,context:8,implicit:!0})],ie.prototype,"registeredID",void 0);ie=f([B({type:R.Choice})],ie);const tl="1.3.6.1.5.5.7",R2=`${tl}.1`,xr=`${tl}.3`,Uo=`${tl}.48`,Lu=`${Uo}.1`,Uu=`${Uo}.2`,Mu=`${Uo}.3`,Fu=`${Uo}.5`,hn="2.5.29";var ic;const sc=`${R2}.1`;class wi{constructor(e={}){this.accessMethod="",this.accessLocation=new ie,Object.assign(this,e)}}f([g({type:b.ObjectIdentifier})],wi.prototype,"accessMethod",void 0);f([g({type:ie})],wi.prototype,"accessLocation",void 0);let er=ic=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,ic.prototype)}};er=ic=f([B({type:R.Sequence,itemType:wi})],er);const oc=`${hn}.35`;class nl extends le{}class kn{constructor(e={}){e&&Object.assign(this,e)}}f([g({type:nl,context:0,optional:!0,implicit:!0})],kn.prototype,"keyIdentifier",void 0);f([g({type:ie,context:1,optional:!0,implicit:!0,repeated:"sequence"})],kn.prototype,"authorityCertIssuer",void 0);f([g({type:b.Integer,context:2,optional:!0,implicit:!0,converter:_e})],kn.prototype,"authorityCertSerialNumber",void 0);const Yh=`${hn}.19`;class As{constructor(e={}){this.cA=!1,Object.assign(this,e)}}f([g({type:b.Boolean,defaultValue:!1})],As.prototype,"cA",void 0);f([g({type:b.Integer,optional:!0})],As.prototype,"pathLenConstraint",void 0);var ac;let De=ac=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,ac.prototype)}};De=ac=f([B({type:R.Sequence,itemType:ie})],De);var cc;let Vu=cc=class extends De{constructor(e){super(e),Object.setPrototypeOf(this,cc.prototype)}};Vu=cc=f([B({type:R.Sequence})],Vu);var dc;const Qh=`${hn}.32`;let Vt=class{constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};f([g({type:b.IA5String})],Vt.prototype,"ia5String",void 0);f([g({type:b.VisibleString})],Vt.prototype,"visibleString",void 0);f([g({type:b.BmpString})],Vt.prototype,"bmpString",void 0);f([g({type:b.Utf8String})],Vt.prototype,"utf8String",void 0);Vt=f([B({type:R.Choice})],Vt);class rl{constructor(e={}){this.organization=new Vt,this.noticeNumbers=[],Object.assign(this,e)}}f([g({type:Vt})],rl.prototype,"organization",void 0);f([g({type:b.Integer,repeated:"sequence"})],rl.prototype,"noticeNumbers",void 0);class il{constructor(e={}){Object.assign(this,e)}}f([g({type:rl,optional:!0})],il.prototype,"noticeRef",void 0);f([g({type:Vt,optional:!0})],il.prototype,"explicitText",void 0);let Es=class{constructor(e={}){Object.assign(this,e)}};f([g({type:b.IA5String})],Es.prototype,"cPSuri",void 0);f([g({type:il})],Es.prototype,"userNotice",void 0);Es=f([B({type:R.Choice})],Es);class sl{constructor(e={}){this.policyQualifierId="",this.qualifier=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:b.ObjectIdentifier})],sl.prototype,"policyQualifierId",void 0);f([g({type:b.Any})],sl.prototype,"qualifier",void 0);class Mo{constructor(e={}){this.policyIdentifier="",Object.assign(this,e)}}f([g({type:b.ObjectIdentifier})],Mo.prototype,"policyIdentifier",void 0);f([g({type:sl,repeated:"sequence",optional:!0})],Mo.prototype,"policyQualifiers",void 0);let Is=dc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,dc.prototype)}};Is=dc=f([B({type:R.Sequence,itemType:Mo})],Is);let Ns=class{constructor(e=0){this.value=e}};f([g({type:b.Integer})],Ns.prototype,"value",void 0);Ns=f([B({type:R.Choice})],Ns);let Du=class extends Ns{};Du=f([B({type:R.Choice})],Du);var lc;const uc=`${hn}.31`;var pt;(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"})(pt||(pt={}));class eg extends Bo{toJSON(){const e=[],n=this.toNumber();return n&pt.aACompromise&&e.push("aACompromise"),n&pt.affiliationChanged&&e.push("affiliationChanged"),n&pt.cACompromise&&e.push("cACompromise"),n&pt.certificateHold&&e.push("certificateHold"),n&pt.cessationOfOperation&&e.push("cessationOfOperation"),n&pt.keyCompromise&&e.push("keyCompromise"),n&pt.privilegeWithdrawn&&e.push("privilegeWithdrawn"),n&pt.superseded&&e.push("superseded"),n&pt.unused&&e.push("unused"),e}toString(){return`[${this.toJSON().join(", ")}]`}}let zn=class{constructor(e={}){Object.assign(this,e)}};f([g({type:ie,context:0,repeated:"sequence",implicit:!0})],zn.prototype,"fullName",void 0);f([g({type:dr,context:1,implicit:!0})],zn.prototype,"nameRelativeToCRLIssuer",void 0);zn=f([B({type:R.Choice})],zn);class kr{constructor(e={}){Object.assign(this,e)}}f([g({type:zn,context:0,optional:!0})],kr.prototype,"distributionPoint",void 0);f([g({type:eg,context:1,optional:!0,implicit:!0})],kr.prototype,"reasons",void 0);f([g({type:ie,context:2,optional:!0,repeated:"sequence",implicit:!0})],kr.prototype,"cRLIssuer",void 0);let rr=lc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,lc.prototype)}};rr=lc=f([B({type:R.Sequence,itemType:kr})],rr);var fc;let qu=fc=class extends rr{constructor(e){super(e),Object.setPrototypeOf(this,fc.prototype)}};qu=fc=f([B({type:R.Sequence,itemType:kr})],qu);class Me{constructor(e={}){this.onlyContainsUserCerts=Me.ONLY,this.onlyContainsCACerts=Me.ONLY,this.indirectCRL=Me.ONLY,this.onlyContainsAttributeCerts=Me.ONLY,Object.assign(this,e)}}Me.ONLY=!1;f([g({type:zn,context:0,optional:!0})],Me.prototype,"distributionPoint",void 0);f([g({type:b.Boolean,context:1,defaultValue:Me.ONLY,implicit:!0})],Me.prototype,"onlyContainsUserCerts",void 0);f([g({type:b.Boolean,context:2,defaultValue:Me.ONLY,implicit:!0})],Me.prototype,"onlyContainsCACerts",void 0);f([g({type:eg,context:3,optional:!0,implicit:!0})],Me.prototype,"onlySomeReasons",void 0);f([g({type:b.Boolean,context:4,defaultValue:Me.ONLY,implicit:!0})],Me.prototype,"indirectCRL",void 0);f([g({type:b.Boolean,context:5,defaultValue:Me.ONLY,implicit:!0})],Me.prototype,"onlyContainsAttributeCerts",void 0);var Vr;(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"})(Vr||(Vr={}));let pc=class{constructor(e=Vr.unspecified){this.reason=Vr.unspecified,this.reason=e}toJSON(){return Vr[this.reason]}toString(){return this.toJSON()}};f([g({type:b.Enumerated})],pc.prototype,"reason",void 0);pc=f([B({type:R.Choice})],pc);var hc;const tg=`${hn}.37`;let Cs=hc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,hc.prototype)}};Cs=hc=f([B({type:R.Sequence,itemType:b.ObjectIdentifier})],Cs);const B2=`${xr}.1`,L2=`${xr}.2`,U2=`${xr}.3`,M2=`${xr}.4`,F2=`${xr}.8`,V2=`${xr}.9`;let gc=class{constructor(e=new ArrayBuffer(0)){this.value=e}};f([g({type:b.Integer,converter:_e})],gc.prototype,"value",void 0);gc=f([B({type:R.Choice})],gc);let mc=class{constructor(e){this.value=new Date,e&&(this.value=e)}};f([g({type:b.GeneralizedTime})],mc.prototype,"value",void 0);mc=f([B({type:R.Choice})],mc);var _c;let Hu=_c=class extends De{constructor(e){super(e),Object.setPrototypeOf(this,_c.prototype)}};Hu=_c=f([B({type:R.Sequence})],Hu);const ng=`${hn}.15`;var ht;(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"})(ht||(ht={}));class $a extends Bo{toJSON(){const e=this.toNumber(),n=[];return e&ht.cRLSign&&n.push("crlSign"),e&ht.dataEncipherment&&n.push("dataEncipherment"),e&ht.decipherOnly&&n.push("decipherOnly"),e&ht.digitalSignature&&n.push("digitalSignature"),e&ht.encipherOnly&&n.push("encipherOnly"),e&ht.keyAgreement&&n.push("keyAgreement"),e&ht.keyCertSign&&n.push("keyCertSign"),e&ht.keyEncipherment&&n.push("keyEncipherment"),e&ht.nonRepudiation&&n.push("nonRepudiation"),n}toString(){return`[${this.toJSON().join(", ")}]`}}var yc;class Fo{constructor(e={}){this.base=new ie,this.minimum=0,Object.assign(this,e)}}f([g({type:ie})],Fo.prototype,"base",void 0);f([g({type:b.Integer,context:0,defaultValue:0,implicit:!0})],Fo.prototype,"minimum",void 0);f([g({type:b.Integer,context:1,optional:!0,implicit:!0})],Fo.prototype,"maximum",void 0);let zs=yc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,yc.prototype)}};zs=yc=f([B({type:R.Sequence,itemType:Fo})],zs);class rg{constructor(e={}){Object.assign(this,e)}}f([g({type:zs,context:0,optional:!0,implicit:!0})],rg.prototype,"permittedSubtrees",void 0);f([g({type:zs,context:1,optional:!0,implicit:!0})],rg.prototype,"excludedSubtrees",void 0);class ig{constructor(e={}){Object.assign(this,e)}}f([g({type:b.Integer,context:0,implicit:!0,optional:!0,converter:_e})],ig.prototype,"requireExplicitPolicy",void 0);f([g({type:b.Integer,context:1,implicit:!0,optional:!0,converter:_e})],ig.prototype,"inhibitPolicyMapping",void 0);var wc;class ol{constructor(e={}){this.issuerDomainPolicy="",this.subjectDomainPolicy="",Object.assign(this,e)}}f([g({type:b.ObjectIdentifier})],ol.prototype,"issuerDomainPolicy",void 0);f([g({type:b.ObjectIdentifier})],ol.prototype,"subjectDomainPolicy",void 0);let Ku=wc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,wc.prototype)}};Ku=wc=f([B({type:R.Sequence,itemType:ol})],Ku);var vc;const sg=`${hn}.17`;let bc=vc=class extends De{constructor(e){super(e),Object.setPrototypeOf(this,vc.prototype)}};bc=vc=f([B({type:R.Sequence})],bc);let Dt=class{constructor(e={}){this.type="",this.values=[],Object.assign(this,e)}};f([g({type:b.ObjectIdentifier})],Dt.prototype,"type",void 0);f([g({type:b.Any,repeated:"set"})],Dt.prototype,"values",void 0);var $c;let Gu=$c=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,$c.prototype)}};Gu=$c=f([B({type:R.Sequence,itemType:Dt})],Gu);const og=`${hn}.14`;class rn extends nl{}class ag{constructor(e={}){Object.assign(this,e)}}f([g({type:b.GeneralizedTime,context:0,implicit:!0,optional:!0})],ag.prototype,"notBefore",void 0);f([g({type:b.GeneralizedTime,context:1,implicit:!0,optional:!0})],ag.prototype,"notAfter",void 0);var Dr;(function(t){t[t.keyUpdateAllowed=1]="keyUpdateAllowed",t[t.newExtensions=2]="newExtensions",t[t.pKIXCertificate=4]="pKIXCertificate"})(Dr||(Dr={}));class cg extends Bo{toJSON(){const e=[],n=this.toNumber();return n&Dr.pKIXCertificate&&e.push("pKIXCertificate"),n&Dr.newExtensions&&e.push("newExtensions"),n&Dr.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return`[${this.toJSON().join(", ")}]`}}class dg{constructor(e={}){this.entrustVers="",this.entrustInfoFlags=new cg,Object.assign(this,e)}}f([g({type:b.GeneralString})],dg.prototype,"entrustVers",void 0);f([g({type:cg})],dg.prototype,"entrustInfoFlags",void 0);var xc;let Wu=xc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,xc.prototype)}};Wu=xc=f([B({type:R.Sequence,itemType:wi})],Wu);class H{constructor(e={}){this.algorithm="",Object.assign(this,e)}isEqual(e){return e instanceof H&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&J0(e.parameters,this.parameters)||e.parameters===this.parameters)}}f([g({type:b.ObjectIdentifier})],H.prototype,"algorithm",void 0);f([g({type:b.Any,optional:!0})],H.prototype,"parameters",void 0);class gt{constructor(e={}){this.algorithm=new H,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:H})],gt.prototype,"algorithm",void 0);f([g({type:b.BitString})],gt.prototype,"subjectPublicKey",void 0);let Re=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}};f([g({type:b.UTCTime})],Re.prototype,"utcTime",void 0);f([g({type:b.GeneralizedTime})],Re.prototype,"generalTime",void 0);Re=f([B({type:R.Choice})],Re);class vi{constructor(e){this.notBefore=new Re(new Date),this.notAfter=new Re(new Date),e&&(this.notBefore=new Re(e.notBefore),this.notAfter=new Re(e.notAfter))}}f([g({type:Re})],vi.prototype,"notBefore",void 0);f([g({type:Re})],vi.prototype,"notAfter",void 0);var kc;let at=class lg{constructor(e={}){this.extnID="",this.critical=lg.CRITICAL,this.extnValue=new le,Object.assign(this,e)}};at.CRITICAL=!1;f([g({type:b.ObjectIdentifier})],at.prototype,"extnID",void 0);f([g({type:b.Boolean,defaultValue:at.CRITICAL})],at.prototype,"critical",void 0);f([g({type:le})],at.prototype,"extnValue",void 0);let an=kc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,kc.prototype)}};an=kc=f([B({type:R.Sequence,itemType:at})],an);var On;(function(t){t[t.v1=0]="v1",t[t.v2=1]="v2",t[t.v3=2]="v3"})(On||(On={}));class rt{constructor(e={}){this.version=On.v1,this.serialNumber=new ArrayBuffer(0),this.signature=new H,this.issuer=new $e,this.validity=new vi,this.subject=new $e,this.subjectPublicKeyInfo=new gt,Object.assign(this,e)}}f([g({type:b.Integer,context:0,defaultValue:On.v1})],rt.prototype,"version",void 0);f([g({type:b.Integer,converter:_e})],rt.prototype,"serialNumber",void 0);f([g({type:H})],rt.prototype,"signature",void 0);f([g({type:$e})],rt.prototype,"issuer",void 0);f([g({type:vi})],rt.prototype,"validity",void 0);f([g({type:$e})],rt.prototype,"subject",void 0);f([g({type:gt})],rt.prototype,"subjectPublicKeyInfo",void 0);f([g({type:b.BitString,context:1,implicit:!0,optional:!0})],rt.prototype,"issuerUniqueID",void 0);f([g({type:b.BitString,context:2,implicit:!0,optional:!0})],rt.prototype,"subjectUniqueID",void 0);f([g({type:an,context:3,optional:!0})],rt.prototype,"extensions",void 0);class Pn{constructor(e={}){this.tbsCertificate=new rt,this.signatureAlgorithm=new H,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:rt})],Pn.prototype,"tbsCertificate",void 0);f([g({type:H})],Pn.prototype,"signatureAlgorithm",void 0);f([g({type:b.BitString})],Pn.prototype,"signatureValue",void 0);class Vo{constructor(e={}){this.userCertificate=new ArrayBuffer(0),this.revocationDate=new Re,Object.assign(this,e)}}f([g({type:b.Integer,converter:_e})],Vo.prototype,"userCertificate",void 0);f([g({type:Re})],Vo.prototype,"revocationDate",void 0);f([g({type:at,optional:!0,repeated:"sequence"})],Vo.prototype,"crlEntryExtensions",void 0);class Zt{constructor(e={}){this.signature=new H,this.issuer=new $e,this.thisUpdate=new Re,Object.assign(this,e)}}f([g({type:b.Integer,optional:!0})],Zt.prototype,"version",void 0);f([g({type:H})],Zt.prototype,"signature",void 0);f([g({type:$e})],Zt.prototype,"issuer",void 0);f([g({type:Re})],Zt.prototype,"thisUpdate",void 0);f([g({type:Re,optional:!0})],Zt.prototype,"nextUpdate",void 0);f([g({type:Vo,repeated:"sequence",optional:!0})],Zt.prototype,"revokedCertificates",void 0);f([g({type:at,optional:!0,context:0,repeated:"sequence"})],Zt.prototype,"crlExtensions",void 0);class al{constructor(e={}){this.tbsCertList=new Zt,this.signatureAlgorithm=new H,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:Zt})],al.prototype,"tbsCertList",void 0);f([g({type:H})],al.prototype,"signatureAlgorithm",void 0);f([g({type:b.BitString})],al.prototype,"signature",void 0);class Sr{constructor(e={}){this.issuer=new $e,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:$e})],Sr.prototype,"issuer",void 0);f([g({type:b.Integer,converter:_e})],Sr.prototype,"serialNumber",void 0);let lr=class{constructor(e={}){Object.assign(this,e)}};f([g({type:rn,context:0,implicit:!0})],lr.prototype,"subjectKeyIdentifier",void 0);f([g({type:Sr})],lr.prototype,"issuerAndSerialNumber",void 0);lr=f([B({type:R.Choice})],lr);var qt;(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"})(qt||(qt={}));let Yr=class extends H{};Yr=f([B({type:R.Sequence})],Yr);let Os=class extends H{};Os=f([B({type:R.Sequence})],Os);let zt=class extends H{};zt=f([B({type:R.Sequence})],zt);let Ps=class extends H{};Ps=f([B({type:R.Sequence})],Ps);let Ju=class extends H{};Ju=f([B({type:R.Sequence})],Ju);let Sc=class extends H{};Sc=f([B({type:R.Sequence})],Sc);let Ar=class{constructor(e={}){this.attrType="",this.attrValues=[],Object.assign(this,e)}};f([g({type:b.ObjectIdentifier})],Ar.prototype,"attrType",void 0);f([g({type:b.Any,repeated:"set"})],Ar.prototype,"attrValues",void 0);var Ac;class jt{constructor(e={}){this.version=qt.v0,this.sid=new lr,this.digestAlgorithm=new Yr,this.signatureAlgorithm=new Os,this.signature=new le,Object.assign(this,e)}}f([g({type:b.Integer})],jt.prototype,"version",void 0);f([g({type:lr})],jt.prototype,"sid",void 0);f([g({type:Yr})],jt.prototype,"digestAlgorithm",void 0);f([g({type:Ar,repeated:"set",context:0,implicit:!0,optional:!0})],jt.prototype,"signedAttrs",void 0);f([g({type:Os})],jt.prototype,"signatureAlgorithm",void 0);f([g({type:le})],jt.prototype,"signature",void 0);f([g({type:Ar,repeated:"set",context:1,implicit:!0,optional:!0})],jt.prototype,"unsignedAttrs",void 0);let js=Ac=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Ac.prototype)}};js=Ac=f([B({type:R.Set,itemType:jt})],js);let Zu=class extends Re{};Zu=f([B({type:R.Choice})],Zu);let Xu=class extends jt{};Xu=f([B({type:R.Sequence})],Xu);class cl{constructor(e={}){this.acIssuer=new ie,this.acSerial=0,this.attrs=[],Object.assign(this,e)}}f([g({type:ie})],cl.prototype,"acIssuer",void 0);f([g({type:b.Integer})],cl.prototype,"acSerial",void 0);f([g({type:Dt,repeated:"sequence"})],cl.prototype,"attrs",void 0);var Ec;let Ts=Ec=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Ec.prototype)}};Ts=Ec=f([B({type:R.Sequence,itemType:b.ObjectIdentifier})],Ts);class Do{constructor(e={}){this.permitUnSpecified=!0,Object.assign(this,e)}}f([g({type:b.Integer,optional:!0})],Do.prototype,"pathLenConstraint",void 0);f([g({type:Ts,implicit:!0,context:0,optional:!0})],Do.prototype,"permittedAttrs",void 0);f([g({type:Ts,implicit:!0,context:1,optional:!0})],Do.prototype,"excludedAttrs",void 0);f([g({type:b.Boolean,defaultValue:!0})],Do.prototype,"permitUnSpecified",void 0);class Vn{constructor(e={}){this.issuer=new De,this.serial=new ArrayBuffer(0),this.issuerUID=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:De})],Vn.prototype,"issuer",void 0);f([g({type:b.Integer,converter:_e})],Vn.prototype,"serial",void 0);f([g({type:b.BitString,optional:!0})],Vn.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 Dn{constructor(e={}){this.digestedObjectType=Ic.publicKey,this.digestAlgorithm=new H,this.objectDigest=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:b.Enumerated})],Dn.prototype,"digestedObjectType",void 0);f([g({type:b.ObjectIdentifier,optional:!0})],Dn.prototype,"otherObjectTypeID",void 0);f([g({type:H})],Dn.prototype,"digestAlgorithm",void 0);f([g({type:b.BitString})],Dn.prototype,"objectDigest",void 0);class qo{constructor(e={}){Object.assign(this,e)}}f([g({type:De,optional:!0})],qo.prototype,"issuerName",void 0);f([g({type:Vn,context:0,implicit:!0,optional:!0})],qo.prototype,"baseCertificateID",void 0);f([g({type:Dn,context:1,implicit:!0,optional:!0})],qo.prototype,"objectDigestInfo",void 0);let ur=class{constructor(e={}){Object.assign(this,e)}};f([g({type:ie,repeated:"sequence"})],ur.prototype,"v1Form",void 0);f([g({type:qo,context:0,implicit:!0})],ur.prototype,"v2Form",void 0);ur=f([B({type:R.Choice})],ur);class Ho{constructor(e={}){this.notBeforeTime=new Date,this.notAfterTime=new Date,Object.assign(this,e)}}f([g({type:b.GeneralizedTime})],Ho.prototype,"notBeforeTime",void 0);f([g({type:b.GeneralizedTime})],Ho.prototype,"notAfterTime",void 0);class bi{constructor(e={}){Object.assign(this,e)}}f([g({type:Vn,implicit:!0,context:0,optional:!0})],bi.prototype,"baseCertificateID",void 0);f([g({type:De,implicit:!0,context:1,optional:!0})],bi.prototype,"entityName",void 0);f([g({type:Dn,implicit:!0,context:2,optional:!0})],bi.prototype,"objectDigestInfo",void 0);var Nc;(function(t){t[t.v2=1]="v2"})(Nc||(Nc={}));class $t{constructor(e={}){this.version=Nc.v2,this.holder=new bi,this.issuer=new ur,this.signature=new H,this.serialNumber=new ArrayBuffer(0),this.attrCertValidityPeriod=new Ho,this.attributes=[],Object.assign(this,e)}}f([g({type:b.Integer})],$t.prototype,"version",void 0);f([g({type:bi})],$t.prototype,"holder",void 0);f([g({type:ur})],$t.prototype,"issuer",void 0);f([g({type:H})],$t.prototype,"signature",void 0);f([g({type:b.Integer,converter:_e})],$t.prototype,"serialNumber",void 0);f([g({type:Ho})],$t.prototype,"attrCertValidityPeriod",void 0);f([g({type:Dt,repeated:"sequence"})],$t.prototype,"attributes",void 0);f([g({type:b.BitString,optional:!0})],$t.prototype,"issuerUniqueID",void 0);f([g({type:an,optional:!0})],$t.prototype,"extensions",void 0);class Ko{constructor(e={}){this.acinfo=new $t,this.signatureAlgorithm=new H,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:$t})],Ko.prototype,"acinfo",void 0);f([g({type:H})],Ko.prototype,"signatureAlgorithm",void 0);f([g({type:b.BitString})],Ko.prototype,"signatureValue",void 0);var Rs;(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"})(Rs||(Rs={}));class Cc extends Bo{}class dl{constructor(e={}){this.type="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:b.ObjectIdentifier,implicit:!0,context:0})],dl.prototype,"type",void 0);f([g({type:b.Any,implicit:!0,context:1})],dl.prototype,"value",void 0);class ll{constructor(e={}){this.policyId="",this.classList=new Cc(Rs.unclassified),Object.assign(this,e)}}f([g({type:b.ObjectIdentifier})],ll.prototype,"policyId",void 0);f([g({type:Cc,defaultValue:new Cc(Rs.unclassified)})],ll.prototype,"classList",void 0);f([g({type:dl,repeated:"set"})],ll.prototype,"securityCategories",void 0);class Go{constructor(e={}){Object.assign(this,e)}}f([g({type:le})],Go.prototype,"cotets",void 0);f([g({type:b.ObjectIdentifier})],Go.prototype,"oid",void 0);f([g({type:b.Utf8String})],Go.prototype,"string",void 0);class ug{constructor(e={}){this.values=[],Object.assign(this,e)}}f([g({type:De,implicit:!0,context:0,optional:!0})],ug.prototype,"policyAuthority",void 0);f([g({type:Go,repeated:"sequence"})],ug.prototype,"values",void 0);var zc;class Wo{constructor(e={}){this.targetCertificate=new Vn,Object.assign(this,e)}}f([g({type:Vn})],Wo.prototype,"targetCertificate",void 0);f([g({type:ie,optional:!0})],Wo.prototype,"targetName",void 0);f([g({type:Dn,optional:!0})],Wo.prototype,"certDigestInfo",void 0);let fr=class{constructor(e={}){Object.assign(this,e)}};f([g({type:ie,context:0,implicit:!0})],fr.prototype,"targetName",void 0);f([g({type:ie,context:1,implicit:!0})],fr.prototype,"targetGroup",void 0);f([g({type:Wo,context:2,implicit:!0})],fr.prototype,"targetCert",void 0);fr=f([B({type:R.Choice})],fr);let Oc=zc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,zc.prototype)}};Oc=zc=f([B({type:R.Sequence,itemType:fr})],Oc);var Pc;let Yu=Pc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Pc.prototype)}};Yu=Pc=f([B({type:R.Sequence,itemType:Oc})],Yu);class fg{constructor(e={}){Object.assign(this,e)}}f([g({type:De,implicit:!0,context:0,optional:!0})],fg.prototype,"roleAuthority",void 0);f([g({type:ie,implicit:!0,context:1})],fg.prototype,"roleName",void 0);class ul{constructor(e={}){this.service=new ie,this.ident=new ie,Object.assign(this,e)}}f([g({type:ie})],ul.prototype,"service",void 0);f([g({type:ie})],ul.prototype,"ident",void 0);f([g({type:le,optional:!0})],ul.prototype,"authInfo",void 0);var jc;class fl{constructor(e={}){this.otherCertFormat="",this.otherCert=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:b.ObjectIdentifier})],fl.prototype,"otherCertFormat",void 0);f([g({type:b.Any})],fl.prototype,"otherCert",void 0);let pr=class{constructor(e={}){Object.assign(this,e)}};f([g({type:Pn})],pr.prototype,"certificate",void 0);f([g({type:Ko,context:2,implicit:!0})],pr.prototype,"v2AttrCert",void 0);f([g({type:fl,context:3,implicit:!0})],pr.prototype,"other",void 0);pr=f([B({type:R.Choice})],pr);let Bs=jc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,jc.prototype)}};Bs=jc=f([B({type:R.Set,itemType:pr})],Bs);class Er{constructor(e={}){this.contentType="",this.content=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:b.ObjectIdentifier})],Er.prototype,"contentType",void 0);f([g({type:b.Any,context:0})],Er.prototype,"content",void 0);let Qr=class{constructor(e={}){Object.assign(this,e)}};f([g({type:le})],Qr.prototype,"single",void 0);f([g({type:b.Any})],Qr.prototype,"any",void 0);Qr=f([B({type:R.Choice})],Qr);class Jo{constructor(e={}){this.eContentType="",Object.assign(this,e)}}f([g({type:b.ObjectIdentifier})],Jo.prototype,"eContentType",void 0);f([g({type:Qr,context:0,optional:!0})],Jo.prototype,"eContent",void 0);let ei=class{constructor(e={}){Object.assign(this,e)}};f([g({type:le,context:0,implicit:!0,optional:!0})],ei.prototype,"value",void 0);f([g({type:le,converter:_2,context:0,implicit:!0,optional:!0,repeated:"sequence"})],ei.prototype,"constructedValue",void 0);ei=f([B({type:R.Choice})],ei);class $i{constructor(e={}){this.contentType="",this.contentEncryptionAlgorithm=new Ps,Object.assign(this,e)}}f([g({type:b.ObjectIdentifier})],$i.prototype,"contentType",void 0);f([g({type:Ps})],$i.prototype,"contentEncryptionAlgorithm",void 0);f([g({type:ei,optional:!0})],$i.prototype,"encryptedContent",void 0);class Zo{constructor(e={}){this.keyAttrId="",Object.assign(this,e)}}f([g({type:b.ObjectIdentifier})],Zo.prototype,"keyAttrId",void 0);f([g({type:b.Any,optional:!0})],Zo.prototype,"keyAttr",void 0);var Tc;class Xo{constructor(e={}){this.subjectKeyIdentifier=new rn,Object.assign(this,e)}}f([g({type:rn})],Xo.prototype,"subjectKeyIdentifier",void 0);f([g({type:b.GeneralizedTime,optional:!0})],Xo.prototype,"date",void 0);f([g({type:Zo,optional:!0})],Xo.prototype,"other",void 0);let hr=class{constructor(e={}){Object.assign(this,e)}};f([g({type:Xo,context:0,implicit:!0,optional:!0})],hr.prototype,"rKeyId",void 0);f([g({type:Sr,optional:!0})],hr.prototype,"issuerAndSerialNumber",void 0);hr=f([B({type:R.Choice})],hr);class pl{constructor(e={}){this.rid=new hr,this.encryptedKey=new le,Object.assign(this,e)}}f([g({type:hr})],pl.prototype,"rid",void 0);f([g({type:le})],pl.prototype,"encryptedKey",void 0);let Ls=Tc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Tc.prototype)}};Ls=Tc=f([B({type:R.Sequence,itemType:pl})],Ls);class hl{constructor(e={}){this.algorithm=new H,this.publicKey=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:H})],hl.prototype,"algorithm",void 0);f([g({type:b.BitString})],hl.prototype,"publicKey",void 0);let jn=class{constructor(e={}){Object.assign(this,e)}};f([g({type:rn,context:0,implicit:!0,optional:!0})],jn.prototype,"subjectKeyIdentifier",void 0);f([g({type:hl,context:1,implicit:!0,optional:!0})],jn.prototype,"originatorKey",void 0);f([g({type:Sr,optional:!0})],jn.prototype,"issuerAndSerialNumber",void 0);jn=f([B({type:R.Choice})],jn);class Ir{constructor(e={}){this.version=qt.v3,this.originator=new jn,this.keyEncryptionAlgorithm=new zt,this.recipientEncryptedKeys=new Ls,Object.assign(this,e)}}f([g({type:b.Integer})],Ir.prototype,"version",void 0);f([g({type:jn,context:0})],Ir.prototype,"originator",void 0);f([g({type:le,context:1,optional:!0})],Ir.prototype,"ukm",void 0);f([g({type:zt})],Ir.prototype,"keyEncryptionAlgorithm",void 0);f([g({type:Ls})],Ir.prototype,"recipientEncryptedKeys",void 0);let gr=class{constructor(e={}){Object.assign(this,e)}};f([g({type:rn,context:0,implicit:!0})],gr.prototype,"subjectKeyIdentifier",void 0);f([g({type:Sr})],gr.prototype,"issuerAndSerialNumber",void 0);gr=f([B({type:R.Choice})],gr);class xi{constructor(e={}){this.version=qt.v0,this.rid=new gr,this.keyEncryptionAlgorithm=new zt,this.encryptedKey=new le,Object.assign(this,e)}}f([g({type:b.Integer})],xi.prototype,"version",void 0);f([g({type:gr})],xi.prototype,"rid",void 0);f([g({type:zt})],xi.prototype,"keyEncryptionAlgorithm",void 0);f([g({type:le})],xi.prototype,"encryptedKey",void 0);class ki{constructor(e={}){this.keyIdentifier=new le,Object.assign(this,e)}}f([g({type:le})],ki.prototype,"keyIdentifier",void 0);f([g({type:b.GeneralizedTime,optional:!0})],ki.prototype,"date",void 0);f([g({type:Zo,optional:!0})],ki.prototype,"other",void 0);class Si{constructor(e={}){this.version=qt.v4,this.kekid=new ki,this.keyEncryptionAlgorithm=new zt,this.encryptedKey=new le,Object.assign(this,e)}}f([g({type:b.Integer})],Si.prototype,"version",void 0);f([g({type:ki})],Si.prototype,"kekid",void 0);f([g({type:zt})],Si.prototype,"keyEncryptionAlgorithm",void 0);f([g({type:le})],Si.prototype,"encryptedKey",void 0);class Ai{constructor(e={}){this.version=qt.v0,this.keyEncryptionAlgorithm=new zt,this.encryptedKey=new le,Object.assign(this,e)}}f([g({type:b.Integer})],Ai.prototype,"version",void 0);f([g({type:Sc,context:0,optional:!0})],Ai.prototype,"keyDerivationAlgorithm",void 0);f([g({type:zt})],Ai.prototype,"keyEncryptionAlgorithm",void 0);f([g({type:le})],Ai.prototype,"encryptedKey",void 0);class gl{constructor(e={}){this.oriType="",this.oriValue=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:b.ObjectIdentifier})],gl.prototype,"oriType",void 0);f([g({type:b.Any})],gl.prototype,"oriValue",void 0);let cn=class{constructor(e={}){Object.assign(this,e)}};f([g({type:xi,optional:!0})],cn.prototype,"ktri",void 0);f([g({type:Ir,context:1,implicit:!0,optional:!0})],cn.prototype,"kari",void 0);f([g({type:Si,context:2,implicit:!0,optional:!0})],cn.prototype,"kekri",void 0);f([g({type:Ai,context:3,implicit:!0,optional:!0})],cn.prototype,"pwri",void 0);f([g({type:gl,context:4,implicit:!0,optional:!0})],cn.prototype,"ori",void 0);cn=f([B({type:R.Choice})],cn);var Rc;let Us=Rc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Rc.prototype)}};Us=Rc=f([B({type:R.Set,itemType:cn})],Us);var Bc;class Yo{constructor(e={}){this.otherRevInfoFormat="",this.otherRevInfo=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:b.ObjectIdentifier})],Yo.prototype,"otherRevInfoFormat",void 0);f([g({type:b.Any})],Yo.prototype,"otherRevInfo",void 0);let Ms=class{constructor(e={}){this.other=new Yo,Object.assign(this,e)}};f([g({type:Yo,context:1,implicit:!0})],Ms.prototype,"other",void 0);Ms=f([B({type:R.Choice})],Ms);let Fs=Bc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Bc.prototype)}};Fs=Bc=f([B({type:R.Set,itemType:Ms})],Fs);class ml{constructor(e={}){Object.assign(this,e)}}f([g({type:Bs,context:0,implicit:!0,optional:!0})],ml.prototype,"certs",void 0);f([g({type:Fs,context:1,implicit:!0,optional:!0})],ml.prototype,"crls",void 0);var Lc;let Uc=Lc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Lc.prototype)}};Uc=Lc=f([B({type:R.Set,itemType:Ar})],Uc);class Ei{constructor(e={}){this.version=qt.v0,this.recipientInfos=new Us,this.encryptedContentInfo=new $i,Object.assign(this,e)}}f([g({type:b.Integer})],Ei.prototype,"version",void 0);f([g({type:ml,context:0,implicit:!0,optional:!0})],Ei.prototype,"originatorInfo",void 0);f([g({type:Us})],Ei.prototype,"recipientInfos",void 0);f([g({type:$i})],Ei.prototype,"encryptedContentInfo",void 0);f([g({type:Uc,context:1,implicit:!0,optional:!0})],Ei.prototype,"unprotectedAttrs",void 0);const D2="1.2.840.113549.1.7.2";var Mc;let Vs=Mc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Mc.prototype)}};Vs=Mc=f([B({type:R.Set,itemType:Yr})],Vs);class Nr{constructor(e={}){this.version=qt.v0,this.digestAlgorithms=new Vs,this.encapContentInfo=new Jo,this.signerInfos=new js,Object.assign(this,e)}}f([g({type:b.Integer})],Nr.prototype,"version",void 0);f([g({type:Vs})],Nr.prototype,"digestAlgorithms",void 0);f([g({type:Jo})],Nr.prototype,"encapContentInfo",void 0);f([g({type:Bs,context:0,implicit:!0,optional:!0})],Nr.prototype,"certificates",void 0);f([g({type:Fs,context:1,implicit:!0,optional:!0})],Nr.prototype,"crls",void 0);f([g({type:js})],Nr.prototype,"signerInfos",void 0);const ti="1.2.840.10045.2.1",_l="1.2.840.10045.4.1",pg="1.2.840.10045.4.3.1",yl="1.2.840.10045.4.3.2",wl="1.2.840.10045.4.3.3",vl="1.2.840.10045.4.3.4",Qu="1.2.840.10045.3.1.7",ef="1.3.132.0.34",tf="1.3.132.0.35";function Ii(t){return new H({algorithm:t})}const q2=Ii(_l);Ii(pg);const H2=Ii(yl),K2=Ii(wl),G2=Ii(vl);let ni=class{constructor(e={}){Object.assign(this,e)}};f([g({type:b.ObjectIdentifier})],ni.prototype,"fieldType",void 0);f([g({type:b.Any})],ni.prototype,"parameters",void 0);ni=f([B({type:R.Sequence})],ni);class W2 extends le{}let mr=class{constructor(e={}){Object.assign(this,e)}};f([g({type:b.OctetString})],mr.prototype,"a",void 0);f([g({type:b.OctetString})],mr.prototype,"b",void 0);f([g({type:b.BitString,optional:!0})],mr.prototype,"seed",void 0);mr=f([B({type:R.Sequence})],mr);var Fc;(function(t){t[t.ecpVer1=1]="ecpVer1"})(Fc||(Fc={}));let Ht=class{constructor(e={}){this.version=Fc.ecpVer1,Object.assign(this,e)}};f([g({type:b.Integer})],Ht.prototype,"version",void 0);f([g({type:ni})],Ht.prototype,"fieldID",void 0);f([g({type:mr})],Ht.prototype,"curve",void 0);f([g({type:W2})],Ht.prototype,"base",void 0);f([g({type:b.Integer,converter:_e})],Ht.prototype,"order",void 0);f([g({type:b.Integer,optional:!0})],Ht.prototype,"cofactor",void 0);Ht=f([B({type:R.Sequence})],Ht);let dn=class{constructor(e={}){Object.assign(this,e)}};f([g({type:b.ObjectIdentifier})],dn.prototype,"namedCurve",void 0);f([g({type:b.Null})],dn.prototype,"implicitCurve",void 0);f([g({type:Ht})],dn.prototype,"specifiedCurve",void 0);dn=f([B({type:R.Choice})],dn);class Qo{constructor(e={}){this.version=1,this.privateKey=new le,Object.assign(this,e)}}f([g({type:b.Integer})],Qo.prototype,"version",void 0);f([g({type:le})],Qo.prototype,"privateKey",void 0);f([g({type:dn,context:0,optional:!0})],Qo.prototype,"parameters",void 0);f([g({type:b.BitString,context:1,optional:!0})],Qo.prototype,"publicKey",void 0);class Ds{constructor(e={}){this.r=new ArrayBuffer(0),this.s=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:b.Integer,converter:_e})],Ds.prototype,"r",void 0);f([g({type:b.Integer,converter:_e})],Ds.prototype,"s",void 0);const Ye="1.2.840.113549.1.1",Tn=`${Ye}.1`,J2=`${Ye}.7`,Z2=`${Ye}.9`,qr=`${Ye}.10`,X2=`${Ye}.2`,Y2=`${Ye}.4`,qs=`${Ye}.5`,Q2=`${Ye}.14`,Vc=`${Ye}.11`,Hs=`${Ye}.12`,Ks=`${Ye}.13`,hg=`${Ye}.15`,gg=`${Ye}.16`,Gs="1.3.14.3.2.26",mg="2.16.840.1.101.3.4.2.4",Ws="2.16.840.1.101.3.4.2.1",Js="2.16.840.1.101.3.4.2.2",Zs="2.16.840.1.101.3.4.2.3",ew="2.16.840.1.101.3.4.2.5",tw="2.16.840.1.101.3.4.2.6",nw="1.2.840.113549.2.2",rw="1.2.840.113549.2.5",ea=`${Ye}.8`;function Ce(t){return new H({algorithm:t,parameters:null})}Ce(nw);Ce(rw);const Rn=Ce(Gs);Ce(mg);Ce(Ws);Ce(Js);Ce(Zs);Ce(ew);Ce(tw);const _g=new H({algorithm:ea,parameters:F.serialize(Rn)}),yg=new H({algorithm:Z2,parameters:F.serialize(Ss.toASN(new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer))});Ce(Tn);Ce(X2);Ce(Y2);Ce(qs);Ce(hg);Ce(gg);Ce(Hs);Ce(Ks);Ce(hg);Ce(gg);class ta{constructor(e={}){this.hashAlgorithm=new H(Rn),this.maskGenAlgorithm=new H({algorithm:ea,parameters:F.serialize(Rn)}),this.pSourceAlgorithm=new H(yg),Object.assign(this,e)}}f([g({type:H,context:0,defaultValue:Rn})],ta.prototype,"hashAlgorithm",void 0);f([g({type:H,context:1,defaultValue:_g})],ta.prototype,"maskGenAlgorithm",void 0);f([g({type:H,context:2,defaultValue:yg})],ta.prototype,"pSourceAlgorithm",void 0);new H({algorithm:J2,parameters:F.serialize(new ta)});class Bn{constructor(e={}){this.hashAlgorithm=new H(Rn),this.maskGenAlgorithm=new H({algorithm:ea,parameters:F.serialize(Rn)}),this.saltLength=20,this.trailerField=1,Object.assign(this,e)}}f([g({type:H,context:0,defaultValue:Rn})],Bn.prototype,"hashAlgorithm",void 0);f([g({type:H,context:1,defaultValue:_g})],Bn.prototype,"maskGenAlgorithm",void 0);f([g({type:b.Integer,context:2,defaultValue:20})],Bn.prototype,"saltLength",void 0);f([g({type:b.Integer,context:3,defaultValue:1})],Bn.prototype,"trailerField",void 0);new H({algorithm:qr,parameters:F.serialize(new Bn)});class na{constructor(e={}){this.digestAlgorithm=new H,this.digest=new le,Object.assign(this,e)}}f([g({type:H})],na.prototype,"digestAlgorithm",void 0);f([g({type:le})],na.prototype,"digest",void 0);var Dc;class ra{constructor(e={}){this.prime=new ArrayBuffer(0),this.exponent=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:b.Integer,converter:_e})],ra.prototype,"prime",void 0);f([g({type:b.Integer,converter:_e})],ra.prototype,"exponent",void 0);f([g({type:b.Integer,converter:_e})],ra.prototype,"coefficient",void 0);let qc=Dc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Dc.prototype)}};qc=Dc=f([B({type:R.Sequence,itemType:ra})],qc);class Tt{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)}}f([g({type:b.Integer})],Tt.prototype,"version",void 0);f([g({type:b.Integer,converter:_e})],Tt.prototype,"modulus",void 0);f([g({type:b.Integer,converter:_e})],Tt.prototype,"publicExponent",void 0);f([g({type:b.Integer,converter:_e})],Tt.prototype,"privateExponent",void 0);f([g({type:b.Integer,converter:_e})],Tt.prototype,"prime1",void 0);f([g({type:b.Integer,converter:_e})],Tt.prototype,"prime2",void 0);f([g({type:b.Integer,converter:_e})],Tt.prototype,"exponent1",void 0);f([g({type:b.Integer,converter:_e})],Tt.prototype,"exponent2",void 0);f([g({type:b.Integer,converter:_e})],Tt.prototype,"coefficient",void 0);f([g({type:qc,optional:!0})],Tt.prototype,"otherPrimeInfos",void 0);class bl{constructor(e={}){this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:b.Integer,converter:_e})],bl.prototype,"modulus",void 0);f([g({type:b.Integer,converter:_e})],bl.prototype,"publicExponent",void 0);var Hc;(function(t){t[t.Transient=0]="Transient",t[t.Singleton=1]="Singleton",t[t.ResolutionScoped=2]="ResolutionScoped",t[t.ContainerScoped=3]="ContainerScoped"})(Hc||(Hc={}));const Ke=Hc;/*! *****************************************************************************
103
+ `)}`:`${n} :`}}ih=We;K.Constructed=ih;We.NAME="CONSTRUCTED";class sh extends qe{fromBER(e,n,r){return n}toBER(e){return bt}}sh.override="EndOfContentValueBlock";var oh;class Dd extends Be{constructor(e={}){super(e,sh),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}oh=Dd;K.EndOfContent=oh;Dd.NAME=Zr;var ah;class Nn extends Be{constructor(e={}){super(e,qe),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}`}}ah=Nn;K.Null=ah;Nn.NAME="NULL";class ch extends Pt(qe){constructor({value:e,...n}={}){super(n),n.valueHex?this.valueHexView=V.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=V.toUint8Array(e);return Wt(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,Z0.call(this),this.blockLength=r,n+r):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}ch.NAME="BooleanValueBlock";var dh;let ko=class extends Be{constructor(e={}){super(e,ch),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}`}};dh=ko;K.Boolean=dh;ko.NAME="BOOLEAN";class lh extends Pt(nn){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=nn.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===Zr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(o!==X0)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?nn.prototype.toBER.call(this,e,n):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}}lh.NAME="OctetStringValueBlock";var uh;let An=class fh extends Be{constructor({idBlock:e={},lenBlock:n={},...r}={}){var i,s;(i=r.isConstructed)!==null&&i!==void 0||(r.isConstructed=!!(!((s=r.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:r.isConstructed,...e},lenBlock:{...n,isIndefiniteForm:!!r.isIndefiniteForm},...r},lh),this.idBlock.tagClass=1,this.idBlock.tagNumber=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=$r(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?We.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 fh&&e.push(n.valueBlock.valueHexView);return V.concat(e)}};uh=An;K.OctetString=uh;An.NAME=X0;class ph extends Pt(nn){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=nn.prototype.fromBER.call(this,e,n,r),i===-1)return i;for(const c of this.value){const d=c.constructor.NAME;if(d===Zr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(d!==Y0)return this.error="BIT STRING may consists of BIT STRINGs only",-1;const l=c.valueBlock;if(this.unusedBits>0&&l.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=l.unusedBits}return i}const s=V.toUint8Array(e);if(!Wt(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 d=$r(c,0,c.byteLength);d.offset!==-1&&d.offset===r-1&&(this.value=[d.result])}}catch{}}return this.valueHexView=o.subarray(1),this.blockLength=o.length,n+r}toBER(e,n){if(this.isConstructed)return nn.prototype.toBER.call(this,e,n);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return bt;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}}}ph.NAME="BitStringValueBlock";var hh;let En=class extends Be{constructor({idBlock:e={},lenBlock:n={},...r}={}){var i,s;(i=r.isConstructed)!==null&&i!==void 0||(r.isConstructed=!!(!((s=r.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:r.isConstructed,...e},lenBlock:{...n,isIndefiniteForm:!!r.isIndefiniteForm},...r},ph),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 We.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)}`}}};hh=En;K.BitString=hh;En.NAME=Y0;var gh;function c2(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),d=c.length-1;let l=0;const u=d<o?o:d;let p=0;for(let m=u;m>=0;m--,p++){switch(!0){case p<c.length:l=s[o-p]+c[d-p]+n[0];break;default:l=s[o-p]+n[0]}switch(n[0]=l/10,!0){case p>=s.length:s=Xa(new Uint8Array([l%10]),s);break;default:s[o-p]=l%10}}return n[0]>0&&(s=Xa(n,s)),s}function ju(t){if(t>=Br.length)for(let e=Br.length;e<=t;e++){const n=new Uint8Array([0]);let r=Br[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=Xa(n,r)),Br.push(r)}return Br[t]}function d2(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),d=c.length-1;let l,u=0;for(let p=d;p>=0;p--,u++)switch(l=s[o-u]-c[d-u]-n,!0){case l<0:n=1,s[o-u]=l+10;break;default:n=0,s[o-u]=l}if(n>0)for(let p=o-d+1;p>=0;p--,u++)if(l=s[o-u]-n,l<0)n=1,s[o-u]=l+10;else{n=0,s[o-u]=l;break}return s.slice()}class qd extends Pt(qe){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=Z0.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(Zy(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 d=s.byteLength-1;d>=0;d--){i=s[d];for(let l=0;l<8;l++){if((i&1)===1)switch(r){case e:n=d2(ju(r),n),o="-";break;default:n=c2(n,ju(r))}r++,i>>=1}}for(let d=0;d<n.length;d++)n[d]&&(c=!0),c&&(o+=Ou.charAt(n[d]));return c===!1&&(o+=Ou.charAt(0)),o}}gh=qd;qd.NAME="IntegerValueBlock";Object.defineProperty(gh.prototype,"valueHex",{set:function(t){this.valueHexView=new Uint8Array(t),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var mh;class Nt extends Be{constructor(e={}){super(e,qd),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return ks(),BigInt(this.valueBlock.toString())}static fromBigInt(e){ks();const n=BigInt(e),r=new $o,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 l=BigInt(`0x${J.ToHex(c)}`)+n,u=V.toUint8Array(J.FromHex(l.toString(16)));u[0]|=128,r.write(u)}else s[0]&128&&r.write(new Uint8Array([0])),r.write(s);return new Nt({valueHex:r.final()})}convertToDER(){const e=new Nt({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new Nt({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}}mh=Nt;K.Integer=mh;Nt.NAME="INTEGER";var _h;class So extends Nt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}_h=So;K.Enumerated=_h;So.NAME="ENUMERATED";class Ya extends Pt(qe){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=V.toUint8Array(e);if(!Wt(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=ar(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),n+this.blockLength)}set valueBigInt(e){ks();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=In(this.valueDec,7);if(n.byteLength===0)return this.error="Error during encoding SID value",bt;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}}}Ya.NAME="sidBlock";class yh extends qe{constructor({value:e=Ge,...n}={}){super(n),this.value=[],e&&this.fromString(e)}fromBER(e,n,r){let i=n;for(;r>0;){const s=new Ya;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,bt;n.push(i)}return Fd(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 d=parseInt(i,10);if(isNaN(d))return;o.valueDec=d+c,s=!1}else{const o=new Ya;if(i>Number.MAX_SAFE_INTEGER){ks();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}}yh.NAME="ObjectIdentifierValueBlock";var wh;class Ao extends Be{constructor(e={}){super(e,yh),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()}}}wh=Ao;K.ObjectIdentifier=wh;Ao.NAME="OBJECT IDENTIFIER";class Qa extends Pt(Fn){constructor({valueDec:e=0,...n}={}){super(n),this.valueDec=e}fromBER(e,n,r){if(r===0)return n;const i=V.toUint8Array(e);if(!Wt(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=ar(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=In(this.valueDec,7);if(n.byteLength===0)return this.error="Error during encoding SID value",bt;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}}}Qa.NAME="relativeSidBlock";class vh extends qe{constructor({value:e=Ge,...n}={}){super(n),this.value=[],e&&this.fromString(e)}fromBER(e,n,r){let i=n;for(;r>0;){const s=new Qa;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,bt;r.push(s)}return Fd(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 Qa;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}}vh.NAME="RelativeObjectIdentifierValueBlock";var bh;class Hd extends Be{constructor(e={}){super(e,vh),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()}}}bh=Hd;K.RelativeObjectIdentifier=bh;Hd.NAME="RelativeObjectIdentifier";var $h;class Ut extends We{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}$h=Ut;K.Sequence=$h;Ut.NAME="SEQUENCE";var xh;let Mt=class extends We{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};xh=Mt;K.Set=xh;Mt.NAME="SET";class kh extends Pt(qe){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=Ge}toJSON(){return{...super.toJSON(),value:this.value}}}kh.NAME="StringValueBlock";class Sh extends kh{}Sh.NAME="SimpleStringValueBlock";class nt extends Vd{constructor({...e}={}){super(e,Sh)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,V.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}}nt.NAME="SIMPLE STRING";class Ah extends nt{fromBuffer(e){this.valueBlock.valueHexView=V.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}}Ah.NAME="Utf8StringValueBlock";var Eh;class Jt extends Ah{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}Eh=Jt;K.Utf8String=Eh;Jt.NAME="UTF8String";class Ih extends nt{fromBuffer(e){this.valueBlock.value=J.ToUtf16String(e),this.valueBlock.valueHexView=V.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(J.FromUtf16String(e))}}Ih.NAME="BmpStringValueBlock";var Nh;class Eo extends Ih{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}Nh=Eo;K.BmpString=Nh;Eo.NAME="BMPString";class Ch extends nt{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=In(e.charCodeAt(i),8),o=new Uint8Array(s);if(o.length>4)continue;const c=4-o.length;for(let d=o.length-1;d>=0;d--)r[i*4+d+c]=o[d]}this.valueBlock.value=e}}Ch.NAME="UniversalStringValueBlock";var zh;class Io extends Ch{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}zh=Io;K.UniversalString=zh;Io.NAME="UniversalString";var Oh;class No extends nt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}Oh=No;K.NumericString=Oh;No.NAME="NumericString";var Ph;class Co extends nt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}Ph=Co;K.PrintableString=Ph;Co.NAME="PrintableString";var jh;class zo extends nt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}jh=zo;K.TeletexString=jh;zo.NAME="TeletexString";var Th;class Oo extends nt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}Th=Oo;K.VideotexString=Th;Oo.NAME="VideotexString";var Rh;class Po extends nt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}Rh=Po;K.IA5String=Rh;Po.NAME="IA5String";var Bh;class jo extends nt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}Bh=jo;K.GraphicString=Bh;jo.NAME="GraphicString";var Lh;class yi extends nt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}Lh=yi;K.VisibleString=Lh;yi.NAME="VisibleString";var Uh;class To extends nt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}Uh=To;K.GeneralString=Uh;To.NAME="GeneralString";var Mh;class Ro extends nt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}Mh=Ro;K.CharacterString=Mh;Ro.NAME="CharacterString";var Fh;class wi extends yi{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,V.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]=et(this.year<2e3?this.year-1900:this.year-2e3,2),n[1]=et(this.month,2),n[2]=et(this.day,2),n[3]=et(this.hour,2),n[4]=et(this.minute,2),n[5]=et(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}}}Fh=wi;K.UTCTime=Fh;wi.NAME="UTCTime";var Vh;class Bo extends wi{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,d=0;if(e[e.length-1]==="Z")r=e.substring(0,e.length-1),n=!0;else{const p=new Number(e[e.length-1]);if(isNaN(p.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 p=1,m=r.indexOf("+"),w="";if(m===-1&&(m=r.indexOf("-"),p=-1),m!==-1){if(w=r.substring(m+1),r=r.substring(0,m),w.length!==2&&w.length!==4)throw new Error("Wrong input string for conversion");let h=parseInt(w.substring(0,2),10);if(isNaN(h.valueOf()))throw new Error("Wrong input string for conversion");if(c=p*h,w.length===4){if(h=parseInt(w.substring(2,4),10),isNaN(h.valueOf()))throw new Error("Wrong input string for conversion");d=p*h}}}let l=r.indexOf(".");if(l===-1&&(l=r.indexOf(",")),l!==-1){const p=new Number(`0${r.substring(l)}`);if(isNaN(p.valueOf()))throw new Error("Wrong input string for conversion");s=p.valueOf(),i=r.substring(0,l)}else i=r;switch(!0){case i.length===8:if(o=/(\d{4})(\d{2})(\d{2})/ig,l!==-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,l!==-1){let p=60*s;this.minute=Math.floor(p),p=60*(p-this.minute),this.second=Math.floor(p),p=1e3*(p-this.second),this.millisecond=Math.floor(p)}break;case i.length===12:if(o=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,l!==-1){let p=60*s;this.second=Math.floor(p),p=1e3*(p-this.second),this.millisecond=Math.floor(p)}break;case i.length===14:if(o=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,l!==-1){const p=1e3*s;this.millisecond=Math.floor(p)}break;default:throw new Error("Wrong input string for conversion")}const u=o.exec(i);if(u===null)throw new Error("Wrong input string for conversion");for(let p=1;p<u.length;p++)switch(p){case 1:this.year=parseInt(u[p],10);break;case 2:this.month=parseInt(u[p],10);break;case 3:this.day=parseInt(u[p],10);break;case 4:this.hour=parseInt(u[p],10)+c;break;case 5:this.minute=parseInt(u[p],10)+d;break;case 6:this.second=parseInt(u[p],10);break;default:throw new Error("Wrong input string for conversion")}if(n===!1){const p=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=p.getUTCFullYear(),this.month=p.getUTCMonth(),this.day=p.getUTCDay(),this.hour=p.getUTCHours(),this.minute=p.getUTCMinutes(),this.second=p.getUTCSeconds(),this.millisecond=p.getUTCMilliseconds()}}toString(e="iso"){if(e==="iso"){const n=[];return n.push(et(this.year,4)),n.push(et(this.month,2)),n.push(et(this.day,2)),n.push(et(this.hour,2)),n.push(et(this.minute,2)),n.push(et(this.second,2)),this.millisecond!==0&&(n.push("."),n.push(et(this.millisecond,3))),n.push("Z"),n.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}}Vh=Bo;K.GeneralizedTime=Vh;Bo.NAME="GeneralizedTime";var Dh;class Kd extends Jt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}Dh=Kd;K.DATE=Dh;Kd.NAME="DATE";var qh;class Gd extends Jt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}qh=Gd;K.TimeOfDay=qh;Gd.NAME="TimeOfDay";var Hh;class Wd extends Jt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}Hh=Wd;K.DateTime=Hh;Wd.NAME="DateTime";var Kh;class Jd extends Jt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}Kh=Jd;K.Duration=Kh;Jd.NAME="Duration";var Gh;class Zd extends Jt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}Gh=Zd;K.TIME=Gh;Zd.NAME="TIME";class Cn{constructor({name:e=Ge,optional:n=!1}={}){this.name=e,this.optional=n}}class Xd extends Cn{constructor({value:e=[],...n}={}){super(n),this.value=e}}class Ss extends Cn{constructor({value:e=new Cn,local:n=!1,...r}={}){super(r),this.value=e,this.local=n}}class l2{constructor({data:e=xo}={}){this.dataView=V.toUint8Array(e)}get data(){return this.dataView.slice().buffer}set data(e){this.dataView=V.toUint8Array(e)}fromBER(e,n,r){const i=n+r;return this.dataView=V.toUint8Array(e).subarray(n,i),i}toBER(e){return this.dataView.slice().buffer}}function xn(t,e,n){if(n instanceof Xd){for(let s=0;s<n.value.length;s++)if(xn(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(ba)&&(s.name=n.name),s}}if(n instanceof Cn)return n.hasOwnProperty(ba)&&(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(!(Qy in n))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(r2 in n.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(i2 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(e2)===!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(t2)===!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(n2)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(n.idBlock.isConstructed!==e.idBlock.isConstructed)return{verified:!1,result:t};if(!(Yy 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(!(Pu 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,Ge),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 Ss&&(c=e.valueBlock.value.length),c===0)return{verified:!0,result:t};if(e.valueBlock.value.length===0&&n.valueBlock.value.length!==0){let d=!0;for(let l=0;l<n.valueBlock.value.length;l++)d=d&&(n.valueBlock.value[l].optional||!1);return d?{verified:!0,result:t}:(n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Ge),n.name&&delete t[n.name]),t.error="Inconsistent object length",{verified:!1,result:t})}for(let d=0;d<c;d++)if(d-s>=e.valueBlock.value.length){if(n.valueBlock.value[d].optional===!1){const l={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,Ge),n.name&&(delete t[n.name],l.name=n.name)),l}}else if(n.valueBlock.value[0]instanceof Ss){if(o=xn(t,e.valueBlock.value[d],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,Ge),n.name&&delete t[n.name]),o;if(ba in n.valueBlock.value[0]&&n.valueBlock.value[0].name.length>0){let l={};s2 in n.valueBlock.value[0]&&n.valueBlock.value[0].local?l=e:l=t,typeof l[n.valueBlock.value[0].name]>"u"&&(l[n.valueBlock.value[0].name]=[]),l[n.valueBlock.value[0].name].push(e.valueBlock.value[d])}}else if(o=xn(t,e.valueBlock.value[d-s],n.valueBlock.value[d]),o.verified===!1)if(n.valueBlock.value[d].optional)s++;else return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Ge),n.name&&delete t[n.name]),o;if(o.verified===!1){const d={verified:!1,result:t};return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Ge),n.name&&(delete t[n.name],d.name=n.name)),d}return{verified:!0,result:t}}if(n.primitiveSchema&&Pu in e.valueBlock){const s=$r(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,Ge),n.name&&(delete t[n.name],o.name=n.name)),o}return xn(t,s.result,n.primitiveSchema)}return{verified:!0,result:t}}function u2(t,e){if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};const n=$r(V.toUint8Array(t));return n.offset===-1?{verified:!1,result:n.result}:xn(n.result,n.result,e)}const Wh=Object.freeze(Object.defineProperty({__proto__:null,Any:Cn,BaseBlock:Be,BaseStringBlock:Vd,BitString:En,BmpString:Eo,Boolean:ko,CharacterString:Ro,Choice:Xd,Constructed:We,DATE:Kd,DateTime:Wd,Duration:Jd,EndOfContent:Dd,Enumerated:So,GeneralString:To,GeneralizedTime:Bo,GraphicString:jo,HexBlock:Pt,IA5String:Po,Integer:Nt,Null:Nn,NumericString:No,ObjectIdentifier:Ao,OctetString:An,Primitive:_i,PrintableString:Co,RawData:l2,RelativeObjectIdentifier:Hd,Repeated:Ss,Sequence:Ut,Set:Mt,TIME:Zd,TeletexString:zo,TimeOfDay:Gd,UTCTime:wi,UniversalString:Io,Utf8String:Jt,ValueBlock:qe,VideotexString:Oo,ViewWriter:$o,VisibleString:yi,compareSchema:xn,fromBER:nr,verifySchema:u2},Symbol.toStringTag,{value:"Module"}));var R;(function(t){t[t.Sequence=0]="Sequence",t[t.Set=1]="Set",t[t.Choice=2]="Choice"})(R||(R={}));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 Lo{constructor(e,n=0){if(this.unusedBits=0,this.value=new ArrayBuffer(0),e)if(typeof e=="number")this.fromNumber(e);else if(V.isBufferSource(e))this.unusedBits=n,this.value=V.toArrayBuffer(e);else throw TypeError("Unsupported type of 'params' argument for BitString")}fromASN(e){if(!(e instanceof En))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 En({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new En({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 le{get byteLength(){return this.buffer.byteLength}get byteOffset(){return 0}constructor(e){typeof e=="number"?this.buffer=new ArrayBuffer(e):V.isBufferSource(e)?this.buffer=V.toArrayBuffer(e):Array.isArray(e)?this.buffer=new Uint8Array(e):this.buffer=new ArrayBuffer(0)}fromASN(e){if(!(e instanceof An))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=e.valueBlock.valueHex,this}toASN(){return new An({valueHex:this.buffer})}toSchema(e){return new An({name:e})}}const f2={fromASN:t=>t instanceof Nn?null:t.valueBeforeDecodeView,toASN:t=>{if(t===null)return new Nn;const e=nr(t);if(e.result.error)throw new Error(e.result.error);return e.result}},p2={fromASN:t=>t.valueBlock.valueHexView.byteLength>=4?t.valueBlock.toString():t.valueBlock.valueDec,toASN:t=>new Nt({value:+t})},h2={fromASN:t=>t.valueBlock.valueDec,toASN:t=>new So({value:t})},_e={fromASN:t=>t.valueBlock.valueHexView,toASN:t=>new Nt({valueHex:t})},g2={fromASN:t=>t.valueBlock.valueHexView,toASN:t=>new En({valueHex:t})},m2={fromASN:t=>t.valueBlock.toString(),toASN:t=>new Ao({value:t})},_2={fromASN:t=>t.valueBlock.value,toASN:t=>new ko({value:t})},As={fromASN:t=>t.valueBlock.valueHexView,toASN:t=>new An({valueHex:t})},y2={fromASN:t=>new le(t.getValue()),toASN:t=>t.toASN()};function dt(t){return{fromASN:e=>e.valueBlock.value,toASN:e=>new t({value:e})}}const Jh=dt(Jt),w2=dt(Eo),v2=dt(Io),b2=dt(No),$2=dt(Co),x2=dt(zo),k2=dt(Oo),S2=dt(Po),A2=dt(jo),E2=dt(yi),I2=dt(To),N2=dt(Ro),C2={fromASN:t=>t.toDate(),toASN:t=>new wi({valueDate:t})},z2={fromASN:t=>t.toDate(),toASN:t=>new Bo({valueDate:t})},O2={fromASN:()=>null,toASN:()=>new Nn};function Yd(t){switch(t){case b.Any:return f2;case b.BitString:return g2;case b.BmpString:return w2;case b.Boolean:return _2;case b.CharacterString:return N2;case b.Enumerated:return h2;case b.GeneralString:return I2;case b.GeneralizedTime:return z2;case b.GraphicString:return A2;case b.IA5String:return S2;case b.Integer:return p2;case b.Null:return O2;case b.NumericString:return b2;case b.ObjectIdentifier:return m2;case b.OctetString:return As;case b.PrintableString:return $2;case b.TeletexString:return x2;case b.UTCTime:return C2;case b.UniversalString:return v2;case b.Utf8String:return Jh;case b.VideotexString:return k2;case b.VisibleString:return E2;default:return null}}function Lt(t){return typeof t=="function"&&t.prototype?t.prototype.toASN&&t.prototype.fromASN?!0:Lt(t.prototype):!!(t&&typeof t=="object"&&"toASN"in t&&"fromASN"in t)}function Zh(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:Zh(n)}return!1}function P2(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 j2{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:R.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 d;if(typeof o.type=="number"){const u=b[o.type],p=Wh[u];if(!p)throw new Error(`Cannot get ASN1 class by name '${u}'`);d=new p({name:c})}else Lt(o.type)?d=new o.type().toSchema(c):o.optional?this.get(o.type).type===R.Choice?d=new Cn({name:c}):(d=this.create(o.type,!1),d.name=c):d=new Cn({name:c});const l=!!o.optional||o.defaultValue!==void 0;if(o.repeated){d.name="";const u=o.repeated==="set"?Mt:Ut;d=new u({name:"",value:[new Ss({name:c,value:d})]})}if(o.context!==null&&o.context!==void 0)if(o.implicit)if(typeof o.type=="number"||Lt(o.type)){const u=o.repeated?We:_i;i.push(new u({name:c,optional:l,idBlock:{tagClass:3,tagNumber:o.context}}))}else{this.cache(o.type);const u=!!o.repeated;let p=u?d:this.get(o.type,!0).schema;p="valueBlock"in p?p.valueBlock.value:p.value,i.push(new We({name:u?"":c,optional:l,idBlock:{tagClass:3,tagNumber:o.context},value:p}))}else i.push(new We({optional:l,idBlock:{tagClass:3,tagNumber:o.context},value:[d]}));else d.optional=l,i.push(d)}switch(r.type){case R.Sequence:return new Ut({value:i,name:""});case R.Set:return new Mt({value:i,name:""});case R.Choice:return new Xd({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 it=new j2,B=t=>e=>{let n;it.has(e)?n=it.get(e):(n=it.createDefault(e),it.set(e,n)),Object.assign(n,t)},g=t=>(e,n)=>{let r;it.has(e.constructor)?r=it.get(e.constructor):(r=it.createDefault(e.constructor),it.set(e.constructor,r));const i=Object.assign({},t);if(typeof i.type=="number"&&!i.converter){const s=Yd(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 Tu extends Error{constructor(){super(...arguments),this.schemas=[]}}class T2{static parse(e,n){const r=nr(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(Lt(n))return new n().fromASN(e);const i=it.get(n);it.cache(n);let s=i.schema;if(e.constructor===We&&i.type!==R.Choice){s=new We({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:i.schema.valueBlock.value});for(const d in i.items)delete e[d]}const o=xn({},e,s);if(!o.verified)throw new Tu(`Data does not match to ${n.name} ASN1 schema. ${o.result.error}`);const c=new n;if(Zh(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 d=i.itemType;if(typeof d=="number"){const l=Yd(d);if(!l)throw new Error(`Cannot get default converter for array item of ${n.name} ASN1 schema`);return n.from(e.valueBlock.value,u=>l.fromASN(u))}else return n.from(e.valueBlock.value,l=>this.fromASN(l,d))}for(const d in i.items){const l=o.result[d];if(!l)continue;const u=i.items[d],p=u.type;if(typeof p=="number"||Lt(p)){const m=(r=u.converter)!==null&&r!==void 0?r:Lt(p)?new p:null;if(!m)throw new Error("Converter is empty");if(u.repeated)if(u.implicit){const w=u.repeated==="sequence"?Ut:Mt,h=new w;h.valueBlock=l.valueBlock;const _=nr(h.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 v=_.result.valueBlock.value;c[d]=Array.from(v,k=>m.fromASN(k))}else c[d]=Array.from(l,w=>m.fromASN(w));else{let w=l;if(u.implicit){let h;if(Lt(p))h=new p().toSchema("");else{const _=b[p],v=Wh[_];if(!v)throw new Error(`Cannot get '${_}' class from asn1js module`);h=new v}h.valueBlock=w.valueBlock,w=nr(h.toBER(!1)).result}c[d]=m.fromASN(w)}}else if(u.repeated){if(!Array.isArray(l))throw new Error("Cannot get list of items from the ASN.1 parsed value. ASN.1 value should be iterable.");c[d]=Array.from(l,m=>this.fromASN(m,p))}else c[d]=this.fromASN(l,p)}return c}catch(i){throw i instanceof Tu&&i.schemas.push(n.name),i}}}class Qd{static serialize(e){return e instanceof Be?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&typeof e=="object"&&Lt(e))return e.toASN();if(!(e&&typeof e=="object"))throw new TypeError("Parameter 1 should be type of Object.");const n=e.constructor,r=it.get(n);it.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=Yd(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],d=e[o];if(d===void 0||c.defaultValue===d||typeof c.defaultValue=="object"&&typeof d=="object"&&P2(this.serialize(c.defaultValue),this.serialize(d)))continue;const l=Qd.toAsnItem(c,o,n,d);if(typeof c.context=="number")if(c.implicit)if(!c.repeated&&(typeof c.type=="number"||Lt(c.type))){const u={};u.valueHex=l instanceof Nn?l.valueBeforeDecodeView:l.valueBlock.toBER(),i.push(new _i({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},...u}))}else i.push(new We({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:l.valueBlock.value}));else i.push(new We({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:[l]}));else c.repeated?i=i.concat(l):i.push(l)}let s;switch(r.type){case R.Sequence:s=new Ut({value:i});break;case R.Set:s=new Mt({value:i});break;case R.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,l=>o.toASN(l)),d=e.repeated==="sequence"?Ut:Mt;s=new d({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,d=>this.toASN(d)),c=e.repeated==="sequence"?Ut:Mt;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 F{static serialize(e){return Qd.serialize(e)}static parse(e,n){return T2.parse(e,n)}static toString(e){const n=V.isBufferSource(e)?V.toArrayBuffer(e):F.serialize(e),r=nr(n);if(r.offset===-1)throw new Error(`Cannot decode ASN.1 data. ${r.result.error}`);return r.result.toString()}}function f(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 Xh={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]+::?)+",d={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 l(h,_){if(h.indexOf("::")!==h.lastIndexOf("::"))return null;let v=0,k=-1,I=(h.match(d.zoneIndex)||[])[0],O,L;for(I&&(I=I.substring(1),h=h.replace(/%.+$/,""));(k=h.indexOf(":",k+1))>=0;)v++;if(h.substr(0,2)==="::"&&v--,h.substr(-2,2)==="::"&&v--,v>_)return null;for(L=_-v,O=":";L--;)O+="0:";return h=h.replace("::",O),h[0]===":"&&(h=h.slice(1)),h[h.length-1]===":"&&(h=h.slice(0,-1)),_=function(){const Y=h.split(":"),oe=[];for(let ae=0;ae<Y.length;ae++)oe.push(parseInt(Y[ae],16));return oe}(),{parts:_,zoneId:I}}function u(h,_,v,k){if(h.length!==_.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let I=0,O;for(;k>0;){if(O=v-k,O<0&&(O=0),h[I]>>O!==_[I]>>O)return!1;k-=v,I+=1}return!0}function p(h){if(s.test(h))return parseInt(h,16);if(h[0]==="0"&&!isNaN(parseInt(h[1],10))){if(i.test(h))return parseInt(h,8);throw new Error(`ipaddr: cannot parse ${h} as octal`)}return parseInt(h,10)}function m(h,_){for(;h.length<_;)h=`0${h}`;return h}const w={};w.IPv4=function(){function h(_){if(_.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let v,k;for(v=0;v<_.length;v++)if(k=_[v],!(0<=k&&k<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=_}return h.prototype.SpecialRanges={unspecified:[[new h([0,0,0,0]),8]],broadcast:[[new h([255,255,255,255]),32]],multicast:[[new h([224,0,0,0]),4]],linkLocal:[[new h([169,254,0,0]),16]],loopback:[[new h([127,0,0,0]),8]],carrierGradeNat:[[new h([100,64,0,0]),10]],private:[[new h([10,0,0,0]),8],[new h([172,16,0,0]),12],[new h([192,168,0,0]),16]],reserved:[[new h([192,0,0,0]),24],[new h([192,0,2,0]),24],[new h([192,88,99,0]),24],[new h([198,18,0,0]),15],[new h([198,51,100,0]),24],[new h([203,0,113,0]),24],[new h([240,0,0,0]),4]],as112:[[new h([192,175,48,0]),24],[new h([192,31,196,0]),24]],amt:[[new h([192,52,193,0]),24]]},h.prototype.kind=function(){return"ipv4"},h.prototype.match=function(_,v){let k;if(v===void 0&&(k=_,_=k[0],v=k[1]),_.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return u(this.octets,_.octets,8,v)},h.prototype.prefixLengthFromSubnetMask=function(){let _=0,v=!1;const k={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0};let I,O,L;for(I=3;I>=0;I-=1)if(O=this.octets[I],O in k){if(L=k[O],v&&L!==0)return null;L!==8&&(v=!0),_+=L}else return null;return 32-_},h.prototype.range=function(){return w.subnetMatch(this,this.SpecialRanges)},h.prototype.toByteArray=function(){return this.octets.slice(0)},h.prototype.toIPv4MappedAddress=function(){return w.IPv6.parse(`::ffff:${this.toString()}`)},h.prototype.toNormalizedString=function(){return this.toString()},h.prototype.toString=function(){return this.octets.join(".")},h}(),w.IPv4.broadcastAddressFromCIDR=function(h){try{const _=this.parseCIDR(h),v=_[0].toByteArray(),k=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),I=[];let O=0;for(;O<4;)I.push(parseInt(v[O],10)|parseInt(k[O],10)^255),O++;return new this(I)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},w.IPv4.isIPv4=function(h){return this.parser(h)!==null},w.IPv4.isValid=function(h){try{return new this(this.parser(h)),!0}catch{return!1}},w.IPv4.isValidCIDR=function(h){try{return this.parseCIDR(h),!0}catch{return!1}},w.IPv4.isValidFourPartDecimal=function(h){return!!(w.IPv4.isValid(h)&&h.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},w.IPv4.networkAddressFromCIDR=function(h){let _,v,k,I,O;try{for(_=this.parseCIDR(h),k=_[0].toByteArray(),O=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),I=[],v=0;v<4;)I.push(parseInt(k[v],10)&parseInt(O[v],10)),v++;return new this(I)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},w.IPv4.parse=function(h){const _=this.parser(h);if(_===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(_)},w.IPv4.parseCIDR=function(h){let _;if(_=h.match(/^(.+)\/(\d+)$/)){const v=parseInt(_[2]);if(v>=0&&v<=32){const k=[this.parse(_[1]),v];return Object.defineProperty(k,"toString",{value:function(){return this.join("/")}}),k}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},w.IPv4.parser=function(h){let _,v,k;if(_=h.match(r.fourOctet))return function(){const I=_.slice(1,6),O=[];for(let L=0;L<I.length;L++)v=I[L],O.push(p(v));return O}();if(_=h.match(r.longValue)){if(k=p(_[1]),k>4294967295||k<0)throw new Error("ipaddr: address outside defined range");return function(){const I=[];let O;for(O=0;O<=24;O+=8)I.push(k>>O&255);return I}().reverse()}else return(_=h.match(r.twoOctet))?function(){const I=_.slice(1,4),O=[];if(k=p(I[1]),k>16777215||k<0)throw new Error("ipaddr: address outside defined range");return O.push(p(I[0])),O.push(k>>16&255),O.push(k>>8&255),O.push(k&255),O}():(_=h.match(r.threeOctet))?function(){const I=_.slice(1,5),O=[];if(k=p(I[2]),k>65535||k<0)throw new Error("ipaddr: address outside defined range");return O.push(p(I[0])),O.push(p(I[1])),O.push(k>>8&255),O.push(k&255),O}():null},w.IPv4.subnetMaskFromPrefixLength=function(h){if(h=parseInt(h),h<0||h>32)throw new Error("ipaddr: invalid IPv4 prefix length");const _=[0,0,0,0];let v=0;const k=Math.floor(h/8);for(;v<k;)_[v]=255,v++;return k<4&&(_[k]=Math.pow(2,h%8)-1<<8-h%8),new this(_)},w.IPv6=function(){function h(_,v){let k,I;if(_.length===16)for(this.parts=[],k=0;k<=14;k+=2)this.parts.push(_[k]<<8|_[k+1]);else if(_.length===8)this.parts=_;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(k=0;k<this.parts.length;k++)if(I=this.parts[k],!(0<=I&&I<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");v&&(this.zoneId=v)}return h.prototype.SpecialRanges={unspecified:[new h([0,0,0,0,0,0,0,0]),128],linkLocal:[new h([65152,0,0,0,0,0,0,0]),10],multicast:[new h([65280,0,0,0,0,0,0,0]),8],loopback:[new h([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new h([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new h([0,0,0,0,0,65535,0,0]),96],discard:[new h([256,0,0,0,0,0,0,0]),64],rfc6145:[new h([0,0,0,0,65535,0,0,0]),96],rfc6052:[new h([100,65435,0,0,0,0,0,0]),96],"6to4":[new h([8194,0,0,0,0,0,0,0]),16],teredo:[new h([8193,0,0,0,0,0,0,0]),32],benchmarking:[new h([8193,2,0,0,0,0,0,0]),48],amt:[new h([8193,3,0,0,0,0,0,0]),32],as112v6:[[new h([8193,4,274,0,0,0,0,0]),48],[new h([9760,79,32768,0,0,0,0,0]),48]],deprecated:[new h([8193,16,0,0,0,0,0,0]),28],orchid2:[new h([8193,32,0,0,0,0,0,0]),28],droneRemoteIdProtocolEntityTags:[new h([8193,48,0,0,0,0,0,0]),28],reserved:[[new h([8193,0,0,0,0,0,0,0]),23],[new h([8193,3512,0,0,0,0,0,0]),32]]},h.prototype.isIPv4MappedAddress=function(){return this.range()==="ipv4Mapped"},h.prototype.kind=function(){return"ipv6"},h.prototype.match=function(_,v){let k;if(v===void 0&&(k=_,_=k[0],v=k[1]),_.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return u(this.parts,_.parts,16,v)},h.prototype.prefixLengthFromSubnetMask=function(){let _=0,v=!1;const k={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 I,O;for(let L=7;L>=0;L-=1)if(I=this.parts[L],I in k){if(O=k[I],v&&O!==0)return null;O!==16&&(v=!0),_+=O}else return null;return 128-_},h.prototype.range=function(){return w.subnetMatch(this,this.SpecialRanges)},h.prototype.toByteArray=function(){let _;const v=[],k=this.parts;for(let I=0;I<k.length;I++)_=k[I],v.push(_>>8),v.push(_&255);return v},h.prototype.toFixedLengthString=function(){const _=(function(){const k=[];for(let I=0;I<this.parts.length;I++)k.push(m(this.parts[I].toString(16),4));return k}).call(this).join(":");let v="";return this.zoneId&&(v=`%${this.zoneId}`),_+v},h.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");const _=this.parts.slice(-2),v=_[0],k=_[1];return new w.IPv4([v>>8,v&255,k>>8,k&255])},h.prototype.toNormalizedString=function(){const _=(function(){const k=[];for(let I=0;I<this.parts.length;I++)k.push(this.parts[I].toString(16));return k}).call(this).join(":");let v="";return this.zoneId&&(v=`%${this.zoneId}`),_+v},h.prototype.toRFC5952String=function(){const _=/((^|:)(0(:|$)){2,})/g,v=this.toNormalizedString();let k=0,I=-1,O;for(;O=_.exec(v);)O[0].length>I&&(k=O.index,I=O[0].length);return I<0?v:`${v.substring(0,k)}::${v.substring(k+I)}`},h.prototype.toString=function(){return this.toRFC5952String()},h}(),w.IPv6.broadcastAddressFromCIDR=function(h){try{const _=this.parseCIDR(h),v=_[0].toByteArray(),k=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),I=[];let O=0;for(;O<16;)I.push(parseInt(v[O],10)|parseInt(k[O],10)^255),O++;return new this(I)}catch(_){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${_})`)}},w.IPv6.isIPv6=function(h){return this.parser(h)!==null},w.IPv6.isValid=function(h){if(typeof h=="string"&&h.indexOf(":")===-1)return!1;try{const _=this.parser(h);return new this(_.parts,_.zoneId),!0}catch{return!1}},w.IPv6.isValidCIDR=function(h){if(typeof h=="string"&&h.indexOf(":")===-1)return!1;try{return this.parseCIDR(h),!0}catch{return!1}},w.IPv6.networkAddressFromCIDR=function(h){let _,v,k,I,O;try{for(_=this.parseCIDR(h),k=_[0].toByteArray(),O=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),I=[],v=0;v<16;)I.push(parseInt(k[v],10)&parseInt(O[v],10)),v++;return new this(I)}catch(L){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${L})`)}},w.IPv6.parse=function(h){const _=this.parser(h);if(_.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(_.parts,_.zoneId)},w.IPv6.parseCIDR=function(h){let _,v,k;if((v=h.match(/^(.+)\/(\d+)$/))&&(_=parseInt(v[2]),_>=0&&_<=128))return k=[this.parse(v[1]),_],Object.defineProperty(k,"toString",{value:function(){return this.join("/")}}),k;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},w.IPv6.parser=function(h){let _,v,k,I,O,L;if(k=h.match(d.deprecatedTransitional))return this.parser(`::ffff:${k[1]}`);if(d.native.test(h))return l(h,8);if((k=h.match(d.transitional))&&(L=k[6]||"",_=k[1],k[1].endsWith("::")||(_=_.slice(0,-1)),_=l(_+L,6),_.parts)){for(O=[parseInt(k[2]),parseInt(k[3]),parseInt(k[4]),parseInt(k[5])],v=0;v<O.length;v++)if(I=O[v],!(0<=I&&I<=255))return null;return _.parts.push(O[0]<<8|O[1]),_.parts.push(O[2]<<8|O[3]),{parts:_.parts,zoneId:_.zoneId}}return null},w.IPv6.subnetMaskFromPrefixLength=function(h){if(h=parseInt(h),h<0||h>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 v=0;const k=Math.floor(h/8);for(;v<k;)_[v]=255,v++;return k<16&&(_[k]=Math.pow(2,h%8)-1<<8-h%8),new this(_)},w.fromByteArray=function(h){const _=h.length;if(_===4)return new w.IPv4(h);if(_===16)return new w.IPv6(h);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},w.isValid=function(h){return w.IPv6.isValid(h)||w.IPv4.isValid(h)},w.isValidCIDR=function(h){return w.IPv6.isValidCIDR(h)||w.IPv4.isValidCIDR(h)},w.parse=function(h){if(w.IPv6.isValid(h))return w.IPv6.parse(h);if(w.IPv4.isValid(h))return w.IPv4.parse(h);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},w.parseCIDR=function(h){try{return w.IPv6.parseCIDR(h)}catch{try{return w.IPv4.parseCIDR(h)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},w.process=function(h){const _=this.parse(h);return _.kind()==="ipv6"&&_.isIPv4MappedAddress()?_.toIPv4Address():_},w.subnetMatch=function(h,_,v){let k,I,O,L;v==null&&(v="unicast");for(I in _)if(Object.prototype.hasOwnProperty.call(_,I)){for(O=_[I],O[0]&&!(O[0]instanceof Array)&&(O=[O]),k=0;k<O.length;k++)if(L=O[k],h.kind()===L[0].kind()&&h.match.apply(h,L))return I}return v},t.exports?t.exports=w:e.ipaddr=w})(bs)})(Xh);var Ru=Xh.exports;class Bu{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 Ru.fromByteArray(Array.from(n)).toString()}return this.decodeIP(J.ToHex(e))}static fromString(e){const n=Ru.parse(e);return new Uint8Array(n.toByteArray()).buffer}}var ec,tc,nc;let Le=class{constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};f([g({type:b.TeletexString})],Le.prototype,"teletexString",void 0);f([g({type:b.PrintableString})],Le.prototype,"printableString",void 0);f([g({type:b.UniversalString})],Le.prototype,"universalString",void 0);f([g({type:b.Utf8String})],Le.prototype,"utf8String",void 0);f([g({type:b.BmpString})],Le.prototype,"bmpString",void 0);Le=f([B({type:R.Choice})],Le);let cr=class extends Le{constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?J.ToHex(this.anyValue):super.toString())}};f([g({type:b.IA5String})],cr.prototype,"ia5String",void 0);f([g({type:b.Any})],cr.prototype,"anyValue",void 0);cr=f([B({type:R.Choice})],cr);class Uo{constructor(e={}){this.type="",this.value=new cr,Object.assign(this,e)}}f([g({type:b.ObjectIdentifier})],Uo.prototype,"type",void 0);f([g({type:cr})],Uo.prototype,"value",void 0);let dr=ec=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,ec.prototype)}};dr=ec=f([B({type:R.Set,itemType:Uo})],dr);let rc=tc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,tc.prototype)}};rc=tc=f([B({type:R.Sequence,itemType:dr})],rc);let $e=nc=class extends rc{constructor(e){super(e),Object.setPrototypeOf(this,nc.prototype)}};$e=nc=f([B({type:R.Sequence})],$e);const R2={fromASN:t=>Bu.toString(As.fromASN(t)),toASN:t=>As.toASN(Bu.fromString(t))};class Xr{constructor(e={}){this.typeId="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:b.ObjectIdentifier})],Xr.prototype,"typeId",void 0);f([g({type:b.Any,context:0})],Xr.prototype,"value",void 0);class el{constructor(e={}){this.partyName=new Le,Object.assign(this,e)}}f([g({type:Le,optional:!0,context:0,implicit:!0})],el.prototype,"nameAssigner",void 0);f([g({type:Le,context:1,implicit:!0})],el.prototype,"partyName",void 0);let ie=class{constructor(e={}){Object.assign(this,e)}};f([g({type:Xr,context:0,implicit:!0})],ie.prototype,"otherName",void 0);f([g({type:b.IA5String,context:1,implicit:!0})],ie.prototype,"rfc822Name",void 0);f([g({type:b.IA5String,context:2,implicit:!0})],ie.prototype,"dNSName",void 0);f([g({type:b.Any,context:3,implicit:!0})],ie.prototype,"x400Address",void 0);f([g({type:$e,context:4,implicit:!1})],ie.prototype,"directoryName",void 0);f([g({type:el,context:5})],ie.prototype,"ediPartyName",void 0);f([g({type:b.IA5String,context:6,implicit:!0})],ie.prototype,"uniformResourceIdentifier",void 0);f([g({type:b.OctetString,context:7,implicit:!0,converter:R2})],ie.prototype,"iPAddress",void 0);f([g({type:b.ObjectIdentifier,context:8,implicit:!0})],ie.prototype,"registeredID",void 0);ie=f([B({type:R.Choice})],ie);const tl="1.3.6.1.5.5.7",B2=`${tl}.1`,xr=`${tl}.3`,Mo=`${tl}.48`,Lu=`${Mo}.1`,Uu=`${Mo}.2`,Mu=`${Mo}.3`,Fu=`${Mo}.5`,hn="2.5.29";var ic;const sc=`${B2}.1`;class vi{constructor(e={}){this.accessMethod="",this.accessLocation=new ie,Object.assign(this,e)}}f([g({type:b.ObjectIdentifier})],vi.prototype,"accessMethod",void 0);f([g({type:ie})],vi.prototype,"accessLocation",void 0);let er=ic=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,ic.prototype)}};er=ic=f([B({type:R.Sequence,itemType:vi})],er);const oc=`${hn}.35`;class nl extends le{}class kn{constructor(e={}){e&&Object.assign(this,e)}}f([g({type:nl,context:0,optional:!0,implicit:!0})],kn.prototype,"keyIdentifier",void 0);f([g({type:ie,context:1,optional:!0,implicit:!0,repeated:"sequence"})],kn.prototype,"authorityCertIssuer",void 0);f([g({type:b.Integer,context:2,optional:!0,implicit:!0,converter:_e})],kn.prototype,"authorityCertSerialNumber",void 0);const Yh=`${hn}.19`;class Es{constructor(e={}){this.cA=!1,Object.assign(this,e)}}f([g({type:b.Boolean,defaultValue:!1})],Es.prototype,"cA",void 0);f([g({type:b.Integer,optional:!0})],Es.prototype,"pathLenConstraint",void 0);var ac;let De=ac=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,ac.prototype)}};De=ac=f([B({type:R.Sequence,itemType:ie})],De);var cc;let Vu=cc=class extends De{constructor(e){super(e),Object.setPrototypeOf(this,cc.prototype)}};Vu=cc=f([B({type:R.Sequence})],Vu);var dc;const Qh=`${hn}.32`;let Vt=class{constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};f([g({type:b.IA5String})],Vt.prototype,"ia5String",void 0);f([g({type:b.VisibleString})],Vt.prototype,"visibleString",void 0);f([g({type:b.BmpString})],Vt.prototype,"bmpString",void 0);f([g({type:b.Utf8String})],Vt.prototype,"utf8String",void 0);Vt=f([B({type:R.Choice})],Vt);class rl{constructor(e={}){this.organization=new Vt,this.noticeNumbers=[],Object.assign(this,e)}}f([g({type:Vt})],rl.prototype,"organization",void 0);f([g({type:b.Integer,repeated:"sequence"})],rl.prototype,"noticeNumbers",void 0);class il{constructor(e={}){Object.assign(this,e)}}f([g({type:rl,optional:!0})],il.prototype,"noticeRef",void 0);f([g({type:Vt,optional:!0})],il.prototype,"explicitText",void 0);let Is=class{constructor(e={}){Object.assign(this,e)}};f([g({type:b.IA5String})],Is.prototype,"cPSuri",void 0);f([g({type:il})],Is.prototype,"userNotice",void 0);Is=f([B({type:R.Choice})],Is);class sl{constructor(e={}){this.policyQualifierId="",this.qualifier=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:b.ObjectIdentifier})],sl.prototype,"policyQualifierId",void 0);f([g({type:b.Any})],sl.prototype,"qualifier",void 0);class Fo{constructor(e={}){this.policyIdentifier="",Object.assign(this,e)}}f([g({type:b.ObjectIdentifier})],Fo.prototype,"policyIdentifier",void 0);f([g({type:sl,repeated:"sequence",optional:!0})],Fo.prototype,"policyQualifiers",void 0);let Ns=dc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,dc.prototype)}};Ns=dc=f([B({type:R.Sequence,itemType:Fo})],Ns);let Cs=class{constructor(e=0){this.value=e}};f([g({type:b.Integer})],Cs.prototype,"value",void 0);Cs=f([B({type:R.Choice})],Cs);let Du=class extends Cs{};Du=f([B({type:R.Choice})],Du);var lc;const uc=`${hn}.31`;var pt;(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"})(pt||(pt={}));class eg extends Lo{toJSON(){const e=[],n=this.toNumber();return n&pt.aACompromise&&e.push("aACompromise"),n&pt.affiliationChanged&&e.push("affiliationChanged"),n&pt.cACompromise&&e.push("cACompromise"),n&pt.certificateHold&&e.push("certificateHold"),n&pt.cessationOfOperation&&e.push("cessationOfOperation"),n&pt.keyCompromise&&e.push("keyCompromise"),n&pt.privilegeWithdrawn&&e.push("privilegeWithdrawn"),n&pt.superseded&&e.push("superseded"),n&pt.unused&&e.push("unused"),e}toString(){return`[${this.toJSON().join(", ")}]`}}let zn=class{constructor(e={}){Object.assign(this,e)}};f([g({type:ie,context:0,repeated:"sequence",implicit:!0})],zn.prototype,"fullName",void 0);f([g({type:dr,context:1,implicit:!0})],zn.prototype,"nameRelativeToCRLIssuer",void 0);zn=f([B({type:R.Choice})],zn);class kr{constructor(e={}){Object.assign(this,e)}}f([g({type:zn,context:0,optional:!0})],kr.prototype,"distributionPoint",void 0);f([g({type:eg,context:1,optional:!0,implicit:!0})],kr.prototype,"reasons",void 0);f([g({type:ie,context:2,optional:!0,repeated:"sequence",implicit:!0})],kr.prototype,"cRLIssuer",void 0);let rr=lc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,lc.prototype)}};rr=lc=f([B({type:R.Sequence,itemType:kr})],rr);var fc;let qu=fc=class extends rr{constructor(e){super(e),Object.setPrototypeOf(this,fc.prototype)}};qu=fc=f([B({type:R.Sequence,itemType:kr})],qu);class Me{constructor(e={}){this.onlyContainsUserCerts=Me.ONLY,this.onlyContainsCACerts=Me.ONLY,this.indirectCRL=Me.ONLY,this.onlyContainsAttributeCerts=Me.ONLY,Object.assign(this,e)}}Me.ONLY=!1;f([g({type:zn,context:0,optional:!0})],Me.prototype,"distributionPoint",void 0);f([g({type:b.Boolean,context:1,defaultValue:Me.ONLY,implicit:!0})],Me.prototype,"onlyContainsUserCerts",void 0);f([g({type:b.Boolean,context:2,defaultValue:Me.ONLY,implicit:!0})],Me.prototype,"onlyContainsCACerts",void 0);f([g({type:eg,context:3,optional:!0,implicit:!0})],Me.prototype,"onlySomeReasons",void 0);f([g({type:b.Boolean,context:4,defaultValue:Me.ONLY,implicit:!0})],Me.prototype,"indirectCRL",void 0);f([g({type:b.Boolean,context:5,defaultValue:Me.ONLY,implicit:!0})],Me.prototype,"onlyContainsAttributeCerts",void 0);var Vr;(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"})(Vr||(Vr={}));let pc=class{constructor(e=Vr.unspecified){this.reason=Vr.unspecified,this.reason=e}toJSON(){return Vr[this.reason]}toString(){return this.toJSON()}};f([g({type:b.Enumerated})],pc.prototype,"reason",void 0);pc=f([B({type:R.Choice})],pc);var hc;const tg=`${hn}.37`;let zs=hc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,hc.prototype)}};zs=hc=f([B({type:R.Sequence,itemType:b.ObjectIdentifier})],zs);const L2=`${xr}.1`,U2=`${xr}.2`,M2=`${xr}.3`,F2=`${xr}.4`,V2=`${xr}.8`,D2=`${xr}.9`;let gc=class{constructor(e=new ArrayBuffer(0)){this.value=e}};f([g({type:b.Integer,converter:_e})],gc.prototype,"value",void 0);gc=f([B({type:R.Choice})],gc);let mc=class{constructor(e){this.value=new Date,e&&(this.value=e)}};f([g({type:b.GeneralizedTime})],mc.prototype,"value",void 0);mc=f([B({type:R.Choice})],mc);var _c;let Hu=_c=class extends De{constructor(e){super(e),Object.setPrototypeOf(this,_c.prototype)}};Hu=_c=f([B({type:R.Sequence})],Hu);const ng=`${hn}.15`;var ht;(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"})(ht||(ht={}));class $a extends Lo{toJSON(){const e=this.toNumber(),n=[];return e&ht.cRLSign&&n.push("crlSign"),e&ht.dataEncipherment&&n.push("dataEncipherment"),e&ht.decipherOnly&&n.push("decipherOnly"),e&ht.digitalSignature&&n.push("digitalSignature"),e&ht.encipherOnly&&n.push("encipherOnly"),e&ht.keyAgreement&&n.push("keyAgreement"),e&ht.keyCertSign&&n.push("keyCertSign"),e&ht.keyEncipherment&&n.push("keyEncipherment"),e&ht.nonRepudiation&&n.push("nonRepudiation"),n}toString(){return`[${this.toJSON().join(", ")}]`}}var yc;class Vo{constructor(e={}){this.base=new ie,this.minimum=0,Object.assign(this,e)}}f([g({type:ie})],Vo.prototype,"base",void 0);f([g({type:b.Integer,context:0,defaultValue:0,implicit:!0})],Vo.prototype,"minimum",void 0);f([g({type:b.Integer,context:1,optional:!0,implicit:!0})],Vo.prototype,"maximum",void 0);let Os=yc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,yc.prototype)}};Os=yc=f([B({type:R.Sequence,itemType:Vo})],Os);class rg{constructor(e={}){Object.assign(this,e)}}f([g({type:Os,context:0,optional:!0,implicit:!0})],rg.prototype,"permittedSubtrees",void 0);f([g({type:Os,context:1,optional:!0,implicit:!0})],rg.prototype,"excludedSubtrees",void 0);class ig{constructor(e={}){Object.assign(this,e)}}f([g({type:b.Integer,context:0,implicit:!0,optional:!0,converter:_e})],ig.prototype,"requireExplicitPolicy",void 0);f([g({type:b.Integer,context:1,implicit:!0,optional:!0,converter:_e})],ig.prototype,"inhibitPolicyMapping",void 0);var wc;class ol{constructor(e={}){this.issuerDomainPolicy="",this.subjectDomainPolicy="",Object.assign(this,e)}}f([g({type:b.ObjectIdentifier})],ol.prototype,"issuerDomainPolicy",void 0);f([g({type:b.ObjectIdentifier})],ol.prototype,"subjectDomainPolicy",void 0);let Ku=wc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,wc.prototype)}};Ku=wc=f([B({type:R.Sequence,itemType:ol})],Ku);var vc;const sg=`${hn}.17`;let bc=vc=class extends De{constructor(e){super(e),Object.setPrototypeOf(this,vc.prototype)}};bc=vc=f([B({type:R.Sequence})],bc);let Dt=class{constructor(e={}){this.type="",this.values=[],Object.assign(this,e)}};f([g({type:b.ObjectIdentifier})],Dt.prototype,"type",void 0);f([g({type:b.Any,repeated:"set"})],Dt.prototype,"values",void 0);var $c;let Gu=$c=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,$c.prototype)}};Gu=$c=f([B({type:R.Sequence,itemType:Dt})],Gu);const og=`${hn}.14`;class rn extends nl{}class ag{constructor(e={}){Object.assign(this,e)}}f([g({type:b.GeneralizedTime,context:0,implicit:!0,optional:!0})],ag.prototype,"notBefore",void 0);f([g({type:b.GeneralizedTime,context:1,implicit:!0,optional:!0})],ag.prototype,"notAfter",void 0);var Dr;(function(t){t[t.keyUpdateAllowed=1]="keyUpdateAllowed",t[t.newExtensions=2]="newExtensions",t[t.pKIXCertificate=4]="pKIXCertificate"})(Dr||(Dr={}));class cg extends Lo{toJSON(){const e=[],n=this.toNumber();return n&Dr.pKIXCertificate&&e.push("pKIXCertificate"),n&Dr.newExtensions&&e.push("newExtensions"),n&Dr.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return`[${this.toJSON().join(", ")}]`}}class dg{constructor(e={}){this.entrustVers="",this.entrustInfoFlags=new cg,Object.assign(this,e)}}f([g({type:b.GeneralString})],dg.prototype,"entrustVers",void 0);f([g({type:cg})],dg.prototype,"entrustInfoFlags",void 0);var xc;let Wu=xc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,xc.prototype)}};Wu=xc=f([B({type:R.Sequence,itemType:vi})],Wu);class H{constructor(e={}){this.algorithm="",Object.assign(this,e)}isEqual(e){return e instanceof H&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&J0(e.parameters,this.parameters)||e.parameters===this.parameters)}}f([g({type:b.ObjectIdentifier})],H.prototype,"algorithm",void 0);f([g({type:b.Any,optional:!0})],H.prototype,"parameters",void 0);class gt{constructor(e={}){this.algorithm=new H,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:H})],gt.prototype,"algorithm",void 0);f([g({type:b.BitString})],gt.prototype,"subjectPublicKey",void 0);let Re=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}};f([g({type:b.UTCTime})],Re.prototype,"utcTime",void 0);f([g({type:b.GeneralizedTime})],Re.prototype,"generalTime",void 0);Re=f([B({type:R.Choice})],Re);class bi{constructor(e){this.notBefore=new Re(new Date),this.notAfter=new Re(new Date),e&&(this.notBefore=new Re(e.notBefore),this.notAfter=new Re(e.notAfter))}}f([g({type:Re})],bi.prototype,"notBefore",void 0);f([g({type:Re})],bi.prototype,"notAfter",void 0);var kc;let at=class lg{constructor(e={}){this.extnID="",this.critical=lg.CRITICAL,this.extnValue=new le,Object.assign(this,e)}};at.CRITICAL=!1;f([g({type:b.ObjectIdentifier})],at.prototype,"extnID",void 0);f([g({type:b.Boolean,defaultValue:at.CRITICAL})],at.prototype,"critical",void 0);f([g({type:le})],at.prototype,"extnValue",void 0);let an=kc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,kc.prototype)}};an=kc=f([B({type:R.Sequence,itemType:at})],an);var On;(function(t){t[t.v1=0]="v1",t[t.v2=1]="v2",t[t.v3=2]="v3"})(On||(On={}));class rt{constructor(e={}){this.version=On.v1,this.serialNumber=new ArrayBuffer(0),this.signature=new H,this.issuer=new $e,this.validity=new bi,this.subject=new $e,this.subjectPublicKeyInfo=new gt,Object.assign(this,e)}}f([g({type:b.Integer,context:0,defaultValue:On.v1})],rt.prototype,"version",void 0);f([g({type:b.Integer,converter:_e})],rt.prototype,"serialNumber",void 0);f([g({type:H})],rt.prototype,"signature",void 0);f([g({type:$e})],rt.prototype,"issuer",void 0);f([g({type:bi})],rt.prototype,"validity",void 0);f([g({type:$e})],rt.prototype,"subject",void 0);f([g({type:gt})],rt.prototype,"subjectPublicKeyInfo",void 0);f([g({type:b.BitString,context:1,implicit:!0,optional:!0})],rt.prototype,"issuerUniqueID",void 0);f([g({type:b.BitString,context:2,implicit:!0,optional:!0})],rt.prototype,"subjectUniqueID",void 0);f([g({type:an,context:3,optional:!0})],rt.prototype,"extensions",void 0);class Pn{constructor(e={}){this.tbsCertificate=new rt,this.signatureAlgorithm=new H,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:rt})],Pn.prototype,"tbsCertificate",void 0);f([g({type:H})],Pn.prototype,"signatureAlgorithm",void 0);f([g({type:b.BitString})],Pn.prototype,"signatureValue",void 0);class Do{constructor(e={}){this.userCertificate=new ArrayBuffer(0),this.revocationDate=new Re,Object.assign(this,e)}}f([g({type:b.Integer,converter:_e})],Do.prototype,"userCertificate",void 0);f([g({type:Re})],Do.prototype,"revocationDate",void 0);f([g({type:at,optional:!0,repeated:"sequence"})],Do.prototype,"crlEntryExtensions",void 0);class Zt{constructor(e={}){this.signature=new H,this.issuer=new $e,this.thisUpdate=new Re,Object.assign(this,e)}}f([g({type:b.Integer,optional:!0})],Zt.prototype,"version",void 0);f([g({type:H})],Zt.prototype,"signature",void 0);f([g({type:$e})],Zt.prototype,"issuer",void 0);f([g({type:Re})],Zt.prototype,"thisUpdate",void 0);f([g({type:Re,optional:!0})],Zt.prototype,"nextUpdate",void 0);f([g({type:Do,repeated:"sequence",optional:!0})],Zt.prototype,"revokedCertificates",void 0);f([g({type:at,optional:!0,context:0,repeated:"sequence"})],Zt.prototype,"crlExtensions",void 0);class al{constructor(e={}){this.tbsCertList=new Zt,this.signatureAlgorithm=new H,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:Zt})],al.prototype,"tbsCertList",void 0);f([g({type:H})],al.prototype,"signatureAlgorithm",void 0);f([g({type:b.BitString})],al.prototype,"signature",void 0);class Sr{constructor(e={}){this.issuer=new $e,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:$e})],Sr.prototype,"issuer",void 0);f([g({type:b.Integer,converter:_e})],Sr.prototype,"serialNumber",void 0);let lr=class{constructor(e={}){Object.assign(this,e)}};f([g({type:rn,context:0,implicit:!0})],lr.prototype,"subjectKeyIdentifier",void 0);f([g({type:Sr})],lr.prototype,"issuerAndSerialNumber",void 0);lr=f([B({type:R.Choice})],lr);var qt;(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"})(qt||(qt={}));let Yr=class extends H{};Yr=f([B({type:R.Sequence})],Yr);let Ps=class extends H{};Ps=f([B({type:R.Sequence})],Ps);let zt=class extends H{};zt=f([B({type:R.Sequence})],zt);let js=class extends H{};js=f([B({type:R.Sequence})],js);let Ju=class extends H{};Ju=f([B({type:R.Sequence})],Ju);let Sc=class extends H{};Sc=f([B({type:R.Sequence})],Sc);let Ar=class{constructor(e={}){this.attrType="",this.attrValues=[],Object.assign(this,e)}};f([g({type:b.ObjectIdentifier})],Ar.prototype,"attrType",void 0);f([g({type:b.Any,repeated:"set"})],Ar.prototype,"attrValues",void 0);var Ac;class jt{constructor(e={}){this.version=qt.v0,this.sid=new lr,this.digestAlgorithm=new Yr,this.signatureAlgorithm=new Ps,this.signature=new le,Object.assign(this,e)}}f([g({type:b.Integer})],jt.prototype,"version",void 0);f([g({type:lr})],jt.prototype,"sid",void 0);f([g({type:Yr})],jt.prototype,"digestAlgorithm",void 0);f([g({type:Ar,repeated:"set",context:0,implicit:!0,optional:!0})],jt.prototype,"signedAttrs",void 0);f([g({type:Ps})],jt.prototype,"signatureAlgorithm",void 0);f([g({type:le})],jt.prototype,"signature",void 0);f([g({type:Ar,repeated:"set",context:1,implicit:!0,optional:!0})],jt.prototype,"unsignedAttrs",void 0);let Ts=Ac=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Ac.prototype)}};Ts=Ac=f([B({type:R.Set,itemType:jt})],Ts);let Zu=class extends Re{};Zu=f([B({type:R.Choice})],Zu);let Xu=class extends jt{};Xu=f([B({type:R.Sequence})],Xu);class cl{constructor(e={}){this.acIssuer=new ie,this.acSerial=0,this.attrs=[],Object.assign(this,e)}}f([g({type:ie})],cl.prototype,"acIssuer",void 0);f([g({type:b.Integer})],cl.prototype,"acSerial",void 0);f([g({type:Dt,repeated:"sequence"})],cl.prototype,"attrs",void 0);var Ec;let Rs=Ec=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Ec.prototype)}};Rs=Ec=f([B({type:R.Sequence,itemType:b.ObjectIdentifier})],Rs);class qo{constructor(e={}){this.permitUnSpecified=!0,Object.assign(this,e)}}f([g({type:b.Integer,optional:!0})],qo.prototype,"pathLenConstraint",void 0);f([g({type:Rs,implicit:!0,context:0,optional:!0})],qo.prototype,"permittedAttrs",void 0);f([g({type:Rs,implicit:!0,context:1,optional:!0})],qo.prototype,"excludedAttrs",void 0);f([g({type:b.Boolean,defaultValue:!0})],qo.prototype,"permitUnSpecified",void 0);class Vn{constructor(e={}){this.issuer=new De,this.serial=new ArrayBuffer(0),this.issuerUID=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:De})],Vn.prototype,"issuer",void 0);f([g({type:b.Integer,converter:_e})],Vn.prototype,"serial",void 0);f([g({type:b.BitString,optional:!0})],Vn.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 Dn{constructor(e={}){this.digestedObjectType=Ic.publicKey,this.digestAlgorithm=new H,this.objectDigest=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:b.Enumerated})],Dn.prototype,"digestedObjectType",void 0);f([g({type:b.ObjectIdentifier,optional:!0})],Dn.prototype,"otherObjectTypeID",void 0);f([g({type:H})],Dn.prototype,"digestAlgorithm",void 0);f([g({type:b.BitString})],Dn.prototype,"objectDigest",void 0);class Ho{constructor(e={}){Object.assign(this,e)}}f([g({type:De,optional:!0})],Ho.prototype,"issuerName",void 0);f([g({type:Vn,context:0,implicit:!0,optional:!0})],Ho.prototype,"baseCertificateID",void 0);f([g({type:Dn,context:1,implicit:!0,optional:!0})],Ho.prototype,"objectDigestInfo",void 0);let ur=class{constructor(e={}){Object.assign(this,e)}};f([g({type:ie,repeated:"sequence"})],ur.prototype,"v1Form",void 0);f([g({type:Ho,context:0,implicit:!0})],ur.prototype,"v2Form",void 0);ur=f([B({type:R.Choice})],ur);class Ko{constructor(e={}){this.notBeforeTime=new Date,this.notAfterTime=new Date,Object.assign(this,e)}}f([g({type:b.GeneralizedTime})],Ko.prototype,"notBeforeTime",void 0);f([g({type:b.GeneralizedTime})],Ko.prototype,"notAfterTime",void 0);class $i{constructor(e={}){Object.assign(this,e)}}f([g({type:Vn,implicit:!0,context:0,optional:!0})],$i.prototype,"baseCertificateID",void 0);f([g({type:De,implicit:!0,context:1,optional:!0})],$i.prototype,"entityName",void 0);f([g({type:Dn,implicit:!0,context:2,optional:!0})],$i.prototype,"objectDigestInfo",void 0);var Nc;(function(t){t[t.v2=1]="v2"})(Nc||(Nc={}));class $t{constructor(e={}){this.version=Nc.v2,this.holder=new $i,this.issuer=new ur,this.signature=new H,this.serialNumber=new ArrayBuffer(0),this.attrCertValidityPeriod=new Ko,this.attributes=[],Object.assign(this,e)}}f([g({type:b.Integer})],$t.prototype,"version",void 0);f([g({type:$i})],$t.prototype,"holder",void 0);f([g({type:ur})],$t.prototype,"issuer",void 0);f([g({type:H})],$t.prototype,"signature",void 0);f([g({type:b.Integer,converter:_e})],$t.prototype,"serialNumber",void 0);f([g({type:Ko})],$t.prototype,"attrCertValidityPeriod",void 0);f([g({type:Dt,repeated:"sequence"})],$t.prototype,"attributes",void 0);f([g({type:b.BitString,optional:!0})],$t.prototype,"issuerUniqueID",void 0);f([g({type:an,optional:!0})],$t.prototype,"extensions",void 0);class Go{constructor(e={}){this.acinfo=new $t,this.signatureAlgorithm=new H,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:$t})],Go.prototype,"acinfo",void 0);f([g({type:H})],Go.prototype,"signatureAlgorithm",void 0);f([g({type:b.BitString})],Go.prototype,"signatureValue",void 0);var Bs;(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"})(Bs||(Bs={}));class Cc extends Lo{}class dl{constructor(e={}){this.type="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:b.ObjectIdentifier,implicit:!0,context:0})],dl.prototype,"type",void 0);f([g({type:b.Any,implicit:!0,context:1})],dl.prototype,"value",void 0);class ll{constructor(e={}){this.policyId="",this.classList=new Cc(Bs.unclassified),Object.assign(this,e)}}f([g({type:b.ObjectIdentifier})],ll.prototype,"policyId",void 0);f([g({type:Cc,defaultValue:new Cc(Bs.unclassified)})],ll.prototype,"classList",void 0);f([g({type:dl,repeated:"set"})],ll.prototype,"securityCategories",void 0);class Wo{constructor(e={}){Object.assign(this,e)}}f([g({type:le})],Wo.prototype,"cotets",void 0);f([g({type:b.ObjectIdentifier})],Wo.prototype,"oid",void 0);f([g({type:b.Utf8String})],Wo.prototype,"string",void 0);class ug{constructor(e={}){this.values=[],Object.assign(this,e)}}f([g({type:De,implicit:!0,context:0,optional:!0})],ug.prototype,"policyAuthority",void 0);f([g({type:Wo,repeated:"sequence"})],ug.prototype,"values",void 0);var zc;class Jo{constructor(e={}){this.targetCertificate=new Vn,Object.assign(this,e)}}f([g({type:Vn})],Jo.prototype,"targetCertificate",void 0);f([g({type:ie,optional:!0})],Jo.prototype,"targetName",void 0);f([g({type:Dn,optional:!0})],Jo.prototype,"certDigestInfo",void 0);let fr=class{constructor(e={}){Object.assign(this,e)}};f([g({type:ie,context:0,implicit:!0})],fr.prototype,"targetName",void 0);f([g({type:ie,context:1,implicit:!0})],fr.prototype,"targetGroup",void 0);f([g({type:Jo,context:2,implicit:!0})],fr.prototype,"targetCert",void 0);fr=f([B({type:R.Choice})],fr);let Oc=zc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,zc.prototype)}};Oc=zc=f([B({type:R.Sequence,itemType:fr})],Oc);var Pc;let Yu=Pc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Pc.prototype)}};Yu=Pc=f([B({type:R.Sequence,itemType:Oc})],Yu);class fg{constructor(e={}){Object.assign(this,e)}}f([g({type:De,implicit:!0,context:0,optional:!0})],fg.prototype,"roleAuthority",void 0);f([g({type:ie,implicit:!0,context:1})],fg.prototype,"roleName",void 0);class ul{constructor(e={}){this.service=new ie,this.ident=new ie,Object.assign(this,e)}}f([g({type:ie})],ul.prototype,"service",void 0);f([g({type:ie})],ul.prototype,"ident",void 0);f([g({type:le,optional:!0})],ul.prototype,"authInfo",void 0);var jc;class fl{constructor(e={}){this.otherCertFormat="",this.otherCert=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:b.ObjectIdentifier})],fl.prototype,"otherCertFormat",void 0);f([g({type:b.Any})],fl.prototype,"otherCert",void 0);let pr=class{constructor(e={}){Object.assign(this,e)}};f([g({type:Pn})],pr.prototype,"certificate",void 0);f([g({type:Go,context:2,implicit:!0})],pr.prototype,"v2AttrCert",void 0);f([g({type:fl,context:3,implicit:!0})],pr.prototype,"other",void 0);pr=f([B({type:R.Choice})],pr);let Ls=jc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,jc.prototype)}};Ls=jc=f([B({type:R.Set,itemType:pr})],Ls);class Er{constructor(e={}){this.contentType="",this.content=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:b.ObjectIdentifier})],Er.prototype,"contentType",void 0);f([g({type:b.Any,context:0})],Er.prototype,"content",void 0);let Qr=class{constructor(e={}){Object.assign(this,e)}};f([g({type:le})],Qr.prototype,"single",void 0);f([g({type:b.Any})],Qr.prototype,"any",void 0);Qr=f([B({type:R.Choice})],Qr);class Zo{constructor(e={}){this.eContentType="",Object.assign(this,e)}}f([g({type:b.ObjectIdentifier})],Zo.prototype,"eContentType",void 0);f([g({type:Qr,context:0,optional:!0})],Zo.prototype,"eContent",void 0);let ei=class{constructor(e={}){Object.assign(this,e)}};f([g({type:le,context:0,implicit:!0,optional:!0})],ei.prototype,"value",void 0);f([g({type:le,converter:y2,context:0,implicit:!0,optional:!0,repeated:"sequence"})],ei.prototype,"constructedValue",void 0);ei=f([B({type:R.Choice})],ei);class xi{constructor(e={}){this.contentType="",this.contentEncryptionAlgorithm=new js,Object.assign(this,e)}}f([g({type:b.ObjectIdentifier})],xi.prototype,"contentType",void 0);f([g({type:js})],xi.prototype,"contentEncryptionAlgorithm",void 0);f([g({type:ei,optional:!0})],xi.prototype,"encryptedContent",void 0);class Xo{constructor(e={}){this.keyAttrId="",Object.assign(this,e)}}f([g({type:b.ObjectIdentifier})],Xo.prototype,"keyAttrId",void 0);f([g({type:b.Any,optional:!0})],Xo.prototype,"keyAttr",void 0);var Tc;class Yo{constructor(e={}){this.subjectKeyIdentifier=new rn,Object.assign(this,e)}}f([g({type:rn})],Yo.prototype,"subjectKeyIdentifier",void 0);f([g({type:b.GeneralizedTime,optional:!0})],Yo.prototype,"date",void 0);f([g({type:Xo,optional:!0})],Yo.prototype,"other",void 0);let hr=class{constructor(e={}){Object.assign(this,e)}};f([g({type:Yo,context:0,implicit:!0,optional:!0})],hr.prototype,"rKeyId",void 0);f([g({type:Sr,optional:!0})],hr.prototype,"issuerAndSerialNumber",void 0);hr=f([B({type:R.Choice})],hr);class pl{constructor(e={}){this.rid=new hr,this.encryptedKey=new le,Object.assign(this,e)}}f([g({type:hr})],pl.prototype,"rid",void 0);f([g({type:le})],pl.prototype,"encryptedKey",void 0);let Us=Tc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Tc.prototype)}};Us=Tc=f([B({type:R.Sequence,itemType:pl})],Us);class hl{constructor(e={}){this.algorithm=new H,this.publicKey=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:H})],hl.prototype,"algorithm",void 0);f([g({type:b.BitString})],hl.prototype,"publicKey",void 0);let jn=class{constructor(e={}){Object.assign(this,e)}};f([g({type:rn,context:0,implicit:!0,optional:!0})],jn.prototype,"subjectKeyIdentifier",void 0);f([g({type:hl,context:1,implicit:!0,optional:!0})],jn.prototype,"originatorKey",void 0);f([g({type:Sr,optional:!0})],jn.prototype,"issuerAndSerialNumber",void 0);jn=f([B({type:R.Choice})],jn);class Ir{constructor(e={}){this.version=qt.v3,this.originator=new jn,this.keyEncryptionAlgorithm=new zt,this.recipientEncryptedKeys=new Us,Object.assign(this,e)}}f([g({type:b.Integer})],Ir.prototype,"version",void 0);f([g({type:jn,context:0})],Ir.prototype,"originator",void 0);f([g({type:le,context:1,optional:!0})],Ir.prototype,"ukm",void 0);f([g({type:zt})],Ir.prototype,"keyEncryptionAlgorithm",void 0);f([g({type:Us})],Ir.prototype,"recipientEncryptedKeys",void 0);let gr=class{constructor(e={}){Object.assign(this,e)}};f([g({type:rn,context:0,implicit:!0})],gr.prototype,"subjectKeyIdentifier",void 0);f([g({type:Sr})],gr.prototype,"issuerAndSerialNumber",void 0);gr=f([B({type:R.Choice})],gr);class ki{constructor(e={}){this.version=qt.v0,this.rid=new gr,this.keyEncryptionAlgorithm=new zt,this.encryptedKey=new le,Object.assign(this,e)}}f([g({type:b.Integer})],ki.prototype,"version",void 0);f([g({type:gr})],ki.prototype,"rid",void 0);f([g({type:zt})],ki.prototype,"keyEncryptionAlgorithm",void 0);f([g({type:le})],ki.prototype,"encryptedKey",void 0);class Si{constructor(e={}){this.keyIdentifier=new le,Object.assign(this,e)}}f([g({type:le})],Si.prototype,"keyIdentifier",void 0);f([g({type:b.GeneralizedTime,optional:!0})],Si.prototype,"date",void 0);f([g({type:Xo,optional:!0})],Si.prototype,"other",void 0);class Ai{constructor(e={}){this.version=qt.v4,this.kekid=new Si,this.keyEncryptionAlgorithm=new zt,this.encryptedKey=new le,Object.assign(this,e)}}f([g({type:b.Integer})],Ai.prototype,"version",void 0);f([g({type:Si})],Ai.prototype,"kekid",void 0);f([g({type:zt})],Ai.prototype,"keyEncryptionAlgorithm",void 0);f([g({type:le})],Ai.prototype,"encryptedKey",void 0);class Ei{constructor(e={}){this.version=qt.v0,this.keyEncryptionAlgorithm=new zt,this.encryptedKey=new le,Object.assign(this,e)}}f([g({type:b.Integer})],Ei.prototype,"version",void 0);f([g({type:Sc,context:0,optional:!0})],Ei.prototype,"keyDerivationAlgorithm",void 0);f([g({type:zt})],Ei.prototype,"keyEncryptionAlgorithm",void 0);f([g({type:le})],Ei.prototype,"encryptedKey",void 0);class gl{constructor(e={}){this.oriType="",this.oriValue=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:b.ObjectIdentifier})],gl.prototype,"oriType",void 0);f([g({type:b.Any})],gl.prototype,"oriValue",void 0);let cn=class{constructor(e={}){Object.assign(this,e)}};f([g({type:ki,optional:!0})],cn.prototype,"ktri",void 0);f([g({type:Ir,context:1,implicit:!0,optional:!0})],cn.prototype,"kari",void 0);f([g({type:Ai,context:2,implicit:!0,optional:!0})],cn.prototype,"kekri",void 0);f([g({type:Ei,context:3,implicit:!0,optional:!0})],cn.prototype,"pwri",void 0);f([g({type:gl,context:4,implicit:!0,optional:!0})],cn.prototype,"ori",void 0);cn=f([B({type:R.Choice})],cn);var Rc;let Ms=Rc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Rc.prototype)}};Ms=Rc=f([B({type:R.Set,itemType:cn})],Ms);var Bc;class Qo{constructor(e={}){this.otherRevInfoFormat="",this.otherRevInfo=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:b.ObjectIdentifier})],Qo.prototype,"otherRevInfoFormat",void 0);f([g({type:b.Any})],Qo.prototype,"otherRevInfo",void 0);let Fs=class{constructor(e={}){this.other=new Qo,Object.assign(this,e)}};f([g({type:Qo,context:1,implicit:!0})],Fs.prototype,"other",void 0);Fs=f([B({type:R.Choice})],Fs);let Vs=Bc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Bc.prototype)}};Vs=Bc=f([B({type:R.Set,itemType:Fs})],Vs);class ml{constructor(e={}){Object.assign(this,e)}}f([g({type:Ls,context:0,implicit:!0,optional:!0})],ml.prototype,"certs",void 0);f([g({type:Vs,context:1,implicit:!0,optional:!0})],ml.prototype,"crls",void 0);var Lc;let Uc=Lc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Lc.prototype)}};Uc=Lc=f([B({type:R.Set,itemType:Ar})],Uc);class Ii{constructor(e={}){this.version=qt.v0,this.recipientInfos=new Ms,this.encryptedContentInfo=new xi,Object.assign(this,e)}}f([g({type:b.Integer})],Ii.prototype,"version",void 0);f([g({type:ml,context:0,implicit:!0,optional:!0})],Ii.prototype,"originatorInfo",void 0);f([g({type:Ms})],Ii.prototype,"recipientInfos",void 0);f([g({type:xi})],Ii.prototype,"encryptedContentInfo",void 0);f([g({type:Uc,context:1,implicit:!0,optional:!0})],Ii.prototype,"unprotectedAttrs",void 0);const q2="1.2.840.113549.1.7.2";var Mc;let Ds=Mc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Mc.prototype)}};Ds=Mc=f([B({type:R.Set,itemType:Yr})],Ds);class Nr{constructor(e={}){this.version=qt.v0,this.digestAlgorithms=new Ds,this.encapContentInfo=new Zo,this.signerInfos=new Ts,Object.assign(this,e)}}f([g({type:b.Integer})],Nr.prototype,"version",void 0);f([g({type:Ds})],Nr.prototype,"digestAlgorithms",void 0);f([g({type:Zo})],Nr.prototype,"encapContentInfo",void 0);f([g({type:Ls,context:0,implicit:!0,optional:!0})],Nr.prototype,"certificates",void 0);f([g({type:Vs,context:1,implicit:!0,optional:!0})],Nr.prototype,"crls",void 0);f([g({type:Ts})],Nr.prototype,"signerInfos",void 0);const ti="1.2.840.10045.2.1",_l="1.2.840.10045.4.1",pg="1.2.840.10045.4.3.1",yl="1.2.840.10045.4.3.2",wl="1.2.840.10045.4.3.3",vl="1.2.840.10045.4.3.4",Qu="1.2.840.10045.3.1.7",ef="1.3.132.0.34",tf="1.3.132.0.35";function Ni(t){return new H({algorithm:t})}const H2=Ni(_l);Ni(pg);const K2=Ni(yl),G2=Ni(wl),W2=Ni(vl);let ni=class{constructor(e={}){Object.assign(this,e)}};f([g({type:b.ObjectIdentifier})],ni.prototype,"fieldType",void 0);f([g({type:b.Any})],ni.prototype,"parameters",void 0);ni=f([B({type:R.Sequence})],ni);class J2 extends le{}let mr=class{constructor(e={}){Object.assign(this,e)}};f([g({type:b.OctetString})],mr.prototype,"a",void 0);f([g({type:b.OctetString})],mr.prototype,"b",void 0);f([g({type:b.BitString,optional:!0})],mr.prototype,"seed",void 0);mr=f([B({type:R.Sequence})],mr);var Fc;(function(t){t[t.ecpVer1=1]="ecpVer1"})(Fc||(Fc={}));let Ht=class{constructor(e={}){this.version=Fc.ecpVer1,Object.assign(this,e)}};f([g({type:b.Integer})],Ht.prototype,"version",void 0);f([g({type:ni})],Ht.prototype,"fieldID",void 0);f([g({type:mr})],Ht.prototype,"curve",void 0);f([g({type:J2})],Ht.prototype,"base",void 0);f([g({type:b.Integer,converter:_e})],Ht.prototype,"order",void 0);f([g({type:b.Integer,optional:!0})],Ht.prototype,"cofactor",void 0);Ht=f([B({type:R.Sequence})],Ht);let dn=class{constructor(e={}){Object.assign(this,e)}};f([g({type:b.ObjectIdentifier})],dn.prototype,"namedCurve",void 0);f([g({type:b.Null})],dn.prototype,"implicitCurve",void 0);f([g({type:Ht})],dn.prototype,"specifiedCurve",void 0);dn=f([B({type:R.Choice})],dn);class ea{constructor(e={}){this.version=1,this.privateKey=new le,Object.assign(this,e)}}f([g({type:b.Integer})],ea.prototype,"version",void 0);f([g({type:le})],ea.prototype,"privateKey",void 0);f([g({type:dn,context:0,optional:!0})],ea.prototype,"parameters",void 0);f([g({type:b.BitString,context:1,optional:!0})],ea.prototype,"publicKey",void 0);class qs{constructor(e={}){this.r=new ArrayBuffer(0),this.s=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:b.Integer,converter:_e})],qs.prototype,"r",void 0);f([g({type:b.Integer,converter:_e})],qs.prototype,"s",void 0);const Ye="1.2.840.113549.1.1",Tn=`${Ye}.1`,Z2=`${Ye}.7`,X2=`${Ye}.9`,qr=`${Ye}.10`,Y2=`${Ye}.2`,Q2=`${Ye}.4`,Hs=`${Ye}.5`,ew=`${Ye}.14`,Vc=`${Ye}.11`,Ks=`${Ye}.12`,Gs=`${Ye}.13`,hg=`${Ye}.15`,gg=`${Ye}.16`,Ws="1.3.14.3.2.26",mg="2.16.840.1.101.3.4.2.4",Js="2.16.840.1.101.3.4.2.1",Zs="2.16.840.1.101.3.4.2.2",Xs="2.16.840.1.101.3.4.2.3",tw="2.16.840.1.101.3.4.2.5",nw="2.16.840.1.101.3.4.2.6",rw="1.2.840.113549.2.2",iw="1.2.840.113549.2.5",ta=`${Ye}.8`;function Ce(t){return new H({algorithm:t,parameters:null})}Ce(rw);Ce(iw);const Rn=Ce(Ws);Ce(mg);Ce(Js);Ce(Zs);Ce(Xs);Ce(tw);Ce(nw);const _g=new H({algorithm:ta,parameters:F.serialize(Rn)}),yg=new H({algorithm:X2,parameters:F.serialize(As.toASN(new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer))});Ce(Tn);Ce(Y2);Ce(Q2);Ce(Hs);Ce(hg);Ce(gg);Ce(Ks);Ce(Gs);Ce(hg);Ce(gg);class na{constructor(e={}){this.hashAlgorithm=new H(Rn),this.maskGenAlgorithm=new H({algorithm:ta,parameters:F.serialize(Rn)}),this.pSourceAlgorithm=new H(yg),Object.assign(this,e)}}f([g({type:H,context:0,defaultValue:Rn})],na.prototype,"hashAlgorithm",void 0);f([g({type:H,context:1,defaultValue:_g})],na.prototype,"maskGenAlgorithm",void 0);f([g({type:H,context:2,defaultValue:yg})],na.prototype,"pSourceAlgorithm",void 0);new H({algorithm:Z2,parameters:F.serialize(new na)});class Bn{constructor(e={}){this.hashAlgorithm=new H(Rn),this.maskGenAlgorithm=new H({algorithm:ta,parameters:F.serialize(Rn)}),this.saltLength=20,this.trailerField=1,Object.assign(this,e)}}f([g({type:H,context:0,defaultValue:Rn})],Bn.prototype,"hashAlgorithm",void 0);f([g({type:H,context:1,defaultValue:_g})],Bn.prototype,"maskGenAlgorithm",void 0);f([g({type:b.Integer,context:2,defaultValue:20})],Bn.prototype,"saltLength",void 0);f([g({type:b.Integer,context:3,defaultValue:1})],Bn.prototype,"trailerField",void 0);new H({algorithm:qr,parameters:F.serialize(new Bn)});class ra{constructor(e={}){this.digestAlgorithm=new H,this.digest=new le,Object.assign(this,e)}}f([g({type:H})],ra.prototype,"digestAlgorithm",void 0);f([g({type:le})],ra.prototype,"digest",void 0);var Dc;class ia{constructor(e={}){this.prime=new ArrayBuffer(0),this.exponent=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:b.Integer,converter:_e})],ia.prototype,"prime",void 0);f([g({type:b.Integer,converter:_e})],ia.prototype,"exponent",void 0);f([g({type:b.Integer,converter:_e})],ia.prototype,"coefficient",void 0);let qc=Dc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Dc.prototype)}};qc=Dc=f([B({type:R.Sequence,itemType:ia})],qc);class Tt{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)}}f([g({type:b.Integer})],Tt.prototype,"version",void 0);f([g({type:b.Integer,converter:_e})],Tt.prototype,"modulus",void 0);f([g({type:b.Integer,converter:_e})],Tt.prototype,"publicExponent",void 0);f([g({type:b.Integer,converter:_e})],Tt.prototype,"privateExponent",void 0);f([g({type:b.Integer,converter:_e})],Tt.prototype,"prime1",void 0);f([g({type:b.Integer,converter:_e})],Tt.prototype,"prime2",void 0);f([g({type:b.Integer,converter:_e})],Tt.prototype,"exponent1",void 0);f([g({type:b.Integer,converter:_e})],Tt.prototype,"exponent2",void 0);f([g({type:b.Integer,converter:_e})],Tt.prototype,"coefficient",void 0);f([g({type:qc,optional:!0})],Tt.prototype,"otherPrimeInfos",void 0);class bl{constructor(e={}){this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:b.Integer,converter:_e})],bl.prototype,"modulus",void 0);f([g({type:b.Integer,converter:_e})],bl.prototype,"publicExponent",void 0);var Hc;(function(t){t[t.Transient=0]="Transient",t[t.Singleton=1]="Singleton",t[t.ResolutionScoped=2]="ResolutionScoped",t[t.ContainerScoped=3]="ContainerScoped"})(Hc||(Hc={}));const Ke=Hc;/*! *****************************************************************************
104
104
  Copyright (c) Microsoft Corporation.
105
105
 
106
106
  Permission to use, copy, modify, and/or distribute this software for any
@@ -113,9 +113,9 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
113
113
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
114
114
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
115
115
  PERFORMANCE OF THIS SOFTWARE.
116
- ***************************************************************************** */var Kc=function(t,e){return Kc=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])},Kc(t,e)};function $l(t,e){Kc(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}function iw(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(u){try{l(r.next(u))}catch(p){o(p)}}function d(u){try{l(r.throw(u))}catch(p){o(p)}}function l(u){u.done?s(u.value):i(u.value).then(c,d)}l((r=r.apply(t,[])).next())})}function sw(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(l){return function(u){return d([l,u])}}function d(l){if(r)throw new TypeError("Generator is already executing.");for(;n;)try{if(r=1,i&&(s=l[0]&2?i.return:l[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,l[1])).done)return s;switch(i=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return n.label++,{value:l[1],done:!1};case 5:n.label++,i=l[1],l=[0];continue;case 7:l=n.ops.pop(),n.trys.pop();continue;default:if(s=n.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){n=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){n.label=l[1];break}if(l[0]===6&&n.label<s[1]){n.label=s[1],s=l;break}if(s&&n.label<s[2]){n.label=s[2],n.ops.push(l);break}s[2]&&n.ops.pop(),n.trys.pop();continue}l=e.call(t,n)}catch(u){l=[6,u],i=0}finally{r=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function Di(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 Xs(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 wn(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Xs(arguments[e]));return t}var ow="injectionTokens";function aw(t){var e=Reflect.getMetadata("design:paramtypes",t)||[],n=Reflect.getOwnMetadata(ow,t)||{};return Object.keys(n).forEach(function(r){e[+r]=n[r]}),e}function wg(t){return!!t.useClass}function Gc(t){return!!t.useFactory}var vg=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,wn(s))}};return this.reflectMethods.forEach(r),n},t}();function Gn(t){return typeof t=="string"||typeof t=="symbol"}function cw(t){return typeof t=="object"&&"token"in t&&"multiple"in t}function nf(t){return typeof t=="object"&&"token"in t&&"transform"in t}function dw(t){return typeof t=="function"||t instanceof vg}function Zi(t){return!!t.useToken}function Xi(t){return t.useValue!=null}function lw(t){return wg(t)||Xi(t)||Zi(t)||Gc(t)}var xl=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}(),uw=function(t){$l(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(xl),rf=function(){function t(){this.scopedResolutions=new Map}return t}();function fw(t,e){if(t===null)return"at position #"+e;var n=t.split(",")[e].trim();return'"'+n+'" at position #'+e}function pw(t,e,n){return n===void 0&&(n=" "),wn([t],e.message.split(`
116
+ ***************************************************************************** */var Kc=function(t,e){return Kc=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])},Kc(t,e)};function $l(t,e){Kc(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}function sw(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(u){try{l(r.next(u))}catch(p){o(p)}}function d(u){try{l(r.throw(u))}catch(p){o(p)}}function l(u){u.done?s(u.value):i(u.value).then(c,d)}l((r=r.apply(t,[])).next())})}function ow(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(l){return function(u){return d([l,u])}}function d(l){if(r)throw new TypeError("Generator is already executing.");for(;n;)try{if(r=1,i&&(s=l[0]&2?i.return:l[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,l[1])).done)return s;switch(i=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return n.label++,{value:l[1],done:!1};case 5:n.label++,i=l[1],l=[0];continue;case 7:l=n.ops.pop(),n.trys.pop();continue;default:if(s=n.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){n=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){n.label=l[1];break}if(l[0]===6&&n.label<s[1]){n.label=s[1],s=l;break}if(s&&n.label<s[2]){n.label=s[2],n.ops.push(l);break}s[2]&&n.ops.pop(),n.trys.pop();continue}l=e.call(t,n)}catch(u){l=[6,u],i=0}finally{r=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function qi(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 Ys(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 wn(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Ys(arguments[e]));return t}var aw="injectionTokens";function cw(t){var e=Reflect.getMetadata("design:paramtypes",t)||[],n=Reflect.getOwnMetadata(aw,t)||{};return Object.keys(n).forEach(function(r){e[+r]=n[r]}),e}function wg(t){return!!t.useClass}function Gc(t){return!!t.useFactory}var vg=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,wn(s))}};return this.reflectMethods.forEach(r),n},t}();function Gn(t){return typeof t=="string"||typeof t=="symbol"}function dw(t){return typeof t=="object"&&"token"in t&&"multiple"in t}function nf(t){return typeof t=="object"&&"token"in t&&"transform"in t}function lw(t){return typeof t=="function"||t instanceof vg}function Xi(t){return!!t.useToken}function Yi(t){return t.useValue!=null}function uw(t){return wg(t)||Yi(t)||Xi(t)||Gc(t)}var xl=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}(),fw=function(t){$l(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(xl),rf=function(){function t(){this.scopedResolutions=new Map}return t}();function pw(t,e){if(t===null)return"at position #"+e;var n=t.split(",")[e].trim();return'"'+n+'" at position #'+e}function hw(t,e,n){return n===void 0&&(n=" "),wn([t],e.message.split(`
117
117
  `).map(function(r){return n+r})).join(`
118
- `)}function hw(t,e,n){var r=Xs(t.toString().match(/constructor\(([\w, ]+)\)/)||[],2),i=r[1],s=i===void 0?null:i,o=fw(s,e);return pw("Cannot inject the dependency "+o+' of "'+t.name+'" constructor. Reason:',n)}function gw(t){if(typeof t.dispose!="function")return!1;var e=t.dispose;return!(e.length>0)}var mw=function(t){$l(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(xl),_w=function(t){$l(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(xl),yw=function(){function t(){this.preResolution=new mw,this.postResolution=new _w}return t}(),bg=new Map,ww=function(){function t(e){this.parent=e,this._registry=new uw,this.interceptors=new yw,this.disposed=!1,this.disposables=new Set}return t.prototype.register=function(e,n,r){r===void 0&&(r={lifecycle:Ke.Transient}),this.ensureNotDisposed();var i;if(lw(n)?i=n:i={useClass:n},Zi(i))for(var s=[e],o=i;o!=null;){var c=o.useToken;if(s.includes(c))throw new Error("Token registration cycle detected! "+wn(s,[c]).join(" -> "));s.push(c);var d=this._registry.get(c);d&&Zi(d.provider)?o=d.provider:o=null}if((r.lifecycle===Ke.Singleton||r.lifecycle==Ke.ContainerScoped||r.lifecycle==Ke.ResolutionScoped)&&(Xi(i)||Gc(i)))throw new Error('Cannot use lifecycle "'+Ke[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(),Gn(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(),Gn(e)){if(Gn(n))return this.register(e,{useToken:n},{lifecycle:Ke.Singleton});if(n)return this.register(e,{useClass:n},{lifecycle:Ke.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var r=e;return n&&!Gn(n)&&(r=n),this.register(e,{useClass:r},{lifecycle:Ke.Singleton})},t.prototype.resolve=function(e,n){n===void 0&&(n=new rf),this.ensureNotDisposed();var r=this.getRegistration(e);if(!r&&Gn(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(dw(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=Di(this.interceptors.preResolution.getAll(e)),c=o.next();!c.done;c=o.next()){var d=c.value;d.options.frequency!="Once"&&s.push(d),d.callback(e,n)}}catch(l){r={error:l}}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=Di(this.interceptors.postResolution.getAll(e)),d=c.next();!d.done;d=c.next()){var l=d.value;l.options.frequency!="Once"&&o.push(l),l.callback(e,n,r)}}catch(u){i={error:u}}finally{try{d&&!d.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===Ke.ResolutionScoped&&n.scopedResolutions.has(e))return n.scopedResolutions.get(e);var r=e.options.lifecycle===Ke.Singleton,i=e.options.lifecycle===Ke.ContainerScoped,s=r||i,o;return Xi(e.provider)?o=e.provider.useValue:Zi(e.provider)?o=s?e.instance||(e.instance=this.resolve(e.provider.useToken,n)):this.resolve(e.provider.useToken,n):wg(e.provider)?o=s?e.instance||(e.instance=this.construct(e.provider.useClass,n)):this.construct(e.provider.useClass,n):Gc(e.provider)?o=e.provider.useFactory(this):o=this.construct(e.provider,n),e.options.lifecycle===Ke.ResolutionScoped&&n.scopedResolutions.set(e,o),o},t.prototype.resolveAll=function(e,n){var r=this;n===void 0&&(n=new rf),this.ensureNotDisposed();var i=this.getAllRegistrations(e);if(!i&&Gn(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=Di(this._registry.entries()),i=r.next();!i.done;i=r.next()){var s=Xs(i.value,2),o=s[0],c=s[1];this._registry.setAll(o,c.filter(function(d){return!Xi(d.provider)}).map(function(d){return d.instance=void 0,d}))}}catch(d){e={error:d}}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=Di(this._registry.entries()),s=i.next();!s.done;s=i.next()){var o=Xs(s.value,2),c=o[0],d=o[1];d.some(function(l){var u=l.options;return u.lifecycle===Ke.ContainerScoped})&&r._registry.setAll(c,d.map(function(l){return l.options.lifecycle===Ke.ContainerScoped?{provider:l.provider,options:l.options}:l}))}}catch(l){e={error:l}}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 iw(this,void 0,void 0,function(){var e;return sw(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 vg)return e.createProxy(function(s){return r.resolve(s,n)});var i=function(){var s=bg.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,wn([void 0],o)))}();return gw(i)&&this.disposables.add(i),i},t.prototype.resolveParams=function(e,n){var r=this;return function(i,s){var o,c,d;try{return cw(i)?nf(i)?i.multiple?(o=r.resolve(i.transform)).transform.apply(o,wn([r.resolveAll(i.token)],i.transformArgs)):(c=r.resolve(i.transform)).transform.apply(c,wn([r.resolve(i.token,e)],i.transformArgs)):i.multiple?r.resolveAll(i.token):r.resolve(i.token,e):nf(i)?(d=r.resolve(i.transform,e)).transform.apply(d,wn([r.resolve(i.token,e)],i.transformArgs)):r.resolve(i,e)}catch(l){throw new Error(hw(n,s,l))}}},t.prototype.ensureNotDisposed=function(){if(this.disposed)throw new Error("This container has been disposed, you cannot interact with a disposed container")},t}(),Ue=new ww;function ia(){return function(t){bg.set(t,aw(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 Wc;class sa{constructor(e={}){this.attrId="",this.attrValues=[],Object.assign(e)}}f([g({type:b.ObjectIdentifier})],sa.prototype,"attrId",void 0);f([g({type:b.Any,repeated:"set"})],sa.prototype,"attrValues",void 0);let sf=Wc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Wc.prototype)}};sf=Wc=f([B({type:R.Sequence,itemType:sa})],sf);var Jc;let of=Jc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Jc.prototype)}};of=Jc=f([B({type:R.Sequence,itemType:Er})],of);class $g{constructor(e={}){this.certId="",this.certValue=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:b.ObjectIdentifier})],$g.prototype,"certId",void 0);f([g({type:b.Any,context:0})],$g.prototype,"certValue",void 0);class xg{constructor(e={}){this.crlId="",this.crltValue=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:b.ObjectIdentifier})],xg.prototype,"crlId",void 0);f([g({type:b.Any,context:0})],xg.prototype,"crltValue",void 0);class kg extends le{}let oa=class{constructor(e={}){this.encryptionAlgorithm=new H,this.encryptedData=new kg,Object.assign(this,e)}};f([g({type:H})],oa.prototype,"encryptionAlgorithm",void 0);f([g({type:kg})],oa.prototype,"encryptedData",void 0);var Zc,Xc;(function(t){t[t.v1=0]="v1"})(Xc||(Xc={}));class Sg extends le{}let Yc=Zc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Zc.prototype)}};Yc=Zc=f([B({type:R.Sequence,itemType:Dt})],Yc);class Ni{constructor(e={}){this.version=Xc.v1,this.privateKeyAlgorithm=new H,this.privateKey=new Sg,Object.assign(this,e)}}f([g({type:b.Integer})],Ni.prototype,"version",void 0);f([g({type:H})],Ni.prototype,"privateKeyAlgorithm",void 0);f([g({type:Sg})],Ni.prototype,"privateKey",void 0);f([g({type:Yc,implicit:!0,context:0,optional:!0})],Ni.prototype,"attributes",void 0);let af=class extends Ni{};af=f([B({type:R.Sequence})],af);let cf=class extends oa{};cf=f([B({type:R.Sequence})],cf);class Ag{constructor(e={}){this.secretTypeId="",this.secretValue=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:b.ObjectIdentifier})],Ag.prototype,"secretTypeId",void 0);f([g({type:b.Any,context:0})],Ag.prototype,"secretValue",void 0);class Ci{constructor(e={}){this.mac=new na,this.macSalt=new le,this.iterations=1,Object.assign(this,e)}}f([g({type:na})],Ci.prototype,"mac",void 0);f([g({type:le})],Ci.prototype,"macSalt",void 0);f([g({type:b.Integer,defaultValue:1})],Ci.prototype,"iterations",void 0);class aa{constructor(e={}){this.version=3,this.authSafe=new Er,this.macData=new Ci,Object.assign(this,e)}}f([g({type:b.Integer})],aa.prototype,"version",void 0);f([g({type:Er})],aa.prototype,"authSafe",void 0);f([g({type:Ci,optional:!0})],aa.prototype,"macData",void 0);var Qc;class ca{constructor(e={}){this.bagId="",this.bagValue=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:b.ObjectIdentifier})],ca.prototype,"bagId",void 0);f([g({type:b.Any,context:0})],ca.prototype,"bagValue",void 0);f([g({type:sa,repeated:"set",optional:!0})],ca.prototype,"bagAttributes",void 0);let df=Qc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Qc.prototype)}};df=Qc=f([B({type:R.Sequence,itemType:ca})],df);var ed,td,nd;const Eg="1.2.840.113549.1.9",Ig=`${Eg}.7`,kl=`${Eg}.14`;let Ys=class extends Le{constructor(e={}){super(e)}toString(){return this.ia5String||super.toString()}};f([g({type:b.IA5String})],Ys.prototype,"ia5String",void 0);Ys=f([B({type:R.Choice})],Ys);let lf=class extends Er{};lf=f([B({type:R.Sequence})],lf);let uf=class extends aa{};uf=f([B({type:R.Sequence})],uf);let ff=class extends oa{};ff=f([B({type:R.Sequence})],ff);let rd=class{constructor(e=""){this.value=e}toString(){return this.value}};f([g({type:b.IA5String})],rd.prototype,"value",void 0);rd=f([B({type:R.Choice})],rd);let pf=class extends Ys{};pf=f([B({type:R.Choice})],pf);let hf=class extends Le{};hf=f([B({type:R.Choice})],hf);let id=class{constructor(e=new Date){this.value=e}};f([g({type:b.GeneralizedTime})],id.prototype,"value",void 0);id=f([B({type:R.Choice})],id);let gf=class extends Le{};gf=f([B({type:R.Choice})],gf);let sd=class{constructor(e="M"){this.value=e}toString(){return this.value}};f([g({type:b.PrintableString})],sd.prototype,"value",void 0);sd=f([B({type:R.Choice})],sd);let Qs=class{constructor(e=""){this.value=e}toString(){return this.value}};f([g({type:b.PrintableString})],Qs.prototype,"value",void 0);Qs=f([B({type:R.Choice})],Qs);let mf=class extends Qs{};mf=f([B({type:R.Choice})],mf);let _f=class extends Le{};_f=f([B({type:R.Choice})],_f);let od=class{constructor(e=""){this.value=e}toString(){return this.value}};f([g({type:b.ObjectIdentifier})],od.prototype,"value",void 0);od=f([B({type:R.Choice})],od);let yf=class extends Re{};yf=f([B({type:R.Choice})],yf);let ad=class{constructor(e=0){this.value=e}toString(){return this.value.toString()}};f([g({type:b.Integer})],ad.prototype,"value",void 0);ad=f([B({type:R.Choice})],ad);let wf=class extends jt{};wf=f([B({type:R.Sequence})],wf);let eo=class extends Le{};eo=f([B({type:R.Choice})],eo);let vf=ed=class extends an{constructor(e){super(e),Object.setPrototypeOf(this,ed.prototype)}};vf=ed=f([B({type:R.Sequence})],vf);let bf=td=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,td.prototype)}};bf=td=f([B({type:R.Set,itemType:Ar})],bf);let cd=class{constructor(e=""){this.value=e}toString(){return this.value}};f([g({type:b.BmpString})],cd.prototype,"value",void 0);cd=f([B({type:R.Choice})],cd);let dd=class extends H{};dd=f([B({type:R.Sequence})],dd);let $f=nd=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,nd.prototype)}};$f=nd=f([B({type:R.Sequence,itemType:dd})],$f);var ld;let to=ld=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,ld.prototype)}};to=ld=f([B({type:R.Sequence,itemType:Dt})],to);class Cr{constructor(e={}){this.version=0,this.subject=new $e,this.subjectPKInfo=new gt,this.attributes=new to,Object.assign(this,e)}}f([g({type:b.Integer})],Cr.prototype,"version",void 0);f([g({type:$e})],Cr.prototype,"subject",void 0);f([g({type:gt})],Cr.prototype,"subjectPKInfo",void 0);f([g({type:to,implicit:!0,context:0})],Cr.prototype,"attributes",void 0);class ri{constructor(e={}){this.certificationRequestInfo=new Cr,this.signatureAlgorithm=new H,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:Cr})],ri.prototype,"certificationRequestInfo",void 0);f([g({type:H})],ri.prototype,"signatureAlgorithm",void 0);f([g({type:b.BitString})],ri.prototype,"signature",void 0);/*!
118
+ `)}function gw(t,e,n){var r=Ys(t.toString().match(/constructor\(([\w, ]+)\)/)||[],2),i=r[1],s=i===void 0?null:i,o=pw(s,e);return hw("Cannot inject the dependency "+o+' of "'+t.name+'" constructor. Reason:',n)}function mw(t){if(typeof t.dispose!="function")return!1;var e=t.dispose;return!(e.length>0)}var _w=function(t){$l(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(xl),yw=function(t){$l(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(xl),ww=function(){function t(){this.preResolution=new _w,this.postResolution=new yw}return t}(),bg=new Map,vw=function(){function t(e){this.parent=e,this._registry=new fw,this.interceptors=new ww,this.disposed=!1,this.disposables=new Set}return t.prototype.register=function(e,n,r){r===void 0&&(r={lifecycle:Ke.Transient}),this.ensureNotDisposed();var i;if(uw(n)?i=n:i={useClass:n},Xi(i))for(var s=[e],o=i;o!=null;){var c=o.useToken;if(s.includes(c))throw new Error("Token registration cycle detected! "+wn(s,[c]).join(" -> "));s.push(c);var d=this._registry.get(c);d&&Xi(d.provider)?o=d.provider:o=null}if((r.lifecycle===Ke.Singleton||r.lifecycle==Ke.ContainerScoped||r.lifecycle==Ke.ResolutionScoped)&&(Yi(i)||Gc(i)))throw new Error('Cannot use lifecycle "'+Ke[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(),Gn(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(),Gn(e)){if(Gn(n))return this.register(e,{useToken:n},{lifecycle:Ke.Singleton});if(n)return this.register(e,{useClass:n},{lifecycle:Ke.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var r=e;return n&&!Gn(n)&&(r=n),this.register(e,{useClass:r},{lifecycle:Ke.Singleton})},t.prototype.resolve=function(e,n){n===void 0&&(n=new rf),this.ensureNotDisposed();var r=this.getRegistration(e);if(!r&&Gn(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(lw(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=qi(this.interceptors.preResolution.getAll(e)),c=o.next();!c.done;c=o.next()){var d=c.value;d.options.frequency!="Once"&&s.push(d),d.callback(e,n)}}catch(l){r={error:l}}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=qi(this.interceptors.postResolution.getAll(e)),d=c.next();!d.done;d=c.next()){var l=d.value;l.options.frequency!="Once"&&o.push(l),l.callback(e,n,r)}}catch(u){i={error:u}}finally{try{d&&!d.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===Ke.ResolutionScoped&&n.scopedResolutions.has(e))return n.scopedResolutions.get(e);var r=e.options.lifecycle===Ke.Singleton,i=e.options.lifecycle===Ke.ContainerScoped,s=r||i,o;return Yi(e.provider)?o=e.provider.useValue:Xi(e.provider)?o=s?e.instance||(e.instance=this.resolve(e.provider.useToken,n)):this.resolve(e.provider.useToken,n):wg(e.provider)?o=s?e.instance||(e.instance=this.construct(e.provider.useClass,n)):this.construct(e.provider.useClass,n):Gc(e.provider)?o=e.provider.useFactory(this):o=this.construct(e.provider,n),e.options.lifecycle===Ke.ResolutionScoped&&n.scopedResolutions.set(e,o),o},t.prototype.resolveAll=function(e,n){var r=this;n===void 0&&(n=new rf),this.ensureNotDisposed();var i=this.getAllRegistrations(e);if(!i&&Gn(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=qi(this._registry.entries()),i=r.next();!i.done;i=r.next()){var s=Ys(i.value,2),o=s[0],c=s[1];this._registry.setAll(o,c.filter(function(d){return!Yi(d.provider)}).map(function(d){return d.instance=void 0,d}))}}catch(d){e={error:d}}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=qi(this._registry.entries()),s=i.next();!s.done;s=i.next()){var o=Ys(s.value,2),c=o[0],d=o[1];d.some(function(l){var u=l.options;return u.lifecycle===Ke.ContainerScoped})&&r._registry.setAll(c,d.map(function(l){return l.options.lifecycle===Ke.ContainerScoped?{provider:l.provider,options:l.options}:l}))}}catch(l){e={error:l}}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 sw(this,void 0,void 0,function(){var e;return ow(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 vg)return e.createProxy(function(s){return r.resolve(s,n)});var i=function(){var s=bg.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,wn([void 0],o)))}();return mw(i)&&this.disposables.add(i),i},t.prototype.resolveParams=function(e,n){var r=this;return function(i,s){var o,c,d;try{return dw(i)?nf(i)?i.multiple?(o=r.resolve(i.transform)).transform.apply(o,wn([r.resolveAll(i.token)],i.transformArgs)):(c=r.resolve(i.transform)).transform.apply(c,wn([r.resolve(i.token,e)],i.transformArgs)):i.multiple?r.resolveAll(i.token):r.resolve(i.token,e):nf(i)?(d=r.resolve(i.transform,e)).transform.apply(d,wn([r.resolve(i.token,e)],i.transformArgs)):r.resolve(i,e)}catch(l){throw new Error(gw(n,s,l))}}},t.prototype.ensureNotDisposed=function(){if(this.disposed)throw new Error("This container has been disposed, you cannot interact with a disposed container")},t}(),Ue=new vw;function sa(){return function(t){bg.set(t,cw(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 Wc;class oa{constructor(e={}){this.attrId="",this.attrValues=[],Object.assign(e)}}f([g({type:b.ObjectIdentifier})],oa.prototype,"attrId",void 0);f([g({type:b.Any,repeated:"set"})],oa.prototype,"attrValues",void 0);let sf=Wc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Wc.prototype)}};sf=Wc=f([B({type:R.Sequence,itemType:oa})],sf);var Jc;let of=Jc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Jc.prototype)}};of=Jc=f([B({type:R.Sequence,itemType:Er})],of);class $g{constructor(e={}){this.certId="",this.certValue=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:b.ObjectIdentifier})],$g.prototype,"certId",void 0);f([g({type:b.Any,context:0})],$g.prototype,"certValue",void 0);class xg{constructor(e={}){this.crlId="",this.crltValue=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:b.ObjectIdentifier})],xg.prototype,"crlId",void 0);f([g({type:b.Any,context:0})],xg.prototype,"crltValue",void 0);class kg extends le{}let aa=class{constructor(e={}){this.encryptionAlgorithm=new H,this.encryptedData=new kg,Object.assign(this,e)}};f([g({type:H})],aa.prototype,"encryptionAlgorithm",void 0);f([g({type:kg})],aa.prototype,"encryptedData",void 0);var Zc,Xc;(function(t){t[t.v1=0]="v1"})(Xc||(Xc={}));class Sg extends le{}let Yc=Zc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Zc.prototype)}};Yc=Zc=f([B({type:R.Sequence,itemType:Dt})],Yc);class Ci{constructor(e={}){this.version=Xc.v1,this.privateKeyAlgorithm=new H,this.privateKey=new Sg,Object.assign(this,e)}}f([g({type:b.Integer})],Ci.prototype,"version",void 0);f([g({type:H})],Ci.prototype,"privateKeyAlgorithm",void 0);f([g({type:Sg})],Ci.prototype,"privateKey",void 0);f([g({type:Yc,implicit:!0,context:0,optional:!0})],Ci.prototype,"attributes",void 0);let af=class extends Ci{};af=f([B({type:R.Sequence})],af);let cf=class extends aa{};cf=f([B({type:R.Sequence})],cf);class Ag{constructor(e={}){this.secretTypeId="",this.secretValue=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:b.ObjectIdentifier})],Ag.prototype,"secretTypeId",void 0);f([g({type:b.Any,context:0})],Ag.prototype,"secretValue",void 0);class zi{constructor(e={}){this.mac=new ra,this.macSalt=new le,this.iterations=1,Object.assign(this,e)}}f([g({type:ra})],zi.prototype,"mac",void 0);f([g({type:le})],zi.prototype,"macSalt",void 0);f([g({type:b.Integer,defaultValue:1})],zi.prototype,"iterations",void 0);class ca{constructor(e={}){this.version=3,this.authSafe=new Er,this.macData=new zi,Object.assign(this,e)}}f([g({type:b.Integer})],ca.prototype,"version",void 0);f([g({type:Er})],ca.prototype,"authSafe",void 0);f([g({type:zi,optional:!0})],ca.prototype,"macData",void 0);var Qc;class da{constructor(e={}){this.bagId="",this.bagValue=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:b.ObjectIdentifier})],da.prototype,"bagId",void 0);f([g({type:b.Any,context:0})],da.prototype,"bagValue",void 0);f([g({type:oa,repeated:"set",optional:!0})],da.prototype,"bagAttributes",void 0);let df=Qc=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,Qc.prototype)}};df=Qc=f([B({type:R.Sequence,itemType:da})],df);var ed,td,nd;const Eg="1.2.840.113549.1.9",Ig=`${Eg}.7`,kl=`${Eg}.14`;let Qs=class extends Le{constructor(e={}){super(e)}toString(){return this.ia5String||super.toString()}};f([g({type:b.IA5String})],Qs.prototype,"ia5String",void 0);Qs=f([B({type:R.Choice})],Qs);let lf=class extends Er{};lf=f([B({type:R.Sequence})],lf);let uf=class extends ca{};uf=f([B({type:R.Sequence})],uf);let ff=class extends aa{};ff=f([B({type:R.Sequence})],ff);let rd=class{constructor(e=""){this.value=e}toString(){return this.value}};f([g({type:b.IA5String})],rd.prototype,"value",void 0);rd=f([B({type:R.Choice})],rd);let pf=class extends Qs{};pf=f([B({type:R.Choice})],pf);let hf=class extends Le{};hf=f([B({type:R.Choice})],hf);let id=class{constructor(e=new Date){this.value=e}};f([g({type:b.GeneralizedTime})],id.prototype,"value",void 0);id=f([B({type:R.Choice})],id);let gf=class extends Le{};gf=f([B({type:R.Choice})],gf);let sd=class{constructor(e="M"){this.value=e}toString(){return this.value}};f([g({type:b.PrintableString})],sd.prototype,"value",void 0);sd=f([B({type:R.Choice})],sd);let eo=class{constructor(e=""){this.value=e}toString(){return this.value}};f([g({type:b.PrintableString})],eo.prototype,"value",void 0);eo=f([B({type:R.Choice})],eo);let mf=class extends eo{};mf=f([B({type:R.Choice})],mf);let _f=class extends Le{};_f=f([B({type:R.Choice})],_f);let od=class{constructor(e=""){this.value=e}toString(){return this.value}};f([g({type:b.ObjectIdentifier})],od.prototype,"value",void 0);od=f([B({type:R.Choice})],od);let yf=class extends Re{};yf=f([B({type:R.Choice})],yf);let ad=class{constructor(e=0){this.value=e}toString(){return this.value.toString()}};f([g({type:b.Integer})],ad.prototype,"value",void 0);ad=f([B({type:R.Choice})],ad);let wf=class extends jt{};wf=f([B({type:R.Sequence})],wf);let to=class extends Le{};to=f([B({type:R.Choice})],to);let vf=ed=class extends an{constructor(e){super(e),Object.setPrototypeOf(this,ed.prototype)}};vf=ed=f([B({type:R.Sequence})],vf);let bf=td=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,td.prototype)}};bf=td=f([B({type:R.Set,itemType:Ar})],bf);let cd=class{constructor(e=""){this.value=e}toString(){return this.value}};f([g({type:b.BmpString})],cd.prototype,"value",void 0);cd=f([B({type:R.Choice})],cd);let dd=class extends H{};dd=f([B({type:R.Sequence})],dd);let $f=nd=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,nd.prototype)}};$f=nd=f([B({type:R.Sequence,itemType:dd})],$f);var ld;let no=ld=class extends pe{constructor(e){super(e),Object.setPrototypeOf(this,ld.prototype)}};no=ld=f([B({type:R.Sequence,itemType:Dt})],no);class Cr{constructor(e={}){this.version=0,this.subject=new $e,this.subjectPKInfo=new gt,this.attributes=new no,Object.assign(this,e)}}f([g({type:b.Integer})],Cr.prototype,"version",void 0);f([g({type:$e})],Cr.prototype,"subject",void 0);f([g({type:gt})],Cr.prototype,"subjectPKInfo",void 0);f([g({type:no,implicit:!0,context:0})],Cr.prototype,"attributes",void 0);class ri{constructor(e={}){this.certificationRequestInfo=new Cr,this.signatureAlgorithm=new H,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}f([g({type:Cr})],ri.prototype,"certificationRequestInfo",void 0);f([g({type:H})],ri.prototype,"signatureAlgorithm",void 0);f([g({type:b.BitString})],ri.prototype,"signature",void 0);/*!
119
119
  * MIT License
120
120
  *
121
121
  * Copyright (c) Peculiar Ventures. All rights reserved.
@@ -138,20 +138,20 @@ PERFORMANCE OF THIS SOFTWARE.
138
138
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
139
139
  * SOFTWARE.
140
140
  *
141
- */const zi="crypto.algorithm";class vw{getAlgorithms(){return Ue.resolveAll(zi)}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 H({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 Ln="crypto.algorithmProvider";Ue.registerSingleton(Ln,vw);var Yi;const Qe="1.3.36.3.3.2.8.1.1",xf=`${Qe}.1`,kf=`${Qe}.2`,Sf=`${Qe}.3`,Af=`${Qe}.4`,Ef=`${Qe}.5`,If=`${Qe}.6`,Nf=`${Qe}.7`,Cf=`${Qe}.8`,zf=`${Qe}.9`,Of=`${Qe}.10`,Pf=`${Qe}.11`,jf=`${Qe}.12`,Tf=`${Qe}.13`,Rf=`${Qe}.14`,Bf="brainpoolP160r1",Lf="brainpoolP160t1",Uf="brainpoolP192r1",Mf="brainpoolP192t1",Ff="brainpoolP224r1",Vf="brainpoolP224t1",Df="brainpoolP256r1",qf="brainpoolP256t1",Hf="brainpoolP320r1",Kf="brainpoolP320t1",Gf="brainpoolP384r1",Wf="brainpoolP384t1",Jf="brainpoolP512r1",Zf="brainpoolP512t1",ye="ECDSA";let ii=Yi=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 q2;case"sha-256":return H2;case"sha-384":return K2;case"sha-512":return G2}else if("namedCurve"in e){let n="";switch(e.namedCurve){case"P-256":n=Qu;break;case"K-256":n=Yi.SECP256K1;break;case"P-384":n=ef;break;case"P-521":n=tf;break;case Bf:n=xf;break;case Lf:n=kf;break;case Uf:n=Sf;break;case Mf:n=Af;break;case Ff:n=Ef;break;case Vf:n=If;break;case Df:n=Nf;break;case qf:n=Cf;break;case Hf:n=zf;break;case Kf:n=Of;break;case Gf:n=Pf;break;case Wf:n=jf;break;case Jf:n=Tf;break;case Zf:n=Rf;break}if(n)return new H({algorithm:ti,parameters:F.serialize(new dn({namedCurve:n}))})}}return null}toWebAlgorithm(e){switch(e.algorithm){case _l:return{name:ye,hash:{name:"SHA-1"}};case yl:return{name:ye,hash:{name:"SHA-256"}};case wl:return{name:ye,hash:{name:"SHA-384"}};case vl:return{name:ye,hash:{name:"SHA-512"}};case ti:{if(!e.parameters)throw new TypeError("Cannot get required parameters from EC algorithm");switch(F.parse(e.parameters,dn).namedCurve){case Qu:return{name:ye,namedCurve:"P-256"};case Yi.SECP256K1:return{name:ye,namedCurve:"K-256"};case ef:return{name:ye,namedCurve:"P-384"};case tf:return{name:ye,namedCurve:"P-521"};case xf:return{name:ye,namedCurve:Bf};case kf:return{name:ye,namedCurve:Lf};case Sf:return{name:ye,namedCurve:Uf};case Af:return{name:ye,namedCurve:Mf};case Ef:return{name:ye,namedCurve:Ff};case If:return{name:ye,namedCurve:Vf};case Nf:return{name:ye,namedCurve:Df};case Cf:return{name:ye,namedCurve:qf};case zf:return{name:ye,namedCurve:Hf};case Of:return{name:ye,namedCurve:Kf};case Pf:return{name:ye,namedCurve:Gf};case jf:return{name:ye,namedCurve:Wf};case Tf:return{name:ye,namedCurve:Jf};case Rf:return{name:ye,namedCurve:Zf}}}}return null}};ii.SECP256K1="1.3.132.0.10";ii=Yi=f([ia()],ii);Ue.registerSingleton(zi,ii);const Ng=Symbol("name"),Cg=Symbol("value");class fe{constructor(e,n={},r=""){this[Ng]=e,this[Cg]=r;for(const i in n)this[i]=n[i]}}fe.NAME=Ng;fe.VALUE=Cg;class bw{static toTextObject(e){const n=new fe("Algorithm Identifier",{},gn.toString(e.algorithm));if(e.parameters)switch(e.algorithm){case ti:{const r=new ii().toWebAlgorithm(e);r&&"namedCurve"in r?n["Named Curve"]=r.namedCurve:n.Parameters=e.parameters;break}default:n.Parameters=e.parameters}return n}}class gn{static toString(e){const n=this.items[e];return n||e}}gn.items={[Gs]:"sha1",[mg]:"sha224",[Ws]:"sha256",[Js]:"sha384",[Zs]:"sha512",[Tn]:"rsaEncryption",[qs]:"sha1WithRSAEncryption",[Q2]:"sha224WithRSAEncryption",[Vc]:"sha256WithRSAEncryption",[Hs]:"sha384WithRSAEncryption",[Ks]:"sha512WithRSAEncryption",[ti]:"ecPublicKey",[_l]:"ecdsaWithSHA1",[pg]:"ecdsaWithSHA224",[yl]:"ecdsaWithSHA256",[wl]:"ecdsaWithSHA384",[vl]:"ecdsaWithSHA512",[B2]:"TLS WWW server authentication",[L2]:"TLS WWW client authentication",[U2]:"Code Signing",[M2]:"E-mail Protection",[F2]:"Time Stamping",[V2]:"OCSP Signing",[D2]:"Signed Data"};class Un{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[fe.VALUE];o&&(s=` ${o}`),r.push(`${i}${e[fe.NAME]}:${s}`),i=this.pad(n);for(const c in e){if(typeof c=="symbol")continue;const d=e[c],l=c?`${c}: `:"";if(typeof d=="string"||typeof d=="number"||typeof d=="boolean")r.push(`${i}${l}${d}`);else if(d instanceof Date)r.push(`${i}${l}${d.toUTCString()}`);else if(Array.isArray(d))for(const u of d)u[fe.NAME]=c,r.push(...this.serializeObj(u,n));else if(d instanceof fe)d[fe.NAME]=c,r.push(...this.serializeObj(d,n));else if(V.isBufferSource(d))c?(r.push(`${i}${l}`),r.push(...this.serializeBufferSource(d,n+1))):r.push(...this.serializeBufferSource(d,n));else if("toTextObject"in d){const u=d.toTextObject();u[fe.NAME]=c,r.push(...this.serializeObj(u,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=V.toUint8Array(e),s=[];for(let o=0;o<i.length;){const c=[];for(let d=0;d<16&&o<i.length;d++){d===8&&c.push("");const l=i[o++].toString(16).padStart(2,"0");c.push(l)}s.push(`${r}${c.join(" ")}`)}return s}static serializeAlgorithm(e){return this.algorithmSerializer.toTextObject(e)}}Un.oidSerializer=gn;Un.algorithmSerializer=bw;class mn{constructor(...e){if(e.length===1){const n=e[0];this.rawData=F.serialize(n),this.onInit(n)}else{const n=F.parse(e[0],e[1]);this.rawData=V.toArrayBuffer(e[0]),this.onInit(n)}}equal(e){return e instanceof mn?J0(e.rawData,this.rawData):!1}toString(e="text"){switch(e){case"asn":return F.toString(this.rawData);case"text":return Un.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 fe(this.getTextName(),{},e)}}mn.NAME="ASN";class lt extends mn{constructor(...e){let n;V.isBufferSource(e[0])?n=V.toArrayBuffer(e[0]):n=F.serialize(new at({extnID:e[0],critical:e[1],extnValue:new le(V.toArrayBuffer(e[2]))})),super(n,at)}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[fe.NAME]===lt.NAME&&(e[fe.NAME]=gn.toString(this.type)),e}}var zg;class en{static isCryptoKeyPair(e){return e&&e.privateKey&&e.publicKey}static isCryptoKey(e){return e&&e.usages&&e.type&&e.algorithm&&e.extractable!==void 0}constructor(){this.items=new Map,this[zg]="CryptoProvider",typeof self<"u"&&typeof crypto<"u"?this.set(en.DEFAULT,crypto):typeof global<"u"&&global.crypto&&global.crypto.subtle&&this.set(en.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=en.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(en.DEFAULT,e);return this}}zg=Symbol.toStringTag;en.DEFAULT="default";const Te=new en,$w=/^[0-2](?:\.[1-9][0-9]*)+$/;function xw(t){return new RegExp($w).test(t)}class Og{constructor(e={}){this.items={};for(const n in e)this.register(n,e[n])}get(e){return this.items[e]||null}findId(e){return xw(e)?e:this.get(e)}register(e,n){this.items[e]=n,this.items[n]=e}}const Ze=new Og;Ze.register("CN","2.5.4.3");Ze.register("L","2.5.4.7");Ze.register("ST","2.5.4.8");Ze.register("O","2.5.4.10");Ze.register("OU","2.5.4.11");Ze.register("C","2.5.4.6");Ze.register("DC","0.9.2342.19200300.100.1.25");Ze.register("E","1.2.840.113549.1.9.1");Ze.register("G","2.5.4.42");Ze.register("I","2.5.4.43");Ze.register("SN","2.5.4.4");Ze.register("T","2.5.4.12");function kw(t,e){return`\\${J.ToHex(J.FromUtf8String(e)).toUpperCase()}`}function Sw(t){return t.replace(/([,+"\\<>;])/g,"\\$1").replace(/^([ #])/,"\\$1").replace(/([ ]$)/,"\\$1").replace(/([\r\n\t])/,kw)}class st{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 Og,this.asn=new $e;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 $e?this.asn=e:V.isBufferSource(e)?this.asn=F.parse(e,$e):this.asn=this.fromJSON(e)}getField(e){const n=this.extraNames.findId(e)||Ze.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)||Ze.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)}`:Sw(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 $e,r=/(\d\.[\d.]*\d|[A-Za-z]+)=((?:"")|(?:".*?[^\\]")|(?:[^,+].*?(?:[^\\][,+]))|(?:))([,+])?/g;let i=null,s=",";for(;i=r.exec(`${e},`);){let[,o,c]=i;const d=c[c.length-1];(d===","||d==="+")&&(c=c.slice(0,c.length-1),i[3]=d);const l=i[3];o=this.getTypeOid(o);const u=this.createAttribute(o,c);s==="+"?n[n.length-1].push(u):n.push(new dr([u])),s=l}return n}fromJSON(e){const n=new $e;for(const r of e){const i=new dr;for(const s in r){const o=this.getTypeOid(s),c=r[s];for(const d of c){const l=this.createAttribute(o,d);i.push(l)}}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 Lo({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:st.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 F.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]||Te.get()):r=e[0]||Te.get(),await r.subtle.digest(i,this.toArrayBuffer())}}const Pg="Cannot initialize GeneralName from ASN.1 data.",Xf=`${Pg} Unsupported string format in use.`,Aw=`${Pg} Value doesn't match to GUID regular expression.`,Yf=/^([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})$/i,Qf="1.3.6.1.4.1.311.25.1",ep="1.3.6.1.4.1.311.20.2.3",xa="dns",ka="dn",Sa="email",Aa="ip",Ea="url",Ia="guid",Na="upn",qi="id";class tn extends mn{constructor(...e){let n;if(e.length===2)switch(e[0]){case ka:{const r=new st(e[1]).toArrayBuffer(),i=F.parse(r,$e);n=new ie({directoryName:i});break}case xa:n=new ie({dNSName:e[1]});break;case Sa:n=new ie({rfc822Name:e[1]});break;case Ia:{const r=new RegExp(Yf,"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 ie({otherName:new Xr({typeId:Qf,value:F.serialize(new le(J.FromHex(i)))})});break}case Aa:n=new ie({iPAddress:e[1]});break;case qi:n=new ie({registeredID:e[1]});break;case Na:{n=new ie({otherName:new Xr({typeId:ep,value:F.serialize(Jh.toASN(e[1]))})});break}case Ea:n=new ie({uniformResourceIdentifier:e[1]});break;default:throw new Error("Cannot create GeneralName. Unsupported type of the name")}else V.isBufferSource(e[0])?n=F.parse(e[0],ie):n=e[0];super(n)}onInit(e){if(e.dNSName!=null)this.type=xa,this.value=e.dNSName;else if(e.rfc822Name!=null)this.type=Sa,this.value=e.rfc822Name;else if(e.iPAddress!=null)this.type=Aa,this.value=e.iPAddress;else if(e.uniformResourceIdentifier!=null)this.type=Ea,this.value=e.uniformResourceIdentifier;else if(e.registeredID!=null)this.type=qi,this.value=e.registeredID;else if(e.directoryName!=null)this.type=ka,this.value=new st(e.directoryName).toString();else if(e.otherName!=null)if(e.otherName.typeId===Qf){this.type=Ia;const n=F.parse(e.otherName.value,le),r=new RegExp(Yf,"i").exec(J.ToHex(n));if(!r)throw new Error(Aw);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===ep)this.type=Na,this.value=F.parse(e.otherName.value,Le).toString();else throw new Error(Xf);else throw new Error(Xf)}toJSON(){return{type:this.type,value:this.value}}toTextObject(){let e;switch(this.type){case ka:case xa:case Ia:case Aa:case qi:case Na:case Ea:e=this.type.toUpperCase();break;case Sa:e="Email";break;default:throw new Error("Unsupported GeneralName type")}let n=this.value;return this.type===qi&&(n=gn.toString(n)),new fe(e,void 0,n)}}class si extends mn{constructor(e){let n;if(e instanceof De)n=e;else if(Array.isArray(e)){const r=[];for(const i of e)if(i instanceof ie)r.push(i);else{const s=F.parse(new tn(i.type,i.value).rawData,ie);r.push(s)}n=new De(r)}else if(V.isBufferSource(e))n=F.parse(e,De);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 tn(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[fe.NAME]];Array.isArray(i)||(i=[],e[r[fe.NAME]]=i),i.push(r)}return e}}si.NAME="GeneralNames";const Hr="-{5}",oi="\\n",Ew=`[^${oi}]+`,Iw=`${Hr}BEGIN (${Ew}(?=${Hr}))${Hr}`,Nw=`${Hr}END \\1${Hr}`,_r="\\n",Cw=`[^:${oi}]+`,zw=`(?:[^${oi}]+${_r}(?: +[^${oi}]+${_r})*)`,Ow="[a-zA-Z0-9=+/]+",Pw=`(?:${Ow}${_r})+`,tp=`${Iw}${_r}(?:((?:${Cw}: ${zw})+))?${_r}?(${Pw})${Nw}`;class tt{static isPem(e){return typeof e=="string"&&new RegExp(tp,"g").test(e)}static decodeWithHeaders(e){e=e.replace(/\r/g,"");const n=new RegExp(tp,"g"),r=[];let i=null;for(;i=n.exec(e);){const s=i[3].replace(new RegExp(`[${oi}]+`,"g"),""),o={type:i[1],headers:[],rawData:J.FromBase64(s)},c=i[2];if(c){const d=c.split(new RegExp(_r,"g"));let l=null;for(const u of d){const[p,m]=u.split(/:(.*)/);if(m===void 0){if(!l)throw new Error("Cannot parse PEM string. Incorrect header value");l.value+=p.trim()}else l&&o.headers.push(l),l={key:p,value:m.trim()}}l&&o.headers.push(l)}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(!V.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:V.toArrayBuffer(i)}))}):e.forEach(i=>{if(!("type"in i))throw new TypeError("Cannot encode array of PemStruct in PEM format. Not all items of the array are PemStrut");r.push(this.encodeStruct(i))}),r.join(`
141
+ */const Oi="crypto.algorithm";class bw{getAlgorithms(){return Ue.resolveAll(Oi)}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 H({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 Ln="crypto.algorithmProvider";Ue.registerSingleton(Ln,bw);var Qi;const Qe="1.3.36.3.3.2.8.1.1",xf=`${Qe}.1`,kf=`${Qe}.2`,Sf=`${Qe}.3`,Af=`${Qe}.4`,Ef=`${Qe}.5`,If=`${Qe}.6`,Nf=`${Qe}.7`,Cf=`${Qe}.8`,zf=`${Qe}.9`,Of=`${Qe}.10`,Pf=`${Qe}.11`,jf=`${Qe}.12`,Tf=`${Qe}.13`,Rf=`${Qe}.14`,Bf="brainpoolP160r1",Lf="brainpoolP160t1",Uf="brainpoolP192r1",Mf="brainpoolP192t1",Ff="brainpoolP224r1",Vf="brainpoolP224t1",Df="brainpoolP256r1",qf="brainpoolP256t1",Hf="brainpoolP320r1",Kf="brainpoolP320t1",Gf="brainpoolP384r1",Wf="brainpoolP384t1",Jf="brainpoolP512r1",Zf="brainpoolP512t1",ye="ECDSA";let ii=Qi=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 H2;case"sha-256":return K2;case"sha-384":return G2;case"sha-512":return W2}else if("namedCurve"in e){let n="";switch(e.namedCurve){case"P-256":n=Qu;break;case"K-256":n=Qi.SECP256K1;break;case"P-384":n=ef;break;case"P-521":n=tf;break;case Bf:n=xf;break;case Lf:n=kf;break;case Uf:n=Sf;break;case Mf:n=Af;break;case Ff:n=Ef;break;case Vf:n=If;break;case Df:n=Nf;break;case qf:n=Cf;break;case Hf:n=zf;break;case Kf:n=Of;break;case Gf:n=Pf;break;case Wf:n=jf;break;case Jf:n=Tf;break;case Zf:n=Rf;break}if(n)return new H({algorithm:ti,parameters:F.serialize(new dn({namedCurve:n}))})}}return null}toWebAlgorithm(e){switch(e.algorithm){case _l:return{name:ye,hash:{name:"SHA-1"}};case yl:return{name:ye,hash:{name:"SHA-256"}};case wl:return{name:ye,hash:{name:"SHA-384"}};case vl:return{name:ye,hash:{name:"SHA-512"}};case ti:{if(!e.parameters)throw new TypeError("Cannot get required parameters from EC algorithm");switch(F.parse(e.parameters,dn).namedCurve){case Qu:return{name:ye,namedCurve:"P-256"};case Qi.SECP256K1:return{name:ye,namedCurve:"K-256"};case ef:return{name:ye,namedCurve:"P-384"};case tf:return{name:ye,namedCurve:"P-521"};case xf:return{name:ye,namedCurve:Bf};case kf:return{name:ye,namedCurve:Lf};case Sf:return{name:ye,namedCurve:Uf};case Af:return{name:ye,namedCurve:Mf};case Ef:return{name:ye,namedCurve:Ff};case If:return{name:ye,namedCurve:Vf};case Nf:return{name:ye,namedCurve:Df};case Cf:return{name:ye,namedCurve:qf};case zf:return{name:ye,namedCurve:Hf};case Of:return{name:ye,namedCurve:Kf};case Pf:return{name:ye,namedCurve:Gf};case jf:return{name:ye,namedCurve:Wf};case Tf:return{name:ye,namedCurve:Jf};case Rf:return{name:ye,namedCurve:Zf}}}}return null}};ii.SECP256K1="1.3.132.0.10";ii=Qi=f([sa()],ii);Ue.registerSingleton(Oi,ii);const Ng=Symbol("name"),Cg=Symbol("value");class fe{constructor(e,n={},r=""){this[Ng]=e,this[Cg]=r;for(const i in n)this[i]=n[i]}}fe.NAME=Ng;fe.VALUE=Cg;class $w{static toTextObject(e){const n=new fe("Algorithm Identifier",{},gn.toString(e.algorithm));if(e.parameters)switch(e.algorithm){case ti:{const r=new ii().toWebAlgorithm(e);r&&"namedCurve"in r?n["Named Curve"]=r.namedCurve:n.Parameters=e.parameters;break}default:n.Parameters=e.parameters}return n}}class gn{static toString(e){const n=this.items[e];return n||e}}gn.items={[Ws]:"sha1",[mg]:"sha224",[Js]:"sha256",[Zs]:"sha384",[Xs]:"sha512",[Tn]:"rsaEncryption",[Hs]:"sha1WithRSAEncryption",[ew]:"sha224WithRSAEncryption",[Vc]:"sha256WithRSAEncryption",[Ks]:"sha384WithRSAEncryption",[Gs]:"sha512WithRSAEncryption",[ti]:"ecPublicKey",[_l]:"ecdsaWithSHA1",[pg]:"ecdsaWithSHA224",[yl]:"ecdsaWithSHA256",[wl]:"ecdsaWithSHA384",[vl]:"ecdsaWithSHA512",[L2]:"TLS WWW server authentication",[U2]:"TLS WWW client authentication",[M2]:"Code Signing",[F2]:"E-mail Protection",[V2]:"Time Stamping",[D2]:"OCSP Signing",[q2]:"Signed Data"};class Un{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[fe.VALUE];o&&(s=` ${o}`),r.push(`${i}${e[fe.NAME]}:${s}`),i=this.pad(n);for(const c in e){if(typeof c=="symbol")continue;const d=e[c],l=c?`${c}: `:"";if(typeof d=="string"||typeof d=="number"||typeof d=="boolean")r.push(`${i}${l}${d}`);else if(d instanceof Date)r.push(`${i}${l}${d.toUTCString()}`);else if(Array.isArray(d))for(const u of d)u[fe.NAME]=c,r.push(...this.serializeObj(u,n));else if(d instanceof fe)d[fe.NAME]=c,r.push(...this.serializeObj(d,n));else if(V.isBufferSource(d))c?(r.push(`${i}${l}`),r.push(...this.serializeBufferSource(d,n+1))):r.push(...this.serializeBufferSource(d,n));else if("toTextObject"in d){const u=d.toTextObject();u[fe.NAME]=c,r.push(...this.serializeObj(u,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=V.toUint8Array(e),s=[];for(let o=0;o<i.length;){const c=[];for(let d=0;d<16&&o<i.length;d++){d===8&&c.push("");const l=i[o++].toString(16).padStart(2,"0");c.push(l)}s.push(`${r}${c.join(" ")}`)}return s}static serializeAlgorithm(e){return this.algorithmSerializer.toTextObject(e)}}Un.oidSerializer=gn;Un.algorithmSerializer=$w;class mn{constructor(...e){if(e.length===1){const n=e[0];this.rawData=F.serialize(n),this.onInit(n)}else{const n=F.parse(e[0],e[1]);this.rawData=V.toArrayBuffer(e[0]),this.onInit(n)}}equal(e){return e instanceof mn?J0(e.rawData,this.rawData):!1}toString(e="text"){switch(e){case"asn":return F.toString(this.rawData);case"text":return Un.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 fe(this.getTextName(),{},e)}}mn.NAME="ASN";class lt extends mn{constructor(...e){let n;V.isBufferSource(e[0])?n=V.toArrayBuffer(e[0]):n=F.serialize(new at({extnID:e[0],critical:e[1],extnValue:new le(V.toArrayBuffer(e[2]))})),super(n,at)}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[fe.NAME]===lt.NAME&&(e[fe.NAME]=gn.toString(this.type)),e}}var zg;class en{static isCryptoKeyPair(e){return e&&e.privateKey&&e.publicKey}static isCryptoKey(e){return e&&e.usages&&e.type&&e.algorithm&&e.extractable!==void 0}constructor(){this.items=new Map,this[zg]="CryptoProvider",typeof self<"u"&&typeof crypto<"u"?this.set(en.DEFAULT,crypto):typeof global<"u"&&global.crypto&&global.crypto.subtle&&this.set(en.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=en.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(en.DEFAULT,e);return this}}zg=Symbol.toStringTag;en.DEFAULT="default";const Te=new en,xw=/^[0-2](?:\.[1-9][0-9]*)+$/;function kw(t){return new RegExp(xw).test(t)}class Og{constructor(e={}){this.items={};for(const n in e)this.register(n,e[n])}get(e){return this.items[e]||null}findId(e){return kw(e)?e:this.get(e)}register(e,n){this.items[e]=n,this.items[n]=e}}const Ze=new Og;Ze.register("CN","2.5.4.3");Ze.register("L","2.5.4.7");Ze.register("ST","2.5.4.8");Ze.register("O","2.5.4.10");Ze.register("OU","2.5.4.11");Ze.register("C","2.5.4.6");Ze.register("DC","0.9.2342.19200300.100.1.25");Ze.register("E","1.2.840.113549.1.9.1");Ze.register("G","2.5.4.42");Ze.register("I","2.5.4.43");Ze.register("SN","2.5.4.4");Ze.register("T","2.5.4.12");function Sw(t,e){return`\\${J.ToHex(J.FromUtf8String(e)).toUpperCase()}`}function Aw(t){return t.replace(/([,+"\\<>;])/g,"\\$1").replace(/^([ #])/,"\\$1").replace(/([ ]$)/,"\\$1").replace(/([\r\n\t])/,Sw)}class st{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 Og,this.asn=new $e;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 $e?this.asn=e:V.isBufferSource(e)?this.asn=F.parse(e,$e):this.asn=this.fromJSON(e)}getField(e){const n=this.extraNames.findId(e)||Ze.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)||Ze.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)}`:Aw(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 $e,r=/(\d\.[\d.]*\d|[A-Za-z]+)=((?:"")|(?:".*?[^\\]")|(?:[^,+].*?(?:[^\\][,+]))|(?:))([,+])?/g;let i=null,s=",";for(;i=r.exec(`${e},`);){let[,o,c]=i;const d=c[c.length-1];(d===","||d==="+")&&(c=c.slice(0,c.length-1),i[3]=d);const l=i[3];o=this.getTypeOid(o);const u=this.createAttribute(o,c);s==="+"?n[n.length-1].push(u):n.push(new dr([u])),s=l}return n}fromJSON(e){const n=new $e;for(const r of e){const i=new dr;for(const s in r){const o=this.getTypeOid(s),c=r[s];for(const d of c){const l=this.createAttribute(o,d);i.push(l)}}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 Uo({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:st.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 F.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]||Te.get()):r=e[0]||Te.get(),await r.subtle.digest(i,this.toArrayBuffer())}}const Pg="Cannot initialize GeneralName from ASN.1 data.",Xf=`${Pg} Unsupported string format in use.`,Ew=`${Pg} Value doesn't match to GUID regular expression.`,Yf=/^([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})$/i,Qf="1.3.6.1.4.1.311.25.1",ep="1.3.6.1.4.1.311.20.2.3",xa="dns",ka="dn",Sa="email",Aa="ip",Ea="url",Ia="guid",Na="upn",Hi="id";class tn extends mn{constructor(...e){let n;if(e.length===2)switch(e[0]){case ka:{const r=new st(e[1]).toArrayBuffer(),i=F.parse(r,$e);n=new ie({directoryName:i});break}case xa:n=new ie({dNSName:e[1]});break;case Sa:n=new ie({rfc822Name:e[1]});break;case Ia:{const r=new RegExp(Yf,"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 ie({otherName:new Xr({typeId:Qf,value:F.serialize(new le(J.FromHex(i)))})});break}case Aa:n=new ie({iPAddress:e[1]});break;case Hi:n=new ie({registeredID:e[1]});break;case Na:{n=new ie({otherName:new Xr({typeId:ep,value:F.serialize(Jh.toASN(e[1]))})});break}case Ea:n=new ie({uniformResourceIdentifier:e[1]});break;default:throw new Error("Cannot create GeneralName. Unsupported type of the name")}else V.isBufferSource(e[0])?n=F.parse(e[0],ie):n=e[0];super(n)}onInit(e){if(e.dNSName!=null)this.type=xa,this.value=e.dNSName;else if(e.rfc822Name!=null)this.type=Sa,this.value=e.rfc822Name;else if(e.iPAddress!=null)this.type=Aa,this.value=e.iPAddress;else if(e.uniformResourceIdentifier!=null)this.type=Ea,this.value=e.uniformResourceIdentifier;else if(e.registeredID!=null)this.type=Hi,this.value=e.registeredID;else if(e.directoryName!=null)this.type=ka,this.value=new st(e.directoryName).toString();else if(e.otherName!=null)if(e.otherName.typeId===Qf){this.type=Ia;const n=F.parse(e.otherName.value,le),r=new RegExp(Yf,"i").exec(J.ToHex(n));if(!r)throw new Error(Ew);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===ep)this.type=Na,this.value=F.parse(e.otherName.value,Le).toString();else throw new Error(Xf);else throw new Error(Xf)}toJSON(){return{type:this.type,value:this.value}}toTextObject(){let e;switch(this.type){case ka:case xa:case Ia:case Aa:case Hi:case Na:case Ea:e=this.type.toUpperCase();break;case Sa:e="Email";break;default:throw new Error("Unsupported GeneralName type")}let n=this.value;return this.type===Hi&&(n=gn.toString(n)),new fe(e,void 0,n)}}class si extends mn{constructor(e){let n;if(e instanceof De)n=e;else if(Array.isArray(e)){const r=[];for(const i of e)if(i instanceof ie)r.push(i);else{const s=F.parse(new tn(i.type,i.value).rawData,ie);r.push(s)}n=new De(r)}else if(V.isBufferSource(e))n=F.parse(e,De);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 tn(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[fe.NAME]];Array.isArray(i)||(i=[],e[r[fe.NAME]]=i),i.push(r)}return e}}si.NAME="GeneralNames";const Hr="-{5}",oi="\\n",Iw=`[^${oi}]+`,Nw=`${Hr}BEGIN (${Iw}(?=${Hr}))${Hr}`,Cw=`${Hr}END \\1${Hr}`,_r="\\n",zw=`[^:${oi}]+`,Ow=`(?:[^${oi}]+${_r}(?: +[^${oi}]+${_r})*)`,Pw="[a-zA-Z0-9=+/]+",jw=`(?:${Pw}${_r})+`,tp=`${Nw}${_r}(?:((?:${zw}: ${Ow})+))?${_r}?(${jw})${Cw}`;class tt{static isPem(e){return typeof e=="string"&&new RegExp(tp,"g").test(e)}static decodeWithHeaders(e){e=e.replace(/\r/g,"");const n=new RegExp(tp,"g"),r=[];let i=null;for(;i=n.exec(e);){const s=i[3].replace(new RegExp(`[${oi}]+`,"g"),""),o={type:i[1],headers:[],rawData:J.FromBase64(s)},c=i[2];if(c){const d=c.split(new RegExp(_r,"g"));let l=null;for(const u of d){const[p,m]=u.split(/:(.*)/);if(m===void 0){if(!l)throw new Error("Cannot parse PEM string. Incorrect header value");l.value+=p.trim()}else l&&o.headers.push(l),l={key:p,value:m.trim()}}l&&o.headers.push(l)}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(!V.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:V.toArrayBuffer(i)}))}):e.forEach(i=>{if(!("type"in i))throw new TypeError("Cannot encode array of PemStruct in PEM format. Not all items of the array are PemStrut");r.push(this.encodeStruct(i))}),r.join(`
144
144
  `)}else{if(!n)throw new Error("Required argument 'tag' is missed");return this.encodeStruct({type:n,rawData:V.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 l of e.headers)i.push(`${l.key}: ${l.value}`);i.push("")}const s=J.ToBase64(e.rawData);let o,c=0;const d=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(d.push(o),o.length<64)break;return i.push(...d),i.push(`-----END ${r}-----`),i.join(`
145
- `)}}tt.CertificateTag="CERTIFICATE";tt.CrlTag="CRL";tt.CertificateRequestTag="CERTIFICATE REQUEST";tt.PublicKeyTag="PUBLIC KEY";tt.PrivateKeyTag="PRIVATE KEY";class Kt extends mn{static isAsnEncoded(e){return V.isBufferSource(e)||typeof e=="string"}static toArrayBuffer(e){if(typeof e=="string"){if(tt.isPem(e))return tt.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 tt.isPem(n)?tt.decode(n)[0]:J.isHex(n)?J.FromHex(n):J.isBase64(n)?J.FromBase64(n):J.isBase64Url(n)?J.FromBase64Url(n):V.toArrayBuffer(e)}}constructor(...e){Kt.isAsnEncoded(e[0])?super(Kt.toArrayBuffer(e[0]),e[1]):super(e[0])}toString(e="pem"){switch(e){case"pem":return tt.encode(this.rawData,this.tag);default:return super.toString(e)}}}class mt extends Kt{static async create(e,n=Te.get()){if(e instanceof mt)return e;if(en.isCryptoKey(e)){if(e.type!=="public")throw new TypeError("Public key is required");const r=await n.subtle.exportKey("spki",e);return new mt(r)}else{if(e.publicKey)return e.publicKey;if(V.isBufferSource(e))return new mt(e);throw new TypeError("Unsupported PublicKeyType")}}constructor(e){Kt.isAsnEncoded(e)?super(e,gt):super(e),this.tag=tt.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]||Te.get()):n=e[0]||Te.get();let s=this.rawData;const o=F.parse(this.rawData,gt);return o.algorithm.algorithm===qr&&(s=jw(o,s)),n.subtle.importKey("spki",s,i,!0,r)}onInit(e){const n=Ue.resolve(Ln),r=this.algorithm=n.toWebAlgorithm(e.algorithm);switch(e.algorithm.algorithm){case Tn:{const i=F.parse(e.subjectPublicKey,bl),s=V.toUint8Array(i.modulus);r.publicExponent=V.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]||Te.get()):r=e[0]||Te.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=Te.get()):n=e[0]:e.length===2?(r=e[0],n=e[1]):n=Te.get();const i=F.parse(this.rawData,gt);return await n.subtle.digest(r,i.subjectPublicKey)}toTextObject(){const e=this.toTextObjectEmpty(),n=F.parse(this.rawData,gt);switch(e.Algorithm=Un.serializeAlgorithm(n.algorithm),n.algorithm.algorithm){case ti:e["EC Point"]=n.subjectPublicKey;break;case Tn:default:e["Raw Data"]=n.subjectPublicKey}return e}}function jw(t,e){return t.algorithm=new H({algorithm:Tn,parameters:null}),e=F.serialize(t),e}class ai extends lt{static async create(e,n=!1,r=Te.get()){if("name"in e&&"serialNumber"in e)return new ai(e,n);const s=await(await mt.create(e,r)).getKeyIdentifier(r);return new ai(J.ToHex(s),n)}constructor(...e){if(V.isBufferSource(e[0]))super(e[0]);else if(typeof e[0]=="string"){const n=new kn({keyIdentifier:new nl(J.FromHex(e[0]))});super(oc,e[1],F.serialize(n))}else{const n=e[0],r=n.name instanceof si?F.parse(n.name.rawData,De):n.name,i=new kn({authorityCertIssuer:r,authorityCertSerialNumber:J.FromHex(n.serialNumber)});super(oc,e[1],F.serialize(i))}}onInit(e){super.onInit(e);const n=F.parse(e.extnValue,kn);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=F.parse(this.value,kn);return n.authorityCertIssuer&&(e["Authority Issuer"]=new si(n.authorityCertIssuer).toTextObject()),n.authorityCertSerialNumber&&(e["Authority Serial Number"]=n.authorityCertSerialNumber),n.keyIdentifier&&(e[""]=n.keyIdentifier),e}}ai.NAME="Authority Key Identifier";class Sl extends lt{constructor(...e){if(V.isBufferSource(e[0])){super(e[0]);const n=F.parse(this.value,As);this.ca=n.cA,this.pathLength=n.pathLenConstraint}else{const n=new As({cA:e[0],pathLenConstraint:e[1]});super(Yh,e[2],F.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}}Sl.NAME="Basic Constraints";var np;(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"})(np||(np={}));class Al extends lt{constructor(...e){if(V.isBufferSource(e[0])){super(e[0]);const n=F.parse(this.value,Cs);this.usages=n.map(r=>r)}else{const n=new Cs(e[0]);super(tg,e[1],F.serialize(n)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.usages.map(n=>gn.toString(n)).join(", "),e}}Al.NAME="Extended Key Usages";var no;(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"})(no||(no={}));class El extends lt{constructor(...e){if(V.isBufferSource(e[0])){super(e[0]);const n=F.parse(this.value,$a);this.usages=n.toNumber()}else{const n=new $a(e[0]);super(ng,e[1],F.serialize(n)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue(),n=F.parse(this.value,$a);return e[""]=n.toJSON().join(", "),e}}El.NAME="Key Usages";class Oi extends lt{static async create(e,n=!1,r=Te.get()){const s=await(await mt.create(e,r)).getKeyIdentifier(r);return new Oi(J.ToHex(s),n)}constructor(...e){if(V.isBufferSource(e[0])){super(e[0]);const n=F.parse(this.value,rn);this.keyId=J.ToHex(n)}else{const n=typeof e[0]=="string"?J.FromHex(e[0]):e[0],r=new rn(n);super(og,e[1],F.serialize(r)),this.keyId=J.ToHex(n)}}toTextObject(){const e=this.toTextObjectWithoutValue(),n=F.parse(this.value,rn);return e[""]=n,e}}Oi.NAME="Subject Key Identifier";class jg extends lt{constructor(...e){V.isBufferSource(e[0])?super(e[0]):super(sg,e[1],new si(e[0]||[]).rawData)}onInit(e){super.onInit(e);const n=F.parse(e.extnValue,bc);this.names=new si(n)}toTextObject(){const e=this.toTextObjectWithoutValue(),n=this.names.toTextObject();for(const r in n)e[r]=n[r];return e}}jg.NAME="Subject Alternative Name";class ut{static register(e,n){this.items.set(e,n)}static create(e){const n=new lt(e),r=this.items.get(n.type);return r?new r(e):n}}ut.items=new Map;class Tg extends lt{constructor(...e){var n;if(V.isBufferSource(e[0])){super(e[0]);const r=F.parse(this.value,Is);this.policies=r.map(i=>i.policyIdentifier)}else{const r=e[0],i=(n=e[1])!==null&&n!==void 0?n:!1,s=new Is(r.map(o=>new Mo({policyIdentifier:o})));super(Qh,i,F.serialize(s)),this.policies=r}}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map(n=>new fe("",{},gn.toString(n))),e}}Tg.NAME="Certificate Policies";ut.register(Qh,Tg);class Rg extends lt{constructor(...e){var n;if(V.isBufferSource(e[0]))super(e[0]);else if(Array.isArray(e[0])&&typeof e[0][0]=="string"){const i=e[0].map(o=>new kr({distributionPoint:new zn({fullName:[new ie({uniformResourceIdentifier:o})]})})),s=new rr(i);super(uc,e[1],F.serialize(s))}else{const r=new rr(e[0]);super(uc,e[1],F.serialize(r))}(n=this.distributionPoints)!==null&&n!==void 0||(this.distributionPoints=[])}onInit(e){super.onInit(e);const n=F.parse(e.extnValue,rr);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 tn(s).toString()).join(", ")),n.reasons&&(i.Reasons=n.reasons.toString()),n.cRLIssuer&&(i["CRL Issuer"]=n.cRLIssuer.map(s=>s.toString()).join(", ")),i}),e}}Rg.NAME="CRL Distribution Points";class Bg extends lt{constructor(...e){var n,r,i,s;if(V.isBufferSource(e[0]))super(e[0]);else if(e[0]instanceof er){const o=new er(e[0]);super(sc,e[1],F.serialize(o))}else{const o=e[0],c=new er;Ki(c,o,Lu,"ocsp"),Ki(c,o,Uu,"caIssuers"),Ki(c,o,Mu,"timeStamping"),Ki(c,o,Fu,"caRepository"),super(sc,e[1],F.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=[],F.parse(e.extnValue,er).forEach(r=>{switch(r.accessMethod){case Lu:this.ocsp.push(new tn(r.accessLocation));break;case Uu:this.caIssuers.push(new tn(r.accessLocation));break;case Mu:this.timeStamping.push(new tn(r.accessLocation));break;case Fu:this.caRepository.push(new tn(r.accessLocation));break}})}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ocsp.length&&Hi(e,"OCSP",this.ocsp),this.caIssuers.length&&Hi(e,"CA Issuers",this.caIssuers),this.timeStamping.length&&Hi(e,"Time Stamping",this.timeStamping),this.caRepository.length&&Hi(e,"CA Repository",this.caRepository),e}}Bg.NAME="Authority Info Access";function Hi(t,e,n){if(n.length===1)t[e]=n[0].toTextObject();else{const r=new fe("");n.forEach((i,s)=>{const o=i.toTextObject(),c=`${o[fe.NAME]} ${s+1}`;let d=r[c];Array.isArray(d)||(d=[],r[c]=d),d.push(o)}),t[e]=r}}function Ki(t,e,n,r){const i=e[r];i&&(Array.isArray(i)?i:[i]).forEach(o=>{typeof o=="string"&&(o=new tn("url",o)),t.push(new wi({accessMethod:n,accessLocation:F.parse(o.rawData,ie)}))})}class zr extends mn{constructor(...e){let n;if(V.isBufferSource(e[0]))n=V.toArrayBuffer(e[0]);else{const r=e[0],i=Array.isArray(e[1])?e[1].map(s=>V.toArrayBuffer(s)):[];n=F.serialize(new Dt({type:r,values:i}))}super(n,Dt)}onInit(e){this.type=e.type,this.values=e.values}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Value=this.values.map(n=>new fe("",{"":n})),e}toTextObjectWithoutValue(){const e=this.toTextObjectEmpty();return e[fe.NAME]===zr.NAME&&(e[fe.NAME]=gn.toString(this.type)),e}}zr.NAME="Attribute";class Lg extends zr{constructor(...e){var n;if(V.isBufferSource(e[0]))super(e[0]);else{const r=new eo({printableString:e[0]});super(Ig,[F.serialize(r)])}(n=this.password)!==null&&n!==void 0||(this.password="")}onInit(e){if(super.onInit(e),this.values[0]){const n=F.parse(this.values[0],eo);this.password=n.toString()}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[fe.VALUE]=this.password,e}}Lg.NAME="Challenge Password";class Il extends zr{constructor(...e){var n;if(V.isBufferSource(e[0]))super(e[0]);else{const r=e[0],i=new an;for(const s of r)i.push(F.parse(s.rawData,at));super(kl,[F.serialize(i)])}(n=this.items)!==null&&n!==void 0||(this.items=[])}onInit(e){if(super.onInit(e),this.values[0]){const n=F.parse(this.values[0],an);this.items=n.map(r=>ut.create(F.serialize(r)))}}toTextObject(){const e=this.toTextObjectWithoutValue(),n=this.items.map(r=>r.toTextObject());for(const r of n)e[r[fe.NAME]]=r;return e}}Il.NAME="Extensions";class da{static register(e,n){this.items.set(e,n)}static create(e){const n=new zr(e),r=this.items.get(n.type);return r?new r(e):n}}da.items=new Map;const Pi="crypto.signatureFormatter";class Tw{toAsnSignature(e,n){return V.toArrayBuffer(n)}toWebSignature(e,n){return V.toArrayBuffer(n)}}var Qi;let ud=Qi=class{static createPssParams(e,n){const r=Qi.getHashAlgorithm(e);return r?new Bn({hashAlgorithm:r,maskGenAlgorithm:new H({algorithm:ea,parameters:F.serialize(r)}),saltLength:n}):null}static getHashAlgorithm(e){const n=Ue.resolve(Ln);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 H({algorithm:qs,parameters:null});case"sha-256":return new H({algorithm:Vc,parameters:null});case"sha-384":return new H({algorithm:Hs,parameters:null});case"sha-512":return new H({algorithm:Ks,parameters:null})}}else return new H({algorithm:Tn,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 H({algorithm:qr,parameters:F.serialize(n)})}else return new H({algorithm:qr,parameters:null})}return null}toWebAlgorithm(e){switch(e.algorithm){case Tn:return{name:"RSASSA-PKCS1-v1_5"};case qs:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case Vc:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case Hs:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case Ks:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}};case qr:if(e.parameters){const n=F.parse(e.parameters,Bn);return{name:"RSA-PSS",hash:Ue.resolve(Ln).toWebAlgorithm(n.hashAlgorithm),saltLength:n.saltLength}}else return{name:"RSA-PSS"}}return null}};ud=Qi=f([ia()],ud);Ue.registerSingleton(zi,ud);let fd=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"sha-1":return new H({algorithm:Gs});case"sha-256":return new H({algorithm:Ws});case"sha-384":return new H({algorithm:Js});case"sha-512":return new H({algorithm:Zs})}return null}toWebAlgorithm(e){switch(e.algorithm){case Gs:return{name:"SHA-1"};case Ws:return{name:"SHA-256"};case Js:return{name:"SHA-384"};case Zs:return{name:"SHA-512"}}return null}};fd=f([ia()],fd);Ue.registerSingleton(zi,fd);class ot{addPadding(e,n){const r=V.toUint8Array(n),i=new Uint8Array(e);return i.set(r,e-r.length),i}removePadding(e,n=!1){let r=V.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=ot.namedCurveSize.get(r)||ot.defaultNamedCurveSize,s=new Ds,o=V.toUint8Array(n);return s.r=this.removePadding(o.slice(0,i),!0),s.s=this.removePadding(o.slice(i,i+i),!0),F.serialize(s)}return null}toWebSignature(e,n){if(e.name==="ECDSA"){const r=F.parse(n,Ds),i=e.namedCurve,s=ot.namedCurveSize.get(i)||ot.defaultNamedCurveSize,o=this.addPadding(s,this.removePadding(r.r)),c=this.addPadding(s,this.removePadding(r.s));return Wy(o,c)}return null}}ot.namedCurveSize=new Map;ot.defaultNamedCurveSize=32;const Ca="1.3.101.110",rp="1.3.101.111",za="1.3.101.112",ip="1.3.101.113";let pd=class{toAsnAlgorithm(e){let n=null;switch(e.name.toLowerCase()){case"ed25519":n=za;break;case"x25519":n=Ca;break;case"eddsa":switch(e.namedCurve.toLowerCase()){case"ed25519":n=za;break;case"ed448":n=ip;break}break;case"ecdh-es":switch(e.namedCurve.toLowerCase()){case"x25519":n=Ca;break;case"x448":n=rp;break}}return n?new H({algorithm:n}):null}toWebAlgorithm(e){switch(e.algorithm){case za:return{name:"Ed25519"};case ip:return{name:"EdDSA",namedCurve:"Ed448"};case Ca:return{name:"X25519"};case rp:return{name:"ECDH-ES",namedCurve:"X448"}}return null}};pd=f([ia()],pd);Ue.registerSingleton(zi,pd);class Rw extends Kt{constructor(e){Kt.isAsnEncoded(e)?super(e,ri):super(e),this.tag=tt.CertificateRequestTag}onInit(e){this.tbs=F.serialize(e.certificationRequestInfo),this.publicKey=new mt(e.certificationRequestInfo.subjectPKInfo);const n=Ue.resolve(Ln);this.signatureAlgorithm=n.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signature,this.attributes=e.certificationRequestInfo.attributes.map(i=>da.create(F.serialize(i)));const r=this.getAttribute(kl);this.extensions=[],r instanceof Il&&(this.extensions=r.items),this.subjectName=new st(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=Te.get()){const n={...this.publicKey.algorithm,...this.signatureAlgorithm},r=await this.publicKey.export(n,["verify"],e),i=Ue.resolveAll(Pi).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=F.parse(this.rawData,ri),r=n.certificationRequestInfo,i=new fe("",{Version:`${On[r.version]} (${r.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){const s=new fe("");for(const o of this.attributes){const c=o.toTextObject();s[c[fe.NAME]]=c}i.Attributes=s}return e.Data=i,e.Signature=new fe("",{Algorithm:Un.serializeAlgorithm(n.signatureAlgorithm),"":n.signature}),e}}Rw.NAME="PKCS#10 Certificate Request";class Nl extends Kt{constructor(e){Kt.isAsnEncoded(e)?super(e,Pn):super(e),this.tag=tt.CertificateTag}onInit(e){const n=e.tbsCertificate;this.tbs=F.serialize(n),this.serialNumber=J.ToHex(n.serialNumber),this.subjectName=new st(n.subject),this.subject=new st(n.subject).toString(),this.issuerName=new st(n.issuer),this.issuer=this.issuerName.toString();const r=Ue.resolve(Ln);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=>ut.create(F.serialize(o)))),this.publicKey=new mt(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=Te.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 mt)r={...s.algorithm,...this.signatureAlgorithm},i=await s.export(r,["verify"],n);else if(V.isBufferSource(s)){const l=new mt(s);r={...l.algorithm,...this.signatureAlgorithm},i=await l.export(r,["verify"],n)}else r={...s.algorithm,...this.signatureAlgorithm},i=s}catch{return!1}const o=Ue.resolveAll(Pi).reverse();let c=null;for(const l of o)if(c=l.toWebSignature(r,this.signature),c)break;if(!c)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");const d=await n.subtle.verify(this.signatureAlgorithm,i,c,this.tbs);if(e.signatureOnly)return d;{const u=(e.date||new Date).getTime();return d&&this.notBefore.getTime()<u&&u<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=Te.get()),await n.subtle.digest(r,this.rawData)}async isSelfSigned(e=Te.get()){return this.subject===this.issuer&&await this.verify({signatureOnly:!0},e)}toTextObject(){const e=this.toTextObjectEmpty(),n=F.parse(this.rawData,Pn),r=n.tbsCertificate,i=new fe("",{Version:`${On[r.version]} (${r.version})`,"Serial Number":r.serialNumber,"Signature Algorithm":Un.serializeAlgorithm(r.signature),Issuer:this.issuer,Validity:new fe("",{"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 fe("");for(const o of this.extensions){const c=o.toTextObject();s[c[fe.NAME]]=c}i.Extensions=s}return e.Data=i,e.Signature=new fe("",{Algorithm:Un.serializeAlgorithm(n.signatureAlgorithm),"":n.signatureValue}),e}}Nl.NAME="Certificate";class Bw{static async createSelfSigned(e,n=Te.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=Te.get()){var r;let i;e.publicKey instanceof mt?i=e.publicKey.rawData:"publicKey"in e.publicKey?i=e.publicKey.publicKey.rawData:V.isBufferSource(e.publicKey)?i=e.publicKey:i=await n.subtle.exportKey("spki",e.publicKey);const s=e.serialNumber?V.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),d=new Pn({tbsCertificate:new rt({version:On.v3,serialNumber:s,validity:new vi({notBefore:o,notAfter:c}),extensions:new an(((r=e.extensions)===null||r===void 0?void 0:r.map(v=>F.parse(v.rawData,at)))||[]),subjectPublicKeyInfo:F.parse(i,gt)})});if(e.subject){const v=e.subject instanceof st?e.subject:new st(e.subject);d.tbsCertificate.subject=F.parse(v.toArrayBuffer(),$e)}if(e.issuer){const v=e.issuer instanceof st?e.issuer:new st(e.issuer);d.tbsCertificate.issuer=F.parse(v.toArrayBuffer(),$e)}const l={hash:"SHA-256"},u="signingKey"in e?{...l,...e.signingAlgorithm,...e.signingKey.algorithm}:{...l,...e.signingAlgorithm},p=Ue.resolve(Ln);d.tbsCertificate.signature=d.signatureAlgorithm=p.toAsnAlgorithm(u);const m=F.serialize(d.tbsCertificate),w="signingKey"in e?await n.subtle.sign(u,e.signingKey,m):e.signature,h=Ue.resolveAll(Pi).reverse();let _=null;for(const v of h)if(_=v.toAsnSignature(u,w),_)break;if(!_)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");return d.signatureValue=_,new Nl(F.serialize(d))}}var sp;(function(t){t[t.unspecified=0]="unspecified",t[t.keyCompromise=1]="keyCompromise",t[t.cACompromise=2]="cACompromise",t[t.affiliationChanged=3]="affiliationChanged",t[t.superseded=4]="superseded",t[t.cessationOfOperation=5]="cessationOfOperation",t[t.certificateHold=6]="certificateHold",t[t.removeFromCRL=8]="removeFromCRL",t[t.privilegeWithdrawn=9]="privilegeWithdrawn",t[t.aACompromise=10]="aACompromise"})(sp||(sp={}));ut.register(Yh,Sl);ut.register(tg,Al);ut.register(ng,El);ut.register(og,Oi);ut.register(oc,ai);ut.register(sg,jg);ut.register(uc,Rg);ut.register(sc,Bg);da.register(Ig,Lg);da.register(kl,Il);Ue.registerSingleton(Pi,Tw);Ue.registerSingleton(Pi,ot);ot.namedCurveSize.set("P-256",32);ot.namedCurveSize.set("K-256",32);ot.namedCurveSize.set("P-384",48);ot.namedCurveSize.set("P-521",66);async function hd(t){const e={name:"RSASSA-PKCS1-v1_5",hash:"SHA-256",publicExponent:new Uint8Array([1,0,1]),modulusLength:2048},n=await crypto.subtle.generateKey(e,!0,["sign","verify"]),r=xe(),i=Ga(new TextEncoder().encode(r)),s=await Bw.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 Sl(!0,2,!0),new Al(["1.3.6.1.5.5.7.3.1"],!0),new El(no.keyCertSign|no.cRLSign,!0),await Oi.create(n.publicKey)]}),o=await crypto.subtle.exportKey("pkcs8",n.privateKey),c=s.toString("pem"),d=await Uw(s),l=Ga(await s.getThumbprint()),u=Lw("PRIVATE",o);return{kid:s.serialNumber,cert:c,thumbprint:l,fingerprint:d,pkcs7:u}}function Lw(t,e){const n=W1.encode(new Uint8Array(e));let r=`-----BEGIN ${t} KEY-----\r
145
+ `)}}tt.CertificateTag="CERTIFICATE";tt.CrlTag="CRL";tt.CertificateRequestTag="CERTIFICATE REQUEST";tt.PublicKeyTag="PUBLIC KEY";tt.PrivateKeyTag="PRIVATE KEY";class Kt extends mn{static isAsnEncoded(e){return V.isBufferSource(e)||typeof e=="string"}static toArrayBuffer(e){if(typeof e=="string"){if(tt.isPem(e))return tt.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 tt.isPem(n)?tt.decode(n)[0]:J.isHex(n)?J.FromHex(n):J.isBase64(n)?J.FromBase64(n):J.isBase64Url(n)?J.FromBase64Url(n):V.toArrayBuffer(e)}}constructor(...e){Kt.isAsnEncoded(e[0])?super(Kt.toArrayBuffer(e[0]),e[1]):super(e[0])}toString(e="pem"){switch(e){case"pem":return tt.encode(this.rawData,this.tag);default:return super.toString(e)}}}class mt extends Kt{static async create(e,n=Te.get()){if(e instanceof mt)return e;if(en.isCryptoKey(e)){if(e.type!=="public")throw new TypeError("Public key is required");const r=await n.subtle.exportKey("spki",e);return new mt(r)}else{if(e.publicKey)return e.publicKey;if(V.isBufferSource(e))return new mt(e);throw new TypeError("Unsupported PublicKeyType")}}constructor(e){Kt.isAsnEncoded(e)?super(e,gt):super(e),this.tag=tt.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]||Te.get()):n=e[0]||Te.get();let s=this.rawData;const o=F.parse(this.rawData,gt);return o.algorithm.algorithm===qr&&(s=Tw(o,s)),n.subtle.importKey("spki",s,i,!0,r)}onInit(e){const n=Ue.resolve(Ln),r=this.algorithm=n.toWebAlgorithm(e.algorithm);switch(e.algorithm.algorithm){case Tn:{const i=F.parse(e.subjectPublicKey,bl),s=V.toUint8Array(i.modulus);r.publicExponent=V.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]||Te.get()):r=e[0]||Te.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=Te.get()):n=e[0]:e.length===2?(r=e[0],n=e[1]):n=Te.get();const i=F.parse(this.rawData,gt);return await n.subtle.digest(r,i.subjectPublicKey)}toTextObject(){const e=this.toTextObjectEmpty(),n=F.parse(this.rawData,gt);switch(e.Algorithm=Un.serializeAlgorithm(n.algorithm),n.algorithm.algorithm){case ti:e["EC Point"]=n.subjectPublicKey;break;case Tn:default:e["Raw Data"]=n.subjectPublicKey}return e}}function Tw(t,e){return t.algorithm=new H({algorithm:Tn,parameters:null}),e=F.serialize(t),e}class ai extends lt{static async create(e,n=!1,r=Te.get()){if("name"in e&&"serialNumber"in e)return new ai(e,n);const s=await(await mt.create(e,r)).getKeyIdentifier(r);return new ai(J.ToHex(s),n)}constructor(...e){if(V.isBufferSource(e[0]))super(e[0]);else if(typeof e[0]=="string"){const n=new kn({keyIdentifier:new nl(J.FromHex(e[0]))});super(oc,e[1],F.serialize(n))}else{const n=e[0],r=n.name instanceof si?F.parse(n.name.rawData,De):n.name,i=new kn({authorityCertIssuer:r,authorityCertSerialNumber:J.FromHex(n.serialNumber)});super(oc,e[1],F.serialize(i))}}onInit(e){super.onInit(e);const n=F.parse(e.extnValue,kn);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=F.parse(this.value,kn);return n.authorityCertIssuer&&(e["Authority Issuer"]=new si(n.authorityCertIssuer).toTextObject()),n.authorityCertSerialNumber&&(e["Authority Serial Number"]=n.authorityCertSerialNumber),n.keyIdentifier&&(e[""]=n.keyIdentifier),e}}ai.NAME="Authority Key Identifier";class Sl extends lt{constructor(...e){if(V.isBufferSource(e[0])){super(e[0]);const n=F.parse(this.value,Es);this.ca=n.cA,this.pathLength=n.pathLenConstraint}else{const n=new Es({cA:e[0],pathLenConstraint:e[1]});super(Yh,e[2],F.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}}Sl.NAME="Basic Constraints";var np;(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"})(np||(np={}));class Al extends lt{constructor(...e){if(V.isBufferSource(e[0])){super(e[0]);const n=F.parse(this.value,zs);this.usages=n.map(r=>r)}else{const n=new zs(e[0]);super(tg,e[1],F.serialize(n)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.usages.map(n=>gn.toString(n)).join(", "),e}}Al.NAME="Extended Key Usages";var ro;(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"})(ro||(ro={}));class El extends lt{constructor(...e){if(V.isBufferSource(e[0])){super(e[0]);const n=F.parse(this.value,$a);this.usages=n.toNumber()}else{const n=new $a(e[0]);super(ng,e[1],F.serialize(n)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue(),n=F.parse(this.value,$a);return e[""]=n.toJSON().join(", "),e}}El.NAME="Key Usages";class Pi extends lt{static async create(e,n=!1,r=Te.get()){const s=await(await mt.create(e,r)).getKeyIdentifier(r);return new Pi(J.ToHex(s),n)}constructor(...e){if(V.isBufferSource(e[0])){super(e[0]);const n=F.parse(this.value,rn);this.keyId=J.ToHex(n)}else{const n=typeof e[0]=="string"?J.FromHex(e[0]):e[0],r=new rn(n);super(og,e[1],F.serialize(r)),this.keyId=J.ToHex(n)}}toTextObject(){const e=this.toTextObjectWithoutValue(),n=F.parse(this.value,rn);return e[""]=n,e}}Pi.NAME="Subject Key Identifier";class jg extends lt{constructor(...e){V.isBufferSource(e[0])?super(e[0]):super(sg,e[1],new si(e[0]||[]).rawData)}onInit(e){super.onInit(e);const n=F.parse(e.extnValue,bc);this.names=new si(n)}toTextObject(){const e=this.toTextObjectWithoutValue(),n=this.names.toTextObject();for(const r in n)e[r]=n[r];return e}}jg.NAME="Subject Alternative Name";class ut{static register(e,n){this.items.set(e,n)}static create(e){const n=new lt(e),r=this.items.get(n.type);return r?new r(e):n}}ut.items=new Map;class Tg extends lt{constructor(...e){var n;if(V.isBufferSource(e[0])){super(e[0]);const r=F.parse(this.value,Ns);this.policies=r.map(i=>i.policyIdentifier)}else{const r=e[0],i=(n=e[1])!==null&&n!==void 0?n:!1,s=new Ns(r.map(o=>new Fo({policyIdentifier:o})));super(Qh,i,F.serialize(s)),this.policies=r}}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map(n=>new fe("",{},gn.toString(n))),e}}Tg.NAME="Certificate Policies";ut.register(Qh,Tg);class Rg extends lt{constructor(...e){var n;if(V.isBufferSource(e[0]))super(e[0]);else if(Array.isArray(e[0])&&typeof e[0][0]=="string"){const i=e[0].map(o=>new kr({distributionPoint:new zn({fullName:[new ie({uniformResourceIdentifier:o})]})})),s=new rr(i);super(uc,e[1],F.serialize(s))}else{const r=new rr(e[0]);super(uc,e[1],F.serialize(r))}(n=this.distributionPoints)!==null&&n!==void 0||(this.distributionPoints=[])}onInit(e){super.onInit(e);const n=F.parse(e.extnValue,rr);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 tn(s).toString()).join(", ")),n.reasons&&(i.Reasons=n.reasons.toString()),n.cRLIssuer&&(i["CRL Issuer"]=n.cRLIssuer.map(s=>s.toString()).join(", ")),i}),e}}Rg.NAME="CRL Distribution Points";class Bg extends lt{constructor(...e){var n,r,i,s;if(V.isBufferSource(e[0]))super(e[0]);else if(e[0]instanceof er){const o=new er(e[0]);super(sc,e[1],F.serialize(o))}else{const o=e[0],c=new er;Gi(c,o,Lu,"ocsp"),Gi(c,o,Uu,"caIssuers"),Gi(c,o,Mu,"timeStamping"),Gi(c,o,Fu,"caRepository"),super(sc,e[1],F.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=[],F.parse(e.extnValue,er).forEach(r=>{switch(r.accessMethod){case Lu:this.ocsp.push(new tn(r.accessLocation));break;case Uu:this.caIssuers.push(new tn(r.accessLocation));break;case Mu:this.timeStamping.push(new tn(r.accessLocation));break;case Fu:this.caRepository.push(new tn(r.accessLocation));break}})}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ocsp.length&&Ki(e,"OCSP",this.ocsp),this.caIssuers.length&&Ki(e,"CA Issuers",this.caIssuers),this.timeStamping.length&&Ki(e,"Time Stamping",this.timeStamping),this.caRepository.length&&Ki(e,"CA Repository",this.caRepository),e}}Bg.NAME="Authority Info Access";function Ki(t,e,n){if(n.length===1)t[e]=n[0].toTextObject();else{const r=new fe("");n.forEach((i,s)=>{const o=i.toTextObject(),c=`${o[fe.NAME]} ${s+1}`;let d=r[c];Array.isArray(d)||(d=[],r[c]=d),d.push(o)}),t[e]=r}}function Gi(t,e,n,r){const i=e[r];i&&(Array.isArray(i)?i:[i]).forEach(o=>{typeof o=="string"&&(o=new tn("url",o)),t.push(new vi({accessMethod:n,accessLocation:F.parse(o.rawData,ie)}))})}class zr extends mn{constructor(...e){let n;if(V.isBufferSource(e[0]))n=V.toArrayBuffer(e[0]);else{const r=e[0],i=Array.isArray(e[1])?e[1].map(s=>V.toArrayBuffer(s)):[];n=F.serialize(new Dt({type:r,values:i}))}super(n,Dt)}onInit(e){this.type=e.type,this.values=e.values}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Value=this.values.map(n=>new fe("",{"":n})),e}toTextObjectWithoutValue(){const e=this.toTextObjectEmpty();return e[fe.NAME]===zr.NAME&&(e[fe.NAME]=gn.toString(this.type)),e}}zr.NAME="Attribute";class Lg extends zr{constructor(...e){var n;if(V.isBufferSource(e[0]))super(e[0]);else{const r=new to({printableString:e[0]});super(Ig,[F.serialize(r)])}(n=this.password)!==null&&n!==void 0||(this.password="")}onInit(e){if(super.onInit(e),this.values[0]){const n=F.parse(this.values[0],to);this.password=n.toString()}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[fe.VALUE]=this.password,e}}Lg.NAME="Challenge Password";class Il extends zr{constructor(...e){var n;if(V.isBufferSource(e[0]))super(e[0]);else{const r=e[0],i=new an;for(const s of r)i.push(F.parse(s.rawData,at));super(kl,[F.serialize(i)])}(n=this.items)!==null&&n!==void 0||(this.items=[])}onInit(e){if(super.onInit(e),this.values[0]){const n=F.parse(this.values[0],an);this.items=n.map(r=>ut.create(F.serialize(r)))}}toTextObject(){const e=this.toTextObjectWithoutValue(),n=this.items.map(r=>r.toTextObject());for(const r of n)e[r[fe.NAME]]=r;return e}}Il.NAME="Extensions";class la{static register(e,n){this.items.set(e,n)}static create(e){const n=new zr(e),r=this.items.get(n.type);return r?new r(e):n}}la.items=new Map;const ji="crypto.signatureFormatter";class Rw{toAsnSignature(e,n){return V.toArrayBuffer(n)}toWebSignature(e,n){return V.toArrayBuffer(n)}}var es;let ud=es=class{static createPssParams(e,n){const r=es.getHashAlgorithm(e);return r?new Bn({hashAlgorithm:r,maskGenAlgorithm:new H({algorithm:ta,parameters:F.serialize(r)}),saltLength:n}):null}static getHashAlgorithm(e){const n=Ue.resolve(Ln);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 H({algorithm:Hs,parameters:null});case"sha-256":return new H({algorithm:Vc,parameters:null});case"sha-384":return new H({algorithm:Ks,parameters:null});case"sha-512":return new H({algorithm:Gs,parameters:null})}}else return new H({algorithm:Tn,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=es.createPssParams(e.hash,e.saltLength);if(!n)throw new Error("Cannot create PSS parameters");return new H({algorithm:qr,parameters:F.serialize(n)})}else return new H({algorithm:qr,parameters:null})}return null}toWebAlgorithm(e){switch(e.algorithm){case Tn:return{name:"RSASSA-PKCS1-v1_5"};case Hs:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case Vc:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case Ks:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case Gs:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}};case qr:if(e.parameters){const n=F.parse(e.parameters,Bn);return{name:"RSA-PSS",hash:Ue.resolve(Ln).toWebAlgorithm(n.hashAlgorithm),saltLength:n.saltLength}}else return{name:"RSA-PSS"}}return null}};ud=es=f([sa()],ud);Ue.registerSingleton(Oi,ud);let fd=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"sha-1":return new H({algorithm:Ws});case"sha-256":return new H({algorithm:Js});case"sha-384":return new H({algorithm:Zs});case"sha-512":return new H({algorithm:Xs})}return null}toWebAlgorithm(e){switch(e.algorithm){case Ws:return{name:"SHA-1"};case Js:return{name:"SHA-256"};case Zs:return{name:"SHA-384"};case Xs:return{name:"SHA-512"}}return null}};fd=f([sa()],fd);Ue.registerSingleton(Oi,fd);class ot{addPadding(e,n){const r=V.toUint8Array(n),i=new Uint8Array(e);return i.set(r,e-r.length),i}removePadding(e,n=!1){let r=V.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=ot.namedCurveSize.get(r)||ot.defaultNamedCurveSize,s=new qs,o=V.toUint8Array(n);return s.r=this.removePadding(o.slice(0,i),!0),s.s=this.removePadding(o.slice(i,i+i),!0),F.serialize(s)}return null}toWebSignature(e,n){if(e.name==="ECDSA"){const r=F.parse(n,qs),i=e.namedCurve,s=ot.namedCurveSize.get(i)||ot.defaultNamedCurveSize,o=this.addPadding(s,this.removePadding(r.r)),c=this.addPadding(s,this.removePadding(r.s));return Jy(o,c)}return null}}ot.namedCurveSize=new Map;ot.defaultNamedCurveSize=32;const Ca="1.3.101.110",rp="1.3.101.111",za="1.3.101.112",ip="1.3.101.113";let pd=class{toAsnAlgorithm(e){let n=null;switch(e.name.toLowerCase()){case"ed25519":n=za;break;case"x25519":n=Ca;break;case"eddsa":switch(e.namedCurve.toLowerCase()){case"ed25519":n=za;break;case"ed448":n=ip;break}break;case"ecdh-es":switch(e.namedCurve.toLowerCase()){case"x25519":n=Ca;break;case"x448":n=rp;break}}return n?new H({algorithm:n}):null}toWebAlgorithm(e){switch(e.algorithm){case za:return{name:"Ed25519"};case ip:return{name:"EdDSA",namedCurve:"Ed448"};case Ca:return{name:"X25519"};case rp:return{name:"ECDH-ES",namedCurve:"X448"}}return null}};pd=f([sa()],pd);Ue.registerSingleton(Oi,pd);class Bw extends Kt{constructor(e){Kt.isAsnEncoded(e)?super(e,ri):super(e),this.tag=tt.CertificateRequestTag}onInit(e){this.tbs=F.serialize(e.certificationRequestInfo),this.publicKey=new mt(e.certificationRequestInfo.subjectPKInfo);const n=Ue.resolve(Ln);this.signatureAlgorithm=n.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signature,this.attributes=e.certificationRequestInfo.attributes.map(i=>la.create(F.serialize(i)));const r=this.getAttribute(kl);this.extensions=[],r instanceof Il&&(this.extensions=r.items),this.subjectName=new st(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=Te.get()){const n={...this.publicKey.algorithm,...this.signatureAlgorithm},r=await this.publicKey.export(n,["verify"],e),i=Ue.resolveAll(ji).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=F.parse(this.rawData,ri),r=n.certificationRequestInfo,i=new fe("",{Version:`${On[r.version]} (${r.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){const s=new fe("");for(const o of this.attributes){const c=o.toTextObject();s[c[fe.NAME]]=c}i.Attributes=s}return e.Data=i,e.Signature=new fe("",{Algorithm:Un.serializeAlgorithm(n.signatureAlgorithm),"":n.signature}),e}}Bw.NAME="PKCS#10 Certificate Request";class Nl extends Kt{constructor(e){Kt.isAsnEncoded(e)?super(e,Pn):super(e),this.tag=tt.CertificateTag}onInit(e){const n=e.tbsCertificate;this.tbs=F.serialize(n),this.serialNumber=J.ToHex(n.serialNumber),this.subjectName=new st(n.subject),this.subject=new st(n.subject).toString(),this.issuerName=new st(n.issuer),this.issuer=this.issuerName.toString();const r=Ue.resolve(Ln);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=>ut.create(F.serialize(o)))),this.publicKey=new mt(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=Te.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 mt)r={...s.algorithm,...this.signatureAlgorithm},i=await s.export(r,["verify"],n);else if(V.isBufferSource(s)){const l=new mt(s);r={...l.algorithm,...this.signatureAlgorithm},i=await l.export(r,["verify"],n)}else r={...s.algorithm,...this.signatureAlgorithm},i=s}catch{return!1}const o=Ue.resolveAll(ji).reverse();let c=null;for(const l of o)if(c=l.toWebSignature(r,this.signature),c)break;if(!c)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");const d=await n.subtle.verify(this.signatureAlgorithm,i,c,this.tbs);if(e.signatureOnly)return d;{const u=(e.date||new Date).getTime();return d&&this.notBefore.getTime()<u&&u<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=Te.get()),await n.subtle.digest(r,this.rawData)}async isSelfSigned(e=Te.get()){return this.subject===this.issuer&&await this.verify({signatureOnly:!0},e)}toTextObject(){const e=this.toTextObjectEmpty(),n=F.parse(this.rawData,Pn),r=n.tbsCertificate,i=new fe("",{Version:`${On[r.version]} (${r.version})`,"Serial Number":r.serialNumber,"Signature Algorithm":Un.serializeAlgorithm(r.signature),Issuer:this.issuer,Validity:new fe("",{"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 fe("");for(const o of this.extensions){const c=o.toTextObject();s[c[fe.NAME]]=c}i.Extensions=s}return e.Data=i,e.Signature=new fe("",{Algorithm:Un.serializeAlgorithm(n.signatureAlgorithm),"":n.signatureValue}),e}}Nl.NAME="Certificate";class Lw{static async createSelfSigned(e,n=Te.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=Te.get()){var r;let i;e.publicKey instanceof mt?i=e.publicKey.rawData:"publicKey"in e.publicKey?i=e.publicKey.publicKey.rawData:V.isBufferSource(e.publicKey)?i=e.publicKey:i=await n.subtle.exportKey("spki",e.publicKey);const s=e.serialNumber?V.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),d=new Pn({tbsCertificate:new rt({version:On.v3,serialNumber:s,validity:new bi({notBefore:o,notAfter:c}),extensions:new an(((r=e.extensions)===null||r===void 0?void 0:r.map(v=>F.parse(v.rawData,at)))||[]),subjectPublicKeyInfo:F.parse(i,gt)})});if(e.subject){const v=e.subject instanceof st?e.subject:new st(e.subject);d.tbsCertificate.subject=F.parse(v.toArrayBuffer(),$e)}if(e.issuer){const v=e.issuer instanceof st?e.issuer:new st(e.issuer);d.tbsCertificate.issuer=F.parse(v.toArrayBuffer(),$e)}const l={hash:"SHA-256"},u="signingKey"in e?{...l,...e.signingAlgorithm,...e.signingKey.algorithm}:{...l,...e.signingAlgorithm},p=Ue.resolve(Ln);d.tbsCertificate.signature=d.signatureAlgorithm=p.toAsnAlgorithm(u);const m=F.serialize(d.tbsCertificate),w="signingKey"in e?await n.subtle.sign(u,e.signingKey,m):e.signature,h=Ue.resolveAll(ji).reverse();let _=null;for(const v of h)if(_=v.toAsnSignature(u,w),_)break;if(!_)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");return d.signatureValue=_,new Nl(F.serialize(d))}}var sp;(function(t){t[t.unspecified=0]="unspecified",t[t.keyCompromise=1]="keyCompromise",t[t.cACompromise=2]="cACompromise",t[t.affiliationChanged=3]="affiliationChanged",t[t.superseded=4]="superseded",t[t.cessationOfOperation=5]="cessationOfOperation",t[t.certificateHold=6]="certificateHold",t[t.removeFromCRL=8]="removeFromCRL",t[t.privilegeWithdrawn=9]="privilegeWithdrawn",t[t.aACompromise=10]="aACompromise"})(sp||(sp={}));ut.register(Yh,Sl);ut.register(tg,Al);ut.register(ng,El);ut.register(og,Pi);ut.register(oc,ai);ut.register(sg,jg);ut.register(uc,Rg);ut.register(sc,Bg);la.register(Ig,Lg);la.register(kl,Il);Ue.registerSingleton(ji,Rw);Ue.registerSingleton(ji,ot);ot.namedCurveSize.set("P-256",32);ot.namedCurveSize.set("K-256",32);ot.namedCurveSize.set("P-384",48);ot.namedCurveSize.set("P-521",66);async function hd(t){const e={name:"RSASSA-PKCS1-v1_5",hash:"SHA-256",publicExponent:new Uint8Array([1,0,1]),modulusLength:2048},n=await crypto.subtle.generateKey(e,!0,["sign","verify"]),r=xe(),i=Ga(new TextEncoder().encode(r)),s=await Lw.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 Sl(!0,2,!0),new Al(["1.3.6.1.5.5.7.3.1"],!0),new El(ro.keyCertSign|ro.cRLSign,!0),await Pi.create(n.publicKey)]}),o=await crypto.subtle.exportKey("pkcs8",n.privateKey),c=s.toString("pem"),d=await Mw(s),l=Ga(await s.getThumbprint()),u=Uw("PRIVATE",o);return{kid:s.serialNumber,cert:c,thumbprint:l,fingerprint:d,pkcs7:u}}function Uw(t,e){const n=J1.encode(new Uint8Array(e));let r=`-----BEGIN ${t} KEY-----\r
146
146
  `,i=0;for(;i<n.length;)i+64<=n.length?r+=n.substr(i,64)+`\r
147
147
  `:r+=n.substr(i)+`\r
148
148
  `,i+=64;return r+=`-----END ${t} KEY-----\r
149
- `,r}async function Uw(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 Ga(await P0(s))}const Mw=1e3*60*60*24,Fw=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(Ka)}},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:Ka}},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()+Mw).toISOString()});const n=await hd({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 hd({name:`CN=${t.env.ORGANIZATION_NAME}`});return await t.env.data.keys.create(r),t.text("OK")}),Vw=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(Id)}},description:"List of users"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{email:n}=t.req.valid("query"),i=(await Md(t.env.data.users,e,n)).filter(s=>!s.linked_to);return t.json(i)}),Dw=un.extend({clients:a.z.array(bn)}),qw=new a.OpenAPIHono().openapi(a.createRoute({tags:["clients"],method:"get",path:"/",request:{query:on,headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:a.z.union([Dw,a.z.array(bn)])}},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"),d=(await t.env.data.applications.list(e,{page:n,per_page:r,include_totals:i,sort:br(s),q:o})).applications;return i?t.json({clients:d,start:0,limit:10,length:d.length}):t.json(d)}).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:bn}},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(gs.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:bn}},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(gs.shape)}}},headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:a.z.object(bn.shape)}},description:"An application"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),r={...n,id:n.id||xe(),client_secret:n.client_secret||xe()},i=await t.env.data.applications.create(e,r);return t.json(i,{status:201})});a.z.object({start:a.z.number(),limit:a.z.number(),length:a.z.number()});uo.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 Hw=un.extend({tenants:a.z.array(tr)}),Kw=new a.OpenAPIHono().openapi(a.createRoute({tags:["tenants"],method:"get",path:"/",request:{query:on},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:a.z.union([a.z.array(tr),Hw])}},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:br(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:tr}},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(_s.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(_s.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"tenant/json":{schema:tr}},description:"An tenant"}}}),async t=>{const e=t.req.valid("json"),n=await t.env.data.tenants.create(e);return t.json(n,{status:201})}),Gw=un.extend({logs:a.z.array(ws)}),Ww=new a.OpenAPIHono().openapi(a.createRoute({tags:["logs"],method:"get",path:"/",request:{query:on,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(ws),Gw])}},description:"List of log rows"}}}),async t=>{const{page:e,per_page:n,include_totals:r,sort:i,q:s}=t.req.valid("query"),{"tenant-id":o}=t.req.valid("header"),c=await t.env.data.logs.list(o,{page:e,per_page:n,include_totals:r,sort:br(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:ws}},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)}),Jw=un.extend({hooks:a.z.array(Yn)}),Zw=new a.OpenAPIHono().openapi(a.createRoute({tags:["hooks"],method:"get",path:"/",request:{query:on,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(Yn),Jw])}},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:br(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(ys.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Yn}},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(ys.shape).omit({hook_id:!0}).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Yn.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:Yn}},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")}),Xw=un.extend({connections:a.z.array(Qt)}),Yw=new a.OpenAPIHono().openapi(a.createRoute({tags:["connections"],method:"get",path:"/",request:{query:on,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(Qt),Xw])}},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:br(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:Qt}},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(ms.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:Qt}},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(ms.shape)}}},headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Qt}},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})}),Qw=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:Wi}},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(Wi.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(Wi.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 op=!1;function Ug(t){t.use(async(e,n)=>(op||(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"}}}}),op=!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 ev(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 tv(t,e){const r=new TextEncoder().encode([e.raw.header,e.raw.payload].join(".")),i=new Uint8Array(Array.from(e.signature).map(d=>d.charCodeAt(0))),o=(await ev(t.env)).find(d=>d.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 nv(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 Mg(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 d=e.req.header("authorization")||"",[l,u]=d.split(" ");if((l==null?void 0:l.toLowerCase())!=="bearer"||!u)throw new N(401,{message:"Missing bearer token"});const p=nv(u);if(!p||!await tv(e,p))throw new N(403,{message:"Invalid JWT signature"});e.set("user_id",p.payload.sub),e.set("user",p.payload);const m=p.payload.permissions||[],w=((o=p.payload.scope)==null?void 0:o.split(" "))||[];if(c.length&&!(c.some(h=>m.includes(h))||c.some(h=>w.includes(h))))throw new N(403,{message:"Unauthorized"})}return await n()}}const rv=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:Ji}},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(Ji.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(Ji.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")}),iv=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:po}},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})}),sv=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:Od}},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")}),ov=new a.OpenAPIHono().openapi(a.createRoute({tags:["custom-domains"],method:"get",path:"/",request:{query:on,headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:a.z.array(Yt)}},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:Yt}},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(Yt.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:Yt}},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(Cd.shape)}}},headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Yt}},description:"The created custom domain"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),r=await t.env.data.customDomains.create(e,n);return t.json(r,{status:201})}).openapi(a.createRoute({tags:["custom-domains"],method:"post",path:"/{id}/verify",request:{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:Yt}},description:"The custom domain"}}}),async()=>{throw new N(501,{message:"Not implemented"})});function Cl(t,e){const n={};for(const[r,i]of Object.entries(e)){const s={};for(const[o,c]of Object.entries(i))typeof c=="function"?s[o]=async(...d)=>{const l=performance.now();try{const u=await c(...d),m=performance.now()-l,w=t.res.headers.get("Server-Timing")||"",h=w?`${w}, ${r}-${o};dur=${m.toFixed(2)}`:`${r}-${o};dur=${m.toFixed(2)}`;return t.res.headers.set("Server-Timing",h),u}catch(u){const m=performance.now()-l,w=t.res.headers.get("Server-Timing")||"",h=w?`${w}, ${r}-${o}-error;dur=${m.toFixed(2)}`:`${r}-${o}-error;dur=${m.toFixed(2)}`;throw t.res.headers.set("Server-Timing",h),u}}:s[o]=c;n[r]=s}return n}async function zl(t,e){const n=t.req.header("x-forwarded-host");if(n){const i=await t.env.data.customDomains.getByDomain(n);if(i)return t.set("tenant_id",i.tenant_id),t.set("custom_domain",n),await e()}const r=t.req.header("host");if(r){const i=r.split(".");if(i.length>1&&typeof i[0]=="string"){const s=i[0];await t.env.data.tenants.get(s)&&t.set("tenant_id",s)}}return await e()}const vn=class vn{constructor(){te(this,"cacheStore",new Map)}static getInstance(){return vn.instance||(vn.instance=new vn),vn.instance}set(e,n,r){if(r<=0)return;const i=Date.now()+r;this.cacheStore.set(e,{value:n,expiresAt:i})}get(e){const n=this.cacheStore.get(e);if(n){if(Date.now()>n.expiresAt){this.cacheStore.delete(e);return}return n.value}}delete(e){this.cacheStore.delete(e)}getKeysByPrefix(e){return Array.from(this.cacheStore.keys()).filter(n=>n.startsWith(e))}clear(){this.cacheStore.clear()}};te(vn,"instance");let gd=vn;function av(t,e,n){try{return`${t}:${e}:${JSON.stringify(n)}`}catch{return`${t}:${e}:${Date.now()}-${Math.random()}`}}function Ol(t,e){const n=e.cache||gd.getInstance(),r=e.defaultTtl,i=e.customTtls||{},s=new Set(e.excludeMethods||[]),o=e.maxItems||0,c=e.cacheEntities||[],d=c.length===0,l=new Set(c),u={};for(const[p,m]of Object.entries(t)){const w=d||l.has(p),h={};for(const[_,v]of Object.entries(m))if(typeof v=="function"){if(!w){h[_]=v;continue}const k=`${p}:${_}`;if(s.has(k)){h[_]=v;continue}const I=i[k]||r,O=["create","update","remove","delete","set","used"].includes(_);h[_]=async(...L)=>{if(O){const ke=await Promise.resolve(n.getKeysByPrefix(`${p}:`));for(const Ee of ke)await Promise.resolve(n.delete(Ee));return await v.apply(m,L)}const Y=av(p,_,L),oe=await Promise.resolve(n.get(Y));if(oe!==void 0)return oe;const ae=await v.apply(m,L);if(await n.set(Y,ae,I),o>0){const ke=await Promise.resolve(n.getKeysByPrefix(""));if(ke.length>o){const Ee=ke.slice(0,ke.length-o);for(const ze of Ee)await Promise.resolve(n.delete(ze))}}return ae}}else h[_]=v;u[p]=h}return u}function cv(t){const e=new a.OpenAPIHono;e.use(d0({origin:r=>{var i;return r&&(i=t.allowedOrigins)!=null&&i.includes(r)?r:""},allowHeaders:["Tenant-Id","Content-Type","Content-Range","Auth0-Client","Authorization","Range","Upgrade-Insecure-Requests"],allowMethods:["POST","PUT","GET","DELETE","PATCH","OPTIONS"],exposeHeaders:["Content-Length","Content-Range"],maxAge:600,credentials:!0})),Ug(e),e.use(async(r,i)=>{const s=yo(r,t.dataAdapter),o=Ol(s,{defaultTtl:0,cacheEntities:["tenants","connections","clients"]});return r.env.data=Cl(r,o),i()}),e.use(zl).use(Mg(e));const n=e.route("/branding",j1).route("/custom-domains",ov).route("/email/providers",rv).route("/users",Dy).route("/keys",Fw).route("/users-by-email",Vw).route("/clients",qw).route("/tenants",Kw).route("/logs",Ww).route("/hooks",Zw).route("/connections",Yw).route("/prompts",Qw).route("/sessions",iv).route("/refresh_tokens",sv);return n.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Management api"},security:[{oauth2:["openid","email","profile"]}]}),n}function dv(t,e){Object.keys(e).forEach(n=>{const r=e[n];r!=null&&r.length&&t.searchParams.set(n,r)})}var ap;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(ap||(ap={}));var cp;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(cp||(cp={}));function lv(t){return Vg(t,uv,ci.Include)}function Fg(t){return Vg(t,fv,ci.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===ci.Include&&(r+="=")}return r}const uv="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",fv="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";var ci;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(ci||(ci={}));var dp;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(dp||(dp={}));class pv{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 lp=new pv;function St(t,e){return(t<<32-e|t>>>e)>>>0}function hv(t){const e=new gv;return e.update(t),e.digest()}class gv{constructor(){te(this,"blockSize",64);te(this,"size",32);te(this,"blocks",new Uint8Array(64));te(this,"currentBlockSize",0);te(this,"H",new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]));te(this,"l",0n);te(this,"w",new Uint32Array(64))}update(e){if(this.l+=BigInt(e.byteLength)*8n,this.currentBlockSize+e.byteLength<64){this.blocks.set(e,this.currentBlockSize),this.currentBlockSize+=e.byteLength;return}let n=0;if(this.currentBlockSize>0){const r=e.slice(0,64-this.currentBlockSize);this.blocks.set(r,this.currentBlockSize),this.process(),n+=r.byteLength,this.currentBlockSize=0}for(;n+64<=e.byteLength;){const r=e.slice(n,n+64);this.blocks.set(r),this.process(),n+=64}if(e.byteLength-n>0){const r=e.slice(n);this.blocks.set(r),this.currentBlockSize=r.byteLength}}digest(){this.blocks[this.currentBlockSize]=128,this.currentBlockSize+=1,64-this.currentBlockSize<8&&(this.blocks.fill(0,this.currentBlockSize),this.process(),this.currentBlockSize=0),this.blocks.fill(0,this.currentBlockSize),lp.putUint64(this.blocks,this.l,this.blockSize-8),this.process();const e=new Uint8Array(32);for(let n=0;n<8;n++)lp.putUint32(e,this.H[n],n*4);return e}process(){for(let l=0;l<16;l++)this.w[l]=(this.blocks[l*4]<<24|this.blocks[l*4+1]<<16|this.blocks[l*4+2]<<8|this.blocks[l*4+3])>>>0;for(let l=16;l<64;l++){const u=(St(this.w[l-2],17)^St(this.w[l-2],19)^this.w[l-2]>>>10)>>>0,p=(St(this.w[l-15],7)^St(this.w[l-15],18)^this.w[l-15]>>>3)>>>0;this.w[l]=u+this.w[l-7]+p+this.w[l-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],d=this.H[7];for(let l=0;l<64;l++){const u=(St(s,6)^St(s,11)^St(s,25))>>>0,p=(s&o^~s&c)>>>0,m=d+u+p+mv[l]+this.w[l]|0,w=(St(e,2)^St(e,13)^St(e,22))>>>0,h=(e&n^e&r^n&r)>>>0,_=w+h|0;d=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]=d+this.H[7]|0}}const mv=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 _v{constructor(e){te(this,"data");this.data=e}tokenType(){if("token_type"in this.data&&typeof this.data.token_type=="string")return this.data.token_type;throw new Error("Missing or invalid 'token_type' field")}accessToken(){if("access_token"in this.data&&typeof this.data.access_token=="string")return this.data.access_token;throw new Error("Missing or invalid 'access_token' field")}accessTokenExpiresInSeconds(){if("expires_in"in this.data&&typeof this.data.expires_in=="number")return this.data.expires_in;throw new Error("Missing or invalid 'expires_in' field")}accessTokenExpiresAt(){return new Date(Date.now()+this.accessTokenExpiresInSeconds()*1e3)}hasRefreshToken(){return"refresh_token"in this.data&&typeof this.data.refresh_token=="string"}refreshToken(){if("refresh_token"in this.data&&typeof this.data.refresh_token=="string")return this.data.refresh_token;throw new Error("Missing or invalid 'refresh_token' field")}hasScopes(){return"scope"in this.data&&typeof this.data.scope=="string"}scopes(){if("scope"in this.data&&typeof this.data.scope=="string")return this.data.scope.split(" ");throw new Error("Missing or invalid 'scope' field")}idToken(){if("id_token"in this.data&&typeof this.data.id_token=="string")return this.data.id_token;throw new Error("Missing or invalid field 'id_token'")}}function yv(t){const e=hv(new TextEncoder().encode(t));return Fg(e)}function wv(){const t=new Uint8Array(32);return crypto.getRandomValues(t),Fg(t)}function Kr(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 Oa(t,e){const n=new TextEncoder().encode(`${t}:${e}`);return lv(n)}async function ro(t){let e;try{e=await fetch(t)}catch(n){throw new qg(n)}if(e.status===400||e.status===401){let n;try{n=await e.json()}catch{throw new es(e.status)}if(typeof n!="object"||n===null)throw new ir(e.status,n);let r;try{r=Dg(n)}catch{throw new ir(e.status,n)}throw r}if(e.status===200){let n;try{n=await e.json()}catch{throw new es(e.status)}if(typeof n!="object"||n===null)throw new ir(e.status,n);return new _v(n)}throw e.body!==null&&await e.body.cancel(),new es(e.status)}async function vv(t){let e;try{e=await fetch(t)}catch(n){throw new qg(n)}if(e.status===400||e.status===401){let n;try{n=await e.json()}catch{throw new ir(e.status,null)}if(typeof n!="object"||n===null)throw new ir(e.status,n);let r;try{r=Dg(n)}catch{throw new ir(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 es(e.status)}function Dg(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 bv(e,n,r,i)}class qg extends Error{constructor(e){super("Failed to send request",{cause:e})}}class bv extends Error{constructor(n,r,i,s){super(`OAuth request error: ${n}`);te(this,"code");te(this,"description");te(this,"uri");te(this,"state");this.code=n,this.description=r,this.uri=i,this.state=s}}class es extends Error{constructor(n){super("Unexpected error response");te(this,"status");this.status=n}}class ir extends Error{constructor(n,r){super("Unexpected error response body");te(this,"status");te(this,"data");this.status=n,this.data=r}}class Pl{constructor(e,n,r){te(this,"clientId");te(this,"clientPassword");te(this,"redirectURI");this.clientId=e,this.clientPassword=n,this.redirectURI=r}createAuthorizationURL(e,n,r){const i=new URL(e);return i.searchParams.set("response_type","code"),i.searchParams.set("client_id",this.clientId),this.redirectURI!==null&&i.searchParams.set("redirect_uri",this.redirectURI),i.searchParams.set("state",n),r.length>0&&i.searchParams.set("scope",r.join(" ")),i}createAuthorizationURLWithPKCE(e,n,r,i,s){const 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===di.S256){const c=yv(i);o.searchParams.set("code_challenge_method","S256"),o.searchParams.set("code_challenge",c)}else r===di.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=Kr(e,i);if(this.clientPassword!==null){const c=Oa(this.clientId,this.clientPassword);s.headers.set("Authorization",`Basic ${c}`)}return await ro(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=Kr(e,i);if(this.clientPassword!==null){const c=Oa(this.clientId,this.clientPassword);s.headers.set("Authorization",`Basic ${c}`)}return await ro(s)}async revokeToken(e,n){const r=new URLSearchParams;r.set("token",n),this.clientPassword===null&&r.set("client_id",this.clientId);const i=Kr(e,r);if(this.clientPassword!==null){const s=Oa(this.clientId,this.clientPassword);i.headers.set("Authorization",`Basic ${s}`)}await vv(i)}}var di;(function(t){t[t.S256=0]="S256",t[t.Plain=1]="Plain"})(di||(di={}));var up;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(up||(up={}));var fp;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(fp||(fp={}));function Gr(t){return $v(t,xv,io.None)}function $v(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===io.Include&&(r+="=")}return r}const xv="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";var io;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(io||(io={}));var pp;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(pp||(pp={}));function kv(t,e,n){const r=Gr(new TextEncoder().encode(t)),i=Gr(new TextEncoder().encode(e)),s=Gr(n);return r+"."+i+"."+s}function Sv(t,e){const n=Gr(new TextEncoder().encode(t)),r=Gr(new TextEncoder().encode(e)),i=n+"."+r;return new TextEncoder().encode(i)}const Av="https://appleid.apple.com/auth/authorize",Ev="https://appleid.apple.com/auth/token";class Hg{constructor(e,n,r,i,s){te(this,"clientId");te(this,"teamId");te(this,"keyId");te(this,"pkcs8PrivateKey");te(this,"redirectURI");this.clientId=e,this.teamId=n,this.keyId=r,this.pkcs8PrivateKey=i,this.redirectURI=s}createAuthorizationURL(e,n){const r=new URL(Av);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=Kr(Ev,n);return await ro(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,Sv(r,i)));return kv(r,i,s)}}const Iv="https://www.facebook.com/v16.0/dialog/oauth",Nv="https://graph.facebook.com/v16.0/oauth/access_token";class Kg{constructor(e,n,r){te(this,"clientId");te(this,"clientSecret");te(this,"redirectURI");this.clientId=e,this.clientSecret=n,this.redirectURI=r}createAuthorizationURL(e,n){const r=new URL(Iv);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=Kr(Nv,n);return await ro(r)}}const Cv="https://accounts.google.com/o/oauth2/v2/auth",hp="https://oauth2.googleapis.com/token",zv="https://oauth2.googleapis.com/revoke";let Gg=class{constructor(e,n,r){te(this,"client");this.client=new Pl(e,n,r)}createAuthorizationURL(e,n,r){return this.client.createAuthorizationURLWithPKCE(Cv,e,di.S256,n,r)}async validateAuthorizationCode(e,n){return await this.client.validateAuthorizationCode(hp,e,n)}async refreshAccessToken(e){return await this.client.refreshAccessToken(hp,e,[])}async revokeToken(e){await this.client.revokeToken(zv,e)}};const la=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();la.omit({iat:!0,auth_time:!0,nonce:!0,acr:!0,amr:!0,azp:!0,at_hash:!0,c_hash:!0});function Ov(t){return t.ISSUER}function ct(t){return t.UNIVERSAL_LOGIN_URL||`${t.ISSUER}u/`}function je(t){return t.OAUTH_API_URL||t.ISSUER}function Wg(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 Pv(t,e){var d,l;const{options:n,keyArray:r}=Wg(e),i=new Hg(n.client_id,n.team_id,n.kid,r,`${je(t.env)}callback`),s=xe(),o=await i.createAuthorizationURL(s,((d=n.scope)==null?void 0:d.split(" "))||["name","email"]);return(((l=n.scope)==null?void 0:l.split(" "))||["name","email"]).some(u=>["email","name"].includes(u))&&o.searchParams.set("response_mode","form_post"),{redirectUrl:o.href,code:s}}async function jv(t,e,n){const{options:r,keyArray:i}=Wg(e),o=await new Hg(r.client_id,r.team_id,r.kid,i,`${je(t.env)}callback`).validateAuthorizationCode(n),c=jd(o.idToken());if(!c)throw new Error("Invalid ID token");const d=la.parse(c.payload);return{sub:d.sub,email:d.email,given_name:d.given_name,family_name:d.family_name,name:d.name,picture:d.picture,locale:d.locale}}const Tv=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:Pv,validateAuthorizationCodeAndGetUser:jv},Symbol.toStringTag,{value:"Module"}));async function Rv(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 Kg(n.client_id,n.client_secret,`${je(t.env)}callback`),i=xe();return{redirectUrl:r.createAuthorizationURL(i,((o=n.scope)==null?void 0:o.split(" "))||["email"]).href,code:i}}async function Bv(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 Kg(r.client_id,r.client_secret,`${je(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 Lv=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:Rv,validateAuthorizationCodeAndGetUser:Bv},Symbol.toStringTag,{value:"Module"}));async function Uv(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 Gg(n.client_id,n.client_secret,`${je(t.env)}callback`),i=xe(),s=wv();return{redirectUrl:r.createAuthorizationURL(i,s,((c=n.scope)==null?void 0:c.split(" "))??["email","profile"]).href,code:i,codeVerifier:s}}async function Mv(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 Gg(i.client_id,i.client_secret,`${je(t.env)}callback`).validateAuthorizationCode(n,r),c=jd(o.idToken());if(!c)throw new Error("Invalid ID token");const d=la.parse(c.payload);return{sub:d.sub,email:d.email,given_name:d.given_name,family_name:d.family_name,name:d.name,picture:d.picture,locale:d.locale}}const Fv=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:Uv,validateAuthorizationCodeAndGetUser:Mv},Symbol.toStringTag,{value:"Module"}));async function Vv(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 Pl(n.client_id,n.client_secret,`${je(t.env)}callback`),i=xe(),s=r.createAuthorizationURL("https://api.vipps.no/access-management-1.0/access/oauth2/auth",i,((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 Dv(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 Pl(r.client_id,r.client_secret,`${je(t.env)}callback`).validateAuthorizationCode("https://api.vipps.no/access-management-1.0/access/oauth2/token",n,null),o=jd(s.idToken());if(!o)throw new Error("Invalid ID token");const c=la.parse(o.payload);if(typeof c.msn!="string")throw new Error("msn not available in id token");const d=await fetch("https://api.vipps.no/vipps-userinfo-api/userinfo",{headers:{Authorization:`Bearer ${s.accessToken()}`,"Merchant-Serial-Number":c.msn}});if(!d.ok)throw new N(400,{message:"Failed to get user from vipps"});return await d.json()}const qv=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:Vv,validateAuthorizationCodeAndGetUser:Dv},Symbol.toStringTag,{value:"Module"}));function Jg(t,e){const n=t.env.STRATEGIES||{},i={apple:Tv,facebook:Lv,"google-oauth2":Fv,vipps:qv,...n}[e];if(!i)throw new Error(`Strategy ${e} not found`);return i}async function ji(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 u;const d=(u=s.connections)==null?void 0:u.find(p=>p.name===c.name);if(!(d!=null&&d.options))return c;const l=Qt.parse({...d||{},...c});return l.options=Nd.passthrough().parse({...d.options||{},...c.options}),l}).filter(c=>c);return{...n,web_origins:[...(r==null?void 0:r.web_origins)||[],...n.web_origins||[],`${ct(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||[],`${ct(t)}info`],connections:o,tenant:{...(r==null?void 0:r.tenant)||{},...n.tenant}}}async function Hv(t,e,n,r){if(!r.state)throw new N(400,{message:"State not found"});const i=e.connections.find(d=>d.name===n);if(!i){t.set("client_id",e.id);const d=we(t,{type:ge.FAILED_LOGIN,description:"Connection not found"});throw await t.env.data.logs.create(e.tenant.id,d),new N(403,{message:"Connection Not Found"})}let s=await t.env.data.loginSessions.get(e.tenant.id,r.state);s||(s=await t.env.data.loginSessions.create(e.tenant.id,{expires_at:new Date(Date.now()+or*1e3).toISOString(),authParams:r,csrf_token:xe(),...Ot(t.req)}));const c=await Jg(t,i.strategy).getRedirect(t,i);return await t.env.data.codes.create(e.tenant.id,{login_id:s.id,code_id:c.code,code_type:"oauth2_state",connection_id:i.id,code_verifier:c.codeVerifier,expires_at:new Date(Date.now()+s_*1e3).toISOString()}),t.redirect(c.redirectUrl)}async function gp(t,{code:e,state:n}){var h;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.loginSessions.get(t.var.tenant_id||"",i.login_id);if(!s)throw new N(403,{message:"Session not found"});if(s.authorization_url){const _=new URL(s.authorization_url).hostname,v=t.var.custom_domain||t.req.header("host")||"";if(_!==v&&_){const k=new URL(`https://${_}/callback`);return k.searchParams.set("state",n),k.searchParams.set("code",e),new Response("Redirecting",{status:307,headers:{location:k.toString()}})}}const o=await ji(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 _=we(t,{type:ge.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 _=we(t,{type:ge.FAILED_LOGIN,description:"Redirect URI not defined"});throw await r.data.logs.create(o.tenant.id,_),new N(403,{message:"Redirect URI not defined"})}const l=await Jg(t,c.strategy).validateAuthorizationCodeAndGetUser(t,c,e,i.code_verifier),{sub:u,...p}=l;t.set("user_id",u);const m=((h=l.email)==null?void 0:h.toLocaleLowerCase())||`${c.name}.${u}@${new URL(t.env.ISSUER).hostname}`;t.set("username",m);const w=await vo(t,{client:o,username:m,provider:c.strategy,connection:c.name,userId:u,profileData:p,isSocial:!0,ip:t.req.header("x-real-ip")});return pn(t,{client:o,authParams:s.authParams,loginSession:s,user:w})}async function mp(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.loginSessions.get(t.var.tenant_id,o.login_id);if(!c)throw new N(400,{message:"Login not found"});const{redirect_uri:d}=c.authParams;if(!d)throw new N(400,{message:"Redirect uri not found"});const l=we(t,{type:ge.FAILED_LOGIN,description:`Failed connection login: ${i} ${n}, ${r}`});It(t,t.env.data.logs.create(t.var.tenant_id,l));const u=new URL(d);return dv(u,{error:n,error_description:r,error_reason:s,error_code:i,state:c.authParams.state}),t.redirect(`${ct(t.env)}login/identifier?state=${c.id}&error=${n}`)}const Kv=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 mp(t,e,r,i,s,o);if(!n)throw new N(400,{message:"Code is required"});return gp(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 mp(t,e,r,i,s,o);if(!n)throw new N(400,{message:"Code is required"});return gp(t,{code:n,state:e})});function Zg(t,e=[],n={}){try{const r=new URL(t);return e.some(i=>{try{return Gv(r,new URL(i),n.allowPathWildcards)}catch{return!1}})}catch{return!1}}function Gv(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}const Wv=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(!Zg(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 d=bs(r.tenant.id,o);if(d){const l=await t.env.data.sessions.get(r.tenant.id,d);if(l){const u=await t.env.data.users.get(r.tenant.id,l.user_id);u&&(t.set("user_id",u.user_id),t.set("connection",u.connection));const p=await t.env.data.refreshTokens.list(r.tenant.id,{q:`session_id=${d}`,page:0,per_page:100,include_totals:!1});await Promise.all(p.refresh_tokens.map(m=>t.env.data.refreshTokens.remove(r.tenant.id,m.id))),await t.env.data.sessions.update(r.tenant.id,d,{revoked_at:new Date().toISOString()})}}}const c=we(t,{type:ge.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":l_(r.tenant.id,t.req.header("host")),location:s}})}),_p=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()}),Jv=new a.OpenAPIHono().openapi(a.createRoute({tags:["oauth2"],method:"get",path:"/",request:{},security:[{Bearer:["openid"]}],responses:{200:{content:{"application/json":{schema:_p}},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(_p.parse({...e,sub:e.user_id}))}),Zv=new a.OpenAPIHono().openapi(a.createRoute({tags:["well known"],method:"get",path:"/jwks.json",request:{},responses:{200:{content:{"application/json":{schema:y0}},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 Nl(r.cert).publicKey.export(),o=await crypto.subtle.exportKey("jwk",s);return zd.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=${Vi}, stale-while-revalidate=${Vi*2}, stale-if-error=86400`}})}).openapi(a.createRoute({tags:["well known"],method:"get",path:"/openid-configuration",request:{},responses:{200:{content:{"application/json":{schema:Ha}},description:"List of tenants"}}}),async t=>{const e=Ha.parse({issuer:Ov(t.env),authorization_endpoint:`${je(t.env)}authorize`,token_endpoint:`${je(t.env)}oauth/token`,device_authorization_endpoint:`${je(t.env)}oauth/device/code`,userinfo_endpoint:`${je(t.env)}userinfo`,mfa_challenge_endpoint:`${je(t.env)}mfa/challenge`,jwks_uri:`${je(t.env)}.well-known/jwks.json`,registration_endpoint:`${je(t.env)}oidc/register`,revocation_endpoint:`${je(t.env)}oauth/revoke`,scopes_supported:["openid","profile","offline_access","name","given_name","family_name","nickname","email","email_verified","picture","created_at","identities","phone","address"],response_types_supported:["code","token","id_token","code token","code id_token","token id_token","code token id_token"],code_challenge_methods_supported:["S256","plain"],response_modes_supported:["query","fragment","form_post"],subject_types_supported:["public"],id_token_signing_alg_values_supported:["RS256"],token_endpoint_auth_methods_supported:["client_secret_basic","client_secret_post"],claims_supported:["aud","auth_time","created_at","email","email_verified","exp","family_name","given_name","iat","identities","iss","name","nickname","phone_number","picture","sub"],request_uri_parameter_supported:!1,request_parameter_supported:!1,token_endpoint_auth_signing_alg_values_supported:["RS256","RS384","PS256"]});return t.json(e,{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${Vi}, stale-while-revalidate=${Vi*2}, stale-if-error=86400`}})});function ts(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 Xg=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 Xv(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&&!ts(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 _o(t,{authParams:r,client:n});return t.json(i)}const Yv=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 Qv(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.loginSessions.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(!ts(n.client_secret,e.client_secret)&&!ts(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 t_(e.code_verifier,i.authParams.code_challenge_method);if(!ts(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),pn(t,{user:s,client:n,loginSession:i,authParams:{...i.authParams,response_mode:Ft.WEB_MESSAGE}})}const e3=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 t3(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 pn(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:Ft.WEB_MESSAGE}})}const n3={version:4,country_calling_codes:{1:["US","AG","AI","AS","BB","BM","BS","CA","DM","DO","GD","GU","JM","KN","KY","LC","MP","MS","PR","SX","TC","TT","VC","VG","VI"],7:["RU","KZ"],20:["EG"],27:["ZA"],30:["GR"],31:["NL"],32:["BE"],33:["FR"],34:["ES"],36:["HU"],39:["IT","VA"],40:["RO"],41:["CH"],43:["AT"],44:["GB","GG","IM","JE"],45:["DK"],46:["SE"],47:["NO","SJ"],48:["PL"],49:["DE"],51:["PE"],52:["MX"],53:["CU"],54:["AR"],55:["BR"],56:["CL"],57:["CO"],58:["VE"],60:["MY"],61:["AU","CC","CX"],62:["ID"],63:["PH"],64:["NZ"],65:["SG"],66:["TH"],81:["JP"],82:["KR"],84:["VN"],86:["CN"],90:["TR"],91:["IN"],92:["PK"],93:["AF"],94:["LK"],95:["MM"],98:["IR"],211:["SS"],212:["MA","EH"],213:["DZ"],216:["TN"],218:["LY"],220:["GM"],221:["SN"],222:["MR"],223:["ML"],224:["GN"],225:["CI"],226:["BF"],227:["NE"],228:["TG"],229:["BJ"],230:["MU"],231:["LR"],232:["SL"],233:["GH"],234:["NG"],235:["TD"],236:["CF"],237:["CM"],238:["CV"],239:["ST"],240:["GQ"],241:["GA"],242:["CG"],243:["CD"],244:["AO"],245:["GW"],246:["IO"],247:["AC"],248:["SC"],249:["SD"],250:["RW"],251:["ET"],252:["SO"],253:["DJ"],254:["KE"],255:["TZ"],256:["UG"],257:["BI"],258:["MZ"],260:["ZM"],261:["MG"],262:["RE","YT"],263:["ZW"],264:["NA"],265:["MW"],266:["LS"],267:["BW"],268:["SZ"],269:["KM"],290:["SH","TA"],291:["ER"],297:["AW"],298:["FO"],299:["GL"],350:["GI"],351:["PT"],352:["LU"],353:["IE"],354:["IS"],355:["AL"],356:["MT"],357:["CY"],358:["FI","AX"],359:["BG"],370:["LT"],371:["LV"],372:["EE"],373:["MD"],374:["AM"],375:["BY"],376:["AD"],377:["MC"],378:["SM"],380:["UA"],381:["RS"],382:["ME"],383:["XK"],385:["HR"],386:["SI"],387:["BA"],389:["MK"],420:["CZ"],421:["SK"],423:["LI"],500:["FK"],501:["BZ"],502:["GT"],503:["SV"],504:["HN"],505:["NI"],506:["CR"],507:["PA"],508:["PM"],509:["HT"],590:["GP","BL","MF"],591:["BO"],592:["GY"],593:["EC"],594:["GF"],595:["PY"],596:["MQ"],597:["SR"],598:["UY"],599:["CW","BQ"],670:["TL"],672:["NF"],673:["BN"],674:["NR"],675:["PG"],676:["TO"],677:["SB"],678:["VU"],679:["FJ"],680:["PW"],681:["WF"],682:["CK"],683:["NU"],685:["WS"],686:["KI"],687:["NC"],688:["TV"],689:["PF"],690:["TK"],691:["FM"],692:["MH"],850:["KP"],852:["HK"],853:["MO"],855:["KH"],856:["LA"],880:["BD"],886:["TW"],960:["MV"],961:["LB"],962:["JO"],963:["SY"],964:["IQ"],965:["KW"],966:["SA"],967:["YE"],968:["OM"],970:["PS"],971:["AE"],972:["IL"],973:["BH"],974:["QA"],975:["BT"],976:["MN"],977:["NP"],992:["TJ"],993:["TM"],994:["AZ"],995:["GE"],996:["KG"],998:["UZ"]},countries:{AC:["247","00","(?:[01589]\\d|[46])\\d{4}",[5,6]],AD:["376","00","(?:1|6\\d)\\d{7}|[135-9]\\d{5}",[6,8,9],[["(\\d{3})(\\d{3})","$1 $2",["[135-9]"]],["(\\d{4})(\\d{4})","$1 $2",["1"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6"]]]],AE:["971","00","(?:[4-7]\\d|9[0-689])\\d{7}|800\\d{2,9}|[2-4679]\\d{7}",[5,6,7,8,9,10,11,12],[["(\\d{3})(\\d{2,9})","$1 $2",["60|8"]],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[236]|[479][2-8]"],"0$1"],["(\\d{3})(\\d)(\\d{5})","$1 $2 $3",["[479]"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["5"],"0$1"]],"0"],AF:["93","00","[2-7]\\d{8}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[2-7]"],"0$1"]],"0"],AG:["1","011","(?:268|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([457]\\d{6})$|1","268$1",0,"268"],AI:["1","011","(?:264|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2457]\\d{6})$|1","264$1",0,"264"],AL:["355","00","(?:700\\d\\d|900)\\d{3}|8\\d{5,7}|(?:[2-5]|6\\d)\\d{7}",[6,7,8,9],[["(\\d{3})(\\d{3,4})","$1 $2",["80|9"],"0$1"],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["4[2-6]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2358][2-5]|4"],"0$1"],["(\\d{3})(\\d{5})","$1 $2",["[23578]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["6"],"0$1"]],"0"],AM:["374","00","(?:[1-489]\\d|55|60|77)\\d{6}",[8],[["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["[89]0"],"0 $1"],["(\\d{3})(\\d{5})","$1 $2",["2|3[12]"],"(0$1)"],["(\\d{2})(\\d{6})","$1 $2",["1|47"],"(0$1)"],["(\\d{2})(\\d{6})","$1 $2",["[3-9]"],"0$1"]],"0"],AO:["244","00","[29]\\d{8}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[29]"]]]],AR:["54","00","(?:11|[89]\\d\\d)\\d{8}|[2368]\\d{9}",[10,11],[["(\\d{4})(\\d{2})(\\d{4})","$1 $2-$3",["2(?:2[024-9]|3[0-59]|47|6[245]|9[02-8])|3(?:3[28]|4[03-9]|5[2-46-8]|7[1-578]|8[2-9])","2(?:[23]02|6(?:[25]|4[6-8])|9(?:[02356]|4[02568]|72|8[23]))|3(?:3[28]|4(?:[04679]|3[5-8]|5[4-68]|8[2379])|5(?:[2467]|3[237]|8[2-5])|7[1-578]|8(?:[2469]|3[2578]|5[4-8]|7[36-8]|8[5-8]))|2(?:2[24-9]|3[1-59]|47)","2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3[78]|5(?:4[46]|8)|8[2379])|5(?:[2467]|3[237]|8[23])|7[1-578]|8(?:[2469]|3[278]|5[56][46]|86[3-6]))|2(?:2[24-9]|3[1-59]|47)|38(?:[58][78]|7[378])|3(?:4[35][56]|58[45]|8(?:[38]5|54|76))[4-6]","2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3(?:5(?:4[0-25689]|[56])|[78])|58|8[2379])|5(?:[2467]|3[237]|8(?:[23]|4(?:[45]|60)|5(?:4[0-39]|5|64)))|7[1-578]|8(?:[2469]|3[278]|54(?:4|5[13-7]|6[89])|86[3-6]))|2(?:2[24-9]|3[1-59]|47)|38(?:[58][78]|7[378])|3(?:454|85[56])[46]|3(?:4(?:36|5[56])|8(?:[38]5|76))[4-6]"],"0$1",1],["(\\d{2})(\\d{4})(\\d{4})","$1 $2-$3",["1"],"0$1",1],["(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["[68]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2-$3",["[23]"],"0$1",1],["(\\d)(\\d{4})(\\d{2})(\\d{4})","$2 15-$3-$4",["9(?:2[2-469]|3[3-578])","9(?:2(?:2[024-9]|3[0-59]|47|6[245]|9[02-8])|3(?:3[28]|4[03-9]|5[2-46-8]|7[1-578]|8[2-9]))","9(?:2(?:[23]02|6(?:[25]|4[6-8])|9(?:[02356]|4[02568]|72|8[23]))|3(?:3[28]|4(?:[04679]|3[5-8]|5[4-68]|8[2379])|5(?:[2467]|3[237]|8[2-5])|7[1-578]|8(?:[2469]|3[2578]|5[4-8]|7[36-8]|8[5-8])))|92(?:2[24-9]|3[1-59]|47)","9(?:2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3[78]|5(?:4[46]|8)|8[2379])|5(?:[2467]|3[237]|8[23])|7[1-578]|8(?:[2469]|3[278]|5(?:[56][46]|[78])|7[378]|8(?:6[3-6]|[78]))))|92(?:2[24-9]|3[1-59]|47)|93(?:4[35][56]|58[45]|8(?:[38]5|54|76))[4-6]","9(?:2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3(?:5(?:4[0-25689]|[56])|[78])|5(?:4[46]|8)|8[2379])|5(?:[2467]|3[237]|8(?:[23]|4(?:[45]|60)|5(?:4[0-39]|5|64)))|7[1-578]|8(?:[2469]|3[278]|5(?:4(?:4|5[13-7]|6[89])|[56][46]|[78])|7[378]|8(?:6[3-6]|[78]))))|92(?:2[24-9]|3[1-59]|47)|93(?:4(?:36|5[56])|8(?:[38]5|76))[4-6]"],"0$1",0,"$1 $2 $3-$4"],["(\\d)(\\d{2})(\\d{4})(\\d{4})","$2 15-$3-$4",["91"],"0$1",0,"$1 $2 $3-$4"],["(\\d{3})(\\d{3})(\\d{5})","$1-$2-$3",["8"],"0$1"],["(\\d)(\\d{3})(\\d{3})(\\d{4})","$2 15-$3-$4",["9"],"0$1",0,"$1 $2 $3-$4"]],"0",0,"0?(?:(11|2(?:2(?:02?|[13]|2[13-79]|4[1-6]|5[2457]|6[124-8]|7[1-4]|8[13-6]|9[1267])|3(?:02?|1[467]|2[03-6]|3[13-8]|[49][2-6]|5[2-8]|[67])|4(?:7[3-578]|9)|6(?:[0136]|2[24-6]|4[6-8]?|5[15-8])|80|9(?:0[1-3]|[19]|2\\d|3[1-6]|4[02568]?|5[2-4]|6[2-46]|72?|8[23]?))|3(?:3(?:2[79]|6|8[2578])|4(?:0[0-24-9]|[12]|3[5-8]?|4[24-7]|5[4-68]?|6[02-9]|7[126]|8[2379]?|9[1-36-8])|5(?:1|2[1245]|3[237]?|4[1-46-9]|6[2-4]|7[1-6]|8[2-5]?)|6[24]|7(?:[069]|1[1568]|2[15]|3[145]|4[13]|5[14-8]|7[2-57]|8[126])|8(?:[01]|2[15-7]|3[2578]?|4[13-6]|5[4-8]?|6[1-357-9]|7[36-8]?|8[5-8]?|9[124])))15)?","9$1"],AS:["1","011","(?:[58]\\d\\d|684|900)\\d{7}",[10],0,"1",0,"([267]\\d{6})$|1","684$1",0,"684"],AT:["43","00","1\\d{3,12}|2\\d{6,12}|43(?:(?:0\\d|5[02-9])\\d{3,9}|2\\d{4,5}|[3467]\\d{4}|8\\d{4,6}|9\\d{4,7})|5\\d{4,12}|8\\d{7,12}|9\\d{8,12}|(?:[367]\\d|4[0-24-9])\\d{4,11}",[4,5,6,7,8,9,10,11,12,13],[["(\\d)(\\d{3,12})","$1 $2",["1(?:11|[2-9])"],"0$1"],["(\\d{3})(\\d{2})","$1 $2",["517"],"0$1"],["(\\d{2})(\\d{3,5})","$1 $2",["5[079]"],"0$1"],["(\\d{3})(\\d{3,10})","$1 $2",["(?:31|4)6|51|6(?:48|5[0-3579]|[6-9])|7(?:20|32|8)|[89]","(?:31|4)6|51|6(?:485|5[0-3579]|[6-9])|7(?:20|32|8)|[89]"],"0$1"],["(\\d{4})(\\d{3,9})","$1 $2",["[2-467]|5[2-6]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["5"],"0$1"],["(\\d{2})(\\d{4})(\\d{4,7})","$1 $2 $3",["5"],"0$1"]],"0"],AU:["61","001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011","1(?:[0-79]\\d{7}(?:\\d(?:\\d{2})?)?|8[0-24-9]\\d{7})|[2-478]\\d{8}|1\\d{4,7}",[5,6,7,8,9,10,12],[["(\\d{2})(\\d{3,4})","$1 $2",["16"],"0$1"],["(\\d{2})(\\d{3})(\\d{2,4})","$1 $2 $3",["16"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["14|4"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["[2378]"],"(0$1)"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1(?:30|[89])"]]],"0",0,"(183[12])|0",0,0,0,[["(?:(?:(?:2(?:[0-26-9]\\d|3[0-8]|4[02-9]|5[0135-9])|7(?:[013-57-9]\\d|2[0-8]))\\d|3(?:(?:[0-3589]\\d|6[1-9]|7[0-35-9])\\d|4(?:[0-578]\\d|90)))\\d\\d|8(?:51(?:0(?:0[03-9]|[12479]\\d|3[2-9]|5[0-8]|6[1-9]|8[0-7])|1(?:[0235689]\\d|1[0-69]|4[0-589]|7[0-47-9])|2(?:0[0-79]|[18][13579]|2[14-9]|3[0-46-9]|[4-6]\\d|7[89]|9[0-4])|3\\d\\d)|(?:6[0-8]|[78]\\d)\\d{3}|9(?:[02-9]\\d{3}|1(?:(?:[0-58]\\d|6[0135-9])\\d|7(?:0[0-24-9]|[1-9]\\d)|9(?:[0-46-9]\\d|5[0-79])))))\\d{3}",[9]],["4(?:79[01]|83[0-389]|94[0-4])\\d{5}|4(?:[0-36]\\d|4[047-9]|5[0-25-9]|7[02-8]|8[0-24-9]|9[0-37-9])\\d{6}",[9]],["180(?:0\\d{3}|2)\\d{3}",[7,10]],["190[0-26]\\d{6}",[10]],0,0,0,["163\\d{2,6}",[5,6,7,8,9]],["14(?:5(?:1[0458]|[23][458])|71\\d)\\d{4}",[9]],["13(?:00\\d{6}(?:\\d{2})?|45[0-4]\\d{3})|13\\d{4}",[6,8,10,12]]],"0011"],AW:["297","00","(?:[25-79]\\d\\d|800)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[25-9]"]]]],AX:["358","00|99(?:[01469]|5(?:[14]1|3[23]|5[59]|77|88|9[09]))","2\\d{4,9}|35\\d{4,5}|(?:60\\d\\d|800)\\d{4,6}|7\\d{5,11}|(?:[14]\\d|3[0-46-9]|50)\\d{4,8}",[5,6,7,8,9,10,11,12],0,"0",0,0,0,0,"18",0,"00"],AZ:["994","00","365\\d{6}|(?:[124579]\\d|60|88)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["90"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[28]|2|365|46","1[28]|2|365[45]|46","1[28]|2|365(?:4|5[02])|46"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[13-9]"],"0$1"]],"0"],BA:["387","00","6\\d{8}|(?:[35689]\\d|49|70)\\d{6}",[8,9],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["6[1-3]|[7-9]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2-$3",["[3-5]|6[56]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3 $4",["6"],"0$1"]],"0"],BB:["1","011","(?:246|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","246$1",0,"246"],BD:["880","00","[1-469]\\d{9}|8[0-79]\\d{7,8}|[2-79]\\d{8}|[2-9]\\d{7}|[3-9]\\d{6}|[57-9]\\d{5}",[6,7,8,9,10],[["(\\d{2})(\\d{4,6})","$1-$2",["31[5-8]|[459]1"],"0$1"],["(\\d{3})(\\d{3,7})","$1-$2",["3(?:[67]|8[013-9])|4(?:6[168]|7|[89][18])|5(?:6[128]|9)|6(?:[15]|28|4[14])|7[2-589]|8(?:0[014-9]|[12])|9[358]|(?:3[2-5]|4[235]|5[2-578]|6[0389]|76|8[3-7]|9[24])1|(?:44|66)[01346-9]"],"0$1"],["(\\d{4})(\\d{3,6})","$1-$2",["[13-9]|2[23]"],"0$1"],["(\\d)(\\d{7,8})","$1-$2",["2"],"0$1"]],"0"],BE:["32","00","4\\d{8}|[1-9]\\d{7}",[8,9],[["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["(?:80|9)0"],"0$1"],["(\\d)(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[239]|4[23]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[15-8]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["4"],"0$1"]],"0"],BF:["226","00","[025-7]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[025-7]"]]]],BG:["359","00","00800\\d{7}|[2-7]\\d{6,7}|[89]\\d{6,8}|2\\d{5}",[6,7,8,9,12],[["(\\d)(\\d)(\\d{2})(\\d{2})","$1 $2 $3 $4",["2"],"0$1"],["(\\d{3})(\\d{4})","$1 $2",["43[1-6]|70[1-9]"],"0$1"],["(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{2,3})","$1 $2 $3",["[356]|4[124-7]|7[1-9]|8[1-6]|9[1-7]"],"0$1"],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["(?:70|8)0"],"0$1"],["(\\d{3})(\\d{3})(\\d{2})","$1 $2 $3",["43[1-7]|7"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[48]|9[08]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["9"],"0$1"]],"0"],BH:["973","00","[136-9]\\d{7}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[13679]|8[02-4679]"]]]],BI:["257","00","(?:[267]\\d|31)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2367]"]]]],BJ:["229","00","(?:01\\d|[24-689])\\d{7}",[8,10],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[24-689]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["0"]]]],BL:["590","00","(?:590\\d|7090)\\d{5}|(?:69|80|9\\d)\\d{7}",[9],0,"0",0,0,0,0,0,[["590(?:2[7-9]|3[3-7]|5[12]|87)\\d{4}"],["(?:69(?:0\\d\\d|1(?:2[2-9]|3[0-5])|4(?:0[89]|1[2-6]|9\\d)|6(?:1[016-9]|5[0-4]|[67]\\d))|7090[0-4])\\d{4}"],["80[0-5]\\d{6}"],0,0,0,0,0,["9(?:(?:39[5-7]|76[018])\\d|475[0-6])\\d{4}"]]],BM:["1","011","(?:441|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","441$1",0,"441"],BN:["673","00","[2-578]\\d{6}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-578]"]]]],BO:["591","00(?:1\\d)?","8001\\d{5}|(?:[2-467]\\d|50)\\d{6}",[8,9],[["(\\d)(\\d{7})","$1 $2",["[235]|4[46]"]],["(\\d{8})","$1",["[67]"]],["(\\d{3})(\\d{2})(\\d{4})","$1 $2 $3",["8"]]],"0",0,"0(1\\d)?"],BQ:["599","00","(?:[34]1|7\\d)\\d{5}",[7],0,0,0,0,0,0,"[347]"],BR:["55","00(?:1[245]|2[1-35]|31|4[13]|[56]5|99)","[1-467]\\d{9,10}|55[0-46-9]\\d{8}|[34]\\d{7}|55\\d{7,8}|(?:5[0-46-9]|[89]\\d)\\d{7,9}",[8,9,10,11],[["(\\d{4})(\\d{4})","$1-$2",["300|4(?:0[02]|37|86)","300|4(?:0(?:0|20)|370|864)"]],["(\\d{3})(\\d{2,3})(\\d{4})","$1 $2 $3",["(?:[358]|90)0"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1 $2-$3",["(?:[14689][1-9]|2[12478]|3[1-578]|5[13-5]|7[13-579])[2-57]"],"($1)"],["(\\d{2})(\\d{5})(\\d{4})","$1 $2-$3",["[16][1-9]|[2-57-9]"],"($1)"]],"0",0,"(?:0|90)(?:(1[245]|2[1-35]|31|4[13]|[56]5|99)(\\d{10,11}))?","$2"],BS:["1","011","(?:242|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([3-8]\\d{6})$|1","242$1",0,"242"],BT:["975","00","[17]\\d{7}|[2-8]\\d{6}",[7,8],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[2-68]|7[246]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[67]|7"]]]],BW:["267","00","(?:0800|(?:[37]|800)\\d)\\d{6}|(?:[2-6]\\d|90)\\d{5}",[7,8,10],[["(\\d{2})(\\d{5})","$1 $2",["90"]],["(\\d{3})(\\d{4})","$1 $2",["[24-6]|3[15-9]"]],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[37]"]],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["0"]],["(\\d{3})(\\d{4})(\\d{3})","$1 $2 $3",["8"]]]],BY:["375","810","(?:[12]\\d|33|44|902)\\d{7}|8(?:0[0-79]\\d{5,7}|[1-7]\\d{9})|8(?:1[0-489]|[5-79]\\d)\\d{7}|8[1-79]\\d{6,7}|8[0-79]\\d{5}|8\\d{5}",[6,7,8,9,10,11],[["(\\d{3})(\\d{3})","$1 $2",["800"],"8 $1"],["(\\d{3})(\\d{2})(\\d{2,4})","$1 $2 $3",["800"],"8 $1"],["(\\d{4})(\\d{2})(\\d{3})","$1 $2-$3",["1(?:5[169]|6[3-5]|7[179])|2(?:1[35]|2[34]|3[3-5])","1(?:5[169]|6(?:3[1-3]|4|5[125])|7(?:1[3-9]|7[0-24-6]|9[2-7]))|2(?:1[35]|2[34]|3[3-5])"],"8 0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2-$3-$4",["1(?:[56]|7[467])|2[1-3]"],"8 0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2-$3-$4",["[1-4]"],"8 0$1"],["(\\d{3})(\\d{3,4})(\\d{4})","$1 $2 $3",["[89]"],"8 $1"]],"8",0,"0|80?",0,0,0,0,"8~10"],BZ:["501","00","(?:0800\\d|[2-8])\\d{6}",[7,11],[["(\\d{3})(\\d{4})","$1-$2",["[2-8]"]],["(\\d)(\\d{3})(\\d{4})(\\d{3})","$1-$2-$3-$4",["0"]]]],CA:["1","011","[2-9]\\d{9}|3\\d{6}",[7,10],0,"1",0,0,0,0,0,[["(?:2(?:04|[23]6|[48]9|50|63)|3(?:06|43|54|6[578]|82)|4(?:03|1[68]|[26]8|3[178]|50|74)|5(?:06|1[49]|48|79|8[147])|6(?:04|[18]3|39|47|72)|7(?:0[59]|42|53|78|8[02])|8(?:[06]7|19|25|7[39])|9(?:0[25]|42))[2-9]\\d{6}",[10]],["",[10]],["8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",[10]],["900[2-9]\\d{6}",[10]],["52(?:3(?:[2-46-9][02-9]\\d|5(?:[02-46-9]\\d|5[0-46-9]))|4(?:[2-478][02-9]\\d|5(?:[034]\\d|2[024-9]|5[0-46-9])|6(?:0[1-9]|[2-9]\\d)|9(?:[05-9]\\d|2[0-5]|49)))\\d{4}|52[34][2-9]1[02-9]\\d{4}|(?:5(?:2[125-9]|33|44|66|77|88)|6(?:22|33))[2-9]\\d{6}",[10]],0,["310\\d{4}",[7]],0,["600[2-9]\\d{6}",[10]]]],CC:["61","001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011","1(?:[0-79]\\d{8}(?:\\d{2})?|8[0-24-9]\\d{7})|[148]\\d{8}|1\\d{5,7}",[6,7,8,9,10,12],0,"0",0,"([59]\\d{7})$|0","8$1",0,0,[["8(?:51(?:0(?:02|31|60|89)|1(?:18|76)|223)|91(?:0(?:1[0-2]|29)|1(?:[28]2|50|79)|2(?:10|64)|3(?:[06]8|22)|4[29]8|62\\d|70[23]|959))\\d{3}",[9]],["4(?:79[01]|83[0-389]|94[0-4])\\d{5}|4(?:[0-36]\\d|4[047-9]|5[0-25-9]|7[02-8]|8[0-24-9]|9[0-37-9])\\d{6}",[9]],["180(?:0\\d{3}|2)\\d{3}",[7,10]],["190[0-26]\\d{6}",[10]],0,0,0,0,["14(?:5(?:1[0458]|[23][458])|71\\d)\\d{4}",[9]],["13(?:00\\d{6}(?:\\d{2})?|45[0-4]\\d{3})|13\\d{4}",[6,8,10,12]]],"0011"],CD:["243","00","(?:(?:[189]|5\\d)\\d|2)\\d{7}|[1-68]\\d{6}",[7,8,9,10],[["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["88"],"0$1"],["(\\d{2})(\\d{5})","$1 $2",["[1-6]"],"0$1"],["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[89]"],"0$1"],["(\\d{2})(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3 $4",["5"],"0$1"]],"0"],CF:["236","00","(?:[27]\\d{3}|8776)\\d{4}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[278]"]]]],CG:["242","00","222\\d{6}|(?:0\\d|80)\\d{7}",[9],[["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["8"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[02]"]]]],CH:["41","00","8\\d{11}|[2-9]\\d{8}",[9,12],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8[047]|90"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-79]|81"],"0$1"],["(\\d{3})(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["8"],"0$1"]],"0"],CI:["225","00","[02]\\d{9}",[10],[["(\\d{2})(\\d{2})(\\d)(\\d{5})","$1 $2 $3 $4",["2"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3 $4",["0"]]]],CK:["682","00","[2-578]\\d{4}",[5],[["(\\d{2})(\\d{3})","$1 $2",["[2-578]"]]]],CL:["56","(?:0|1(?:1[0-69]|2[02-5]|5[13-58]|69|7[0167]|8[018]))0","12300\\d{6}|6\\d{9,10}|[2-9]\\d{8}",[9,10,11],[["(\\d{5})(\\d{4})","$1 $2",["219","2196"],"($1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["44"]],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["2[1-36]"],"($1)"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["9[2-9]"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["3[2-5]|[47]|5[1-3578]|6[13-57]|8(?:0[1-9]|[1-9])"],"($1)"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["60|8"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]],["(\\d{3})(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3 $4",["60"]]]],CM:["237","00","[26]\\d{8}|88\\d{6,7}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["88"]],["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["[26]|88"]]]],CN:["86","00|1(?:[12]\\d|79)\\d\\d00","(?:(?:1[03-689]|2\\d)\\d\\d|6)\\d{8}|1\\d{10}|[126]\\d{6}(?:\\d(?:\\d{2})?)?|86\\d{5,6}|(?:[3-579]\\d|8[0-57-9])\\d{5,9}",[7,8,9,10,11,12],[["(\\d{2})(\\d{5,6})","$1 $2",["(?:10|2[0-57-9])[19]|3(?:[157]|35|49|9[1-68])|4(?:1[124-9]|2[179]|6[47-9]|7|8[23])|5(?:[1357]|2[37]|4[36]|6[1-46]|80)|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:07|1[236-8]|2[5-7]|[37]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3|4[13]|5[1-5]|7[0-79]|9[0-35-9])|(?:4[35]|59|85)[1-9]","(?:10|2[0-57-9])(?:1[02]|9[56])|8078|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))1","10(?:1(?:0|23)|9[56])|2[0-57-9](?:1(?:00|23)|9[56])|80781|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))12","10(?:1(?:0|23)|9[56])|2[0-57-9](?:1(?:00|23)|9[56])|807812|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))123","10(?:1(?:0|23)|9[56])|2[0-57-9](?:1(?:00|23)|9[56])|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:078|1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))123"],"0$1"],["(\\d{3})(\\d{5,6})","$1 $2",["3(?:[157]|35|49|9[1-68])|4(?:[17]|2[179]|6[47-9]|8[23])|5(?:[1357]|2[37]|4[36]|6[1-46]|80)|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]|4[13]|5[1-5])|(?:4[35]|59|85)[1-9]","(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))[19]","85[23](?:10|95)|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[14-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))(?:10|9[56])","85[23](?:100|95)|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[14-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))(?:100|9[56])"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["(?:4|80)0"]],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["10|2(?:[02-57-9]|1[1-9])","10|2(?:[02-57-9]|1[1-9])","10[0-79]|2(?:[02-57-9]|1[1-79])|(?:10|21)8(?:0[1-9]|[1-9])"],"0$1",1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["3(?:[3-59]|7[02-68])|4(?:[26-8]|3[3-9]|5[2-9])|5(?:3[03-9]|[468]|7[028]|9[2-46-9])|6|7(?:[0-247]|3[04-9]|5[0-4689]|6[2368])|8(?:[1-358]|9[1-7])|9(?:[013479]|5[1-5])|(?:[34]1|55|79|87)[02-9]"],"0$1",1],["(\\d{3})(\\d{7,8})","$1 $2",["9"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["80"],"0$1",1],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["[3-578]"],"0$1",1],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["1[3-9]"]],["(\\d{2})(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3 $4",["[12]"],"0$1",1]],"0",0,"(1(?:[12]\\d|79)\\d\\d)|0",0,0,0,0,"00"],CO:["57","00(?:4(?:[14]4|56)|[579])","(?:46|60\\d\\d)\\d{6}|(?:1\\d|[39])\\d{9}",[8,10,11],[["(\\d{4})(\\d{4})","$1 $2",["46"]],["(\\d{3})(\\d{7})","$1 $2",["6|90"],"($1)"],["(\\d{3})(\\d{7})","$1 $2",["3[0-357]|91"]],["(\\d)(\\d{3})(\\d{7})","$1-$2-$3",["1"],"0$1",0,"$1 $2 $3"]],"0",0,"0([3579]|4(?:[14]4|56))?"],CR:["506","00","(?:8\\d|90)\\d{8}|(?:[24-8]\\d{3}|3005)\\d{4}",[8,10],[["(\\d{4})(\\d{4})","$1 $2",["[2-7]|8[3-9]"]],["(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["[89]"]]],0,0,"(19(?:0[0-2468]|1[09]|20|66|77|99))"],CU:["53","119","(?:[2-7]|8\\d\\d)\\d{7}|[2-47]\\d{6}|[34]\\d{5}",[6,7,8,10],[["(\\d{2})(\\d{4,6})","$1 $2",["2[1-4]|[34]"],"(0$1)"],["(\\d)(\\d{6,7})","$1 $2",["7"],"(0$1)"],["(\\d)(\\d{7})","$1 $2",["[56]"],"0$1"],["(\\d{3})(\\d{7})","$1 $2",["8"],"0$1"]],"0"],CV:["238","0","(?:[2-59]\\d\\d|800)\\d{4}",[7],[["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["[2-589]"]]]],CW:["599","00","(?:[34]1|60|(?:7|9\\d)\\d)\\d{5}",[7,8],[["(\\d{3})(\\d{4})","$1 $2",["[3467]"]],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["9[4-8]"]]],0,0,0,0,0,"[69]"],CX:["61","001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011","1(?:[0-79]\\d{8}(?:\\d{2})?|8[0-24-9]\\d{7})|[148]\\d{8}|1\\d{5,7}",[6,7,8,9,10,12],0,"0",0,"([59]\\d{7})$|0","8$1",0,0,[["8(?:51(?:0(?:01|30|59|88)|1(?:17|46|75)|2(?:22|35))|91(?:00[6-9]|1(?:[28]1|49|78)|2(?:09|63)|3(?:12|26|75)|4(?:56|97)|64\\d|7(?:0[01]|1[0-2])|958))\\d{3}",[9]],["4(?:79[01]|83[0-389]|94[0-4])\\d{5}|4(?:[0-36]\\d|4[047-9]|5[0-25-9]|7[02-8]|8[0-24-9]|9[0-37-9])\\d{6}",[9]],["180(?:0\\d{3}|2)\\d{3}",[7,10]],["190[0-26]\\d{6}",[10]],0,0,0,0,["14(?:5(?:1[0458]|[23][458])|71\\d)\\d{4}",[9]],["13(?:00\\d{6}(?:\\d{2})?|45[0-4]\\d{3})|13\\d{4}",[6,8,10,12]]],"0011"],CY:["357","00","(?:[279]\\d|[58]0)\\d{6}",[8],[["(\\d{2})(\\d{6})","$1 $2",["[257-9]"]]]],CZ:["420","00","(?:[2-578]\\d|60)\\d{7}|9\\d{8,11}",[9,10,11,12],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[2-8]|9[015-7]"]],["(\\d{2})(\\d{3})(\\d{3})(\\d{2})","$1 $2 $3 $4",["96"]],["(\\d{2})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["9"]],["(\\d{3})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["9"]]]],DE:["49","00","[2579]\\d{5,14}|49(?:[34]0|69|8\\d)\\d\\d?|49(?:37|49|60|7[089]|9\\d)\\d{1,3}|49(?:2[024-9]|3[2-689]|7[1-7])\\d{1,8}|(?:1|[368]\\d|4[0-8])\\d{3,13}|49(?:[015]\\d|2[13]|31|[46][1-8])\\d{1,9}",[4,5,6,7,8,9,10,11,12,13,14,15],[["(\\d{2})(\\d{3,13})","$1 $2",["3[02]|40|[68]9"],"0$1"],["(\\d{3})(\\d{3,12})","$1 $2",["2(?:0[1-389]|1[124]|2[18]|3[14])|3(?:[35-9][15]|4[015])|906|(?:2[4-9]|4[2-9]|[579][1-9]|[68][1-8])1","2(?:0[1-389]|12[0-8])|3(?:[35-9][15]|4[015])|906|2(?:[13][14]|2[18])|(?:2[4-9]|4[2-9]|[579][1-9]|[68][1-8])1"],"0$1"],["(\\d{4})(\\d{2,11})","$1 $2",["[24-6]|3(?:[3569][02-46-9]|4[2-4679]|7[2-467]|8[2-46-8])|70[2-8]|8(?:0[2-9]|[1-8])|90[7-9]|[79][1-9]","[24-6]|3(?:3(?:0[1-467]|2[127-9]|3[124578]|7[1257-9]|8[1256]|9[145])|4(?:2[135]|4[13578]|9[1346])|5(?:0[14]|2[1-3589]|6[1-4]|7[13468]|8[13568])|6(?:2[1-489]|3[124-6]|6[13]|7[12579]|8[1-356]|9[135])|7(?:2[1-7]|4[145]|6[1-5]|7[1-4])|8(?:21|3[1468]|6|7[1467]|8[136])|9(?:0[12479]|2[1358]|4[134679]|6[1-9]|7[136]|8[147]|9[1468]))|70[2-8]|8(?:0[2-9]|[1-8])|90[7-9]|[79][1-9]|3[68]4[1347]|3(?:47|60)[1356]|3(?:3[46]|46|5[49])[1246]|3[4579]3[1357]"],"0$1"],["(\\d{3})(\\d{4})","$1 $2",["138"],"0$1"],["(\\d{5})(\\d{2,10})","$1 $2",["3"],"0$1"],["(\\d{3})(\\d{5,11})","$1 $2",["181"],"0$1"],["(\\d{3})(\\d)(\\d{4,10})","$1 $2 $3",["1(?:3|80)|9"],"0$1"],["(\\d{3})(\\d{7,8})","$1 $2",["1[67]"],"0$1"],["(\\d{3})(\\d{7,12})","$1 $2",["8"],"0$1"],["(\\d{5})(\\d{6})","$1 $2",["185","1850","18500"],"0$1"],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["7"],"0$1"],["(\\d{4})(\\d{7})","$1 $2",["18[68]"],"0$1"],["(\\d{4})(\\d{7})","$1 $2",["15[1279]"],"0$1"],["(\\d{5})(\\d{6})","$1 $2",["15[03568]","15(?:[0568]|31)"],"0$1"],["(\\d{3})(\\d{8})","$1 $2",["18"],"0$1"],["(\\d{3})(\\d{2})(\\d{7,8})","$1 $2 $3",["1(?:6[023]|7)"],"0$1"],["(\\d{4})(\\d{2})(\\d{7})","$1 $2 $3",["15[279]"],"0$1"],["(\\d{3})(\\d{2})(\\d{8})","$1 $2 $3",["15"],"0$1"]],"0"],DJ:["253","00","(?:2\\d|77)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[27]"]]]],DK:["45","00","[2-9]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-9]"]]]],DM:["1","011","(?:[58]\\d\\d|767|900)\\d{7}",[10],0,"1",0,"([2-7]\\d{6})$|1","767$1",0,"767"],DO:["1","011","(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,0,0,0,"8001|8[024]9"],DZ:["213","00","(?:[1-4]|[5-79]\\d|80)\\d{7}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[1-4]"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["9"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-8]"],"0$1"]],"0"],EC:["593","00","1\\d{9,10}|(?:[2-7]|9\\d)\\d{7}",[8,9,10,11],[["(\\d)(\\d{3})(\\d{4})","$1 $2-$3",["[2-7]"],"(0$1)",0,"$1-$2-$3"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["9"],"0$1"],["(\\d{4})(\\d{3})(\\d{3,4})","$1 $2 $3",["1"]]],"0"],EE:["372","00","8\\d{9}|[4578]\\d{7}|(?:[3-8]\\d|90)\\d{5}",[7,8,10],[["(\\d{3})(\\d{4})","$1 $2",["[369]|4[3-8]|5(?:[0-2]|5[0-478]|6[45])|7[1-9]|88","[369]|4[3-8]|5(?:[02]|1(?:[0-8]|95)|5[0-478]|6(?:4[0-4]|5[1-589]))|7[1-9]|88"]],["(\\d{4})(\\d{3,4})","$1 $2",["[45]|8(?:00|[1-49])","[45]|8(?:00[1-9]|[1-49])"]],["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["7"]],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["8"]]]],EG:["20","00","[189]\\d{8,9}|[24-6]\\d{8}|[135]\\d{7}",[8,9,10],[["(\\d)(\\d{7,8})","$1 $2",["[23]"],"0$1"],["(\\d{2})(\\d{6,7})","$1 $2",["1[35]|[4-6]|8[2468]|9[235-7]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[89]"],"0$1"],["(\\d{2})(\\d{8})","$1 $2",["1"],"0$1"]],"0"],EH:["212","00","[5-8]\\d{8}",[9],0,"0",0,0,0,0,"528[89]"],ER:["291","00","[178]\\d{6}",[7],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[178]"],"0$1"]],"0"],ES:["34","00","[5-9]\\d{8}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[89]00"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-9]"]]]],ET:["251","00","(?:11|[2-579]\\d)\\d{7}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[1-579]"],"0$1"]],"0"],FI:["358","00|99(?:[01469]|5(?:[14]1|3[23]|5[59]|77|88|9[09]))","[1-35689]\\d{4}|7\\d{10,11}|(?:[124-7]\\d|3[0-46-9])\\d{8}|[1-9]\\d{5,8}",[5,6,7,8,9,10,11,12],[["(\\d{5})","$1",["20[2-59]"],"0$1"],["(\\d{3})(\\d{3,7})","$1 $2",["(?:[1-3]0|[68])0|70[07-9]"],"0$1"],["(\\d{2})(\\d{4,8})","$1 $2",["[14]|2[09]|50|7[135]"],"0$1"],["(\\d{2})(\\d{6,10})","$1 $2",["7"],"0$1"],["(\\d)(\\d{4,9})","$1 $2",["(?:19|[2568])[1-8]|3(?:0[1-9]|[1-9])|9"],"0$1"]],"0",0,0,0,0,"1[03-79]|[2-9]",0,"00"],FJ:["679","0(?:0|52)","45\\d{5}|(?:0800\\d|[235-9])\\d{6}",[7,11],[["(\\d{3})(\\d{4})","$1 $2",["[235-9]|45"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["0"]]],0,0,0,0,0,0,0,"00"],FK:["500","00","[2-7]\\d{4}",[5]],FM:["691","00","(?:[39]\\d\\d|820)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[389]"]]]],FO:["298","00","[2-9]\\d{5}",[6],[["(\\d{6})","$1",["[2-9]"]]],0,0,"(10(?:01|[12]0|88))"],FR:["33","00","[1-9]\\d{8}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0 $1"],["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["[1-79]"],"0$1"]],"0"],GA:["241","00","(?:[067]\\d|11)\\d{6}|[2-7]\\d{6}",[7,8],[["(\\d)(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-7]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["0"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["11|[67]"],"0$1"]],0,0,"0(11\\d{6}|60\\d{6}|61\\d{6}|6[256]\\d{6}|7[467]\\d{6})","$1"],GB:["44","00","[1-357-9]\\d{9}|[18]\\d{8}|8\\d{6}",[7,9,10],[["(\\d{3})(\\d{4})","$1 $2",["800","8001","80011","800111","8001111"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["845","8454","84546","845464"],"0$1"],["(\\d{3})(\\d{6})","$1 $2",["800"],"0$1"],["(\\d{5})(\\d{4,5})","$1 $2",["1(?:38|5[23]|69|76|94)","1(?:(?:38|69)7|5(?:24|39)|768|946)","1(?:3873|5(?:242|39[4-6])|(?:697|768)[347]|9467)"],"0$1"],["(\\d{4})(\\d{5,6})","$1 $2",["1(?:[2-69][02-9]|[78])"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["[25]|7(?:0|6[02-9])","[25]|7(?:0|6(?:[03-9]|2[356]))"],"0$1"],["(\\d{4})(\\d{6})","$1 $2",["7"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[1389]"],"0$1"]],"0",0,0,0,0,0,[["(?:1(?:1(?:3(?:[0-58]\\d\\d|73[0-35])|4(?:(?:[0-5]\\d|70)\\d|69[7-9])|(?:(?:5[0-26-9]|[78][0-49])\\d|6(?:[0-4]\\d|50))\\d)|(?:2(?:(?:0[024-9]|2[3-9]|3[3-79]|4[1-689]|[58][02-9]|6[0-47-9]|7[013-9]|9\\d)\\d|1(?:[0-7]\\d|8[0-3]))|(?:3(?:0\\d|1[0-8]|[25][02-9]|3[02-579]|[468][0-46-9]|7[1-35-79]|9[2-578])|4(?:0[03-9]|[137]\\d|[28][02-57-9]|4[02-69]|5[0-8]|[69][0-79])|5(?:0[1-35-9]|[16]\\d|2[024-9]|3[015689]|4[02-9]|5[03-9]|7[0-35-9]|8[0-468]|9[0-57-9])|6(?:0[034689]|1\\d|2[0-35689]|[38][013-9]|4[1-467]|5[0-69]|6[13-9]|7[0-8]|9[0-24578])|7(?:0[0246-9]|2\\d|3[0236-8]|4[03-9]|5[0-46-9]|6[013-9]|7[0-35-9]|8[024-9]|9[02-9])|8(?:0[35-9]|2[1-57-9]|3[02-578]|4[0-578]|5[124-9]|6[2-69]|7\\d|8[02-9]|9[02569])|9(?:0[02-589]|[18]\\d|2[02-689]|3[1-57-9]|4[2-9]|5[0-579]|6[2-47-9]|7[0-24578]|9[2-57]))\\d)\\d)|2(?:0[013478]|3[0189]|4[017]|8[0-46-9]|9[0-2])\\d{3})\\d{4}|1(?:2(?:0(?:46[1-4]|87[2-9])|545[1-79]|76(?:2\\d|3[1-8]|6[1-6])|9(?:7(?:2[0-4]|3[2-5])|8(?:2[2-8]|7[0-47-9]|8[3-5])))|3(?:6(?:38[2-5]|47[23])|8(?:47[04-9]|64[0157-9]))|4(?:044[1-7]|20(?:2[23]|8\\d)|6(?:0(?:30|5[2-57]|6[1-8]|7[2-8])|140)|8(?:052|87[1-3]))|5(?:2(?:4(?:3[2-79]|6\\d)|76\\d)|6(?:26[06-9]|686))|6(?:06(?:4\\d|7[4-79])|295[5-7]|35[34]\\d|47(?:24|61)|59(?:5[08]|6[67]|74)|9(?:55[0-4]|77[23]))|7(?:26(?:6[13-9]|7[0-7])|(?:442|688)\\d|50(?:2[0-3]|[3-68]2|76))|8(?:27[56]\\d|37(?:5[2-5]|8[239])|843[2-58])|9(?:0(?:0(?:6[1-8]|85)|52\\d)|3583|4(?:66[1-8]|9(?:2[01]|81))|63(?:23|3[1-4])|9561))\\d{3}",[9,10]],["7(?:457[0-57-9]|700[01]|911[028])\\d{5}|7(?:[1-3]\\d\\d|4(?:[0-46-9]\\d|5[0-689])|5(?:0[0-8]|[13-9]\\d|2[0-35-9])|7(?:0[1-9]|[1-7]\\d|8[02-9]|9[0-689])|8(?:[014-9]\\d|[23][0-8])|9(?:[024-9]\\d|1[02-9]|3[0-689]))\\d{6}",[10]],["80[08]\\d{7}|800\\d{6}|8001111"],["(?:8(?:4[2-5]|7[0-3])|9(?:[01]\\d|8[2-49]))\\d{7}|845464\\d",[7,10]],["70\\d{8}",[10]],0,["(?:3[0347]|55)\\d{8}",[10]],["76(?:464|652)\\d{5}|76(?:0[0-28]|2[356]|34|4[01347]|5[49]|6[0-369]|77|8[14]|9[139])\\d{6}",[10]],["56\\d{8}",[10]]],0," x"],GD:["1","011","(?:473|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","473$1",0,"473"],GE:["995","00","(?:[3-57]\\d\\d|800)\\d{6}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["70"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["32"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[57]"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[348]"],"0$1"]],"0"],GF:["594","00","(?:[56]94\\d|7093)\\d{5}|(?:80|9\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-7]|9[47]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[89]"],"0$1"]],"0"],GG:["44","00","(?:1481|[357-9]\\d{3})\\d{6}|8\\d{6}(?:\\d{2})?",[7,9,10],0,"0",0,"([25-9]\\d{5})$|0","1481$1",0,0,[["1481[25-9]\\d{5}",[10]],["7(?:(?:781|839)\\d|911[17])\\d{5}",[10]],["80[08]\\d{7}|800\\d{6}|8001111"],["(?:8(?:4[2-5]|7[0-3])|9(?:[01]\\d|8[0-3]))\\d{7}|845464\\d",[7,10]],["70\\d{8}",[10]],0,["(?:3[0347]|55)\\d{8}",[10]],["76(?:464|652)\\d{5}|76(?:0[0-28]|2[356]|34|4[01347]|5[49]|6[0-369]|77|8[14]|9[139])\\d{6}",[10]],["56\\d{8}",[10]]]],GH:["233","00","(?:[235]\\d{3}|800)\\d{5}",[8,9],[["(\\d{3})(\\d{5})","$1 $2",["8"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[235]"],"0$1"]],"0"],GI:["350","00","(?:[25]\\d|60)\\d{6}",[8],[["(\\d{3})(\\d{5})","$1 $2",["2"]]]],GL:["299","00","(?:19|[2-689]\\d|70)\\d{4}",[6],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["19|[2-9]"]]]],GM:["220","00","[2-9]\\d{6}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-9]"]]]],GN:["224","00","722\\d{6}|(?:3|6\\d)\\d{7}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["3"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[67]"]]]],GP:["590","00","(?:590\\d|7090)\\d{5}|(?:69|80|9\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-79]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0$1"]],"0",0,0,0,0,0,[["590(?:0[1-68]|[14][0-24-9]|2[0-68]|3[1-9]|5[3-579]|[68][0-689]|7[08]|9\\d)\\d{4}"],["(?:69(?:0\\d\\d|1(?:2[2-9]|3[0-5])|4(?:0[89]|1[2-6]|9\\d)|6(?:1[016-9]|5[0-4]|[67]\\d))|7090[0-4])\\d{4}"],["80[0-5]\\d{6}"],0,0,0,0,0,["9(?:(?:39[5-7]|76[018])\\d|475[0-6])\\d{4}"]]],GQ:["240","00","222\\d{6}|(?:3\\d|55|[89]0)\\d{7}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[235]"]],["(\\d{3})(\\d{6})","$1 $2",["[89]"]]]],GR:["30","00","5005000\\d{3}|8\\d{9,11}|(?:[269]\\d|70)\\d{8}",[10,11,12],[["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["21|7"]],["(\\d{4})(\\d{6})","$1 $2",["2(?:2|3[2-57-9]|4[2-469]|5[2-59]|6[2-9]|7[2-69]|8[2-49])|5"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[2689]"]],["(\\d{3})(\\d{3,4})(\\d{5})","$1 $2 $3",["8"]]]],GT:["502","00","80\\d{6}|(?:1\\d{3}|[2-7])\\d{7}",[8,11],[["(\\d{4})(\\d{4})","$1 $2",["[2-8]"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]]]],GU:["1","011","(?:[58]\\d\\d|671|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","671$1",0,"671"],GW:["245","00","[49]\\d{8}|4\\d{6}",[7,9],[["(\\d{3})(\\d{4})","$1 $2",["40"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[49]"]]]],GY:["592","001","(?:[2-8]\\d{3}|9008)\\d{3}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-9]"]]]],HK:["852","00(?:30|5[09]|[126-9]?)","8[0-46-9]\\d{6,7}|9\\d{4,7}|(?:[2-7]|9\\d{3})\\d{7}",[5,6,7,8,9,11],[["(\\d{3})(\\d{2,5})","$1 $2",["900","9003"]],["(\\d{4})(\\d{4})","$1 $2",["[2-7]|8[1-4]|9(?:0[1-9]|[1-8])"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"]],["(\\d{3})(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3 $4",["9"]]],0,0,0,0,0,0,0,"00"],HN:["504","00","8\\d{10}|[237-9]\\d{7}",[8,11],[["(\\d{4})(\\d{4})","$1-$2",["[237-9]"]]]],HR:["385","00","[2-69]\\d{8}|80\\d{5,7}|[1-79]\\d{7}|6\\d{6}",[7,8,9],[["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["6[01]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2,3})","$1 $2 $3",["8"],"0$1"],["(\\d)(\\d{4})(\\d{3})","$1 $2 $3",["1"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["6|7[245]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["9"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-57]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"],"0$1"]],"0"],HT:["509","00","(?:[2-489]\\d|55)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["[2-589]"]]]],HU:["36","00","[235-7]\\d{8}|[1-9]\\d{7}",[8,9],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["1"],"(06 $1)"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[27][2-9]|3[2-7]|4[24-9]|5[2-79]|6|8[2-57-9]|9[2-69]"],"(06 $1)"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-9]"],"06 $1"]],"06"],ID:["62","00[89]","00[1-9]\\d{9,14}|(?:[1-36]|8\\d{5})\\d{6}|00\\d{9}|[1-9]\\d{8,10}|[2-9]\\d{7}",[7,8,9,10,11,12,13,14,15,16,17],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["15"]],["(\\d{2})(\\d{5,9})","$1 $2",["2[124]|[36]1"],"(0$1)"],["(\\d{3})(\\d{5,7})","$1 $2",["800"],"0$1"],["(\\d{3})(\\d{5,8})","$1 $2",["[2-79]"],"(0$1)"],["(\\d{3})(\\d{3,4})(\\d{3})","$1-$2-$3",["8[1-35-9]"],"0$1"],["(\\d{3})(\\d{6,8})","$1 $2",["1"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["804"],"0$1"],["(\\d{3})(\\d)(\\d{3})(\\d{3})","$1 $2 $3 $4",["80"],"0$1"],["(\\d{3})(\\d{4})(\\d{4,5})","$1-$2-$3",["8"],"0$1"]],"0"],IE:["353","00","(?:1\\d|[2569])\\d{6,8}|4\\d{6,9}|7\\d{8}|8\\d{8,9}",[7,8,9,10],[["(\\d{2})(\\d{5})","$1 $2",["2[24-9]|47|58|6[237-9]|9[35-9]"],"(0$1)"],["(\\d{3})(\\d{5})","$1 $2",["[45]0"],"(0$1)"],["(\\d)(\\d{3,4})(\\d{4})","$1 $2 $3",["1"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2569]|4[1-69]|7[14]"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["70"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["81"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[78]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["4"],"(0$1)"],["(\\d{2})(\\d)(\\d{3})(\\d{4})","$1 $2 $3 $4",["8"],"0$1"]],"0"],IL:["972","0(?:0|1[2-9])","1\\d{6}(?:\\d{3,5})?|[57]\\d{8}|[1-489]\\d{7}",[7,8,9,10,11,12],[["(\\d{4})(\\d{3})","$1-$2",["125"]],["(\\d{4})(\\d{2})(\\d{2})","$1-$2-$3",["121"]],["(\\d)(\\d{3})(\\d{4})","$1-$2-$3",["[2-489]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["[57]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1-$2-$3",["12"]],["(\\d{4})(\\d{6})","$1-$2",["159"]],["(\\d)(\\d{3})(\\d{3})(\\d{3})","$1-$2-$3-$4",["1[7-9]"]],["(\\d{3})(\\d{1,2})(\\d{3})(\\d{4})","$1-$2 $3-$4",["15"]]],"0"],IM:["44","00","1624\\d{6}|(?:[3578]\\d|90)\\d{8}",[10],0,"0",0,"([25-8]\\d{5})$|0","1624$1",0,"74576|(?:16|7[56])24"],IN:["91","00","(?:000800|[2-9]\\d\\d)\\d{7}|1\\d{7,12}",[8,9,10,11,12,13],[["(\\d{8})","$1",["5(?:0|2[23]|3[03]|[67]1|88)","5(?:0|2(?:21|3)|3(?:0|3[23])|616|717|888)","5(?:0|2(?:21|3)|3(?:0|3[23])|616|717|8888)"],0,1],["(\\d{4})(\\d{4,5})","$1 $2",["180","1800"],0,1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["140"],0,1],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["11|2[02]|33|4[04]|79[1-7]|80[2-46]","11|2[02]|33|4[04]|79(?:[1-6]|7[19])|80(?:[2-4]|6[0-589])","11|2[02]|33|4[04]|79(?:[124-6]|3(?:[02-9]|1[0-24-9])|7(?:1|9[1-6]))|80(?:[2-4]|6[0-589])"],"0$1",1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["1(?:2[0-249]|3[0-25]|4[145]|[68]|7[1257])|2(?:1[257]|3[013]|4[01]|5[0137]|6[0158]|78|8[1568])|3(?:26|4[1-3]|5[34]|6[01489]|7[02-46]|8[159])|4(?:1[36]|2[1-47]|5[12]|6[0-26-9]|7[0-24-9]|8[013-57]|9[014-7])|5(?:1[025]|22|[36][25]|4[28]|5[12]|[78]1)|6(?:12|[2-4]1|5[17]|6[13]|80)|7(?:12|3[134]|4[47]|61|88)|8(?:16|2[014]|3[126]|6[136]|7[078]|8[34]|91)|(?:43|59|75)[15]|(?:1[59]|29|67|72)[14]","1(?:2[0-24]|3[0-25]|4[145]|[59][14]|6[1-9]|7[1257]|8[1-57-9])|2(?:1[257]|3[013]|4[01]|5[0137]|6[058]|78|8[1568]|9[14])|3(?:26|4[1-3]|5[34]|6[01489]|7[02-46]|8[159])|4(?:1[36]|2[1-47]|3[15]|5[12]|6[0-26-9]|7[0-24-9]|8[013-57]|9[014-7])|5(?:1[025]|22|[36][25]|4[28]|[578]1|9[15])|674|7(?:(?:2[14]|3[34]|5[15])[2-6]|61[346]|88[0-8])|8(?:70[2-6]|84[235-7]|91[3-7])|(?:1(?:29|60|8[06])|261|552|6(?:12|[2-47]1|5[17]|6[13]|80)|7(?:12|31|4[47])|8(?:16|2[014]|3[126]|6[136]|7[78]|83))[2-7]","1(?:2[0-24]|3[0-25]|4[145]|[59][14]|6[1-9]|7[1257]|8[1-57-9])|2(?:1[257]|3[013]|4[01]|5[0137]|6[058]|78|8[1568]|9[14])|3(?:26|4[1-3]|5[34]|6[01489]|7[02-46]|8[159])|4(?:1[36]|2[1-47]|3[15]|5[12]|6[0-26-9]|7[0-24-9]|8[013-57]|9[014-7])|5(?:1[025]|22|[36][25]|4[28]|[578]1|9[15])|6(?:12(?:[2-6]|7[0-8])|74[2-7])|7(?:(?:2[14]|5[15])[2-6]|3171|61[346]|88(?:[2-7]|82))|8(?:70[2-6]|84(?:[2356]|7[19])|91(?:[3-6]|7[19]))|73[134][2-6]|(?:74[47]|8(?:16|2[014]|3[126]|6[136]|7[78]|83))(?:[2-6]|7[19])|(?:1(?:29|60|8[06])|261|552|6(?:[2-4]1|5[17]|6[13]|7(?:1|4[0189])|80)|7(?:12|88[01]))[2-7]"],"0$1",1],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1(?:[2-479]|5[0235-9])|[2-5]|6(?:1[1358]|2[2457-9]|3[2-5]|4[235-7]|5[2-689]|6[24578]|7[235689]|8[1-6])|7(?:1[013-9]|28|3[129]|4[1-35689]|5[29]|6[02-5]|70)|807","1(?:[2-479]|5[0235-9])|[2-5]|6(?:1[1358]|2(?:[2457]|84|95)|3(?:[2-4]|55)|4[235-7]|5[2-689]|6[24578]|7[235689]|8[1-6])|7(?:1(?:[013-8]|9[6-9])|28[6-8]|3(?:17|2[0-49]|9[2-57])|4(?:1[2-4]|[29][0-7]|3[0-8]|[56]|8[0-24-7])|5(?:2[1-3]|9[0-6])|6(?:0[5689]|2[5-9]|3[02-8]|4|5[0-367])|70[13-7])|807[19]","1(?:[2-479]|5(?:[0236-9]|5[013-9]))|[2-5]|6(?:2(?:84|95)|355|83)|73179|807(?:1|9[1-3])|(?:1552|6(?:1[1358]|2[2457]|3[2-4]|4[235-7]|5[2-689]|6[24578]|7[235689]|8[124-6])\\d|7(?:1(?:[013-8]\\d|9[6-9])|28[6-8]|3(?:2[0-49]|9[2-57])|4(?:1[2-4]|[29][0-7]|3[0-8]|[56]\\d|8[0-24-7])|5(?:2[1-3]|9[0-6])|6(?:0[5689]|2[5-9]|3[02-8]|4\\d|5[0-367])|70[13-7]))[2-7]"],"0$1",1],["(\\d{5})(\\d{5})","$1 $2",["[6-9]"],"0$1",1],["(\\d{4})(\\d{2,4})(\\d{4})","$1 $2 $3",["1(?:6|8[06])","1(?:6|8[06]0)"],0,1],["(\\d{4})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["18"],0,1]],"0"],IO:["246","00","3\\d{6}",[7],[["(\\d{3})(\\d{4})","$1 $2",["3"]]]],IQ:["964","00","(?:1|7\\d\\d)\\d{7}|[2-6]\\d{7,8}",[8,9,10],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-6]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"0$1"]],"0"],IR:["98","00","[1-9]\\d{9}|(?:[1-8]\\d\\d|9)\\d{3,4}",[4,5,6,7,10],[["(\\d{4,5})","$1",["96"],"0$1"],["(\\d{2})(\\d{4,5})","$1 $2",["(?:1[137]|2[13-68]|3[1458]|4[145]|5[1468]|6[16]|7[1467]|8[13467])[12689]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["9"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["[1-8]"],"0$1"]],"0"],IS:["354","00|1(?:0(?:01|[12]0)|100)","(?:38\\d|[4-9])\\d{6}",[7,9],[["(\\d{3})(\\d{4})","$1 $2",["[4-9]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["3"]]],0,0,0,0,0,0,0,"00"],IT:["39","00","0\\d{5,10}|1\\d{8,10}|3(?:[0-8]\\d{7,10}|9\\d{7,8})|(?:43|55|70)\\d{8}|8\\d{5}(?:\\d{2,4})?",[6,7,8,9,10,11,12],[["(\\d{2})(\\d{4,6})","$1 $2",["0[26]"]],["(\\d{3})(\\d{3,6})","$1 $2",["0[13-57-9][0159]|8(?:03|4[17]|9[2-5])","0[13-57-9][0159]|8(?:03|4[17]|9(?:2|3[04]|[45][0-4]))"]],["(\\d{4})(\\d{2,6})","$1 $2",["0(?:[13-579][2-46-8]|8[236-8])"]],["(\\d{4})(\\d{4})","$1 $2",["894"]],["(\\d{2})(\\d{3,4})(\\d{4})","$1 $2 $3",["0[26]|5"]],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["1(?:44|[679])|[378]|43"]],["(\\d{3})(\\d{3,4})(\\d{4})","$1 $2 $3",["0[13-57-9][0159]|14"]],["(\\d{2})(\\d{4})(\\d{5})","$1 $2 $3",["0[26]"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["0"]],["(\\d{3})(\\d{4})(\\d{4,5})","$1 $2 $3",["3"]]],0,0,0,0,0,0,[["0669[0-79]\\d{1,6}|0(?:1(?:[0159]\\d|[27][1-5]|31|4[1-4]|6[1356]|8[2-57])|2\\d\\d|3(?:[0159]\\d|2[1-4]|3[12]|[48][1-6]|6[2-59]|7[1-7])|4(?:[0159]\\d|[23][1-9]|4[245]|6[1-5]|7[1-4]|81)|5(?:[0159]\\d|2[1-5]|3[2-6]|4[1-79]|6[4-6]|7[1-578]|8[3-8])|6(?:[0-57-9]\\d|6[0-8])|7(?:[0159]\\d|2[12]|3[1-7]|4[2-46]|6[13569]|7[13-6]|8[1-59])|8(?:[0159]\\d|2[3-578]|3[1-356]|[6-8][1-5])|9(?:[0159]\\d|[238][1-5]|4[12]|6[1-8]|7[1-6]))\\d{2,7}",[6,7,8,9,10,11]],["3[2-9]\\d{7,8}|(?:31|43)\\d{8}",[9,10]],["80(?:0\\d{3}|3)\\d{3}",[6,9]],["(?:0878\\d{3}|89(?:2\\d|3[04]|4(?:[0-4]|[5-9]\\d\\d)|5[0-4]))\\d\\d|(?:1(?:44|6[346])|89(?:38|5[5-9]|9))\\d{6}",[6,8,9,10]],["1(?:78\\d|99)\\d{6}",[9,10]],["3[2-8]\\d{9,10}",[11,12]],0,0,["55\\d{8}",[10]],["84(?:[08]\\d{3}|[17])\\d{3}",[6,9]]]],JE:["44","00","1534\\d{6}|(?:[3578]\\d|90)\\d{8}",[10],0,"0",0,"([0-24-8]\\d{5})$|0","1534$1",0,0,[["1534[0-24-8]\\d{5}"],["7(?:(?:(?:50|82)9|937)\\d|7(?:00[378]|97\\d))\\d{5}"],["80(?:07(?:35|81)|8901)\\d{4}"],["(?:8(?:4(?:4(?:4(?:05|42|69)|703)|5(?:041|800))|7(?:0002|1206))|90(?:066[59]|1810|71(?:07|55)))\\d{4}"],["701511\\d{4}"],0,["(?:3(?:0(?:07(?:35|81)|8901)|3\\d{4}|4(?:4(?:4(?:05|42|69)|703)|5(?:041|800))|7(?:0002|1206))|55\\d{4})\\d{4}"],["76(?:464|652)\\d{5}|76(?:0[0-28]|2[356]|34|4[01347]|5[49]|6[0-369]|77|8[14]|9[139])\\d{6}"],["56\\d{8}"]]],JM:["1","011","(?:[58]\\d\\d|658|900)\\d{7}",[10],0,"1",0,0,0,0,"658|876"],JO:["962","00","(?:(?:[2689]|7\\d)\\d|32|53)\\d{6}",[8,9],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[2356]|87"],"(0$1)"],["(\\d{3})(\\d{5,6})","$1 $2",["[89]"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["70"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["7"],"0$1"]],"0"],JP:["81","010","00[1-9]\\d{6,14}|[257-9]\\d{9}|(?:00|[1-9]\\d\\d)\\d{6}",[8,9,10,11,12,13,14,15,16,17],[["(\\d{3})(\\d{3})(\\d{3})","$1-$2-$3",["(?:12|57|99)0"],"0$1"],["(\\d{4})(\\d)(\\d{4})","$1-$2-$3",["1(?:26|3[79]|4[56]|5[4-68]|6[3-5])|499|5(?:76|97)|746|8(?:3[89]|47|51)|9(?:80|9[16])","1(?:267|3(?:7[247]|9[278])|466|5(?:47|58|64)|6(?:3[245]|48|5[4-68]))|499[2468]|5(?:76|97)9|7468|8(?:3(?:8[7-9]|96)|477|51[2-9])|9(?:802|9(?:1[23]|69))|1(?:45|58)[67]","1(?:267|3(?:7[247]|9[278])|466|5(?:47|58|64)|6(?:3[245]|48|5[4-68]))|499[2468]|5(?:769|979[2-69])|7468|8(?:3(?:8[7-9]|96[2457-9])|477|51[2-9])|9(?:802|9(?:1[23]|69))|1(?:45|58)[67]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["60"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1-$2-$3",["[36]|4(?:2[09]|7[01])","[36]|4(?:2(?:0|9[02-69])|7(?:0[019]|1))"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["1(?:1|5[45]|77|88|9[69])|2(?:2[1-37]|3[0-269]|4[59]|5|6[24]|7[1-358]|8[1369]|9[0-38])|4(?:[28][1-9]|3[0-57]|[45]|6[248]|7[2-579]|9[29])|5(?:2|3[0459]|4[0-369]|5[29]|8[02389]|9[0-389])|7(?:2[02-46-9]|34|[58]|6[0249]|7[57]|9[2-6])|8(?:2[124589]|3[26-9]|49|51|6|7[0-468]|8[68]|9[019])|9(?:[23][1-9]|4[15]|5[138]|6[1-3]|7[156]|8[189]|9[1-489])","1(?:1|5(?:4[018]|5[017])|77|88|9[69])|2(?:2(?:[127]|3[014-9])|3[0-269]|4[59]|5(?:[1-3]|5[0-69]|9[19])|62|7(?:[1-35]|8[0189])|8(?:[16]|3[0134]|9[0-5])|9(?:[028]|17))|4(?:2(?:[13-79]|8[014-6])|3[0-57]|[45]|6[248]|7[2-47]|8[1-9]|9[29])|5(?:2|3(?:[045]|9[0-8])|4[0-369]|5[29]|8[02389]|9[0-3])|7(?:2[02-46-9]|34|[58]|6[0249]|7[57]|9(?:[23]|4[0-59]|5[01569]|6[0167]))|8(?:2(?:[1258]|4[0-39]|9[0-2469])|3(?:[29]|60)|49|51|6(?:[0-24]|36|5[0-3589]|7[23]|9[01459])|7[0-468]|8[68])|9(?:[23][1-9]|4[15]|5[138]|6[1-3]|7[156]|8[189]|9(?:[1289]|3[34]|4[0178]))|(?:264|837)[016-9]|2(?:57|93)[015-9]|(?:25[0468]|422|838)[01]|(?:47[59]|59[89]|8(?:6[68]|9))[019]","1(?:1|5(?:4[018]|5[017])|77|88|9[69])|2(?:2[127]|3[0-269]|4[59]|5(?:[1-3]|5[0-69]|9(?:17|99))|6(?:2|4[016-9])|7(?:[1-35]|8[0189])|8(?:[16]|3[0134]|9[0-5])|9(?:[028]|17))|4(?:2(?:[13-79]|8[014-6])|3[0-57]|[45]|6[248]|7[2-47]|9[29])|5(?:2|3(?:[045]|9(?:[0-58]|6[4-9]|7[0-35689]))|4[0-369]|5[29]|8[02389]|9[0-3])|7(?:2[02-46-9]|34|[58]|6[0249]|7[57]|9(?:[23]|4[0-59]|5[01569]|6[0167]))|8(?:2(?:[1258]|4[0-39]|9[0169])|3(?:[29]|60|7(?:[017-9]|6[6-8]))|49|51|6(?:[0-24]|36[2-57-9]|5(?:[0-389]|5[23])|6(?:[01]|9[178])|7(?:2[2-468]|3[78])|9[0145])|7[0-468]|8[68])|9(?:4[15]|5[138]|7[156]|8[189]|9(?:[1289]|3(?:31|4[357])|4[0178]))|(?:8294|96)[1-3]|2(?:57|93)[015-9]|(?:223|8699)[014-9]|(?:25[0468]|422|838)[01]|(?:48|8292|9[23])[1-9]|(?:47[59]|59[89]|8(?:68|9))[019]"],"0$1"],["(\\d{3})(\\d{2})(\\d{4})","$1-$2-$3",["[14]|[289][2-9]|5[3-9]|7[2-4679]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["800"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1-$2-$3",["[257-9]"],"0$1"]],"0",0,"(000[259]\\d{6})$|(?:(?:003768)0?)|0","$1"],KE:["254","000","(?:[17]\\d\\d|900)\\d{6}|(?:2|80)0\\d{6,7}|[4-6]\\d{6,8}",[7,8,9,10],[["(\\d{2})(\\d{5,7})","$1 $2",["[24-6]"],"0$1"],["(\\d{3})(\\d{6})","$1 $2",["[17]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[89]"],"0$1"]],"0"],KG:["996","00","8\\d{9}|[235-9]\\d{8}",[9,10],[["(\\d{4})(\\d{5})","$1 $2",["3(?:1[346]|[24-79])"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[235-79]|88"],"0$1"],["(\\d{3})(\\d{3})(\\d)(\\d{2,3})","$1 $2 $3 $4",["8"],"0$1"]],"0"],KH:["855","00[14-9]","1\\d{9}|[1-9]\\d{7,8}",[8,9,10],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[1-9]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]]],"0"],KI:["686","00","(?:[37]\\d|6[0-79])\\d{6}|(?:[2-48]\\d|50)\\d{3}",[5,8],0,"0"],KM:["269","00","[3478]\\d{6}",[7],[["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["[3478]"]]]],KN:["1","011","(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-7]\\d{6})$|1","869$1",0,"869"],KP:["850","00|99","85\\d{6}|(?:19\\d|[2-7])\\d{7}",[8,10],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["8"],"0$1"],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[2-7]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"]],"0"],KR:["82","00(?:[125689]|3(?:[46]5|91)|7(?:00|27|3|55|6[126]))","00[1-9]\\d{8,11}|(?:[12]|5\\d{3})\\d{7}|[13-6]\\d{9}|(?:[1-6]\\d|80)\\d{7}|[3-6]\\d{4,5}|(?:00|7)0\\d{8}",[5,6,8,9,10,11,12,13,14],[["(\\d{2})(\\d{3,4})","$1-$2",["(?:3[1-3]|[46][1-4]|5[1-5])1"],"0$1"],["(\\d{4})(\\d{4})","$1-$2",["1"]],["(\\d)(\\d{3,4})(\\d{4})","$1-$2-$3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["[36]0|8"],"0$1"],["(\\d{2})(\\d{3,4})(\\d{4})","$1-$2-$3",["[1346]|5[1-5]"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1-$2-$3",["[57]"],"0$1"],["(\\d{2})(\\d{5})(\\d{4})","$1-$2-$3",["5"],"0$1"]],"0",0,"0(8(?:[1-46-8]|5\\d\\d))?"],KW:["965","00","18\\d{5}|(?:[2569]\\d|41)\\d{6}",[7,8],[["(\\d{4})(\\d{3,4})","$1 $2",["[169]|2(?:[235]|4[1-35-9])|52"]],["(\\d{3})(\\d{5})","$1 $2",["[245]"]]]],KY:["1","011","(?:345|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","345$1",0,"345"],KZ:["7","810","(?:33622|8\\d{8})\\d{5}|[78]\\d{9}",[10,14],0,"8",0,0,0,0,"33|7",0,"8~10"],LA:["856","00","[23]\\d{9}|3\\d{8}|(?:[235-8]\\d|41)\\d{6}",[8,9,10],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["2[13]|3[14]|[4-8]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3 $4",["3"],"0$1"],["(\\d{2})(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3 $4",["[23]"],"0$1"]],"0"],LB:["961","00","[27-9]\\d{7}|[13-9]\\d{6}",[7,8],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[13-69]|7(?:[2-57]|62|8[0-7]|9[04-9])|8[02-9]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[27-9]"]]],"0"],LC:["1","011","(?:[58]\\d\\d|758|900)\\d{7}",[10],0,"1",0,"([2-8]\\d{6})$|1","758$1",0,"758"],LI:["423","00","[68]\\d{8}|(?:[2378]\\d|90)\\d{5}",[7,9],[["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["[2379]|8(?:0[09]|7)","[2379]|8(?:0(?:02|9)|7)"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["69"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6"]]],"0",0,"(1001)|0"],LK:["94","00","[1-9]\\d{8}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[1-689]"],"0$1"]],"0"],LR:["231","00","(?:[245]\\d|33|77|88)\\d{7}|(?:2\\d|[4-6])\\d{6}",[7,8,9],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["4[67]|[56]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[2-578]"],"0$1"]],"0"],LS:["266","00","(?:[256]\\d\\d|800)\\d{5}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[2568]"]]]],LT:["370","00","(?:[3469]\\d|52|[78]0)\\d{6}",[8],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["52[0-7]"],"(0-$1)",1],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["[7-9]"],"0 $1",1],["(\\d{2})(\\d{6})","$1 $2",["37|4(?:[15]|6[1-8])"],"(0-$1)",1],["(\\d{3})(\\d{5})","$1 $2",["[3-6]"],"(0-$1)",1]],"0",0,"[08]"],LU:["352","00","35[013-9]\\d{4,8}|6\\d{8}|35\\d{2,4}|(?:[2457-9]\\d|3[0-46-9])\\d{2,9}",[4,5,6,7,8,9,10,11],[["(\\d{2})(\\d{3})","$1 $2",["2(?:0[2-689]|[2-9])|[3-57]|8(?:0[2-9]|[13-9])|9(?:0[89]|[2-579])"]],["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["2(?:0[2-689]|[2-9])|[3-57]|8(?:0[2-9]|[13-9])|9(?:0[89]|[2-579])"]],["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["20[2-689]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{1,2})","$1 $2 $3 $4",["2(?:[0367]|4[3-8])"]],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["80[01]|90[015]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3 $4",["20"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{1,2})","$1 $2 $3 $4 $5",["2(?:[0367]|4[3-8])"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{1,5})","$1 $2 $3 $4",["[3-57]|8[13-9]|9(?:0[89]|[2-579])|(?:2|80)[2-9]"]]],0,0,"(15(?:0[06]|1[12]|[35]5|4[04]|6[26]|77|88|99)\\d)"],LV:["371","00","(?:[268]\\d|90)\\d{6}",[8],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[269]|8[01]"]]]],LY:["218","00","[2-9]\\d{8}",[9],[["(\\d{2})(\\d{7})","$1-$2",["[2-9]"],"0$1"]],"0"],MA:["212","00","[5-8]\\d{8}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["5[45]"],"0$1"],["(\\d{4})(\\d{5})","$1-$2",["5(?:2[2-46-9]|3[3-9]|9)|8(?:0[89]|92)"],"0$1"],["(\\d{2})(\\d{7})","$1-$2",["8"],"0$1"],["(\\d{3})(\\d{6})","$1-$2",["[5-7]"],"0$1"]],"0",0,0,0,0,0,[["5(?:2(?:[0-25-79]\\d|3[1-578]|4[02-46-8]|8[0235-7])|3(?:[0-47]\\d|5[02-9]|6[02-8]|8[014-9]|9[3-9])|(?:4[067]|5[03])\\d)\\d{5}"],["(?:6(?:[0-79]\\d|8[0-247-9])|7(?:[0167]\\d|2[0-467]|5[0-3]|8[0-7]))\\d{6}"],["80[0-7]\\d{6}"],["89\\d{7}"],0,0,0,0,["(?:592(?:4[0-2]|93)|80[89]\\d\\d)\\d{4}"]]],MC:["377","00","(?:[3489]|6\\d)\\d{7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["4"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[389]"]],["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["6"],"0$1"]],"0"],MD:["373","00","(?:[235-7]\\d|[89]0)\\d{6}",[8],[["(\\d{3})(\\d{5})","$1 $2",["[89]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["22|3"],"0$1"],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["[25-7]"],"0$1"]],"0"],ME:["382","00","(?:20|[3-79]\\d)\\d{6}|80\\d{6,7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-9]"],"0$1"]],"0"],MF:["590","00","(?:590\\d|7090)\\d{5}|(?:69|80|9\\d)\\d{7}",[9],0,"0",0,0,0,0,0,[["590(?:0[079]|[14]3|[27][79]|3[03-7]|5[0-268]|87)\\d{4}"],["(?:69(?:0\\d\\d|1(?:2[2-9]|3[0-5])|4(?:0[89]|1[2-6]|9\\d)|6(?:1[016-9]|5[0-4]|[67]\\d))|7090[0-4])\\d{4}"],["80[0-5]\\d{6}"],0,0,0,0,0,["9(?:(?:39[5-7]|76[018])\\d|475[0-6])\\d{4}"]]],MG:["261","00","[23]\\d{8}",[9],[["(\\d{2})(\\d{2})(\\d{3})(\\d{2})","$1 $2 $3 $4",["[23]"],"0$1"]],"0",0,"([24-9]\\d{6})$|0","20$1"],MH:["692","011","329\\d{4}|(?:[256]\\d|45)\\d{5}",[7],[["(\\d{3})(\\d{4})","$1-$2",["[2-6]"]]],"1"],MK:["389","00","[2-578]\\d{7}",[8],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["2|34[47]|4(?:[37]7|5[47]|64)"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[347]"],"0$1"],["(\\d{3})(\\d)(\\d{2})(\\d{2})","$1 $2 $3 $4",["[58]"],"0$1"]],"0"],ML:["223","00","[24-9]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[24-9]"]]]],MM:["95","00","1\\d{5,7}|95\\d{6}|(?:[4-7]|9[0-46-9])\\d{6,8}|(?:2|8\\d)\\d{5,8}",[6,7,8,9,10],[["(\\d)(\\d{2})(\\d{3})","$1 $2 $3",["16|2"],"0$1"],["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["4(?:[2-46]|5[3-5])|5|6(?:[1-689]|7[235-7])|7(?:[0-4]|5[2-7])|8[1-5]|(?:60|86)[23]"],"0$1"],["(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["[12]|452|678|86","[12]|452|6788|86"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[4-7]|8[1-35]"],"0$1"],["(\\d)(\\d{3})(\\d{4,6})","$1 $2 $3",["9(?:2[0-4]|[35-9]|4[137-9])"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"],"0$1"],["(\\d)(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["92"],"0$1"],["(\\d)(\\d{5})(\\d{4})","$1 $2 $3",["9"],"0$1"]],"0"],MN:["976","001","[12]\\d{7,9}|[5-9]\\d{7}",[8,9,10],[["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["[12]1"],"0$1"],["(\\d{4})(\\d{4})","$1 $2",["[5-9]"]],["(\\d{3})(\\d{5,6})","$1 $2",["[12]2[1-3]"],"0$1"],["(\\d{4})(\\d{5,6})","$1 $2",["[12](?:27|3[2-8]|4[2-68]|5[1-4689])","[12](?:27|3[2-8]|4[2-68]|5[1-4689])[0-3]"],"0$1"],["(\\d{5})(\\d{4,5})","$1 $2",["[12]"],"0$1"]],"0"],MO:["853","00","0800\\d{3}|(?:28|[68]\\d)\\d{6}",[7,8],[["(\\d{4})(\\d{3})","$1 $2",["0"]],["(\\d{4})(\\d{4})","$1 $2",["[268]"]]]],MP:["1","011","[58]\\d{9}|(?:67|90)0\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","670$1",0,"670"],MQ:["596","00","(?:596\\d|7091)\\d{5}|(?:69|[89]\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-79]|8(?:0[6-9]|[36])"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0$1"]],"0"],MR:["222","00","(?:[2-4]\\d\\d|800)\\d{5}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-48]"]]]],MS:["1","011","(?:[58]\\d\\d|664|900)\\d{7}",[10],0,"1",0,"([34]\\d{6})$|1","664$1",0,"664"],MT:["356","00","3550\\d{4}|(?:[2579]\\d\\d|800)\\d{5}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[2357-9]"]]]],MU:["230","0(?:0|[24-7]0|3[03])","(?:[57]|8\\d\\d)\\d{7}|[2-468]\\d{6}",[7,8,10],[["(\\d{3})(\\d{4})","$1 $2",["[2-46]|8[013]"]],["(\\d{4})(\\d{4})","$1 $2",["[57]"]],["(\\d{5})(\\d{5})","$1 $2",["8"]]],0,0,0,0,0,0,0,"020"],MV:["960","0(?:0|19)","(?:800|9[0-57-9]\\d)\\d{7}|[34679]\\d{6}",[7,10],[["(\\d{3})(\\d{4})","$1-$2",["[34679]"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[89]"]]],0,0,0,0,0,0,0,"00"],MW:["265","00","(?:[1289]\\d|31|77)\\d{7}|1\\d{6}",[7,9],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["1[2-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["2"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[137-9]"],"0$1"]],"0"],MX:["52","0[09]","[2-9]\\d{9}",[10],[["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["33|5[56]|81"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[2-9]"]]],0,0,0,0,0,0,0,"00"],MY:["60","00","1\\d{8,9}|(?:3\\d|[4-9])\\d{7}",[8,9,10],[["(\\d)(\\d{3})(\\d{4})","$1-$2 $3",["[4-79]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1-$2 $3",["1(?:[02469]|[378][1-9]|53)|8","1(?:[02469]|[37][1-9]|53|8(?:[1-46-9]|5[7-9]))|8"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1-$2 $3",["3"],"0$1"],["(\\d)(\\d{3})(\\d{2})(\\d{4})","$1-$2-$3-$4",["1(?:[367]|80)"]],["(\\d{3})(\\d{3})(\\d{4})","$1-$2 $3",["15"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1-$2 $3",["1"],"0$1"]],"0"],MZ:["258","00","(?:2|8\\d)\\d{7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["2|8[2-79]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"]]]],NA:["264","00","[68]\\d{7,8}",[8,9],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["88"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["6"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["87"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["8"],"0$1"]],"0"],NC:["687","00","(?:050|[2-57-9]\\d\\d)\\d{3}",[6],[["(\\d{2})(\\d{2})(\\d{2})","$1.$2.$3",["[02-57-9]"]]]],NE:["227","00","[027-9]\\d{7}",[8],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["08"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[089]|2[013]|7[0467]"]]]],NF:["672","00","[13]\\d{5}",[6],[["(\\d{2})(\\d{4})","$1 $2",["1[0-3]"]],["(\\d)(\\d{5})","$1 $2",["[13]"]]],0,0,"([0-258]\\d{4})$","3$1"],NG:["234","009","(?:20|9\\d)\\d{8}|[78]\\d{9,13}",[10,11,12,13,14],[["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[7-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["20[129]"],"0$1"],["(\\d{4})(\\d{2})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{3})(\\d{4})(\\d{4,5})","$1 $2 $3",["[78]"],"0$1"],["(\\d{3})(\\d{5})(\\d{5,6})","$1 $2 $3",["[78]"],"0$1"]],"0"],NI:["505","00","(?:1800|[25-8]\\d{3})\\d{4}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[125-8]"]]]],NL:["31","00","(?:[124-7]\\d\\d|3(?:[02-9]\\d|1[0-8]))\\d{6}|8\\d{6,9}|9\\d{6,10}|1\\d{4,5}",[5,6,7,8,9,10,11],[["(\\d{3})(\\d{4,7})","$1 $2",["[89]0"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["66"],"0$1"],["(\\d)(\\d{8})","$1 $2",["6"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["1[16-8]|2[259]|3[124]|4[17-9]|5[124679]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[1-578]|91"],"0$1"],["(\\d{3})(\\d{3})(\\d{5})","$1 $2 $3",["9"],"0$1"]],"0"],NO:["47","00","(?:0|[2-9]\\d{3})\\d{4}",[5,8],[["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["8"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-79]"]]],0,0,0,0,0,"[02-689]|7[0-8]"],NP:["977","00","(?:1\\d|9)\\d{9}|[1-9]\\d{7}",[8,10,11],[["(\\d)(\\d{7})","$1-$2",["1[2-6]"],"0$1"],["(\\d{2})(\\d{6})","$1-$2",["1[01]|[2-8]|9(?:[1-59]|[67][2-6])"],"0$1"],["(\\d{3})(\\d{7})","$1-$2",["9"]]],"0"],NR:["674","00","(?:222|444|(?:55|8\\d)\\d|666|777|999)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[24-9]"]]]],NU:["683","00","(?:[4-7]|888\\d)\\d{3}",[4,7],[["(\\d{3})(\\d{4})","$1 $2",["8"]]]],NZ:["64","0(?:0|161)","[1289]\\d{9}|50\\d{5}(?:\\d{2,3})?|[27-9]\\d{7,8}|(?:[34]\\d|6[0-35-9])\\d{6}|8\\d{4,6}",[5,6,7,8,9,10],[["(\\d{2})(\\d{3,8})","$1 $2",["8[1-79]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2,3})","$1 $2 $3",["50[036-8]|8|90","50(?:[0367]|88)|8|90"],"0$1"],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["24|[346]|7[2-57-9]|9[2-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["2(?:10|74)|[589]"],"0$1"],["(\\d{2})(\\d{3,4})(\\d{4})","$1 $2 $3",["1|2[028]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,5})","$1 $2 $3",["2(?:[169]|7[0-35-9])|7"],"0$1"]],"0",0,0,0,0,0,0,"00"],OM:["968","00","(?:1505|[279]\\d{3}|500)\\d{4}|800\\d{5,6}",[7,8,9],[["(\\d{3})(\\d{4,6})","$1 $2",["[58]"]],["(\\d{2})(\\d{6})","$1 $2",["2"]],["(\\d{4})(\\d{4})","$1 $2",["[179]"]]]],PA:["507","00","(?:00800|8\\d{3})\\d{6}|[68]\\d{7}|[1-57-9]\\d{6}",[7,8,10,11],[["(\\d{3})(\\d{4})","$1-$2",["[1-57-9]"]],["(\\d{4})(\\d{4})","$1-$2",["[68]"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"]]]],PE:["51","00|19(?:1[124]|77|90)00","(?:[14-8]|9\\d)\\d{7}",[8,9],[["(\\d{3})(\\d{5})","$1 $2",["80"],"(0$1)"],["(\\d)(\\d{7})","$1 $2",["1"],"(0$1)"],["(\\d{2})(\\d{6})","$1 $2",["[4-8]"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["9"]]],"0",0,0,0,0,0,0,"00"," Anexo "],PF:["689","00","4\\d{5}(?:\\d{2})?|8\\d{7,8}",[6,8,9],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["44"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["4|8[7-9]"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"]]]],PG:["675","00|140[1-3]","(?:180|[78]\\d{3})\\d{4}|(?:[2-589]\\d|64)\\d{5}",[7,8],[["(\\d{3})(\\d{4})","$1 $2",["18|[2-69]|85"]],["(\\d{4})(\\d{4})","$1 $2",["[78]"]]],0,0,0,0,0,0,0,"00"],PH:["63","00","(?:[2-7]|9\\d)\\d{8}|2\\d{5}|(?:1800|8)\\d{7,9}",[6,8,9,10,11,12,13],[["(\\d)(\\d{5})","$1 $2",["2"],"(0$1)"],["(\\d{4})(\\d{4,6})","$1 $2",["3(?:23|39|46)|4(?:2[3-6]|[35]9|4[26]|76)|544|88[245]|(?:52|64|86)2","3(?:230|397|461)|4(?:2(?:35|[46]4|51)|396|4(?:22|63)|59[347]|76[15])|5(?:221|446)|642[23]|8(?:622|8(?:[24]2|5[13]))"],"(0$1)"],["(\\d{5})(\\d{4})","$1 $2",["346|4(?:27|9[35])|883","3469|4(?:279|9(?:30|56))|8834"],"(0$1)"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["2"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[3-7]|8[2-8]"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[89]"],"0$1"],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]],["(\\d{4})(\\d{1,2})(\\d{3})(\\d{4})","$1 $2 $3 $4",["1"]]],"0"],PK:["92","00","122\\d{6}|[24-8]\\d{10,11}|9(?:[013-9]\\d{8,10}|2(?:[01]\\d\\d|2(?:[06-8]\\d|1[01]))\\d{7})|(?:[2-8]\\d{3}|92(?:[0-7]\\d|8[1-9]))\\d{6}|[24-9]\\d{8}|[89]\\d{7}",[8,9,10,11,12],[["(\\d{3})(\\d{3})(\\d{2,7})","$1 $2 $3",["[89]0"],"0$1"],["(\\d{4})(\\d{5})","$1 $2",["1"]],["(\\d{3})(\\d{6,7})","$1 $2",["2(?:3[2358]|4[2-4]|9[2-8])|45[3479]|54[2-467]|60[468]|72[236]|8(?:2[2-689]|3[23578]|4[3478]|5[2356])|9(?:2[2-8]|3[27-9]|4[2-6]|6[3569]|9[25-8])","9(?:2[3-8]|98)|(?:2(?:3[2358]|4[2-4]|9[2-8])|45[3479]|54[2-467]|60[468]|72[236]|8(?:2[2-689]|3[23578]|4[3478]|5[2356])|9(?:22|3[27-9]|4[2-6]|6[3569]|9[25-7]))[2-9]"],"(0$1)"],["(\\d{2})(\\d{7,8})","$1 $2",["(?:2[125]|4[0-246-9]|5[1-35-7]|6[1-8]|7[14]|8[16]|91)[2-9]"],"(0$1)"],["(\\d{5})(\\d{5})","$1 $2",["58"],"(0$1)"],["(\\d{3})(\\d{7})","$1 $2",["3"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["2[125]|4[0-246-9]|5[1-35-7]|6[1-8]|7[14]|8[16]|91"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["[24-9]"],"(0$1)"]],"0"],PL:["48","00","(?:6|8\\d\\d)\\d{7}|[1-9]\\d{6}(?:\\d{2})?|[26]\\d{5}",[6,7,8,9,10],[["(\\d{5})","$1",["19"]],["(\\d{3})(\\d{3})","$1 $2",["11|20|64"]],["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["(?:1[2-8]|2[2-69]|3[2-4]|4[1-468]|5[24-689]|6[1-3578]|7[14-7]|8[1-79]|9[145])1","(?:1[2-8]|2[2-69]|3[2-4]|4[1-468]|5[24-689]|6[1-3578]|7[14-7]|8[1-79]|9[145])19"]],["(\\d{3})(\\d{2})(\\d{2,3})","$1 $2 $3",["64"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["21|39|45|5[0137]|6[0469]|7[02389]|8(?:0[14]|8)"]],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[2-8]|[2-7]|8[1-79]|9[145]"]],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["8"]]]],PM:["508","00","[45]\\d{5}|(?:708|8\\d\\d)\\d{6}",[6,9],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["[45]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["7"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0$1"]],"0"],PR:["1","011","(?:[589]\\d\\d|787)\\d{7}",[10],0,"1",0,0,0,0,"787|939"],PS:["970","00","[2489]2\\d{6}|(?:1\\d|5)\\d{8}",[8,9,10],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[2489]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["5"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]]],"0"],PT:["351","00","1693\\d{5}|(?:[26-9]\\d|30)\\d{7}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["2[12]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["16|[236-9]"]]]],PW:["680","01[12]","(?:[24-8]\\d\\d|345|900)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-9]"]]]],PY:["595","00","59\\d{4,6}|9\\d{5,10}|(?:[2-46-8]\\d|5[0-8])\\d{4,7}",[6,7,8,9,10,11],[["(\\d{3})(\\d{3,6})","$1 $2",["[2-9]0"],"0$1"],["(\\d{2})(\\d{5})","$1 $2",["[26]1|3[289]|4[1246-8]|7[1-3]|8[1-36]"],"(0$1)"],["(\\d{3})(\\d{4,5})","$1 $2",["2[279]|3[13-5]|4[359]|5|6(?:[34]|7[1-46-8])|7[46-8]|85"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["2[14-68]|3[26-9]|4[1246-8]|6(?:1|75)|7[1-35]|8[1-36]"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["87"]],["(\\d{3})(\\d{6})","$1 $2",["9(?:[5-79]|8[1-7])"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[2-8]"],"0$1"],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["9"]]],"0"],QA:["974","00","800\\d{4}|(?:2|800)\\d{6}|(?:0080|[3-7])\\d{7}",[7,8,9,11],[["(\\d{3})(\\d{4})","$1 $2",["2[136]|8"]],["(\\d{4})(\\d{4})","$1 $2",["[3-7]"]]]],RE:["262","00","709\\d{6}|(?:26|[689]\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[26-9]"],"0$1"]],"0",0,0,0,0,0,[["26(?:2\\d\\d|3(?:0\\d|1[0-6]))\\d{4}"],["(?:69(?:2\\d\\d|3(?:[06][0-6]|1[0-3]|2[0-2]|3[0-39]|4\\d|5[0-5]|7[0-37]|8[0-8]|9[0-479]))|7092[0-3])\\d{4}"],["80\\d{7}"],["89[1-37-9]\\d{6}"],0,0,0,0,["9(?:399[0-3]|479[0-6]|76(?:2[278]|3[0-37]))\\d{4}"],["8(?:1[019]|2[0156]|84|90)\\d{6}"]]],RO:["40","00","(?:[236-8]\\d|90)\\d{7}|[23]\\d{5}",[6,9],[["(\\d{3})(\\d{3})","$1 $2",["2[3-6]","2[3-6]\\d9"],"0$1"],["(\\d{2})(\\d{4})","$1 $2",["219|31"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[23]1"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[236-9]"],"0$1"]],"0",0,0,0,0,0,0,0," int "],RS:["381","00","38[02-9]\\d{6,9}|6\\d{7,9}|90\\d{4,8}|38\\d{5,6}|(?:7\\d\\d|800)\\d{3,9}|(?:[12]\\d|3[0-79])\\d{5,10}",[6,7,8,9,10,11,12],[["(\\d{3})(\\d{3,9})","$1 $2",["(?:2[389]|39)0|[7-9]"],"0$1"],["(\\d{2})(\\d{5,10})","$1 $2",["[1-36]"],"0$1"]],"0"],RU:["7","810","8\\d{13}|[347-9]\\d{9}",[10,14],[["(\\d{4})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["7(?:1[0-8]|2[1-9])","7(?:1(?:[0-356]2|4[29]|7|8[27])|2(?:1[23]|[2-9]2))","7(?:1(?:[0-356]2|4[29]|7|8[27])|2(?:13[03-69]|62[013-9]))|72[1-57-9]2"],"8 ($1)",1],["(\\d{5})(\\d)(\\d{2})(\\d{2})","$1 $2 $3 $4",["7(?:1[0-68]|2[1-9])","7(?:1(?:[06][3-6]|[18]|2[35]|[3-5][3-5])|2(?:[13][3-5]|[24-689]|7[457]))","7(?:1(?:0(?:[356]|4[023])|[18]|2(?:3[013-9]|5)|3[45]|43[013-79]|5(?:3[1-8]|4[1-7]|5)|6(?:3[0-35-9]|[4-6]))|2(?:1(?:3[178]|[45])|[24-689]|3[35]|7[457]))|7(?:14|23)4[0-8]|71(?:33|45)[1-79]"],"8 ($1)",1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"8 ($1)",1],["(\\d{3})(\\d{3})(\\d{2})(\\d{2})","$1 $2-$3-$4",["[349]|8(?:[02-7]|1[1-8])"],"8 ($1)",1],["(\\d{4})(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3 $4",["8"],"8 ($1)"]],"8",0,0,0,0,"3[04-689]|[489]",0,"8~10"],RW:["250","00","(?:06|[27]\\d\\d|[89]00)\\d{6}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["0"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["2"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[7-9]"],"0$1"]],"0"],SA:["966","00","92\\d{7}|(?:[15]|8\\d)\\d{8}",[9,10],[["(\\d{4})(\\d{5})","$1 $2",["9"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["5"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["81"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"]]],"0"],SB:["677","0[01]","[6-9]\\d{6}|[1-6]\\d{4}",[5,7],[["(\\d{2})(\\d{5})","$1 $2",["6[89]|7|8[4-9]|9(?:[1-8]|9[0-8])"]]]],SC:["248","010|0[0-2]","(?:[2489]\\d|64)\\d{5}",[7],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[246]|9[57]"]]],0,0,0,0,0,0,0,"00"],SD:["249","00","[19]\\d{8}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[19]"],"0$1"]],"0"],SE:["46","00","(?:[26]\\d\\d|9)\\d{9}|[1-9]\\d{8}|[1-689]\\d{7}|[1-4689]\\d{6}|2\\d{5}",[6,7,8,9,10,12],[["(\\d{2})(\\d{2,3})(\\d{2})","$1-$2 $3",["20"],"0$1",0,"$1 $2 $3"],["(\\d{3})(\\d{4})","$1-$2",["9(?:00|39|44|9)"],"0$1",0,"$1 $2"],["(\\d{2})(\\d{3})(\\d{2})","$1-$2 $3",["[12][136]|3[356]|4[0246]|6[03]|90[1-9]"],"0$1",0,"$1 $2 $3"],["(\\d)(\\d{2,3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["8"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2,3})(\\d{2})","$1-$2 $3",["1[2457]|2(?:[247-9]|5[0138])|3[0247-9]|4[1357-9]|5[0-35-9]|6(?:[125689]|4[02-57]|7[0-2])|9(?:[125-8]|3[02-5]|4[0-3])"],"0$1",0,"$1 $2 $3"],["(\\d{3})(\\d{2,3})(\\d{3})","$1-$2 $3",["9(?:00|39|44)"],"0$1",0,"$1 $2 $3"],["(\\d{2})(\\d{2,3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["1[13689]|2[0136]|3[1356]|4[0246]|54|6[03]|90[1-9]"],"0$1",0,"$1 $2 $3 $4"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["10|7"],"0$1",0,"$1 $2 $3 $4"],["(\\d)(\\d{3})(\\d{3})(\\d{2})","$1-$2 $3 $4",["8"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1-$2 $3 $4",["[13-5]|2(?:[247-9]|5[0138])|6(?:[124-689]|7[0-2])|9(?:[125-8]|3[02-5]|4[0-3])"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{2})(\\d{3})","$1-$2 $3 $4",["9"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1-$2 $3 $4 $5",["[26]"],"0$1",0,"$1 $2 $3 $4 $5"]],"0"],SG:["65","0[0-3]\\d","(?:(?:1\\d|8)\\d\\d|7000)\\d{7}|[3689]\\d{7}",[8,10,11],[["(\\d{4})(\\d{4})","$1 $2",["[369]|8(?:0[1-9]|[1-9])"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"]],["(\\d{4})(\\d{4})(\\d{3})","$1 $2 $3",["7"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]]]],SH:["290","00","(?:[256]\\d|8)\\d{3}",[4,5],0,0,0,0,0,0,"[256]"],SI:["386","00|10(?:22|66|88|99)","[1-7]\\d{7}|8\\d{4,7}|90\\d{4,6}",[5,6,7,8],[["(\\d{2})(\\d{3,6})","$1 $2",["8[09]|9"],"0$1"],["(\\d{3})(\\d{5})","$1 $2",["59|8"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[37][01]|4[0139]|51|6"],"0$1"],["(\\d)(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[1-57]"],"(0$1)"]],"0",0,0,0,0,0,0,"00"],SJ:["47","00","0\\d{4}|(?:[489]\\d|79)\\d{6}",[5,8],0,0,0,0,0,0,"79"],SK:["421","00","[2-689]\\d{8}|[2-59]\\d{6}|[2-5]\\d{5}",[6,7,9],[["(\\d)(\\d{2})(\\d{3,4})","$1 $2 $3",["21"],"0$1"],["(\\d{2})(\\d{2})(\\d{2,3})","$1 $2 $3",["[3-5][1-8]1","[3-5][1-8]1[67]"],"0$1"],["(\\d)(\\d{3})(\\d{3})(\\d{2})","$1/$2 $3 $4",["2"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[689]"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1/$2 $3 $4",["[3-5]"],"0$1"]],"0"],SL:["232","00","(?:[237-9]\\d|66)\\d{6}",[8],[["(\\d{2})(\\d{6})","$1 $2",["[236-9]"],"(0$1)"]],"0"],SM:["378","00","(?:0549|[5-7]\\d)\\d{6}",[8,10],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-7]"]],["(\\d{4})(\\d{6})","$1 $2",["0"]]],0,0,"([89]\\d{5})$","0549$1"],SN:["221","00","(?:[378]\\d|93)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"]],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[379]"]]]],SO:["252","00","[346-9]\\d{8}|[12679]\\d{7}|[1-5]\\d{6}|[1348]\\d{5}",[6,7,8,9],[["(\\d{2})(\\d{4})","$1 $2",["8[125]"]],["(\\d{6})","$1",["[134]"]],["(\\d)(\\d{6})","$1 $2",["[15]|2[0-79]|3[0-46-8]|4[0-7]"]],["(\\d)(\\d{7})","$1 $2",["(?:2|90)4|[67]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[348]|64|79|90"]],["(\\d{2})(\\d{5,7})","$1 $2",["1|28|6[0-35-9]|7[67]|9[2-9]"]]],"0"],SR:["597","00","(?:[2-5]|68|[78]\\d|90)\\d{5}",[6,7],[["(\\d{2})(\\d{2})(\\d{2})","$1-$2-$3",["56"]],["(\\d{3})(\\d{3})","$1-$2",["[2-5]"]],["(\\d{3})(\\d{4})","$1-$2",["[6-9]"]]]],SS:["211","00","[19]\\d{8}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[19]"],"0$1"]],"0"],ST:["239","00","(?:22|9\\d)\\d{5}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[29]"]]]],SV:["503","00","[267]\\d{7}|(?:80\\d|900)\\d{4}(?:\\d{4})?",[7,8,11],[["(\\d{3})(\\d{4})","$1 $2",["[89]"]],["(\\d{4})(\\d{4})","$1 $2",["[267]"]],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["[89]"]]]],SX:["1","011","7215\\d{6}|(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"(5\\d{6})$|1","721$1",0,"721"],SY:["963","00","[1-39]\\d{8}|[1-5]\\d{7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[1-5]"],"0$1",1],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["9"],"0$1",1]],"0"],SZ:["268","00","0800\\d{4}|(?:[237]\\d|900)\\d{6}",[8,9],[["(\\d{4})(\\d{4})","$1 $2",["[0237]"]],["(\\d{5})(\\d{4})","$1 $2",["9"]]]],TA:["290","00","8\\d{3}",[4],0,0,0,0,0,0,"8"],TC:["1","011","(?:[58]\\d\\d|649|900)\\d{7}",[10],0,"1",0,"([2-479]\\d{6})$|1","649$1",0,"649"],TD:["235","00|16","(?:22|[689]\\d|77)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[26-9]"]]],0,0,0,0,0,0,0,"00"],TG:["228","00","[279]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[279]"]]]],TH:["66","00[1-9]","(?:001800|[2-57]|[689]\\d)\\d{7}|1\\d{7,9}",[8,9,10,13],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[13-9]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]]],"0"],TJ:["992","810","[0-57-9]\\d{8}",[9],[["(\\d{6})(\\d)(\\d{2})","$1 $2 $3",["331","3317"]],["(\\d{3})(\\d{2})(\\d{4})","$1 $2 $3",["44[02-479]|[34]7"]],["(\\d{4})(\\d)(\\d{4})","$1 $2 $3",["3(?:[1245]|3[12])"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[0-57-9]"]]],0,0,0,0,0,0,0,"8~10"],TK:["690","00","[2-47]\\d{3,6}",[4,5,6,7]],TL:["670","00","7\\d{7}|(?:[2-47]\\d|[89]0)\\d{5}",[7,8],[["(\\d{3})(\\d{4})","$1 $2",["[2-489]|70"]],["(\\d{4})(\\d{4})","$1 $2",["7"]]]],TM:["993","810","(?:[1-6]\\d|71)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2-$3-$4",["12"],"(8 $1)"],["(\\d{3})(\\d)(\\d{2})(\\d{2})","$1 $2-$3-$4",["[1-5]"],"(8 $1)"],["(\\d{2})(\\d{6})","$1 $2",["[67]"],"8 $1"]],"8",0,0,0,0,0,0,"8~10"],TN:["216","00","[2-57-9]\\d{7}",[8],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2-57-9]"]]]],TO:["676","00","(?:0800|(?:[5-8]\\d\\d|999)\\d)\\d{3}|[2-8]\\d{4}",[5,7],[["(\\d{2})(\\d{3})","$1-$2",["[2-4]|50|6[09]|7[0-24-69]|8[05]"]],["(\\d{4})(\\d{3})","$1 $2",["0"]],["(\\d{3})(\\d{4})","$1 $2",["[5-9]"]]]],TR:["90","00","4\\d{6}|8\\d{11,12}|(?:[2-58]\\d\\d|900)\\d{7}",[7,10,12,13],[["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["512|8[01589]|90"],"0$1",1],["(\\d{3})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["5(?:[0-59]|61)","5(?:[0-59]|61[06])","5(?:[0-59]|61[06]1)"],"0$1",1],["(\\d{3})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[24][1-8]|3[1-9]"],"(0$1)",1],["(\\d{3})(\\d{3})(\\d{6,7})","$1 $2 $3",["80"],"0$1",1]],"0"],TT:["1","011","(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-46-8]\\d{6})$|1","868$1",0,"868"],TV:["688","00","(?:2|7\\d\\d|90)\\d{4}",[5,6,7],[["(\\d{2})(\\d{3})","$1 $2",["2"]],["(\\d{2})(\\d{4})","$1 $2",["90"]],["(\\d{2})(\\d{5})","$1 $2",["7"]]]],TW:["886","0(?:0[25-79]|19)","[2-689]\\d{8}|7\\d{9,10}|[2-8]\\d{7}|2\\d{6}",[7,8,9,10,11],[["(\\d{2})(\\d)(\\d{4})","$1 $2 $3",["202"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[258]0"],"0$1"],["(\\d)(\\d{3,4})(\\d{4})","$1 $2 $3",["[23568]|4(?:0[02-48]|[1-47-9])|7[1-9]","[23568]|4(?:0[2-48]|[1-47-9])|(?:400|7)[1-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[49]"],"0$1"],["(\\d{2})(\\d{4})(\\d{4,5})","$1 $2 $3",["7"],"0$1"]],"0",0,0,0,0,0,0,0,"#"],TZ:["255","00[056]","(?:[25-8]\\d|41|90)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{4})","$1 $2 $3",["[89]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[24]"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["5"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[67]"],"0$1"]],"0"],UA:["380","00","[89]\\d{9}|[3-9]\\d{8}",[9,10],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6[12][29]|(?:3[1-8]|4[136-8]|5[12457]|6[49])2|(?:56|65)[24]","6[12][29]|(?:35|4[1378]|5[12457]|6[49])2|(?:56|65)[24]|(?:3[1-46-8]|46)2[013-9]"],"0$1"],["(\\d{4})(\\d{5})","$1 $2",["3[1-8]|4(?:[1367]|[45][6-9]|8[4-6])|5(?:[1-5]|6[0135689]|7[4-6])|6(?:[12][3-7]|[459])","3[1-8]|4(?:[1367]|[45][6-9]|8[4-6])|5(?:[1-5]|6(?:[015689]|3[02389])|7[4-6])|6(?:[12][3-7]|[459])"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[3-7]|89|9[1-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[89]"],"0$1"]],"0",0,0,0,0,0,0,"0~0"],UG:["256","00[057]","800\\d{6}|(?:[29]0|[347]\\d)\\d{7}",[9],[["(\\d{4})(\\d{5})","$1 $2",["202","2024"],"0$1"],["(\\d{3})(\\d{6})","$1 $2",["[27-9]|4(?:6[45]|[7-9])"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["[34]"],"0$1"]],"0"],US:["1","011","[2-9]\\d{9}|3\\d{6}",[10],[["(\\d{3})(\\d{4})","$1-$2",["310"],0,1],["(\\d{3})(\\d{3})(\\d{4})","($1) $2-$3",["[2-9]"],0,1,"$1-$2-$3"]],"1",0,0,0,0,0,[["(?:3052(?:0[0-8]|[1-9]\\d)|5056(?:[0-35-9]\\d|4[0-468]))\\d{4}|(?:2742|305[3-9]|472[247-9]|505[2-57-9]|983[2-47-9])\\d{6}|(?:2(?:0[1-35-9]|1[02-9]|2[03-57-9]|3[1459]|4[08]|5[1-46]|6[0279]|7[0269]|8[13])|3(?:0[1-47-9]|1[02-9]|2[0135-79]|3[0-24679]|4[167]|5[0-2]|6[01349]|8[056])|4(?:0[124-9]|1[02-579]|2[3-5]|3[0245]|4[023578]|58|6[349]|7[0589]|8[04])|5(?:0[1-47-9]|1[0235-8]|20|3[0149]|4[01]|5[179]|6[1-47]|7[0-5]|8[0256])|6(?:0[1-35-9]|1[024-9]|2[03689]|3[016]|4[0156]|5[01679]|6[0-279]|78|8[0-29])|7(?:0[1-46-8]|1[2-9]|2[04-8]|3[0-247]|4[037]|5[47]|6[02359]|7[0-59]|8[156])|8(?:0[1-68]|1[02-8]|2[0168]|3[0-2589]|4[03578]|5[046-9]|6[02-5]|7[028])|9(?:0[1346-9]|1[02-9]|2[0589]|3[0146-8]|4[01357-9]|5[12469]|7[0-389]|8[04-69]))[2-9]\\d{6}"],[""],["8(?:00|33|44|55|66|77|88)[2-9]\\d{6}"],["900[2-9]\\d{6}"],["52(?:3(?:[2-46-9][02-9]\\d|5(?:[02-46-9]\\d|5[0-46-9]))|4(?:[2-478][02-9]\\d|5(?:[034]\\d|2[024-9]|5[0-46-9])|6(?:0[1-9]|[2-9]\\d)|9(?:[05-9]\\d|2[0-5]|49)))\\d{4}|52[34][2-9]1[02-9]\\d{4}|5(?:00|2[125-9]|33|44|66|77|88)[2-9]\\d{6}"],0,0,0,["305209\\d{4}"]]],UY:["598","0(?:0|1[3-9]\\d)","0004\\d{2,9}|[1249]\\d{7}|(?:[49]\\d|80)\\d{5}",[6,7,8,9,10,11,12,13],[["(\\d{3})(\\d{3,4})","$1 $2",["0"]],["(\\d{3})(\\d{4})","$1 $2",["[49]0|8"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["9"],"0$1"],["(\\d{4})(\\d{4})","$1 $2",["[124]"]],["(\\d{3})(\\d{3})(\\d{2,4})","$1 $2 $3",["0"]],["(\\d{3})(\\d{3})(\\d{3})(\\d{2,4})","$1 $2 $3 $4",["0"]]],"0",0,0,0,0,0,0,"00"," int. "],UZ:["998","00","(?:20|33|[5-9]\\d)\\d{7}",[9],[["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[235-9]"]]]],VA:["39","00","0\\d{5,10}|3[0-8]\\d{7,10}|55\\d{8}|8\\d{5}(?:\\d{2,4})?|(?:1\\d|39)\\d{7,8}",[6,7,8,9,10,11,12],0,0,0,0,0,0,"06698"],VC:["1","011","(?:[58]\\d\\d|784|900)\\d{7}",[10],0,"1",0,"([2-7]\\d{6})$|1","784$1",0,"784"],VE:["58","00","[68]00\\d{7}|(?:[24]\\d|[59]0)\\d{8}",[10],[["(\\d{3})(\\d{7})","$1-$2",["[24-689]"],"0$1"]],"0"],VG:["1","011","(?:284|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-578]\\d{6})$|1","284$1",0,"284"],VI:["1","011","[58]\\d{9}|(?:34|90)0\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","340$1",0,"340"],VN:["84","00","[12]\\d{9}|[135-9]\\d{8}|[16]\\d{7}|[16-8]\\d{6}",[7,8,9,10],[["(\\d{2})(\\d{5})","$1 $2",["80"],"0$1",1],["(\\d{4})(\\d{4,6})","$1 $2",["1"],0,1],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["6"],"0$1",1],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[357-9]"],"0$1",1],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["2[48]"],"0$1",1],["(\\d{3})(\\d{4})(\\d{3})","$1 $2 $3",["2"],"0$1",1]],"0"],VU:["678","00","[57-9]\\d{6}|(?:[238]\\d|48)\\d{3}",[5,7],[["(\\d{3})(\\d{4})","$1 $2",["[57-9]"]]]],WF:["681","00","(?:40|72|8\\d{4})\\d{4}|[89]\\d{5}",[6,9],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["[47-9]"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"]]]],WS:["685","0","(?:[2-6]|8\\d{5})\\d{4}|[78]\\d{6}|[68]\\d{5}",[5,6,7,10],[["(\\d{5})","$1",["[2-5]|6[1-9]"]],["(\\d{3})(\\d{3,7})","$1 $2",["[68]"]],["(\\d{2})(\\d{5})","$1 $2",["7"]]]],XK:["383","00","2\\d{7,8}|3\\d{7,11}|(?:4\\d\\d|[89]00)\\d{5}",[8,9,10,11,12],[["(\\d{3})(\\d{5})","$1 $2",["[89]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2-4]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["2|39"],"0$1"],["(\\d{2})(\\d{7,10})","$1 $2",["3"],"0$1"]],"0"],YE:["967","00","(?:1|7\\d)\\d{7}|[1-7]\\d{6}",[7,8,9],[["(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["[1-6]|7(?:[24-6]|8[0-7])"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["7"],"0$1"]],"0"],YT:["262","00","7093\\d{5}|(?:80|9\\d)\\d{7}|(?:26|63)9\\d{6}",[9],0,"0",0,0,0,0,0,[["269(?:0[0-467]|15|5[0-4]|6\\d|[78]0)\\d{4}"],["(?:639(?:0[0-79]|1[019]|[267]\\d|3[09]|40|5[05-9]|9[04-79])|7093[5-7])\\d{4}"],["80\\d{7}"],0,0,0,0,0,["9(?:(?:39|47)8[01]|769\\d)\\d{4}"]]],ZA:["27","00","[1-79]\\d{8}|8\\d{4,9}",[5,6,7,8,9,10],[["(\\d{2})(\\d{3,4})","$1 $2",["8[1-4]"],"0$1"],["(\\d{2})(\\d{3})(\\d{2,3})","$1 $2 $3",["8[1-4]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["860"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[1-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"],"0$1"]],"0"],ZM:["260","00","800\\d{6}|(?:21|[579]\\d|63)\\d{7}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[28]"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["[579]"],"0$1"]],"0"],ZW:["263","00","2(?:[0-57-9]\\d{6,8}|6[0-24-9]\\d{6,7})|[38]\\d{9}|[35-8]\\d{8}|[3-6]\\d{7}|[1-689]\\d{6}|[1-3569]\\d{5}|[1356]\\d{4}",[5,6,7,8,9,10],[["(\\d{3})(\\d{3,5})","$1 $2",["2(?:0[45]|2[278]|[49]8)|3(?:[09]8|17)|6(?:[29]8|37|75)|[23][78]|(?:33|5[15]|6[68])[78]"],"0$1"],["(\\d)(\\d{3})(\\d{2,4})","$1 $2 $3",["[49]"],"0$1"],["(\\d{3})(\\d{4})","$1 $2",["80"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["24|8[13-59]|(?:2[05-79]|39|5[45]|6[15-8])2","2(?:02[014]|4|[56]20|[79]2)|392|5(?:42|525)|6(?:[16-8]21|52[013])|8[13-59]"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["2(?:1[39]|2[0157]|[378]|[56][14])|3(?:12|29)","2(?:1[39]|2[0157]|[378]|[56][14])|3(?:123|29)"],"0$1"],["(\\d{4})(\\d{6})","$1 $2",["8"],"0$1"],["(\\d{2})(\\d{3,5})","$1 $2",["1|2(?:0[0-36-9]|12|29|[56])|3(?:1[0-689]|[24-6])|5(?:[0236-9]|1[2-4])|6(?:[013-59]|7[0-46-9])|(?:33|55|6[68])[0-69]|(?:29|3[09]|62)[0-79]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["29[013-9]|39|54"],"0$1"],["(\\d{4})(\\d{3,5})","$1 $2",["(?:25|54)8","258|5483"],"0$1"]],"0"]},nonGeographic:{800:["800",0,"(?:00|[1-9]\\d)\\d{6}",[8],[["(\\d{4})(\\d{4})","$1 $2",["\\d"]]],0,0,0,0,0,0,[0,0,["(?:00|[1-9]\\d)\\d{6}"]]],808:["808",0,"[1-9]\\d{7}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[1-9]"]]],0,0,0,0,0,0,[0,0,0,0,0,0,0,0,0,["[1-9]\\d{7}"]]],870:["870",0,"7\\d{11}|[235-7]\\d{8}",[9,12],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[235-7]"]]],0,0,0,0,0,0,[0,["(?:[356]|774[45])\\d{8}|7[6-8]\\d{7}"],0,0,0,0,0,0,["2\\d{8}",[9]]]],878:["878",0,"10\\d{10}",[12],[["(\\d{2})(\\d{5})(\\d{5})","$1 $2 $3",["1"]]],0,0,0,0,0,0,[0,0,0,0,0,0,0,0,["10\\d{10}"]]],881:["881",0,"6\\d{9}|[0-36-9]\\d{8}",[9,10],[["(\\d)(\\d{3})(\\d{5})","$1 $2 $3",["[0-37-9]"]],["(\\d)(\\d{3})(\\d{5,6})","$1 $2 $3",["6"]]],0,0,0,0,0,0,[0,["6\\d{9}|[0-36-9]\\d{8}"]]],882:["882",0,"[13]\\d{6}(?:\\d{2,5})?|[19]\\d{7}|(?:[25]\\d\\d|4)\\d{7}(?:\\d{2})?",[7,8,9,10,11,12],[["(\\d{2})(\\d{5})","$1 $2",["16|342"]],["(\\d{2})(\\d{6})","$1 $2",["49"]],["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["1[36]|9"]],["(\\d{2})(\\d{4})(\\d{3})","$1 $2 $3",["3[23]"]],["(\\d{2})(\\d{3,4})(\\d{4})","$1 $2 $3",["16"]],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["10|23|3(?:[15]|4[57])|4|51"]],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["34"]],["(\\d{2})(\\d{4,5})(\\d{5})","$1 $2 $3",["[1-35]"]]],0,0,0,0,0,0,[0,["342\\d{4}|(?:337|49)\\d{6}|(?:3(?:2|47|7\\d{3})|50\\d{3})\\d{7}",[7,8,9,10,12]],0,0,0,["348[57]\\d{7}",[11]],0,0,["1(?:3(?:0[0347]|[13][0139]|2[035]|4[013568]|6[0459]|7[06]|8[15-8]|9[0689])\\d{4}|6\\d{5,10})|(?:345\\d|9[89])\\d{6}|(?:10|2(?:3|85\\d)|3(?:[15]|[69]\\d\\d)|4[15-8]|51)\\d{8}"]]],883:["883",0,"(?:[1-4]\\d|51)\\d{6,10}",[8,9,10,11,12],[["(\\d{3})(\\d{3})(\\d{2,8})","$1 $2 $3",["[14]|2[24-689]|3[02-689]|51[24-9]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["510"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["21"]],["(\\d{4})(\\d{4})(\\d{4})","$1 $2 $3",["51[13]"]],["(\\d{3})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["[235]"]]],0,0,0,0,0,0,[0,0,0,0,0,0,0,0,["(?:2(?:00\\d\\d|10)|(?:370[1-9]|51\\d0)\\d)\\d{7}|51(?:00\\d{5}|[24-9]0\\d{4,7})|(?:1[0-79]|2[24-689]|3[02-689]|4[0-4])0\\d{5,9}"]]],888:["888",0,"\\d{11}",[11],[["(\\d{3})(\\d{3})(\\d{5})","$1 $2 $3"]],0,0,0,0,0,0,[0,0,0,0,0,0,["\\d{11}"]]],979:["979",0,"[1359]\\d{8}",[9],[["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["[1359]"]]],0,0,0,0,0,0,[0,0,0,["[1359]\\d{8}"]]]}};function r3(t,e){var n=Array.prototype.slice.call(e);return n.push(n3),t.apply(this,n)}function yp(t,e){t=t.split("-"),e=e.split("-");for(var n=t[0].split("."),r=e[0].split("."),i=0;i<3;i++){var s=Number(n[i]),o=Number(r[i]);if(s>o)return 1;if(o>s)return-1;if(!isNaN(s)&&isNaN(o))return 1;if(isNaN(s)&&!isNaN(o))return-1}return t[1]&&e[1]?t[1]>e[1]?1:t[1]<e[1]?-1:0:!t[1]&&e[1]?1:t[1]&&!e[1]?-1:0}var i3={}.constructor;function sr(t){return t!=null&&t.constructor===i3}function md(t){"@babel/helpers - typeof";return md=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},md(t)}function ua(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s3(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function fa(t,e,n){return e&&s3(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}var o3="1.2.0",a3="1.7.35",wp=" ext. ",c3=/^\d+$/,He=function(){function t(e){ua(this,t),Yg(e),this.metadata=e,Qg.call(this,e)}return fa(t,[{key:"getCountries",value:function(){return Object.keys(this.metadata.countries).filter(function(n){return n!=="001"})}},{key:"getCountryMetadata",value:function(n){return this.metadata.countries[n]}},{key:"nonGeographic",value:function(){if(!(this.v1||this.v2||this.v3))return this.metadata.nonGeographic||this.metadata.nonGeographical}},{key:"hasCountry",value:function(n){return this.getCountryMetadata(n)!==void 0}},{key:"hasCallingCode",value:function(n){if(this.getCountryCodesForCallingCode(n))return!0;if(this.nonGeographic()){if(this.nonGeographic()[n])return!0}else{var r=this.countryCallingCodes()[n];if(r&&r.length===1&&r[0]==="001")return!0}}},{key:"isNonGeographicCallingCode",value:function(n){return this.nonGeographic()?!!this.nonGeographic()[n]:!this.getCountryCodesForCallingCode(n)}},{key:"country",value:function(n){return this.selectNumberingPlan(n)}},{key:"selectNumberingPlan",value:function(n,r){if(n&&c3.test(n)&&(r=n,n=null),n&&n!=="001"){if(!this.hasCountry(n))throw new Error("Unknown country: ".concat(n));this.numberingPlan=new vp(this.getCountryMetadata(n),this)}else if(r){if(!this.hasCallingCode(r))throw new Error("Unknown calling code: ".concat(r));this.numberingPlan=new vp(this.getNumberingPlanMetadata(r),this)}else this.numberingPlan=void 0;return this}},{key:"getCountryCodesForCallingCode",value:function(n){var r=this.countryCallingCodes()[n];if(r)return r.length===1&&r[0].length===3?void 0:r}},{key:"getCountryCodeForCallingCode",value:function(n){var r=this.getCountryCodesForCallingCode(n);if(r)return r[0]}},{key:"getNumberingPlanMetadata",value:function(n){var r=this.getCountryCodeForCallingCode(n);if(r)return this.getCountryMetadata(r);if(this.nonGeographic()){var i=this.nonGeographic()[n];if(i)return i}else{var s=this.countryCallingCodes()[n];if(s&&s.length===1&&s[0]==="001")return this.metadata.countries["001"]}}},{key:"countryCallingCode",value:function(){return this.numberingPlan.callingCode()}},{key:"IDDPrefix",value:function(){return this.numberingPlan.IDDPrefix()}},{key:"defaultIDDPrefix",value:function(){return this.numberingPlan.defaultIDDPrefix()}},{key:"nationalNumberPattern",value:function(){return this.numberingPlan.nationalNumberPattern()}},{key:"possibleLengths",value:function(){return this.numberingPlan.possibleLengths()}},{key:"formats",value:function(){return this.numberingPlan.formats()}},{key:"nationalPrefixForParsing",value:function(){return this.numberingPlan.nationalPrefixForParsing()}},{key:"nationalPrefixTransformRule",value:function(){return this.numberingPlan.nationalPrefixTransformRule()}},{key:"leadingDigits",value:function(){return this.numberingPlan.leadingDigits()}},{key:"hasTypes",value:function(){return this.numberingPlan.hasTypes()}},{key:"type",value:function(n){return this.numberingPlan.type(n)}},{key:"ext",value:function(){return this.numberingPlan.ext()}},{key:"countryCallingCodes",value:function(){return this.v1?this.metadata.country_phone_code_to_countries:this.metadata.country_calling_codes}},{key:"chooseCountryByCountryCallingCode",value:function(n){return this.selectNumberingPlan(n)}},{key:"hasSelectedNumberingPlan",value:function(){return this.numberingPlan!==void 0}}]),t}(),vp=function(){function t(e,n){ua(this,t),this.globalMetadataObject=n,this.metadata=e,Qg.call(this,n.metadata)}return fa(t,[{key:"callingCode",value:function(){return this.metadata[0]}},{key:"getDefaultCountryMetadataForRegion",value:function(){return this.globalMetadataObject.getNumberingPlanMetadata(this.callingCode())}},{key:"IDDPrefix",value:function(){if(!(this.v1||this.v2))return this.metadata[1]}},{key:"defaultIDDPrefix",value:function(){if(!(this.v1||this.v2))return this.metadata[12]}},{key:"nationalNumberPattern",value:function(){return this.v1||this.v2?this.metadata[1]:this.metadata[2]}},{key:"possibleLengths",value:function(){if(!this.v1)return this.metadata[this.v2?2:3]}},{key:"_getFormats",value:function(n){return n[this.v1?2:this.v2?3:4]}},{key:"formats",value:function(){var n=this,r=this._getFormats(this.metadata)||this._getFormats(this.getDefaultCountryMetadataForRegion())||[];return r.map(function(i){return new d3(i,n)})}},{key:"nationalPrefix",value:function(){return this.metadata[this.v1?3:this.v2?4:5]}},{key:"_getNationalPrefixFormattingRule",value:function(n){return n[this.v1?4:this.v2?5:6]}},{key:"nationalPrefixFormattingRule",value:function(){return this._getNationalPrefixFormattingRule(this.metadata)||this._getNationalPrefixFormattingRule(this.getDefaultCountryMetadataForRegion())}},{key:"_nationalPrefixForParsing",value:function(){return this.metadata[this.v1?5:this.v2?6:7]}},{key:"nationalPrefixForParsing",value:function(){return this._nationalPrefixForParsing()||this.nationalPrefix()}},{key:"nationalPrefixTransformRule",value:function(){return this.metadata[this.v1?6:this.v2?7:8]}},{key:"_getNationalPrefixIsOptionalWhenFormatting",value:function(){return!!this.metadata[this.v1?7:this.v2?8:9]}},{key:"nationalPrefixIsOptionalWhenFormattingInNationalFormat",value:function(){return this._getNationalPrefixIsOptionalWhenFormatting(this.metadata)||this._getNationalPrefixIsOptionalWhenFormatting(this.getDefaultCountryMetadataForRegion())}},{key:"leadingDigits",value:function(){return this.metadata[this.v1?8:this.v2?9:10]}},{key:"types",value:function(){return this.metadata[this.v1?9:this.v2?10:11]}},{key:"hasTypes",value:function(){return this.types()&&this.types().length===0?!1:!!this.types()}},{key:"type",value:function(n){if(this.hasTypes()&&bp(this.types(),n))return new u3(bp(this.types(),n),this)}},{key:"ext",value:function(){return this.v1||this.v2?wp:this.metadata[13]||wp}}]),t}(),d3=function(){function t(e,n){ua(this,t),this._format=e,this.metadata=n}return fa(t,[{key:"pattern",value:function(){return this._format[0]}},{key:"format",value:function(){return this._format[1]}},{key:"leadingDigitsPatterns",value:function(){return this._format[2]||[]}},{key:"nationalPrefixFormattingRule",value:function(){return this._format[3]||this.metadata.nationalPrefixFormattingRule()}},{key:"nationalPrefixIsOptionalWhenFormattingInNationalFormat",value:function(){return!!this._format[4]||this.metadata.nationalPrefixIsOptionalWhenFormattingInNationalFormat()}},{key:"nationalPrefixIsMandatoryWhenFormattingInNationalFormat",value:function(){return this.usesNationalPrefix()&&!this.nationalPrefixIsOptionalWhenFormattingInNationalFormat()}},{key:"usesNationalPrefix",value:function(){return!!(this.nationalPrefixFormattingRule()&&!l3.test(this.nationalPrefixFormattingRule()))}},{key:"internationalFormat",value:function(){return this._format[5]||this.format()}}]),t}(),l3=/^\(?\$1\)?$/,u3=function(){function t(e,n){ua(this,t),this.type=e,this.metadata=n}return fa(t,[{key:"pattern",value:function(){return this.metadata.v1?this.type:this.type[0]}},{key:"possibleLengths",value:function(){if(!this.metadata.v1)return this.type[1]||this.metadata.possibleLengths()}}]),t}();function bp(t,e){switch(e){case"FIXED_LINE":return t[0];case"MOBILE":return t[1];case"TOLL_FREE":return t[2];case"PREMIUM_RATE":return t[3];case"PERSONAL_NUMBER":return t[4];case"VOICEMAIL":return t[5];case"UAN":return t[6];case"PAGER":return t[7];case"VOIP":return t[8];case"SHARED_COST":return t[9]}}function Yg(t){if(!t)throw new Error("[libphonenumber-js] `metadata` argument not passed. Check your arguments.");if(!sr(t)||!sr(t.countries))throw new Error("[libphonenumber-js] `metadata` argument was passed but it's not a valid metadata. Must be an object having `.countries` child object property. Got ".concat(sr(t)?"an object of shape: { "+Object.keys(t).join(", ")+" }":"a "+f3(t)+": "+t,"."))}var f3=function(e){return md(e)};function jl(t,e){if(e=new He(e),e.hasCountry(t))return e.country(t).countryCallingCode();throw new Error("Unknown country: ".concat(t))}function p3(t,e){return e.countries.hasOwnProperty(t)}function Qg(t){var e=t.version;typeof e=="number"?(this.v1=e===1,this.v2=e===2,this.v3=e===3,this.v4=e===4):e?yp(e,o3)===-1?this.v2=!0:yp(e,a3)===-1?this.v3=!0:this.v4=!0:this.v1=!0}function Tl(t,e){return h3(t,void 0,e)}function h3(t,e,n){var r=n.type(e),i=r&&r.possibleLengths()||n.possibleLengths();if(!i)return"IS_POSSIBLE";var s=t.length,o=i[0];return o===s?"IS_POSSIBLE":o>s?"TOO_SHORT":i[i.length-1]<s?"TOO_LONG":i.indexOf(s,1)>=0?"IS_POSSIBLE":"INVALID_LENGTH"}function g3(t,e,n){if(e===void 0&&(e={}),n=new He(n),e.v2){if(!t.countryCallingCode)throw new Error("Invalid phone number object passed");n.selectNumberingPlan(t.countryCallingCode)}else{if(!t.phone)return!1;if(t.country){if(!n.hasCountry(t.country))throw new Error("Unknown country: ".concat(t.country));n.country(t.country)}else{if(!t.countryCallingCode)throw new Error("Invalid phone number object passed");n.selectNumberingPlan(t.countryCallingCode)}}if(n.possibleLengths())return em(t.phone||t.nationalNumber,n);if(t.countryCallingCode&&n.isNonGeographicCallingCode(t.countryCallingCode))return!0;throw new Error('Missing "possibleLengths" in metadata. Perhaps the metadata has been generated before v1.0.18.')}function em(t,e){switch(Tl(t,e)){case"IS_POSSIBLE":return!0;default:return!1}}function Gt(t,e){return t=t||"",new RegExp("^(?:"+e+")$").test(t)}function m3(t,e){var n=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n)return(n=n.call(t)).next.bind(n);if(Array.isArray(t)||(n=_3(t))||e){n&&(t=n);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
150
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _3(t,e){if(t){if(typeof t=="string")return $p(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return $p(t,e)}}function $p(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var y3=["MOBILE","PREMIUM_RATE","TOLL_FREE","SHARED_COST","VOIP","PERSONAL_NUMBER","PAGER","UAN","VOICEMAIL"];function Rl(t,e,n){if(e=e||{},!(!t.country&&!t.countryCallingCode)){n=new He(n),n.selectNumberingPlan(t.country,t.countryCallingCode);var r=e.v2?t.nationalNumber:t.phone;if(Gt(r,n.nationalNumberPattern())){if(Pa(r,"FIXED_LINE",n))return n.type("MOBILE")&&n.type("MOBILE").pattern()===""||!n.type("MOBILE")||Pa(r,"MOBILE",n)?"FIXED_LINE_OR_MOBILE":"FIXED_LINE";for(var i=m3(y3),s;!(s=i()).done;){var o=s.value;if(Pa(r,o,n))return o}}}}function Pa(t,e,n){return e=n.type(e),!e||!e.pattern()||e.possibleLengths()&&e.possibleLengths().indexOf(t.length)<0?!1:Gt(t,e.pattern())}function w3(t,e,n){if(e=e||{},n=new He(n),n.selectNumberingPlan(t.country,t.countryCallingCode),n.hasTypes())return Rl(t,e,n.metadata)!==void 0;var r=e.v2?t.nationalNumber:t.phone;return Gt(r,n.nationalNumberPattern())}function v3(t,e,n){var r=new He(n),i=r.getCountryCodesForCallingCode(t);return i?i.filter(function(s){return b3(e,s,n)}):[]}function b3(t,e,n){var r=new He(n);return r.selectNumberingPlan(e),r.numberingPlan.possibleLengths().indexOf(t.length)>=0}var Bl=2,$3=17,x3=3,wt="0-90-9٠-٩۰-۹",k3="-‐-―−ー-",S3="//",A3="..",E3="  ­​⁠ ",I3="()()[]\\[\\]",N3="~⁓∼~",so="".concat(k3).concat(S3).concat(A3).concat(E3).concat(I3).concat(N3),Ll="++",C3=new RegExp("(["+wt+"])");function z3(t,e,n,r){if(e){var i=new He(r);i.selectNumberingPlan(e,n);var s=new RegExp(i.IDDPrefix());if(t.search(s)===0){t=t.slice(t.match(s)[0].length);var o=t.match(C3);if(!(o&&o[1]!=null&&o[1].length>0&&o[1]==="0"))return t}}}function O3(t,e){if(t&&e.numberingPlan.nationalPrefixForParsing()){var n=new RegExp("^(?:"+e.numberingPlan.nationalPrefixForParsing()+")"),r=n.exec(t);if(r){var i,s,o=r.length-1,c=o>0&&r[o];if(e.nationalPrefixTransformRule()&&c)i=t.replace(n,e.nationalPrefixTransformRule()),o>1&&(s=r[1]);else{var d=r[0];i=t.slice(d.length),c&&(s=r[1])}var l;if(c){var u=t.indexOf(r[1]),p=t.slice(0,u);p===e.numberingPlan.nationalPrefix()&&(l=e.numberingPlan.nationalPrefix())}else l=r[0];return{nationalNumber:i,nationalPrefix:l,carrierCode:s}}}return{nationalNumber:t}}function _d(t,e){var n=O3(t,e),r=n.carrierCode,i=n.nationalNumber;if(i!==t){if(!P3(t,i,e))return{nationalNumber:t};if(e.possibleLengths()&&!j3(i,e))return{nationalNumber:t}}return{nationalNumber:i,carrierCode:r}}function P3(t,e,n){return!(Gt(t,n.nationalNumberPattern())&&!Gt(e,n.nationalNumberPattern()))}function j3(t,e){switch(Tl(t,e)){case"TOO_SHORT":case"INVALID_LENGTH":return!1;default:return!0}}function T3(t,e,n,r){var i=e?jl(e,r):n;if(t.indexOf(i)===0){r=new He(r),r.selectNumberingPlan(e,n);var s=t.slice(i.length),o=_d(s,r),c=o.nationalNumber,d=_d(t,r),l=d.nationalNumber;if(!Gt(l,r.nationalNumberPattern())&&Gt(c,r.nationalNumberPattern())||Tl(l,r)==="TOO_LONG")return{countryCallingCode:i,number:s}}return{number:t}}function tm(t,e,n,r){if(!t)return{};var i;if(t[0]!=="+"){var s=z3(t,e,n,r);if(s&&s!==t)i=!0,t="+"+s;else{if(e||n){var o=T3(t,e,n,r),c=o.countryCallingCode,d=o.number;if(c)return{countryCallingCodeSource:"FROM_NUMBER_WITHOUT_PLUS_SIGN",countryCallingCode:c,number:d}}return{number:t}}}if(t[1]==="0")return{};r=new He(r);for(var l=2;l-1<=x3&&l<=t.length;){var u=t.slice(1,l);if(r.hasCallingCode(u))return r.selectNumberingPlan(u),{countryCallingCodeSource:i?"FROM_NUMBER_WITH_IDD":"FROM_NUMBER_WITH_PLUS_SIGN",countryCallingCode:u,number:t.slice(l)};l++}return{}}function R3(t){return t.replace(new RegExp("[".concat(so,"]+"),"g")," ").trim()}var B3=/(\$\d)/;function L3(t,e,n){var r=n.useInternationalFormat,i=n.withNationalPrefix,s=t.replace(new RegExp(e.pattern()),r?e.internationalFormat():i&&e.nationalPrefixFormattingRule()?e.format().replace(B3,e.nationalPrefixFormattingRule()):e.format());return r?R3(s):s}var U3=/^[\d]+(?:[~\u2053\u223C\uFF5E][\d]+)?$/;function M3(t,e,n){var r=new He(n);if(r.selectNumberingPlan(t,e),r.defaultIDDPrefix())return r.defaultIDDPrefix();if(U3.test(r.IDDPrefix()))return r.IDDPrefix()}var F3=";ext=",Wn=function(e){return"([".concat(wt,"]{1,").concat(e,"})")};function nm(t){var e="20",n="15",r="9",i="6",s="[  \\t,]*",o="[:\\..]?[  \\t,-]*",c="#?",d="(?:e?xt(?:ensi(?:ó?|ó))?n?|e?xtn?|доб|anexo)",l="(?:[xx##~~]|int|int)",u="[- ]+",p="[  \\t]*",m="(?:,{2}|;)",w=F3+Wn(e),h=s+d+o+Wn(e)+c,_=s+l+o+Wn(r)+c,v=u+Wn(i)+"#",k=p+m+o+Wn(n)+c,I=p+"(?:,)+"+o+Wn(r)+c;return w+"|"+h+"|"+_+"|"+v+"|"+k+"|"+I}var V3="["+wt+"]{"+Bl+"}",D3="["+Ll+"]{0,1}(?:["+so+"]*["+wt+"]){3,}["+so+wt+"]*",q3=new RegExp("^["+Ll+"]{0,1}(?:["+so+"]*["+wt+"]){1,2}$","i"),H3=D3+"(?:"+nm()+")?",K3=new RegExp("^"+V3+"$|^"+H3+"$","i");function G3(t){return t.length>=Bl&&K3.test(t)}function W3(t){return q3.test(t)}function J3(t){var e=t.number,n=t.ext;if(!e)return"";if(e[0]!=="+")throw new Error('"formatRFC3966()" expects "number" to be in E.164 format.');return"tel:".concat(e).concat(n?";ext="+n:"")}function Z3(t,e){var n=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n)return(n=n.call(t)).next.bind(n);if(Array.isArray(t)||(n=X3(t))||e){n&&(t=n);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
151
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function X3(t,e){if(t){if(typeof t=="string")return xp(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return xp(t,e)}}function xp(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function kp(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Sp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?kp(Object(n),!0).forEach(function(r){Y3(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):kp(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Y3(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var Ap={formatExtension:function(e,n,r){return"".concat(e).concat(r.ext()).concat(n)}};function Q3(t,e,n,r){if(n?n=Sp(Sp({},Ap),n):n=Ap,r=new He(r),t.country&&t.country!=="001"){if(!r.hasCountry(t.country))throw new Error("Unknown country: ".concat(t.country));r.country(t.country)}else if(t.countryCallingCode)r.selectNumberingPlan(t.countryCallingCode);else return t.phone||"";var i=r.countryCallingCode(),s=n.v2?t.nationalNumber:t.phone,o;switch(e){case"NATIONAL":return s?(o=oo(s,t.carrierCode,"NATIONAL",r,n),ja(o,t.ext,r,n.formatExtension)):"";case"INTERNATIONAL":return s?(o=oo(s,null,"INTERNATIONAL",r,n),o="+".concat(i," ").concat(o),ja(o,t.ext,r,n.formatExtension)):"+".concat(i);case"E.164":return"+".concat(i).concat(s);case"RFC3966":return J3({number:"+".concat(i).concat(s),ext:t.ext});case"IDD":if(!n.fromCountry)return;var c=tb(s,t.carrierCode,i,n.fromCountry,r);return ja(c,t.ext,r,n.formatExtension);default:throw new Error('Unknown "format" argument passed to "formatNumber()": "'.concat(e,'"'))}}function oo(t,e,n,r,i){var s=eb(r.formats(),t);return s?L3(t,s,{useInternationalFormat:n==="INTERNATIONAL",withNationalPrefix:!(s.nationalPrefixIsOptionalWhenFormattingInNationalFormat()&&i&&i.nationalPrefix===!1),carrierCode:e,metadata:r}):t}function eb(t,e){for(var n=Z3(t),r;!(r=n()).done;){var i=r.value;if(i.leadingDigitsPatterns().length>0){var s=i.leadingDigitsPatterns()[i.leadingDigitsPatterns().length-1];if(e.search(s)!==0)continue}if(Gt(e,i.pattern()))return i}}function ja(t,e,n,r){return e?r(t,e,n):t}function tb(t,e,n,r,i){var s=jl(r,i.metadata);if(s===n){var o=oo(t,e,"NATIONAL",i);return n==="1"?n+" "+o:o}var c=M3(r,void 0,i.metadata);if(c)return"".concat(c," ").concat(n," ").concat(oo(t,null,"INTERNATIONAL",i))}function Ep(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ip(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Ep(Object(n),!0).forEach(function(r){nb(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Ep(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function nb(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function rb(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function ib(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function sb(t,e,n){return e&&ib(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}var ob=function(){function t(e,n,r){if(rb(this,t),!e)throw new TypeError("First argument is required");if(typeof e!="string")throw new TypeError("First argument must be a string");if(typeof e=="string"){if(e[0]==="+"&&!n)throw new TypeError("`metadata` argument not passed");if(sr(n)&&sr(n.countries)){r=n;var i=e;if(!db.test(i))throw new Error('Invalid `number` argument passed: must consist of a "+" followed by digits');var s=tm(i,void 0,void 0,r),o=s.countryCallingCode,c=s.number;if(n=c,e=o,!n)throw new Error("Invalid `number` argument passed: too short")}}if(!n)throw new TypeError("`nationalNumber` argument is required");if(typeof n!="string")throw new TypeError("`nationalNumber` argument must be a string");Yg(r);var d=cb(e,r),l=d.country,u=d.countryCallingCode;this.country=l,this.countryCallingCode=u,this.nationalNumber=n,this.number="+"+this.countryCallingCode+this.nationalNumber,this.getMetadata=function(){return r}}return sb(t,[{key:"setExt",value:function(n){this.ext=n}},{key:"getPossibleCountries",value:function(){return this.country?[this.country]:v3(this.countryCallingCode,this.nationalNumber,this.getMetadata())}},{key:"isPossible",value:function(){return g3(this,{v2:!0},this.getMetadata())}},{key:"isValid",value:function(){return w3(this,{v2:!0},this.getMetadata())}},{key:"isNonGeographic",value:function(){var n=new He(this.getMetadata());return n.isNonGeographicCallingCode(this.countryCallingCode)}},{key:"isEqual",value:function(n){return this.number===n.number&&this.ext===n.ext}},{key:"getType",value:function(){return Rl(this,{v2:!0},this.getMetadata())}},{key:"format",value:function(n,r){return Q3(this,n,r?Ip(Ip({},r),{},{v2:!0}):{v2:!0},this.getMetadata())}},{key:"formatNational",value:function(n){return this.format("NATIONAL",n)}},{key:"formatInternational",value:function(n){return this.format("INTERNATIONAL",n)}},{key:"getURI",value:function(n){return this.format("RFC3966",n)}}]),t}(),ab=function(e){return/^[A-Z]{2}$/.test(e)};function cb(t,e){var n,r,i=new He(e);return ab(t)?(n=t,i.selectNumberingPlan(n),r=i.countryCallingCode()):r=t,{country:n,countryCallingCode:r}}var db=/^\+\d+$/;function yd(t){"@babel/helpers - typeof";return yd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},yd(t)}function lb(t,e,n){return Object.defineProperty(t,"prototype",{writable:!1}),t}function ub(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function fb(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&li(t,e)}function pb(t){var e=im();return function(){var r=ui(t),i;if(e){var s=ui(this).constructor;i=Reflect.construct(r,arguments,s)}else i=r.apply(this,arguments);return hb(this,i)}}function hb(t,e){if(e&&(yd(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return rm(t)}function rm(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function wd(t){var e=typeof Map=="function"?new Map:void 0;return wd=function(r){if(r===null||!gb(r))return r;if(typeof r!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e<"u"){if(e.has(r))return e.get(r);e.set(r,i)}function i(){return ns(r,arguments,ui(this).constructor)}return i.prototype=Object.create(r.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),li(i,r)},wd(t)}function ns(t,e,n){return im()?ns=Reflect.construct:ns=function(i,s,o){var c=[null];c.push.apply(c,s);var d=Function.bind.apply(i,c),l=new d;return o&&li(l,o.prototype),l},ns.apply(null,arguments)}function im(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function gb(t){return Function.toString.call(t).indexOf("[native code]")!==-1}function li(t,e){return li=Object.setPrototypeOf||function(r,i){return r.__proto__=i,r},li(t,e)}function ui(t){return ui=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},ui(t)}var Rt=function(t){fb(n,t);var e=pb(n);function n(r){var i;return ub(this,n),i=e.call(this,r),Object.setPrototypeOf(rm(i),n.prototype),i.name=i.constructor.name,i}return lb(n)}(wd(Error)),Np=new RegExp("(?:"+nm()+")$","i");function mb(t){var e=t.search(Np);if(e<0)return{};for(var n=t.slice(0,e),r=t.match(Np),i=1;i<r.length;){if(r[i])return{number:n,ext:r[i]};i++}}var _b={0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9","0":"0","1":"1","2":"2","3":"3","4":"4","5":"5","6":"6","7":"7","8":"8","9":"9","٠":"0","١":"1","٢":"2","٣":"3","٤":"4","٥":"5","٦":"6","٧":"7","٨":"8","٩":"9","۰":"0","۱":"1","۲":"2","۳":"3","۴":"4","۵":"5","۶":"6","۷":"7","۸":"8","۹":"9"};function yb(t){return _b[t]}function wb(t,e){var n=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n)return(n=n.call(t)).next.bind(n);if(Array.isArray(t)||(n=vb(t))||e){n&&(t=n);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
152
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function vb(t,e){if(t){if(typeof t=="string")return Cp(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Cp(t,e)}}function Cp(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function zp(t){for(var e="",n=wb(t.split("")),r;!(r=n()).done;){var i=r.value;e+=bb(i,e)||""}return e}function bb(t,e,n){return t==="+"?e?void 0:"+":yb(t)}function $b(t,e){var n=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n)return(n=n.call(t)).next.bind(n);if(Array.isArray(t)||(n=xb(t))||e){n&&(t=n);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
153
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function xb(t,e){if(t){if(typeof t=="string")return Op(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Op(t,e)}}function Op(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function kb(t,e){var n=e.countries,r=e.metadata;r=new He(r);for(var i=$b(n),s;!(s=i()).done;){var o=s.value;if(r.country(o),r.leadingDigits()){if(t&&t.search(r.leadingDigits())===0)return o}else if(Rl({phone:t,country:o},void 0,r.metadata))return o}}function Sb(t,e){var n=e.nationalNumber,r=e.defaultCountry,i=e.metadata,s=i.getCountryCodesForCallingCode(t);if(s)return s.length===1?s[0]:kb(n,{countries:s,defaultCountry:r,metadata:i.metadata})}var sm="+",Ab="[\\-\\.\\(\\)]?",Pp="(["+wt+"]|"+Ab+")",Eb="^\\"+sm+Pp+"*["+wt+"]"+Pp+"*$",Ib=new RegExp(Eb,"g"),vd=wt,Nb="["+vd+"]+((\\-)*["+vd+"])*",Cb="a-zA-Z",zb="["+Cb+"]+((\\-)*["+vd+"])*",Ob="^("+Nb+"\\.)*"+zb+"\\.?$",Pb=new RegExp(Ob,"g"),jp="tel:",bd=";phone-context=",jb=";isub=";function Tb(t){var e=t.indexOf(bd);if(e<0)return null;var n=e+bd.length;if(n>=t.length)return"";var r=t.indexOf(";",n);return r>=0?t.substring(n,r):t.substring(n)}function Rb(t){return t===null?!0:t.length===0?!1:Ib.test(t)||Pb.test(t)}function Bb(t,e){var n=e.extractFormattedPhoneNumber,r=Tb(t);if(!Rb(r))throw new Rt("NOT_A_NUMBER");var i;if(r===null)i=n(t)||"";else{i="",r.charAt(0)===sm&&(i+=r);var s=t.indexOf(jp),o;s>=0?o=s+jp.length:o=0;var c=t.indexOf(bd);i+=t.substring(o,c)}var d=i.indexOf(jb);if(d>0&&(i=i.substring(0,d)),i!=="")return i}var Lb=250,Ub=new RegExp("["+Ll+wt+"]"),Mb=new RegExp("[^"+wt+"#]+$");function Fb(t,e,n){if(e=e||{},n=new He(n),e.defaultCountry&&!n.hasCountry(e.defaultCountry))throw e.v2?new Rt("INVALID_COUNTRY"):new Error("Unknown country: ".concat(e.defaultCountry));var r=Db(t,e.v2,e.extract),i=r.number,s=r.ext,o=r.error;if(!i){if(e.v2)throw o==="TOO_SHORT"?new Rt("TOO_SHORT"):new Rt("NOT_A_NUMBER");return{}}var c=Hb(i,e.defaultCountry,e.defaultCallingCode,n),d=c.country,l=c.nationalNumber,u=c.countryCallingCode,p=c.countryCallingCodeSource,m=c.carrierCode;if(!n.hasSelectedNumberingPlan()){if(e.v2)throw new Rt("INVALID_COUNTRY");return{}}if(!l||l.length<Bl){if(e.v2)throw new Rt("TOO_SHORT");return{}}if(l.length>$3){if(e.v2)throw new Rt("TOO_LONG");return{}}if(e.v2){var w=new ob(u,l,n.metadata);return d&&(w.country=d),m&&(w.carrierCode=m),s&&(w.ext=s),w.__countryCallingCodeSource=p,w}var h=(e.extended?n.hasSelectedNumberingPlan():d)?Gt(l,n.nationalNumberPattern()):!1;return e.extended?{country:d,countryCallingCode:u,carrierCode:m,valid:h,possible:h?!0:!!(e.extended===!0&&n.possibleLengths()&&em(l,n)),phone:l,ext:s}:h?qb(d,l,s):{}}function Vb(t,e,n){if(t){if(t.length>Lb){if(n)throw new Rt("TOO_LONG");return}if(e===!1)return t;var r=t.search(Ub);if(!(r<0))return t.slice(r).replace(Mb,"")}}function Db(t,e,n){var r=Bb(t,{extractFormattedPhoneNumber:function(o){return Vb(o,n,e)}});if(!r)return{};if(!G3(r))return W3(r)?{error:"TOO_SHORT"}:{};var i=mb(r);return i.ext?i:{number:r}}function qb(t,e,n){var r={country:t,phone:e};return n&&(r.ext=n),r}function Hb(t,e,n,r){var i=tm(zp(t),e,n,r.metadata),s=i.countryCallingCodeSource,o=i.countryCallingCode,c=i.number,d;if(o)r.selectNumberingPlan(o);else if(c&&(e||n))r.selectNumberingPlan(e,n),e&&(d=e),o=n||jl(e,r.metadata);else return{};if(!c)return{countryCallingCodeSource:s,countryCallingCode:o};var l=_d(zp(c),r),u=l.nationalNumber,p=l.carrierCode,m=Sb(o,{nationalNumber:u,defaultCountry:e,metadata:r});return m&&(d=m,m==="001"||r.country(d)),{country:d,countryCallingCode:o,countryCallingCodeSource:s,nationalNumber:u,carrierCode:p}}function Tp(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Rp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Tp(Object(n),!0).forEach(function(r){Kb(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Tp(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Kb(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Gb(t,e,n){return Fb(t,Rp(Rp({},e),{},{v2:!0}),n)}function Bp(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Wb(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Bp(Object(n),!0).forEach(function(r){Jb(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Bp(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Jb(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Zb(t,e){return e4(t)||Qb(t,e)||Yb(t,e)||Xb()}function Xb(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
154
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Yb(t,e){if(t){if(typeof t=="string")return Lp(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Lp(t,e)}}function Lp(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function Qb(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var r=[],i=!0,s=!1,o,c;try{for(n=n.call(t);!(i=(o=n.next()).done)&&(r.push(o.value),!(e&&r.length===e));i=!0);}catch(d){s=!0,c=d}finally{try{!i&&n.return!=null&&n.return()}finally{if(s)throw c}}return r}}function e4(t){if(Array.isArray(t))return t}function t4(t){var e=Array.prototype.slice.call(t),n=Zb(e,4),r=n[0],i=n[1],s=n[2],o=n[3],c,d,l;if(typeof r=="string")c=r;else throw new TypeError("A text for parsing must be a string.");if(!i||typeof i=="string")o?(d=s,l=o):(d=void 0,l=s),i&&(d=Wb({defaultCountry:i},d));else if(sr(i))s?(d=i,l=s):l=i;else throw new Error("Invalid second argument: ".concat(i));return{text:c,options:d,metadata:l}}function Up(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Mp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Up(Object(n),!0).forEach(function(r){n4(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Up(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function n4(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function r4(t,e,n){e&&e.defaultCountry&&!p3(e.defaultCountry,n)&&(e=Mp(Mp({},e),{},{defaultCountry:void 0}));try{return Gb(t,e,n)}catch(r){if(!(r instanceof Rt))throw r}}function i4(){var t=t4(arguments),e=t.text,n=t.options,r=t.metadata;return r4(e,n,r)}function s4(){return r3(i4,arguments)}function pa(t,e="US"){const n=t.trim();if(n.includes("@")){const r=n.toLowerCase(),i=/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r);return{connection:"email",normalized:i?r:null,isValid:i}}else if(/^\+?\d[\d\s\-().]*$/.test(n)){const r=s4(n,{defaultCountry:e});return r&&r.isValid()?{connection:"sms",normalized:r.number,isValid:!0}:{connection:"sms",normalized:null,isValid:!1}}else return{connection:"username",normalized:n,isValid:!0}}const o4=a.z.object({client_id:a.z.string(),username:a.z.string().transform(t=>t.toLowerCase()),otp:a.z.string(),authParams:Jr.optional()});async function om(t,{client_id:e,username:n,otp:r,authParams:i}){const s=await t.env.data.clients.get(e);if(!s)throw new N(403,{message:"Client not found"});return Ul(t,s,i||{client_id:e,response_type:Ct.TOKEN_ID_TOKEN,response_mode:Ft.WEB_MESSAGE},n,r)}async function Ul(t,e,n,r,i,s,o){const{env:c}=t,d=await c.data.codes.get(e.tenant.id,i,"otp");if(!d)throw new N(400,{message:"Code not found or expired"});if(d.expires_at<new Date().toISOString())throw new N(400,{message:"Code expired"});if(d.used_at)throw new N(400,{message:"Code already used"});const l=Ot(t.req),{connection:u,normalized:p}=pa(r,l.countryCode);if(!p)throw new N(400,{message:"Invalid username format"});const m=await c.data.loginSessions.get(e.tenant.id,d.login_id);if(!m||m.authParams.username!==r)throw new N(400,{message:"Code not found or expired"});if(o&&m.ip!==l.ip)return t.redirect(`${ct(t.env)}invalid-session?state=${m.id}`);const w=await vo(t,{client:e,username:p,provider:u,connection:u,isSocial:!1,ip:t.req.header("x-real-ip")});return await c.data.codes.used(e.tenant.id,i),pn(t,{user:w,client:e,loginSession:m,authParams:n,ticketAuth:s})}const Fp=a.z.object({client_id:a.z.string().optional(),client_secret:a.z.string().optional()}),a4=a.z.union([Xg.extend(Fp.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(),...Fp.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()}),a.z.object({grant_type:a.z.literal("http://auth0.com/oauth/grant-type/passwordless/otp"),client_id:a.z.string(),username:a.z.string(),otp:a.z.string(),realm:a.z.enum(["email","sms"])})]);function c4(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 d4=new a.OpenAPIHono().openapi(a.createRoute({tags:["oauth2"],method:"post",path:"/",request:{body:{content:{"application/x-www-form-urlencoded":{schema:a4}}}},responses:{200:{content:{"application/json":{schema:k0}},description:"Tokens"}}}),async t=>{const e=t.req.valid("form"),n=c4(t.req.header("Authorization")),r={...e,...n};if(!r.client_id)throw new N(400,{message:"client_id is required"});switch(t.set("client_id",r.client_id),e.grant_type){case Qn.AuthorizationCode:return Qv(t,Yv.parse(r));case Qn.ClientCredential:return Xv(t,Xg.parse(r));case Qn.RefreshToken:return t3(t,e3.parse(r));case Qn.OTP:return om(t,o4.parse(r));default:throw new N(400,{message:"Not implemented"})}});var Ml={exports:{}};const Fl=[{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}],am=(t,e=Fl,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,d)=>d.id-c.id).map(c=>({id:c.id,value:c.value}));return Object.assign(s,o[0]),s};Ml.exports={passwordStrength:am,defaultOptions:Fl};var l4=Ml.exports.passwordStrength=am;Ml.exports.defaultOptions=Fl;function Vl(t){return l4(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 Ti(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 u4(t,e){var o,c;if(!t.var.client_id)throw new N(500,{message:"Client not found"});const n=await ji(t.env,t.var.client_id),r=n.connections.find(d=>d.strategy==="sms");if(!r)throw new N(500,{message:"SMS provider not found"});const i=((o=r.options)==null?void 0:o.provider)||"twilio",s=(c=t.env.smsProviders)==null?void 0:c[i];if(!s)throw new N(500,{message:"SMS provider not found"});await s({options:r.options,to:e.to,text:e.text,template:"auth-code",data:{code:e.code,tenantName:n.tenant.name,tenantId:n.tenant.id}})}async function cm(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=`${ct(t.env)}reset-password?state=${r}&code=${n}`,o={vendorName:i.name,lng:i.language||"en"};await Ti(t,{to:e,subject:re("reset_password_title",o),html:`Click here to reset your password: ${ct(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:re("password_reset_title",o),resetPasswordEmailClickToReset:re("reset_password_email_click_to_reset",o),resetPasswordEmailReset:re("reset_password_email_reset",o),supportInfo:re("support_info",o),contactUs:re("contact_us",o),copyright:re("copyright",o),tenantName:i.name,tenantId:i.id}})}async function dm(t,{to:e,code:n}){const r=await t.env.data.tenants.get(t.var.tenant_id);if(!r)throw new N(500,{message:"Tenant not found"});const{connection:i}=pa(e),s=new URL(ct(t.env)),o={vendorName:r.name,vendorId:r.id,loginDomain:s.hostname,code:n,lng:r.language||"en"};i==="email"?await Ti(t,{to:e,subject:re("code_email_subject",o),html:`Click here to validate your email: ${ct(t.env)}validate-email`,template:"auth-code",data:{code:n,vendorName:r.name,logo:r.logo||"",supportUrl:r.support_url||"",buttonColor:r.primary_color||"",welcomeToYourAccount:re("welcome_to_your_account",o),linkEmailClickToLogin:re("link_email_click_to_login",o),linkEmailLogin:re("link_email_login",o),linkEmailOrEnterCode:re("link_email_or_enter_code",o),codeValid30Mins:re("code_valid_30_minutes",o),supportInfo:re("support_info",o),contactUs:re("contact_us",o),copyright:re("copyright",o)}}):i==="sms"&&await u4(t,{to:e,text:re("sms_code_text",o),code:n});const c=we(t,{type:ge.CODE_LINK_SENT,description:e});It(t,t.env.data.logs.create(r.id,c))}async function Dl(t,{to:e,code:n,authParams: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{connection:s}=pa(e),o=new URL(je(t.env));o.pathname="passwordless/verify_redirect",o.searchParams.set("verification_code",n),o.searchParams.set("connection",s),o.searchParams.set("client_id",r.client_id),o.searchParams.set("redirect_uri",r.redirect_uri),o.searchParams.set("email",e),r.response_type&&o.searchParams.set("response_type",r.response_type),r.scope&&o.searchParams.set("scope",r.scope),r.state&&o.searchParams.set("state",r.state),r.nonce&&o.searchParams.set("nonce",r.nonce),r.code_challenge&&o.searchParams.set("code_challenge",r.code_challenge),r.code_challenge_method&&o.searchParams.set("code_challenge_method",r.code_challenge_method),r.audience&&o.searchParams.set("audience",r.audience);const c={vendorName:i.name,code:n,lng:i.language||"en"};if(s!=="email")throw new N(400,{message:"Only email connections are supported for magic links"});await Ti(t,{to:e,subject:re("code_email_subject",c),html:`Click here to validate your email: ${ct(t.env)}validate-email`,template:"auth-link",data:{code:n,vendorName:i.name,logo:i.logo||"",supportUrl:i.support_url||"",magicLink:o.toString(),buttonColor:i.primary_color||"",welcomeToYourAccount:re("welcome_to_your_account",c),linkEmailClickToLogin:re("link_email_click_to_login",c),linkEmailLogin:re("link_email_login",c),linkEmailOrEnterCode:re("link_email_or_enter_code",c),codeValid30Mins:re("code_valid_30_minutes",c),supportInfo:re("support_info",c),contactUs:re("contact_us",c),copyright:re("copyright",c)}});const d=we(t,{type:ge.CODE_LINK_SENT,description:e});It(t,t.env.data.logs.create(i.id,d))}async function ql(t,e){const n=await t.env.data.tenants.get(t.var.tenant_id);if(!n)throw new N(500,{message:"Tenant not found"});if(!e.email)throw new N(400,{message:"User has no email"});const r={vendorName:n.name,lng:n.language||"en"};await Ti(t,{to:e.email,subject:re("welcome_to_your_account",r),html:`Click here to validate your email: ${ct(t.env)}validate-email`,template:"auth-verify-email",data:{vendorName:n.name,logo:n.logo||"",emailValidationUrl:`${ct(t.env)}validate-email`,supportUrl:n.support_url||"https://support.sesamy.com",buttonColor:n.primary_color||"#7d68f4",welcomeToYourAccount:re("welcome_to_your_account",r),verifyEmailVerify:re("verify_email_verify",r),supportInfo:re("support_info",r),contactUs:re("contact_us",r),copyright:re("copyright",r)}})}async function f4(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={vendorName:i.name,lng:i.language||"en"},o=`${ct(t.env)}signup?state=${r}&code=${n}`;await Ti(t,{to:e,subject:re("register_password_account",s),html:`Click here to register: ${o}`,template:"auth-pre-signup-verification",data:{vendorName:i.name,logo:i.logo||"",signupUrl:o,setPassword:re("set_password",s),registerPasswordAccount:re("register_password_account",s),clickToSignUpDescription:re("click_to_sign_up_description",s),supportUrl:i.support_url||"https://support.sesamy.com",buttonColor:i.primary_color||"#7d68f4",welcomeToYourAccount:re("welcome_to_your_account",s),verifyEmailVerify:re("verify_email_verify",s),supportInfo:re("support_info",s),contactUs:re("contact_us",s),copyright:re("copyright",s)}})}const p4=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().optional(),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),!Vl(n))throw new N(400,{message:"Password does not meet the requirements"});if(await $s({userAdapter:t.env.data.users,tenant_id:i.tenant.id,username: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|${ho()}`,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 gi.hash(n,10);await t.env.data.passwords.create(i.tenant.id,{user_id:o.user_id,password:c,algorithm:"bcrypt"}),await ql(t,o);const d=we(t,{type:ge.SUCCESS_SIGNUP,description:"Successful signup"});return await t.env.data.logs.create(i.tenant.id,d),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 vr({userAdapter:t.env.data.users,tenant_id:r.tenant.id,username: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.loginSessions.create(r.tenant.id,{expires_at:new Date(Date.now()+or*1e3).toISOString(),authParams:s,csrf_token:xe(),...Ot(t.req)});return await cm(t,e,o.id,o.authParams.state),t.html("If an account with that email exists, we've sent instructions to reset your password.")});function Mn(){const t="1234567890";let e="";for(let n=0;n<6;n+=1)e+=t[Math.floor(Math.random()*10)];return e.toString()}const h4=new a.OpenAPIHono().openapi(a.createRoute({tags:["passwordless"],method:"post",path:"/start",request:{body:{content:{"application/json":{schema:a.z.union([a.z.object({connection:a.z.literal("email"),client_id:a.z.string(),email:a.z.string().transform(t=>t.toLowerCase()),send:a.z.enum(["link","code"]),authParams:Jr.omit({client_id:!0})}),a.z.object({client_id:a.z.string(),connection:a.z.literal("sms"),phone_number:a.z.string(),send:a.z.enum(["link","code"]),authParams:Jr.omit({client_id:!0})})])}}}},responses:{200:{description:"Status"}}}),async t=>{const e=t.req.valid("json"),{env:n}=t,{client_id:r,send:i,authParams:s,connection: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 d=o==="email"?e.email:e.phone_number,l=await n.data.loginSessions.create(c.tenant.id,{authParams:{...s,client_id:r,username:d},expires_at:new Date(Date.now()+Wa).toISOString(),csrf_token:xe(),...Ot(t.req)}),u=await n.data.codes.create(c.tenant.id,{code_id:Mn(),code_type:"otp",login_id:l.id,expires_at:new Date(Date.now()+Wa).toISOString()});return i==="link"?await Dl(t,{to:d,code:u.code_id,authParams:{...s,client_id:r}}):await dm(t,{to:d,code: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(Ct),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:d,response_type:l,nonce:u}=t.req.valid("query"),p=await ji(e,n);return t.set("client_id",p.id),t.set("tenant_id",p.tenant.id),t.set("connection","email"),Ul(t,p,{client_id:n,redirect_uri:s,state:o,nonce:u,scope:c,audience:d,response_type:l},r,i,!1,!0)});class Lr extends N{constructor(n,r){super(n,r);te(this,"_code");this._code=r==null?void 0:r.code}get code(){return this._code}}async function Hl(t,e,n,r,i){const{env:s}=t,{username:o}=n;if(t.set("username",o),!o)throw new N(400,{message:"Username is required"});const c=await vr({userAdapter:t.env.data.users,tenant_id:e.tenant.id,username:o,provider:"auth2"});if(!c){const h=we(t,{type:ge.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid user"});throw It(t,t.env.data.logs.create(e.tenant.id,h)),new Lr(403,{message:"User not found",code:"USER_NOT_FOUND"})}const d=c.linked_to?await s.data.users.get(e.tenant.id,c.linked_to):c;if(!d)throw new Lr(403,{message:"User not found",code:"USER_NOT_FOUND"});t.set("connection",c.connection),t.set("user_id",d.user_id);const l=await s.data.passwords.get(e.tenant.id,c.user_id);if(!(l&&await gi.compare(n.password,l.password))){const h=we(t,{type:ge.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid password"});throw It(t,t.env.data.logs.create(e.tenant.id,h)),new Lr(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:${d.user_id}`})).logs.filter(h=>h.type===ge.FAILED_LOGIN_INCORRECT_PASSWORD&&new Date(h.date)>new Date(Date.now()-1e3*60*5)).length>=3){const h=we(t,{type:ge.FAILED_LOGIN,description:"Too many failed login attempts"});throw It(t,t.env.data.logs.create(e.tenant.id,h)),new Lr(403,{message:"Too many failed login attempts",code:"TOO_MANY_FAILED_LOGINS"})}if(!c.email_verified&&e.email_validation==="enforced"){await ql(t,c);const h=we(t,{type:ge.FAILED_LOGIN,description:"Email not verified"});throw await t.env.data.logs.create(e.tenant.id,h),new Lr(403,{message:"Email not verified",code:"EMAIL_NOT_VERIFIED"})}const w=we(t,{type:ge.SUCCESS_LOGIN,description:"Successful login",strategy_type:"Username-Password-Authentication",strategy:"Username-Password-Authentication"});return It(t,t.env.data.logs.create(e.tenant.id,w)),pn(t,{client:e,authParams:n,user:d,ticketAuth:i,loginSession:r})}async function g4(t,e,n,r){await vo(t,{client:e,username:n,provider:"auth2",connection:"Username-Password-Authentication",isSocial:!1,ip:t.req.header("x-real-ip")});let i=Mn(),s=await t.env.data.codes.get(e.tenant.id,i,"password_reset");for(;s;)i=Mn(),s=await t.env.data.codes.get(e.tenant.id,i,"password_reset");const o=await t.env.data.loginSessions.create(e.tenant.id,{expires_at:new Date(Date.now()+c_).toISOString(),authParams:{client_id:e.id,username:n},csrf_token:xe(),...Ot(t.req)}),c=await t.env.data.codes.create(e.tenant.id,{code_id:i,code_type:"password_reset",login_id:o.id,expires_at:new Date(Date.now()+a_).toISOString()});await cm(t,n,c.code_id,r)}const m4=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 Ul(t,i,{client_id:n,username:s},s,e.otp,!0);if("password"in e){const o=await t.env.data.loginSessions.create(i.tenant.id,{expires_at:new Date(Date.now()+or*1e3).toISOString(),authParams:{client_id:n,username:s},csrf_token:xe(),...Ot(t.req)});return Hl(t,i,{username:s,password:e.password,client_id:n},o,!0)}else throw new N(400,{message:"Code or password required"})});function _4(t,e){var r,i,s;if(!t||e.length===0)return!1;const n=((r=Ta(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=Ta(o))==null?void 0:i.host)??null:c=((s=Ta("https://"+o))==null?void 0:s.host)??null,n===c)return!0}return!1}function Ta(t){try{return new URL(t)}catch{return null}}async function y4({ctx:t,session:e,client:n,authParams:r,connection:i,login_hint:s}){const o=new URL(t.req.url);t.var.custom_domain&&(o.hostname=t.var.custom_domain);const c=await t.env.data.loginSessions.create(n.tenant.id,{expires_at:new Date(Date.now()+or*1e3).toISOString(),authParams:r,csrf_token:xe(),authorization_url:o.toString(),...Ot(t.req)});if(e&&s){const d=await t.env.data.users.get(n.tenant.id,e.user_id);if((d==null?void 0:d.email)===s)return pn(t,{client:n,loginSession:c,authParams:r,user:d,sessionId:e.id})}if(i==="email"&&s){const d=Mn();return await t.env.data.codes.create(n.tenant.id,{code_id:d,code_type:"otp",login_id:c.id,expires_at:new Date(Date.now()+or*1e3).toISOString()}),await Dl(t,{code:d,to:s,authParams:r}),t.redirect(`/u/enter-code?state=${c.id}`)}return e?t.redirect(`/u/check-account?state=${c.id}`):t.redirect(`/u/login/identifier?state=${c.id}`)}function w4(t){if(t==="Username-Password-Authentication")return"auth2";if(t==="email")return"email";throw new N(403,{message:"Invalid realm"})}async function v4(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.loginSessions.get(e,o.login_id);if(!c||!c.authParams.username)throw new N(403,{message:"Session not found"});const d=await s.data.clients.get(c.authParams.client_id);if(!d)throw new N(403,{message:"Client not found"});t.set("client_id",c.authParams.client_id),await s.data.codes.used(e,n);const l=w4(i);let u=await vo(t,{username:c.authParams.username,provider:l,client:d,connection:l==="auth2"?"Username-Password-Authentication":"email",isSocial:!1,ip:t.req.header("x-real-ip")});t.set("username",u.email||u.phone_number),t.set("user_id",u.user_id);const p=await G0(t,{user:u,client:d,loginSession:c});return pn(t,{authParams:{scope:(m=c.authParams)==null?void 0:m.scope,...r},loginSession:c,sessionId:p.id,user:u,client:d})}async function Vp(t,e){return`<!DOCTYPE html>
149
+ `,r}async function Mw(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 Ga(await P0(s))}const Fw=1e3*60*60*24,Vw=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(Ka)}},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:Ka}},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()+Fw).toISOString()});const n=await hd({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 hd({name:`CN=${t.env.ORGANIZATION_NAME}`});return await t.env.data.keys.create(r),t.text("OK")}),Dw=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(Id)}},description:"List of users"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{email:n}=t.req.valid("query"),i=(await Md(t.env.data.users,e,n)).filter(s=>!s.linked_to);return t.json(i)}),qw=un.extend({clients:a.z.array(bn)}),Hw=new a.OpenAPIHono().openapi(a.createRoute({tags:["clients"],method:"get",path:"/",request:{query:on,headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:a.z.union([qw,a.z.array(bn)])}},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"),d=(await t.env.data.applications.list(e,{page:n,per_page:r,include_totals:i,sort:br(s),q:o})).applications;return i?t.json({clients:d,start:0,limit:10,length:d.length}):t.json(d)}).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:bn}},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(ms.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:bn}},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(ms.shape)}}},headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:a.z.object(bn.shape)}},description:"An application"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),r={...n,id:n.id||xe(),client_secret:n.client_secret||xe()},i=await t.env.data.applications.create(e,r);return t.json(i,{status:201})});a.z.object({start:a.z.number(),limit:a.z.number(),length:a.z.number()});fo.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 Kw=un.extend({tenants:a.z.array(tr)}),Gw=new a.OpenAPIHono().openapi(a.createRoute({tags:["tenants"],method:"get",path:"/",request:{query:on},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:a.z.union([a.z.array(tr),Kw])}},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:br(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:tr}},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(ys.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(ys.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"tenant/json":{schema:tr}},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})}),Ww=un.extend({logs:a.z.array(vs)}),Jw=new a.OpenAPIHono().openapi(a.createRoute({tags:["logs"],method:"get",path:"/",request:{query:on,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(vs),Ww])}},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:br(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:vs}},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)}),Zw=un.extend({hooks:a.z.array(Yn)}),Xw=new a.OpenAPIHono().openapi(a.createRoute({tags:["hooks"],method:"get",path:"/",request:{query:on,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(Yn),Zw])}},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:br(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(ws.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Yn}},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(ws.shape).omit({hook_id:!0}).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Yn.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:Yn}},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")}),Yw=un.extend({connections:a.z.array(Qt)}),Qw=new a.OpenAPIHono().openapi(a.createRoute({tags:["connections"],method:"get",path:"/",request:{query:on,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(Qt),Yw])}},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:br(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:Qt}},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(_s.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:Qt}},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(_s.shape)}}},headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Qt}},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})}),ev=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:Ji}},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(Ji.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(Ji.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 op=!1;function Ug(t){t.use(async(e,n)=>(op||(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"}}}}),op=!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 tv(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 nv(t,e){const r=new TextEncoder().encode([e.raw.header,e.raw.payload].join(".")),i=new Uint8Array(Array.from(e.signature).map(d=>d.charCodeAt(0))),o=(await tv(t.env)).find(d=>d.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 rv(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 Mg(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 d=e.req.header("authorization")||"",[l,u]=d.split(" ");if((l==null?void 0:l.toLowerCase())!=="bearer"||!u)throw new N(401,{message:"Missing bearer token"});const p=rv(u);if(!p||!await nv(e,p))throw new N(403,{message:"Invalid JWT signature"});e.set("user_id",p.payload.sub),e.set("user",p.payload);const m=p.payload.permissions||[],w=((o=p.payload.scope)==null?void 0:o.split(" "))||[];if(c.length&&!(c.some(h=>m.includes(h))||c.some(h=>w.includes(h))))throw new N(403,{message:"Unauthorized"})}return await n()}}const iv=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:Zi}},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(Zi.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(Zi.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")}),sv=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:ho}},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})}),ov=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:Od}},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")}),av=new a.OpenAPIHono().openapi(a.createRoute({tags:["custom-domains"],method:"get",path:"/",request:{query:on,headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:a.z.array(Yt)}},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:Yt}},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(Yt.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:Yt}},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(Cd.shape)}}},headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Yt}},description:"The created custom domain"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),r=await t.env.data.customDomains.create(e,n);return t.json(r,{status:201})}).openapi(a.createRoute({tags:["custom-domains"],method:"post",path:"/{id}/verify",request:{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:Yt}},description:"The custom domain"}}}),async()=>{throw new N(501,{message:"Not implemented"})});function Cl(t,e){const n={};for(const[r,i]of Object.entries(e)){const s={};for(const[o,c]of Object.entries(i))typeof c=="function"?s[o]=async(...d)=>{const l=performance.now();try{const u=await c(...d),m=performance.now()-l,w=t.res.headers.get("Server-Timing")||"",h=w?`${w}, ${r}-${o};dur=${m.toFixed(2)}`:`${r}-${o};dur=${m.toFixed(2)}`;return t.res.headers.set("Server-Timing",h),u}catch(u){const m=performance.now()-l,w=t.res.headers.get("Server-Timing")||"",h=w?`${w}, ${r}-${o}-error;dur=${m.toFixed(2)}`:`${r}-${o}-error;dur=${m.toFixed(2)}`;throw t.res.headers.set("Server-Timing",h),u}}:s[o]=c;n[r]=s}return n}async function zl(t,e){const n=t.req.header("x-forwarded-host");if(n){const i=await t.env.data.customDomains.getByDomain(n);if(i)return t.set("tenant_id",i.tenant_id),t.set("custom_domain",n),await e()}const r=t.req.header("host");if(r){const i=r.split(".");if(i.length>1&&typeof i[0]=="string"){const s=i[0];await t.env.data.tenants.get(s)&&t.set("tenant_id",s)}}return await e()}const vn=class vn{constructor(){te(this,"cacheStore",new Map)}static getInstance(){return vn.instance||(vn.instance=new vn),vn.instance}set(e,n,r){if(r<=0)return;const i=Date.now()+r;this.cacheStore.set(e,{value:n,expiresAt:i})}get(e){const n=this.cacheStore.get(e);if(n){if(Date.now()>n.expiresAt){this.cacheStore.delete(e);return}return n.value}}delete(e){this.cacheStore.delete(e)}getKeysByPrefix(e){return Array.from(this.cacheStore.keys()).filter(n=>n.startsWith(e))}clear(){this.cacheStore.clear()}};te(vn,"instance");let gd=vn;function cv(t,e,n){try{return`${t}:${e}:${JSON.stringify(n)}`}catch{return`${t}:${e}:${Date.now()}-${Math.random()}`}}function Ol(t,e){const n=e.cache||gd.getInstance(),r=e.defaultTtl,i=e.customTtls||{},s=new Set(e.excludeMethods||[]),o=e.maxItems||0,c=e.cacheEntities||[],d=c.length===0,l=new Set(c),u={};for(const[p,m]of Object.entries(t)){const w=d||l.has(p),h={};for(const[_,v]of Object.entries(m))if(typeof v=="function"){if(!w){h[_]=v;continue}const k=`${p}:${_}`;if(s.has(k)){h[_]=v;continue}const I=i[k]||r,O=["create","update","remove","delete","set","used"].includes(_);h[_]=async(...L)=>{if(O){const ke=await Promise.resolve(n.getKeysByPrefix(`${p}:`));for(const Ee of ke)await Promise.resolve(n.delete(Ee));return await v.apply(m,L)}const Y=cv(p,_,L),oe=await Promise.resolve(n.get(Y));if(oe!==void 0)return oe;const ae=await v.apply(m,L);if(await n.set(Y,ae,I),o>0){const ke=await Promise.resolve(n.getKeysByPrefix(""));if(ke.length>o){const Ee=ke.slice(0,ke.length-o);for(const ze of Ee)await Promise.resolve(n.delete(ze))}}return ae}}else h[_]=v;u[p]=h}return u}function dv(t){const e=new a.OpenAPIHono;e.use(d0({origin:r=>{var i;return r&&(i=t.allowedOrigins)!=null&&i.includes(r)?r:""},allowHeaders:["Tenant-Id","Content-Type","Content-Range","Auth0-Client","Authorization","Range","Upgrade-Insecure-Requests"],allowMethods:["POST","PUT","GET","DELETE","PATCH","OPTIONS"],exposeHeaders:["Content-Length","Content-Range"],maxAge:600,credentials:!0})),Ug(e),e.use(async(r,i)=>{const s=wo(r,t.dataAdapter),o=Ol(s,{defaultTtl:0,cacheEntities:["tenants","connections","clients"]});return r.env.data=Cl(r,o),i()}),e.use(zl).use(Mg(e));const n=e.route("/branding",T1).route("/custom-domains",av).route("/email/providers",iv).route("/users",qy).route("/keys",Vw).route("/users-by-email",Dw).route("/clients",Hw).route("/tenants",Gw).route("/logs",Jw).route("/hooks",Xw).route("/connections",Qw).route("/prompts",ev).route("/sessions",sv).route("/refresh_tokens",ov);return n.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Management api"},security:[{oauth2:["openid","email","profile"]}]}),n}function lv(t,e){Object.keys(e).forEach(n=>{const r=e[n];r!=null&&r.length&&t.searchParams.set(n,r)})}var ap;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(ap||(ap={}));var cp;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(cp||(cp={}));function uv(t){return Vg(t,fv,ci.Include)}function Fg(t){return Vg(t,pv,ci.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===ci.Include&&(r+="=")}return r}const fv="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",pv="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";var ci;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(ci||(ci={}));var dp;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(dp||(dp={}));class hv{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 lp=new hv;function St(t,e){return(t<<32-e|t>>>e)>>>0}function gv(t){const e=new mv;return e.update(t),e.digest()}class mv{constructor(){te(this,"blockSize",64);te(this,"size",32);te(this,"blocks",new Uint8Array(64));te(this,"currentBlockSize",0);te(this,"H",new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]));te(this,"l",0n);te(this,"w",new Uint32Array(64))}update(e){if(this.l+=BigInt(e.byteLength)*8n,this.currentBlockSize+e.byteLength<64){this.blocks.set(e,this.currentBlockSize),this.currentBlockSize+=e.byteLength;return}let n=0;if(this.currentBlockSize>0){const r=e.slice(0,64-this.currentBlockSize);this.blocks.set(r,this.currentBlockSize),this.process(),n+=r.byteLength,this.currentBlockSize=0}for(;n+64<=e.byteLength;){const r=e.slice(n,n+64);this.blocks.set(r),this.process(),n+=64}if(e.byteLength-n>0){const r=e.slice(n);this.blocks.set(r),this.currentBlockSize=r.byteLength}}digest(){this.blocks[this.currentBlockSize]=128,this.currentBlockSize+=1,64-this.currentBlockSize<8&&(this.blocks.fill(0,this.currentBlockSize),this.process(),this.currentBlockSize=0),this.blocks.fill(0,this.currentBlockSize),lp.putUint64(this.blocks,this.l,this.blockSize-8),this.process();const e=new Uint8Array(32);for(let n=0;n<8;n++)lp.putUint32(e,this.H[n],n*4);return e}process(){for(let l=0;l<16;l++)this.w[l]=(this.blocks[l*4]<<24|this.blocks[l*4+1]<<16|this.blocks[l*4+2]<<8|this.blocks[l*4+3])>>>0;for(let l=16;l<64;l++){const u=(St(this.w[l-2],17)^St(this.w[l-2],19)^this.w[l-2]>>>10)>>>0,p=(St(this.w[l-15],7)^St(this.w[l-15],18)^this.w[l-15]>>>3)>>>0;this.w[l]=u+this.w[l-7]+p+this.w[l-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],d=this.H[7];for(let l=0;l<64;l++){const u=(St(s,6)^St(s,11)^St(s,25))>>>0,p=(s&o^~s&c)>>>0,m=d+u+p+_v[l]+this.w[l]|0,w=(St(e,2)^St(e,13)^St(e,22))>>>0,h=(e&n^e&r^n&r)>>>0,_=w+h|0;d=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]=d+this.H[7]|0}}const _v=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 yv{constructor(e){te(this,"data");this.data=e}tokenType(){if("token_type"in this.data&&typeof this.data.token_type=="string")return this.data.token_type;throw new Error("Missing or invalid 'token_type' field")}accessToken(){if("access_token"in this.data&&typeof this.data.access_token=="string")return this.data.access_token;throw new Error("Missing or invalid 'access_token' field")}accessTokenExpiresInSeconds(){if("expires_in"in this.data&&typeof this.data.expires_in=="number")return this.data.expires_in;throw new Error("Missing or invalid 'expires_in' field")}accessTokenExpiresAt(){return new Date(Date.now()+this.accessTokenExpiresInSeconds()*1e3)}hasRefreshToken(){return"refresh_token"in this.data&&typeof this.data.refresh_token=="string"}refreshToken(){if("refresh_token"in this.data&&typeof this.data.refresh_token=="string")return this.data.refresh_token;throw new Error("Missing or invalid 'refresh_token' field")}hasScopes(){return"scope"in this.data&&typeof this.data.scope=="string"}scopes(){if("scope"in this.data&&typeof this.data.scope=="string")return this.data.scope.split(" ");throw new Error("Missing or invalid 'scope' field")}idToken(){if("id_token"in this.data&&typeof this.data.id_token=="string")return this.data.id_token;throw new Error("Missing or invalid field 'id_token'")}}function wv(t){const e=gv(new TextEncoder().encode(t));return Fg(e)}function vv(){const t=new Uint8Array(32);return crypto.getRandomValues(t),Fg(t)}function Kr(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 Oa(t,e){const n=new TextEncoder().encode(`${t}:${e}`);return uv(n)}async function io(t){let e;try{e=await fetch(t)}catch(n){throw new qg(n)}if(e.status===400||e.status===401){let n;try{n=await e.json()}catch{throw new ts(e.status)}if(typeof n!="object"||n===null)throw new ir(e.status,n);let r;try{r=Dg(n)}catch{throw new ir(e.status,n)}throw r}if(e.status===200){let n;try{n=await e.json()}catch{throw new ts(e.status)}if(typeof n!="object"||n===null)throw new ir(e.status,n);return new yv(n)}throw e.body!==null&&await e.body.cancel(),new ts(e.status)}async function bv(t){let e;try{e=await fetch(t)}catch(n){throw new qg(n)}if(e.status===400||e.status===401){let n;try{n=await e.json()}catch{throw new ir(e.status,null)}if(typeof n!="object"||n===null)throw new ir(e.status,n);let r;try{r=Dg(n)}catch{throw new ir(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 ts(e.status)}function Dg(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 $v(e,n,r,i)}class qg extends Error{constructor(e){super("Failed to send request",{cause:e})}}class $v extends Error{constructor(n,r,i,s){super(`OAuth request error: ${n}`);te(this,"code");te(this,"description");te(this,"uri");te(this,"state");this.code=n,this.description=r,this.uri=i,this.state=s}}class ts extends Error{constructor(n){super("Unexpected error response");te(this,"status");this.status=n}}class ir extends Error{constructor(n,r){super("Unexpected error response body");te(this,"status");te(this,"data");this.status=n,this.data=r}}class Pl{constructor(e,n,r){te(this,"clientId");te(this,"clientPassword");te(this,"redirectURI");this.clientId=e,this.clientPassword=n,this.redirectURI=r}createAuthorizationURL(e,n,r){const i=new URL(e);return i.searchParams.set("response_type","code"),i.searchParams.set("client_id",this.clientId),this.redirectURI!==null&&i.searchParams.set("redirect_uri",this.redirectURI),i.searchParams.set("state",n),r.length>0&&i.searchParams.set("scope",r.join(" ")),i}createAuthorizationURLWithPKCE(e,n,r,i,s){const 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===di.S256){const c=wv(i);o.searchParams.set("code_challenge_method","S256"),o.searchParams.set("code_challenge",c)}else r===di.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=Kr(e,i);if(this.clientPassword!==null){const c=Oa(this.clientId,this.clientPassword);s.headers.set("Authorization",`Basic ${c}`)}return await io(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=Kr(e,i);if(this.clientPassword!==null){const c=Oa(this.clientId,this.clientPassword);s.headers.set("Authorization",`Basic ${c}`)}return await io(s)}async revokeToken(e,n){const r=new URLSearchParams;r.set("token",n),this.clientPassword===null&&r.set("client_id",this.clientId);const i=Kr(e,r);if(this.clientPassword!==null){const s=Oa(this.clientId,this.clientPassword);i.headers.set("Authorization",`Basic ${s}`)}await bv(i)}}var di;(function(t){t[t.S256=0]="S256",t[t.Plain=1]="Plain"})(di||(di={}));var up;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(up||(up={}));var fp;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(fp||(fp={}));function Gr(t){return xv(t,kv,so.None)}function xv(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===so.Include&&(r+="=")}return r}const kv="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";var so;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(so||(so={}));var pp;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(pp||(pp={}));function Sv(t,e,n){const r=Gr(new TextEncoder().encode(t)),i=Gr(new TextEncoder().encode(e)),s=Gr(n);return r+"."+i+"."+s}function Av(t,e){const n=Gr(new TextEncoder().encode(t)),r=Gr(new TextEncoder().encode(e)),i=n+"."+r;return new TextEncoder().encode(i)}const Ev="https://appleid.apple.com/auth/authorize",Iv="https://appleid.apple.com/auth/token";class Hg{constructor(e,n,r,i,s){te(this,"clientId");te(this,"teamId");te(this,"keyId");te(this,"pkcs8PrivateKey");te(this,"redirectURI");this.clientId=e,this.teamId=n,this.keyId=r,this.pkcs8PrivateKey=i,this.redirectURI=s}createAuthorizationURL(e,n){const r=new URL(Ev);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=Kr(Iv,n);return await io(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,Av(r,i)));return Sv(r,i,s)}}const Nv="https://www.facebook.com/v16.0/dialog/oauth",Cv="https://graph.facebook.com/v16.0/oauth/access_token";class Kg{constructor(e,n,r){te(this,"clientId");te(this,"clientSecret");te(this,"redirectURI");this.clientId=e,this.clientSecret=n,this.redirectURI=r}createAuthorizationURL(e,n){const r=new URL(Nv);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=Kr(Cv,n);return await io(r)}}const zv="https://accounts.google.com/o/oauth2/v2/auth",hp="https://oauth2.googleapis.com/token",Ov="https://oauth2.googleapis.com/revoke";let Gg=class{constructor(e,n,r){te(this,"client");this.client=new Pl(e,n,r)}createAuthorizationURL(e,n,r){return this.client.createAuthorizationURLWithPKCE(zv,e,di.S256,n,r)}async validateAuthorizationCode(e,n){return await this.client.validateAuthorizationCode(hp,e,n)}async refreshAccessToken(e){return await this.client.refreshAccessToken(hp,e,[])}async revokeToken(e){await this.client.revokeToken(Ov,e)}};const ua=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();ua.omit({iat:!0,auth_time:!0,nonce:!0,acr:!0,amr:!0,azp:!0,at_hash:!0,c_hash:!0});function Pv(t){return t.ISSUER}function ct(t){return t.UNIVERSAL_LOGIN_URL||`${t.ISSUER}u/`}function je(t){return t.OAUTH_API_URL||t.ISSUER}function Wg(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 jv(t,e){var d,l;const{options:n,keyArray:r}=Wg(e),i=new Hg(n.client_id,n.team_id,n.kid,r,`${je(t.env)}callback`),s=xe(),o=await i.createAuthorizationURL(s,((d=n.scope)==null?void 0:d.split(" "))||["name","email"]);return(((l=n.scope)==null?void 0:l.split(" "))||["name","email"]).some(u=>["email","name"].includes(u))&&o.searchParams.set("response_mode","form_post"),{redirectUrl:o.href,code:s}}async function Tv(t,e,n){const{options:r,keyArray:i}=Wg(e),o=await new Hg(r.client_id,r.team_id,r.kid,i,`${je(t.env)}callback`).validateAuthorizationCode(n),c=jd(o.idToken());if(!c)throw new Error("Invalid ID token");const d=ua.parse(c.payload);return{sub:d.sub,email:d.email,given_name:d.given_name,family_name:d.family_name,name:d.name,picture:d.picture,locale:d.locale}}const Rv=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:jv,validateAuthorizationCodeAndGetUser:Tv},Symbol.toStringTag,{value:"Module"}));async function Bv(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 Kg(n.client_id,n.client_secret,`${je(t.env)}callback`),i=xe();return{redirectUrl:r.createAuthorizationURL(i,((o=n.scope)==null?void 0:o.split(" "))||["email"]).href,code:i}}async function Lv(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 Kg(r.client_id,r.client_secret,`${je(t.env)}callback`).validateAuthorizationCode(n),o=await fetch("https://graph.facebook.com/v22.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 Uv=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:Bv,validateAuthorizationCodeAndGetUser:Lv},Symbol.toStringTag,{value:"Module"}));async function Mv(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 Gg(n.client_id,n.client_secret,`${je(t.env)}callback`),i=xe(),s=vv();return{redirectUrl:r.createAuthorizationURL(i,s,((c=n.scope)==null?void 0:c.split(" "))??["email","profile"]).href,code:i,codeVerifier:s}}async function Fv(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 Gg(i.client_id,i.client_secret,`${je(t.env)}callback`).validateAuthorizationCode(n,r),c=jd(o.idToken());if(!c)throw new Error("Invalid ID token");const d=ua.parse(c.payload);return{sub:d.sub,email:d.email,given_name:d.given_name,family_name:d.family_name,name:d.name,picture:d.picture,locale:d.locale}}const Vv=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:Mv,validateAuthorizationCodeAndGetUser:Fv},Symbol.toStringTag,{value:"Module"}));async function Dv(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 Pl(n.client_id,n.client_secret,`${je(t.env)}callback`),i=xe(),s=r.createAuthorizationURL("https://api.vipps.no/access-management-1.0/access/oauth2/auth",i,((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 qv(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 Pl(r.client_id,r.client_secret,`${je(t.env)}callback`).validateAuthorizationCode("https://api.vipps.no/access-management-1.0/access/oauth2/token",n,null),o=jd(s.idToken());if(!o)throw new Error("Invalid ID token");const c=ua.parse(o.payload);if(typeof c.msn!="string")throw new Error("msn not available in id token");const d=await fetch("https://api.vipps.no/vipps-userinfo-api/userinfo",{headers:{Authorization:`Bearer ${s.accessToken()}`,"Merchant-Serial-Number":c.msn}});if(!d.ok)throw new N(400,{message:"Failed to get user from vipps"});return await d.json()}const Hv=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:Dv,validateAuthorizationCodeAndGetUser:qv},Symbol.toStringTag,{value:"Module"}));function Jg(t,e){const n=t.env.STRATEGIES||{},i={apple:Rv,facebook:Uv,"google-oauth2":Vv,vipps:Hv,...n}[e];if(!i)throw new Error(`Strategy ${e} not found`);return i}async function Ti(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 u;const d=(u=s.connections)==null?void 0:u.find(p=>p.name===c.name);if(!(d!=null&&d.options))return c;const l=Qt.parse({...d||{},...c});return l.options=Nd.passthrough().parse({...d.options||{},...c.options}),l}).filter(c=>c);return{...n,web_origins:[...(r==null?void 0:r.web_origins)||[],...n.web_origins||[],`${ct(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||[],`${ct(t)}info`],connections:o,tenant:{...(r==null?void 0:r.tenant)||{},...n.tenant}}}async function Kv(t,e,n,r){if(!r.state)throw new N(400,{message:"State not found"});const i=e.connections.find(d=>d.name===n);if(!i){t.set("client_id",e.id);const d=we(t,{type:ge.FAILED_LOGIN,description:"Connection not found"});throw await t.env.data.logs.create(e.tenant.id,d),new N(403,{message:"Connection Not Found"})}let s=await t.env.data.loginSessions.get(e.tenant.id,r.state);s||(s=await t.env.data.loginSessions.create(e.tenant.id,{expires_at:new Date(Date.now()+or*1e3).toISOString(),authParams:r,csrf_token:xe(),...Ot(t.req)}));const c=await Jg(t,i.strategy).getRedirect(t,i);return await t.env.data.codes.create(e.tenant.id,{login_id:s.id,code_id:c.code,code_type:"oauth2_state",connection_id:i.id,code_verifier:c.codeVerifier,expires_at:new Date(Date.now()+o_*1e3).toISOString()}),t.redirect(c.redirectUrl)}async function gp(t,{code:e,state:n}){var h;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.loginSessions.get(t.var.tenant_id||"",i.login_id);if(!s)throw new N(403,{message:"Session not found"});if(s.authorization_url){const _=new URL(s.authorization_url).hostname,v=t.var.custom_domain||t.req.header("host")||"";if(_!==v&&_){const k=new URL(`https://${_}/callback`);return k.searchParams.set("state",n),k.searchParams.set("code",e),new Response("Redirecting",{status:307,headers:{location:k.toString()}})}}const o=await Ti(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 _=we(t,{type:ge.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 _=we(t,{type:ge.FAILED_LOGIN,description:"Redirect URI not defined"});throw await r.data.logs.create(o.tenant.id,_),new N(403,{message:"Redirect URI not defined"})}const l=await Jg(t,c.strategy).validateAuthorizationCodeAndGetUser(t,c,e,i.code_verifier),{sub:u,...p}=l;t.set("user_id",u);const m=((h=l.email)==null?void 0:h.toLocaleLowerCase())||`${c.name}.${u}@${new URL(t.env.ISSUER).hostname}`;t.set("username",m);const w=await bo(t,{client:o,username:m,provider:c.strategy,connection:c.name,userId:u,profileData:p,isSocial:!0,ip:t.req.header("x-real-ip")});return pn(t,{client:o,authParams:s.authParams,loginSession:s,user:w})}async function mp(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.loginSessions.get(t.var.tenant_id,o.login_id);if(!c)throw new N(400,{message:"Login not found"});const{redirect_uri:d}=c.authParams;if(!d)throw new N(400,{message:"Redirect uri not found"});const l=we(t,{type:ge.FAILED_LOGIN,description:`Failed connection login: ${i} ${n}, ${r}`});It(t,t.env.data.logs.create(t.var.tenant_id,l));const u=new URL(d);return lv(u,{error:n,error_description:r,error_reason:s,error_code:i,state:c.authParams.state}),t.redirect(`${ct(t.env)}login/identifier?state=${c.id}&error=${n}`)}const Gv=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 mp(t,e,r,i,s,o);if(!n)throw new N(400,{message:"Code is required"});return gp(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 mp(t,e,r,i,s,o);if(!n)throw new N(400,{message:"Code is required"});return gp(t,{code:n,state:e})});function Zg(t,e=[],n={}){try{const r=new URL(t);return e.some(i=>{try{return Wv(r,new URL(i),n.allowPathWildcards)}catch{return!1}})}catch{return!1}}function Wv(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}const Jv=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(!Zg(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 d=$s(r.tenant.id,o);if(d){const l=await t.env.data.sessions.get(r.tenant.id,d);if(l){const u=await t.env.data.users.get(r.tenant.id,l.user_id);u&&(t.set("user_id",u.user_id),t.set("connection",u.connection));const p=await t.env.data.refreshTokens.list(r.tenant.id,{q:`session_id=${d}`,page:0,per_page:100,include_totals:!1});await Promise.all(p.refresh_tokens.map(m=>t.env.data.refreshTokens.remove(r.tenant.id,m.id))),await t.env.data.sessions.update(r.tenant.id,d,{revoked_at:new Date().toISOString()})}}}const c=we(t,{type:ge.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":u_(r.tenant.id,t.req.header("host")),location:s}})}),_p=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()}),Zv=new a.OpenAPIHono().openapi(a.createRoute({tags:["oauth2"],method:"get",path:"/",request:{},security:[{Bearer:["openid"]}],responses:{200:{content:{"application/json":{schema:_p}},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(_p.parse({...e,sub:e.user_id}))}),Xv=new a.OpenAPIHono().openapi(a.createRoute({tags:["well known"],method:"get",path:"/jwks.json",request:{},responses:{200:{content:{"application/json":{schema:y0}},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 Nl(r.cert).publicKey.export(),o=await crypto.subtle.exportKey("jwk",s);return zd.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=${Di}, stale-while-revalidate=${Di*2}, stale-if-error=86400`}})}).openapi(a.createRoute({tags:["well known"],method:"get",path:"/openid-configuration",request:{},responses:{200:{content:{"application/json":{schema:Ha}},description:"List of tenants"}}}),async t=>{const e=Ha.parse({issuer:Pv(t.env),authorization_endpoint:`${je(t.env)}authorize`,token_endpoint:`${je(t.env)}oauth/token`,device_authorization_endpoint:`${je(t.env)}oauth/device/code`,userinfo_endpoint:`${je(t.env)}userinfo`,mfa_challenge_endpoint:`${je(t.env)}mfa/challenge`,jwks_uri:`${je(t.env)}.well-known/jwks.json`,registration_endpoint:`${je(t.env)}oidc/register`,revocation_endpoint:`${je(t.env)}oauth/revoke`,scopes_supported:["openid","profile","offline_access","name","given_name","family_name","nickname","email","email_verified","picture","created_at","identities","phone","address"],response_types_supported:["code","token","id_token","code token","code id_token","token id_token","code token id_token"],code_challenge_methods_supported:["S256","plain"],response_modes_supported:["query","fragment","form_post"],subject_types_supported:["public"],id_token_signing_alg_values_supported:["RS256"],token_endpoint_auth_methods_supported:["client_secret_basic","client_secret_post"],claims_supported:["aud","auth_time","created_at","email","email_verified","exp","family_name","given_name","iat","identities","iss","name","nickname","phone_number","picture","sub"],request_uri_parameter_supported:!1,request_parameter_supported:!1,token_endpoint_auth_signing_alg_values_supported:["RS256","RS384","PS256"]});return t.json(e,{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${Di}, stale-while-revalidate=${Di*2}, stale-if-error=86400`}})});function ns(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 Xg=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 Yv(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&&!ns(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 yo(t,{authParams:r,client:n});return t.json(i)}const Qv=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 e3(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.loginSessions.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(!ns(n.client_secret,e.client_secret)&&!ns(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 n_(e.code_verifier,i.authParams.code_challenge_method);if(!ns(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),pn(t,{user:s,client:n,loginSession:i,authParams:{...i.authParams,response_mode:Ft.WEB_MESSAGE}})}const t3=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 n3(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 pn(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:Ft.WEB_MESSAGE}})}const r3={version:4,country_calling_codes:{1:["US","AG","AI","AS","BB","BM","BS","CA","DM","DO","GD","GU","JM","KN","KY","LC","MP","MS","PR","SX","TC","TT","VC","VG","VI"],7:["RU","KZ"],20:["EG"],27:["ZA"],30:["GR"],31:["NL"],32:["BE"],33:["FR"],34:["ES"],36:["HU"],39:["IT","VA"],40:["RO"],41:["CH"],43:["AT"],44:["GB","GG","IM","JE"],45:["DK"],46:["SE"],47:["NO","SJ"],48:["PL"],49:["DE"],51:["PE"],52:["MX"],53:["CU"],54:["AR"],55:["BR"],56:["CL"],57:["CO"],58:["VE"],60:["MY"],61:["AU","CC","CX"],62:["ID"],63:["PH"],64:["NZ"],65:["SG"],66:["TH"],81:["JP"],82:["KR"],84:["VN"],86:["CN"],90:["TR"],91:["IN"],92:["PK"],93:["AF"],94:["LK"],95:["MM"],98:["IR"],211:["SS"],212:["MA","EH"],213:["DZ"],216:["TN"],218:["LY"],220:["GM"],221:["SN"],222:["MR"],223:["ML"],224:["GN"],225:["CI"],226:["BF"],227:["NE"],228:["TG"],229:["BJ"],230:["MU"],231:["LR"],232:["SL"],233:["GH"],234:["NG"],235:["TD"],236:["CF"],237:["CM"],238:["CV"],239:["ST"],240:["GQ"],241:["GA"],242:["CG"],243:["CD"],244:["AO"],245:["GW"],246:["IO"],247:["AC"],248:["SC"],249:["SD"],250:["RW"],251:["ET"],252:["SO"],253:["DJ"],254:["KE"],255:["TZ"],256:["UG"],257:["BI"],258:["MZ"],260:["ZM"],261:["MG"],262:["RE","YT"],263:["ZW"],264:["NA"],265:["MW"],266:["LS"],267:["BW"],268:["SZ"],269:["KM"],290:["SH","TA"],291:["ER"],297:["AW"],298:["FO"],299:["GL"],350:["GI"],351:["PT"],352:["LU"],353:["IE"],354:["IS"],355:["AL"],356:["MT"],357:["CY"],358:["FI","AX"],359:["BG"],370:["LT"],371:["LV"],372:["EE"],373:["MD"],374:["AM"],375:["BY"],376:["AD"],377:["MC"],378:["SM"],380:["UA"],381:["RS"],382:["ME"],383:["XK"],385:["HR"],386:["SI"],387:["BA"],389:["MK"],420:["CZ"],421:["SK"],423:["LI"],500:["FK"],501:["BZ"],502:["GT"],503:["SV"],504:["HN"],505:["NI"],506:["CR"],507:["PA"],508:["PM"],509:["HT"],590:["GP","BL","MF"],591:["BO"],592:["GY"],593:["EC"],594:["GF"],595:["PY"],596:["MQ"],597:["SR"],598:["UY"],599:["CW","BQ"],670:["TL"],672:["NF"],673:["BN"],674:["NR"],675:["PG"],676:["TO"],677:["SB"],678:["VU"],679:["FJ"],680:["PW"],681:["WF"],682:["CK"],683:["NU"],685:["WS"],686:["KI"],687:["NC"],688:["TV"],689:["PF"],690:["TK"],691:["FM"],692:["MH"],850:["KP"],852:["HK"],853:["MO"],855:["KH"],856:["LA"],880:["BD"],886:["TW"],960:["MV"],961:["LB"],962:["JO"],963:["SY"],964:["IQ"],965:["KW"],966:["SA"],967:["YE"],968:["OM"],970:["PS"],971:["AE"],972:["IL"],973:["BH"],974:["QA"],975:["BT"],976:["MN"],977:["NP"],992:["TJ"],993:["TM"],994:["AZ"],995:["GE"],996:["KG"],998:["UZ"]},countries:{AC:["247","00","(?:[01589]\\d|[46])\\d{4}",[5,6]],AD:["376","00","(?:1|6\\d)\\d{7}|[135-9]\\d{5}",[6,8,9],[["(\\d{3})(\\d{3})","$1 $2",["[135-9]"]],["(\\d{4})(\\d{4})","$1 $2",["1"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6"]]]],AE:["971","00","(?:[4-7]\\d|9[0-689])\\d{7}|800\\d{2,9}|[2-4679]\\d{7}",[5,6,7,8,9,10,11,12],[["(\\d{3})(\\d{2,9})","$1 $2",["60|8"]],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[236]|[479][2-8]"],"0$1"],["(\\d{3})(\\d)(\\d{5})","$1 $2 $3",["[479]"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["5"],"0$1"]],"0"],AF:["93","00","[2-7]\\d{8}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[2-7]"],"0$1"]],"0"],AG:["1","011","(?:268|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([457]\\d{6})$|1","268$1",0,"268"],AI:["1","011","(?:264|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2457]\\d{6})$|1","264$1",0,"264"],AL:["355","00","(?:700\\d\\d|900)\\d{3}|8\\d{5,7}|(?:[2-5]|6\\d)\\d{7}",[6,7,8,9],[["(\\d{3})(\\d{3,4})","$1 $2",["80|9"],"0$1"],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["4[2-6]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2358][2-5]|4"],"0$1"],["(\\d{3})(\\d{5})","$1 $2",["[23578]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["6"],"0$1"]],"0"],AM:["374","00","(?:[1-489]\\d|55|60|77)\\d{6}",[8],[["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["[89]0"],"0 $1"],["(\\d{3})(\\d{5})","$1 $2",["2|3[12]"],"(0$1)"],["(\\d{2})(\\d{6})","$1 $2",["1|47"],"(0$1)"],["(\\d{2})(\\d{6})","$1 $2",["[3-9]"],"0$1"]],"0"],AO:["244","00","[29]\\d{8}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[29]"]]]],AR:["54","00","(?:11|[89]\\d\\d)\\d{8}|[2368]\\d{9}",[10,11],[["(\\d{4})(\\d{2})(\\d{4})","$1 $2-$3",["2(?:2[024-9]|3[0-59]|47|6[245]|9[02-8])|3(?:3[28]|4[03-9]|5[2-46-8]|7[1-578]|8[2-9])","2(?:[23]02|6(?:[25]|4[6-8])|9(?:[02356]|4[02568]|72|8[23]))|3(?:3[28]|4(?:[04679]|3[5-8]|5[4-68]|8[2379])|5(?:[2467]|3[237]|8[2-5])|7[1-578]|8(?:[2469]|3[2578]|5[4-8]|7[36-8]|8[5-8]))|2(?:2[24-9]|3[1-59]|47)","2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3[78]|5(?:4[46]|8)|8[2379])|5(?:[2467]|3[237]|8[23])|7[1-578]|8(?:[2469]|3[278]|5[56][46]|86[3-6]))|2(?:2[24-9]|3[1-59]|47)|38(?:[58][78]|7[378])|3(?:4[35][56]|58[45]|8(?:[38]5|54|76))[4-6]","2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3(?:5(?:4[0-25689]|[56])|[78])|58|8[2379])|5(?:[2467]|3[237]|8(?:[23]|4(?:[45]|60)|5(?:4[0-39]|5|64)))|7[1-578]|8(?:[2469]|3[278]|54(?:4|5[13-7]|6[89])|86[3-6]))|2(?:2[24-9]|3[1-59]|47)|38(?:[58][78]|7[378])|3(?:454|85[56])[46]|3(?:4(?:36|5[56])|8(?:[38]5|76))[4-6]"],"0$1",1],["(\\d{2})(\\d{4})(\\d{4})","$1 $2-$3",["1"],"0$1",1],["(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["[68]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2-$3",["[23]"],"0$1",1],["(\\d)(\\d{4})(\\d{2})(\\d{4})","$2 15-$3-$4",["9(?:2[2-469]|3[3-578])","9(?:2(?:2[024-9]|3[0-59]|47|6[245]|9[02-8])|3(?:3[28]|4[03-9]|5[2-46-8]|7[1-578]|8[2-9]))","9(?:2(?:[23]02|6(?:[25]|4[6-8])|9(?:[02356]|4[02568]|72|8[23]))|3(?:3[28]|4(?:[04679]|3[5-8]|5[4-68]|8[2379])|5(?:[2467]|3[237]|8[2-5])|7[1-578]|8(?:[2469]|3[2578]|5[4-8]|7[36-8]|8[5-8])))|92(?:2[24-9]|3[1-59]|47)","9(?:2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3[78]|5(?:4[46]|8)|8[2379])|5(?:[2467]|3[237]|8[23])|7[1-578]|8(?:[2469]|3[278]|5(?:[56][46]|[78])|7[378]|8(?:6[3-6]|[78]))))|92(?:2[24-9]|3[1-59]|47)|93(?:4[35][56]|58[45]|8(?:[38]5|54|76))[4-6]","9(?:2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3(?:5(?:4[0-25689]|[56])|[78])|5(?:4[46]|8)|8[2379])|5(?:[2467]|3[237]|8(?:[23]|4(?:[45]|60)|5(?:4[0-39]|5|64)))|7[1-578]|8(?:[2469]|3[278]|5(?:4(?:4|5[13-7]|6[89])|[56][46]|[78])|7[378]|8(?:6[3-6]|[78]))))|92(?:2[24-9]|3[1-59]|47)|93(?:4(?:36|5[56])|8(?:[38]5|76))[4-6]"],"0$1",0,"$1 $2 $3-$4"],["(\\d)(\\d{2})(\\d{4})(\\d{4})","$2 15-$3-$4",["91"],"0$1",0,"$1 $2 $3-$4"],["(\\d{3})(\\d{3})(\\d{5})","$1-$2-$3",["8"],"0$1"],["(\\d)(\\d{3})(\\d{3})(\\d{4})","$2 15-$3-$4",["9"],"0$1",0,"$1 $2 $3-$4"]],"0",0,"0?(?:(11|2(?:2(?:02?|[13]|2[13-79]|4[1-6]|5[2457]|6[124-8]|7[1-4]|8[13-6]|9[1267])|3(?:02?|1[467]|2[03-6]|3[13-8]|[49][2-6]|5[2-8]|[67])|4(?:7[3-578]|9)|6(?:[0136]|2[24-6]|4[6-8]?|5[15-8])|80|9(?:0[1-3]|[19]|2\\d|3[1-6]|4[02568]?|5[2-4]|6[2-46]|72?|8[23]?))|3(?:3(?:2[79]|6|8[2578])|4(?:0[0-24-9]|[12]|3[5-8]?|4[24-7]|5[4-68]?|6[02-9]|7[126]|8[2379]?|9[1-36-8])|5(?:1|2[1245]|3[237]?|4[1-46-9]|6[2-4]|7[1-6]|8[2-5]?)|6[24]|7(?:[069]|1[1568]|2[15]|3[145]|4[13]|5[14-8]|7[2-57]|8[126])|8(?:[01]|2[15-7]|3[2578]?|4[13-6]|5[4-8]?|6[1-357-9]|7[36-8]?|8[5-8]?|9[124])))15)?","9$1"],AS:["1","011","(?:[58]\\d\\d|684|900)\\d{7}",[10],0,"1",0,"([267]\\d{6})$|1","684$1",0,"684"],AT:["43","00","1\\d{3,12}|2\\d{6,12}|43(?:(?:0\\d|5[02-9])\\d{3,9}|2\\d{4,5}|[3467]\\d{4}|8\\d{4,6}|9\\d{4,7})|5\\d{4,12}|8\\d{7,12}|9\\d{8,12}|(?:[367]\\d|4[0-24-9])\\d{4,11}",[4,5,6,7,8,9,10,11,12,13],[["(\\d)(\\d{3,12})","$1 $2",["1(?:11|[2-9])"],"0$1"],["(\\d{3})(\\d{2})","$1 $2",["517"],"0$1"],["(\\d{2})(\\d{3,5})","$1 $2",["5[079]"],"0$1"],["(\\d{3})(\\d{3,10})","$1 $2",["(?:31|4)6|51|6(?:48|5[0-3579]|[6-9])|7(?:20|32|8)|[89]","(?:31|4)6|51|6(?:485|5[0-3579]|[6-9])|7(?:20|32|8)|[89]"],"0$1"],["(\\d{4})(\\d{3,9})","$1 $2",["[2-467]|5[2-6]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["5"],"0$1"],["(\\d{2})(\\d{4})(\\d{4,7})","$1 $2 $3",["5"],"0$1"]],"0"],AU:["61","001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011","1(?:[0-79]\\d{7}(?:\\d(?:\\d{2})?)?|8[0-24-9]\\d{7})|[2-478]\\d{8}|1\\d{4,7}",[5,6,7,8,9,10,12],[["(\\d{2})(\\d{3,4})","$1 $2",["16"],"0$1"],["(\\d{2})(\\d{3})(\\d{2,4})","$1 $2 $3",["16"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["14|4"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["[2378]"],"(0$1)"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1(?:30|[89])"]]],"0",0,"(183[12])|0",0,0,0,[["(?:(?:(?:2(?:[0-26-9]\\d|3[0-8]|4[02-9]|5[0135-9])|7(?:[013-57-9]\\d|2[0-8]))\\d|3(?:(?:[0-3589]\\d|6[1-9]|7[0-35-9])\\d|4(?:[0-578]\\d|90)))\\d\\d|8(?:51(?:0(?:0[03-9]|[12479]\\d|3[2-9]|5[0-8]|6[1-9]|8[0-7])|1(?:[0235689]\\d|1[0-69]|4[0-589]|7[0-47-9])|2(?:0[0-79]|[18][13579]|2[14-9]|3[0-46-9]|[4-6]\\d|7[89]|9[0-4])|3\\d\\d)|(?:6[0-8]|[78]\\d)\\d{3}|9(?:[02-9]\\d{3}|1(?:(?:[0-58]\\d|6[0135-9])\\d|7(?:0[0-24-9]|[1-9]\\d)|9(?:[0-46-9]\\d|5[0-79])))))\\d{3}",[9]],["4(?:79[01]|83[0-389]|94[0-4])\\d{5}|4(?:[0-36]\\d|4[047-9]|5[0-25-9]|7[02-8]|8[0-24-9]|9[0-37-9])\\d{6}",[9]],["180(?:0\\d{3}|2)\\d{3}",[7,10]],["190[0-26]\\d{6}",[10]],0,0,0,["163\\d{2,6}",[5,6,7,8,9]],["14(?:5(?:1[0458]|[23][458])|71\\d)\\d{4}",[9]],["13(?:00\\d{6}(?:\\d{2})?|45[0-4]\\d{3})|13\\d{4}",[6,8,10,12]]],"0011"],AW:["297","00","(?:[25-79]\\d\\d|800)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[25-9]"]]]],AX:["358","00|99(?:[01469]|5(?:[14]1|3[23]|5[59]|77|88|9[09]))","2\\d{4,9}|35\\d{4,5}|(?:60\\d\\d|800)\\d{4,6}|7\\d{5,11}|(?:[14]\\d|3[0-46-9]|50)\\d{4,8}",[5,6,7,8,9,10,11,12],0,"0",0,0,0,0,"18",0,"00"],AZ:["994","00","365\\d{6}|(?:[124579]\\d|60|88)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["90"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[28]|2|365|46","1[28]|2|365[45]|46","1[28]|2|365(?:4|5[02])|46"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[13-9]"],"0$1"]],"0"],BA:["387","00","6\\d{8}|(?:[35689]\\d|49|70)\\d{6}",[8,9],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["6[1-3]|[7-9]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2-$3",["[3-5]|6[56]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3 $4",["6"],"0$1"]],"0"],BB:["1","011","(?:246|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","246$1",0,"246"],BD:["880","00","[1-469]\\d{9}|8[0-79]\\d{7,8}|[2-79]\\d{8}|[2-9]\\d{7}|[3-9]\\d{6}|[57-9]\\d{5}",[6,7,8,9,10],[["(\\d{2})(\\d{4,6})","$1-$2",["31[5-8]|[459]1"],"0$1"],["(\\d{3})(\\d{3,7})","$1-$2",["3(?:[67]|8[013-9])|4(?:6[168]|7|[89][18])|5(?:6[128]|9)|6(?:[15]|28|4[14])|7[2-589]|8(?:0[014-9]|[12])|9[358]|(?:3[2-5]|4[235]|5[2-578]|6[0389]|76|8[3-7]|9[24])1|(?:44|66)[01346-9]"],"0$1"],["(\\d{4})(\\d{3,6})","$1-$2",["[13-9]|2[23]"],"0$1"],["(\\d)(\\d{7,8})","$1-$2",["2"],"0$1"]],"0"],BE:["32","00","4\\d{8}|[1-9]\\d{7}",[8,9],[["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["(?:80|9)0"],"0$1"],["(\\d)(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[239]|4[23]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[15-8]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["4"],"0$1"]],"0"],BF:["226","00","[025-7]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[025-7]"]]]],BG:["359","00","00800\\d{7}|[2-7]\\d{6,7}|[89]\\d{6,8}|2\\d{5}",[6,7,8,9,12],[["(\\d)(\\d)(\\d{2})(\\d{2})","$1 $2 $3 $4",["2"],"0$1"],["(\\d{3})(\\d{4})","$1 $2",["43[1-6]|70[1-9]"],"0$1"],["(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{2,3})","$1 $2 $3",["[356]|4[124-7]|7[1-9]|8[1-6]|9[1-7]"],"0$1"],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["(?:70|8)0"],"0$1"],["(\\d{3})(\\d{3})(\\d{2})","$1 $2 $3",["43[1-7]|7"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[48]|9[08]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["9"],"0$1"]],"0"],BH:["973","00","[136-9]\\d{7}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[13679]|8[02-4679]"]]]],BI:["257","00","(?:[267]\\d|31)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2367]"]]]],BJ:["229","00","(?:01\\d|[24-689])\\d{7}",[8,10],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[24-689]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["0"]]]],BL:["590","00","(?:590\\d|7090)\\d{5}|(?:69|80|9\\d)\\d{7}",[9],0,"0",0,0,0,0,0,[["590(?:2[7-9]|3[3-7]|5[12]|87)\\d{4}"],["(?:69(?:0\\d\\d|1(?:2[2-9]|3[0-5])|4(?:0[89]|1[2-6]|9\\d)|6(?:1[016-9]|5[0-4]|[67]\\d))|7090[0-4])\\d{4}"],["80[0-5]\\d{6}"],0,0,0,0,0,["9(?:(?:39[5-7]|76[018])\\d|475[0-6])\\d{4}"]]],BM:["1","011","(?:441|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","441$1",0,"441"],BN:["673","00","[2-578]\\d{6}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-578]"]]]],BO:["591","00(?:1\\d)?","8001\\d{5}|(?:[2-467]\\d|50)\\d{6}",[8,9],[["(\\d)(\\d{7})","$1 $2",["[235]|4[46]"]],["(\\d{8})","$1",["[67]"]],["(\\d{3})(\\d{2})(\\d{4})","$1 $2 $3",["8"]]],"0",0,"0(1\\d)?"],BQ:["599","00","(?:[34]1|7\\d)\\d{5}",[7],0,0,0,0,0,0,"[347]"],BR:["55","00(?:1[245]|2[1-35]|31|4[13]|[56]5|99)","[1-467]\\d{9,10}|55[0-46-9]\\d{8}|[34]\\d{7}|55\\d{7,8}|(?:5[0-46-9]|[89]\\d)\\d{7,9}",[8,9,10,11],[["(\\d{4})(\\d{4})","$1-$2",["300|4(?:0[02]|37|86)","300|4(?:0(?:0|20)|370|864)"]],["(\\d{3})(\\d{2,3})(\\d{4})","$1 $2 $3",["(?:[358]|90)0"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1 $2-$3",["(?:[14689][1-9]|2[12478]|3[1-578]|5[13-5]|7[13-579])[2-57]"],"($1)"],["(\\d{2})(\\d{5})(\\d{4})","$1 $2-$3",["[16][1-9]|[2-57-9]"],"($1)"]],"0",0,"(?:0|90)(?:(1[245]|2[1-35]|31|4[13]|[56]5|99)(\\d{10,11}))?","$2"],BS:["1","011","(?:242|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([3-8]\\d{6})$|1","242$1",0,"242"],BT:["975","00","[17]\\d{7}|[2-8]\\d{6}",[7,8],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[2-68]|7[246]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[67]|7"]]]],BW:["267","00","(?:0800|(?:[37]|800)\\d)\\d{6}|(?:[2-6]\\d|90)\\d{5}",[7,8,10],[["(\\d{2})(\\d{5})","$1 $2",["90"]],["(\\d{3})(\\d{4})","$1 $2",["[24-6]|3[15-9]"]],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[37]"]],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["0"]],["(\\d{3})(\\d{4})(\\d{3})","$1 $2 $3",["8"]]]],BY:["375","810","(?:[12]\\d|33|44|902)\\d{7}|8(?:0[0-79]\\d{5,7}|[1-7]\\d{9})|8(?:1[0-489]|[5-79]\\d)\\d{7}|8[1-79]\\d{6,7}|8[0-79]\\d{5}|8\\d{5}",[6,7,8,9,10,11],[["(\\d{3})(\\d{3})","$1 $2",["800"],"8 $1"],["(\\d{3})(\\d{2})(\\d{2,4})","$1 $2 $3",["800"],"8 $1"],["(\\d{4})(\\d{2})(\\d{3})","$1 $2-$3",["1(?:5[169]|6[3-5]|7[179])|2(?:1[35]|2[34]|3[3-5])","1(?:5[169]|6(?:3[1-3]|4|5[125])|7(?:1[3-9]|7[0-24-6]|9[2-7]))|2(?:1[35]|2[34]|3[3-5])"],"8 0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2-$3-$4",["1(?:[56]|7[467])|2[1-3]"],"8 0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2-$3-$4",["[1-4]"],"8 0$1"],["(\\d{3})(\\d{3,4})(\\d{4})","$1 $2 $3",["[89]"],"8 $1"]],"8",0,"0|80?",0,0,0,0,"8~10"],BZ:["501","00","(?:0800\\d|[2-8])\\d{6}",[7,11],[["(\\d{3})(\\d{4})","$1-$2",["[2-8]"]],["(\\d)(\\d{3})(\\d{4})(\\d{3})","$1-$2-$3-$4",["0"]]]],CA:["1","011","[2-9]\\d{9}|3\\d{6}",[7,10],0,"1",0,0,0,0,0,[["(?:2(?:04|[23]6|[48]9|50|63)|3(?:06|43|54|6[578]|82)|4(?:03|1[68]|[26]8|3[178]|50|74)|5(?:06|1[49]|48|79|8[147])|6(?:04|[18]3|39|47|72)|7(?:0[59]|42|53|78|8[02])|8(?:[06]7|19|25|7[39])|9(?:0[25]|42))[2-9]\\d{6}",[10]],["",[10]],["8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",[10]],["900[2-9]\\d{6}",[10]],["52(?:3(?:[2-46-9][02-9]\\d|5(?:[02-46-9]\\d|5[0-46-9]))|4(?:[2-478][02-9]\\d|5(?:[034]\\d|2[024-9]|5[0-46-9])|6(?:0[1-9]|[2-9]\\d)|9(?:[05-9]\\d|2[0-5]|49)))\\d{4}|52[34][2-9]1[02-9]\\d{4}|(?:5(?:2[125-9]|33|44|66|77|88)|6(?:22|33))[2-9]\\d{6}",[10]],0,["310\\d{4}",[7]],0,["600[2-9]\\d{6}",[10]]]],CC:["61","001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011","1(?:[0-79]\\d{8}(?:\\d{2})?|8[0-24-9]\\d{7})|[148]\\d{8}|1\\d{5,7}",[6,7,8,9,10,12],0,"0",0,"([59]\\d{7})$|0","8$1",0,0,[["8(?:51(?:0(?:02|31|60|89)|1(?:18|76)|223)|91(?:0(?:1[0-2]|29)|1(?:[28]2|50|79)|2(?:10|64)|3(?:[06]8|22)|4[29]8|62\\d|70[23]|959))\\d{3}",[9]],["4(?:79[01]|83[0-389]|94[0-4])\\d{5}|4(?:[0-36]\\d|4[047-9]|5[0-25-9]|7[02-8]|8[0-24-9]|9[0-37-9])\\d{6}",[9]],["180(?:0\\d{3}|2)\\d{3}",[7,10]],["190[0-26]\\d{6}",[10]],0,0,0,0,["14(?:5(?:1[0458]|[23][458])|71\\d)\\d{4}",[9]],["13(?:00\\d{6}(?:\\d{2})?|45[0-4]\\d{3})|13\\d{4}",[6,8,10,12]]],"0011"],CD:["243","00","(?:(?:[189]|5\\d)\\d|2)\\d{7}|[1-68]\\d{6}",[7,8,9,10],[["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["88"],"0$1"],["(\\d{2})(\\d{5})","$1 $2",["[1-6]"],"0$1"],["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[89]"],"0$1"],["(\\d{2})(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3 $4",["5"],"0$1"]],"0"],CF:["236","00","(?:[27]\\d{3}|8776)\\d{4}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[278]"]]]],CG:["242","00","222\\d{6}|(?:0\\d|80)\\d{7}",[9],[["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["8"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[02]"]]]],CH:["41","00","8\\d{11}|[2-9]\\d{8}",[9,12],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8[047]|90"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-79]|81"],"0$1"],["(\\d{3})(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["8"],"0$1"]],"0"],CI:["225","00","[02]\\d{9}",[10],[["(\\d{2})(\\d{2})(\\d)(\\d{5})","$1 $2 $3 $4",["2"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3 $4",["0"]]]],CK:["682","00","[2-578]\\d{4}",[5],[["(\\d{2})(\\d{3})","$1 $2",["[2-578]"]]]],CL:["56","(?:0|1(?:1[0-69]|2[02-5]|5[13-58]|69|7[0167]|8[018]))0","12300\\d{6}|6\\d{9,10}|[2-9]\\d{8}",[9,10,11],[["(\\d{5})(\\d{4})","$1 $2",["219","2196"],"($1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["44"]],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["2[1-36]"],"($1)"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["9[2-9]"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["3[2-5]|[47]|5[1-3578]|6[13-57]|8(?:0[1-9]|[1-9])"],"($1)"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["60|8"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]],["(\\d{3})(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3 $4",["60"]]]],CM:["237","00","[26]\\d{8}|88\\d{6,7}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["88"]],["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["[26]|88"]]]],CN:["86","00|1(?:[12]\\d|79)\\d\\d00","(?:(?:1[03-689]|2\\d)\\d\\d|6)\\d{8}|1\\d{10}|[126]\\d{6}(?:\\d(?:\\d{2})?)?|86\\d{5,6}|(?:[3-579]\\d|8[0-57-9])\\d{5,9}",[7,8,9,10,11,12],[["(\\d{2})(\\d{5,6})","$1 $2",["(?:10|2[0-57-9])[19]|3(?:[157]|35|49|9[1-68])|4(?:1[124-9]|2[179]|6[47-9]|7|8[23])|5(?:[1357]|2[37]|4[36]|6[1-46]|80)|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:07|1[236-8]|2[5-7]|[37]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3|4[13]|5[1-5]|7[0-79]|9[0-35-9])|(?:4[35]|59|85)[1-9]","(?:10|2[0-57-9])(?:1[02]|9[56])|8078|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))1","10(?:1(?:0|23)|9[56])|2[0-57-9](?:1(?:00|23)|9[56])|80781|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))12","10(?:1(?:0|23)|9[56])|2[0-57-9](?:1(?:00|23)|9[56])|807812|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))123","10(?:1(?:0|23)|9[56])|2[0-57-9](?:1(?:00|23)|9[56])|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:078|1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))123"],"0$1"],["(\\d{3})(\\d{5,6})","$1 $2",["3(?:[157]|35|49|9[1-68])|4(?:[17]|2[179]|6[47-9]|8[23])|5(?:[1357]|2[37]|4[36]|6[1-46]|80)|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]|4[13]|5[1-5])|(?:4[35]|59|85)[1-9]","(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))[19]","85[23](?:10|95)|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[14-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))(?:10|9[56])","85[23](?:100|95)|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[14-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))(?:100|9[56])"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["(?:4|80)0"]],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["10|2(?:[02-57-9]|1[1-9])","10|2(?:[02-57-9]|1[1-9])","10[0-79]|2(?:[02-57-9]|1[1-79])|(?:10|21)8(?:0[1-9]|[1-9])"],"0$1",1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["3(?:[3-59]|7[02-68])|4(?:[26-8]|3[3-9]|5[2-9])|5(?:3[03-9]|[468]|7[028]|9[2-46-9])|6|7(?:[0-247]|3[04-9]|5[0-4689]|6[2368])|8(?:[1-358]|9[1-7])|9(?:[013479]|5[1-5])|(?:[34]1|55|79|87)[02-9]"],"0$1",1],["(\\d{3})(\\d{7,8})","$1 $2",["9"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["80"],"0$1",1],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["[3-578]"],"0$1",1],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["1[3-9]"]],["(\\d{2})(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3 $4",["[12]"],"0$1",1]],"0",0,"(1(?:[12]\\d|79)\\d\\d)|0",0,0,0,0,"00"],CO:["57","00(?:4(?:[14]4|56)|[579])","(?:46|60\\d\\d)\\d{6}|(?:1\\d|[39])\\d{9}",[8,10,11],[["(\\d{4})(\\d{4})","$1 $2",["46"]],["(\\d{3})(\\d{7})","$1 $2",["6|90"],"($1)"],["(\\d{3})(\\d{7})","$1 $2",["3[0-357]|91"]],["(\\d)(\\d{3})(\\d{7})","$1-$2-$3",["1"],"0$1",0,"$1 $2 $3"]],"0",0,"0([3579]|4(?:[14]4|56))?"],CR:["506","00","(?:8\\d|90)\\d{8}|(?:[24-8]\\d{3}|3005)\\d{4}",[8,10],[["(\\d{4})(\\d{4})","$1 $2",["[2-7]|8[3-9]"]],["(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["[89]"]]],0,0,"(19(?:0[0-2468]|1[09]|20|66|77|99))"],CU:["53","119","(?:[2-7]|8\\d\\d)\\d{7}|[2-47]\\d{6}|[34]\\d{5}",[6,7,8,10],[["(\\d{2})(\\d{4,6})","$1 $2",["2[1-4]|[34]"],"(0$1)"],["(\\d)(\\d{6,7})","$1 $2",["7"],"(0$1)"],["(\\d)(\\d{7})","$1 $2",["[56]"],"0$1"],["(\\d{3})(\\d{7})","$1 $2",["8"],"0$1"]],"0"],CV:["238","0","(?:[2-59]\\d\\d|800)\\d{4}",[7],[["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["[2-589]"]]]],CW:["599","00","(?:[34]1|60|(?:7|9\\d)\\d)\\d{5}",[7,8],[["(\\d{3})(\\d{4})","$1 $2",["[3467]"]],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["9[4-8]"]]],0,0,0,0,0,"[69]"],CX:["61","001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011","1(?:[0-79]\\d{8}(?:\\d{2})?|8[0-24-9]\\d{7})|[148]\\d{8}|1\\d{5,7}",[6,7,8,9,10,12],0,"0",0,"([59]\\d{7})$|0","8$1",0,0,[["8(?:51(?:0(?:01|30|59|88)|1(?:17|46|75)|2(?:22|35))|91(?:00[6-9]|1(?:[28]1|49|78)|2(?:09|63)|3(?:12|26|75)|4(?:56|97)|64\\d|7(?:0[01]|1[0-2])|958))\\d{3}",[9]],["4(?:79[01]|83[0-389]|94[0-4])\\d{5}|4(?:[0-36]\\d|4[047-9]|5[0-25-9]|7[02-8]|8[0-24-9]|9[0-37-9])\\d{6}",[9]],["180(?:0\\d{3}|2)\\d{3}",[7,10]],["190[0-26]\\d{6}",[10]],0,0,0,0,["14(?:5(?:1[0458]|[23][458])|71\\d)\\d{4}",[9]],["13(?:00\\d{6}(?:\\d{2})?|45[0-4]\\d{3})|13\\d{4}",[6,8,10,12]]],"0011"],CY:["357","00","(?:[279]\\d|[58]0)\\d{6}",[8],[["(\\d{2})(\\d{6})","$1 $2",["[257-9]"]]]],CZ:["420","00","(?:[2-578]\\d|60)\\d{7}|9\\d{8,11}",[9,10,11,12],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[2-8]|9[015-7]"]],["(\\d{2})(\\d{3})(\\d{3})(\\d{2})","$1 $2 $3 $4",["96"]],["(\\d{2})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["9"]],["(\\d{3})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["9"]]]],DE:["49","00","[2579]\\d{5,14}|49(?:[34]0|69|8\\d)\\d\\d?|49(?:37|49|60|7[089]|9\\d)\\d{1,3}|49(?:2[024-9]|3[2-689]|7[1-7])\\d{1,8}|(?:1|[368]\\d|4[0-8])\\d{3,13}|49(?:[015]\\d|2[13]|31|[46][1-8])\\d{1,9}",[4,5,6,7,8,9,10,11,12,13,14,15],[["(\\d{2})(\\d{3,13})","$1 $2",["3[02]|40|[68]9"],"0$1"],["(\\d{3})(\\d{3,12})","$1 $2",["2(?:0[1-389]|1[124]|2[18]|3[14])|3(?:[35-9][15]|4[015])|906|(?:2[4-9]|4[2-9]|[579][1-9]|[68][1-8])1","2(?:0[1-389]|12[0-8])|3(?:[35-9][15]|4[015])|906|2(?:[13][14]|2[18])|(?:2[4-9]|4[2-9]|[579][1-9]|[68][1-8])1"],"0$1"],["(\\d{4})(\\d{2,11})","$1 $2",["[24-6]|3(?:[3569][02-46-9]|4[2-4679]|7[2-467]|8[2-46-8])|70[2-8]|8(?:0[2-9]|[1-8])|90[7-9]|[79][1-9]","[24-6]|3(?:3(?:0[1-467]|2[127-9]|3[124578]|7[1257-9]|8[1256]|9[145])|4(?:2[135]|4[13578]|9[1346])|5(?:0[14]|2[1-3589]|6[1-4]|7[13468]|8[13568])|6(?:2[1-489]|3[124-6]|6[13]|7[12579]|8[1-356]|9[135])|7(?:2[1-7]|4[145]|6[1-5]|7[1-4])|8(?:21|3[1468]|6|7[1467]|8[136])|9(?:0[12479]|2[1358]|4[134679]|6[1-9]|7[136]|8[147]|9[1468]))|70[2-8]|8(?:0[2-9]|[1-8])|90[7-9]|[79][1-9]|3[68]4[1347]|3(?:47|60)[1356]|3(?:3[46]|46|5[49])[1246]|3[4579]3[1357]"],"0$1"],["(\\d{3})(\\d{4})","$1 $2",["138"],"0$1"],["(\\d{5})(\\d{2,10})","$1 $2",["3"],"0$1"],["(\\d{3})(\\d{5,11})","$1 $2",["181"],"0$1"],["(\\d{3})(\\d)(\\d{4,10})","$1 $2 $3",["1(?:3|80)|9"],"0$1"],["(\\d{3})(\\d{7,8})","$1 $2",["1[67]"],"0$1"],["(\\d{3})(\\d{7,12})","$1 $2",["8"],"0$1"],["(\\d{5})(\\d{6})","$1 $2",["185","1850","18500"],"0$1"],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["7"],"0$1"],["(\\d{4})(\\d{7})","$1 $2",["18[68]"],"0$1"],["(\\d{4})(\\d{7})","$1 $2",["15[1279]"],"0$1"],["(\\d{5})(\\d{6})","$1 $2",["15[03568]","15(?:[0568]|31)"],"0$1"],["(\\d{3})(\\d{8})","$1 $2",["18"],"0$1"],["(\\d{3})(\\d{2})(\\d{7,8})","$1 $2 $3",["1(?:6[023]|7)"],"0$1"],["(\\d{4})(\\d{2})(\\d{7})","$1 $2 $3",["15[279]"],"0$1"],["(\\d{3})(\\d{2})(\\d{8})","$1 $2 $3",["15"],"0$1"]],"0"],DJ:["253","00","(?:2\\d|77)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[27]"]]]],DK:["45","00","[2-9]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-9]"]]]],DM:["1","011","(?:[58]\\d\\d|767|900)\\d{7}",[10],0,"1",0,"([2-7]\\d{6})$|1","767$1",0,"767"],DO:["1","011","(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,0,0,0,"8001|8[024]9"],DZ:["213","00","(?:[1-4]|[5-79]\\d|80)\\d{7}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[1-4]"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["9"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-8]"],"0$1"]],"0"],EC:["593","00","1\\d{9,10}|(?:[2-7]|9\\d)\\d{7}",[8,9,10,11],[["(\\d)(\\d{3})(\\d{4})","$1 $2-$3",["[2-7]"],"(0$1)",0,"$1-$2-$3"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["9"],"0$1"],["(\\d{4})(\\d{3})(\\d{3,4})","$1 $2 $3",["1"]]],"0"],EE:["372","00","8\\d{9}|[4578]\\d{7}|(?:[3-8]\\d|90)\\d{5}",[7,8,10],[["(\\d{3})(\\d{4})","$1 $2",["[369]|4[3-8]|5(?:[0-2]|5[0-478]|6[45])|7[1-9]|88","[369]|4[3-8]|5(?:[02]|1(?:[0-8]|95)|5[0-478]|6(?:4[0-4]|5[1-589]))|7[1-9]|88"]],["(\\d{4})(\\d{3,4})","$1 $2",["[45]|8(?:00|[1-49])","[45]|8(?:00[1-9]|[1-49])"]],["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["7"]],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["8"]]]],EG:["20","00","[189]\\d{8,9}|[24-6]\\d{8}|[135]\\d{7}",[8,9,10],[["(\\d)(\\d{7,8})","$1 $2",["[23]"],"0$1"],["(\\d{2})(\\d{6,7})","$1 $2",["1[35]|[4-6]|8[2468]|9[235-7]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[89]"],"0$1"],["(\\d{2})(\\d{8})","$1 $2",["1"],"0$1"]],"0"],EH:["212","00","[5-8]\\d{8}",[9],0,"0",0,0,0,0,"528[89]"],ER:["291","00","[178]\\d{6}",[7],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[178]"],"0$1"]],"0"],ES:["34","00","[5-9]\\d{8}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[89]00"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-9]"]]]],ET:["251","00","(?:11|[2-579]\\d)\\d{7}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[1-579]"],"0$1"]],"0"],FI:["358","00|99(?:[01469]|5(?:[14]1|3[23]|5[59]|77|88|9[09]))","[1-35689]\\d{4}|7\\d{10,11}|(?:[124-7]\\d|3[0-46-9])\\d{8}|[1-9]\\d{5,8}",[5,6,7,8,9,10,11,12],[["(\\d{5})","$1",["20[2-59]"],"0$1"],["(\\d{3})(\\d{3,7})","$1 $2",["(?:[1-3]0|[68])0|70[07-9]"],"0$1"],["(\\d{2})(\\d{4,8})","$1 $2",["[14]|2[09]|50|7[135]"],"0$1"],["(\\d{2})(\\d{6,10})","$1 $2",["7"],"0$1"],["(\\d)(\\d{4,9})","$1 $2",["(?:19|[2568])[1-8]|3(?:0[1-9]|[1-9])|9"],"0$1"]],"0",0,0,0,0,"1[03-79]|[2-9]",0,"00"],FJ:["679","0(?:0|52)","45\\d{5}|(?:0800\\d|[235-9])\\d{6}",[7,11],[["(\\d{3})(\\d{4})","$1 $2",["[235-9]|45"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["0"]]],0,0,0,0,0,0,0,"00"],FK:["500","00","[2-7]\\d{4}",[5]],FM:["691","00","(?:[39]\\d\\d|820)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[389]"]]]],FO:["298","00","[2-9]\\d{5}",[6],[["(\\d{6})","$1",["[2-9]"]]],0,0,"(10(?:01|[12]0|88))"],FR:["33","00","[1-9]\\d{8}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0 $1"],["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["[1-79]"],"0$1"]],"0"],GA:["241","00","(?:[067]\\d|11)\\d{6}|[2-7]\\d{6}",[7,8],[["(\\d)(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-7]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["0"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["11|[67]"],"0$1"]],0,0,"0(11\\d{6}|60\\d{6}|61\\d{6}|6[256]\\d{6}|7[467]\\d{6})","$1"],GB:["44","00","[1-357-9]\\d{9}|[18]\\d{8}|8\\d{6}",[7,9,10],[["(\\d{3})(\\d{4})","$1 $2",["800","8001","80011","800111","8001111"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["845","8454","84546","845464"],"0$1"],["(\\d{3})(\\d{6})","$1 $2",["800"],"0$1"],["(\\d{5})(\\d{4,5})","$1 $2",["1(?:38|5[23]|69|76|94)","1(?:(?:38|69)7|5(?:24|39)|768|946)","1(?:3873|5(?:242|39[4-6])|(?:697|768)[347]|9467)"],"0$1"],["(\\d{4})(\\d{5,6})","$1 $2",["1(?:[2-69][02-9]|[78])"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["[25]|7(?:0|6[02-9])","[25]|7(?:0|6(?:[03-9]|2[356]))"],"0$1"],["(\\d{4})(\\d{6})","$1 $2",["7"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[1389]"],"0$1"]],"0",0,0,0,0,0,[["(?:1(?:1(?:3(?:[0-58]\\d\\d|73[0-35])|4(?:(?:[0-5]\\d|70)\\d|69[7-9])|(?:(?:5[0-26-9]|[78][0-49])\\d|6(?:[0-4]\\d|50))\\d)|(?:2(?:(?:0[024-9]|2[3-9]|3[3-79]|4[1-689]|[58][02-9]|6[0-47-9]|7[013-9]|9\\d)\\d|1(?:[0-7]\\d|8[0-3]))|(?:3(?:0\\d|1[0-8]|[25][02-9]|3[02-579]|[468][0-46-9]|7[1-35-79]|9[2-578])|4(?:0[03-9]|[137]\\d|[28][02-57-9]|4[02-69]|5[0-8]|[69][0-79])|5(?:0[1-35-9]|[16]\\d|2[024-9]|3[015689]|4[02-9]|5[03-9]|7[0-35-9]|8[0-468]|9[0-57-9])|6(?:0[034689]|1\\d|2[0-35689]|[38][013-9]|4[1-467]|5[0-69]|6[13-9]|7[0-8]|9[0-24578])|7(?:0[0246-9]|2\\d|3[0236-8]|4[03-9]|5[0-46-9]|6[013-9]|7[0-35-9]|8[024-9]|9[02-9])|8(?:0[35-9]|2[1-57-9]|3[02-578]|4[0-578]|5[124-9]|6[2-69]|7\\d|8[02-9]|9[02569])|9(?:0[02-589]|[18]\\d|2[02-689]|3[1-57-9]|4[2-9]|5[0-579]|6[2-47-9]|7[0-24578]|9[2-57]))\\d)\\d)|2(?:0[013478]|3[0189]|4[017]|8[0-46-9]|9[0-2])\\d{3})\\d{4}|1(?:2(?:0(?:46[1-4]|87[2-9])|545[1-79]|76(?:2\\d|3[1-8]|6[1-6])|9(?:7(?:2[0-4]|3[2-5])|8(?:2[2-8]|7[0-47-9]|8[3-5])))|3(?:6(?:38[2-5]|47[23])|8(?:47[04-9]|64[0157-9]))|4(?:044[1-7]|20(?:2[23]|8\\d)|6(?:0(?:30|5[2-57]|6[1-8]|7[2-8])|140)|8(?:052|87[1-3]))|5(?:2(?:4(?:3[2-79]|6\\d)|76\\d)|6(?:26[06-9]|686))|6(?:06(?:4\\d|7[4-79])|295[5-7]|35[34]\\d|47(?:24|61)|59(?:5[08]|6[67]|74)|9(?:55[0-4]|77[23]))|7(?:26(?:6[13-9]|7[0-7])|(?:442|688)\\d|50(?:2[0-3]|[3-68]2|76))|8(?:27[56]\\d|37(?:5[2-5]|8[239])|843[2-58])|9(?:0(?:0(?:6[1-8]|85)|52\\d)|3583|4(?:66[1-8]|9(?:2[01]|81))|63(?:23|3[1-4])|9561))\\d{3}",[9,10]],["7(?:457[0-57-9]|700[01]|911[028])\\d{5}|7(?:[1-3]\\d\\d|4(?:[0-46-9]\\d|5[0-689])|5(?:0[0-8]|[13-9]\\d|2[0-35-9])|7(?:0[1-9]|[1-7]\\d|8[02-9]|9[0-689])|8(?:[014-9]\\d|[23][0-8])|9(?:[024-9]\\d|1[02-9]|3[0-689]))\\d{6}",[10]],["80[08]\\d{7}|800\\d{6}|8001111"],["(?:8(?:4[2-5]|7[0-3])|9(?:[01]\\d|8[2-49]))\\d{7}|845464\\d",[7,10]],["70\\d{8}",[10]],0,["(?:3[0347]|55)\\d{8}",[10]],["76(?:464|652)\\d{5}|76(?:0[0-28]|2[356]|34|4[01347]|5[49]|6[0-369]|77|8[14]|9[139])\\d{6}",[10]],["56\\d{8}",[10]]],0," x"],GD:["1","011","(?:473|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","473$1",0,"473"],GE:["995","00","(?:[3-57]\\d\\d|800)\\d{6}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["70"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["32"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[57]"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[348]"],"0$1"]],"0"],GF:["594","00","(?:[56]94\\d|7093)\\d{5}|(?:80|9\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-7]|9[47]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[89]"],"0$1"]],"0"],GG:["44","00","(?:1481|[357-9]\\d{3})\\d{6}|8\\d{6}(?:\\d{2})?",[7,9,10],0,"0",0,"([25-9]\\d{5})$|0","1481$1",0,0,[["1481[25-9]\\d{5}",[10]],["7(?:(?:781|839)\\d|911[17])\\d{5}",[10]],["80[08]\\d{7}|800\\d{6}|8001111"],["(?:8(?:4[2-5]|7[0-3])|9(?:[01]\\d|8[0-3]))\\d{7}|845464\\d",[7,10]],["70\\d{8}",[10]],0,["(?:3[0347]|55)\\d{8}",[10]],["76(?:464|652)\\d{5}|76(?:0[0-28]|2[356]|34|4[01347]|5[49]|6[0-369]|77|8[14]|9[139])\\d{6}",[10]],["56\\d{8}",[10]]]],GH:["233","00","(?:[235]\\d{3}|800)\\d{5}",[8,9],[["(\\d{3})(\\d{5})","$1 $2",["8"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[235]"],"0$1"]],"0"],GI:["350","00","(?:[25]\\d|60)\\d{6}",[8],[["(\\d{3})(\\d{5})","$1 $2",["2"]]]],GL:["299","00","(?:19|[2-689]\\d|70)\\d{4}",[6],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["19|[2-9]"]]]],GM:["220","00","[2-9]\\d{6}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-9]"]]]],GN:["224","00","722\\d{6}|(?:3|6\\d)\\d{7}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["3"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[67]"]]]],GP:["590","00","(?:590\\d|7090)\\d{5}|(?:69|80|9\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-79]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0$1"]],"0",0,0,0,0,0,[["590(?:0[1-68]|[14][0-24-9]|2[0-68]|3[1-9]|5[3-579]|[68][0-689]|7[08]|9\\d)\\d{4}"],["(?:69(?:0\\d\\d|1(?:2[2-9]|3[0-5])|4(?:0[89]|1[2-6]|9\\d)|6(?:1[016-9]|5[0-4]|[67]\\d))|7090[0-4])\\d{4}"],["80[0-5]\\d{6}"],0,0,0,0,0,["9(?:(?:39[5-7]|76[018])\\d|475[0-6])\\d{4}"]]],GQ:["240","00","222\\d{6}|(?:3\\d|55|[89]0)\\d{7}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[235]"]],["(\\d{3})(\\d{6})","$1 $2",["[89]"]]]],GR:["30","00","5005000\\d{3}|8\\d{9,11}|(?:[269]\\d|70)\\d{8}",[10,11,12],[["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["21|7"]],["(\\d{4})(\\d{6})","$1 $2",["2(?:2|3[2-57-9]|4[2-469]|5[2-59]|6[2-9]|7[2-69]|8[2-49])|5"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[2689]"]],["(\\d{3})(\\d{3,4})(\\d{5})","$1 $2 $3",["8"]]]],GT:["502","00","80\\d{6}|(?:1\\d{3}|[2-7])\\d{7}",[8,11],[["(\\d{4})(\\d{4})","$1 $2",["[2-8]"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]]]],GU:["1","011","(?:[58]\\d\\d|671|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","671$1",0,"671"],GW:["245","00","[49]\\d{8}|4\\d{6}",[7,9],[["(\\d{3})(\\d{4})","$1 $2",["40"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[49]"]]]],GY:["592","001","(?:[2-8]\\d{3}|9008)\\d{3}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-9]"]]]],HK:["852","00(?:30|5[09]|[126-9]?)","8[0-46-9]\\d{6,7}|9\\d{4,7}|(?:[2-7]|9\\d{3})\\d{7}",[5,6,7,8,9,11],[["(\\d{3})(\\d{2,5})","$1 $2",["900","9003"]],["(\\d{4})(\\d{4})","$1 $2",["[2-7]|8[1-4]|9(?:0[1-9]|[1-8])"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"]],["(\\d{3})(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3 $4",["9"]]],0,0,0,0,0,0,0,"00"],HN:["504","00","8\\d{10}|[237-9]\\d{7}",[8,11],[["(\\d{4})(\\d{4})","$1-$2",["[237-9]"]]]],HR:["385","00","[2-69]\\d{8}|80\\d{5,7}|[1-79]\\d{7}|6\\d{6}",[7,8,9],[["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["6[01]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2,3})","$1 $2 $3",["8"],"0$1"],["(\\d)(\\d{4})(\\d{3})","$1 $2 $3",["1"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["6|7[245]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["9"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-57]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"],"0$1"]],"0"],HT:["509","00","(?:[2-489]\\d|55)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["[2-589]"]]]],HU:["36","00","[235-7]\\d{8}|[1-9]\\d{7}",[8,9],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["1"],"(06 $1)"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[27][2-9]|3[2-7]|4[24-9]|5[2-79]|6|8[2-57-9]|9[2-69]"],"(06 $1)"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-9]"],"06 $1"]],"06"],ID:["62","00[89]","00[1-9]\\d{9,14}|(?:[1-36]|8\\d{5})\\d{6}|00\\d{9}|[1-9]\\d{8,10}|[2-9]\\d{7}",[7,8,9,10,11,12,13,14,15,16,17],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["15"]],["(\\d{2})(\\d{5,9})","$1 $2",["2[124]|[36]1"],"(0$1)"],["(\\d{3})(\\d{5,7})","$1 $2",["800"],"0$1"],["(\\d{3})(\\d{5,8})","$1 $2",["[2-79]"],"(0$1)"],["(\\d{3})(\\d{3,4})(\\d{3})","$1-$2-$3",["8[1-35-9]"],"0$1"],["(\\d{3})(\\d{6,8})","$1 $2",["1"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["804"],"0$1"],["(\\d{3})(\\d)(\\d{3})(\\d{3})","$1 $2 $3 $4",["80"],"0$1"],["(\\d{3})(\\d{4})(\\d{4,5})","$1-$2-$3",["8"],"0$1"]],"0"],IE:["353","00","(?:1\\d|[2569])\\d{6,8}|4\\d{6,9}|7\\d{8}|8\\d{8,9}",[7,8,9,10],[["(\\d{2})(\\d{5})","$1 $2",["2[24-9]|47|58|6[237-9]|9[35-9]"],"(0$1)"],["(\\d{3})(\\d{5})","$1 $2",["[45]0"],"(0$1)"],["(\\d)(\\d{3,4})(\\d{4})","$1 $2 $3",["1"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2569]|4[1-69]|7[14]"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["70"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["81"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[78]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["4"],"(0$1)"],["(\\d{2})(\\d)(\\d{3})(\\d{4})","$1 $2 $3 $4",["8"],"0$1"]],"0"],IL:["972","0(?:0|1[2-9])","1\\d{6}(?:\\d{3,5})?|[57]\\d{8}|[1-489]\\d{7}",[7,8,9,10,11,12],[["(\\d{4})(\\d{3})","$1-$2",["125"]],["(\\d{4})(\\d{2})(\\d{2})","$1-$2-$3",["121"]],["(\\d)(\\d{3})(\\d{4})","$1-$2-$3",["[2-489]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["[57]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1-$2-$3",["12"]],["(\\d{4})(\\d{6})","$1-$2",["159"]],["(\\d)(\\d{3})(\\d{3})(\\d{3})","$1-$2-$3-$4",["1[7-9]"]],["(\\d{3})(\\d{1,2})(\\d{3})(\\d{4})","$1-$2 $3-$4",["15"]]],"0"],IM:["44","00","1624\\d{6}|(?:[3578]\\d|90)\\d{8}",[10],0,"0",0,"([25-8]\\d{5})$|0","1624$1",0,"74576|(?:16|7[56])24"],IN:["91","00","(?:000800|[2-9]\\d\\d)\\d{7}|1\\d{7,12}",[8,9,10,11,12,13],[["(\\d{8})","$1",["5(?:0|2[23]|3[03]|[67]1|88)","5(?:0|2(?:21|3)|3(?:0|3[23])|616|717|888)","5(?:0|2(?:21|3)|3(?:0|3[23])|616|717|8888)"],0,1],["(\\d{4})(\\d{4,5})","$1 $2",["180","1800"],0,1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["140"],0,1],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["11|2[02]|33|4[04]|79[1-7]|80[2-46]","11|2[02]|33|4[04]|79(?:[1-6]|7[19])|80(?:[2-4]|6[0-589])","11|2[02]|33|4[04]|79(?:[124-6]|3(?:[02-9]|1[0-24-9])|7(?:1|9[1-6]))|80(?:[2-4]|6[0-589])"],"0$1",1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["1(?:2[0-249]|3[0-25]|4[145]|[68]|7[1257])|2(?:1[257]|3[013]|4[01]|5[0137]|6[0158]|78|8[1568])|3(?:26|4[1-3]|5[34]|6[01489]|7[02-46]|8[159])|4(?:1[36]|2[1-47]|5[12]|6[0-26-9]|7[0-24-9]|8[013-57]|9[014-7])|5(?:1[025]|22|[36][25]|4[28]|5[12]|[78]1)|6(?:12|[2-4]1|5[17]|6[13]|80)|7(?:12|3[134]|4[47]|61|88)|8(?:16|2[014]|3[126]|6[136]|7[078]|8[34]|91)|(?:43|59|75)[15]|(?:1[59]|29|67|72)[14]","1(?:2[0-24]|3[0-25]|4[145]|[59][14]|6[1-9]|7[1257]|8[1-57-9])|2(?:1[257]|3[013]|4[01]|5[0137]|6[058]|78|8[1568]|9[14])|3(?:26|4[1-3]|5[34]|6[01489]|7[02-46]|8[159])|4(?:1[36]|2[1-47]|3[15]|5[12]|6[0-26-9]|7[0-24-9]|8[013-57]|9[014-7])|5(?:1[025]|22|[36][25]|4[28]|[578]1|9[15])|674|7(?:(?:2[14]|3[34]|5[15])[2-6]|61[346]|88[0-8])|8(?:70[2-6]|84[235-7]|91[3-7])|(?:1(?:29|60|8[06])|261|552|6(?:12|[2-47]1|5[17]|6[13]|80)|7(?:12|31|4[47])|8(?:16|2[014]|3[126]|6[136]|7[78]|83))[2-7]","1(?:2[0-24]|3[0-25]|4[145]|[59][14]|6[1-9]|7[1257]|8[1-57-9])|2(?:1[257]|3[013]|4[01]|5[0137]|6[058]|78|8[1568]|9[14])|3(?:26|4[1-3]|5[34]|6[01489]|7[02-46]|8[159])|4(?:1[36]|2[1-47]|3[15]|5[12]|6[0-26-9]|7[0-24-9]|8[013-57]|9[014-7])|5(?:1[025]|22|[36][25]|4[28]|[578]1|9[15])|6(?:12(?:[2-6]|7[0-8])|74[2-7])|7(?:(?:2[14]|5[15])[2-6]|3171|61[346]|88(?:[2-7]|82))|8(?:70[2-6]|84(?:[2356]|7[19])|91(?:[3-6]|7[19]))|73[134][2-6]|(?:74[47]|8(?:16|2[014]|3[126]|6[136]|7[78]|83))(?:[2-6]|7[19])|(?:1(?:29|60|8[06])|261|552|6(?:[2-4]1|5[17]|6[13]|7(?:1|4[0189])|80)|7(?:12|88[01]))[2-7]"],"0$1",1],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1(?:[2-479]|5[0235-9])|[2-5]|6(?:1[1358]|2[2457-9]|3[2-5]|4[235-7]|5[2-689]|6[24578]|7[235689]|8[1-6])|7(?:1[013-9]|28|3[129]|4[1-35689]|5[29]|6[02-5]|70)|807","1(?:[2-479]|5[0235-9])|[2-5]|6(?:1[1358]|2(?:[2457]|84|95)|3(?:[2-4]|55)|4[235-7]|5[2-689]|6[24578]|7[235689]|8[1-6])|7(?:1(?:[013-8]|9[6-9])|28[6-8]|3(?:17|2[0-49]|9[2-57])|4(?:1[2-4]|[29][0-7]|3[0-8]|[56]|8[0-24-7])|5(?:2[1-3]|9[0-6])|6(?:0[5689]|2[5-9]|3[02-8]|4|5[0-367])|70[13-7])|807[19]","1(?:[2-479]|5(?:[0236-9]|5[013-9]))|[2-5]|6(?:2(?:84|95)|355|83)|73179|807(?:1|9[1-3])|(?:1552|6(?:1[1358]|2[2457]|3[2-4]|4[235-7]|5[2-689]|6[24578]|7[235689]|8[124-6])\\d|7(?:1(?:[013-8]\\d|9[6-9])|28[6-8]|3(?:2[0-49]|9[2-57])|4(?:1[2-4]|[29][0-7]|3[0-8]|[56]\\d|8[0-24-7])|5(?:2[1-3]|9[0-6])|6(?:0[5689]|2[5-9]|3[02-8]|4\\d|5[0-367])|70[13-7]))[2-7]"],"0$1",1],["(\\d{5})(\\d{5})","$1 $2",["[6-9]"],"0$1",1],["(\\d{4})(\\d{2,4})(\\d{4})","$1 $2 $3",["1(?:6|8[06])","1(?:6|8[06]0)"],0,1],["(\\d{4})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["18"],0,1]],"0"],IO:["246","00","3\\d{6}",[7],[["(\\d{3})(\\d{4})","$1 $2",["3"]]]],IQ:["964","00","(?:1|7\\d\\d)\\d{7}|[2-6]\\d{7,8}",[8,9,10],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-6]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"0$1"]],"0"],IR:["98","00","[1-9]\\d{9}|(?:[1-8]\\d\\d|9)\\d{3,4}",[4,5,6,7,10],[["(\\d{4,5})","$1",["96"],"0$1"],["(\\d{2})(\\d{4,5})","$1 $2",["(?:1[137]|2[13-68]|3[1458]|4[145]|5[1468]|6[16]|7[1467]|8[13467])[12689]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["9"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["[1-8]"],"0$1"]],"0"],IS:["354","00|1(?:0(?:01|[12]0)|100)","(?:38\\d|[4-9])\\d{6}",[7,9],[["(\\d{3})(\\d{4})","$1 $2",["[4-9]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["3"]]],0,0,0,0,0,0,0,"00"],IT:["39","00","0\\d{5,10}|1\\d{8,10}|3(?:[0-8]\\d{7,10}|9\\d{7,8})|(?:43|55|70)\\d{8}|8\\d{5}(?:\\d{2,4})?",[6,7,8,9,10,11,12],[["(\\d{2})(\\d{4,6})","$1 $2",["0[26]"]],["(\\d{3})(\\d{3,6})","$1 $2",["0[13-57-9][0159]|8(?:03|4[17]|9[2-5])","0[13-57-9][0159]|8(?:03|4[17]|9(?:2|3[04]|[45][0-4]))"]],["(\\d{4})(\\d{2,6})","$1 $2",["0(?:[13-579][2-46-8]|8[236-8])"]],["(\\d{4})(\\d{4})","$1 $2",["894"]],["(\\d{2})(\\d{3,4})(\\d{4})","$1 $2 $3",["0[26]|5"]],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["1(?:44|[679])|[378]|43"]],["(\\d{3})(\\d{3,4})(\\d{4})","$1 $2 $3",["0[13-57-9][0159]|14"]],["(\\d{2})(\\d{4})(\\d{5})","$1 $2 $3",["0[26]"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["0"]],["(\\d{3})(\\d{4})(\\d{4,5})","$1 $2 $3",["3"]]],0,0,0,0,0,0,[["0669[0-79]\\d{1,6}|0(?:1(?:[0159]\\d|[27][1-5]|31|4[1-4]|6[1356]|8[2-57])|2\\d\\d|3(?:[0159]\\d|2[1-4]|3[12]|[48][1-6]|6[2-59]|7[1-7])|4(?:[0159]\\d|[23][1-9]|4[245]|6[1-5]|7[1-4]|81)|5(?:[0159]\\d|2[1-5]|3[2-6]|4[1-79]|6[4-6]|7[1-578]|8[3-8])|6(?:[0-57-9]\\d|6[0-8])|7(?:[0159]\\d|2[12]|3[1-7]|4[2-46]|6[13569]|7[13-6]|8[1-59])|8(?:[0159]\\d|2[3-578]|3[1-356]|[6-8][1-5])|9(?:[0159]\\d|[238][1-5]|4[12]|6[1-8]|7[1-6]))\\d{2,7}",[6,7,8,9,10,11]],["3[2-9]\\d{7,8}|(?:31|43)\\d{8}",[9,10]],["80(?:0\\d{3}|3)\\d{3}",[6,9]],["(?:0878\\d{3}|89(?:2\\d|3[04]|4(?:[0-4]|[5-9]\\d\\d)|5[0-4]))\\d\\d|(?:1(?:44|6[346])|89(?:38|5[5-9]|9))\\d{6}",[6,8,9,10]],["1(?:78\\d|99)\\d{6}",[9,10]],["3[2-8]\\d{9,10}",[11,12]],0,0,["55\\d{8}",[10]],["84(?:[08]\\d{3}|[17])\\d{3}",[6,9]]]],JE:["44","00","1534\\d{6}|(?:[3578]\\d|90)\\d{8}",[10],0,"0",0,"([0-24-8]\\d{5})$|0","1534$1",0,0,[["1534[0-24-8]\\d{5}"],["7(?:(?:(?:50|82)9|937)\\d|7(?:00[378]|97\\d))\\d{5}"],["80(?:07(?:35|81)|8901)\\d{4}"],["(?:8(?:4(?:4(?:4(?:05|42|69)|703)|5(?:041|800))|7(?:0002|1206))|90(?:066[59]|1810|71(?:07|55)))\\d{4}"],["701511\\d{4}"],0,["(?:3(?:0(?:07(?:35|81)|8901)|3\\d{4}|4(?:4(?:4(?:05|42|69)|703)|5(?:041|800))|7(?:0002|1206))|55\\d{4})\\d{4}"],["76(?:464|652)\\d{5}|76(?:0[0-28]|2[356]|34|4[01347]|5[49]|6[0-369]|77|8[14]|9[139])\\d{6}"],["56\\d{8}"]]],JM:["1","011","(?:[58]\\d\\d|658|900)\\d{7}",[10],0,"1",0,0,0,0,"658|876"],JO:["962","00","(?:(?:[2689]|7\\d)\\d|32|53)\\d{6}",[8,9],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[2356]|87"],"(0$1)"],["(\\d{3})(\\d{5,6})","$1 $2",["[89]"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["70"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["7"],"0$1"]],"0"],JP:["81","010","00[1-9]\\d{6,14}|[257-9]\\d{9}|(?:00|[1-9]\\d\\d)\\d{6}",[8,9,10,11,12,13,14,15,16,17],[["(\\d{3})(\\d{3})(\\d{3})","$1-$2-$3",["(?:12|57|99)0"],"0$1"],["(\\d{4})(\\d)(\\d{4})","$1-$2-$3",["1(?:26|3[79]|4[56]|5[4-68]|6[3-5])|499|5(?:76|97)|746|8(?:3[89]|47|51)|9(?:80|9[16])","1(?:267|3(?:7[247]|9[278])|466|5(?:47|58|64)|6(?:3[245]|48|5[4-68]))|499[2468]|5(?:76|97)9|7468|8(?:3(?:8[7-9]|96)|477|51[2-9])|9(?:802|9(?:1[23]|69))|1(?:45|58)[67]","1(?:267|3(?:7[247]|9[278])|466|5(?:47|58|64)|6(?:3[245]|48|5[4-68]))|499[2468]|5(?:769|979[2-69])|7468|8(?:3(?:8[7-9]|96[2457-9])|477|51[2-9])|9(?:802|9(?:1[23]|69))|1(?:45|58)[67]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["60"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1-$2-$3",["[36]|4(?:2[09]|7[01])","[36]|4(?:2(?:0|9[02-69])|7(?:0[019]|1))"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["1(?:1|5[45]|77|88|9[69])|2(?:2[1-37]|3[0-269]|4[59]|5|6[24]|7[1-358]|8[1369]|9[0-38])|4(?:[28][1-9]|3[0-57]|[45]|6[248]|7[2-579]|9[29])|5(?:2|3[0459]|4[0-369]|5[29]|8[02389]|9[0-389])|7(?:2[02-46-9]|34|[58]|6[0249]|7[57]|9[2-6])|8(?:2[124589]|3[26-9]|49|51|6|7[0-468]|8[68]|9[019])|9(?:[23][1-9]|4[15]|5[138]|6[1-3]|7[156]|8[189]|9[1-489])","1(?:1|5(?:4[018]|5[017])|77|88|9[69])|2(?:2(?:[127]|3[014-9])|3[0-269]|4[59]|5(?:[1-3]|5[0-69]|9[19])|62|7(?:[1-35]|8[0189])|8(?:[16]|3[0134]|9[0-5])|9(?:[028]|17))|4(?:2(?:[13-79]|8[014-6])|3[0-57]|[45]|6[248]|7[2-47]|8[1-9]|9[29])|5(?:2|3(?:[045]|9[0-8])|4[0-369]|5[29]|8[02389]|9[0-3])|7(?:2[02-46-9]|34|[58]|6[0249]|7[57]|9(?:[23]|4[0-59]|5[01569]|6[0167]))|8(?:2(?:[1258]|4[0-39]|9[0-2469])|3(?:[29]|60)|49|51|6(?:[0-24]|36|5[0-3589]|7[23]|9[01459])|7[0-468]|8[68])|9(?:[23][1-9]|4[15]|5[138]|6[1-3]|7[156]|8[189]|9(?:[1289]|3[34]|4[0178]))|(?:264|837)[016-9]|2(?:57|93)[015-9]|(?:25[0468]|422|838)[01]|(?:47[59]|59[89]|8(?:6[68]|9))[019]","1(?:1|5(?:4[018]|5[017])|77|88|9[69])|2(?:2[127]|3[0-269]|4[59]|5(?:[1-3]|5[0-69]|9(?:17|99))|6(?:2|4[016-9])|7(?:[1-35]|8[0189])|8(?:[16]|3[0134]|9[0-5])|9(?:[028]|17))|4(?:2(?:[13-79]|8[014-6])|3[0-57]|[45]|6[248]|7[2-47]|9[29])|5(?:2|3(?:[045]|9(?:[0-58]|6[4-9]|7[0-35689]))|4[0-369]|5[29]|8[02389]|9[0-3])|7(?:2[02-46-9]|34|[58]|6[0249]|7[57]|9(?:[23]|4[0-59]|5[01569]|6[0167]))|8(?:2(?:[1258]|4[0-39]|9[0169])|3(?:[29]|60|7(?:[017-9]|6[6-8]))|49|51|6(?:[0-24]|36[2-57-9]|5(?:[0-389]|5[23])|6(?:[01]|9[178])|7(?:2[2-468]|3[78])|9[0145])|7[0-468]|8[68])|9(?:4[15]|5[138]|7[156]|8[189]|9(?:[1289]|3(?:31|4[357])|4[0178]))|(?:8294|96)[1-3]|2(?:57|93)[015-9]|(?:223|8699)[014-9]|(?:25[0468]|422|838)[01]|(?:48|8292|9[23])[1-9]|(?:47[59]|59[89]|8(?:68|9))[019]"],"0$1"],["(\\d{3})(\\d{2})(\\d{4})","$1-$2-$3",["[14]|[289][2-9]|5[3-9]|7[2-4679]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["800"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1-$2-$3",["[257-9]"],"0$1"]],"0",0,"(000[259]\\d{6})$|(?:(?:003768)0?)|0","$1"],KE:["254","000","(?:[17]\\d\\d|900)\\d{6}|(?:2|80)0\\d{6,7}|[4-6]\\d{6,8}",[7,8,9,10],[["(\\d{2})(\\d{5,7})","$1 $2",["[24-6]"],"0$1"],["(\\d{3})(\\d{6})","$1 $2",["[17]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[89]"],"0$1"]],"0"],KG:["996","00","8\\d{9}|[235-9]\\d{8}",[9,10],[["(\\d{4})(\\d{5})","$1 $2",["3(?:1[346]|[24-79])"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[235-79]|88"],"0$1"],["(\\d{3})(\\d{3})(\\d)(\\d{2,3})","$1 $2 $3 $4",["8"],"0$1"]],"0"],KH:["855","00[14-9]","1\\d{9}|[1-9]\\d{7,8}",[8,9,10],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[1-9]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]]],"0"],KI:["686","00","(?:[37]\\d|6[0-79])\\d{6}|(?:[2-48]\\d|50)\\d{3}",[5,8],0,"0"],KM:["269","00","[3478]\\d{6}",[7],[["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["[3478]"]]]],KN:["1","011","(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-7]\\d{6})$|1","869$1",0,"869"],KP:["850","00|99","85\\d{6}|(?:19\\d|[2-7])\\d{7}",[8,10],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["8"],"0$1"],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[2-7]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"]],"0"],KR:["82","00(?:[125689]|3(?:[46]5|91)|7(?:00|27|3|55|6[126]))","00[1-9]\\d{8,11}|(?:[12]|5\\d{3})\\d{7}|[13-6]\\d{9}|(?:[1-6]\\d|80)\\d{7}|[3-6]\\d{4,5}|(?:00|7)0\\d{8}",[5,6,8,9,10,11,12,13,14],[["(\\d{2})(\\d{3,4})","$1-$2",["(?:3[1-3]|[46][1-4]|5[1-5])1"],"0$1"],["(\\d{4})(\\d{4})","$1-$2",["1"]],["(\\d)(\\d{3,4})(\\d{4})","$1-$2-$3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["[36]0|8"],"0$1"],["(\\d{2})(\\d{3,4})(\\d{4})","$1-$2-$3",["[1346]|5[1-5]"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1-$2-$3",["[57]"],"0$1"],["(\\d{2})(\\d{5})(\\d{4})","$1-$2-$3",["5"],"0$1"]],"0",0,"0(8(?:[1-46-8]|5\\d\\d))?"],KW:["965","00","18\\d{5}|(?:[2569]\\d|41)\\d{6}",[7,8],[["(\\d{4})(\\d{3,4})","$1 $2",["[169]|2(?:[235]|4[1-35-9])|52"]],["(\\d{3})(\\d{5})","$1 $2",["[245]"]]]],KY:["1","011","(?:345|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","345$1",0,"345"],KZ:["7","810","(?:33622|8\\d{8})\\d{5}|[78]\\d{9}",[10,14],0,"8",0,0,0,0,"33|7",0,"8~10"],LA:["856","00","[23]\\d{9}|3\\d{8}|(?:[235-8]\\d|41)\\d{6}",[8,9,10],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["2[13]|3[14]|[4-8]"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3 $4",["3"],"0$1"],["(\\d{2})(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3 $4",["[23]"],"0$1"]],"0"],LB:["961","00","[27-9]\\d{7}|[13-9]\\d{6}",[7,8],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[13-69]|7(?:[2-57]|62|8[0-7]|9[04-9])|8[02-9]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[27-9]"]]],"0"],LC:["1","011","(?:[58]\\d\\d|758|900)\\d{7}",[10],0,"1",0,"([2-8]\\d{6})$|1","758$1",0,"758"],LI:["423","00","[68]\\d{8}|(?:[2378]\\d|90)\\d{5}",[7,9],[["(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["[2379]|8(?:0[09]|7)","[2379]|8(?:0(?:02|9)|7)"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["69"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6"]]],"0",0,"(1001)|0"],LK:["94","00","[1-9]\\d{8}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[1-689]"],"0$1"]],"0"],LR:["231","00","(?:[245]\\d|33|77|88)\\d{7}|(?:2\\d|[4-6])\\d{6}",[7,8,9],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["4[67]|[56]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[2-578]"],"0$1"]],"0"],LS:["266","00","(?:[256]\\d\\d|800)\\d{5}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[2568]"]]]],LT:["370","00","(?:[3469]\\d|52|[78]0)\\d{6}",[8],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["52[0-7]"],"(0-$1)",1],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["[7-9]"],"0 $1",1],["(\\d{2})(\\d{6})","$1 $2",["37|4(?:[15]|6[1-8])"],"(0-$1)",1],["(\\d{3})(\\d{5})","$1 $2",["[3-6]"],"(0-$1)",1]],"0",0,"[08]"],LU:["352","00","35[013-9]\\d{4,8}|6\\d{8}|35\\d{2,4}|(?:[2457-9]\\d|3[0-46-9])\\d{2,9}",[4,5,6,7,8,9,10,11],[["(\\d{2})(\\d{3})","$1 $2",["2(?:0[2-689]|[2-9])|[3-57]|8(?:0[2-9]|[13-9])|9(?:0[89]|[2-579])"]],["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["2(?:0[2-689]|[2-9])|[3-57]|8(?:0[2-9]|[13-9])|9(?:0[89]|[2-579])"]],["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["20[2-689]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{1,2})","$1 $2 $3 $4",["2(?:[0367]|4[3-8])"]],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["80[01]|90[015]"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3 $4",["20"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{1,2})","$1 $2 $3 $4 $5",["2(?:[0367]|4[3-8])"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{1,5})","$1 $2 $3 $4",["[3-57]|8[13-9]|9(?:0[89]|[2-579])|(?:2|80)[2-9]"]]],0,0,"(15(?:0[06]|1[12]|[35]5|4[04]|6[26]|77|88|99)\\d)"],LV:["371","00","(?:[268]\\d|90)\\d{6}",[8],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[269]|8[01]"]]]],LY:["218","00","[2-9]\\d{8}",[9],[["(\\d{2})(\\d{7})","$1-$2",["[2-9]"],"0$1"]],"0"],MA:["212","00","[5-8]\\d{8}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["5[45]"],"0$1"],["(\\d{4})(\\d{5})","$1-$2",["5(?:2[2-46-9]|3[3-9]|9)|8(?:0[89]|92)"],"0$1"],["(\\d{2})(\\d{7})","$1-$2",["8"],"0$1"],["(\\d{3})(\\d{6})","$1-$2",["[5-7]"],"0$1"]],"0",0,0,0,0,0,[["5(?:2(?:[0-25-79]\\d|3[1-578]|4[02-46-8]|8[0235-7])|3(?:[0-47]\\d|5[02-9]|6[02-8]|8[014-9]|9[3-9])|(?:4[067]|5[03])\\d)\\d{5}"],["(?:6(?:[0-79]\\d|8[0-247-9])|7(?:[0167]\\d|2[0-467]|5[0-3]|8[0-7]))\\d{6}"],["80[0-7]\\d{6}"],["89\\d{7}"],0,0,0,0,["(?:592(?:4[0-2]|93)|80[89]\\d\\d)\\d{4}"]]],MC:["377","00","(?:[3489]|6\\d)\\d{7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["4"],"0$1"],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[389]"]],["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["6"],"0$1"]],"0"],MD:["373","00","(?:[235-7]\\d|[89]0)\\d{6}",[8],[["(\\d{3})(\\d{5})","$1 $2",["[89]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["22|3"],"0$1"],["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["[25-7]"],"0$1"]],"0"],ME:["382","00","(?:20|[3-79]\\d)\\d{6}|80\\d{6,7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-9]"],"0$1"]],"0"],MF:["590","00","(?:590\\d|7090)\\d{5}|(?:69|80|9\\d)\\d{7}",[9],0,"0",0,0,0,0,0,[["590(?:0[079]|[14]3|[27][79]|3[03-7]|5[0-268]|87)\\d{4}"],["(?:69(?:0\\d\\d|1(?:2[2-9]|3[0-5])|4(?:0[89]|1[2-6]|9\\d)|6(?:1[016-9]|5[0-4]|[67]\\d))|7090[0-4])\\d{4}"],["80[0-5]\\d{6}"],0,0,0,0,0,["9(?:(?:39[5-7]|76[018])\\d|475[0-6])\\d{4}"]]],MG:["261","00","[23]\\d{8}",[9],[["(\\d{2})(\\d{2})(\\d{3})(\\d{2})","$1 $2 $3 $4",["[23]"],"0$1"]],"0",0,"([24-9]\\d{6})$|0","20$1"],MH:["692","011","329\\d{4}|(?:[256]\\d|45)\\d{5}",[7],[["(\\d{3})(\\d{4})","$1-$2",["[2-6]"]]],"1"],MK:["389","00","[2-578]\\d{7}",[8],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["2|34[47]|4(?:[37]7|5[47]|64)"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[347]"],"0$1"],["(\\d{3})(\\d)(\\d{2})(\\d{2})","$1 $2 $3 $4",["[58]"],"0$1"]],"0"],ML:["223","00","[24-9]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[24-9]"]]]],MM:["95","00","1\\d{5,7}|95\\d{6}|(?:[4-7]|9[0-46-9])\\d{6,8}|(?:2|8\\d)\\d{5,8}",[6,7,8,9,10],[["(\\d)(\\d{2})(\\d{3})","$1 $2 $3",["16|2"],"0$1"],["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["4(?:[2-46]|5[3-5])|5|6(?:[1-689]|7[235-7])|7(?:[0-4]|5[2-7])|8[1-5]|(?:60|86)[23]"],"0$1"],["(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["[12]|452|678|86","[12]|452|6788|86"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[4-7]|8[1-35]"],"0$1"],["(\\d)(\\d{3})(\\d{4,6})","$1 $2 $3",["9(?:2[0-4]|[35-9]|4[137-9])"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"],"0$1"],["(\\d)(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["92"],"0$1"],["(\\d)(\\d{5})(\\d{4})","$1 $2 $3",["9"],"0$1"]],"0"],MN:["976","001","[12]\\d{7,9}|[5-9]\\d{7}",[8,9,10],[["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["[12]1"],"0$1"],["(\\d{4})(\\d{4})","$1 $2",["[5-9]"]],["(\\d{3})(\\d{5,6})","$1 $2",["[12]2[1-3]"],"0$1"],["(\\d{4})(\\d{5,6})","$1 $2",["[12](?:27|3[2-8]|4[2-68]|5[1-4689])","[12](?:27|3[2-8]|4[2-68]|5[1-4689])[0-3]"],"0$1"],["(\\d{5})(\\d{4,5})","$1 $2",["[12]"],"0$1"]],"0"],MO:["853","00","0800\\d{3}|(?:28|[68]\\d)\\d{6}",[7,8],[["(\\d{4})(\\d{3})","$1 $2",["0"]],["(\\d{4})(\\d{4})","$1 $2",["[268]"]]]],MP:["1","011","[58]\\d{9}|(?:67|90)0\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","670$1",0,"670"],MQ:["596","00","(?:596\\d|7091)\\d{5}|(?:69|[89]\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-79]|8(?:0[6-9]|[36])"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0$1"]],"0"],MR:["222","00","(?:[2-4]\\d\\d|800)\\d{5}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-48]"]]]],MS:["1","011","(?:[58]\\d\\d|664|900)\\d{7}",[10],0,"1",0,"([34]\\d{6})$|1","664$1",0,"664"],MT:["356","00","3550\\d{4}|(?:[2579]\\d\\d|800)\\d{5}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[2357-9]"]]]],MU:["230","0(?:0|[24-7]0|3[03])","(?:[57]|8\\d\\d)\\d{7}|[2-468]\\d{6}",[7,8,10],[["(\\d{3})(\\d{4})","$1 $2",["[2-46]|8[013]"]],["(\\d{4})(\\d{4})","$1 $2",["[57]"]],["(\\d{5})(\\d{5})","$1 $2",["8"]]],0,0,0,0,0,0,0,"020"],MV:["960","0(?:0|19)","(?:800|9[0-57-9]\\d)\\d{7}|[34679]\\d{6}",[7,10],[["(\\d{3})(\\d{4})","$1-$2",["[34679]"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[89]"]]],0,0,0,0,0,0,0,"00"],MW:["265","00","(?:[1289]\\d|31|77)\\d{7}|1\\d{6}",[7,9],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["1[2-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["2"],"0$1"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[137-9]"],"0$1"]],"0"],MX:["52","0[09]","[2-9]\\d{9}",[10],[["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["33|5[56]|81"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[2-9]"]]],0,0,0,0,0,0,0,"00"],MY:["60","00","1\\d{8,9}|(?:3\\d|[4-9])\\d{7}",[8,9,10],[["(\\d)(\\d{3})(\\d{4})","$1-$2 $3",["[4-79]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1-$2 $3",["1(?:[02469]|[378][1-9]|53)|8","1(?:[02469]|[37][1-9]|53|8(?:[1-46-9]|5[7-9]))|8"],"0$1"],["(\\d)(\\d{4})(\\d{4})","$1-$2 $3",["3"],"0$1"],["(\\d)(\\d{3})(\\d{2})(\\d{4})","$1-$2-$3-$4",["1(?:[367]|80)"]],["(\\d{3})(\\d{3})(\\d{4})","$1-$2 $3",["15"],"0$1"],["(\\d{2})(\\d{4})(\\d{4})","$1-$2 $3",["1"],"0$1"]],"0"],MZ:["258","00","(?:2|8\\d)\\d{7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["2|8[2-79]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["8"]]]],NA:["264","00","[68]\\d{7,8}",[8,9],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["88"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["6"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["87"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["8"],"0$1"]],"0"],NC:["687","00","(?:050|[2-57-9]\\d\\d)\\d{3}",[6],[["(\\d{2})(\\d{2})(\\d{2})","$1.$2.$3",["[02-57-9]"]]]],NE:["227","00","[027-9]\\d{7}",[8],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["08"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[089]|2[013]|7[0467]"]]]],NF:["672","00","[13]\\d{5}",[6],[["(\\d{2})(\\d{4})","$1 $2",["1[0-3]"]],["(\\d)(\\d{5})","$1 $2",["[13]"]]],0,0,"([0-258]\\d{4})$","3$1"],NG:["234","009","(?:20|9\\d)\\d{8}|[78]\\d{9,13}",[10,11,12,13,14],[["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[7-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["20[129]"],"0$1"],["(\\d{4})(\\d{2})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{3})(\\d{4})(\\d{4,5})","$1 $2 $3",["[78]"],"0$1"],["(\\d{3})(\\d{5})(\\d{5,6})","$1 $2 $3",["[78]"],"0$1"]],"0"],NI:["505","00","(?:1800|[25-8]\\d{3})\\d{4}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[125-8]"]]]],NL:["31","00","(?:[124-7]\\d\\d|3(?:[02-9]\\d|1[0-8]))\\d{6}|8\\d{6,9}|9\\d{6,10}|1\\d{4,5}",[5,6,7,8,9,10,11],[["(\\d{3})(\\d{4,7})","$1 $2",["[89]0"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["66"],"0$1"],["(\\d)(\\d{8})","$1 $2",["6"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["1[16-8]|2[259]|3[124]|4[17-9]|5[124679]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[1-578]|91"],"0$1"],["(\\d{3})(\\d{3})(\\d{5})","$1 $2 $3",["9"],"0$1"]],"0"],NO:["47","00","(?:0|[2-9]\\d{3})\\d{4}",[5,8],[["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["8"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-79]"]]],0,0,0,0,0,"[02-689]|7[0-8]"],NP:["977","00","(?:1\\d|9)\\d{9}|[1-9]\\d{7}",[8,10,11],[["(\\d)(\\d{7})","$1-$2",["1[2-6]"],"0$1"],["(\\d{2})(\\d{6})","$1-$2",["1[01]|[2-8]|9(?:[1-59]|[67][2-6])"],"0$1"],["(\\d{3})(\\d{7})","$1-$2",["9"]]],"0"],NR:["674","00","(?:222|444|(?:55|8\\d)\\d|666|777|999)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[24-9]"]]]],NU:["683","00","(?:[4-7]|888\\d)\\d{3}",[4,7],[["(\\d{3})(\\d{4})","$1 $2",["8"]]]],NZ:["64","0(?:0|161)","[1289]\\d{9}|50\\d{5}(?:\\d{2,3})?|[27-9]\\d{7,8}|(?:[34]\\d|6[0-35-9])\\d{6}|8\\d{4,6}",[5,6,7,8,9,10],[["(\\d{2})(\\d{3,8})","$1 $2",["8[1-79]"],"0$1"],["(\\d{3})(\\d{2})(\\d{2,3})","$1 $2 $3",["50[036-8]|8|90","50(?:[0367]|88)|8|90"],"0$1"],["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["24|[346]|7[2-57-9]|9[2-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["2(?:10|74)|[589]"],"0$1"],["(\\d{2})(\\d{3,4})(\\d{4})","$1 $2 $3",["1|2[028]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,5})","$1 $2 $3",["2(?:[169]|7[0-35-9])|7"],"0$1"]],"0",0,0,0,0,0,0,"00"],OM:["968","00","(?:1505|[279]\\d{3}|500)\\d{4}|800\\d{5,6}",[7,8,9],[["(\\d{3})(\\d{4,6})","$1 $2",["[58]"]],["(\\d{2})(\\d{6})","$1 $2",["2"]],["(\\d{4})(\\d{4})","$1 $2",["[179]"]]]],PA:["507","00","(?:00800|8\\d{3})\\d{6}|[68]\\d{7}|[1-57-9]\\d{6}",[7,8,10,11],[["(\\d{3})(\\d{4})","$1-$2",["[1-57-9]"]],["(\\d{4})(\\d{4})","$1-$2",["[68]"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"]]]],PE:["51","00|19(?:1[124]|77|90)00","(?:[14-8]|9\\d)\\d{7}",[8,9],[["(\\d{3})(\\d{5})","$1 $2",["80"],"(0$1)"],["(\\d)(\\d{7})","$1 $2",["1"],"(0$1)"],["(\\d{2})(\\d{6})","$1 $2",["[4-8]"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["9"]]],"0",0,0,0,0,0,0,"00"," Anexo "],PF:["689","00","4\\d{5}(?:\\d{2})?|8\\d{7,8}",[6,8,9],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["44"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["4|8[7-9]"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"]]]],PG:["675","00|140[1-3]","(?:180|[78]\\d{3})\\d{4}|(?:[2-589]\\d|64)\\d{5}",[7,8],[["(\\d{3})(\\d{4})","$1 $2",["18|[2-69]|85"]],["(\\d{4})(\\d{4})","$1 $2",["[78]"]]],0,0,0,0,0,0,0,"00"],PH:["63","00","(?:[2-7]|9\\d)\\d{8}|2\\d{5}|(?:1800|8)\\d{7,9}",[6,8,9,10,11,12,13],[["(\\d)(\\d{5})","$1 $2",["2"],"(0$1)"],["(\\d{4})(\\d{4,6})","$1 $2",["3(?:23|39|46)|4(?:2[3-6]|[35]9|4[26]|76)|544|88[245]|(?:52|64|86)2","3(?:230|397|461)|4(?:2(?:35|[46]4|51)|396|4(?:22|63)|59[347]|76[15])|5(?:221|446)|642[23]|8(?:622|8(?:[24]2|5[13]))"],"(0$1)"],["(\\d{5})(\\d{4})","$1 $2",["346|4(?:27|9[35])|883","3469|4(?:279|9(?:30|56))|8834"],"(0$1)"],["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["2"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[3-7]|8[2-8]"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[89]"],"0$1"],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]],["(\\d{4})(\\d{1,2})(\\d{3})(\\d{4})","$1 $2 $3 $4",["1"]]],"0"],PK:["92","00","122\\d{6}|[24-8]\\d{10,11}|9(?:[013-9]\\d{8,10}|2(?:[01]\\d\\d|2(?:[06-8]\\d|1[01]))\\d{7})|(?:[2-8]\\d{3}|92(?:[0-7]\\d|8[1-9]))\\d{6}|[24-9]\\d{8}|[89]\\d{7}",[8,9,10,11,12],[["(\\d{3})(\\d{3})(\\d{2,7})","$1 $2 $3",["[89]0"],"0$1"],["(\\d{4})(\\d{5})","$1 $2",["1"]],["(\\d{3})(\\d{6,7})","$1 $2",["2(?:3[2358]|4[2-4]|9[2-8])|45[3479]|54[2-467]|60[468]|72[236]|8(?:2[2-689]|3[23578]|4[3478]|5[2356])|9(?:2[2-8]|3[27-9]|4[2-6]|6[3569]|9[25-8])","9(?:2[3-8]|98)|(?:2(?:3[2358]|4[2-4]|9[2-8])|45[3479]|54[2-467]|60[468]|72[236]|8(?:2[2-689]|3[23578]|4[3478]|5[2356])|9(?:22|3[27-9]|4[2-6]|6[3569]|9[25-7]))[2-9]"],"(0$1)"],["(\\d{2})(\\d{7,8})","$1 $2",["(?:2[125]|4[0-246-9]|5[1-35-7]|6[1-8]|7[14]|8[16]|91)[2-9]"],"(0$1)"],["(\\d{5})(\\d{5})","$1 $2",["58"],"(0$1)"],["(\\d{3})(\\d{7})","$1 $2",["3"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["2[125]|4[0-246-9]|5[1-35-7]|6[1-8]|7[14]|8[16]|91"],"(0$1)"],["(\\d{3})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["[24-9]"],"(0$1)"]],"0"],PL:["48","00","(?:6|8\\d\\d)\\d{7}|[1-9]\\d{6}(?:\\d{2})?|[26]\\d{5}",[6,7,8,9,10],[["(\\d{5})","$1",["19"]],["(\\d{3})(\\d{3})","$1 $2",["11|20|64"]],["(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["(?:1[2-8]|2[2-69]|3[2-4]|4[1-468]|5[24-689]|6[1-3578]|7[14-7]|8[1-79]|9[145])1","(?:1[2-8]|2[2-69]|3[2-4]|4[1-468]|5[24-689]|6[1-3578]|7[14-7]|8[1-79]|9[145])19"]],["(\\d{3})(\\d{2})(\\d{2,3})","$1 $2 $3",["64"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["21|39|45|5[0137]|6[0469]|7[02389]|8(?:0[14]|8)"]],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[2-8]|[2-7]|8[1-79]|9[145]"]],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["8"]]]],PM:["508","00","[45]\\d{5}|(?:708|8\\d\\d)\\d{6}",[6,9],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["[45]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["7"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0$1"]],"0"],PR:["1","011","(?:[589]\\d\\d|787)\\d{7}",[10],0,"1",0,0,0,0,"787|939"],PS:["970","00","[2489]2\\d{6}|(?:1\\d|5)\\d{8}",[8,9,10],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[2489]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["5"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]]],"0"],PT:["351","00","1693\\d{5}|(?:[26-9]\\d|30)\\d{7}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["2[12]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["16|[236-9]"]]]],PW:["680","01[12]","(?:[24-8]\\d\\d|345|900)\\d{4}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[2-9]"]]]],PY:["595","00","59\\d{4,6}|9\\d{5,10}|(?:[2-46-8]\\d|5[0-8])\\d{4,7}",[6,7,8,9,10,11],[["(\\d{3})(\\d{3,6})","$1 $2",["[2-9]0"],"0$1"],["(\\d{2})(\\d{5})","$1 $2",["[26]1|3[289]|4[1246-8]|7[1-3]|8[1-36]"],"(0$1)"],["(\\d{3})(\\d{4,5})","$1 $2",["2[279]|3[13-5]|4[359]|5|6(?:[34]|7[1-46-8])|7[46-8]|85"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["2[14-68]|3[26-9]|4[1246-8]|6(?:1|75)|7[1-35]|8[1-36]"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["87"]],["(\\d{3})(\\d{6})","$1 $2",["9(?:[5-79]|8[1-7])"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[2-8]"],"0$1"],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["9"]]],"0"],QA:["974","00","800\\d{4}|(?:2|800)\\d{6}|(?:0080|[3-7])\\d{7}",[7,8,9,11],[["(\\d{3})(\\d{4})","$1 $2",["2[136]|8"]],["(\\d{4})(\\d{4})","$1 $2",["[3-7]"]]]],RE:["262","00","709\\d{6}|(?:26|[689]\\d)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[26-9]"],"0$1"]],"0",0,0,0,0,0,[["26(?:2\\d\\d|3(?:0\\d|1[0-6]))\\d{4}"],["(?:69(?:2\\d\\d|3(?:[06][0-6]|1[0-3]|2[0-2]|3[0-39]|4\\d|5[0-5]|7[0-37]|8[0-8]|9[0-479]))|7092[0-3])\\d{4}"],["80\\d{7}"],["89[1-37-9]\\d{6}"],0,0,0,0,["9(?:399[0-3]|479[0-6]|76(?:2[278]|3[0-37]))\\d{4}"],["8(?:1[019]|2[0156]|84|90)\\d{6}"]]],RO:["40","00","(?:[236-8]\\d|90)\\d{7}|[23]\\d{5}",[6,9],[["(\\d{3})(\\d{3})","$1 $2",["2[3-6]","2[3-6]\\d9"],"0$1"],["(\\d{2})(\\d{4})","$1 $2",["219|31"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[23]1"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[236-9]"],"0$1"]],"0",0,0,0,0,0,0,0," int "],RS:["381","00","38[02-9]\\d{6,9}|6\\d{7,9}|90\\d{4,8}|38\\d{5,6}|(?:7\\d\\d|800)\\d{3,9}|(?:[12]\\d|3[0-79])\\d{5,10}",[6,7,8,9,10,11,12],[["(\\d{3})(\\d{3,9})","$1 $2",["(?:2[389]|39)0|[7-9]"],"0$1"],["(\\d{2})(\\d{5,10})","$1 $2",["[1-36]"],"0$1"]],"0"],RU:["7","810","8\\d{13}|[347-9]\\d{9}",[10,14],[["(\\d{4})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["7(?:1[0-8]|2[1-9])","7(?:1(?:[0-356]2|4[29]|7|8[27])|2(?:1[23]|[2-9]2))","7(?:1(?:[0-356]2|4[29]|7|8[27])|2(?:13[03-69]|62[013-9]))|72[1-57-9]2"],"8 ($1)",1],["(\\d{5})(\\d)(\\d{2})(\\d{2})","$1 $2 $3 $4",["7(?:1[0-68]|2[1-9])","7(?:1(?:[06][3-6]|[18]|2[35]|[3-5][3-5])|2(?:[13][3-5]|[24-689]|7[457]))","7(?:1(?:0(?:[356]|4[023])|[18]|2(?:3[013-9]|5)|3[45]|43[013-79]|5(?:3[1-8]|4[1-7]|5)|6(?:3[0-35-9]|[4-6]))|2(?:1(?:3[178]|[45])|[24-689]|3[35]|7[457]))|7(?:14|23)4[0-8]|71(?:33|45)[1-79]"],"8 ($1)",1],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"8 ($1)",1],["(\\d{3})(\\d{3})(\\d{2})(\\d{2})","$1 $2-$3-$4",["[349]|8(?:[02-7]|1[1-8])"],"8 ($1)",1],["(\\d{4})(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3 $4",["8"],"8 ($1)"]],"8",0,0,0,0,"3[04-689]|[489]",0,"8~10"],RW:["250","00","(?:06|[27]\\d\\d|[89]00)\\d{6}",[8,9],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["0"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["2"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[7-9]"],"0$1"]],"0"],SA:["966","00","92\\d{7}|(?:[15]|8\\d)\\d{8}",[9,10],[["(\\d{4})(\\d{5})","$1 $2",["9"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["5"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["81"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"]]],"0"],SB:["677","0[01]","[6-9]\\d{6}|[1-6]\\d{4}",[5,7],[["(\\d{2})(\\d{5})","$1 $2",["6[89]|7|8[4-9]|9(?:[1-8]|9[0-8])"]]]],SC:["248","010|0[0-2]","(?:[2489]\\d|64)\\d{5}",[7],[["(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[246]|9[57]"]]],0,0,0,0,0,0,0,"00"],SD:["249","00","[19]\\d{8}",[9],[["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[19]"],"0$1"]],"0"],SE:["46","00","(?:[26]\\d\\d|9)\\d{9}|[1-9]\\d{8}|[1-689]\\d{7}|[1-4689]\\d{6}|2\\d{5}",[6,7,8,9,10,12],[["(\\d{2})(\\d{2,3})(\\d{2})","$1-$2 $3",["20"],"0$1",0,"$1 $2 $3"],["(\\d{3})(\\d{4})","$1-$2",["9(?:00|39|44|9)"],"0$1",0,"$1 $2"],["(\\d{2})(\\d{3})(\\d{2})","$1-$2 $3",["[12][136]|3[356]|4[0246]|6[03]|90[1-9]"],"0$1",0,"$1 $2 $3"],["(\\d)(\\d{2,3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["8"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2,3})(\\d{2})","$1-$2 $3",["1[2457]|2(?:[247-9]|5[0138])|3[0247-9]|4[1357-9]|5[0-35-9]|6(?:[125689]|4[02-57]|7[0-2])|9(?:[125-8]|3[02-5]|4[0-3])"],"0$1",0,"$1 $2 $3"],["(\\d{3})(\\d{2,3})(\\d{3})","$1-$2 $3",["9(?:00|39|44)"],"0$1",0,"$1 $2 $3"],["(\\d{2})(\\d{2,3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["1[13689]|2[0136]|3[1356]|4[0246]|54|6[03]|90[1-9]"],"0$1",0,"$1 $2 $3 $4"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["10|7"],"0$1",0,"$1 $2 $3 $4"],["(\\d)(\\d{3})(\\d{3})(\\d{2})","$1-$2 $3 $4",["8"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1-$2 $3 $4",["[13-5]|2(?:[247-9]|5[0138])|6(?:[124-689]|7[0-2])|9(?:[125-8]|3[02-5]|4[0-3])"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{2})(\\d{3})","$1-$2 $3 $4",["9"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1-$2 $3 $4 $5",["[26]"],"0$1",0,"$1 $2 $3 $4 $5"]],"0"],SG:["65","0[0-3]\\d","(?:(?:1\\d|8)\\d\\d|7000)\\d{7}|[3689]\\d{7}",[8,10,11],[["(\\d{4})(\\d{4})","$1 $2",["[369]|8(?:0[1-9]|[1-9])"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"]],["(\\d{4})(\\d{4})(\\d{3})","$1 $2 $3",["7"]],["(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"]]]],SH:["290","00","(?:[256]\\d|8)\\d{3}",[4,5],0,0,0,0,0,0,"[256]"],SI:["386","00|10(?:22|66|88|99)","[1-7]\\d{7}|8\\d{4,7}|90\\d{4,6}",[5,6,7,8],[["(\\d{2})(\\d{3,6})","$1 $2",["8[09]|9"],"0$1"],["(\\d{3})(\\d{5})","$1 $2",["59|8"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[37][01]|4[0139]|51|6"],"0$1"],["(\\d)(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[1-57]"],"(0$1)"]],"0",0,0,0,0,0,0,"00"],SJ:["47","00","0\\d{4}|(?:[489]\\d|79)\\d{6}",[5,8],0,0,0,0,0,0,"79"],SK:["421","00","[2-689]\\d{8}|[2-59]\\d{6}|[2-5]\\d{5}",[6,7,9],[["(\\d)(\\d{2})(\\d{3,4})","$1 $2 $3",["21"],"0$1"],["(\\d{2})(\\d{2})(\\d{2,3})","$1 $2 $3",["[3-5][1-8]1","[3-5][1-8]1[67]"],"0$1"],["(\\d)(\\d{3})(\\d{3})(\\d{2})","$1/$2 $3 $4",["2"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[689]"],"0$1"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1/$2 $3 $4",["[3-5]"],"0$1"]],"0"],SL:["232","00","(?:[237-9]\\d|66)\\d{6}",[8],[["(\\d{2})(\\d{6})","$1 $2",["[236-9]"],"(0$1)"]],"0"],SM:["378","00","(?:0549|[5-7]\\d)\\d{6}",[8,10],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-7]"]],["(\\d{4})(\\d{6})","$1 $2",["0"]]],0,0,"([89]\\d{5})$","0549$1"],SN:["221","00","(?:[378]\\d|93)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"]],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[379]"]]]],SO:["252","00","[346-9]\\d{8}|[12679]\\d{7}|[1-5]\\d{6}|[1348]\\d{5}",[6,7,8,9],[["(\\d{2})(\\d{4})","$1 $2",["8[125]"]],["(\\d{6})","$1",["[134]"]],["(\\d)(\\d{6})","$1 $2",["[15]|2[0-79]|3[0-46-8]|4[0-7]"]],["(\\d)(\\d{7})","$1 $2",["(?:2|90)4|[67]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[348]|64|79|90"]],["(\\d{2})(\\d{5,7})","$1 $2",["1|28|6[0-35-9]|7[67]|9[2-9]"]]],"0"],SR:["597","00","(?:[2-5]|68|[78]\\d|90)\\d{5}",[6,7],[["(\\d{2})(\\d{2})(\\d{2})","$1-$2-$3",["56"]],["(\\d{3})(\\d{3})","$1-$2",["[2-5]"]],["(\\d{3})(\\d{4})","$1-$2",["[6-9]"]]]],SS:["211","00","[19]\\d{8}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[19]"],"0$1"]],"0"],ST:["239","00","(?:22|9\\d)\\d{5}",[7],[["(\\d{3})(\\d{4})","$1 $2",["[29]"]]]],SV:["503","00","[267]\\d{7}|(?:80\\d|900)\\d{4}(?:\\d{4})?",[7,8,11],[["(\\d{3})(\\d{4})","$1 $2",["[89]"]],["(\\d{4})(\\d{4})","$1 $2",["[267]"]],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["[89]"]]]],SX:["1","011","7215\\d{6}|(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"(5\\d{6})$|1","721$1",0,"721"],SY:["963","00","[1-39]\\d{8}|[1-5]\\d{7}",[8,9],[["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[1-5]"],"0$1",1],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["9"],"0$1",1]],"0"],SZ:["268","00","0800\\d{4}|(?:[237]\\d|900)\\d{6}",[8,9],[["(\\d{4})(\\d{4})","$1 $2",["[0237]"]],["(\\d{5})(\\d{4})","$1 $2",["9"]]]],TA:["290","00","8\\d{3}",[4],0,0,0,0,0,0,"8"],TC:["1","011","(?:[58]\\d\\d|649|900)\\d{7}",[10],0,"1",0,"([2-479]\\d{6})$|1","649$1",0,"649"],TD:["235","00|16","(?:22|[689]\\d|77)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[26-9]"]]],0,0,0,0,0,0,0,"00"],TG:["228","00","[279]\\d{7}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[279]"]]]],TH:["66","00[1-9]","(?:001800|[2-57]|[689]\\d)\\d{7}|1\\d{7,9}",[8,9,10,13],[["(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["2"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[13-9]"],"0$1"],["(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"]]],"0"],TJ:["992","810","[0-57-9]\\d{8}",[9],[["(\\d{6})(\\d)(\\d{2})","$1 $2 $3",["331","3317"]],["(\\d{3})(\\d{2})(\\d{4})","$1 $2 $3",["44[02-479]|[34]7"]],["(\\d{4})(\\d)(\\d{4})","$1 $2 $3",["3(?:[1245]|3[12])"]],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[0-57-9]"]]],0,0,0,0,0,0,0,"8~10"],TK:["690","00","[2-47]\\d{3,6}",[4,5,6,7]],TL:["670","00","7\\d{7}|(?:[2-47]\\d|[89]0)\\d{5}",[7,8],[["(\\d{3})(\\d{4})","$1 $2",["[2-489]|70"]],["(\\d{4})(\\d{4})","$1 $2",["7"]]]],TM:["993","810","(?:[1-6]\\d|71)\\d{6}",[8],[["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2-$3-$4",["12"],"(8 $1)"],["(\\d{3})(\\d)(\\d{2})(\\d{2})","$1 $2-$3-$4",["[1-5]"],"(8 $1)"],["(\\d{2})(\\d{6})","$1 $2",["[67]"],"8 $1"]],"8",0,0,0,0,0,0,"8~10"],TN:["216","00","[2-57-9]\\d{7}",[8],[["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2-57-9]"]]]],TO:["676","00","(?:0800|(?:[5-8]\\d\\d|999)\\d)\\d{3}|[2-8]\\d{4}",[5,7],[["(\\d{2})(\\d{3})","$1-$2",["[2-4]|50|6[09]|7[0-24-69]|8[05]"]],["(\\d{4})(\\d{3})","$1 $2",["0"]],["(\\d{3})(\\d{4})","$1 $2",["[5-9]"]]]],TR:["90","00","4\\d{6}|8\\d{11,12}|(?:[2-58]\\d\\d|900)\\d{7}",[7,10,12,13],[["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["512|8[01589]|90"],"0$1",1],["(\\d{3})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["5(?:[0-59]|61)","5(?:[0-59]|61[06])","5(?:[0-59]|61[06]1)"],"0$1",1],["(\\d{3})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[24][1-8]|3[1-9]"],"(0$1)",1],["(\\d{3})(\\d{3})(\\d{6,7})","$1 $2 $3",["80"],"0$1",1]],"0"],TT:["1","011","(?:[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-46-8]\\d{6})$|1","868$1",0,"868"],TV:["688","00","(?:2|7\\d\\d|90)\\d{4}",[5,6,7],[["(\\d{2})(\\d{3})","$1 $2",["2"]],["(\\d{2})(\\d{4})","$1 $2",["90"]],["(\\d{2})(\\d{5})","$1 $2",["7"]]]],TW:["886","0(?:0[25-79]|19)","[2-689]\\d{8}|7\\d{9,10}|[2-8]\\d{7}|2\\d{6}",[7,8,9,10,11],[["(\\d{2})(\\d)(\\d{4})","$1 $2 $3",["202"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[258]0"],"0$1"],["(\\d)(\\d{3,4})(\\d{4})","$1 $2 $3",["[23568]|4(?:0[02-48]|[1-47-9])|7[1-9]","[23568]|4(?:0[2-48]|[1-47-9])|(?:400|7)[1-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[49]"],"0$1"],["(\\d{2})(\\d{4})(\\d{4,5})","$1 $2 $3",["7"],"0$1"]],"0",0,0,0,0,0,0,0,"#"],TZ:["255","00[056]","(?:[25-8]\\d|41|90)\\d{7}",[9],[["(\\d{3})(\\d{2})(\\d{4})","$1 $2 $3",["[89]"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[24]"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["5"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[67]"],"0$1"]],"0"],UA:["380","00","[89]\\d{9}|[3-9]\\d{8}",[9,10],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6[12][29]|(?:3[1-8]|4[136-8]|5[12457]|6[49])2|(?:56|65)[24]","6[12][29]|(?:35|4[1378]|5[12457]|6[49])2|(?:56|65)[24]|(?:3[1-46-8]|46)2[013-9]"],"0$1"],["(\\d{4})(\\d{5})","$1 $2",["3[1-8]|4(?:[1367]|[45][6-9]|8[4-6])|5(?:[1-5]|6[0135689]|7[4-6])|6(?:[12][3-7]|[459])","3[1-8]|4(?:[1367]|[45][6-9]|8[4-6])|5(?:[1-5]|6(?:[015689]|3[02389])|7[4-6])|6(?:[12][3-7]|[459])"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[3-7]|89|9[1-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[89]"],"0$1"]],"0",0,0,0,0,0,0,"0~0"],UG:["256","00[057]","800\\d{6}|(?:[29]0|[347]\\d)\\d{7}",[9],[["(\\d{4})(\\d{5})","$1 $2",["202","2024"],"0$1"],["(\\d{3})(\\d{6})","$1 $2",["[27-9]|4(?:6[45]|[7-9])"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["[34]"],"0$1"]],"0"],US:["1","011","[2-9]\\d{9}|3\\d{6}",[10],[["(\\d{3})(\\d{4})","$1-$2",["310"],0,1],["(\\d{3})(\\d{3})(\\d{4})","($1) $2-$3",["[2-9]"],0,1,"$1-$2-$3"]],"1",0,0,0,0,0,[["(?:3052(?:0[0-8]|[1-9]\\d)|5056(?:[0-35-9]\\d|4[0-468]))\\d{4}|(?:2742|305[3-9]|472[247-9]|505[2-57-9]|983[2-47-9])\\d{6}|(?:2(?:0[1-35-9]|1[02-9]|2[03-57-9]|3[1459]|4[08]|5[1-46]|6[0279]|7[0269]|8[13])|3(?:0[1-47-9]|1[02-9]|2[0135-79]|3[0-24679]|4[167]|5[0-2]|6[01349]|8[056])|4(?:0[124-9]|1[02-579]|2[3-5]|3[0245]|4[023578]|58|6[349]|7[0589]|8[04])|5(?:0[1-47-9]|1[0235-8]|20|3[0149]|4[01]|5[179]|6[1-47]|7[0-5]|8[0256])|6(?:0[1-35-9]|1[024-9]|2[03689]|3[016]|4[0156]|5[01679]|6[0-279]|78|8[0-29])|7(?:0[1-46-8]|1[2-9]|2[04-8]|3[0-247]|4[037]|5[47]|6[02359]|7[0-59]|8[156])|8(?:0[1-68]|1[02-8]|2[0168]|3[0-2589]|4[03578]|5[046-9]|6[02-5]|7[028])|9(?:0[1346-9]|1[02-9]|2[0589]|3[0146-8]|4[01357-9]|5[12469]|7[0-389]|8[04-69]))[2-9]\\d{6}"],[""],["8(?:00|33|44|55|66|77|88)[2-9]\\d{6}"],["900[2-9]\\d{6}"],["52(?:3(?:[2-46-9][02-9]\\d|5(?:[02-46-9]\\d|5[0-46-9]))|4(?:[2-478][02-9]\\d|5(?:[034]\\d|2[024-9]|5[0-46-9])|6(?:0[1-9]|[2-9]\\d)|9(?:[05-9]\\d|2[0-5]|49)))\\d{4}|52[34][2-9]1[02-9]\\d{4}|5(?:00|2[125-9]|33|44|66|77|88)[2-9]\\d{6}"],0,0,0,["305209\\d{4}"]]],UY:["598","0(?:0|1[3-9]\\d)","0004\\d{2,9}|[1249]\\d{7}|(?:[49]\\d|80)\\d{5}",[6,7,8,9,10,11,12,13],[["(\\d{3})(\\d{3,4})","$1 $2",["0"]],["(\\d{3})(\\d{4})","$1 $2",["[49]0|8"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["9"],"0$1"],["(\\d{4})(\\d{4})","$1 $2",["[124]"]],["(\\d{3})(\\d{3})(\\d{2,4})","$1 $2 $3",["0"]],["(\\d{3})(\\d{3})(\\d{3})(\\d{2,4})","$1 $2 $3 $4",["0"]]],"0",0,0,0,0,0,0,"00"," int. "],UZ:["998","00","(?:20|33|[5-9]\\d)\\d{7}",[9],[["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[235-9]"]]]],VA:["39","00","0\\d{5,10}|3[0-8]\\d{7,10}|55\\d{8}|8\\d{5}(?:\\d{2,4})?|(?:1\\d|39)\\d{7,8}",[6,7,8,9,10,11,12],0,0,0,0,0,0,"06698"],VC:["1","011","(?:[58]\\d\\d|784|900)\\d{7}",[10],0,"1",0,"([2-7]\\d{6})$|1","784$1",0,"784"],VE:["58","00","[68]00\\d{7}|(?:[24]\\d|[59]0)\\d{8}",[10],[["(\\d{3})(\\d{7})","$1-$2",["[24-689]"],"0$1"]],"0"],VG:["1","011","(?:284|[58]\\d\\d|900)\\d{7}",[10],0,"1",0,"([2-578]\\d{6})$|1","284$1",0,"284"],VI:["1","011","[58]\\d{9}|(?:34|90)0\\d{7}",[10],0,"1",0,"([2-9]\\d{6})$|1","340$1",0,"340"],VN:["84","00","[12]\\d{9}|[135-9]\\d{8}|[16]\\d{7}|[16-8]\\d{6}",[7,8,9,10],[["(\\d{2})(\\d{5})","$1 $2",["80"],"0$1",1],["(\\d{4})(\\d{4,6})","$1 $2",["1"],0,1],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["6"],"0$1",1],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[357-9]"],"0$1",1],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["2[48]"],"0$1",1],["(\\d{3})(\\d{4})(\\d{3})","$1 $2 $3",["2"],"0$1",1]],"0"],VU:["678","00","[57-9]\\d{6}|(?:[238]\\d|48)\\d{3}",[5,7],[["(\\d{3})(\\d{4})","$1 $2",["[57-9]"]]]],WF:["681","00","(?:40|72|8\\d{4})\\d{4}|[89]\\d{5}",[6,9],[["(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["[47-9]"]],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"]]]],WS:["685","0","(?:[2-6]|8\\d{5})\\d{4}|[78]\\d{6}|[68]\\d{5}",[5,6,7,10],[["(\\d{5})","$1",["[2-5]|6[1-9]"]],["(\\d{3})(\\d{3,7})","$1 $2",["[68]"]],["(\\d{2})(\\d{5})","$1 $2",["7"]]]],XK:["383","00","2\\d{7,8}|3\\d{7,11}|(?:4\\d\\d|[89]00)\\d{5}",[8,9,10,11,12],[["(\\d{3})(\\d{5})","$1 $2",["[89]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2-4]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["2|39"],"0$1"],["(\\d{2})(\\d{7,10})","$1 $2",["3"],"0$1"]],"0"],YE:["967","00","(?:1|7\\d)\\d{7}|[1-7]\\d{6}",[7,8,9],[["(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["[1-6]|7(?:[24-6]|8[0-7])"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["7"],"0$1"]],"0"],YT:["262","00","7093\\d{5}|(?:80|9\\d)\\d{7}|(?:26|63)9\\d{6}",[9],0,"0",0,0,0,0,0,[["269(?:0[0-467]|15|5[0-4]|6\\d|[78]0)\\d{4}"],["(?:639(?:0[0-79]|1[019]|[267]\\d|3[09]|40|5[05-9]|9[04-79])|7093[5-7])\\d{4}"],["80\\d{7}"],0,0,0,0,0,["9(?:(?:39|47)8[01]|769\\d)\\d{4}"]]],ZA:["27","00","[1-79]\\d{8}|8\\d{4,9}",[5,6,7,8,9,10],[["(\\d{2})(\\d{3,4})","$1 $2",["8[1-4]"],"0$1"],["(\\d{2})(\\d{3})(\\d{2,3})","$1 $2 $3",["8[1-4]"],"0$1"],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["860"],"0$1"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[1-9]"],"0$1"],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8"],"0$1"]],"0"],ZM:["260","00","800\\d{6}|(?:21|[579]\\d|63)\\d{7}",[9],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[28]"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["[579]"],"0$1"]],"0"],ZW:["263","00","2(?:[0-57-9]\\d{6,8}|6[0-24-9]\\d{6,7})|[38]\\d{9}|[35-8]\\d{8}|[3-6]\\d{7}|[1-689]\\d{6}|[1-3569]\\d{5}|[1356]\\d{4}",[5,6,7,8,9,10],[["(\\d{3})(\\d{3,5})","$1 $2",["2(?:0[45]|2[278]|[49]8)|3(?:[09]8|17)|6(?:[29]8|37|75)|[23][78]|(?:33|5[15]|6[68])[78]"],"0$1"],["(\\d)(\\d{3})(\\d{2,4})","$1 $2 $3",["[49]"],"0$1"],["(\\d{3})(\\d{4})","$1 $2",["80"],"0$1"],["(\\d{2})(\\d{7})","$1 $2",["24|8[13-59]|(?:2[05-79]|39|5[45]|6[15-8])2","2(?:02[014]|4|[56]20|[79]2)|392|5(?:42|525)|6(?:[16-8]21|52[013])|8[13-59]"],"(0$1)"],["(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"0$1"],["(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["2(?:1[39]|2[0157]|[378]|[56][14])|3(?:12|29)","2(?:1[39]|2[0157]|[378]|[56][14])|3(?:123|29)"],"0$1"],["(\\d{4})(\\d{6})","$1 $2",["8"],"0$1"],["(\\d{2})(\\d{3,5})","$1 $2",["1|2(?:0[0-36-9]|12|29|[56])|3(?:1[0-689]|[24-6])|5(?:[0236-9]|1[2-4])|6(?:[013-59]|7[0-46-9])|(?:33|55|6[68])[0-69]|(?:29|3[09]|62)[0-79]"],"0$1"],["(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["29[013-9]|39|54"],"0$1"],["(\\d{4})(\\d{3,5})","$1 $2",["(?:25|54)8","258|5483"],"0$1"]],"0"]},nonGeographic:{800:["800",0,"(?:00|[1-9]\\d)\\d{6}",[8],[["(\\d{4})(\\d{4})","$1 $2",["\\d"]]],0,0,0,0,0,0,[0,0,["(?:00|[1-9]\\d)\\d{6}"]]],808:["808",0,"[1-9]\\d{7}",[8],[["(\\d{4})(\\d{4})","$1 $2",["[1-9]"]]],0,0,0,0,0,0,[0,0,0,0,0,0,0,0,0,["[1-9]\\d{7}"]]],870:["870",0,"7\\d{11}|[235-7]\\d{8}",[9,12],[["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[235-7]"]]],0,0,0,0,0,0,[0,["(?:[356]|774[45])\\d{8}|7[6-8]\\d{7}"],0,0,0,0,0,0,["2\\d{8}",[9]]]],878:["878",0,"10\\d{10}",[12],[["(\\d{2})(\\d{5})(\\d{5})","$1 $2 $3",["1"]]],0,0,0,0,0,0,[0,0,0,0,0,0,0,0,["10\\d{10}"]]],881:["881",0,"6\\d{9}|[0-36-9]\\d{8}",[9,10],[["(\\d)(\\d{3})(\\d{5})","$1 $2 $3",["[0-37-9]"]],["(\\d)(\\d{3})(\\d{5,6})","$1 $2 $3",["6"]]],0,0,0,0,0,0,[0,["6\\d{9}|[0-36-9]\\d{8}"]]],882:["882",0,"[13]\\d{6}(?:\\d{2,5})?|[19]\\d{7}|(?:[25]\\d\\d|4)\\d{7}(?:\\d{2})?",[7,8,9,10,11,12],[["(\\d{2})(\\d{5})","$1 $2",["16|342"]],["(\\d{2})(\\d{6})","$1 $2",["49"]],["(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["1[36]|9"]],["(\\d{2})(\\d{4})(\\d{3})","$1 $2 $3",["3[23]"]],["(\\d{2})(\\d{3,4})(\\d{4})","$1 $2 $3",["16"]],["(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["10|23|3(?:[15]|4[57])|4|51"]],["(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["34"]],["(\\d{2})(\\d{4,5})(\\d{5})","$1 $2 $3",["[1-35]"]]],0,0,0,0,0,0,[0,["342\\d{4}|(?:337|49)\\d{6}|(?:3(?:2|47|7\\d{3})|50\\d{3})\\d{7}",[7,8,9,10,12]],0,0,0,["348[57]\\d{7}",[11]],0,0,["1(?:3(?:0[0347]|[13][0139]|2[035]|4[013568]|6[0459]|7[06]|8[15-8]|9[0689])\\d{4}|6\\d{5,10})|(?:345\\d|9[89])\\d{6}|(?:10|2(?:3|85\\d)|3(?:[15]|[69]\\d\\d)|4[15-8]|51)\\d{8}"]]],883:["883",0,"(?:[1-4]\\d|51)\\d{6,10}",[8,9,10,11,12],[["(\\d{3})(\\d{3})(\\d{2,8})","$1 $2 $3",["[14]|2[24-689]|3[02-689]|51[24-9]"]],["(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["510"]],["(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["21"]],["(\\d{4})(\\d{4})(\\d{4})","$1 $2 $3",["51[13]"]],["(\\d{3})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["[235]"]]],0,0,0,0,0,0,[0,0,0,0,0,0,0,0,["(?:2(?:00\\d\\d|10)|(?:370[1-9]|51\\d0)\\d)\\d{7}|51(?:00\\d{5}|[24-9]0\\d{4,7})|(?:1[0-79]|2[24-689]|3[02-689]|4[0-4])0\\d{5,9}"]]],888:["888",0,"\\d{11}",[11],[["(\\d{3})(\\d{3})(\\d{5})","$1 $2 $3"]],0,0,0,0,0,0,[0,0,0,0,0,0,["\\d{11}"]]],979:["979",0,"[1359]\\d{8}",[9],[["(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["[1359]"]]],0,0,0,0,0,0,[0,0,0,["[1359]\\d{8}"]]]}};function i3(t,e){var n=Array.prototype.slice.call(e);return n.push(r3),t.apply(this,n)}function yp(t,e){t=t.split("-"),e=e.split("-");for(var n=t[0].split("."),r=e[0].split("."),i=0;i<3;i++){var s=Number(n[i]),o=Number(r[i]);if(s>o)return 1;if(o>s)return-1;if(!isNaN(s)&&isNaN(o))return 1;if(isNaN(s)&&!isNaN(o))return-1}return t[1]&&e[1]?t[1]>e[1]?1:t[1]<e[1]?-1:0:!t[1]&&e[1]?1:t[1]&&!e[1]?-1:0}var s3={}.constructor;function sr(t){return t!=null&&t.constructor===s3}function md(t){"@babel/helpers - typeof";return md=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},md(t)}function fa(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o3(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function pa(t,e,n){return e&&o3(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}var a3="1.2.0",c3="1.7.35",wp=" ext. ",d3=/^\d+$/,He=function(){function t(e){fa(this,t),Yg(e),this.metadata=e,Qg.call(this,e)}return pa(t,[{key:"getCountries",value:function(){return Object.keys(this.metadata.countries).filter(function(n){return n!=="001"})}},{key:"getCountryMetadata",value:function(n){return this.metadata.countries[n]}},{key:"nonGeographic",value:function(){if(!(this.v1||this.v2||this.v3))return this.metadata.nonGeographic||this.metadata.nonGeographical}},{key:"hasCountry",value:function(n){return this.getCountryMetadata(n)!==void 0}},{key:"hasCallingCode",value:function(n){if(this.getCountryCodesForCallingCode(n))return!0;if(this.nonGeographic()){if(this.nonGeographic()[n])return!0}else{var r=this.countryCallingCodes()[n];if(r&&r.length===1&&r[0]==="001")return!0}}},{key:"isNonGeographicCallingCode",value:function(n){return this.nonGeographic()?!!this.nonGeographic()[n]:!this.getCountryCodesForCallingCode(n)}},{key:"country",value:function(n){return this.selectNumberingPlan(n)}},{key:"selectNumberingPlan",value:function(n,r){if(n&&d3.test(n)&&(r=n,n=null),n&&n!=="001"){if(!this.hasCountry(n))throw new Error("Unknown country: ".concat(n));this.numberingPlan=new vp(this.getCountryMetadata(n),this)}else if(r){if(!this.hasCallingCode(r))throw new Error("Unknown calling code: ".concat(r));this.numberingPlan=new vp(this.getNumberingPlanMetadata(r),this)}else this.numberingPlan=void 0;return this}},{key:"getCountryCodesForCallingCode",value:function(n){var r=this.countryCallingCodes()[n];if(r)return r.length===1&&r[0].length===3?void 0:r}},{key:"getCountryCodeForCallingCode",value:function(n){var r=this.getCountryCodesForCallingCode(n);if(r)return r[0]}},{key:"getNumberingPlanMetadata",value:function(n){var r=this.getCountryCodeForCallingCode(n);if(r)return this.getCountryMetadata(r);if(this.nonGeographic()){var i=this.nonGeographic()[n];if(i)return i}else{var s=this.countryCallingCodes()[n];if(s&&s.length===1&&s[0]==="001")return this.metadata.countries["001"]}}},{key:"countryCallingCode",value:function(){return this.numberingPlan.callingCode()}},{key:"IDDPrefix",value:function(){return this.numberingPlan.IDDPrefix()}},{key:"defaultIDDPrefix",value:function(){return this.numberingPlan.defaultIDDPrefix()}},{key:"nationalNumberPattern",value:function(){return this.numberingPlan.nationalNumberPattern()}},{key:"possibleLengths",value:function(){return this.numberingPlan.possibleLengths()}},{key:"formats",value:function(){return this.numberingPlan.formats()}},{key:"nationalPrefixForParsing",value:function(){return this.numberingPlan.nationalPrefixForParsing()}},{key:"nationalPrefixTransformRule",value:function(){return this.numberingPlan.nationalPrefixTransformRule()}},{key:"leadingDigits",value:function(){return this.numberingPlan.leadingDigits()}},{key:"hasTypes",value:function(){return this.numberingPlan.hasTypes()}},{key:"type",value:function(n){return this.numberingPlan.type(n)}},{key:"ext",value:function(){return this.numberingPlan.ext()}},{key:"countryCallingCodes",value:function(){return this.v1?this.metadata.country_phone_code_to_countries:this.metadata.country_calling_codes}},{key:"chooseCountryByCountryCallingCode",value:function(n){return this.selectNumberingPlan(n)}},{key:"hasSelectedNumberingPlan",value:function(){return this.numberingPlan!==void 0}}]),t}(),vp=function(){function t(e,n){fa(this,t),this.globalMetadataObject=n,this.metadata=e,Qg.call(this,n.metadata)}return pa(t,[{key:"callingCode",value:function(){return this.metadata[0]}},{key:"getDefaultCountryMetadataForRegion",value:function(){return this.globalMetadataObject.getNumberingPlanMetadata(this.callingCode())}},{key:"IDDPrefix",value:function(){if(!(this.v1||this.v2))return this.metadata[1]}},{key:"defaultIDDPrefix",value:function(){if(!(this.v1||this.v2))return this.metadata[12]}},{key:"nationalNumberPattern",value:function(){return this.v1||this.v2?this.metadata[1]:this.metadata[2]}},{key:"possibleLengths",value:function(){if(!this.v1)return this.metadata[this.v2?2:3]}},{key:"_getFormats",value:function(n){return n[this.v1?2:this.v2?3:4]}},{key:"formats",value:function(){var n=this,r=this._getFormats(this.metadata)||this._getFormats(this.getDefaultCountryMetadataForRegion())||[];return r.map(function(i){return new l3(i,n)})}},{key:"nationalPrefix",value:function(){return this.metadata[this.v1?3:this.v2?4:5]}},{key:"_getNationalPrefixFormattingRule",value:function(n){return n[this.v1?4:this.v2?5:6]}},{key:"nationalPrefixFormattingRule",value:function(){return this._getNationalPrefixFormattingRule(this.metadata)||this._getNationalPrefixFormattingRule(this.getDefaultCountryMetadataForRegion())}},{key:"_nationalPrefixForParsing",value:function(){return this.metadata[this.v1?5:this.v2?6:7]}},{key:"nationalPrefixForParsing",value:function(){return this._nationalPrefixForParsing()||this.nationalPrefix()}},{key:"nationalPrefixTransformRule",value:function(){return this.metadata[this.v1?6:this.v2?7:8]}},{key:"_getNationalPrefixIsOptionalWhenFormatting",value:function(){return!!this.metadata[this.v1?7:this.v2?8:9]}},{key:"nationalPrefixIsOptionalWhenFormattingInNationalFormat",value:function(){return this._getNationalPrefixIsOptionalWhenFormatting(this.metadata)||this._getNationalPrefixIsOptionalWhenFormatting(this.getDefaultCountryMetadataForRegion())}},{key:"leadingDigits",value:function(){return this.metadata[this.v1?8:this.v2?9:10]}},{key:"types",value:function(){return this.metadata[this.v1?9:this.v2?10:11]}},{key:"hasTypes",value:function(){return this.types()&&this.types().length===0?!1:!!this.types()}},{key:"type",value:function(n){if(this.hasTypes()&&bp(this.types(),n))return new f3(bp(this.types(),n),this)}},{key:"ext",value:function(){return this.v1||this.v2?wp:this.metadata[13]||wp}}]),t}(),l3=function(){function t(e,n){fa(this,t),this._format=e,this.metadata=n}return pa(t,[{key:"pattern",value:function(){return this._format[0]}},{key:"format",value:function(){return this._format[1]}},{key:"leadingDigitsPatterns",value:function(){return this._format[2]||[]}},{key:"nationalPrefixFormattingRule",value:function(){return this._format[3]||this.metadata.nationalPrefixFormattingRule()}},{key:"nationalPrefixIsOptionalWhenFormattingInNationalFormat",value:function(){return!!this._format[4]||this.metadata.nationalPrefixIsOptionalWhenFormattingInNationalFormat()}},{key:"nationalPrefixIsMandatoryWhenFormattingInNationalFormat",value:function(){return this.usesNationalPrefix()&&!this.nationalPrefixIsOptionalWhenFormattingInNationalFormat()}},{key:"usesNationalPrefix",value:function(){return!!(this.nationalPrefixFormattingRule()&&!u3.test(this.nationalPrefixFormattingRule()))}},{key:"internationalFormat",value:function(){return this._format[5]||this.format()}}]),t}(),u3=/^\(?\$1\)?$/,f3=function(){function t(e,n){fa(this,t),this.type=e,this.metadata=n}return pa(t,[{key:"pattern",value:function(){return this.metadata.v1?this.type:this.type[0]}},{key:"possibleLengths",value:function(){if(!this.metadata.v1)return this.type[1]||this.metadata.possibleLengths()}}]),t}();function bp(t,e){switch(e){case"FIXED_LINE":return t[0];case"MOBILE":return t[1];case"TOLL_FREE":return t[2];case"PREMIUM_RATE":return t[3];case"PERSONAL_NUMBER":return t[4];case"VOICEMAIL":return t[5];case"UAN":return t[6];case"PAGER":return t[7];case"VOIP":return t[8];case"SHARED_COST":return t[9]}}function Yg(t){if(!t)throw new Error("[libphonenumber-js] `metadata` argument not passed. Check your arguments.");if(!sr(t)||!sr(t.countries))throw new Error("[libphonenumber-js] `metadata` argument was passed but it's not a valid metadata. Must be an object having `.countries` child object property. Got ".concat(sr(t)?"an object of shape: { "+Object.keys(t).join(", ")+" }":"a "+p3(t)+": "+t,"."))}var p3=function(e){return md(e)};function jl(t,e){if(e=new He(e),e.hasCountry(t))return e.country(t).countryCallingCode();throw new Error("Unknown country: ".concat(t))}function h3(t,e){return e.countries.hasOwnProperty(t)}function Qg(t){var e=t.version;typeof e=="number"?(this.v1=e===1,this.v2=e===2,this.v3=e===3,this.v4=e===4):e?yp(e,a3)===-1?this.v2=!0:yp(e,c3)===-1?this.v3=!0:this.v4=!0:this.v1=!0}function Tl(t,e){return g3(t,void 0,e)}function g3(t,e,n){var r=n.type(e),i=r&&r.possibleLengths()||n.possibleLengths();if(!i)return"IS_POSSIBLE";var s=t.length,o=i[0];return o===s?"IS_POSSIBLE":o>s?"TOO_SHORT":i[i.length-1]<s?"TOO_LONG":i.indexOf(s,1)>=0?"IS_POSSIBLE":"INVALID_LENGTH"}function m3(t,e,n){if(e===void 0&&(e={}),n=new He(n),e.v2){if(!t.countryCallingCode)throw new Error("Invalid phone number object passed");n.selectNumberingPlan(t.countryCallingCode)}else{if(!t.phone)return!1;if(t.country){if(!n.hasCountry(t.country))throw new Error("Unknown country: ".concat(t.country));n.country(t.country)}else{if(!t.countryCallingCode)throw new Error("Invalid phone number object passed");n.selectNumberingPlan(t.countryCallingCode)}}if(n.possibleLengths())return em(t.phone||t.nationalNumber,n);if(t.countryCallingCode&&n.isNonGeographicCallingCode(t.countryCallingCode))return!0;throw new Error('Missing "possibleLengths" in metadata. Perhaps the metadata has been generated before v1.0.18.')}function em(t,e){switch(Tl(t,e)){case"IS_POSSIBLE":return!0;default:return!1}}function Gt(t,e){return t=t||"",new RegExp("^(?:"+e+")$").test(t)}function _3(t,e){var n=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n)return(n=n.call(t)).next.bind(n);if(Array.isArray(t)||(n=y3(t))||e){n&&(t=n);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
150
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function y3(t,e){if(t){if(typeof t=="string")return $p(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return $p(t,e)}}function $p(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var w3=["MOBILE","PREMIUM_RATE","TOLL_FREE","SHARED_COST","VOIP","PERSONAL_NUMBER","PAGER","UAN","VOICEMAIL"];function Rl(t,e,n){if(e=e||{},!(!t.country&&!t.countryCallingCode)){n=new He(n),n.selectNumberingPlan(t.country,t.countryCallingCode);var r=e.v2?t.nationalNumber:t.phone;if(Gt(r,n.nationalNumberPattern())){if(Pa(r,"FIXED_LINE",n))return n.type("MOBILE")&&n.type("MOBILE").pattern()===""||!n.type("MOBILE")||Pa(r,"MOBILE",n)?"FIXED_LINE_OR_MOBILE":"FIXED_LINE";for(var i=_3(w3),s;!(s=i()).done;){var o=s.value;if(Pa(r,o,n))return o}}}}function Pa(t,e,n){return e=n.type(e),!e||!e.pattern()||e.possibleLengths()&&e.possibleLengths().indexOf(t.length)<0?!1:Gt(t,e.pattern())}function v3(t,e,n){if(e=e||{},n=new He(n),n.selectNumberingPlan(t.country,t.countryCallingCode),n.hasTypes())return Rl(t,e,n.metadata)!==void 0;var r=e.v2?t.nationalNumber:t.phone;return Gt(r,n.nationalNumberPattern())}function b3(t,e,n){var r=new He(n),i=r.getCountryCodesForCallingCode(t);return i?i.filter(function(s){return $3(e,s,n)}):[]}function $3(t,e,n){var r=new He(n);return r.selectNumberingPlan(e),r.numberingPlan.possibleLengths().indexOf(t.length)>=0}var Bl=2,x3=17,k3=3,wt="0-90-9٠-٩۰-۹",S3="-‐-―−ー-",A3="//",E3="..",I3="  ­​⁠ ",N3="()()[]\\[\\]",C3="~⁓∼~",oo="".concat(S3).concat(A3).concat(E3).concat(I3).concat(N3).concat(C3),Ll="++",z3=new RegExp("(["+wt+"])");function O3(t,e,n,r){if(e){var i=new He(r);i.selectNumberingPlan(e,n);var s=new RegExp(i.IDDPrefix());if(t.search(s)===0){t=t.slice(t.match(s)[0].length);var o=t.match(z3);if(!(o&&o[1]!=null&&o[1].length>0&&o[1]==="0"))return t}}}function P3(t,e){if(t&&e.numberingPlan.nationalPrefixForParsing()){var n=new RegExp("^(?:"+e.numberingPlan.nationalPrefixForParsing()+")"),r=n.exec(t);if(r){var i,s,o=r.length-1,c=o>0&&r[o];if(e.nationalPrefixTransformRule()&&c)i=t.replace(n,e.nationalPrefixTransformRule()),o>1&&(s=r[1]);else{var d=r[0];i=t.slice(d.length),c&&(s=r[1])}var l;if(c){var u=t.indexOf(r[1]),p=t.slice(0,u);p===e.numberingPlan.nationalPrefix()&&(l=e.numberingPlan.nationalPrefix())}else l=r[0];return{nationalNumber:i,nationalPrefix:l,carrierCode:s}}}return{nationalNumber:t}}function _d(t,e){var n=P3(t,e),r=n.carrierCode,i=n.nationalNumber;if(i!==t){if(!j3(t,i,e))return{nationalNumber:t};if(e.possibleLengths()&&!T3(i,e))return{nationalNumber:t}}return{nationalNumber:i,carrierCode:r}}function j3(t,e,n){return!(Gt(t,n.nationalNumberPattern())&&!Gt(e,n.nationalNumberPattern()))}function T3(t,e){switch(Tl(t,e)){case"TOO_SHORT":case"INVALID_LENGTH":return!1;default:return!0}}function R3(t,e,n,r){var i=e?jl(e,r):n;if(t.indexOf(i)===0){r=new He(r),r.selectNumberingPlan(e,n);var s=t.slice(i.length),o=_d(s,r),c=o.nationalNumber,d=_d(t,r),l=d.nationalNumber;if(!Gt(l,r.nationalNumberPattern())&&Gt(c,r.nationalNumberPattern())||Tl(l,r)==="TOO_LONG")return{countryCallingCode:i,number:s}}return{number:t}}function tm(t,e,n,r){if(!t)return{};var i;if(t[0]!=="+"){var s=O3(t,e,n,r);if(s&&s!==t)i=!0,t="+"+s;else{if(e||n){var o=R3(t,e,n,r),c=o.countryCallingCode,d=o.number;if(c)return{countryCallingCodeSource:"FROM_NUMBER_WITHOUT_PLUS_SIGN",countryCallingCode:c,number:d}}return{number:t}}}if(t[1]==="0")return{};r=new He(r);for(var l=2;l-1<=k3&&l<=t.length;){var u=t.slice(1,l);if(r.hasCallingCode(u))return r.selectNumberingPlan(u),{countryCallingCodeSource:i?"FROM_NUMBER_WITH_IDD":"FROM_NUMBER_WITH_PLUS_SIGN",countryCallingCode:u,number:t.slice(l)};l++}return{}}function B3(t){return t.replace(new RegExp("[".concat(oo,"]+"),"g")," ").trim()}var L3=/(\$\d)/;function U3(t,e,n){var r=n.useInternationalFormat,i=n.withNationalPrefix,s=t.replace(new RegExp(e.pattern()),r?e.internationalFormat():i&&e.nationalPrefixFormattingRule()?e.format().replace(L3,e.nationalPrefixFormattingRule()):e.format());return r?B3(s):s}var M3=/^[\d]+(?:[~\u2053\u223C\uFF5E][\d]+)?$/;function F3(t,e,n){var r=new He(n);if(r.selectNumberingPlan(t,e),r.defaultIDDPrefix())return r.defaultIDDPrefix();if(M3.test(r.IDDPrefix()))return r.IDDPrefix()}var V3=";ext=",Wn=function(e){return"([".concat(wt,"]{1,").concat(e,"})")};function nm(t){var e="20",n="15",r="9",i="6",s="[  \\t,]*",o="[:\\..]?[  \\t,-]*",c="#?",d="(?:e?xt(?:ensi(?:ó?|ó))?n?|e?xtn?|доб|anexo)",l="(?:[xx##~~]|int|int)",u="[- ]+",p="[  \\t]*",m="(?:,{2}|;)",w=V3+Wn(e),h=s+d+o+Wn(e)+c,_=s+l+o+Wn(r)+c,v=u+Wn(i)+"#",k=p+m+o+Wn(n)+c,I=p+"(?:,)+"+o+Wn(r)+c;return w+"|"+h+"|"+_+"|"+v+"|"+k+"|"+I}var D3="["+wt+"]{"+Bl+"}",q3="["+Ll+"]{0,1}(?:["+oo+"]*["+wt+"]){3,}["+oo+wt+"]*",H3=new RegExp("^["+Ll+"]{0,1}(?:["+oo+"]*["+wt+"]){1,2}$","i"),K3=q3+"(?:"+nm()+")?",G3=new RegExp("^"+D3+"$|^"+K3+"$","i");function W3(t){return t.length>=Bl&&G3.test(t)}function J3(t){return H3.test(t)}function Z3(t){var e=t.number,n=t.ext;if(!e)return"";if(e[0]!=="+")throw new Error('"formatRFC3966()" expects "number" to be in E.164 format.');return"tel:".concat(e).concat(n?";ext="+n:"")}function X3(t,e){var n=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n)return(n=n.call(t)).next.bind(n);if(Array.isArray(t)||(n=Y3(t))||e){n&&(t=n);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
151
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Y3(t,e){if(t){if(typeof t=="string")return xp(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return xp(t,e)}}function xp(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function kp(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Sp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?kp(Object(n),!0).forEach(function(r){Q3(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):kp(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Q3(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var Ap={formatExtension:function(e,n,r){return"".concat(e).concat(r.ext()).concat(n)}};function eb(t,e,n,r){if(n?n=Sp(Sp({},Ap),n):n=Ap,r=new He(r),t.country&&t.country!=="001"){if(!r.hasCountry(t.country))throw new Error("Unknown country: ".concat(t.country));r.country(t.country)}else if(t.countryCallingCode)r.selectNumberingPlan(t.countryCallingCode);else return t.phone||"";var i=r.countryCallingCode(),s=n.v2?t.nationalNumber:t.phone,o;switch(e){case"NATIONAL":return s?(o=ao(s,t.carrierCode,"NATIONAL",r,n),ja(o,t.ext,r,n.formatExtension)):"";case"INTERNATIONAL":return s?(o=ao(s,null,"INTERNATIONAL",r,n),o="+".concat(i," ").concat(o),ja(o,t.ext,r,n.formatExtension)):"+".concat(i);case"E.164":return"+".concat(i).concat(s);case"RFC3966":return Z3({number:"+".concat(i).concat(s),ext:t.ext});case"IDD":if(!n.fromCountry)return;var c=nb(s,t.carrierCode,i,n.fromCountry,r);return ja(c,t.ext,r,n.formatExtension);default:throw new Error('Unknown "format" argument passed to "formatNumber()": "'.concat(e,'"'))}}function ao(t,e,n,r,i){var s=tb(r.formats(),t);return s?U3(t,s,{useInternationalFormat:n==="INTERNATIONAL",withNationalPrefix:!(s.nationalPrefixIsOptionalWhenFormattingInNationalFormat()&&i&&i.nationalPrefix===!1),carrierCode:e,metadata:r}):t}function tb(t,e){for(var n=X3(t),r;!(r=n()).done;){var i=r.value;if(i.leadingDigitsPatterns().length>0){var s=i.leadingDigitsPatterns()[i.leadingDigitsPatterns().length-1];if(e.search(s)!==0)continue}if(Gt(e,i.pattern()))return i}}function ja(t,e,n,r){return e?r(t,e,n):t}function nb(t,e,n,r,i){var s=jl(r,i.metadata);if(s===n){var o=ao(t,e,"NATIONAL",i);return n==="1"?n+" "+o:o}var c=F3(r,void 0,i.metadata);if(c)return"".concat(c," ").concat(n," ").concat(ao(t,null,"INTERNATIONAL",i))}function Ep(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ip(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Ep(Object(n),!0).forEach(function(r){rb(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Ep(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function rb(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ib(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function sb(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function ob(t,e,n){return e&&sb(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}var ab=function(){function t(e,n,r){if(ib(this,t),!e)throw new TypeError("First argument is required");if(typeof e!="string")throw new TypeError("First argument must be a string");if(typeof e=="string"){if(e[0]==="+"&&!n)throw new TypeError("`metadata` argument not passed");if(sr(n)&&sr(n.countries)){r=n;var i=e;if(!lb.test(i))throw new Error('Invalid `number` argument passed: must consist of a "+" followed by digits');var s=tm(i,void 0,void 0,r),o=s.countryCallingCode,c=s.number;if(n=c,e=o,!n)throw new Error("Invalid `number` argument passed: too short")}}if(!n)throw new TypeError("`nationalNumber` argument is required");if(typeof n!="string")throw new TypeError("`nationalNumber` argument must be a string");Yg(r);var d=db(e,r),l=d.country,u=d.countryCallingCode;this.country=l,this.countryCallingCode=u,this.nationalNumber=n,this.number="+"+this.countryCallingCode+this.nationalNumber,this.getMetadata=function(){return r}}return ob(t,[{key:"setExt",value:function(n){this.ext=n}},{key:"getPossibleCountries",value:function(){return this.country?[this.country]:b3(this.countryCallingCode,this.nationalNumber,this.getMetadata())}},{key:"isPossible",value:function(){return m3(this,{v2:!0},this.getMetadata())}},{key:"isValid",value:function(){return v3(this,{v2:!0},this.getMetadata())}},{key:"isNonGeographic",value:function(){var n=new He(this.getMetadata());return n.isNonGeographicCallingCode(this.countryCallingCode)}},{key:"isEqual",value:function(n){return this.number===n.number&&this.ext===n.ext}},{key:"getType",value:function(){return Rl(this,{v2:!0},this.getMetadata())}},{key:"format",value:function(n,r){return eb(this,n,r?Ip(Ip({},r),{},{v2:!0}):{v2:!0},this.getMetadata())}},{key:"formatNational",value:function(n){return this.format("NATIONAL",n)}},{key:"formatInternational",value:function(n){return this.format("INTERNATIONAL",n)}},{key:"getURI",value:function(n){return this.format("RFC3966",n)}}]),t}(),cb=function(e){return/^[A-Z]{2}$/.test(e)};function db(t,e){var n,r,i=new He(e);return cb(t)?(n=t,i.selectNumberingPlan(n),r=i.countryCallingCode()):r=t,{country:n,countryCallingCode:r}}var lb=/^\+\d+$/;function yd(t){"@babel/helpers - typeof";return yd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},yd(t)}function ub(t,e,n){return Object.defineProperty(t,"prototype",{writable:!1}),t}function fb(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function pb(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&li(t,e)}function hb(t){var e=im();return function(){var r=ui(t),i;if(e){var s=ui(this).constructor;i=Reflect.construct(r,arguments,s)}else i=r.apply(this,arguments);return gb(this,i)}}function gb(t,e){if(e&&(yd(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return rm(t)}function rm(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function wd(t){var e=typeof Map=="function"?new Map:void 0;return wd=function(r){if(r===null||!mb(r))return r;if(typeof r!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e<"u"){if(e.has(r))return e.get(r);e.set(r,i)}function i(){return rs(r,arguments,ui(this).constructor)}return i.prototype=Object.create(r.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),li(i,r)},wd(t)}function rs(t,e,n){return im()?rs=Reflect.construct:rs=function(i,s,o){var c=[null];c.push.apply(c,s);var d=Function.bind.apply(i,c),l=new d;return o&&li(l,o.prototype),l},rs.apply(null,arguments)}function im(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function mb(t){return Function.toString.call(t).indexOf("[native code]")!==-1}function li(t,e){return li=Object.setPrototypeOf||function(r,i){return r.__proto__=i,r},li(t,e)}function ui(t){return ui=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},ui(t)}var Rt=function(t){pb(n,t);var e=hb(n);function n(r){var i;return fb(this,n),i=e.call(this,r),Object.setPrototypeOf(rm(i),n.prototype),i.name=i.constructor.name,i}return ub(n)}(wd(Error)),Np=new RegExp("(?:"+nm()+")$","i");function _b(t){var e=t.search(Np);if(e<0)return{};for(var n=t.slice(0,e),r=t.match(Np),i=1;i<r.length;){if(r[i])return{number:n,ext:r[i]};i++}}var yb={0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9","0":"0","1":"1","2":"2","3":"3","4":"4","5":"5","6":"6","7":"7","8":"8","9":"9","٠":"0","١":"1","٢":"2","٣":"3","٤":"4","٥":"5","٦":"6","٧":"7","٨":"8","٩":"9","۰":"0","۱":"1","۲":"2","۳":"3","۴":"4","۵":"5","۶":"6","۷":"7","۸":"8","۹":"9"};function wb(t){return yb[t]}function vb(t,e){var n=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n)return(n=n.call(t)).next.bind(n);if(Array.isArray(t)||(n=bb(t))||e){n&&(t=n);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
152
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function bb(t,e){if(t){if(typeof t=="string")return Cp(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Cp(t,e)}}function Cp(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function zp(t){for(var e="",n=vb(t.split("")),r;!(r=n()).done;){var i=r.value;e+=$b(i,e)||""}return e}function $b(t,e,n){return t==="+"?e?void 0:"+":wb(t)}function xb(t,e){var n=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n)return(n=n.call(t)).next.bind(n);if(Array.isArray(t)||(n=kb(t))||e){n&&(t=n);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
153
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function kb(t,e){if(t){if(typeof t=="string")return Op(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Op(t,e)}}function Op(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function Sb(t,e){var n=e.countries,r=e.metadata;r=new He(r);for(var i=xb(n),s;!(s=i()).done;){var o=s.value;if(r.country(o),r.leadingDigits()){if(t&&t.search(r.leadingDigits())===0)return o}else if(Rl({phone:t,country:o},void 0,r.metadata))return o}}function Ab(t,e){var n=e.nationalNumber,r=e.defaultCountry,i=e.metadata,s=i.getCountryCodesForCallingCode(t);if(s)return s.length===1?s[0]:Sb(n,{countries:s,defaultCountry:r,metadata:i.metadata})}var sm="+",Eb="[\\-\\.\\(\\)]?",Pp="(["+wt+"]|"+Eb+")",Ib="^\\"+sm+Pp+"*["+wt+"]"+Pp+"*$",Nb=new RegExp(Ib,"g"),vd=wt,Cb="["+vd+"]+((\\-)*["+vd+"])*",zb="a-zA-Z",Ob="["+zb+"]+((\\-)*["+vd+"])*",Pb="^("+Cb+"\\.)*"+Ob+"\\.?$",jb=new RegExp(Pb,"g"),jp="tel:",bd=";phone-context=",Tb=";isub=";function Rb(t){var e=t.indexOf(bd);if(e<0)return null;var n=e+bd.length;if(n>=t.length)return"";var r=t.indexOf(";",n);return r>=0?t.substring(n,r):t.substring(n)}function Bb(t){return t===null?!0:t.length===0?!1:Nb.test(t)||jb.test(t)}function Lb(t,e){var n=e.extractFormattedPhoneNumber,r=Rb(t);if(!Bb(r))throw new Rt("NOT_A_NUMBER");var i;if(r===null)i=n(t)||"";else{i="",r.charAt(0)===sm&&(i+=r);var s=t.indexOf(jp),o;s>=0?o=s+jp.length:o=0;var c=t.indexOf(bd);i+=t.substring(o,c)}var d=i.indexOf(Tb);if(d>0&&(i=i.substring(0,d)),i!=="")return i}var Ub=250,Mb=new RegExp("["+Ll+wt+"]"),Fb=new RegExp("[^"+wt+"#]+$");function Vb(t,e,n){if(e=e||{},n=new He(n),e.defaultCountry&&!n.hasCountry(e.defaultCountry))throw e.v2?new Rt("INVALID_COUNTRY"):new Error("Unknown country: ".concat(e.defaultCountry));var r=qb(t,e.v2,e.extract),i=r.number,s=r.ext,o=r.error;if(!i){if(e.v2)throw o==="TOO_SHORT"?new Rt("TOO_SHORT"):new Rt("NOT_A_NUMBER");return{}}var c=Kb(i,e.defaultCountry,e.defaultCallingCode,n),d=c.country,l=c.nationalNumber,u=c.countryCallingCode,p=c.countryCallingCodeSource,m=c.carrierCode;if(!n.hasSelectedNumberingPlan()){if(e.v2)throw new Rt("INVALID_COUNTRY");return{}}if(!l||l.length<Bl){if(e.v2)throw new Rt("TOO_SHORT");return{}}if(l.length>x3){if(e.v2)throw new Rt("TOO_LONG");return{}}if(e.v2){var w=new ab(u,l,n.metadata);return d&&(w.country=d),m&&(w.carrierCode=m),s&&(w.ext=s),w.__countryCallingCodeSource=p,w}var h=(e.extended?n.hasSelectedNumberingPlan():d)?Gt(l,n.nationalNumberPattern()):!1;return e.extended?{country:d,countryCallingCode:u,carrierCode:m,valid:h,possible:h?!0:!!(e.extended===!0&&n.possibleLengths()&&em(l,n)),phone:l,ext:s}:h?Hb(d,l,s):{}}function Db(t,e,n){if(t){if(t.length>Ub){if(n)throw new Rt("TOO_LONG");return}if(e===!1)return t;var r=t.search(Mb);if(!(r<0))return t.slice(r).replace(Fb,"")}}function qb(t,e,n){var r=Lb(t,{extractFormattedPhoneNumber:function(o){return Db(o,n,e)}});if(!r)return{};if(!W3(r))return J3(r)?{error:"TOO_SHORT"}:{};var i=_b(r);return i.ext?i:{number:r}}function Hb(t,e,n){var r={country:t,phone:e};return n&&(r.ext=n),r}function Kb(t,e,n,r){var i=tm(zp(t),e,n,r.metadata),s=i.countryCallingCodeSource,o=i.countryCallingCode,c=i.number,d;if(o)r.selectNumberingPlan(o);else if(c&&(e||n))r.selectNumberingPlan(e,n),e&&(d=e),o=n||jl(e,r.metadata);else return{};if(!c)return{countryCallingCodeSource:s,countryCallingCode:o};var l=_d(zp(c),r),u=l.nationalNumber,p=l.carrierCode,m=Ab(o,{nationalNumber:u,defaultCountry:e,metadata:r});return m&&(d=m,m==="001"||r.country(d)),{country:d,countryCallingCode:o,countryCallingCodeSource:s,nationalNumber:u,carrierCode:p}}function Tp(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Rp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Tp(Object(n),!0).forEach(function(r){Gb(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Tp(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Gb(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Wb(t,e,n){return Vb(t,Rp(Rp({},e),{},{v2:!0}),n)}function Bp(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Jb(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Bp(Object(n),!0).forEach(function(r){Zb(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Bp(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Zb(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Xb(t,e){return t4(t)||e4(t,e)||Qb(t,e)||Yb()}function Yb(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
154
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Qb(t,e){if(t){if(typeof t=="string")return Lp(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Lp(t,e)}}function Lp(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function e4(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var r=[],i=!0,s=!1,o,c;try{for(n=n.call(t);!(i=(o=n.next()).done)&&(r.push(o.value),!(e&&r.length===e));i=!0);}catch(d){s=!0,c=d}finally{try{!i&&n.return!=null&&n.return()}finally{if(s)throw c}}return r}}function t4(t){if(Array.isArray(t))return t}function n4(t){var e=Array.prototype.slice.call(t),n=Xb(e,4),r=n[0],i=n[1],s=n[2],o=n[3],c,d,l;if(typeof r=="string")c=r;else throw new TypeError("A text for parsing must be a string.");if(!i||typeof i=="string")o?(d=s,l=o):(d=void 0,l=s),i&&(d=Jb({defaultCountry:i},d));else if(sr(i))s?(d=i,l=s):l=i;else throw new Error("Invalid second argument: ".concat(i));return{text:c,options:d,metadata:l}}function Up(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Mp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Up(Object(n),!0).forEach(function(r){r4(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Up(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function r4(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function i4(t,e,n){e&&e.defaultCountry&&!h3(e.defaultCountry,n)&&(e=Mp(Mp({},e),{},{defaultCountry:void 0}));try{return Wb(t,e,n)}catch(r){if(!(r instanceof Rt))throw r}}function s4(){var t=n4(arguments),e=t.text,n=t.options,r=t.metadata;return i4(e,n,r)}function o4(){return i3(s4,arguments)}function fi(t,e="US"){const n=t.trim();if(n.includes("@")){const r=n.toLowerCase(),i=/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r);return{connection:"email",normalized:i?r:null,isValid:i}}else if(/^\+?\d[\d\s\-().]*$/.test(n)){const r=o4(n,{defaultCountry:e});return r&&r.isValid()?{connection:"sms",normalized:r.number,isValid:!0}:{connection:"sms",normalized:null,isValid:!1}}else return{connection:"username",normalized:n,isValid:!0}}const a4=a.z.object({client_id:a.z.string(),username:a.z.string().transform(t=>t.toLowerCase()),otp:a.z.string(),authParams:Jr.optional()});async function om(t,{client_id:e,username:n,otp:r,authParams:i}){const s=await t.env.data.clients.get(e);if(!s)throw new N(403,{message:"Client not found"});return Ul(t,s,i||{client_id:e,response_type:Ct.TOKEN_ID_TOKEN,response_mode:Ft.WEB_MESSAGE},n,r)}async function Ul(t,e,n,r,i,s,o){const{env:c}=t,d=await c.data.codes.get(e.tenant.id,i,"otp");if(!d)throw new N(400,{message:"Code not found or expired"});if(d.expires_at<new Date().toISOString())throw new N(400,{message:"Code expired"});if(d.used_at)throw new N(400,{message:"Code already used"});const l=Ot(t.req),{connection:u,normalized:p}=fi(r,l.countryCode);if(!p)throw new N(400,{message:"Invalid username format"});const m=await c.data.loginSessions.get(e.tenant.id,d.login_id);if(!m||m.authParams.username!==r)throw new N(400,{message:"Code not found or expired"});if(o&&m.ip!==l.ip)return t.redirect(`${ct(t.env)}invalid-session?state=${m.id}`);const w=await bo(t,{client:e,username:p,provider:u,connection:u,isSocial:!1,ip:t.req.header("x-real-ip")});return await c.data.codes.used(e.tenant.id,i),pn(t,{user:w,client:e,loginSession:m,authParams:n,ticketAuth:s})}const Fp=a.z.object({client_id:a.z.string().optional(),client_secret:a.z.string().optional()}),c4=a.z.union([Xg.extend(Fp.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(),...Fp.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()}),a.z.object({grant_type:a.z.literal("http://auth0.com/oauth/grant-type/passwordless/otp"),client_id:a.z.string(),username:a.z.string(),otp:a.z.string(),realm:a.z.enum(["email","sms"])})]);function d4(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 l4=new a.OpenAPIHono().openapi(a.createRoute({tags:["oauth2"],method:"post",path:"/",request:{body:{content:{"application/x-www-form-urlencoded":{schema:c4}}}},responses:{200:{content:{"application/json":{schema:k0}},description:"Tokens"}}}),async t=>{const e=t.req.valid("form"),n=d4(t.req.header("Authorization")),r={...e,...n};if(!r.client_id)throw new N(400,{message:"client_id is required"});switch(t.set("client_id",r.client_id),e.grant_type){case Qn.AuthorizationCode:return e3(t,Qv.parse(r));case Qn.ClientCredential:return Yv(t,Xg.parse(r));case Qn.RefreshToken:return n3(t,t3.parse(r));case Qn.OTP:return om(t,a4.parse(r));default:throw new N(400,{message:"Not implemented"})}});var Ml={exports:{}};const Fl=[{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}],am=(t,e=Fl,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,d)=>d.id-c.id).map(c=>({id:c.id,value:c.value}));return Object.assign(s,o[0]),s};Ml.exports={passwordStrength:am,defaultOptions:Fl};var u4=Ml.exports.passwordStrength=am;Ml.exports.defaultOptions=Fl;function Vl(t){return u4(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 Ri(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 cm(t,e){var o,c;if(!t.var.client_id)throw new N(500,{message:"Client not found"});const n=await Ti(t.env,t.var.client_id),r=n.connections.find(d=>d.strategy==="sms");if(!r)throw new N(500,{message:"SMS provider not found"});const i=((o=r.options)==null?void 0:o.provider)||"twilio",s=(c=t.env.smsProviders)==null?void 0:c[i];if(!s)throw new N(500,{message:"SMS provider not found"});await s({options:r.options,to:e.to,from:e.from,text:e.text,template:"auth-code",data:{code:e.code,tenantName:n.tenant.name,tenantId:n.tenant.id}})}async function dm(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=`${ct(t.env)}reset-password?state=${r}&code=${n}`,o={vendorName:i.name,lng:i.language||"en"};await Ri(t,{to:e,subject:re("reset_password_title",o),html:`Click here to reset your password: ${ct(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:re("password_reset_title",o),resetPasswordEmailClickToReset:re("reset_password_email_click_to_reset",o),resetPasswordEmailReset:re("reset_password_email_reset",o),supportInfo:re("support_info",o),contactUs:re("contact_us",o),copyright:re("copyright",o),tenantName:i.name,tenantId:i.id}})}async function lm(t,{to:e,code:n}){const r=await t.env.data.tenants.get(t.var.tenant_id);if(!r)throw new N(500,{message:"Tenant not found"});const{connection:i}=fi(e),s=new URL(ct(t.env)),o={vendorName:r.name,vendorId:r.id,loginDomain:s.hostname,code:n,lng:r.language||"en"};i==="email"?await Ri(t,{to:e,subject:re("code_email_subject",o),html:`Click here to validate your email: ${ct(t.env)}validate-email`,template:"auth-code",data:{code:n,vendorName:r.name,logo:r.logo||"",supportUrl:r.support_url||"",buttonColor:r.primary_color||"",welcomeToYourAccount:re("welcome_to_your_account",o),linkEmailClickToLogin:re("link_email_click_to_login",o),linkEmailLogin:re("link_email_login",o),linkEmailOrEnterCode:re("link_email_or_enter_code",o),codeValid30Mins:re("code_valid_30_minutes",o),supportInfo:re("support_info",o),contactUs:re("contact_us",o),copyright:re("copyright",o)}}):i==="sms"&&await cm(t,{to:e,text:re("sms_code_text",o),code:n,from:r.name});const c=we(t,{type:ge.CODE_LINK_SENT,description:e});It(t,t.env.data.logs.create(r.id,c))}async function Dl(t,{to:e,code:n,authParams: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{connection:s}=fi(e),o=new URL(je(t.env));o.pathname="passwordless/verify_redirect",o.searchParams.set("verification_code",n),o.searchParams.set("connection",s),o.searchParams.set("client_id",r.client_id),o.searchParams.set("redirect_uri",r.redirect_uri),o.searchParams.set("email",e),r.response_type&&o.searchParams.set("response_type",r.response_type),r.scope&&o.searchParams.set("scope",r.scope),r.state&&o.searchParams.set("state",r.state),r.nonce&&o.searchParams.set("nonce",r.nonce),r.code_challenge&&o.searchParams.set("code_challenge",r.code_challenge),r.code_challenge_method&&o.searchParams.set("code_challenge_method",r.code_challenge_method),r.audience&&o.searchParams.set("audience",r.audience);const c={vendorName:i.name,code:n,lng:i.language||"en"};if(s==="email")await Ri(t,{to:e,subject:re("code_email_subject",c),html:`Click here to validate your email: ${ct(t.env)}validate-email`,template:"auth-link",data:{code:n,vendorName:i.name,logo:i.logo||"",supportUrl:i.support_url||"",magicLink:o.toString(),buttonColor:i.primary_color||"",welcomeToYourAccount:re("welcome_to_your_account",c),linkEmailClickToLogin:re("link_email_click_to_login",c),linkEmailLogin:re("link_email_login",c),linkEmailOrEnterCode:re("link_email_or_enter_code",c),codeValid30Mins:re("code_valid_30_minutes",c),supportInfo:re("support_info",c),contactUs:re("contact_us",c),copyright:re("copyright",c)}});else if(s==="sms")await cm(t,{to:e,text:`${re("link_sms_login",c)}: ${o.toString()}`,code:n,from:i.name});else throw new N(400,{message:"Only email and SMS connections are supported for magic links"});const d=we(t,{type:ge.CODE_LINK_SENT,description:e});It(t,t.env.data.logs.create(i.id,d))}async function ql(t,e){const n=await t.env.data.tenants.get(t.var.tenant_id);if(!n)throw new N(500,{message:"Tenant not found"});if(!e.email)throw new N(400,{message:"User has no email"});const r={vendorName:n.name,lng:n.language||"en"};await Ri(t,{to:e.email,subject:re("welcome_to_your_account",r),html:`Click here to validate your email: ${ct(t.env)}validate-email`,template:"auth-verify-email",data:{vendorName:n.name,logo:n.logo||"",emailValidationUrl:`${ct(t.env)}validate-email`,supportUrl:n.support_url||"https://support.sesamy.com",buttonColor:n.primary_color||"#7d68f4",welcomeToYourAccount:re("welcome_to_your_account",r),verifyEmailVerify:re("verify_email_verify",r),supportInfo:re("support_info",r),contactUs:re("contact_us",r),copyright:re("copyright",r)}})}async function f4(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={vendorName:i.name,lng:i.language||"en"},o=`${ct(t.env)}signup?state=${r}&code=${n}`;await Ri(t,{to:e,subject:re("register_password_account",s),html:`Click here to register: ${o}`,template:"auth-pre-signup-verification",data:{vendorName:i.name,logo:i.logo||"",signupUrl:o,setPassword:re("set_password",s),registerPasswordAccount:re("register_password_account",s),clickToSignUpDescription:re("click_to_sign_up_description",s),supportUrl:i.support_url||"https://support.sesamy.com",buttonColor:i.primary_color||"#7d68f4",welcomeToYourAccount:re("welcome_to_your_account",s),verifyEmailVerify:re("verify_email_verify",s),supportInfo:re("support_info",s),contactUs:re("contact_us",s),copyright:re("copyright",s)}})}const p4=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().optional(),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),!Vl(n))throw new N(400,{message:"Password does not meet the requirements"});if(await xs({userAdapter:t.env.data.users,tenant_id:i.tenant.id,username: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|${go()}`,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 mi.hash(n,10);await t.env.data.passwords.create(i.tenant.id,{user_id:o.user_id,password:c,algorithm:"bcrypt"}),await ql(t,o);const d=we(t,{type:ge.SUCCESS_SIGNUP,description:"Successful signup"});return await t.env.data.logs.create(i.tenant.id,d),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 vr({userAdapter:t.env.data.users,tenant_id:r.tenant.id,username: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.loginSessions.create(r.tenant.id,{expires_at:new Date(Date.now()+or*1e3).toISOString(),authParams:s,csrf_token:xe(),...Ot(t.req)});return await dm(t,e,o.id,o.authParams.state),t.html("If an account with that email exists, we've sent instructions to reset your password.")});function Mn(){const t="1234567890";let e="";for(let n=0;n<6;n+=1)e+=t[Math.floor(Math.random()*10)];return e.toString()}const h4=new a.OpenAPIHono().openapi(a.createRoute({tags:["passwordless"],method:"post",path:"/start",request:{body:{content:{"application/json":{schema:a.z.union([a.z.object({connection:a.z.literal("email"),client_id:a.z.string(),email:a.z.string().transform(t=>t.toLowerCase()),send:a.z.enum(["link","code"]),authParams:Jr.omit({client_id:!0})}),a.z.object({client_id:a.z.string(),connection:a.z.literal("sms"),phone_number:a.z.string(),send:a.z.enum(["link","code"]),authParams:Jr.omit({client_id:!0})})])}}}},responses:{200:{description:"Status"}}}),async t=>{const e=t.req.valid("json"),{env:n}=t,{client_id:r,send:i,authParams:s,connection: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 d=o==="email"?e.email:e.phone_number,l=await n.data.loginSessions.create(c.tenant.id,{authParams:{...s,client_id:r,username:d},expires_at:new Date(Date.now()+Wa).toISOString(),csrf_token:xe(),...Ot(t.req)}),u=await n.data.codes.create(c.tenant.id,{code_id:Mn(),code_type:"otp",login_id:l.id,expires_at:new Date(Date.now()+Wa).toISOString()});return i==="link"?await Dl(t,{to:d,code:u.code_id,authParams:{...s,client_id:r}}):await lm(t,{to:d,code: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(Ct),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:d,response_type:l,nonce:u}=t.req.valid("query"),p=await Ti(e,n);return t.set("client_id",p.id),t.set("tenant_id",p.tenant.id),t.set("connection","email"),Ul(t,p,{client_id:n,redirect_uri:s,state:o,nonce:u,scope:c,audience:d,response_type:l},r,i,!1,!0)});class Lr extends N{constructor(n,r){super(n,r);te(this,"_code");this._code=r==null?void 0:r.code}get code(){return this._code}}async function Hl(t,e,n,r,i){const{env:s}=t,{username:o}=n;if(t.set("username",o),!o)throw new N(400,{message:"Username is required"});const c=await vr({userAdapter:t.env.data.users,tenant_id:e.tenant.id,username:o,provider:"auth2"});if(!c){const h=we(t,{type:ge.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid user"});throw It(t,t.env.data.logs.create(e.tenant.id,h)),new Lr(403,{message:"User not found",code:"USER_NOT_FOUND"})}const d=c.linked_to?await s.data.users.get(e.tenant.id,c.linked_to):c;if(!d)throw new Lr(403,{message:"User not found",code:"USER_NOT_FOUND"});t.set("connection",c.connection),t.set("user_id",d.user_id);const l=await s.data.passwords.get(e.tenant.id,c.user_id);if(!(l&&await mi.compare(n.password,l.password))){const h=we(t,{type:ge.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid password"});throw It(t,t.env.data.logs.create(e.tenant.id,h)),new Lr(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:${d.user_id}`})).logs.filter(h=>h.type===ge.FAILED_LOGIN_INCORRECT_PASSWORD&&new Date(h.date)>new Date(Date.now()-1e3*60*5)).length>=3){const h=we(t,{type:ge.FAILED_LOGIN,description:"Too many failed login attempts"});throw It(t,t.env.data.logs.create(e.tenant.id,h)),new Lr(403,{message:"Too many failed login attempts",code:"TOO_MANY_FAILED_LOGINS"})}if(!c.email_verified&&e.email_validation==="enforced"){await ql(t,c);const h=we(t,{type:ge.FAILED_LOGIN,description:"Email not verified"});throw await t.env.data.logs.create(e.tenant.id,h),new Lr(403,{message:"Email not verified",code:"EMAIL_NOT_VERIFIED"})}const w=we(t,{type:ge.SUCCESS_LOGIN,description:"Successful login",strategy_type:"Username-Password-Authentication",strategy:"Username-Password-Authentication"});return It(t,t.env.data.logs.create(e.tenant.id,w)),pn(t,{client:e,authParams:n,user:d,ticketAuth:i,loginSession:r})}async function g4(t,e,n,r){await bo(t,{client:e,username:n,provider:"auth2",connection:"Username-Password-Authentication",isSocial:!1,ip:t.req.header("x-real-ip")});let i=Mn(),s=await t.env.data.codes.get(e.tenant.id,i,"password_reset");for(;s;)i=Mn(),s=await t.env.data.codes.get(e.tenant.id,i,"password_reset");const o=await t.env.data.loginSessions.create(e.tenant.id,{expires_at:new Date(Date.now()+d_).toISOString(),authParams:{client_id:e.id,username:n},csrf_token:xe(),...Ot(t.req)}),c=await t.env.data.codes.create(e.tenant.id,{code_id:i,code_type:"password_reset",login_id:o.id,expires_at:new Date(Date.now()+c_).toISOString()});await dm(t,n,c.code_id,r)}const m4=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 Ul(t,i,{client_id:n,username:s},s,e.otp,!0);if("password"in e){const o=await t.env.data.loginSessions.create(i.tenant.id,{expires_at:new Date(Date.now()+or*1e3).toISOString(),authParams:{client_id:n,username:s},csrf_token:xe(),...Ot(t.req)});return Hl(t,i,{username:s,password:e.password,client_id:n},o,!0)}else throw new N(400,{message:"Code or password required"})});function _4(t,e){var r,i,s;if(!t||e.length===0)return!1;const n=((r=Ta(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=Ta(o))==null?void 0:i.host)??null:c=((s=Ta("https://"+o))==null?void 0:s.host)??null,n===c)return!0}return!1}function Ta(t){try{return new URL(t)}catch{return null}}async function y4({ctx:t,session:e,client:n,authParams:r,connection:i,login_hint:s}){const o=new URL(t.req.url);t.var.custom_domain&&(o.hostname=t.var.custom_domain);const{ip:c,useragent:d,auth0Client:l}=Ot(t.req),u=await t.env.data.loginSessions.create(n.tenant.id,{expires_at:new Date(Date.now()+or*1e3).toISOString(),authParams:r,csrf_token:xe(),authorization_url:o.toString(),ip:c,useragent:d,auth0Client:l});if(e&&s){const p=await t.env.data.users.get(n.tenant.id,e.user_id);if((p==null?void 0:p.email)===s)return pn(t,{client:n,loginSession:u,authParams:r,user:p,sessionId:e.id})}if(i==="email"&&s){const p=Mn();return await t.env.data.codes.create(n.tenant.id,{code_id:p,code_type:"otp",login_id:u.id,expires_at:new Date(Date.now()+or*1e3).toISOString()}),await Dl(t,{code:p,to:s,authParams:r}),t.redirect(`/u/enter-code?state=${u.id}`)}return e?t.redirect(`/u/check-account?state=${u.id}`):t.redirect(`/u/login/identifier?state=${u.id}`)}function w4(t){if(t==="Username-Password-Authentication")return"auth2";if(t==="email")return"email";throw new N(403,{message:"Invalid realm"})}async function v4(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.loginSessions.get(e,o.login_id);if(!c||!c.authParams.username)throw new N(403,{message:"Session not found"});const d=await s.data.clients.get(c.authParams.client_id);if(!d)throw new N(403,{message:"Client not found"});t.set("client_id",c.authParams.client_id),await s.data.codes.used(e,n);const l=w4(i);let u=await bo(t,{username:c.authParams.username,provider:l,client:d,connection:l==="auth2"?"Username-Password-Authentication":"email",isSocial:!1,ip:t.req.header("x-real-ip")});t.set("username",u.email||u.phone_number),t.set("user_id",u.user_id);const p=await G0(t,{user:u,client:d,loginSession:c});return pn(t,{authParams:{scope:(m=c.authParams)==null?void 0:m.scope,...r},loginSession:c,sessionId:p.id,user:u,client:d})}async function Vp(t,e){return`<!DOCTYPE html>
155
155
  <html>
156
156
 
157
157
  <head>
@@ -194,17 +194,17 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
194
194
  <\/script>
195
195
  </body>
196
196
 
197
- </html>`}async function b4({ctx:t,client:e,session:n,redirect_uri:r,state:i,nonce:s,code_challenge_method:o,code_challenge:c,audience:d,scope:l,response_type:u}){const{env:p}=t,m=new URL(r),w=`${m.protocol}//${m.host}`;async function h(oe="Login required"){const ae=we(t,{type:ge.FAILED_SILENT_AUTH,description:oe});return await t.env.data.logs.create(e.tenant.id,ae),t.html(Vp(w,JSON.stringify({error:"login_required",error_description:oe,state:i})))}if(!n||(n==null?void 0:n.expires_at)&&new Date(n.expires_at)<new Date||(n==null?void 0:n.idle_expires_at)&&new Date(n.idle_expires_at)<new Date)return h();t.set("user_id",n.user_id);const v=await p.data.users.get(e.tenant.id,n.user_id);if(!v)return console.error("User not found",n.user_id),h("User not found");t.set("username",v.email),t.set("connection",v.connection);const k={client:e,authParams:{client_id:e.id,audience:d,code_challenge_method:o,code_challenge:c,scope:l,state:i,nonce:s,response_type:u},user:v,session_id:n.id},I=u===Ct.CODE?await K0(t,k):await _o(t,k);await p.data.sessions.update(e.tenant.id,n.id,{used_at:new Date().toISOString(),last_interaction_at:new Date().toISOString(),device:{...n.device,last_ip:t.req.header("x-real-ip")||"",last_user_agent:t.req.header("user-agent")||""},idle_expires_at:n.idle_expires_at?new Date(Date.now()+go*1e3).toISOString():void 0});const O=we(t,{type:ge.SUCCESS_SILENT_AUTH,description:"Successful silent authentication"});await t.env.data.logs.create(e.tenant.id,O);const L=new Headers;L.set("Server-Timing","cf-nel=0; no-cloudflare-insights=1");const Y=L0(e.tenant.id,n.id,t.req.header("host"));return L.set("set-cookie",Y),t.html(Vp(w,JSON.stringify(I)),{headers:L})}const $4=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(Ft).optional(),response_type:a.z.nativeEnum(Ct).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(fo).optional(),code_challenge:a.z.string().optional(),realm:a.z.string().optional(),auth0Client:a.z.string().optional(),organization:a.z.string().optional(),login_hint:a.z.string().optional(),screen_hint:a.z.string().openapi({example:"signup",description:'Optional hint for the screen to show, like "signup" or "login".'}).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:d,connection:l,response_type:u,response_mode:p,code_challenge:m,code_challenge_method:w,prompt:h,login_ticket:_,realm:v,auth0Client:k,login_hint:I,ui_locales:O,organization:L}=t.req.valid("query");t.set("log","authorize");const Y=await ji(e,n);t.set("client_id",Y.id),t.set("tenant_id",Y.tenant.id);const oe={redirect_uri:i,scope:s,state:o,client_id:n,vendor_id:r,audience:c,nonce:d,prompt:h,response_type:u,response_mode:p,code_challenge:m,code_challenge_method:w,username:I,ui_locales:O,organization:L},ae=t.req.header("origin");if(ae&&!_4(ae,Y.web_origins||[]))throw new N(403,{message:`Origin ${ae} not allowed`});if(oe.redirect_uri&&!Zg(oe.redirect_uri,Y.callbacks||[],{allowPathWildcards:!0}))throw new N(400,{message:`Invalid redirect URI - ${oe.redirect_uri}`});const ke=bs(Y.tenant.id,t.req.header("cookie")),Ee=ke?await e.data.sessions.get(Y.tenant.id,ke):void 0,ze=Ee&&!Ee.revoked_at?Ee:void 0;if(h=="none"){if(!u)throw new N(400,{message:"Missing response_type"});return b4({ctx:t,session:ze||void 0,redirect_uri:i,state:o,response_type:u,client:Y,nonce:d,code_challenge_method:w,code_challenge:m,audience:c,scope:s})}return l&&l!=="email"?Hv(t,Y,l,oe):_?v4(t,Y.tenant.id,_,oe,v):y4({ctx:t,client:Y,auth0Client:k,authParams:oe,session:ze||void 0,connection:l,login_hint:I})});function x4(t){const e=new a.OpenAPIHono;e.use(async(r,i)=>{const s=yo(r,t.dataAdapter),o=Ol(s,{defaultTtl:3e5,cacheEntities:["tenants","connections","clients"]});return r.env.data=Cl(r,o),i()}),e.use("/oauth/token",d0({origin:r=>r||"",allowHeaders:["Tenant-Id","Content-Type","Auth0-Client","Upgrade-Insecure-Requests"],allowMethods:["POST"],maxAge:600})),e.use(zl).use(Mg(e));const n=e.route("/v2/logout",Wv).route("/userinfo",Jv).route("/.well-known",Zv).route("/oauth/token",d4).route("/dbconnections",p4).route("/passwordless",h4).route("/co/authenticate",m4).route("/authorize",$4).route("/callback",Kv);return n.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Oauth API"},security:[{oauth2:["openid","email","profile"]}]}),Ug(n),n}var k4={Stringify:1,BeforeStream:2,Stream:3},_t=(t,e)=>{const n=new String(t);return n.isEscaped=!0,n.callbacks=e,n},S4=/[&<>'"]/,lm=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];sn(s,c),n=c[0]}}return _t(n,e)},sn=(t,e)=>{const n=t.search(S4);if(n===-1){e[0]+=t;return}let r,i,s=0;for(i=n;i<t.length;i++){switch(t.charCodeAt(i)){case 34:r="&quot;";break;case 39:r="&#39;";break;case 38:r="&amp;";break;case 60:r="&lt;";break;case 62:r="&gt;";break;default:continue}e[0]+=t.substring(s,i)+r,s=i+1}e[0]+=t.substring(s,i)},um=t=>{const e=t.callbacks;if(!(e!=null&&e.length))return t;const n=[t],r={};return e.forEach(i=>i({phase:k4.Stringify,buffer:n,context:r})),n[0]},fm=(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 d=s[o];if(typeof d=="string")sn(d,n);else if(typeof d=="number")n[0]+=d;else{if(typeof d=="boolean"||d===null||d===void 0)continue;if(typeof d=="object"&&d.isEscaped)if(d.callbacks)n.unshift("",d);else{const l=d.toString();l instanceof Promise?n.unshift("",l):n[0]+=l}else d instanceof Promise?n.unshift("",d):sn(d.toString(),n)}}}return n[0]+=t.at(-1),n.length===1?"callbacks"in n?_t(um(_t(n[0],n.callbacks))):_t(n[0]):lm(n,n.callbacks)},Kl=Symbol("RENDERER"),$d=Symbol("ERROR_HANDLER"),Ae=Symbol("STASH"),pm=Symbol("INTERNAL"),A4=Symbol("MEMO"),ao=Symbol("PERMALINK"),Dp=t=>(t[pm]=!0,t),hm=t=>({value:e,children:n})=>{if(!n)return;const r={children:[{tag:Dp(()=>{t.push(e)}),props:{}}]};Array.isArray(n)?r.children.push(...n.flat()):r.children.push(n),r.children.push({tag:Dp(()=>{t.pop()}),props:{}});const i={tag:"",props:r,type:""};return i[$d]=s=>{throw t.pop(),s},i},gm=t=>{const e=[t],n=hm(e);return n.values=e,n.Provider=n,yr.push(n),n},yr=[],E4=t=>{const e=[t],n=r=>{e.push(r.value);let i;try{i=r.children?(Array.isArray(r.children)?new wm("",{},r.children):r.children).toString():""}finally{e.pop()}return i instanceof Promise?i.then(s=>_t(s,s.callbacks)):_t(i)};return n.values=e,n.Provider=n,n[Kl]=hm(e),yr.push(n),n},Or=t=>t.values.at(-1),rs={title:[],script:["src"],style:["data-href"],link:["href"],meta:["name","httpEquiv","charset","itemProp"]},xd={},is="data-precedence",Ri=t=>Array.isArray(t)?t:[t],qp=new WeakMap,Hp=(t,e,n,r)=>({buffer:i,context:s})=>{if(!i)return;const o=qp.get(s)||{};qp.set(s,o);const c=o[t]||(o[t]=[]);let d=!1;const l=rs[t];if(l.length>0){e:for(const[,u]of c)for(const p of l)if(((u==null?void 0:u[p])??null)===(n==null?void 0:n[p])){d=!0;break e}}if(d?i[0]=i[0].replaceAll(e,""):l.length>0?c.push([e,n,r]):c.unshift([e,n,r]),i[0].indexOf("</head>")!==-1){let u;if(r===void 0)u=c.map(([p])=>p);else{const p=[];u=c.map(([m,,w])=>{let h=p.indexOf(w);return h===-1&&(p.push(w),h=p.length-1),[m,h]}).sort((m,w)=>m[1]-w[1]).map(([m])=>m)}u.forEach(p=>{i[0]=i[0].replaceAll(p,"")}),i[0]=i[0].replace(/(?=<\/head>)/,u.join(""))}},Bi=(t,e,n)=>_t(new yt(t,n,Ri(e??[])).toString()),Li=(t,e,n,r)=>{if("itemProp"in n)return Bi(t,e,n);let{precedence:i,blocking:s,...o}=n;i=r?i??"":void 0,r&&(o[is]=i);const c=new yt(t,o,Ri(e||[])).toString();return c instanceof Promise?c.then(d=>_t(c,[...d.callbacks||[],Hp(t,d,o,i)])):_t(c,[Hp(t,c,o,i)])},I4=({children:t,...e})=>{const n=Gl();if(n){const r=Or(n);if(r==="svg"||r==="head")return new yt("title",e,Ri(t??[]))}return Li("title",t,e,!1)},N4=({children:t,...e})=>{const n=Gl();return["src","async"].some(r=>!e[r])||n&&Or(n)==="head"?Bi("script",t,e):Li("script",t,e,!1)},C4=({children:t,...e})=>["href","precedence"].every(n=>n in e)?(e["data-href"]=e.href,delete e.href,Li("style",t,e,!0)):Bi("style",t,e),z4=({children:t,...e})=>["onLoad","onError"].some(n=>n in e)||e.rel==="stylesheet"&&(!("precedence"in e)||"disabled"in e)?Bi("link",t,e):Li("link",t,e,"precedence"in e),O4=({children:t,...e})=>{const n=Gl();return n&&Or(n)==="head"?Bi("meta",t,e):Li("meta",t,e,!1)},mm=(t,{children:e,...n})=>new yt(t,n,Ri(e??[])),P4=t=>(typeof t.action=="function"&&(t.action=ao in t.action?t.action[ao]:void 0),mm("form",t)),_m=(t,e)=>(typeof e.formAction=="function"&&(e.formAction=ao in e.formAction?e.formAction[ao]:void 0),mm(t,e)),j4=t=>_m("input",t),T4=t=>_m("button",t);const Ra=Object.freeze(Object.defineProperty({__proto__:null,button:T4,form:P4,input:j4,link:z4,meta:O4,script:N4,style:C4,title:I4},Symbol.toStringTag,{value:"Module"}));var R4=new Map([["className","class"],["htmlFor","for"],["crossOrigin","crossorigin"],["httpEquiv","http-equiv"],["itemProp","itemprop"],["fetchPriority","fetchpriority"],["noModule","nomodule"],["formAction","formaction"]]),co=t=>R4.get(t)||t,ym=(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)}},fi=void 0,Gl=()=>fi,B4=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,L4=["area","base","br","col","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],U4=["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"],Wl=(t,e)=>{for(let n=0,r=t.length;n<r;n++){const i=t[n];if(typeof i=="string")sn(i,e);else{if(typeof i=="boolean"||i===null||i===void 0)continue;i instanceof yt?i.toStringToBuffer(e):typeof i=="number"||i.isEscaped?e[0]+=i:i instanceof Promise?e.unshift("",i):Wl(i,e)}}},yt=class{constructor(t,e,n){te(this,"tag");te(this,"props");te(this,"key");te(this,"children");te(this,"isEscaped",!0);te(this,"localContexts");this.tag=t,this.props=e,this.children=n}get type(){return this.tag}get ref(){return this.props.ref||null}toString(){var e,n;const t=[""];(e=this.localContexts)==null||e.forEach(([r,i])=>{r.values.push(i)});try{this.toStringToBuffer(t)}finally{(n=this.localContexts)==null||n.forEach(([r])=>{r.values.pop()})}return t.length===1?"callbacks"in t?um(_t(t[0],t.callbacks)).toString():t[0]:lm(t,t.callbacks)}toStringToBuffer(t){const e=this.tag,n=this.props;let{children:r}=this;t[0]+=`<${e}`;const i=fi&&Or(fi)==="svg"?s=>B4(co(s)):s=>co(s);for(let[s,o]of Object.entries(n))if(s=i(s),s!=="children"){if(s==="style"&&typeof o=="object"){let c="";ym(o,(d,l)=>{l!=null&&(c+=`${c?";":""}${d}:${l}`)}),t[0]+=' style="',sn(c,t),t[0]+='"'}else if(typeof o=="string")t[0]+=` ${s}="`,sn(o,t),t[0]+='"';else if(o!=null)if(typeof o=="number"||o.isEscaped)t[0]+=` ${s}="${o}"`;else if(typeof o=="boolean"&&U4.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=[_t(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}="`,sn(o.toString(),t),t[0]+='"'}if(L4.includes(e)&&r.length===0){t[0]+="/>";return}t[0]+=">",Wl(r,t),t[0]+=`</${e}>`}},Ba=class extends yt{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(yr.length===0)t.unshift("",n);else{const r=yr.map(i=>[i,i.values.at(-1)]);t.unshift("",n.then(i=>(i instanceof yt&&(i.localContexts=r),i)))}else n instanceof yt?n.toStringToBuffer(t):typeof n=="number"||n.isEscaped?(t[0]+=n,n.callbacks&&(t.callbacks||(t.callbacks=[]),t.callbacks.push(...n.callbacks))):sn(n,t)}},wm=class extends yt{toStringToBuffer(t){Wl(this.children,t)}},M4=(t,e,...n)=>{e??(e={}),n.length&&(e.children=n.length===1?n[0]:n);const r=e.key;delete e.key;const i=ss(t,e,n);return i.key=r,i},Kp=!1,ss=(t,e,n)=>{if(!Kp){for(const r in xd)Ra[r][Kl]=xd[r];Kp=!0}return typeof t=="function"?new Ba(t,e,n):Ra[t]?new Ba(Ra[t],e,n):t==="svg"||t==="head"?(fi||(fi=E4("")),new yt(t,e,[new Ba(fi,{value:t},n)])):new yt(t,e,n)},vm=({children:t})=>new wm("",{children:t},Array.isArray(t)?t:t?[t]:[]),F4=(t,e,...n)=>M4(t.tag,{...t.props,...e},...n);function y(t,e,n){let r;if(!e||!("children"in e))r=ss(t,e,[]);else{const i=e.children;r=Array.isArray(i)?ss(t,e,i):ss(t,e,[i])}return r.key=n,r}const Gp={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 Jl(t,e,n){if(!n&&!e)return Gp;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 h0.parse(s)}catch(i){return console.error(i),Gp}}async function Ne(t,e,n=!1){var l;const{env:r}=t,i=await r.data.loginSessions.get(t.var.tenant_id||"",e);if(i)i.session_id;else throw new N(400,{message:"Login session not found"});t.set("loginSession",i);const s=await ji(r,i.authParams.client_id);t.set("client_id",s.id),t.set("tenant_id",s.tenant.id);const o=await r.data.tenants.get(s.tenant.id);if(o){if(i.session_id&&!n)throw new N(400,{message:"Login session closed"})}else throw new N(400,{message:"Tenant not found"});const c=await Jl(r,s.id,i.authParams.vendor_id),d=(l=i.authParams.ui_locales)==null?void 0:l.split(" ").map(u=>u.split("-")[0]).find(u=>{if(Array.isArray(T.options.supportedLngs))return T.options.supportedLngs.includes(u)});return await T.changeLanguage(d||o.language||"sv"),{vendorSettings:{...c,termsAndConditionsUrl:s.id==="fokus-app"?"https://www.fokus.se/kopvillkor-app/":c.termsAndConditionsUrl},client:s,tenant:o,loginSession:i}}async function V4(t,e,n,r){if(r!==void 0)return r==="password";const i=await wo({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:${ge.SUCCESS_LOGIN} user_id:${i.user_id}`}),[c]=o.logs.filter(d=>d.strategy&&["Username-Password-Authentication","passwordless","email"].includes(d.strategy));if(c)return c.strategy==="Username-Password-Authentication"}return(await t.env.data.promptSettings.get(e.tenant.id)).password_first}const bm=({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(vm,{}),$m=({vendorSettings:t})=>{const{termsAndConditionsUrl:e}=t;return y("div",{className:"mt-8",children:e&&y("div",{className:"text-xs text-gray-300",children:[T.t("agree_to")," ",y("a",{href:e,className:"text-primary hover:underline",target:"_blank",rel:"noreferrer",children:T.t("terms")})]})})};var xm={exports:{}};/*!
197
+ </html>`}async function b4({ctx:t,client:e,session:n,redirect_uri:r,state:i,nonce:s,code_challenge_method:o,code_challenge:c,audience:d,scope:l,response_type:u}){const{env:p}=t,m=new URL(r),w=`${m.protocol}//${m.host}`;async function h(oe="Login required"){const ae=we(t,{type:ge.FAILED_SILENT_AUTH,description:oe});return await t.env.data.logs.create(e.tenant.id,ae),t.html(Vp(w,JSON.stringify({error:"login_required",error_description:oe,state:i})))}if(!n||(n==null?void 0:n.expires_at)&&new Date(n.expires_at)<new Date||(n==null?void 0:n.idle_expires_at)&&new Date(n.idle_expires_at)<new Date)return h();t.set("user_id",n.user_id);const v=await p.data.users.get(e.tenant.id,n.user_id);if(!v)return console.error("User not found",n.user_id),h("User not found");t.set("username",v.email),t.set("connection",v.connection);const k={client:e,authParams:{client_id:e.id,audience:d,code_challenge_method:o,code_challenge:c,scope:l,state:i,nonce:s,response_type:u},user:v,session_id:n.id},I=u===Ct.CODE?await K0(t,k):await yo(t,k);await p.data.sessions.update(e.tenant.id,n.id,{used_at:new Date().toISOString(),last_interaction_at:new Date().toISOString(),device:{...n.device,last_ip:t.req.header("x-real-ip")||"",last_user_agent:t.req.header("user-agent")||""},idle_expires_at:n.idle_expires_at?new Date(Date.now()+mo*1e3).toISOString():void 0});const O=we(t,{type:ge.SUCCESS_SILENT_AUTH,description:"Successful silent authentication"});await t.env.data.logs.create(e.tenant.id,O);const L=new Headers;L.set("Server-Timing","cf-nel=0; no-cloudflare-insights=1");const Y=L0(e.tenant.id,n.id,t.req.header("host"));return L.set("set-cookie",Y),t.html(Vp(w,JSON.stringify(I)),{headers:L})}const $4=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(Ft).optional(),response_type:a.z.nativeEnum(Ct).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(po).optional(),code_challenge:a.z.string().optional(),realm:a.z.string().optional(),auth0Client:a.z.string().optional(),organization:a.z.string().optional(),login_hint:a.z.string().optional(),screen_hint:a.z.string().openapi({example:"signup",description:'Optional hint for the screen to show, like "signup" or "login".'}).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:d,connection:l,response_type:u,response_mode:p,code_challenge:m,code_challenge_method:w,prompt:h,login_ticket:_,realm:v,auth0Client:k,login_hint:I,ui_locales:O,organization:L}=t.req.valid("query");t.set("log","authorize");const Y=await Ti(e,n);t.set("client_id",Y.id),t.set("tenant_id",Y.tenant.id);const oe={redirect_uri:i,scope:s,state:o,client_id:n,vendor_id:r,audience:c,nonce:d,prompt:h,response_type:u,response_mode:p,code_challenge:m,code_challenge_method:w,username:I,ui_locales:O,organization:L},ae=t.req.header("origin");if(ae&&!_4(ae,Y.web_origins||[]))throw new N(403,{message:`Origin ${ae} not allowed`});if(oe.redirect_uri&&!Zg(oe.redirect_uri,Y.callbacks||[],{allowPathWildcards:!0}))throw new N(400,{message:`Invalid redirect URI - ${oe.redirect_uri}`});const ke=$s(Y.tenant.id,t.req.header("cookie")),Ee=ke?await e.data.sessions.get(Y.tenant.id,ke):void 0,ze=Ee&&!Ee.revoked_at?Ee:void 0;if(h=="none"){if(!u)throw new N(400,{message:"Missing response_type"});return b4({ctx:t,session:ze||void 0,redirect_uri:i,state:o,response_type:u,client:Y,nonce:d,code_challenge_method:w,code_challenge:m,audience:c,scope:s})}return l&&l!=="email"?Kv(t,Y,l,oe):_?v4(t,Y.tenant.id,_,oe,v):y4({ctx:t,client:Y,auth0Client:k,authParams:oe,session:ze||void 0,connection:l,login_hint:I})});function x4(t){const e=new a.OpenAPIHono;e.use(async(r,i)=>{const s=wo(r,t.dataAdapter),o=Ol(s,{defaultTtl:3e5,cacheEntities:["tenants","connections","clients"]});return r.env.data=Cl(r,o),i()}),e.use("/oauth/token",d0({origin:r=>r||"",allowHeaders:["Tenant-Id","Content-Type","Auth0-Client","Upgrade-Insecure-Requests"],allowMethods:["POST"],maxAge:600})),e.use(zl).use(Mg(e));const n=e.route("/v2/logout",Jv).route("/userinfo",Zv).route("/.well-known",Xv).route("/oauth/token",l4).route("/dbconnections",p4).route("/passwordless",h4).route("/co/authenticate",m4).route("/authorize",$4).route("/callback",Gv);return n.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Oauth API"},security:[{oauth2:["openid","email","profile"]}]}),Ug(n),n}var k4={Stringify:1,BeforeStream:2,Stream:3},_t=(t,e)=>{const n=new String(t);return n.isEscaped=!0,n.callbacks=e,n},S4=/[&<>'"]/,um=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];sn(s,c),n=c[0]}}return _t(n,e)},sn=(t,e)=>{const n=t.search(S4);if(n===-1){e[0]+=t;return}let r,i,s=0;for(i=n;i<t.length;i++){switch(t.charCodeAt(i)){case 34:r="&quot;";break;case 39:r="&#39;";break;case 38:r="&amp;";break;case 60:r="&lt;";break;case 62:r="&gt;";break;default:continue}e[0]+=t.substring(s,i)+r,s=i+1}e[0]+=t.substring(s,i)},fm=t=>{const e=t.callbacks;if(!(e!=null&&e.length))return t;const n=[t],r={};return e.forEach(i=>i({phase:k4.Stringify,buffer:n,context:r})),n[0]},pm=(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 d=s[o];if(typeof d=="string")sn(d,n);else if(typeof d=="number")n[0]+=d;else{if(typeof d=="boolean"||d===null||d===void 0)continue;if(typeof d=="object"&&d.isEscaped)if(d.callbacks)n.unshift("",d);else{const l=d.toString();l instanceof Promise?n.unshift("",l):n[0]+=l}else d instanceof Promise?n.unshift("",d):sn(d.toString(),n)}}}return n[0]+=t.at(-1),n.length===1?"callbacks"in n?_t(fm(_t(n[0],n.callbacks))):_t(n[0]):um(n,n.callbacks)},Kl=Symbol("RENDERER"),$d=Symbol("ERROR_HANDLER"),Ae=Symbol("STASH"),hm=Symbol("INTERNAL"),A4=Symbol("MEMO"),co=Symbol("PERMALINK"),Dp=t=>(t[hm]=!0,t),gm=t=>({value:e,children:n})=>{if(!n)return;const r={children:[{tag:Dp(()=>{t.push(e)}),props:{}}]};Array.isArray(n)?r.children.push(...n.flat()):r.children.push(n),r.children.push({tag:Dp(()=>{t.pop()}),props:{}});const i={tag:"",props:r,type:""};return i[$d]=s=>{throw t.pop(),s},i},mm=t=>{const e=[t],n=gm(e);return n.values=e,n.Provider=n,yr.push(n),n},yr=[],E4=t=>{const e=[t],n=r=>{e.push(r.value);let i;try{i=r.children?(Array.isArray(r.children)?new vm("",{},r.children):r.children).toString():""}finally{e.pop()}return i instanceof Promise?i.then(s=>_t(s,s.callbacks)):_t(i)};return n.values=e,n.Provider=n,n[Kl]=gm(e),yr.push(n),n},Or=t=>t.values.at(-1),is={title:[],script:["src"],style:["data-href"],link:["href"],meta:["name","httpEquiv","charset","itemProp"]},xd={},ss="data-precedence",Bi=t=>Array.isArray(t)?t:[t],qp=new WeakMap,Hp=(t,e,n,r)=>({buffer:i,context:s})=>{if(!i)return;const o=qp.get(s)||{};qp.set(s,o);const c=o[t]||(o[t]=[]);let d=!1;const l=is[t];if(l.length>0){e:for(const[,u]of c)for(const p of l)if(((u==null?void 0:u[p])??null)===(n==null?void 0:n[p])){d=!0;break e}}if(d?i[0]=i[0].replaceAll(e,""):l.length>0?c.push([e,n,r]):c.unshift([e,n,r]),i[0].indexOf("</head>")!==-1){let u;if(r===void 0)u=c.map(([p])=>p);else{const p=[];u=c.map(([m,,w])=>{let h=p.indexOf(w);return h===-1&&(p.push(w),h=p.length-1),[m,h]}).sort((m,w)=>m[1]-w[1]).map(([m])=>m)}u.forEach(p=>{i[0]=i[0].replaceAll(p,"")}),i[0]=i[0].replace(/(?=<\/head>)/,u.join(""))}},Li=(t,e,n)=>_t(new yt(t,n,Bi(e??[])).toString()),Ui=(t,e,n,r)=>{if("itemProp"in n)return Li(t,e,n);let{precedence:i,blocking:s,...o}=n;i=r?i??"":void 0,r&&(o[ss]=i);const c=new yt(t,o,Bi(e||[])).toString();return c instanceof Promise?c.then(d=>_t(c,[...d.callbacks||[],Hp(t,d,o,i)])):_t(c,[Hp(t,c,o,i)])},I4=({children:t,...e})=>{const n=Gl();if(n){const r=Or(n);if(r==="svg"||r==="head")return new yt("title",e,Bi(t??[]))}return Ui("title",t,e,!1)},N4=({children:t,...e})=>{const n=Gl();return["src","async"].some(r=>!e[r])||n&&Or(n)==="head"?Li("script",t,e):Ui("script",t,e,!1)},C4=({children:t,...e})=>["href","precedence"].every(n=>n in e)?(e["data-href"]=e.href,delete e.href,Ui("style",t,e,!0)):Li("style",t,e),z4=({children:t,...e})=>["onLoad","onError"].some(n=>n in e)||e.rel==="stylesheet"&&(!("precedence"in e)||"disabled"in e)?Li("link",t,e):Ui("link",t,e,"precedence"in e),O4=({children:t,...e})=>{const n=Gl();return n&&Or(n)==="head"?Li("meta",t,e):Ui("meta",t,e,!1)},_m=(t,{children:e,...n})=>new yt(t,n,Bi(e??[])),P4=t=>(typeof t.action=="function"&&(t.action=co in t.action?t.action[co]:void 0),_m("form",t)),ym=(t,e)=>(typeof e.formAction=="function"&&(e.formAction=co in e.formAction?e.formAction[co]:void 0),_m(t,e)),j4=t=>ym("input",t),T4=t=>ym("button",t);const Ra=Object.freeze(Object.defineProperty({__proto__:null,button:T4,form:P4,input:j4,link:z4,meta:O4,script:N4,style:C4,title:I4},Symbol.toStringTag,{value:"Module"}));var R4=new Map([["className","class"],["htmlFor","for"],["crossOrigin","crossorigin"],["httpEquiv","http-equiv"],["itemProp","itemprop"],["fetchPriority","fetchpriority"],["noModule","nomodule"],["formAction","formaction"]]),lo=t=>R4.get(t)||t,wm=(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)}},pi=void 0,Gl=()=>pi,B4=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,L4=["area","base","br","col","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],U4=["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"],Wl=(t,e)=>{for(let n=0,r=t.length;n<r;n++){const i=t[n];if(typeof i=="string")sn(i,e);else{if(typeof i=="boolean"||i===null||i===void 0)continue;i instanceof yt?i.toStringToBuffer(e):typeof i=="number"||i.isEscaped?e[0]+=i:i instanceof Promise?e.unshift("",i):Wl(i,e)}}},yt=class{constructor(t,e,n){te(this,"tag");te(this,"props");te(this,"key");te(this,"children");te(this,"isEscaped",!0);te(this,"localContexts");this.tag=t,this.props=e,this.children=n}get type(){return this.tag}get ref(){return this.props.ref||null}toString(){var e,n;const t=[""];(e=this.localContexts)==null||e.forEach(([r,i])=>{r.values.push(i)});try{this.toStringToBuffer(t)}finally{(n=this.localContexts)==null||n.forEach(([r])=>{r.values.pop()})}return t.length===1?"callbacks"in t?fm(_t(t[0],t.callbacks)).toString():t[0]:um(t,t.callbacks)}toStringToBuffer(t){const e=this.tag,n=this.props;let{children:r}=this;t[0]+=`<${e}`;const i=pi&&Or(pi)==="svg"?s=>B4(lo(s)):s=>lo(s);for(let[s,o]of Object.entries(n))if(s=i(s),s!=="children"){if(s==="style"&&typeof o=="object"){let c="";wm(o,(d,l)=>{l!=null&&(c+=`${c?";":""}${d}:${l}`)}),t[0]+=' style="',sn(c,t),t[0]+='"'}else if(typeof o=="string")t[0]+=` ${s}="`,sn(o,t),t[0]+='"';else if(o!=null)if(typeof o=="number"||o.isEscaped)t[0]+=` ${s}="${o}"`;else if(typeof o=="boolean"&&U4.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=[_t(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}="`,sn(o.toString(),t),t[0]+='"'}if(L4.includes(e)&&r.length===0){t[0]+="/>";return}t[0]+=">",Wl(r,t),t[0]+=`</${e}>`}},Ba=class extends yt{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(yr.length===0)t.unshift("",n);else{const r=yr.map(i=>[i,i.values.at(-1)]);t.unshift("",n.then(i=>(i instanceof yt&&(i.localContexts=r),i)))}else n instanceof yt?n.toStringToBuffer(t):typeof n=="number"||n.isEscaped?(t[0]+=n,n.callbacks&&(t.callbacks||(t.callbacks=[]),t.callbacks.push(...n.callbacks))):sn(n,t)}},vm=class extends yt{toStringToBuffer(t){Wl(this.children,t)}},M4=(t,e,...n)=>{e??(e={}),n.length&&(e.children=n.length===1?n[0]:n);const r=e.key;delete e.key;const i=os(t,e,n);return i.key=r,i},Kp=!1,os=(t,e,n)=>{if(!Kp){for(const r in xd)Ra[r][Kl]=xd[r];Kp=!0}return typeof t=="function"?new Ba(t,e,n):Ra[t]?new Ba(Ra[t],e,n):t==="svg"||t==="head"?(pi||(pi=E4("")),new yt(t,e,[new Ba(pi,{value:t},n)])):new yt(t,e,n)},bm=({children:t})=>new vm("",{children:t},Array.isArray(t)?t:t?[t]:[]),F4=(t,e,...n)=>M4(t.tag,{...t.props,...e},...n);function y(t,e,n){let r;if(!e||!("children"in e))r=os(t,e,[]);else{const i=e.children;r=Array.isArray(i)?os(t,e,i):os(t,e,[i])}return r.key=n,r}const Gp={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 Jl(t,e,n){if(!n&&!e)return Gp;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 h0.parse(s)}catch(i){return console.error(i),Gp}}async function Ne(t,e,n=!1){var l;const{env:r}=t,i=await r.data.loginSessions.get(t.var.tenant_id||"",e);if(i)i.session_id;else throw new N(400,{message:"Login session not found"});t.set("loginSession",i);const s=await Ti(r,i.authParams.client_id);t.set("client_id",s.id),t.set("tenant_id",s.tenant.id);const o=await r.data.tenants.get(s.tenant.id);if(o){if(i.session_id&&!n)throw new N(400,{message:"Login session closed"})}else throw new N(400,{message:"Tenant not found"});const c=await Jl(r,s.id,i.authParams.vendor_id),d=(l=i.authParams.ui_locales)==null?void 0:l.split(" ").map(u=>u.split("-")[0]).find(u=>{if(Array.isArray(T.options.supportedLngs))return T.options.supportedLngs.includes(u)});return await T.changeLanguage(d||o.language||"sv"),{vendorSettings:{...c,termsAndConditionsUrl:s.id==="fokus-app"?"https://www.fokus.se/kopvillkor-app/":c.termsAndConditionsUrl},client:s,tenant:o,loginSession:i}}async function V4(t,e,n,r){if(r!==void 0)return r==="password";const i=await vo({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:${ge.SUCCESS_LOGIN} user_id:${i.user_id}`}),[c]=o.logs.filter(d=>d.strategy&&["Username-Password-Authentication","passwordless","email"].includes(d.strategy));if(c)return c.strategy==="Username-Password-Authentication"}return(await t.env.data.promptSettings.get(e.tenant.id)).password_first}const $m=({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(bm,{}),xm=({vendorSettings:t})=>{const{termsAndConditionsUrl:e}=t;return y("div",{className:"mt-8",children:e&&y("div",{className:"text-xs text-gray-300",children:[T.t("agree_to")," ",y("a",{href:e,className:"text-primary hover:underline",target:"_blank",rel:"noreferrer",children:T.t("terms")})]})})};var km={exports:{}};/*!
198
198
  Copyright (c) 2018 Jed Watson.
199
199
  Licensed under the MIT License (MIT), see
200
200
  http://jedwatson.github.io/classnames
201
- */(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})()})(xm);var D4=xm.exports;const ln=z0(D4),q4=t=>t==="small"?"text-base":t==="medium"?"text-2xl":t==="large"?"text-3xl":"",Je=({name:t,size:e,className:n=""})=>{const r=q4(e);return y("span",{className:ln(`uicon-${t}`,n,r)})};var Wp=Object.freeze,H4=Object.defineProperty,K4=(t,e)=>Wp(H4(t,"raw",{value:Wp(t.slice())})),Jp;const G4=t=>{const{style:e}=t;return`
201
+ */(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})()})(km);var D4=km.exports;const ln=z0(D4),q4=t=>t==="small"?"text-base":t==="medium"?"text-2xl":t==="large"?"text-3xl":"",Je=({name:t,size:e,className:n=""})=>{const r=q4(e);return y("span",{className:ln(`uicon-${t}`,n,r)})};var Wp=Object.freeze,H4=Object.defineProperty,K4=(t,e)=>Wp(H4(t,"raw",{value:Wp(t.slice())})),Jp;const G4=t=>{const{style:e}=t;return`
202
202
  body {
203
203
  --primary-color: ${e.primaryColor};
204
204
  --primary-hover: ${e.primaryHoverColor};
205
205
  --text-on-primary: ${e.buttonTextColor};
206
206
  }
207
- `},W4="https://assets.sesamy.com/images/login-bg.jpg",Fe=({title:t,children:e,vendorSettings:n})=>{const r={backgroundImage:`url(${(n==null?void 0:n.loginBackgroundImage)||W4})`};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:"/u/css/tailwind.css"}),y("meta",{name:"viewport",content:"width=device-width, initial-scale=1, maximum-scale=1"}),y("style",{children:G4(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(bm,{vendorSettings:n})}),y("div",{className:"flex flex-1 flex-col",children:[e,y($m,{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(Je,{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:T.t("contact_support")})})]})]})})})}),fm(Jp||(Jp=K4([`
207
+ `},W4="https://assets.sesamy.com/images/login-bg.jpg",Fe=({title:t,children:e,vendorSettings:n})=>{const r={backgroundImage:`url(${(n==null?void 0:n.loginBackgroundImage)||W4})`};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:"/u/css/tailwind.css"}),y("meta",{name:"viewport",content:"width=device-width, initial-scale=1, maximum-scale=1"}),y("style",{children:G4(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($m,{vendorSettings:n})}),y("div",{className:"flex flex-1 flex-col",children:[e,y(xm,{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(Je,{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:T.t("contact_support")})})]})]})})})}),pm(Jp||(Jp=K4([`
208
208
  <script>
209
209
  // Add loading class to submit button on form submission
210
210
  var form = document.getElementById("form");
@@ -219,9 +219,9 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
219
219
  }
220
220
  });
221
221
  <\/script>
222
- `])))]})},qn=({children:t})=>y("div",{className:"mb-2 text-sm text-red",children:t}),J4=t=>t==="small"?"text-base":t==="medium"?"text-2xl":t==="large"?"text-3xl":"",km=({size:t})=>{const e=J4(t);return y("div",{className:"relative inline-block leading-[0]",children:[y(Je,{className:ln("text-gray-200 dark:text-[#201a41]",{[e]:e}),name:"spinner-circle"}),y(Je,{className:ln("absolute inset-0 animate-spin text-primary",{[e]:e}),name:"spinner-inner"})]})},Xe=({children:t,className:e,Component:n="button",variant:r="primary",href:i,disabled:s,isLoading:o,id:c})=>{const d=n==="a"?{href:i}:{};return y(n,{class:ln("btn relative w-full rounded-lg text-center",{"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,"is-loading":o},"focus:outline-none focus:ring",e),type:"submit",disabled:s,id:c,...d,children:[y("span",{className:"btn-label flex items-center justify-center space-x-2",children:t}),y("div",{className:"btn-spinner absolute left-0 top-0 flex h-full w-full items-center justify-center",children:y(km,{size:"medium"})})]})},Ur=({connection:t,text:e,icon:n=null,canResize:r=!1,loginSession:i})=>{const s=new URLSearchParams({client_id:i.authParams.client_id,connection:t});i.authParams.response_type&&s.set("response_type",i.authParams.response_type),i.authParams.redirect_uri&&s.set("redirect_uri",i.authParams.redirect_uri),i.authParams.scope&&s.set("scope",i.authParams.scope),i.authParams.nonce&&s.set("nonce",i.authParams.nonce),i.authParams.response_type&&s.set("response_type",i.authParams.response_type),i.authParams.state&&s.set("state",i.id);const o=`/authorize?${s.toString()}`;return y(Xe,{className:ln("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:ln("text-left text-black dark:text-white sm:text-base",{"hidden sm:inline short:hidden":r}),children:e})]})},Sm=({...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"})]}),Xt=({children:t,className:e})=>y("form",{id:"form",method:"post",className:e,children:t}),Am=({...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
222
+ `])))]})},qn=({children:t})=>y("div",{className:"mb-2 text-sm text-red",children:t}),J4=t=>t==="small"?"text-base":t==="medium"?"text-2xl":t==="large"?"text-3xl":"",Sm=({size:t})=>{const e=J4(t);return y("div",{className:"relative inline-block leading-[0]",children:[y(Je,{className:ln("text-gray-200 dark:text-[#201a41]",{[e]:e}),name:"spinner-circle"}),y(Je,{className:ln("absolute inset-0 animate-spin text-primary",{[e]:e}),name:"spinner-inner"})]})},Xe=({children:t,className:e,Component:n="button",variant:r="primary",href:i,disabled:s,isLoading:o,id:c})=>{const d=n==="a"?{href:i}:{};return y(n,{class:ln("btn relative w-full rounded-lg text-center",{"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,"is-loading":o},"focus:outline-none focus:ring",e),type:"submit",disabled:s,id:c,...d,children:[y("span",{className:"btn-label flex items-center justify-center space-x-2",children:t}),y("div",{className:"btn-spinner absolute left-0 top-0 flex h-full w-full items-center justify-center",children:y(Sm,{size:"medium"})})]})},Ur=({connection:t,text:e,icon:n=null,canResize:r=!1,loginSession:i})=>{const s=new URLSearchParams({client_id:i.authParams.client_id,connection:t});i.authParams.response_type&&s.set("response_type",i.authParams.response_type),i.authParams.redirect_uri&&s.set("redirect_uri",i.authParams.redirect_uri),i.authParams.scope&&s.set("scope",i.authParams.scope),i.authParams.nonce&&s.set("nonce",i.authParams.nonce),i.authParams.response_type&&s.set("response_type",i.authParams.response_type),i.authParams.state&&s.set("state",i.id);const o=`/authorize?${s.toString()}`;return y(Xe,{className:ln("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:ln("text-left text-black dark:text-white sm:text-base",{"hidden sm:inline short:hidden":r}),children:e})]})},Am=({...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"})]}),Xt=({children:t,className:e})=>y("form",{id:"form",method:"post",className:e,children:t}),Em=({...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
223
223
  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
224
- 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`})]}),os=({error:t,vendorSettings:e,loginSession:n,email:r,client:i})=>{const s=i.connections.map(({strategy:k})=>k),o=s.includes("email")||s.includes("Username-Password-Authentication"),c=s.includes("sms"),d=s.includes("facebook"),l=s.includes("google-oauth2"),u=s.includes("apple"),p=s.includes("vipps"),m=d||l||u||p,w=o||c;let h="text",_="username",v=T.t("email_or_phone_placeholder","Email or Phone Number");return o&&!c?(h="email",v=T.t("email_placeholder","Email address")):!o&&c&&(h="tel",v=T.t("phone_placeholder","Phone number")),y(Fe,{title:T.t("welcome"),vendorSettings:e,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:T.t("welcome")}),y("div",{className:"mb-8 text-gray-300",children:T.t("login_description")}),y("div",{className:"flex flex-1 flex-col justify-center",children:[w&&y(Xt,{className:"mb-7",children:[y("input",{type:h,name:_,placeholder:v,className:ln("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||""}),t&&y(qn,{children:t}),y(Xe,{className:"sm:mt-4 !text-base",children:[y("span",{children:T.t("continue")}),y(Je,{className:"text-xs",name:"arrow-right"})]})]}),w&&m&&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:T.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:[d&&y(Ur,{connection:"facebook",text:T.t("continue_with",{provider:"Facebook"}),canResize:!0,icon:y(Je,{className:"text-xl text-[#1196F5] sm:absolute sm:left-4 sm:top-1/2 sm:-translate-y-1/2 sm:text-2xl short:static short:left-auto short:top-auto short:translate-y-0 short:text-xl",name:"facebook"}),loginSession:n}),l&&y(Ur,{connection:"google-oauth2",text:T.t("continue_with",{provider:"Google"}),canResize:!0,icon:y(Sm,{className:"h-5 w-5 sm:absolute sm:left-4 sm:top-1/2 sm:h-6 sm:w-6 sm:-translate-y-1/2 short:static short:left-auto short:top-auto short:h-5 short:w-5 short:translate-y-0"}),loginSession:n}),u&&y(Ur,{connection:"apple",text:T.t("continue_with",{provider:"Apple"}),canResize:!0,icon:y(Je,{className:"text-xl text-black dark:text-white sm:absolute sm:left-4 sm:top-1/2 sm:-translate-y-1/2 sm:text-2xl short:static short:left-auto short:top-auto short:translate-y-0 short:text-xl",name:"apple"}),loginSession:n}),p&&y(Ur,{connection:"vipps",text:T.t("continue_with",{provider:"Vipps"}),canResize:!0,icon:y(Am,{className:"h-5 w-5 sm:absolute sm:left-4 sm:top-1/2 sm:h-6 sm:w-6 sm:-translate-y-1/2 short:static short:left-auto short:top-auto short:h-5 short:w-5 short:translate-y-0"}),loginSession:n})]})]})]})},Z4=["Auth0.swift"];function X4(t){if(!t)return"code";const e=atob(t),n=JSON.parse(e);return Z4.includes(n.name)?"code":"link"}const Y4=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}=t.req.valid("query"),{vendorSettings:n,loginSession:r,client:i}=await Ne(t,e);return t.html(y(os,{vendorSettings:n,loginSession:r,client:i,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"})}),body:{content:{"application/x-www-form-urlencoded":{schema:a.z.object({username:a.z.string().transform(t=>t.toLowerCase()),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,loginSession:s,vendorSettings:o}=await Ne(t,n);t.set("client_id",i.id);const{countryCode:c}=Ot(t.req),{normalized:d}=pa(r.username,c);if(!d)return t.html(y(os,{vendorSettings:o,loginSession:s,error:T.t("invalid_identifier"),email:r.username,client:i}),400);const l=await wo({userAdapter:e.data.users,tenant_id:i.tenant.id,email:d});if(l&&t.set("user_id",l.user_id),!l)try{await Fy(t,i,t.env.data,d)}catch{const h=we(t,{type:ge.FAILED_SIGNUP,description:"Public signup is disabled"});return await t.env.data.logs.create(i.tenant.id,h),t.html(y(os,{vendorSettings:o,loginSession:s,error:T.t("user_account_does_not_exist"),email:r.username,client:i}),400)}if(s.authParams.username=d,await e.data.loginSessions.update(i.tenant.id,s.id,s),await V4(t,i,r.username,r.login_selection))return t.redirect(`/u/enter-password?state=${n}`);let u=Mn(),p=await e.data.codes.get(i.tenant.id,u,"otp");for(;p;)u=Mn(),p=await e.data.codes.get(i.tenant.id,u,"otp");const m=await t.env.data.codes.create(i.tenant.id,{code_id:u,code_type:"otp",login_id:s.id,expires_at:new Date(Date.now()+Wa).toISOString()});return X4(s.auth0Client)==="link"&&!d.includes("online.no")?await Dl(t,{to:d,code:m.code_id,authParams:s.authParams}):await dm(t,{to:d,code:m.code_id}),t.redirect(`/u/enter-code?state=${n}`)}),vt=t=>y("a",{className:"block text-primary hover:text-primaryHover text-center",href:`/u/login/identifier?state=${t.state}`,children:T.t("go_back")});var pi="_hp",Q4={Change:"Input",DoubleClick:"DblClick"},e$={svg:"2000/svg",math:"1998/Math/MathML"},hi=[],kd=new WeakMap,wr=void 0,t$=()=>wr,Bt=t=>"t"in t,La={onClick:["click",!1]},Zp=t=>{if(!t.startsWith("on"))return;if(La[t])return La[t];const e=t.match(/^on([A-Z][a-zA-Z]+?(?:PointerCapture)?)(Capture)?$/);if(e){const[,n,r]=e;return La[t]=[(Q4[n]||n).toLowerCase(),!!r]}},Xp=(t,e)=>wr&&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,n$=(t,e,n)=>{var r;e||(e={});for(let i in e){const s=e[i];if(i!=="children"&&(!n||n[i]!==s)){i=co(i);const o=Zp(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),kd.set(t,c)}else if(i==="style"){const c=t.style;typeof s=="string"?c.cssText=s:(c.cssText="",s!=null&&ym(s,c.setProperty.bind(c)))}else{if(i==="value"){const d=t.nodeName;if(d==="INPUT"||d==="TEXTAREA"||d==="SELECT"){if(t.value=s==null||s===!1?null:s,d==="TEXTAREA"){t.textContent=s;continue}else if(d==="SELECT"){t.selectedIndex===-1&&(t.selectedIndex=0);continue}}}else(i==="checked"&&t.nodeName==="INPUT"||i==="selected"&&t.nodeName==="OPTION")&&(t[i]=s);const c=Xp(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=co(i);const o=Zp(i);o?t.removeEventListener(o[0],s,o[1]):i==="ref"?(r=kd.get(t))==null||r():t.removeAttribute(Xp(t,i))}}},r$=(t,e)=>{e[Ae][0]=0,hi.push([t,e]);const n=e.tag[Kl]||e.tag,r=n.defaultProps?{...n.defaultProps,...e.props}:e.props;try{return[n.call(null,r)]}finally{hi.pop()}},Em=(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[Ae][1][zm])==null||o.forEach(c=>i.push(c))),t.vC.forEach(c=>{var d;if(Bt(c))n.push(c);else if(typeof c.tag=="function"||c.tag===""){c.c=e;const l=n.length;if(Em(c,e,n,r,i),c.s){for(let u=l;u<n.length;u++)n[u].s=!0;c.s=!1}}else n.push(c),(d=c.vR)!=null&&d.length&&(r.push(...c.vR),delete c.vR)})},i$=t=>{for(;;t=t.tag===pi||!t.vC||!t.pP?t.nN:t.vC[0]){if(!t)return null;if(t.tag!==pi&&t.e)return t.e}},Im=t=>{var e,n,r,i,s,o;Bt(t)||((n=(e=t[Ae])==null?void 0:e[1][zm])==null||n.forEach(c=>{var d;return(d=c[2])==null?void 0:d.call(c)}),(r=kd.get(t.e))==null||r(),t.p===2&&((i=t.vC)==null||i.forEach(c=>c.p=2)),(s=t.vC)==null||s.forEach(Im)),t.p||((o=t.e)==null||o.remove(),delete t.e),typeof t.tag=="function"&&(Mr.delete(t),as.delete(t),delete t[Ae][3],t.a=!0)},Nm=(t,e,n)=>{t.c=e,Cm(t,e,n)},Yp=(t,e)=>{if(e){for(let n=0,r=t.length;n<r;n++)if(t[n]===e)return n}},Qp=Symbol(),Cm=(t,e,n)=>{var l;const r=[],i=[],s=[];Em(t,e,r,i,s),i.forEach(Im);const o=n?void 0:e.childNodes;let c,d=null;if(n)c=-1;else if(!o.length)c=0;else{const u=Yp(o,i$(t.nN));u!==void 0?(d=o[u],c=u):c=Yp(o,(l=r.find(p=>p.tag!==pi&&p.e))==null?void 0:l.e)??-1,c===-1&&(n=!0)}for(let u=0,p=r.length;u<p;u++,c++){const m=r[u];let w;if(m.s&&m.e)w=m.e,m.s=!1;else{const h=n||!m.e;Bt(m)?(m.e&&m.d&&(m.e.textContent=m.t),m.d=!1,w=m.e||(m.e=document.createTextNode(m.t))):(w=m.e||(m.e=m.n?document.createElementNS(m.n,m.tag):document.createElement(m.tag)),n$(w,m.props,m.pP),Cm(m,w,h))}m.tag===pi?c--:n?w.parentNode||e.appendChild(w):o[c]!==w&&o[c-1]!==w&&(o[c+1]===w?e.appendChild(o[c]):e.insertBefore(w,d||o[c]||null))}if(t.pP&&delete t.pP,s.length){const u=[],p=[];s.forEach(([,m,,w,h])=>{m&&u.push(m),w&&p.push(w),h==null||h()}),u.forEach(m=>m()),p.length&&requestAnimationFrame(()=>{p.forEach(m=>m())})}},as=new WeakMap,Sd=(t,e,n)=>{var s,o,c,d,l,u;const r=!n&&e.pC;n&&(e.pC||(e.pC=e.vC));let i;try{n||(n=typeof e.tag=="function"?r$(t,e):Ri(e.props.children)),((s=n[0])==null?void 0:s.tag)===""&&n[0][$d]&&(i=n[0][$d],t[5].push([t,i,e]));const p=r?[...e.pC]:e.vC?[...e.vC]:void 0,m=[];let w;for(let h=0;h<n.length;h++){Array.isArray(n[h])&&n.splice(h,1,...n[h].flat());let _=s$(n[h]);if(_){typeof _.tag=="function"&&!_.tag[pm]&&(yr.length>0&&(_[Ae][2]=yr.map(k=>[k,k.values.at(-1)])),(o=t[5])!=null&&o.length&&(_[Ae][3]=t[5].at(-1)));let v;if(p&&p.length){const k=p.findIndex(Bt(_)?I=>Bt(I):_.key!==void 0?I=>I.key===_.key&&I.tag===_.tag:I=>I.tag===_.tag);k!==-1&&(v=p[k],p.splice(k,1))}if(v)if(Bt(_))v.t!==_.t&&(v.t=_.t,v.d=!0),_=v;else{const k=v.pP=v.props;v.props=_.props,v.f||(v.f=_.f||e.f),typeof _.tag=="function"&&(v[Ae][2]=_[Ae][2]||[],v[Ae][3]=_[Ae][3],!v.f&&((v.o||v)===_.o||(d=(c=v.tag)[A4])!=null&&d.call(c,k,v.props))&&(v.s=!0)),_=v}else if(!Bt(_)&&wr){const k=Or(wr);k&&(_.n=k)}if(!Bt(_)&&!_.s&&(Sd(t,_),delete _.f),m.push(_),w&&!w.s&&!_.s)for(let k=w;k&&!Bt(k);k=(l=k.vC)==null?void 0:l.at(-1))k.nN=_;w=_}}e.vR=r?[...e.vC,...p||[]]:p||[],e.vC=m,r&&delete e.pC}catch(p){if(e.f=!0,p===Qp){if(i)return;throw p}const[m,w,h]=((u=e[Ae])==null?void 0:u[3])||[];if(w){const _=()=>cs([0,!1,t[2]],h),v=as.get(h)||[];v.push(_),as.set(h,v);const k=w(p,()=>{const I=as.get(h);if(I){const O=I.indexOf(_);if(O!==-1)return I.splice(O,1),_()}});if(k){if(t[0]===1)t[1]=!0;else if(Sd(t,h,[k]),(w.length===1||t!==m)&&h.c){Nm(h,h.c,!1);return}throw Qp}}throw p}finally{i&&t[5].pop()}},s$=t=>{if(!(t==null||typeof t=="boolean")){if(typeof t=="string"||typeof t=="number")return{t:t.toString(),d:!0};if("vR"in t&&(t={tag:t.tag,props:t.props,key:t.key,f:t.f,type:t.tag,ref:t.props.ref,o:t.o||t}),typeof t.tag=="function")t[Ae]=[0,[]];else{const e=e$[t.tag];e&&(wr||(wr=gm("")),t.props.children=[{tag:wr,props:{value:t.n=`http://www.w3.org/${e}`,children:t.props.children}}])}return t}},e0=(t,e)=>{var n,r;(n=e[Ae][2])==null||n.forEach(([i,s])=>{i.values.push(s)});try{Sd(t,e,void 0)}catch{return}if(e.a){delete e.a;return}(r=e[Ae][2])==null||r.forEach(([i])=>{i.values.pop()}),(t[0]!==1||!t[1])&&Nm(e,e.c,!1)},Mr=new WeakMap,t0=[],cs=async(t,e)=>{t[5]||(t[5]=[]);const n=Mr.get(e);n&&n[0](void 0);let r;const i=new Promise(s=>r=s);if(Mr.set(e,[r,()=>{t[2]?t[2](t,e,s=>{e0(s,e)}).then(()=>r(e)):(e0(t,e),r(e))}]),t0.length)t0.at(-1).add(e);else{await Promise.resolve();const s=Mr.get(e);s&&(Mr.delete(e),s[1]())}return i},o$=(t,e,n)=>({tag:pi,props:{children:t},key:n,e,p:1}),Ua=0,zm=1,Ma=2,Fa=3,Va=new WeakMap,Om=(t,e)=>!t||!e||t.length!==e.length||e.some((n,r)=>n!==t[r]),a$=void 0,n0=[],c$=t=>{var o;const e=()=>typeof t=="function"?t():t,n=hi.at(-1);if(!n)return[e(),()=>{}];const[,r]=n,i=(o=r[Ae][1])[Ua]||(o[Ua]=[]),s=r[Ae][0]++;return i[s]||(i[s]=[e(),c=>{const d=a$,l=i[s];if(typeof c=="function"&&(c=c(l[0])),!Object.is(c,l[0]))if(l[0]=c,n0.length){const[u,p]=n0.at(-1);Promise.all([u===3?r:cs([u,!1,d],r),p]).then(([m])=>{if(!m||!(u===2||u===3))return;const w=m.vC;requestAnimationFrame(()=>{setTimeout(()=>{w===m.vC&&cs([u===3?1:0,!1,d],m)})})})}else cs([0,!1,d],r)}])},Zl=(t,e)=>{var c;const n=hi.at(-1);if(!n)return t;const[,r]=n,i=(c=r[Ae][1])[Ma]||(c[Ma]=[]),s=r[Ae][0]++,o=i[s];return Om(o==null?void 0:o[1],e)?i[s]=[t,e]:t=i[s][0],t},d$=t=>{const e=Va.get(t);if(e){if(e.length===2)throw e[1];return e[0]}throw t.then(n=>Va.set(t,[n]),n=>Va.set(t,[void 0,n])),t},l$=(t,e)=>{var c;const n=hi.at(-1);if(!n)return t();const[,r]=n,i=(c=r[Ae][1])[Fa]||(c[Fa]=[]),s=r[Ae][0]++,o=i[s];return Om(o==null?void 0:o[1],e)&&(i[s]=[t(),e]),i[s][0]},u$=gm({pending:!1,data:null,method:null,action:null}),r0=new Set,f$=t=>{r0.add(t),t.finally(()=>r0.delete(t))},Xl=(t,e)=>l$(()=>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]),Jn=Object.create(null),Gi=Object.create(null),Ui=(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:d,blocking:l,...u}=e,p=null,m=!1;const w=rs[t];let h;if(w.length>0){const I=s.querySelectorAll(t);e:for(const O of I)for(const L of rs[t])if(O.getAttribute(L)===e[L]){p=O;break e}if(!p){const O=w.reduce((L,Y)=>e[Y]===void 0?L:`${L}-${Y}-${e[Y]}`,t);m=!Gi[O],p=Gi[O]||(Gi[O]=(()=>{const L=document.createElement(t);for(const Y of w)e[Y]!==void 0&&L.setAttribute(Y,e[Y]),e.rel&&L.setAttribute("rel",e.rel);return L})())}}else h=s.querySelectorAll(t);d=r?d??"":void 0,r&&(u[is]=d);const _=Zl(I=>{if(w.length>0){let O=!1;for(const L of s.querySelectorAll(t)){if(O&&L.getAttribute(is)!==d){s.insertBefore(I,L);return}L.getAttribute(is)===d&&(O=!0)}s.appendChild(I)}else if(h){let O=!1;for(const L of h)if(L===I){O=!0;break}O||s.insertBefore(I,s.contains(h[0])?h[0]:s.querySelector(t)),h=void 0}},[d]),v=Xl(e.ref,I=>{var Y;const O=w[0];if(n===2&&(I.innerHTML=""),(m||h)&&_(I),!c&&!o)return;let L=Jn[Y=I.getAttribute(O)]||(Jn[Y]=new Promise((oe,ae)=>{I.addEventListener("load",oe),I.addEventListener("error",ae)}));o&&(L=L.then(o)),c&&(L=L.catch(c)),L.catch(()=>{})});if(i&&l==="render"){const I=rs[t][0];if(e[I]){const O=e[I],L=Jn[O]||(Jn[O]=new Promise((Y,oe)=>{_(p),p.addEventListener("load",Y),p.addEventListener("error",oe)}));d$(L)}}const k={tag:t,type:t,props:{...u,ref:v},ref:v};return k.p=n,p&&(k.e=p),o$(k,s)},p$=t=>{const e=t$(),n=e&&Or(e);return n!=null&&n.endsWith("svg")?{tag:"title",props:t,type:"title",ref:t.ref}:Ui("title",t,void 0,!1,!1)},h$=t=>!t||["src","async"].some(e=>!t[e])?{tag:"script",props:t,type:"script",ref:t.ref}:Ui("script",t,1,!1,!0),g$=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,Ui("style",t,2,!0,!0)),m$=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}:Ui("link",t,1,"precedence"in t,!0),_$=t=>Ui("meta",t,void 0,!1,!1),Pm=Symbol(),y$=t=>{const{action:e,...n}=t;typeof e!="function"&&(n.action=e);const[r,i]=c$([null,!1]),s=Zl(async l=>{const u=l.isTrusted?e:l.detail[Pm];if(typeof u!="function")return;l.preventDefault();const p=new FormData(l.target);i([p,!0]);const m=u(p);m instanceof Promise&&(f$(m),await m),i([null,!0])},[]),o=Xl(t.ref,l=>(l.addEventListener("submit",s),()=>{l.removeEventListener("submit",s)})),[c,d]=r;return r[1]=!1,{tag:u$,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:d}},jm=(t,{formAction:e,...n})=>{if(typeof e=="function"){const r=Zl(i=>{i.preventDefault(),i.currentTarget.form.dispatchEvent(new CustomEvent("submit",{detail:{[Pm]:e}}))},[]);n.ref=Xl(n.ref,i=>(i.addEventListener("click",r),()=>{i.removeEventListener("click",r)}))}return{tag:t,props:n,type:t,ref:n.ref}},w$=t=>jm("input",t),v$=t=>jm("button",t);Object.assign(xd,{title:p$,script:h$,style:g$,link:m$,meta:_$,form:y$,input:w$,button:v$});new TextEncoder;const ha=t=>{const{i18nKey:e,values:n,components:r}=t,i=T.t(e,n),s=/<(\d+)>(.*?)<\/\d+>/g,o=[];let c=0,d;for(;(d=s.exec(i))!==null;){const[,l,u]=d,p=i.substring(c,d.index);p&&o.push(p);const m=parseInt(l,10);o.push(F4(r[m],{},u)),c=s.lastIndex}return c<i.length&&o.push(i.substring(c)),y(vm,{children:o})},i0=6,Ad=({error:t,vendorSettings:e,email:n,state:r,client:i,hasPasswordLogin:s})=>{const o=new URLSearchParams({state:r}),d=i.connections.map(({name:l})=>l).includes("auth2");return y(Fe,{title:T.t("verify_your_email"),vendorSettings:e,children:[y("div",{className:"mb-4 text-2xl font-medium",children:T.t("verify_your_email")}),y("div",{className:"mb-8 text-gray-300",children:y(ha,{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(Xt,{className:"pt-2",children:[y("input",{autoFocus:!0,type:"text",pattern:"[0-9]*",maxLength:i0,inputMode:"numeric",name:"code",placeholder:"******",className:ln("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:i0,required:!0,id:"code-input"}),t&&y(qn,{children:t}),y(Xe,{className:"sm:mt-4 !text-base",children:[y("span",{children:T.t("login")}),y(Je,{className:"text-xs",name:"arrow-right"})]}),y("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[y(Je,{className:"text-base",name:"info-bubble"}),y("div",{className:"text-sm text-gray-300 md:text-sm",children:T.t("sent_code_spam")})]}),d&&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:T.t("or")})]}),y(Xe,{Component:"a",href:`/u/${s?"enter-password":"pre-signup"}?${o.toString()}`,variant:"secondary",className:"block",children:T.t("enter_your_password_btn")})]})]}),y(vt,{state:r})]})]})},b$=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,loginSession:r,client:i}=await Ne(t,e);if(!r.authParams.username)throw new N(400,{message:"Username not found in state"});const s=await $s({userAdapter:t.env.data.users,tenant_id:i.tenant.id,username:r.authParams.username,provider:"auth2"});return t.html(y(Ad,{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"),{loginSession:r,client:i,vendorSettings:s}=await Ne(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 om(t,{client_id:i.id,authParams:r.authParams,username:r.authParams.username,otp:n})}catch(o){const c=o,d=await $s({userAdapter:t.env.data.users,tenant_id:i.tenant.id,username:r.authParams.username,provider:"auth2"});return t.html(y(Ad,{vendorSettings:s,email:r.authParams.username,state:e,client:i,error:c.message,hasPasswordLogin:!!d}),400)}}),Tm=t=>{const{vendorSettings:e,state:n}=t;return y(Fe,{title:T.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:T.t("unverified_email")}),y("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[y(Je,{className:"text-base",name:"info-bubble"}),y("div",{className:"text-sm text-gray-300 md:text-sm",children:T.t("sent_code_spam")})]}),y(vt,{state:n})]}),y(vt,{state:n})]})},$$=({width:t=22,height:e=17})=>y("svg",{width:t,height:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 576 512",children:y("path",{fill:"currentColor",d:"M288 32c-80.8 0-145.5 36.8-192.6 80.6C48.6 156 17.3 208 2.5 243.7c-3.3 7.9-3.3 16.7 0 24.6C17.3 304 48.6 356 95.4 399.4 142.5 443.2 207.2 480 288 480s145.5-36.8 192.6-80.6c46.8-43.5 78.1-95.4 93-131.1 3.3-7.9 3.3-16.7 0-24.6-14.9-35.7-46.2-87.7-93-131.1C433.5 68.8 368.8 32 288 32M144 256a144 144 0 1 1 288 0 144 144 0 1 1-288 0m144-64c0 35.3-28.7 64-64 64-7.1 0-13.9-1.2-20.3-3.3-5.5-1.8-11.9 1.6-11.7 7.4.3 6.9 1.3 13.8 3.2 20.7 13.7 51.2 66.4 81.6 117.6 67.9s81.6-66.4 67.9-117.6c-11.1-41.5-47.8-69.4-88.6-71.1-5.8-.2-9.2 6.1-7.4 11.7 2.1 6.4 3.3 13.2 3.3 20.3"})}),x$=({width:t=23,height:e=18})=>y("svg",{width:t,height:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 640 512",children:y("path",{fill:"currentColor",d:"M38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2s-6.3 25.5 4.1 33.7l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7l-105.2-82.4c39.6-40.6 66.4-86.1 79.9-118.4 3.3-7.9 3.3-16.7 0-24.6-14.9-35.7-46.2-87.7-93-131.1C465.5 68.8 400.8 32 320 32c-68.2 0-125 26.3-169.3 60.8zm184.3 144.4c25.5-23.3 59.6-37.5 96.9-37.5 79.5 0 144 64.5 144 144 0 24.9-6.3 48.3-17.4 68.7L408 294.5c8.4-19.3 10.6-41.4 4.8-63.3-11.1-41.5-47.8-69.4-88.6-71.1-5.8-.2-9.2 6.1-7.4 11.7 2.1 6.4 3.3 13.2 3.3 20.3 0 10.2-2.4 19.8-6.6 28.3l-90.3-70.8zM373 389.9c-16.4 6.5-34.3 10.1-53 10.1-79.5 0-144-64.5-144-144 0-6.9.5-13.6 1.4-20.2l-94.3-74.3c-22.8 29.7-39.1 59.3-48.6 82.2-3.3 7.9-3.3 16.7 0 24.6 14.9 35.7 46.2 87.7 93 131.1 47 43.8 111.7 80.6 192.5 80.6 47.8 0 89.9-12.9 126.2-32.5z"})}),Ed=({name:t,placeholder:e=T.t("password")})=>y("div",{className:"password-input relative mb-2",children:[y("input",{type:"password",name:t,placeholder:e,className:"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}),y("button",{type:"button","aria-label":T.t("show_password"),title:T.t("show_password"),className:"show-password-toggle-show absolute right-0 top-0 w-10 h-full rounded-r-lg text-gray-400 column hover:bg-black/5",children:y($$,{})}),y("button",{type:"button","aria-label":T.t("hide_password"),title:T.t("hide_password"),className:"show-password-toggle-hide !hidden absolute right-0 top-0 w-10 h-full rounded-r-lg text-gray-400 column hover:bg-black/5",children:y(x$,{})})]});var s0=Object.freeze,k$=Object.defineProperty,S$=(t,e)=>s0(k$(t,"raw",{value:s0(t.slice())})),o0;const ds=t=>{const{error:e,vendorSettings:n,email:r,state:i}=t,s=new URLSearchParams({state:i});return y(Fe,{title:T.t("enter_password"),vendorSettings:n,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:T.t("enter_password")}),y("div",{className:"mb-6 text-gray-300",children:T.t("enter_password_description")}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y(Xt,{className:"mb-7",children:[y("input",{type:"text",name:"username",placeholder:T.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(Ed,{name:"password"}),e&&y(qn,{children:e}),y(Xe,{className:"sm:mt-4 !text-base",children:[y("span",{children:T.t("login")}),y(Je,{className:"text-xs",name:"arrow-right"})]})]}),y("a",{href:`/u/forgot-password?${s.toString()}`,className:"text-primary hover:underline mb-4",children:T.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:T.t("or")})]}),y("form",{method:"post",action:`/u/login/identifier?${s.toString()}`,children:[y("input",{type:"hidden",name:"login_selection",value:"code"}),y("input",{type:"hidden",name:"username",value:r}),y(Xe,{variant:"secondary",className:"block",children:T.t("enter_a_code_btn")})]})]}),y(vt,{state:i})]}),fm(o0||(o0=S$([`
224
+ 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`})]}),as=({error:t,vendorSettings:e,loginSession:n,email:r,client:i})=>{const s=i.connections.map(({strategy:k})=>k),o=s.includes("email")||s.includes("Username-Password-Authentication"),c=s.includes("sms"),d=s.includes("facebook"),l=s.includes("google-oauth2"),u=s.includes("apple"),p=s.includes("vipps"),m=d||l||u||p,w=o||c;let h="text",_="username",v=T.t("email_or_phone_placeholder","Email or Phone Number");return o&&!c?(h="email",v=T.t("email_placeholder","Email address")):!o&&c&&(h="tel",v=T.t("phone_placeholder","Phone number")),y(Fe,{title:T.t("welcome"),vendorSettings:e,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:T.t("welcome")}),y("div",{className:"mb-8 text-gray-300",children:T.t("login_description")}),y("div",{className:"flex flex-1 flex-col justify-center",children:[w&&y(Xt,{className:"mb-7",children:[y("input",{type:h,name:_,placeholder:v,className:ln("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||""}),t&&y(qn,{children:t}),y(Xe,{className:"sm:mt-4 !text-base",children:[y("span",{children:T.t("continue")}),y(Je,{className:"text-xs",name:"arrow-right"})]})]}),w&&m&&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:T.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:[d&&y(Ur,{connection:"facebook",text:T.t("continue_with",{provider:"Facebook"}),canResize:!0,icon:y(Je,{className:"text-xl text-[#1196F5] sm:absolute sm:left-4 sm:top-1/2 sm:-translate-y-1/2 sm:text-2xl short:static short:left-auto short:top-auto short:translate-y-0 short:text-xl",name:"facebook"}),loginSession:n}),l&&y(Ur,{connection:"google-oauth2",text:T.t("continue_with",{provider:"Google"}),canResize:!0,icon:y(Am,{className:"h-5 w-5 sm:absolute sm:left-4 sm:top-1/2 sm:h-6 sm:w-6 sm:-translate-y-1/2 short:static short:left-auto short:top-auto short:h-5 short:w-5 short:translate-y-0"}),loginSession:n}),u&&y(Ur,{connection:"apple",text:T.t("continue_with",{provider:"Apple"}),canResize:!0,icon:y(Je,{className:"text-xl text-black dark:text-white sm:absolute sm:left-4 sm:top-1/2 sm:-translate-y-1/2 sm:text-2xl short:static short:left-auto short:top-auto short:translate-y-0 short:text-xl",name:"apple"}),loginSession:n}),p&&y(Ur,{connection:"vipps",text:T.t("continue_with",{provider:"Vipps"}),canResize:!0,icon:y(Em,{className:"h-5 w-5 sm:absolute sm:left-4 sm:top-1/2 sm:h-6 sm:w-6 sm:-translate-y-1/2 short:static short:left-auto short:top-auto short:h-5 short:w-5 short:translate-y-0"}),loginSession:n})]})]})]})},Z4=["Auth0.swift"];function X4(t){if(!t)return"code";const e=atob(t),n=JSON.parse(e);return Z4.includes(n.name)?"code":"link"}const Y4=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}=t.req.valid("query"),{vendorSettings:n,loginSession:r,client:i}=await Ne(t,e);return t.html(y(as,{vendorSettings:n,loginSession:r,client:i,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"})}),body:{content:{"application/x-www-form-urlencoded":{schema:a.z.object({username:a.z.string().transform(t=>t.toLowerCase()),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,loginSession:s,vendorSettings:o}=await Ne(t,n);t.set("client_id",i.id);const{countryCode:c}=Ot(t.req),{normalized:d}=fi(r.username,c);if(!d)return t.html(y(as,{vendorSettings:o,loginSession:s,error:T.t("invalid_identifier"),email:r.username,client:i}),400);const l=await vo({userAdapter:e.data.users,tenant_id:i.tenant.id,email:d});if(l&&t.set("user_id",l.user_id),!l)try{await Vy(t,i,t.env.data,d)}catch{const _=we(t,{type:ge.FAILED_SIGNUP,description:"Public signup is disabled"});return await t.env.data.logs.create(i.tenant.id,_),t.html(y(as,{vendorSettings:o,loginSession:s,error:T.t("user_account_does_not_exist"),email:r.username,client:i}),400)}if(s.authParams.username=d,await e.data.loginSessions.update(i.tenant.id,s.id,s),await V4(t,i,r.username,r.login_selection))return t.redirect(`/u/enter-password?state=${n}`);let u=Mn(),p=await e.data.codes.get(i.tenant.id,u,"otp");for(;p;)u=Mn(),p=await e.data.codes.get(i.tenant.id,u,"otp");const m=await t.env.data.codes.create(i.tenant.id,{code_id:u,code_type:"otp",login_id:s.id,expires_at:new Date(Date.now()+Wa).toISOString()}),w=X4(s.auth0Client),{connection:h}=fi(d);return h==="email"&&w==="link"&&!d.includes("online.no")?await Dl(t,{to:d,code:m.code_id,authParams:s.authParams}):await lm(t,{to:d,code:m.code_id}),t.redirect(`/u/enter-code?state=${n}`)}),vt=t=>y("a",{className:"block text-primary hover:text-primaryHover text-center",href:`/u/login/identifier?state=${t.state}`,children:T.t("go_back")});var hi="_hp",Q4={Change:"Input",DoubleClick:"DblClick"},e$={svg:"2000/svg",math:"1998/Math/MathML"},gi=[],kd=new WeakMap,wr=void 0,t$=()=>wr,Bt=t=>"t"in t,La={onClick:["click",!1]},Zp=t=>{if(!t.startsWith("on"))return;if(La[t])return La[t];const e=t.match(/^on([A-Z][a-zA-Z]+?(?:PointerCapture)?)(Capture)?$/);if(e){const[,n,r]=e;return La[t]=[(Q4[n]||n).toLowerCase(),!!r]}},Xp=(t,e)=>wr&&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,n$=(t,e,n)=>{var r;e||(e={});for(let i in e){const s=e[i];if(i!=="children"&&(!n||n[i]!==s)){i=lo(i);const o=Zp(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),kd.set(t,c)}else if(i==="style"){const c=t.style;typeof s=="string"?c.cssText=s:(c.cssText="",s!=null&&wm(s,c.setProperty.bind(c)))}else{if(i==="value"){const d=t.nodeName;if(d==="INPUT"||d==="TEXTAREA"||d==="SELECT"){if(t.value=s==null||s===!1?null:s,d==="TEXTAREA"){t.textContent=s;continue}else if(d==="SELECT"){t.selectedIndex===-1&&(t.selectedIndex=0);continue}}}else(i==="checked"&&t.nodeName==="INPUT"||i==="selected"&&t.nodeName==="OPTION")&&(t[i]=s);const c=Xp(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=lo(i);const o=Zp(i);o?t.removeEventListener(o[0],s,o[1]):i==="ref"?(r=kd.get(t))==null||r():t.removeAttribute(Xp(t,i))}}},r$=(t,e)=>{e[Ae][0]=0,gi.push([t,e]);const n=e.tag[Kl]||e.tag,r=n.defaultProps?{...n.defaultProps,...e.props}:e.props;try{return[n.call(null,r)]}finally{gi.pop()}},Im=(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[Ae][1][Om])==null||o.forEach(c=>i.push(c))),t.vC.forEach(c=>{var d;if(Bt(c))n.push(c);else if(typeof c.tag=="function"||c.tag===""){c.c=e;const l=n.length;if(Im(c,e,n,r,i),c.s){for(let u=l;u<n.length;u++)n[u].s=!0;c.s=!1}}else n.push(c),(d=c.vR)!=null&&d.length&&(r.push(...c.vR),delete c.vR)})},i$=t=>{for(;;t=t.tag===hi||!t.vC||!t.pP?t.nN:t.vC[0]){if(!t)return null;if(t.tag!==hi&&t.e)return t.e}},Nm=t=>{var e,n,r,i,s,o;Bt(t)||((n=(e=t[Ae])==null?void 0:e[1][Om])==null||n.forEach(c=>{var d;return(d=c[2])==null?void 0:d.call(c)}),(r=kd.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"&&(Mr.delete(t),cs.delete(t),delete t[Ae][3],t.a=!0)},Cm=(t,e,n)=>{t.c=e,zm(t,e,n)},Yp=(t,e)=>{if(e){for(let n=0,r=t.length;n<r;n++)if(t[n]===e)return n}},Qp=Symbol(),zm=(t,e,n)=>{var l;const r=[],i=[],s=[];Im(t,e,r,i,s),i.forEach(Nm);const o=n?void 0:e.childNodes;let c,d=null;if(n)c=-1;else if(!o.length)c=0;else{const u=Yp(o,i$(t.nN));u!==void 0?(d=o[u],c=u):c=Yp(o,(l=r.find(p=>p.tag!==hi&&p.e))==null?void 0:l.e)??-1,c===-1&&(n=!0)}for(let u=0,p=r.length;u<p;u++,c++){const m=r[u];let w;if(m.s&&m.e)w=m.e,m.s=!1;else{const h=n||!m.e;Bt(m)?(m.e&&m.d&&(m.e.textContent=m.t),m.d=!1,w=m.e||(m.e=document.createTextNode(m.t))):(w=m.e||(m.e=m.n?document.createElementNS(m.n,m.tag):document.createElement(m.tag)),n$(w,m.props,m.pP),zm(m,w,h))}m.tag===hi?c--:n?w.parentNode||e.appendChild(w):o[c]!==w&&o[c-1]!==w&&(o[c+1]===w?e.appendChild(o[c]):e.insertBefore(w,d||o[c]||null))}if(t.pP&&delete t.pP,s.length){const u=[],p=[];s.forEach(([,m,,w,h])=>{m&&u.push(m),w&&p.push(w),h==null||h()}),u.forEach(m=>m()),p.length&&requestAnimationFrame(()=>{p.forEach(m=>m())})}},cs=new WeakMap,Sd=(t,e,n)=>{var s,o,c,d,l,u;const r=!n&&e.pC;n&&(e.pC||(e.pC=e.vC));let i;try{n||(n=typeof e.tag=="function"?r$(t,e):Bi(e.props.children)),((s=n[0])==null?void 0:s.tag)===""&&n[0][$d]&&(i=n[0][$d],t[5].push([t,i,e]));const p=r?[...e.pC]:e.vC?[...e.vC]:void 0,m=[];let w;for(let h=0;h<n.length;h++){Array.isArray(n[h])&&n.splice(h,1,...n[h].flat());let _=s$(n[h]);if(_){typeof _.tag=="function"&&!_.tag[hm]&&(yr.length>0&&(_[Ae][2]=yr.map(k=>[k,k.values.at(-1)])),(o=t[5])!=null&&o.length&&(_[Ae][3]=t[5].at(-1)));let v;if(p&&p.length){const k=p.findIndex(Bt(_)?I=>Bt(I):_.key!==void 0?I=>I.key===_.key&&I.tag===_.tag:I=>I.tag===_.tag);k!==-1&&(v=p[k],p.splice(k,1))}if(v)if(Bt(_))v.t!==_.t&&(v.t=_.t,v.d=!0),_=v;else{const k=v.pP=v.props;v.props=_.props,v.f||(v.f=_.f||e.f),typeof _.tag=="function"&&(v[Ae][2]=_[Ae][2]||[],v[Ae][3]=_[Ae][3],!v.f&&((v.o||v)===_.o||(d=(c=v.tag)[A4])!=null&&d.call(c,k,v.props))&&(v.s=!0)),_=v}else if(!Bt(_)&&wr){const k=Or(wr);k&&(_.n=k)}if(!Bt(_)&&!_.s&&(Sd(t,_),delete _.f),m.push(_),w&&!w.s&&!_.s)for(let k=w;k&&!Bt(k);k=(l=k.vC)==null?void 0:l.at(-1))k.nN=_;w=_}}e.vR=r?[...e.vC,...p||[]]:p||[],e.vC=m,r&&delete e.pC}catch(p){if(e.f=!0,p===Qp){if(i)return;throw p}const[m,w,h]=((u=e[Ae])==null?void 0:u[3])||[];if(w){const _=()=>ds([0,!1,t[2]],h),v=cs.get(h)||[];v.push(_),cs.set(h,v);const k=w(p,()=>{const I=cs.get(h);if(I){const O=I.indexOf(_);if(O!==-1)return I.splice(O,1),_()}});if(k){if(t[0]===1)t[1]=!0;else if(Sd(t,h,[k]),(w.length===1||t!==m)&&h.c){Cm(h,h.c,!1);return}throw Qp}}throw p}finally{i&&t[5].pop()}},s$=t=>{if(!(t==null||typeof t=="boolean")){if(typeof t=="string"||typeof t=="number")return{t:t.toString(),d:!0};if("vR"in t&&(t={tag:t.tag,props:t.props,key:t.key,f:t.f,type:t.tag,ref:t.props.ref,o:t.o||t}),typeof t.tag=="function")t[Ae]=[0,[]];else{const e=e$[t.tag];e&&(wr||(wr=mm("")),t.props.children=[{tag:wr,props:{value:t.n=`http://www.w3.org/${e}`,children:t.props.children}}])}return t}},e0=(t,e)=>{var n,r;(n=e[Ae][2])==null||n.forEach(([i,s])=>{i.values.push(s)});try{Sd(t,e,void 0)}catch{return}if(e.a){delete e.a;return}(r=e[Ae][2])==null||r.forEach(([i])=>{i.values.pop()}),(t[0]!==1||!t[1])&&Cm(e,e.c,!1)},Mr=new WeakMap,t0=[],ds=async(t,e)=>{t[5]||(t[5]=[]);const n=Mr.get(e);n&&n[0](void 0);let r;const i=new Promise(s=>r=s);if(Mr.set(e,[r,()=>{t[2]?t[2](t,e,s=>{e0(s,e)}).then(()=>r(e)):(e0(t,e),r(e))}]),t0.length)t0.at(-1).add(e);else{await Promise.resolve();const s=Mr.get(e);s&&(Mr.delete(e),s[1]())}return i},o$=(t,e,n)=>({tag:hi,props:{children:t},key:n,e,p:1}),Ua=0,Om=1,Ma=2,Fa=3,Va=new WeakMap,Pm=(t,e)=>!t||!e||t.length!==e.length||e.some((n,r)=>n!==t[r]),a$=void 0,n0=[],c$=t=>{var o;const e=()=>typeof t=="function"?t():t,n=gi.at(-1);if(!n)return[e(),()=>{}];const[,r]=n,i=(o=r[Ae][1])[Ua]||(o[Ua]=[]),s=r[Ae][0]++;return i[s]||(i[s]=[e(),c=>{const d=a$,l=i[s];if(typeof c=="function"&&(c=c(l[0])),!Object.is(c,l[0]))if(l[0]=c,n0.length){const[u,p]=n0.at(-1);Promise.all([u===3?r:ds([u,!1,d],r),p]).then(([m])=>{if(!m||!(u===2||u===3))return;const w=m.vC;requestAnimationFrame(()=>{setTimeout(()=>{w===m.vC&&ds([u===3?1:0,!1,d],m)})})})}else ds([0,!1,d],r)}])},Zl=(t,e)=>{var c;const n=gi.at(-1);if(!n)return t;const[,r]=n,i=(c=r[Ae][1])[Ma]||(c[Ma]=[]),s=r[Ae][0]++,o=i[s];return Pm(o==null?void 0:o[1],e)?i[s]=[t,e]:t=i[s][0],t},d$=t=>{const e=Va.get(t);if(e){if(e.length===2)throw e[1];return e[0]}throw t.then(n=>Va.set(t,[n]),n=>Va.set(t,[void 0,n])),t},l$=(t,e)=>{var c;const n=gi.at(-1);if(!n)return t();const[,r]=n,i=(c=r[Ae][1])[Fa]||(c[Fa]=[]),s=r[Ae][0]++,o=i[s];return Pm(o==null?void 0:o[1],e)&&(i[s]=[t(),e]),i[s][0]},u$=mm({pending:!1,data:null,method:null,action:null}),r0=new Set,f$=t=>{r0.add(t),t.finally(()=>r0.delete(t))},Xl=(t,e)=>l$(()=>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]),Jn=Object.create(null),Wi=Object.create(null),Mi=(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:d,blocking:l,...u}=e,p=null,m=!1;const w=is[t];let h;if(w.length>0){const I=s.querySelectorAll(t);e:for(const O of I)for(const L of is[t])if(O.getAttribute(L)===e[L]){p=O;break e}if(!p){const O=w.reduce((L,Y)=>e[Y]===void 0?L:`${L}-${Y}-${e[Y]}`,t);m=!Wi[O],p=Wi[O]||(Wi[O]=(()=>{const L=document.createElement(t);for(const Y of w)e[Y]!==void 0&&L.setAttribute(Y,e[Y]),e.rel&&L.setAttribute("rel",e.rel);return L})())}}else h=s.querySelectorAll(t);d=r?d??"":void 0,r&&(u[ss]=d);const _=Zl(I=>{if(w.length>0){let O=!1;for(const L of s.querySelectorAll(t)){if(O&&L.getAttribute(ss)!==d){s.insertBefore(I,L);return}L.getAttribute(ss)===d&&(O=!0)}s.appendChild(I)}else if(h){let O=!1;for(const L of h)if(L===I){O=!0;break}O||s.insertBefore(I,s.contains(h[0])?h[0]:s.querySelector(t)),h=void 0}},[d]),v=Xl(e.ref,I=>{var Y;const O=w[0];if(n===2&&(I.innerHTML=""),(m||h)&&_(I),!c&&!o)return;let L=Jn[Y=I.getAttribute(O)]||(Jn[Y]=new Promise((oe,ae)=>{I.addEventListener("load",oe),I.addEventListener("error",ae)}));o&&(L=L.then(o)),c&&(L=L.catch(c)),L.catch(()=>{})});if(i&&l==="render"){const I=is[t][0];if(e[I]){const O=e[I],L=Jn[O]||(Jn[O]=new Promise((Y,oe)=>{_(p),p.addEventListener("load",Y),p.addEventListener("error",oe)}));d$(L)}}const k={tag:t,type:t,props:{...u,ref:v},ref:v};return k.p=n,p&&(k.e=p),o$(k,s)},p$=t=>{const e=t$(),n=e&&Or(e);return n!=null&&n.endsWith("svg")?{tag:"title",props:t,type:"title",ref:t.ref}:Mi("title",t,void 0,!1,!1)},h$=t=>!t||["src","async"].some(e=>!t[e])?{tag:"script",props:t,type:"script",ref:t.ref}:Mi("script",t,1,!1,!0),g$=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,Mi("style",t,2,!0,!0)),m$=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}:Mi("link",t,1,"precedence"in t,!0),_$=t=>Mi("meta",t,void 0,!1,!1),jm=Symbol(),y$=t=>{const{action:e,...n}=t;typeof e!="function"&&(n.action=e);const[r,i]=c$([null,!1]),s=Zl(async l=>{const u=l.isTrusted?e:l.detail[jm];if(typeof u!="function")return;l.preventDefault();const p=new FormData(l.target);i([p,!0]);const m=u(p);m instanceof Promise&&(f$(m),await m),i([null,!0])},[]),o=Xl(t.ref,l=>(l.addEventListener("submit",s),()=>{l.removeEventListener("submit",s)})),[c,d]=r;return r[1]=!1,{tag:u$,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:d}},Tm=(t,{formAction:e,...n})=>{if(typeof e=="function"){const r=Zl(i=>{i.preventDefault(),i.currentTarget.form.dispatchEvent(new CustomEvent("submit",{detail:{[jm]:e}}))},[]);n.ref=Xl(n.ref,i=>(i.addEventListener("click",r),()=>{i.removeEventListener("click",r)}))}return{tag:t,props:n,type:t,ref:n.ref}},w$=t=>Tm("input",t),v$=t=>Tm("button",t);Object.assign(xd,{title:p$,script:h$,style:g$,link:m$,meta:_$,form:y$,input:w$,button:v$});new TextEncoder;const ha=t=>{const{i18nKey:e,values:n,components:r}=t,i=T.t(e,n),s=/<(\d+)>(.*?)<\/\d+>/g,o=[];let c=0,d;for(;(d=s.exec(i))!==null;){const[,l,u]=d,p=i.substring(c,d.index);p&&o.push(p);const m=parseInt(l,10);o.push(F4(r[m],{},u)),c=s.lastIndex}return c<i.length&&o.push(i.substring(c)),y(bm,{children:o})},i0=6,Ad=({error:t,vendorSettings:e,email:n,state:r,client:i,hasPasswordLogin:s})=>{const o=new URLSearchParams({state:r}),d=i.connections.map(({name:l})=>l).includes("auth2");return y(Fe,{title:T.t("verify_your_email"),vendorSettings:e,children:[y("div",{className:"mb-4 text-2xl font-medium",children:T.t("verify_your_email")}),y("div",{className:"mb-8 text-gray-300",children:y(ha,{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(Xt,{className:"pt-2",children:[y("input",{autoFocus:!0,type:"text",pattern:"[0-9]*",maxLength:i0,inputMode:"numeric",name:"code",placeholder:"******",className:ln("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:i0,required:!0,id:"code-input"}),t&&y(qn,{children:t}),y(Xe,{className:"sm:mt-4 !text-base",children:[y("span",{children:T.t("login")}),y(Je,{className:"text-xs",name:"arrow-right"})]}),y("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[y(Je,{className:"text-base",name:"info-bubble"}),y("div",{className:"text-sm text-gray-300 md:text-sm",children:T.t("sent_code_spam")})]}),d&&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:T.t("or")})]}),y(Xe,{Component:"a",href:`/u/${s?"enter-password":"pre-signup"}?${o.toString()}`,variant:"secondary",className:"block",children:T.t("enter_your_password_btn")})]})]}),y(vt,{state:r})]})]})},b$=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,loginSession:r,client:i}=await Ne(t,e);if(!r.authParams.username)throw new N(400,{message:"Username not found in state"});const s=await xs({userAdapter:t.env.data.users,tenant_id:i.tenant.id,username:r.authParams.username,provider:"auth2"});return t.html(y(Ad,{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"),{loginSession:r,client:i,vendorSettings:s}=await Ne(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 om(t,{client_id:i.id,authParams:r.authParams,username:r.authParams.username,otp:n})}catch(o){const c=o,d=await xs({userAdapter:t.env.data.users,tenant_id:i.tenant.id,username:r.authParams.username,provider:"auth2"});return t.html(y(Ad,{vendorSettings:s,email:r.authParams.username,state:e,client:i,error:c.message,hasPasswordLogin:!!d}),400)}}),Rm=t=>{const{vendorSettings:e,state:n}=t;return y(Fe,{title:T.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:T.t("unverified_email")}),y("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[y(Je,{className:"text-base",name:"info-bubble"}),y("div",{className:"text-sm text-gray-300 md:text-sm",children:T.t("sent_code_spam")})]}),y(vt,{state:n})]}),y(vt,{state:n})]})},$$=({width:t=22,height:e=17})=>y("svg",{width:t,height:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 576 512",children:y("path",{fill:"currentColor",d:"M288 32c-80.8 0-145.5 36.8-192.6 80.6C48.6 156 17.3 208 2.5 243.7c-3.3 7.9-3.3 16.7 0 24.6C17.3 304 48.6 356 95.4 399.4 142.5 443.2 207.2 480 288 480s145.5-36.8 192.6-80.6c46.8-43.5 78.1-95.4 93-131.1 3.3-7.9 3.3-16.7 0-24.6-14.9-35.7-46.2-87.7-93-131.1C433.5 68.8 368.8 32 288 32M144 256a144 144 0 1 1 288 0 144 144 0 1 1-288 0m144-64c0 35.3-28.7 64-64 64-7.1 0-13.9-1.2-20.3-3.3-5.5-1.8-11.9 1.6-11.7 7.4.3 6.9 1.3 13.8 3.2 20.7 13.7 51.2 66.4 81.6 117.6 67.9s81.6-66.4 67.9-117.6c-11.1-41.5-47.8-69.4-88.6-71.1-5.8-.2-9.2 6.1-7.4 11.7 2.1 6.4 3.3 13.2 3.3 20.3"})}),x$=({width:t=23,height:e=18})=>y("svg",{width:t,height:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 640 512",children:y("path",{fill:"currentColor",d:"M38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2s-6.3 25.5 4.1 33.7l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7l-105.2-82.4c39.6-40.6 66.4-86.1 79.9-118.4 3.3-7.9 3.3-16.7 0-24.6-14.9-35.7-46.2-87.7-93-131.1C465.5 68.8 400.8 32 320 32c-68.2 0-125 26.3-169.3 60.8zm184.3 144.4c25.5-23.3 59.6-37.5 96.9-37.5 79.5 0 144 64.5 144 144 0 24.9-6.3 48.3-17.4 68.7L408 294.5c8.4-19.3 10.6-41.4 4.8-63.3-11.1-41.5-47.8-69.4-88.6-71.1-5.8-.2-9.2 6.1-7.4 11.7 2.1 6.4 3.3 13.2 3.3 20.3 0 10.2-2.4 19.8-6.6 28.3l-90.3-70.8zM373 389.9c-16.4 6.5-34.3 10.1-53 10.1-79.5 0-144-64.5-144-144 0-6.9.5-13.6 1.4-20.2l-94.3-74.3c-22.8 29.7-39.1 59.3-48.6 82.2-3.3 7.9-3.3 16.7 0 24.6 14.9 35.7 46.2 87.7 93 131.1 47 43.8 111.7 80.6 192.5 80.6 47.8 0 89.9-12.9 126.2-32.5z"})}),Ed=({name:t,placeholder:e=T.t("password")})=>y("div",{className:"password-input relative mb-2",children:[y("input",{type:"password",name:t,placeholder:e,className:"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}),y("button",{type:"button","aria-label":T.t("show_password"),title:T.t("show_password"),className:"show-password-toggle-show absolute right-0 top-0 w-10 h-full rounded-r-lg text-gray-400 column hover:bg-black/5",children:y($$,{})}),y("button",{type:"button","aria-label":T.t("hide_password"),title:T.t("hide_password"),className:"show-password-toggle-hide !hidden absolute right-0 top-0 w-10 h-full rounded-r-lg text-gray-400 column hover:bg-black/5",children:y(x$,{})})]});var s0=Object.freeze,k$=Object.defineProperty,S$=(t,e)=>s0(k$(t,"raw",{value:s0(t.slice())})),o0;const ls=t=>{const{error:e,vendorSettings:n,email:r,state:i}=t,s=new URLSearchParams({state:i});return y(Fe,{title:T.t("enter_password"),vendorSettings:n,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:T.t("enter_password")}),y("div",{className:"mb-6 text-gray-300",children:T.t("enter_password_description")}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y(Xt,{className:"mb-7",children:[y("input",{type:"text",name:"username",placeholder:T.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(Ed,{name:"password"}),e&&y(qn,{children:e}),y(Xe,{className:"sm:mt-4 !text-base",children:[y("span",{children:T.t("login")}),y(Je,{className:"text-xs",name:"arrow-right"})]})]}),y("a",{href:`/u/forgot-password?${s.toString()}`,className:"text-primary hover:underline mb-4",children:T.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:T.t("or")})]}),y("form",{method:"post",action:`/u/login/identifier?${s.toString()}`,children:[y("input",{type:"hidden",name:"login_selection",value:"code"}),y("input",{type:"hidden",name:"username",value:r}),y(Xe,{variant:"secondary",className:"block",children:T.t("enter_a_code_btn")})]})]}),y(vt,{state:i})]}),pm(o0||(o0=S$([`
225
225
  <script>
226
226
  // Show password toggle
227
227
  var passwordInputs = document.querySelectorAll(".password-input");
@@ -245,10 +245,10 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
245
245
  });
246
246
  });
247
247
  <\/script>
248
- `])))]})},A$=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,loginSession:i}=await Ne(t,e);if(!i.authParams.username)throw new N(400,{message:"Username required"});return t.html(y(ds,{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,loginSession:o}=await Ne(t,e),{username:c}=o.authParams;if(!c)throw new N(400,{message:"Username required"});try{return await Hl(t,s,{...o.authParams,password:r},o)}catch(d){const l=d;return l.code==="INVALID_PASSWORD"||l.code==="USER_NOT_FOUND"?t.html(y(ds,{vendorSettings:i,email:c,error:T.t("invalid_password"),state:e,client:s}),400):l.code==="EMAIL_NOT_VERIFIED"?t.html(y(Tm,{vendorSettings:i,state:e}),400):t.html(y(ds,{vendorSettings:i,email:c,error:l.message,state:e,client:s}),400)}}),Zn=t=>{const{state:e,error:n,vendorSettings:r,email:i,code:s}=t;return y(Fe,{title:T.t("create_account_title"),vendorSettings:r,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:T.t("create_account_title")}),y("div",{className:"mb-6 text-gray-300",children:T.t("create_account_description")}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y(Xt,{children:[y("input",{type:"hidden",name:"code",value:s}),y("input",{type:"email",name:"username",placeholder:T.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:T.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:T.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(qn,{children:n}),y(Xe,{className:"sm:mt-4 !text-base",children:T.t("continue")})]}),y(vt,{state:e})]})]})},ga=t=>{const{message:e,vendorSettings:n,pageTitle:r,state:i}=t;return y(Fe,{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(vt,{state:i}):""]})},E$=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,loginSession:i}=await Ne(t,e),{username:s}=i.authParams;if(!s)throw new N(400,{message:"Username required"});return n?t.html(y(Zn,{state:e,vendorSettings:r,email:s,code:n})):t.html(y(Zn,{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,loginSession:o}=await Ne(t,e),c="Username-Password-Authentication";t.set("client_id",s.id),t.set("connection",c);const{username:d}=o.authParams;if(!d)throw new N(400,{message:"Username required"});if(n.password!==n["re-enter-password"])return t.html(y(Zn,{state:e,code:n.code,vendorSettings:i,error:T.t("create_account_passwords_didnt_match"),email:o.authParams.username}),400);if(!Vl(n.password))return t.html(y(Zn,{state:e,code:n.code,vendorSettings:i,error:T.t("create_account_weak_password"),email:o.authParams.username}),400);const l=n.code?await r.data.codes.get(s.tenant.id,n.code,"email_verification"):void 0,u=l?await r.data.loginSessions.get(s.tenant.id,l.login_id):void 0;try{if(await vr({userAdapter:t.env.data.users,tenant_id:s.tenant.id,username:d,provider:"auth2"}))throw new N(400,{message:"Invalid sign up"});const m=(u==null?void 0:u.authParams.username)===d,w=await W0(t).users.create(s.tenant.id,{user_id:`auth2|${ho()}`,email:d,email_verified:m,provider:"auth2",connection:c,is_social:!1});return await r.data.passwords.create(s.tenant.id,{user_id:w.user_id,password:await gi.hash(n.password,10),algorithm:"bcrypt"}),m?await Hl(t,s,{...o.authParams,password:n.password},o):(await ql(t,w),t.html(y(ga,{message:T.t("validate_email_body"),pageTitle:T.t("validate_email_title"),vendorSettings:i,state:e})))}catch(p){const m=await Jl(r,s.id,o.authParams.vendor_id),w=p;return t.html(y(Zn,{state:e,vendorSettings:m,error:w.message,email:d}),400)}}),Xn=t=>{const{error:e,vendorSettings:n,email:r}=t;return y(Fe,{title:T.t("reset_password_title"),vendorSettings:n,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:T.t("reset_password_title")}),y("div",{className:"mb-6 text-gray-300",children:`${T.t("reset_password_description")} ${r}`}),y("div",{className:"flex flex-1 flex-col justify-center",children:y(Xt,{children:[y(Ed,{name:"password",placeholder:T.t("enter_new_password_placeholder")}),y(Ed,{name:"re-enter-password",placeholder:T.t("reenter_new_password_placeholder")}),e&&y(qn,{children:e}),y(Xe,{className:"sm:mt-4 !text-base",children:T.t("reset_password_cta")})]})})]})},I$=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,loginSession:r}=await Ne(t,e);if(!r.authParams.username)throw new N(400,{message:"Username required"});return t.html(y(Xn,{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,loginSession:d}=await Ne(t,e);if(!d.authParams.username)throw new N(400,{message:"Username required"});if(r!==i)return t.html(y(Xn,{error:T.t("create_account_passwords_didnt_match"),vendorSettings:o,email:d.authParams.username}),400);if(!Vl(r))return t.html(y(Xn,{error:T.t("create_account_weak_password"),vendorSettings:o,email:d.authParams.username}),400);const l=await vr({userAdapter:s.data.users,tenant_id:c.tenant.id,username:d.authParams.username,provider:"auth2"});if(!l)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(Xn,{error:"Code not found or expired",vendorSettings:o,email:d.authParams.username}),400);const p={user_id:l.user_id,password:await gi.hash(r,10),algorithm:"bcrypt"};await s.data.passwords.get(c.tenant.id,l.user_id)?await s.data.passwords.update(c.tenant.id,p):await s.data.passwords.create(c.tenant.id,p),l.email_verified||await s.data.users.update(c.tenant.id,l.user_id,{email_verified:!0})}catch{return t.html(y(Xn,{error:"The password could not be reset",vendorSettings:o,email:d.authParams.username}),400)}return t.html(y(ga,{message:T.t("password_has_been_reset"),vendorSettings:o,state:e}))}),Rm=t=>{const{error:e,vendorSettings:n,email:r,state:i}=t;return y(Fe,{title:T.t("forgot_password_title"),vendorSettings:n,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:T.t("forgot_password_title")}),y("div",{className:"mb-6 text-gray-300",children:T.t("forgot_password_description")}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y(Xt,{className:"pt-2",children:[y("input",{type:"email",name:"username",placeholder:T.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(qn,{children:e}),y(Xe,{className:"sm:mt-4 !text-base",children:T.t("forgot_password_cta")})]}),y(vt,{state:i})]})]})},Bm=t=>{const{vendorSettings:e,state:n}=t;return y(Fe,{title:"Login",vendorSettings:e,children:[y("div",{className:"flex flex-1 flex-col justify-center",children:[y("div",{children:T.t("forgot_password_email_sent")}),y("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[y(Je,{className:"text-base",name:"info-bubble"}),y("div",{className:"text-sm text-gray-300 md:text-sm",children:T.t("sent_code_spam")})]})]}),y(vt,{state:n})]})},N$=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,loginSession:r}=await Ne(t,e);return t.html(y(Rm,{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,loginSession:i}=await Ne(t,e);return await g4(t,r,i.authParams.username,i.id),t.html(y(Bm,{vendorSettings:n,state:e}))}),Lm=({vendorSettings:t,state:e,user:n})=>y(Fe,{title:re("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(ha,{i18nKey:"currently_logged_in_as",components:[y("span",{className:"font-semibold text-gray-900 dark:text-white"},"span")],values:{email:n.email||""}}),y("br",{}),re("continue_with_sso_provider_headline")]}),y("div",{className:"space-y-6",children:[y(Xt,{children:y(Xe,{className:"!text-base",children:y("span",{children:T.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/login/identifier?state=${encodeURIComponent(e)}`,children:T.t("no_use_another")})]})]})}),C$=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 Ne(t,n),s=bs(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/login/identifier?state=${n}`);const c=await e.data.users.get(i.tenant.id,o.user_id);return c?t.html(y(Lm,{vendorSettings:r,state:n,user:c})):t.redirect(`/u/login/identifier?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"),{loginSession:r,client:i}=await Ne(t,n),s=bs(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/login/identifier?state=${n}`);const c=await e.data.users.get(i.tenant.id,o.user_id);return c?pn(t,{user:c,authParams:r.authParams,client:i,loginSession:r}):t.redirect(`/u/login/identifier?state=${n}`)}),Um=t=>{const{vendorSettings:e,email:n,state:r}=t;return y(Fe,{title:T.t("create_password_account_title"),vendorSettings:e,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:T.t("create_password_account_title")}),y("div",{className:"mb-6 text-gray-300",children:T.t("enter_email_for_verification_description")}),y("div",{className:"flex flex-1 flex-col justify-center",children:y(Xt,{className:"pt-2",children:[y("input",{type:"email",name:"username",placeholder:T.t("email_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",required:!0,value:n,disabled:!0}),y(Xe,{className:"sm:mt-4 !text-base",children:T.t("send")})]})}),y(vt,{state:r})]})},z$=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,loginSession:r}=await Ne(t,e),{username:i}=r.authParams;if(!i)throw new N(400,{message:"Username required"});return t.html(y(Um,{state:e,vendorSettings:n,email:i}))}).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"),{loginSession:n,client:r}=await Ne(t,e),{username:i}=n.authParams;if(!i)throw new N(400,{message:"Username required"});const s=await t.env.data.codes.create(r.tenant.id,{code_id:Mn(),code_type:"email_verification",login_id:n.id,expires_at:new Date(Date.now()+r_).toISOString()});return await f4(t,i,s.code_id,n.id),t.redirect(`/u/pre-signup-sent?state=${e}`)}),Mm=t=>{const{redirectUrl:e,vendorSettings:n}=t;return y(Fe,{title:T.t("invalid_session_title"),vendorSettings:n,children:[y("div",{className:"flex flex-1 flex-col justify-center",children:T.t("invalid_session_body")}),y("div",{className:"flex flex-1 flex-col justify-center",children:e&&y("a",{className:"block text-primary hover:text-primaryHover text-center",href:e,children:T.t("go_back")})})]})},O$=new a.OpenAPIHono().openapi(a.createRoute({tags:["login"],method:"get",path:"/",request:{query:a.z.object({state:a.z.string()})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,loginSession:r}=await Ne(t,e);let i;return r.authParams.redirect_uri&&r.authParams.state&&(i=new URL(r.authParams.redirect_uri),i.searchParams.set("state",r.authParams.state),i.searchParams.set("error","invalid_session"),i.searchParams.set("error_description",r.authParams.username||"")),t.html(y(Mm,{redirectUrl:i==null?void 0:i.href,vendorSettings:n}))}),P$=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 e=await Jl(t.env),{state:n}=t.req.valid("query");return t.html(y(ga,{message:"Not implemented",pageTitle:"User info",vendorSettings:e,state:n}))}),Fm=({vendorSettings:t,state:e})=>{const n=new URLSearchParams({state:e});return y(Fe,{title:T.t("email_validated"),vendorSettings:t,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:T.t("email_validated")}),y("div",{className:"flex flex-1 flex-col justify-center mb-7",children:y(Xe,{Component:"a",href:`/u/enter-password?${n}`,className:"text-base sm:mt-4 md:text-base",children:y("div",{className:"flex items-center space-x-2",children:[y("span",{children:T.t("email_validated_cta")}),y(Je,{className:"text-xs",name:"arrow-right"})]})})})]})},j$=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=>{var m;const{state:e,code:n}=t.req.valid("query"),{env:r}=t,{client:i,loginSession:s,vendorSettings:o}=await Ne(t,e),{username:c}=s.authParams;if(!c)throw new N(400,{message:"Username not found in state"});const d=await vr({userAdapter:r.data.users,tenant_id:i.tenant.id,username:c,provider:"auth2"});if(!d)throw new N(500,{message:"No user found"});if(!await r.data.codes.get(i.tenant.id,n,"email_verification"))throw new N(400,{message:"Code not found or expired"});await r.data.users.update(i.tenant.id,d.user_id,{email_verified:!0});const p=(await Md(r.data.users,i.tenant.id,c)).filter(w=>w.provider!=="auth2");if(p.length>0){const w=p.filter(h=>!h.linked_to);w.length>1&&console.error("More than one primary user found for email",c),w.length===0&&console.error("No primary user found for email",c),w.length===1&&await r.data.users.update(i.tenant.id,d.user_id,{linked_to:(m=w[0])==null?void 0:m.user_id})}return t.html(y(Fm,{vendorSettings:o,state:e}))}),Vm=t=>{const{vendorSettings:e,email:n,state:r}=t;return y(Fe,{title:T.t("email_verification_for_signup_sent_title"),vendorSettings:e,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:T.t("email_verification_for_signup_sent_title")}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y("div",{className:"mb-6 text-gray-300",children:y(ha,{i18nKey:"email_verification_for_signup_sent_description",components:[y("span",{className:"text-black dark:text-white"},"span")],values:{email:n}})}),y("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[y(Je,{className:"text-base",name:"info-bubble"}),y("div",{className:"text-sm text-gray-300 md:text-sm",children:T.t("sent_code_spam")})]})]}),y(vt,{state:r})]})},T$=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,loginSession:r}=await Ne(t,e),{username:i}=r.authParams;if(!i)throw new N(400,{message:"Username required"});return t.html(y(Vm,{vendorSettings:n,state:e,email:i}))}),Yl=`
248
+ `])))]})},A$=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,loginSession:i}=await Ne(t,e);if(!i.authParams.username)throw new N(400,{message:"Username required"});return t.html(y(ls,{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,loginSession:o}=await Ne(t,e),{username:c}=o.authParams;if(!c)throw new N(400,{message:"Username required"});try{return await Hl(t,s,{...o.authParams,password:r},o)}catch(d){const l=d;return l.code==="INVALID_PASSWORD"||l.code==="USER_NOT_FOUND"?t.html(y(ls,{vendorSettings:i,email:c,error:T.t("invalid_password"),state:e,client:s}),400):l.code==="EMAIL_NOT_VERIFIED"?t.html(y(Rm,{vendorSettings:i,state:e}),400):t.html(y(ls,{vendorSettings:i,email:c,error:l.message,state:e,client:s}),400)}}),Zn=t=>{const{state:e,error:n,vendorSettings:r,email:i,code:s}=t;return y(Fe,{title:T.t("create_account_title"),vendorSettings:r,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:T.t("create_account_title")}),y("div",{className:"mb-6 text-gray-300",children:T.t("create_account_description")}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y(Xt,{children:[y("input",{type:"hidden",name:"code",value:s}),y("input",{type:"email",name:"username",placeholder:T.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:T.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:T.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(qn,{children:n}),y(Xe,{className:"sm:mt-4 !text-base",children:T.t("continue")})]}),y(vt,{state:e})]})]})},ga=t=>{const{message:e,vendorSettings:n,pageTitle:r,state:i}=t;return y(Fe,{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(vt,{state:i}):""]})},E$=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,loginSession:i}=await Ne(t,e),{username:s}=i.authParams;if(!s)throw new N(400,{message:"Username required"});return n?t.html(y(Zn,{state:e,vendorSettings:r,email:s,code:n})):t.html(y(Zn,{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,loginSession:o}=await Ne(t,e),c="Username-Password-Authentication";t.set("client_id",s.id),t.set("connection",c);const{username:d}=o.authParams;if(!d)throw new N(400,{message:"Username required"});if(n.password!==n["re-enter-password"])return t.html(y(Zn,{state:e,code:n.code,vendorSettings:i,error:T.t("create_account_passwords_didnt_match"),email:o.authParams.username}),400);if(!Vl(n.password))return t.html(y(Zn,{state:e,code:n.code,vendorSettings:i,error:T.t("create_account_weak_password"),email:o.authParams.username}),400);const l=n.code?await r.data.codes.get(s.tenant.id,n.code,"email_verification"):void 0,u=l?await r.data.loginSessions.get(s.tenant.id,l.login_id):void 0;try{if(await vr({userAdapter:t.env.data.users,tenant_id:s.tenant.id,username:d,provider:"auth2"}))throw new N(400,{message:"Invalid sign up"});const m=(u==null?void 0:u.authParams.username)===d,w=await W0(t).users.create(s.tenant.id,{user_id:`auth2|${go()}`,email:d,email_verified:m,provider:"auth2",connection:c,is_social:!1});return await r.data.passwords.create(s.tenant.id,{user_id:w.user_id,password:await mi.hash(n.password,10),algorithm:"bcrypt"}),m?await Hl(t,s,{...o.authParams,password:n.password},o):(await ql(t,w),t.html(y(ga,{message:T.t("validate_email_body"),pageTitle:T.t("validate_email_title"),vendorSettings:i,state:e})))}catch(p){const m=await Jl(r,s.id,o.authParams.vendor_id),w=p;return t.html(y(Zn,{state:e,vendorSettings:m,error:w.message,email:d}),400)}}),Xn=t=>{const{error:e,vendorSettings:n,email:r}=t;return y(Fe,{title:T.t("reset_password_title"),vendorSettings:n,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:T.t("reset_password_title")}),y("div",{className:"mb-6 text-gray-300",children:`${T.t("reset_password_description")} ${r}`}),y("div",{className:"flex flex-1 flex-col justify-center",children:y(Xt,{children:[y(Ed,{name:"password",placeholder:T.t("enter_new_password_placeholder")}),y(Ed,{name:"re-enter-password",placeholder:T.t("reenter_new_password_placeholder")}),e&&y(qn,{children:e}),y(Xe,{className:"sm:mt-4 !text-base",children:T.t("reset_password_cta")})]})})]})},I$=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,loginSession:r}=await Ne(t,e);if(!r.authParams.username)throw new N(400,{message:"Username required"});return t.html(y(Xn,{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,loginSession:d}=await Ne(t,e);if(!d.authParams.username)throw new N(400,{message:"Username required"});if(r!==i)return t.html(y(Xn,{error:T.t("create_account_passwords_didnt_match"),vendorSettings:o,email:d.authParams.username}),400);if(!Vl(r))return t.html(y(Xn,{error:T.t("create_account_weak_password"),vendorSettings:o,email:d.authParams.username}),400);const l=await vr({userAdapter:s.data.users,tenant_id:c.tenant.id,username:d.authParams.username,provider:"auth2"});if(!l)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(Xn,{error:"Code not found or expired",vendorSettings:o,email:d.authParams.username}),400);const p={user_id:l.user_id,password:await mi.hash(r,10),algorithm:"bcrypt"};await s.data.passwords.get(c.tenant.id,l.user_id)?await s.data.passwords.update(c.tenant.id,p):await s.data.passwords.create(c.tenant.id,p),l.email_verified||await s.data.users.update(c.tenant.id,l.user_id,{email_verified:!0})}catch{return t.html(y(Xn,{error:"The password could not be reset",vendorSettings:o,email:d.authParams.username}),400)}return t.html(y(ga,{message:T.t("password_has_been_reset"),vendorSettings:o,state:e}))}),Bm=t=>{const{error:e,vendorSettings:n,email:r,state:i}=t;return y(Fe,{title:T.t("forgot_password_title"),vendorSettings:n,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:T.t("forgot_password_title")}),y("div",{className:"mb-6 text-gray-300",children:T.t("forgot_password_description")}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y(Xt,{className:"pt-2",children:[y("input",{type:"email",name:"username",placeholder:T.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(qn,{children:e}),y(Xe,{className:"sm:mt-4 !text-base",children:T.t("forgot_password_cta")})]}),y(vt,{state:i})]})]})},Lm=t=>{const{vendorSettings:e,state:n}=t;return y(Fe,{title:"Login",vendorSettings:e,children:[y("div",{className:"flex flex-1 flex-col justify-center",children:[y("div",{children:T.t("forgot_password_email_sent")}),y("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[y(Je,{className:"text-base",name:"info-bubble"}),y("div",{className:"text-sm text-gray-300 md:text-sm",children:T.t("sent_code_spam")})]})]}),y(vt,{state:n})]})},N$=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,loginSession:r}=await Ne(t,e);return t.html(y(Bm,{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,loginSession:i}=await Ne(t,e);return await g4(t,r,i.authParams.username,i.id),t.html(y(Lm,{vendorSettings:n,state:e}))}),Um=({vendorSettings:t,state:e,user:n})=>y(Fe,{title:re("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(ha,{i18nKey:"currently_logged_in_as",components:[y("span",{className:"font-semibold text-gray-900 dark:text-white"},"span")],values:{email:n.email||""}}),y("br",{}),re("continue_with_sso_provider_headline")]}),y("div",{className:"space-y-6",children:[y(Xt,{children:y(Xe,{className:"!text-base",children:y("span",{children:T.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/login/identifier?state=${encodeURIComponent(e)}`,children:T.t("no_use_another")})]})]})}),C$=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 Ne(t,n),s=$s(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/login/identifier?state=${n}`);const c=await e.data.users.get(i.tenant.id,o.user_id);return c?t.html(y(Um,{vendorSettings:r,state:n,user:c})):t.redirect(`/u/login/identifier?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"),{loginSession:r,client:i}=await Ne(t,n),s=$s(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/login/identifier?state=${n}`);const c=await e.data.users.get(i.tenant.id,o.user_id);return c?pn(t,{user:c,authParams:r.authParams,client:i,loginSession:r}):t.redirect(`/u/login/identifier?state=${n}`)}),Mm=t=>{const{vendorSettings:e,email:n,state:r}=t;return y(Fe,{title:T.t("create_password_account_title"),vendorSettings:e,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:T.t("create_password_account_title")}),y("div",{className:"mb-6 text-gray-300",children:T.t("enter_email_for_verification_description")}),y("div",{className:"flex flex-1 flex-col justify-center",children:y(Xt,{className:"pt-2",children:[y("input",{type:"email",name:"username",placeholder:T.t("email_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",required:!0,value:n,disabled:!0}),y(Xe,{className:"sm:mt-4 !text-base",children:T.t("send")})]})}),y(vt,{state:r})]})},z$=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,loginSession:r}=await Ne(t,e),{username:i}=r.authParams;if(!i)throw new N(400,{message:"Username required"});return t.html(y(Mm,{state:e,vendorSettings:n,email:i}))}).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"),{loginSession:n,client:r}=await Ne(t,e),{username:i}=n.authParams;if(!i)throw new N(400,{message:"Username required"});const s=await t.env.data.codes.create(r.tenant.id,{code_id:Mn(),code_type:"email_verification",login_id:n.id,expires_at:new Date(Date.now()+i_).toISOString()});return await f4(t,i,s.code_id,n.id),t.redirect(`/u/pre-signup-sent?state=${e}`)}),Fm=t=>{const{redirectUrl:e,vendorSettings:n}=t;return y(Fe,{title:T.t("invalid_session_title"),vendorSettings:n,children:[y("div",{className:"flex flex-1 flex-col justify-center",children:T.t("invalid_session_body")}),y("div",{className:"flex flex-1 flex-col justify-center",children:e&&y("a",{className:"block text-primary hover:text-primaryHover text-center",href:e,children:T.t("go_back")})})]})},O$=new a.OpenAPIHono().openapi(a.createRoute({tags:["login"],method:"get",path:"/",request:{query:a.z.object({state:a.z.string()})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,loginSession:r}=await Ne(t,e);let i;return r.authParams.redirect_uri&&r.authParams.state&&(i=new URL(r.authParams.redirect_uri),i.searchParams.set("state",r.authParams.state),i.searchParams.set("error","invalid_session"),i.searchParams.set("error_description",r.authParams.username||"")),t.html(y(Fm,{redirectUrl:i==null?void 0:i.href,vendorSettings:n}))}),P$=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 e=await Jl(t.env),{state:n}=t.req.valid("query");return t.html(y(ga,{message:"Not implemented",pageTitle:"User info",vendorSettings:e,state:n}))}),Vm=({vendorSettings:t,state:e})=>{const n=new URLSearchParams({state:e});return y(Fe,{title:T.t("email_validated"),vendorSettings:t,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:T.t("email_validated")}),y("div",{className:"flex flex-1 flex-col justify-center mb-7",children:y(Xe,{Component:"a",href:`/u/enter-password?${n}`,className:"text-base sm:mt-4 md:text-base",children:y("div",{className:"flex items-center space-x-2",children:[y("span",{children:T.t("email_validated_cta")}),y(Je,{className:"text-xs",name:"arrow-right"})]})})})]})},j$=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=>{var m;const{state:e,code:n}=t.req.valid("query"),{env:r}=t,{client:i,loginSession:s,vendorSettings:o}=await Ne(t,e),{username:c}=s.authParams;if(!c)throw new N(400,{message:"Username not found in state"});const d=await vr({userAdapter:r.data.users,tenant_id:i.tenant.id,username:c,provider:"auth2"});if(!d)throw new N(500,{message:"No user found"});if(!await r.data.codes.get(i.tenant.id,n,"email_verification"))throw new N(400,{message:"Code not found or expired"});await r.data.users.update(i.tenant.id,d.user_id,{email_verified:!0});const p=(await Md(r.data.users,i.tenant.id,c)).filter(w=>w.provider!=="auth2");if(p.length>0){const w=p.filter(h=>!h.linked_to);w.length>1&&console.error("More than one primary user found for email",c),w.length===0&&console.error("No primary user found for email",c),w.length===1&&await r.data.users.update(i.tenant.id,d.user_id,{linked_to:(m=w[0])==null?void 0:m.user_id})}return t.html(y(Vm,{vendorSettings:o,state:e}))}),Dm=t=>{const{vendorSettings:e,email:n,state:r}=t;return y(Fe,{title:T.t("email_verification_for_signup_sent_title"),vendorSettings:e,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:T.t("email_verification_for_signup_sent_title")}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y("div",{className:"mb-6 text-gray-300",children:y(ha,{i18nKey:"email_verification_for_signup_sent_description",components:[y("span",{className:"text-black dark:text-white"},"span")],values:{email:n}})}),y("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[y(Je,{className:"text-base",name:"info-bubble"}),y("div",{className:"text-sm text-gray-300 md:text-sm",children:T.t("sent_code_spam")})]})]}),y(vt,{state:r})]})},T$=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,loginSession:r}=await Ne(t,e),{username:i}=r.authParams;if(!i)throw new N(400,{message:"Username required"});return t.html(y(Dm,{vendorSettings:n,state:e,email:i}))}),Yl=`
249
249
  @font-face{font-display:swap;font-family:KHTeka;font-style:normal;font-weight:400;src:url(https://assets.sesamy.com/fonts/khteka/WOFF2/KHTeka-Regular.woff2) format("woff2")}@font-face{font-display:swap;font-family:KHTeka;font-style:normal;font-weight:500;src:url(https://assets.sesamy.com/fonts/khteka/WOFF2/KHTeka-Medium.woff2) format("woff2")}@font-face{font-display:swap;font-family:KHTeka;font-style:normal;font-weight:600;src:url(https://assets.sesamy.com/fonts/khteka/WOFF2/KHTeka-Bold.woff2) format("woff2")}@font-face{font-family:uicon;src:url(https://login2.sesamy.com/_next/static/media/uicon.0b00e08a.woff2)}[class*=" uicon-"],[class^=uicon-]{font-family:uicon!important;font-size:inherit;font-style:normal;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.uicon-apple:before{content:"\\ea01"}.uicon-arrow-down:before{content:"\\ea02"}.uicon-arrow-left:before{content:"\\ea03"}.uicon-arrow-right:before{content:"\\ea04"}.uicon-arrow-up:before{content:"\\ea05"}.uicon-facebook:before{content:"\\ea06"}.uicon-google:before{content:"\\ea07"}.uicon-info-bubble:before{content:"\\ea08"}.uicon-info:before{content:"\\ea09"}.uicon-sesamy:before{content:"\\ea0a"}.uicon-spinner-circle:before{content:"\\ea0b"}.uicon-spinner-inner:before{content:"\\ea0c"}
250
250
 
251
- /*! tailwindcss v3.4.1 | MIT License | https://tailwindcss.com*/*,:after,:before{border:0 solid #bfbcd7;box-sizing:border-box}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;font-family:KHTeka,Helvetica Neue,HelveticaNeue,TeX Gyre Heros,TeXGyreHeros,FreeSans,Nimbus Sans L,Liberation Sans,Arimo,Helvetica,sans-serif;font-feature-settings:normal;font-variation-settings:normal;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-tap-highlight-color:transparent}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-size:1em;font-variation-settings:normal}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{color:inherit;font-family:inherit;font-feature-settings:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{color:#4b4a58;opacity:1}input::placeholder,textarea::placeholder{color:#4b4a58;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]{display:none}body,html{height:100%}body{--tw-bg-opacity:1;background-color:rgb(248 249 251/var(--tw-bg-opacity));font-size:1rem;letter-spacing:.0125rem;line-height:120%;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}@media (min-width:1280px){body{font-size:1.125rem;line-height:120%}}:is(.dark body){--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}button,input,optgroup,select,textarea{font-size:.875rem;letter-spacing:.0125rem;line-height:120%}@media (min-width:1280px){button,input,optgroup,select,textarea{font-size:1rem;line-height:120%}}h1{font-size:1.5rem;font-weight:500;line-height:120%}@media (min-width:1280px){h1{font-size:2rem;line-height:120%}}@media (min-width:640px){h1{font-size:3rem;letter-spacing:-.0625rem;line-height:100%}}@media (min-width:1280px){h1{font-size:3.5rem;letter-spacing:-.0625rem;line-height:100%}}h2{font-size:1.25rem;font-weight:500;line-height:120%}@media (min-width:1280px){h2{font-size:1.5rem;line-height:120%}}@media (min-width:640px){h2{font-size:2rem;letter-spacing:0;line-height:120%}}@media (min-width:1280px){h2{font-size:3rem;letter-spacing:-.0625rem;line-height:100%}}h3{font-size:1.125rem;font-weight:500;line-height:120%}@media (min-width:1280px){h3{font-size:1.25rem;line-height:120%}}@media (min-width:640px){h3{font-size:1.5rem;line-height:120%}}@media (min-width:1280px){h3{font-size:2rem;line-height:120%}}h4{font-size:1rem;font-weight:500;line-height:120%}@media (min-width:1280px){h4{font-size:1.125rem;line-height:120%}}@media (min-width:640px){h4{font-size:1.125rem;line-height:120%}}@media (min-width:1280px){h4{font-size:1.5rem;line-height:120%}}h5{font-size:.875rem;font-weight:500;line-height:120%}@media (min-width:1280px){h5{font-size:1rem;line-height:120%}}@media (min-width:640px){h5{font-size:1rem;line-height:120%}}@media (min-width:1280px){h5{font-size:1.125rem;line-height:120%}}h6{font-size:.75rem;font-weight:500;line-height:135%}@media (min-width:1280px){h6{font-size:.875rem;line-height:120%}}@media (min-width:640px){h6{font-size:.875rem;line-height:120%}}@media (min-width:1280px){h6{font-size:1rem;line-height:120%}}*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.pointer-events-none{pointer-events:none}.absolute{position:absolute}.relative{position:relative}.inset-0{inset:0}.left-0{left:0}.right-0{right:0}.top-0{top:0}.top-1\\/2{top:50%}.my-4{margin-bottom:1rem;margin-top:1rem}.mb-12{margin-bottom:3rem}.mb-16{margin-bottom:4rem}.mb-2{margin-bottom:.5rem}.mb-4{margin-bottom:1rem}.mb-5{margin-bottom:1.25rem}.mb-6{margin-bottom:1.5rem}.mb-7{margin-bottom:1.75rem}.mb-8{margin-bottom:2rem}.mt-8{margin-top:2rem}.block{display:block}.inline-block{display:inline-block}.flex{display:flex}.\\!hidden{display:none!important}.hidden{display:none}.h-5{height:1.25rem}.h-9{height:2.25rem}.h-full{height:100%}.max-h-full{max-height:100%}.min-h-\\[calc\\(100vh-83px\\)\\]{min-height:calc(100vh - 83px)}.min-h-full{min-height:100%}.w-10{width:2.5rem}.w-5{width:1.25rem}.w-\\[calc\\(100\\%-theme\\(space\\.2\\)-theme\\(space\\.2\\)\\)\\]{width:calc(100% - 1rem)}.w-full{width:100%}.max-w-\\[1295px\\]{max-width:1295px}.flex-1{flex:1 1 0%}@keyframes spin{to{transform:rotate(1turn)}}.animate-spin{animation:spin 1s linear infinite}.cursor-not-allowed{cursor:not-allowed}.flex-col{flex-direction:column}.\\!flex-nowrap{flex-wrap:nowrap!important}.items-center{align-items:center}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.5rem*var(--tw-space-x-reverse))}.space-x-4>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(1rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(1rem*var(--tw-space-x-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1.5rem*var(--tw-space-y-reverse));margin-top:calc(1.5rem*(1 - var(--tw-space-y-reverse)))}.overflow-hidden{overflow:hidden}.rounded-2xl{border-radius:1.25rem}.rounded-lg{border-radius:.625rem}.rounded-r-lg{border-bottom-right-radius:.625rem;border-top-right-radius:.625rem}.border{border-width:1px}.border-b{border-bottom-width:1px}.border-gray-100{--tw-border-opacity:1;border-color:rgb(248 249 251/var(--tw-border-opacity))}.border-gray-200{--tw-border-opacity:1;border-color:rgb(191 188 215/var(--tw-border-opacity))}.border-gray-300{--tw-border-opacity:1;border-color:rgb(136 134 159/var(--tw-border-opacity))}.border-gray-500{--tw-border-opacity:1;border-color:rgb(59 57 70/var(--tw-border-opacity))}.border-red{--tw-border-opacity:1;border-color:rgb(252 90 90/var(--tw-border-opacity))}.bg-gray-100{--tw-bg-opacity:1;background-color:rgb(248 249 251/var(--tw-bg-opacity))}.bg-primary{background-color:var(--primary-color)}.bg-primaryHover{background-color:var(--primary-hover)}.bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}.bg-cover{background-size:cover}.bg-center{background-position:50%}.px-0{padding-left:0;padding-right:0}.px-10{padding-left:2.5rem;padding-right:2.5rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-4{padding-left:1rem;padding-right:1rem}.px-5{padding-left:1.25rem;padding-right:1.25rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.py-10{padding-bottom:2.5rem;padding-top:2.5rem}.py-2{padding-bottom:.5rem;padding-top:.5rem}.py-3{padding-bottom:.75rem;padding-top:.75rem}.py-5{padding-bottom:1.25rem;padding-top:1.25rem}.pb-2{padding-bottom:.5rem}.pb-8{padding-bottom:2rem}.pt-2{padding-top:.5rem}.pt-2\\.5{padding-top:.625rem}.pt-4{padding-top:1rem}.text-left{text-align:left}.text-center{text-align:center}.indent-\\[5px\\]{text-indent:5px}.font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.\\!text-base{font-size:1rem!important;line-height:120%!important}.text-2xl{font-size:1.5rem;line-height:120%}.text-3xl{font-size:2rem;line-height:120%}.text-base{font-size:1rem;line-height:120%}.text-lg{font-size:1.125rem;line-height:120%}.text-sm{font-size:.875rem;line-height:120%}.text-xl{font-size:1.25rem;line-height:120%}.text-xs{font-size:.75rem;line-height:135%}.font-medium{font-weight:500}.font-semibold{font-weight:600}.leading-\\[0\\]{line-height:0}.text-\\[\\#1196F5\\]{--tw-text-opacity:1;color:rgb(17 150 245/var(--tw-text-opacity))}.text-\\[\\#B2B2B2\\]{--tw-text-opacity:1;color:rgb(178 178 178/var(--tw-text-opacity))}.text-black{--tw-text-opacity:1;color:rgb(0 0 0/var(--tw-text-opacity))}.text-gray-200{--tw-text-opacity:1;color:rgb(191 188 215/var(--tw-text-opacity))}.text-gray-300{--tw-text-opacity:1;color:rgb(136 134 159/var(--tw-text-opacity))}.text-gray-400{--tw-text-opacity:1;color:rgb(75 74 88/var(--tw-text-opacity))}.text-gray-700{--tw-text-opacity:1;color:rgb(30 30 39/var(--tw-text-opacity))}.text-gray-900{--tw-text-opacity:1;color:rgb(8 8 14/var(--tw-text-opacity))}.text-primary{color:var(--primary-color)}.text-red{--tw-text-opacity:1;color:rgb(252 90 90/var(--tw-text-opacity))}.text-textOnPrimary{color:var(--text-on-primary)}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}.opacity-40{opacity:.4}.row-up-left{align-content:flex-start;justify-content:flex-start}.row,.row-up-left{display:flex;flex-direction:row;flex-wrap:wrap}.row{align-content:center;align-items:center;justify-content:center}.column-left{align-items:flex-start}.column,.column-left{display:flex;flex-direction:column;justify-content:center}.column{align-items:center}@media (min-width:1280px){.text-5xl{font-size:5.125rem;letter-spacing:-.125rem;line-height:100%}.text-4xl{font-size:3.5rem}.text-3xl,.text-4xl{letter-spacing:-.0625rem;line-height:100%}.text-3xl{font-size:3rem}.text-2xl{font-size:2rem}.text-2xl,.text-xl{line-height:120%}.text-xl{font-size:1.5rem}.text-lg{font-size:1.25rem}.text-base,.text-lg{line-height:120%}.text-base{font-size:1.125rem}.text-sm{font-size:1rem}.text-sm,.text-xs{line-height:120%}.text-xs{font-size:.875rem}}:root{--primary-color:#7d68f4;--primary-hover:#7e69f4;--text-on-primary:#fff}svg{transform:translate3d(var(--tw-translate-x),var(--tw-translate-y),0) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}*,:after,:before{text-underline-offset:4px}input[type=number],input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-spin-button{-webkit-appearance:none;-moz-appearance:textfield!important}.btn.is-loading{cursor:not-allowed;opacity:.4;pointer-events:none}.btn .btn-spinner,.btn.is-loading .btn-label{opacity:0;visibility:hidden}.btn.is-loading .btn-spinner{opacity:1;visibility:visible}[class*=" uicon-"],[class^=uicon-]{letter-spacing:0;line-height:100%}.placeholder\\:text-gray-300::-moz-placeholder{--tw-text-opacity:1;color:rgb(136 134 159/var(--tw-text-opacity))}.placeholder\\:text-gray-300::placeholder{--tw-text-opacity:1;color:rgb(136 134 159/var(--tw-text-opacity))}.hover\\:bg-black\\/5:hover{background-color:rgba(0,0,0,.05)}.hover\\:bg-gray-100:hover{--tw-bg-opacity:1;background-color:rgb(248 249 251/var(--tw-bg-opacity))}.hover\\:bg-primaryHover:hover{background-color:var(--primary-hover)}.hover\\:text-primaryHover:hover{color:var(--primary-hover)}.hover\\:underline:hover{text-decoration-line:underline}.focus\\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\\:ring:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(3px + var(--tw-ring-offset-width)) var(--tw-ring-color)}.focus\\:ring-2:focus,.focus\\:ring:focus{box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus\\:ring-2:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color)}.focus\\:ring-primary:focus{--tw-ring-color:var(--primary-color)}.focus\\:ring-offset-2:focus{--tw-ring-offset-width:2px}:is(.dark .dark\\:border-gray-400){--tw-border-opacity:1;border-color:rgb(75 74 88/var(--tw-border-opacity))}:is(.dark .dark\\:border-gray-500){--tw-border-opacity:1;border-color:rgb(59 57 70/var(--tw-border-opacity))}:is(.dark .dark\\:border-gray-600){--tw-border-opacity:1;border-color:rgb(40 40 52/var(--tw-border-opacity))}:is(.dark .dark\\:bg-black){--tw-bg-opacity:1;background-color:rgb(0 0 0/var(--tw-bg-opacity))}:is(.dark .dark\\:bg-gray-600){--tw-bg-opacity:1;background-color:rgb(40 40 52/var(--tw-bg-opacity))}:is(.dark .dark\\:bg-gray-800){--tw-bg-opacity:1;background-color:rgb(20 20 26/var(--tw-bg-opacity))}:is(.dark .dark\\:text-\\[\\#201a41\\]){--tw-text-opacity:1;color:rgb(32 26 65/var(--tw-text-opacity))}:is(.dark .dark\\:text-gray-300){--tw-text-opacity:1;color:rgb(136 134 159/var(--tw-text-opacity))}:is(.dark .dark\\:text-white){--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}:is(.dark .dark\\:hover\\:bg-black\\/90:hover){background-color:rgba(0,0,0,.9)}:is(.dark .dark\\:focus\\:ring-offset-gray-900:focus){--tw-ring-offset-color:#08080e}@media (min-width:640px){.sm\\:absolute{position:absolute}.sm\\:left-4{left:1rem}.sm\\:top-1\\/2{top:50%}.sm\\:mt-4{margin-top:1rem}.sm\\:inline{display:inline}.sm\\:h-6{height:1.5rem}.sm\\:min-h-\\[700px\\]{min-height:700px}.sm\\:w-6{width:1.5rem}.sm\\:w-\\[calc\\(100\\%-theme\\(space\\.16\\)-theme\\(space\\.16\\)\\)\\]{width:calc(100% - 8rem)}.sm\\:w-auto{width:auto}.sm\\:max-w-md{max-width:28rem}.sm\\:-translate-y-1\\/2{--tw-translate-y:-50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.sm\\:flex-col{flex-direction:column}.sm\\:justify-normal{justify-content:normal}.sm\\:space-x-0>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(0px*(1 - var(--tw-space-x-reverse)));margin-right:calc(0px*var(--tw-space-x-reverse))}.sm\\:space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1rem*var(--tw-space-y-reverse));margin-top:calc(1rem*(1 - var(--tw-space-y-reverse)))}.sm\\:bg-fixed{background-attachment:fixed}.sm\\:bg-left-top{background-position:0 0}.sm\\:px-10{padding-left:2.5rem;padding-right:2.5rem}.sm\\:px-14{padding-left:3.5rem;padding-right:3.5rem}.sm\\:py-14{padding-bottom:3.5rem;padding-top:3.5rem}.sm\\:py-4{padding-bottom:1rem;padding-top:1rem}.sm\\:pt-16{padding-top:4rem}.sm\\:text-2xl{font-size:1.5rem;line-height:120%}.sm\\:text-base{font-size:1rem;line-height:120%}}@media (min-width:1280px){.md\\:min-w-\\[448px\\]{min-width:448px}.md\\:text-3xl{font-size:2rem;line-height:120%}.md\\:text-base{font-size:1rem;line-height:120%}.md\\:text-sm{font-size:.875rem;line-height:120%}.md\\:text-xs{font-size:.75rem;line-height:135%}}@media (max-height:900px) and (min-width:640px){.short\\:static{position:static}.short\\:left-auto{left:auto}.short\\:top-auto{top:auto}.short\\:hidden{display:none}.short\\:h-5{height:1.25rem}.short\\:min-h-\\[558px\\]{min-height:558px}.short\\:w-5{width:1.25rem}.short\\:translate-y-0{--tw-translate-y:0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.short\\:flex-row{flex-direction:row}.short\\:space-x-4>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(1rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(1rem*var(--tw-space-x-reverse))}.short\\:space-y-0>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(0px*var(--tw-space-y-reverse));margin-top:calc(0px*(1 - var(--tw-space-y-reverse)))}.short\\:px-0{padding-left:0;padding-right:0}.short\\:py-3{padding-bottom:.75rem;padding-top:.75rem}.short\\:text-xl{font-size:1.25rem;line-height:120%}}`;function R$(){if(typeof document<"u"){const t=document.createElement("style");t.innerHTML=Yl,t.setAttribute("data-authhero-tailwind",""),document.head.appendChild(t)}}function B$(t){const e=new a.OpenAPIHono;e.use(async(r,i)=>{const s=yo(r,t.dataAdapter),o=Ol(s,{defaultTtl:3e5,cacheEntities:["tenants","connections","clients"]});return r.env.data=Cl(r,o),i()}).use(zl),e.get("/css/tailwind.css",async r=>{const i=Yl;return r.text(i,200,{"content-type":"text/css; charset=utf-8"})});const n=e.route("/info",P$).route("/check-account",C$).route("/login/identifier",Y4).route("/enter-code",b$).route("/enter-password",A$).route("/invalid-session",O$).route("/pre-signup",z$).route("/pre-signup-sent",T$).route("/reset-password",I$).route("/forgot-password",N$).route("/validate-email",j$).route("/signup",E$);return n.doc("/u/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Universal login"}}),n}const L$="Account detected",U$="We have detected that you have already created an account through",M$="By signing in, you agree to our",F$="and",V$="Callback URL mismatch",D$="The provided redirect_uri is not in the list of allowed callback URLs.",q$="continue with user",H$="Please click the button to create a new password account.",K$="Enter the code at {{vendorName}} to complete the login",G$="Welcome to {{vendorName}}! {{code}} is the login code",W$="Welcome to {{vendorName}}! {{code}} is the login code",J$="The code is valid for 30 minutes",Z$="Confirm password",X$="Need Help?",Y$="Contact us",Q$="or continue with social account",e6="Continue with {{provider}}",t6="Would you like to continue with your existing account?",n6="Copyright © 2023 SESAMY. All rights reserved.",r6="©2023 Sesamy",i6="Choose a password with a mix of uppercase and lowercase letters, numbers, and symbols.",s6="Please enter a valid email address.",o6="The passwords didn't match. Try again.",a6="Choose password",c6="Password must be at least 8 characters long and contain at least one lowercase letter, one uppercase letter, one number and one symbol.",d6="Create new account",l6="Sign up with password",u6="You are currently logged in as <0>{{email}}</0>",f6="Email",p6="Email or Phone Number",h6="Email address",g6="Your email address has been validated",m6="Now enter your password to login again",_6="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.",y6="Email verification sent",w6="Enter a code",v6="We'll send you a verification link to ensure you own this email address.",b6="Enter new password",$6="Enter password",x6="Enter your email address and password to login.",k6="Enter your password",S6="The magic link has expired. Please click on the button below to receive a new link in your inbox.",A6="Hey! We updated our login experience. <0>Click here to learn more about it.</0>",E6="Send password reset email",I6="Click the button below and we’ll send instructions on how to reset your password.",N6="Password reset email sent",C6="Forgot password?",z6="Forgot password?",O6="Go back",P6="Hide password",j6="Invalid password",T6=`The link is no longer valid.
251
+ /*! tailwindcss v3.4.1 | MIT License | https://tailwindcss.com*/*,:after,:before{border:0 solid #bfbcd7;box-sizing:border-box}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;font-family:KHTeka,Helvetica Neue,HelveticaNeue,TeX Gyre Heros,TeXGyreHeros,FreeSans,Nimbus Sans L,Liberation Sans,Arimo,Helvetica,sans-serif;font-feature-settings:normal;font-variation-settings:normal;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-tap-highlight-color:transparent}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-size:1em;font-variation-settings:normal}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{color:inherit;font-family:inherit;font-feature-settings:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{color:#4b4a58;opacity:1}input::placeholder,textarea::placeholder{color:#4b4a58;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]{display:none}body,html{height:100%}body{--tw-bg-opacity:1;background-color:rgb(248 249 251/var(--tw-bg-opacity));font-size:1rem;letter-spacing:.0125rem;line-height:120%;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}@media (min-width:1280px){body{font-size:1.125rem;line-height:120%}}:is(.dark body){--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}button,input,optgroup,select,textarea{font-size:.875rem;letter-spacing:.0125rem;line-height:120%}@media (min-width:1280px){button,input,optgroup,select,textarea{font-size:1rem;line-height:120%}}h1{font-size:1.5rem;font-weight:500;line-height:120%}@media (min-width:1280px){h1{font-size:2rem;line-height:120%}}@media (min-width:640px){h1{font-size:3rem;letter-spacing:-.0625rem;line-height:100%}}@media (min-width:1280px){h1{font-size:3.5rem;letter-spacing:-.0625rem;line-height:100%}}h2{font-size:1.25rem;font-weight:500;line-height:120%}@media (min-width:1280px){h2{font-size:1.5rem;line-height:120%}}@media (min-width:640px){h2{font-size:2rem;letter-spacing:0;line-height:120%}}@media (min-width:1280px){h2{font-size:3rem;letter-spacing:-.0625rem;line-height:100%}}h3{font-size:1.125rem;font-weight:500;line-height:120%}@media (min-width:1280px){h3{font-size:1.25rem;line-height:120%}}@media (min-width:640px){h3{font-size:1.5rem;line-height:120%}}@media (min-width:1280px){h3{font-size:2rem;line-height:120%}}h4{font-size:1rem;font-weight:500;line-height:120%}@media (min-width:1280px){h4{font-size:1.125rem;line-height:120%}}@media (min-width:640px){h4{font-size:1.125rem;line-height:120%}}@media (min-width:1280px){h4{font-size:1.5rem;line-height:120%}}h5{font-size:.875rem;font-weight:500;line-height:120%}@media (min-width:1280px){h5{font-size:1rem;line-height:120%}}@media (min-width:640px){h5{font-size:1rem;line-height:120%}}@media (min-width:1280px){h5{font-size:1.125rem;line-height:120%}}h6{font-size:.75rem;font-weight:500;line-height:135%}@media (min-width:1280px){h6{font-size:.875rem;line-height:120%}}@media (min-width:640px){h6{font-size:.875rem;line-height:120%}}@media (min-width:1280px){h6{font-size:1rem;line-height:120%}}*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.pointer-events-none{pointer-events:none}.absolute{position:absolute}.relative{position:relative}.inset-0{inset:0}.left-0{left:0}.right-0{right:0}.top-0{top:0}.top-1\\/2{top:50%}.my-4{margin-bottom:1rem;margin-top:1rem}.mb-12{margin-bottom:3rem}.mb-16{margin-bottom:4rem}.mb-2{margin-bottom:.5rem}.mb-4{margin-bottom:1rem}.mb-5{margin-bottom:1.25rem}.mb-6{margin-bottom:1.5rem}.mb-7{margin-bottom:1.75rem}.mb-8{margin-bottom:2rem}.mt-8{margin-top:2rem}.block{display:block}.inline-block{display:inline-block}.flex{display:flex}.\\!hidden{display:none!important}.hidden{display:none}.h-5{height:1.25rem}.h-9{height:2.25rem}.h-full{height:100%}.max-h-full{max-height:100%}.min-h-\\[calc\\(100vh-83px\\)\\]{min-height:calc(100vh - 83px)}.min-h-full{min-height:100%}.w-10{width:2.5rem}.w-5{width:1.25rem}.w-\\[calc\\(100\\%-theme\\(space\\.2\\)-theme\\(space\\.2\\)\\)\\]{width:calc(100% - 1rem)}.w-full{width:100%}.max-w-\\[1295px\\]{max-width:1295px}.flex-1{flex:1 1 0%}@keyframes spin{to{transform:rotate(1turn)}}.animate-spin{animation:spin 1s linear infinite}.cursor-not-allowed{cursor:not-allowed}.flex-col{flex-direction:column}.\\!flex-nowrap{flex-wrap:nowrap!important}.items-center{align-items:center}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.5rem*var(--tw-space-x-reverse))}.space-x-4>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(1rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(1rem*var(--tw-space-x-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1.5rem*var(--tw-space-y-reverse));margin-top:calc(1.5rem*(1 - var(--tw-space-y-reverse)))}.overflow-hidden{overflow:hidden}.rounded-2xl{border-radius:1.25rem}.rounded-lg{border-radius:.625rem}.rounded-r-lg{border-bottom-right-radius:.625rem;border-top-right-radius:.625rem}.border{border-width:1px}.border-b{border-bottom-width:1px}.border-gray-100{--tw-border-opacity:1;border-color:rgb(248 249 251/var(--tw-border-opacity))}.border-gray-200{--tw-border-opacity:1;border-color:rgb(191 188 215/var(--tw-border-opacity))}.border-gray-300{--tw-border-opacity:1;border-color:rgb(136 134 159/var(--tw-border-opacity))}.border-gray-500{--tw-border-opacity:1;border-color:rgb(59 57 70/var(--tw-border-opacity))}.border-red{--tw-border-opacity:1;border-color:rgb(252 90 90/var(--tw-border-opacity))}.bg-gray-100{--tw-bg-opacity:1;background-color:rgb(248 249 251/var(--tw-bg-opacity))}.bg-primary{background-color:var(--primary-color)}.bg-primaryHover{background-color:var(--primary-hover)}.bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}.bg-cover{background-size:cover}.bg-center{background-position:50%}.px-0{padding-left:0;padding-right:0}.px-10{padding-left:2.5rem;padding-right:2.5rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-4{padding-left:1rem;padding-right:1rem}.px-5{padding-left:1.25rem;padding-right:1.25rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.py-10{padding-bottom:2.5rem;padding-top:2.5rem}.py-2{padding-bottom:.5rem;padding-top:.5rem}.py-3{padding-bottom:.75rem;padding-top:.75rem}.py-5{padding-bottom:1.25rem;padding-top:1.25rem}.pb-2{padding-bottom:.5rem}.pb-8{padding-bottom:2rem}.pt-2{padding-top:.5rem}.pt-2\\.5{padding-top:.625rem}.pt-4{padding-top:1rem}.text-left{text-align:left}.text-center{text-align:center}.indent-\\[5px\\]{text-indent:5px}.font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.\\!text-base{font-size:1rem!important;line-height:120%!important}.text-2xl{font-size:1.5rem;line-height:120%}.text-3xl{font-size:2rem;line-height:120%}.text-base{font-size:1rem;line-height:120%}.text-lg{font-size:1.125rem;line-height:120%}.text-sm{font-size:.875rem;line-height:120%}.text-xl{font-size:1.25rem;line-height:120%}.text-xs{font-size:.75rem;line-height:135%}.font-medium{font-weight:500}.font-semibold{font-weight:600}.leading-\\[0\\]{line-height:0}.text-\\[\\#1196F5\\]{--tw-text-opacity:1;color:rgb(17 150 245/var(--tw-text-opacity))}.text-\\[\\#B2B2B2\\]{--tw-text-opacity:1;color:rgb(178 178 178/var(--tw-text-opacity))}.text-black{--tw-text-opacity:1;color:rgb(0 0 0/var(--tw-text-opacity))}.text-gray-200{--tw-text-opacity:1;color:rgb(191 188 215/var(--tw-text-opacity))}.text-gray-300{--tw-text-opacity:1;color:rgb(136 134 159/var(--tw-text-opacity))}.text-gray-400{--tw-text-opacity:1;color:rgb(75 74 88/var(--tw-text-opacity))}.text-gray-700{--tw-text-opacity:1;color:rgb(30 30 39/var(--tw-text-opacity))}.text-gray-900{--tw-text-opacity:1;color:rgb(8 8 14/var(--tw-text-opacity))}.text-primary{color:var(--primary-color)}.text-red{--tw-text-opacity:1;color:rgb(252 90 90/var(--tw-text-opacity))}.text-textOnPrimary{color:var(--text-on-primary)}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}.opacity-40{opacity:.4}.row-up-left{align-content:flex-start;justify-content:flex-start}.row,.row-up-left{display:flex;flex-direction:row;flex-wrap:wrap}.row{align-content:center;align-items:center;justify-content:center}.column-left{align-items:flex-start}.column,.column-left{display:flex;flex-direction:column;justify-content:center}.column{align-items:center}@media (min-width:1280px){.text-5xl{font-size:5.125rem;letter-spacing:-.125rem;line-height:100%}.text-4xl{font-size:3.5rem}.text-3xl,.text-4xl{letter-spacing:-.0625rem;line-height:100%}.text-3xl{font-size:3rem}.text-2xl{font-size:2rem}.text-2xl,.text-xl{line-height:120%}.text-xl{font-size:1.5rem}.text-lg{font-size:1.25rem}.text-base,.text-lg{line-height:120%}.text-base{font-size:1.125rem}.text-sm{font-size:1rem}.text-sm,.text-xs{line-height:120%}.text-xs{font-size:.875rem}}:root{--primary-color:#7d68f4;--primary-hover:#7e69f4;--text-on-primary:#fff}svg{transform:translate3d(var(--tw-translate-x),var(--tw-translate-y),0) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}*,:after,:before{text-underline-offset:4px}input[type=number],input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-spin-button{-webkit-appearance:none;-moz-appearance:textfield!important}.btn.is-loading{cursor:not-allowed;opacity:.4;pointer-events:none}.btn .btn-spinner,.btn.is-loading .btn-label{opacity:0;visibility:hidden}.btn.is-loading .btn-spinner{opacity:1;visibility:visible}[class*=" uicon-"],[class^=uicon-]{letter-spacing:0;line-height:100%}.placeholder\\:text-gray-300::-moz-placeholder{--tw-text-opacity:1;color:rgb(136 134 159/var(--tw-text-opacity))}.placeholder\\:text-gray-300::placeholder{--tw-text-opacity:1;color:rgb(136 134 159/var(--tw-text-opacity))}.hover\\:bg-black\\/5:hover{background-color:rgba(0,0,0,.05)}.hover\\:bg-gray-100:hover{--tw-bg-opacity:1;background-color:rgb(248 249 251/var(--tw-bg-opacity))}.hover\\:bg-primaryHover:hover{background-color:var(--primary-hover)}.hover\\:text-primaryHover:hover{color:var(--primary-hover)}.hover\\:underline:hover{text-decoration-line:underline}.focus\\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\\:ring:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(3px + var(--tw-ring-offset-width)) var(--tw-ring-color)}.focus\\:ring-2:focus,.focus\\:ring:focus{box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus\\:ring-2:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color)}.focus\\:ring-primary:focus{--tw-ring-color:var(--primary-color)}.focus\\:ring-offset-2:focus{--tw-ring-offset-width:2px}:is(.dark .dark\\:border-gray-400){--tw-border-opacity:1;border-color:rgb(75 74 88/var(--tw-border-opacity))}:is(.dark .dark\\:border-gray-500){--tw-border-opacity:1;border-color:rgb(59 57 70/var(--tw-border-opacity))}:is(.dark .dark\\:border-gray-600){--tw-border-opacity:1;border-color:rgb(40 40 52/var(--tw-border-opacity))}:is(.dark .dark\\:bg-black){--tw-bg-opacity:1;background-color:rgb(0 0 0/var(--tw-bg-opacity))}:is(.dark .dark\\:bg-gray-600){--tw-bg-opacity:1;background-color:rgb(40 40 52/var(--tw-bg-opacity))}:is(.dark .dark\\:bg-gray-800){--tw-bg-opacity:1;background-color:rgb(20 20 26/var(--tw-bg-opacity))}:is(.dark .dark\\:text-\\[\\#201a41\\]){--tw-text-opacity:1;color:rgb(32 26 65/var(--tw-text-opacity))}:is(.dark .dark\\:text-gray-300){--tw-text-opacity:1;color:rgb(136 134 159/var(--tw-text-opacity))}:is(.dark .dark\\:text-white){--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}:is(.dark .dark\\:hover\\:bg-black\\/90:hover){background-color:rgba(0,0,0,.9)}:is(.dark .dark\\:focus\\:ring-offset-gray-900:focus){--tw-ring-offset-color:#08080e}@media (min-width:640px){.sm\\:absolute{position:absolute}.sm\\:left-4{left:1rem}.sm\\:top-1\\/2{top:50%}.sm\\:mt-4{margin-top:1rem}.sm\\:inline{display:inline}.sm\\:h-6{height:1.5rem}.sm\\:min-h-\\[700px\\]{min-height:700px}.sm\\:w-6{width:1.5rem}.sm\\:w-\\[calc\\(100\\%-theme\\(space\\.16\\)-theme\\(space\\.16\\)\\)\\]{width:calc(100% - 8rem)}.sm\\:w-auto{width:auto}.sm\\:max-w-md{max-width:28rem}.sm\\:-translate-y-1\\/2{--tw-translate-y:-50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.sm\\:flex-col{flex-direction:column}.sm\\:justify-normal{justify-content:normal}.sm\\:space-x-0>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(0px*(1 - var(--tw-space-x-reverse)));margin-right:calc(0px*var(--tw-space-x-reverse))}.sm\\:space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1rem*var(--tw-space-y-reverse));margin-top:calc(1rem*(1 - var(--tw-space-y-reverse)))}.sm\\:bg-fixed{background-attachment:fixed}.sm\\:bg-left-top{background-position:0 0}.sm\\:px-10{padding-left:2.5rem;padding-right:2.5rem}.sm\\:px-14{padding-left:3.5rem;padding-right:3.5rem}.sm\\:py-14{padding-bottom:3.5rem;padding-top:3.5rem}.sm\\:py-4{padding-bottom:1rem;padding-top:1rem}.sm\\:pt-16{padding-top:4rem}.sm\\:text-2xl{font-size:1.5rem;line-height:120%}.sm\\:text-base{font-size:1rem;line-height:120%}}@media (min-width:1280px){.md\\:min-w-\\[448px\\]{min-width:448px}.md\\:text-3xl{font-size:2rem;line-height:120%}.md\\:text-base{font-size:1rem;line-height:120%}.md\\:text-sm{font-size:.875rem;line-height:120%}.md\\:text-xs{font-size:.75rem;line-height:135%}}@media (max-height:900px) and (min-width:640px){.short\\:static{position:static}.short\\:left-auto{left:auto}.short\\:top-auto{top:auto}.short\\:hidden{display:none}.short\\:h-5{height:1.25rem}.short\\:min-h-\\[558px\\]{min-height:558px}.short\\:w-5{width:1.25rem}.short\\:translate-y-0{--tw-translate-y:0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.short\\:flex-row{flex-direction:row}.short\\:space-x-4>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(1rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(1rem*var(--tw-space-x-reverse))}.short\\:space-y-0>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(0px*var(--tw-space-y-reverse));margin-top:calc(0px*(1 - var(--tw-space-y-reverse)))}.short\\:px-0{padding-left:0;padding-right:0}.short\\:py-3{padding-bottom:.75rem;padding-top:.75rem}.short\\:text-xl{font-size:1.25rem;line-height:120%}}`;function R$(){if(typeof document<"u"){const t=document.createElement("style");t.innerHTML=Yl,t.setAttribute("data-authhero-tailwind",""),document.head.appendChild(t)}}function B$(t){const e=new a.OpenAPIHono;e.use(async(r,i)=>{const s=wo(r,t.dataAdapter),o=Ol(s,{defaultTtl:3e5,cacheEntities:["tenants","connections","clients"]});return r.env.data=Cl(r,o),i()}).use(zl),e.get("/css/tailwind.css",async r=>{const i=Yl;return r.text(i,200,{"content-type":"text/css; charset=utf-8"})});const n=e.route("/info",P$).route("/check-account",C$).route("/login/identifier",Y4).route("/enter-code",b$).route("/enter-password",A$).route("/invalid-session",O$).route("/pre-signup",z$).route("/pre-signup-sent",T$).route("/reset-password",I$).route("/forgot-password",N$).route("/validate-email",j$).route("/signup",E$);return n.doc("/u/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Universal login"}}),n}const L$="Account detected",U$="We have detected that you have already created an account through",M$="By signing in, you agree to our",F$="and",V$="Callback URL mismatch",D$="The provided redirect_uri is not in the list of allowed callback URLs.",q$="continue with user",H$="Please click the button to create a new password account.",K$="Enter the code at {{vendorName}} to complete the login",G$="Welcome to {{vendorName}}! {{code}} is the login code",W$="Welcome to {{vendorName}}! {{code}} is the login code",J$="The code is valid for 30 minutes",Z$="Confirm password",X$="Need Help?",Y$="Contact us",Q$="or continue with social account",e6="Continue with {{provider}}",t6="Would you like to continue with your existing account?",n6="Copyright © 2023 SESAMY. All rights reserved.",r6="©2023 Sesamy",i6="Choose a password with a mix of uppercase and lowercase letters, numbers, and symbols.",s6="Please enter a valid email address.",o6="The passwords didn't match. Try again.",a6="Choose password",c6="Password must be at least 8 characters long and contain at least one lowercase letter, one uppercase letter, one number and one symbol.",d6="Create new account",l6="Sign up with password",u6="You are currently logged in as <0>{{email}}</0>",f6="Email",p6="Email or Phone Number",h6="Email address",g6="Your email address has been validated",m6="Now enter your password to login again",_6="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.",y6="Email verification sent",w6="Enter a code",v6="We'll send you a verification link to ensure you own this email address.",b6="Enter new password",$6="Enter password",x6="Enter your email address and password to login.",k6="Enter your password",S6="The magic link has expired. Please click on the button below to receive a new link in your inbox.",A6="Hey! We updated our login experience. <0>Click here to learn more about it.</0>",E6="Send password reset email",I6="Click the button below and we’ll send instructions on how to reset your password.",N6="Password reset email sent",C6="Forgot password?",z6="Forgot password?",O6="Go back",P6="Hide password",j6="Invalid password",T6=`The link is no longer valid.
252
252
 
253
253
  Please make sure to open the login link in the same browser you started the login with.
254
254
 
@@ -276,4 +276,4 @@ Kliknutím na odkaz níže můžete zahájit nové přihlášení.`,YN="Neplatn
276
276
 
277
277
  Varmista, että avaat kirjautumislinkin samalla selaimella, jolla aloitit kirjautumisen.
278
278
 
279
- Voit aloittaa uuden kirjautumisen klikkaamalla alla olevaa linkkiä.`,fO="Virheellinen linkki",pO="Kirjaudu sisään napsauttamalla painiketta",hO="Kirjaudu sisään",gO="Tai kirjoita koodi osoitteessa {{vendorName}} kirjautumisen loppuun saattamiseksi.",mO="Kirjoita sähköpostiosoitteesi avataksesi tämän ohjelman osoitteessa {{service}}",_O="Yhdistä tilisi {{service}}",yO="Olet kirjautunut sisään nimellä",wO="Kirjaudu sisään",vO="Kirjoita sähköpostiosoitteesi kirjautuaksesi sisään.",bO="Anna sähköpostiosoitteesi, niin lähetämme sinulle kirjautumiskoodin.",$O="Anna sähköpostiosoitteesi, niin lähetämme sinulle kirjautumislinkin.",xO="Kirjaudu ulos",kO="Ei, haluan käyttää toista tiliä",SO="tai",AO="Salasana",EO="Salasana on nollattu",IO="Menestys",NO="Vaihda salasana tilillesi {{vendorName}} ",CO="Vaihda salasana tilillesi {{vendorName}} ",zO="Puhelinnumero",OO="Tietosuojakäytäntö",PO="Uudelleenohjaus",jO="Vahvista salasana",TO="Rekisteröi uusi salasana",RO="Lähetä koodi uudelleen",BO="Vaihda salasana",LO="Kirjoita alla oleva uusi salasanasi sähköpostitiliä varten: ",UO="Napsauta painiketta salasanasi palauttamiseksi",MO="Napsauta painiketta salasanasi palauttamiseksi",FO="Nollaa salasanasi",VO="Vaihda salasana tilillesi {{vendorName}} ",DO="Nollaa salasana",qO="Lähetä",HO="Lähetä minulle uusi maaginen linkki",KO="Muista tarkistaa roskapostikansiosi, jos sähköposti ei ole saapunut.",GO="Aseta salasana",WO="Näytä salasana",JO="Kirjaudu sisään",ZO="Rekisteröityminen",XO="Rekisteröidy onnistuneesti",YO="{{code}} on kirjautumiskoodisi {{vendorName}}",QO="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.",eP="Siirry Spotifyn Content Access -sivulle",tP='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ä.',nP="Vaihe 1: Poista Spotify-tilisi linkitys",rP="Kun olet onnistuneesti irrottanut Spotify-tilisi, voit yhdistää sen uudelleen Sesamyn kanssa. Toista vain aiemmin tekemäsi vaiheet, jotka johtivat sinut tälle sivulle.",iP="Vaihe 2: Yhdistä Spotify-tilisi uudelleen Sesamyn kanssa",sP="Hups! Spotify-tilisi on jo linkitetty",oP="Jos sinulla on kysyttävää tai tarvitset apua, voit ottaa yhteyttä tukitiimiimme.",aP="Ehdot ja edellytykset",cP="Sähköpostiosoitteesi on vahvistettava. Olemme lähettäneet uuden sähköpostiviestin sähköpostiisi.",dP="Käyttäjätiliä ei ole olemassa",lP="Käyttäjätiliä ei ole olemassa",uP="Emme löytäneet käyttäjää, jolla on annettu sähköpostiosoite. Yritä uudelleen.",fP="Yritä uudelleen.",pP="Validoi koodi",hP="Tarkista sähköpostin vahvistusohjeet postilaatikostasi.",gP="Rekisteröitynyt",mP="Vahvista sähköpostiosoitteesi napsauttamalla painiketta",_P="Vahvista sähköpostiosoitteesi",yP="Vahvista sähköpostiosoitteesi",wP="Vahvista tili",vP="Vahvista sähköpostiosoitteesi",bP="Tervetuloa",$P="Tervetuloa tilillesi {{vendorName}}!",xP="Tarkista sähköpostisi osoitteesta <0>{{email}}</0> ja syötä lähettämämme kuusinumeroinen koodi.",kP="Jatka tällä tilillä",SP="Kyllä, jatka {{text}}",AP="Kyllä, jatka olemassa olevalla tilillä",EP={account_detected:hz,account_with_sso_provider:gz,agree_to:mz,and:_z,callback_url_mismatch:yz,callback_url_not_allowed:wz,check_email_title:vz,click_to_sign_up_description:bz,code_email_enter_code:$z,code_email_subject:xz,code_email_title:kz,code_valid_30_minutes:Sz,confirm_password:Az,contact_support:Ez,contact_us:Iz,continue:"Jatka",continue_social_login:Nz,continue_with:Cz,continue_with_sso_provider_headline:zz,copyright:Oz,copyright_sesamy:Pz,create_account_description:jz,create_account_email_invalid:Tz,create_account_passwords_didnt_match:Rz,create_account_title:Bz,create_account_weak_password:Lz,create_new_account_link:Uz,create_password_account_title:Mz,currently_logged_in_as:Fz,email:Vz,email_or_phone_placeholder:Dz,email_placeholder:qz,email_validated:Hz,email_validated_cta:Kz,email_verification_for_signup_sent_description:Gz,email_verification_for_signup_sent_title:Wz,enter_a_code_btn:Jz,enter_email_for_verification_description:Zz,enter_new_password_placeholder:Xz,enter_password:Yz,enter_password_description:Qz,enter_your_password_btn:eO,expired_code:tO,fokus_info_message:nO,forgot_password_cta:rO,forgot_password_description:iO,forgot_password_email_sent:sO,forgot_password_link:oO,forgot_password_title:aO,go_back:cO,hide_password:dO,"invalid-email":"Virheellinen sähköpostiosoite",invalid_password:lO,invalid_session_body:uO,invalid_session_title:fO,link_email_click_to_login:pO,link_email_login:hO,link_email_or_enter_code:gO,link_page_body:mO,link_page_headline:_O,logged_in_as:yO,login:wO,login_description:vO,login_description_code:bO,login_description_link:$O,logout:xO,no_use_another:kO,or:SO,password:AO,password_has_been_reset:EO,password_has_been_reset_title:IO,password_reset_subject:NO,password_reset_title:CO,phone_placeholder:zO,privacy_policy:OO,redirecting:PO,reenter_new_password_placeholder:jO,register_password_account:TO,resend_code:RO,reset_password_cta:BO,reset_password_description:LO,reset_password_email_click_to_reset:UO,reset_password_email_cta:MO,reset_password_email_reset:FO,reset_password_subject:VO,reset_password_title:DO,send:qO,send_me_a_new_magic_link:HO,sent_code_spam:KO,"Server error: Invalid code":"Virheellinen koodi",set_password:GO,show_password:WO,sign_in:JO,signup:ZO,signup_success:XO,sms_code_text:YO,spotify_already_linked_body:QO,spotify_already_linked_cta:eP,spotify_already_linked_step1_body:tP,spotify_already_linked_step1_title:nP,spotify_already_linked_step2_body:rP,spotify_already_linked_step2_title:iP,spotify_already_linked_title:sP,support_info:oP,terms:aP,unverified_email:cP,user_account_does_not_exist:dP,user_not_found:lP,user_not_found_body:uP,user_not_found_cta:fP,validate_code:pP,validate_email_body:hP,validate_email_title:gP,verify_email_click_to_verify:mP,verify_email_subject:_P,verify_email_title:yP,verify_email_verify:wP,verify_your_email:vP,welcome:bP,welcome_to_your_account:$P,we_sent_a_code_to:xP,"Wrong email or verification code":{"":"Väärä sähköpostiosoite tai vahvistuskoodi."},yes_continue:kP,yes_continue_with:SP,yes_continue_with_existing_account:AP},IP=t=>{const{vendorSettings:e,authParams:n}=t,i=`/authorize?${new URLSearchParams({...n})}`;return y(Fe,{vendorSettings:e,title:T.t("user_not_found"),children:y("div",{className:"flex flex-1 flex-col justify-center",children:[y("p",{className:"mb-8 text-gray-300 text-lg",children:T.t("user_not_found_body")}),y(Xe,{Component:"a",href:i,children:T.t("user_not_found_cta")})]})})};T.init({supportedLngs:["en","it","nb","sv","pl","cs","fi"],fallbackLng:"en",resources:{en:{translation:X8},it:{translation:u9},nb:{translation:S7},sv:{translation:UA},pl:{translation:QI},cs:{translation:pz},fi:{translation:EP}}});function NP(t){const e=new a.OpenAPIHono;e.get("/",s=>s.json({name:"authhero"}));const n=cv(t);e.route("/api/v2",n);const r=x4(t);e.route("/",r);const i=B$(t);return e.route("/u",i),{app:e,managementApp:n,oauthApp:r,universalApp:i,createX509Certificate:hd}}exports.AppLogo=bm;exports.Auth0Client=v0;exports.AuthorizationResponseMode=Ft;exports.AuthorizationResponseType=Ct;exports.Button=Xe;exports.CheckEmailPage=Lm;exports.CodeChallengeMethod=fo;exports.EmailValidatedPage=Fm;exports.EnterCodePage=Ad;exports.EnterPasswordPage=ds;exports.ErrorMessage=qn;exports.Footer=$m;exports.ForgotPasswordPage=Rm;exports.ForgotPasswordSentPage=Bm;exports.Form=Xt;exports.GoBack=vt;exports.GoogleLogo=Sm;exports.GrantType=Qn;exports.Icon=Je;exports.IdentifierPage=os;exports.InvalidSession=Mm;exports.Layout=Fe;exports.LogTypes=ge;exports.Message=ga;exports.PreSignUpConfirmationPage=Vm;exports.PreSignUpPage=Um;exports.ResetPasswordPage=Xn;exports.SignUpPage=Zn;exports.SocialButton=Ur;exports.Spinner=km;exports.Trans=ha;exports.UnverifiedEmailPage=Tm;exports.UserNotFoundPage=IP;exports.VippsLogo=Am;exports.applicationInsertSchema=gs;exports.applicationSchema=bn;exports.auth0UserResponseSchema=At;exports.authParamsSchema=Jr;exports.baseUserSchema=uo;exports.bordersSchema=S0;exports.brandingSchema=qa;exports.codeInsertSchema=m0;exports.codeSchema=k1;exports.codeTypeSchema=g0;exports.colorsSchema=A0;exports.connectionInsertSchema=ms;exports.connectionOptionsSchema=Nd;exports.connectionSchema=Qt;exports.customDomainInsertSchema=Cd;exports.customDomainSchema=Yt;exports.customDomainWithTenantIdSchema=S1;exports.emailProviderSchema=Ji;exports.fontDetailsSchema=yn;exports.fontsSchema=E0;exports.hookInsertSchema=ys;exports.hookSchema=Yn;exports.identitySchema=f0;exports.init=NP;exports.injectTailwindCSS=R$;exports.jwksKeySchema=y0;exports.jwksSchema=zd;exports.logSchema=ws;exports.loginSessionInsertSchema=w0;exports.loginSessionSchema=A1;exports.openIDConfigurationSchema=Ha;exports.pageBackgroundSchema=I0;exports.parseUserId=P1;exports.passwordInsertSchema=b0;exports.passwordSchema=I1;exports.profileDataSchema=u0;exports.promptSettingSchema=Wi;exports.refreshTokenInsertSchema=Od;exports.refreshTokenSchema=C1;exports.samlpAddon=p0;exports.sessionInsertSchema=x0;exports.sessionSchema=po;exports.signingKeySchema=Ka;exports.smsProviderSchema=O1;exports.smsSendParamsSchema=z1;exports.tailwindCss=Yl;exports.tenantInsertSchema=_s;exports.tenantSchema=tr;exports.themeInsertSchema=C0;exports.themeSchema=N1;exports.tokenResponseSchema=k0;exports.totalsSchema=un;exports.userInsertSchema=hs;exports.userResponseSchema=b1;exports.userSchema=Id;exports.vendorSettingsSchema=h0;exports.verificationMethodsSchema=_0;exports.widgetSchema=N0;
279
+ Voit aloittaa uuden kirjautumisen klikkaamalla alla olevaa linkkiä.`,fO="Virheellinen linkki",pO="Kirjaudu sisään napsauttamalla painiketta",hO="Kirjaudu sisään",gO="Tai kirjoita koodi osoitteessa {{vendorName}} kirjautumisen loppuun saattamiseksi.",mO="Kirjoita sähköpostiosoitteesi avataksesi tämän ohjelman osoitteessa {{service}}",_O="Yhdistä tilisi {{service}}",yO="Olet kirjautunut sisään nimellä",wO="Kirjaudu sisään",vO="Kirjoita sähköpostiosoitteesi kirjautuaksesi sisään.",bO="Anna sähköpostiosoitteesi, niin lähetämme sinulle kirjautumiskoodin.",$O="Anna sähköpostiosoitteesi, niin lähetämme sinulle kirjautumislinkin.",xO="Kirjaudu ulos",kO="Ei, haluan käyttää toista tiliä",SO="tai",AO="Salasana",EO="Salasana on nollattu",IO="Menestys",NO="Vaihda salasana tilillesi {{vendorName}} ",CO="Vaihda salasana tilillesi {{vendorName}} ",zO="Puhelinnumero",OO="Tietosuojakäytäntö",PO="Uudelleenohjaus",jO="Vahvista salasana",TO="Rekisteröi uusi salasana",RO="Lähetä koodi uudelleen",BO="Vaihda salasana",LO="Kirjoita alla oleva uusi salasanasi sähköpostitiliä varten: ",UO="Napsauta painiketta salasanasi palauttamiseksi",MO="Napsauta painiketta salasanasi palauttamiseksi",FO="Nollaa salasanasi",VO="Vaihda salasana tilillesi {{vendorName}} ",DO="Nollaa salasana",qO="Lähetä",HO="Lähetä minulle uusi maaginen linkki",KO="Muista tarkistaa roskapostikansiosi, jos sähköposti ei ole saapunut.",GO="Aseta salasana",WO="Näytä salasana",JO="Kirjaudu sisään",ZO="Rekisteröityminen",XO="Rekisteröidy onnistuneesti",YO="{{code}} on kirjautumiskoodisi {{vendorName}}",QO="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.",eP="Siirry Spotifyn Content Access -sivulle",tP='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ä.',nP="Vaihe 1: Poista Spotify-tilisi linkitys",rP="Kun olet onnistuneesti irrottanut Spotify-tilisi, voit yhdistää sen uudelleen Sesamyn kanssa. Toista vain aiemmin tekemäsi vaiheet, jotka johtivat sinut tälle sivulle.",iP="Vaihe 2: Yhdistä Spotify-tilisi uudelleen Sesamyn kanssa",sP="Hups! Spotify-tilisi on jo linkitetty",oP="Jos sinulla on kysyttävää tai tarvitset apua, voit ottaa yhteyttä tukitiimiimme.",aP="Ehdot ja edellytykset",cP="Sähköpostiosoitteesi on vahvistettava. Olemme lähettäneet uuden sähköpostiviestin sähköpostiisi.",dP="Käyttäjätiliä ei ole olemassa",lP="Käyttäjätiliä ei ole olemassa",uP="Emme löytäneet käyttäjää, jolla on annettu sähköpostiosoite. Yritä uudelleen.",fP="Yritä uudelleen.",pP="Validoi koodi",hP="Tarkista sähköpostin vahvistusohjeet postilaatikostasi.",gP="Rekisteröitynyt",mP="Vahvista sähköpostiosoitteesi napsauttamalla painiketta",_P="Vahvista sähköpostiosoitteesi",yP="Vahvista sähköpostiosoitteesi",wP="Vahvista tili",vP="Vahvista sähköpostiosoitteesi",bP="Tervetuloa",$P="Tervetuloa tilillesi {{vendorName}}!",xP="Tarkista sähköpostisi osoitteesta <0>{{email}}</0> ja syötä lähettämämme kuusinumeroinen koodi.",kP="Jatka tällä tilillä",SP="Kyllä, jatka {{text}}",AP="Kyllä, jatka olemassa olevalla tilillä",EP={account_detected:hz,account_with_sso_provider:gz,agree_to:mz,and:_z,callback_url_mismatch:yz,callback_url_not_allowed:wz,check_email_title:vz,click_to_sign_up_description:bz,code_email_enter_code:$z,code_email_subject:xz,code_email_title:kz,code_valid_30_minutes:Sz,confirm_password:Az,contact_support:Ez,contact_us:Iz,continue:"Jatka",continue_social_login:Nz,continue_with:Cz,continue_with_sso_provider_headline:zz,copyright:Oz,copyright_sesamy:Pz,create_account_description:jz,create_account_email_invalid:Tz,create_account_passwords_didnt_match:Rz,create_account_title:Bz,create_account_weak_password:Lz,create_new_account_link:Uz,create_password_account_title:Mz,currently_logged_in_as:Fz,email:Vz,email_or_phone_placeholder:Dz,email_placeholder:qz,email_validated:Hz,email_validated_cta:Kz,email_verification_for_signup_sent_description:Gz,email_verification_for_signup_sent_title:Wz,enter_a_code_btn:Jz,enter_email_for_verification_description:Zz,enter_new_password_placeholder:Xz,enter_password:Yz,enter_password_description:Qz,enter_your_password_btn:eO,expired_code:tO,fokus_info_message:nO,forgot_password_cta:rO,forgot_password_description:iO,forgot_password_email_sent:sO,forgot_password_link:oO,forgot_password_title:aO,go_back:cO,hide_password:dO,"invalid-email":"Virheellinen sähköpostiosoite",invalid_password:lO,invalid_session_body:uO,invalid_session_title:fO,link_email_click_to_login:pO,link_email_login:hO,link_email_or_enter_code:gO,link_page_body:mO,link_page_headline:_O,logged_in_as:yO,login:wO,login_description:vO,login_description_code:bO,login_description_link:$O,logout:xO,no_use_another:kO,or:SO,password:AO,password_has_been_reset:EO,password_has_been_reset_title:IO,password_reset_subject:NO,password_reset_title:CO,phone_placeholder:zO,privacy_policy:OO,redirecting:PO,reenter_new_password_placeholder:jO,register_password_account:TO,resend_code:RO,reset_password_cta:BO,reset_password_description:LO,reset_password_email_click_to_reset:UO,reset_password_email_cta:MO,reset_password_email_reset:FO,reset_password_subject:VO,reset_password_title:DO,send:qO,send_me_a_new_magic_link:HO,sent_code_spam:KO,"Server error: Invalid code":"Virheellinen koodi",set_password:GO,show_password:WO,sign_in:JO,signup:ZO,signup_success:XO,sms_code_text:YO,spotify_already_linked_body:QO,spotify_already_linked_cta:eP,spotify_already_linked_step1_body:tP,spotify_already_linked_step1_title:nP,spotify_already_linked_step2_body:rP,spotify_already_linked_step2_title:iP,spotify_already_linked_title:sP,support_info:oP,terms:aP,unverified_email:cP,user_account_does_not_exist:dP,user_not_found:lP,user_not_found_body:uP,user_not_found_cta:fP,validate_code:pP,validate_email_body:hP,validate_email_title:gP,verify_email_click_to_verify:mP,verify_email_subject:_P,verify_email_title:yP,verify_email_verify:wP,verify_your_email:vP,welcome:bP,welcome_to_your_account:$P,we_sent_a_code_to:xP,"Wrong email or verification code":{"":"Väärä sähköpostiosoite tai vahvistuskoodi."},yes_continue:kP,yes_continue_with:SP,yes_continue_with_existing_account:AP},IP=t=>{const{vendorSettings:e,authParams:n}=t,i=`/authorize?${new URLSearchParams({...n})}`;return y(Fe,{vendorSettings:e,title:T.t("user_not_found"),children:y("div",{className:"flex flex-1 flex-col justify-center",children:[y("p",{className:"mb-8 text-gray-300 text-lg",children:T.t("user_not_found_body")}),y(Xe,{Component:"a",href:i,children:T.t("user_not_found_cta")})]})})};T.init({supportedLngs:["en","it","nb","sv","pl","cs","fi"],fallbackLng:"en",resources:{en:{translation:X8},it:{translation:u9},nb:{translation:S7},sv:{translation:UA},pl:{translation:QI},cs:{translation:pz},fi:{translation:EP}}});function NP(t){const e=new a.OpenAPIHono;e.get("/",s=>s.json({name:"authhero"}));const n=dv(t);e.route("/api/v2",n);const r=x4(t);e.route("/",r);const i=B$(t);return e.route("/u",i),{app:e,managementApp:n,oauthApp:r,universalApp:i,createX509Certificate:hd}}exports.AppLogo=$m;exports.Auth0Client=v0;exports.AuthorizationResponseMode=Ft;exports.AuthorizationResponseType=Ct;exports.Button=Xe;exports.CheckEmailPage=Um;exports.CodeChallengeMethod=po;exports.EmailValidatedPage=Vm;exports.EnterCodePage=Ad;exports.EnterPasswordPage=ls;exports.ErrorMessage=qn;exports.Footer=xm;exports.ForgotPasswordPage=Bm;exports.ForgotPasswordSentPage=Lm;exports.Form=Xt;exports.GoBack=vt;exports.GoogleLogo=Am;exports.GrantType=Qn;exports.Icon=Je;exports.IdentifierPage=as;exports.InvalidSession=Fm;exports.Layout=Fe;exports.LogTypes=ge;exports.Message=ga;exports.PreSignUpConfirmationPage=Dm;exports.PreSignUpPage=Mm;exports.ResetPasswordPage=Xn;exports.SignUpPage=Zn;exports.SocialButton=Ur;exports.Spinner=Sm;exports.Trans=ha;exports.UnverifiedEmailPage=Rm;exports.UserNotFoundPage=IP;exports.VippsLogo=Em;exports.applicationInsertSchema=ms;exports.applicationSchema=bn;exports.auth0UserResponseSchema=At;exports.authParamsSchema=Jr;exports.baseUserSchema=fo;exports.bordersSchema=S0;exports.brandingSchema=qa;exports.codeInsertSchema=m0;exports.codeSchema=S1;exports.codeTypeSchema=g0;exports.colorsSchema=A0;exports.connectionInsertSchema=_s;exports.connectionOptionsSchema=Nd;exports.connectionSchema=Qt;exports.customDomainInsertSchema=Cd;exports.customDomainSchema=Yt;exports.customDomainWithTenantIdSchema=A1;exports.emailProviderSchema=Zi;exports.fontDetailsSchema=yn;exports.fontsSchema=E0;exports.hookInsertSchema=ws;exports.hookSchema=Yn;exports.identitySchema=f0;exports.init=NP;exports.injectTailwindCSS=R$;exports.jwksKeySchema=y0;exports.jwksSchema=zd;exports.logSchema=vs;exports.loginSessionInsertSchema=w0;exports.loginSessionSchema=E1;exports.openIDConfigurationSchema=Ha;exports.pageBackgroundSchema=I0;exports.parseUserId=j1;exports.passwordInsertSchema=b0;exports.passwordSchema=N1;exports.profileDataSchema=u0;exports.promptSettingSchema=Ji;exports.refreshTokenInsertSchema=Od;exports.refreshTokenSchema=z1;exports.samlpAddon=p0;exports.sessionInsertSchema=x0;exports.sessionSchema=ho;exports.signingKeySchema=Ka;exports.smsProviderSchema=P1;exports.smsSendParamsSchema=O1;exports.tailwindCss=Yl;exports.tenantInsertSchema=ys;exports.tenantSchema=tr;exports.themeInsertSchema=C0;exports.themeSchema=C1;exports.tokenResponseSchema=k0;exports.totalsSchema=un;exports.userInsertSchema=gs;exports.userResponseSchema=$1;exports.userSchema=Id;exports.vendorSettingsSchema=h0;exports.verificationMethodsSchema=_0;exports.widgetSchema=N0;