authhero 0.153.0 → 0.154.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,4 +1,4 @@
1
- "use strict";var z1=Object.defineProperty;var I1=(t,e,n)=>e in t?z1(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var te=(t,e,n)=>I1(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@hono/zod-openapi"),ne=t=>typeof t=="string",Br=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},yu=t=>t==null?"":""+t,N1=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},C1=/###/g,wu=t=>t&&t.indexOf("###")>-1?t.replace(C1,"."):t,vu=t=>!t||ne(t),qr=(t,e,n)=>{const r=ne(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(vu(t))return{};const o=wu(r[i]);!t[o]&&n&&(t[o]=new n),Object.prototype.hasOwnProperty.call(t,o)?t=t[o]:t={},++i}return vu(t)?{}:{obj:t,k:wu(r[i])}},bu=(t,e,n)=>{const{obj:r,k:i}=qr(t,e,Object);if(r!==void 0||e.length===1){r[i]=n;return}let o=e[e.length-1],a=e.slice(0,e.length-1),c=qr(t,a,Object);for(;c.obj===void 0&&a.length;)o=`${a[a.length-1]}.${o}`,a=a.slice(0,a.length-1),c=qr(t,a,Object),c!=null&&c.obj&&typeof c.obj[`${c.k}.${o}`]<"u"&&(c.obj=void 0);c.obj[`${c.k}.${o}`]=n},j1=(t,e,n,r)=>{const{obj:i,k:o}=qr(t,e,Object);i[o]=i[o]||[],i[o].push(n)},_o=(t,e)=>{const{obj:n,k:r}=qr(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},O1=(t,e,n)=>{const r=_o(t,n);return r!==void 0?r:_o(e,n)},wh=(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]):wh(t[r],e[r],n):t[r]=e[r]);return t},Wn=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var P1={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const T1=t=>ne(t)?t.replace(/[&<>"'\/]/g,e=>P1[e]):t;class R1{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 B1=[" ",",","?","!",";"],L1=new R1(20),U1=(t,e,n)=>{e=e||"",n=n||"";const r=B1.filter(a=>e.indexOf(a)<0&&n.indexOf(a)<0);if(r.length===0)return!0;const i=L1.getRegExp(`(${r.map(a=>a==="?"?"\\?":a).join("|")})`);let o=!i.test(t);if(!o){const a=t.indexOf(n);a>0&&!i.test(t.substring(0,a))&&(o=!0)}return o},Ya=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 o=0;o<r.length;){if(!i||typeof i!="object")return;let a,c="";for(let d=o;d<r.length;++d)if(d!==o&&(c+=n),c+=r[d],a=i[c],a!==void 0){if(["string","number","boolean"].indexOf(typeof a)>-1&&d<r.length-1)continue;o+=d-o+1;break}i=a}return i},yo=t=>t==null?void 0:t.replace("_","-"),M1={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 wo{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||M1,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 wo(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new wo(this.logger,e)}}var zt=new wo;class ms{constructor(){this.observers={}}on(e,n){return e.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);const i=this.observers[r].get(n)||0;this.observers[r].set(n,i+1)}),this}off(e,n){if(this.observers[e]){if(!n){delete this.observers[e];return}this.observers[e].delete(n)}}emit(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];this.observers[e]&&Array.from(this.observers[e].entries()).forEach(a=>{let[c,d]=a;for(let l=0;l<d;l++)c(...r)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(a=>{let[c,d]=a;for(let l=0;l<d;l++)c.apply(c,[e,...r])})}}class $u extends ms{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 o=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,a=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let c;e.indexOf(".")>-1?c=e.split("."):(c=[e,n],r&&(Array.isArray(r)?c.push(...r):ne(r)&&o?c.push(...r.split(o)):c.push(r)));const d=_o(this.data,c);return!d&&!n&&!r&&e.indexOf(".")>-1&&(e=c[0],n=c[1],r=c.slice(2).join(".")),d||!a||!ne(r)?d:Ya((u=(l=this.data)==null?void 0:l[e])==null?void 0:u[n],r,o)}addResource(e,n,r,i){let o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1};const a=o.keySeparator!==void 0?o.keySeparator:this.options.keySeparator;let c=[e,n];r&&(c=c.concat(a?r.split(a):r)),e.indexOf(".")>-1&&(c=e.split("."),i=n,n=c[1]),this.addNamespaces(n),bu(this.data,c,i),o.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 o in r)(ne(r[o])||Array.isArray(r[o]))&&this.addResource(e,n,o,r[o],{silent:!0});i.silent||this.emit("added",e,n,r)}addResourceBundle(e,n,r,i,o){let a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1,skipCopy:!1},c=[e,n];e.indexOf(".")>-1&&(c=e.split("."),i=r,r=n,n=c[1]),this.addNamespaces(n);let d=_o(this.data,c)||{};a.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?wh(d,r,o):d={...d,...r},bu(this.data,c,d),a.silent||this.emit("added",e,n,r)}removeResourceBundle(e,n){this.hasResourceBundle(e,n)&&delete this.data[e][n],this.removeNamespaces(n),this.emit("removed",e,n)}hasResourceBundle(e,n){return this.getResource(e,n)!==void 0}getResourceBundle(e,n){return n||(n=this.options.defaultNS),this.getResource(e,n)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const n=this.getDataByLanguage(e);return!!(n&&Object.keys(n)||[]).find(i=>n[i]&&Object.keys(n[i]).length>0)}toJSON(){return this.data}}var vh={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,n,r,i){return t.forEach(o=>{var a;e=((a=this.processors[o])==null?void 0:a.process(e,n,r,i))??e}),e}};const xu={};class vo extends ms{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),N1(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=zt.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 o=n.ns||this.options.defaultNS||[];const a=r&&e.indexOf(r)>-1,c=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!U1(e,r,i);if(a&&!c){const d=e.match(this.interpolator.nestingRegexp);if(d&&d.length>0)return{key:e,namespaces:ne(o)?[o]:o};const l=e.split(r);(r!==i||r===i&&this.options.ns.indexOf(l[0])>-1)&&(o=l.shift()),e=l.join(i)}return{key:e,namespaces:ne(o)?[o]:o}}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,o=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator,{key:a,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}${a}`,usedKey:a,exactUsedKey:a,usedLng:l,usedNS:d,usedParams:this.getUsedParamsDetails(n)}:`${d}${L}${a}`}return i?{res:a,usedKey:a,exactUsedKey:a,usedLng:l,usedNS:d,usedParams:this.getUsedParamsDetails(n)}:a}const f=this.resolve(e,n);let m=f==null?void 0:f.res;const w=(f==null?void 0:f.usedKey)||a,h=(f==null?void 0:f.exactUsedKey)||a,y=Object.prototype.toString.apply(m),v=["[object Number]","[object Function]","[object RegExp]"],b=n.joinArrays!==void 0?n.joinArrays:this.options.joinArrays,E=!this.i18nFormat||this.i18nFormat.handleAsObject,C=!ne(m)&&typeof m!="boolean"&&typeof m!="number";if(E&&m&&C&&v.indexOf(y)<0&&!(ne(b)&&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 '${a} (${this.language})' returned an object instead of string.`;return i?(f.res=L,f.usedParams=this.getUsedParamsDetails(n),f):L}if(o){const L=Array.isArray(m),Y=L?[]:{},se=L?h:w;for(const ae in m)if(Object.prototype.hasOwnProperty.call(m,ae)){const Se=`${se}${o}${ae}`;Y[ae]=this.translate(Se,{...n,joinArrays:!1,ns:c}),Y[ae]===Se&&(Y[ae]=m[ae])}m=Y}}else if(E&&ne(b)&&Array.isArray(m))m=m.join(b),m&&(m=this.extendTranslation(m,e,n,r));else{let L=!1,Y=!1;const se=n.count!==void 0&&!ne(n.count),ae=vo.hasDefaultValue(n),Se=se?this.pluralResolver.getSuffix(l,n.count,n):"",ze=n.ordinal&&se?this.pluralResolver.getSuffix(l,n.count,{ordinal:!1}):"",Ce=se&&!n.ordinal&&n.count===0,j=Ce&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${Se}`]||n[`defaultValue${ze}`]||n.defaultValue;!this.isValidLookup(m)&&ae&&(L=!0,m=j),this.isValidLookup(m)||(Y=!0,m=a);const z=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&Y?void 0:m,k=ae&&j!==m&&this.options.updateMissing;if(Y||L||k){if(this.logger.log(k?"updateKey":"missingKey",l,d,a,k?j:m),o){const Q=this.resolve(a,{...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 x=[];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++)x.push(P[Q]);else this.options.saveMissingTo==="all"?x=this.languageUtils.toResolveHierarchy(n.lng||this.language):x.push(n.lng||this.language);const U=(Q,W,oe)=>{var q;const ue=ae&&oe!==m?oe:z;this.options.missingKeyHandler?this.options.missingKeyHandler(Q,d,W,ue,k,n):(q=this.backendConnector)!=null&&q.saveMissing&&this.backendConnector.saveMissing(Q,d,W,ue,k,n),this.emit("missingKey",Q,d,W,m)};this.options.saveMissing&&(this.options.saveMissingPlurals&&se?x.forEach(Q=>{const W=this.pluralResolver.getSuffixes(Q,n);Ce&&n[`defaultValue${this.options.pluralSeparator}zero`]&&W.indexOf(`${this.options.pluralSeparator}zero`)<0&&W.push(`${this.options.pluralSeparator}zero`),W.forEach(oe=>{U([Q],a+oe,n[`defaultValue${oe}`]||j)})}):U(x,a,j))}m=this.extendTranslation(m,e,n,f,r),Y&&m===a&&this.options.appendNamespaceToMissingKey&&(m=`${d}:${a}`),(Y||L)&&this.options.parseMissingKeyHandler&&(m=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${d}:${a}`:a,L?m:void 0))}return i?(f.res=m,f.usedParams=this.getUsedParamsDetails(n),f):m}extendTranslation(e,n,r,i,o){var l,u;var a=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 f=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(f){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),f){const h=e.match(this.interpolator.nestingRegexp),y=h&&h.length;m<y&&(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,y=new Array(h),v=0;v<h;v++)y[v]=arguments[v];return(o==null?void 0:o[0])===y[0]&&!r.context?(a.logger.warn(`It seems you are nesting recursively key: ${y[0]} in key: ${n[0]}`),null):a.translate(...y,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=vh.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,o,a,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 f=l.namespaces;this.options.fallbackNS&&(f=f.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!=="",y=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);f.forEach(v=>{var b,E;this.isValidLookup(r)||(c=v,!xu[`${y[0]}-${v}`]&&((b=this.utils)!=null&&b.hasLoadedNamespace)&&!((E=this.utils)!=null&&E.hasLoadedNamespace(c))&&(xu[`${y[0]}-${v}`]=!0,this.logger.warn(`key "${i}" for languages "${y.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!!!")),y.forEach(C=>{var se;if(this.isValidLookup(r))return;a=C;const L=[u];if((se=this.i18nFormat)!=null&&se.addLookupKeys)this.i18nFormat.addLookupKeys(L,u,C,v,n);else{let ae;m&&(ae=this.pluralResolver.getSuffix(C,n.count,n));const Se=`${this.options.pluralSeparator}zero`,ze=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(L.push(u+ae),n.ordinal&&ae.indexOf(ze)===0&&L.push(u+ae.replace(ze,this.options.pluralSeparator)),w&&L.push(u+Se)),h){const Ce=`${u}${this.options.contextSeparator}${n.context}`;L.push(Ce),m&&(L.push(Ce+ae),n.ordinal&&ae.indexOf(ze)===0&&L.push(Ce+ae.replace(ze,this.options.pluralSeparator)),w&&L.push(Ce+Se))}}let Y;for(;Y=L.pop();)this.isValidLookup(r)||(o=Y,r=this.getResource(C,v,Y,n))}))})}),{res:r,usedKey:i,exactUsedKey:o,usedLng:a,usedNS:c}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,n,r){var o;let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return(o=this.i18nFormat)!=null&&o.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 o of n)delete i[o]}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 ku{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=zt.create("languageUtils")}getScriptPartFromCode(e){if(e=yo(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=yo(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(o=>{if(o===i)return o;if(!(o.indexOf("-")<0&&i.indexOf("-")<0)&&(o.indexOf("-")>0&&i.indexOf("-")<0&&o.substring(0,o.indexOf("-"))===i||o.indexOf(i)===0&&i.length>1))return o})}),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=[],o=a=>{a&&(this.isSupportedCode(a)?i.push(a):this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`))};return ne(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&o(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&o(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&o(this.getLanguagePartFromCode(e))):ne(e)&&o(this.formatLanguageCode(e)),r.forEach(a=>{i.indexOf(a)<0&&o(this.formatLanguageCode(a))}),i}}const Su={zero:0,one:1,two:2,few:3,many:4,other:5},Au={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class F1{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=e,this.options=n,this.logger=zt.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=yo(e==="dev"?"en":e),i=n.ordinal?"ordinal":"cardinal",o=JSON.stringify({cleanedCode:r,type:i});if(o in this.pluralRulesCache)return this.pluralRulesCache[o];let a;try{a=new Intl.PluralRules(r,{type:i})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),Au;if(!e.match(/-|_/))return Au;const d=this.languageUtils.getLanguagePartFromCode(e);a=this.getRule(d,n)}return this.pluralRulesCache[o]=a,a}needsPlural(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),(r==null?void 0:r.resolvedOptions().pluralCategories.length)>1}getPluralFormsOfKey(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.getSuffixes(e,r).map(i=>`${n}${i}`)}getSuffixes(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),r?r.resolvedOptions().pluralCategories.sort((i,o)=>Su[i]-Su[o]).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 Eu=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,o=O1(t,e,n);return!o&&i&&ne(n)&&(o=Ya(t,n,r),o===void 0&&(o=Ya(e,n,r))),o},Ea=t=>t.replace(/\$/g,"$$$$");class D1{constructor(){var n;let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=zt.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:o,prefixEscaped:a,suffix:c,suffixEscaped:d,formatSeparator:l,unescapeSuffix:u,unescapePrefix:f,nestingPrefix:m,nestingPrefixEscaped:w,nestingSuffix:h,nestingSuffixEscaped:y,nestingOptionsSeparator:v,maxReplaces:b,alwaysFormat:E}=e.interpolation;this.escape=n!==void 0?n:T1,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=o?Wn(o):a||"{{",this.suffix=c?Wn(c):d||"}}",this.formatSeparator=l||",",this.unescapePrefix=u?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":u||"",this.nestingPrefix=m?Wn(m):w||Wn("$t("),this.nestingSuffix=h?Wn(h):y||Wn(")"),this.nestingOptionsSeparator=v||",",this.maxReplaces=b||1e3,this.alwaysFormat=E!==void 0?E:!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 o,a,c;const d=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},l=h=>{if(h.indexOf(this.formatSeparator)<0){const E=Eu(n,d,h,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(E,void 0,r,{...i,...n,interpolationkey:h}):E}const y=h.split(this.formatSeparator),v=y.shift().trim(),b=y.join(this.formatSeparator).trim();return this.format(Eu(n,d,v,this.options.keySeparator,this.options.ignoreJSONStructure),b,r,{...i,...n,interpolationkey:v})};this.resetRegExp();const u=(i==null?void 0:i.missingInterpolationHandler)||this.options.missingInterpolationHandler,f=((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=>Ea(h)},{regex:this.regexp,safeValue:h=>this.escapeValue?Ea(this.escape(h)):Ea(h)}].forEach(h=>{for(c=0;o=h.regex.exec(e);){const y=o[1].trim();if(a=l(y),a===void 0)if(typeof u=="function"){const b=u(e,o,i);a=ne(b)?b:""}else if(i&&Object.prototype.hasOwnProperty.call(i,y))a="";else if(f){a=o[0];continue}else this.logger.warn(`missed to pass in variable ${y} for interpolating ${e}`),a="";else!ne(a)&&!this.useRawValueToEscape&&(a=yu(a));const v=h.safeValue(a);if(e=e.replace(o[0],v),f?(h.regex.lastIndex+=a.length,h.regex.lastIndex-=o[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,o,a;const c=(d,l)=>{const u=this.nestingOptionsSeparator;if(d.indexOf(u)<0)return d;const f=d.split(new RegExp(`${u}[ ]*{`));let m=`{${f[1]}`;d=f[0],m=this.interpolate(m,a);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{a=JSON.parse(m),l&&(a={...l,...a})}catch(y){return this.logger.warn(`failed parsing options string in nesting for key ${d}`,y),`${d}${u}${m}`}return a.defaultValue&&a.defaultValue.indexOf(this.prefix)>-1&&delete a.defaultValue,d};for(;i=this.nestingRegexp.exec(e);){let d=[];a={...r},a=a.replace&&!ne(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;let l=!1;if(i[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(i[1])){const u=i[1].split(this.formatSeparator).map(f=>f.trim());i[1]=u.shift(),d=u,l=!0}if(o=n(c.call(this,i[1].trim(),a),a),o&&i[0]===e&&!ne(o))return o;ne(o)||(o=yu(o)),o||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),o=""),l&&(o=d.reduce((u,f)=>this.format(u,f,r.lng,{...r,interpolationkey:i[1].trim()}),o.trim())),e=e.replace(i[0],o),this.regexp.lastIndex=0}return e}}const V1=t=>{let e=t.toLowerCase().trim();const n={};if(t.indexOf("(")>-1){const r=t.split("(");e=r[0].toLowerCase().trim();const i=r[1].substring(0,r[1].length-1);e==="currency"&&i.indexOf(":")<0?n.currency||(n.currency=i.trim()):e==="relativetime"&&i.indexOf(":")<0?n.range||(n.range=i.trim()):i.split(";").forEach(a=>{if(a){const[c,...d]=a.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}},Jn=t=>{const e={};return(n,r,i)=>{let o=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(o={...o,[i.interpolationkey]:void 0});const a=r+JSON.stringify(o);let c=e[a];return c||(c=t(yo(r),i),e[a]=c),c(n)}};class q1{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=zt.create("formatter"),this.options=e,this.formats={number:Jn((n,r)=>{const i=new Intl.NumberFormat(n,{...r});return o=>i.format(o)}),currency:Jn((n,r)=>{const i=new Intl.NumberFormat(n,{...r,style:"currency"});return o=>i.format(o)}),datetime:Jn((n,r)=>{const i=new Intl.DateTimeFormat(n,{...r});return o=>i.format(o)}),relativetime:Jn((n,r)=>{const i=new Intl.RelativeTimeFormat(n,{...r});return o=>i.format(o,r.range||"day")}),list:Jn((n,r)=>{const i=new Intl.ListFormat(n,{...r});return o=>i.format(o)})},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()]=Jn(n)}format(e,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const o=n.split(this.formatSeparator);if(o.length>1&&o[0].indexOf("(")>1&&o[0].indexOf(")")<0&&o.find(c=>c.indexOf(")")>-1)){const c=o.findIndex(d=>d.indexOf(")")>-1);o[0]=[o[0],...o.splice(1,c)].join(this.formatSeparator)}return o.reduce((c,d)=>{var f;const{formatName:l,formatOptions:u}=V1(d);if(this.formats[l]){let m=c;try{const w=((f=i==null?void 0:i.formatParams)==null?void 0:f[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 H1=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class K1 extends ms{constructor(e,n,r){var o,a;let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=zt.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],(a=(o=this.backend)==null?void 0:o.init)==null||a.call(o,r,i.backend,i)}queueLoad(e,n,r,i){const o={},a={},c={},d={};return e.forEach(l=>{let u=!0;n.forEach(f=>{const m=`${l}|${f}`;!r.reload&&this.store.hasResourceBundle(l,f)?this.state[m]=2:this.state[m]<0||(this.state[m]===1?a[m]===void 0&&(a[m]=!0):(this.state[m]=1,u=!1,a[m]===void 0&&(a[m]=!0),o[m]===void 0&&(o[m]=!0),d[f]===void 0&&(d[f]=!0)))}),u||(c[l]=!0)}),(Object.keys(o).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(o),pending:Object.keys(a),toLoadLanguages:Object.keys(c),toLoadNamespaces:Object.keys(d)}}loaded(e,n,r){const i=e.split("|"),o=i[0],a=i[1];n&&this.emit("failedLoading",o,a,n),!n&&r&&this.store.addResourceBundle(o,a,r,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&r&&(this.state[e]=0);const c={};this.queue.forEach(d=>{j1(d.loaded,[o],a),H1(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(f=>{c[l][f]===void 0&&(c[l][f]=!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,o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,a=arguments.length>5?arguments[5]:void 0;if(!e.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:n,fcName:r,tried:i,wait:o,callback:a});return}this.readingCalls++;const c=(l,u)=>{if(this.readingCalls--,this.waitingReads.length>0){const f=this.waitingReads.shift();this.read(f.lng,f.ns,f.fcName,f.tried,f.wait,f.callback)}if(l&&u&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,e,n,r,i+1,o*2,a)},o);return}a(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 o=this.queueLoad(e,n,r,i);if(!o.toLoad.length)return o.pending.length||i(),null;o.toLoad.forEach(a=>{this.loadOne(a)})}load(e,n,r){this.prepareLoading(e,n,{},r)}reload(e,n,r){this.prepareLoading(e,n,{reload:!0},r)}loadOne(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const r=e.split("|"),i=r[0],o=r[1];this.read(i,o,"read",void 0,void 0,(a,c)=>{a&&this.logger.warn(`${n}loading namespace ${o} for language ${i} failed`,a),!a&&c&&this.logger.log(`${n}loaded namespace ${o} for language ${i}`,c),this.loaded(e,a,c)})}saveMissing(e,n,r,i,o){var d,l,u,f,m;let a=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&&!((f=(u=this.services)==null?void 0:u.utils)!=null&&f.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={...a,isUpdate:o},h=this.backend.create.bind(this.backend);if(h.length<6)try{let y;h.length===5?y=h(e,n,r,i,w):y=h(e,n,r,i),y&&typeof y.then=="function"?y.then(v=>c(null,v)).catch(c):c(null,y)}catch(y){c(y)}else h(e,n,r,i,c,w)}!e||!e[0]||this.store.addResource(e[0],n,r,i)}}}const zu=()=>({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}}),Iu=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},Ki=()=>{},G1=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class Zr extends ms{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(super(),this.options=Iu(e),this.services={},this.logger=zt,this.modules={external:[]},G1(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=zu();this.options={...i,...this.options,...Iu(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 o=u=>u?typeof u=="function"?new u:u:null;if(!this.options.isClone){this.modules.logger?zt.init(o(this.modules.logger),this.options):zt.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=q1;const f=new ku(this.options);this.store=new $u(this.options.resources,this.options);const m=this.services;m.logger=zt,m.resourceStore=this.store,m.languageUtils=f,m.pluralResolver=new F1(f,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),u&&(!this.options.interpolation.format||this.options.interpolation.format===i.interpolation.format)&&(m.formatter=o(u),m.formatter.init(m,this.options),this.options.interpolation.format=m.formatter.format.bind(m.formatter)),m.interpolator=new D1(this.options),m.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},m.backendConnector=new K1(o(this.modules.backend),m.resourceStore,m,this.options),m.backendConnector.on("*",function(w){for(var h=arguments.length,y=new Array(h>1?h-1:0),v=1;v<h;v++)y[v-1]=arguments[v];e.emit(w,...y)}),this.modules.languageDetector&&(m.languageDetector=o(this.modules.languageDetector),m.languageDetector.init&&m.languageDetector.init(m,this.options.detection,this.options)),this.modules.i18nFormat&&(m.i18nFormat=o(this.modules.i18nFormat),m.i18nFormat.init&&m.i18nFormat.init(this)),this.translator=new vo(this.services,this.options),this.translator.on("*",function(w){for(var h=arguments.length,y=new Array(h>1?h-1:0),v=1;v<h;v++)y[v-1]=arguments[v];e.emit(w,...y)}),this.modules.external.forEach(w=>{w.init&&w.init(this)})}if(this.format=this.options.interpolation.format,r||(r=Ki),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=Br(),l=()=>{const u=(f,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(f,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 o,a;let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Ki;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(f=>{f!=="cimode"&&c.indexOf(f)<0&&c.push(f)})};i?d(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(u=>d(u)),(a=(o=this.options.preload)==null?void 0:o.forEach)==null||a.call(o,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=Br();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=Ki),this.services.backendConnector.reload(e,n,o=>{i.resolve(),r(o)}),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"&&vh.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=Br();this.emit("languageChanging",e);const o=d=>{this.language=d,this.languages=this.services.languageUtils.toResolveHierarchy(d),this.resolvedLanguage=void 0,this.setResolvedLanguage(d)},a=(d,l)=>{l?(o(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,f;!e&&!d&&this.services.languageDetector&&(d=[]);const l=ne(d)?d:this.services.languageUtils.getBestMatchFromCodes(d);l&&(this.language||o(l),this.translator.language||this.translator.changeLanguage(l),(f=(u=this.services.languageDetector)==null?void 0:u.cacheUserLanguage)==null||f.call(u,l)),this.loadResources(l,m=>{a(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 o=function(a,c){let d;if(typeof c!="object"){for(var l=arguments.length,u=new Array(l>2?l-2:0),f=2;f<l;f++)u[f-2]=arguments[f];d=i.options.overloadTranslationOptionHandler([a,c].concat(u))}else d={...c};d.lng=d.lng||o.lng,d.lngs=d.lngs||o.lngs,d.ns=d.ns||o.ns,d.keyPrefix!==""&&(d.keyPrefix=d.keyPrefix||r||o.keyPrefix);const m=i.options.keySeparator||".";let w;return d.keyPrefix&&Array.isArray(a)?w=a.map(h=>`${d.keyPrefix}${m}${h}`):w=d.keyPrefix?`${d.keyPrefix}${m}${a}`:a,i.t(w,d)};return ne(e)?o.lng=e:o.lngs=e,o.ns=n,o.keyPrefix=r,o}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,o=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const a=(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,a);if(c!==void 0)return c}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(r,e)&&(!i||a(o,e)))}loadNamespaces(e,n){const r=Br();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=Br();ne(e)&&(e=[e]);const i=this.options.preload||[],o=e.filter(a=>i.indexOf(a)<0&&this.services.languageUtils.isSupportedCode(a));return o.length?(this.options.preload=i.concat(o),this.loadResources(a=>{r.resolve(),n&&n(a)}),r):(n&&n(),Promise.resolve())}dir(e){var i,o;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=((o=this.services)==null?void 0:o.languageUtils)||new ku(zu());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 Zr(e,n)}cloneInstance(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Ki;const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},o=new Zr(i);if((e.debug!==void 0||e.prefix!==void 0)&&(o.logger=o.logger.clone(e)),["store","services","language"].forEach(c=>{o[c]=this[c]}),o.services={...this.services},o.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},r){const c=Object.keys(this.store.data).reduce((d,l)=>(d[l]={...this.store.data[l]},Object.keys(d[l]).reduce((u,f)=>(u[f]={...d[l][f]},u),{})),{});o.store=new $u(c,i),o.services.resourceStore=o.store}return o.translator=new vo(o.services,i),o.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];o.emit(c,...l)}),o.init(i,n),o.translator.options=i,o.translator.backendConnector.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},o}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const O=Zr.createInstance();O.createInstance=Zr.createInstance;O.createInstance;O.dir;O.init;O.loadResources;O.reloadResources;O.use;O.changeLanguage;O.getFixedT;const re=O.t;O.exists;O.setDefaultNamespace;O.hasLoadedNamespace;O.loadNamespaces;O.loadLanguages;var bh=t=>{const n={...{origin:"*",allowMethods:["GET","HEAD","PUT","POST","DELETE","PATCH"],allowHeaders:[],exposeHeaders:[]},...t},r=(i=>typeof i=="string"?i==="*"?()=>i:o=>i===o?o:null:typeof i=="function"?i:o=>i.includes(o)?o:null)(n.origin);return async function(o,a){var l,u;function c(f,m){o.res.headers.set(f,m)}const d=r(o.req.header("origin")||"",o);if(d&&c("Access-Control-Allow-Origin",d),n.origin!=="*"){const f=o.req.header("Vary");f?c("Vary",f):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(",")),o.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 f=n.allowHeaders;if(!(f!=null&&f.length)){const m=o.req.header("Access-Control-Request-Headers");m&&(f=m.split(/\s*,\s*/))}return f!=null&&f.length&&(c("Access-Control-Allow-Headers",f.join(",")),o.res.headers.append("Vary","Access-Control-Request-Headers")),o.res.headers.delete("Content-Length"),o.res.headers.delete("Content-Type"),new Response(null,{headers:o.res.headers,status:204,statusText:"No Content"})}await a()}};const Xt=s.z.object({start:s.z.number(),limit:s.z.number(),length:s.z.number()}),_s=s.z.object({created_at:s.z.string(),updated_at:s.z.string()}),$h=s.z.object({email:s.z.string().optional(),email_verified:s.z.boolean().optional(),name:s.z.string().optional(),username:s.z.string().optional(),given_name:s.z.string().optional(),phone_number:s.z.string().optional(),phone_verified:s.z.boolean().optional(),family_name:s.z.string().optional()}).catchall(s.z.any()),xh=s.z.object({connection:s.z.string(),user_id:s.z.string(),provider:s.z.string(),isSocial:s.z.boolean(),access_token:s.z.string().optional(),access_token_secret:s.z.string().optional(),refresh_token:s.z.string().optional(),profileData:$h.optional()}),ys=s.z.object({email:s.z.string().optional().transform(t=>t&&t.toLowerCase()),username:s.z.string().optional(),phone_number:s.z.string().optional(),given_name:s.z.string().optional(),family_name:s.z.string().optional(),nickname:s.z.string().optional(),name:s.z.string().optional(),picture:s.z.string().optional(),locale:s.z.string().optional(),linked_to:s.z.string().optional(),profileData:s.z.string().optional(),user_id:s.z.string().optional(),app_metadata:s.z.any().default({}).optional(),user_metadata:s.z.any().default({}).optional()}),bo=ys.extend({email_verified:s.z.boolean().default(!1),verify_email:s.z.boolean().optional(),last_ip:s.z.string().optional(),last_login:s.z.string().optional(),user_id:s.z.string().optional(),provider:s.z.string().default("email"),connection:s.z.string().default("email"),is_social:s.z.boolean().optional()}),Bd=s.z.object({...bo.shape,..._s.shape,user_id:s.z.string(),is_social:s.z.boolean(),email:s.z.string().optional(),login_count:s.z.number().default(0),identities:s.z.array(xh).optional()}),Et=Bd,W1=ys.extend({login_count:s.z.number(),multifactor:s.z.array(s.z.string()).optional(),last_ip:s.z.string().optional(),last_login:s.z.string().optional(),user_id:s.z.string()}).catchall(s.z.any()),J1="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let X1=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=J1[n[t]&63];return e};const kh=s.z.object({audience:s.z.string().optional(),recipient:s.z.string().optional(),createUpnClaim:s.z.boolean().optional(),mapUnknownClaimsAsIs:s.z.boolean().optional(),passthroughClaimsWithNoMapping:s.z.boolean().optional(),mapIdentities:s.z.boolean().optional(),signatureAlgorithm:s.z.string().optional(),digestAlgorithm:s.z.string().optional(),issuer:s.z.string().optional(),destination:s.z.string().optional(),lifetimeInSeconds:s.z.number().optional(),signResponse:s.z.boolean().optional(),nameIdentifierFormat:s.z.string().optional(),nameIdentifierProbes:s.z.array(s.z.string()).optional(),authnContextClassRef:s.z.string().optional(),mappings:s.z.record(s.z.string()).optional()}),$o=s.z.object({id:s.z.string(),name:s.z.string(),callbacks:s.z.array(s.z.string()).default([]).optional().openapi({description:"Comma-separated list of URLs whitelisted to use as a callback to the client after authentication."}),allowed_origins:s.z.array(s.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:s.z.array(s.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:s.z.array(s.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:s.z.array(s.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:s.z.object({samlp:kh.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:s.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:s.z.string().default(()=>X1()).optional(),disable_sign_ups:s.z.boolean().optional().default(!1).openapi({description:"Prevents users from signing up using the hosted login page. This is not available in auth0"})}),xn=s.z.object({created_at:s.z.string().transform(t=>t===null?"":t),updated_at:s.z.string().transform(t=>t===null?"":t),...$o.shape}),xr=s.z.object({x:s.z.number(),y:s.z.number()});var Ld=(t=>(t.RICH_TEXT="RICH_TEXT",t.NEXT_BUTTON="NEXT_BUTTON",t.BACK_BUTTON="BACK_BUTTON",t.SUBMIT_BUTTON="SUBMIT_BUTTON",t.DIVIDER="DIVIDER",t.TEXT="TEXT",t.EMAIL="EMAIL",t.PASSWORD="PASSWORD",t.NUMBER="NUMBER",t.PHONE="PHONE",t.DATE="DATE",t.CHECKBOX="CHECKBOX",t.RADIO="RADIO",t.SELECT="SELECT",t.HIDDEN="HIDDEN",t.LEGAL="LEGAL",t))(Ld||{}),Ud=(t=>(t.BLOCK="BLOCK",t.FIELD="FIELD",t))(Ud||{});const ws=s.z.object({id:s.z.string(),category:s.z.nativeEnum(Ud),type:s.z.nativeEnum(Ld)}),Sh=ws.extend({category:s.z.literal("BLOCK"),type:s.z.literal("RICH_TEXT"),config:s.z.object({content:s.z.string()}).passthrough()}),Ah=ws.extend({category:s.z.literal("BLOCK"),type:s.z.union([s.z.literal("NEXT_BUTTON"),s.z.literal("BACK_BUTTON"),s.z.literal("SUBMIT_BUTTON")]),config:s.z.object({text:s.z.string()}).passthrough()}),Eh=ws.extend({category:s.z.literal("FIELD"),type:s.z.literal("LEGAL"),required:s.z.boolean().optional(),sensitive:s.z.boolean().optional(),config:s.z.object({text:s.z.string()}).passthrough()}),zh=ws.extend({category:s.z.literal("FIELD"),type:s.z.union([s.z.literal("TEXT"),s.z.literal("EMAIL"),s.z.literal("PASSWORD"),s.z.literal("NUMBER"),s.z.literal("PHONE"),s.z.literal("DATE"),s.z.literal("CHECKBOX"),s.z.literal("RADIO"),s.z.literal("SELECT"),s.z.literal("HIDDEN")]),required:s.z.boolean().optional(),sensitive:s.z.boolean().optional(),config:s.z.object({label:s.z.string().optional(),placeholder:s.z.string().optional()}).passthrough()}),Ih=s.z.object({id:s.z.string(),category:s.z.string(),type:s.z.string()}).passthrough(),Nh=s.z.union([Sh,Ah,Eh,zh,Ih]);var Ch=(t=>(t.STEP="STEP",t.FLOW="FLOW",t.CONDITION="CONDITION",t.ACTION="ACTION",t))(Ch||{});const jh=s.z.object({id:s.z.string(),type:s.z.literal("STEP"),coordinates:xr,alias:s.z.string().optional(),config:s.z.object({components:s.z.array(Nh),next_node:s.z.string()}).passthrough()}),Oh=s.z.object({id:s.z.string(),type:s.z.literal("FLOW"),coordinates:xr,alias:s.z.string().optional(),config:s.z.object({flow_id:s.z.string(),next_node:s.z.string()})}),Ph=s.z.object({id:s.z.string(),type:s.z.string(),coordinates:xr}).passthrough(),Th=s.z.union([jh,Oh,Ph]),Rh=s.z.object({next_node:s.z.string(),coordinates:xr}).passthrough(),Bh=s.z.object({resume_flow:s.z.boolean().optional(),coordinates:xr}).passthrough(),Lh=s.z.object({id:s.z.string(),name:s.z.string(),languages:s.z.object({primary:s.z.string()}).passthrough(),nodes:s.z.array(Th),start:Rh,ending:Bh,created_at:s.z.string(),updated_at:s.z.string(),links:s.z.object({sdkSrc:s.z.string().optional(),sdk_src:s.z.string().optional()}).passthrough()}).passthrough(),Z1=Lh.omit({id:!0,created_at:!0,updated_at:!0});var it=(t=>(t.TOKEN="token",t.TOKEN_ID_TOKEN="token id_token",t.CODE="code",t))(it||{}),Dt=(t=>(t.QUERY="query",t.FRAGMENT="fragment",t.FORM_POST="form_post",t.WEB_MESSAGE="web_message",t.SAML_POST="saml_post",t))(Dt||{}),vs=(t=>(t.S256="S256",t.Plain="plain",t))(vs||{});const Yr=s.z.object({client_id:s.z.string(),act_as:s.z.string().optional(),response_type:s.z.nativeEnum(it).optional(),response_mode:s.z.nativeEnum(Dt).optional(),redirect_uri:s.z.string().optional(),audience:s.z.string().optional(),organization:s.z.string().optional(),state:s.z.string().optional(),nonce:s.z.string().optional(),scope:s.z.string().optional(),prompt:s.z.string().optional(),code_challenge_method:s.z.nativeEnum(vs).optional(),code_challenge:s.z.string().optional(),username:s.z.string().optional(),ui_locales:s.z.string().optional(),vendor_id:s.z.string().optional()}),Qa=s.z.object({colors:s.z.object({primary:s.z.string(),page_background:s.z.object({type:s.z.string().optional(),start:s.z.string().optional(),end:s.z.string().optional(),angle_deg:s.z.number().optional()}).optional()}).optional(),logo_url:s.z.string().optional(),favicon_url:s.z.string().optional(),font:s.z.object({url:s.z.string()}).optional()}),Md=s.z.object({kid:s.z.string().optional(),team_id:s.z.string().optional(),realms:s.z.string().optional(),client_id:s.z.string().optional(),client_secret:s.z.string().optional(),app_secret:s.z.string().optional(),scope:s.z.string().optional(),authorization_endpoint:s.z.string().optional(),token_endpoint:s.z.string().optional(),userinfo_endpoint:s.z.string().optional(),jwks_uri:s.z.string().optional(),discovery_url:s.z.string().optional(),issuer:s.z.string().optional(),provider:s.z.string().optional(),from:s.z.string().optional(),twilio_sid:s.z.string().optional(),twilio_token:s.z.string().optional()}),xo=s.z.object({id:s.z.string().optional(),name:s.z.string(),strategy:s.z.string(),options:Md.default({}),enabled_clients:s.z.array(s.z.string()).default([]).optional(),response_type:s.z.custom().optional(),response_mode:s.z.custom().optional()}),rn=s.z.object({id:s.z.string(),created_at:s.z.string().transform(t=>t===null?"":t),updated_at:s.z.string().transform(t=>t===null?"":t)}).extend(xo.shape),ko=s.z.object({name:s.z.string(),audience:s.z.string(),sender_email:s.z.string().email(),sender_name:s.z.string(),support_url:s.z.string().url().optional(),logo:s.z.string().url().optional(),primary_color:s.z.string().optional(),secondary_color:s.z.string().optional(),language:s.z.string().optional(),id:s.z.string().optional()}),or=s.z.object({created_at:s.z.string().transform(t=>t===null?"":t),updated_at:s.z.string().transform(t=>t===null?"":t),...ko.shape,id:s.z.string()}),Uh=s.z.object({logoUrl:s.z.string(),loginBackgroundImage:s.z.string().nullish(),style:s.z.object({primaryColor:s.z.string(),buttonTextColor:s.z.string(),primaryHoverColor:s.z.string()}),supportEmail:s.z.string().nullable(),supportUrl:s.z.string().nullable(),name:s.z.string(),showGreyishBackground:s.z.boolean().optional(),termsAndConditionsUrl:s.z.string().nullable(),companyName:s.z.string().optional(),checkoutHideSocial:s.z.boolean().optional(),siteUrl:s.z.string().nullable(),manageSubscriptionsUrl:s.z.string().optional()});s.z.object({...xn.shape,tenant:or,connections:s.z.array(rn)});const Mh=s.z.enum(["password_reset","email_verification","otp","authorization_code","oauth2_state","ticket"]),Fh=s.z.object({code_id:s.z.string().openapi({description:"The code that will be used in for instance an email verification flow"}),login_id:s.z.string().openapi({description:"The id of the login session that the code is connected to"}),connection_id:s.z.string().optional().openapi({description:"The connection that the code is connected to"}),code_type:Mh,code_verifier:s.z.string().optional().openapi({description:"The code verifier used in PKCE in outbound flows"}),code_challenge:s.z.string().optional().openapi({description:"The code challenge used in PKCE in outbound flows"}),code_challenge_method:s.z.enum(["plain","S256"]).optional().openapi({description:"The code challenge method used in PKCE in outbound flows"}),redirect_uri:s.z.string().optional().openapi({description:"The redirect URI associated with the code"}),nonce:s.z.string().optional().openapi({description:"The nonce value used for security in OIDC flows"}),state:s.z.string().optional().openapi({description:"The state parameter used for CSRF protection in OAuth flows"}),expires_at:s.z.string(),used_at:s.z.string().optional(),user_id:s.z.string().optional()}),Y1=s.z.object({...Fh.shape,created_at:s.z.string()}),Fd=s.z.object({domain:s.z.string(),custom_domain_id:s.z.string().optional(),type:s.z.enum(["auth0_managed_certs","self_managed_certs"]),verification_method:s.z.enum(["txt"]).optional(),tls_policy:s.z.enum(["recommended"]).optional(),custom_client_ip_header:s.z.enum(["true-client-ip","cf-connecting-ip","x-forwarded-for","x-azure-clientip","null"]).optional(),domain_metadata:s.z.record(s.z.string().max(255)).optional()}),Dh=s.z.object({name:s.z.literal("txt"),record:s.z.string(),domain:s.z.string()}),nn=s.z.object({...Fd.shape,custom_domain_id:s.z.string(),primary:s.z.boolean(),status:s.z.enum(["disabled","pending","pending_verification","ready"]),origin_domain_name:s.z.string().optional(),verification:s.z.object({methods:s.z.array(Dh)}).optional(),tls_policy:s.z.string().optional()}),Q1=nn.extend({tenant_id:s.z.string()}),e_=s.z.object({id:s.z.string(),type:s.z.literal("submit"),label:s.z.string(),className:s.z.string().optional(),disabled:s.z.boolean().optional().default(!1),order:s.z.number().optional(),visible:s.z.boolean().optional().default(!0),customizations:s.z.record(s.z.string(),s.z.any()).optional()}),Vh=s.z.discriminatedUnion("type",[s.z.object({id:s.z.string(),type:s.z.literal("RICH_TEXT"),config:s.z.object({content:s.z.string()}),order:s.z.number().optional(),visible:s.z.boolean().optional().default(!0)}),s.z.object({id:s.z.string(),type:s.z.literal("LEGAL"),config:s.z.object({text:s.z.string(),html:s.z.boolean().optional()}),required:s.z.boolean().optional(),order:s.z.number().optional(),visible:s.z.boolean().optional().default(!0)}),s.z.object({id:s.z.string(),type:s.z.literal("NEXT_BUTTON"),config:s.z.object({text:s.z.string().optional()}),order:s.z.number().optional(),visible:s.z.boolean().optional().default(!0)})]),So=s.z.object({name:s.z.string().openapi({description:"The name of the form"}),messages:s.z.object({errors:s.z.record(s.z.string(),s.z.any()).optional(),custom:s.z.record(s.z.string(),s.z.any()).optional()}).optional(),languages:s.z.object({primary:s.z.string().optional(),default:s.z.string().optional()}).optional(),translations:s.z.record(s.z.string(),s.z.any()).optional(),nodes:s.z.array(s.z.discriminatedUnion("type",[s.z.object({id:s.z.string(),type:s.z.literal("FLOW"),coordinates:s.z.object({x:s.z.number(),y:s.z.number()}),alias:s.z.string().min(1).max(150).optional(),config:s.z.object({flow_id:s.z.string().max(30),next_node:s.z.string()})}),s.z.object({id:s.z.string(),type:s.z.literal("ROUTER"),coordinates:s.z.object({x:s.z.number(),y:s.z.number()}),alias:s.z.string().min(1).max(150),config:s.z.object({rules:s.z.array(s.z.object({id:s.z.string(),alias:s.z.string().min(1).max(150).optional(),condition:s.z.any(),next_node:s.z.string()})),fallback:s.z.array(s.z.string())})}),s.z.object({id:s.z.string(),type:s.z.literal("STEP"),coordinates:s.z.object({x:s.z.number(),y:s.z.number()}),alias:s.z.string().min(1).max(150).optional(),config:s.z.object({components:s.z.array(Vh),next_node:s.z.string()})})])).optional(),start:s.z.object({hidden_fields:s.z.array(s.z.object({key:s.z.string(),value:s.z.string()})).optional(),next_node:s.z.string().optional(),coordinates:s.z.object({x:s.z.number(),y:s.z.number()}).optional()}).optional(),ending:s.z.object({redirection:s.z.object({delay:s.z.number().optional(),target:s.z.string().optional()}).optional(),after_submit:s.z.object({flow_id:s.z.string().optional()}).optional(),coordinates:s.z.object({x:s.z.number(),y:s.z.number()}).optional(),resume_flow:s.z.boolean().optional()}).optional(),style:s.z.object({css:s.z.string().optional()}).optional()}).openapi({description:"Schema for flow-based forms (matches new JSON structure)"}),tr=s.z.object({..._s.shape,...So.shape,id:s.z.string()}),qh=s.z.enum(["pre-user-signup","post-user-registration","post-user-login"]),Hh=s.z.enum(["pre-user-signup","post-user-registration","post-user-login"]),bs={enabled:s.z.boolean().default(!1),synchronous:s.z.boolean().default(!1),priority:s.z.number().optional(),hook_id:s.z.string().optional()},t_=s.z.object({...bs,trigger_id:qh,url:s.z.string()}),n_=s.z.object({...bs,trigger_id:Hh,form_id:s.z.string()}),Qi=s.z.union([t_,n_]),r_=s.z.object({...bs,trigger_id:qh,..._s.shape,hook_id:s.z.string(),url:s.z.string()}),i_=s.z.object({...bs,trigger_id:Hh,..._s.shape,hook_id:s.z.string(),form_id:s.z.string()}),nr=s.z.union([r_,i_]),Dd=s.z.object({alg:s.z.enum(["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512"]),e:s.z.string(),kid:s.z.string(),kty:s.z.enum(["RSA","EC","oct"]),n:s.z.string(),x5t:s.z.string().optional(),x5c:s.z.array(s.z.string()).optional(),use:s.z.enum(["sig","enc"]).optional()}),Kh=s.z.object({keys:s.z.array(Dd)}),ec=s.z.object({issuer:s.z.string(),authorization_endpoint:s.z.string(),token_endpoint:s.z.string(),device_authorization_endpoint:s.z.string(),userinfo_endpoint:s.z.string(),mfa_challenge_endpoint:s.z.string(),jwks_uri:s.z.string(),registration_endpoint:s.z.string(),revocation_endpoint:s.z.string(),scopes_supported:s.z.array(s.z.string()),response_types_supported:s.z.array(s.z.string()),code_challenge_methods_supported:s.z.array(s.z.string()),response_modes_supported:s.z.array(s.z.string()),subject_types_supported:s.z.array(s.z.string()),id_token_signing_alg_values_supported:s.z.array(s.z.string()),token_endpoint_auth_methods_supported:s.z.array(s.z.string()),claims_supported:s.z.array(s.z.string()),request_uri_parameter_supported:s.z.boolean(),request_parameter_supported:s.z.boolean(),token_endpoint_auth_signing_alg_values_supported:s.z.array(s.z.string())}),Gh=s.z.object({csrf_token:s.z.string(),auth0Client:s.z.string().optional(),authParams:Yr,expires_at:s.z.string(),deleted_at:s.z.string().optional(),ip:s.z.string().optional(),useragent:s.z.string().optional(),session_id:s.z.string().optional(),authorization_url:s.z.string().optional(),login_completed:s.z.boolean().optional().default(!1)}).openapi({description:"This represents a login sesion"}),o_=s.z.object({...Gh.shape,id:s.z.string().openapi({description:"This is is used as the state in the universal login"}),created_at:s.z.string(),updated_at:s.z.string()});var he=(t=>(t.FAILED_SILENT_AUTH="fsa",t.FAILED_SIGNUP="fs",t.FAILED_LOGIN="f",t.FAILED_LOGIN_INCORRECT_PASSWORD="fp",t.FAILED_CHANGE_PASSWORD="fcp",t.FAILED_BY_CONNECTOR="fc",t.FAILED_LOGIN_INVALID_EMAIL_USERNAME="fu",t.FAILED_HOOK="fh",t.FAILED_CROSS_ORIGIN_AUTHENTICATION="fcoa",t.SUCCESS_API_OPERATION="sapi",t.SUCCESS_CHANGE_PASSWORD="scp",t.SUCCESS_CHANGE_PASSWORD_REQUEST="scpr",t.SUCCESS_CHANGE_USERNAME="scu",t.SUCCESS_CROSS_ORIGIN_AUTHENTICATION="scoa",t.SUCCESS_EXCHANGE_AUTHORIZATION_CODE_FOR_ACCESS_TOKEN="seacft",t.SUCCESS_EXCHANGE_REFRESH_TOKEN_FOR_ACCESS_TOKEN="serft",t.SUCCESS_LOGIN="s",t.SUCCESS_LOGOUT="slo",t.SUCCESS_SIGNUP="ss",t.SUCCESS_SILENT_AUTH="ssa",t.SUCCESS_VERIFICATION_EMAIL="sv",t.SUCCESS_VERIFICATION_EMAIL_REQUEST="svr",t.CODE_LINK_SENT="cls",t.BLOCKED_ACCOUNT_EMAIL="limit_wc",t.BLOCKED_ACCOUNT_IP="limit_sul",t.BLOCKED_IP_ADDRESS="limit_mu",t))(he||{});const s_=s.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"]),Wh=s.z.object({name:s.z.string(),version:s.z.string(),env:s.z.object({node:s.z.string().optional()}).optional()}),Ao=s.z.object({type:s_,date:s.z.string(),description:s.z.string().optional(),log_id:s.z.string().optional(),_id:s.z.string().optional(),ip:s.z.string(),user_agent:s.z.string(),details:s.z.any().optional(),isMobile:s.z.boolean(),user_id:s.z.string().optional(),user_name:s.z.string().optional(),connection:s.z.string().optional(),connection_id:s.z.string().optional(),client_id:s.z.string().optional(),client_name:s.z.string().optional(),audience:s.z.string().optional(),scope:s.z.array(s.z.string()).optional(),strategy:s.z.string().optional(),strategy_type:s.z.string().optional(),hostname:s.z.string().optional(),auth0_client:Wh.optional()}),Jh=s.z.object({user_id:s.z.string(),password:s.z.string(),algorithm:s.z.enum(["bcrypt","argon2id"]).default("argon2id")}),a_=s.z.object({...Jh.shape,created_at:s.z.string(),updated_at:s.z.string()}),Xh=s.z.object({initial_user_agent:s.z.string().describe("First user agent of the device from which this user logged in"),initial_ip:s.z.string().describe("First IP address associated with this session"),initial_asn:s.z.string().describe("First autonomous system number associated with this session"),last_user_agent:s.z.string().describe("Last user agent of the device from which this user logged in"),last_ip:s.z.string().describe("Last IP address from which this user logged in"),last_asn:s.z.string().describe("Last autonomous system number from which this user logged in")}),Zh=s.z.object({id:s.z.string(),revoked_at:s.z.string().optional(),used_at:s.z.string().optional(),user_id:s.z.string().describe("The user ID associated with the session"),expires_at:s.z.string().optional(),login_session_id:s.z.string(),idle_expires_at:s.z.string().optional(),device:Xh.describe("Metadata related to the device used in the session"),clients:s.z.array(s.z.string()).describe("List of client details for the session")}),$s=s.z.object({created_at:s.z.string(),updated_at:s.z.string(),authenticated_at:s.z.string(),last_interaction_at:s.z.string(),...Zh.shape}),tc=s.z.object({kid:s.z.string().openapi({description:"The key id of the signing key"}),cert:s.z.string().openapi({description:"The public certificate of the signing key"}),fingerprint:s.z.string().openapi({description:"The cert fingerprint"}),thumbprint:s.z.string().openapi({description:"The cert thumbprint"}),pkcs7:s.z.string().optional().openapi({description:"The private key in pkcs7 format"}),current:s.z.boolean().optional().openapi({description:"True if the key is the current key"}),next:s.z.boolean().optional().openapi({description:"True if the key is the next key"}),previous:s.z.boolean().optional().openapi({description:"True if the key is the previous key"}),current_since:s.z.string().optional().openapi({description:"The date and time when the key became the current key"}),current_until:s.z.string().optional().openapi({description:"The date and time when the current key was rotated"}),revoked:s.z.boolean().optional().openapi({description:"True if the key is revoked"}),revoked_at:s.z.string().optional().openapi({description:"The date and time when the key was revoked"})});var rr=(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))(rr||{});const Vd=s.z.object({access_token:s.z.string(),id_token:s.z.string().optional(),scope:s.z.string().optional(),state:s.z.string().optional(),refresh_token:s.z.string().optional(),token_type:s.z.string(),expires_in:s.z.number()});s.z.object({code:s.z.string(),state:s.z.string().optional()});const Yh=s.z.object({button_border_radius:s.z.number(),button_border_weight:s.z.number(),buttons_style:s.z.enum(["pill"]),input_border_radius:s.z.number(),input_border_weight:s.z.number(),inputs_style:s.z.enum(["pill"]),show_widget_shadow:s.z.boolean(),widget_border_weight:s.z.number(),widget_corner_radius:s.z.number()}),Qh=s.z.object({base_focus_color:s.z.string(),base_hover_color:s.z.string(),body_text:s.z.string(),captcha_widget_theme:s.z.enum(["auto"]),error:s.z.string(),header:s.z.string(),icons:s.z.string(),input_background:s.z.string(),input_border:s.z.string(),input_filled_text:s.z.string(),input_labels_placeholders:s.z.string(),links_focused_components:s.z.string(),primary_button:s.z.string(),primary_button_label:s.z.string(),secondary_button_border:s.z.string(),secondary_button_label:s.z.string(),success:s.z.string(),widget_background:s.z.string(),widget_border:s.z.string()}),wn=s.z.object({bold:s.z.boolean(),size:s.z.number()}),e0=s.z.object({body_text:wn,buttons_text:wn,font_url:s.z.string(),input_labels:wn,links:wn,links_style:s.z.enum(["normal"]),reference_text_size:s.z.number(),subtitle:wn,title:wn}),t0=s.z.object({background_color:s.z.string(),background_image_url:s.z.string(),page_layout:s.z.enum(["center"])}),n0=s.z.object({header_text_alignment:s.z.enum(["center"]),logo_height:s.z.number(),logo_position:s.z.enum(["center"]),logo_url:s.z.string(),social_buttons_layout:s.z.enum(["bottom"])}),r0=s.z.object({borders:Yh,colors:Qh,displayName:s.z.string(),fonts:e0,page_background:t0,widget:n0}),c_=r0.extend({themeId:s.z.string()}),eo=s.z.object({universal_login_experience:s.z.enum(["new","classic"]).default("new"),identifier_first:s.z.boolean().default(!0),password_first:s.z.boolean().default(!1),webauthn_platform_first_factor:s.z.boolean()}),to=s.z.object({name:s.z.string(),enabled:s.z.boolean().optional().default(!0),default_from_address:s.z.string().optional(),credentials:s.z.union([s.z.object({accessKeyId:s.z.string(),secretAccessKey:s.z.string(),region:s.z.string()}),s.z.object({smtp_host:s.z.array(s.z.string()),smtp_port:s.z.number(),smtp_user:s.z.string(),smtp_pass:s.z.string()}),s.z.object({api_key:s.z.string(),domain:s.z.string().optional()}),s.z.object({connectionString:s.z.string()}),s.z.object({tenantId:s.z.string(),clientId:s.z.string(),clientSecret:s.z.string()})]),settings:s.z.object({}).optional()}),qd=s.z.object({id:s.z.string(),session_id:s.z.string(),user_id:s.z.string(),client_id:s.z.string(),expires_at:s.z.string().optional(),idle_expires_at:s.z.string().optional(),last_exchanged_at:s.z.string().optional(),device:Xh,resource_servers:s.z.array(s.z.object({audience:s.z.string(),scopes:s.z.string()})),rotating:s.z.boolean()}),d_=s.z.object({created_at:s.z.string(),...qd.shape}),l_=s.z.object({to:s.z.string(),message:s.z.string()}),u_=s.z.object({name:s.z.string(),options:s.z.object({})});function p_(t){const[e,n]=t.split("|");if(!e||!n)throw new Error(`Invalid user_id: ${t}`);return{connection:e,id:n}}const f_=new s.OpenAPIHono().openapi(s.createRoute({tags:["branding"],method:"get",path:"/",request:{headers:s.z.object({"tenant-id":s.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(s.createRoute({tags:["branding"],method:"patch",path:"/",request:{headers:s.z.object({"tenant-id":s.z.string()}),body:{content:{"application/json":{schema:s.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 A=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})}},Eo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function i0(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function h_(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 g_(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 m_={},__=Object.freeze(Object.defineProperty({__proto__:null,default:m_},Symbol.toStringTag,{value:"Module"})),y_=h_(__);(function(t){/**
1
+ "use strict";var z1=Object.defineProperty;var I1=(t,e,n)=>e in t?z1(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var te=(t,e,n)=>I1(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@hono/zod-openapi"),ne=t=>typeof t=="string",Br=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},yu=t=>t==null?"":""+t,N1=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},C1=/###/g,wu=t=>t&&t.indexOf("###")>-1?t.replace(C1,"."):t,vu=t=>!t||ne(t),qr=(t,e,n)=>{const r=ne(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(vu(t))return{};const o=wu(r[i]);!t[o]&&n&&(t[o]=new n),Object.prototype.hasOwnProperty.call(t,o)?t=t[o]:t={},++i}return vu(t)?{}:{obj:t,k:wu(r[i])}},bu=(t,e,n)=>{const{obj:r,k:i}=qr(t,e,Object);if(r!==void 0||e.length===1){r[i]=n;return}let o=e[e.length-1],a=e.slice(0,e.length-1),c=qr(t,a,Object);for(;c.obj===void 0&&a.length;)o=`${a[a.length-1]}.${o}`,a=a.slice(0,a.length-1),c=qr(t,a,Object),c!=null&&c.obj&&typeof c.obj[`${c.k}.${o}`]<"u"&&(c.obj=void 0);c.obj[`${c.k}.${o}`]=n},j1=(t,e,n,r)=>{const{obj:i,k:o}=qr(t,e,Object);i[o]=i[o]||[],i[o].push(n)},_o=(t,e)=>{const{obj:n,k:r}=qr(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},O1=(t,e,n)=>{const r=_o(t,n);return r!==void 0?r:_o(e,n)},wh=(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]):wh(t[r],e[r],n):t[r]=e[r]);return t},Wn=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var P1={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const T1=t=>ne(t)?t.replace(/[&<>"'\/]/g,e=>P1[e]):t;class R1{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 B1=[" ",",","?","!",";"],L1=new R1(20),U1=(t,e,n)=>{e=e||"",n=n||"";const r=B1.filter(a=>e.indexOf(a)<0&&n.indexOf(a)<0);if(r.length===0)return!0;const i=L1.getRegExp(`(${r.map(a=>a==="?"?"\\?":a).join("|")})`);let o=!i.test(t);if(!o){const a=t.indexOf(n);a>0&&!i.test(t.substring(0,a))&&(o=!0)}return o},Ya=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 o=0;o<r.length;){if(!i||typeof i!="object")return;let a,c="";for(let d=o;d<r.length;++d)if(d!==o&&(c+=n),c+=r[d],a=i[c],a!==void 0){if(["string","number","boolean"].indexOf(typeof a)>-1&&d<r.length-1)continue;o+=d-o+1;break}i=a}return i},yo=t=>t==null?void 0:t.replace("_","-"),M1={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 wo{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||M1,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 wo(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new wo(this.logger,e)}}var zt=new wo;class ms{constructor(){this.observers={}}on(e,n){return e.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);const i=this.observers[r].get(n)||0;this.observers[r].set(n,i+1)}),this}off(e,n){if(this.observers[e]){if(!n){delete this.observers[e];return}this.observers[e].delete(n)}}emit(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];this.observers[e]&&Array.from(this.observers[e].entries()).forEach(a=>{let[c,d]=a;for(let l=0;l<d;l++)c(...r)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(a=>{let[c,d]=a;for(let l=0;l<d;l++)c.apply(c,[e,...r])})}}class $u extends ms{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 o=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,a=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let c;e.indexOf(".")>-1?c=e.split("."):(c=[e,n],r&&(Array.isArray(r)?c.push(...r):ne(r)&&o?c.push(...r.split(o)):c.push(r)));const d=_o(this.data,c);return!d&&!n&&!r&&e.indexOf(".")>-1&&(e=c[0],n=c[1],r=c.slice(2).join(".")),d||!a||!ne(r)?d:Ya((u=(l=this.data)==null?void 0:l[e])==null?void 0:u[n],r,o)}addResource(e,n,r,i){let o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1};const a=o.keySeparator!==void 0?o.keySeparator:this.options.keySeparator;let c=[e,n];r&&(c=c.concat(a?r.split(a):r)),e.indexOf(".")>-1&&(c=e.split("."),i=n,n=c[1]),this.addNamespaces(n),bu(this.data,c,i),o.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 o in r)(ne(r[o])||Array.isArray(r[o]))&&this.addResource(e,n,o,r[o],{silent:!0});i.silent||this.emit("added",e,n,r)}addResourceBundle(e,n,r,i,o){let a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1,skipCopy:!1},c=[e,n];e.indexOf(".")>-1&&(c=e.split("."),i=r,r=n,n=c[1]),this.addNamespaces(n);let d=_o(this.data,c)||{};a.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?wh(d,r,o):d={...d,...r},bu(this.data,c,d),a.silent||this.emit("added",e,n,r)}removeResourceBundle(e,n){this.hasResourceBundle(e,n)&&delete this.data[e][n],this.removeNamespaces(n),this.emit("removed",e,n)}hasResourceBundle(e,n){return this.getResource(e,n)!==void 0}getResourceBundle(e,n){return n||(n=this.options.defaultNS),this.getResource(e,n)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const n=this.getDataByLanguage(e);return!!(n&&Object.keys(n)||[]).find(i=>n[i]&&Object.keys(n[i]).length>0)}toJSON(){return this.data}}var vh={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,n,r,i){return t.forEach(o=>{var a;e=((a=this.processors[o])==null?void 0:a.process(e,n,r,i))??e}),e}};const xu={};class vo extends ms{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),N1(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=zt.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 o=n.ns||this.options.defaultNS||[];const a=r&&e.indexOf(r)>-1,c=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!U1(e,r,i);if(a&&!c){const d=e.match(this.interpolator.nestingRegexp);if(d&&d.length>0)return{key:e,namespaces:ne(o)?[o]:o};const l=e.split(r);(r!==i||r===i&&this.options.ns.indexOf(l[0])>-1)&&(o=l.shift()),e=l.join(i)}return{key:e,namespaces:ne(o)?[o]:o}}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,o=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator,{key:a,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}${a}`,usedKey:a,exactUsedKey:a,usedLng:l,usedNS:d,usedParams:this.getUsedParamsDetails(n)}:`${d}${L}${a}`}return i?{res:a,usedKey:a,exactUsedKey:a,usedLng:l,usedNS:d,usedParams:this.getUsedParamsDetails(n)}:a}const f=this.resolve(e,n);let m=f==null?void 0:f.res;const w=(f==null?void 0:f.usedKey)||a,h=(f==null?void 0:f.exactUsedKey)||a,y=Object.prototype.toString.apply(m),v=["[object Number]","[object Function]","[object RegExp]"],b=n.joinArrays!==void 0?n.joinArrays:this.options.joinArrays,E=!this.i18nFormat||this.i18nFormat.handleAsObject,C=!ne(m)&&typeof m!="boolean"&&typeof m!="number";if(E&&m&&C&&v.indexOf(y)<0&&!(ne(b)&&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 '${a} (${this.language})' returned an object instead of string.`;return i?(f.res=L,f.usedParams=this.getUsedParamsDetails(n),f):L}if(o){const L=Array.isArray(m),Y=L?[]:{},se=L?h:w;for(const ae in m)if(Object.prototype.hasOwnProperty.call(m,ae)){const Se=`${se}${o}${ae}`;Y[ae]=this.translate(Se,{...n,joinArrays:!1,ns:c}),Y[ae]===Se&&(Y[ae]=m[ae])}m=Y}}else if(E&&ne(b)&&Array.isArray(m))m=m.join(b),m&&(m=this.extendTranslation(m,e,n,r));else{let L=!1,Y=!1;const se=n.count!==void 0&&!ne(n.count),ae=vo.hasDefaultValue(n),Se=se?this.pluralResolver.getSuffix(l,n.count,n):"",ze=n.ordinal&&se?this.pluralResolver.getSuffix(l,n.count,{ordinal:!1}):"",Ce=se&&!n.ordinal&&n.count===0,j=Ce&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${Se}`]||n[`defaultValue${ze}`]||n.defaultValue;!this.isValidLookup(m)&&ae&&(L=!0,m=j),this.isValidLookup(m)||(Y=!0,m=a);const z=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&Y?void 0:m,k=ae&&j!==m&&this.options.updateMissing;if(Y||L||k){if(this.logger.log(k?"updateKey":"missingKey",l,d,a,k?j:m),o){const Q=this.resolve(a,{...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 x=[];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++)x.push(P[Q]);else this.options.saveMissingTo==="all"?x=this.languageUtils.toResolveHierarchy(n.lng||this.language):x.push(n.lng||this.language);const U=(Q,W,oe)=>{var q;const ue=ae&&oe!==m?oe:z;this.options.missingKeyHandler?this.options.missingKeyHandler(Q,d,W,ue,k,n):(q=this.backendConnector)!=null&&q.saveMissing&&this.backendConnector.saveMissing(Q,d,W,ue,k,n),this.emit("missingKey",Q,d,W,m)};this.options.saveMissing&&(this.options.saveMissingPlurals&&se?x.forEach(Q=>{const W=this.pluralResolver.getSuffixes(Q,n);Ce&&n[`defaultValue${this.options.pluralSeparator}zero`]&&W.indexOf(`${this.options.pluralSeparator}zero`)<0&&W.push(`${this.options.pluralSeparator}zero`),W.forEach(oe=>{U([Q],a+oe,n[`defaultValue${oe}`]||j)})}):U(x,a,j))}m=this.extendTranslation(m,e,n,f,r),Y&&m===a&&this.options.appendNamespaceToMissingKey&&(m=`${d}:${a}`),(Y||L)&&this.options.parseMissingKeyHandler&&(m=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${d}:${a}`:a,L?m:void 0))}return i?(f.res=m,f.usedParams=this.getUsedParamsDetails(n),f):m}extendTranslation(e,n,r,i,o){var l,u;var a=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 f=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(f){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),f){const h=e.match(this.interpolator.nestingRegexp),y=h&&h.length;m<y&&(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,y=new Array(h),v=0;v<h;v++)y[v]=arguments[v];return(o==null?void 0:o[0])===y[0]&&!r.context?(a.logger.warn(`It seems you are nesting recursively key: ${y[0]} in key: ${n[0]}`),null):a.translate(...y,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=vh.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,o,a,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 f=l.namespaces;this.options.fallbackNS&&(f=f.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!=="",y=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);f.forEach(v=>{var b,E;this.isValidLookup(r)||(c=v,!xu[`${y[0]}-${v}`]&&((b=this.utils)!=null&&b.hasLoadedNamespace)&&!((E=this.utils)!=null&&E.hasLoadedNamespace(c))&&(xu[`${y[0]}-${v}`]=!0,this.logger.warn(`key "${i}" for languages "${y.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!!!")),y.forEach(C=>{var se;if(this.isValidLookup(r))return;a=C;const L=[u];if((se=this.i18nFormat)!=null&&se.addLookupKeys)this.i18nFormat.addLookupKeys(L,u,C,v,n);else{let ae;m&&(ae=this.pluralResolver.getSuffix(C,n.count,n));const Se=`${this.options.pluralSeparator}zero`,ze=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(L.push(u+ae),n.ordinal&&ae.indexOf(ze)===0&&L.push(u+ae.replace(ze,this.options.pluralSeparator)),w&&L.push(u+Se)),h){const Ce=`${u}${this.options.contextSeparator}${n.context}`;L.push(Ce),m&&(L.push(Ce+ae),n.ordinal&&ae.indexOf(ze)===0&&L.push(Ce+ae.replace(ze,this.options.pluralSeparator)),w&&L.push(Ce+Se))}}let Y;for(;Y=L.pop();)this.isValidLookup(r)||(o=Y,r=this.getResource(C,v,Y,n))}))})}),{res:r,usedKey:i,exactUsedKey:o,usedLng:a,usedNS:c}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,n,r){var o;let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return(o=this.i18nFormat)!=null&&o.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 o of n)delete i[o]}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 ku{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=zt.create("languageUtils")}getScriptPartFromCode(e){if(e=yo(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=yo(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(o=>{if(o===i)return o;if(!(o.indexOf("-")<0&&i.indexOf("-")<0)&&(o.indexOf("-")>0&&i.indexOf("-")<0&&o.substring(0,o.indexOf("-"))===i||o.indexOf(i)===0&&i.length>1))return o})}),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=[],o=a=>{a&&(this.isSupportedCode(a)?i.push(a):this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`))};return ne(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&o(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&o(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&o(this.getLanguagePartFromCode(e))):ne(e)&&o(this.formatLanguageCode(e)),r.forEach(a=>{i.indexOf(a)<0&&o(this.formatLanguageCode(a))}),i}}const Su={zero:0,one:1,two:2,few:3,many:4,other:5},Au={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class F1{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=e,this.options=n,this.logger=zt.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=yo(e==="dev"?"en":e),i=n.ordinal?"ordinal":"cardinal",o=JSON.stringify({cleanedCode:r,type:i});if(o in this.pluralRulesCache)return this.pluralRulesCache[o];let a;try{a=new Intl.PluralRules(r,{type:i})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),Au;if(!e.match(/-|_/))return Au;const d=this.languageUtils.getLanguagePartFromCode(e);a=this.getRule(d,n)}return this.pluralRulesCache[o]=a,a}needsPlural(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),(r==null?void 0:r.resolvedOptions().pluralCategories.length)>1}getPluralFormsOfKey(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.getSuffixes(e,r).map(i=>`${n}${i}`)}getSuffixes(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),r?r.resolvedOptions().pluralCategories.sort((i,o)=>Su[i]-Su[o]).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 Eu=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,o=O1(t,e,n);return!o&&i&&ne(n)&&(o=Ya(t,n,r),o===void 0&&(o=Ya(e,n,r))),o},Ea=t=>t.replace(/\$/g,"$$$$");class D1{constructor(){var n;let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=zt.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:o,prefixEscaped:a,suffix:c,suffixEscaped:d,formatSeparator:l,unescapeSuffix:u,unescapePrefix:f,nestingPrefix:m,nestingPrefixEscaped:w,nestingSuffix:h,nestingSuffixEscaped:y,nestingOptionsSeparator:v,maxReplaces:b,alwaysFormat:E}=e.interpolation;this.escape=n!==void 0?n:T1,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=o?Wn(o):a||"{{",this.suffix=c?Wn(c):d||"}}",this.formatSeparator=l||",",this.unescapePrefix=u?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":u||"",this.nestingPrefix=m?Wn(m):w||Wn("$t("),this.nestingSuffix=h?Wn(h):y||Wn(")"),this.nestingOptionsSeparator=v||",",this.maxReplaces=b||1e3,this.alwaysFormat=E!==void 0?E:!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 o,a,c;const d=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},l=h=>{if(h.indexOf(this.formatSeparator)<0){const E=Eu(n,d,h,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(E,void 0,r,{...i,...n,interpolationkey:h}):E}const y=h.split(this.formatSeparator),v=y.shift().trim(),b=y.join(this.formatSeparator).trim();return this.format(Eu(n,d,v,this.options.keySeparator,this.options.ignoreJSONStructure),b,r,{...i,...n,interpolationkey:v})};this.resetRegExp();const u=(i==null?void 0:i.missingInterpolationHandler)||this.options.missingInterpolationHandler,f=((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=>Ea(h)},{regex:this.regexp,safeValue:h=>this.escapeValue?Ea(this.escape(h)):Ea(h)}].forEach(h=>{for(c=0;o=h.regex.exec(e);){const y=o[1].trim();if(a=l(y),a===void 0)if(typeof u=="function"){const b=u(e,o,i);a=ne(b)?b:""}else if(i&&Object.prototype.hasOwnProperty.call(i,y))a="";else if(f){a=o[0];continue}else this.logger.warn(`missed to pass in variable ${y} for interpolating ${e}`),a="";else!ne(a)&&!this.useRawValueToEscape&&(a=yu(a));const v=h.safeValue(a);if(e=e.replace(o[0],v),f?(h.regex.lastIndex+=a.length,h.regex.lastIndex-=o[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,o,a;const c=(d,l)=>{const u=this.nestingOptionsSeparator;if(d.indexOf(u)<0)return d;const f=d.split(new RegExp(`${u}[ ]*{`));let m=`{${f[1]}`;d=f[0],m=this.interpolate(m,a);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{a=JSON.parse(m),l&&(a={...l,...a})}catch(y){return this.logger.warn(`failed parsing options string in nesting for key ${d}`,y),`${d}${u}${m}`}return a.defaultValue&&a.defaultValue.indexOf(this.prefix)>-1&&delete a.defaultValue,d};for(;i=this.nestingRegexp.exec(e);){let d=[];a={...r},a=a.replace&&!ne(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;let l=!1;if(i[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(i[1])){const u=i[1].split(this.formatSeparator).map(f=>f.trim());i[1]=u.shift(),d=u,l=!0}if(o=n(c.call(this,i[1].trim(),a),a),o&&i[0]===e&&!ne(o))return o;ne(o)||(o=yu(o)),o||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),o=""),l&&(o=d.reduce((u,f)=>this.format(u,f,r.lng,{...r,interpolationkey:i[1].trim()}),o.trim())),e=e.replace(i[0],o),this.regexp.lastIndex=0}return e}}const V1=t=>{let e=t.toLowerCase().trim();const n={};if(t.indexOf("(")>-1){const r=t.split("(");e=r[0].toLowerCase().trim();const i=r[1].substring(0,r[1].length-1);e==="currency"&&i.indexOf(":")<0?n.currency||(n.currency=i.trim()):e==="relativetime"&&i.indexOf(":")<0?n.range||(n.range=i.trim()):i.split(";").forEach(a=>{if(a){const[c,...d]=a.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}},Jn=t=>{const e={};return(n,r,i)=>{let o=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(o={...o,[i.interpolationkey]:void 0});const a=r+JSON.stringify(o);let c=e[a];return c||(c=t(yo(r),i),e[a]=c),c(n)}};class q1{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=zt.create("formatter"),this.options=e,this.formats={number:Jn((n,r)=>{const i=new Intl.NumberFormat(n,{...r});return o=>i.format(o)}),currency:Jn((n,r)=>{const i=new Intl.NumberFormat(n,{...r,style:"currency"});return o=>i.format(o)}),datetime:Jn((n,r)=>{const i=new Intl.DateTimeFormat(n,{...r});return o=>i.format(o)}),relativetime:Jn((n,r)=>{const i=new Intl.RelativeTimeFormat(n,{...r});return o=>i.format(o,r.range||"day")}),list:Jn((n,r)=>{const i=new Intl.ListFormat(n,{...r});return o=>i.format(o)})},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()]=Jn(n)}format(e,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const o=n.split(this.formatSeparator);if(o.length>1&&o[0].indexOf("(")>1&&o[0].indexOf(")")<0&&o.find(c=>c.indexOf(")")>-1)){const c=o.findIndex(d=>d.indexOf(")")>-1);o[0]=[o[0],...o.splice(1,c)].join(this.formatSeparator)}return o.reduce((c,d)=>{var f;const{formatName:l,formatOptions:u}=V1(d);if(this.formats[l]){let m=c;try{const w=((f=i==null?void 0:i.formatParams)==null?void 0:f[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 H1=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class K1 extends ms{constructor(e,n,r){var o,a;let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=zt.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],(a=(o=this.backend)==null?void 0:o.init)==null||a.call(o,r,i.backend,i)}queueLoad(e,n,r,i){const o={},a={},c={},d={};return e.forEach(l=>{let u=!0;n.forEach(f=>{const m=`${l}|${f}`;!r.reload&&this.store.hasResourceBundle(l,f)?this.state[m]=2:this.state[m]<0||(this.state[m]===1?a[m]===void 0&&(a[m]=!0):(this.state[m]=1,u=!1,a[m]===void 0&&(a[m]=!0),o[m]===void 0&&(o[m]=!0),d[f]===void 0&&(d[f]=!0)))}),u||(c[l]=!0)}),(Object.keys(o).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(o),pending:Object.keys(a),toLoadLanguages:Object.keys(c),toLoadNamespaces:Object.keys(d)}}loaded(e,n,r){const i=e.split("|"),o=i[0],a=i[1];n&&this.emit("failedLoading",o,a,n),!n&&r&&this.store.addResourceBundle(o,a,r,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&r&&(this.state[e]=0);const c={};this.queue.forEach(d=>{j1(d.loaded,[o],a),H1(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(f=>{c[l][f]===void 0&&(c[l][f]=!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,o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,a=arguments.length>5?arguments[5]:void 0;if(!e.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:n,fcName:r,tried:i,wait:o,callback:a});return}this.readingCalls++;const c=(l,u)=>{if(this.readingCalls--,this.waitingReads.length>0){const f=this.waitingReads.shift();this.read(f.lng,f.ns,f.fcName,f.tried,f.wait,f.callback)}if(l&&u&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,e,n,r,i+1,o*2,a)},o);return}a(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 o=this.queueLoad(e,n,r,i);if(!o.toLoad.length)return o.pending.length||i(),null;o.toLoad.forEach(a=>{this.loadOne(a)})}load(e,n,r){this.prepareLoading(e,n,{},r)}reload(e,n,r){this.prepareLoading(e,n,{reload:!0},r)}loadOne(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const r=e.split("|"),i=r[0],o=r[1];this.read(i,o,"read",void 0,void 0,(a,c)=>{a&&this.logger.warn(`${n}loading namespace ${o} for language ${i} failed`,a),!a&&c&&this.logger.log(`${n}loaded namespace ${o} for language ${i}`,c),this.loaded(e,a,c)})}saveMissing(e,n,r,i,o){var d,l,u,f,m;let a=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&&!((f=(u=this.services)==null?void 0:u.utils)!=null&&f.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={...a,isUpdate:o},h=this.backend.create.bind(this.backend);if(h.length<6)try{let y;h.length===5?y=h(e,n,r,i,w):y=h(e,n,r,i),y&&typeof y.then=="function"?y.then(v=>c(null,v)).catch(c):c(null,y)}catch(y){c(y)}else h(e,n,r,i,c,w)}!e||!e[0]||this.store.addResource(e[0],n,r,i)}}}const zu=()=>({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}}),Iu=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},Ki=()=>{},G1=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class Zr extends ms{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(super(),this.options=Iu(e),this.services={},this.logger=zt,this.modules={external:[]},G1(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=zu();this.options={...i,...this.options,...Iu(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 o=u=>u?typeof u=="function"?new u:u:null;if(!this.options.isClone){this.modules.logger?zt.init(o(this.modules.logger),this.options):zt.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=q1;const f=new ku(this.options);this.store=new $u(this.options.resources,this.options);const m=this.services;m.logger=zt,m.resourceStore=this.store,m.languageUtils=f,m.pluralResolver=new F1(f,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),u&&(!this.options.interpolation.format||this.options.interpolation.format===i.interpolation.format)&&(m.formatter=o(u),m.formatter.init(m,this.options),this.options.interpolation.format=m.formatter.format.bind(m.formatter)),m.interpolator=new D1(this.options),m.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},m.backendConnector=new K1(o(this.modules.backend),m.resourceStore,m,this.options),m.backendConnector.on("*",function(w){for(var h=arguments.length,y=new Array(h>1?h-1:0),v=1;v<h;v++)y[v-1]=arguments[v];e.emit(w,...y)}),this.modules.languageDetector&&(m.languageDetector=o(this.modules.languageDetector),m.languageDetector.init&&m.languageDetector.init(m,this.options.detection,this.options)),this.modules.i18nFormat&&(m.i18nFormat=o(this.modules.i18nFormat),m.i18nFormat.init&&m.i18nFormat.init(this)),this.translator=new vo(this.services,this.options),this.translator.on("*",function(w){for(var h=arguments.length,y=new Array(h>1?h-1:0),v=1;v<h;v++)y[v-1]=arguments[v];e.emit(w,...y)}),this.modules.external.forEach(w=>{w.init&&w.init(this)})}if(this.format=this.options.interpolation.format,r||(r=Ki),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=Br(),l=()=>{const u=(f,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(f,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 o,a;let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Ki;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(f=>{f!=="cimode"&&c.indexOf(f)<0&&c.push(f)})};i?d(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(u=>d(u)),(a=(o=this.options.preload)==null?void 0:o.forEach)==null||a.call(o,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=Br();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=Ki),this.services.backendConnector.reload(e,n,o=>{i.resolve(),r(o)}),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"&&vh.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=Br();this.emit("languageChanging",e);const o=d=>{this.language=d,this.languages=this.services.languageUtils.toResolveHierarchy(d),this.resolvedLanguage=void 0,this.setResolvedLanguage(d)},a=(d,l)=>{l?(o(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,f;!e&&!d&&this.services.languageDetector&&(d=[]);const l=ne(d)?d:this.services.languageUtils.getBestMatchFromCodes(d);l&&(this.language||o(l),this.translator.language||this.translator.changeLanguage(l),(f=(u=this.services.languageDetector)==null?void 0:u.cacheUserLanguage)==null||f.call(u,l)),this.loadResources(l,m=>{a(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 o=function(a,c){let d;if(typeof c!="object"){for(var l=arguments.length,u=new Array(l>2?l-2:0),f=2;f<l;f++)u[f-2]=arguments[f];d=i.options.overloadTranslationOptionHandler([a,c].concat(u))}else d={...c};d.lng=d.lng||o.lng,d.lngs=d.lngs||o.lngs,d.ns=d.ns||o.ns,d.keyPrefix!==""&&(d.keyPrefix=d.keyPrefix||r||o.keyPrefix);const m=i.options.keySeparator||".";let w;return d.keyPrefix&&Array.isArray(a)?w=a.map(h=>`${d.keyPrefix}${m}${h}`):w=d.keyPrefix?`${d.keyPrefix}${m}${a}`:a,i.t(w,d)};return ne(e)?o.lng=e:o.lngs=e,o.ns=n,o.keyPrefix=r,o}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,o=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const a=(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,a);if(c!==void 0)return c}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(r,e)&&(!i||a(o,e)))}loadNamespaces(e,n){const r=Br();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=Br();ne(e)&&(e=[e]);const i=this.options.preload||[],o=e.filter(a=>i.indexOf(a)<0&&this.services.languageUtils.isSupportedCode(a));return o.length?(this.options.preload=i.concat(o),this.loadResources(a=>{r.resolve(),n&&n(a)}),r):(n&&n(),Promise.resolve())}dir(e){var i,o;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=((o=this.services)==null?void 0:o.languageUtils)||new ku(zu());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 Zr(e,n)}cloneInstance(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Ki;const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},o=new Zr(i);if((e.debug!==void 0||e.prefix!==void 0)&&(o.logger=o.logger.clone(e)),["store","services","language"].forEach(c=>{o[c]=this[c]}),o.services={...this.services},o.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},r){const c=Object.keys(this.store.data).reduce((d,l)=>(d[l]={...this.store.data[l]},Object.keys(d[l]).reduce((u,f)=>(u[f]={...d[l][f]},u),{})),{});o.store=new $u(c,i),o.services.resourceStore=o.store}return o.translator=new vo(o.services,i),o.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];o.emit(c,...l)}),o.init(i,n),o.translator.options=i,o.translator.backendConnector.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},o}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const O=Zr.createInstance();O.createInstance=Zr.createInstance;O.createInstance;O.dir;O.init;O.loadResources;O.reloadResources;O.use;O.changeLanguage;O.getFixedT;const re=O.t;O.exists;O.setDefaultNamespace;O.hasLoadedNamespace;O.loadNamespaces;O.loadLanguages;var bh=t=>{const n={...{origin:"*",allowMethods:["GET","HEAD","PUT","POST","DELETE","PATCH"],allowHeaders:[],exposeHeaders:[]},...t},r=(i=>typeof i=="string"?i==="*"?()=>i:o=>i===o?o:null:typeof i=="function"?i:o=>i.includes(o)?o:null)(n.origin);return async function(o,a){var l,u;function c(f,m){o.res.headers.set(f,m)}const d=r(o.req.header("origin")||"",o);if(d&&c("Access-Control-Allow-Origin",d),n.origin!=="*"){const f=o.req.header("Vary");f?c("Vary",f):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(",")),o.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 f=n.allowHeaders;if(!(f!=null&&f.length)){const m=o.req.header("Access-Control-Request-Headers");m&&(f=m.split(/\s*,\s*/))}return f!=null&&f.length&&(c("Access-Control-Allow-Headers",f.join(",")),o.res.headers.append("Vary","Access-Control-Request-Headers")),o.res.headers.delete("Content-Length"),o.res.headers.delete("Content-Type"),new Response(null,{headers:o.res.headers,status:204,statusText:"No Content"})}await a()}};const Xt=s.z.object({start:s.z.number(),limit:s.z.number(),length:s.z.number()}),_s=s.z.object({created_at:s.z.string(),updated_at:s.z.string()}),$h=s.z.object({email:s.z.string().optional(),email_verified:s.z.boolean().optional(),name:s.z.string().optional(),username:s.z.string().optional(),given_name:s.z.string().optional(),phone_number:s.z.string().optional(),phone_verified:s.z.boolean().optional(),family_name:s.z.string().optional()}).catchall(s.z.any()),xh=s.z.object({connection:s.z.string(),user_id:s.z.string(),provider:s.z.string(),isSocial:s.z.boolean(),access_token:s.z.string().optional(),access_token_secret:s.z.string().optional(),refresh_token:s.z.string().optional(),profileData:$h.optional()}),ys=s.z.object({email:s.z.string().optional().transform(t=>t&&t.toLowerCase()),username:s.z.string().optional(),phone_number:s.z.string().optional(),given_name:s.z.string().optional(),family_name:s.z.string().optional(),nickname:s.z.string().optional(),name:s.z.string().optional(),picture:s.z.string().optional(),locale:s.z.string().optional(),linked_to:s.z.string().optional(),profileData:s.z.string().optional(),user_id:s.z.string().optional(),app_metadata:s.z.any().default({}).optional(),user_metadata:s.z.any().default({}).optional()}),bo=ys.extend({email_verified:s.z.boolean().default(!1),verify_email:s.z.boolean().optional(),last_ip:s.z.string().optional(),last_login:s.z.string().optional(),user_id:s.z.string().optional(),provider:s.z.string().default("email"),connection:s.z.string().default("email"),is_social:s.z.boolean().optional()}),Bd=s.z.object({...bo.shape,..._s.shape,user_id:s.z.string(),is_social:s.z.boolean(),email:s.z.string().optional(),login_count:s.z.number().default(0),identities:s.z.array(xh).optional()}),Et=Bd,W1=ys.extend({login_count:s.z.number(),multifactor:s.z.array(s.z.string()).optional(),last_ip:s.z.string().optional(),last_login:s.z.string().optional(),user_id:s.z.string()}).catchall(s.z.any()),J1="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let X1=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=J1[n[t]&63];return e};const kh=s.z.object({audience:s.z.string().optional(),recipient:s.z.string().optional(),createUpnClaim:s.z.boolean().optional(),mapUnknownClaimsAsIs:s.z.boolean().optional(),passthroughClaimsWithNoMapping:s.z.boolean().optional(),mapIdentities:s.z.boolean().optional(),signatureAlgorithm:s.z.string().optional(),digestAlgorithm:s.z.string().optional(),issuer:s.z.string().optional(),destination:s.z.string().optional(),lifetimeInSeconds:s.z.number().optional(),signResponse:s.z.boolean().optional(),nameIdentifierFormat:s.z.string().optional(),nameIdentifierProbes:s.z.array(s.z.string()).optional(),authnContextClassRef:s.z.string().optional(),mappings:s.z.record(s.z.string()).optional()}),$o=s.z.object({id:s.z.string(),name:s.z.string(),callbacks:s.z.array(s.z.string()).default([]).optional().openapi({description:"Comma-separated list of URLs whitelisted to use as a callback to the client after authentication."}),allowed_origins:s.z.array(s.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:s.z.array(s.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:s.z.array(s.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:s.z.array(s.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:s.z.object({samlp:kh.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:s.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:s.z.string().default(()=>X1()).optional(),disable_sign_ups:s.z.boolean().optional().default(!1).openapi({description:"Prevents users from signing up using the hosted login page. This is not available in auth0"})}),xn=s.z.object({created_at:s.z.string().transform(t=>t===null?"":t),updated_at:s.z.string().transform(t=>t===null?"":t),...$o.shape}),xr=s.z.object({x:s.z.number(),y:s.z.number()});var Ld=(t=>(t.RICH_TEXT="RICH_TEXT",t.NEXT_BUTTON="NEXT_BUTTON",t.BACK_BUTTON="BACK_BUTTON",t.SUBMIT_BUTTON="SUBMIT_BUTTON",t.DIVIDER="DIVIDER",t.TEXT="TEXT",t.EMAIL="EMAIL",t.PASSWORD="PASSWORD",t.NUMBER="NUMBER",t.PHONE="PHONE",t.DATE="DATE",t.CHECKBOX="CHECKBOX",t.RADIO="RADIO",t.SELECT="SELECT",t.HIDDEN="HIDDEN",t.LEGAL="LEGAL",t))(Ld||{}),Ud=(t=>(t.BLOCK="BLOCK",t.FIELD="FIELD",t))(Ud||{});const ws=s.z.object({id:s.z.string(),category:s.z.nativeEnum(Ud),type:s.z.nativeEnum(Ld)}),Sh=ws.extend({category:s.z.literal("BLOCK"),type:s.z.literal("RICH_TEXT"),config:s.z.object({content:s.z.string()}).passthrough()}),Ah=ws.extend({category:s.z.literal("BLOCK"),type:s.z.union([s.z.literal("NEXT_BUTTON"),s.z.literal("BACK_BUTTON"),s.z.literal("SUBMIT_BUTTON")]),config:s.z.object({text:s.z.string()}).passthrough()}),Eh=ws.extend({category:s.z.literal("FIELD"),type:s.z.literal("LEGAL"),required:s.z.boolean().optional(),sensitive:s.z.boolean().optional(),config:s.z.object({text:s.z.string()}).passthrough()}),zh=ws.extend({category:s.z.literal("FIELD"),type:s.z.union([s.z.literal("TEXT"),s.z.literal("EMAIL"),s.z.literal("PASSWORD"),s.z.literal("NUMBER"),s.z.literal("PHONE"),s.z.literal("DATE"),s.z.literal("CHECKBOX"),s.z.literal("RADIO"),s.z.literal("SELECT"),s.z.literal("HIDDEN")]),required:s.z.boolean().optional(),sensitive:s.z.boolean().optional(),config:s.z.object({label:s.z.string().optional(),placeholder:s.z.string().optional()}).passthrough()}),Ih=s.z.object({id:s.z.string(),category:s.z.string(),type:s.z.string()}).passthrough(),Nh=s.z.union([Sh,Ah,Eh,zh,Ih]);var Ch=(t=>(t.STEP="STEP",t.FLOW="FLOW",t.CONDITION="CONDITION",t.ACTION="ACTION",t))(Ch||{});const jh=s.z.object({id:s.z.string(),type:s.z.literal("STEP"),coordinates:xr,alias:s.z.string().optional(),config:s.z.object({components:s.z.array(Nh),next_node:s.z.string()}).passthrough()}),Oh=s.z.object({id:s.z.string(),type:s.z.literal("FLOW"),coordinates:xr,alias:s.z.string().optional(),config:s.z.object({flow_id:s.z.string(),next_node:s.z.string()})}),Ph=s.z.object({id:s.z.string(),type:s.z.string(),coordinates:xr}).passthrough(),Th=s.z.union([jh,Oh,Ph]),Rh=s.z.object({next_node:s.z.string(),coordinates:xr}).passthrough(),Bh=s.z.object({resume_flow:s.z.boolean().optional(),coordinates:xr}).passthrough(),Lh=s.z.object({id:s.z.string(),name:s.z.string(),languages:s.z.object({primary:s.z.string()}).passthrough(),nodes:s.z.array(Th),start:Rh,ending:Bh,created_at:s.z.string(),updated_at:s.z.string(),links:s.z.object({sdkSrc:s.z.string().optional(),sdk_src:s.z.string().optional()}).passthrough()}).passthrough(),Z1=Lh.omit({id:!0,created_at:!0,updated_at:!0});var it=(t=>(t.TOKEN="token",t.TOKEN_ID_TOKEN="token id_token",t.CODE="code",t))(it||{}),Dt=(t=>(t.QUERY="query",t.FRAGMENT="fragment",t.FORM_POST="form_post",t.WEB_MESSAGE="web_message",t.SAML_POST="saml_post",t))(Dt||{}),vs=(t=>(t.S256="S256",t.Plain="plain",t))(vs||{});const Yr=s.z.object({client_id:s.z.string(),act_as:s.z.string().optional(),response_type:s.z.nativeEnum(it).optional(),response_mode:s.z.nativeEnum(Dt).optional(),redirect_uri:s.z.string().optional(),audience:s.z.string().optional(),organization:s.z.string().optional(),state:s.z.string().optional(),nonce:s.z.string().optional(),scope:s.z.string().optional(),prompt:s.z.string().optional(),code_challenge_method:s.z.nativeEnum(vs).optional(),code_challenge:s.z.string().optional(),username:s.z.string().optional(),ui_locales:s.z.string().optional(),vendor_id:s.z.string().optional()}),Qa=s.z.object({colors:s.z.object({primary:s.z.string(),page_background:s.z.object({type:s.z.string().optional(),start:s.z.string().optional(),end:s.z.string().optional(),angle_deg:s.z.number().optional()}).optional()}).optional(),logo_url:s.z.string().optional(),favicon_url:s.z.string().optional(),font:s.z.object({url:s.z.string()}).optional()}),Md=s.z.object({kid:s.z.string().optional(),team_id:s.z.string().optional(),realms:s.z.string().optional(),authentication_method:s.z.string().optional(),client_id:s.z.string().optional(),client_secret:s.z.string().optional(),app_secret:s.z.string().optional(),scope:s.z.string().optional(),authorization_endpoint:s.z.string().optional(),token_endpoint:s.z.string().optional(),userinfo_endpoint:s.z.string().optional(),jwks_uri:s.z.string().optional(),discovery_url:s.z.string().optional(),issuer:s.z.string().optional(),provider:s.z.string().optional(),from:s.z.string().optional(),twilio_sid:s.z.string().optional(),twilio_token:s.z.string().optional()}),xo=s.z.object({id:s.z.string().optional(),name:s.z.string(),strategy:s.z.string(),options:Md.default({}),enabled_clients:s.z.array(s.z.string()).default([]).optional(),response_type:s.z.custom().optional(),response_mode:s.z.custom().optional()}),rn=s.z.object({id:s.z.string(),created_at:s.z.string().transform(t=>t===null?"":t),updated_at:s.z.string().transform(t=>t===null?"":t)}).extend(xo.shape),ko=s.z.object({name:s.z.string(),audience:s.z.string(),sender_email:s.z.string().email(),sender_name:s.z.string(),support_url:s.z.string().url().optional(),logo:s.z.string().url().optional(),primary_color:s.z.string().optional(),secondary_color:s.z.string().optional(),language:s.z.string().optional(),id:s.z.string().optional()}),or=s.z.object({created_at:s.z.string().transform(t=>t===null?"":t),updated_at:s.z.string().transform(t=>t===null?"":t),...ko.shape,id:s.z.string()}),Uh=s.z.object({logoUrl:s.z.string(),loginBackgroundImage:s.z.string().nullish(),style:s.z.object({primaryColor:s.z.string(),buttonTextColor:s.z.string(),primaryHoverColor:s.z.string()}),supportEmail:s.z.string().nullable(),supportUrl:s.z.string().nullable(),name:s.z.string(),showGreyishBackground:s.z.boolean().optional(),termsAndConditionsUrl:s.z.string().nullable(),companyName:s.z.string().optional(),checkoutHideSocial:s.z.boolean().optional(),siteUrl:s.z.string().nullable(),manageSubscriptionsUrl:s.z.string().optional()});s.z.object({...xn.shape,tenant:or,connections:s.z.array(rn)});const Mh=s.z.enum(["password_reset","email_verification","otp","authorization_code","oauth2_state","ticket"]),Fh=s.z.object({code_id:s.z.string().openapi({description:"The code that will be used in for instance an email verification flow"}),login_id:s.z.string().openapi({description:"The id of the login session that the code is connected to"}),connection_id:s.z.string().optional().openapi({description:"The connection that the code is connected to"}),code_type:Mh,code_verifier:s.z.string().optional().openapi({description:"The code verifier used in PKCE in outbound flows"}),code_challenge:s.z.string().optional().openapi({description:"The code challenge used in PKCE in outbound flows"}),code_challenge_method:s.z.enum(["plain","S256"]).optional().openapi({description:"The code challenge method used in PKCE in outbound flows"}),redirect_uri:s.z.string().optional().openapi({description:"The redirect URI associated with the code"}),nonce:s.z.string().optional().openapi({description:"The nonce value used for security in OIDC flows"}),state:s.z.string().optional().openapi({description:"The state parameter used for CSRF protection in OAuth flows"}),expires_at:s.z.string(),used_at:s.z.string().optional(),user_id:s.z.string().optional()}),Y1=s.z.object({...Fh.shape,created_at:s.z.string()}),Fd=s.z.object({domain:s.z.string(),custom_domain_id:s.z.string().optional(),type:s.z.enum(["auth0_managed_certs","self_managed_certs"]),verification_method:s.z.enum(["txt"]).optional(),tls_policy:s.z.enum(["recommended"]).optional(),custom_client_ip_header:s.z.enum(["true-client-ip","cf-connecting-ip","x-forwarded-for","x-azure-clientip","null"]).optional(),domain_metadata:s.z.record(s.z.string().max(255)).optional()}),Dh=s.z.object({name:s.z.literal("txt"),record:s.z.string(),domain:s.z.string()}),nn=s.z.object({...Fd.shape,custom_domain_id:s.z.string(),primary:s.z.boolean(),status:s.z.enum(["disabled","pending","pending_verification","ready"]),origin_domain_name:s.z.string().optional(),verification:s.z.object({methods:s.z.array(Dh)}).optional(),tls_policy:s.z.string().optional()}),Q1=nn.extend({tenant_id:s.z.string()}),e_=s.z.object({id:s.z.string(),type:s.z.literal("submit"),label:s.z.string(),className:s.z.string().optional(),disabled:s.z.boolean().optional().default(!1),order:s.z.number().optional(),visible:s.z.boolean().optional().default(!0),customizations:s.z.record(s.z.string(),s.z.any()).optional()}),Vh=s.z.discriminatedUnion("type",[s.z.object({id:s.z.string(),type:s.z.literal("RICH_TEXT"),config:s.z.object({content:s.z.string()}),order:s.z.number().optional(),visible:s.z.boolean().optional().default(!0)}),s.z.object({id:s.z.string(),type:s.z.literal("LEGAL"),config:s.z.object({text:s.z.string(),html:s.z.boolean().optional()}),required:s.z.boolean().optional(),order:s.z.number().optional(),visible:s.z.boolean().optional().default(!0)}),s.z.object({id:s.z.string(),type:s.z.literal("NEXT_BUTTON"),config:s.z.object({text:s.z.string().optional()}),order:s.z.number().optional(),visible:s.z.boolean().optional().default(!0)})]),So=s.z.object({name:s.z.string().openapi({description:"The name of the form"}),messages:s.z.object({errors:s.z.record(s.z.string(),s.z.any()).optional(),custom:s.z.record(s.z.string(),s.z.any()).optional()}).optional(),languages:s.z.object({primary:s.z.string().optional(),default:s.z.string().optional()}).optional(),translations:s.z.record(s.z.string(),s.z.any()).optional(),nodes:s.z.array(s.z.discriminatedUnion("type",[s.z.object({id:s.z.string(),type:s.z.literal("FLOW"),coordinates:s.z.object({x:s.z.number(),y:s.z.number()}),alias:s.z.string().min(1).max(150).optional(),config:s.z.object({flow_id:s.z.string().max(30),next_node:s.z.string()})}),s.z.object({id:s.z.string(),type:s.z.literal("ROUTER"),coordinates:s.z.object({x:s.z.number(),y:s.z.number()}),alias:s.z.string().min(1).max(150),config:s.z.object({rules:s.z.array(s.z.object({id:s.z.string(),alias:s.z.string().min(1).max(150).optional(),condition:s.z.any(),next_node:s.z.string()})),fallback:s.z.array(s.z.string())})}),s.z.object({id:s.z.string(),type:s.z.literal("STEP"),coordinates:s.z.object({x:s.z.number(),y:s.z.number()}),alias:s.z.string().min(1).max(150).optional(),config:s.z.object({components:s.z.array(Vh),next_node:s.z.string()})})])).optional(),start:s.z.object({hidden_fields:s.z.array(s.z.object({key:s.z.string(),value:s.z.string()})).optional(),next_node:s.z.string().optional(),coordinates:s.z.object({x:s.z.number(),y:s.z.number()}).optional()}).optional(),ending:s.z.object({redirection:s.z.object({delay:s.z.number().optional(),target:s.z.string().optional()}).optional(),after_submit:s.z.object({flow_id:s.z.string().optional()}).optional(),coordinates:s.z.object({x:s.z.number(),y:s.z.number()}).optional(),resume_flow:s.z.boolean().optional()}).optional(),style:s.z.object({css:s.z.string().optional()}).optional()}).openapi({description:"Schema for flow-based forms (matches new JSON structure)"}),tr=s.z.object({..._s.shape,...So.shape,id:s.z.string()}),qh=s.z.enum(["pre-user-signup","post-user-registration","post-user-login"]),Hh=s.z.enum(["pre-user-signup","post-user-registration","post-user-login"]),bs={enabled:s.z.boolean().default(!1),synchronous:s.z.boolean().default(!1),priority:s.z.number().optional(),hook_id:s.z.string().optional()},t_=s.z.object({...bs,trigger_id:qh,url:s.z.string()}),n_=s.z.object({...bs,trigger_id:Hh,form_id:s.z.string()}),Qi=s.z.union([t_,n_]),r_=s.z.object({...bs,trigger_id:qh,..._s.shape,hook_id:s.z.string(),url:s.z.string()}),i_=s.z.object({...bs,trigger_id:Hh,..._s.shape,hook_id:s.z.string(),form_id:s.z.string()}),nr=s.z.union([r_,i_]),Dd=s.z.object({alg:s.z.enum(["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512"]),e:s.z.string(),kid:s.z.string(),kty:s.z.enum(["RSA","EC","oct"]),n:s.z.string(),x5t:s.z.string().optional(),x5c:s.z.array(s.z.string()).optional(),use:s.z.enum(["sig","enc"]).optional()}),Kh=s.z.object({keys:s.z.array(Dd)}),ec=s.z.object({issuer:s.z.string(),authorization_endpoint:s.z.string(),token_endpoint:s.z.string(),device_authorization_endpoint:s.z.string(),userinfo_endpoint:s.z.string(),mfa_challenge_endpoint:s.z.string(),jwks_uri:s.z.string(),registration_endpoint:s.z.string(),revocation_endpoint:s.z.string(),scopes_supported:s.z.array(s.z.string()),response_types_supported:s.z.array(s.z.string()),code_challenge_methods_supported:s.z.array(s.z.string()),response_modes_supported:s.z.array(s.z.string()),subject_types_supported:s.z.array(s.z.string()),id_token_signing_alg_values_supported:s.z.array(s.z.string()),token_endpoint_auth_methods_supported:s.z.array(s.z.string()),claims_supported:s.z.array(s.z.string()),request_uri_parameter_supported:s.z.boolean(),request_parameter_supported:s.z.boolean(),token_endpoint_auth_signing_alg_values_supported:s.z.array(s.z.string())}),Gh=s.z.object({csrf_token:s.z.string(),auth0Client:s.z.string().optional(),authParams:Yr,expires_at:s.z.string(),deleted_at:s.z.string().optional(),ip:s.z.string().optional(),useragent:s.z.string().optional(),session_id:s.z.string().optional(),authorization_url:s.z.string().optional(),login_completed:s.z.boolean().optional().default(!1)}).openapi({description:"This represents a login sesion"}),o_=s.z.object({...Gh.shape,id:s.z.string().openapi({description:"This is is used as the state in the universal login"}),created_at:s.z.string(),updated_at:s.z.string()});var he=(t=>(t.FAILED_SILENT_AUTH="fsa",t.FAILED_SIGNUP="fs",t.FAILED_LOGIN="f",t.FAILED_LOGIN_INCORRECT_PASSWORD="fp",t.FAILED_CHANGE_PASSWORD="fcp",t.FAILED_BY_CONNECTOR="fc",t.FAILED_LOGIN_INVALID_EMAIL_USERNAME="fu",t.FAILED_HOOK="fh",t.FAILED_CROSS_ORIGIN_AUTHENTICATION="fcoa",t.SUCCESS_API_OPERATION="sapi",t.SUCCESS_CHANGE_PASSWORD="scp",t.SUCCESS_CHANGE_PASSWORD_REQUEST="scpr",t.SUCCESS_CHANGE_USERNAME="scu",t.SUCCESS_CROSS_ORIGIN_AUTHENTICATION="scoa",t.SUCCESS_EXCHANGE_AUTHORIZATION_CODE_FOR_ACCESS_TOKEN="seacft",t.SUCCESS_EXCHANGE_REFRESH_TOKEN_FOR_ACCESS_TOKEN="serft",t.SUCCESS_LOGIN="s",t.SUCCESS_LOGOUT="slo",t.SUCCESS_SIGNUP="ss",t.SUCCESS_SILENT_AUTH="ssa",t.SUCCESS_VERIFICATION_EMAIL="sv",t.SUCCESS_VERIFICATION_EMAIL_REQUEST="svr",t.CODE_LINK_SENT="cls",t.BLOCKED_ACCOUNT_EMAIL="limit_wc",t.BLOCKED_ACCOUNT_IP="limit_sul",t.BLOCKED_IP_ADDRESS="limit_mu",t))(he||{});const s_=s.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"]),Wh=s.z.object({name:s.z.string(),version:s.z.string(),env:s.z.object({node:s.z.string().optional()}).optional()}),Ao=s.z.object({type:s_,date:s.z.string(),description:s.z.string().optional(),log_id:s.z.string().optional(),_id:s.z.string().optional(),ip:s.z.string(),user_agent:s.z.string(),details:s.z.any().optional(),isMobile:s.z.boolean(),user_id:s.z.string().optional(),user_name:s.z.string().optional(),connection:s.z.string().optional(),connection_id:s.z.string().optional(),client_id:s.z.string().optional(),client_name:s.z.string().optional(),audience:s.z.string().optional(),scope:s.z.array(s.z.string()).optional(),strategy:s.z.string().optional(),strategy_type:s.z.string().optional(),hostname:s.z.string().optional(),auth0_client:Wh.optional()}),Jh=s.z.object({user_id:s.z.string(),password:s.z.string(),algorithm:s.z.enum(["bcrypt","argon2id"]).default("argon2id")}),a_=s.z.object({...Jh.shape,created_at:s.z.string(),updated_at:s.z.string()}),Xh=s.z.object({initial_user_agent:s.z.string().describe("First user agent of the device from which this user logged in"),initial_ip:s.z.string().describe("First IP address associated with this session"),initial_asn:s.z.string().describe("First autonomous system number associated with this session"),last_user_agent:s.z.string().describe("Last user agent of the device from which this user logged in"),last_ip:s.z.string().describe("Last IP address from which this user logged in"),last_asn:s.z.string().describe("Last autonomous system number from which this user logged in")}),Zh=s.z.object({id:s.z.string(),revoked_at:s.z.string().optional(),used_at:s.z.string().optional(),user_id:s.z.string().describe("The user ID associated with the session"),expires_at:s.z.string().optional(),login_session_id:s.z.string(),idle_expires_at:s.z.string().optional(),device:Xh.describe("Metadata related to the device used in the session"),clients:s.z.array(s.z.string()).describe("List of client details for the session")}),$s=s.z.object({created_at:s.z.string(),updated_at:s.z.string(),authenticated_at:s.z.string(),last_interaction_at:s.z.string(),...Zh.shape}),tc=s.z.object({kid:s.z.string().openapi({description:"The key id of the signing key"}),cert:s.z.string().openapi({description:"The public certificate of the signing key"}),fingerprint:s.z.string().openapi({description:"The cert fingerprint"}),thumbprint:s.z.string().openapi({description:"The cert thumbprint"}),pkcs7:s.z.string().optional().openapi({description:"The private key in pkcs7 format"}),current:s.z.boolean().optional().openapi({description:"True if the key is the current key"}),next:s.z.boolean().optional().openapi({description:"True if the key is the next key"}),previous:s.z.boolean().optional().openapi({description:"True if the key is the previous key"}),current_since:s.z.string().optional().openapi({description:"The date and time when the key became the current key"}),current_until:s.z.string().optional().openapi({description:"The date and time when the current key was rotated"}),revoked:s.z.boolean().optional().openapi({description:"True if the key is revoked"}),revoked_at:s.z.string().optional().openapi({description:"The date and time when the key was revoked"})});var rr=(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))(rr||{});const Vd=s.z.object({access_token:s.z.string(),id_token:s.z.string().optional(),scope:s.z.string().optional(),state:s.z.string().optional(),refresh_token:s.z.string().optional(),token_type:s.z.string(),expires_in:s.z.number()});s.z.object({code:s.z.string(),state:s.z.string().optional()});const Yh=s.z.object({button_border_radius:s.z.number(),button_border_weight:s.z.number(),buttons_style:s.z.enum(["pill"]),input_border_radius:s.z.number(),input_border_weight:s.z.number(),inputs_style:s.z.enum(["pill"]),show_widget_shadow:s.z.boolean(),widget_border_weight:s.z.number(),widget_corner_radius:s.z.number()}),Qh=s.z.object({base_focus_color:s.z.string(),base_hover_color:s.z.string(),body_text:s.z.string(),captcha_widget_theme:s.z.enum(["auto"]),error:s.z.string(),header:s.z.string(),icons:s.z.string(),input_background:s.z.string(),input_border:s.z.string(),input_filled_text:s.z.string(),input_labels_placeholders:s.z.string(),links_focused_components:s.z.string(),primary_button:s.z.string(),primary_button_label:s.z.string(),secondary_button_border:s.z.string(),secondary_button_label:s.z.string(),success:s.z.string(),widget_background:s.z.string(),widget_border:s.z.string()}),wn=s.z.object({bold:s.z.boolean(),size:s.z.number()}),e0=s.z.object({body_text:wn,buttons_text:wn,font_url:s.z.string(),input_labels:wn,links:wn,links_style:s.z.enum(["normal"]),reference_text_size:s.z.number(),subtitle:wn,title:wn}),t0=s.z.object({background_color:s.z.string(),background_image_url:s.z.string(),page_layout:s.z.enum(["center"])}),n0=s.z.object({header_text_alignment:s.z.enum(["center"]),logo_height:s.z.number(),logo_position:s.z.enum(["center"]),logo_url:s.z.string(),social_buttons_layout:s.z.enum(["bottom"])}),r0=s.z.object({borders:Yh,colors:Qh,displayName:s.z.string(),fonts:e0,page_background:t0,widget:n0}),c_=r0.extend({themeId:s.z.string()}),eo=s.z.object({universal_login_experience:s.z.enum(["new","classic"]).default("new"),identifier_first:s.z.boolean().default(!0),password_first:s.z.boolean().default(!1),webauthn_platform_first_factor:s.z.boolean()}),to=s.z.object({name:s.z.string(),enabled:s.z.boolean().optional().default(!0),default_from_address:s.z.string().optional(),credentials:s.z.union([s.z.object({accessKeyId:s.z.string(),secretAccessKey:s.z.string(),region:s.z.string()}),s.z.object({smtp_host:s.z.array(s.z.string()),smtp_port:s.z.number(),smtp_user:s.z.string(),smtp_pass:s.z.string()}),s.z.object({api_key:s.z.string(),domain:s.z.string().optional()}),s.z.object({connectionString:s.z.string()}),s.z.object({tenantId:s.z.string(),clientId:s.z.string(),clientSecret:s.z.string()})]),settings:s.z.object({}).optional()}),qd=s.z.object({id:s.z.string(),session_id:s.z.string(),user_id:s.z.string(),client_id:s.z.string(),expires_at:s.z.string().optional(),idle_expires_at:s.z.string().optional(),last_exchanged_at:s.z.string().optional(),device:Xh,resource_servers:s.z.array(s.z.object({audience:s.z.string(),scopes:s.z.string()})),rotating:s.z.boolean()}),d_=s.z.object({created_at:s.z.string(),...qd.shape}),l_=s.z.object({to:s.z.string(),message:s.z.string()}),u_=s.z.object({name:s.z.string(),options:s.z.object({})});function p_(t){const[e,n]=t.split("|");if(!e||!n)throw new Error(`Invalid user_id: ${t}`);return{connection:e,id:n}}const f_=new s.OpenAPIHono().openapi(s.createRoute({tags:["branding"],method:"get",path:"/",request:{headers:s.z.object({"tenant-id":s.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(s.createRoute({tags:["branding"],method:"patch",path:"/",request:{headers:s.z.object({"tenant-id":s.z.string()}),body:{content:{"application/json":{schema:s.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 A=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})}},Eo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function i0(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function h_(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 g_(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 m_={},__=Object.freeze(Object.defineProperty({__proto__:null,default:m_},Symbol.toStringTag,{value:"Module"})),y_=h_(__);(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
@@ -151,7 +151,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
151
151
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function O3(t,e){if(t){if(typeof t=="string")return Tf(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 Tf(t,e)}}function Tf(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 Rf(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 Bf(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Rf(Object(n),!0).forEach(function(r){P3(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Rf(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function P3(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var Lf={formatExtension:function(e,n,r){return"".concat(e).concat(r.ext()).concat(n)}};function T3(t,e,n,r){if(n?n=Bf(Bf({},Lf),n):n=Lf,r=new Ge(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(),o=n.v2?t.nationalNumber:t.phone,a;switch(e){case"NATIONAL":return o?(a=fs(o,t.carrierCode,"NATIONAL",r,n),Da(a,t.ext,r,n.formatExtension)):"";case"INTERNATIONAL":return o?(a=fs(o,null,"INTERNATIONAL",r,n),a="+".concat(i," ").concat(a),Da(a,t.ext,r,n.formatExtension)):"+".concat(i);case"E.164":return"+".concat(i).concat(o);case"RFC3966":return C3({number:"+".concat(i).concat(o),ext:t.ext});case"IDD":if(!n.fromCountry)return;var c=B3(o,t.carrierCode,i,n.fromCountry,r);return Da(c,t.ext,r,n.formatExtension);default:throw new Error('Unknown "format" argument passed to "formatNumber()": "'.concat(e,'"'))}}function fs(t,e,n,r,i){var o=R3(r.formats(),t);return o?v3(t,o,{useInternationalFormat:n==="INTERNATIONAL",withNationalPrefix:!(o.nationalPrefixIsOptionalWhenFormattingInNationalFormat()&&i&&i.nationalPrefix===!1),carrierCode:e,metadata:r}):t}function R3(t,e){for(var n=j3(t),r;!(r=n()).done;){var i=r.value;if(i.leadingDigitsPatterns().length>0){var o=i.leadingDigitsPatterns()[i.leadingDigitsPatterns().length-1];if(e.search(o)!==0)continue}if(Jt(e,i.pattern()))return i}}function Da(t,e,n,r){return e?r(t,e,n):t}function B3(t,e,n,r,i){var o=Hl(r,i.metadata);if(o===n){var a=fs(t,e,"NATIONAL",i);return n==="1"?n+" "+a:a}var c=$3(r,void 0,i.metadata);if(c)return"".concat(c," ").concat(n," ").concat(fs(t,null,"INTERNATIONAL",i))}function Uf(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 Mf(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Uf(Object(n),!0).forEach(function(r){L3(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Uf(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function L3(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function U3(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function M3(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 F3(t,e,n){return e&&M3(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}var D3=function(){function t(e,n,r){if(U3(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(dr(n)&&dr(n.countries)){r=n;var i=e;if(!H3.test(i))throw new Error('Invalid `number` argument passed: must consist of a "+" followed by digits');var o=zm(i,void 0,void 0,r),a=o.countryCallingCode,c=o.number;if(n=c,e=a,!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");Sm(r);var d=q3(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 F3(t,[{key:"setExt",value:function(n){this.ext=n}},{key:"getPossibleCountries",value:function(){return this.country?[this.country]:n3(this.countryCallingCode,this.nationalNumber,this.getMetadata())}},{key:"isPossible",value:function(){return Zb(this,{v2:!0},this.getMetadata())}},{key:"isValid",value:function(){return t3(this,{v2:!0},this.getMetadata())}},{key:"isNonGeographic",value:function(){var n=new Ge(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 Gl(this,{v2:!0},this.getMetadata())}},{key:"format",value:function(n,r){return T3(this,n,r?Mf(Mf({},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}(),V3=function(e){return/^[A-Z]{2}$/.test(e)};function q3(t,e){var n,r,i=new Ge(e);return V3(t)?(n=t,i.selectNumberingPlan(n),r=i.countryCallingCode()):r=t,{country:n,countryCallingCode:r}}var H3=/^\+\d+$/;function Ed(t){"@babel/helpers - typeof";return Ed=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},Ed(t)}function K3(t,e,n){return Object.defineProperty(t,"prototype",{writable:!1}),t}function G3(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function W3(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&&hi(t,e)}function J3(t){var e=Cm();return function(){var r=gi(t),i;if(e){var o=gi(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return X3(this,i)}}function X3(t,e){if(e&&(Ed(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Nm(t)}function Nm(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function zd(t){var e=typeof Map=="function"?new Map:void 0;return zd=function(r){if(r===null||!Z3(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 lo(r,arguments,gi(this).constructor)}return i.prototype=Object.create(r.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),hi(i,r)},zd(t)}function lo(t,e,n){return Cm()?lo=Reflect.construct:lo=function(i,o,a){var c=[null];c.push.apply(c,o);var d=Function.bind.apply(i,c),l=new d;return a&&hi(l,a.prototype),l},lo.apply(null,arguments)}function Cm(){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 Z3(t){return Function.toString.call(t).indexOf("[native code]")!==-1}function hi(t,e){return hi=Object.setPrototypeOf||function(r,i){return r.__proto__=i,r},hi(t,e)}function gi(t){return gi=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},gi(t)}var Bt=function(t){W3(n,t);var e=J3(n);function n(r){var i;return G3(this,n),i=e.call(this,r),Object.setPrototypeOf(Nm(i),n.prototype),i.name=i.constructor.name,i}return K3(n)}(zd(Error)),Ff=new RegExp("(?:"+Im()+")$","i");function Y3(t){var e=t.search(Ff);if(e<0)return{};for(var n=t.slice(0,e),r=t.match(Ff),i=1;i<r.length;){if(r[i])return{number:n,ext:r[i]};i++}}var Q3={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 e4(t){return Q3[t]}function t4(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=n4(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
152
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function n4(t,e){if(t){if(typeof t=="string")return Df(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 Df(t,e)}}function Df(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 Vf(t){for(var e="",n=t4(t.split("")),r;!(r=n()).done;){var i=r.value;e+=r4(i,e)||""}return e}function r4(t,e,n){return t==="+"?e?void 0:"+":e4(t)}function i4(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=o4(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
153
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function o4(t,e){if(t){if(typeof t=="string")return qf(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 qf(t,e)}}function qf(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 s4(t,e){var n=e.countries,r=e.metadata;r=new Ge(r);for(var i=i4(n),o;!(o=i()).done;){var a=o.value;if(r.country(a),r.leadingDigits()){if(t&&t.search(r.leadingDigits())===0)return a}else if(Gl({phone:t,country:a},void 0,r.metadata))return a}}function a4(t,e){var n=e.nationalNumber,r=e.defaultCountry,i=e.metadata,o=i.getCountryCodesForCallingCode(t);if(o)return o.length===1?o[0]:s4(n,{countries:o,defaultCountry:r,metadata:i.metadata})}var jm="+",c4="[\\-\\.\\(\\)]?",Hf="(["+vt+"]|"+c4+")",d4="^\\"+jm+Hf+"*["+vt+"]"+Hf+"*$",l4=new RegExp(d4,"g"),Id=vt,u4="["+Id+"]+((\\-)*["+Id+"])*",p4="a-zA-Z",f4="["+p4+"]+((\\-)*["+Id+"])*",h4="^("+u4+"\\.)*"+f4+"\\.?$",g4=new RegExp(h4,"g"),Kf="tel:",Nd=";phone-context=",m4=";isub=";function _4(t){var e=t.indexOf(Nd);if(e<0)return null;var n=e+Nd.length;if(n>=t.length)return"";var r=t.indexOf(";",n);return r>=0?t.substring(n,r):t.substring(n)}function y4(t){return t===null?!0:t.length===0?!1:l4.test(t)||g4.test(t)}function w4(t,e){var n=e.extractFormattedPhoneNumber,r=_4(t);if(!y4(r))throw new Bt("NOT_A_NUMBER");var i;if(r===null)i=n(t)||"";else{i="",r.charAt(0)===jm&&(i+=r);var o=t.indexOf(Kf),a;o>=0?a=o+Kf.length:a=0;var c=t.indexOf(Nd);i+=t.substring(a,c)}var d=i.indexOf(m4);if(d>0&&(i=i.substring(0,d)),i!=="")return i}var v4=250,b4=new RegExp("["+Jl+vt+"]"),$4=new RegExp("[^"+vt+"#]+$");function x4(t,e,n){if(e=e||{},n=new Ge(n),e.defaultCountry&&!n.hasCountry(e.defaultCountry))throw e.v2?new Bt("INVALID_COUNTRY"):new Error("Unknown country: ".concat(e.defaultCountry));var r=S4(t,e.v2,e.extract),i=r.number,o=r.ext,a=r.error;if(!i){if(e.v2)throw a==="TOO_SHORT"?new Bt("TOO_SHORT"):new Bt("NOT_A_NUMBER");return{}}var c=E4(i,e.defaultCountry,e.defaultCallingCode,n),d=c.country,l=c.nationalNumber,u=c.countryCallingCode,f=c.countryCallingCodeSource,m=c.carrierCode;if(!n.hasSelectedNumberingPlan()){if(e.v2)throw new Bt("INVALID_COUNTRY");return{}}if(!l||l.length<Wl){if(e.v2)throw new Bt("TOO_SHORT");return{}}if(l.length>i3){if(e.v2)throw new Bt("TOO_LONG");return{}}if(e.v2){var w=new D3(u,l,n.metadata);return d&&(w.country=d),m&&(w.carrierCode=m),o&&(w.ext=o),w.__countryCallingCodeSource=f,w}var h=(e.extended?n.hasSelectedNumberingPlan():d)?Jt(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:o}:h?A4(d,l,o):{}}function k4(t,e,n){if(t){if(t.length>v4){if(n)throw new Bt("TOO_LONG");return}if(e===!1)return t;var r=t.search(b4);if(!(r<0))return t.slice(r).replace($4,"")}}function S4(t,e,n){var r=w4(t,{extractFormattedPhoneNumber:function(a){return k4(a,n,e)}});if(!r)return{};if(!I3(r))return N3(r)?{error:"TOO_SHORT"}:{};var i=Y3(r);return i.ext?i:{number:r}}function A4(t,e,n){var r={country:t,phone:e};return n&&(r.ext=n),r}function E4(t,e,n,r){var i=zm(Vf(t),e,n,r.metadata),o=i.countryCallingCodeSource,a=i.countryCallingCode,c=i.number,d;if(a)r.selectNumberingPlan(a);else if(c&&(e||n))r.selectNumberingPlan(e,n),e&&(d=e),a=n||Hl(e,r.metadata);else return{};if(!c)return{countryCallingCodeSource:o,countryCallingCode:a};var l=Ad(Vf(c),r),u=l.nationalNumber,f=l.carrierCode,m=a4(a,{nationalNumber:u,defaultCountry:e,metadata:r});return m&&(d=m,m==="001"||r.country(d)),{country:d,countryCallingCode:a,countryCallingCodeSource:o,nationalNumber:u,carrierCode:f}}function Gf(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 Wf(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Gf(Object(n),!0).forEach(function(r){z4(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Gf(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function z4(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){return x4(t,Wf(Wf({},e),{},{v2:!0}),n)}function Jf(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 N4(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Jf(Object(n),!0).forEach(function(r){C4(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Jf(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function C4(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function j4(t,e){return R4(t)||T4(t,e)||P4(t,e)||O4()}function O4(){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 P4(t,e){if(t){if(typeof t=="string")return Xf(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 Xf(t,e)}}function Xf(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 T4(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var r=[],i=!0,o=!1,a,c;try{for(n=n.call(t);!(i=(a=n.next()).done)&&(r.push(a.value),!(e&&r.length===e));i=!0);}catch(d){o=!0,c=d}finally{try{!i&&n.return!=null&&n.return()}finally{if(o)throw c}}return r}}function R4(t){if(Array.isArray(t))return t}function B4(t){var e=Array.prototype.slice.call(t),n=j4(e,4),r=n[0],i=n[1],o=n[2],a=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")a?(d=o,l=a):(d=void 0,l=o),i&&(d=N4({defaultCountry:i},d));else if(dr(i))o?(d=i,l=o):l=i;else throw new Error("Invalid second argument: ".concat(i));return{text:c,options:d,metadata:l}}function Zf(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 Yf(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Zf(Object(n),!0).forEach(function(r){L4(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Zf(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function L4(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function U4(t,e,n){e&&e.defaultCountry&&!Jb(e.defaultCountry,n)&&(e=Yf(Yf({},e),{},{defaultCountry:void 0}));try{return I4(t,e,n)}catch(r){if(!(r instanceof Bt))throw r}}function M4(){var t=B4(arguments),e=t.text,n=t.options,r=t.metadata;return U4(e,n,r)}function F4(){return Ub(M4,arguments)}function mi(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=F4(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 D4=s.z.object({client_id:s.z.string(),username:s.z.string().transform(t=>t.toLowerCase()),otp:s.z.string(),authParams:Yr.optional()});async function $a(t,{client_id:e,username:n,otp:r,authParams:i}){const o=jt(t.req),{connection:a,normalized:c}=mi(n,o.countryCode);if(!c)throw new A(400,{message:"Invalid username format"});const d=await t.env.data.clients.get(e);if(!d)throw new A(403,{message:"Client not found"});const{env:l}=t,u=await l.data.codes.get(d.tenant.id,r,"otp");if(!u)throw new A(400,{message:"Code not found or expired"});if(u.expires_at<new Date().toISOString())throw new A(400,{message:"Code expired"});if(u.used_at)throw new A(400,{message:"Code already used"});const f=await l.data.loginSessions.get(d.tenant.id,u.login_id);if(!f||f.authParams.username!==n)throw new A(400,{message:"Code not found or expired"});if(f.ip&&o.ip&&f.ip!==o.ip)return t.redirect(`${dt(t.env)}invalid-session?state=${f.id}`);const m=await Is(t,{client:d,username:c,provider:a,connection:a,isSocial:!1,ip:t.req.header("x-real-ip")});return await l.data.codes.used(d.tenant.id,r),Zt(t,{user:m,client:d,loginSession:f,authParams:i||{client_id:e,response_type:it.TOKEN_ID_TOKEN,response_mode:Dt.WEB_MESSAGE}})}const Qf=s.z.object({client_id:s.z.string().optional(),client_secret:s.z.string().optional()}),V4=s.z.union([km.extend(Qf.shape),s.z.object({grant_type:s.z.literal("authorization_code"),client_id:s.z.string(),code:s.z.string(),redirect_uri:s.z.string(),code_verifier:s.z.string().min(43).max(128)}),s.z.object({grant_type:s.z.literal("authorization_code"),code:s.z.string(),redirect_uri:s.z.string().optional(),...Qf.shape}),s.z.object({grant_type:s.z.literal("refresh_token"),client_id:s.z.string(),refresh_token:s.z.string(),redirect_uri:s.z.string().optional()}),s.z.object({grant_type:s.z.literal("http://auth0.com/oauth/grant-type/passwordless/otp"),client_id:s.z.string(),username:s.z.string(),otp:s.z.string(),realm:s.z.enum(["email","sms"])})]);function q4(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 H4=new s.OpenAPIHono().openapi(s.createRoute({tags:["oauth2"],method:"post",path:"/",request:{body:{content:{"application/x-www-form-urlencoded":{schema:V4}}}},responses:{200:{content:{"application/json":{schema:Vd}},description:"Tokens"},302:{description:"Redirect for further user interaction (e.g., MFA, consent).",headers:s.z.object({Location:s.z.string().url()}).openapi({})},400:{description:"Bad Request - The request was malformed or invalid.",content:{"application/json":{schema:s.z.object({error:s.z.string(),error_description:s.z.string().optional()})}}},401:{description:"Unauthorized - Client authentication failed.",content:{"application/json":{schema:s.z.object({error:s.z.string(),error_description:s.z.string().optional()})}}}}}),async t=>{const e=t.req.valid("form"),n=q4(t.req.header("Authorization")),r={...e,...n};if(!r.client_id)throw new A(400,{message:"client_id is required"});t.set("client_id",r.client_id);let i;switch(e.grant_type){case rr.AuthorizationCode:i=await Tb(t,Pb.parse(r));break;case rr.ClientCredential:i=await Ob(t,km.parse(r));break;case rr.RefreshToken:i=await Bb(t,Rb.parse(r));break;case rr.OTP:i=await $a(t,D4.parse(r));break;default:return t.json({error:"unsupported_grant_type",error_description:"Grant type not implemented"},400)}if(i instanceof Response){const o=i.status,a=i.headers.get("Location");if(o===302&&a)return t.redirect(a,302);try{const c=await i.json();return t.json(c,o)}catch(c){return console.error("Failed to process raw Response from grant flow:",c),t.json({error:"server_error",error_description:"Invalid response format from authentication flow."},500)}}else return t.json(i)});var Xl={exports:{}};const Zl=[{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}],Om=(t,e=Zl,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 o={};o.contains=i.filter(c=>new RegExp(`${c.regex}`).test(r)).map(c=>c.message),o.length=r.length;let a=e.filter(c=>o.contains.length>=c.minDiversity).filter(c=>o.length>=c.minLength).sort((c,d)=>d.id-c.id).map(c=>({id:c.id,value:c.value}));return Object.assign(o,a[0]),o};Xl.exports={passwordStrength:Om,defaultOptions:Zl};var K4=Xl.exports.passwordStrength=Om;Xl.exports.defaultOptions=Zl;function Yl(t){return K4(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 Mi(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 A(500,{message:"Email provider not found"});const r=(i=t.env.emailProviders)==null?void 0:i[n.name];if(!r)throw new A(500,{message:"Email provider not found"});await r({emailProvider:n,...e,from:n.default_from_address||`login@${t.env.ISSUER}`})}async function Pm(t,e){var a,c;if(!t.var.client_id)throw new A(500,{message:"Client not found"});const n=await Ui(t.env,t.var.client_id),r=n.connections.find(d=>d.strategy==="sms");if(!r)throw new A(500,{message:"SMS provider not found"});const i=((a=r.options)==null?void 0:a.provider)||"twilio",o=(c=t.env.smsProviders)==null?void 0:c[i];if(!o)throw new A(500,{message:"SMS provider not found"});await o({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 Tm(t,e,n,r){const i=await t.env.data.tenants.get(t.var.tenant_id);if(!i)throw new A(500,{message:"Tenant not found"});const o=`${dt(t.env)}reset-password?state=${r}&code=${n}`,a={vendorName:i.name,lng:i.language||"en"};await Mi(t,{to:e,subject:re("reset_password_title",a),html:`Click here to reset your password: ${dt(t.env)}reset-password?state=${r}&code=${n}`,template:"auth-password-reset",data:{vendorName:i.name,logo:i.logo||"",passwordResetUrl:o,supportUrl:i.support_url||"https://support.sesamy.com",buttonColor:i.primary_color||"#7d68f4",passwordResetTitle:re("password_reset_title",a),resetPasswordEmailClickToReset:re("reset_password_email_click_to_reset",a),resetPasswordEmailReset:re("reset_password_email_reset",a),supportInfo:re("support_info",a),contactUs:re("contact_us",a),copyright:re("copyright",a),tenantName:i.name,tenantId:i.id}})}async function Rm(t,{to:e,code:n}){const r=await t.env.data.tenants.get(t.var.tenant_id);if(!r)throw new A(500,{message:"Tenant not found"});const{connection:i}=mi(e),o=new URL(dt(t.env)),a={vendorName:r.name,vendorId:r.id,loginDomain:o.hostname,code:n,lng:r.language||"en"};i==="email"?await Mi(t,{to:e,subject:re("code_email_subject",a),html:`Click here to validate your email: ${dt(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",a),linkEmailClickToLogin:re("link_email_click_to_login",a),linkEmailLogin:re("link_email_login",a),linkEmailOrEnterCode:re("link_email_or_enter_code",a),codeValid30Mins:re("code_valid_30_minutes",a),supportInfo:re("support_info",a),contactUs:re("contact_us",a),copyright:re("copyright",a)}}):i==="sms"&&await Pm(t,{to:e,text:re("sms_code_text",a),code:n,from:r.name});const c=we(t,{type:he.CODE_LINK_SENT,description:e});It(t,t.env.data.logs.create(r.id,c))}async function Ql(t,{to:e,code:n,authParams:r}){const i=await t.env.data.tenants.get(t.var.tenant_id);if(!i)throw new A(500,{message:"Tenant not found"});if(!r.redirect_uri)throw new A(400,{message:"redirect_uri is required"});const{connection:o}=mi(e),a=new URL(Pe(t.env));a.pathname="passwordless/verify_redirect",a.searchParams.set("verification_code",n),a.searchParams.set("connection",o),a.searchParams.set("client_id",r.client_id),a.searchParams.set("redirect_uri",r.redirect_uri),a.searchParams.set("email",e),r.response_type&&a.searchParams.set("response_type",r.response_type),r.scope&&a.searchParams.set("scope",r.scope),r.state&&a.searchParams.set("state",r.state),r.nonce&&a.searchParams.set("nonce",r.nonce),r.code_challenge&&a.searchParams.set("code_challenge",r.code_challenge),r.code_challenge_method&&a.searchParams.set("code_challenge_method",r.code_challenge_method),r.audience&&a.searchParams.set("audience",r.audience);const c={vendorName:i.name,code:n,lng:i.language||"en"};if(o==="email")await Mi(t,{to:e,subject:re("code_email_subject",c),html:`Click here to validate your email: ${dt(t.env)}validate-email`,template:"auth-link",data:{code:n,vendorName:i.name,logo:i.logo||"",supportUrl:i.support_url||"",magicLink:a.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(o==="sms")await Pm(t,{to:e,text:`${re("link_sms_login",c)}: ${a.toString()}`,code:n,from:i.name});else throw new A(400,{message:"Only email and SMS connections are supported for magic links"});const d=we(t,{type:he.CODE_LINK_SENT,description:e});It(t,t.env.data.logs.create(i.id,d))}async function eu(t,e){const n=await t.env.data.tenants.get(t.var.tenant_id);if(!n)throw new A(500,{message:"Tenant not found"});if(!e.email)throw new A(400,{message:"User has no email"});const r={vendorName:n.name,lng:n.language||"en"};await Mi(t,{to:e.email,subject:re("welcome_to_your_account",r),html:`Click here to validate your email: ${dt(t.env)}validate-email`,template:"auth-verify-email",data:{vendorName:n.name,logo:n.logo||"",emailValidationUrl:`${dt(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 G4(t,e,n,r){const i=await t.env.data.tenants.get(t.var.tenant_id);if(!i)throw new A(500,{message:"Tenant not found"});const o={vendorName:i.name,lng:i.language||"en"},a=`${dt(t.env)}signup?state=${r}&code=${n}`;await Mi(t,{to:e,subject:re("register_password_account",o),html:`Click here to register: ${a}`,template:"auth-pre-signup-verification",data:{vendorName:i.name,logo:i.logo||"",signupUrl:a,setPassword:re("set_password",o),registerPasswordAccount:re("register_password_account",o),clickToSignUpDescription:re("click_to_sign_up_description",o),supportUrl:i.support_url||"https://support.sesamy.com",buttonColor:i.primary_color||"#7d68f4",welcomeToYourAccount:re("welcome_to_your_account",o),verifyEmailVerify:re("verify_email_verify",o),supportInfo:re("support_info",o),contactUs:re("contact_us",o),copyright:re("copyright",o)}})}const W4=new s.OpenAPIHono().openapi(s.createRoute({tags:["dbconnections"],method:"post",path:"/signup",request:{body:{content:{"application/json":{schema:s.z.object({client_id:s.z.string(),connection:s.z.literal("Username-Password-Authentication"),email:s.z.string().transform(t=>t.toLowerCase()),password:s.z.string()})}}}},responses:{200:{content:{"application/json":{schema:s.z.object({_id:s.z.string(),email:s.z.string().optional(),email_verified:s.z.boolean(),app_metadata:s.z.object({}),user_metadata:s.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 A(400,{message:"Client not found"});if(t.set("client_id",i.id),t.set("tenant_id",i.tenant.id),!Yl(n))throw new A(400,{message:"Password does not meet the requirements"});if(await Io({userAdapter:t.env.data.users,tenant_id:i.tenant.id,username:e,provider:"auth2"}))throw new A(400,{message:"Invalid sign up"});const a=await t.env.data.users.create(i.tenant.id,{user_id:`auth2|${xs()}`,email:e,email_verified:!1,provider:"auth2",connection:"Username-Password-Authentication",is_social:!1});t.set("user_id",a.user_id),t.set("username",a.email),t.set("connection",a.connection);const c=await vi.hash(n,10);await t.env.data.passwords.create(i.tenant.id,{user_id:a.user_id,password:c,algorithm:"bcrypt"}),await eu(t,a);const d=we(t,{type:he.SUCCESS_SIGNUP,description:"Successful signup"});return await t.env.data.logs.create(i.tenant.id,d),t.json({_id:a.user_id,email:a.email,email_verified:!1,app_metadata:{},user_metadata:{}})}).openapi(s.createRoute({tags:["dbconnections"],method:"post",path:"/change_password",request:{body:{content:{"application/json":{schema:s.z.object({client_id:s.z.string(),connection:s.z.literal("Username-Password-Authentication"),email:s.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 A(400,{message:"Client not found"});if(t.set("client_id",r.id),t.set("tenant_id",r.tenant.id),!await kr({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 o={client_id:n,username:e},a=await t.env.data.loginSessions.create(r.tenant.id,{expires_at:new Date(Date.now()+Qr*1e3).toISOString(),authParams:o,csrf_token:xe(),...jt(t.req)});return await Tm(t,e,a.id,a.authParams.state),t.html("If an account with that email exists, we've sent instructions to reset your password.")});function Dn(){const t="1234567890";let e="";for(let n=0;n<6;n+=1)e+=t[Math.floor(Math.random()*10)];return e.toString()}const J4=new s.OpenAPIHono().openapi(s.createRoute({tags:["passwordless"],method:"post",path:"/start",request:{body:{content:{"application/json":{schema:s.z.union([s.z.object({connection:s.z.literal("email"),client_id:s.z.string(),email:s.z.string().transform(t=>t.toLowerCase()),send:s.z.enum(["link","code"]),authParams:Yr.omit({client_id:!0})}),s.z.object({client_id:s.z.string(),connection:s.z.literal("sms"),phone_number:s.z.string(),send:s.z.enum(["link","code"]),authParams:Yr.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:o,connection:a}=e,c=await t.env.data.clients.get(r);if(!c)throw new A(400,{message:"Client not found"});t.set("client_id",c.id),t.set("tenant_id",c.tenant.id);const d=a==="email"?e.email:e.phone_number,{ip:l,useragent:u,auth0Client:f}=jt(t.req),m=await n.data.loginSessions.create(c.tenant.id,{authParams:{...o,client_id:r,username:d},expires_at:new Date(Date.now()+no).toISOString(),csrf_token:xe(),ip:l,useragent:u,auth0Client:f}),w=await n.data.codes.create(c.tenant.id,{code_id:Dn(),code_type:"otp",login_id:m.id,expires_at:new Date(Date.now()+no).toISOString(),redirect_uri:o.redirect_uri});return i==="link"?await Ql(t,{to:d,code:w.code_id,authParams:{...o,client_id:r}}):await Rm(t,{to:d,code:w.code_id}),t.html("OK")}).openapi(s.createRoute({tags:["passwordless"],method:"get",path:"/verify_redirect",request:{query:s.z.object({scope:s.z.string(),response_type:s.z.nativeEnum(it),redirect_uri:s.z.string(),state:s.z.string(),nonce:s.z.string().optional(),verification_code:s.z.string(),connection:s.z.string(),client_id:s.z.string(),email:s.z.string().transform(t=>t.toLowerCase()),audience:s.z.string().optional()})},responses:{302:{description:"Successful verification, redirecting to continue flow.",headers:s.z.object({Location:s.z.string().url()}).openapi({})},400:{description:"Bad Request (e.g., invalid client, invalid code, missing parameters).",content:{"application/json":{schema:s.z.object({error:s.z.string(),error_description:s.z.string().optional()})}}},500:{description:"Internal Server Error.",content:{"application/json":{schema:s.z.object({error:s.z.string(),error_description:s.z.string().optional()})}}}}}),async t=>{const{env:e}=t,{client_id:n,email:r,verification_code:i,redirect_uri:o,state:a,scope:c,audience:d,response_type:l,nonce:u}=t.req.valid("query"),f=await Ui(e,n);t.set("client_id",f.id),t.set("tenant_id",f.tenant.id),t.set("connection","email");const m={client_id:n,redirect_uri:o,state:a,nonce:u,scope:c,audience:d,response_type:l};let w="Something went wrong. Please try again later.";try{const E=await $a(t,{client_id:n,username:r,otp:i,authParams:m});if(E instanceof Response)return E;if(E&&typeof E=="object"&&"access_token"in E)return t.json(E)}catch(E){const C=E;"message"in C&&typeof C.message=="string"&&(w=C.message)}const{ip:h,useragent:y,auth0Client:v}=jt(t.req),b=await e.data.loginSessions.create(f.tenant.id,{authParams:{...m,username:r},expires_at:new Date(Date.now()+no).toISOString(),csrf_token:xe(),ip:h,useragent:y,auth0Client:v});return t.redirect(`/u/invalid-session?state=${b.id}&error=${encodeURIComponent(w)}`,302)});class Qn extends A{constructor(n,r){super(n,r);te(this,"_code");this._code=r==null?void 0:r.code}get code(){return this._code}}async function tu(t,e,n,r,i){const{env:o}=t,{username:a}=n;if(t.set("username",a),!a)throw new A(400,{message:"Username is required"});const c=await kr({userAdapter:t.env.data.users,tenant_id:e.tenant.id,username:a,provider:"auth2"});if(!c){const h=we(t,{type:he.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid user"});throw It(t,t.env.data.logs.create(e.tenant.id,h)),new Qn(403,{message:"User not found",code:"USER_NOT_FOUND"})}const d=c.linked_to?await o.data.users.get(e.tenant.id,c.linked_to):c;if(!d)throw new Qn(403,{message:"User not found",code:"USER_NOT_FOUND"});t.set("connection",c.connection),t.set("user_id",d.user_id);const l=await o.data.passwords.get(e.tenant.id,c.user_id);if(!(l&&await vi.compare(n.password,l.password))){const h=we(t,{type:he.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid password"});throw It(t,t.env.data.logs.create(e.tenant.id,h)),new Qn(403,{message:"Invalid password",code:"INVALID_PASSWORD"})}if((await o.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===he.FAILED_LOGIN_INCORRECT_PASSWORD&&new Date(h.date)>new Date(Date.now()-1e3*60*5)).length>=3){const h=we(t,{type:he.FAILED_LOGIN,description:"Too many failed login attempts"});throw It(t,t.env.data.logs.create(e.tenant.id,h)),new Qn(403,{message:"Too many failed login attempts",code:"TOO_MANY_FAILED_LOGINS"})}if(!c.email_verified&&e.email_validation==="enforced"){await eu(t,c);const h=we(t,{type:he.FAILED_LOGIN,description:"Email not verified"});throw await t.env.data.logs.create(e.tenant.id,h),new Qn(403,{message:"Email not verified",code:"EMAIL_NOT_VERIFIED"})}const w=we(t,{type:he.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)),Zt(t,{client:e,authParams:n,user:d,ticketAuth:i,loginSession:r})}async function X4(t,e,n,r){await Is(t,{client:e,username:n,provider:"auth2",connection:"Username-Password-Authentication",isSocial:!1,ip:t.req.header("x-real-ip")});let i=Dn(),o=await t.env.data.codes.get(e.tenant.id,i,"password_reset");for(;o;)i=Dn(),o=await t.env.data.codes.get(e.tenant.id,i,"password_reset");const{ip:a,useragent:c,auth0Client:d}=jt(t.req),l=await t.env.data.loginSessions.create(e.tenant.id,{expires_at:new Date(Date.now()+F_).toISOString(),authParams:{client_id:e.id,username:n},csrf_token:xe(),ip:a,useragent:c,auth0Client:d}),u=await t.env.data.codes.create(e.tenant.id,{code_id:i,code_type:"password_reset",login_id:l.id,expires_at:new Date(Date.now()+M_).toISOString()});await Tm(t,n,u.code_id,r)}const Z4=new s.OpenAPIHono().openapi(s.createRoute({tags:["oauth"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:s.z.union([s.z.object({credential_type:s.z.literal("http://auth0.com/oauth/grant-type/passwordless/otp"),otp:s.z.string(),client_id:s.z.string(),username:s.z.string().transform(t=>t.toLowerCase()),realm:s.z.enum(["email"]),scope:s.z.string().optional()}),s.z.object({credential_type:s.z.literal("http://auth0.com/oauth/grant-type/password-realm"),client_id:s.z.string(),username:s.z.string().transform(t=>t.toLowerCase()),password:s.z.string(),realm:s.z.enum(["Username-Password-Authentication"]),scope:s.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 A(400,{message:"Client not found"});t.set("client_id",n),t.set("tenant_id",i.tenant.id);const o=r.toLocaleLowerCase(),a=jt(t.req);let c;if("otp"in e)c=await $a(t,{client_id:n,username:o,otp:e.otp});else if("password"in e){const d=await t.env.data.loginSessions.create(i.tenant.id,{expires_at:new Date(Date.now()+Qr*1e3).toISOString(),authParams:{client_id:n,username:o},csrf_token:xe(),ip:a.ip,useragent:a.useragent,auth0Client:a.auth0Client});c=await tu(t,i,{username:o,password:e.password,client_id:n},d,!0)}else throw new A(400,{message:"Code or password required"});if(!(c instanceof Response))throw new A(500,{message:"Unexpected response from loginWithPassword"});return c});function Y4(t,e){var r,i,o;if(!t||e.length===0)return!1;const n=((r=Va(t))==null?void 0:r.host)??null;if(!n)return!1;for(const a of e){let c;if(a.startsWith("http://")||a.startsWith("https://")?c=((i=Va(a))==null?void 0:i.host)??null:c=((o=Va("https://"+a))==null?void 0:o.host)??null,n===c)return!0}return!1}function Va(t){try{return new URL(t)}catch{return null}}async function Q4({ctx:t,session:e,client:n,authParams:r,connection:i,login_hint:o}){const a=new URL(t.req.url);t.var.custom_domain&&(a.hostname=t.var.custom_domain);const{ip:c,useragent:d,auth0Client:l}=jt(t.req),u=await t.env.data.loginSessions.create(n.tenant.id,{expires_at:new Date(Date.now()+Qr*1e3).toISOString(),authParams:r,csrf_token:xe(),authorization_url:a.toString(),ip:c,useragent:d,auth0Client:l});if(e&&o){const f=await t.env.data.users.get(n.tenant.id,e.user_id);if((f==null?void 0:f.email)===o)return Zt(t,{client:n,loginSession:u,authParams:r,user:f,sessionId:e.id})}if(i==="email"&&o){const f=Dn();return await t.env.data.codes.create(n.tenant.id,{code_id:f,code_type:"otp",login_id:u.id,expires_at:new Date(Date.now()+Qr*1e3).toISOString(),redirect_uri:r.redirect_uri}),await Ql(t,{code:f,to:o,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 e$(t){if(t==="Username-Password-Authentication")return"auth2";if(t==="email")return"email";throw new A(403,{message:"Invalid realm"})}async function t$(t,e,n,r,i){var m;const{env:o}=t;t.set("connection",i);const a=await o.data.codes.get(e,n,"ticket");if(!a||a.used_at)throw new A(403,{message:"Ticket not found"});const c=await o.data.loginSessions.get(e,a.login_id);if(!c||!c.authParams.username)throw new A(403,{message:"Session not found"});const d=await o.data.clients.get(c.authParams.client_id);if(!d)throw new A(403,{message:"Client not found"});t.set("client_id",c.authParams.client_id),await o.data.codes.used(e,n);const l=e$(i);let u=await Is(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 f=await w0(t,{user:u,client:d,loginSession:c});return Zt(t,{authParams:{scope:(m=c.authParams)==null?void 0:m.scope,...r},loginSession:c,sessionId:f.id,user:u,client:d})}async function eh(t,e){return`<!DOCTYPE html>
154
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function P4(t,e){if(t){if(typeof t=="string")return Xf(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 Xf(t,e)}}function Xf(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 T4(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var r=[],i=!0,o=!1,a,c;try{for(n=n.call(t);!(i=(a=n.next()).done)&&(r.push(a.value),!(e&&r.length===e));i=!0);}catch(d){o=!0,c=d}finally{try{!i&&n.return!=null&&n.return()}finally{if(o)throw c}}return r}}function R4(t){if(Array.isArray(t))return t}function B4(t){var e=Array.prototype.slice.call(t),n=j4(e,4),r=n[0],i=n[1],o=n[2],a=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")a?(d=o,l=a):(d=void 0,l=o),i&&(d=N4({defaultCountry:i},d));else if(dr(i))o?(d=i,l=o):l=i;else throw new Error("Invalid second argument: ".concat(i));return{text:c,options:d,metadata:l}}function Zf(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 Yf(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Zf(Object(n),!0).forEach(function(r){L4(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Zf(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function L4(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function U4(t,e,n){e&&e.defaultCountry&&!Jb(e.defaultCountry,n)&&(e=Yf(Yf({},e),{},{defaultCountry:void 0}));try{return I4(t,e,n)}catch(r){if(!(r instanceof Bt))throw r}}function M4(){var t=B4(arguments),e=t.text,n=t.options,r=t.metadata;return U4(e,n,r)}function F4(){return Ub(M4,arguments)}function mi(t,e="US"){const n=t.trim();if(n.includes("@")){const r=n.toLowerCase(),i=/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r);return{connectionType:"email",normalized:i?r:null,isValid:i}}else if(/^\+?\d[\d\s\-().]*$/.test(n)){const r=F4(n,{defaultCountry:e});return r&&r.isValid()?{connectionType:"sms",normalized:r.number,isValid:!0}:{connectionType:"sms",normalized:null,isValid:!1}}else return{connectionType:"username",normalized:n,isValid:!0}}const D4=s.z.object({client_id:s.z.string(),username:s.z.string().transform(t=>t.toLowerCase()),otp:s.z.string(),authParams:Yr.optional()});async function $a(t,{client_id:e,username:n,otp:r,authParams:i}){const o=jt(t.req),{connectionType:a,normalized:c}=mi(n,o.countryCode);if(!c)throw new A(400,{message:"Invalid username format"});const d=await t.env.data.clients.get(e);if(!d)throw new A(403,{message:"Client not found"});const{env:l}=t,u=await l.data.codes.get(d.tenant.id,r,"otp");if(!u)throw new A(400,{message:"Code not found or expired"});if(u.expires_at<new Date().toISOString())throw new A(400,{message:"Code expired"});if(u.used_at)throw new A(400,{message:"Code already used"});const f=await l.data.loginSessions.get(d.tenant.id,u.login_id);if(!f||f.authParams.username!==n)throw new A(400,{message:"Code not found or expired"});if(f.ip&&o.ip&&f.ip!==o.ip)return t.redirect(`${dt(t.env)}invalid-session?state=${f.id}`);const m=await Is(t,{client:d,username:c,provider:a,connection:a,isSocial:!1,ip:t.req.header("x-real-ip")});return await l.data.codes.used(d.tenant.id,r),Zt(t,{user:m,client:d,loginSession:f,authParams:i||{client_id:e,response_type:it.TOKEN_ID_TOKEN,response_mode:Dt.WEB_MESSAGE}})}const Qf=s.z.object({client_id:s.z.string().optional(),client_secret:s.z.string().optional()}),V4=s.z.union([km.extend(Qf.shape),s.z.object({grant_type:s.z.literal("authorization_code"),client_id:s.z.string(),code:s.z.string(),redirect_uri:s.z.string(),code_verifier:s.z.string().min(43).max(128)}),s.z.object({grant_type:s.z.literal("authorization_code"),code:s.z.string(),redirect_uri:s.z.string().optional(),...Qf.shape}),s.z.object({grant_type:s.z.literal("refresh_token"),client_id:s.z.string(),refresh_token:s.z.string(),redirect_uri:s.z.string().optional()}),s.z.object({grant_type:s.z.literal("http://auth0.com/oauth/grant-type/passwordless/otp"),client_id:s.z.string(),username:s.z.string(),otp:s.z.string(),realm:s.z.enum(["email","sms"])})]);function q4(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 H4=new s.OpenAPIHono().openapi(s.createRoute({tags:["oauth2"],method:"post",path:"/",request:{body:{content:{"application/x-www-form-urlencoded":{schema:V4}}}},responses:{200:{content:{"application/json":{schema:Vd}},description:"Tokens"},302:{description:"Redirect for further user interaction (e.g., MFA, consent).",headers:s.z.object({Location:s.z.string().url()}).openapi({})},400:{description:"Bad Request - The request was malformed or invalid.",content:{"application/json":{schema:s.z.object({error:s.z.string(),error_description:s.z.string().optional()})}}},401:{description:"Unauthorized - Client authentication failed.",content:{"application/json":{schema:s.z.object({error:s.z.string(),error_description:s.z.string().optional()})}}}}}),async t=>{const e=t.req.valid("form"),n=q4(t.req.header("Authorization")),r={...e,...n};if(!r.client_id)throw new A(400,{message:"client_id is required"});t.set("client_id",r.client_id);let i;switch(e.grant_type){case rr.AuthorizationCode:i=await Tb(t,Pb.parse(r));break;case rr.ClientCredential:i=await Ob(t,km.parse(r));break;case rr.RefreshToken:i=await Bb(t,Rb.parse(r));break;case rr.OTP:i=await $a(t,D4.parse(r));break;default:return t.json({error:"unsupported_grant_type",error_description:"Grant type not implemented"},400)}if(i instanceof Response){const o=i.status,a=i.headers.get("Location");if(o===302&&a)return t.redirect(a,302);try{const c=await i.json();return t.json(c,o)}catch(c){return console.error("Failed to process raw Response from grant flow:",c),t.json({error:"server_error",error_description:"Invalid response format from authentication flow."},500)}}else return t.json(i)});var Xl={exports:{}};const Zl=[{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}],Om=(t,e=Zl,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 o={};o.contains=i.filter(c=>new RegExp(`${c.regex}`).test(r)).map(c=>c.message),o.length=r.length;let a=e.filter(c=>o.contains.length>=c.minDiversity).filter(c=>o.length>=c.minLength).sort((c,d)=>d.id-c.id).map(c=>({id:c.id,value:c.value}));return Object.assign(o,a[0]),o};Xl.exports={passwordStrength:Om,defaultOptions:Zl};var K4=Xl.exports.passwordStrength=Om;Xl.exports.defaultOptions=Zl;function Yl(t){return K4(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 Mi(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 A(500,{message:"Email provider not found"});const r=(i=t.env.emailProviders)==null?void 0:i[n.name];if(!r)throw new A(500,{message:"Email provider not found"});await r({emailProvider:n,...e,from:n.default_from_address||`login@${t.env.ISSUER}`})}async function Pm(t,e){var a,c;if(!t.var.client_id)throw new A(500,{message:"Client not found"});const n=await Ui(t.env,t.var.client_id),r=n.connections.find(d=>d.strategy==="sms");if(!r)throw new A(500,{message:"SMS provider not found"});const i=((a=r.options)==null?void 0:a.provider)||"twilio",o=(c=t.env.smsProviders)==null?void 0:c[i];if(!o)throw new A(500,{message:"SMS provider not found"});await o({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 Tm(t,e,n,r){const i=await t.env.data.tenants.get(t.var.tenant_id);if(!i)throw new A(500,{message:"Tenant not found"});const o=`${dt(t.env)}reset-password?state=${r}&code=${n}`,a={vendorName:i.name,lng:i.language||"en"};await Mi(t,{to:e,subject:re("reset_password_title",a),html:`Click here to reset your password: ${dt(t.env)}reset-password?state=${r}&code=${n}`,template:"auth-password-reset",data:{vendorName:i.name,logo:i.logo||"",passwordResetUrl:o,supportUrl:i.support_url||"https://support.sesamy.com",buttonColor:i.primary_color||"#7d68f4",passwordResetTitle:re("password_reset_title",a),resetPasswordEmailClickToReset:re("reset_password_email_click_to_reset",a),resetPasswordEmailReset:re("reset_password_email_reset",a),supportInfo:re("support_info",a),contactUs:re("contact_us",a),copyright:re("copyright",a),tenantName:i.name,tenantId:i.id}})}async function Rm(t,{to:e,code:n}){const r=await t.env.data.tenants.get(t.var.tenant_id);if(!r)throw new A(500,{message:"Tenant not found"});const{connectionType:i}=mi(e),o=new URL(dt(t.env)),a={vendorName:r.name,vendorId:r.id,loginDomain:o.hostname,code:n,lng:r.language||"en"};i==="email"?await Mi(t,{to:e,subject:re("code_email_subject",a),html:`Click here to validate your email: ${dt(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",a),linkEmailClickToLogin:re("link_email_click_to_login",a),linkEmailLogin:re("link_email_login",a),linkEmailOrEnterCode:re("link_email_or_enter_code",a),codeValid30Mins:re("code_valid_30_minutes",a),supportInfo:re("support_info",a),contactUs:re("contact_us",a),copyright:re("copyright",a)}}):i==="sms"&&await Pm(t,{to:e,text:re("sms_code_text",a),code:n,from:r.name});const c=we(t,{type:he.CODE_LINK_SENT,description:e});It(t,t.env.data.logs.create(r.id,c))}async function Ql(t,{to:e,code:n,authParams:r}){const i=await t.env.data.tenants.get(t.var.tenant_id);if(!i)throw new A(500,{message:"Tenant not found"});if(!r.redirect_uri)throw new A(400,{message:"redirect_uri is required"});const{connectionType:o}=mi(e),a=new URL(Pe(t.env));a.pathname="passwordless/verify_redirect",a.searchParams.set("verification_code",n),a.searchParams.set("connection",o),a.searchParams.set("client_id",r.client_id),a.searchParams.set("redirect_uri",r.redirect_uri),a.searchParams.set("email",e),r.response_type&&a.searchParams.set("response_type",r.response_type),r.scope&&a.searchParams.set("scope",r.scope),r.state&&a.searchParams.set("state",r.state),r.nonce&&a.searchParams.set("nonce",r.nonce),r.code_challenge&&a.searchParams.set("code_challenge",r.code_challenge),r.code_challenge_method&&a.searchParams.set("code_challenge_method",r.code_challenge_method),r.audience&&a.searchParams.set("audience",r.audience);const c={vendorName:i.name,code:n,lng:i.language||"en"};if(o==="email")await Mi(t,{to:e,subject:re("code_email_subject",c),html:`Click here to validate your email: ${dt(t.env)}validate-email`,template:"auth-link",data:{code:n,vendorName:i.name,logo:i.logo||"",supportUrl:i.support_url||"",magicLink:a.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(o==="sms")await Pm(t,{to:e,text:`${re("link_sms_login",c)}: ${a.toString()}`,code:n,from:i.name});else throw new A(400,{message:"Only email and SMS connections are supported for magic links"});const d=we(t,{type:he.CODE_LINK_SENT,description:e});It(t,t.env.data.logs.create(i.id,d))}async function eu(t,e){const n=await t.env.data.tenants.get(t.var.tenant_id);if(!n)throw new A(500,{message:"Tenant not found"});if(!e.email)throw new A(400,{message:"User has no email"});const r={vendorName:n.name,lng:n.language||"en"};await Mi(t,{to:e.email,subject:re("welcome_to_your_account",r),html:`Click here to validate your email: ${dt(t.env)}validate-email`,template:"auth-verify-email",data:{vendorName:n.name,logo:n.logo||"",emailValidationUrl:`${dt(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 G4(t,e,n,r){const i=await t.env.data.tenants.get(t.var.tenant_id);if(!i)throw new A(500,{message:"Tenant not found"});const o={vendorName:i.name,lng:i.language||"en"},a=`${dt(t.env)}signup?state=${r}&code=${n}`;await Mi(t,{to:e,subject:re("register_password_account",o),html:`Click here to register: ${a}`,template:"auth-pre-signup-verification",data:{vendorName:i.name,logo:i.logo||"",signupUrl:a,setPassword:re("set_password",o),registerPasswordAccount:re("register_password_account",o),clickToSignUpDescription:re("click_to_sign_up_description",o),supportUrl:i.support_url||"https://support.sesamy.com",buttonColor:i.primary_color||"#7d68f4",welcomeToYourAccount:re("welcome_to_your_account",o),verifyEmailVerify:re("verify_email_verify",o),supportInfo:re("support_info",o),contactUs:re("contact_us",o),copyright:re("copyright",o)}})}const W4=new s.OpenAPIHono().openapi(s.createRoute({tags:["dbconnections"],method:"post",path:"/signup",request:{body:{content:{"application/json":{schema:s.z.object({client_id:s.z.string(),connection:s.z.literal("Username-Password-Authentication"),email:s.z.string().transform(t=>t.toLowerCase()),password:s.z.string()})}}}},responses:{200:{content:{"application/json":{schema:s.z.object({_id:s.z.string(),email:s.z.string().optional(),email_verified:s.z.boolean(),app_metadata:s.z.object({}),user_metadata:s.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 A(400,{message:"Client not found"});if(t.set("client_id",i.id),t.set("tenant_id",i.tenant.id),!Yl(n))throw new A(400,{message:"Password does not meet the requirements"});if(await Io({userAdapter:t.env.data.users,tenant_id:i.tenant.id,username:e,provider:"auth2"}))throw new A(400,{message:"Invalid sign up"});const a=await t.env.data.users.create(i.tenant.id,{user_id:`auth2|${xs()}`,email:e,email_verified:!1,provider:"auth2",connection:"Username-Password-Authentication",is_social:!1});t.set("user_id",a.user_id),t.set("username",a.email),t.set("connection",a.connection);const c=await vi.hash(n,10);await t.env.data.passwords.create(i.tenant.id,{user_id:a.user_id,password:c,algorithm:"bcrypt"}),await eu(t,a);const d=we(t,{type:he.SUCCESS_SIGNUP,description:"Successful signup"});return await t.env.data.logs.create(i.tenant.id,d),t.json({_id:a.user_id,email:a.email,email_verified:!1,app_metadata:{},user_metadata:{}})}).openapi(s.createRoute({tags:["dbconnections"],method:"post",path:"/change_password",request:{body:{content:{"application/json":{schema:s.z.object({client_id:s.z.string(),connection:s.z.literal("Username-Password-Authentication"),email:s.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 A(400,{message:"Client not found"});if(t.set("client_id",r.id),t.set("tenant_id",r.tenant.id),!await kr({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 o={client_id:n,username:e},a=await t.env.data.loginSessions.create(r.tenant.id,{expires_at:new Date(Date.now()+Qr*1e3).toISOString(),authParams:o,csrf_token:xe(),...jt(t.req)});return await Tm(t,e,a.id,a.authParams.state),t.html("If an account with that email exists, we've sent instructions to reset your password.")});function Dn(){const t="1234567890";let e="";for(let n=0;n<6;n+=1)e+=t[Math.floor(Math.random()*10)];return e.toString()}const J4=new s.OpenAPIHono().openapi(s.createRoute({tags:["passwordless"],method:"post",path:"/start",request:{body:{content:{"application/json":{schema:s.z.union([s.z.object({connection:s.z.literal("email"),client_id:s.z.string(),email:s.z.string().transform(t=>t.toLowerCase()),send:s.z.enum(["link","code"]),authParams:Yr.omit({client_id:!0})}),s.z.object({client_id:s.z.string(),connection:s.z.literal("sms"),phone_number:s.z.string(),send:s.z.enum(["link","code"]),authParams:Yr.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:o,connection:a}=e,c=await t.env.data.clients.get(r);if(!c)throw new A(400,{message:"Client not found"});t.set("client_id",c.id),t.set("tenant_id",c.tenant.id);const d=a==="email"?e.email:e.phone_number,{ip:l,useragent:u,auth0Client:f}=jt(t.req),m=await n.data.loginSessions.create(c.tenant.id,{authParams:{...o,client_id:r,username:d},expires_at:new Date(Date.now()+no).toISOString(),csrf_token:xe(),ip:l,useragent:u,auth0Client:f}),w=await n.data.codes.create(c.tenant.id,{code_id:Dn(),code_type:"otp",login_id:m.id,expires_at:new Date(Date.now()+no).toISOString(),redirect_uri:o.redirect_uri});return i==="link"?await Ql(t,{to:d,code:w.code_id,authParams:{...o,client_id:r}}):await Rm(t,{to:d,code:w.code_id}),t.html("OK")}).openapi(s.createRoute({tags:["passwordless"],method:"get",path:"/verify_redirect",request:{query:s.z.object({scope:s.z.string(),response_type:s.z.nativeEnum(it),redirect_uri:s.z.string(),state:s.z.string(),nonce:s.z.string().optional(),verification_code:s.z.string(),connection:s.z.string(),client_id:s.z.string(),email:s.z.string().transform(t=>t.toLowerCase()),audience:s.z.string().optional()})},responses:{302:{description:"Successful verification, redirecting to continue flow.",headers:s.z.object({Location:s.z.string().url()}).openapi({})},400:{description:"Bad Request (e.g., invalid client, invalid code, missing parameters).",content:{"application/json":{schema:s.z.object({error:s.z.string(),error_description:s.z.string().optional()})}}},500:{description:"Internal Server Error.",content:{"application/json":{schema:s.z.object({error:s.z.string(),error_description:s.z.string().optional()})}}}}}),async t=>{const{env:e}=t,{client_id:n,email:r,verification_code:i,redirect_uri:o,state:a,scope:c,audience:d,response_type:l,nonce:u}=t.req.valid("query"),f=await Ui(e,n);t.set("client_id",f.id),t.set("tenant_id",f.tenant.id),t.set("connection","email");const m={client_id:n,redirect_uri:o,state:a,nonce:u,scope:c,audience:d,response_type:l};let w="Something went wrong. Please try again later.";try{const E=await $a(t,{client_id:n,username:r,otp:i,authParams:m});if(E instanceof Response)return E;if(E&&typeof E=="object"&&"access_token"in E)return t.json(E)}catch(E){const C=E;"message"in C&&typeof C.message=="string"&&(w=C.message)}const{ip:h,useragent:y,auth0Client:v}=jt(t.req),b=await e.data.loginSessions.create(f.tenant.id,{authParams:{...m,username:r},expires_at:new Date(Date.now()+no).toISOString(),csrf_token:xe(),ip:h,useragent:y,auth0Client:v});return t.redirect(`/u/invalid-session?state=${b.id}&error=${encodeURIComponent(w)}`,302)});class Qn extends A{constructor(n,r){super(n,r);te(this,"_code");this._code=r==null?void 0:r.code}get code(){return this._code}}async function tu(t,e,n,r,i){const{env:o}=t,{username:a}=n;if(t.set("username",a),!a)throw new A(400,{message:"Username is required"});const c=await kr({userAdapter:t.env.data.users,tenant_id:e.tenant.id,username:a,provider:"auth2"});if(!c){const h=we(t,{type:he.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid user"});throw It(t,t.env.data.logs.create(e.tenant.id,h)),new Qn(403,{message:"User not found",code:"USER_NOT_FOUND"})}const d=c.linked_to?await o.data.users.get(e.tenant.id,c.linked_to):c;if(!d)throw new Qn(403,{message:"User not found",code:"USER_NOT_FOUND"});t.set("connection",c.connection),t.set("user_id",d.user_id);const l=await o.data.passwords.get(e.tenant.id,c.user_id);if(!(l&&await vi.compare(n.password,l.password))){const h=we(t,{type:he.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid password"});throw It(t,t.env.data.logs.create(e.tenant.id,h)),new Qn(403,{message:"Invalid password",code:"INVALID_PASSWORD"})}if((await o.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===he.FAILED_LOGIN_INCORRECT_PASSWORD&&new Date(h.date)>new Date(Date.now()-1e3*60*5)).length>=3){const h=we(t,{type:he.FAILED_LOGIN,description:"Too many failed login attempts"});throw It(t,t.env.data.logs.create(e.tenant.id,h)),new Qn(403,{message:"Too many failed login attempts",code:"TOO_MANY_FAILED_LOGINS"})}if(!c.email_verified&&e.email_validation==="enforced"){await eu(t,c);const h=we(t,{type:he.FAILED_LOGIN,description:"Email not verified"});throw await t.env.data.logs.create(e.tenant.id,h),new Qn(403,{message:"Email not verified",code:"EMAIL_NOT_VERIFIED"})}const w=we(t,{type:he.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)),Zt(t,{client:e,authParams:n,user:d,ticketAuth:i,loginSession:r})}async function X4(t,e,n,r){await Is(t,{client:e,username:n,provider:"auth2",connection:"Username-Password-Authentication",isSocial:!1,ip:t.req.header("x-real-ip")});let i=Dn(),o=await t.env.data.codes.get(e.tenant.id,i,"password_reset");for(;o;)i=Dn(),o=await t.env.data.codes.get(e.tenant.id,i,"password_reset");const{ip:a,useragent:c,auth0Client:d}=jt(t.req),l=await t.env.data.loginSessions.create(e.tenant.id,{expires_at:new Date(Date.now()+F_).toISOString(),authParams:{client_id:e.id,username:n},csrf_token:xe(),ip:a,useragent:c,auth0Client:d}),u=await t.env.data.codes.create(e.tenant.id,{code_id:i,code_type:"password_reset",login_id:l.id,expires_at:new Date(Date.now()+M_).toISOString()});await Tm(t,n,u.code_id,r)}const Z4=new s.OpenAPIHono().openapi(s.createRoute({tags:["oauth"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:s.z.union([s.z.object({credential_type:s.z.literal("http://auth0.com/oauth/grant-type/passwordless/otp"),otp:s.z.string(),client_id:s.z.string(),username:s.z.string().transform(t=>t.toLowerCase()),realm:s.z.enum(["email"]),scope:s.z.string().optional()}),s.z.object({credential_type:s.z.literal("http://auth0.com/oauth/grant-type/password-realm"),client_id:s.z.string(),username:s.z.string().transform(t=>t.toLowerCase()),password:s.z.string(),realm:s.z.enum(["Username-Password-Authentication"]),scope:s.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 A(400,{message:"Client not found"});t.set("client_id",n),t.set("tenant_id",i.tenant.id);const o=r.toLocaleLowerCase(),a=jt(t.req);let c;if("otp"in e)c=await $a(t,{client_id:n,username:o,otp:e.otp});else if("password"in e){const d=await t.env.data.loginSessions.create(i.tenant.id,{expires_at:new Date(Date.now()+Qr*1e3).toISOString(),authParams:{client_id:n,username:o},csrf_token:xe(),ip:a.ip,useragent:a.useragent,auth0Client:a.auth0Client});c=await tu(t,i,{username:o,password:e.password,client_id:n},d,!0)}else throw new A(400,{message:"Code or password required"});if(!(c instanceof Response))throw new A(500,{message:"Unexpected response from loginWithPassword"});return c});function Y4(t,e){var r,i,o;if(!t||e.length===0)return!1;const n=((r=Va(t))==null?void 0:r.host)??null;if(!n)return!1;for(const a of e){let c;if(a.startsWith("http://")||a.startsWith("https://")?c=((i=Va(a))==null?void 0:i.host)??null:c=((o=Va("https://"+a))==null?void 0:o.host)??null,n===c)return!0}return!1}function Va(t){try{return new URL(t)}catch{return null}}async function Q4({ctx:t,session:e,client:n,authParams:r,connection:i,login_hint:o}){const a=new URL(t.req.url);t.var.custom_domain&&(a.hostname=t.var.custom_domain);const{ip:c,useragent:d,auth0Client:l}=jt(t.req),u=await t.env.data.loginSessions.create(n.tenant.id,{expires_at:new Date(Date.now()+Qr*1e3).toISOString(),authParams:r,csrf_token:xe(),authorization_url:a.toString(),ip:c,useragent:d,auth0Client:l});if(e&&o){const f=await t.env.data.users.get(n.tenant.id,e.user_id);if((f==null?void 0:f.email)===o)return Zt(t,{client:n,loginSession:u,authParams:r,user:f,sessionId:e.id})}if(i==="email"&&o){const f=Dn();return await t.env.data.codes.create(n.tenant.id,{code_id:f,code_type:"otp",login_id:u.id,expires_at:new Date(Date.now()+Qr*1e3).toISOString(),redirect_uri:r.redirect_uri}),await Ql(t,{code:f,to:o,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 e$(t){if(t==="Username-Password-Authentication")return"auth2";if(t==="email")return"email";throw new A(403,{message:"Invalid realm"})}async function t$(t,e,n,r,i){var m;const{env:o}=t;t.set("connection",i);const a=await o.data.codes.get(e,n,"ticket");if(!a||a.used_at)throw new A(403,{message:"Ticket not found"});const c=await o.data.loginSessions.get(e,a.login_id);if(!c||!c.authParams.username)throw new A(403,{message:"Session not found"});const d=await o.data.clients.get(c.authParams.client_id);if(!d)throw new A(403,{message:"Client not found"});t.set("client_id",c.authParams.client_id),await o.data.codes.used(e,n);const l=e$(i);let u=await Is(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 f=await w0(t,{user:u,client:d,loginSession:c});return Zt(t,{authParams:{scope:(m=c.authParams)==null?void 0:m.scope,...r},loginSession:c,sessionId:f.id,user:u,client:d})}async function eh(t,e){return`<!DOCTYPE html>
155
155
  <html>
156
156
 
157
157
  <head>
@@ -221,7 +221,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
221
221
  <\/script>
222
222
  `])))]})},Gn=({children:t})=>_("div",{className:"mb-2 text-sm text-red",children:t}),N$=t=>t==="small"?"text-base":t==="medium"?"text-2xl":t==="large"?"text-3xl":"",Zm=({size:t})=>{const e=N$(t);return _("div",{className:"relative inline-block leading-[0]",children:[_(Be,{className:fn("text-gray-200 dark:text-[#201a41]",{[e]:e}),name:"spinner-circle"}),_(Be,{className:fn("absolute inset-0 animate-spin text-primary",{[e]:e}),name:"spinner-inner"})]})},Le=({children:t,className:e,Component:n="button",variant:r="primary",href:i,disabled:o,isLoading:a,id:c})=>{const d=n==="a"?{href:i}:{};return _(n,{class:fn("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":o,"is-loading":a},"focus:outline-none focus:ring",e),type:"submit",disabled:o,id:c,...d,children:[_("span",{className:"btn-label flex items-center justify-center space-x-2",children:t}),_("div",{className:"btn-spinner absolute left-0 top-0 flex h-full w-full items-center justify-center",children:_(Zm,{size:"medium"})})]})},Fr=({connection:t,text:e,icon:n=null,canResize:r=!1,loginSession:i})=>{const o=new URLSearchParams({client_id:i.authParams.client_id,connection:t});i.authParams.response_type&&o.set("response_type",i.authParams.response_type),i.authParams.redirect_uri&&o.set("redirect_uri",i.authParams.redirect_uri),i.authParams.scope&&o.set("scope",i.authParams.scope),i.authParams.nonce&&o.set("nonce",i.authParams.nonce),i.authParams.response_type&&o.set("response_type",i.authParams.response_type),i.authParams.state&&o.set("state",i.id);const a=`/authorize?${o.toString()}`;return _(Le,{className:fn("border border-gray-200 bg-white hover:bg-gray-100 dark:border-gray-400 dark:bg-black dark:hover:bg-black/90",{"px-0 py-3 sm:px-10 sm:py-4 short:px-0 short:py-3":r,"px-10 py-3":!r}),variant:"custom","aria-label":e,Component:"a",href:a,children:[n||"",_("div",{className:fn("text-left text-black dark:text-white sm:text-base",{"hidden sm:inline short:hidden":r}),children:e})]})},Ym=({...t})=>_("svg",{width:"45",height:"45",viewBox:"0 0 45 45",xmlns:"http://www.w3.org/2000/svg",...t,children:[_("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"}),_("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"}),_("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"}),_("path",{d:"M22.4982 8.90741C25.7068 8.85499 28.8071 10.0673 31.1291 12.2823L37.5507 5.86064C33.4788 2.03602 28.0843 -0.0637686 22.4982 0.00147616C18.3277 0.00166623 14.2394 1.16098 10.6896 3.34999C7.13989 5.539 4.26839 8.67155 2.39575 12.3979L9.86736 18.1946C11.6485 12.8635 16.6296 8.90741 22.4982 8.90741Z",fill:"#EA4335"})]}),tn=({children:t,className:e})=>_("form",{id:"form",method:"post",className:e,children:t}),Qm=({...t})=>_("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:[_("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"}),_("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`})]}),ho=({error:t,vendorSettings:e,loginSession:n,email:r,client:i})=>{const o=i.connections.map(({strategy:C})=>C),a=o.includes("email")||o.includes("Username-Password-Authentication"),c=o.includes("sms"),d=o.includes("facebook"),l=o.includes("google-oauth2"),u=o.includes("apple"),f=o.includes("vipps"),m=d||l||u||f,w=a||c;let h="text",y="username";const v=a&&c?"email_or_phone_placeholder":a?"email_placeholder":"phone_placeholder";let b=O.t(v,a&&c?"Email or Phone Number":a?"Email Address":"Phone Number");return _(De,{title:O.t("welcome"),vendorSettings:e,children:[_("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:O.t("welcome")}),_("div",{className:"mb-8 text-gray-300",children:O.t("login_description_template",{authMethod:O.t(v,{defaultValue:a&&c?"email or phone number":a?"email address":"phone number"}).toLocaleLowerCase(),defaultValue:"Sign in with your {{authMethod}}"})}),_("div",{className:"flex flex-1 flex-col justify-center",children:[w&&_(tn,{className:"mb-7",children:[_("input",{type:h,name:y,placeholder:b,className:fn("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&&_(Gn,{children:t}),_(Le,{className:"sm:mt-4 !text-base",children:[_("span",{children:O.t("continue")}),_(Be,{className:"text-xs",name:"arrow-right"})]})]}),w&&m&&_("div",{className:"relative mb-5 block text-center text-gray-300 dark:text-gray-300",children:[_("div",{className:"absolute left-0 right-0 top-1/2 border-b border-gray-200 dark:border-gray-600"}),_("div",{className:"relative inline-block bg-white px-2 dark:bg-gray-800",children:O.t("continue_social_login")})]}),_("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&&_(Fr,{connection:"facebook",text:O.t("continue_with",{provider:"Facebook"}),canResize:!0,icon:_(Be,{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&&_(Fr,{connection:"google-oauth2",text:O.t("continue_with",{provider:"Google"}),canResize:!0,icon:_(Ym,{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&&_(Fr,{connection:"apple",text:O.t("continue_with",{provider:"Apple"}),canResize:!0,icon:_(Be,{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}),f&&_(Fr,{connection:"vipps",text:O.t("continue_with",{provider:"Vipps"}),canResize:!0,icon:_(Qm,{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})]})]})]})},C$=["Auth0.swift"];function j$(t){if(!t)return"code";const e=atob(t),n=JSON.parse(e);return C$.includes(n.name)?"code":"link"}const O$=new s.OpenAPIHono().openapi(s.createRoute({tags:["login"],method:"get",path:"/",request:{query:s.z.object({state:s.z.string().openapi({description:"The state parameter from the authorization request"}),impersonation:s.z.string().optional()})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,loginSession:r,client:i}=await ke(t,e);return t.html(_(ho,{vendorSettings:n,loginSession:r,client:i,email:r.authParams.username}))}).openapi(s.createRoute({tags:["login"],method:"post",path:"/",request:{query:s.z.object({state:s.z.string().openapi({description:"The state parameter from the authorization request"})}),body:{content:{"application/x-www-form-urlencoded":{schema:s.z.object({username:s.z.string().transform(t=>t.toLowerCase()),login_selection:s.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:o,vendorSettings:a}=await ke(t,n);t.set("client_id",i.id);const{countryCode:c}=jt(t.req),{normalized:d}=mi(r.username,c);if(!d)return t.html(_(ho,{vendorSettings:a,loginSession:o,error:O.t("invalid_identifier"),email:r.username,client:i}),400);const l=await zs({userAdapter:e.data.users,tenant_id:i.tenant.id,email:d});if(l&&t.set("user_id",l.user_id),!l)try{await v2(t,i,t.env.data,d)}catch{const y=we(t,{type:he.FAILED_SIGNUP,description:"Public signup is disabled"});return await t.env.data.logs.create(i.tenant.id,y),t.html(_(ho,{vendorSettings:a,loginSession:o,error:O.t("user_account_does_not_exist"),email:r.username,client:i}),400)}if(o.authParams.username=d,await e.data.loginSessions.update(i.tenant.id,o.id,o),await x$(t,i,r.username,r.login_selection))return t.redirect(`/u/enter-password?state=${n}`);let u=Dn(),f=await e.data.codes.get(i.tenant.id,u,"otp");for(;f;)u=Dn(),f=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:o.id,expires_at:new Date(Date.now()+no).toISOString(),redirect_uri:o.authParams.redirect_uri}),w=j$(o.auth0Client),{connection:h}=mi(d);return h==="email"&&w==="link"&&!d.includes("online.no")?await Ql(t,{to:d,code:m.code_id,authParams:o.authParams}):await Rm(t,{to:d,code:m.code_id}),t.redirect(`/u/enter-code?state=${n}`)}),bt=t=>_("a",{className:"block text-primary hover:text-primaryHover text-center",href:`/u/login/identifier?state=${t.state}`,children:O.t("go_back")});var yi="_hp",P$={Change:"Input",DoubleClick:"DblClick"},T$={svg:"2000/svg",math:"1998/Math/MathML"},wi=[],Od=new WeakMap,$r=void 0,R$=()=>$r,Lt=t=>"t"in t,Ka={onClick:["click",!1]},ch=t=>{if(!t.startsWith("on"))return;if(Ka[t])return Ka[t];const e=t.match(/^on([A-Z][a-zA-Z]+?(?:PointerCapture)?)(Capture)?$/);if(e){const[,n,r]=e;return Ka[t]=[(P$[n]||n).toLowerCase(),!!r]}},dh=(t,e)=>$r&&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,B$=(t,e,n)=>{var r;e||(e={});for(let i in e){const o=e[i];if(i!=="children"&&(!n||n[i]!==o)){i=gs(i);const a=ch(i);if(a){if((n==null?void 0:n[i])!==o&&(n&&t.removeEventListener(a[0],n[i],a[1]),o!=null)){if(typeof o!="function")throw new Error(`Event handler for "${i}" is not a function`);t.addEventListener(a[0],o,a[1])}}else if(i==="dangerouslySetInnerHTML"&&o)t.innerHTML=o.__html;else if(i==="ref"){let c;typeof o=="function"?c=o(t)||(()=>o(null)):o&&"current"in o&&(o.current=t,c=()=>o.current=null),Od.set(t,c)}else if(i==="style"){const c=t.style;typeof o=="string"?c.cssText=o:(c.cssText="",o!=null&&Hm(o,c.setProperty.bind(c)))}else{if(i==="value"){const d=t.nodeName;if(d==="INPUT"||d==="TEXTAREA"||d==="SELECT"){if(t.value=o==null||o===!1?null:o,d==="TEXTAREA"){t.textContent=o;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]=o);const c=dh(t,i);o==null||o===!1?t.removeAttribute(c):o===!0?t.setAttribute(c,""):typeof o=="string"||typeof o=="number"?t.setAttribute(c,o):t.setAttribute(c,o.toString())}}}if(n)for(let i in n){const o=n[i];if(i!=="children"&&!(i in e)){i=gs(i);const a=ch(i);a?t.removeEventListener(a[0],o,a[1]):i==="ref"?(r=Od.get(t))==null||r():t.removeAttribute(dh(t,i))}}},L$=(t,e)=>{e[Ee][0]=0,wi.push([t,e]);const n=e.tag[nu]||e.tag,r=n.defaultProps?{...n.defaultProps,...e.props}:e.props;try{return[n.call(null,r)]}finally{wi.pop()}},e1=(t,e,n,r,i)=>{var o,a;(o=t.vR)!=null&&o.length&&(r.push(...t.vR),delete t.vR),typeof t.tag=="function"&&((a=t[Ee][1][i1])==null||a.forEach(c=>i.push(c))),t.vC.forEach(c=>{var d;if(Lt(c))n.push(c);else if(typeof c.tag=="function"||c.tag===""){c.c=e;const l=n.length;if(e1(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)})},U$=t=>{for(;;t=t.tag===yi||!t.vC||!t.pP?t.nN:t.vC[0]){if(!t)return null;if(t.tag!==yi&&t.e)return t.e}},t1=t=>{var e,n,r,i,o,a;Lt(t)||((n=(e=t[Ee])==null?void 0:e[1][i1])==null||n.forEach(c=>{var d;return(d=c[2])==null?void 0:d.call(c)}),(r=Od.get(t.e))==null||r(),t.p===2&&((i=t.vC)==null||i.forEach(c=>c.p=2)),(o=t.vC)==null||o.forEach(t1)),t.p||((a=t.e)==null||a.remove(),delete t.e),typeof t.tag=="function"&&(Dr.delete(t),go.delete(t),delete t[Ee][3],t.a=!0)},n1=(t,e,n)=>{t.c=e,r1(t,e,n)},lh=(t,e)=>{if(e){for(let n=0,r=t.length;n<r;n++)if(t[n]===e)return n}},uh=Symbol(),r1=(t,e,n)=>{var l;const r=[],i=[],o=[];e1(t,e,r,i,o),i.forEach(t1);const a=n?void 0:e.childNodes;let c,d=null;if(n)c=-1;else if(!a.length)c=0;else{const u=lh(a,U$(t.nN));u!==void 0?(d=a[u],c=u):c=lh(a,(l=r.find(f=>f.tag!==yi&&f.e))==null?void 0:l.e)??-1,c===-1&&(n=!0)}for(let u=0,f=r.length;u<f;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;Lt(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)),B$(w,m.props,m.pP),r1(m,w,h))}m.tag===yi?c--:n?w.parentNode||e.appendChild(w):a[c]!==w&&a[c-1]!==w&&(a[c+1]===w?e.appendChild(a[c]):e.insertBefore(w,d||a[c]||null))}if(t.pP&&delete t.pP,o.length){const u=[],f=[];o.forEach(([,m,,w,h])=>{m&&u.push(m),w&&f.push(w),h==null||h()}),u.forEach(m=>m()),f.length&&requestAnimationFrame(()=>{f.forEach(m=>m())})}},go=new WeakMap,Pd=(t,e,n)=>{var o,a,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"?L$(t,e):Fi(e.props.children)),((o=n[0])==null?void 0:o.tag)===""&&n[0][Cd]&&(i=n[0][Cd],t[5].push([t,i,e]));const f=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 y=M$(n[h]);if(y){typeof y.tag=="function"&&!y.tag[Mm]&&(br.length>0&&(y[Ee][2]=br.map(b=>[b,b.values.at(-1)])),(a=t[5])!=null&&a.length&&(y[Ee][3]=t[5].at(-1)));let v;if(f&&f.length){const b=f.findIndex(Lt(y)?E=>Lt(E):y.key!==void 0?E=>E.key===y.key&&E.tag===y.tag:E=>E.tag===y.tag);b!==-1&&(v=f[b],f.splice(b,1))}if(v)if(Lt(y))v.t!==y.t&&(v.t=y.t,v.d=!0),y=v;else{const b=v.pP=v.props;v.props=y.props,v.f||(v.f=y.f||e.f),typeof y.tag=="function"&&(v[Ee][2]=y[Ee][2]||[],v[Ee][3]=y[Ee][3],!v.f&&((v.o||v)===y.o||(d=(c=v.tag)[a$])!=null&&d.call(c,b,v.props))&&(v.s=!0)),y=v}else if(!Lt(y)&&$r){const b=Tr($r);b&&(y.n=b)}if(!Lt(y)&&!y.s&&(Pd(t,y),delete y.f),m.push(y),w&&!w.s&&!y.s)for(let b=w;b&&!Lt(b);b=(l=b.vC)==null?void 0:l.at(-1))b.nN=y;w=y}}e.vR=r?[...e.vC,...f||[]]:f||[],e.vC=m,r&&delete e.pC}catch(f){if(e.f=!0,f===uh){if(i)return;throw f}const[m,w,h]=((u=e[Ee])==null?void 0:u[3])||[];if(w){const y=()=>mo([0,!1,t[2]],h),v=go.get(h)||[];v.push(y),go.set(h,v);const b=w(f,()=>{const E=go.get(h);if(E){const C=E.indexOf(y);if(C!==-1)return E.splice(C,1),y()}});if(b){if(t[0]===1)t[1]=!0;else if(Pd(t,h,[b]),(w.length===1||t!==m)&&h.c){n1(h,h.c,!1);return}throw uh}}throw f}finally{i&&t[5].pop()}},M$=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[Ee]=[0,[]];else{const e=T$[t.tag];e&&($r||($r=Dm("")),t.props.children=[{tag:$r,props:{value:t.n=`http://www.w3.org/${e}`,children:t.props.children}}])}return t}},ph=(t,e)=>{var n,r;(n=e[Ee][2])==null||n.forEach(([i,o])=>{i.values.push(o)});try{Pd(t,e,void 0)}catch{return}if(e.a){delete e.a;return}(r=e[Ee][2])==null||r.forEach(([i])=>{i.values.pop()}),(t[0]!==1||!t[1])&&n1(e,e.c,!1)},Dr=new WeakMap,fh=[],mo=async(t,e)=>{t[5]||(t[5]=[]);const n=Dr.get(e);n&&n[0](void 0);let r;const i=new Promise(o=>r=o);if(Dr.set(e,[r,()=>{t[2]?t[2](t,e,o=>{ph(o,e)}).then(()=>r(e)):(ph(t,e),r(e))}]),fh.length)fh.at(-1).add(e);else{await Promise.resolve();const o=Dr.get(e);o&&(Dr.delete(e),o[1]())}return i},F$=(t,e,n)=>({tag:yi,props:{children:t},key:n,e,p:1}),Ga=0,i1=1,Wa=2,Ja=3,Xa=new WeakMap,o1=(t,e)=>!t||!e||t.length!==e.length||e.some((n,r)=>n!==t[r]),D$=void 0,hh=[],V$=t=>{var a;const e=()=>typeof t=="function"?t():t,n=wi.at(-1);if(!n)return[e(),()=>{}];const[,r]=n,i=(a=r[Ee][1])[Ga]||(a[Ga]=[]),o=r[Ee][0]++;return i[o]||(i[o]=[e(),c=>{const d=D$,l=i[o];if(typeof c=="function"&&(c=c(l[0])),!Object.is(c,l[0]))if(l[0]=c,hh.length){const[u,f]=hh.at(-1);Promise.all([u===3?r:mo([u,!1,d],r),f]).then(([m])=>{if(!m||!(u===2||u===3))return;const w=m.vC;requestAnimationFrame(()=>{setTimeout(()=>{w===m.vC&&mo([u===3?1:0,!1,d],m)})})})}else mo([0,!1,d],r)}])},su=(t,e)=>{var c;const n=wi.at(-1);if(!n)return t;const[,r]=n,i=(c=r[Ee][1])[Wa]||(c[Wa]=[]),o=r[Ee][0]++,a=i[o];return o1(a==null?void 0:a[1],e)?i[o]=[t,e]:t=i[o][0],t},q$=t=>{const e=Xa.get(t);if(e){if(e.length===2)throw e[1];return e[0]}throw t.then(n=>Xa.set(t,[n]),n=>Xa.set(t,[void 0,n])),t},H$=(t,e)=>{var c;const n=wi.at(-1);if(!n)return t();const[,r]=n,i=(c=r[Ee][1])[Ja]||(c[Ja]=[]),o=r[Ee][0]++,a=i[o];return o1(a==null?void 0:a[1],e)&&(i[o]=[t(),e]),i[o][0]},K$=Dm({pending:!1,data:null,method:null,action:null}),gh=new Set,G$=t=>{gh.add(t),t.finally(()=>gh.delete(t))},au=(t,e)=>H$(()=>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]),Yn=Object.create(null),Yi=Object.create(null),qi=(t,e,n,r,i)=>{if(e!=null&&e.itemProp)return{tag:t,props:e,type:t,ref:e.ref};const o=document.head;let{onLoad:a,onError:c,precedence:d,blocking:l,...u}=e,f=null,m=!1;const w=uo[t];let h;if(w.length>0){const E=o.querySelectorAll(t);e:for(const C of E)for(const L of uo[t])if(C.getAttribute(L)===e[L]){f=C;break e}if(!f){const C=w.reduce((L,Y)=>e[Y]===void 0?L:`${L}-${Y}-${e[Y]}`,t);m=!Yi[C],f=Yi[C]||(Yi[C]=(()=>{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=o.querySelectorAll(t);d=r?d??"":void 0,r&&(u[po]=d);const y=su(E=>{if(w.length>0){let C=!1;for(const L of o.querySelectorAll(t)){if(C&&L.getAttribute(po)!==d){o.insertBefore(E,L);return}L.getAttribute(po)===d&&(C=!0)}o.appendChild(E)}else if(h){let C=!1;for(const L of h)if(L===E){C=!0;break}C||o.insertBefore(E,o.contains(h[0])?h[0]:o.querySelector(t)),h=void 0}},[d]),v=au(e.ref,E=>{var Y;const C=w[0];if(n===2&&(E.innerHTML=""),(m||h)&&y(E),!c&&!a)return;let L=Yn[Y=E.getAttribute(C)]||(Yn[Y]=new Promise((se,ae)=>{E.addEventListener("load",se),E.addEventListener("error",ae)}));a&&(L=L.then(a)),c&&(L=L.catch(c)),L.catch(()=>{})});if(i&&l==="render"){const E=uo[t][0];if(e[E]){const C=e[E],L=Yn[C]||(Yn[C]=new Promise((Y,se)=>{y(f),f.addEventListener("load",Y),f.addEventListener("error",se)}));q$(L)}}const b={tag:t,type:t,props:{...u,ref:v},ref:v};return b.p=n,f&&(b.e=f),F$(b,o)},W$=t=>{const e=R$(),n=e&&Tr(e);return n!=null&&n.endsWith("svg")?{tag:"title",props:t,type:"title",ref:t.ref}:qi("title",t,void 0,!1,!1)},J$=t=>!t||["src","async"].some(e=>!t[e])?{tag:"script",props:t,type:"script",ref:t.ref}:qi("script",t,1,!1,!0),X$=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,qi("style",t,2,!0,!0)),Z$=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}:qi("link",t,1,"precedence"in t,!0),Y$=t=>qi("meta",t,void 0,!1,!1),s1=Symbol(),Q$=t=>{const{action:e,...n}=t;typeof e!="function"&&(n.action=e);const[r,i]=V$([null,!1]),o=su(async l=>{const u=l.isTrusted?e:l.detail[s1];if(typeof u!="function")return;l.preventDefault();const f=new FormData(l.target);i([f,!0]);const m=u(f);m instanceof Promise&&(G$(m),await m),i([null,!0])},[]),a=au(t.ref,l=>(l.addEventListener("submit",o),()=>{l.removeEventListener("submit",o)})),[c,d]=r;return r[1]=!1,{tag:K$,props:{value:{pending:c!==null,data:c,method:c?"post":null,action:c?e:null},children:{tag:"form",props:{...n,ref:a},type:"form",ref:a}},f:d}},a1=(t,{formAction:e,...n})=>{if(typeof e=="function"){const r=su(i=>{i.preventDefault(),i.currentTarget.form.dispatchEvent(new CustomEvent("submit",{detail:{[s1]:e}}))},[]);n.ref=au(n.ref,i=>(i.addEventListener("click",r),()=>{i.removeEventListener("click",r)}))}return{tag:t,props:n,type:t,ref:n.ref}},e6=t=>a1("input",t),t6=t=>a1("button",t);Object.assign(jd,{title:W$,script:J$,style:X$,link:Z$,meta:Y$,form:Q$,input:e6,button:t6});new TextEncoder;const xa=t=>{const{i18nKey:e,values:n,components:r}=t,i=O.t(e,n),o=/<(\d+)>(.*?)<\/\d+>/g,a=[];let c=0,d;for(;(d=o.exec(i))!==null;){const[,l,u]=d,f=i.substring(c,d.index);f&&a.push(f);const m=parseInt(l,10);a.push($$(r[m],{},u)),c=o.lastIndex}return c<i.length&&a.push(i.substring(c)),_(ou,{children:a})},mh=6,Td=({error:t,vendorSettings:e,email:n,state:r,client:i,hasPasswordLogin:o})=>{const a=new URLSearchParams({state:r}),d=i.connections.map(({name:l})=>l).includes("auth2");return _(De,{title:O.t("verify_your_email"),vendorSettings:e,children:[_("div",{className:"mb-4 text-2xl font-medium",children:O.t("verify_your_email")}),_("div",{className:"mb-8 text-gray-300",children:_(xa,{i18nKey:"code_sent_template",components:[_("span",{className:"text-black dark:text-white"},"span")],values:{username:n}})}),_("div",{className:"flex flex-1 flex-col justify-center",children:[_(tn,{className:"pt-2",children:[_("input",{autoFocus:!0,type:"text",pattern:"[0-9]*",maxLength:mh,inputMode:"numeric",name:"code",placeholder:"******",className:fn("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:mh,required:!0,id:"code-input"}),t&&_(Gn,{children:t}),_(Le,{className:"sm:mt-4 !text-base",children:[_("span",{children:O.t("login")}),_(Be,{className:"text-xs",name:"arrow-right"})]}),_("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[_(Be,{className:"text-base",name:"info-bubble"}),_("div",{className:"text-sm text-gray-300 md:text-sm",children:O.t("sent_code_spam")})]}),d&&_("div",{className:"text-center mb-12",children:[_("div",{className:"relative mb-5 block text-center text-gray-300 dark:text-gray-300",children:[_("div",{className:"absolute left-0 right-0 top-1/2 border-b border-gray-200 dark:border-gray-600"}),_("div",{className:"relative inline-block bg-white px-2 dark:bg-gray-800",children:O.t("or")})]}),_(Le,{Component:"a",href:`/u/${o?"enter-password":"pre-signup"}?${a.toString()}`,variant:"secondary",className:"block",children:O.t("enter_your_password_btn")})]})]}),_(bt,{state:r})]})]})},Ct=t=>{const{message:e,vendorSettings:n,pageTitle:r,state:i}=t;return _(De,{title:"Login",vendorSettings:n,children:[r?_("div",{className:"mb-6 text-gray-300",children:r}):"",_("div",{className:"flex flex-1 flex-col justify-center",children:e}),i?_(bt,{state:i}):""]})},n6=new s.OpenAPIHono().openapi(s.createRoute({tags:["login"],method:"get",path:"/",request:{query:s.z.object({state:s.z.string().openapi({description:"The state"})})},responses:{200:{description:"HTML page to enter verification code.",content:{"text/html":{schema:s.z.string()}}},400:{description:"Bad Request - HTML error page if username is missing in state.",content:{"text/html":{schema:s.z.string()}}},500:{description:"Internal Server Error - HTML error page.",content:{"text/html":{schema:s.z.string()}}}}}),async t=>{const{state:e}=t.req.valid("query");let n,r,i;try{if({vendorSettings:n,loginSession:r,client:i}=await ke(t,e),!r.authParams.username)return t.html(_(Ct,{vendorSettings:n,state:e,pageTitle:O.t("error_page_title")||"Error",message:O.t("username_not_found_error")||"Username not found in session."}),400);const o=await Io({userAdapter:t.env.data.users,tenant_id:i.tenant.id,username:r.authParams.username,provider:"auth2"});return t.html(_(Td,{vendorSettings:n,email:r.authParams.username,state:e,client:i,hasPasswordLogin:!!o}))}catch(o){return console.error("Error in GET /u/enter-code:",o),n||(n={styles:"",disable_signup:!1,disable_connection_signup:!1,domains:[],client:{id:"",tenant:{id:""}}}),t.html(_(Ct,{vendorSettings:n,state:e,pageTitle:O.t("error_page_title")||"Error",message:O.t("unexpected_error_try_again")||"An unexpected error occurred. Please try again."}),500)}}).openapi(s.createRoute({tags:["login"],method:"post",path:"/",request:{query:s.z.object({state:s.z.string().openapi({description:"The state"})}),body:{content:{"application/x-www-form-urlencoded":{schema:s.z.object({code:s.z.string()})}}}},responses:{302:{description:"Redirect to continue authentication flow.",headers:s.z.object({Location:s.z.string().url()})},400:{description:"Bad Request - HTML page with an error message (e.g., invalid code, username missing).",content:{"text/html":{schema:s.z.string()}}},500:{description:"Internal Server Error - HTML error page for unexpected issues.",content:{"text/html":{schema:s.z.string()}}}}}),async t=>{var a;const{state:e}=t.req.valid("query"),{code:n}=t.req.valid("form"),{vendorSettings:r,client:i,loginSession:o}=await ke(t,e);if(!o.authParams.username)throw new A(400,{message:O.t("username_not_found_error")||"Username not found in session."});try{t.set("client_id",i.id);const c=await $a(t,{client_id:i.id,authParams:o.authParams,username:o.authParams.username,otp:n});if(c instanceof Response)return c;throw new A(500,{message:O.t("unexpected_error_try_again")||"An unexpected error occurred. Please try again."})}catch(c){let d;try{d=await Io({userAdapter:t.env.data.users,tenant_id:i.tenant.id,username:o.authParams.username,provider:"auth2"})}catch{d=null}return t.html(_(Td,{vendorSettings:r,email:(a=o.authParams)==null?void 0:a.username,state:e,client:i,error:c.message,hasPasswordLogin:!!d}),400)}}),c1=t=>{const{vendorSettings:e,state:n}=t;return _(De,{title:O.t("unverified_email"),vendorSettings:e,children:[_("div",{className:"flex flex-1 flex-col justify-center",children:[_("p",{className:"mb-8 text-gray-300 text-lg",children:O.t("unverified_email")}),_("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[_(Be,{className:"text-base",name:"info-bubble"}),_("div",{className:"text-sm text-gray-300 md:text-sm",children:O.t("sent_code_spam")})]}),_(bt,{state:n})]}),_(bt,{state:n})]})},r6=({width:t=22,height:e=17})=>_("svg",{width:t,height:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 576 512",children:_("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"})}),i6=({width:t=23,height:e=18})=>_("svg",{width:t,height:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 640 512",children:_("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"})}),Rd=({name:t,placeholder:e=O.t("password")})=>_("div",{className:"password-input relative mb-2",children:[_("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}),_("button",{type:"button","aria-label":O.t("show_password"),title:O.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:_(r6,{})}),_("button",{type:"button","aria-label":O.t("hide_password"),title:O.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:_(i6,{})})]});var _h=Object.freeze,o6=Object.defineProperty,s6=(t,e)=>_h(o6(t,"raw",{value:_h(t.slice())})),yh;const Vr=t=>{const{error:e,vendorSettings:n,email:r,state:i}=t,o=new URLSearchParams({state:i});return _(De,{title:O.t("enter_password"),vendorSettings:n,children:[_("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:O.t("enter_password")}),_("div",{className:"mb-6 text-gray-300",children:O.t("enter_password_description")}),_("div",{className:"flex flex-1 flex-col justify-center",children:[_(tn,{className:"mb-7",children:[_("input",{type:"text",name:"username",placeholder:O.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}),_(Rd,{name:"password"}),e&&_(Gn,{children:e}),_(Le,{className:"sm:mt-4 !text-base",children:[_("span",{children:O.t("login")}),_(Be,{className:"text-xs",name:"arrow-right"})]})]}),_("a",{href:`/u/forgot-password?${o.toString()}`,className:"text-primary hover:underline mb-4",children:O.t("forgot_password_link")}),_("div",{className:"text-center mb-12",children:[_("div",{className:"relative mb-5 block text-center text-gray-300 dark:text-gray-300",children:[_("div",{className:"absolute left-0 right-0 top-1/2 border-b border-gray-200 dark:border-gray-600"}),_("div",{className:"relative inline-block bg-white px-2 dark:bg-gray-800",children:O.t("or")})]}),_("form",{method:"post",action:`/u/login/identifier?${o.toString()}`,children:[_("input",{type:"hidden",name:"login_selection",value:"code"}),_("input",{type:"hidden",name:"username",value:r}),_(Le,{variant:"secondary",className:"block",children:O.t("enter_a_code_btn")})]})]}),_(bt,{state:i})]}),Um(yh||(yh=s6([`
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`})]}),ho=({error:t,vendorSettings:e,loginSession:n,email:r,client:i})=>{const o=i.connections.map(({strategy:C})=>C),a=o.includes("email")||o.includes("Username-Password-Authentication"),c=o.includes("sms"),d=o.includes("facebook"),l=o.includes("google-oauth2"),u=o.includes("apple"),f=o.includes("vipps"),m=d||l||u||f,w=a||c;let h="text",y="username";const v=a&&c?"email_or_phone_placeholder":a?"email_placeholder":"phone_placeholder";let b=O.t(v,a&&c?"Email or Phone Number":a?"Email Address":"Phone Number");return _(De,{title:O.t("welcome"),vendorSettings:e,children:[_("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:O.t("welcome")}),_("div",{className:"mb-8 text-gray-300",children:O.t("login_description_template",{authMethod:O.t(v,{defaultValue:a&&c?"email or phone number":a?"email address":"phone number"}).toLocaleLowerCase(),defaultValue:"Sign in with your {{authMethod}}"})}),_("div",{className:"flex flex-1 flex-col justify-center",children:[w&&_(tn,{className:"mb-7",children:[_("input",{type:h,name:y,placeholder:b,className:fn("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&&_(Gn,{children:t}),_(Le,{className:"sm:mt-4 !text-base",children:[_("span",{children:O.t("continue")}),_(Be,{className:"text-xs",name:"arrow-right"})]})]}),w&&m&&_("div",{className:"relative mb-5 block text-center text-gray-300 dark:text-gray-300",children:[_("div",{className:"absolute left-0 right-0 top-1/2 border-b border-gray-200 dark:border-gray-600"}),_("div",{className:"relative inline-block bg-white px-2 dark:bg-gray-800",children:O.t("continue_social_login")})]}),_("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&&_(Fr,{connection:"facebook",text:O.t("continue_with",{provider:"Facebook"}),canResize:!0,icon:_(Be,{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&&_(Fr,{connection:"google-oauth2",text:O.t("continue_with",{provider:"Google"}),canResize:!0,icon:_(Ym,{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&&_(Fr,{connection:"apple",text:O.t("continue_with",{provider:"Apple"}),canResize:!0,icon:_(Be,{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}),f&&_(Fr,{connection:"vipps",text:O.t("continue_with",{provider:"Vipps"}),canResize:!0,icon:_(Qm,{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})]})]})]})},C$=["Auth0.swift"];function j$(t){if(!t)return"code";const e=atob(t),n=JSON.parse(e);return C$.includes(n.name)?"code":"link"}const O$=new s.OpenAPIHono().openapi(s.createRoute({tags:["login"],method:"get",path:"/",request:{query:s.z.object({state:s.z.string().openapi({description:"The state parameter from the authorization request"}),impersonation:s.z.string().optional()})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,loginSession:r,client:i}=await ke(t,e);return t.html(_(ho,{vendorSettings:n,loginSession:r,client:i,email:r.authParams.username}))}).openapi(s.createRoute({tags:["login"],method:"post",path:"/",request:{query:s.z.object({state:s.z.string().openapi({description:"The state parameter from the authorization request"})}),body:{content:{"application/x-www-form-urlencoded":{schema:s.z.object({username:s.z.string().transform(t=>t.toLowerCase()),login_selection:s.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:o,vendorSettings:a}=await ke(t,n);t.set("client_id",i.id);const{countryCode:c}=jt(t.req),{normalized:d}=mi(r.username,c);if(!d)return t.html(_(ho,{vendorSettings:a,loginSession:o,error:O.t("invalid_identifier"),email:r.username,client:i}),400);const l=await zs({userAdapter:e.data.users,tenant_id:i.tenant.id,email:d});if(l&&t.set("user_id",l.user_id),!l)try{await v2(t,i,t.env.data,d)}catch{const v=we(t,{type:he.FAILED_SIGNUP,description:"Public signup is disabled"});return await t.env.data.logs.create(i.tenant.id,v),t.html(_(ho,{vendorSettings:a,loginSession:o,error:O.t("user_account_does_not_exist"),email:r.username,client:i}),400)}if(o.authParams.username=d,await e.data.loginSessions.update(i.tenant.id,o.id,o),await x$(t,i,r.username,r.login_selection))return t.redirect(`/u/enter-password?state=${n}`);let u=Dn(),f=await e.data.codes.get(i.tenant.id,u,"otp");for(;f;)u=Dn(),f=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:o.id,expires_at:new Date(Date.now()+no).toISOString(),redirect_uri:o.authParams.redirect_uri}),w=j$(o.auth0Client),{connectionType:h}=mi(d),y=i.connections.find(v=>v.strategy===h);if(!y)throw new A(400,{message:O.t("connection_not_found",{connection:h})});return h==="email"&&w==="link"&&y.options.authentication_method==="magic_link"?await Ql(t,{to:d,code:m.code_id,authParams:o.authParams}):await Rm(t,{to:d,code:m.code_id}),t.redirect(`/u/enter-code?state=${n}`)}),bt=t=>_("a",{className:"block text-primary hover:text-primaryHover text-center",href:`/u/login/identifier?state=${t.state}`,children:O.t("go_back")});var yi="_hp",P$={Change:"Input",DoubleClick:"DblClick"},T$={svg:"2000/svg",math:"1998/Math/MathML"},wi=[],Od=new WeakMap,$r=void 0,R$=()=>$r,Lt=t=>"t"in t,Ka={onClick:["click",!1]},ch=t=>{if(!t.startsWith("on"))return;if(Ka[t])return Ka[t];const e=t.match(/^on([A-Z][a-zA-Z]+?(?:PointerCapture)?)(Capture)?$/);if(e){const[,n,r]=e;return Ka[t]=[(P$[n]||n).toLowerCase(),!!r]}},dh=(t,e)=>$r&&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,B$=(t,e,n)=>{var r;e||(e={});for(let i in e){const o=e[i];if(i!=="children"&&(!n||n[i]!==o)){i=gs(i);const a=ch(i);if(a){if((n==null?void 0:n[i])!==o&&(n&&t.removeEventListener(a[0],n[i],a[1]),o!=null)){if(typeof o!="function")throw new Error(`Event handler for "${i}" is not a function`);t.addEventListener(a[0],o,a[1])}}else if(i==="dangerouslySetInnerHTML"&&o)t.innerHTML=o.__html;else if(i==="ref"){let c;typeof o=="function"?c=o(t)||(()=>o(null)):o&&"current"in o&&(o.current=t,c=()=>o.current=null),Od.set(t,c)}else if(i==="style"){const c=t.style;typeof o=="string"?c.cssText=o:(c.cssText="",o!=null&&Hm(o,c.setProperty.bind(c)))}else{if(i==="value"){const d=t.nodeName;if(d==="INPUT"||d==="TEXTAREA"||d==="SELECT"){if(t.value=o==null||o===!1?null:o,d==="TEXTAREA"){t.textContent=o;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]=o);const c=dh(t,i);o==null||o===!1?t.removeAttribute(c):o===!0?t.setAttribute(c,""):typeof o=="string"||typeof o=="number"?t.setAttribute(c,o):t.setAttribute(c,o.toString())}}}if(n)for(let i in n){const o=n[i];if(i!=="children"&&!(i in e)){i=gs(i);const a=ch(i);a?t.removeEventListener(a[0],o,a[1]):i==="ref"?(r=Od.get(t))==null||r():t.removeAttribute(dh(t,i))}}},L$=(t,e)=>{e[Ee][0]=0,wi.push([t,e]);const n=e.tag[nu]||e.tag,r=n.defaultProps?{...n.defaultProps,...e.props}:e.props;try{return[n.call(null,r)]}finally{wi.pop()}},e1=(t,e,n,r,i)=>{var o,a;(o=t.vR)!=null&&o.length&&(r.push(...t.vR),delete t.vR),typeof t.tag=="function"&&((a=t[Ee][1][i1])==null||a.forEach(c=>i.push(c))),t.vC.forEach(c=>{var d;if(Lt(c))n.push(c);else if(typeof c.tag=="function"||c.tag===""){c.c=e;const l=n.length;if(e1(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)})},U$=t=>{for(;;t=t.tag===yi||!t.vC||!t.pP?t.nN:t.vC[0]){if(!t)return null;if(t.tag!==yi&&t.e)return t.e}},t1=t=>{var e,n,r,i,o,a;Lt(t)||((n=(e=t[Ee])==null?void 0:e[1][i1])==null||n.forEach(c=>{var d;return(d=c[2])==null?void 0:d.call(c)}),(r=Od.get(t.e))==null||r(),t.p===2&&((i=t.vC)==null||i.forEach(c=>c.p=2)),(o=t.vC)==null||o.forEach(t1)),t.p||((a=t.e)==null||a.remove(),delete t.e),typeof t.tag=="function"&&(Dr.delete(t),go.delete(t),delete t[Ee][3],t.a=!0)},n1=(t,e,n)=>{t.c=e,r1(t,e,n)},lh=(t,e)=>{if(e){for(let n=0,r=t.length;n<r;n++)if(t[n]===e)return n}},uh=Symbol(),r1=(t,e,n)=>{var l;const r=[],i=[],o=[];e1(t,e,r,i,o),i.forEach(t1);const a=n?void 0:e.childNodes;let c,d=null;if(n)c=-1;else if(!a.length)c=0;else{const u=lh(a,U$(t.nN));u!==void 0?(d=a[u],c=u):c=lh(a,(l=r.find(f=>f.tag!==yi&&f.e))==null?void 0:l.e)??-1,c===-1&&(n=!0)}for(let u=0,f=r.length;u<f;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;Lt(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)),B$(w,m.props,m.pP),r1(m,w,h))}m.tag===yi?c--:n?w.parentNode||e.appendChild(w):a[c]!==w&&a[c-1]!==w&&(a[c+1]===w?e.appendChild(a[c]):e.insertBefore(w,d||a[c]||null))}if(t.pP&&delete t.pP,o.length){const u=[],f=[];o.forEach(([,m,,w,h])=>{m&&u.push(m),w&&f.push(w),h==null||h()}),u.forEach(m=>m()),f.length&&requestAnimationFrame(()=>{f.forEach(m=>m())})}},go=new WeakMap,Pd=(t,e,n)=>{var o,a,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"?L$(t,e):Fi(e.props.children)),((o=n[0])==null?void 0:o.tag)===""&&n[0][Cd]&&(i=n[0][Cd],t[5].push([t,i,e]));const f=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 y=M$(n[h]);if(y){typeof y.tag=="function"&&!y.tag[Mm]&&(br.length>0&&(y[Ee][2]=br.map(b=>[b,b.values.at(-1)])),(a=t[5])!=null&&a.length&&(y[Ee][3]=t[5].at(-1)));let v;if(f&&f.length){const b=f.findIndex(Lt(y)?E=>Lt(E):y.key!==void 0?E=>E.key===y.key&&E.tag===y.tag:E=>E.tag===y.tag);b!==-1&&(v=f[b],f.splice(b,1))}if(v)if(Lt(y))v.t!==y.t&&(v.t=y.t,v.d=!0),y=v;else{const b=v.pP=v.props;v.props=y.props,v.f||(v.f=y.f||e.f),typeof y.tag=="function"&&(v[Ee][2]=y[Ee][2]||[],v[Ee][3]=y[Ee][3],!v.f&&((v.o||v)===y.o||(d=(c=v.tag)[a$])!=null&&d.call(c,b,v.props))&&(v.s=!0)),y=v}else if(!Lt(y)&&$r){const b=Tr($r);b&&(y.n=b)}if(!Lt(y)&&!y.s&&(Pd(t,y),delete y.f),m.push(y),w&&!w.s&&!y.s)for(let b=w;b&&!Lt(b);b=(l=b.vC)==null?void 0:l.at(-1))b.nN=y;w=y}}e.vR=r?[...e.vC,...f||[]]:f||[],e.vC=m,r&&delete e.pC}catch(f){if(e.f=!0,f===uh){if(i)return;throw f}const[m,w,h]=((u=e[Ee])==null?void 0:u[3])||[];if(w){const y=()=>mo([0,!1,t[2]],h),v=go.get(h)||[];v.push(y),go.set(h,v);const b=w(f,()=>{const E=go.get(h);if(E){const C=E.indexOf(y);if(C!==-1)return E.splice(C,1),y()}});if(b){if(t[0]===1)t[1]=!0;else if(Pd(t,h,[b]),(w.length===1||t!==m)&&h.c){n1(h,h.c,!1);return}throw uh}}throw f}finally{i&&t[5].pop()}},M$=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[Ee]=[0,[]];else{const e=T$[t.tag];e&&($r||($r=Dm("")),t.props.children=[{tag:$r,props:{value:t.n=`http://www.w3.org/${e}`,children:t.props.children}}])}return t}},ph=(t,e)=>{var n,r;(n=e[Ee][2])==null||n.forEach(([i,o])=>{i.values.push(o)});try{Pd(t,e,void 0)}catch{return}if(e.a){delete e.a;return}(r=e[Ee][2])==null||r.forEach(([i])=>{i.values.pop()}),(t[0]!==1||!t[1])&&n1(e,e.c,!1)},Dr=new WeakMap,fh=[],mo=async(t,e)=>{t[5]||(t[5]=[]);const n=Dr.get(e);n&&n[0](void 0);let r;const i=new Promise(o=>r=o);if(Dr.set(e,[r,()=>{t[2]?t[2](t,e,o=>{ph(o,e)}).then(()=>r(e)):(ph(t,e),r(e))}]),fh.length)fh.at(-1).add(e);else{await Promise.resolve();const o=Dr.get(e);o&&(Dr.delete(e),o[1]())}return i},F$=(t,e,n)=>({tag:yi,props:{children:t},key:n,e,p:1}),Ga=0,i1=1,Wa=2,Ja=3,Xa=new WeakMap,o1=(t,e)=>!t||!e||t.length!==e.length||e.some((n,r)=>n!==t[r]),D$=void 0,hh=[],V$=t=>{var a;const e=()=>typeof t=="function"?t():t,n=wi.at(-1);if(!n)return[e(),()=>{}];const[,r]=n,i=(a=r[Ee][1])[Ga]||(a[Ga]=[]),o=r[Ee][0]++;return i[o]||(i[o]=[e(),c=>{const d=D$,l=i[o];if(typeof c=="function"&&(c=c(l[0])),!Object.is(c,l[0]))if(l[0]=c,hh.length){const[u,f]=hh.at(-1);Promise.all([u===3?r:mo([u,!1,d],r),f]).then(([m])=>{if(!m||!(u===2||u===3))return;const w=m.vC;requestAnimationFrame(()=>{setTimeout(()=>{w===m.vC&&mo([u===3?1:0,!1,d],m)})})})}else mo([0,!1,d],r)}])},su=(t,e)=>{var c;const n=wi.at(-1);if(!n)return t;const[,r]=n,i=(c=r[Ee][1])[Wa]||(c[Wa]=[]),o=r[Ee][0]++,a=i[o];return o1(a==null?void 0:a[1],e)?i[o]=[t,e]:t=i[o][0],t},q$=t=>{const e=Xa.get(t);if(e){if(e.length===2)throw e[1];return e[0]}throw t.then(n=>Xa.set(t,[n]),n=>Xa.set(t,[void 0,n])),t},H$=(t,e)=>{var c;const n=wi.at(-1);if(!n)return t();const[,r]=n,i=(c=r[Ee][1])[Ja]||(c[Ja]=[]),o=r[Ee][0]++,a=i[o];return o1(a==null?void 0:a[1],e)&&(i[o]=[t(),e]),i[o][0]},K$=Dm({pending:!1,data:null,method:null,action:null}),gh=new Set,G$=t=>{gh.add(t),t.finally(()=>gh.delete(t))},au=(t,e)=>H$(()=>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]),Yn=Object.create(null),Yi=Object.create(null),qi=(t,e,n,r,i)=>{if(e!=null&&e.itemProp)return{tag:t,props:e,type:t,ref:e.ref};const o=document.head;let{onLoad:a,onError:c,precedence:d,blocking:l,...u}=e,f=null,m=!1;const w=uo[t];let h;if(w.length>0){const E=o.querySelectorAll(t);e:for(const C of E)for(const L of uo[t])if(C.getAttribute(L)===e[L]){f=C;break e}if(!f){const C=w.reduce((L,Y)=>e[Y]===void 0?L:`${L}-${Y}-${e[Y]}`,t);m=!Yi[C],f=Yi[C]||(Yi[C]=(()=>{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=o.querySelectorAll(t);d=r?d??"":void 0,r&&(u[po]=d);const y=su(E=>{if(w.length>0){let C=!1;for(const L of o.querySelectorAll(t)){if(C&&L.getAttribute(po)!==d){o.insertBefore(E,L);return}L.getAttribute(po)===d&&(C=!0)}o.appendChild(E)}else if(h){let C=!1;for(const L of h)if(L===E){C=!0;break}C||o.insertBefore(E,o.contains(h[0])?h[0]:o.querySelector(t)),h=void 0}},[d]),v=au(e.ref,E=>{var Y;const C=w[0];if(n===2&&(E.innerHTML=""),(m||h)&&y(E),!c&&!a)return;let L=Yn[Y=E.getAttribute(C)]||(Yn[Y]=new Promise((se,ae)=>{E.addEventListener("load",se),E.addEventListener("error",ae)}));a&&(L=L.then(a)),c&&(L=L.catch(c)),L.catch(()=>{})});if(i&&l==="render"){const E=uo[t][0];if(e[E]){const C=e[E],L=Yn[C]||(Yn[C]=new Promise((Y,se)=>{y(f),f.addEventListener("load",Y),f.addEventListener("error",se)}));q$(L)}}const b={tag:t,type:t,props:{...u,ref:v},ref:v};return b.p=n,f&&(b.e=f),F$(b,o)},W$=t=>{const e=R$(),n=e&&Tr(e);return n!=null&&n.endsWith("svg")?{tag:"title",props:t,type:"title",ref:t.ref}:qi("title",t,void 0,!1,!1)},J$=t=>!t||["src","async"].some(e=>!t[e])?{tag:"script",props:t,type:"script",ref:t.ref}:qi("script",t,1,!1,!0),X$=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,qi("style",t,2,!0,!0)),Z$=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}:qi("link",t,1,"precedence"in t,!0),Y$=t=>qi("meta",t,void 0,!1,!1),s1=Symbol(),Q$=t=>{const{action:e,...n}=t;typeof e!="function"&&(n.action=e);const[r,i]=V$([null,!1]),o=su(async l=>{const u=l.isTrusted?e:l.detail[s1];if(typeof u!="function")return;l.preventDefault();const f=new FormData(l.target);i([f,!0]);const m=u(f);m instanceof Promise&&(G$(m),await m),i([null,!0])},[]),a=au(t.ref,l=>(l.addEventListener("submit",o),()=>{l.removeEventListener("submit",o)})),[c,d]=r;return r[1]=!1,{tag:K$,props:{value:{pending:c!==null,data:c,method:c?"post":null,action:c?e:null},children:{tag:"form",props:{...n,ref:a},type:"form",ref:a}},f:d}},a1=(t,{formAction:e,...n})=>{if(typeof e=="function"){const r=su(i=>{i.preventDefault(),i.currentTarget.form.dispatchEvent(new CustomEvent("submit",{detail:{[s1]:e}}))},[]);n.ref=au(n.ref,i=>(i.addEventListener("click",r),()=>{i.removeEventListener("click",r)}))}return{tag:t,props:n,type:t,ref:n.ref}},e6=t=>a1("input",t),t6=t=>a1("button",t);Object.assign(jd,{title:W$,script:J$,style:X$,link:Z$,meta:Y$,form:Q$,input:e6,button:t6});new TextEncoder;const xa=t=>{const{i18nKey:e,values:n,components:r}=t,i=O.t(e,n),o=/<(\d+)>(.*?)<\/\d+>/g,a=[];let c=0,d;for(;(d=o.exec(i))!==null;){const[,l,u]=d,f=i.substring(c,d.index);f&&a.push(f);const m=parseInt(l,10);a.push($$(r[m],{},u)),c=o.lastIndex}return c<i.length&&a.push(i.substring(c)),_(ou,{children:a})},mh=6,Td=({error:t,vendorSettings:e,email:n,state:r,client:i,hasPasswordLogin:o})=>{const a=new URLSearchParams({state:r}),d=i.connections.map(({name:l})=>l).includes("auth2");return _(De,{title:O.t("verify_your_email"),vendorSettings:e,children:[_("div",{className:"mb-4 text-2xl font-medium",children:O.t("verify_your_email")}),_("div",{className:"mb-8 text-gray-300",children:_(xa,{i18nKey:"code_sent_template",components:[_("span",{className:"text-black dark:text-white"},"span")],values:{username:n}})}),_("div",{className:"flex flex-1 flex-col justify-center",children:[_(tn,{className:"pt-2",children:[_("input",{autoFocus:!0,type:"text",pattern:"[0-9]*",maxLength:mh,inputMode:"numeric",name:"code",placeholder:"******",className:fn("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:mh,required:!0,id:"code-input"}),t&&_(Gn,{children:t}),_(Le,{className:"sm:mt-4 !text-base",children:[_("span",{children:O.t("login")}),_(Be,{className:"text-xs",name:"arrow-right"})]}),_("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[_(Be,{className:"text-base",name:"info-bubble"}),_("div",{className:"text-sm text-gray-300 md:text-sm",children:O.t("sent_code_spam")})]}),d&&_("div",{className:"text-center mb-12",children:[_("div",{className:"relative mb-5 block text-center text-gray-300 dark:text-gray-300",children:[_("div",{className:"absolute left-0 right-0 top-1/2 border-b border-gray-200 dark:border-gray-600"}),_("div",{className:"relative inline-block bg-white px-2 dark:bg-gray-800",children:O.t("or")})]}),_(Le,{Component:"a",href:`/u/${o?"enter-password":"pre-signup"}?${a.toString()}`,variant:"secondary",className:"block",children:O.t("enter_your_password_btn")})]})]}),_(bt,{state:r})]})]})},Ct=t=>{const{message:e,vendorSettings:n,pageTitle:r,state:i}=t;return _(De,{title:"Login",vendorSettings:n,children:[r?_("div",{className:"mb-6 text-gray-300",children:r}):"",_("div",{className:"flex flex-1 flex-col justify-center",children:e}),i?_(bt,{state:i}):""]})},n6=new s.OpenAPIHono().openapi(s.createRoute({tags:["login"],method:"get",path:"/",request:{query:s.z.object({state:s.z.string().openapi({description:"The state"})})},responses:{200:{description:"HTML page to enter verification code.",content:{"text/html":{schema:s.z.string()}}},400:{description:"Bad Request - HTML error page if username is missing in state.",content:{"text/html":{schema:s.z.string()}}},500:{description:"Internal Server Error - HTML error page.",content:{"text/html":{schema:s.z.string()}}}}}),async t=>{const{state:e}=t.req.valid("query");let n,r,i;try{if({vendorSettings:n,loginSession:r,client:i}=await ke(t,e),!r.authParams.username)return t.html(_(Ct,{vendorSettings:n,state:e,pageTitle:O.t("error_page_title")||"Error",message:O.t("username_not_found_error")||"Username not found in session."}),400);const o=await Io({userAdapter:t.env.data.users,tenant_id:i.tenant.id,username:r.authParams.username,provider:"auth2"});return t.html(_(Td,{vendorSettings:n,email:r.authParams.username,state:e,client:i,hasPasswordLogin:!!o}))}catch(o){return console.error("Error in GET /u/enter-code:",o),n||(n={styles:"",disable_signup:!1,disable_connection_signup:!1,domains:[],client:{id:"",tenant:{id:""}}}),t.html(_(Ct,{vendorSettings:n,state:e,pageTitle:O.t("error_page_title")||"Error",message:O.t("unexpected_error_try_again")||"An unexpected error occurred. Please try again."}),500)}}).openapi(s.createRoute({tags:["login"],method:"post",path:"/",request:{query:s.z.object({state:s.z.string().openapi({description:"The state"})}),body:{content:{"application/x-www-form-urlencoded":{schema:s.z.object({code:s.z.string()})}}}},responses:{302:{description:"Redirect to continue authentication flow.",headers:s.z.object({Location:s.z.string().url()})},400:{description:"Bad Request - HTML page with an error message (e.g., invalid code, username missing).",content:{"text/html":{schema:s.z.string()}}},500:{description:"Internal Server Error - HTML error page for unexpected issues.",content:{"text/html":{schema:s.z.string()}}}}}),async t=>{var a;const{state:e}=t.req.valid("query"),{code:n}=t.req.valid("form"),{vendorSettings:r,client:i,loginSession:o}=await ke(t,e);if(!o.authParams.username)throw new A(400,{message:O.t("username_not_found_error")||"Username not found in session."});try{t.set("client_id",i.id);const c=await $a(t,{client_id:i.id,authParams:o.authParams,username:o.authParams.username,otp:n});if(c instanceof Response)return c;throw new A(500,{message:O.t("unexpected_error_try_again")||"An unexpected error occurred. Please try again."})}catch(c){let d;try{d=await Io({userAdapter:t.env.data.users,tenant_id:i.tenant.id,username:o.authParams.username,provider:"auth2"})}catch{d=null}return t.html(_(Td,{vendorSettings:r,email:(a=o.authParams)==null?void 0:a.username,state:e,client:i,error:c.message,hasPasswordLogin:!!d}),400)}}),c1=t=>{const{vendorSettings:e,state:n}=t;return _(De,{title:O.t("unverified_email"),vendorSettings:e,children:[_("div",{className:"flex flex-1 flex-col justify-center",children:[_("p",{className:"mb-8 text-gray-300 text-lg",children:O.t("unverified_email")}),_("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[_(Be,{className:"text-base",name:"info-bubble"}),_("div",{className:"text-sm text-gray-300 md:text-sm",children:O.t("sent_code_spam")})]}),_(bt,{state:n})]}),_(bt,{state:n})]})},r6=({width:t=22,height:e=17})=>_("svg",{width:t,height:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 576 512",children:_("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"})}),i6=({width:t=23,height:e=18})=>_("svg",{width:t,height:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 640 512",children:_("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"})}),Rd=({name:t,placeholder:e=O.t("password")})=>_("div",{className:"password-input relative mb-2",children:[_("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}),_("button",{type:"button","aria-label":O.t("show_password"),title:O.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:_(r6,{})}),_("button",{type:"button","aria-label":O.t("hide_password"),title:O.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:_(i6,{})})]});var _h=Object.freeze,o6=Object.defineProperty,s6=(t,e)=>_h(o6(t,"raw",{value:_h(t.slice())})),yh;const Vr=t=>{const{error:e,vendorSettings:n,email:r,state:i}=t,o=new URLSearchParams({state:i});return _(De,{title:O.t("enter_password"),vendorSettings:n,children:[_("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:O.t("enter_password")}),_("div",{className:"mb-6 text-gray-300",children:O.t("enter_password_description")}),_("div",{className:"flex flex-1 flex-col justify-center",children:[_(tn,{className:"mb-7",children:[_("input",{type:"text",name:"username",placeholder:O.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}),_(Rd,{name:"password"}),e&&_(Gn,{children:e}),_(Le,{className:"sm:mt-4 !text-base",children:[_("span",{children:O.t("login")}),_(Be,{className:"text-xs",name:"arrow-right"})]})]}),_("a",{href:`/u/forgot-password?${o.toString()}`,className:"text-primary hover:underline mb-4",children:O.t("forgot_password_link")}),_("div",{className:"text-center mb-12",children:[_("div",{className:"relative mb-5 block text-center text-gray-300 dark:text-gray-300",children:[_("div",{className:"absolute left-0 right-0 top-1/2 border-b border-gray-200 dark:border-gray-600"}),_("div",{className:"relative inline-block bg-white px-2 dark:bg-gray-800",children:O.t("or")})]}),_("form",{method:"post",action:`/u/login/identifier?${o.toString()}`,children:[_("input",{type:"hidden",name:"login_selection",value:"code"}),_("input",{type:"hidden",name:"username",value:r}),_(Le,{variant:"secondary",className:"block",children:O.t("enter_a_code_btn")})]})]}),_(bt,{state:i})]}),Um(yh||(yh=s6([`
225
225
  <script>
226
226
  // Show password toggle
227
227
  var passwordInputs = document.querySelectorAll(".password-input");
@@ -8194,6 +8194,7 @@ declare const ClientSchema: z.ZodObject<{
8194
8194
  kid: z.ZodOptional<z.ZodString>;
8195
8195
  team_id: z.ZodOptional<z.ZodString>;
8196
8196
  realms: z.ZodOptional<z.ZodString>;
8197
+ authentication_method: z.ZodOptional<z.ZodString>;
8197
8198
  client_id: z.ZodOptional<z.ZodString>;
8198
8199
  client_secret: z.ZodOptional<z.ZodString>;
8199
8200
  app_secret: z.ZodOptional<z.ZodString>;
@@ -8217,6 +8218,7 @@ declare const ClientSchema: z.ZodObject<{
8217
8218
  kid?: string | undefined;
8218
8219
  team_id?: string | undefined;
8219
8220
  realms?: string | undefined;
8221
+ authentication_method?: string | undefined;
8220
8222
  app_secret?: string | undefined;
8221
8223
  authorization_endpoint?: string | undefined;
8222
8224
  token_endpoint?: string | undefined;
@@ -8235,6 +8237,7 @@ declare const ClientSchema: z.ZodObject<{
8235
8237
  kid?: string | undefined;
8236
8238
  team_id?: string | undefined;
8237
8239
  realms?: string | undefined;
8240
+ authentication_method?: string | undefined;
8238
8241
  app_secret?: string | undefined;
8239
8242
  authorization_endpoint?: string | undefined;
8240
8243
  token_endpoint?: string | undefined;
@@ -8258,6 +8261,7 @@ declare const ClientSchema: z.ZodObject<{
8258
8261
  kid?: string | undefined;
8259
8262
  team_id?: string | undefined;
8260
8263
  realms?: string | undefined;
8264
+ authentication_method?: string | undefined;
8261
8265
  app_secret?: string | undefined;
8262
8266
  authorization_endpoint?: string | undefined;
8263
8267
  token_endpoint?: string | undefined;
@@ -8290,6 +8294,7 @@ declare const ClientSchema: z.ZodObject<{
8290
8294
  kid?: string | undefined;
8291
8295
  team_id?: string | undefined;
8292
8296
  realms?: string | undefined;
8297
+ authentication_method?: string | undefined;
8293
8298
  app_secret?: string | undefined;
8294
8299
  authorization_endpoint?: string | undefined;
8295
8300
  token_endpoint?: string | undefined;
@@ -8443,6 +8448,7 @@ declare const ClientSchema: z.ZodObject<{
8443
8448
  kid?: string | undefined;
8444
8449
  team_id?: string | undefined;
8445
8450
  realms?: string | undefined;
8451
+ authentication_method?: string | undefined;
8446
8452
  app_secret?: string | undefined;
8447
8453
  authorization_endpoint?: string | undefined;
8448
8454
  token_endpoint?: string | undefined;
@@ -8522,6 +8528,7 @@ declare const ClientSchema: z.ZodObject<{
8522
8528
  kid?: string | undefined;
8523
8529
  team_id?: string | undefined;
8524
8530
  realms?: string | undefined;
8531
+ authentication_method?: string | undefined;
8525
8532
  app_secret?: string | undefined;
8526
8533
  authorization_endpoint?: string | undefined;
8527
8534
  token_endpoint?: string | undefined;
@@ -8691,6 +8698,7 @@ export declare const connectionOptionsSchema: z.ZodObject<{
8691
8698
  kid: z.ZodOptional<z.ZodString>;
8692
8699
  team_id: z.ZodOptional<z.ZodString>;
8693
8700
  realms: z.ZodOptional<z.ZodString>;
8701
+ authentication_method: z.ZodOptional<z.ZodString>;
8694
8702
  client_id: z.ZodOptional<z.ZodString>;
8695
8703
  client_secret: z.ZodOptional<z.ZodString>;
8696
8704
  app_secret: z.ZodOptional<z.ZodString>;
@@ -8714,6 +8722,7 @@ export declare const connectionOptionsSchema: z.ZodObject<{
8714
8722
  kid?: string | undefined;
8715
8723
  team_id?: string | undefined;
8716
8724
  realms?: string | undefined;
8725
+ authentication_method?: string | undefined;
8717
8726
  app_secret?: string | undefined;
8718
8727
  authorization_endpoint?: string | undefined;
8719
8728
  token_endpoint?: string | undefined;
@@ -8732,6 +8741,7 @@ export declare const connectionOptionsSchema: z.ZodObject<{
8732
8741
  kid?: string | undefined;
8733
8742
  team_id?: string | undefined;
8734
8743
  realms?: string | undefined;
8744
+ authentication_method?: string | undefined;
8735
8745
  app_secret?: string | undefined;
8736
8746
  authorization_endpoint?: string | undefined;
8737
8747
  token_endpoint?: string | undefined;
@@ -8750,6 +8760,7 @@ export declare const connectionInsertSchema: z.ZodObject<{
8750
8760
  kid: z.ZodOptional<z.ZodString>;
8751
8761
  team_id: z.ZodOptional<z.ZodString>;
8752
8762
  realms: z.ZodOptional<z.ZodString>;
8763
+ authentication_method: z.ZodOptional<z.ZodString>;
8753
8764
  client_id: z.ZodOptional<z.ZodString>;
8754
8765
  client_secret: z.ZodOptional<z.ZodString>;
8755
8766
  app_secret: z.ZodOptional<z.ZodString>;
@@ -8773,6 +8784,7 @@ export declare const connectionInsertSchema: z.ZodObject<{
8773
8784
  kid?: string | undefined;
8774
8785
  team_id?: string | undefined;
8775
8786
  realms?: string | undefined;
8787
+ authentication_method?: string | undefined;
8776
8788
  app_secret?: string | undefined;
8777
8789
  authorization_endpoint?: string | undefined;
8778
8790
  token_endpoint?: string | undefined;
@@ -8791,6 +8803,7 @@ export declare const connectionInsertSchema: z.ZodObject<{
8791
8803
  kid?: string | undefined;
8792
8804
  team_id?: string | undefined;
8793
8805
  realms?: string | undefined;
8806
+ authentication_method?: string | undefined;
8794
8807
  app_secret?: string | undefined;
8795
8808
  authorization_endpoint?: string | undefined;
8796
8809
  token_endpoint?: string | undefined;
@@ -8814,6 +8827,7 @@ export declare const connectionInsertSchema: z.ZodObject<{
8814
8827
  kid?: string | undefined;
8815
8828
  team_id?: string | undefined;
8816
8829
  realms?: string | undefined;
8830
+ authentication_method?: string | undefined;
8817
8831
  app_secret?: string | undefined;
8818
8832
  authorization_endpoint?: string | undefined;
8819
8833
  token_endpoint?: string | undefined;
@@ -8842,6 +8856,7 @@ export declare const connectionInsertSchema: z.ZodObject<{
8842
8856
  kid?: string | undefined;
8843
8857
  team_id?: string | undefined;
8844
8858
  realms?: string | undefined;
8859
+ authentication_method?: string | undefined;
8845
8860
  app_secret?: string | undefined;
8846
8861
  authorization_endpoint?: string | undefined;
8847
8862
  token_endpoint?: string | undefined;
@@ -8869,6 +8884,7 @@ export declare const connectionSchema: z.ZodObject<{
8869
8884
  kid: z.ZodOptional<z.ZodString>;
8870
8885
  team_id: z.ZodOptional<z.ZodString>;
8871
8886
  realms: z.ZodOptional<z.ZodString>;
8887
+ authentication_method: z.ZodOptional<z.ZodString>;
8872
8888
  client_id: z.ZodOptional<z.ZodString>;
8873
8889
  client_secret: z.ZodOptional<z.ZodString>;
8874
8890
  app_secret: z.ZodOptional<z.ZodString>;
@@ -8892,6 +8908,7 @@ export declare const connectionSchema: z.ZodObject<{
8892
8908
  kid?: string | undefined;
8893
8909
  team_id?: string | undefined;
8894
8910
  realms?: string | undefined;
8911
+ authentication_method?: string | undefined;
8895
8912
  app_secret?: string | undefined;
8896
8913
  authorization_endpoint?: string | undefined;
8897
8914
  token_endpoint?: string | undefined;
@@ -8910,6 +8927,7 @@ export declare const connectionSchema: z.ZodObject<{
8910
8927
  kid?: string | undefined;
8911
8928
  team_id?: string | undefined;
8912
8929
  realms?: string | undefined;
8930
+ authentication_method?: string | undefined;
8913
8931
  app_secret?: string | undefined;
8914
8932
  authorization_endpoint?: string | undefined;
8915
8933
  token_endpoint?: string | undefined;
@@ -8933,6 +8951,7 @@ export declare const connectionSchema: z.ZodObject<{
8933
8951
  kid?: string | undefined;
8934
8952
  team_id?: string | undefined;
8935
8953
  realms?: string | undefined;
8954
+ authentication_method?: string | undefined;
8936
8955
  app_secret?: string | undefined;
8937
8956
  authorization_endpoint?: string | undefined;
8938
8957
  token_endpoint?: string | undefined;
@@ -8965,6 +8984,7 @@ export declare const connectionSchema: z.ZodObject<{
8965
8984
  kid?: string | undefined;
8966
8985
  team_id?: string | undefined;
8967
8986
  realms?: string | undefined;
8987
+ authentication_method?: string | undefined;
8968
8988
  app_secret?: string | undefined;
8969
8989
  authorization_endpoint?: string | undefined;
8970
8990
  token_endpoint?: string | undefined;
@@ -15147,6 +15167,7 @@ export declare function init(config: AuthHeroConfig): {
15147
15167
  kid?: string | undefined | undefined;
15148
15168
  team_id?: string | undefined | undefined;
15149
15169
  realms?: string | undefined | undefined;
15170
+ authentication_method?: string | undefined | undefined;
15150
15171
  app_secret?: string | undefined | undefined;
15151
15172
  authorization_endpoint?: string | undefined | undefined;
15152
15173
  token_endpoint?: string | undefined | undefined;
@@ -15179,6 +15200,7 @@ export declare function init(config: AuthHeroConfig): {
15179
15200
  kid?: string | undefined | undefined;
15180
15201
  team_id?: string | undefined | undefined;
15181
15202
  realms?: string | undefined | undefined;
15203
+ authentication_method?: string | undefined | undefined;
15182
15204
  app_secret?: string | undefined | undefined;
15183
15205
  authorization_endpoint?: string | undefined | undefined;
15184
15206
  token_endpoint?: string | undefined | undefined;
@@ -15225,6 +15247,7 @@ export declare function init(config: AuthHeroConfig): {
15225
15247
  kid?: string | undefined | undefined;
15226
15248
  team_id?: string | undefined | undefined;
15227
15249
  realms?: string | undefined | undefined;
15250
+ authentication_method?: string | undefined | undefined;
15228
15251
  app_secret?: string | undefined | undefined;
15229
15252
  authorization_endpoint?: string | undefined | undefined;
15230
15253
  token_endpoint?: string | undefined | undefined;
@@ -15288,6 +15311,7 @@ export declare function init(config: AuthHeroConfig): {
15288
15311
  kid?: string | undefined;
15289
15312
  team_id?: string | undefined;
15290
15313
  realms?: string | undefined;
15314
+ authentication_method?: string | undefined;
15291
15315
  app_secret?: string | undefined;
15292
15316
  authorization_endpoint?: string | undefined;
15293
15317
  token_endpoint?: string | undefined;
@@ -15315,6 +15339,7 @@ export declare function init(config: AuthHeroConfig): {
15315
15339
  kid?: string | undefined | undefined;
15316
15340
  team_id?: string | undefined | undefined;
15317
15341
  realms?: string | undefined | undefined;
15342
+ authentication_method?: string | undefined | undefined;
15318
15343
  app_secret?: string | undefined | undefined;
15319
15344
  authorization_endpoint?: string | undefined | undefined;
15320
15345
  token_endpoint?: string | undefined | undefined;
@@ -15358,6 +15383,7 @@ export declare function init(config: AuthHeroConfig): {
15358
15383
  kid?: string | undefined;
15359
15384
  team_id?: string | undefined;
15360
15385
  realms?: string | undefined;
15386
+ authentication_method?: string | undefined;
15361
15387
  app_secret?: string | undefined;
15362
15388
  authorization_endpoint?: string | undefined;
15363
15389
  token_endpoint?: string | undefined;
@@ -15384,6 +15410,7 @@ export declare function init(config: AuthHeroConfig): {
15384
15410
  kid?: string | undefined | undefined;
15385
15411
  team_id?: string | undefined | undefined;
15386
15412
  realms?: string | undefined | undefined;
15413
+ authentication_method?: string | undefined | undefined;
15387
15414
  app_secret?: string | undefined | undefined;
15388
15415
  authorization_endpoint?: string | undefined | undefined;
15389
15416
  token_endpoint?: string | undefined | undefined;
package/dist/authhero.mjs CHANGED
@@ -1760,6 +1760,7 @@ const _s = o.object({
1760
1760
  kid: o.string().optional(),
1761
1761
  team_id: o.string().optional(),
1762
1762
  realms: o.string().optional(),
1763
+ authentication_method: o.string().optional(),
1763
1764
  client_id: o.string().optional(),
1764
1765
  client_secret: o.string().optional(),
1765
1766
  app_secret: o.string().optional(),
@@ -21547,7 +21548,7 @@ function hi(t, e = "US") {
21547
21548
  if (n.includes("@")) {
21548
21549
  const r = n.toLowerCase(), i = /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r);
21549
21550
  return {
21550
- connection: "email",
21551
+ connectionType: "email",
21551
21552
  normalized: i ? r : null,
21552
21553
  isValid: i
21553
21554
  };
@@ -21556,18 +21557,18 @@ function hi(t, e = "US") {
21556
21557
  defaultCountry: e
21557
21558
  });
21558
21559
  return r && r.isValid() ? {
21559
- connection: "sms",
21560
+ connectionType: "sms",
21560
21561
  normalized: r.number,
21561
21562
  // E.164 format
21562
21563
  isValid: !0
21563
21564
  } : {
21564
- connection: "sms",
21565
+ connectionType: "sms",
21565
21566
  normalized: null,
21566
21567
  isValid: !1
21567
21568
  };
21568
21569
  } else
21569
21570
  return {
21570
- connection: "username",
21571
+ connectionType: "username",
21571
21572
  normalized: n,
21572
21573
  isValid: !0
21573
21574
  };
@@ -21584,7 +21585,7 @@ async function ua(t, {
21584
21585
  otp: r,
21585
21586
  authParams: i
21586
21587
  }) {
21587
- const s = jt(t.req), { connection: a, normalized: c } = hi(
21588
+ const s = jt(t.req), { connectionType: a, normalized: c } = hi(
21588
21589
  n,
21589
21590
  s.countryCode
21590
21591
  );
@@ -21935,7 +21936,7 @@ async function im(t, { to: e, code: n }) {
21935
21936
  const r = await t.env.data.tenants.get(t.var.tenant_id);
21936
21937
  if (!r)
21937
21938
  throw new A(500, { message: "Tenant not found" });
21938
- const { connection: i } = hi(e), s = new URL(lt(t.env)), a = {
21939
+ const { connectionType: i } = hi(e), s = new URL(lt(t.env)), a = {
21939
21940
  vendorName: r.name,
21940
21941
  vendorId: r.id,
21941
21942
  loginDomain: s.hostname,
@@ -21980,7 +21981,7 @@ async function Vl(t, { to: e, code: n, authParams: r }) {
21980
21981
  throw new A(500, { message: "Tenant not found" });
21981
21982
  if (!r.redirect_uri)
21982
21983
  throw new A(400, { message: "redirect_uri is required" });
21983
- const { connection: s } = hi(e), a = new URL(Re(t.env));
21984
+ const { connectionType: s } = hi(e), a = new URL(Re(t.env));
21984
21985
  a.pathname = "passwordless/verify_redirect", a.searchParams.set("verification_code", n), a.searchParams.set("connection", s), a.searchParams.set("client_id", r.client_id), a.searchParams.set("redirect_uri", r.redirect_uri), a.searchParams.set("email", e), r.response_type && a.searchParams.set("response_type", r.response_type), r.scope && a.searchParams.set("scope", r.scope), r.state && a.searchParams.set("state", r.state), r.nonce && a.searchParams.set("nonce", r.nonce), r.code_challenge && a.searchParams.set("code_challenge", r.code_challenge), r.code_challenge_method && a.searchParams.set(
21985
21986
  "code_challenge_method",
21986
21987
  r.code_challenge_method
@@ -24197,11 +24198,11 @@ const g$ = new ae().openapi(
24197
24198
  try {
24198
24199
  await Zy(t, i, t.env.data, d);
24199
24200
  } catch {
24200
- const y = be(t, {
24201
+ const v = be(t, {
24201
24202
  type: _e.FAILED_SIGNUP,
24202
24203
  description: "Public signup is disabled"
24203
24204
  });
24204
- return await t.env.data.logs.create(i.tenant.id, y), t.html(
24205
+ return await t.env.data.logs.create(i.tenant.id, v), t.html(
24205
24206
  /* @__PURE__ */ _(
24206
24207
  La,
24207
24208
  {
@@ -24245,8 +24246,17 @@ const g$ = new ae().openapi(
24245
24246
  redirect_uri: s.authParams.redirect_uri
24246
24247
  }), w = h$(
24247
24248
  s.auth0Client
24248
- ), { connection: h } = hi(d);
24249
- return h === "email" && w === "link" && !d.includes("online.no") ? await Vl(t, {
24249
+ ), { connectionType: h } = hi(d), y = i.connections.find(
24250
+ (v) => v.strategy === h
24251
+ );
24252
+ if (!y)
24253
+ throw new A(400, {
24254
+ message: P.t("connection_not_found", {
24255
+ connection: h
24256
+ })
24257
+ });
24258
+ return h === "email" && w === "link" && // This is different to how it works in auth0
24259
+ y.options.authentication_method === "magic_link" ? await Vl(t, {
24250
24260
  to: d,
24251
24261
  code: m.code_id,
24252
24262
  authParams: s.authParams
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "authhero",
3
- "version": "0.153.0",
3
+ "version": "0.154.0",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
@@ -36,7 +36,7 @@
36
36
  "vite": "^5.4.11",
37
37
  "vite-plugin-dts": "^4.3.0",
38
38
  "vitest": "^2.1.5",
39
- "@authhero/kysely-adapter": "^10.19.0"
39
+ "@authhero/kysely-adapter": "^10.20.0"
40
40
  },
41
41
  "dependencies": {
42
42
  "@peculiar/x509": "^1.12.3",
@@ -49,7 +49,7 @@
49
49
  "libphonenumber-js": "^1.12.8",
50
50
  "nanoid": "^5.0.8",
51
51
  "oslo": "^1.2.1",
52
- "@authhero/adapter-interfaces": "^0.70.0"
52
+ "@authhero/adapter-interfaces": "^0.71.0"
53
53
  },
54
54
  "peerDependencies": {
55
55
  "@hono/zod-openapi": "^0.19.2",