@descope/user-profile-widget 0.0.96 → 0.0.98
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/esm/index.js +2 -2
- package/dist/index.d.ts +37 -32
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
/**
|
|
3
|
-
* @descope/user-profile-widget v0.0.
|
|
3
|
+
* @descope/user-profile-widget v0.0.98
|
|
4
4
|
*/
|
|
5
|
-
this["descope-user-profile-widget"]=function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},e.apply(this,arguments)};function t(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(e);i<o.length;i++)t.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(e,o[i])&&(n[o[i]]=e[o[i]])}return n}function n(e,t,n,o){return new(n||(n=Promise))((function(i,r){function s(e){try{c(o.next(e))}catch(e){r(e)}}function a(e){try{c(o.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((o=o.apply(e,t||[])).next())}))}function o(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)}function i(e,t,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(e,n):i?i.value=n:t.set(e,n),n}function r(...e){return t=>e.reduce(((e,t)=>t(e)),t)}"function"==typeof SuppressedError&&SuppressedError;const s=e=>{const t=document.createElement("template");return t.innerHTML=e,t},a=e=>{let t,n;return(...o)=>(t&&((e,t)=>e.length===t.length&&e.every(((e,n)=>e===t[n])))(t,o)||(t=o,n=e(...o)),n)},c=e=>{const t=Symbol((e=>{const t=e.toString();let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n&=n;return n.toString(16)})(e));return n=>{if(n[t])return n;const o=e(n);return o[t]=!0,o}};var l,d,u,h;function f(e,t){const n=Object.getOwnPropertyNames(e),o=Object.getOwnPropertyNames(t);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const i=n[o],r=e[i],s=t[i];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!f(r,s))return!1}else if(r!==s)return!1}return!0}let p=class{constructor(e={},{updateOnlyOnChange:t=!0}={}){l.set(this,void 0),d.set(this,{}),u.set(this,0),h.set(this,!1),this.update=e=>{const t="function"==typeof e?e(o(this,l,"f")):e,n=Object.assign(Object.assign({},o(this,l,"f")),t);if(!o(this,h,"f")||!f(o(this,l,"f"),n)){const e=o(this,l,"f");i(this,l,n,"f"),Object.freeze(o(this,l,"f")),setTimeout((()=>{Object.values(o(this,d,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},i(this,l,e,"f"),i(this,h,t,"f")}get current(){return Object.assign({},o(this,l,"f"))}subscribe(e){return i(this,u,o(this,u,"f")+1,"f"),o(this,d,"f")[o(this,u,"f")]=e,o(this,u,"f").toString()}unsubscribe(e){const t=!!o(this,d,"f")[e];return t&&delete o(this,d,"f")[e],t}unsubscribeAll(){return i(this,d,{},"f"),!0}};function g(e){this.message=e}l=new WeakMap,d=new WeakMap,u=new WeakMap,h=new WeakMap,g.prototype=new Error,g.prototype.name="InvalidCharacterError";var v="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new g("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,o,i=0,r=0,s="";o=t.charAt(r++);~o&&(n=i%4?64*n+o:o,i++%4)?s+=String.fromCharCode(255&n>>(-2*i&6)):0)o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);return s};function m(e){this.message=e}function b(e,t){if("string"!=typeof e)throw new m("Invalid token specified");var n=!0===(t=t||{}).header?0:1;try{return JSON.parse(function(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(v(e).replace(/(.)/g,(function(e,t){var n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return v(t)}}(e.split(".")[n]))}catch(e){throw new m("Invalid token specified: "+e.message)}}m.prototype=new Error,m.prototype.name="InvalidTokenError";var w="/v1/auth/accesskey/exchange",y="/v1/auth/otp/verify",k="/v1/auth/otp/signin",I="/v1/auth/otp/signup",S={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},j="/v1/auth/otp/signup-in",x="/v1/auth/magiclink/verify",C="/v1/auth/magiclink/signin",E="/v1/auth/magiclink/signup",A={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},O="/v1/auth/magiclink/signup-in",U="/v1/auth/enchantedlink/verify",_="/v1/auth/enchantedlink/signin",R="/v1/auth/enchantedlink/signup",T="/v1/auth/enchantedlink/pending-session",M={email:"/v1/auth/enchantedlink/update/email"},L="/v1/auth/enchantedlink/signup-in",P="/v1/auth/oauth/authorize",W="/v1/auth/oauth/exchange",$="v1/auth/oauth/native/start",D="v1/auth/oauth/native/finish",N="/v1/auth/saml/authorize",F="/v1/auth/saml/exchange",q="/v1/auth/totp/verify",z="/v1/auth/totp/signup",B="/v1/auth/totp/update",V="/v1/auth/notp/whatsapp/signin",H="/v1/auth/notp/whatsapp/signup",K="/v1/auth/notp/whatsapp/signup-in",G="/v1/auth/notp/pending-session",J={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},X={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},Y={start:"/v1/auth/webauthn/signup-in/start"},Z={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},Q="/v1/auth/password/signup",ee="/v1/auth/password/signin",te="/v1/auth/password/reset",ne="/v1/auth/password/update",oe="/v1/auth/password/replace",ie="/v1/auth/password/policy",re="/v1/auth/refresh",se="/v1/auth/tenant/select",ae="/v1/auth/logout",ce="/v1/auth/logoutall",le="/v1/auth/me",de="/v1/auth/me/history",ue="/v1/flow/start",he="/v1/flow/next";const fe="<region>",pe=`https://api.${fe}descope.com`,ge=6e5,ve="dct",me=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}};var be;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT",e.patch="PATCH"}(be||(be={}));const we=({path:e,baseUrl:t,queryParams:n,projectId:o})=>{const i=o.slice(1,-27);t=t.replace(fe,i?i+".":"");let r=e?`${t.replace(/\/$/,"")}/${null==e?void 0:e.replace(/^\//,"")}`:t;if(n){r=`${r}?`;const e=Object.keys(n);e.forEach(((t,o)=>{r=`${r}${t}=${n[t]}${o===e.length-1?"":"&"}`}))}return r},ye=(...e)=>new Headers(e.reduce(((e,t)=>{const n=(e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t);return n.reduce(((t,[n,o])=>(e[n]=o,e)),e),e}),{})),ke={"Content-Type":"application/json"},Ie=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},Se=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e},je=({baseUrl:e,projectId:t,baseConfig:n,logger:o,hooks:i,cookiePolicy:r,fetch:s})=>{const a=((e,t)=>{const n=(e=>async(...t)=>{const n=await e(...t),o=await n.text();return n.text=()=>Promise.resolve(o),n.json=()=>Promise.resolve(JSON.parse(o)),n.clone=()=>n,n})(t||fetch);return n||null==e||e.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),e?async(...t)=>{if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");e.log((e=>me().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const o=await n(...t);return e[o.ok?"log":"error"](await(async e=>{const t=await e.text();return me().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(o)),o}:n})(o,s),c=async o=>{var s;const c=(null==i?void 0:i.beforeRequest)?i.beforeRequest(o):o,{path:l,body:d,headers:u,queryParams:h,method:f,token:p}=c,g=(e=>void 0===e?void 0:JSON.stringify(e))(d),v={headers:ye(Ie(t,p),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.24.1"},(null==n?void 0:n.baseHeaders)||{},Se(g)?ke:{},u),method:f,body:g};null!==r&&(v.credentials=r||"include");const m=await a(we({path:l,baseUrl:e,queryParams:h,projectId:t}),v);if((null==i?void 0:i.afterRequest)&&await i.afterRequest(o,null==m?void 0:m.clone()),null==i?void 0:i.transformResponse){const e=await m.json(),t=((null===(s=m.headers)||void 0===s?void 0:s.get("set-cookie"))||"").split(";").reduce(((e,t)=>{const[n,o]=t.split("=");return Object.assign(Object.assign({},e),{[n.trim()]:o})}),{}),n=Object.assign(Object.assign({},m),{json:()=>Promise.resolve(e),cookies:t});return n.clone=()=>n,i.transformResponse(n)}return m};return{get:(e,{headers:t,queryParams:n,token:o}={})=>c({path:e,headers:t,queryParams:n,body:void 0,method:be.get,token:o}),post:(e,t,{headers:n,queryParams:o,token:i}={})=>c({path:e,headers:n,queryParams:o,body:t,method:be.post,token:i}),patch:(e,t,{headers:n,queryParams:o,token:i}={})=>c({path:e,headers:n,queryParams:o,body:t,method:be.patch,token:i}),put:(e,t,{headers:n,queryParams:o,token:i}={})=>c({path:e,headers:n,queryParams:o,body:t,method:be.put,token:i}),delete:(e,{headers:t,queryParams:n,token:o}={})=>c({path:e,headers:t,queryParams:n,body:void 0,method:be.delete,token:o}),hooks:i,buildUrl:(n,o)=>we({projectId:t,baseUrl:e,path:n,queryParams:o})}};var xe=429;function Ce(e,t,n){var o;let i=Ee(e);if(t){if(!(null==i?void 0:i.tenants)&&(null==i?void 0:i[ve])===t)return(null==i?void 0:i[n])||[];i=null===(o=null==i?void 0:i.tenants)||void 0===o?void 0:o[t]}const r=null==i?void 0:i[n];return Array.isArray(r)?r:[]}function Ee(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return b(e)}function Ae(e){const{exp:t}=Ee(e);return(new Date).getTime()/1e3>t}function Oe(e){let t=Ee(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function Ue(e,t){return Ce(e,t,"permissions")}function _e(e,t){return Ce(e,t,"roles")}const Re=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function Te(e,t){var n;const o=await e,i={code:o.status,ok:o.ok,response:o},r=await o.clone().json();return o.ok?i.data=t?t(r):r:(i.error=r,o.status===xe&&Object.assign(i.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),i}const Me=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),Le=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),Pe=e=>t=>e.test(t),We=Pe(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),$e=Pe(/^\+[1-9]{1}[0-9]{3,14}$/),De=Me(We,'"{val}" is not a valid email'),Ne=Me($e,'"{val}" is not a valid phone number'),Fe=Me((e=>e.length>=1),"Minimum length is 1");const qe=Me((e=>"string"==typeof e),"Input is not a string"),ze=Me((e=>void 0===e),"Input is defined"),Be=(Ve=[qe(),ze()],(e="Input is not a string or undefined")=>t=>{const n=Ve.filter((e=>e(t)));return!(n.length<Ve.length)&&(e?e.replace("{val}",t):n.join(" OR "))});var Ve;const He=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>Le(...e).validate(n[t]))),t(...n)),Ke=e=>[qe(`"${e}" must be a string`)],Ge=e=>[qe(`"${e}" must be a string`),Fe(`"${e}" must not be empty`)],Je=e=>[qe(`"${e}" must be a string`),De()],Xe=e=>[qe(`"${e}" must be a string`),Ne()],Ye=He(Ge("accessKey")),Ze=e=>({exchange:Ye(((t,n)=>Te(e.post(w,{loginOptions:n},{token:t}))))}),Qe=(e,t,n)=>(t.forEach((t=>{const o=t.split(".");let i=o.shift(),r=e;for(;o.length>0;){if(r=r[i],!i||!r)throw Error(`Invalid path "${t}", "${i}" is missing or has no value`);i=o.shift()}if("function"!=typeof r[i])throw Error(`"${t}" is not a function`);const s=r[i];r[i]=n(s)})),e),et=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||ge,ge)});var tt,nt;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp"}(tt||(tt={})),function(e){e.email="email"}(nt||(nt={}));const ot=Object.assign(Object.assign({},tt),nt);var it;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(it||(it={}));const rt=Ge("loginId"),st=He(Ge("token")),at=He(rt),ct=He(Ge("pendingRef")),lt=He(rt,Je("email")),dt=e=>({verify:st((t=>Te(e.post(U,{token:t})))),signIn:at(((t,n,o,i)=>Te(e.post(Re(_,ot.email),{loginId:t,URI:n,loginOptions:o},{token:i})))),signUpOrIn:at(((t,n,o)=>Te(e.post(Re(L,ot.email),{loginId:t,URI:n,loginOptions:o})))),signUp:at(((t,n,o,i)=>Te(e.post(Re(R,ot.email),{loginId:t,URI:n,user:o,loginOptions:i})))),waitForSession:ct(((t,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=et(n);let s;const a=setInterval((async()=>{const n=await e.post(T,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(Te(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:lt(((t,n,o,i,r)=>Te(e.post(M.email,Object.assign({loginId:t,email:n,URI:o},r),{token:i}))))}}),ut=He(Ge("flowId")),ht=He(Ge("executionId"),Ge("stepId"),Ge("interactionId")),ft=e=>({start:ut(((t,n,o,i,r,s,a)=>Te(e.post(ue,{flowId:t,options:n,conditionInteractionId:o,interactionId:i,version:r,componentsVersion:s,input:a})))),next:ht(((t,n,o,i,r,s)=>Te(e.post(he,{executionId:t,stepId:n,interactionId:o,version:i,componentsVersion:r,input:s}))))}),pt=Ge("loginId"),gt=He(Ge("token")),vt=He(pt),mt=He(pt,Xe("phone")),bt=He(pt,Je("email")),wt=Object.keys(ot).filter((e=>e!==tt.voice)),yt=e=>({verify:gt((t=>Te(e.post(x,{token:t})))),signIn:wt.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:vt(((t,o,i,r)=>Te(e.post(Re(C,n),{loginId:t,URI:o,loginOptions:i},{token:r}))))})),{}),signUp:wt.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:vt(((t,o,i,r)=>Te(e.post(Re(E,n),{loginId:t,URI:o,user:i,loginOptions:r}))))})),{}),signUpOrIn:wt.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:vt(((t,o,i)=>Te(e.post(Re(O,n),{loginId:t,URI:o,loginOptions:i}))))})),{}),update:{email:bt(((t,n,o,i,r)=>Te(e.post(A.email,Object.assign({loginId:t,email:n,URI:o},r),{token:i})))),phone:Object.keys(tt).filter((e=>e!==tt.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:mt(((t,o,i,r,s)=>Te(e.post(Re(A.phone,n),Object.assign({loginId:t,phone:o,URI:i},s),{token:r}))))})),{})}});var kt;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple",e.discord="discord",e.linkedin="linkedin",e.slack="slack"}(kt||(kt={}));const It=He(Ge("code")),St=e=>({start:Object.assign(((t,n,o,i)=>Te(e.post(P,o||{},{queryParams:Object.assign({provider:t},n&&{redirectURL:n}),token:i}))),Object.keys(kt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,o,i)=>Te(e.post(P,o||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:i}))})),{})),exchange:It((t=>Te(e.post(W,{code:t})))),startNative:(t,n,o)=>Te(e.post($,{provider:t,loginOptions:n,implicit:o})),finishNative:(t,n,o,i,r)=>Te(e.post(D,{provider:t,stateId:n,user:o,code:i,idToken:r}))}),jt=Ge("loginId"),xt=He(jt,Ge("code")),Ct=He(jt),Et=He(jt,Xe("phone")),At=He(jt,Je("email")),Ot=e=>({verify:Object.keys(ot).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:xt(((t,o)=>Te(e.post(Re(y,n),{code:o,loginId:t}))))})),{}),signIn:Object.keys(ot).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ct(((t,o,i)=>Te(e.post(Re(k,n),{loginId:t,loginOptions:o},{token:i}))))})),{}),signUp:Object.keys(ot).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ct(((t,o,i)=>Te(e.post(Re(I,n),{loginId:t,user:o,loginOptions:i}))))})),{}),signUpOrIn:Object.keys(ot).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ct(((t,o)=>Te(e.post(Re(j,n),{loginId:t,loginOptions:o}))))})),{}),update:{email:At(((t,n,o,i)=>Te(e.post(S.email,Object.assign({loginId:t,email:n},i),{token:o})))),phone:Object.keys(tt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Et(((t,o,i,r)=>Te(e.post(Re(S.phone,n),Object.assign({loginId:t,phone:o},r),{token:i}))))})),{})}}),Ut=He(Ge("tenant")),_t=He(Ge("code")),Rt=e=>({start:Ut(((t,n,o,i)=>Te(e.post(N,o||{},{queryParams:{tenant:t,redirectURL:n},token:i})))),exchange:_t((t=>Te(e.post(F,{code:t}))))}),Tt=Ge("loginId"),Mt=He(Tt,Ge("code")),Lt=He(Tt),Pt=He(Tt),Wt=e=>({signUp:Lt(((t,n)=>Te(e.post(z,{loginId:t,user:n})))),verify:Mt(((t,n,o,i)=>Te(e.post(q,{loginId:t,code:n,loginOptions:o},{token:i})))),update:Pt(((t,n)=>Te(e.post(B,{loginId:t},{token:n}))))}),$t=Ge("loginId"),Dt=Ge("newPassword"),Nt=He($t,Ge("password")),Ft=He($t),qt=He($t,Dt),zt=He($t,Ge("oldPassword"),Dt),Bt=e=>({signUp:Nt(((t,n,o,i)=>Te(e.post(Q,{loginId:t,password:n,user:o,loginOptions:i})))),signIn:Nt(((t,n,o)=>Te(e.post(ee,{loginId:t,password:n,loginOptions:o})))),sendReset:Ft(((t,n,o)=>Te(e.post(te,{loginId:t,redirectUrl:n,templateOptions:o})))),update:qt(((t,n,o)=>Te(e.post(ne,{loginId:t,newPassword:n},{token:o})))),replace:zt(((t,n,o)=>Te(e.post(oe,{loginId:t,oldPassword:n,newPassword:o})))),policy:()=>Te(e.get(ie))}),Vt=Ke("loginId"),Ht=Ge("loginId"),Kt=Ge("origin"),Gt=He(Ht,Kt,Ge("name")),Jt=He(Ht,Kt),Xt=He(Vt,Kt),Yt=He(Ht,Kt,Ge("token")),Zt=He(Ge("transactionId"),Ge("response")),Qt=e=>({signUp:{start:Gt(((t,n,o)=>Te(e.post(J.start,{user:{loginId:t,name:o},origin:n})))),finish:Zt(((t,n)=>Te(e.post(J.finish,{transactionId:t,response:n}))))},signIn:{start:Xt(((t,n,o,i)=>Te(e.post(X.start,{loginId:t,origin:n,loginOptions:o},{token:i})))),finish:Zt(((t,n)=>Te(e.post(X.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Jt(((t,n)=>Te(e.post(Y.start,{loginId:t,origin:n}))))},update:{start:Yt(((t,n,o)=>Te(e.post(Z.start,{loginId:t,origin:n},{token:o})))),finish:Zt(((t,n)=>Te(e.post(Z.finish,{transactionId:t,response:n}))))}}),en=Ke("loginId"),tn=He(en),nn=He(Ge("pendingRef")),on=e=>({signUpOrIn:tn(((t,n)=>Te(e.post(K,{loginId:t,loginOptions:n})))),signUp:tn(((t,n,o)=>Te(e.post(H,{loginId:t,user:n,loginOptions:o})))),signIn:tn(((t,n,o)=>Te(e.post(V,{loginId:t,loginOptions:n},{token:o})))),waitForSession:nn(((t,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=et(n);let s;const a=setInterval((async()=>{const n=await e.post(G,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(Te(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),rn=He(Ge("token")),sn=He([Be('"token" must be string or undefined')]);var an,cn=He([(an=Ge("projectId"),Me(((e,t)=>n=>Le(...t).validate(((e,t)=>{const n=(Array.isArray(t)?t.join("."):String(t)).replace(/\[\\?("|')?(\w|d)+\\?("|')?\]/g,((e,t,n)=>"."+n)).split("."),o=n.length;let i=0,r=e===Object(e)?e:void 0;for(;null!=r&&i<o;)r=r[n[i++]];return i&&i===o&&void 0!==r?r:void 0})(n,e)))("projectId",an))())])((e=>{var t;return(({projectId:e,logger:t,baseUrl:n,hooks:o,cookiePolicy:i,baseHeaders:r={},fetch:s})=>{return a=je({baseUrl:n||pe,projectId:e,logger:t,hooks:o,cookiePolicy:i,baseConfig:{baseHeaders:r},fetch:s}),{accessKey:Ze(a),otp:Ot(a),magicLink:yt(a),enchantedLink:dt(a),oauth:St(a),saml:Rt(a),totp:Wt(a),notp:on(a),webauthn:Qt(a),password:Bt(a),flow:ft(a),refresh:sn((e=>Te(a.post(re,{},{token:e})))),selectTenant:He([qe("tenantId")],[Be('"token" must be string or undefined')])(((e,t)=>Te(a.post(se,{tenant:e},{token:t})))),logout:sn((e=>Te(a.post(ae,{},{token:e})))),logoutAll:sn((e=>Te(a.post(ce,{},{token:e})))),me:sn((e=>Te(a.get(le,{token:e})))),history:sn((e=>Te(a.get(de,{token:e})))),isJwtExpired:rn(Ae),getTenants:rn(Oe),getJwtPermissions:rn(Ue),getJwtRoles:rn(_e),httpClient:a};var a})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var n;const o=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==o?void 0:o.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,n)=>{var o;const i=[].concat((null===(o=e.hooks)||void 0===o?void 0:o.afterRequest)||[]);0!=i.length&&(await Promise.allSettled(null==i?void 0:i.map((e=>e(t,null==n?void 0:n.clone()))))).forEach((t=>{var n;return"rejected"===t.status&&(null===(n=e.logger)||void 0===n?void 0:n.error(t.reason))}))},transformResponse:null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}}))})),ln=Object.assign(cn,{DeliveryMethods:ot});
|
|
5
|
+
this["descope-user-profile-widget"]=function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},e.apply(this,arguments)};function t(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(e);i<o.length;i++)t.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(e,o[i])&&(n[o[i]]=e[o[i]])}return n}function n(e,t,n,o){return new(n||(n=Promise))((function(i,r){function s(e){try{c(o.next(e))}catch(e){r(e)}}function a(e){try{c(o.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((o=o.apply(e,t||[])).next())}))}function o(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)}function i(e,t,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(e,n):i?i.value=n:t.set(e,n),n}function r(...e){return t=>e.reduce(((e,t)=>t(e)),t)}"function"==typeof SuppressedError&&SuppressedError;const s=e=>{const t=document.createElement("template");return t.innerHTML=e,t},a=e=>{let t,n;return(...o)=>(t&&((e,t)=>e.length===t.length&&e.every(((e,n)=>e===t[n])))(t,o)||(t=o,n=e(...o)),n)},c=e=>{const t=Symbol((e=>{const t=e.toString();let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n&=n;return n.toString(16)})(e));return n=>{if(n[t])return n;const o=e(n);return o[t]=!0,o}};var l,d,u,h;function f(e,t){const n=Object.getOwnPropertyNames(e),o=Object.getOwnPropertyNames(t);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const i=n[o],r=e[i],s=t[i];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!f(r,s))return!1}else if(r!==s)return!1}return!0}let p=class{constructor(e={},{updateOnlyOnChange:t=!0}={}){l.set(this,void 0),d.set(this,{}),u.set(this,0),h.set(this,!1),this.update=e=>{const t="function"==typeof e?e(o(this,l,"f")):e,n=Object.assign(Object.assign({},o(this,l,"f")),t);if(!o(this,h,"f")||!f(o(this,l,"f"),n)){const e=o(this,l,"f");i(this,l,n,"f"),Object.freeze(o(this,l,"f")),setTimeout((()=>{Object.values(o(this,d,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},i(this,l,e,"f"),i(this,h,t,"f")}get current(){return Object.assign({},o(this,l,"f"))}subscribe(e){return i(this,u,o(this,u,"f")+1,"f"),o(this,d,"f")[o(this,u,"f")]=e,o(this,u,"f").toString()}unsubscribe(e){const t=!!o(this,d,"f")[e];return t&&delete o(this,d,"f")[e],t}unsubscribeAll(){return i(this,d,{},"f"),!0}};function g(e){this.message=e}l=new WeakMap,d=new WeakMap,u=new WeakMap,h=new WeakMap,g.prototype=new Error,g.prototype.name="InvalidCharacterError";var v="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new g("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,o,i=0,r=0,s="";o=t.charAt(r++);~o&&(n=i%4?64*n+o:o,i++%4)?s+=String.fromCharCode(255&n>>(-2*i&6)):0)o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);return s};function m(e){this.message=e}function b(e,t){if("string"!=typeof e)throw new m("Invalid token specified");var n=!0===(t=t||{}).header?0:1;try{return JSON.parse(function(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(v(e).replace(/(.)/g,(function(e,t){var n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return v(t)}}(e.split(".")[n]))}catch(e){throw new m("Invalid token specified: "+e.message)}}m.prototype=new Error,m.prototype.name="InvalidTokenError";var w="/v1/auth/accesskey/exchange",y="/v1/auth/otp/verify",k="/v1/auth/otp/signin",I="/v1/auth/otp/signup",S={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},j="/v1/auth/otp/signup-in",x="/v1/auth/magiclink/verify",C="/v1/auth/magiclink/signin",A="/v1/auth/magiclink/signup",E={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},O="/v1/auth/magiclink/signup-in",U="/v1/auth/enchantedlink/verify",_="/v1/auth/enchantedlink/signin",R="/v1/auth/enchantedlink/signup",T="/v1/auth/enchantedlink/pending-session",M={email:"/v1/auth/enchantedlink/update/email"},L="/v1/auth/enchantedlink/signup-in",P="/v1/auth/oauth/authorize",W="/v1/auth/oauth/exchange",$="v1/auth/oauth/native/start",D="v1/auth/oauth/native/finish",N="/v1/auth/saml/authorize",F="/v1/auth/saml/exchange",q="/v1/auth/totp/verify",z="/v1/auth/totp/signup",B="/v1/auth/totp/update",V="/v1/auth/notp/whatsapp/signin",H="/v1/auth/notp/whatsapp/signup",K="/v1/auth/notp/whatsapp/signup-in",G="/v1/auth/notp/pending-session",J={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},X={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},Y={start:"/v1/auth/webauthn/signup-in/start"},Z={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},Q="/v1/auth/password/signup",ee="/v1/auth/password/signin",te="/v1/auth/password/reset",ne="/v1/auth/password/update",oe="/v1/auth/password/replace",ie="/v1/auth/password/policy",re="/v1/auth/refresh",se="/v1/auth/tenant/select",ae="/v1/auth/logout",ce="/v1/auth/logoutall",le="/v1/auth/me",de="/v1/auth/me/history",ue="/v1/flow/start",he="/v1/flow/next";const fe="<region>",pe=`https://api.${fe}descope.com`,ge=6e5,ve="dct",me=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}};var be;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT",e.patch="PATCH"}(be||(be={}));const we=({path:e,baseUrl:t,queryParams:n,projectId:o})=>{const i=o.slice(1,-27);t=t.replace(fe,i?i+".":"");let r=e?`${t.replace(/\/$/,"")}/${null==e?void 0:e.replace(/^\//,"")}`:t;if(n){r=`${r}?`;const e=Object.keys(n);e.forEach(((t,o)=>{r=`${r}${t}=${n[t]}${o===e.length-1?"":"&"}`}))}return r},ye=(...e)=>new Headers(e.reduce(((e,t)=>{const n=(e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t);return n.reduce(((t,[n,o])=>(e[n]=o,e)),e),e}),{})),ke={"Content-Type":"application/json"},Ie=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},Se=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e},je=({baseUrl:e,projectId:t,baseConfig:n,logger:o,hooks:i,cookiePolicy:r,fetch:s})=>{const a=((e,t)=>{const n=(e=>async(...t)=>{const n=await e(...t),o=await n.text();return n.text=()=>Promise.resolve(o),n.json=()=>Promise.resolve(JSON.parse(o)),n.clone=()=>n,n})(t||fetch);return n||null==e||e.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),e?async(...t)=>{if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");e.log((e=>me().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const o=await n(...t);return e[o.ok?"log":"error"](await(async e=>{const t=await e.text();return me().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).build()})(o)),o}:n})(o,s),c=async o=>{var s;const c=(null==i?void 0:i.beforeRequest)?i.beforeRequest(o):o,{path:l,body:d,headers:u,queryParams:h,method:f,token:p}=c,g=(e=>void 0===e?void 0:JSON.stringify(e))(d),v={headers:ye(Ie(t,p),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.24.2"},(null==n?void 0:n.baseHeaders)||{},Se(g)?ke:{},u),method:f,body:g};null!==r&&(v.credentials=r||"include");const m=await a(we({path:l,baseUrl:e,queryParams:h,projectId:t}),v);if((null==i?void 0:i.afterRequest)&&await i.afterRequest(o,null==m?void 0:m.clone()),null==i?void 0:i.transformResponse){const e=await m.json(),t=((null===(s=m.headers)||void 0===s?void 0:s.get("set-cookie"))||"").split(";").reduce(((e,t)=>{const[n,o]=t.split("=");return Object.assign(Object.assign({},e),{[n.trim()]:o})}),{}),n=Object.assign(Object.assign({},m),{json:()=>Promise.resolve(e),cookies:t});return n.clone=()=>n,i.transformResponse(n)}return m};return{get:(e,{headers:t,queryParams:n,token:o}={})=>c({path:e,headers:t,queryParams:n,body:void 0,method:be.get,token:o}),post:(e,t,{headers:n,queryParams:o,token:i}={})=>c({path:e,headers:n,queryParams:o,body:t,method:be.post,token:i}),patch:(e,t,{headers:n,queryParams:o,token:i}={})=>c({path:e,headers:n,queryParams:o,body:t,method:be.patch,token:i}),put:(e,t,{headers:n,queryParams:o,token:i}={})=>c({path:e,headers:n,queryParams:o,body:t,method:be.put,token:i}),delete:(e,{headers:t,queryParams:n,token:o}={})=>c({path:e,headers:t,queryParams:n,body:void 0,method:be.delete,token:o}),hooks:i,buildUrl:(n,o)=>we({projectId:t,baseUrl:e,path:n,queryParams:o})}};var xe=429;function Ce(e,t,n){var o;let i=Ae(e);if(t){if(!(null==i?void 0:i.tenants)&&(null==i?void 0:i[ve])===t)return(null==i?void 0:i[n])||[];i=null===(o=null==i?void 0:i.tenants)||void 0===o?void 0:o[t]}const r=null==i?void 0:i[n];return Array.isArray(r)?r:[]}function Ae(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return b(e)}function Ee(e){const{exp:t}=Ae(e);return(new Date).getTime()/1e3>t}function Oe(e){let t=Ae(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function Ue(e,t){return Ce(e,t,"permissions")}function _e(e,t){return Ce(e,t,"roles")}const Re=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function Te(e,t){var n;const o=await e,i={code:o.status,ok:o.ok,response:o},r=await o.clone().json();return o.ok?i.data=t?t(r):r:(i.error=r,o.status===xe&&Object.assign(i.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),i}const Me=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),Le=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),Pe=e=>t=>e.test(t),We=Pe(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),$e=Pe(/^\+[1-9]{1}[0-9]{3,14}$/),De=Me(We,'"{val}" is not a valid email'),Ne=Me($e,'"{val}" is not a valid phone number'),Fe=Me((e=>e.length>=1),"Minimum length is 1");const qe=Me((e=>"string"==typeof e),"Input is not a string"),ze=Me((e=>void 0===e),"Input is defined"),Be=(Ve=[qe(),ze()],(e="Input is not a string or undefined")=>t=>{const n=Ve.filter((e=>e(t)));return!(n.length<Ve.length)&&(e?e.replace("{val}",t):n.join(" OR "))});var Ve;const He=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>Le(...e).validate(n[t]))),t(...n)),Ke=e=>[qe(`"${e}" must be a string`)],Ge=e=>[qe(`"${e}" must be a string`),Fe(`"${e}" must not be empty`)],Je=e=>[qe(`"${e}" must be a string`),De()],Xe=e=>[qe(`"${e}" must be a string`),Ne()],Ye=He(Ge("accessKey")),Ze=e=>({exchange:Ye(((t,n)=>Te(e.post(w,{loginOptions:n},{token:t}))))}),Qe=(e,t,n)=>(t.forEach((t=>{const o=t.split(".");let i=o.shift(),r=e;for(;o.length>0;){if(r=r[i],!i||!r)throw Error(`Invalid path "${t}", "${i}" is missing or has no value`);i=o.shift()}if("function"!=typeof r[i])throw Error(`"${t}" is not a function`);const s=r[i];r[i]=n(s)})),e),et=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||ge,ge)});var tt,nt;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp"}(tt||(tt={})),function(e){e.email="email"}(nt||(nt={}));const ot=Object.assign(Object.assign({},tt),nt);var it;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(it||(it={}));const rt=Ge("loginId"),st=He(Ge("token")),at=He(rt),ct=He(Ge("pendingRef")),lt=He(rt,Je("email")),dt=e=>({verify:st((t=>Te(e.post(U,{token:t})))),signIn:at(((t,n,o,i)=>Te(e.post(Re(_,ot.email),{loginId:t,URI:n,loginOptions:o},{token:i})))),signUpOrIn:at(((t,n,o)=>Te(e.post(Re(L,ot.email),{loginId:t,URI:n,loginOptions:o})))),signUp:at(((t,n,o,i)=>Te(e.post(Re(R,ot.email),{loginId:t,URI:n,user:o,loginOptions:i})))),waitForSession:ct(((t,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=et(n);let s;const a=setInterval((async()=>{const n=await e.post(T,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(Te(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:lt(((t,n,o,i,r)=>Te(e.post(M.email,Object.assign({loginId:t,email:n,URI:o},r),{token:i}))))}}),ut=He(Ge("flowId")),ht=He(Ge("executionId"),Ge("stepId"),Ge("interactionId")),ft=e=>({start:ut(((t,n,o,i,r,s,a)=>Te(e.post(ue,{flowId:t,options:n,conditionInteractionId:o,interactionId:i,version:r,componentsVersion:s,input:a})))),next:ht(((t,n,o,i,r,s)=>Te(e.post(he,{executionId:t,stepId:n,interactionId:o,version:i,componentsVersion:r,input:s}))))}),pt=Ge("loginId"),gt=He(Ge("token")),vt=He(pt),mt=He(pt,Xe("phone")),bt=He(pt,Je("email")),wt=Object.keys(ot).filter((e=>e!==tt.voice)),yt=e=>({verify:gt((t=>Te(e.post(x,{token:t})))),signIn:wt.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:vt(((t,o,i,r)=>Te(e.post(Re(C,n),{loginId:t,URI:o,loginOptions:i},{token:r}))))})),{}),signUp:wt.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:vt(((t,o,i,r)=>Te(e.post(Re(A,n),{loginId:t,URI:o,user:i,loginOptions:r}))))})),{}),signUpOrIn:wt.reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:vt(((t,o,i)=>Te(e.post(Re(O,n),{loginId:t,URI:o,loginOptions:i}))))})),{}),update:{email:bt(((t,n,o,i,r)=>Te(e.post(E.email,Object.assign({loginId:t,email:n,URI:o},r),{token:i})))),phone:Object.keys(tt).filter((e=>e!==tt.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:mt(((t,o,i,r,s)=>Te(e.post(Re(E.phone,n),Object.assign({loginId:t,phone:o,URI:i},s),{token:r}))))})),{})}});var kt;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple",e.discord="discord",e.linkedin="linkedin",e.slack="slack"}(kt||(kt={}));const It=He(Ge("code")),St=e=>({start:Object.assign(((t,n,o,i)=>Te(e.post(P,o||{},{queryParams:Object.assign({provider:t},n&&{redirectURL:n}),token:i}))),Object.keys(kt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,o,i)=>Te(e.post(P,o||{},{queryParams:Object.assign({provider:n},t&&{redirectURL:t}),token:i}))})),{})),exchange:It((t=>Te(e.post(W,{code:t})))),startNative:(t,n,o)=>Te(e.post($,{provider:t,loginOptions:n,implicit:o})),finishNative:(t,n,o,i,r)=>Te(e.post(D,{provider:t,stateId:n,user:o,code:i,idToken:r}))}),jt=Ge("loginId"),xt=He(jt,Ge("code")),Ct=He(jt),At=He(jt,Xe("phone")),Et=He(jt,Je("email")),Ot=e=>({verify:Object.keys(ot).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:xt(((t,o)=>Te(e.post(Re(y,n),{code:o,loginId:t}))))})),{}),signIn:Object.keys(ot).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ct(((t,o,i)=>Te(e.post(Re(k,n),{loginId:t,loginOptions:o},{token:i}))))})),{}),signUp:Object.keys(ot).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ct(((t,o,i)=>Te(e.post(Re(I,n),{loginId:t,user:o,loginOptions:i}))))})),{}),signUpOrIn:Object.keys(ot).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ct(((t,o)=>Te(e.post(Re(j,n),{loginId:t,loginOptions:o}))))})),{}),update:{email:Et(((t,n,o,i)=>Te(e.post(S.email,Object.assign({loginId:t,email:n},i),{token:o})))),phone:Object.keys(tt).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:At(((t,o,i,r)=>Te(e.post(Re(S.phone,n),Object.assign({loginId:t,phone:o},r),{token:i}))))})),{})}}),Ut=He(Ge("tenant")),_t=He(Ge("code")),Rt=e=>({start:Ut(((t,n,o,i)=>Te(e.post(N,o||{},{queryParams:{tenant:t,redirectURL:n},token:i})))),exchange:_t((t=>Te(e.post(F,{code:t}))))}),Tt=Ge("loginId"),Mt=He(Tt,Ge("code")),Lt=He(Tt),Pt=He(Tt),Wt=e=>({signUp:Lt(((t,n)=>Te(e.post(z,{loginId:t,user:n})))),verify:Mt(((t,n,o,i)=>Te(e.post(q,{loginId:t,code:n,loginOptions:o},{token:i})))),update:Pt(((t,n)=>Te(e.post(B,{loginId:t},{token:n}))))}),$t=Ge("loginId"),Dt=Ge("newPassword"),Nt=He($t,Ge("password")),Ft=He($t),qt=He($t,Dt),zt=He($t,Ge("oldPassword"),Dt),Bt=e=>({signUp:Nt(((t,n,o,i)=>Te(e.post(Q,{loginId:t,password:n,user:o,loginOptions:i})))),signIn:Nt(((t,n,o)=>Te(e.post(ee,{loginId:t,password:n,loginOptions:o})))),sendReset:Ft(((t,n,o)=>Te(e.post(te,{loginId:t,redirectUrl:n,templateOptions:o})))),update:qt(((t,n,o)=>Te(e.post(ne,{loginId:t,newPassword:n},{token:o})))),replace:zt(((t,n,o)=>Te(e.post(oe,{loginId:t,oldPassword:n,newPassword:o})))),policy:()=>Te(e.get(ie))}),Vt=Ke("loginId"),Ht=Ge("loginId"),Kt=Ge("origin"),Gt=He(Ht,Kt,Ge("name")),Jt=He(Ht,Kt),Xt=He(Vt,Kt),Yt=He(Ht,Kt,Ge("token")),Zt=He(Ge("transactionId"),Ge("response")),Qt=e=>({signUp:{start:Gt(((t,n,o)=>Te(e.post(J.start,{user:{loginId:t,name:o},origin:n})))),finish:Zt(((t,n)=>Te(e.post(J.finish,{transactionId:t,response:n}))))},signIn:{start:Xt(((t,n,o,i)=>Te(e.post(X.start,{loginId:t,origin:n,loginOptions:o},{token:i})))),finish:Zt(((t,n)=>Te(e.post(X.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Jt(((t,n)=>Te(e.post(Y.start,{loginId:t,origin:n}))))},update:{start:Yt(((t,n,o)=>Te(e.post(Z.start,{loginId:t,origin:n},{token:o})))),finish:Zt(((t,n)=>Te(e.post(Z.finish,{transactionId:t,response:n}))))}}),en=Ke("loginId"),tn=He(en),nn=He(Ge("pendingRef")),on=e=>({signUpOrIn:tn(((t,n)=>Te(e.post(K,{loginId:t,loginOptions:n})))),signUp:tn(((t,n,o)=>Te(e.post(H,{loginId:t,user:n,loginOptions:o})))),signIn:tn(((t,n,o)=>Te(e.post(V,{loginId:t,loginOptions:n},{token:o})))),waitForSession:nn(((t,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=et(n);let s;const a=setInterval((async()=>{const n=await e.post(G,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(Te(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),rn=He(Ge("token")),sn=He([Be('"token" must be string or undefined')]);var an,cn=He([(an=Ge("projectId"),Me(((e,t)=>n=>Le(...t).validate(((e,t)=>{const n=(Array.isArray(t)?t.join("."):String(t)).replace(/\[\\?("|')?(\w|d)+\\?("|')?\]/g,((e,t,n)=>"."+n)).split("."),o=n.length;let i=0,r=e===Object(e)?e:void 0;for(;null!=r&&i<o;)r=r[n[i++]];return i&&i===o&&void 0!==r?r:void 0})(n,e)))("projectId",an))())])((e=>{var t;return(({projectId:e,logger:t,baseUrl:n,hooks:o,cookiePolicy:i,baseHeaders:r={},fetch:s})=>{return a=je({baseUrl:n||pe,projectId:e,logger:t,hooks:o,cookiePolicy:i,baseConfig:{baseHeaders:r},fetch:s}),{accessKey:Ze(a),otp:Ot(a),magicLink:yt(a),enchantedLink:dt(a),oauth:St(a),saml:Rt(a),totp:Wt(a),notp:on(a),webauthn:Qt(a),password:Bt(a),flow:ft(a),refresh:sn((e=>Te(a.post(re,{},{token:e})))),selectTenant:He([qe("tenantId")],[Be('"token" must be string or undefined')])(((e,t)=>Te(a.post(se,{tenant:e},{token:t})))),logout:sn((e=>Te(a.post(ae,{},{token:e})))),logoutAll:sn((e=>Te(a.post(ce,{},{token:e})))),me:sn((e=>Te(a.get(le,{token:e})))),history:sn((e=>Te(a.get(de,{token:e})))),isJwtExpired:rn(Ee),getTenants:rn(Oe),getJwtPermissions:rn(Ue),getJwtRoles:rn(_e),httpClient:a};var a})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var n;const o=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==o?void 0:o.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,n)=>{var o;const i=[].concat((null===(o=e.hooks)||void 0===o?void 0:o.afterRequest)||[]);0!=i.length&&(await Promise.allSettled(null==i?void 0:i.map((e=>e(t,null==n?void 0:n.clone()))))).forEach((t=>{var n;return"rejected"===t.status&&(null===(n=e.logger)||void 0===n?void 0:n.error(t.reason))}))},transformResponse:null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}}))})),ln=Object.assign(cn,{DeliveryMethods:ot});
|
|
6
6
|
/*! js-cookie v3.0.5 | MIT */
|
|
7
|
-
function dn(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)e[o]=n[o]}return e}var un=function e(t,n){function o(e,o,i){if("undefined"!=typeof document){"number"==typeof(i=dn({},n,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var r="";for(var s in i)i[s]&&(r+="; "+s,!0!==i[s]&&(r+="="+i[s].split(";")[0]));return document.cookie=e+"="+t.write(o,e)+r}}return Object.create({set:o,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],o={},i=0;i<n.length;i++){var r=n[i].split("="),s=r.slice(1).join("=");try{var a=decodeURIComponent(r[0]);if(o[a]=t.read(s,a),e===a)break}catch(e){}}return e?o[e]:o}},remove:function(e,t){o(e,"",dn({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,dn({},this.attributes,t))},withConverter:function(t){return e(dn({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(t)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"});var hn={default:"endpoint"},fn="Blocked by CSP",pn="The endpoint parameter is not a valid URL",gn="Failed to load the JS script of the agent",vn="9319";function mn(e,t){var n,o,i,r,s=[],a=(n=function(e){var t=function(e,t,n){if(n||2===arguments.length)for(var o,i=0,r=t.length;i<r;i++)!o&&i in t||(o||(o=Array.prototype.slice.call(t,0,i)),o[i]=t[i]);return e.concat(o||Array.prototype.slice.call(t))}([],e,!0);return{current:function(){return t[0]},postpone:function(){var e=t.shift();void 0!==e&&t.push(e)},exclude:function(){t.shift()}}}(e),r=0,o=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,r++))},i=new Set,[n.current(),function(e,t){var r,s=t instanceof Error?t.message:"";if(s===fn||s===pn)n.exclude(),r=0;else if(s===vn)n.exclude();else if(s===gn){var a=Date.now()-e.getTime()<50,c=n.current();c&&a&&!i.has(c)&&(i.add(c),r=0),n.postpone()}else n.postpone();var l=n.current();return void 0===l?void 0:[l,null!=r?r:e.getTime()+o()-Date.now()]}]),c=a[0],l=a[1];if(void 0===c)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var d=function(e){var n=new Date,o=function(t){return s.push({url:e,startedAt:n,finishedAt:new Date,error:t})},i=t(e);return i.then((function(){return o()}),o),i.catch((function(e){if(s.length>=5)throw e;var t=l(n,e);if(!t)throw e;var o,i=t[0],r=t[1];return(o=r,new Promise((function(e){return setTimeout(e,o)}))).then((function(){return d(i)}))}))};return d(c).then((function(e){return[e,s]}))}var bn="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",wn=bn;function yn(n){var o;n.scriptUrlPattern;var i=n.token,r=n.apiKey,s=void 0===r?i:r,a=t(n,["scriptUrlPattern","token","apiKey"]),c=null!==(o=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(n,"scriptUrlPattern"))&&void 0!==o?o:bn,l=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},n=function(e,t,n,o){return e.addEventListener(t,n,o),function(){return e.removeEventListener(t,n,o)}}(document,"visibilitychange",t);return t(),[e,n]}(),d=l[0],u=l[1];return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error("API key required");var e=function(e,t){return(Array.isArray(e)?e:[e]).map((function(e){return function(e,t){var n=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?n(t):"<loaderVersion>"===e?n("3.9.9"):e}))}(String(e),t)}))}(c,s);return mn(e,kn)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===vn?new Error(gn):e}(e)})).then((function(t){var n=t[0],o=t[1];return u(),n.load(e(e({},a),{ldi:{attempts:o,visibilityStates:d}}))}))}function kn(e){return function(e,t,n,o){var i,r=document,s="securitypolicyviolation",a=function(t){var n=new URL(e,location.href),o=t.blockedURI;o!==n.href&&o!==n.protocol.slice(0,-1)&&o!==n.origin||(i=t,c())};r.addEventListener(s,a);var c=function(){return r.removeEventListener(s,a)};return null==o||o.then(c,c),Promise.resolve().then(t).then((function(e){return c(),e}),(function(e){return new Promise((function(e){var t=new MessageChannel;t.port1.onmessage=function(){return e()},t.port2.postMessage(null)})).then((function(){if(c(),i)return n(i);throw e}))}))}(e,(function(){return function(e){return new Promise((function(t,n){if(function(e){if(URL.prototype)try{return new URL(e,location.href),!1}catch(e){if(e instanceof Error&&"TypeError"===e.name)return!0;throw e}}(e))throw new Error(pn);var o=document.createElement("script"),i=function(){var e;return null===(e=o.parentNode)||void 0===e?void 0:e.removeChild(o)},r=document.head||document.getElementsByTagName("head")[0];o.onload=function(){i(),t()},o.onerror=function(){i(),n(new Error(gn))},o.async=!0,o.src=e,r.appendChild(o)}))}(e)}),(function(){throw new Error(fn)})).then(In)}function In(){var e=window,t="__fpjs_p_l_b",n=e[t];if(function(e,t){var n,o=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==o?void 0:o.configurable)?delete e[t]:o&&!o.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error(vn);return n}const Sn=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,o)=>{var i;return n[o]=[].concat((null===(i=e.hooks)||void 0===i?void 0:i[o])||[]).concat((null==t?void 0:t[o])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},jn=async e=>{if(!(null==e?void 0:e.ok))return{};const t=await(null==e?void 0:e.clone().json());return(null==t?void 0:t.authInfo)||t||{}},xn=async e=>{const t=await jn(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)},Cn="undefined"!=typeof localStorage,En=(e,t)=>Cn&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(e,t)),An=e=>Cn&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(e)),On=e=>Cn&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(e)),Un=(...e)=>{console.debug(...e)},_n="undefined"!=typeof window,Rn=Math.pow(2,31)-1,Tn="DS",Mn="DSR";function Ln(e=""){return An(`${e}${Mn}`)||""}function Pn(e=""){On(`${e}${Mn}`),On(`${e}${Tn}`),un.remove(Tn)}const Wn=_n&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",$n="fp",Dn=(e=!1)=>{const t=localStorage.getItem($n);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},Nn=async(e,t=Wn)=>{try{if(Dn())return;const n=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const i=new URL(t);i.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const r=i.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=yn({apiKey:e,endpoint:[o.toString(),hn],scriptUrlPattern:[r,wn]}),a=await s,{requestId:c}=await a.get({linkedId:n}),l=((e,t)=>({vsid:e,vrid:t}))(n,c);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};localStorage.setItem($n,JSON.stringify(t))})(l)}catch(e){console.warn("Could not load fingerprint",e)}},Fn=e=>{const t=Dn(!0);return t&&e.body&&(e.body.fpData=t),e},qn="dls_last_user_login_id",zn="dls_last_user_display_name",Bn=()=>An(qn),Vn=()=>An(zn),Hn=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,o={}]=t,i=Bn(),r=Vn();return i&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=i,o.lastAuth.name=r),await e(...t)};function Kn(){const e=[];return{pub:t=>{e.forEach((e=>e(t)))},sub:t=>{const n=e.push(t)-1;return()=>e.splice(n,1)}}}async function Gn(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=eo(n.publicKey.challenge),n.publicKey.user.id=eo(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=eo(e.id)})),n}(e);return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:to(n.rawId),type:n.type,response:{attestationObject:to(n.response.attestationObject),clientDataJSON:to(n.response.clientDataJSON)}});var n}async function Jn(e){const t=Zn(e);return Qn(await navigator.credentials.get(t))}async function Xn(e,t){const n=Zn(e);return n.signal=t.signal,n.mediation="conditional",Qn(await navigator.credentials.get(n))}async function Yn(e=!1){if(!_n)return Promise.resolve(!1);const t=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return t&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():t}function Zn(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=eo(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=eo(e.id)})),n}function Qn(e){return JSON.stringify({id:e.id,rawId:to(e.rawId),type:e.type,response:{authenticatorData:to(e.response.authenticatorData),clientDataJSON:to(e.response.clientDataJSON),signature:to(e.response.signature),userHandle:e.response.userHandle?to(e.response.userHandle):void 0}})}function eo(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function to(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var no,oo=(no=e=>({async signUp(t,n){const o=await e.webauthn.signUp.start(t,window.location.origin,n);if(!o.ok)return o;const i=await Gn(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,i)},async signIn(t){const n=await e.webauthn.signIn.start(t,window.location.origin);if(!n.ok)return n;const o=await Jn(n.data.options);return await e.webauthn.signIn.finish(n.data.transactionId,o)},async signUpOrIn(t){var n;const o=await e.webauthn.signUpOrIn.start(t,window.location.origin);if(!o.ok)return o;if(null===(n=o.data)||void 0===n?void 0:n.create){const t=await Gn(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,t)}{const t=await Jn(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,t)}},async update(t,n){const o=await e.webauthn.update.start(t,window.location.origin,n);if(!o.ok)return o;const i=await Gn(o.data.options);return await e.webauthn.update.finish(o.data.transactionId,i)},helpers:{create:Gn,get:Jn,isSupported:Yn,conditional:Xn}}),(...e)=>{const t=no(...e);return Object.assign(t.signUp,e[0].webauthn.signUp),Object.assign(t.signIn,e[0].webauthn.signIn),Object.assign(t.signUpOrIn,e[0].webauthn.signUpOrIn),Object.assign(t.update,e[0].webauthn.update),t});const io="/fedcm/config",ro=(e,t)=>({async oneTap(t,n,o,i){const r=null!=t?t:"google",s=await e.oauth.startNative(r,o,!0);if(!s.ok)return s;const{clientId:a,stateId:c,nonce:l}=s.data,d=await async function(){return new Promise(((e,t)=>{if(window.google)return void e(window.google.accounts.id);let n=document.getElementById("google-gsi-client-script");n||(n=document.createElement("script"),document.head.appendChild(n),n.async=!0,n.defer=!0,n.id="google-gsi-client-script",n.src="https://accounts.google.com/gsi/client"),n.onload=function(){window.google?e(window.google.accounts.id):t("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){t("Failed to load Google GSI client script - failed to load")}}))}();return new Promise((t=>{var o,s;d.initialize(Object.assign(Object.assign({},n),{itp_support:null===(o=null==n?void 0:n.itp_support)||void 0===o||o,use_fedcm_for_prompt:null===(s=null==n?void 0:n.use_fedcm_for_prompt)||void 0===s||s,client_id:a,callback:n=>{t(e.oauth.finishNative(r,c,"","",n.credential))},nonce:l})),d.prompt((e=>{(null==e?void 0:e.isSkippedMoment())&&(null==i||i())}))}))},async launch(n){var o;const i={identity:{context:n||"signin",providers:[{configURL:e.httpClient.buildUrl(t+io),clientId:t}]}},r=await(null===(o=navigator.credentials)||void 0===o?void 0:o.get(i));return e.refresh(r.token)},isSupported:()=>_n&&"IdentityCredential"in window});var so=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await Yn(),o=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=o,e.flow.start(...t)}});const ao=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>n=>{var{fpKey:o,fpLoad:i}=n,r=t(n,["fpKey","fpLoad"]);return _n?(o&&i&&Nn(o).catch((()=>null)),e(Sn(r,{beforeRequest:Fn}))):e(r)}),(e=>n=>{var{autoRefresh:o}=n,i=t(n,["autoRefresh"]);if(!o)return e(i);const{clearAllTimers:r,setTimer:s}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let a,c;_n&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&new Date>a&&(Un("Expiration time passed, refreshing session"),l.refresh(Ln()||c))}));const l=e(Sn(i,{afterRequest:async(e,t)=>{const{refreshJwt:n,sessionJwt:o}=await jn(t);if(401===(null==t?void 0:t.status))Un("Received 401, canceling all timers"),r();else if(o){if(a=(e=>{try{const t=b(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(o),!a)return void Un("Could not extract expiration time from session token");c=n;let e=((i=a)?i.getTime()-(new Date).getTime():0)-2e4;e>Rn&&(Un(`Timeout is too large (${e}ms), setting it to ${Rn}ms`),e=Rn),r();const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});Un(`Setting refresh timer for ${t}. (${e}ms)`),s((()=>{Un("Refreshing session due to timer"),l.refresh(Ln()||n)}),e)}var i}}));return Qe(l,["logout","logoutAll"],(e=>async(...t)=>{const n=await e(...t);return Un("Clearing all timers"),r(),n}))}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.16.1"},t.baseHeaders)}))),(e=>t=>{const n=Kn(),o=Kn(),i=e(Sn(t,{afterRequest:async(e,t)=>{if(401===(null==t?void 0:t.status))n.pub(null),o.pub(null);else{const e=await xn(t);e&&o.pub(e);const{sessionJwt:i}=await jn(t);i&&n.pub(i)}}})),r=Qe(i,["logout","logoutAll"],(e=>async(...t)=>{const i=await e(...t);return n.pub(null),o.pub(null),i}));return Object.assign(r,{onSessionTokenChange:n.sub,onUserChange:o.sub})}),(e=>n=>{var{storeLastAuthenticatedUser:o=!0,keepLastAuthenticatedUserAfterLogout:i=!1}=n,r=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!o)return Object.assign(e(r),{getLastUserLoginId:Bn,getLastUserDisplayName:Vn});const s=e(Sn(r,{afterRequest:async(e,t)=>{var n;const o=await xn(t),i=null===(n=null==o?void 0:o.loginIds)||void 0===n?void 0:n[0],r=null==o?void 0:o.name;i&&((e=>{En(qn,e)})(i),(e=>{En(zn,e)})(r))}}));let a=Qe(s,["flow.start"],Hn);return a=Qe(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const o=await t(...n);return e||(On(qn),On(zn)),o})(i)),Object.assign(a,{getLastUserLoginId:Bn,getLastUserDisplayName:Vn})}),(e=>n=>{var{persistTokens:o,sessionTokenViaCookie:i,storagePrefix:r}=n,s=t(n,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!o||!_n)return e(s);const a=e(Sn(s,{beforeRequest:(c=r,e=>Object.assign(e,{token:e.token||Ln(c)})),afterRequest:async(e,n)=>{const o=/^\/v\d+\/mgmt\//.test(e.path);401===(null==n?void 0:n.status)?o||Pn(r):((e={},n,o)=>{var{refreshJwt:i,sessionJwt:r}=e,s=t(e,["refreshJwt","sessionJwt"]);void 0===n&&(n=!1),void 0===o&&(o=""),i&&En(`${o}${Mn}`,i),r&&(n?function(e,t,{cookiePath:n,cookieDomain:o,cookieExpiration:i}){if(t){const r=new Date(1e3*i),s=function(e){const t=window.location.hostname.split("."),n=e.split(".");return t.slice(-n.length).join(".")===e}(o);un.set(e,t,{path:n,domain:s?o:void 0,expires:r,sameSite:"Strict",secure:!0})}}(Tn,r,s):En(`${o}${Tn}`,r))})(await jn(n),i,r)}}));var c;const l=Qe(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const o=await t(...n);return Pn(e),o})(r));return Object.assign(l,{getRefreshToken:()=>Ln(r),getSessionToken:()=>function(e=""){return un.get(Tn)||An(`${e}${Tn}`)||""}(r)})}))(((...e)=>{const t=ln(...e);return Object.assign(Object.assign({},t),{flow:so(t),webauthn:oo(t),fedcm:ro(t,e[0].projectId)})})),co="undefined"!=typeof localStorage,lo=co&&localStorage.getItem("base.content.url")||"",uo="config.json",ho="base.ui.components.url",fo=co&&localStorage.getItem(ho)||"https://static.descope.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",po=co&&localStorage.getItem(ho)||"https://cdn.jsdelivr.net/npm/@descope/web-components-ui@<version>/dist/umd/index.js",go="descope-login-flow",vo="code",mo="ra-challenge",bo="ra-callback",wo="ra-backup-callback",yo="ra-initiator",ko="data-exclude-field",Io="dls_last_auth",So="state_id",jo="saml_idp_state_id",xo="saml_idp_username",Co="descope_idp_initiated",Eo="sso_app_id",Ao="oidc_login_hint",Oo="oidc_prompt",Uo="oidc_error_redirect_uri",_o="data-type",Ro="poll",To="webauthnCreate",Mo="submit",Lo="polling",Po=["descope-multi-select-combo-box","descope-text-area"];var Wo;function $o(e){return new URLSearchParams(window.location.search).get(e)}function Do(e){if(window.history.replaceState&&$o(e)){const t=new URL(window.location.href),n=new URLSearchParams(t.search);n.delete(e),t.search=n.toString(),window.history.replaceState({},"",t.toString())}}function No(e,t){return n(this,void 0,void 0,(function*(){const n=yield fetch(e,{cache:"default"});if(!n.ok)throw Error(`Error fetching URL ${e} [${n.status}]`);return{body:yield n[t||"text"](),headers:Object.fromEntries(n.headers.entries())}}))}function Fo({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:o}){const i=new URL(lo||o||"https://static.descope.com/pages");return i.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(i.pathname,e,n,t),i.toString()}function qo(e,t){if(!t)return;const n=+e,o=+t;return Number.isNaN(n)||Number.isNaN(o)?void 0:n>o?Wo.forward:n<o?Wo.backward:void 0}!function(e){e.backward="backward",e.forward="forward"}(Wo||(Wo={}));const zo=()=>{const[e="",t=""]=($o(go)||"").split("_");return{executionId:e,stepId:t}};function Bo(){Do(go)}const Vo=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),Ho=e=>{let t,n;return(...o)=>{return t&&(r=o,(i=t).length===r.length&&i.every(((e,t)=>e===r[t])))||(t=o,n=e(...o)),n;var i,r}},Ko=(e,{oidcIdpStateId:t,samlIdpStateId:n,samlIdpUsername:o,ssoAppId:i,oidcLoginHint:r,oidcPrompt:s,oidcErrorRedirectUri:a})=>!(!e||t||n||o||i||r||s||a),Go=e=>null==e?void 0:e.submit(),Jo=(e,t)=>{const n=t.find((t=>e[t]));return n?e[n]:null},Xo=(e,t=100)=>{let n;return function(...o){n||e.apply(this,o),clearTimeout(n),n=setTimeout((()=>{n=null}),t)}};function Yo(e){let t=navigator.language;return t&&"zh-TW"!==t&&(t=t.split("-")[0]),(e||t||"").toLowerCase()}var Zo,Qo,ei,ti;function ni(e,t){const n=Object.getOwnPropertyNames(e),o=Object.getOwnPropertyNames(t);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const i=n[o],r=e[i],s=t[i];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!ni(r,s))return!1}else if(r!==s)return!1}return!0}class oi{constructor(e={},{updateOnlyOnChange:t=!0}={}){Zo.set(this,void 0),Qo.set(this,{}),ei.set(this,0),ti.set(this,!1),this.update=e=>{const t="function"==typeof e?e(o(this,Zo,"f")):e,n=Object.assign(Object.assign({},o(this,Zo,"f")),t);if(!o(this,ti,"f")||!ni(o(this,Zo,"f"),n)){const e=o(this,Zo,"f");i(this,Zo,n,"f"),Object.freeze(o(this,Zo,"f")),setTimeout((()=>{Object.values(o(this,Qo,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},i(this,Zo,e,"f"),i(this,ti,t,"f")}get current(){return Object.assign({},o(this,Zo,"f"))}subscribe(e){return i(this,ei,o(this,ei,"f")+1,"f"),o(this,Qo,"f")[o(this,ei,"f")]=e,o(this,ei,"f").toString()}unsubscribe(e){const t=!!o(this,Qo,"f")[e];return t&&delete o(this,Qo,"f")[e],t}unsubscribeAll(){return i(this,Qo,{},"f"),!0}}Zo=new WeakMap,Qo=new WeakMap,ei=new WeakMap,ti=new WeakMap;const ii=["disabled"],ri=(e,t)=>{Object.entries(t||{}).forEach((([t,n])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${ko}])`)).forEach((e=>{e.value=n}))}))},si=(e,t)=>e.replace(/{{(.+?)}}/g,((e,n)=>{return o=t,n.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),o);var o})),ai=(e,t,n)=>{e.querySelectorAll(`[${_o}="${t}"]`).forEach((e=>{e.setAttribute("href",n)}))},ci=(e,t,n)=>{var o,i;const r=null===(o=customElements.get(t))||void 0===o?void 0:o.cssVarList.url;n&&r&&(null===(i=null==e?void 0:e.style)||void 0===i||i.setProperty(r,`url(data:image/jpg;base64,${n})`))},li=Ho((()=>n(void 0,void 0,void 0,(function*(){var e,t,n,o;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const i=Promise.all([null===(e=window.PublicKeyCredential)||void 0===e?void 0:e.isConditionalMediationAvailable(),null===(t=window.PublicKeyCredential)||void 0===t?void 0:t.isUserVerifyingPlatformAuthenticatorAvailable()]).then((e=>e.every((e=>!!e)))),r=(()=>{var e;const t=null===(e=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===e?void 0:e.brands,n=null==t?void 0:t.find((({brand:e,version:t})=>"Chromium"===e&&parseFloat(t)));return n?n.version:0})()>=108;return yield(n=i,o=r,new Promise(((e,t)=>{let i=!1;const r=setTimeout((()=>{i=!0,void 0!==o?e(o):t(new Error("Promise timed out after 100 ms"))}),100);n.then((t=>{i||(clearTimeout(r),e(t))})).catch((e=>{i||(clearTimeout(r),t(e))}))})))}catch(e){return console.error("Conditional login check failed",e),!1}})))),di={"lastAuth.loginId":{"not-empty":e=>!!e.loginId,empty:e=>!e.loginId},idpInitiated:{"is-true":e=>!!e.code,"is-false":e=>!e.code},externalToken:{"is-true":e=>!!e.token,"is-false":e=>!e.token},abTestingKey:{"greater-than":(e,t)=>(e.abTestingKey||0)>t,"less-than":(e,t)=>(e.abTestingKey||0)<t}};function ui(e){const t={};if(e)try{Object.assign(t,JSON.parse(localStorage.getItem(Io)))}catch(e){}return t}const hi="dls_ab_testing_id",fi=document.createElement("template");fi.innerHTML='\n\t<style>\n\t\t:host {\n all: initial;\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n display: block;\n\t\t}\n\n\t\t#wc-root {\n\t\t\theight: 100%;\n\t\t\ttransition: opacity 300ms ease-in-out;\n display: flex;\n\t\t}\n\n\t\t#wc-root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1;\n\t\t}\n\n\t</style>\n\t<div id="wc-root"></div>\n\t';const pi=(e,t="")=>Object.keys(e).reduce(((n,o)=>{var i;if("object"==typeof e[o]&&null!==e[o]&&!(null===(i=e[o])||void 0===i?void 0:i.value))return Object.assign(Object.assign({},n),pi(e[o],`${t+o}.`));const r="object"==typeof e[o]?e[o]:{value:e[o]},s=Object.assign(Object.assign({},n),{[t+o]:r,[`form.${t}${o}`]:r});return"displayName"===o?Object.assign(Object.assign({},s),{[`${t}fullName`]:r,[`form.${t}fullName`]:r}):s}),[]);var gi,vi,mi,bi,wi,yi,ki,Ii,Si,ji,xi,Ci,Ei,Ai,Oi,Ui,_i,Ri,Ti,Mi,Li,Pi,Wi,$i,Di,Ni,Fi,qi,zi,Bi,Vi,Hi,Ki,Gi,Ji,Xi,Yi,Zi,Qi,er,tr,nr,or,ir,rr,sr,ar,cr,lr,dr,ur,hr,fr;class pr extends HTMLElement{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","theme","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","keep-last-authenticated-user-after-logout","validate-on-blur"]}constructor(e){super(),gi.add(this),this.logger=console,mi.set(this,!1),this.loggerWrapper={error:(e,t="")=>{this.logger.error(e,t,new Error),o(this,gi,"m",zi).call(this,e,t)},warn:(e,t="")=>{this.logger.warn(e,t)},info:(e,t="",n={})=>{this.logger.info(e,t,n)},debug:(e,t="")=>{this.logger.debug(e,t)}},bi.set(this,new oi),wi.set(this,new oi),yi.set(this,{}),this.getComponentsContext=()=>o(this,yi,"f"),this.nextRequestStatus=new oi({isLoading:!1}),ki.set(this,void 0),Ii.set(this,{popstate:o(this,gi,"m",Ai).bind(this),componentsContext:o(this,gi,"m",Di).bind(this)}),Si.set(this,void 0),Ti.set(this,Ho((()=>n(this,void 0,void 0,(function*(){const e=Fo({projectId:this.projectId,filename:uo,baseUrl:this.baseStaticUrl});try{const{body:t,headers:n}=yield No(e,"json");return{projectConfig:t,executionContext:{geo:n["x-geo"]}}}catch(e){return{isMissingConfig:!0}}}))))),Li.set(this,void 0),i(this,Si,e,"f"),o(this,gi,"m",ji).call(this)}get projectId(){return this.getAttribute("project-id")}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(e){return{}}}get baseUrl(){return this.getAttribute("base-url")||void 0}get baseStaticUrl(){return this.getAttribute("base-static-url")}get tenant(){return this.getAttribute("tenant")||void 0}get redirectUrl(){return this.getAttribute("redirect-url")||void 0}get debug(){return"true"===this.getAttribute("debug")}get locale(){return this.getAttribute("locale")||void 0}get theme(){var e,t;const n=this.getAttribute("theme");return"os"===n?window.matchMedia&&(null===(t=null===(e=window.matchMedia)||void 0===e?void 0:e.call(window,"(prefers-color-scheme: dark)"))||void 0===t?void 0:t.matches)?"dark":"light":n||"light"}get autoFocus(){var e;const t=null!==(e=this.getAttribute("auto-focus"))&&void 0!==e?e:"true";return"skipFirstScreen"===t?t:"true"===t}get validateOnBlur(){return"true"===this.getAttribute("validate-on-blur")}get storeLastAuthenticatedUser(){var e;return"true"===(null!==(e=this.getAttribute("store-last-authenticated-user"))&&void 0!==e?e:"true")}get keepLastAuthenticatedUserAfterLogout(){return"true"===this.getAttribute("keep-last-authenticated-user-after-logout")}get storagePrefix(){return this.getAttribute("storage-prefix")||""}get preview(){return!!this.getAttribute("preview")}get formConfig(){return(e=>{try{return pi(JSON.parse(e))}catch(e){return{}}})(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return e=this.formConfig,Object.fromEntries(Object.entries(e).map((([e,t])=>[e,t.value])));var e}getExecutionContext(){return n(this,void 0,void 0,(function*(){const{executionContext:e}=yield o(this,Ti,"f").call(this);return e}))}getProjectConfig(){return n(this,void 0,void 0,(function*(){const{projectConfig:e}=yield o(this,Ti,"f").call(this);return e}))}getFlowConfig(){return n(this,void 0,void 0,(function*(){var e,t;const n=yield this.getProjectConfig(),o=(null===(e=null==n?void 0:n.flows)||void 0===e?void 0:e[this.flowId])||{};return null!==(t=o.version)&&void 0!==t||(o.version=0),o}))}getTargetLocales(){return n(this,void 0,void 0,(function*(){const e=yield this.getFlowConfig();return((null==e?void 0:e.targetLocales)||[]).map((e=>e.toLowerCase()))}))}connectedCallback(){return n(this,void 0,void 0,(function*(){if(this.shadowRoot.isConnected){if(o(this,wi,"f").subscribe(o(this,gi,"m",qi).bind(this)),o(this,wi,"f").update({isDebug:this.debug}),o(this,gi,"m",xi).call(this))return void o(this,gi,"m",Ci).call(this);if(o(this,gi,"m",Ei).call(this),i(this,Li,o(this,gi,"m",Mi).call(this),"f"),yield o(this,gi,"m",_i).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");if((yield o(this,Ti,"f").call(this)).isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");o(this,gi,"m",Pi).call(this),yield o(this,gi,"m",Hi).call(this),yield o(this,gi,"m",Wi).call(this),o(this,gi,"m",Bi).call(this);const{executionId:e,stepId:t,token:n,code:r,exchangeError:s,redirectAuthCallbackUrl:a,redirectAuthBackupCallbackUri:c,redirectAuthCodeChallenge:l,redirectAuthInitiator:d,ssoQueryParams:u}=(()=>{const{executionId:e,stepId:t}=zo();(e||t)&&Bo();const n=$o("t")||void 0;n&&Do("t");const o=$o(vo)||void 0;o&&Do(vo);const i=$o("err")||void 0;i&&Do("err");const{redirectAuthCodeChallenge:r,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:c}={redirectAuthCodeChallenge:$o(mo),redirectAuthCallbackUrl:$o(bo),redirectAuthBackupCallbackUri:$o(wo),redirectAuthInitiator:$o(yo)};(r||s||a||c)&&(Do(mo),Do(bo),Do(wo),Do(yo));const l=$o(So);l&&Do(So);const d=$o(jo);d&&Do(jo);const u=$o(xo);d&&Do(xo);const h=$o(Co);h&&Do(Co);const f=$o(Eo);f&&Do(Eo);const p=$o(Ao);p&&Do(Ao);const g=$o(Oo);g&&Do(Oo);const v=$o(Uo);return v&&Do(Uo),{executionId:e,stepId:t,token:n,code:o,exchangeError:i,redirectAuthCodeChallenge:r,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:c,ssoQueryParams:{oidcIdpStateId:l,samlIdpStateId:d,samlIdpUsername:u,descopeIdpInitiated:"true"===h,ssoAppId:f,oidcLoginHint:p,oidcPrompt:g,oidcErrorRedirectUri:v}}})();window.addEventListener("popstate",o(this,Ii,"f").popstate),window.addEventListener("components-context",o(this,Ii,"f").componentsContext),o(this,bi,"f").subscribe(o(this,gi,"m",Ui).bind(this)),o(this,bi,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenant,redirectUrl:this.redirectUrl,locale:this.locale,stepId:t,executionId:e,token:n,code:r,exchangeError:s,redirectAuthCallbackUrl:a,redirectAuthBackupCallbackUri:c,redirectAuthCodeChallenge:l,redirectAuthInitiator:d},u)),i(this,mi,!0,"f")}}))}disconnectedCallback(){o(this,bi,"f").unsubscribeAll(),o(this,wi,"f").unsubscribeAll(),o(this,gi,"m",Fi).call(this),window.removeEventListener("popstate",o(this,Ii,"f").popstate),window.removeEventListener("components-context",o(this,Ii,"f").componentsContext)}attributeChangedCallback(e,t,n){if(this.shadowRoot.isConnected&&o(this,mi,"f")&&t!==n&&vi.observedAttributes.includes(e)){o(this,gi,"m",Ei).call(this);const i=null===t;o(this,bi,"f").update((({stepId:t,executionId:o})=>{let r=t,s=o;return i||(s=null,r=null,Bo()),{[Vo(e)]:n,stepId:r,executionId:s}})),o(this,wi,"f").update({isDebug:this.debug}),"theme"===e&&o(this,gi,"m",Ni).call(this)}}}function gr(e,t){return`sdkScriptsResults.${t?`${e}_${t}`:e}`}vi=pr,mi=new WeakMap,bi=new WeakMap,wi=new WeakMap,yi=new WeakMap,ki=new WeakMap,Ii=new WeakMap,Si=new WeakMap,Ti=new WeakMap,Li=new WeakMap,gi=new WeakSet,ji=function(){this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(fi.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#wc-root")},xi=function(){return!this.shadowRoot.host.closest("form")&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)},Ci=function(){const e=this.shadowRoot.host,t=document.createElement("form");t.style.width="100%",t.style.height="100%",e.parentElement.appendChild(t),t.appendChild(e)},Ei=function(){const e=["base-url","tenant","theme","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur"];if(vi.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[Vo(t)])throw Error(`${t} cannot be empty`)})),this.theme&&"light"!==this.theme&&"dark"!==this.theme)throw Error('Supported theme values are "light", "dark", or leave empty for using the OS theme')},Ai=function(){const{stepId:e,executionId:t}=zo();o(this,bi,"f").update({stepId:e,executionId:t})},Oi=function(e,t){this.sdk=ao(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout},vi.sdkConfigOverrides),{projectId:e,baseUrl:t})),["start","next"].forEach((e=>{const t=this.sdk.flow[e];this.sdk.flow[e]=(...e)=>n(this,void 0,void 0,(function*(){this.nextRequestStatus.update({isLoading:!0});try{return yield t(...e)}catch(e){return{error:{errorCode:"J151000",errorDescription:e.toString()}}}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},Ui=function(e,t,i){return n(this,void 0,void 0,(function*(){const{projectId:t,baseUrl:n}=e;if(i("projectId")||i("baseUrl")){if(!t)return;o(this,gi,"m",Oi).call(this,t,n)}o(this,Si,"f").call(this,e)}))},_i=function(){return n(this,void 0,void 0,(function*(){return(yield o(this,Ti,"f").call(this)).isMissingConfig&&(yield o(this,gi,"m",Ri).call(this))}))},Ri=function(){return n(this,void 0,void 0,(function*(){const e=Fo({projectId:this.projectId,filename:uo,assetsFolder:"v2-alpha",baseUrl:this.baseStaticUrl});try{return yield No(e,"json"),!0}catch(e){return!1}}))},Mi=function(){return n(this,void 0,void 0,(function*(){const e=Fo({projectId:this.projectId,filename:"theme.json",baseUrl:this.baseStaticUrl});try{const{body:t}=yield No(e,"json");return t}catch(e){return void this.loggerWrapper.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}}))},Pi=function(){return n(this,void 0,void 0,(function*(){var e,t;const{projectConfig:n}=yield o(this,Ti,"f").call(this),i=null===(t=null===(e=null==n?void 0:n.cssTemplate)||void 0===e?void 0:e[this.theme])||void 0===t?void 0:t.fonts;i&&Object.values(i).forEach((e=>(e=>{if(!e)return;const t=document.createElement("link");t.href=e,t.rel="stylesheet",document.head.appendChild(t)})(e.url)))}))},Wi=function(){return n(this,void 0,void 0,(function*(){yield o(this,gi,"m",$i).call(this),yield o(this,gi,"m",Ni).call(this)}))},$i=function(){return n(this,void 0,void 0,(function*(){var e,t,n,i;const r=document.createElement("style"),s=yield o(this,Li,"f");r.innerText=((null===(e=null==s?void 0:s.light)||void 0===e?void 0:e.globals)||"")+((null===(t=null==s?void 0:s.dark)||void 0===t?void 0:t.globals)||"");const a=yield vi.descopeUI;(null==a?void 0:a.componentsThemeManager)&&!a.componentsThemeManager.hasThemes&&(a.componentsThemeManager.themes={light:null===(n=null==s?void 0:s.light)||void 0===n?void 0:n.components,dark:null===(i=null==s?void 0:s.dark)||void 0===i?void 0:i.components}),this.shadowRoot.appendChild(r)}))},Di=function(e){i(this,yi,Object.assign(Object.assign({},o(this,yi,"f")),e.detail),"f")},Ni=function(){return n(this,void 0,void 0,(function*(){this.rootElement.setAttribute("data-theme",this.theme);const e=yield vi.descopeUI;(null==e?void 0:e.componentsThemeManager)&&(e.componentsThemeManager.currentThemeName=this.theme)}))},Fi=function(){var e;null===(e=o(this,ki,"f"))||void 0===e||e.remove(),i(this,ki,null,"f")},qi=function(e){return n(this,arguments,void 0,(function*({isDebug:e}){e?(i(this,ki,document.createElement("descope-debugger"),"f"),Object.assign(o(this,ki,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return ul})),document.body.appendChild(o(this,ki,"f"))):o(this,gi,"m",Fi).call(this)}))},zi=function(e,t){var n;e&&this.debug&&(null===(n=o(this,ki,"f"))||void 0===n||n.updateData({title:e,description:t}))},Bi=function(){this.rootElement.onkeydown=e=>{var t,n,o;const i=!!(null===(t=this.shadowRoot.activeElement)||void 0===t?void 0:t.getAttribute("href")),r=Po.includes(null!==(o=null===(n=this.shadowRoot.activeElement)||void 0===n?void 0:n.localName)&&void 0!==o?o:"");if("Enter"!==e.key||i||r)return;e.preventDefault();const s=this.rootElement.querySelectorAll("descope-button");if(1===s.length&&"false"!==s[0].getAttribute("auto-submit"))return void s[0].click();const a=Array.from(s).filter((e=>"true"===e.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const c=Array.from(s).filter((e=>"button"===e.getAttribute("data-type")));if(1===c.length)"false"!==c[0].getAttribute("auto-submit")&&c[0].click();else if(0===c.length){const e=Array.from(s).filter((e=>"sso"===e.getAttribute("data-type")));1===e.length&&"false"!==e[0].getAttribute("auto-submit")&&e[0].click()}}},Vi=function(){return n(this,void 0,void 0,(function*(){var e,t;return(null===(t=null===(e=yield o(this,Ti,"f").call(this))||void 0===e?void 0:e.projectConfig)||void 0===t?void 0:t.componentsVersion)||(this.logger.error("Did not get components version, using latest version"),"latest")}))},Hi=function(){return n(this,void 0,void 0,(function*(){vi.descopeUI?this.loggerWrapper.debug("DescopeUI is already loading, probably multiple flows are running on the same page"):vi.descopeUI=new Promise((e=>{if(globalThis.DescopeUI)return void e(globalThis.DescopeUI);const t=e=>{const t=document.createElement("script");return t.id="load-descope-ui",t.src=e,t},i=(e,t)=>e.replace("<version>",t),r=(t,n)=>{const o=()=>{this.loggerWrapper.error("Cannot load DescopeUI",`Make sure this URL is valid and return the correct script: "${t.src}"`),n()};t.addEventListener("load",(()=>{globalThis.DescopeUI||o(),e(globalThis.DescopeUI)})),t.addEventListener("error",o)};(()=>{n(this,void 0,void 0,(function*(){const n=yield o(this,gi,"m",Vi).call(this),s=t(i(fo,n));r(s,(()=>{s.remove(),this.loggerWrapper.info("Trying to load DescopeUI from a fallback URL");const o=t(i(po,n));r(o,(()=>{e(void 0)})),document.body.append(o)})),document.body.append(s)}))})()}))}))},pr.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.22.1"}};class vr extends pr{static set sdkConfigOverrides(e){pr.sdkConfigOverrides=e}constructor(){const e=new oi({deferredRedirect:!1});super(e.update.bind(e)),Ki.add(this),this.stepState=new oi({},{updateOnlyOnChange:!1}),Gi.set(this,void 0),Ji.set(this,null),Xi.set(this,{visibilitychange:o(this,Ki,"m",Yi).bind(this)}),Zi.set(this,((e,t,r,s,a)=>{r===Ro&&i(this,Gi,setTimeout((()=>n(this,void 0,void 0,(function*(){var n;let i;try{i=yield this.sdk.flow.next(e,t,Lo,s,a,{})}catch(n){return void o(this,Zi,"f").call(this,e,t,r,s,a)}o(this,er,"f").call(this,i);const{action:c}=null!==(n=null==i?void 0:i.data)&&void 0!==n?n:{};o(this,Zi,"f").call(this,e,t,c,s,a)}))),2e3),"f")})),Qi.set(this,(()=>{clearTimeout(o(this,Gi,"f")),i(this,Gi,null,"f")})),er.set(this,(e=>{var t,n,i,r,s,a,c,l,d,u,h;if(!(null==e?void 0:e.ok)){const a=null===(t=null==e?void 0:e.response)||void 0===t?void 0:t.url,c=`${null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.status} - ${null===(i=null==e?void 0:e.response)||void 0===i?void 0:i.statusText}`;return o(this,Ki,"m",hr).call(this,"error",(null==e?void 0:e.error)||{errorCode:"J151001",errorDescription:c,errorMessage:a}),void this.loggerWrapper.error((null===(r=null==e?void 0:e.error)||void 0===r?void 0:r.errorDescription)||a,(null===(s=null==e?void 0:e.error)||void 0===s?void 0:s.errorMessage)||c)}null===(c=null===(a=e.data)||void 0===a?void 0:a.runnerLogs)||void 0===c||c.forEach((e=>{const{level:t,title:n,log:o}=e;t&&this.loggerWrapper[t]?this.loggerWrapper[t](n,o):this.loggerWrapper.info(n,o)}));const f=null===(u=null===(d=null===(l=e.data)||void 0===l?void 0:l.screen)||void 0===d?void 0:d.state)||void 0===u?void 0:u.errorText;(null===(h=e.data)||void 0===h?void 0:h.error)?this.loggerWrapper.error(`[${e.data.error.code}]: ${e.data.error.description}`,`${f?`${f} - `:""}${e.data.error.message}`):f&&this.loggerWrapper.error(f);const{status:p,authInfo:g,lastAuth:v}=e.data;if("completed"===p)return this.storeLastAuthenticatedUser&&function(e){(null==e?void 0:e.authMethod)&&co&&localStorage.setItem(Io,JSON.stringify(e))}(v),void o(this,Ki,"m",hr).call(this,"success",g);const{executionId:m,stepId:b,stepName:w,action:y,screen:k,redirect:I,openInNewTabUrl:S,webauthn:j,error:x,samlIdpResponse:C}=e.data;y!==Ro?(this.loggerWrapper.info(`Step "${w||`#${b}`}" is ${p}`,"",{screen:k,status:p,stepId:b,stepName:w,action:y,error:x}),this.flowState.update({stepId:b,executionId:m,action:y,redirectTo:null==I?void 0:I.url,openInNewTabUrl:S,screenId:null==k?void 0:k.id,screenState:null==k?void 0:k.state,webauthnTransactionId:null==j?void 0:j.transactionId,webauthnOptions:null==j?void 0:j.options,samlIdpResponseUrl:null==C?void 0:C.url,samlIdpResponseSamlResponse:null==C?void 0:C.samlResponse,samlIdpResponseRelayState:null==C?void 0:C.relayState})):this.flowState.update({action:y})})),tr.set(this,Ho((()=>n(this,void 0,void 0,(function*(){var e;try{const t=yield this.sdk.webauthn.signIn.start("",window.location.origin);return t.ok||this.loggerWrapper.warn("Webauthn start failed",null===(e=null==t?void 0:t.error)||void 0===e?void 0:e.errorMessage),t.data}catch(e){this.loggerWrapper.warn("Webauthn start failed",e.message)}}))))),cr.set(this,Xo(((e,t)=>n(this,void 0,void 0,(function*(){if("true"===e.getAttribute("formnovalidate")||o(this,Ki,"m",ir).call(this)){const i=null==e?void 0:e.getAttribute("id");o(this,Ki,"m",sr).call(this,e);const r=yield o(this,Ki,"m",rr).call(this),s=(n=e,Array.from((null==n?void 0:n.attributes)||[]).reduce(((e,t)=>{var n;const o=null===(n=new RegExp("^data-descope-(\\S+)$").exec(t.name))||void 0===n?void 0:n[1];return o?Object.assign(e,{[o]:t.value}):e}),{})),a=this.getComponentsContext(),c=Object.assign(Object.assign(Object.assign(Object.assign({},a),s),r),{origin:window.location.origin}),l=yield this.getFlowConfig(),d=yield this.getProjectConfig(),u=yield t(i,l.version,d.componentsVersion,c);o(this,er,"f").call(this,u),o(this,Ki,"m",ar).call(this,r)}var n}))))),this.flowState=e}loadSdkScripts(){return n(this,void 0,void 0,(function*(){const e=(yield this.getFlowConfig()).sdkScripts;null==e||e.forEach((e=>n(this,void 0,void 0,(function*(){(yield function(e){return n(this,void 0,void 0,(function*(){let t;switch(e){case"forter":return t=yield Promise.resolve().then((function(){return hl})),t.default;case"fingerprint":return t=yield Promise.resolve().then((function(){return pl})),t.default;case"fingerprintDescope":return t=yield Promise.resolve().then((function(){return vl})),t.default;default:throw new Error(`Unknown script id: ${e}`)}}))}(e.id))(e.initArgs,{baseUrl:this.baseUrl},(t=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[gr(e.id,e.resultKey)]:t},bubbles:!0,composed:!0}))}))}))))}))}connectedCallback(){const e=Object.create(null,{connectedCallback:{get:()=>super.connectedCallback}});return n(this,void 0,void 0,(function*(){var t,n;this.shadowRoot.isConnected&&(null===(t=this.flowState)||void 0===t||t.subscribe(this.onFlowChange.bind(this)),null===(n=this.stepState)||void 0===n||n.subscribe(this.onStepChange.bind(this)),window.addEventListener("visibilitychange",o(this,Xi,"f").visibilitychange)),yield e.connectedCallback.call(this)}))}disconnectedCallback(){var e;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),null===(e=o(this,Ji,"f"))||void 0===e||e.abort(),i(this,Ji,null,"f"),window.removeEventListener("visibilitychange",o(this,Xi,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return n(this,void 0,void 0,(function*(){let n;const o=Yo(e);return(yield this.getTargetLocales()).includes(o)&&(n=`${t}-${o}.html`),n}))}getPageContent(e,t){return n(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield No(t,"text");return e}catch(n){this.loggerWrapper.error(`Failed to fetch flow page from ${t}. Fallback to url ${e}`,n)}try{const{body:t}=yield No(e,"text");return t}catch(e){this.loggerWrapper.error("Failed to fetch flow page",e.message)}return null}))}onFlowChange(e,r,s){return n(this,void 0,void 0,(function*(){var n,a;const{projectId:c,flowId:l,tenant:d,stepId:u,executionId:h,action:f,screenId:p,screenState:g,redirectTo:v,openInNewTabUrl:m,redirectUrl:b,token:w,code:y,exchangeError:k,webauthnTransactionId:I,webauthnOptions:S,redirectAuthCodeChallenge:j,redirectAuthCallbackUrl:x,redirectAuthBackupCallbackUri:C,redirectAuthInitiator:E,locale:A,samlIdpResponseUrl:O,samlIdpResponseSamlResponse:U,samlIdpResponseRelayState:_}=e,R=t(e,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","openInNewTabUrl","redirectUrl","token","code","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"]);let T,M;const L=(()=>{const e=localStorage.getItem(hi);if(!e){const e=Math.floor(100*Math.random()+1);return localStorage.setItem(hi,e.toString()),e}return Number(e)})(),P=this.sdk.getLastUserLoginId(),W=yield this.getFlowConfig(),$=yield this.getProjectConfig(),D=x&&j?{callbackUrl:x,codeChallenge:j,backupCallbackUri:C}:void 0;if(!h&&(this.loadSdkScripts(),W.fingerprintEnabled&&W.fingerprintKey?yield Nn(W.fingerprintKey,this.baseUrl):localStorage.removeItem($n),W.conditions?({startScreenId:T,conditionInteractionId:M}=((e,t)=>{const n=null==t?void 0:t.find((({key:t,operator:n,predicate:o})=>{var i;if("ELSE"===t)return!0;const r=null===(i=di[t])||void 0===i?void 0:i[n];return!!(null==r?void 0:r(e,o))}));return n?{startScreenId:n.met.screenId,conditionInteractionId:n.met.interactionId}:{}})({loginId:P,code:y,token:w,abTestingKey:L},W.conditions)):W.condition?({startScreenId:T,conditionInteractionId:M}=((e,t)=>{var n;const o=null===(n=di[null==e?void 0:e.key])||void 0===n?void 0:n[e.operator];if(!o)return{};const i=o(t,e.predicate)?e.met:e.unmet;return{startScreenId:null==i?void 0:i.screenId,conditionInteractionId:null==i?void 0:i.interactionId}})(W.condition,{loginId:P,code:y,token:w,abTestingKey:L})):T=W.startScreenId,!Ko(T,R))){const e=yield this.sdk.flow.start(l,Object.assign(Object.assign(Object.assign(Object.assign({tenant:d,redirectAuth:D},R),{client:this.client}),b&&{redirectUrl:b}),{lastAuth:ui(P),abTestingKey:L,locale:Yo(A)}),M,"",W.version,$.componentsVersion,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),y?{exchangeCode:y,idpInitiated:!0}:{}),R.descopeIdpInitiated&&{idpInitiated:!0}),w?{token:w}:{}),R.oidcLoginHint?{externalId:R.oidcLoginHint}:{}));return o(this,er,"f").call(this,e),void("completed"!==(null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.status)&&this.flowState.update({code:void 0,token:void 0}))}if(h&&(s("token")&&w||s("code")&&y||s("exchangeError")&&k)){const e=yield this.sdk.flow.next(h,u,Mo,W.version,$.componentsVersion,{token:w,exchangeCode:y,exchangeError:k});return o(this,er,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if("loadForm"===f&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>s(e)))){if(!O||!U)return void this.loggerWrapper.error("Did not get saml idp params data to load");((e,t,n,o)=>{const i=document.createElement("form");i.method="POST",i.action=e,i.innerHTML=`\n <input type="hidden" role="saml-response" name="SAMLResponse" value="${t}" />\n <input type="hidden" role="saml-relay-state" name="RelayState" value="${n}" />\n <input style="display: none;" id="SAMLSubmitButton" type="submit" value="Continue" />\n `,document.body.appendChild(i),o(i)})(O,U,_||"",Go)}if("redirect"===f&&(s("redirectTo")||s("deferredRedirect")))return v?"android"===E&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(v):void this.loggerWrapper.error("Did not get redirect url");if(f===To||"webauthnGet"===f){if(!I||!S)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,t;null===(a=o(this,Ji,"f"))||void 0===a||a.abort(),i(this,Ji,null,"f");try{e=f===To?yield this.sdk.webauthn.helpers.create(S):yield this.sdk.webauthn.helpers.get(S)}catch(n){"InvalidStateError"===n.name?this.loggerWrapper.warn("WebAuthn operation failed",n.message):"NotAllowedError"!==n.name&&this.loggerWrapper.error(n.message),t=n.name}const r=yield this.sdk.flow.next(h,u,Mo,W.version,$.componentsVersion,{transactionId:I,response:e,failure:t});o(this,er,"f").call(this,r)}if(o(this,Zi,"f").call(this,h,u,f,W.version,$.componentsVersion),!p&&!T)return void this.loggerWrapper.warn("No screen was found to show");const N=T||p,F=yield this.getHtmlFilenameWithLocale(A,N),{oidcLoginHint:q,oidcPrompt:z,oidcErrorRedirectUri:B,samlIdpUsername:V}=R,H={direction:qo(u,r.stepId),screenState:Object.assign(Object.assign({},g),{form:Object.assign(Object.assign({},this.formConfigValues),null==g?void 0:g.form),lastAuth:{loginId:P,name:this.sdk.getLastUserDisplayName()||P}}),htmlUrl:Fo({projectId:c,filename:`${N}.html`,baseUrl:this.baseStaticUrl}),htmlLocaleUrl:F&&Fo({projectId:c,filename:F,baseUrl:this.baseStaticUrl}),samlIdpUsername:V,oidcLoginHint:q,oidcPrompt:z,oidcErrorRedirectUri:B,openInNewTabUrl:m},K=ui(P);Ko(T,R)?H.next=(e,t,n,o)=>this.sdk.flow.start(l,Object.assign(Object.assign(Object.assign(Object.assign({tenant:d,redirectAuth:D},R),{lastAuth:K,preview:this.preview,abTestingKey:L,client:this.client}),b&&{redirectUrl:b}),{locale:Yo(A)}),M,e,t,n,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),o),y&&{exchangeCode:y,idpInitiated:!0}),R.descopeIdpInitiated&&{idpInitiated:!0}),w&&{token:w})):(s("projectId")||s("baseUrl")||s("executionId")||s("stepId"))&&(H.next=(...e)=>this.sdk.flow.next(h,u,...e)),this.stepState.update(H)}))}loadDescopeUiComponents(e){return n(this,void 0,void 0,(function*(){const t=yield pr.descopeUI;if(!t)return;const o=(e=>[...Array.from(e.querySelectorAll("*")).reduce(((e,t)=>t.tagName.startsWith("DESCOPE-")?e.add(t.tagName.toLocaleLowerCase()):e),new Set)])(e);yield Promise.all(o.map((e=>n(this,void 0,void 0,(function*(){if(!customElements.get(e))if(t[e])try{return yield t[e]()}catch(t){if("NotSupportedError"!==t.name)throw t;console.debug(`${e} is already registered`)}else this.loggerWrapper.error(`Cannot load UI component "${e}"`,`Descope UI does not have a component named "${e}", available components are: "${Object.keys(t).join(", ")}"`)})))))}))}onStepChange(e,t){return n(this,void 0,void 0,(function*(){var i,r;const{htmlUrl:s,htmlLocaleUrl:a,direction:c,next:l,screenState:d,openInNewTabUrl:u}=e,h=document.createElement("template");h.innerHTML=yield this.getPageContent(s,a);const f=h.content.cloneNode(!0),p=this.loadDescopeUiComponents(h.content);this.sdk.webauthn.helpers.isSupported()?yield o(this,Ki,"m",or).call(this,f,l):f.querySelectorAll(`descope-button[${_o}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true"))),!e.samlIdpUsername||(null===(i=d.form)||void 0===i?void 0:i.loginId)||(null===(r=d.form)||void 0===r?void 0:r.email)||(d.form||(d.form={}),d.form.loginId=e.samlIdpUsername,d.form.email=e.samlIdpUsername),((e,t,n,o,i,r)=>{var s,a;let c=null==t?void 0:t.errorText;try{c=(null==i?void 0:i({text:null==t?void 0:t.errorText,type:null==t?void 0:t.errorType}))||(null==t?void 0:t.errorText)}catch(e){r.error("Error transforming error message",e.message)}((e,t,n="")=>{e.querySelectorAll(`[${_o}="${t}"]`).forEach((e=>{e.textContent=n,e.classList[n?"remove":"add"]("hide")}))})(e,"error-message",c),ai(e,"totp-link",null===(s=null==t?void 0:t.totp)||void 0===s?void 0:s.provisionUrl),ai(e,"notp-link",null===(a=null==t?void 0:t.notp)||void 0===a?void 0:a.redirectUrl),((e,t)=>{e.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((e=>{e.textContent=si(e.textContent,t);const n=e.getAttribute("href");n&&e.setAttribute("href",si(n,t))}))})(e,t),((e,t,n)=>{t&&Object.keys(t).forEach((o=>{e.querySelectorAll(`[name=${o}]`).forEach((e=>{const i=t[o];Object.keys(i).forEach((t=>{let o=i[t];if("string"!=typeof o)try{o=JSON.stringify(o)}catch(e){n.error(`Could not stringify value "${o}" for "${t}"`,e.message),o=""}e.setAttribute(t,o)}))}))}))})(e,n,r),((e,t)=>{e.querySelectorAll("[data-has-dynamic-attr-values]").forEach((e=>{Array.from(e.attributes).forEach((e=>{e.value=si(e.value,t)}))}))})(e,t),((e,t)=>{Object.entries(t).forEach((([t,n])=>{e.querySelectorAll(`[name="${t}"]`).forEach((e=>{Object.entries(n).forEach((([t,n])=>{ii.includes(t)&&e.setAttribute(t,n)}))}))}))})(e,o)})(f,d,d.componentsConfig,this.formConfig,this.errorTransformer,this.loggerWrapper);const{geo:g}=yield this.getExecutionContext();((e,t)=>{Array.from(e.querySelectorAll('descope-phone-field[default-code="autoDetect"]')).forEach((e=>{e.setAttribute("default-code",t)}))})(f,g);const v=()=>n(this,void 0,void 0,(function*(){var e,n;yield p;const i=this.shadowRoot.querySelector("div");var r,s;r=i,s=null===(e=null==d?void 0:d.totp)||void 0===e?void 0:e.image,ci(r,"descope-totp-image",s),((e,t)=>{ci(e,"descope-notp-image",t)})(i,null===(n=null==d?void 0:d.notp)||void 0===n?void 0:n.image),this.rootElement.replaceChildren(f),setTimeout((()=>{((e,t)=>{ri(e,null==t?void 0:t.inputs),ri(e,null==t?void 0:t.form)})(this.rootElement,d)}));const a=!t.htmlUrl;if(((e,t,n)=>{if(!0===t||"skipFirstScreen"===t&&!n){const t=e.querySelector("*[name]");setTimeout((()=>{null==t||t.focus()}))}})(this.rootElement,this.autoFocus,a),this.validateOnBlur&&(()=>{this.rootElement.querySelectorAll("*[name]").forEach((e=>{e.addEventListener("blur",(()=>{var t;const n=e.focus;e.focus=()=>{},null===(t=e.reportValidity)||void 0===t||t.call(e),setTimeout((()=>{e.focus=n}))}))}))})(),o(this,Ki,"m",dr).call(this,l),a&&o(this,Ki,"m",hr).call(this,"ready",{}),o(this,Ki,"m",hr).call(this,"page-updated",{}),this.rootElement.querySelector(`[${_o}="polling"]`)){const e=yield this.getFlowConfig(),t=yield this.getProjectConfig(),n=yield l(Lo,e.version,t.componentsVersion,{});o(this,er,"f").call(this,n)}u&&!t.openInNewTabUrl&&window.open(u,"_blank")}));c?o(this,Ki,"m",ur).call(this,v,c):v()}))}}Gi=new WeakMap,Ji=new WeakMap,Xi=new WeakMap,Zi=new WeakMap,Qi=new WeakMap,er=new WeakMap,tr=new WeakMap,cr=new WeakMap,Ki=new WeakSet,Yi=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},nr=function(e){const t=e.getAttribute("name");if(!["email"].includes(t)){const n=`user-${t}`;e.setAttribute("name",n),e.addEventListener("input",(()=>{e.setAttribute("name",e.value?t:n)}))}},or=function(e,t){return n(this,void 0,void 0,(function*(){var r;null===(r=o(this,Ji,"f"))||void 0===r||r.abort();const s=e.querySelector('*[autocomplete="webauthn"]');if(s&&(yield li())){const{options:e,transactionId:r}=(yield o(this,tr,"f").call(this))||{};if(e&&r){o(this,Ki,"m",nr).call(this,s),i(this,Ji,new AbortController,"f");const a=yield this.getFlowConfig(),c=yield this.getProjectConfig();this.sdk.webauthn.helpers.conditional(e,o(this,Ji,"f")).then((e=>n(this,void 0,void 0,(function*(){const n=yield t(s.id,a.version,c.componentsVersion,{transactionId:r,response:e});o(this,er,"f").call(this,n)})))).catch((e=>{"AbortError"!==e.name&&this.loggerWrapper.error("Conditional login failed",e.message)}))}}}))},ir=function(){let e=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((t=>{var n,o;"slot"!==t.localName&&(null===(n=t.reportValidity)||void 0===n||n.call(t),e&&(e=null===(o=t.checkValidity)||void 0===o?void 0:o.call(t)))})),e},rr=function(){return n(this,void 0,void 0,(function*(){const e=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${ko}])`));return(yield Promise.all(e.map((e=>n(this,void 0,void 0,(function*(){return{name:e.getAttribute("name"),value:e.value}})))))).reduce(((e,t)=>Object.assign(Object.assign({},e),{[t.name]:t.value})),{})}))},sr=function(e){const t=this.nextRequestStatus.subscribe((({isLoading:n})=>{n?e.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(t),e.removeAttribute("loading"))}))},ar=function(e={}){var t,n;const o=Jo(e,["externalId","email","phone"]),i=Jo(e,["newPassword","password"]);if(o&&i)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:o,password:i});null===(n=null===(t=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===t?void 0:t.store)||void 0===n||n.call(t,e)}catch(e){this.loggerWrapper.error("Could not store credentials",e.message)}},lr=function(e){this.rootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((t=>{t.addEventListener("input",(()=>{var n;(null===(n=t.checkValidity)||void 0===n?void 0:n.call(t))&&o(this,cr,"f").call(this,t,e)}))}))},dr=function(e){this.rootElement.querySelectorAll("descope-button:not([data-exclude-next])").forEach((t=>{t.onclick=()=>{o(this,cr,"f").call(this,t,e)}})),o(this,Ki,"m",lr).call(this,e)},ur=function(e,t){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),e()}),{once:!0});const n=t===Wo.forward?"slide-forward":"slide-backward";Array.from(this.rootElement.getElementsByClassName("input-container")).forEach(((e,t)=>{e.style["transition-delay"]=40*t+"ms",e.classList.add(n)})),this.rootElement.classList.add("fade-out")},hr=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},customElements.get("descope-wc")?console.log("descope-wc is already defined"):customElements.define("descope-wc",vr);let mr=class{constructor(e,t){fr.set(this,void 0),this.nodeName="",i(this,fr,e,"f"),this.logger=t.logger}get asyncEle(){return(async e=>new Promise((t=>{const n=setInterval((()=>{const o="function"==typeof e?e():e;o&&(clearInterval(n),t(o))}),100);setTimeout((()=>{clearInterval(n),t(null)}),1e3)})))(o(this,fr,"f"))}get ele(){var e,t;const n="function"==typeof o(this,fr,"f")?o(this,fr,"f").call(this):o(this,fr,"f");return n?(null==n?void 0:n.localName)!==this.nodeName?(null===(t=this.logger)||void 0===t||t.debug(`node name do not match, expected "${this.nodeName}", received "${n.localName}" `,Error()),null):n:(null===(e=this.logger)||void 0===e||e.debug("no element for driver ",this.constructor.name,new Error),null)}};fr=new WeakMap;class br extends mr{constructor(){super(...arguments),this.nodeName="descope-button"}onClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("click",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("click",e)}}disable(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("disabled","true")}enable(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("disabled")}}var wr;class yr extends mr{constructor(){super(...arguments),wr.set(this,void 0),this.nodeName="descope-modal"}close(){var e,t;null===(e=this.ele)||void 0===e||e.removeAttribute("opened"),null===(t=this.afterClose)||void 0===t||t.call(this)}async open(){var e,t;await(null===(e=this.beforeOpen)||void 0===e?void 0:e.call(this)),null===(t=this.ele)||void 0===t||t.setAttribute("opened","true")}reset(){var e;this.ele&&(this.ele.innerHTML=""),o(this,wr,"f")&&(null===(e=this.ele)||void 0===e||e.append(o(this,wr,"f").content.cloneNode(!0)))}setContent(e){i(this,wr,e,"f"),this.reset()}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}}wr=new WeakMap;let kr=class extends mr{constructor(){super(...arguments),this.nodeName="descope-notification"}close(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("opened")}show(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("opened","true")}setContent(e){this.ele.innerHTML="",this.ele.appendChild(e.content.cloneNode(!0))}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}};class Ir extends mr{constructor(){super(...arguments),this.nodeName="descope-avatar"}set displayName(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("display-name",e)}set image(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("img",e)}get flowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id")}onClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("click",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("click",e)}}}let Sr=class extends mr{constructor(){super(...arguments),this.nodeName="descope-user-attribute"}set value(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("value",e)}set badgeLabel(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("badge-label",e)}get label(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("label"))||""}get editFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("edit-flow-id"))||""}get deleteFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("delete-flow-id"))||""}onEditClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("edit-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("edit-clicked",e)}}onDeleteClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("delete-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("delete-clicked",e)}}};class jr extends mr{constructor(){super(...arguments),this.nodeName="descope-user-auth-method"}set fulfilled(e){var t,n;e?null===(t=this.ele)||void 0===t||t.setAttribute("fulfilled","true"):null===(n=this.ele)||void 0===n||n.removeAttribute("fulfilled")}onButtonClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("button-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("button-clicked",e)}}get flowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id")}}class xr extends mr{constructor(){super(...arguments),this.nodeName="descope-wc"}set projectId(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("project-id",e)}set baseUrl(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("base-url",e)}set flowId(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("flow-id",e)}onSuccess(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("success",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("success",e)}}}var Cr=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),Er=()=>Math.random().toString(36).substring(7).split("").join("."),Ar={INIT:`@@redux/INIT${Er()}`,REPLACE:`@@redux/REPLACE${Er()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${Er()}`};function Or(e){if("object"!=typeof e||null===e)return!1;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||null===Object.getPrototypeOf(e)}function Ur(e){if(void 0===e)return"undefined";if(null===e)return"null";const t=typeof e;switch(t){case"boolean":case"string":case"number":case"symbol":case"function":return t}if(Array.isArray(e))return"array";if(function(e){return e instanceof Date||"function"==typeof e.toDateString&&"function"==typeof e.getDate&&"function"==typeof e.setDate}(e))return"date";if(function(e){return e instanceof Error||"string"==typeof e.message&&e.constructor&&"number"==typeof e.constructor.stackTraceLimit}(e))return"error";const n=function(e){return"function"==typeof e.constructor?e.constructor.name:null}(e);switch(n){case"Symbol":case"Promise":case"WeakMap":case"WeakSet":case"Map":case"Set":return n}return Object.prototype.toString.call(e).slice(8,-1).toLowerCase().replace(/\s/g,"")}function _r(e){let t=typeof e;return t=Ur(e),t}function Rr(e,t,n){if("function"!=typeof e)throw new Error(`Expected the root reducer to be a function. Instead, received: '${_r(e)}'`);if("function"==typeof t&&"function"==typeof n||"function"==typeof n&&"function"==typeof arguments[3])throw new Error("It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.");if("function"==typeof t&&void 0===n&&(n=t,t=void 0),void 0!==n){if("function"!=typeof n)throw new Error(`Expected the enhancer to be a function. Instead, received: '${_r(n)}'`);return n(Rr)(e,t)}let o=e,i=t,r=new Map,s=r,a=0,c=!1;function l(){s===r&&(s=new Map,r.forEach(((e,t)=>{s.set(t,e)})))}function d(){if(c)throw new Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return i}function u(e){if("function"!=typeof e)throw new Error(`Expected the listener to be a function. Instead, received: '${_r(e)}'`);if(c)throw new Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");let t=!0;l();const n=a++;return s.set(n,e),function(){if(t){if(c)throw new Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");t=!1,l(),s.delete(n),r=null}}}function h(e){if(!Or(e))throw new Error(`Actions must be plain objects. Instead, the actual type was: '${_r(e)}'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.`);if(void 0===e.type)throw new Error('Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');if("string"!=typeof e.type)throw new Error(`Action "type" property must be a string. Instead, the actual type was: '${_r(e.type)}'. Value was: '${e.type}' (stringified)`);if(c)throw new Error("Reducers may not dispatch actions.");try{c=!0,i=o(i,e)}finally{c=!1}return(r=s).forEach((e=>{e()})),e}h({type:Ar.INIT});return{dispatch:h,subscribe:u,getState:d,replaceReducer:function(e){if("function"!=typeof e)throw new Error(`Expected the nextReducer to be a function. Instead, received: '${_r(e)}`);o=e,h({type:Ar.REPLACE})},[Cr]:function(){const e=u;return{subscribe(t){if("object"!=typeof t||null===t)throw new Error(`Expected the observer to be an object. Instead, received: '${_r(t)}'`);function n(){const e=t;e.next&&e.next(d())}n();return{unsubscribe:e(n)}},[Cr](){return this}}}}}function Tr(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}function Mr(e){const t=Object.keys(e),n={};for(let o=0;o<t.length;o++){const i=t[o];void 0===e[i]&&Tr(`No reducer provided for key "${i}"`),"function"==typeof e[i]&&(n[i]=e[i])}const o=Object.keys(n);let i,r;i={};try{!function(e){Object.keys(e).forEach((t=>{const n=e[t];if(void 0===n(void 0,{type:Ar.INIT}))throw new Error(`The slice reducer for key "${t}" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);if(void 0===n(void 0,{type:Ar.PROBE_UNKNOWN_ACTION()}))throw new Error(`The slice reducer for key "${t}" returned undefined when probed with a random type. Don't try to handle '${Ar.INIT}' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.`)}))}(n)}catch(e){r=e}return function(e={},t){if(r)throw r;{const o=function(e,t,n,o){const i=Object.keys(t),r=n&&n.type===Ar.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(0===i.length)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!Or(e))return`The ${r} has unexpected type of "${_r(e)}". Expected argument to be an object with the following keys: "${i.join('", "')}"`;const s=Object.keys(e).filter((e=>!t.hasOwnProperty(e)&&!o[e]));return s.forEach((e=>{o[e]=!0})),n&&n.type===Ar.REPLACE?void 0:s.length>0?`Unexpected ${s.length>1?"keys":"key"} "${s.join('", "')}" found in ${r}. Expected to find one of the known reducer keys instead: "${i.join('", "')}". Unexpected keys will be ignored.`:void 0}(e,n,t,i);o&&Tr(o)}let s=!1;const a={};for(let i=0;i<o.length;i++){const r=o[i],c=n[r],l=e[r],d=c(l,t);if(void 0===d){const e=t&&t.type;throw new Error(`When called with an action of type ${e?`"${String(e)}"`:"(unknown type)"}, the slice reducer for key "${r}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`)}a[r]=d,s=s||d!==l}return s=s||o.length!==Object.keys(e).length,s?a:e}}function Lr(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...n)=>e(t(...n))))}function Pr(e){return Or(e)&&"type"in e&&"string"==typeof e.type}var Wr=Symbol.for("immer-nothing"),$r=Symbol.for("immer-draftable"),Dr=Symbol.for("immer-state"),Nr=[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}];function Fr(e,...t){{const n=Nr[e],o="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${o}`)}}var qr=Object.getPrototypeOf;function zr(e){return!!e&&!!e[Dr]}function Br(e){return!!e&&(Hr(e)||Array.isArray(e)||!!e[$r]||!!e.constructor?.[$r]||Yr(e)||Zr(e))}var Vr=Object.prototype.constructor.toString();function Hr(e){if(!e||"object"!=typeof e)return!1;const t=qr(e);if(null===t)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object||"function"==typeof n&&Function.toString.call(n)===Vr}function Kr(e,t){0===Gr(e)?Object.entries(e).forEach((([n,o])=>{t(n,o,e)})):e.forEach(((n,o)=>t(o,n,e)))}function Gr(e){const t=e[Dr];return t?t.type_:Array.isArray(e)?1:Yr(e)?2:Zr(e)?3:0}function Jr(e,t){return 2===Gr(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Xr(e,t,n){const o=Gr(e);2===o?e.set(t,n):3===o?e.add(n):e[t]=n}function Yr(e){return e instanceof Map}function Zr(e){return e instanceof Set}function Qr(e){return e.copy_||e.base_}function es(e,t){if(Yr(e))return new Map(e);if(Zr(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&Hr(e)){if(!qr(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const n=Object.getOwnPropertyDescriptors(e);delete n[Dr];let o=Reflect.ownKeys(n);for(let t=0;t<o.length;t++){const i=o[t],r=n[i];!1===r.writable&&(r.writable=!0,r.configurable=!0),(r.get||r.set)&&(n[i]={configurable:!0,writable:!0,enumerable:r.enumerable,value:e[i]})}return Object.create(qr(e),n)}function ts(e,t=!1){return os(e)||zr(e)||!Br(e)||(Gr(e)>1&&(e.set=e.add=e.clear=e.delete=ns),Object.freeze(e),t&&Kr(e,((e,t)=>ts(t,!0)))),e}function ns(){Fr(2)}function os(e){return Object.isFrozen(e)}var is,rs={};function ss(e){const t=rs[e];return t||Fr(0,e),t}function as(){return is}function cs(e,t){t&&(ss("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function ls(e){ds(e),e.drafts_.forEach(hs),e.drafts_=null}function ds(e){e===is&&(is=e.parent_)}function us(e){return is={drafts_:[],parent_:is,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function hs(e){const t=e[Dr];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function fs(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[Dr].modified_&&(ls(t),Fr(4)),Br(e)&&(e=ps(t,e),t.parent_||vs(t,e)),t.patches_&&ss("Patches").generateReplacementPatches_(n[Dr].base_,e,t.patches_,t.inversePatches_)):e=ps(t,n,[]),ls(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Wr?e:void 0}function ps(e,t,n){if(os(t))return t;const o=t[Dr];if(!o)return Kr(t,((i,r)=>gs(e,o,t,i,r,n))),t;if(o.scope_!==e)return t;if(!o.modified_)return vs(e,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;const t=o.copy_;let i=t,r=!1;3===o.type_&&(i=new Set(t),t.clear(),r=!0),Kr(i,((i,s)=>gs(e,o,t,i,s,n,r))),vs(e,t,!1),n&&e.patches_&&ss("Patches").generatePatches_(o,n,e.patches_,e.inversePatches_)}return o.copy_}function gs(e,t,n,o,i,r,s){if(i===n&&Fr(5),zr(i)){const s=ps(e,i,r&&t&&3!==t.type_&&!Jr(t.assigned_,o)?r.concat(o):void 0);if(Xr(n,o,s),!zr(s))return;e.canAutoFreeze_=!1}else s&&n.add(i);if(Br(i)&&!os(i)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;ps(e,i),t&&t.scope_.parent_||vs(e,i)}}function vs(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&ts(t,n)}var ms={get(e,t){if(t===Dr)return e;const n=Qr(e);if(!Jr(n,t))return function(e,t,n){const o=ys(t,n);return o?"value"in o?o.value:o.get?.call(e.draft_):void 0}(e,n,t);const o=n[t];return e.finalized_||!Br(o)?o:o===ws(e.base_,t)?(Is(e),e.copy_[t]=Ss(o,e)):o},has:(e,t)=>t in Qr(e),ownKeys:e=>Reflect.ownKeys(Qr(e)),set(e,t,n){const o=ys(Qr(e),t);if(o?.set)return o.set.call(e.draft_,n),!0;if(!e.modified_){const o=ws(Qr(e),t),i=o?.[Dr];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}(n,o)&&(void 0!==n||Jr(e.base_,t)))return!0;Is(e),ks(e)}return e.copy_[t]===n&&(void 0!==n||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty:(e,t)=>(void 0!==ws(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,Is(e),ks(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=Qr(e),o=Reflect.getOwnPropertyDescriptor(n,t);return o?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:o.enumerable,value:n[t]}:o},defineProperty(){Fr(11)},getPrototypeOf:e=>qr(e.base_),setPrototypeOf(){Fr(12)}},bs={};function ws(e,t){const n=e[Dr];return(n?Qr(n):e)[t]}function ys(e,t){if(!(t in e))return;let n=qr(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=qr(n)}}function ks(e){e.modified_||(e.modified_=!0,e.parent_&&ks(e.parent_))}function Is(e){e.copy_||(e.copy_=es(e.base_,e.scope_.immer_.useStrictShallowCopy_))}Kr(ms,((e,t)=>{bs[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),bs.deleteProperty=function(e,t){return isNaN(parseInt(t))&&Fr(13),bs.set.call(this,e,t,void 0)},bs.set=function(e,t,n){return"length"!==t&&isNaN(parseInt(t))&&Fr(14),ms.set.call(this,e[0],t,n,e[0])};function Ss(e,t){const n=Yr(e)?ss("MapSet").proxyMap_(e,t):Zr(e)?ss("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),o={type_:n?1:0,scope_:t?t.scope_:as(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=o,r=ms;n&&(i=[o],r=bs);const{revoke:s,proxy:a}=Proxy.revocable(i,r);return o.draft_=a,o.revoke_=s,a}(e,t);return(t?t.scope_:as()).drafts_.push(n),n}function js(e){return zr(e)||Fr(10,e),xs(e)}function xs(e){if(!Br(e)||os(e))return e;const t=e[Dr];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=es(e,t.scope_.immer_.useStrictShallowCopy_)}else n=es(e,!0);return Kr(n,((e,t)=>{Xr(n,e,xs(t))})),t&&(t.finalized_=!1),n}var Cs=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,t,n)=>{if("function"==typeof e&&"function"!=typeof t){const n=t;t=e;const o=this;return function(e=n,...i){return o.produce(e,(e=>t.call(this,e,...i)))}}let o;if("function"!=typeof t&&Fr(6),void 0!==n&&"function"!=typeof n&&Fr(7),Br(e)){const i=us(this),r=Ss(e,void 0);let s=!0;try{o=t(r),s=!1}finally{s?ls(i):ds(i)}return cs(i,n),fs(o,i)}if(!e||"object"!=typeof e){if(o=t(e),void 0===o&&(o=e),o===Wr&&(o=void 0),this.autoFreeze_&&ts(o,!0),n){const t=[],i=[];ss("Patches").generateReplacementPatches_(e,o,t,i),n(t,i)}return o}Fr(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...n)=>this.produceWithPatches(t,(t=>e(t,...n)));let n,o;const i=this.produce(e,t,((e,t)=>{n=e,o=t}));return[i,n,o]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){Br(e)||Fr(8),zr(e)&&(e=js(e));const t=us(this),n=Ss(e,void 0);return n[Dr].isManual_=!0,ds(t),n}finishDraft(e,t){const n=e&&e[Dr];n&&n.isManual_||Fr(9);const{scope_:o}=n;return cs(o,t),fs(void 0,o)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const o=t[n];if(0===o.path.length&&"replace"===o.op){e=o.value;break}}n>-1&&(t=t.slice(n+1));const o=ss("Patches").applyPatches_;return zr(e)?o(e,t):this.produce(e,(e=>o(e,t)))}},Es=Cs.produce;Cs.produceWithPatches.bind(Cs),Cs.setAutoFreeze.bind(Cs),Cs.setUseStrictShallowCopy.bind(Cs),Cs.applyPatches.bind(Cs),Cs.createDraft.bind(Cs),Cs.finishDraft.bind(Cs);var As=(e,t,n)=>{if(1===t.length&&t[0]===n){let t=!1;try{const n={};e(n)===n&&(t=!0)}catch{}if(t){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("The result function returned its own inputs without modification. e.g\n`createSelector([state => state.todos], todos => todos)`\nThis could lead to inefficient memoization and unnecessary re-renders.\nEnsure transformation logic is in the result function, and extraction logic is in the input selectors.",{stack:e})}}},Os=(e,t,n)=>{const{memoize:o,memoizeOptions:i}=t,{inputSelectorResults:r,inputSelectorResultsCopy:s}=e,a=o((()=>({})),...i);if(!(a.apply(null,r)===a.apply(null,s))){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("An input selector returned a different result when passed same arguments.\nThis means your output selector will likely run more frequently than intended.\nAvoid returning a new reference inside your input selector, e.g.\n`createSelector([state => state.todos.map(todo => todo.id)], todoIds => todoIds.length)`",{arguments:n,firstInputs:r,secondInputs:s,stack:e})}},Us={inputStabilityCheck:"once",identityFunctionCheck:"once"};var _s=e=>Array.isArray(e)?e:[e];function Rs(e){const t=Array.isArray(e[0])?e[0]:e;return function(e,t="expected all items to be functions, instead received the following types: "){if(!e.every((e=>"function"==typeof e))){const n=e.map((e=>"function"==typeof e?`function ${e.name||"unnamed"}()`:typeof e)).join(", ");throw new TypeError(`${t}[${n}]`)}}(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function Ts(e,t){const n=[],{length:o}=e;for(let i=0;i<o;i++)n.push(e[i].apply(null,t));return n}var Ms="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}},Ls=0,Ps=1;function Ws(){return{s:Ls,v:void 0,o:null,p:null}}function $s(e,t={}){let n=Ws();const{resultEqualityCheck:o}=t;let i,r=0;function s(){let t=n;const{length:s}=arguments;for(let e=0,n=s;e<n;e++){const n=arguments[e];if("function"==typeof n||"object"==typeof n&&null!==n){let e=t.o;null===e&&(t.o=e=new WeakMap);const o=e.get(n);void 0===o?(t=Ws(),e.set(n,t)):t=o}else{let e=t.p;null===e&&(t.p=e=new Map);const o=e.get(n);void 0===o?(t=Ws(),e.set(n,t)):t=o}}const a=t;let c;if(t.s===Ps)c=t.v;else if(c=e.apply(null,arguments),r++,o){const e=i?.deref?.()??i;null!=e&&o(e,c)&&(c=e,0!==r&&r--);i="object"==typeof c&&null!==c||"function"==typeof c?new Ms(c):c}return a.s=Ps,a.v=c,c}return s.clearCache=()=>{n=Ws(),s.resetResultsCount()},s.resultsCount=()=>r,s.resetResultsCount=()=>{r=0},s}function Ds(e,...t){const n="function"==typeof e?{memoize:e,memoizeOptions:t}:e,o=(...e)=>{let t,o=0,i=0,r={},s=e.pop();"object"==typeof s&&(r=s,s=e.pop()),function(e,t="expected a function, instead received "+typeof e){if("function"!=typeof e)throw new TypeError(t)}(s,`createSelector expects an output function after the inputs, but received: [${typeof s}]`);const a={...n,...r},{memoize:c,memoizeOptions:l=[],argsMemoize:d=$s,argsMemoizeOptions:u=[],devModeChecks:h={}}=a,f=_s(l),p=_s(u),g=Rs(e),v=c((function(){return o++,s.apply(null,arguments)}),...f);let m=!0;const b=d((function(){i++;const e=Ts(g,arguments);t=v.apply(null,e);{const{identityFunctionCheck:n,inputStabilityCheck:o}=((e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:o}={...Us,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:As},inputStabilityCheck:{shouldRun:"always"===o||"once"===o&&e,run:Os}}})(m,h);if(n.shouldRun&&n.run(s,e,t),o.shouldRun){const t=Ts(g,arguments);o.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:c,memoizeOptions:f},arguments)}m&&(m=!1)}return t}),...p);return Object.assign(b,{resultFunc:s,memoizedResultFunc:v,dependencies:g,dependencyRecomputations:()=>i,resetDependencyRecomputations:()=>{i=0},lastResult:()=>t,recomputations:()=>o,resetRecomputations:()=>{o=0},memoize:c,argsMemoize:d})};return Object.assign(o,{withTypes:()=>o}),o}var Ns=Ds($s),Fs=Object.assign(((e,t=Ns)=>{!function(e,t="expected an object, instead received "+typeof e){if("object"!=typeof e)throw new TypeError(t)}(e,"createStructuredSelector expects first argument to be an object where each property is a selector, instead received a "+typeof e);const n=Object.keys(e);return t(n.map((t=>e[t])),((...e)=>e.reduce(((e,t,o)=>(e[n[o]]=t,e)),{})))}),{withTypes:()=>Fs});function qs(e){return({dispatch:t,getState:n})=>o=>i=>"function"==typeof i?i(t,n,e):o(i)}var zs=qs(),Bs=qs;((...e)=>{const t=Ds(...e)})($s);var Vs="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?Lr:Lr.apply(null,arguments)},Hs=e=>e&&"function"==typeof e.match;function Ks(e,t){function n(...n){if(t){let o=t(...n);if(!o)throw new Error("prepareAction did not return an object");return{type:e,payload:o.payload,..."meta"in o&&{meta:o.meta},..."error"in o&&{error:o.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>Pr(t)&&t.type===e,n}function Gs(e){return"function"==typeof e&&"type"in e&&Hs(e)}function Js(e,t){let n=0;return{measureTime(e){const t=Date.now();try{return e()}finally{const e=Date.now();n+=e-t}},warnIfExceeded(){n>e&&console.warn(`${t} took ${n}ms, which is more than the warning threshold of ${e}ms. \nIf your state or actions are very large, you may want to disable the middleware as it might cause too much of a slowdown in development mode. See https://redux-toolkit.js.org/api/getDefaultMiddleware for instructions.\nIt is disabled in production builds, so you don't need to worry about that.`)}}}var Xs=class e extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,e.prototype)}static get[Symbol.species](){return e}concat(...e){return super.concat.apply(this,e)}prepend(...t){return 1===t.length&&Array.isArray(t[0])?new e(...t[0].concat(this)):new e(...t.concat(this))}};function Ys(e){return Br(e)?Es(e,(()=>{})):e}function Zs(e,t,n){if(e.has(t)){let o=e.get(t);return n.update&&(o=n.update(o,t,e),e.set(t,o)),o}if(!n.insert)throw new Error("No insert provided for key not already in map");const o=n.insert(t,e);return e.set(t,o),o}function Qs(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function ea(e,t,n){const o=ta(e,t,n);return{detectMutations:()=>na(e,t,o,n)}}function ta(e,t=[],n,o="",i=new Set){const r={value:n};if(!e(n)&&!i.has(n)){i.add(n),r.children={};for(const i in n){const s=o?o+"."+i:i;t.length&&-1!==t.indexOf(s)||(r.children[i]=ta(e,t,n[i],s))}}return r}function na(e,t=[],n,o,i=!1,r=""){const s=n?n.value:void 0,a=s===o;if(i&&!a&&!Number.isNaN(o))return{wasMutated:!0,path:r};if(e(s)||e(o))return{wasMutated:!1};const c={};for(let e in n.children)c[e]=!0;for(let e in o)c[e]=!0;const l=t.length>0;for(let i in c){const s=r?r+"."+i:i;if(l){if(t.some((e=>e instanceof RegExp?e.test(s):s===e)))continue}const c=na(e,t,n.children[i],o[i],a,s);if(c.wasMutated)return c}return{wasMutated:!1}}function oa(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||Or(e)}function ia(e,t="",n=oa,o,i=[],r){let s;if(!n(e))return{keyPath:t||"<root>",value:e};if("object"!=typeof e||null===e)return!1;if(r?.has(e))return!1;const a=null!=o?o(e):Object.entries(e),c=i.length>0;for(const[e,l]of a){const a=t?t+"."+e:e;if(c){if(i.some((e=>e instanceof RegExp?e.test(a):a===e)))continue}if(!n(l))return{keyPath:a,value:l};if("object"==typeof l&&(s=ia(l,a,n,o,i,r),s))return s}return r&&ra(e)&&r.add(e),!1}function ra(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!ra(t))return!1;return!0}function sa(e){return"boolean"==typeof e}var aa=()=>function(e){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:o=!0,actionCreatorCheck:i=!0}=e??{};let r=new Xs;if(t&&(sa(t)?r.push(zs):r.push(Bs(t.extraArgument))),n){let e={};sa(n)||(e=n),r.unshift(function(e={}){{let t=function(e,t,o,i){return JSON.stringify(e,n(t,i),o)},n=function(e,t){let n=[],o=[];return t||(t=function(e,t){return n[0]===t?"[Circular ~]":"[Circular ~."+o.slice(0,n.indexOf(t)).join(".")+"]"}),function(i,r){if(n.length>0){var s=n.indexOf(this);~s?n.splice(s+1):n.push(this),~s?o.splice(s,1/0,i):o.push(i),~n.indexOf(r)&&(r=t.call(this,i,r))}else n.push(r);return null==e?r:e.call(this,i,r)}},{isImmutable:o=Qs,ignoredPaths:i,warnAfter:r=32}=e;const s=ea.bind(null,o,i);return({getState:e})=>{let n,o=e(),i=s(o);return a=>c=>{const l=Js(r,"ImmutableStateInvariantMiddleware");l.measureTime((()=>{if(o=e(),n=i.detectMutations(),i=s(o),n.wasMutated)throw new Error(`A state mutation was detected between dispatches, in the path '${n.path||""}'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)}));const d=a(c);return l.measureTime((()=>{if(o=e(),n=i.detectMutations(),i=s(o),n.wasMutated)throw new Error(`A state mutation was detected inside a dispatch, in the path: ${n.path||""}. Take a look at the reducer(s) handling the action ${t(c)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)})),l.warnIfExceeded(),d}}}}(e))}if(o){let e={};sa(o)||(e=o),r.push(function(e={}){{const{isSerializable:t=oa,getEntries:n,ignoredActions:o=[],ignoredActionPaths:i=["meta.arg","meta.baseQueryMeta"],ignoredPaths:r=[],warnAfter:s=32,ignoreState:a=!1,ignoreActions:c=!1,disableCache:l=!1}=e,d=!l&&WeakSet?new WeakSet:void 0;return e=>l=>u=>{if(!Pr(u))return l(u);const h=l(u),f=Js(s,"SerializableStateInvariantMiddleware");return c||o.length&&-1!==o.indexOf(u.type)||f.measureTime((()=>{const e=ia(u,"",t,n,i,d);if(e){const{keyPath:t,value:n}=e;console.error(`A non-serializable value was detected in an action, in the path: \`${t}\`. Value:`,n,"\nTake a look at the logic that dispatched this action: ",u,"\n(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)","\n(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)")}})),a||(f.measureTime((()=>{const o=ia(e.getState(),"",t,n,r,d);if(o){const{keyPath:e,value:t}=o;console.error(`A non-serializable value was detected in the state, in the path: \`${e}\`. Value:`,t,`\nTake a look at the reducer(s) handling this action type: ${u.type}.\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)`)}})),f.warnIfExceeded()),h}}}(e))}if(i){let e={};sa(i)||(e=i),r.unshift(function(e={}){const{isActionCreator:t=Gs}=e;return()=>e=>n=>(t(n)&&console.warn(function(e){const t=e?`${e}`.split("/"):[],n=t[t.length-1]||"actionCreator";return`Detected an action creator with type "${e||"unknown"}" being dispatched. \nMake sure you're calling the action creator before dispatching, i.e. \`dispatch(${n}())\` instead of \`dispatch(${n})\`. This is necessary even if the action has no payload.`}(n.type)),e(n))}(e))}return r},ca=e=>t=>{setTimeout(t,e)},la="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:ca(10),da=e=>function(t){const{autoBatch:n=!0}=t??{};let o=new Xs(e);return n&&o.push(((e={type:"raf"})=>t=>(...n)=>{const o=t(...n);let i=!0,r=!1,s=!1;const a=new Set,c="tick"===e.type?queueMicrotask:"raf"===e.type?la:"callback"===e.type?e.queueNotification:ca(e.timeout),l=()=>{s=!1,r&&(r=!1,a.forEach((e=>e())))};return Object.assign({},o,{subscribe(e){const t=o.subscribe((()=>i&&e()));return a.add(e),()=>{t(),a.delete(e)}},dispatch(e){try{return i=!e?.meta?.RTK_autoBatch,r=!i,r&&(s||(s=!0,c(l))),o.dispatch(e)}finally{i=!0}}})})("object"==typeof n?n:void 0)),o};function ua(e){const t=aa(),{reducer:n,middleware:o,devTools:i=!0,preloadedState:r,enhancers:s}=e||{};let a,c;if("function"==typeof n)a=n;else{if(!Or(n))throw new Error("`reducer` is a required argument, and must be a function or an object of functions that can be passed to combineReducers");a=Mr(n)}if(o&&"function"!=typeof o)throw new Error("`middleware` field must be a callback");if("function"==typeof o){if(c=o(t),!Array.isArray(c))throw new Error("when using a middleware builder function, an array of middleware must be returned")}else c=t();if(c.some((e=>"function"!=typeof e)))throw new Error("each middleware provided to configureStore must be a function");let l=Lr;i&&(l=Vs({trace:!0,..."object"==typeof i&&i}));const d=function(...e){return t=>(n,o)=>{const i=t(n,o);let r=()=>{throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")};const s={getState:i.getState,dispatch:(e,...t)=>r(e,...t)},a=e.map((e=>e(s)));return r=Lr(...a)(i.dispatch),{...i,dispatch:r}}}(...c),u=da(d);if(s&&"function"!=typeof s)throw new Error("`enhancers` field must be a callback");let h="function"==typeof s?s(u):u();if(!Array.isArray(h))throw new Error("`enhancers` callback must return an array");if(h.some((e=>"function"!=typeof e)))throw new Error("each enhancer provided to configureStore must be a function");c.length&&!h.includes(d)&&console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`");return Rr(a,r,l(...h))}function ha(e){const t={},n=[];let o;const i={addCase(e,r){if(n.length>0)throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");if(o)throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`");const s="string"==typeof e?e:e.type;if(!s)throw new Error("`builder.addCase` cannot be called with an empty action type");if(s in t)throw new Error(`\`builder.addCase\` cannot be called with two reducers for the same action type '${s}'`);return t[s]=r,i},addMatcher(e,t){if(o)throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return n.push({matcher:e,reducer:t}),i},addDefaultCase(e){if(o)throw new Error("`builder.addDefaultCase` can only be called once");return o=e,i}};return e(i),[t,n,o]}function fa(...e){return t=>e.some((e=>((e,t)=>Hs(e)?e.match(t):e(t))(e,t)))}var pa=["name","message","stack","code"],ga=class{constructor(e,t){this.payload=e,this.meta=t}_type},va=class{constructor(e,t){this.payload=e,this.meta=t}_type},ma=e=>{if("object"==typeof e&&null!==e){const t={};for(const n of pa)"string"==typeof e[n]&&(t[n]=e[n]);return t}return{message:String(e)}},ba=(()=>{function e(e,t,n){const o=Ks(e+"/fulfilled",((e,t,n,o)=>({payload:e,meta:{...o||{},arg:n,requestId:t,requestStatus:"fulfilled"}}))),i=Ks(e+"/pending",((e,t,n)=>({payload:void 0,meta:{...n||{},arg:t,requestId:e,requestStatus:"pending"}}))),r=Ks(e+"/rejected",((e,t,o,i,r)=>({payload:i,error:(n&&n.serializeError||ma)(e||"Rejected"),meta:{...r||{},arg:o,requestId:t,rejectedWithValue:!!i,requestStatus:"rejected",aborted:"AbortError"===e?.name,condition:"ConditionError"===e?.name}})));return Object.assign((function(e){return(s,a,c)=>{const l=n?.idGenerator?n.idGenerator(e):((e=21)=>{let t="",n=e;for(;n--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t})(),d=new AbortController;let u;function h(e){u=e,d.abort()}const f=async function(){let f;try{let r=n?.condition?.(e,{getState:a,extra:c});if(null!==(p=r)&&"object"==typeof p&&"function"==typeof p.then&&(r=await r),!1===r||d.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};const g=new Promise(((e,t)=>d.signal.addEventListener("abort",(()=>t({name:"AbortError",message:u||"Aborted"})))));s(i(l,e,n?.getPendingMeta?.({requestId:l,arg:e},{getState:a,extra:c}))),f=await Promise.race([g,Promise.resolve(t(e,{dispatch:s,getState:a,extra:c,requestId:l,signal:d.signal,abort:h,rejectWithValue:(e,t)=>new ga(e,t),fulfillWithValue:(e,t)=>new va(e,t)})).then((t=>{if(t instanceof ga)throw t;return t instanceof va?o(t.payload,l,e,t.meta):o(t,l,e)}))])}catch(t){f=t instanceof ga?r(null,l,e,t.payload,t.meta):r(t,l,e)}var p;return n&&!n.dispatchConditionRejection&&r.match(f)&&f.meta.condition||s(f),f}();return Object.assign(f,{abort:h,requestId:l,arg:e,unwrap:()=>f.then(wa)})}}),{pending:i,rejected:r,fulfilled:o,settled:fa(r,o),typePrefix:e})}return e.withTypes=()=>e,e})();function wa(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}var ya=Symbol.for("rtk-slice-createasyncthunk");function ka(e,t){return`${e}/${t}`}function Ia(e,t,n,o){function i(i,...r){let s=n.call(e,i);if(void 0===s){if(!o)throw new Error("selectState returned undefined for an uninjected slice reducer");s=e.getInitialState()}return t(s,...r)}return i.unwrapped=t,i}var Sa=function({creators:e}={}){const t=e?.asyncThunk?.[ya];return function(e){const{name:n,reducerPath:o=n}=e;if(!n)throw new Error("`name` is a required option for createSlice");"undefined"!=typeof process&&void 0===e.initialState&&console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");const i=("function"==typeof e.reducers?e.reducers(function(){function e(e,t){return{_reducerDefinitionType:"asyncThunk",payloadCreator:e,...t}}return e.withTypes=()=>e,{reducer:e=>Object.assign({[e.name]:(...t)=>e(...t)}[e.name],{_reducerDefinitionType:"reducer"}),preparedReducer:(e,t)=>({_reducerDefinitionType:"reducerWithPrepare",prepare:e,reducer:t}),asyncThunk:e}}()):e.reducers)||{},r=Object.keys(i),s={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},a={addCase(e,t){const n="string"==typeof e?e:e.type;if(!n)throw new Error("`context.addCase` cannot be called with an empty action type");if(n in s.sliceCaseReducersByType)throw new Error("`context.addCase` cannot be called with two reducers for the same action type: "+n);return s.sliceCaseReducersByType[n]=t,a},addMatcher:(e,t)=>(s.sliceMatchers.push({matcher:e,reducer:t}),a),exposeAction:(e,t)=>(s.actionCreators[e]=t,a),exposeCaseReducer:(e,t)=>(s.sliceCaseReducersByName[e]=t,a)};function c(){if("object"==typeof e.extraReducers)throw new Error("The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");const[t={},n=[],o]="function"==typeof e.extraReducers?ha(e.extraReducers):[e.extraReducers],i={...t,...s.sliceCaseReducersByType};return function(e,t){if("object"==typeof t)throw new Error("The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");let n,[o,i,r]=ha(t);if(function(e){return"function"==typeof e}(e))n=()=>Ys(e());else{const t=Ys(e);n=()=>t}function s(e=n(),t){let s=[o[t.type],...i.filter((({matcher:e})=>e(t))).map((({reducer:e})=>e))];return 0===s.filter((e=>!!e)).length&&(s=[r]),s.reduce(((e,n)=>{if(n){if(zr(e)){const o=n(e,t);return void 0===o?e:o}if(Br(e))return Es(e,(e=>n(e,t)));{const o=n(e,t);if(void 0===o){if(null===e)return e;throw new Error("A case reducer on a non-draftable value must not return undefined")}return o}}return e}),e)}return s.getInitialState=n,s}(e.initialState,(e=>{for(let t in i)e.addCase(t,i[t]);for(let t of s.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);o&&e.addDefaultCase(o)}))}r.forEach((o=>{const r=i[o],s={reducerName:o,type:ka(n,o),createNotation:"function"==typeof e.reducers};!function(e){return"asyncThunk"===e._reducerDefinitionType}(r)?function({type:e,reducerName:t,createNotation:n},o,i){let r,s;if("reducer"in o){if(n&&!function(e){return"reducerWithPrepare"===e._reducerDefinitionType}(o))throw new Error("Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");r=o.reducer,s=o.prepare}else r=o;i.addCase(e,r).exposeCaseReducer(t,r).exposeAction(t,s?Ks(e,s):Ks(e))}(s,r,a):function({type:e,reducerName:t},n,o,i){if(!i)throw new Error("Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");const{payloadCreator:r,fulfilled:s,pending:a,rejected:c,settled:l,options:d}=n,u=i(e,r,d);o.exposeAction(t,u),s&&o.addCase(u.fulfilled,s);a&&o.addCase(u.pending,a);c&&o.addCase(u.rejected,c);l&&o.addMatcher(u.settled,l);o.exposeCaseReducer(t,{fulfilled:s||ja,pending:a||ja,rejected:c||ja,settled:l||ja})}(s,r,a,t)}));const l=e=>e,d=new WeakMap;let u;const h={name:n,reducerPath:o,reducer:(e,t)=>(u||(u=c()),u(e,t)),actions:s.actionCreators,caseReducers:s.sliceCaseReducersByName,getInitialState:()=>(u||(u=c()),u.getInitialState()),getSelectors(t=l){const n=Zs(d,this,{insert:()=>new WeakMap});return Zs(n,t,{insert:()=>{const n={};for(const[o,i]of Object.entries(e.selectors??{}))n[o]=Ia(this,i,t,this!==h);return n}})},selectSlice(e){let t=e[this.reducerPath];if(void 0===t){if(this===h)throw new Error("selectSlice returned undefined for an uninjected slice reducer");t=this.getInitialState()}return t},get selectors(){return this.getSelectors(this.selectSlice)},injectInto(e,{reducerPath:t,...n}={}){const o=t??this.reducerPath;return e.inject({reducerPath:o,reducer:this.reducer},n),{...this,reducerPath:o}}};return h}}();function ja(){}var xa="listenerMiddleware";Ks(`${xa}/add`),Ks(`${xa}/removeAll`),Ks(`${xa}/remove`);const Ca=["error","warn","info","debug"],Ea=c((e=>{var t,n,r,s;return s=class extends e{constructor(){super(...arguments),t.add(this),n.set(this,o(this,t,"m",r).call(this,console))}set logger(e){i(this,n,o(this,t,"m",r).call(this,e),"f")}get logger(){return o(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,r=function(e){return Ca.reduce(((t,n)=>(t[n]=(...t)=>{var o;this.onLogEvent(n,t),null===(o=e[n])||void 0===o||o.call(e,...t)},t)),{})},s})),Aa="undefined"!=typeof localStorage,Oa=Aa&&localStorage.getItem("base.content.url")||"",Ua=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,_a=c((e=>{var t,n;return n=class extends e{constructor(){super(...arguments),t.set(this,!0)}connectedCallback(){var e,n;null===(e=super.connectedCallback)||void 0===e||e.call(this),(null===(n=this.shadowRoot)||void 0===n?void 0:n.isConnected)&&o(this,t,"f")&&(i(this,t,!1,"f"),this.init())}async init(){}},t=new WeakMap,n})),Ra=c((e=>{var t,n;const i=r(Ea,_a)(e);return n=class extends i{constructor(){super(...arguments),t.set(this,{})}async init(){var e,n,i;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),n=this,i=e=>{var n;null===(n=o(this,t,"f")[e])||void 0===n||n.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(n.attributes).forEach((e=>i(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&i(e.attributeName)}))})).observe(n,{attributes:!0})}observeAttribute(e,n){o(this,t,"f")[e]||(o(this,t,"f")[e]=[]);const i=o(this,t,"f")[e].push(n);return()=>o(this,t,"f")[e].splice(i,1)}observeAttributes(e,t){const n=e.reduce(((e,n)=>(e.push(this.observeAttribute(n,t)),e)),[]);return()=>n.forEach((e=>e()))}},t=new WeakMap,n})),Ta=e=>t=>{var n,i,s;const a=r(Ea,_a,Ra)(t),c=Object.keys(e);return s=class extends a{constructor(...e){super(...e),n.add(this),this.observeAttributes(c,o(this,n,"m",i).bind(this))}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),c.forEach((e=>o(this,n,"m",i).call(this,e,this.getAttribute(e))))}},n=new WeakSet,i=function(t,n){const o=e[t],i="function"==typeof o?o(t,n):o;i&&this.logger.error(i)},s};Ta.missingAttrValidator=Ua;const Ma=c((e=>{const t=r(Ta({"project-id":Ua}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),La=c((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")}}));const Pa=c((e=>{const t=r(Ea,Ma,La)(e);return class extends t{async fetchStaticResource(e,t){const n=function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:o}){const i=new URL(Oa||o||"https://static.descope.com/pages");return i.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(i.pathname,e,n,t),i.toString()}({projectId:this.projectId,filename:e,baseUrl:this.baseStaticUrl}),o=await fetch(n,{cache:"default"});return o.ok||this.logger.error(`Error fetching URL ${n} [${o.status}]`),{body:await o[t](),headers:Object.fromEntries(o.headers.entries())}}get baseStaticUrl(){return this.getAttribute("base-static-url")}}})),Wa=c((e=>{var t,n,s;const a=r(Pa)(e);return s=class extends a{constructor(){super(...arguments),t.set(this,void 0),n.set(this,(async()=>{try{const{body:e,headers:t}=await this.fetchStaticResource("config.json","json");return{projectConfig:e,executionContext:{geo:t["x-geo"]}}}catch(e){this.logger.error("Cannot fetch config file","make sure that your projectId & flowId are correct")}}))}get config(){return o(this,t,"f")||i(this,t,o(this,n,"f").call(this),"f"),o(this,t,"f")}},t=new WeakMap,n=new WeakMap,s})),$a=c((e=>{var t,n,s,a,c,l,d;return d=class extends(r(_a,Ea)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),this.attributeChangedCallback=(e,n,i)=>{var r;null===(r=super.attributeChangedCallback)||void 0===r||r.call(this,e,n,i),"debug"===e&&o(this,t,"m",c).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(e,n){var i;null===(i=super.onLogEvent)||void 0===i||i.call(this,e,n),"error"===e&&o(this,t,"m",l).call(this,n[0]||"Error",n[1])}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),o(this,t,"m",c).call(this)}},n=new WeakMap,t=new WeakSet,s=function(){var e;null===(e=o(this,n,"f"))||void 0===e||e.remove(),i(this,n,null,"f")},a=async function(){i(this,n,document.createElement("descope-debugger"),"f"),Object.assign(o(this,n,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),await Promise.resolve().then((function(){return gc})),document.body.appendChild(o(this,n,"f"))},c=function(){this.debug?o(this,t,"m",a).call(this):o(this,t,"m",s).call(this)},l=function(e,t){var i;e&&(null===(i=o(this,n,"f"))||void 0===i||i.updateData({title:e,description:t}))},d})),Da="load-descope-ui",Na="base.ui.components.url",Fa=Aa&&localStorage.getItem(Na)||"https://static.descope.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",qa=Aa&&localStorage.getItem(Na)||"https://cdn.jsdelivr.net/npm/@descope/web-components-ui@<version>/dist/umd/index.js",za=e=>{const t=document.createElement("script");return t.id=e,t},Ba=(e,t)=>e.replace("<version>",t),Va=c((e=>{var t,n,s,a,c,l,d,u,h,f,p,g;const v=r(Ea,Wa)(e);return g=class extends v{constructor(){super(...arguments),t.add(this),n.set(this,Symbol("errorCbs")),s.set(this,Symbol("loadCbs")),h.set(this,void 0)}get descopeUi(){return o(this,h,"f")||i(this,h,o(this,t,"m",p).call(this),"f"),o(this,h,"f")}async loadDescopeUiComponents(e){const n=Array.isArray(e)?e:(e=>[...Array.from(e.content.querySelectorAll("*")).reduce(((e,t)=>t.localName.startsWith("descope-")?e.add(t.localName):e),new Set)])(e);return Promise.all(n.map((e=>o(this,t,"m",f).call(this,e))))}},n=new WeakMap,s=new WeakMap,h=new WeakMap,t=new WeakSet,a=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return n?this.logger.debug(`Got component version "${n}"`):this.logger.error("Could not get components version"),n},c=function(e){const t=o(this,n,"f"),i=o(this,s,"f");e[t]=[],e[i]=[],Object.defineProperty(e,"onerror",{set(n){e[t].push(n)}}),Object.defineProperty(e,"onload",{set(t){e[i].push(t)}})},l=async function(e,n){this.logger.debug("Trying to load DescopeUI from a fallback URL");const i=za("load-descope-ui-fallback-script");document.body.append(i),i.addEventListener("error",(()=>{e.forEach((e=>e(`Cannot load DescopeUI from fallback URL, Make sure this URL is valid and return the correct script: "${i.src}"`)))})),i.addEventListener("load",(()=>{n.forEach((e=>e()))})),i.src=Ba(qa,await o(this,t,"m",a).call(this))},d=function(e){e.addEventListener("error",(()=>{e[o(this,n,"f")].forEach((t=>t(`Cannot load DescopeUI from main URL, Make sure this URL is valid and return the correct script: "${e.src}"`))),o(this,t,"m",l).call(this,e[o(this,n,"f")],e[o(this,s,"f")])})),e.addEventListener("load",(()=>{e[o(this,s,"f")].forEach((e=>e()))}))},u=async function(){if(document.querySelector(`script#${Da}`))this.logger.debug("DescopeUI loading script already exists",this);else{this.logger.debug("DescopeUI loading script does not exist, creating it",this);const e=za(Da);document.body.append(e),o(this,t,"m",c).call(this,e),o(this,t,"m",d).call(this,e),e.src=Ba(Fa,await o(this,t,"m",a).call(this))}return document.getElementById(Da)},f=async function(e){if(!!customElements.get(e))return void this.logger.debug(`Loading component "${e}" is skipped as it is already defined`);const t=await this.descopeUi;if(t[e])try{return await t[e]()}catch(t){if("NotSupportedError"!==t.name)throw t;console.debug(`Encountered an error while attempting to define the "${e}" component, it is likely that this component is already defined`)}else this.logger.error(`Cannot load UI component "${e}"`,`Descope UI does not have a component named "${e}", available components are: "${Object.keys(t).join(", ")}"`)},p=function(){return new Promise((e=>{globalThis.DescopeUI&&e(globalThis.DescopeUI),o(this,t,"m",u).call(this).then((t=>{t.onerror=this.logger.error,t.onload=()=>{this.logger.debug("DescopeUI was loaded"),e(globalThis.DescopeUI)},setTimeout((()=>{globalThis.DescopeUI&&e(globalThis.DescopeUI)}))}))}))},g})),Ha="content-root",Ka="root",Ga=c((e=>class extends e{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n\n <style>\n #${Ka}, #${Ha} {\n height: 100%;\n }\n #${Ka} {\n position: relative;\n height: fit-content;\n }\n </style>\n <div id="${Ka}">\n <div id="${Ha}"></div>\n </div>\n `,this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById(Ha),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(Ka)}})),Ja="descope-modal",Xa=c((e=>{var t,n;const i=r(_a,Ga,Va)(e);return n=class extends i{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends yr{setContent(t){e(t),super.setContent(t)}}})())}createModal(e){const n=((e={})=>{const t=document.createElement(Ja);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(o(this,t,"f"))(n,{logger:this.logger})}async init(){var e;this.loadDescopeUiComponents([Ja]),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},t=new WeakMap,n})),Ya="descope-notification";c((e=>{var t,n;const i=r(_a,Ga,Va)(e);return n=class extends i{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends kr{setContent(t){const n="string"==typeof t?s(t):t;e(n),super.setContent(n)}}})())}createNotification(e){const n=((e={})=>{const t=document.createElement(Ya);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(o(this,t,"f"))(n,{logger:this.logger})}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.loadDescopeUiComponents([Ya])}},t=new WeakMap,n}));const Za=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',Qa=c((e=>{var t,n,s,a,c,l,d,u,h;const f=r(Ta({theme:Za}),Pa,_a,Va,Wa,Ga,Ra)(e);return h=class extends f{constructor(){super(...arguments),t.add(this),n.set(this,void 0)}get theme(){var e,t;const n=this.getAttribute("theme");if("os"===n){return window.matchMedia&&(null===(t=null===(e=window.matchMedia)||void 0===e?void 0:e.call(window,"(prefers-color-scheme: dark)"))||void 0===t?void 0:t.matches)?"dark":"light"}return n||"light"}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),o(this,t,"m",c).call(this),o(this,t,"m",l).call(this),o(this,t,"m",d).call(this),o(this,t,"m",u).call(this),this.observeAttributes(["theme"],(()=>{o(this,t,"m",d).call(this),o(this,t,"m",u).call(this)}))}},n=new WeakMap,t=new WeakSet,s=async function(){try{const{body:e}=await this.fetchStaticResource("theme.json","json");if(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(Na))try{this.logger.warn("You are in DEV mode, and UI components override URL was found\ntrying to merge project theme with the default theme of the UI components");const t=await(async()=>{const e=localStorage.getItem(Na),t=null==e?void 0:e.replace(/[^\/]+$/,"DescopeDev.js");console.warn("Trying to load DescopeDev.js from",t);const n=document.createElement("script");if(n.src=t,document.body.appendChild(n),await new Promise(((e,t)=>{n.onload=e,n.onerror=t})),globalThis.DescopeDev){const{themeToStyle:e,defaultTheme:t,darkTheme:n}=globalThis.DescopeDev;return{light:e(t),dark:e(n)}}})();t&&(e.light.components=Object.assign(Object.assign({},t.light.components),e.light.components),e.dark.components=Object.assign(Object.assign({},t.dark.components),e.dark.components),this.logger.warn("Theme was merged successfully"),console.log("%cNOTICE! This is not the theme that will be used in production!\n\nMake sure to test it without the override UI components URL!","color: black; background-color:yellow; font-size: x-large"))}catch(e){this.logger.error("Failed to merge UI components theme\n",e)}return e}catch(e){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}},a=function(){return o(this,n,"f")||(i(this,n,o(this,t,"m",s).call(this),"f"),o(this,n,"f").then((e=>this.logger.debug("Fetched theme",e)))),o(this,n,"f")},c=async function(){var e,n;const i=await o(this,t,"a",a);if(!i)return;const r=document.createElement("style");r.innerText=((null===(e=null==i?void 0:i.light)||void 0===e?void 0:e.globals)||"")+((null===(n=null==i?void 0:i.dark)||void 0===n?void 0:n.globals)||""),this.shadowRoot.appendChild(r)},l=async function(){var e,n;const i=Object.assign({},await o(this,t,"a",a));if(!i)return;const r=await this.descopeUi;(null==r?void 0:r.componentsThemeManager)&&(r.componentsThemeManager.themes={light:null===(e=null==i?void 0:i.light)||void 0===e?void 0:e.components,dark:null===(n=null==i?void 0:i.dark)||void 0===n?void 0:n.components})},d=async function(){var e,t;const{projectConfig:n}=await this.config,o=null===(t=null===(e=null==n?void 0:n.cssTemplate)||void 0===e?void 0:e[this.theme])||void 0===t?void 0:t.fonts;o&&Object.values(o).forEach((e=>{e.url&&(this.logger.debug(`Loading font from URL "${e.url}"`),(e=>{const t=document.createElement("link");t.href=e,t.rel="stylesheet",document.head.appendChild(t)})(e.url))}))},u=async function(){this.rootElement.setAttribute("data-theme",this.theme);const e=await this.descopeUi;(null==e?void 0:e.componentsThemeManager)&&(e.componentsThemeManager.currentThemeName=this.theme)},h})),ec=e=>c((t=>{const n=Sa(e),o=Object.assign(Object.assign({},n.actions),e.asyncActions);return class extends(r(Ea)(t)){constructor(...e){super(...e);const t=ua({reducer:n.reducer,middleware:e=>e({thunk:{extraArgument:this},serializableCheck:!1}),devTools:!1}),i=e=>async(...n)=>{const o=await t.dispatch(e(...n));try{wa(o)}catch(e){this.logger.error(e.message,o.type,e.stack)}return o},r=Object.keys(o).reduce(((e,t)=>(e[t]=i(o[t]),e)),{});this.actions=r,this.subscribe=(e,n=e=>e)=>t.subscribe((()=>e(n(t.getState()))))}}}));c((e=>class extends(Ea(e)){validateForm(e){return this.getFormInputs(e).every((e=>{var t,n;return null===(t=e.reportValidity)||void 0===t||t.call(e),null===(n=e.checkValidity)||void 0===n?void 0:n.call(e)}))}getFormInputs(e){return e?Array.from(e.querySelectorAll("[name]")):(this.logger.debug("cannot get form inputs, no root element was received"),[])}getFormData(e){return this.getFormInputs(e).reduce(((e,t)=>Object.assign(e,{[t.getAttribute("name")]:t.value})),{})}setFormData(e,t){this.getFormInputs(e).forEach((e=>{t.hasOwnProperty(e.getAttribute("name"))&&(e.value=t[e.getAttribute("name")])}))}resetFormData(e){this.getFormInputs(e).forEach((e=>{e.value="",e.checked=!1}))}getFormFieldNames(e){return this.getFormInputs(e).map((e=>e.name))}disableFormField(e,t){var n;null===(n=this.getFormInputs(e).find((e=>e.name===t)))||void 0===n||n.setAttribute("disabled","true")}removeFormField(e,t){var n;null===(n=this.getFormInputs(e).find((e=>e.name===t)))||void 0===n||n.remove()}}));const tc=c((e=>class extends e{get baseStaticUrl(){return this.getAttribute("base-static-url")}})),nc=(e,t,n,o={})=>{var i,r,s,a;return[Math.min(Math.max(t,("all"===o.left?e.offsetWidth:null!==(i=o.left)&&void 0!==i?i:0)-e.offsetWidth),window.innerWidth-("all"===o.right?e.offsetWidth:null!==(r=o.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===o.top?e.offsetHeight:null!==(s=o.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===o.bottom?e.offsetHeight:null!==(a=o.bottom)&&void 0!==a?a:0))]};var oc,ic,rc,sc,ac,cc,lc,dc,uc,hc;const fc=document.createElement("template");fc.innerHTML=`\n<style>\n .debugger {\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n</style>\n\n<div style="top:32px; left:${window.innerWidth-300-32}px;" class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n`;class pc extends HTMLElement{constructor(){var e;super(),oc.add(this),ic.set(this,new p({messages:[]})),rc.set(this,void 0),sc.set(this,void 0),ac.set(this,void 0),cc.set(this,{resize:o(this,oc,"m",hc).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(fc.content.cloneNode(!0)),i(this,rc,this.shadowRoot.querySelector(".debugger"),"f"),i(this,sc,o(this,rc,"f").querySelector(".content"),"f"),i(this,ac,o(this,rc,"f").querySelector(".header"),"f")}updateData(e){o(this,ic,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let o=0,i=0,r=0,s=0;function a(t){t.preventDefault(),o=r-t.clientX,i=s-t.clientY,r=t.clientX,s=t.clientY;const[a,c]=nc(e,e.offsetLeft-o,e.offsetTop-i,n);e.style.top=`${c}px`,e.style.left=`${a}px`}function c(){document.onmouseup=null,document.onmousemove=null}function l(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=c,document.onmousemove=a}t?t.onmousedown=l:e.onmousedown=l})(o(this,rc,"f"),o(this,ac,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,cc,"f").resize),(e=o(this,rc,"f")).onmousemove=t=>{var n;const o=t.target;(o.w&&o.w!==o.offsetWidth||o.h&&o.h!==o.offsetHeight)&&(null===(n=e.onresize)||void 0===n||n.call(e,t)),o.w=o.offsetWidth,o.h=o.offsetHeight},o(this,rc,"f").onresize=o(this,oc,"m",uc).bind(this),o(this,ic,"f").subscribe(o(this,oc,"m",lc).bind(this))}disconnectedCallback(){o(this,ic,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,cc,"f").resize)}}ic=new WeakMap,rc=new WeakMap,sc=new WeakMap,ac=new WeakMap,cc=new WeakMap,oc=new WeakSet,lc=function(e){o(this,oc,"m",dc).call(this,e),o(this,oc,"m",uc).call(this)},dc=function(e){o(this,sc,"f").innerHTML=e.messages.map((e=>`\n <div class="msg">\n <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.99984 13.167L8.99984 10.167L11.9998 13.167L13.1665 12.0003L10.1665 9.00033L13.1665 6.00033L11.9998 4.83366L8.99984 7.83366L5.99984 4.83366L4.83317 6.00033L7.83317 9.00033L4.83317 12.0003L5.99984 13.167ZM8.99984 17.3337C7.84706 17.3337 6.76373 17.1148 5.74984 16.677C4.73595 16.2398 3.854 15.6462 3.104 14.8962C2.354 14.1462 1.76039 13.2642 1.32317 12.2503C0.885393 11.2364 0.666504 10.1531 0.666504 9.00033C0.666504 7.84755 0.885393 6.76421 1.32317 5.75033C1.76039 4.73644 2.354 3.85449 3.104 3.10449C3.854 2.35449 4.73595 1.7606 5.74984 1.32283C6.76373 0.885603 7.84706 0.666992 8.99984 0.666992C10.1526 0.666992 11.2359 0.885603 12.2498 1.32283C13.2637 1.7606 14.1457 2.35449 14.8957 3.10449C15.6457 3.85449 16.2393 4.73644 16.6765 5.75033C17.1143 6.76421 17.3332 7.84755 17.3332 9.00033C17.3332 10.1531 17.1143 11.2364 16.6765 12.2503C16.2393 13.2642 15.6457 14.1462 14.8957 14.8962C14.1457 15.6462 13.2637 16.2398 12.2498 16.677C11.2359 17.1148 10.1526 17.3337 8.99984 17.3337ZM8.99984 15.667C10.8609 15.667 12.4373 15.0212 13.729 13.7295C15.0207 12.4378 15.6665 10.8614 15.6665 9.00033C15.6665 7.13921 15.0207 5.56283 13.729 4.27116C12.4373 2.97949 10.8609 2.33366 8.99984 2.33366C7.13873 2.33366 5.56234 2.97949 4.27067 4.27116C2.979 5.56283 2.33317 7.13921 2.33317 9.00033C2.33317 10.8614 2.979 12.4378 4.27067 13.7295C5.56234 15.0212 7.13873 15.667 8.99984 15.667Z" fill="#ED404A"/>\n</svg>\n\n <div class="msg_content">\n <div class="msg_title">\n ${e.title}\n </div>\n <div class="msg_desc">\n ${e.description||""}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},uc=function(){o(this,sc,"f").querySelectorAll(".msg").forEach((e=>{const t=e,n=t.querySelector(".msg_desc"),o=n.scrollWidth>n.clientWidth,i=n.clientHeight>20;o||i?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},hc=function(){const[e,t]=nc(o(this,rc,"f"),Number.parseInt(o(this,rc,"f").style.left,10),Number.parseInt(o(this,rc,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,rc,"f").style.top=`${t}px`,o(this,rc,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",pc);var gc=Object.freeze({__proto__:null});const vc=e=>e.me.data,mc=Ns(vc,(e=>e.picture)),bc=Ns(vc,(e=>e.email)),wc=Ns(vc,(e=>e.verifiedEmail)),yc=Ns(vc,(e=>e.name)),kc=Ns(vc,(e=>e.phone)),Ic=Ns(vc,(e=>e.verifiedPhone)),Sc=Ns(vc,(e=>e.webauthn));Ns(vc,(e=>e.password));const jc=e=>(...t)=>n=>{n.addCase(e.pending,((e,n)=>{t.forEach((({onPending:t})=>{null==t||t(e,n)}))})),n.addCase(e.fulfilled,((e,n)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,n)}))})),n.addCase(e.rejected,((e,n)=>{t.forEach((({onRejected:t})=>{null==t||t(e,n)}))}))},xc=ba("users/me",((e,{extra:{api:t}})=>t.user.me())),Cc=jc(xc)({onFulfilled:(e,t)=>{e.me.data=t.payload}},(Ec=e=>e.me,{onFulfilled:e=>{Ec(e).loading=!1},onPending:e=>{Ec(e).loading=!0,Ec(e).error=null},onRejected:(e,t)=>{Ec(e).loading=!1,Ec(e).error=t.error}}));var Ec;const Ac={action:xc,reducer:Cc},Oc=ba("users/logout",((e,{extra:{api:t}})=>t.user.logout())),Uc={action:Oc,reducer:jc(Oc)({})},_c={me:{loading:!1,error:null,data:{}}},Rc={me:"/v1/auth/me"},Tc=()=>n(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({loginIds:["user@company.com"],externalIds:["user@company.com"],userId:"user-1",name:"Test User",email:"user@company.com",roleNames:["Role"],phone:"+1-202-555-010",verifiedEmail:!0,verifiedPhone:!0,userTenants:[],status:"enabled",editable:!0,createdTime:(new Date).getTime(),customAttributes:{},familyName:"",givenName:"",middleName:"",picture:void 0,password:!0,SAML:!1,test:!1,TOTP:!1,webauthn:!0})}))})),Mc=({httpClient:e,mock:t})=>({me:()=>n(void 0,void 0,void 0,(function*(){if(t)return Tc();const o=yield e.get(Rc.me);return yield(e=>n(void 0,void 0,void 0,(function*(){const t=yield e.text(),n=JSON.parse(t);if(!e.ok){const t=`${n.errorDescription}${n.errorMessage?`: ${n.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(n),e.text=()=>Promise.resolve(t)})))(o),o.json()}))}),Lc=c((e=>{var t,s,a,c;const l=r(Ma,Ra,Ea,La)(e);return c=class extends l{constructor(){super(...arguments),t.add(this),s.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get api(){return o(this,s,"f")||o(this,t,"m",a).call(this),o(this,s,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),this.observeAttributes(["project-id","base-url"],(()=>{o(this,s,"f")&&o(this,t,"m",a).call(this)}))}))}},s=new WeakMap,t=new WeakSet,a=function(){this.logger.debug("creating an sdk instance"),i(this,s,((e,t,o)=>{const i=ao(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":o,"x-descope-widget-version":"0.0.96"}}));return{user:Object.assign(Object.assign({},Mc({httpClient:i.httpClient,mock:t})),{logout:t?()=>n(void 0,void 0,void 0,(function*(){})):i.logout})}})({projectId:this.projectId,baseUrl:this.baseUrl},"true"===this.mock,this.widgetId),"f")},c})),Pc=c((e=>{const t=r(ec({name:"widget",initialState:_c,reducers:{},extraReducers:e=>{Ac.reducer(e),Uc.reducer(e)},asyncActions:{getMe:Ac.action,logout:Uc.action}}),_a,Ea,Lc)(e);return class extends t{constructor(...e){super(...e),this.state=_c,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),Wc=c((e=>{const t=r(Pa,Ta({"widget-id":Ta.missingAttrValidator}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(e){return n(this,void 0,void 0,(function*(){return(yield this.fetchStaticResource(`user-profile-widget/${this.widgetId}/${e}`,"text")).body}))}}})),$c=c((e=>{var t,i,a;return a=class extends(r(Ea,_a,Va,Ga,Wc,Pc)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return n(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),yield Promise.all([this.actions.getMe(),o(this,t,"m",i).call(this)]),this.onWidgetRootReady()}))}},t=new WeakSet,i=function(){return n(this,void 0,void 0,(function*(){const e=s(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},a})),Dc=(e={})=>{const t=s("<descope-wc></descope-wc>");return Object.entries(e).forEach((([e,n])=>{t.content.querySelector("descope-wc").setAttribute((e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_.]+/g,"-").toLowerCase())(e),n)})),t};function Nc(e){return new URLSearchParams(window.location.search).get(e)}const Fc=c((e=>{var t,s,c,l,d,u,h,f,p;return p=class extends(r(Pc,Ea,$c,Xa,tc)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),c.set(this,void 0),h.set(this,a((e=>{this.avatar.image=e}))),f.set(this,a((e=>{this.avatar.displayName=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",u).call(this),o(this,t,"m",l).call(this),o(this,h,"f").call(this,mc(this.state)),o(this,f,"f").call(this,yc(this.state)),this.subscribe(o(this,h,"f").bind(this),mc),this.subscribe(o(this,f,"f").bind(this),yc)}))}},s=new WeakMap,c=new WeakMap,h=new WeakMap,f=new WeakMap,t=new WeakSet,l=function(){i(this,s,this.createModal({"data-id":"update-pic"}),"f"),i(this,c,new xr((()=>{var e;return null===(e=o(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),o(this,s,"f").afterClose=o(this,t,"m",d).bind(this),o(this,t,"m",d).call(this)},d=function(){o(this,s,"f").setContent(Dc({projectId:this.projectId,flowId:this.avatar.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),o(this,c,"f").onSuccess((()=>{o(this,s,"f").close(),this.actions.getMe()}))},u=function(){this.avatar=new Ir((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-avatar")}),{logger:this.logger}),this.avatar.onClick((()=>{o(this,s,"f").open()}))},p})),qc=c((e=>{var t,s,c,l,d,u,h,f,p,g,v,m,b;return b=class extends(r(Pc,Ea,$c,Xa)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),c.set(this,void 0),l.set(this,void 0),d.set(this,void 0),v.set(this,a((e=>{this.emailUserAttr.value=e}))),m.set(this,a((e=>{this.emailUserAttr.badgeLabel=e?"":"Unverified"})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",g).call(this),o(this,t,"m",u).call(this),o(this,t,"m",f).call(this),o(this,v,"f").call(this,bc(this.state)),o(this,m,"f").call(this,wc(this.state)),this.subscribe(o(this,v,"f").bind(this),bc),this.subscribe(o(this,m,"f").bind(this),wc)}))}},s=new WeakMap,c=new WeakMap,l=new WeakMap,d=new WeakMap,v=new WeakMap,m=new WeakMap,t=new WeakSet,u=function(){i(this,s,this.createModal({"data-id":"edit-email"}),"f"),i(this,c,new xr((()=>{var e;return null===(e=o(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),o(this,s,"f").afterClose=o(this,t,"m",h).bind(this),o(this,t,"m",h).call(this)},h=function(){o(this,s,"f").setContent(Dc({projectId:this.projectId,flowId:this.emailUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),o(this,c,"f").onSuccess((()=>{o(this,s,"f").close(),this.actions.getMe()}))},f=function(){i(this,l,this.createModal({"data-id":"delete-email"}),"f"),i(this,d,new xr((()=>{var e;return null===(e=o(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),o(this,l,"f").afterClose=o(this,t,"m",p).bind(this),o(this,t,"m",p).call(this)},p=function(){o(this,l,"f").setContent(Dc({projectId:this.projectId,flowId:this.emailUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),o(this,d,"f").onSuccess((()=>{o(this,l,"f").close(),this.actions.getMe()}))},g=function(){this.emailUserAttr=new Sr((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="email"]')}),{logger:this.logger}),this.emailUserAttr.onEditClick((()=>{o(this,s,"f").open()})),this.emailUserAttr.onDeleteClick((()=>{o(this,l,"f").open()}))},b})),zc=c((e=>{var t,s,c,l,d,u,h,f,p,g,v,m;return m=class extends(r(Pc,Ea,$c,Xa)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),c.set(this,void 0),l.set(this,void 0),d.set(this,void 0),v.set(this,a((e=>{this.nameUserAttr.value=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",g).call(this),o(this,t,"m",u).call(this),o(this,t,"m",f).call(this),o(this,v,"f").call(this,yc(this.state)),this.subscribe(o(this,v,"f").bind(this),yc)}))}},s=new WeakMap,c=new WeakMap,l=new WeakMap,d=new WeakMap,v=new WeakMap,t=new WeakSet,u=function(){i(this,s,this.createModal({"data-id":"edit-name"}),"f"),i(this,c,new xr((()=>{var e;return null===(e=o(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),o(this,s,"f").afterClose=o(this,t,"m",h).bind(this),o(this,t,"m",h).call(this)},h=function(){o(this,s,"f").setContent(Dc({projectId:this.projectId,flowId:this.nameUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),o(this,c,"f").onSuccess((()=>{o(this,s,"f").close(),this.actions.getMe()}))},f=function(){i(this,l,this.createModal({"data-id":"delete-name"}),"f"),i(this,d,new xr((()=>{var e;return null===(e=o(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),o(this,l,"f").afterClose=o(this,t,"m",p).bind(this),o(this,t,"m",p).call(this)},p=function(){o(this,l,"f").setContent(Dc({projectId:this.projectId,flowId:this.nameUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),o(this,d,"f").onSuccess((()=>{o(this,l,"f").close(),this.actions.getMe()}))},g=function(){this.nameUserAttr=new Sr((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="name"]')}),{logger:this.logger}),this.nameUserAttr.onEditClick((()=>{o(this,s,"f").open()})),this.nameUserAttr.onDeleteClick((()=>{o(this,l,"f").open()}))},m})),Bc=c((e=>{var t,s,c,l,d,u,h,f,p,g,v,m,b;return b=class extends(r(Pc,Ea,$c,Xa)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),c.set(this,void 0),l.set(this,void 0),d.set(this,void 0),v.set(this,a((e=>{this.phoneUserAttr.value=e}))),m.set(this,a((e=>{this.phoneUserAttr.badgeLabel=e?"":"Unverified"})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",g).call(this),o(this,t,"m",u).call(this),o(this,t,"m",f).call(this),o(this,v,"f").call(this,kc(this.state)),o(this,m,"f").call(this,Ic(this.state)),this.subscribe(o(this,v,"f").bind(this),kc),this.subscribe(o(this,m,"f").bind(this),Ic)}))}},s=new WeakMap,c=new WeakMap,l=new WeakMap,d=new WeakMap,v=new WeakMap,m=new WeakMap,t=new WeakSet,u=function(){i(this,s,this.createModal({"data-id":"edit-phone"}),"f"),i(this,c,new xr((()=>{var e;return null===(e=o(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),o(this,s,"f").afterClose=o(this,t,"m",h).bind(this),o(this,t,"m",h).call(this)},h=function(){o(this,s,"f").setContent(Dc({projectId:this.projectId,flowId:this.phoneUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),o(this,c,"f").onSuccess((()=>{o(this,s,"f").close(),this.actions.getMe()}))},f=function(){i(this,l,this.createModal({"data-id":"delete-phone"}),"f"),i(this,d,new xr((()=>{var e;return null===(e=o(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),o(this,l,"f").afterClose=o(this,t,"m",p).bind(this),o(this,t,"m",p).call(this)},p=function(){o(this,l,"f").setContent(Dc({projectId:this.projectId,flowId:this.phoneUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),o(this,d,"f").onSuccess((()=>{o(this,l,"f").close(),this.actions.getMe()}))},g=function(){this.phoneUserAttr=new Sr((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="phone"]')}),{logger:this.logger}),this.phoneUserAttr.onEditClick((()=>{o(this,s,"f").open()})),this.phoneUserAttr.onDeleteClick((()=>{o(this,l,"f").open()}))},b})),Vc=c((e=>{var t,s,c,l,d,u,h,f;return f=class extends(r(Pc,Ea,$c,Xa)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),c.set(this,void 0),h.set(this,a((e=>{this.passkeyUserAuthMethod.fulfilled=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",u).call(this),o(this,t,"m",l).call(this),o(this,h,"f").call(this,Sc(this.state)),this.subscribe(o(this,h,"f").bind(this),Sc)}))}},s=new WeakMap,c=new WeakMap,h=new WeakMap,t=new WeakSet,l=function(){i(this,s,this.createModal({"data-id":"passkey"}),"f"),i(this,c,new xr((()=>{var e;return null===(e=o(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),o(this,s,"f").afterClose=o(this,t,"m",d).bind(this),o(this,t,"m",d).call(this)},d=function(){o(this,s,"f").setContent(Dc({projectId:this.projectId,flowId:this.passkeyUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),o(this,c,"f").onSuccess((()=>{o(this,s,"f").close(),this.actions.getMe()}))},u=function(){this.passkeyUserAuthMethod=new jr((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="passkey"]')}),{logger:this.logger}),this.passkeyUserAuthMethod.onButtonClick((()=>{o(this,s,"f").open()}))},f})),Hc=c((e=>{var t,s,a,c,l,d,u;return u=class extends(r(Pc,Ea,$c,Xa)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),a.set(this,void 0)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",d).call(this),o(this,t,"m",c).call(this)}))}},s=new WeakMap,a=new WeakMap,t=new WeakSet,c=function(){i(this,s,this.createModal({"data-id":"password"}),"f"),i(this,a,new xr((()=>{var e;return null===(e=o(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),o(this,s,"f").afterClose=o(this,t,"m",l).bind(this),o(this,t,"m",l).call(this)},l=function(){o(this,s,"f").setContent(Dc({projectId:this.projectId,flowId:this.passwordUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),o(this,a,"f").onSuccess((()=>{o(this,s,"f").close()}))},d=function(){this.passwordUserAuthMethod=new jr((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="password"]')}),{logger:this.logger}),this.passwordUserAuthMethod.onButtonClick((()=>{o(this,s,"f").open()}))},u})),Kc=c((e=>{var t,i,s;return s=class extends(r(Pc,Ea,$c,Xa)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",i).call(this)}))}},t=new WeakSet,i=function(){this.logout=new br((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-button[data-id="logout"]')}),{logger:this.logger}),this.logout.onClick((()=>n(this,void 0,void 0,(function*(){yield this.actions.logout(),this.dispatchEvent(new CustomEvent("logout"))}))))},s})),Gc="widget-flow",Jc=c((e=>{var t,i,s;return s=class extends(r(_a,Xa,Pc,Ea)(e)){constructor(){super(...arguments),t.add(this)}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this);const r=Nc(Gc);r&&(!function(e){if(window.history.replaceState&&Nc(e)){const t=new URL(window.location.href),n=new URLSearchParams(t.search);n.delete(e),t.search=n.toString(),window.history.replaceState({},"",t.toString())}}(Gc),o(this,t,"m",i).call(this,r))}))}},t=new WeakSet,i=function(e){const t=this.createModal({"data-id":"redirect-flow"});t.setContent(Dc({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl}));new xr((()=>{var e;return null===(e=t.ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>{t.close(),this.actions.getMe()})),t.afterClose=()=>{t.remove()},t.open()},s})),Xc=c((e=>class extends(r($a,Qa,Jc,qc,Fc,zc,Bc,Vc,Hc,Kc)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),Yc=r((e=>class extends(Xc(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),vr.sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.0.96"}}}))}}))(HTMLElement);customElements.define("descope-user-profile-widget",Yc);const Zc=(e,t,n,o={})=>{var i,r,s,a;return[Math.min(Math.max(t,("all"===o.left?e.offsetWidth:null!==(i=o.left)&&void 0!==i?i:0)-e.offsetWidth),window.innerWidth-("all"===o.right?e.offsetWidth:null!==(r=o.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===o.top?e.offsetHeight:null!==(s=o.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===o.bottom?e.offsetHeight:null!==(a=o.bottom)&&void 0!==a?a:0))]};var Qc,el,tl,nl,ol,il,rl,sl,al,cl;const ll=document.createElement("template");ll.innerHTML=`\n<style>\n .debugger {\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n</style>\n\n<div style="top:32px; left:${window.innerWidth-300-32}px;" class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n`;class dl extends HTMLElement{constructor(){super(),Qc.add(this),el.set(this,new oi({messages:[]})),tl.set(this,void 0),nl.set(this,void 0),ol.set(this,void 0),il.set(this,{resize:o(this,Qc,"m",cl).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(ll.content.cloneNode(!0)),i(this,tl,this.shadowRoot.querySelector(".debugger"),"f"),i(this,nl,o(this,tl,"f").querySelector(".content"),"f"),i(this,ol,o(this,tl,"f").querySelector(".header"),"f")}updateData(e){o(this,el,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let o=0,i=0,r=0,s=0;function a(t){t.preventDefault(),o=r-t.clientX,i=s-t.clientY,r=t.clientX,s=t.clientY;const[a,c]=Zc(e,e.offsetLeft-o,e.offsetTop-i,n);e.style.top=`${c}px`,e.style.left=`${a}px`}function c(){document.onmouseup=null,document.onmousemove=null}function l(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=c,document.onmousemove=a}t?t.onmousedown=l:e.onmousedown=l})(o(this,tl,"f"),o(this,ol,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,il,"f").resize),(e=o(this,tl,"f")).onmousemove=t=>{(t.target.w&&t.target.w!==t.target.offsetWidth||t.target.h&&t.target.h!==t.target.offsetHeight)&&e.onresize(t),t.target.w=t.target.offsetWidth,t.target.h=t.target.offsetHeight},o(this,tl,"f").onresize=o(this,Qc,"m",al).bind(this),o(this,el,"f").subscribe(o(this,Qc,"m",rl).bind(this))}disconnectedCallback(){o(this,el,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,il,"f").resize)}}el=new WeakMap,tl=new WeakMap,nl=new WeakMap,ol=new WeakMap,il=new WeakMap,Qc=new WeakSet,rl=function(e){o(this,Qc,"m",sl).call(this,e),o(this,Qc,"m",al).call(this)},sl=function(e){o(this,nl,"f").innerHTML=e.messages.map((e=>`\n <div class="msg">\n <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.99984 13.167L8.99984 10.167L11.9998 13.167L13.1665 12.0003L10.1665 9.00033L13.1665 6.00033L11.9998 4.83366L8.99984 7.83366L5.99984 4.83366L4.83317 6.00033L7.83317 9.00033L4.83317 12.0003L5.99984 13.167ZM8.99984 17.3337C7.84706 17.3337 6.76373 17.1148 5.74984 16.677C4.73595 16.2398 3.854 15.6462 3.104 14.8962C2.354 14.1462 1.76039 13.2642 1.32317 12.2503C0.885393 11.2364 0.666504 10.1531 0.666504 9.00033C0.666504 7.84755 0.885393 6.76421 1.32317 5.75033C1.76039 4.73644 2.354 3.85449 3.104 3.10449C3.854 2.35449 4.73595 1.7606 5.74984 1.32283C6.76373 0.885603 7.84706 0.666992 8.99984 0.666992C10.1526 0.666992 11.2359 0.885603 12.2498 1.32283C13.2637 1.7606 14.1457 2.35449 14.8957 3.10449C15.6457 3.85449 16.2393 4.73644 16.6765 5.75033C17.1143 6.76421 17.3332 7.84755 17.3332 9.00033C17.3332 10.1531 17.1143 11.2364 16.6765 12.2503C16.2393 13.2642 15.6457 14.1462 14.8957 14.8962C14.1457 15.6462 13.2637 16.2398 12.2498 16.677C11.2359 17.1148 10.1526 17.3337 8.99984 17.3337ZM8.99984 15.667C10.8609 15.667 12.4373 15.0212 13.729 13.7295C15.0207 12.4378 15.6665 10.8614 15.6665 9.00033C15.6665 7.13921 15.0207 5.56283 13.729 4.27116C12.4373 2.97949 10.8609 2.33366 8.99984 2.33366C7.13873 2.33366 5.56234 2.97949 4.27067 4.27116C2.979 5.56283 2.33317 7.13921 2.33317 9.00033C2.33317 10.8614 2.979 12.4378 4.27067 13.7295C5.56234 15.0212 7.13873 15.667 8.99984 15.667Z" fill="#ED404A"/>\n</svg>\n\n <div class="msg_content">\n <div class="msg_title">\n ${e.title}\n </div>\n <div class="msg_desc">\n ${e.description}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},al=function(){o(this,nl,"f").querySelectorAll(".msg").forEach((e=>{const t=e.querySelector(".msg_desc"),n=t.scrollWidth>t.clientWidth,o=t.clientHeight>20;n||o?(e.classList.add("collapsible"),e.onclick=t=>{t.target.classList.contains("msg_desc")||e.classList.toggle("collapsed")}):(e.classList.remove("collapsible"),e.onclick=null)}))},cl=function(){const[e,t]=Zc(o(this,tl,"f"),Number.parseInt(o(this,tl,"f").style.left,10),Number.parseInt(o(this,tl,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,tl,"f").style.top=`${t}px`,o(this,tl,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",dl);var ul=Object.freeze({__proto__:null,default:dl});var hl=Object.freeze({__proto__:null,default:(e,t,o)=>n(void 0,void 0,void 0,(function*(){const{siteId:t}=e,n='\n(function () {\nvar merchantConfig = {\n csp: false\n};\n\nvar siteId = "{{SITE_ID}}";\nfunction t(t,n){for(var e=t.split(""),r=0;r<e.length;++r)e[r]=String.fromCharCode(e[r].charCodeAt(0)+n);return e.join("")}function n(n){return t(n,-L).replace(/%SN%/g,siteId)}function e(){var t="no"+"op"+"fn",n="g"+"a",e="n"+"ame";return window[n]&&window[n][e]===t}function r(){return!(!navigator.brave||"function"!=typeof navigator.brave.isBrave)}function o(){return document.currentScript&&document.currentScript.src}function i(t){try{if("number"==typeof t&&window.location&&window.location.pathname){for(var n=window.location.pathname.split("/"),e=[],r=0;r<=Math.min(n.length-1,Math.abs(t));r++)e.push(n[r]);return e.join("/")||"/"}}catch(t){}return"/"}function c(t){try{G.ex=t,e()&&-1===G.ex.indexOf(B.uB)&&(G.ex+=B.uB),r()&&-1===G.ex.indexOf(B.uBr)&&(G.ex+=B.uBr),o()&&-1===G.ex.indexOf(B.nIL)&&(G.ex+=B.nIL),window.ftr__snp_cwc||(G.ex+=B.s),M(G)}catch(t){}}function a(t,n){function e(o){try{o.blockedURI===t&&(n(),document.removeEventListener(r,e))}catch(t){document.removeEventListener(r,e)}}var r="securitypolicyviolation";document.addEventListener(r,e),setTimeout(function(){document.removeEventListener(r,e)},2*60*1e3)}function u(t,n,e,r){var o=!1;t="https://"+t,a(t,function(){r(!0),o=!0});var i=document.createElement("script");i.onerror=function(){if(!o)try{r(!1),o=!0}catch(t){}},i.onload=e,i.type="text/javascript",i.id="ftr__script",i.async=!0,i.src=t;var c=document.getElementsByTagName("script")[0];c.parentNode.insertBefore(i,c)}function f(){J(B.uDF),setTimeout(h,I,B.uDF)}function d(t,n,e,r){var o=!1,i=new XMLHttpRequest;if(a("https:"+t,function(){e(new Error("CSP Violation"),!0),o=!0}),"//"===t.slice(0,2)&&(t="https:"+t),"withCredentials"in i)i.open("GET",t,!0);else{if("undefined"==typeof XDomainRequest)return;i=new XDomainRequest,i.open("GET",t)}Object.keys(r).forEach(function(t){i.setRequestHeader(t,r[t])}),i.onload=function(){"function"==typeof n&&n(i)},i.onerror=function(t){if("function"==typeof e&&!o)try{e(t,!1),o=!0}catch(t){}},i.onprogress=function(){},i.ontimeout=function(){"function"==typeof e&&e("tim"+"eo"+"ut",!1)},setTimeout(function(){i.send()},0)}function s(t,siteId,n){function e(t){var n=t.toString(16);return n.length%2?"0"+n:n}function r(t){if(t<=0)return"";for(var n="0123456789abcdef",e="",r=0;r<t;r++)e+=n[Math.floor(Math.random()*n.length)];return e}function o(t){for(var n="",r=0;r<t.length;r++)n+=e(t.charCodeAt(r));return n}function i(t){for(var n=t.split(""),e=0;e<n.length;++e)n[e]=String.fromCharCode(255^n[e].charCodeAt(0));return n.join("")}n=n?"1":"0";var c=[];return c.push(t),c.push(siteId),c.push(n),function(t){var n=40,e="";return t.length<n/2&&(e=","+r(n/2-t.length-1)),o(i(t+e))}(c.join(","))}function w(){function t(){D&&(J(B.dUAL),setTimeout(h,I,B.dUAL))}function n(t,n){c(n?B.uAS+B.uF+B.cP:B.uAS+B.uF)}window.ftr__fdad(t,n)}function h(t){try{var n;switch(t){case B.uFP:n=q;break;case B.uDF:n=E;break;default:n=D}if(!n)return;u(n,void 0,function(){try{K(),c(t+B.uS)}catch(t){}},function(n){try{K(),G.td=1*new Date-G.ts,c(n?t+B.uF+B.cP:t+B.uF),t===B.uFP&&f(),t===B.uDF&&w()}catch(t){c(B.eUoe)}})}catch(n){c(t+B.eTlu)}}var m="22ge:t7mj8unkn;1forxgiurqw1qhw2vwdwxv",v="fort",l="erTo",p="ken";window.ftr__config={m:merchantConfig,s:"23",si:siteId};var g=!1,_=v+l+p,y=400*24*60,T=10,k={write:function(t,n,e,r){void 0===r&&(r=!0);var o=0;window.ftr__config&&window.ftr__config.m&&window.ftr__config.m.ckDepth&&(o=window.ftr__config.m.ckDepth);var c,a,u=i(o);if(e?(c=new Date,c.setTime(c.getTime()+60*e*1e3),a="; expires="+c.toGMTString()):a="",!r)return void(document.cookie=escape(t)+"="+escape(n)+a+"; path="+u);for(var f=1,d=document.domain.split("."),s=T,w=!0;w&&d.length>=f&&s>0;){var h=d.slice(-f).join(".");document.cookie=escape(t)+"="+escape(n)+a+"; path="+u+"; domain="+h;var m=k.read(t);null!=m&&m==n||(h="."+h,document.cookie=escape(t)+"="+escape(n)+a+"; path="+u+"; domain="+h),w=-1===document.cookie.indexOf(t+"="+n),f++,s--}},read:function(t){var n=null;try{for(var e=escape(t)+"=",r=document.cookie.split(";"),o=32,i=0;i<r.length;i++){for(var c=r[i];c.charCodeAt(0)===o;)c=c.substring(1,c.length);0===c.indexOf(e)&&(n=unescape(c.substring(e.length,c.length)))}}finally{return n}}},S=window.ftr__config.s;S+="ck";var x=function(t){var n=!1,e=null,r=function(){try{if(!e||!n)return;e.remove&&"function"==typeof e.remove?e.remove():document.head.removeChild(e),n=!1}catch(t){}};document.head&&(!function(){e=document.createElement("link"),e.setAttribute("rel","pre"+"con"+"nect"),e.setAttribute("cros"+"sori"+"gin","anonymous"),e.onload=r,e.onerror=r,e.setAttribute("href",t),document.head.appendChild(e),n=!0}(),setTimeout(r,3e3))},L=3,A=n(m||"22ge:t7mj8unkn;1forxgiurqw1qhw2vwdwxv"),F=t("[0Uhtxhvw0LG",-L),U=t("[0Fruuhodwlrq0LG",-L),b=t("Li0Qrqh0Pdwfk",-L),D,C="fgq71iruwhu1frp",E=n("(VQ(1"+C+"2vq2(VQ(2vfulsw1mv"),V=n("(VQ(1"+C+"2vqV2(VQ(2vfulsw1mv"),q;window.ftr__config&&window.ftr__config.m&&window.ftr__config.m.fpi&&(q=window.ftr__config.m.fpi+n("2vq2(VQ(2vfulsw1mv"));var I=10;window.ftr__startScriptLoad=1*new Date;var R=function(t){var n="ft"+"r:tok"+"enR"+"eady";window.ftr__tt&&clearTimeout(window.ftr__tt),window.ftr__tt=setTimeout(function(){try{delete window.ftr__tt,t+="_tt";var e=document.createEvent("Event");e.initEvent(n,!1,!1),e.detail=t,document.dispatchEvent(e)}catch(t){}},1e3)},M=function(t){var n=function(t){return t||""},e=n(t.id)+"_"+n(t.ts)+"_"+n(t.td)+"_"+n(t.ex)+"_"+n(S),r=y;!isNaN(window.ftr__config.m.ckTTL)&&window.ftr__config.m.ckTTL&&(r=window.ftr__config.m.ckTTL),k.write(_,e,r,!0),R(e),window.ftr__gt=e},P=function(){var t=k.read(_)||"",n=t.split("_"),e=function(t){return n[t]||void 0};return{id:e(0),ts:e(1),td:e(2),ex:e(3),vr:e(4)}},j=function(){for(var t={},n="fgu",e=[],r=0;r<256;r++)e[r]=(r<16?"0":"")+r.toString(16);var o=function(t,n,r,o,i){var c=i?"-":"";return e[255&t]+e[t>>8&255]+e[t>>16&255]+e[t>>24&255]+c+e[255&n]+e[n>>8&255]+c+e[n>>16&15|64]+e[n>>24&255]+c+e[63&r|128]+e[r>>8&255]+c+e[r>>16&255]+e[r>>24&255]+e[255&o]+e[o>>8&255]+e[o>>16&255]+e[o>>24&255]},i=function(){if(window.Uint32Array&&window.crypto&&window.crypto.getRandomValues){var t=new window.Uint32Array(4);return window.crypto.getRandomValues(t),{d0:t[0],d1:t[1],d2:t[2],d3:t[3]}}return{d0:4294967296*Math.random()>>>0,d1:4294967296*Math.random()>>>0,d2:4294967296*Math.random()>>>0,d3:4294967296*Math.random()>>>0}},c=function(){var t="",n=function(t,n){for(var e="",r=t;r>0;--r)e+=n.charAt(1e3*Math.random()%n.length);return e};return t+=n(2,"0123456789"),t+=n(1,"123456789"),t+=n(8,"0123456789")};return t.safeGenerateNoDash=function(){try{var t=i();return o(t.d0,t.d1,t.d2,t.d3,!1)}catch(t){try{return n+c()}catch(t){}}},t.isValidNumericalToken=function(t){return t&&t.toString().length<=11&&t.length>=9&&parseInt(t,10).toString().length<=11&&parseInt(t,10).toString().length>=9},t.isValidUUIDToken=function(t){return t&&32===t.toString().length&&/^[a-z0-9]+$/.test(t)},t.isValidFGUToken=function(t){return 0==t.indexOf(n)&&t.length>=12},t}(),B={uDF:"UDF",dUAL:"dUAL",uAS:"UAS",uFP:"UFP",mLd:"1",eTlu:"2",eUoe:"3",uS:"4",uF:"9",tmos:["T5","T10","T15","T30","T60"],tmosSecs:[5,10,15,30,60],bIR:"43",uB:"u",uBr:"b",cP:"c",nIL:"i",s:"s"};try{var G=P();try{G.id&&(j.isValidNumericalToken(G.id)||j.isValidUUIDToken(G.id)||j.isValidFGUToken(G.id))?window.ftr__ncd=!1:(G.id=j.safeGenerateNoDash(),window.ftr__ncd=!0),G.ts=window.ftr__startScriptLoad,M(G),window.ftr__snp_cwc=!!k.read(_),window.ftr__snp_cwc||(E=V);for(var N="for"+"ter"+".co"+"m",O="ht"+"tps://c"+"dn9."+N,Q="ht"+"tps://"+G.id+"-"+siteId+".cd"+"n."+N,H="http"+"s://cd"+"n3."+N,X=[O,Q,H],z=0;z<X.length;z++)x(X[z]);var $=new Array(B.tmosSecs.length),J=function(t){for(var n=0;n<B.tmosSecs.length;n++)$[n]=setTimeout(c,1e3*B.tmosSecs[n],t+B.tmos[n])},K=function(){for(var t=0;t<B.tmosSecs.length;t++)clearTimeout($[t])};window.ftr__fdad=function(n,e){if(!g){g=!0;var r={};r[b]=s(window.ftr__config.s,siteId,window.ftr__config.m.csp),d(A,function(e){try{var r=e.getAllResponseHeaders().toLowerCase();if(r.indexOf(U.toLowerCase())>=0){var o=e.getResponseHeader(U);window.ftr__altd2=t(atob(o),-L-1)}if(r.indexOf(F.toLowerCase())<0)return;var i=e.getResponseHeader(F),c=t(atob(i),-L-1);if(c){var a=c.split(":");if(a&&2===a.length){for(var u=a[0],f=a[1],d="",s=0,w=0;s<20;++s)d+=s%3>0&&w<12?siteId.charAt(w++):G.id.charAt(s);var h=f.split(",");if(h.length>1){var m=h[0],v=h[1];D=u+"/"+m+"."+d+"."+v}}}n()}catch(t){}},function(t,n){e&&e(t,n)},r)}};var W=q?B.uFP:B.uDF;J(W),setTimeout(h,I,W)}catch(t){c(B.mLd)}}catch(t){}})();\n'.replace(/{{SITE_ID}}/g,t),i=document.createElement("script");i.setAttribute("type","text/javascript"),i.setAttribute("id",t),i.text=n,document.body.appendChild(i),document.addEventListener("ftr:tokenReady",(e=>{o(e.detail)}))}))});const fl=(e,t,o)=>n(void 0,void 0,void 0,(function*(){try{const{publicApiKey:t,useCloudflareIntegration:n,cloudflareScriptUrl:i,cloudflareEndpointUrl:r}=e;let s=[];s=n&&r?[r,hn]:[hn];let a=[];if(n&&i){a=[`${new URL(i).toString()}?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`,wn]}else a=[wn];const c=yn({apiKey:t,endpoint:s,scriptUrlPattern:a}),l=yield c,{requestId:d}=yield l.get();o(d)}catch(e){console.warn("Could not load fingerprint",e)}}));var pl=Object.freeze({__proto__:null,default:fl,loadFingerprint:fl});const gl=(e,t,o)=>n(void 0,void 0,void 0,(function*(){try{const{customDomain:n,publicApiKey:i,cloudflareEndpointPath:r,cloudflareScriptPath:s}=e,{baseUrl:a}=t;let c;c=n?`https://${n}`:a||"https://api.descope.com";const l=new URL(c);l.pathname=r;const d=new URL(c);d.pathname=s;const u=`${d.toString()}?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`,h=yn({apiKey:i,endpoint:[l.toString(),hn],scriptUrlPattern:[u,wn]}),f=yield h,{requestId:p}=yield f.get();o(p)}catch(e){console.warn("Could not load descope fingerprint",e)}}));var vl=Object.freeze({__proto__:null,default:gl,loadFingerprint:gl});return Yc}();
|
|
7
|
+
function dn(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)e[o]=n[o]}return e}var un=function e(t,n){function o(e,o,i){if("undefined"!=typeof document){"number"==typeof(i=dn({},n,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var r="";for(var s in i)i[s]&&(r+="; "+s,!0!==i[s]&&(r+="="+i[s].split(";")[0]));return document.cookie=e+"="+t.write(o,e)+r}}return Object.create({set:o,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],o={},i=0;i<n.length;i++){var r=n[i].split("="),s=r.slice(1).join("=");try{var a=decodeURIComponent(r[0]);if(o[a]=t.read(s,a),e===a)break}catch(e){}}return e?o[e]:o}},remove:function(e,t){o(e,"",dn({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,dn({},this.attributes,t))},withConverter:function(t){return e(dn({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(t)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"});var hn={default:"endpoint"},fn="Blocked by CSP",pn="The endpoint parameter is not a valid URL",gn="Failed to load the JS script of the agent",vn="9319";function mn(e,t){var n,o,i,r,s=[],a=(n=function(e){var t=function(e,t,n){if(n||2===arguments.length)for(var o,i=0,r=t.length;i<r;i++)!o&&i in t||(o||(o=Array.prototype.slice.call(t,0,i)),o[i]=t[i]);return e.concat(o||Array.prototype.slice.call(t))}([],e,!0);return{current:function(){return t[0]},postpone:function(){var e=t.shift();void 0!==e&&t.push(e)},exclude:function(){t.shift()}}}(e),r=0,o=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,r++))},i=new Set,[n.current(),function(e,t){var r,s=t instanceof Error?t.message:"";if(s===fn||s===pn)n.exclude(),r=0;else if(s===vn)n.exclude();else if(s===gn){var a=Date.now()-e.getTime()<50,c=n.current();c&&a&&!i.has(c)&&(i.add(c),r=0),n.postpone()}else n.postpone();var l=n.current();return void 0===l?void 0:[l,null!=r?r:e.getTime()+o()-Date.now()]}]),c=a[0],l=a[1];if(void 0===c)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var d=function(e){var n=new Date,o=function(t){return s.push({url:e,startedAt:n,finishedAt:new Date,error:t})},i=t(e);return i.then((function(){return o()}),o),i.catch((function(e){if(s.length>=5)throw e;var t=l(n,e);if(!t)throw e;var o,i=t[0],r=t[1];return(o=r,new Promise((function(e){return setTimeout(e,o)}))).then((function(){return d(i)}))}))};return d(c).then((function(e){return[e,s]}))}var bn="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",wn=bn;function yn(n){var o;n.scriptUrlPattern;var i=n.token,r=n.apiKey,s=void 0===r?i:r,a=t(n,["scriptUrlPattern","token","apiKey"]),c=null!==(o=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(n,"scriptUrlPattern"))&&void 0!==o?o:bn,l=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},n=function(e,t,n,o){return e.addEventListener(t,n,o),function(){return e.removeEventListener(t,n,o)}}(document,"visibilitychange",t);return t(),[e,n]}(),d=l[0],u=l[1];return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error("API key required");var e=function(e,t){return(Array.isArray(e)?e:[e]).map((function(e){return function(e,t){var n=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?n(t):"<loaderVersion>"===e?n("3.9.9"):e}))}(String(e),t)}))}(c,s);return mn(e,kn)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===vn?new Error(gn):e}(e)})).then((function(t){var n=t[0],o=t[1];return u(),n.load(e(e({},a),{ldi:{attempts:o,visibilityStates:d}}))}))}function kn(e){return function(e,t,n,o){var i,r=document,s="securitypolicyviolation",a=function(t){var n=new URL(e,location.href),o=t.blockedURI;o!==n.href&&o!==n.protocol.slice(0,-1)&&o!==n.origin||(i=t,c())};r.addEventListener(s,a);var c=function(){return r.removeEventListener(s,a)};return null==o||o.then(c,c),Promise.resolve().then(t).then((function(e){return c(),e}),(function(e){return new Promise((function(e){var t=new MessageChannel;t.port1.onmessage=function(){return e()},t.port2.postMessage(null)})).then((function(){if(c(),i)return n(i);throw e}))}))}(e,(function(){return function(e){return new Promise((function(t,n){if(function(e){if(URL.prototype)try{return new URL(e,location.href),!1}catch(e){if(e instanceof Error&&"TypeError"===e.name)return!0;throw e}}(e))throw new Error(pn);var o=document.createElement("script"),i=function(){var e;return null===(e=o.parentNode)||void 0===e?void 0:e.removeChild(o)},r=document.head||document.getElementsByTagName("head")[0];o.onload=function(){i(),t()},o.onerror=function(){i(),n(new Error(gn))},o.async=!0,o.src=e,r.appendChild(o)}))}(e)}),(function(){throw new Error(fn)})).then(In)}function In(){var e=window,t="__fpjs_p_l_b",n=e[t];if(function(e,t){var n,o=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==o?void 0:o.configurable)?delete e[t]:o&&!o.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error(vn);return n}const Sn=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,o)=>{var i;return n[o]=[].concat((null===(i=e.hooks)||void 0===i?void 0:i[o])||[]).concat((null==t?void 0:t[o])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},jn=async e=>{if(!(null==e?void 0:e.ok))return{};const t=await(null==e?void 0:e.clone().json());return(null==t?void 0:t.authInfo)||t||{}},xn=async e=>{const t=await jn(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)},Cn="undefined"!=typeof localStorage,An=(e,t)=>Cn&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(e,t)),En=e=>Cn&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(e)),On=e=>Cn&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(e)),Un=(...e)=>{console.debug(...e)},_n="undefined"!=typeof window,Rn=Math.pow(2,31)-1,Tn="DS",Mn="DSR";function Ln(e=""){return En(`${e}${Mn}`)||""}function Pn(e=""){On(`${e}${Mn}`),On(`${e}${Tn}`),un.remove(Tn)}const Wn=_n&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",$n="fp",Dn=(e=!1)=>{const t=localStorage.getItem($n);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},Nn=async(e,t=Wn)=>{try{if(Dn())return;const n=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const i=new URL(t);i.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const r=i.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=yn({apiKey:e,endpoint:[o.toString(),hn],scriptUrlPattern:[r,wn]}),a=await s,{requestId:c}=await a.get({linkedId:n}),l=((e,t)=>({vsid:e,vrid:t}))(n,c);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};localStorage.setItem($n,JSON.stringify(t))})(l)}catch(e){console.warn("Could not load fingerprint",e)}},Fn=e=>{const t=Dn(!0);return t&&e.body&&(e.body.fpData=t),e},qn="dls_last_user_login_id",zn="dls_last_user_display_name",Bn=()=>En(qn),Vn=()=>En(zn),Hn=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,o={}]=t,i=Bn(),r=Vn();return i&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=i,o.lastAuth.name=r),await e(...t)};function Kn(){const e=[];return{pub:t=>{e.forEach((e=>e(t)))},sub:t=>{const n=e.push(t)-1;return()=>e.splice(n,1)}}}async function Gn(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=eo(n.publicKey.challenge),n.publicKey.user.id=eo(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=eo(e.id)})),n}(e);return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:to(n.rawId),type:n.type,response:{attestationObject:to(n.response.attestationObject),clientDataJSON:to(n.response.clientDataJSON)}});var n}async function Jn(e){const t=Zn(e);return Qn(await navigator.credentials.get(t))}async function Xn(e,t){const n=Zn(e);return n.signal=t.signal,n.mediation="conditional",Qn(await navigator.credentials.get(n))}async function Yn(e=!1){if(!_n)return Promise.resolve(!1);const t=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return t&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():t}function Zn(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=eo(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=eo(e.id)})),n}function Qn(e){return JSON.stringify({id:e.id,rawId:to(e.rawId),type:e.type,response:{authenticatorData:to(e.response.authenticatorData),clientDataJSON:to(e.response.clientDataJSON),signature:to(e.response.signature),userHandle:e.response.userHandle?to(e.response.userHandle):void 0}})}function eo(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function to(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var no,oo=(no=e=>({async signUp(t,n){const o=await e.webauthn.signUp.start(t,window.location.origin,n);if(!o.ok)return o;const i=await Gn(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,i)},async signIn(t){const n=await e.webauthn.signIn.start(t,window.location.origin);if(!n.ok)return n;const o=await Jn(n.data.options);return await e.webauthn.signIn.finish(n.data.transactionId,o)},async signUpOrIn(t){var n;const o=await e.webauthn.signUpOrIn.start(t,window.location.origin);if(!o.ok)return o;if(null===(n=o.data)||void 0===n?void 0:n.create){const t=await Gn(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,t)}{const t=await Jn(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,t)}},async update(t,n){const o=await e.webauthn.update.start(t,window.location.origin,n);if(!o.ok)return o;const i=await Gn(o.data.options);return await e.webauthn.update.finish(o.data.transactionId,i)},helpers:{create:Gn,get:Jn,isSupported:Yn,conditional:Xn}}),(...e)=>{const t=no(...e);return Object.assign(t.signUp,e[0].webauthn.signUp),Object.assign(t.signIn,e[0].webauthn.signIn),Object.assign(t.signUpOrIn,e[0].webauthn.signUpOrIn),Object.assign(t.update,e[0].webauthn.update),t});const io="/fedcm/config",ro=(e,t)=>({async oneTap(t,n,o,i){const r=null!=t?t:"google",s=await e.oauth.startNative(r,o,!0);if(!s.ok)return s;const{clientId:a,stateId:c,nonce:l}=s.data,d=await async function(){return new Promise(((e,t)=>{if(window.google)return void e(window.google.accounts.id);let n=document.getElementById("google-gsi-client-script");n||(n=document.createElement("script"),document.head.appendChild(n),n.async=!0,n.defer=!0,n.id="google-gsi-client-script",n.src="https://accounts.google.com/gsi/client"),n.onload=function(){window.google?e(window.google.accounts.id):t("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){t("Failed to load Google GSI client script - failed to load")}}))}();return new Promise((t=>{var o,s;d.initialize(Object.assign(Object.assign({},n),{itp_support:null===(o=null==n?void 0:n.itp_support)||void 0===o||o,use_fedcm_for_prompt:null===(s=null==n?void 0:n.use_fedcm_for_prompt)||void 0===s||s,client_id:a,callback:n=>{t(e.oauth.finishNative(r,c,"","",n.credential))},nonce:l})),d.prompt((e=>{(null==e?void 0:e.isSkippedMoment())&&(null==i||i())}))}))},async launch(n){var o;const i={identity:{context:n||"signin",providers:[{configURL:e.httpClient.buildUrl(t+io),clientId:t}]}},r=await(null===(o=navigator.credentials)||void 0===o?void 0:o.get(i));return e.refresh(r.token)},isSupported:()=>_n&&"IdentityCredential"in window});var so=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await Yn(),o=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=o,e.flow.start(...t)}});const ao=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>n=>{var{fpKey:o,fpLoad:i}=n,r=t(n,["fpKey","fpLoad"]);return _n?(o&&i&&Nn(o).catch((()=>null)),e(Sn(r,{beforeRequest:Fn}))):e(r)}),(e=>n=>{var{autoRefresh:o}=n,i=t(n,["autoRefresh"]);if(!o)return e(i);const{clearAllTimers:r,setTimer:s}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let a,c;_n&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&new Date>a&&(Un("Expiration time passed, refreshing session"),l.refresh(Ln()||c))}));const l=e(Sn(i,{afterRequest:async(e,t)=>{const{refreshJwt:n,sessionJwt:o}=await jn(t);if(401===(null==t?void 0:t.status))Un("Received 401, canceling all timers"),r();else if(o){if(a=(e=>{try{const t=b(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(o),!a)return void Un("Could not extract expiration time from session token");c=n;let e=((i=a)?i.getTime()-(new Date).getTime():0)-2e4;e>Rn&&(Un(`Timeout is too large (${e}ms), setting it to ${Rn}ms`),e=Rn),r();const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});Un(`Setting refresh timer for ${t}. (${e}ms)`),s((()=>{Un("Refreshing session due to timer"),l.refresh(Ln()||n)}),e)}var i}}));return Qe(l,["logout","logoutAll"],(e=>async(...t)=>{const n=await e(...t);return Un("Clearing all timers"),r(),n}))}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.16.2"},t.baseHeaders)}))),(e=>t=>{const n=Kn(),o=Kn(),i=e(Sn(t,{afterRequest:async(e,t)=>{if(401===(null==t?void 0:t.status))n.pub(null),o.pub(null);else{const e=await xn(t);e&&o.pub(e);const{sessionJwt:i}=await jn(t);i&&n.pub(i)}}})),r=Qe(i,["logout","logoutAll"],(e=>async(...t)=>{const i=await e(...t);return n.pub(null),o.pub(null),i}));return Object.assign(r,{onSessionTokenChange:n.sub,onUserChange:o.sub})}),(e=>n=>{var{storeLastAuthenticatedUser:o=!0,keepLastAuthenticatedUserAfterLogout:i=!1}=n,r=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!o)return Object.assign(e(r),{getLastUserLoginId:Bn,getLastUserDisplayName:Vn});const s=e(Sn(r,{afterRequest:async(e,t)=>{var n;const o=await xn(t),i=null===(n=null==o?void 0:o.loginIds)||void 0===n?void 0:n[0],r=null==o?void 0:o.name;i&&((e=>{An(qn,e)})(i),(e=>{An(zn,e)})(r))}}));let a=Qe(s,["flow.start"],Hn);return a=Qe(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const o=await t(...n);return e||(On(qn),On(zn)),o})(i)),Object.assign(a,{getLastUserLoginId:Bn,getLastUserDisplayName:Vn})}),(e=>n=>{var{persistTokens:o,sessionTokenViaCookie:i,storagePrefix:r}=n,s=t(n,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!o||!_n)return e(s);const a=e(Sn(s,{beforeRequest:(c=r,e=>Object.assign(e,{token:e.token||Ln(c)})),afterRequest:async(e,n)=>{const o=/^\/v\d+\/mgmt\//.test(e.path);401===(null==n?void 0:n.status)?o||Pn(r):((e={},n,o)=>{var{refreshJwt:i,sessionJwt:r}=e,s=t(e,["refreshJwt","sessionJwt"]);void 0===n&&(n=!1),void 0===o&&(o=""),i&&An(`${o}${Mn}`,i),r&&(n?function(e,t,{cookiePath:n,cookieDomain:o,cookieExpiration:i}){if(t){const r=new Date(1e3*i),s=function(e){const t=window.location.hostname.split("."),n=e.split(".");return t.slice(-n.length).join(".")===e}(o);un.set(e,t,{path:n,domain:s?o:void 0,expires:r,sameSite:"Strict",secure:!0})}}(Tn,r,s):An(`${o}${Tn}`,r))})(await jn(n),i,r)}}));var c;const l=Qe(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const o=await t(...n);return Pn(e),o})(r));return Object.assign(l,{getRefreshToken:()=>Ln(r),getSessionToken:()=>function(e=""){return un.get(Tn)||En(`${e}${Tn}`)||""}(r)})}))(((...e)=>{const t=ln(...e);return Object.assign(Object.assign({},t),{flow:so(t),webauthn:oo(t),fedcm:ro(t,e[0].projectId)})}));var co;let lo=class{constructor(e,t){co.set(this,void 0),this.nodeName="",i(this,co,e,"f"),this.logger=t.logger}get asyncEle(){return(async e=>new Promise((t=>{const n=setInterval((()=>{const o="function"==typeof e?e():e;o&&(clearInterval(n),t(o))}),100);setTimeout((()=>{clearInterval(n),t(null)}),1e3)})))(o(this,co,"f"))}get ele(){var e,t;const n="function"==typeof o(this,co,"f")?o(this,co,"f").call(this):o(this,co,"f");return n?(null==n?void 0:n.localName)!==this.nodeName?(null===(t=this.logger)||void 0===t||t.debug(`node name do not match, expected "${this.nodeName}", received "${n.localName}" `,Error()),null):n:(null===(e=this.logger)||void 0===e||e.debug("no element for driver ",this.constructor.name,new Error),null)}};co=new WeakMap;let uo=class extends lo{constructor(){super(...arguments),this.nodeName="descope-button"}onClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("click",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("click",e)}}disable(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("disabled","true")}enable(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("disabled")}};var ho;let fo=class extends lo{constructor(){super(...arguments),ho.set(this,void 0),this.nodeName="descope-modal"}close(){var e,t;null===(e=this.ele)||void 0===e||e.removeAttribute("opened"),null===(t=this.afterClose)||void 0===t||t.call(this)}async open(){var e,t;await(null===(e=this.beforeOpen)||void 0===e?void 0:e.call(this)),null===(t=this.ele)||void 0===t||t.setAttribute("opened","true")}reset(){var e;this.ele&&(this.ele.innerHTML=""),o(this,ho,"f")&&(null===(e=this.ele)||void 0===e||e.append(o(this,ho,"f").content.cloneNode(!0)))}setContent(e){i(this,ho,e,"f"),this.reset()}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}};ho=new WeakMap;let po=class extends lo{constructor(){super(...arguments),this.nodeName="descope-notification"}close(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("opened")}show(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("opened","true")}setContent(e){this.ele.innerHTML="",this.ele.appendChild(e.content.cloneNode(!0))}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}},go=class extends lo{constructor(){super(...arguments),this.nodeName="descope-avatar"}set displayName(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("display-name",e)}set image(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("img",e)}get flowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id")}onClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("click",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("click",e)}}},vo=class extends lo{constructor(){super(...arguments),this.nodeName="descope-user-attribute"}set value(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("value",e)}set badgeLabel(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("badge-label",e)}get label(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("label"))||""}get editFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("edit-flow-id"))||""}get deleteFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("delete-flow-id"))||""}onEditClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("edit-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("edit-clicked",e)}}onDeleteClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("delete-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("delete-clicked",e)}}},mo=class extends lo{constructor(){super(...arguments),this.nodeName="descope-user-auth-method"}set fulfilled(e){var t,n;e?null===(t=this.ele)||void 0===t||t.setAttribute("fulfilled","true"):null===(n=this.ele)||void 0===n||n.removeAttribute("fulfilled")}onButtonClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("button-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("button-clicked",e)}}get flowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id")}},bo=class extends lo{constructor(){super(...arguments),this.nodeName="descope-wc"}set projectId(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("project-id",e)}set baseUrl(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("base-url",e)}set flowId(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("flow-id",e)}onSuccess(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("success",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("success",e)}}};var wo=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),yo=()=>Math.random().toString(36).substring(7).split("").join("."),ko={INIT:`@@redux/INIT${yo()}`,REPLACE:`@@redux/REPLACE${yo()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${yo()}`};function Io(e){if("object"!=typeof e||null===e)return!1;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||null===Object.getPrototypeOf(e)}function So(e){if(void 0===e)return"undefined";if(null===e)return"null";const t=typeof e;switch(t){case"boolean":case"string":case"number":case"symbol":case"function":return t}if(Array.isArray(e))return"array";if(function(e){return e instanceof Date||"function"==typeof e.toDateString&&"function"==typeof e.getDate&&"function"==typeof e.setDate}(e))return"date";if(function(e){return e instanceof Error||"string"==typeof e.message&&e.constructor&&"number"==typeof e.constructor.stackTraceLimit}(e))return"error";const n=function(e){return"function"==typeof e.constructor?e.constructor.name:null}(e);switch(n){case"Symbol":case"Promise":case"WeakMap":case"WeakSet":case"Map":case"Set":return n}return Object.prototype.toString.call(e).slice(8,-1).toLowerCase().replace(/\s/g,"")}function jo(e){let t=typeof e;return t=So(e),t}function xo(e,t,n){if("function"!=typeof e)throw new Error(`Expected the root reducer to be a function. Instead, received: '${jo(e)}'`);if("function"==typeof t&&"function"==typeof n||"function"==typeof n&&"function"==typeof arguments[3])throw new Error("It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.");if("function"==typeof t&&void 0===n&&(n=t,t=void 0),void 0!==n){if("function"!=typeof n)throw new Error(`Expected the enhancer to be a function. Instead, received: '${jo(n)}'`);return n(xo)(e,t)}let o=e,i=t,r=new Map,s=r,a=0,c=!1;function l(){s===r&&(s=new Map,r.forEach(((e,t)=>{s.set(t,e)})))}function d(){if(c)throw new Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return i}function u(e){if("function"!=typeof e)throw new Error(`Expected the listener to be a function. Instead, received: '${jo(e)}'`);if(c)throw new Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");let t=!0;l();const n=a++;return s.set(n,e),function(){if(t){if(c)throw new Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");t=!1,l(),s.delete(n),r=null}}}function h(e){if(!Io(e))throw new Error(`Actions must be plain objects. Instead, the actual type was: '${jo(e)}'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.`);if(void 0===e.type)throw new Error('Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');if("string"!=typeof e.type)throw new Error(`Action "type" property must be a string. Instead, the actual type was: '${jo(e.type)}'. Value was: '${e.type}' (stringified)`);if(c)throw new Error("Reducers may not dispatch actions.");try{c=!0,i=o(i,e)}finally{c=!1}return(r=s).forEach((e=>{e()})),e}h({type:ko.INIT});return{dispatch:h,subscribe:u,getState:d,replaceReducer:function(e){if("function"!=typeof e)throw new Error(`Expected the nextReducer to be a function. Instead, received: '${jo(e)}`);o=e,h({type:ko.REPLACE})},[wo]:function(){const e=u;return{subscribe(t){if("object"!=typeof t||null===t)throw new Error(`Expected the observer to be an object. Instead, received: '${jo(t)}'`);function n(){const e=t;e.next&&e.next(d())}n();return{unsubscribe:e(n)}},[wo](){return this}}}}}function Co(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}function Ao(e){const t=Object.keys(e),n={};for(let o=0;o<t.length;o++){const i=t[o];void 0===e[i]&&Co(`No reducer provided for key "${i}"`),"function"==typeof e[i]&&(n[i]=e[i])}const o=Object.keys(n);let i,r;i={};try{!function(e){Object.keys(e).forEach((t=>{const n=e[t];if(void 0===n(void 0,{type:ko.INIT}))throw new Error(`The slice reducer for key "${t}" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);if(void 0===n(void 0,{type:ko.PROBE_UNKNOWN_ACTION()}))throw new Error(`The slice reducer for key "${t}" returned undefined when probed with a random type. Don't try to handle '${ko.INIT}' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.`)}))}(n)}catch(e){r=e}return function(e={},t){if(r)throw r;{const o=function(e,t,n,o){const i=Object.keys(t),r=n&&n.type===ko.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(0===i.length)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!Io(e))return`The ${r} has unexpected type of "${jo(e)}". Expected argument to be an object with the following keys: "${i.join('", "')}"`;const s=Object.keys(e).filter((e=>!t.hasOwnProperty(e)&&!o[e]));return s.forEach((e=>{o[e]=!0})),n&&n.type===ko.REPLACE?void 0:s.length>0?`Unexpected ${s.length>1?"keys":"key"} "${s.join('", "')}" found in ${r}. Expected to find one of the known reducer keys instead: "${i.join('", "')}". Unexpected keys will be ignored.`:void 0}(e,n,t,i);o&&Co(o)}let s=!1;const a={};for(let i=0;i<o.length;i++){const r=o[i],c=n[r],l=e[r],d=c(l,t);if(void 0===d){const e=t&&t.type;throw new Error(`When called with an action of type ${e?`"${String(e)}"`:"(unknown type)"}, the slice reducer for key "${r}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`)}a[r]=d,s=s||d!==l}return s=s||o.length!==Object.keys(e).length,s?a:e}}function Eo(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...n)=>e(t(...n))))}function Oo(e){return Io(e)&&"type"in e&&"string"==typeof e.type}var Uo=Symbol.for("immer-nothing"),_o=Symbol.for("immer-draftable"),Ro=Symbol.for("immer-state"),To=[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}];function Mo(e,...t){{const n=To[e],o="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${o}`)}}var Lo=Object.getPrototypeOf;function Po(e){return!!e&&!!e[Ro]}function Wo(e){return!!e&&(Do(e)||Array.isArray(e)||!!e[_o]||!!e.constructor?.[_o]||Bo(e)||Vo(e))}var $o=Object.prototype.constructor.toString();function Do(e){if(!e||"object"!=typeof e)return!1;const t=Lo(e);if(null===t)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object||"function"==typeof n&&Function.toString.call(n)===$o}function No(e,t){0===Fo(e)?Object.entries(e).forEach((([n,o])=>{t(n,o,e)})):e.forEach(((n,o)=>t(o,n,e)))}function Fo(e){const t=e[Ro];return t?t.type_:Array.isArray(e)?1:Bo(e)?2:Vo(e)?3:0}function qo(e,t){return 2===Fo(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function zo(e,t,n){const o=Fo(e);2===o?e.set(t,n):3===o?e.add(n):e[t]=n}function Bo(e){return e instanceof Map}function Vo(e){return e instanceof Set}function Ho(e){return e.copy_||e.base_}function Ko(e,t){if(Bo(e))return new Map(e);if(Vo(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&Do(e)){if(!Lo(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const n=Object.getOwnPropertyDescriptors(e);delete n[Ro];let o=Reflect.ownKeys(n);for(let t=0;t<o.length;t++){const i=o[t],r=n[i];!1===r.writable&&(r.writable=!0,r.configurable=!0),(r.get||r.set)&&(n[i]={configurable:!0,writable:!0,enumerable:r.enumerable,value:e[i]})}return Object.create(Lo(e),n)}function Go(e,t=!1){return Xo(e)||Po(e)||!Wo(e)||(Fo(e)>1&&(e.set=e.add=e.clear=e.delete=Jo),Object.freeze(e),t&&No(e,((e,t)=>Go(t,!0)))),e}function Jo(){Mo(2)}function Xo(e){return Object.isFrozen(e)}var Yo,Zo={};function Qo(e){const t=Zo[e];return t||Mo(0,e),t}function ei(){return Yo}function ti(e,t){t&&(Qo("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function ni(e){oi(e),e.drafts_.forEach(ri),e.drafts_=null}function oi(e){e===Yo&&(Yo=e.parent_)}function ii(e){return Yo={drafts_:[],parent_:Yo,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function ri(e){const t=e[Ro];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function si(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[Ro].modified_&&(ni(t),Mo(4)),Wo(e)&&(e=ai(t,e),t.parent_||li(t,e)),t.patches_&&Qo("Patches").generateReplacementPatches_(n[Ro].base_,e,t.patches_,t.inversePatches_)):e=ai(t,n,[]),ni(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Uo?e:void 0}function ai(e,t,n){if(Xo(t))return t;const o=t[Ro];if(!o)return No(t,((i,r)=>ci(e,o,t,i,r,n))),t;if(o.scope_!==e)return t;if(!o.modified_)return li(e,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;const t=o.copy_;let i=t,r=!1;3===o.type_&&(i=new Set(t),t.clear(),r=!0),No(i,((i,s)=>ci(e,o,t,i,s,n,r))),li(e,t,!1),n&&e.patches_&&Qo("Patches").generatePatches_(o,n,e.patches_,e.inversePatches_)}return o.copy_}function ci(e,t,n,o,i,r,s){if(i===n&&Mo(5),Po(i)){const s=ai(e,i,r&&t&&3!==t.type_&&!qo(t.assigned_,o)?r.concat(o):void 0);if(zo(n,o,s),!Po(s))return;e.canAutoFreeze_=!1}else s&&n.add(i);if(Wo(i)&&!Xo(i)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;ai(e,i),t&&t.scope_.parent_||li(e,i)}}function li(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Go(t,n)}var di={get(e,t){if(t===Ro)return e;const n=Ho(e);if(!qo(n,t))return function(e,t,n){const o=fi(t,n);return o?"value"in o?o.value:o.get?.call(e.draft_):void 0}(e,n,t);const o=n[t];return e.finalized_||!Wo(o)?o:o===hi(e.base_,t)?(gi(e),e.copy_[t]=vi(o,e)):o},has:(e,t)=>t in Ho(e),ownKeys:e=>Reflect.ownKeys(Ho(e)),set(e,t,n){const o=fi(Ho(e),t);if(o?.set)return o.set.call(e.draft_,n),!0;if(!e.modified_){const o=hi(Ho(e),t),i=o?.[Ro];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}(n,o)&&(void 0!==n||qo(e.base_,t)))return!0;gi(e),pi(e)}return e.copy_[t]===n&&(void 0!==n||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty:(e,t)=>(void 0!==hi(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,gi(e),pi(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=Ho(e),o=Reflect.getOwnPropertyDescriptor(n,t);return o?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:o.enumerable,value:n[t]}:o},defineProperty(){Mo(11)},getPrototypeOf:e=>Lo(e.base_),setPrototypeOf(){Mo(12)}},ui={};function hi(e,t){const n=e[Ro];return(n?Ho(n):e)[t]}function fi(e,t){if(!(t in e))return;let n=Lo(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=Lo(n)}}function pi(e){e.modified_||(e.modified_=!0,e.parent_&&pi(e.parent_))}function gi(e){e.copy_||(e.copy_=Ko(e.base_,e.scope_.immer_.useStrictShallowCopy_))}No(di,((e,t)=>{ui[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),ui.deleteProperty=function(e,t){return isNaN(parseInt(t))&&Mo(13),ui.set.call(this,e,t,void 0)},ui.set=function(e,t,n){return"length"!==t&&isNaN(parseInt(t))&&Mo(14),di.set.call(this,e[0],t,n,e[0])};function vi(e,t){const n=Bo(e)?Qo("MapSet").proxyMap_(e,t):Vo(e)?Qo("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),o={type_:n?1:0,scope_:t?t.scope_:ei(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=o,r=di;n&&(i=[o],r=ui);const{revoke:s,proxy:a}=Proxy.revocable(i,r);return o.draft_=a,o.revoke_=s,a}(e,t);return(t?t.scope_:ei()).drafts_.push(n),n}function mi(e){return Po(e)||Mo(10,e),bi(e)}function bi(e){if(!Wo(e)||Xo(e))return e;const t=e[Ro];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Ko(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Ko(e,!0);return No(n,((e,t)=>{zo(n,e,bi(t))})),t&&(t.finalized_=!1),n}var wi=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,t,n)=>{if("function"==typeof e&&"function"!=typeof t){const n=t;t=e;const o=this;return function(e=n,...i){return o.produce(e,(e=>t.call(this,e,...i)))}}let o;if("function"!=typeof t&&Mo(6),void 0!==n&&"function"!=typeof n&&Mo(7),Wo(e)){const i=ii(this),r=vi(e,void 0);let s=!0;try{o=t(r),s=!1}finally{s?ni(i):oi(i)}return ti(i,n),si(o,i)}if(!e||"object"!=typeof e){if(o=t(e),void 0===o&&(o=e),o===Uo&&(o=void 0),this.autoFreeze_&&Go(o,!0),n){const t=[],i=[];Qo("Patches").generateReplacementPatches_(e,o,t,i),n(t,i)}return o}Mo(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...n)=>this.produceWithPatches(t,(t=>e(t,...n)));let n,o;const i=this.produce(e,t,((e,t)=>{n=e,o=t}));return[i,n,o]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){Wo(e)||Mo(8),Po(e)&&(e=mi(e));const t=ii(this),n=vi(e,void 0);return n[Ro].isManual_=!0,oi(t),n}finishDraft(e,t){const n=e&&e[Ro];n&&n.isManual_||Mo(9);const{scope_:o}=n;return ti(o,t),si(void 0,o)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const o=t[n];if(0===o.path.length&&"replace"===o.op){e=o.value;break}}n>-1&&(t=t.slice(n+1));const o=Qo("Patches").applyPatches_;return Po(e)?o(e,t):this.produce(e,(e=>o(e,t)))}},yi=wi.produce;wi.produceWithPatches.bind(wi),wi.setAutoFreeze.bind(wi),wi.setUseStrictShallowCopy.bind(wi),wi.applyPatches.bind(wi),wi.createDraft.bind(wi),wi.finishDraft.bind(wi);var ki=(e,t,n)=>{if(1===t.length&&t[0]===n){let t=!1;try{const n={};e(n)===n&&(t=!0)}catch{}if(t){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("The result function returned its own inputs without modification. e.g\n`createSelector([state => state.todos], todos => todos)`\nThis could lead to inefficient memoization and unnecessary re-renders.\nEnsure transformation logic is in the result function, and extraction logic is in the input selectors.",{stack:e})}}},Ii=(e,t,n)=>{const{memoize:o,memoizeOptions:i}=t,{inputSelectorResults:r,inputSelectorResultsCopy:s}=e,a=o((()=>({})),...i);if(!(a.apply(null,r)===a.apply(null,s))){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("An input selector returned a different result when passed same arguments.\nThis means your output selector will likely run more frequently than intended.\nAvoid returning a new reference inside your input selector, e.g.\n`createSelector([state => state.todos.map(todo => todo.id)], todoIds => todoIds.length)`",{arguments:n,firstInputs:r,secondInputs:s,stack:e})}},Si={inputStabilityCheck:"once",identityFunctionCheck:"once"};var ji=e=>Array.isArray(e)?e:[e];function xi(e){const t=Array.isArray(e[0])?e[0]:e;return function(e,t="expected all items to be functions, instead received the following types: "){if(!e.every((e=>"function"==typeof e))){const n=e.map((e=>"function"==typeof e?`function ${e.name||"unnamed"}()`:typeof e)).join(", ");throw new TypeError(`${t}[${n}]`)}}(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function Ci(e,t){const n=[],{length:o}=e;for(let i=0;i<o;i++)n.push(e[i].apply(null,t));return n}var Ai="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}},Ei=0,Oi=1;function Ui(){return{s:Ei,v:void 0,o:null,p:null}}function _i(e,t={}){let n=Ui();const{resultEqualityCheck:o}=t;let i,r=0;function s(){let t=n;const{length:s}=arguments;for(let e=0,n=s;e<n;e++){const n=arguments[e];if("function"==typeof n||"object"==typeof n&&null!==n){let e=t.o;null===e&&(t.o=e=new WeakMap);const o=e.get(n);void 0===o?(t=Ui(),e.set(n,t)):t=o}else{let e=t.p;null===e&&(t.p=e=new Map);const o=e.get(n);void 0===o?(t=Ui(),e.set(n,t)):t=o}}const a=t;let c;if(t.s===Oi)c=t.v;else if(c=e.apply(null,arguments),r++,o){const e=i?.deref?.()??i;null!=e&&o(e,c)&&(c=e,0!==r&&r--);i="object"==typeof c&&null!==c||"function"==typeof c?new Ai(c):c}return a.s=Oi,a.v=c,c}return s.clearCache=()=>{n=Ui(),s.resetResultsCount()},s.resultsCount=()=>r,s.resetResultsCount=()=>{r=0},s}function Ri(e,...t){const n="function"==typeof e?{memoize:e,memoizeOptions:t}:e,o=(...e)=>{let t,o=0,i=0,r={},s=e.pop();"object"==typeof s&&(r=s,s=e.pop()),function(e,t="expected a function, instead received "+typeof e){if("function"!=typeof e)throw new TypeError(t)}(s,`createSelector expects an output function after the inputs, but received: [${typeof s}]`);const a={...n,...r},{memoize:c,memoizeOptions:l=[],argsMemoize:d=_i,argsMemoizeOptions:u=[],devModeChecks:h={}}=a,f=ji(l),p=ji(u),g=xi(e),v=c((function(){return o++,s.apply(null,arguments)}),...f);let m=!0;const b=d((function(){i++;const e=Ci(g,arguments);t=v.apply(null,e);{const{identityFunctionCheck:n,inputStabilityCheck:o}=((e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:o}={...Si,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:ki},inputStabilityCheck:{shouldRun:"always"===o||"once"===o&&e,run:Ii}}})(m,h);if(n.shouldRun&&n.run(s,e,t),o.shouldRun){const t=Ci(g,arguments);o.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:c,memoizeOptions:f},arguments)}m&&(m=!1)}return t}),...p);return Object.assign(b,{resultFunc:s,memoizedResultFunc:v,dependencies:g,dependencyRecomputations:()=>i,resetDependencyRecomputations:()=>{i=0},lastResult:()=>t,recomputations:()=>o,resetRecomputations:()=>{o=0},memoize:c,argsMemoize:d})};return Object.assign(o,{withTypes:()=>o}),o}var Ti=Ri(_i),Mi=Object.assign(((e,t=Ti)=>{!function(e,t="expected an object, instead received "+typeof e){if("object"!=typeof e)throw new TypeError(t)}(e,"createStructuredSelector expects first argument to be an object where each property is a selector, instead received a "+typeof e);const n=Object.keys(e);return t(n.map((t=>e[t])),((...e)=>e.reduce(((e,t,o)=>(e[n[o]]=t,e)),{})))}),{withTypes:()=>Mi});function Li(e){return({dispatch:t,getState:n})=>o=>i=>"function"==typeof i?i(t,n,e):o(i)}var Pi=Li(),Wi=Li;((...e)=>{const t=Ri(...e)})(_i);var $i="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?Eo:Eo.apply(null,arguments)},Di=e=>e&&"function"==typeof e.match;function Ni(e,t){function n(...n){if(t){let o=t(...n);if(!o)throw new Error("prepareAction did not return an object");return{type:e,payload:o.payload,..."meta"in o&&{meta:o.meta},..."error"in o&&{error:o.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>Oo(t)&&t.type===e,n}function Fi(e){return"function"==typeof e&&"type"in e&&Di(e)}function qi(e,t){let n=0;return{measureTime(e){const t=Date.now();try{return e()}finally{const e=Date.now();n+=e-t}},warnIfExceeded(){n>e&&console.warn(`${t} took ${n}ms, which is more than the warning threshold of ${e}ms. \nIf your state or actions are very large, you may want to disable the middleware as it might cause too much of a slowdown in development mode. See https://redux-toolkit.js.org/api/getDefaultMiddleware for instructions.\nIt is disabled in production builds, so you don't need to worry about that.`)}}}var zi=class e extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,e.prototype)}static get[Symbol.species](){return e}concat(...e){return super.concat.apply(this,e)}prepend(...t){return 1===t.length&&Array.isArray(t[0])?new e(...t[0].concat(this)):new e(...t.concat(this))}};function Bi(e){return Wo(e)?yi(e,(()=>{})):e}function Vi(e,t,n){if(e.has(t)){let o=e.get(t);return n.update&&(o=n.update(o,t,e),e.set(t,o)),o}if(!n.insert)throw new Error("No insert provided for key not already in map");const o=n.insert(t,e);return e.set(t,o),o}function Hi(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function Ki(e,t,n){const o=Gi(e,t,n);return{detectMutations:()=>Ji(e,t,o,n)}}function Gi(e,t=[],n,o="",i=new Set){const r={value:n};if(!e(n)&&!i.has(n)){i.add(n),r.children={};for(const i in n){const s=o?o+"."+i:i;t.length&&-1!==t.indexOf(s)||(r.children[i]=Gi(e,t,n[i],s))}}return r}function Ji(e,t=[],n,o,i=!1,r=""){const s=n?n.value:void 0,a=s===o;if(i&&!a&&!Number.isNaN(o))return{wasMutated:!0,path:r};if(e(s)||e(o))return{wasMutated:!1};const c={};for(let e in n.children)c[e]=!0;for(let e in o)c[e]=!0;const l=t.length>0;for(let i in c){const s=r?r+"."+i:i;if(l){if(t.some((e=>e instanceof RegExp?e.test(s):s===e)))continue}const c=Ji(e,t,n.children[i],o[i],a,s);if(c.wasMutated)return c}return{wasMutated:!1}}function Xi(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||Io(e)}function Yi(e,t="",n=Xi,o,i=[],r){let s;if(!n(e))return{keyPath:t||"<root>",value:e};if("object"!=typeof e||null===e)return!1;if(r?.has(e))return!1;const a=null!=o?o(e):Object.entries(e),c=i.length>0;for(const[e,l]of a){const a=t?t+"."+e:e;if(c){if(i.some((e=>e instanceof RegExp?e.test(a):a===e)))continue}if(!n(l))return{keyPath:a,value:l};if("object"==typeof l&&(s=Yi(l,a,n,o,i,r),s))return s}return r&&Zi(e)&&r.add(e),!1}function Zi(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!Zi(t))return!1;return!0}function Qi(e){return"boolean"==typeof e}var er=()=>function(e){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:o=!0,actionCreatorCheck:i=!0}=e??{};let r=new zi;if(t&&(Qi(t)?r.push(Pi):r.push(Wi(t.extraArgument))),n){let e={};Qi(n)||(e=n),r.unshift(function(e={}){{let t=function(e,t,o,i){return JSON.stringify(e,n(t,i),o)},n=function(e,t){let n=[],o=[];return t||(t=function(e,t){return n[0]===t?"[Circular ~]":"[Circular ~."+o.slice(0,n.indexOf(t)).join(".")+"]"}),function(i,r){if(n.length>0){var s=n.indexOf(this);~s?n.splice(s+1):n.push(this),~s?o.splice(s,1/0,i):o.push(i),~n.indexOf(r)&&(r=t.call(this,i,r))}else n.push(r);return null==e?r:e.call(this,i,r)}},{isImmutable:o=Hi,ignoredPaths:i,warnAfter:r=32}=e;const s=Ki.bind(null,o,i);return({getState:e})=>{let n,o=e(),i=s(o);return a=>c=>{const l=qi(r,"ImmutableStateInvariantMiddleware");l.measureTime((()=>{if(o=e(),n=i.detectMutations(),i=s(o),n.wasMutated)throw new Error(`A state mutation was detected between dispatches, in the path '${n.path||""}'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)}));const d=a(c);return l.measureTime((()=>{if(o=e(),n=i.detectMutations(),i=s(o),n.wasMutated)throw new Error(`A state mutation was detected inside a dispatch, in the path: ${n.path||""}. Take a look at the reducer(s) handling the action ${t(c)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)})),l.warnIfExceeded(),d}}}}(e))}if(o){let e={};Qi(o)||(e=o),r.push(function(e={}){{const{isSerializable:t=Xi,getEntries:n,ignoredActions:o=[],ignoredActionPaths:i=["meta.arg","meta.baseQueryMeta"],ignoredPaths:r=[],warnAfter:s=32,ignoreState:a=!1,ignoreActions:c=!1,disableCache:l=!1}=e,d=!l&&WeakSet?new WeakSet:void 0;return e=>l=>u=>{if(!Oo(u))return l(u);const h=l(u),f=qi(s,"SerializableStateInvariantMiddleware");return c||o.length&&-1!==o.indexOf(u.type)||f.measureTime((()=>{const e=Yi(u,"",t,n,i,d);if(e){const{keyPath:t,value:n}=e;console.error(`A non-serializable value was detected in an action, in the path: \`${t}\`. Value:`,n,"\nTake a look at the logic that dispatched this action: ",u,"\n(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)","\n(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)")}})),a||(f.measureTime((()=>{const o=Yi(e.getState(),"",t,n,r,d);if(o){const{keyPath:e,value:t}=o;console.error(`A non-serializable value was detected in the state, in the path: \`${e}\`. Value:`,t,`\nTake a look at the reducer(s) handling this action type: ${u.type}.\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)`)}})),f.warnIfExceeded()),h}}}(e))}if(i){let e={};Qi(i)||(e=i),r.unshift(function(e={}){const{isActionCreator:t=Fi}=e;return()=>e=>n=>(t(n)&&console.warn(function(e){const t=e?`${e}`.split("/"):[],n=t[t.length-1]||"actionCreator";return`Detected an action creator with type "${e||"unknown"}" being dispatched. \nMake sure you're calling the action creator before dispatching, i.e. \`dispatch(${n}())\` instead of \`dispatch(${n})\`. This is necessary even if the action has no payload.`}(n.type)),e(n))}(e))}return r},tr=e=>t=>{setTimeout(t,e)},nr="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:tr(10),or=e=>function(t){const{autoBatch:n=!0}=t??{};let o=new zi(e);return n&&o.push(((e={type:"raf"})=>t=>(...n)=>{const o=t(...n);let i=!0,r=!1,s=!1;const a=new Set,c="tick"===e.type?queueMicrotask:"raf"===e.type?nr:"callback"===e.type?e.queueNotification:tr(e.timeout),l=()=>{s=!1,r&&(r=!1,a.forEach((e=>e())))};return Object.assign({},o,{subscribe(e){const t=o.subscribe((()=>i&&e()));return a.add(e),()=>{t(),a.delete(e)}},dispatch(e){try{return i=!e?.meta?.RTK_autoBatch,r=!i,r&&(s||(s=!0,c(l))),o.dispatch(e)}finally{i=!0}}})})("object"==typeof n?n:void 0)),o};function ir(e){const t=er(),{reducer:n,middleware:o,devTools:i=!0,preloadedState:r,enhancers:s}=e||{};let a,c;if("function"==typeof n)a=n;else{if(!Io(n))throw new Error("`reducer` is a required argument, and must be a function or an object of functions that can be passed to combineReducers");a=Ao(n)}if(o&&"function"!=typeof o)throw new Error("`middleware` field must be a callback");if("function"==typeof o){if(c=o(t),!Array.isArray(c))throw new Error("when using a middleware builder function, an array of middleware must be returned")}else c=t();if(c.some((e=>"function"!=typeof e)))throw new Error("each middleware provided to configureStore must be a function");let l=Eo;i&&(l=$i({trace:!0,..."object"==typeof i&&i}));const d=function(...e){return t=>(n,o)=>{const i=t(n,o);let r=()=>{throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")};const s={getState:i.getState,dispatch:(e,...t)=>r(e,...t)},a=e.map((e=>e(s)));return r=Eo(...a)(i.dispatch),{...i,dispatch:r}}}(...c),u=or(d);if(s&&"function"!=typeof s)throw new Error("`enhancers` field must be a callback");let h="function"==typeof s?s(u):u();if(!Array.isArray(h))throw new Error("`enhancers` callback must return an array");if(h.some((e=>"function"!=typeof e)))throw new Error("each enhancer provided to configureStore must be a function");c.length&&!h.includes(d)&&console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`");return xo(a,r,l(...h))}function rr(e){const t={},n=[];let o;const i={addCase(e,r){if(n.length>0)throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");if(o)throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`");const s="string"==typeof e?e:e.type;if(!s)throw new Error("`builder.addCase` cannot be called with an empty action type");if(s in t)throw new Error(`\`builder.addCase\` cannot be called with two reducers for the same action type '${s}'`);return t[s]=r,i},addMatcher(e,t){if(o)throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return n.push({matcher:e,reducer:t}),i},addDefaultCase(e){if(o)throw new Error("`builder.addDefaultCase` can only be called once");return o=e,i}};return e(i),[t,n,o]}function sr(...e){return t=>e.some((e=>((e,t)=>Di(e)?e.match(t):e(t))(e,t)))}var ar=["name","message","stack","code"],cr=class{constructor(e,t){this.payload=e,this.meta=t}_type},lr=class{constructor(e,t){this.payload=e,this.meta=t}_type},dr=e=>{if("object"==typeof e&&null!==e){const t={};for(const n of ar)"string"==typeof e[n]&&(t[n]=e[n]);return t}return{message:String(e)}},ur=(()=>{function e(e,t,n){const o=Ni(e+"/fulfilled",((e,t,n,o)=>({payload:e,meta:{...o||{},arg:n,requestId:t,requestStatus:"fulfilled"}}))),i=Ni(e+"/pending",((e,t,n)=>({payload:void 0,meta:{...n||{},arg:t,requestId:e,requestStatus:"pending"}}))),r=Ni(e+"/rejected",((e,t,o,i,r)=>({payload:i,error:(n&&n.serializeError||dr)(e||"Rejected"),meta:{...r||{},arg:o,requestId:t,rejectedWithValue:!!i,requestStatus:"rejected",aborted:"AbortError"===e?.name,condition:"ConditionError"===e?.name}})));return Object.assign((function(e){return(s,a,c)=>{const l=n?.idGenerator?n.idGenerator(e):((e=21)=>{let t="",n=e;for(;n--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t})(),d=new AbortController;let u;function h(e){u=e,d.abort()}const f=async function(){let f;try{let r=n?.condition?.(e,{getState:a,extra:c});if(null!==(p=r)&&"object"==typeof p&&"function"==typeof p.then&&(r=await r),!1===r||d.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};const g=new Promise(((e,t)=>d.signal.addEventListener("abort",(()=>t({name:"AbortError",message:u||"Aborted"})))));s(i(l,e,n?.getPendingMeta?.({requestId:l,arg:e},{getState:a,extra:c}))),f=await Promise.race([g,Promise.resolve(t(e,{dispatch:s,getState:a,extra:c,requestId:l,signal:d.signal,abort:h,rejectWithValue:(e,t)=>new cr(e,t),fulfillWithValue:(e,t)=>new lr(e,t)})).then((t=>{if(t instanceof cr)throw t;return t instanceof lr?o(t.payload,l,e,t.meta):o(t,l,e)}))])}catch(t){f=t instanceof cr?r(null,l,e,t.payload,t.meta):r(t,l,e)}var p;return n&&!n.dispatchConditionRejection&&r.match(f)&&f.meta.condition||s(f),f}();return Object.assign(f,{abort:h,requestId:l,arg:e,unwrap:()=>f.then(hr)})}}),{pending:i,rejected:r,fulfilled:o,settled:sr(r,o),typePrefix:e})}return e.withTypes=()=>e,e})();function hr(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}var fr=Symbol.for("rtk-slice-createasyncthunk");function pr(e,t){return`${e}/${t}`}function gr(e,t,n,o){function i(i,...r){let s=n.call(e,i);if(void 0===s){if(!o)throw new Error("selectState returned undefined for an uninjected slice reducer");s=e.getInitialState()}return t(s,...r)}return i.unwrapped=t,i}var vr=function({creators:e}={}){const t=e?.asyncThunk?.[fr];return function(e){const{name:n,reducerPath:o=n}=e;if(!n)throw new Error("`name` is a required option for createSlice");"undefined"!=typeof process&&void 0===e.initialState&&console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");const i=("function"==typeof e.reducers?e.reducers(function(){function e(e,t){return{_reducerDefinitionType:"asyncThunk",payloadCreator:e,...t}}return e.withTypes=()=>e,{reducer:e=>Object.assign({[e.name]:(...t)=>e(...t)}[e.name],{_reducerDefinitionType:"reducer"}),preparedReducer:(e,t)=>({_reducerDefinitionType:"reducerWithPrepare",prepare:e,reducer:t}),asyncThunk:e}}()):e.reducers)||{},r=Object.keys(i),s={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},a={addCase(e,t){const n="string"==typeof e?e:e.type;if(!n)throw new Error("`context.addCase` cannot be called with an empty action type");if(n in s.sliceCaseReducersByType)throw new Error("`context.addCase` cannot be called with two reducers for the same action type: "+n);return s.sliceCaseReducersByType[n]=t,a},addMatcher:(e,t)=>(s.sliceMatchers.push({matcher:e,reducer:t}),a),exposeAction:(e,t)=>(s.actionCreators[e]=t,a),exposeCaseReducer:(e,t)=>(s.sliceCaseReducersByName[e]=t,a)};function c(){if("object"==typeof e.extraReducers)throw new Error("The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");const[t={},n=[],o]="function"==typeof e.extraReducers?rr(e.extraReducers):[e.extraReducers],i={...t,...s.sliceCaseReducersByType};return function(e,t){if("object"==typeof t)throw new Error("The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");let n,[o,i,r]=rr(t);if(function(e){return"function"==typeof e}(e))n=()=>Bi(e());else{const t=Bi(e);n=()=>t}function s(e=n(),t){let s=[o[t.type],...i.filter((({matcher:e})=>e(t))).map((({reducer:e})=>e))];return 0===s.filter((e=>!!e)).length&&(s=[r]),s.reduce(((e,n)=>{if(n){if(Po(e)){const o=n(e,t);return void 0===o?e:o}if(Wo(e))return yi(e,(e=>n(e,t)));{const o=n(e,t);if(void 0===o){if(null===e)return e;throw new Error("A case reducer on a non-draftable value must not return undefined")}return o}}return e}),e)}return s.getInitialState=n,s}(e.initialState,(e=>{for(let t in i)e.addCase(t,i[t]);for(let t of s.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);o&&e.addDefaultCase(o)}))}r.forEach((o=>{const r=i[o],s={reducerName:o,type:pr(n,o),createNotation:"function"==typeof e.reducers};!function(e){return"asyncThunk"===e._reducerDefinitionType}(r)?function({type:e,reducerName:t,createNotation:n},o,i){let r,s;if("reducer"in o){if(n&&!function(e){return"reducerWithPrepare"===e._reducerDefinitionType}(o))throw new Error("Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");r=o.reducer,s=o.prepare}else r=o;i.addCase(e,r).exposeCaseReducer(t,r).exposeAction(t,s?Ni(e,s):Ni(e))}(s,r,a):function({type:e,reducerName:t},n,o,i){if(!i)throw new Error("Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");const{payloadCreator:r,fulfilled:s,pending:a,rejected:c,settled:l,options:d}=n,u=i(e,r,d);o.exposeAction(t,u),s&&o.addCase(u.fulfilled,s);a&&o.addCase(u.pending,a);c&&o.addCase(u.rejected,c);l&&o.addMatcher(u.settled,l);o.exposeCaseReducer(t,{fulfilled:s||mr,pending:a||mr,rejected:c||mr,settled:l||mr})}(s,r,a,t)}));const l=e=>e,d=new WeakMap;let u;const h={name:n,reducerPath:o,reducer:(e,t)=>(u||(u=c()),u(e,t)),actions:s.actionCreators,caseReducers:s.sliceCaseReducersByName,getInitialState:()=>(u||(u=c()),u.getInitialState()),getSelectors(t=l){const n=Vi(d,this,{insert:()=>new WeakMap});return Vi(n,t,{insert:()=>{const n={};for(const[o,i]of Object.entries(e.selectors??{}))n[o]=gr(this,i,t,this!==h);return n}})},selectSlice(e){let t=e[this.reducerPath];if(void 0===t){if(this===h)throw new Error("selectSlice returned undefined for an uninjected slice reducer");t=this.getInitialState()}return t},get selectors(){return this.getSelectors(this.selectSlice)},injectInto(e,{reducerPath:t,...n}={}){const o=t??this.reducerPath;return e.inject({reducerPath:o,reducer:this.reducer},n),{...this,reducerPath:o}}};return h}}();function mr(){}var br="listenerMiddleware";Ni(`${br}/add`),Ni(`${br}/removeAll`),Ni(`${br}/remove`);const wr=["error","warn","info","debug"],yr=c((e=>{var t,n,r,s;return s=class extends e{constructor(){super(...arguments),t.add(this),n.set(this,o(this,t,"m",r).call(this,console))}set logger(e){i(this,n,o(this,t,"m",r).call(this,e),"f")}get logger(){return o(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,r=function(e){return wr.reduce(((t,n)=>(t[n]=(...t)=>{var o;this.onLogEvent(n,t),null===(o=e[n])||void 0===o||o.call(e,...t)},t)),{})},s})),kr="undefined"!=typeof localStorage,Ir=kr&&localStorage.getItem("base.content.url")||"",Sr=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,jr=c((e=>{var t,n;return n=class extends e{constructor(){super(...arguments),t.set(this,!0)}connectedCallback(){var e,n;null===(e=super.connectedCallback)||void 0===e||e.call(this),(null===(n=this.shadowRoot)||void 0===n?void 0:n.isConnected)&&o(this,t,"f")&&(i(this,t,!1,"f"),this.init())}async init(){}},t=new WeakMap,n})),xr=c((e=>{var t,n;const i=r(yr,jr)(e);return n=class extends i{constructor(){super(...arguments),t.set(this,{})}async init(){var e,n,i;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),n=this,i=e=>{var n;null===(n=o(this,t,"f")[e])||void 0===n||n.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(n.attributes).forEach((e=>i(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&i(e.attributeName)}))})).observe(n,{attributes:!0})}observeAttribute(e,n){o(this,t,"f")[e]||(o(this,t,"f")[e]=[]);const i=o(this,t,"f")[e].push(n);return()=>o(this,t,"f")[e].splice(i,1)}observeAttributes(e,t){const n=e.reduce(((e,n)=>(e.push(this.observeAttribute(n,t)),e)),[]);return()=>n.forEach((e=>e()))}},t=new WeakMap,n})),Cr=e=>t=>{var n,i,s;const a=r(yr,jr,xr)(t),c=Object.keys(e);return s=class extends a{constructor(...e){super(...e),n.add(this),this.observeAttributes(c,o(this,n,"m",i).bind(this))}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),c.forEach((e=>o(this,n,"m",i).call(this,e,this.getAttribute(e))))}},n=new WeakSet,i=function(t,n){const o=e[t],i="function"==typeof o?o(t,n):o;i&&this.logger.error(i)},s};Cr.missingAttrValidator=Sr;const Ar=c((e=>{const t=r(Cr({"project-id":Sr}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),Er=c((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}}));const Or=c((e=>{const t=r(yr,Ar,Er)(e);return class extends t{async fetchStaticResource(e,t){const n=function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:o}){const i=new URL(Ir||o||"https://static.descope.com/pages");return i.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(i.pathname,e,n,t),i.toString()}({projectId:this.projectId,filename:e,baseUrl:this.baseStaticUrl}),o=await fetch(n,{cache:"default"});return o.ok||this.logger.error(`Error fetching URL ${n} [${o.status}]`),{body:await o[t](),headers:Object.fromEntries(o.headers.entries())}}get baseStaticUrl(){return this.getAttribute("base-static-url")}}})),Ur=c((e=>{var t,n,s;const a=r(Or)(e);return s=class extends a{constructor(){super(...arguments),t.set(this,void 0),n.set(this,(async()=>{try{const{body:e,headers:t}=await this.fetchStaticResource("config.json","json");return{projectConfig:e,executionContext:{geo:t["x-geo"]}}}catch(e){this.logger.error("Cannot fetch config file","make sure that your projectId & flowId are correct")}}))}get config(){return o(this,t,"f")||i(this,t,o(this,n,"f").call(this),"f"),o(this,t,"f")}},t=new WeakMap,n=new WeakMap,s})),_r=c((e=>{var t,n,s,a,c,l,d;return d=class extends(r(jr,yr)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),this.attributeChangedCallback=(e,n,i)=>{var r;null===(r=super.attributeChangedCallback)||void 0===r||r.call(this,e,n,i),"debug"===e&&o(this,t,"m",c).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(e,n){var i;null===(i=super.onLogEvent)||void 0===i||i.call(this,e,n),"error"===e&&o(this,t,"m",l).call(this,n[0]||"Error",n[1])}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),o(this,t,"m",c).call(this)}},n=new WeakMap,t=new WeakSet,s=function(){var e;null===(e=o(this,n,"f"))||void 0===e||e.remove(),i(this,n,null,"f")},a=async function(){i(this,n,document.createElement("descope-debugger"),"f"),Object.assign(o(this,n,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),await Promise.resolve().then((function(){return cs})),document.body.appendChild(o(this,n,"f"))},c=function(){this.debug?o(this,t,"m",a).call(this):o(this,t,"m",s).call(this)},l=function(e,t){var i;e&&(null===(i=o(this,n,"f"))||void 0===i||i.updateData({title:e,description:t}))},d})),Rr="load-descope-ui",Tr="base.ui.components.url",Mr=kr&&localStorage.getItem(Tr)||"https://static.descope.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",Lr=kr&&localStorage.getItem(Tr)||"https://cdn.jsdelivr.net/npm/@descope/web-components-ui@<version>/dist/umd/index.js",Pr=e=>{const t=document.createElement("script");return t.id=e,t},Wr=(e,t)=>e.replace("<version>",t),$r=c((e=>{var t,n,s,a,c,l,d,u,h,f,p,g;const v=r(yr,Ur)(e);return g=class extends v{constructor(){super(...arguments),t.add(this),n.set(this,Symbol("errorCbs")),s.set(this,Symbol("loadCbs")),h.set(this,void 0)}get descopeUi(){return o(this,h,"f")||i(this,h,o(this,t,"m",p).call(this),"f"),o(this,h,"f")}async loadDescopeUiComponents(e){const n=Array.isArray(e)?e:(e=>[...Array.from(e.content.querySelectorAll("*")).reduce(((e,t)=>t.localName.startsWith("descope-")?e.add(t.localName):e),new Set)])(e);return Promise.all(n.map((e=>o(this,t,"m",f).call(this,e))))}},n=new WeakMap,s=new WeakMap,h=new WeakMap,t=new WeakSet,a=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return n?this.logger.debug(`Got component version "${n}"`):this.logger.error("Could not get components version"),n},c=function(e){const t=o(this,n,"f"),i=o(this,s,"f");e[t]=[],e[i]=[],Object.defineProperty(e,"onerror",{set(n){e[t].push(n)}}),Object.defineProperty(e,"onload",{set(t){e[i].push(t)}})},l=async function(e,n){this.logger.debug("Trying to load DescopeUI from a fallback URL");const i=Pr("load-descope-ui-fallback-script");document.body.append(i),i.addEventListener("error",(()=>{e.forEach((e=>e(`Cannot load DescopeUI from fallback URL, Make sure this URL is valid and return the correct script: "${i.src}"`)))})),i.addEventListener("load",(()=>{n.forEach((e=>e()))})),i.src=Wr(Lr,await o(this,t,"m",a).call(this))},d=function(e){e.addEventListener("error",(()=>{e[o(this,n,"f")].forEach((t=>t(`Cannot load DescopeUI from main URL, Make sure this URL is valid and return the correct script: "${e.src}"`))),o(this,t,"m",l).call(this,e[o(this,n,"f")],e[o(this,s,"f")])})),e.addEventListener("load",(()=>{e[o(this,s,"f")].forEach((e=>e()))}))},u=async function(){if(document.querySelector(`script#${Rr}`))this.logger.debug("DescopeUI loading script already exists",this);else{this.logger.debug("DescopeUI loading script does not exist, creating it",this);const e=Pr(Rr);document.body.append(e),o(this,t,"m",c).call(this,e),o(this,t,"m",d).call(this,e),e.src=Wr(Mr,await o(this,t,"m",a).call(this))}return document.getElementById(Rr)},f=async function(e){if(!!customElements.get(e))return void this.logger.debug(`Loading component "${e}" is skipped as it is already defined`);const t=await this.descopeUi;if(t[e])try{return await t[e]()}catch(t){if("NotSupportedError"!==t.name)throw t;console.debug(`Encountered an error while attempting to define the "${e}" component, it is likely that this component is already defined`)}else this.logger.error(`Cannot load UI component "${e}"`,`Descope UI does not have a component named "${e}", available components are: "${Object.keys(t).join(", ")}"`)},p=function(){return new Promise((e=>{globalThis.DescopeUI&&e(globalThis.DescopeUI),o(this,t,"m",u).call(this).then((t=>{t.onerror=this.logger.error,t.onload=()=>{this.logger.debug("DescopeUI was loaded"),e(globalThis.DescopeUI)},setTimeout((()=>{globalThis.DescopeUI&&e(globalThis.DescopeUI)}))}))}))},g})),Dr="content-root",Nr="root",Fr=c((e=>class extends e{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n\n <style>\n #${Nr}, #${Dr} {\n height: 100%;\n }\n #${Nr} {\n position: relative;\n height: fit-content;\n }\n </style>\n <div id="${Nr}">\n <div id="${Dr}"></div>\n </div>\n `,this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById(Dr),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(Nr)}})),qr="descope-modal",zr=c((e=>{var t,n;const i=r(jr,Fr,$r)(e);return n=class extends i{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends fo{setContent(t){e(t),super.setContent(t)}}})())}createModal(e){const n=((e={})=>{const t=document.createElement(qr);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(o(this,t,"f"))(n,{logger:this.logger})}async init(){var e;this.loadDescopeUiComponents([qr]),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},t=new WeakMap,n})),Br="descope-notification";c((e=>{var t,n;const i=r(jr,Fr,$r)(e);return n=class extends i{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends po{setContent(t){const n="string"==typeof t?s(t):t;e(n),super.setContent(n)}}})())}createNotification(e){const n=((e={})=>{const t=document.createElement(Br);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(o(this,t,"f"))(n,{logger:this.logger})}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.loadDescopeUiComponents([Br])}},t=new WeakMap,n}));const Vr=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',Hr=c((e=>{var t,n,s,a,c,l,d,u,h,f,p;const g=r(Cr({theme:Vr}),Or,jr,$r,Ur,Fr,xr)(e);return p=class extends g{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0)}get theme(){var e,t;const n=this.getAttribute("theme");if("os"===n){return window.matchMedia&&(null===(t=null===(e=window.matchMedia)||void 0===e?void 0:e.call(window,"(prefers-color-scheme: dark)"))||void 0===t?void 0:t.matches)?"dark":"light"}return n||"light"}get styleId(){return this.getAttribute("style-id")||"theme"}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),o(this,t,"m",l).call(this),o(this,t,"m",d).call(this),o(this,t,"m",h).call(this),o(this,t,"m",f).call(this),this.observeAttributes(["theme"],(()=>{o(this,t,"m",h).call(this),o(this,t,"m",f).call(this)})),this.observeAttributes(["style-id"],(()=>{i(this,s,null,"f"),o(this,t,"m",h).call(this),o(this,t,"m",l).call(this),o(this,t,"m",d).call(this)}))}},n=new WeakMap,s=new WeakMap,t=new WeakSet,a=async function(){try{const{body:e}=await this.fetchStaticResource(`${this.styleId}.json`,"json");if(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(Tr))try{this.logger.warn("You are in DEV mode, and UI components override URL was found\ntrying to merge project theme with the default theme of the UI components");const t=await(async()=>{const e=localStorage.getItem(Tr),t=null==e?void 0:e.replace(/[^\/]+$/,"DescopeDev.js");console.warn("Trying to load DescopeDev.js from",t);const n=document.createElement("script");if(n.src=t,document.body.appendChild(n),await new Promise(((e,t)=>{n.onload=e,n.onerror=t})),globalThis.DescopeDev){const{themeToStyle:e,defaultTheme:t,darkTheme:n}=globalThis.DescopeDev;return{light:e(t),dark:e(n)}}})();t&&(e.light.components=Object.assign(Object.assign({},t.light.components),e.light.components),e.dark.components=Object.assign(Object.assign({},t.dark.components),e.dark.components),this.logger.warn("Theme was merged successfully"),console.log("%cNOTICE! This is not the theme that will be used in production!\n\nMake sure to test it without the override UI components URL!","color: black; background-color:yellow; font-size: x-large"))}catch(e){this.logger.error("Failed to merge UI components theme\n",e)}return e}catch(e){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}},c=function(){return o(this,s,"f")||(i(this,s,o(this,t,"m",a).call(this),"f"),o(this,s,"f").then((e=>this.logger.debug("Fetched theme",e)))),o(this,s,"f")},l=async function(){var e,r;const s=await o(this,t,"a",c);s&&(o(this,n,"f")||(i(this,n,document.createElement("style"),"f"),o(this,n,"f").id="global-style",this.shadowRoot.appendChild(o(this,n,"f"))),o(this,n,"f").innerText=((null===(e=null==s?void 0:s.light)||void 0===e?void 0:e.globals)||"")+((null===(r=null==s?void 0:s.dark)||void 0===r?void 0:r.globals)||""))},d=async function(){var e,n;const i=Object.assign({},await o(this,t,"a",c));if(!i)return;const r=await this.descopeUi;(null==r?void 0:r.componentsThemeManager)&&(r.componentsThemeManager.themes={light:null===(e=null==i?void 0:i.light)||void 0===e?void 0:e.components,dark:null===(n=null==i?void 0:i.dark)||void 0===n?void 0:n.components})},u=async function(){var e,t;const{projectConfig:n}=await this.config||{},o=null===(e=null==n?void 0:n.styles)||void 0===e?void 0:e[this.styleId],i=null==n?void 0:n.cssTemplate,r=o||i;return null===(t=null==r?void 0:r[this.theme])||void 0===t?void 0:t.fonts},h=async function(){const e=await o(this,t,"m",u).call(this);e?Object.values(e).forEach((e=>{e.url&&(this.logger.debug(`Loading font from URL "${e.url}"`),(e=>{const t=document.createElement("link");t.href=e,t.rel="stylesheet",document.head.appendChild(t)})(e.url))})):this.logger.debug("No fonts to load")},f=async function(){this.rootElement.setAttribute("data-theme",this.theme);const e=await this.descopeUi;(null==e?void 0:e.componentsThemeManager)&&(e.componentsThemeManager.currentThemeName=this.theme)},p})),Kr=e=>c((t=>{const n=vr(e),o=Object.assign(Object.assign({},n.actions),e.asyncActions);return class extends(r(yr)(t)){constructor(...e){super(...e);const t=ir({reducer:n.reducer,middleware:e=>e({thunk:{extraArgument:this},serializableCheck:!1}),devTools:!1}),i=e=>async(...n)=>{const o=await t.dispatch(e(...n));try{hr(o)}catch(e){this.logger.error(e.message,o.type,e.stack)}return o},r=Object.keys(o).reduce(((e,t)=>(e[t]=i(o[t]),e)),{});this.actions=r,this.subscribe=(e,n=e=>e)=>t.subscribe((()=>e(n(t.getState()))))}}}));c((e=>class extends(yr(e)){validateForm(e){return this.getFormInputs(e).every((e=>{var t,n;return null===(t=e.reportValidity)||void 0===t||t.call(e),null===(n=e.checkValidity)||void 0===n?void 0:n.call(e)}))}getFormInputs(e){return e?Array.from(e.querySelectorAll("[name]")):(this.logger.debug("cannot get form inputs, no root element was received"),[])}getFormData(e){return this.getFormInputs(e).reduce(((e,t)=>Object.assign(e,{[t.getAttribute("name")]:t.value})),{})}setFormData(e,t){this.getFormInputs(e).forEach((e=>{t.hasOwnProperty(e.getAttribute("name"))&&(e.value=t[e.getAttribute("name")])}))}resetFormData(e){this.getFormInputs(e).forEach((e=>{e.value="",e.checked=!1}))}getFormFieldNames(e){return this.getFormInputs(e).map((e=>e.name))}disableFormField(e,t){var n;null===(n=this.getFormInputs(e).find((e=>e.name===t)))||void 0===n||n.setAttribute("disabled","true")}removeFormField(e,t){var n;null===(n=this.getFormInputs(e).find((e=>e.name===t)))||void 0===n||n.remove()}}));const Gr=c((e=>class extends e{get baseStaticUrl(){return this.getAttribute("base-static-url")||""}})),Jr=(e,t,n,o={})=>{var i,r,s,a;return[Math.min(Math.max(t,("all"===o.left?e.offsetWidth:null!==(i=o.left)&&void 0!==i?i:0)-e.offsetWidth),window.innerWidth-("all"===o.right?e.offsetWidth:null!==(r=o.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===o.top?e.offsetHeight:null!==(s=o.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===o.bottom?e.offsetHeight:null!==(a=o.bottom)&&void 0!==a?a:0))]};var Xr,Yr,Zr,Qr,es,ts,ns,os,is,rs;const ss=document.createElement("template");ss.innerHTML=`\n<style>\n .debugger {\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n</style>\n\n<div style="top:32px; left:${window.innerWidth-300-32}px;" class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n`;class as extends HTMLElement{constructor(){var e;super(),Xr.add(this),Yr.set(this,new p({messages:[]})),Zr.set(this,void 0),Qr.set(this,void 0),es.set(this,void 0),ts.set(this,{resize:o(this,Xr,"m",rs).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(ss.content.cloneNode(!0)),i(this,Zr,this.shadowRoot.querySelector(".debugger"),"f"),i(this,Qr,o(this,Zr,"f").querySelector(".content"),"f"),i(this,es,o(this,Zr,"f").querySelector(".header"),"f")}updateData(e){o(this,Yr,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let o=0,i=0,r=0,s=0;function a(t){t.preventDefault(),o=r-t.clientX,i=s-t.clientY,r=t.clientX,s=t.clientY;const[a,c]=Jr(e,e.offsetLeft-o,e.offsetTop-i,n);e.style.top=`${c}px`,e.style.left=`${a}px`}function c(){document.onmouseup=null,document.onmousemove=null}function l(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=c,document.onmousemove=a}t?t.onmousedown=l:e.onmousedown=l})(o(this,Zr,"f"),o(this,es,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,ts,"f").resize),(e=o(this,Zr,"f")).onmousemove=t=>{var n;const o=t.target;(o.w&&o.w!==o.offsetWidth||o.h&&o.h!==o.offsetHeight)&&(null===(n=e.onresize)||void 0===n||n.call(e,t)),o.w=o.offsetWidth,o.h=o.offsetHeight},o(this,Zr,"f").onresize=o(this,Xr,"m",is).bind(this),o(this,Yr,"f").subscribe(o(this,Xr,"m",ns).bind(this))}disconnectedCallback(){o(this,Yr,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,ts,"f").resize)}}Yr=new WeakMap,Zr=new WeakMap,Qr=new WeakMap,es=new WeakMap,ts=new WeakMap,Xr=new WeakSet,ns=function(e){o(this,Xr,"m",os).call(this,e),o(this,Xr,"m",is).call(this)},os=function(e){o(this,Qr,"f").innerHTML=e.messages.map((e=>`\n <div class="msg">\n <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.99984 13.167L8.99984 10.167L11.9998 13.167L13.1665 12.0003L10.1665 9.00033L13.1665 6.00033L11.9998 4.83366L8.99984 7.83366L5.99984 4.83366L4.83317 6.00033L7.83317 9.00033L4.83317 12.0003L5.99984 13.167ZM8.99984 17.3337C7.84706 17.3337 6.76373 17.1148 5.74984 16.677C4.73595 16.2398 3.854 15.6462 3.104 14.8962C2.354 14.1462 1.76039 13.2642 1.32317 12.2503C0.885393 11.2364 0.666504 10.1531 0.666504 9.00033C0.666504 7.84755 0.885393 6.76421 1.32317 5.75033C1.76039 4.73644 2.354 3.85449 3.104 3.10449C3.854 2.35449 4.73595 1.7606 5.74984 1.32283C6.76373 0.885603 7.84706 0.666992 8.99984 0.666992C10.1526 0.666992 11.2359 0.885603 12.2498 1.32283C13.2637 1.7606 14.1457 2.35449 14.8957 3.10449C15.6457 3.85449 16.2393 4.73644 16.6765 5.75033C17.1143 6.76421 17.3332 7.84755 17.3332 9.00033C17.3332 10.1531 17.1143 11.2364 16.6765 12.2503C16.2393 13.2642 15.6457 14.1462 14.8957 14.8962C14.1457 15.6462 13.2637 16.2398 12.2498 16.677C11.2359 17.1148 10.1526 17.3337 8.99984 17.3337ZM8.99984 15.667C10.8609 15.667 12.4373 15.0212 13.729 13.7295C15.0207 12.4378 15.6665 10.8614 15.6665 9.00033C15.6665 7.13921 15.0207 5.56283 13.729 4.27116C12.4373 2.97949 10.8609 2.33366 8.99984 2.33366C7.13873 2.33366 5.56234 2.97949 4.27067 4.27116C2.979 5.56283 2.33317 7.13921 2.33317 9.00033C2.33317 10.8614 2.979 12.4378 4.27067 13.7295C5.56234 15.0212 7.13873 15.667 8.99984 15.667Z" fill="#ED404A"/>\n</svg>\n\n <div class="msg_content">\n <div class="msg_title">\n ${e.title}\n </div>\n <div class="msg_desc">\n ${e.description||""}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},is=function(){o(this,Qr,"f").querySelectorAll(".msg").forEach((e=>{const t=e,n=t.querySelector(".msg_desc"),o=n.scrollWidth>n.clientWidth,i=n.clientHeight>20;o||i?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},rs=function(){const[e,t]=Jr(o(this,Zr,"f"),Number.parseInt(o(this,Zr,"f").style.left,10),Number.parseInt(o(this,Zr,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,Zr,"f").style.top=`${t}px`,o(this,Zr,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",as);var cs=Object.freeze({__proto__:null});const ls="undefined"!=typeof localStorage,ds="J151000",us=ls&&localStorage.getItem("base.content.url")||"",hs="config.json",fs="base.ui.components.url";ls&&localStorage.getItem(fs),ls&&localStorage.getItem(fs);const ps="descope-login-flow",gs="code",vs="ra-challenge",ms="ra-callback",bs="ra-backup-callback",ws="ra-initiator",ys="data-exclude-field",ks="dls_last_auth",Is="state_id",Ss="saml_idp_state_id",js="saml_idp_username",xs="descope_idp_initiated",Cs="sso_app_id",As="oidc_login_hint",Es="oidc_prompt",Os="oidc_error_redirect_uri",Us="data-type",_s="poll",Rs="webauthnCreate",Ts="submit",Ms="polling",Ls=["descope-multi-select-combo-box","descope-text-area"];var Ps;function Ws(e){return new URLSearchParams(window.location.search).get(e)}function $s(e){if(window.history.replaceState&&Ws(e)){const t=new URL(window.location.href),n=new URLSearchParams(t.search);n.delete(e),t.search=n.toString(),window.history.replaceState({},"",t.toString())}}function Ds(e,t){return n(this,void 0,void 0,(function*(){const n=yield fetch(e,{cache:"default"});if(!n.ok)throw Error(`Error fetching URL ${e} [${n.status}]`);return{body:yield n[t||"text"](),headers:Object.fromEntries(n.headers.entries())}}))}function Ns({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:o}){const i=new URL(us||o||"https://static.descope.com/pages");return i.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(i.pathname,e,n,t),i.toString()}function Fs(e,t){if(!t)return;const n=+e,o=+t;return Number.isNaN(n)||Number.isNaN(o)?void 0:n>o?Ps.forward:n<o?Ps.backward:void 0}!function(e){e.backward="backward",e.forward="forward"}(Ps||(Ps={}));const qs=()=>{const[e="",t=""]=(Ws(ps)||"").split("_");return{executionId:e,stepId:t}};function zs(){$s(ps)}const Bs=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),Vs=e=>{let t,n;return(...o)=>{return t&&(r=o,(i=t).length===r.length&&i.every(((e,t)=>e===r[t])))||(t=o,n=e(...o)),n;var i,r}},Hs=(e,{oidcIdpStateId:t,samlIdpStateId:n,samlIdpUsername:o,ssoAppId:i,oidcLoginHint:r,oidcPrompt:s,oidcErrorRedirectUri:a})=>!(!e||t||n||o||i||r||s||a),Ks=e=>null==e?void 0:e.submit(),Gs=(e,t)=>{const n=t.find((t=>e[t]));return n?e[n]:null},Js=(e,t=100)=>{let n;return function(...o){n||e.apply(this,o),clearTimeout(n),n=setTimeout((()=>{n=null}),t)}};function Xs(e){let t=navigator.language;return t&&"zh-TW"!==t&&(t=t.split("-")[0]),(e||t||"").toLowerCase()}var Ys,Zs,Qs,ea;function ta(e,t){const n=Object.getOwnPropertyNames(e),o=Object.getOwnPropertyNames(t);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const i=n[o],r=e[i],s=t[i];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!ta(r,s))return!1}else if(r!==s)return!1}return!0}class na{constructor(e={},{updateOnlyOnChange:t=!0}={}){Ys.set(this,void 0),Zs.set(this,{}),Qs.set(this,0),ea.set(this,!1),this.update=e=>{const t="function"==typeof e?e(o(this,Ys,"f")):e,n=Object.assign(Object.assign({},o(this,Ys,"f")),t);if(!o(this,ea,"f")||!ta(o(this,Ys,"f"),n)){const e=o(this,Ys,"f");i(this,Ys,n,"f"),Object.freeze(o(this,Ys,"f")),setTimeout((()=>{Object.values(o(this,Zs,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},i(this,Ys,e,"f"),i(this,ea,t,"f")}get current(){return Object.assign({},o(this,Ys,"f"))}subscribe(e){return i(this,Qs,o(this,Qs,"f")+1,"f"),o(this,Zs,"f")[o(this,Qs,"f")]=e,o(this,Qs,"f").toString()}unsubscribe(e){const t=!!o(this,Zs,"f")[e];return t&&delete o(this,Zs,"f")[e],t}unsubscribeAll(){return i(this,Zs,{},"f"),!0}}Ys=new WeakMap,Zs=new WeakMap,Qs=new WeakMap,ea=new WeakMap;const oa=["disabled"],ia=(e,t)=>{Object.entries(t||{}).forEach((([t,n])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${ys}])`)).forEach((e=>{e.value=n}))}))},ra=(e,t)=>e.replace(/{{(.+?)}}/g,((e,n)=>{return o=t,n.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),o);var o})),sa=(e,t,n)=>{e.querySelectorAll(`[${Us}="${t}"]`).forEach((e=>{e.setAttribute("href",n)}))},aa=(e,t,n)=>{var o,i;const r=null===(o=customElements.get(t))||void 0===o?void 0:o.cssVarList.url;n&&r&&(null===(i=null==e?void 0:e.style)||void 0===i||i.setProperty(r,`url(data:image/jpg;base64,${n})`))},ca=Vs((()=>n(void 0,void 0,void 0,(function*(){var e,t,n,o;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const i=Promise.all([null===(e=window.PublicKeyCredential)||void 0===e?void 0:e.isConditionalMediationAvailable(),null===(t=window.PublicKeyCredential)||void 0===t?void 0:t.isUserVerifyingPlatformAuthenticatorAvailable()]).then((e=>e.every((e=>!!e)))),r=(()=>{var e;const t=null===(e=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===e?void 0:e.brands,n=null==t?void 0:t.find((({brand:e,version:t})=>"Chromium"===e&&parseFloat(t)));return n?n.version:0})()>=108;return yield(n=i,o=r,new Promise(((e,t)=>{let i=!1;const r=setTimeout((()=>{i=!0,void 0!==o?e(o):t(new Error("Promise timed out after 100 ms"))}),100);n.then((t=>{i||(clearTimeout(r),e(t))})).catch((e=>{i||(clearTimeout(r),t(e))}))})))}catch(e){return console.error("Conditional login check failed",e),!1}})))),la={"lastAuth.loginId":{"not-empty":e=>!!e.loginId,empty:e=>!e.loginId},idpInitiated:{"is-true":e=>!!e.code,"is-false":e=>!e.code},externalToken:{"is-true":e=>!!e.token,"is-false":e=>!e.token},abTestingKey:{"greater-than":(e,t)=>(e.abTestingKey||0)>t,"less-than":(e,t)=>(e.abTestingKey||0)<t}};function da(e){const t={};if(e)try{Object.assign(t,JSON.parse(localStorage.getItem(ks)))}catch(e){}return t}const ua="dls_ab_testing_id",ha=c((e=>{var t,n,i,r;return r=class extends e{constructor(){super(...arguments),t.add(this)}connectedCallback(){var e;o(this,t,"m",n).call(this)&&o(this,t,"m",i).call(this),null===(e=super.connectedCallback)||void 0===e||e.call(this)}},t=new WeakSet,n=function(){return!this.shadowRoot.host.closest("form")&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)},i=function(){const e=this.shadowRoot.host,t=document.createElement("form");t.style.width="100%",t.style.height="100%",e.parentElement.appendChild(t),t.appendChild(e)},r})),fa=document.createElement("template");fa.innerHTML="\n\t<style>\n\t\t:host {\n all: initial;\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n\t\t\ttransition: opacity 300ms ease-in-out;\n display: flex;\n\t\t}\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1;\n\t\t}\n\n\t</style>\n\t";const pa=(e,t="")=>Object.keys(e).reduce(((n,o)=>{var i;if("object"==typeof e[o]&&null!==e[o]&&!(null===(i=e[o])||void 0===i?void 0:i.value))return Object.assign(Object.assign({},n),pa(e[o],`${t+o}.`));const r="object"==typeof e[o]?e[o]:{value:e[o]},s=Object.assign(Object.assign({},n),{[t+o]:r,[`form.${t}${o}`]:r});return"displayName"===o?Object.assign(Object.assign({},s),{[`${t}fullName`]:r,[`form.${t}fullName`]:r}):s}),[]);var ga,va,ma,ba,wa,ya,ka,Ia,Sa,ja,xa,Ca,Aa,Ea,Oa,Ua,_a,Ra,Ta,Ma,La,Pa;const Wa=r(Hr,ha)(HTMLElement);class $a extends Wa{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","keep-last-authenticated-user-after-logout","validate-on-blur","style-id"]}constructor(e){super(),ga.add(this),ma.set(this,!1),this.loggerWrapper={error:(e,t="")=>{this.logger.error(e,t,new Error),o(this,ga,"m",La).call(this,e,t)},warn:(e,t="")=>{this.logger.warn(e,t)},info:(e,t="",n={})=>{this.logger.info(e,t,n)},debug:(e,t="")=>{this.logger.debug(e,t)}},ba.set(this,new na),wa.set(this,new na),ya.set(this,{}),this.getComponentsContext=()=>o(this,ya,"f"),this.nextRequestStatus=new na({isLoading:!1}),ka.set(this,void 0),Ia.set(this,{popstate:o(this,ga,"m",Ca).bind(this),componentsContext:o(this,ga,"m",Ra).bind(this)}),Sa.set(this,void 0),_a.set(this,Vs((()=>n(this,void 0,void 0,(function*(){const e=Ns({projectId:this.projectId,filename:hs,baseUrl:this.baseStaticUrl});try{const{body:t,headers:n}=yield Ds(e,"json");return{projectConfig:t,executionContext:{geo:n["x-geo"]}}}catch(e){return{isMissingConfig:!0}}}))))),i(this,Sa,e,"f"),o(this,ga,"m",ja).call(this)}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(e){return{}}}get tenant(){return this.getAttribute("tenant")||void 0}get redirectUrl(){return this.getAttribute("redirect-url")||void 0}get debug(){return"true"===this.getAttribute("debug")}get locale(){return this.getAttribute("locale")||void 0}get autoFocus(){var e;const t=null!==(e=this.getAttribute("auto-focus"))&&void 0!==e?e:"true";return"skipFirstScreen"===t?t:"true"===t}get validateOnBlur(){return"true"===this.getAttribute("validate-on-blur")}get storeLastAuthenticatedUser(){var e;return"true"===(null!==(e=this.getAttribute("store-last-authenticated-user"))&&void 0!==e?e:"true")}get keepLastAuthenticatedUserAfterLogout(){return"true"===this.getAttribute("keep-last-authenticated-user-after-logout")}get storagePrefix(){return this.getAttribute("storage-prefix")||""}get preview(){return!!this.getAttribute("preview")}get formConfig(){return(e=>{try{return pa(JSON.parse(e))}catch(e){return{}}})(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return e=this.formConfig,Object.fromEntries(Object.entries(e).map((([e,t])=>[e,t.value])));var e}getExecutionContext(){return n(this,void 0,void 0,(function*(){const{executionContext:e}=yield o(this,_a,"f").call(this);return e}))}getProjectConfig(){return n(this,void 0,void 0,(function*(){const{projectConfig:e}=yield o(this,_a,"f").call(this);return e}))}getFlowConfig(){return n(this,void 0,void 0,(function*(){var e,t;const n=yield this.getProjectConfig(),o=(null===(e=null==n?void 0:n.flows)||void 0===e?void 0:e[this.flowId])||{};return null!==(t=o.version)&&void 0!==t||(o.version=0),o}))}getTargetLocales(){return n(this,void 0,void 0,(function*(){const e=yield this.getFlowConfig();return((null==e?void 0:e.targetLocales)||[]).map((e=>e.toLowerCase()))}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;if(yield null===(t=e.init)||void 0===t?void 0:t.call(this),o(this,wa,"f").subscribe(o(this,ga,"m",Ma).bind(this)),o(this,wa,"f").update({isDebug:this.debug}),o(this,ga,"m",xa).call(this),yield o(this,ga,"m",Oa).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");if((yield o(this,_a,"f").call(this)).isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");o(this,ga,"m",Pa).call(this);const{executionId:n,stepId:r,token:s,code:a,exchangeError:c,redirectAuthCallbackUrl:l,redirectAuthBackupCallbackUri:d,redirectAuthCodeChallenge:u,redirectAuthInitiator:h,ssoQueryParams:f}=(()=>{const{executionId:e,stepId:t}=qs();(e||t)&&zs();const n=Ws("t")||void 0;n&&$s("t");const o=Ws(gs)||void 0;o&&$s(gs);const i=Ws("err")||void 0;i&&$s("err");const{redirectAuthCodeChallenge:r,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:c}={redirectAuthCodeChallenge:Ws(vs),redirectAuthCallbackUrl:Ws(ms),redirectAuthBackupCallbackUri:Ws(bs),redirectAuthInitiator:Ws(ws)};(r||s||a||c)&&($s(vs),$s(ms),$s(bs),$s(ws));const l=Ws(Is);l&&$s(Is);const d=Ws(Ss);d&&$s(Ss);const u=Ws(js);d&&$s(js);const h=Ws(xs);h&&$s(xs);const f=Ws(Cs);f&&$s(Cs);const p=Ws(As);p&&$s(As);const g=Ws(Es);g&&$s(Es);const v=Ws(Os);return v&&$s(Os),{executionId:e,stepId:t,token:n,code:o,exchangeError:i,redirectAuthCodeChallenge:r,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:c,ssoQueryParams:{oidcIdpStateId:l,samlIdpStateId:d,samlIdpUsername:u,descopeIdpInitiated:"true"===h,ssoAppId:f,oidcLoginHint:p,oidcPrompt:g,oidcErrorRedirectUri:v}}})();window.addEventListener("popstate",o(this,Ia,"f").popstate),window.addEventListener("components-context",o(this,Ia,"f").componentsContext),o(this,ba,"f").subscribe(o(this,ga,"m",Ea).bind(this)),o(this,ba,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenant,redirectUrl:this.redirectUrl,locale:this.locale,stepId:r,executionId:n,token:s,code:a,exchangeError:c,redirectAuthCallbackUrl:l,redirectAuthBackupCallbackUri:d,redirectAuthCodeChallenge:u,redirectAuthInitiator:h},f)),i(this,ma,!0,"f")}))}disconnectedCallback(){o(this,ba,"f").unsubscribeAll(),o(this,wa,"f").unsubscribeAll(),o(this,ga,"m",Ta).call(this),window.removeEventListener("popstate",o(this,Ia,"f").popstate),window.removeEventListener("components-context",o(this,Ia,"f").componentsContext)}attributeChangedCallback(e,t,n){if(this.shadowRoot.isConnected&&o(this,ma,"f")&&t!==n&&va.observedAttributes.includes(e)){o(this,ga,"m",xa).call(this);const i=null===t;o(this,ba,"f").update((({stepId:t,executionId:o})=>{let r=t,s=o;return i||(s=null,r=null,zs()),{[Bs(e)]:n,stepId:r,executionId:s}})),o(this,wa,"f").update({isDebug:this.debug})}}}function Da(e,t){return`sdkScriptsResults.${t?`${e}_${t}`:e}`}var Na,Fa,qa,za,Ba,Va,Ha,Ka,Ga,Ja,Xa,Ya,Za,Qa,ec,tc,nc,oc,ic,rc;va=$a,ma=new WeakMap,ba=new WeakMap,wa=new WeakMap,ya=new WeakMap,ka=new WeakMap,Ia=new WeakMap,Sa=new WeakMap,_a=new WeakMap,ga=new WeakSet,ja=function(){this.shadowRoot.appendChild(fa.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#root")},xa=function(){const e=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","style-id"];va.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[Bs(t)])throw Error(`${t} cannot be empty`)}))},Ca=function(){const{stepId:e,executionId:t}=qs();o(this,ba,"f").update({stepId:e,executionId:t})},Aa=function(e,t){this.sdk=ao(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout},va.sdkConfigOverrides),{projectId:e,baseUrl:t})),["start","next"].forEach((e=>{const t=this.sdk.flow[e];this.sdk.flow[e]=(...e)=>n(this,void 0,void 0,(function*(){this.nextRequestStatus.update({isLoading:!0});try{return yield t(...e)}catch(e){return{error:{errorCode:ds,errorDescription:e.toString()}}}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},Ea=function(e,t,i){return n(this,void 0,void 0,(function*(){const{projectId:t,baseUrl:n}=e;if(i("projectId")||i("baseUrl")){if(!t)return;o(this,ga,"m",Aa).call(this,t,n)}o(this,Sa,"f").call(this,e)}))},Oa=function(){return n(this,void 0,void 0,(function*(){return(yield o(this,_a,"f").call(this)).isMissingConfig&&(yield o(this,ga,"m",Ua).call(this))}))},Ua=function(){return n(this,void 0,void 0,(function*(){const e=Ns({projectId:this.projectId,filename:hs,assetsFolder:"v2-alpha",baseUrl:this.baseStaticUrl});try{return yield Ds(e,"json"),!0}catch(e){return!1}}))},Ra=function(e){i(this,ya,Object.assign(Object.assign({},o(this,ya,"f")),e.detail),"f")},Ta=function(){var e;null===(e=o(this,ka,"f"))||void 0===e||e.remove(),i(this,ka,null,"f")},Ma=function(e){return n(this,arguments,void 0,(function*({isDebug:e}){e?(i(this,ka,document.createElement("descope-debugger"),"f"),Object.assign(o(this,ka,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return nl})),document.body.appendChild(o(this,ka,"f"))):o(this,ga,"m",Ta).call(this)}))},La=function(e,t){var n;e&&this.debug&&(null===(n=o(this,ka,"f"))||void 0===n||n.updateData({title:e,description:t}))},Pa=function(){this.rootElement.onkeydown=e=>{var t,n,o;const i=!!(null===(t=this.shadowRoot.activeElement)||void 0===t?void 0:t.getAttribute("href")),r=Ls.includes(null!==(o=null===(n=this.shadowRoot.activeElement)||void 0===n?void 0:n.localName)&&void 0!==o?o:"");if("Enter"!==e.key||i||r)return;e.preventDefault();const s=this.rootElement.querySelectorAll("descope-button");if(1===s.length&&"false"!==s[0].getAttribute("auto-submit"))return void s[0].click();const a=Array.from(s).filter((e=>"true"===e.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const c=Array.from(s).filter((e=>"button"===e.getAttribute("data-type")));if(1===c.length)"false"!==c[0].getAttribute("auto-submit")&&c[0].click();else if(0===c.length){const e=Array.from(s).filter((e=>"sso"===e.getAttribute("data-type")));1===e.length&&"false"!==e[0].getAttribute("auto-submit")&&e[0].click()}}},$a.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.23.0"}};class sc extends $a{static set sdkConfigOverrides(e){$a.sdkConfigOverrides=e}constructor(){const e=new na({deferredRedirect:!1});super(e.update.bind(e)),Na.add(this),this.stepState=new na({},{updateOnlyOnChange:!1}),Fa.set(this,void 0),qa.set(this,null),za.set(this,{visibilitychange:o(this,Na,"m",Ba).bind(this)}),Va.set(this,((e,t,r,s,a)=>{r===_s&&(this.logger.debug("polling - Scheduling polling request"),i(this,Fa,setTimeout((()=>n(this,void 0,void 0,(function*(){var n,i;this.logger.debug("polling - Calling next");const c=yield this.sdk.flow.next(e,t,Ms,s,a,{});if((null===(n=null==c?void 0:c.error)||void 0===n?void 0:n.errorCode)===ds)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void o(this,Va,"f").call(this,e,t,r,s,a);this.logger.debug("polling - Got a response"),(null==c?void 0:c.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(c.error,null,4)),o(this,Ka,"f").call(this,c);const{action:l}=null!==(i=null==c?void 0:c.data)&&void 0!==i?i:{};o(this,Va,"f").call(this,e,t,l,s,a)}))),2e3),"f"))})),Ha.set(this,(()=>{clearTimeout(o(this,Fa,"f")),i(this,Fa,null,"f")})),Ka.set(this,(e=>{var t,n,i,r,s,a,c,l,d,u,h;if(!(null==e?void 0:e.ok)){const a=null===(t=null==e?void 0:e.response)||void 0===t?void 0:t.url,c=`${null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.status} - ${null===(i=null==e?void 0:e.response)||void 0===i?void 0:i.statusText}`;return o(this,Na,"m",rc).call(this,"error",(null==e?void 0:e.error)||{errorCode:"J151001",errorDescription:c,errorMessage:a}),void this.loggerWrapper.error((null===(r=null==e?void 0:e.error)||void 0===r?void 0:r.errorDescription)||a,(null===(s=null==e?void 0:e.error)||void 0===s?void 0:s.errorMessage)||c)}null===(c=null===(a=e.data)||void 0===a?void 0:a.runnerLogs)||void 0===c||c.forEach((e=>{const{level:t,title:n,log:o}=e;t&&this.loggerWrapper[t]?this.loggerWrapper[t](n,o):this.loggerWrapper.info(n,o)}));const f=null===(u=null===(d=null===(l=e.data)||void 0===l?void 0:l.screen)||void 0===d?void 0:d.state)||void 0===u?void 0:u.errorText;(null===(h=e.data)||void 0===h?void 0:h.error)?this.loggerWrapper.error(`[${e.data.error.code}]: ${e.data.error.description}`,`${f?`${f} - `:""}${e.data.error.message}`):f&&this.loggerWrapper.error(f);const{status:p,authInfo:g,lastAuth:v}=e.data;if("completed"===p)return this.storeLastAuthenticatedUser&&function(e){(null==e?void 0:e.authMethod)&&ls&&localStorage.setItem(ks,JSON.stringify(e))}(v),void o(this,Na,"m",rc).call(this,"success",g);const{executionId:m,stepId:b,stepName:w,action:y,screen:k,redirect:I,openInNewTabUrl:S,webauthn:j,error:x,samlIdpResponse:C}=e.data;y!==_s?(this.loggerWrapper.info(`Step "${w||`#${b}`}" is ${p}`,"",{screen:k,status:p,stepId:b,stepName:w,action:y,error:x}),this.flowState.update({stepId:b,executionId:m,action:y,redirectTo:null==I?void 0:I.url,openInNewTabUrl:S,screenId:null==k?void 0:k.id,screenState:null==k?void 0:k.state,webauthnTransactionId:null==j?void 0:j.transactionId,webauthnOptions:null==j?void 0:j.options,samlIdpResponseUrl:null==C?void 0:C.url,samlIdpResponseSamlResponse:null==C?void 0:C.samlResponse,samlIdpResponseRelayState:null==C?void 0:C.relayState})):this.flowState.update({action:y})})),Ga.set(this,Vs((()=>n(this,void 0,void 0,(function*(){var e;try{const t=yield this.sdk.webauthn.signIn.start("",window.location.origin);return t.ok||this.loggerWrapper.warn("Webauthn start failed",null===(e=null==t?void 0:t.error)||void 0===e?void 0:e.errorMessage),t.data}catch(e){this.loggerWrapper.warn("Webauthn start failed",e.message)}}))))),tc.set(this,Js(((e,t)=>n(this,void 0,void 0,(function*(){if("true"===e.getAttribute("formnovalidate")||o(this,Na,"m",Ya).call(this)){const i=null==e?void 0:e.getAttribute("id");o(this,Na,"m",Qa).call(this,e);const r=yield o(this,Na,"m",Za).call(this),s=(n=e,Array.from((null==n?void 0:n.attributes)||[]).reduce(((e,t)=>{var n;const o=null===(n=new RegExp("^data-descope-(\\S+)$").exec(t.name))||void 0===n?void 0:n[1];return o?Object.assign(e,{[o]:t.value}):e}),{})),a=this.getComponentsContext(),c=Object.assign(Object.assign(Object.assign(Object.assign({},a),s),r),{origin:window.location.origin}),l=yield this.getFlowConfig(),d=yield this.getProjectConfig(),u=yield t(i,l.version,d.componentsVersion,c);o(this,Ka,"f").call(this,u),o(this,Na,"m",ec).call(this,r)}var n}))))),this.flowState=e}loadSdkScripts(){return n(this,void 0,void 0,(function*(){const e=(yield this.getFlowConfig()).sdkScripts;null==e||e.forEach((e=>n(this,void 0,void 0,(function*(){(yield function(e){return n(this,void 0,void 0,(function*(){let t;switch(e){case"forter":return t=yield Promise.resolve().then((function(){return ol})),t.default;case"fingerprint":return t=yield Promise.resolve().then((function(){return rl})),t.default;case"fingerprintDescope":return t=yield Promise.resolve().then((function(){return al})),t.default;default:throw new Error(`Unknown script id: ${e}`)}}))}(e.id))(e.initArgs,{baseUrl:this.baseUrl},(t=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[Da(e.id,e.resultKey)]:t},bubbles:!0,composed:!0}))}))}))))}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t,n,i;this.shadowRoot.isConnected&&(null===(t=this.flowState)||void 0===t||t.subscribe(this.onFlowChange.bind(this)),null===(n=this.stepState)||void 0===n||n.subscribe(this.onStepChange.bind(this)),window.addEventListener("visibilitychange",o(this,za,"f").visibilitychange)),yield null===(i=e.init)||void 0===i?void 0:i.call(this)}))}disconnectedCallback(){var e;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),null===(e=o(this,qa,"f"))||void 0===e||e.abort(),i(this,qa,null,"f"),window.removeEventListener("visibilitychange",o(this,za,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return n(this,void 0,void 0,(function*(){let n;const o=Xs(e);return(yield this.getTargetLocales()).includes(o)&&(n=`${t}-${o}.html`),n}))}getPageContent(e,t){return n(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield Ds(t,"text");return e}catch(n){this.loggerWrapper.error(`Failed to fetch flow page from ${t}. Fallback to url ${e}`,n)}try{const{body:t}=yield Ds(e,"text");return t}catch(e){this.loggerWrapper.error("Failed to fetch flow page",e.message)}return null}))}onFlowChange(e,r,s){return n(this,void 0,void 0,(function*(){var n,a;const{projectId:c,flowId:l,tenant:d,stepId:u,executionId:h,action:f,screenId:p,screenState:g,redirectTo:v,openInNewTabUrl:m,redirectUrl:b,token:w,code:y,exchangeError:k,webauthnTransactionId:I,webauthnOptions:S,redirectAuthCodeChallenge:j,redirectAuthCallbackUrl:x,redirectAuthBackupCallbackUri:C,redirectAuthInitiator:A,locale:E,samlIdpResponseUrl:O,samlIdpResponseSamlResponse:U,samlIdpResponseRelayState:_}=e,R=t(e,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","openInNewTabUrl","redirectUrl","token","code","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"]);let T,M;const L=(()=>{const e=localStorage.getItem(ua);if(!e){const e=Math.floor(100*Math.random()+1);return localStorage.setItem(ua,e.toString()),e}return Number(e)})(),P=this.sdk.getLastUserLoginId(),W=yield this.getFlowConfig(),$=yield this.getProjectConfig(),D=x&&j?{callbackUrl:x,codeChallenge:j,backupCallbackUri:C}:void 0;if(!h&&(this.loadSdkScripts(),W.fingerprintEnabled&&W.fingerprintKey?yield Nn(W.fingerprintKey,this.baseUrl):localStorage.removeItem($n),W.conditions?({startScreenId:T,conditionInteractionId:M}=((e,t)=>{const n=null==t?void 0:t.find((({key:t,operator:n,predicate:o})=>{var i;if("ELSE"===t)return!0;const r=null===(i=la[t])||void 0===i?void 0:i[n];return!!(null==r?void 0:r(e,o))}));return n?{startScreenId:n.met.screenId,conditionInteractionId:n.met.interactionId}:{}})({loginId:P,code:y,token:w,abTestingKey:L},W.conditions)):W.condition?({startScreenId:T,conditionInteractionId:M}=((e,t)=>{var n;const o=null===(n=la[null==e?void 0:e.key])||void 0===n?void 0:n[e.operator];if(!o)return{};const i=o(t,e.predicate)?e.met:e.unmet;return{startScreenId:null==i?void 0:i.screenId,conditionInteractionId:null==i?void 0:i.interactionId}})(W.condition,{loginId:P,code:y,token:w,abTestingKey:L})):T=W.startScreenId,!Hs(T,R))){const e=yield this.sdk.flow.start(l,Object.assign(Object.assign(Object.assign(Object.assign({tenant:d,redirectAuth:D},R),{client:this.client}),b&&{redirectUrl:b}),{lastAuth:da(P),abTestingKey:L,locale:Xs(E)}),M,"",W.version,$.componentsVersion,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),y?{exchangeCode:y,idpInitiated:!0}:{}),R.descopeIdpInitiated&&{idpInitiated:!0}),w?{token:w}:{}),R.oidcLoginHint?{externalId:R.oidcLoginHint}:{}));return o(this,Ka,"f").call(this,e),void("completed"!==(null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.status)&&this.flowState.update({code:void 0,token:void 0}))}if(h&&(s("token")&&w||s("code")&&y||s("exchangeError")&&k)){const e=yield this.sdk.flow.next(h,u,Ts,W.version,$.componentsVersion,{token:w,exchangeCode:y,exchangeError:k});return o(this,Ka,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if("loadForm"===f&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>s(e)))){if(!O||!U)return void this.loggerWrapper.error("Did not get saml idp params data to load");((e,t,n,o)=>{const i=document.createElement("form");i.method="POST",i.action=e,i.innerHTML=`\n <input type="hidden" role="saml-response" name="SAMLResponse" value="${t}" />\n <input type="hidden" role="saml-relay-state" name="RelayState" value="${n}" />\n <input style="display: none;" id="SAMLSubmitButton" type="submit" value="Continue" />\n `,document.body.appendChild(i),o(i)})(O,U,_||"",Ks)}if("redirect"===f&&(s("redirectTo")||s("deferredRedirect")))return v?"android"===A&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(v):void this.loggerWrapper.error("Did not get redirect url");if(f===Rs||"webauthnGet"===f){if(!I||!S)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,t;null===(a=o(this,qa,"f"))||void 0===a||a.abort(),i(this,qa,null,"f");try{e=f===Rs?yield this.sdk.webauthn.helpers.create(S):yield this.sdk.webauthn.helpers.get(S)}catch(n){"InvalidStateError"===n.name?this.loggerWrapper.warn("WebAuthn operation failed",n.message):"NotAllowedError"!==n.name&&this.loggerWrapper.error(n.message),t=n.name}const r=yield this.sdk.flow.next(h,u,Ts,W.version,$.componentsVersion,{transactionId:I,response:e,failure:t});o(this,Ka,"f").call(this,r)}if(o(this,Va,"f").call(this,h,u,f,W.version,$.componentsVersion),!p&&!T)return void this.loggerWrapper.warn("No screen was found to show");const N=T||p,F=yield this.getHtmlFilenameWithLocale(E,N),{oidcLoginHint:q,oidcPrompt:z,oidcErrorRedirectUri:B,samlIdpUsername:V}=R,H={direction:Fs(u,r.stepId),screenState:Object.assign(Object.assign({},g),{form:Object.assign(Object.assign({},this.formConfigValues),null==g?void 0:g.form),lastAuth:{loginId:P,name:this.sdk.getLastUserDisplayName()||P}}),htmlUrl:Ns({projectId:c,filename:`${N}.html`,baseUrl:this.baseStaticUrl}),htmlLocaleUrl:F&&Ns({projectId:c,filename:F,baseUrl:this.baseStaticUrl}),samlIdpUsername:V,oidcLoginHint:q,oidcPrompt:z,oidcErrorRedirectUri:B,openInNewTabUrl:m},K=da(P);Hs(T,R)?H.next=(e,t,n,o)=>this.sdk.flow.start(l,Object.assign(Object.assign(Object.assign(Object.assign({tenant:d,redirectAuth:D},R),{lastAuth:K,preview:this.preview,abTestingKey:L,client:this.client}),b&&{redirectUrl:b}),{locale:Xs(E)}),M,e,t,n,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),o),y&&{exchangeCode:y,idpInitiated:!0}),R.descopeIdpInitiated&&{idpInitiated:!0}),w&&{token:w})):(s("projectId")||s("baseUrl")||s("executionId")||s("stepId"))&&(H.next=(...e)=>this.sdk.flow.next(h,u,...e)),this.stepState.update(H)}))}onStepChange(e,t){return n(this,void 0,void 0,(function*(){var i,r;const{htmlUrl:s,htmlLocaleUrl:a,direction:c,next:l,screenState:d,openInNewTabUrl:u}=e,h=document.createElement("template");h.innerHTML=yield this.getPageContent(s,a);const f=h.content.cloneNode(!0),p=this.loadDescopeUiComponents(h);this.sdk.webauthn.helpers.isSupported()?yield o(this,Na,"m",Xa).call(this,f,l):f.querySelectorAll(`descope-button[${Us}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true"))),!e.samlIdpUsername||(null===(i=d.form)||void 0===i?void 0:i.loginId)||(null===(r=d.form)||void 0===r?void 0:r.email)||(d.form||(d.form={}),d.form.loginId=e.samlIdpUsername,d.form.email=e.samlIdpUsername),((e,t,n,o,i,r)=>{var s,a;let c=null==t?void 0:t.errorText;try{c=(null==i?void 0:i({text:null==t?void 0:t.errorText,type:null==t?void 0:t.errorType}))||(null==t?void 0:t.errorText)}catch(e){r.error("Error transforming error message",e.message)}((e,t,n="")=>{e.querySelectorAll(`[${Us}="${t}"]`).forEach((e=>{e.textContent=n,e.classList[n?"remove":"add"]("hide")}))})(e,"error-message",c),sa(e,"totp-link",null===(s=null==t?void 0:t.totp)||void 0===s?void 0:s.provisionUrl),sa(e,"notp-link",null===(a=null==t?void 0:t.notp)||void 0===a?void 0:a.redirectUrl),((e,t)=>{e.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((e=>{e.textContent=ra(e.textContent,t);const n=e.getAttribute("href");n&&e.setAttribute("href",ra(n,t))}))})(e,t),((e,t,n)=>{t&&Object.keys(t).forEach((o=>{e.querySelectorAll(`[name=${o}]`).forEach((e=>{const i=t[o];Object.keys(i).forEach((t=>{let o=i[t];if("string"!=typeof o)try{o=JSON.stringify(o)}catch(e){n.error(`Could not stringify value "${o}" for "${t}"`,e.message),o=""}e.setAttribute(t,o)}))}))}))})(e,n,r),((e,t)=>{e.querySelectorAll("[data-has-dynamic-attr-values]").forEach((e=>{Array.from(e.attributes).forEach((e=>{e.value=ra(e.value,t)}))}))})(e,t),((e,t)=>{Object.entries(t).forEach((([t,n])=>{e.querySelectorAll(`[name="${t}"]`).forEach((e=>{Object.entries(n).forEach((([t,n])=>{oa.includes(t)&&e.setAttribute(t,n)}))}))}))})(e,o)})(f,d,d.componentsConfig,this.formConfig,this.errorTransformer,this.loggerWrapper);const{geo:g}=yield this.getExecutionContext();((e,t)=>{Array.from(e.querySelectorAll('descope-phone-field[default-code="autoDetect"]')).forEach((e=>{e.setAttribute("default-code",t)}))})(f,g);const v=()=>n(this,void 0,void 0,(function*(){var e,n;yield p;const i=this.shadowRoot.querySelector("div");var r,s;r=i,s=null===(e=null==d?void 0:d.totp)||void 0===e?void 0:e.image,aa(r,"descope-totp-image",s),((e,t)=>{aa(e,"descope-notp-image",t)})(i,null===(n=null==d?void 0:d.notp)||void 0===n?void 0:n.image),this.rootElement.replaceChildren(f),setTimeout((()=>{((e,t)=>{ia(e,null==t?void 0:t.inputs),ia(e,null==t?void 0:t.form)})(this.rootElement,d)}));const a=!t.htmlUrl;if(((e,t,n)=>{if(!0===t||"skipFirstScreen"===t&&!n){const t=e.querySelector("*[name]");setTimeout((()=>{null==t||t.focus()}))}})(this.rootElement,this.autoFocus,a),this.validateOnBlur&&(()=>{this.rootElement.querySelectorAll("*[name]").forEach((e=>{e.addEventListener("blur",(()=>{var t;const n=e.focus;e.focus=()=>{},null===(t=e.reportValidity)||void 0===t||t.call(e),setTimeout((()=>{e.focus=n}))}))}))})(),o(this,Na,"m",oc).call(this,l),a&&o(this,Na,"m",rc).call(this,"ready",{}),o(this,Na,"m",rc).call(this,"page-updated",{}),this.rootElement.querySelector(`[${Us}="polling"]`)){const e=yield this.getFlowConfig(),t=yield this.getProjectConfig(),n=yield l(Ms,e.version,t.componentsVersion,{});o(this,Ka,"f").call(this,n)}u&&!t.openInNewTabUrl&&window.open(u,"_blank")}));c?o(this,Na,"m",ic).call(this,v,c):v()}))}}Fa=new WeakMap,qa=new WeakMap,za=new WeakMap,Va=new WeakMap,Ha=new WeakMap,Ka=new WeakMap,Ga=new WeakMap,tc=new WeakMap,Na=new WeakSet,Ba=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},Ja=function(e){const t=e.getAttribute("name");if(!["email"].includes(t)){const n=`user-${t}`;e.setAttribute("name",n),e.addEventListener("input",(()=>{e.setAttribute("name",e.value?t:n)}))}},Xa=function(e,t){return n(this,void 0,void 0,(function*(){var r;null===(r=o(this,qa,"f"))||void 0===r||r.abort();const s=e.querySelector('*[autocomplete="webauthn"]');if(s&&(yield ca())){const{options:e,transactionId:r}=(yield o(this,Ga,"f").call(this))||{};if(e&&r){o(this,Na,"m",Ja).call(this,s),i(this,qa,new AbortController,"f");const a=yield this.getFlowConfig(),c=yield this.getProjectConfig();this.sdk.webauthn.helpers.conditional(e,o(this,qa,"f")).then((e=>n(this,void 0,void 0,(function*(){const n=yield t(s.id,a.version,c.componentsVersion,{transactionId:r,response:e});o(this,Ka,"f").call(this,n)})))).catch((e=>{"AbortError"!==e.name&&this.loggerWrapper.error("Conditional login failed",e.message)}))}}}))},Ya=function(){let e=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((t=>{var n,o;"slot"!==t.localName&&(null===(n=t.reportValidity)||void 0===n||n.call(t),e&&(e=null===(o=t.checkValidity)||void 0===o?void 0:o.call(t)))})),e},Za=function(){return n(this,void 0,void 0,(function*(){const e=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${ys}])`));return(yield Promise.all(e.map((e=>n(this,void 0,void 0,(function*(){return{name:e.getAttribute("name"),value:e.value}})))))).reduce(((e,t)=>Object.assign(Object.assign({},e),{[t.name]:t.value})),{})}))},Qa=function(e){const t=this.nextRequestStatus.subscribe((({isLoading:n})=>{n?e.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(t),e.removeAttribute("loading"))}))},ec=function(e={}){var t,n;const o=Gs(e,["externalId","email","phone"]),i=Gs(e,["newPassword","password"]);if(o&&i)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:o,password:i});null===(n=null===(t=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===t?void 0:t.store)||void 0===n||n.call(t,e)}catch(e){this.loggerWrapper.error("Could not store credentials",e.message)}},nc=function(e){this.rootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((t=>{t.addEventListener("input",(()=>{var n;(null===(n=t.checkValidity)||void 0===n?void 0:n.call(t))&&o(this,tc,"f").call(this,t,e)}))}))},oc=function(e){this.rootElement.querySelectorAll("descope-button:not([data-exclude-next])").forEach((t=>{t.onclick=()=>{o(this,tc,"f").call(this,t,e)}})),o(this,Na,"m",nc).call(this,e)},ic=function(e,t){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),e()}),{once:!0});const n=t===Ps.forward?"slide-forward":"slide-backward";Array.from(this.rootElement.getElementsByClassName("input-container")).forEach(((e,t)=>{e.style["transition-delay"]=40*t+"ms",e.classList.add(n)})),this.rootElement.classList.add("fade-out")},rc=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},customElements.get("descope-wc")?console.log("descope-wc is already defined"):customElements.define("descope-wc",sc);const ac=e=>e.me.data,cc=Ti(ac,(e=>e.picture)),lc=Ti(ac,(e=>e.email)),dc=Ti(ac,(e=>e.verifiedEmail)),uc=Ti(ac,(e=>e.name)),hc=Ti(ac,(e=>e.phone)),fc=Ti(ac,(e=>e.verifiedPhone)),pc=Ti(ac,(e=>e.webauthn));Ti(ac,(e=>e.password));const gc=e=>(...t)=>n=>{n.addCase(e.pending,((e,n)=>{t.forEach((({onPending:t})=>{null==t||t(e,n)}))})),n.addCase(e.fulfilled,((e,n)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,n)}))})),n.addCase(e.rejected,((e,n)=>{t.forEach((({onRejected:t})=>{null==t||t(e,n)}))}))},vc=ur("users/me",((e,{extra:{api:t}})=>t.user.me())),mc=gc(vc)({onFulfilled:(e,t)=>{e.me.data=t.payload}},(bc=e=>e.me,{onFulfilled:e=>{bc(e).loading=!1},onPending:e=>{bc(e).loading=!0,bc(e).error=null},onRejected:(e,t)=>{bc(e).loading=!1,bc(e).error=t.error}}));var bc;const wc={action:vc,reducer:mc},yc=ur("users/logout",((e,{extra:{api:t}})=>t.user.logout())),kc={action:yc,reducer:gc(yc)({})},Ic={me:{loading:!1,error:null,data:{}}},Sc={me:"/v1/auth/me"},jc=()=>n(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({loginIds:["user@company.com"],externalIds:["user@company.com"],userId:"user-1",name:"Test User",email:"user@company.com",roleNames:["Role"],phone:"+1-202-555-010",verifiedEmail:!0,verifiedPhone:!0,userTenants:[],status:"enabled",editable:!0,createdTime:(new Date).getTime(),customAttributes:{},familyName:"",givenName:"",middleName:"",picture:void 0,password:!0,SAML:!1,test:!1,TOTP:!1,webauthn:!0})}))})),xc=({httpClient:e,mock:t})=>({me:()=>n(void 0,void 0,void 0,(function*(){if(t)return jc();const o=yield e.get(Sc.me);return yield(e=>n(void 0,void 0,void 0,(function*(){const t=yield e.text(),n=JSON.parse(t);if(!e.ok){const t=`${n.errorDescription}${n.errorMessage?`: ${n.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(n),e.text=()=>Promise.resolve(t)})))(o),o.json()}))}),Cc=c((e=>{var t,s,a,c;const l=r(Ar,xr,yr,Er)(e);return c=class extends l{constructor(){super(...arguments),t.add(this),s.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get api(){return o(this,s,"f")||o(this,t,"m",a).call(this),o(this,s,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),this.observeAttributes(["project-id","base-url"],(()=>{o(this,s,"f")&&o(this,t,"m",a).call(this)}))}))}},s=new WeakMap,t=new WeakSet,a=function(){this.logger.debug("creating an sdk instance"),i(this,s,((e,t,o)=>{const i=ao(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":o,"x-descope-widget-version":"0.0.98"}}));return{user:Object.assign(Object.assign({},xc({httpClient:i.httpClient,mock:t})),{logout:t?()=>n(void 0,void 0,void 0,(function*(){})):i.logout})}})({projectId:this.projectId,baseUrl:this.baseUrl},"true"===this.mock,this.widgetId),"f")},c})),Ac=c((e=>{const t=r(Kr({name:"widget",initialState:Ic,reducers:{},extraReducers:e=>{wc.reducer(e),kc.reducer(e)},asyncActions:{getMe:wc.action,logout:kc.action}}),jr,yr,Cc)(e);return class extends t{constructor(...e){super(...e),this.state=Ic,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),Ec=c((e=>{const t=r(Or,Cr({"widget-id":Cr.missingAttrValidator}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(e){return n(this,void 0,void 0,(function*(){return(yield this.fetchStaticResource(`user-profile-widget/${this.widgetId}/${e}`,"text")).body}))}}})),Oc=c((e=>{var t,i,a;return a=class extends(r(yr,jr,$r,Fr,Ec,Ac)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return n(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),yield Promise.all([this.actions.getMe(),o(this,t,"m",i).call(this)]),this.onWidgetRootReady()}))}},t=new WeakSet,i=function(){return n(this,void 0,void 0,(function*(){const e=s(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},a})),Uc=(e={})=>{const t=s("<descope-wc></descope-wc>");return Object.entries(e).forEach((([e,n])=>{t.content.querySelector("descope-wc").setAttribute((e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_.]+/g,"-").toLowerCase())(e),n)})),t};function _c(e){return new URLSearchParams(window.location.search).get(e)}const Rc=c((e=>{var t,s,c,l,d,u,h,f,p;return p=class extends(r(Ac,yr,Oc,zr,Gr)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),c.set(this,void 0),h.set(this,a((e=>{this.avatar.image=e}))),f.set(this,a((e=>{this.avatar.displayName=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",u).call(this),o(this,t,"m",l).call(this),o(this,h,"f").call(this,cc(this.state)),o(this,f,"f").call(this,uc(this.state)),this.subscribe(o(this,h,"f").bind(this),cc),this.subscribe(o(this,f,"f").bind(this),uc)}))}},s=new WeakMap,c=new WeakMap,h=new WeakMap,f=new WeakMap,t=new WeakSet,l=function(){i(this,s,this.createModal({"data-id":"update-pic"}),"f"),i(this,c,new bo((()=>{var e;return null===(e=o(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),o(this,s,"f").afterClose=o(this,t,"m",d).bind(this),o(this,t,"m",d).call(this)},d=function(){o(this,s,"f").setContent(Uc({projectId:this.projectId,flowId:this.avatar.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),o(this,c,"f").onSuccess((()=>{o(this,s,"f").close(),this.actions.getMe()}))},u=function(){this.avatar=new go((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-avatar")}),{logger:this.logger}),this.avatar.onClick((()=>{o(this,s,"f").open()}))},p})),Tc=c((e=>{var t,s,c,l,d,u,h,f,p,g,v,m,b;return b=class extends(r(Ac,yr,Oc,zr)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),c.set(this,void 0),l.set(this,void 0),d.set(this,void 0),v.set(this,a((e=>{this.emailUserAttr.value=e}))),m.set(this,a((e=>{this.emailUserAttr.badgeLabel=e?"":"Unverified"})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",g).call(this),o(this,t,"m",u).call(this),o(this,t,"m",f).call(this),o(this,v,"f").call(this,lc(this.state)),o(this,m,"f").call(this,dc(this.state)),this.subscribe(o(this,v,"f").bind(this),lc),this.subscribe(o(this,m,"f").bind(this),dc)}))}},s=new WeakMap,c=new WeakMap,l=new WeakMap,d=new WeakMap,v=new WeakMap,m=new WeakMap,t=new WeakSet,u=function(){i(this,s,this.createModal({"data-id":"edit-email"}),"f"),i(this,c,new bo((()=>{var e;return null===(e=o(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),o(this,s,"f").afterClose=o(this,t,"m",h).bind(this),o(this,t,"m",h).call(this)},h=function(){o(this,s,"f").setContent(Uc({projectId:this.projectId,flowId:this.emailUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),o(this,c,"f").onSuccess((()=>{o(this,s,"f").close(),this.actions.getMe()}))},f=function(){i(this,l,this.createModal({"data-id":"delete-email"}),"f"),i(this,d,new bo((()=>{var e;return null===(e=o(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),o(this,l,"f").afterClose=o(this,t,"m",p).bind(this),o(this,t,"m",p).call(this)},p=function(){o(this,l,"f").setContent(Uc({projectId:this.projectId,flowId:this.emailUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),o(this,d,"f").onSuccess((()=>{o(this,l,"f").close(),this.actions.getMe()}))},g=function(){this.emailUserAttr=new vo((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="email"]')}),{logger:this.logger}),this.emailUserAttr.onEditClick((()=>{o(this,s,"f").open()})),this.emailUserAttr.onDeleteClick((()=>{o(this,l,"f").open()}))},b})),Mc=c((e=>{var t,s,c,l,d,u,h,f,p,g,v,m;return m=class extends(r(Ac,yr,Oc,zr)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),c.set(this,void 0),l.set(this,void 0),d.set(this,void 0),v.set(this,a((e=>{this.nameUserAttr.value=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",g).call(this),o(this,t,"m",u).call(this),o(this,t,"m",f).call(this),o(this,v,"f").call(this,uc(this.state)),this.subscribe(o(this,v,"f").bind(this),uc)}))}},s=new WeakMap,c=new WeakMap,l=new WeakMap,d=new WeakMap,v=new WeakMap,t=new WeakSet,u=function(){i(this,s,this.createModal({"data-id":"edit-name"}),"f"),i(this,c,new bo((()=>{var e;return null===(e=o(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),o(this,s,"f").afterClose=o(this,t,"m",h).bind(this),o(this,t,"m",h).call(this)},h=function(){o(this,s,"f").setContent(Uc({projectId:this.projectId,flowId:this.nameUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),o(this,c,"f").onSuccess((()=>{o(this,s,"f").close(),this.actions.getMe()}))},f=function(){i(this,l,this.createModal({"data-id":"delete-name"}),"f"),i(this,d,new bo((()=>{var e;return null===(e=o(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),o(this,l,"f").afterClose=o(this,t,"m",p).bind(this),o(this,t,"m",p).call(this)},p=function(){o(this,l,"f").setContent(Uc({projectId:this.projectId,flowId:this.nameUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),o(this,d,"f").onSuccess((()=>{o(this,l,"f").close(),this.actions.getMe()}))},g=function(){this.nameUserAttr=new vo((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="name"]')}),{logger:this.logger}),this.nameUserAttr.onEditClick((()=>{o(this,s,"f").open()})),this.nameUserAttr.onDeleteClick((()=>{o(this,l,"f").open()}))},m})),Lc=c((e=>{var t,s,c,l,d,u,h,f,p,g,v,m,b;return b=class extends(r(Ac,yr,Oc,zr)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),c.set(this,void 0),l.set(this,void 0),d.set(this,void 0),v.set(this,a((e=>{this.phoneUserAttr.value=e}))),m.set(this,a((e=>{this.phoneUserAttr.badgeLabel=e?"":"Unverified"})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",g).call(this),o(this,t,"m",u).call(this),o(this,t,"m",f).call(this),o(this,v,"f").call(this,hc(this.state)),o(this,m,"f").call(this,fc(this.state)),this.subscribe(o(this,v,"f").bind(this),hc),this.subscribe(o(this,m,"f").bind(this),fc)}))}},s=new WeakMap,c=new WeakMap,l=new WeakMap,d=new WeakMap,v=new WeakMap,m=new WeakMap,t=new WeakSet,u=function(){i(this,s,this.createModal({"data-id":"edit-phone"}),"f"),i(this,c,new bo((()=>{var e;return null===(e=o(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),o(this,s,"f").afterClose=o(this,t,"m",h).bind(this),o(this,t,"m",h).call(this)},h=function(){o(this,s,"f").setContent(Uc({projectId:this.projectId,flowId:this.phoneUserAttr.editFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),o(this,c,"f").onSuccess((()=>{o(this,s,"f").close(),this.actions.getMe()}))},f=function(){i(this,l,this.createModal({"data-id":"delete-phone"}),"f"),i(this,d,new bo((()=>{var e;return null===(e=o(this,l,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),o(this,l,"f").afterClose=o(this,t,"m",p).bind(this),o(this,t,"m",p).call(this)},p=function(){o(this,l,"f").setContent(Uc({projectId:this.projectId,flowId:this.phoneUserAttr.deleteFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),o(this,d,"f").onSuccess((()=>{o(this,l,"f").close(),this.actions.getMe()}))},g=function(){this.phoneUserAttr=new vo((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="phone"]')}),{logger:this.logger}),this.phoneUserAttr.onEditClick((()=>{o(this,s,"f").open()})),this.phoneUserAttr.onDeleteClick((()=>{o(this,l,"f").open()}))},b})),Pc=c((e=>{var t,s,c,l,d,u,h,f;return f=class extends(r(Ac,yr,Oc,zr)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),c.set(this,void 0),h.set(this,a((e=>{this.passkeyUserAuthMethod.fulfilled=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",u).call(this),o(this,t,"m",l).call(this),o(this,h,"f").call(this,pc(this.state)),this.subscribe(o(this,h,"f").bind(this),pc)}))}},s=new WeakMap,c=new WeakMap,h=new WeakMap,t=new WeakSet,l=function(){i(this,s,this.createModal({"data-id":"passkey"}),"f"),i(this,c,new bo((()=>{var e;return null===(e=o(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),o(this,s,"f").afterClose=o(this,t,"m",d).bind(this),o(this,t,"m",d).call(this)},d=function(){o(this,s,"f").setContent(Uc({projectId:this.projectId,flowId:this.passkeyUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),o(this,c,"f").onSuccess((()=>{o(this,s,"f").close(),this.actions.getMe()}))},u=function(){this.passkeyUserAuthMethod=new mo((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="passkey"]')}),{logger:this.logger}),this.passkeyUserAuthMethod.onButtonClick((()=>{o(this,s,"f").open()}))},f})),Wc=c((e=>{var t,s,a,c,l,d,u;return u=class extends(r(Ac,yr,Oc,zr)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),a.set(this,void 0)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",d).call(this),o(this,t,"m",c).call(this)}))}},s=new WeakMap,a=new WeakMap,t=new WeakSet,c=function(){i(this,s,this.createModal({"data-id":"password"}),"f"),i(this,a,new bo((()=>{var e;return null===(e=o(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),o(this,s,"f").afterClose=o(this,t,"m",l).bind(this),o(this,t,"m",l).call(this)},l=function(){o(this,s,"f").setContent(Uc({projectId:this.projectId,flowId:this.passwordUserAuthMethod.flowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl})),o(this,a,"f").onSuccess((()=>{o(this,s,"f").close()}))},d=function(){this.passwordUserAuthMethod=new mo((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="password"]')}),{logger:this.logger}),this.passwordUserAuthMethod.onButtonClick((()=>{o(this,s,"f").open()}))},u})),$c=c((e=>{var t,i,s;return s=class extends(r(Ac,yr,Oc,zr)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),o(this,t,"m",i).call(this)}))}},t=new WeakSet,i=function(){this.logout=new uo((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-button[data-id="logout"]')}),{logger:this.logger}),this.logout.onClick((()=>n(this,void 0,void 0,(function*(){yield this.actions.logout(),this.dispatchEvent(new CustomEvent("logout"))}))))},s})),Dc="widget-flow",Nc=c((e=>{var t,i,s;return s=class extends(r(jr,zr,Ac,yr)(e)){constructor(){super(...arguments),t.add(this)}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this);const r=_c(Dc);r&&(!function(e){if(window.history.replaceState&&_c(e)){const t=new URL(window.location.href),n=new URLSearchParams(t.search);n.delete(e),t.search=n.toString(),window.history.replaceState({},"",t.toString())}}(Dc),o(this,t,"m",i).call(this,r))}))}},t=new WeakSet,i=function(e){const t=this.createModal({"data-id":"redirect-flow"});t.setContent(Uc({projectId:this.projectId,flowId:e,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl}));new bo((()=>{var e;return null===(e=t.ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>{t.close(),this.actions.getMe()})),t.afterClose=()=>{t.remove()},t.open()},s})),Fc=c((e=>class extends(r(_r,Hr,Nc,Tc,Rc,Mc,Lc,Pc,Wc,$c)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),qc=r((e=>class extends(Fc(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),sc.sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.0.98"}}}))}}))(HTMLElement);customElements.define("descope-user-profile-widget",qc);const zc=(e,t,n,o={})=>{var i,r,s,a;return[Math.min(Math.max(t,("all"===o.left?e.offsetWidth:null!==(i=o.left)&&void 0!==i?i:0)-e.offsetWidth),window.innerWidth-("all"===o.right?e.offsetWidth:null!==(r=o.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===o.top?e.offsetHeight:null!==(s=o.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===o.bottom?e.offsetHeight:null!==(a=o.bottom)&&void 0!==a?a:0))]};var Bc,Vc,Hc,Kc,Gc,Jc,Xc,Yc,Zc,Qc;const el=document.createElement("template");el.innerHTML=`\n<style>\n .debugger {\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n</style>\n\n<div style="top:32px; left:${window.innerWidth-300-32}px;" class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n`;class tl extends HTMLElement{constructor(){super(),Bc.add(this),Vc.set(this,new na({messages:[]})),Hc.set(this,void 0),Kc.set(this,void 0),Gc.set(this,void 0),Jc.set(this,{resize:o(this,Bc,"m",Qc).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(el.content.cloneNode(!0)),i(this,Hc,this.shadowRoot.querySelector(".debugger"),"f"),i(this,Kc,o(this,Hc,"f").querySelector(".content"),"f"),i(this,Gc,o(this,Hc,"f").querySelector(".header"),"f")}updateData(e){o(this,Vc,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let o=0,i=0,r=0,s=0;function a(t){t.preventDefault(),o=r-t.clientX,i=s-t.clientY,r=t.clientX,s=t.clientY;const[a,c]=zc(e,e.offsetLeft-o,e.offsetTop-i,n);e.style.top=`${c}px`,e.style.left=`${a}px`}function c(){document.onmouseup=null,document.onmousemove=null}function l(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=c,document.onmousemove=a}t?t.onmousedown=l:e.onmousedown=l})(o(this,Hc,"f"),o(this,Gc,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,Jc,"f").resize),(e=o(this,Hc,"f")).onmousemove=t=>{(t.target.w&&t.target.w!==t.target.offsetWidth||t.target.h&&t.target.h!==t.target.offsetHeight)&&e.onresize(t),t.target.w=t.target.offsetWidth,t.target.h=t.target.offsetHeight},o(this,Hc,"f").onresize=o(this,Bc,"m",Zc).bind(this),o(this,Vc,"f").subscribe(o(this,Bc,"m",Xc).bind(this))}disconnectedCallback(){o(this,Vc,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,Jc,"f").resize)}}Vc=new WeakMap,Hc=new WeakMap,Kc=new WeakMap,Gc=new WeakMap,Jc=new WeakMap,Bc=new WeakSet,Xc=function(e){o(this,Bc,"m",Yc).call(this,e),o(this,Bc,"m",Zc).call(this)},Yc=function(e){o(this,Kc,"f").innerHTML=e.messages.map((e=>`\n <div class="msg">\n <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.99984 13.167L8.99984 10.167L11.9998 13.167L13.1665 12.0003L10.1665 9.00033L13.1665 6.00033L11.9998 4.83366L8.99984 7.83366L5.99984 4.83366L4.83317 6.00033L7.83317 9.00033L4.83317 12.0003L5.99984 13.167ZM8.99984 17.3337C7.84706 17.3337 6.76373 17.1148 5.74984 16.677C4.73595 16.2398 3.854 15.6462 3.104 14.8962C2.354 14.1462 1.76039 13.2642 1.32317 12.2503C0.885393 11.2364 0.666504 10.1531 0.666504 9.00033C0.666504 7.84755 0.885393 6.76421 1.32317 5.75033C1.76039 4.73644 2.354 3.85449 3.104 3.10449C3.854 2.35449 4.73595 1.7606 5.74984 1.32283C6.76373 0.885603 7.84706 0.666992 8.99984 0.666992C10.1526 0.666992 11.2359 0.885603 12.2498 1.32283C13.2637 1.7606 14.1457 2.35449 14.8957 3.10449C15.6457 3.85449 16.2393 4.73644 16.6765 5.75033C17.1143 6.76421 17.3332 7.84755 17.3332 9.00033C17.3332 10.1531 17.1143 11.2364 16.6765 12.2503C16.2393 13.2642 15.6457 14.1462 14.8957 14.8962C14.1457 15.6462 13.2637 16.2398 12.2498 16.677C11.2359 17.1148 10.1526 17.3337 8.99984 17.3337ZM8.99984 15.667C10.8609 15.667 12.4373 15.0212 13.729 13.7295C15.0207 12.4378 15.6665 10.8614 15.6665 9.00033C15.6665 7.13921 15.0207 5.56283 13.729 4.27116C12.4373 2.97949 10.8609 2.33366 8.99984 2.33366C7.13873 2.33366 5.56234 2.97949 4.27067 4.27116C2.979 5.56283 2.33317 7.13921 2.33317 9.00033C2.33317 10.8614 2.979 12.4378 4.27067 13.7295C5.56234 15.0212 7.13873 15.667 8.99984 15.667Z" fill="#ED404A"/>\n</svg>\n\n <div class="msg_content">\n <div class="msg_title">\n ${e.title}\n </div>\n <div class="msg_desc">\n ${e.description}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},Zc=function(){o(this,Kc,"f").querySelectorAll(".msg").forEach((e=>{const t=e.querySelector(".msg_desc"),n=t.scrollWidth>t.clientWidth,o=t.clientHeight>20;n||o?(e.classList.add("collapsible"),e.onclick=t=>{t.target.classList.contains("msg_desc")||e.classList.toggle("collapsed")}):(e.classList.remove("collapsible"),e.onclick=null)}))},Qc=function(){const[e,t]=zc(o(this,Hc,"f"),Number.parseInt(o(this,Hc,"f").style.left,10),Number.parseInt(o(this,Hc,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,Hc,"f").style.top=`${t}px`,o(this,Hc,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",tl);var nl=Object.freeze({__proto__:null,default:tl});var ol=Object.freeze({__proto__:null,default:(e,t,o)=>n(void 0,void 0,void 0,(function*(){const{siteId:t}=e,n='\n(function () {\nvar merchantConfig = {\n csp: false\n};\n\nvar siteId = "{{SITE_ID}}";\nfunction t(t,n){for(var e=t.split(""),r=0;r<e.length;++r)e[r]=String.fromCharCode(e[r].charCodeAt(0)+n);return e.join("")}function n(n){return t(n,-L).replace(/%SN%/g,siteId)}function e(){var t="no"+"op"+"fn",n="g"+"a",e="n"+"ame";return window[n]&&window[n][e]===t}function r(){return!(!navigator.brave||"function"!=typeof navigator.brave.isBrave)}function o(){return document.currentScript&&document.currentScript.src}function i(t){try{if("number"==typeof t&&window.location&&window.location.pathname){for(var n=window.location.pathname.split("/"),e=[],r=0;r<=Math.min(n.length-1,Math.abs(t));r++)e.push(n[r]);return e.join("/")||"/"}}catch(t){}return"/"}function c(t){try{G.ex=t,e()&&-1===G.ex.indexOf(B.uB)&&(G.ex+=B.uB),r()&&-1===G.ex.indexOf(B.uBr)&&(G.ex+=B.uBr),o()&&-1===G.ex.indexOf(B.nIL)&&(G.ex+=B.nIL),window.ftr__snp_cwc||(G.ex+=B.s),M(G)}catch(t){}}function a(t,n){function e(o){try{o.blockedURI===t&&(n(),document.removeEventListener(r,e))}catch(t){document.removeEventListener(r,e)}}var r="securitypolicyviolation";document.addEventListener(r,e),setTimeout(function(){document.removeEventListener(r,e)},2*60*1e3)}function u(t,n,e,r){var o=!1;t="https://"+t,a(t,function(){r(!0),o=!0});var i=document.createElement("script");i.onerror=function(){if(!o)try{r(!1),o=!0}catch(t){}},i.onload=e,i.type="text/javascript",i.id="ftr__script",i.async=!0,i.src=t;var c=document.getElementsByTagName("script")[0];c.parentNode.insertBefore(i,c)}function f(){J(B.uDF),setTimeout(h,I,B.uDF)}function d(t,n,e,r){var o=!1,i=new XMLHttpRequest;if(a("https:"+t,function(){e(new Error("CSP Violation"),!0),o=!0}),"//"===t.slice(0,2)&&(t="https:"+t),"withCredentials"in i)i.open("GET",t,!0);else{if("undefined"==typeof XDomainRequest)return;i=new XDomainRequest,i.open("GET",t)}Object.keys(r).forEach(function(t){i.setRequestHeader(t,r[t])}),i.onload=function(){"function"==typeof n&&n(i)},i.onerror=function(t){if("function"==typeof e&&!o)try{e(t,!1),o=!0}catch(t){}},i.onprogress=function(){},i.ontimeout=function(){"function"==typeof e&&e("tim"+"eo"+"ut",!1)},setTimeout(function(){i.send()},0)}function s(t,siteId,n){function e(t){var n=t.toString(16);return n.length%2?"0"+n:n}function r(t){if(t<=0)return"";for(var n="0123456789abcdef",e="",r=0;r<t;r++)e+=n[Math.floor(Math.random()*n.length)];return e}function o(t){for(var n="",r=0;r<t.length;r++)n+=e(t.charCodeAt(r));return n}function i(t){for(var n=t.split(""),e=0;e<n.length;++e)n[e]=String.fromCharCode(255^n[e].charCodeAt(0));return n.join("")}n=n?"1":"0";var c=[];return c.push(t),c.push(siteId),c.push(n),function(t){var n=40,e="";return t.length<n/2&&(e=","+r(n/2-t.length-1)),o(i(t+e))}(c.join(","))}function w(){function t(){D&&(J(B.dUAL),setTimeout(h,I,B.dUAL))}function n(t,n){c(n?B.uAS+B.uF+B.cP:B.uAS+B.uF)}window.ftr__fdad(t,n)}function h(t){try{var n;switch(t){case B.uFP:n=q;break;case B.uDF:n=E;break;default:n=D}if(!n)return;u(n,void 0,function(){try{K(),c(t+B.uS)}catch(t){}},function(n){try{K(),G.td=1*new Date-G.ts,c(n?t+B.uF+B.cP:t+B.uF),t===B.uFP&&f(),t===B.uDF&&w()}catch(t){c(B.eUoe)}})}catch(n){c(t+B.eTlu)}}var m="22ge:t7mj8unkn;1forxgiurqw1qhw2vwdwxv",v="fort",l="erTo",p="ken";window.ftr__config={m:merchantConfig,s:"23",si:siteId};var g=!1,_=v+l+p,y=400*24*60,T=10,k={write:function(t,n,e,r){void 0===r&&(r=!0);var o=0;window.ftr__config&&window.ftr__config.m&&window.ftr__config.m.ckDepth&&(o=window.ftr__config.m.ckDepth);var c,a,u=i(o);if(e?(c=new Date,c.setTime(c.getTime()+60*e*1e3),a="; expires="+c.toGMTString()):a="",!r)return void(document.cookie=escape(t)+"="+escape(n)+a+"; path="+u);for(var f=1,d=document.domain.split("."),s=T,w=!0;w&&d.length>=f&&s>0;){var h=d.slice(-f).join(".");document.cookie=escape(t)+"="+escape(n)+a+"; path="+u+"; domain="+h;var m=k.read(t);null!=m&&m==n||(h="."+h,document.cookie=escape(t)+"="+escape(n)+a+"; path="+u+"; domain="+h),w=-1===document.cookie.indexOf(t+"="+n),f++,s--}},read:function(t){var n=null;try{for(var e=escape(t)+"=",r=document.cookie.split(";"),o=32,i=0;i<r.length;i++){for(var c=r[i];c.charCodeAt(0)===o;)c=c.substring(1,c.length);0===c.indexOf(e)&&(n=unescape(c.substring(e.length,c.length)))}}finally{return n}}},S=window.ftr__config.s;S+="ck";var x=function(t){var n=!1,e=null,r=function(){try{if(!e||!n)return;e.remove&&"function"==typeof e.remove?e.remove():document.head.removeChild(e),n=!1}catch(t){}};document.head&&(!function(){e=document.createElement("link"),e.setAttribute("rel","pre"+"con"+"nect"),e.setAttribute("cros"+"sori"+"gin","anonymous"),e.onload=r,e.onerror=r,e.setAttribute("href",t),document.head.appendChild(e),n=!0}(),setTimeout(r,3e3))},L=3,A=n(m||"22ge:t7mj8unkn;1forxgiurqw1qhw2vwdwxv"),F=t("[0Uhtxhvw0LG",-L),U=t("[0Fruuhodwlrq0LG",-L),b=t("Li0Qrqh0Pdwfk",-L),D,C="fgq71iruwhu1frp",E=n("(VQ(1"+C+"2vq2(VQ(2vfulsw1mv"),V=n("(VQ(1"+C+"2vqV2(VQ(2vfulsw1mv"),q;window.ftr__config&&window.ftr__config.m&&window.ftr__config.m.fpi&&(q=window.ftr__config.m.fpi+n("2vq2(VQ(2vfulsw1mv"));var I=10;window.ftr__startScriptLoad=1*new Date;var R=function(t){var n="ft"+"r:tok"+"enR"+"eady";window.ftr__tt&&clearTimeout(window.ftr__tt),window.ftr__tt=setTimeout(function(){try{delete window.ftr__tt,t+="_tt";var e=document.createEvent("Event");e.initEvent(n,!1,!1),e.detail=t,document.dispatchEvent(e)}catch(t){}},1e3)},M=function(t){var n=function(t){return t||""},e=n(t.id)+"_"+n(t.ts)+"_"+n(t.td)+"_"+n(t.ex)+"_"+n(S),r=y;!isNaN(window.ftr__config.m.ckTTL)&&window.ftr__config.m.ckTTL&&(r=window.ftr__config.m.ckTTL),k.write(_,e,r,!0),R(e),window.ftr__gt=e},P=function(){var t=k.read(_)||"",n=t.split("_"),e=function(t){return n[t]||void 0};return{id:e(0),ts:e(1),td:e(2),ex:e(3),vr:e(4)}},j=function(){for(var t={},n="fgu",e=[],r=0;r<256;r++)e[r]=(r<16?"0":"")+r.toString(16);var o=function(t,n,r,o,i){var c=i?"-":"";return e[255&t]+e[t>>8&255]+e[t>>16&255]+e[t>>24&255]+c+e[255&n]+e[n>>8&255]+c+e[n>>16&15|64]+e[n>>24&255]+c+e[63&r|128]+e[r>>8&255]+c+e[r>>16&255]+e[r>>24&255]+e[255&o]+e[o>>8&255]+e[o>>16&255]+e[o>>24&255]},i=function(){if(window.Uint32Array&&window.crypto&&window.crypto.getRandomValues){var t=new window.Uint32Array(4);return window.crypto.getRandomValues(t),{d0:t[0],d1:t[1],d2:t[2],d3:t[3]}}return{d0:4294967296*Math.random()>>>0,d1:4294967296*Math.random()>>>0,d2:4294967296*Math.random()>>>0,d3:4294967296*Math.random()>>>0}},c=function(){var t="",n=function(t,n){for(var e="",r=t;r>0;--r)e+=n.charAt(1e3*Math.random()%n.length);return e};return t+=n(2,"0123456789"),t+=n(1,"123456789"),t+=n(8,"0123456789")};return t.safeGenerateNoDash=function(){try{var t=i();return o(t.d0,t.d1,t.d2,t.d3,!1)}catch(t){try{return n+c()}catch(t){}}},t.isValidNumericalToken=function(t){return t&&t.toString().length<=11&&t.length>=9&&parseInt(t,10).toString().length<=11&&parseInt(t,10).toString().length>=9},t.isValidUUIDToken=function(t){return t&&32===t.toString().length&&/^[a-z0-9]+$/.test(t)},t.isValidFGUToken=function(t){return 0==t.indexOf(n)&&t.length>=12},t}(),B={uDF:"UDF",dUAL:"dUAL",uAS:"UAS",uFP:"UFP",mLd:"1",eTlu:"2",eUoe:"3",uS:"4",uF:"9",tmos:["T5","T10","T15","T30","T60"],tmosSecs:[5,10,15,30,60],bIR:"43",uB:"u",uBr:"b",cP:"c",nIL:"i",s:"s"};try{var G=P();try{G.id&&(j.isValidNumericalToken(G.id)||j.isValidUUIDToken(G.id)||j.isValidFGUToken(G.id))?window.ftr__ncd=!1:(G.id=j.safeGenerateNoDash(),window.ftr__ncd=!0),G.ts=window.ftr__startScriptLoad,M(G),window.ftr__snp_cwc=!!k.read(_),window.ftr__snp_cwc||(E=V);for(var N="for"+"ter"+".co"+"m",O="ht"+"tps://c"+"dn9."+N,Q="ht"+"tps://"+G.id+"-"+siteId+".cd"+"n."+N,H="http"+"s://cd"+"n3."+N,X=[O,Q,H],z=0;z<X.length;z++)x(X[z]);var $=new Array(B.tmosSecs.length),J=function(t){for(var n=0;n<B.tmosSecs.length;n++)$[n]=setTimeout(c,1e3*B.tmosSecs[n],t+B.tmos[n])},K=function(){for(var t=0;t<B.tmosSecs.length;t++)clearTimeout($[t])};window.ftr__fdad=function(n,e){if(!g){g=!0;var r={};r[b]=s(window.ftr__config.s,siteId,window.ftr__config.m.csp),d(A,function(e){try{var r=e.getAllResponseHeaders().toLowerCase();if(r.indexOf(U.toLowerCase())>=0){var o=e.getResponseHeader(U);window.ftr__altd2=t(atob(o),-L-1)}if(r.indexOf(F.toLowerCase())<0)return;var i=e.getResponseHeader(F),c=t(atob(i),-L-1);if(c){var a=c.split(":");if(a&&2===a.length){for(var u=a[0],f=a[1],d="",s=0,w=0;s<20;++s)d+=s%3>0&&w<12?siteId.charAt(w++):G.id.charAt(s);var h=f.split(",");if(h.length>1){var m=h[0],v=h[1];D=u+"/"+m+"."+d+"."+v}}}n()}catch(t){}},function(t,n){e&&e(t,n)},r)}};var W=q?B.uFP:B.uDF;J(W),setTimeout(h,I,W)}catch(t){c(B.mLd)}}catch(t){}})();\n'.replace(/{{SITE_ID}}/g,t),i=document.createElement("script");i.setAttribute("type","text/javascript"),i.setAttribute("id",t),i.text=n,document.body.appendChild(i),document.addEventListener("ftr:tokenReady",(e=>{o(e.detail)}))}))});const il=(e,t,o)=>n(void 0,void 0,void 0,(function*(){try{const{publicApiKey:t,useCloudflareIntegration:n,cloudflareScriptUrl:i,cloudflareEndpointUrl:r}=e;let s=[];s=n&&r?[r,hn]:[hn];let a=[];if(n&&i){a=[`${new URL(i).toString()}?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`,wn]}else a=[wn];const c=yn({apiKey:t,endpoint:s,scriptUrlPattern:a}),l=yield c,{requestId:d}=yield l.get();o(d)}catch(e){console.warn("Could not load fingerprint",e)}}));var rl=Object.freeze({__proto__:null,default:il,loadFingerprint:il});const sl=(e,t,o)=>n(void 0,void 0,void 0,(function*(){try{const{customDomain:n,publicApiKey:i,cloudflareEndpointPath:r,cloudflareScriptPath:s}=e,{baseUrl:a}=t;let c;c=n?`https://${n}`:a||"https://api.descope.com";const l=new URL(c);l.pathname=r;const d=new URL(c);d.pathname=s;const u=`${d.toString()}?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`,h=yn({apiKey:i,endpoint:[l.toString(),hn],scriptUrlPattern:[u,wn]}),f=yield h,{requestId:p}=yield f.get();o(p)}catch(e){console.warn("Could not load descope fingerprint",e)}}));var al=Object.freeze({__proto__:null,default:sl,loadFingerprint:sl});return qc}();
|
|
8
8
|
//# sourceMappingURL=index.js.map
|