@descope/web-component 3.21.0 → 3.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/{debugger-wc-513433e1.js → debugger-wc-3a1a2c23.js} +1 -1
- package/dist/esm/fingerprint-84b451f2.js +1 -0
- package/dist/esm/fingerprintDescope-effc737b.js +1 -0
- package/dist/esm/index-307d94b0.js +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/index.js +2 -2
- package/package.json +2 -1
- package/dist/esm/index-f0d29122.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__classPrivateFieldGet as e,__classPrivateFieldSet as n}from"tslib";import{S as t}from"./index-
|
|
1
|
+
import{__classPrivateFieldGet as e,__classPrivateFieldSet as n}from"tslib";import{S as t}from"./index-307d94b0.js";import"@descope/web-js-sdk";const s=(e,n,t,s={})=>{var o,i,l,r;return[Math.min(Math.max(n,("all"===s.left?e.offsetWidth:null!==(o=s.left)&&void 0!==o?o:0)-e.offsetWidth),window.innerWidth-("all"===s.right?e.offsetWidth:null!==(i=s.right)&&void 0!==i?i:0)),Math.min(Math.max(t,("all"===s.top?e.offsetHeight:null!==(l=s.top)&&void 0!==l?l:0)-e.offsetHeight),window.innerHeight-("all"===s.bottom?e.offsetHeight:null!==(r=s.bottom)&&void 0!==r?r:0))]};var o,i,l,r,a,d,c,p,h,g;const f=document.createElement("template");f.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 m extends HTMLElement{constructor(){super(),o.add(this),i.set(this,new t({messages:[]})),l.set(this,void 0),r.set(this,void 0),a.set(this,void 0),d.set(this,{resize:e(this,o,"m",g).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(f.content.cloneNode(!0)),n(this,l,this.shadowRoot.querySelector(".debugger"),"f"),n(this,r,e(this,l,"f").querySelector(".content"),"f"),n(this,a,e(this,l,"f").querySelector(".header"),"f")}updateData(n){e(this,i,"f").update((e=>({messages:e.messages.concat(n)})))}connectedCallback(){var n;((e,n,t)=>{let o=0,i=0,l=0,r=0;function a(n){n.preventDefault(),o=l-n.clientX,i=r-n.clientY,l=n.clientX,r=n.clientY;const[a,d]=s(e,e.offsetLeft-o,e.offsetTop-i,t);e.style.top=`${d}px`,e.style.left=`${a}px`}function d(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),l=e.clientX,r=e.clientY,document.onmouseup=d,document.onmousemove=a}n?n.onmousedown=c:e.onmousedown=c})(e(this,l,"f"),e(this,a,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",e(this,d,"f").resize),(n=e(this,l,"f")).onmousemove=e=>{(e.target.w&&e.target.w!==e.target.offsetWidth||e.target.h&&e.target.h!==e.target.offsetHeight)&&n.onresize(e),e.target.w=e.target.offsetWidth,e.target.h=e.target.offsetHeight},e(this,l,"f").onresize=e(this,o,"m",h).bind(this),e(this,i,"f").subscribe(e(this,o,"m",c).bind(this))}disconnectedCallback(){e(this,i,"f").unsubscribeAll(),window.removeEventListener("resize",e(this,d,"f").resize)}}i=new WeakMap,l=new WeakMap,r=new WeakMap,a=new WeakMap,d=new WeakMap,o=new WeakSet,c=function(n){e(this,o,"m",p).call(this,n),e(this,o,"m",h).call(this)},p=function(n){e(this,r,"f").innerHTML=n.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("")},h=function(){e(this,r,"f").querySelectorAll(".msg").forEach((e=>{const n=e.querySelector(".msg_desc"),t=n.scrollWidth>n.clientWidth,s=n.clientHeight>20;t||s?(e.classList.add("collapsible"),e.onclick=n=>{n.target.classList.contains("msg_desc")||e.classList.toggle("collapsed")}):(e.classList.remove("collapsible"),e.onclick=null)}))},g=function(){const[n,t]=s(e(this,l,"f"),Number.parseInt(e(this,l,"f").style.left,10),Number.parseInt(e(this,l,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});e(this,l,"f").style.top=`${t}px`,e(this,l,"f").style.left=`${n}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",m);export{m as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__awaiter as e}from"tslib";import{defaultEndpoint as o,defaultScriptUrlPattern as r,load as i}from"@fingerprintjs/fingerprintjs-pro";const t=(t,n,l)=>e(void 0,void 0,void 0,(function*(){try{const{publicApiKey:e,useCloudflareIntegration:n,cloudflareScriptUrl:s,cloudflareEndpointUrl:d}=t;let p=[];p=n&&d?[d,o]:[o];let a=[];if(n&&s){const e=new URL(s);a=[`${e.toString()}?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`,r]}else a=[r];const c=i({apiKey:e,endpoint:p,scriptUrlPattern:a}),f=yield c,{requestId:u}=yield f.get();l(u)}catch(e){console.warn("Could not load fingerprint",e)}}));export{t as default,t as loadFingerprint};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__awaiter as t}from"tslib";import{load as o,defaultEndpoint as e,defaultScriptUrlPattern as i}from"@fingerprintjs/fingerprintjs-pro";const n=(n,r,p)=>t(void 0,void 0,void 0,(function*(){try{const{customDomain:t,publicApiKey:a,cloudflareEndpointPath:s,cloudflareScriptPath:c}=n,{baseUrl:d}=r;let l;l=t?`https://${t}`:d||"https://api.descope.com";const f=new URL(l);f.pathname=s;const m=new URL(l);m.pathname=c;const u=`${m.toString()}?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`,h=o({apiKey:a,endpoint:[f.toString(),e],scriptUrlPattern:[u,i]}),y=yield h,{requestId:g}=yield y.get();p(g)}catch(t){console.warn("Could not load descope fingerprint",t)}}));export{n as default,n as loadFingerprint};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__awaiter as e,__classPrivateFieldGet as t,__classPrivateFieldSet as i,__rest as o}from"tslib";import r,{ensureFingerprintIds as n,clearFingerprintData as s}from"@descope/web-js-sdk";const a="undefined"!=typeof localStorage,l=a&&localStorage.getItem("base.content.url")||"",d="config.json",c="base.ui.components.url",u=a&&localStorage.getItem(c)||"https://static.descope.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",h=a&&localStorage.getItem(c)||"https://cdn.jsdelivr.net/npm/@descope/web-components-ui@<version>/dist/umd/index.js",p="descope-login-flow",f="code",g="ra-challenge",v="ra-callback",m="ra-backup-callback",b="ra-initiator",y="data-exclude-field",w="dls_last_auth",I="state_id",k="saml_idp_state_id",C="saml_idp_username",A="descope_idp_initiated",S="sso_app_id",j="oidc_login_hint",E="oidc_prompt",U="oidc_error_redirect_uri",x="data-type",O="redirect",T="poll",L="webauthnCreate",R="webauthnGet",W="loadForm",$="submit",M="polling",P=["descope-multi-select-combo-box","descope-text-area"];var N;function D(e){return new URLSearchParams(window.location.search).get(e)}function q(e){if(window.history.replaceState&&D(e)){const t=new URL(window.location.href),i=new URLSearchParams(t.search);i.delete(e),t.search=i.toString(),window.history.replaceState({},"",t.toString())}}function _(t,i){return e(this,void 0,void 0,(function*(){const e=yield fetch(t,{cache:"default"});if(!e.ok)throw Error(`Error fetching URL ${t} [${e.status}]`);return{body:yield e[i||"text"](),headers:Object.fromEntries(e.headers.entries())}}))}!function(e){e.backward="backward",e.forward="forward"}(N||(N={}));function F({projectId:e,filename:t,assetsFolder:i="v2-beta",baseUrl:o}){const r=new URL(l||o||"https://static.descope.com/pages");return r.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(r.pathname,e,i,t),r.toString()}function V(e,t){if(!t)return;const i=+e,o=+t;return Number.isNaN(i)||Number.isNaN(o)?void 0:i>o?N.forward:i<o?N.backward:void 0}const K=()=>{const[e="",t=""]=(D(p)||"").split("_");return{executionId:e,stepId:t}};function H(){q(p)}const B=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),J=()=>{const{executionId:e,stepId:t}=K();(e||t)&&H();const i=D("t")||void 0;i&&q("t");const o=D(f)||void 0;o&&q(f);const r=D("err")||void 0;r&&q("err");const{redirectAuthCodeChallenge:n,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:l}={redirectAuthCodeChallenge:D(g),redirectAuthCallbackUrl:D(v),redirectAuthBackupCallbackUri:D(m),redirectAuthInitiator:D(b)};(n||s||a||l)&&(q(g),q(v),q(m),q(b));const d=D(I);d&&q(I);const c=D(k);c&&q(k);const u=D(C);c&&q(C);const h=D(A);h&&q(A);const p=D(S);p&&q(S);const y=D(j);y&&q(j);const w=D(E);w&&q(E);const x=D(U);x&&q(U);return{executionId:e,stepId:t,token:i,code:o,exchangeError:r,redirectAuthCodeChallenge:n,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:l,ssoQueryParams:{oidcIdpStateId:d,samlIdpStateId:c,samlIdpUsername:u,descopeIdpInitiated:"true"===h,ssoAppId:p,oidcLoginHint:y,oidcPrompt:w,oidcErrorRedirectUri:x}}},z=e=>{let t,i;return(...o)=>{return t&&(n=o,(r=t).length===n.length&&r.every(((e,t)=>e===n[t])))||(t=o,i=e(...o)),i;var r,n}};const G=(e,{oidcIdpStateId:t,samlIdpStateId:i,samlIdpUsername:o,ssoAppId:r,oidcLoginHint:n,oidcPrompt:s,oidcErrorRedirectUri:a})=>!(!e||t||i||o||r||n||s||a),Q=e=>null==e?void 0:e.submit(),X=(e,t)=>{const i=t.find((t=>e[t]));return i?e[i]:null},Y=(e,t=100)=>{let i;return function(...o){i||e.apply(this,o),clearTimeout(i),i=setTimeout((()=>{i=null}),t)}};function Z(e){let t=navigator.language;return t&&"zh-TW"!==t&&(t=t.split("-")[0]),(e||t||"").toLowerCase()}var ee,te,ie,oe;function re(e,t){const i=Object.getOwnPropertyNames(e),o=Object.getOwnPropertyNames(t);if(i.length!==o.length)return!1;for(let o=0;o<i.length;o+=1){const r=i[o],n=e[r],s=t[r];if(null===n||null===s){if(n!==s)return!1}else if("object"==typeof n&&"object"==typeof s){if(!re(n,s))return!1}else if(n!==s)return!1}return!0}class ne{constructor(e={},{updateOnlyOnChange:o=!0}={}){ee.set(this,void 0),te.set(this,{}),ie.set(this,0),oe.set(this,!1),this.update=e=>{const o="function"==typeof e?e(t(this,ee,"f")):e,r=Object.assign(Object.assign({},t(this,ee,"f")),o);if(!t(this,oe,"f")||!re(t(this,ee,"f"),r)){const e=t(this,ee,"f");i(this,ee,r,"f"),Object.freeze(t(this,ee,"f")),setTimeout((()=>{Object.values(t(this,te,"f")).forEach((t=>t(r,e,((e,t)=>i=>e[i]!==t[i])(r,e))))}),0)}},i(this,ee,e,"f"),i(this,oe,o,"f")}get current(){return Object.assign({},t(this,ee,"f"))}subscribe(e){return i(this,ie,t(this,ie,"f")+1,"f"),t(this,te,"f")[t(this,ie,"f")]=e,t(this,ie,"f").toString()}unsubscribe(e){const i=!!t(this,te,"f")[e];return i&&delete t(this,te,"f")[e],i}unsubscribeAll(){return i(this,te,{},"f"),!0}}ee=new WeakMap,te=new WeakMap,ie=new WeakMap,oe=new WeakMap;const se=["disabled"],ae=(e,t)=>{Object.entries(t||{}).forEach((([t,i])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${y}])`)).forEach((e=>{e.value=i}))}))},le=(e,t)=>e.replace(/{{(.+?)}}/g,((e,i)=>{return o=t,i.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),o);var o})),de=(e,t,i)=>{e.querySelectorAll(`[${x}="${t}"]`).forEach((e=>{e.setAttribute("href",i)}))},ce=(e,t,i)=>{var o,r;const n=null===(o=customElements.get(t))||void 0===o?void 0:o.cssVarList.url;i&&n&&(null===(r=null==e?void 0:e.style)||void 0===r||r.setProperty(n,`url(data:image/jpg;base64,${i})`))},ue=(e,t,i,o,r,n)=>{var s,a;let l=null==t?void 0:t.errorText;try{l=(null==r?void 0:r({text:null==t?void 0:t.errorText,type:null==t?void 0:t.errorType}))||(null==t?void 0:t.errorText)}catch(e){n.error("Error transforming error message",e.message)}((e,t,i="")=>{e.querySelectorAll(`[${x}="${t}"]`).forEach((e=>{e.textContent=i,e.classList[i?"remove":"add"]("hide")}))})(e,"error-message",l),de(e,"totp-link",null===(s=null==t?void 0:t.totp)||void 0===s?void 0:s.provisionUrl),de(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=le(e.textContent,t);const i=e.getAttribute("href");i&&e.setAttribute("href",le(i,t))}))})(e,t),((e,t,i)=>{t&&Object.keys(t).forEach((o=>{e.querySelectorAll(`[name=${o}]`).forEach((e=>{const r=t[o];Object.keys(r).forEach((t=>{let o=r[t];if("string"!=typeof o)try{o=JSON.stringify(o)}catch(e){i.error(`Could not stringify value "${o}" for "${t}"`,e.message),o=""}e.setAttribute(t,o)}))}))}))})(e,i,n),((e,t)=>{e.querySelectorAll("[data-has-dynamic-attr-values]").forEach((e=>{Array.from(e.attributes).forEach((e=>{e.value=le(e.value,t)}))}))})(e,t),((e,t)=>{Object.entries(t).forEach((([t,i])=>{e.querySelectorAll(`[name="${t}"]`).forEach((e=>{Object.entries(i).forEach((([t,i])=>{se.includes(t)&&e.setAttribute(t,i)}))}))}))})(e,o)},he=z((()=>e(void 0,void 0,void 0,(function*(){var e,t,i,o,r;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const n=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)))),s=(()=>{var e;const t=null===(e=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===e?void 0:e.brands,i=null==t?void 0:t.find((({brand:e,version:t})=>"Chromium"===e&&parseFloat(t)));return i?i.version:0})()>=108;return yield(i=100,o=n,r=s,new Promise(((e,t)=>{let n=!1;const s=setTimeout((()=>{n=!0,void 0!==r?e(r):t(new Error(`Promise timed out after ${i} ms`))}),i);o.then((t=>{n||(clearTimeout(s),e(t))})).catch((e=>{n||(clearTimeout(s),t(e))}))})))}catch(e){return console.error("Conditional login check failed",e),!1}})))),pe={"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 fe(e){const t={};if(e)try{Object.assign(t,JSON.parse(localStorage.getItem(w)))}catch(e){}return t}const ge="dls_ab_testing_id",ve=document.createElement("template");ve.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 me=(e,t="")=>Object.keys(e).reduce(((i,o)=>{var r;if("object"==typeof e[o]&&null!==e[o]&&!(null===(r=e[o])||void 0===r?void 0:r.value))return Object.assign(Object.assign({},i),me(e[o],`${t+o}.`));const n="object"==typeof e[o]?e[o]:{value:e[o]},s=Object.assign(Object.assign({},i),{[t+o]:n,[`form.${t}${o}`]:n});return"displayName"===o?Object.assign(Object.assign({},s),{[`${t}fullName`]:n,[`form.${t}fullName`]:n}):s}),[]);var be,ye,we,Ie,ke,Ce,Ae,Se,je,Ee,Ue,xe,Oe,Te,Le,Re,We,$e,Me,Pe,Ne,De,qe,_e,Fe,Ve,Ke,He,Be,Je,ze,Ge,Qe,Xe,Ye,Ze,et,tt,it,ot,rt,nt,st,at,lt,dt,ct,ut,ht,pt,ft;class gt 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(o){super(),be.add(this),this.logger=console,ye.set(this,!1),this.loggerWrapper={error:(e,i="")=>{this.logger.error(e,i,new Error),t(this,be,"m",He).call(this,e,i)},warn:(e,t="")=>{this.logger.warn(e,t)},info:(e,t="",i={})=>{this.logger.info(e,t,i)},debug:(e,t="")=>{this.logger.debug(e,t)}},we.set(this,new ne),Ie.set(this,new ne),ke.set(this,{}),this.getComponentsContext=()=>t(this,ke,"f"),this.nextRequestStatus=new ne({isLoading:!1}),Ce.set(this,void 0),Ae.set(this,{popstate:t(this,be,"m",Oe).bind(this),componentsContext:t(this,be,"m",_e).bind(this)}),Se.set(this,void 0),$e.set(this,z((()=>e(this,void 0,void 0,(function*(){const e=F({projectId:this.projectId,filename:d,baseUrl:this.baseStaticUrl});try{const{body:t,headers:i}=yield _(e,"json");return{projectConfig:t,executionContext:{geo:i["x-geo"]}}}catch(e){return{isMissingConfig:!0}}}))))),Pe.set(this,void 0),i(this,Se,o,"f"),t(this,be,"m",je).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 i=this.getAttribute("theme");if("os"===i){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 i||"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 me(JSON.parse(e))}catch(e){return{}}})(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return e=this.formConfig,t="value",Object.fromEntries(Object.entries(e).map((([e,i])=>[e,i[t]])));var e,t}getExecutionContext(){return e(this,void 0,void 0,(function*(){const{executionContext:e}=yield t(this,$e,"f").call(this);return e}))}getProjectConfig(){return e(this,void 0,void 0,(function*(){const{projectConfig:e}=yield t(this,$e,"f").call(this);return e}))}getFlowConfig(){var t,i;return e(this,void 0,void 0,(function*(){const e=yield this.getProjectConfig(),o=(null===(t=null==e?void 0:e.flows)||void 0===t?void 0:t[this.flowId])||{};return null!==(i=o.version)&&void 0!==i||(o.version=0),o}))}getTargetLocales(){return e(this,void 0,void 0,(function*(){const e=yield this.getFlowConfig();return((null==e?void 0:e.targetLocales)||[]).map((e=>e.toLowerCase()))}))}connectedCallback(){return e(this,void 0,void 0,(function*(){if(this.shadowRoot.isConnected){if(t(this,Ie,"f").subscribe(t(this,be,"m",Ke).bind(this)),t(this,Ie,"f").update({isDebug:this.debug}),t(this,be,"m",Ee).call(this))return void t(this,be,"m",Ue).call(this);if(t(this,be,"m",xe).call(this),i(this,Pe,t(this,be,"m",Me).call(this),"f"),yield t(this,be,"m",Re).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 t(this,$e,"f").call(this)).isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");t(this,be,"m",Ne).call(this),yield t(this,be,"m",ze).call(this),yield t(this,be,"m",De).call(this),t(this,be,"m",Be).call(this);const{executionId:e,stepId:o,token:r,code:n,exchangeError:s,redirectAuthCallbackUrl:a,redirectAuthBackupCallbackUri:l,redirectAuthCodeChallenge:d,redirectAuthInitiator:c,ssoQueryParams:u}=J();window.addEventListener("popstate",t(this,Ae,"f").popstate),window.addEventListener("components-context",t(this,Ae,"f").componentsContext),t(this,we,"f").subscribe(t(this,be,"m",Le).bind(this)),t(this,we,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenant,redirectUrl:this.redirectUrl,locale:this.locale,stepId:o,executionId:e,token:r,code:n,exchangeError:s,redirectAuthCallbackUrl:a,redirectAuthBackupCallbackUri:l,redirectAuthCodeChallenge:d,redirectAuthInitiator:c},u)),i(this,ye,!0,"f")}}))}disconnectedCallback(){t(this,we,"f").unsubscribeAll(),t(this,Ie,"f").unsubscribeAll(),t(this,be,"m",Ve).call(this),window.removeEventListener("popstate",t(this,Ae,"f").popstate),window.removeEventListener("components-context",t(this,Ae,"f").componentsContext)}attributeChangedCallback(e,i,o){if(this.shadowRoot.isConnected&&t(this,ye,"f")&&i!==o&>.observedAttributes.includes(e)){t(this,be,"m",xe).call(this);const r=null===i;t(this,we,"f").update((({stepId:t,executionId:i})=>{let n=t,s=i;return r||(s=null,n=null,H()),{[B(e)]:o,stepId:n,executionId:s}})),t(this,Ie,"f").update({isDebug:this.debug}),"theme"===e&&t(this,be,"m",Fe).call(this)}}}function vt(e,t){return`sdkScriptsResults.${t?`${e}_${t}`:e}`}ye=new WeakMap,we=new WeakMap,Ie=new WeakMap,ke=new WeakMap,Ce=new WeakMap,Ae=new WeakMap,Se=new WeakMap,$e=new WeakMap,Pe=new WeakMap,be=new WeakSet,je=function(){this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(ve.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#wc-root")},Ee=function(){return!this.shadowRoot.host.closest("form")&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)},Ue=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)},xe=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(gt.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[B(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')},Oe=function(){const{stepId:e,executionId:i}=K();t(this,we,"f").update({stepId:e,executionId:i})},Te=function(t,i){this.sdk=r(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout},gt.sdkConfigOverrides),{projectId:t,baseUrl:i})),["start","next"].forEach((t=>{const i=this.sdk.flow[t];this.sdk.flow[t]=(...t)=>e(this,void 0,void 0,(function*(){this.nextRequestStatus.update({isLoading:!0});try{return yield i(...t)}catch(e){return{error:{errorCode:"J151000",errorDescription:e.toString()}}}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},Le=function(i,o,r){return e(this,void 0,void 0,(function*(){const{projectId:e,baseUrl:o}=i;if(r("projectId")||r("baseUrl")){if(!e)return;t(this,be,"m",Te).call(this,e,o)}t(this,Se,"f").call(this,i)}))},Re=function(){return e(this,void 0,void 0,(function*(){return(yield t(this,$e,"f").call(this)).isMissingConfig&&(yield t(this,be,"m",We).call(this))}))},We=function(){return e(this,void 0,void 0,(function*(){const e=F({projectId:this.projectId,filename:d,assetsFolder:"v2-alpha",baseUrl:this.baseStaticUrl});try{return yield _(e,"json"),!0}catch(e){return!1}}))},Me=function(){return e(this,void 0,void 0,(function*(){const e=F({projectId:this.projectId,filename:"theme.json",baseUrl:this.baseStaticUrl});try{const{body:t}=yield _(e,"json");return t}catch(e){return void this.loggerWrapper.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}}))},Ne=function(){var i,o;return e(this,void 0,void 0,(function*(){const{projectConfig:e}=yield t(this,$e,"f").call(this),r=null===(o=null===(i=null==e?void 0:e.cssTemplate)||void 0===i?void 0:i[this.theme])||void 0===o?void 0:o.fonts;r&&Object.values(r).forEach((e=>(e=>{if(!e)return;const t=document.createElement("link");t.href=e,t.rel="stylesheet",document.head.appendChild(t)})(e.url)))}))},De=function(){return e(this,void 0,void 0,(function*(){yield t(this,be,"m",qe).call(this),yield t(this,be,"m",Fe).call(this)}))},qe=function(){var i,o,r,n;return e(this,void 0,void 0,(function*(){const e=document.createElement("style"),s=yield t(this,Pe,"f");e.innerText=((null===(i=null==s?void 0:s.light)||void 0===i?void 0:i.globals)||"")+((null===(o=null==s?void 0:s.dark)||void 0===o?void 0:o.globals)||"");const a=yield gt.descopeUI;(null==a?void 0:a.componentsThemeManager)&&!a.componentsThemeManager.hasThemes&&(a.componentsThemeManager.themes={light:null===(r=null==s?void 0:s.light)||void 0===r?void 0:r.components,dark:null===(n=null==s?void 0:s.dark)||void 0===n?void 0:n.components}),this.shadowRoot.appendChild(e)}))},_e=function(e){i(this,ke,Object.assign(Object.assign({},t(this,ke,"f")),e.detail),"f")},Fe=function(){return e(this,void 0,void 0,(function*(){this.rootElement.setAttribute("data-theme",this.theme);const e=yield gt.descopeUI;(null==e?void 0:e.componentsThemeManager)&&(e.componentsThemeManager.currentThemeName=this.theme)}))},Ve=function(){var e;null===(e=t(this,Ce,"f"))||void 0===e||e.remove(),i(this,Ce,null,"f")},Ke=function({isDebug:o}){return e(this,void 0,void 0,(function*(){o?(i(this,Ce,document.createElement("descope-debugger"),"f"),Object.assign(t(this,Ce,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield import("./debugger-wc-3a1a2c23.js"),document.body.appendChild(t(this,Ce,"f"))):t(this,be,"m",Ve).call(this)}))},He=function(e,i){var o;e&&this.debug&&(null===(o=t(this,Ce,"f"))||void 0===o||o.updateData({title:e,description:i}))},Be=function(){this.rootElement.onkeydown=e=>{var t,i,o;const r=!!(null===(t=this.shadowRoot.activeElement)||void 0===t?void 0:t.getAttribute("href")),n=P.includes(null!==(o=null===(i=this.shadowRoot.activeElement)||void 0===i?void 0:i.localName)&&void 0!==o?o:"");if("Enter"!==e.key||r||n)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 l=Array.from(s).filter((e=>"button"===e.getAttribute("data-type")));if(1===l.length)"false"!==l[0].getAttribute("auto-submit")&&l[0].click();else if(0===l.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()}}},Je=function(){var i,o;return e(this,void 0,void 0,(function*(){const e=null===(o=null===(i=yield t(this,$e,"f").call(this))||void 0===i?void 0:i.projectConfig)||void 0===o?void 0:o.componentsVersion;return e||(this.logger.error("Did not get components version, using latest version"),"latest")}))},ze=function(){return e(this,void 0,void 0,(function*(){gt.descopeUI?this.loggerWrapper.debug("DescopeUI is already loading, probably multiple flows are running on the same page"):gt.descopeUI=new Promise((i=>{if(globalThis.DescopeUI)return void i(globalThis.DescopeUI);const o=e=>{const t=document.createElement("script");return t.id="load-descope-ui",t.src=e,t},r=(e,t)=>e.replace("<version>",t),n=(e,t)=>{const o=()=>{this.loggerWrapper.error("Cannot load DescopeUI",`Make sure this URL is valid and return the correct script: "${e.src}"`),t()};e.addEventListener("load",(()=>{globalThis.DescopeUI||o(),i(globalThis.DescopeUI)})),e.addEventListener("error",o)};(()=>{e(this,void 0,void 0,(function*(){const e=yield t(this,be,"m",Je).call(this),s=o(r(u,e));n(s,(()=>{s.remove(),this.loggerWrapper.info("Trying to load DescopeUI from a fallback URL");const t=o(r(h,e));n(t,(()=>{i(void 0)})),document.body.append(t)})),document.body.append(s)}))})()}))}))},gt.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.22.0"}};class mt extends gt{static set sdkConfigOverrides(e){gt.sdkConfigOverrides=e}constructor(){const o=new ne({deferredRedirect:!1});super(o.update.bind(o)),Ge.add(this),this.stepState=new ne({},{updateOnlyOnChange:!1}),Qe.set(this,void 0),Xe.set(this,null),Ye.set(this,{visibilitychange:t(this,Ge,"m",Ze).bind(this)}),et.set(this,((o,r,n,s,a)=>{n===T&&i(this,Qe,setTimeout((()=>e(this,void 0,void 0,(function*(){var e;let i;try{i=yield this.sdk.flow.next(o,r,M,s,a,{})}catch(e){return void t(this,et,"f").call(this,o,r,n,s,a)}t(this,it,"f").call(this,i);const{action:l}=null!==(e=null==i?void 0:i.data)&&void 0!==e?e:{};t(this,et,"f").call(this,o,r,l,s,a)}))),2e3),"f")})),tt.set(this,(()=>{clearTimeout(t(this,Qe,"f")),i(this,Qe,null,"f")})),it.set(this,(e=>{var i,o,r,n,s,l,d,c,u,h,p;if(!(null==e?void 0:e.ok)){const a=null===(i=null==e?void 0:e.response)||void 0===i?void 0:i.url,l=`${null===(o=null==e?void 0:e.response)||void 0===o?void 0:o.status} - ${null===(r=null==e?void 0:e.response)||void 0===r?void 0:r.statusText}`;return t(this,Ge,"m",ft).call(this,"error",(null==e?void 0:e.error)||{errorCode:"J151001",errorDescription:l,errorMessage:a}),void this.loggerWrapper.error((null===(n=null==e?void 0:e.error)||void 0===n?void 0:n.errorDescription)||a,(null===(s=null==e?void 0:e.error)||void 0===s?void 0:s.errorMessage)||l)}null===(d=null===(l=e.data)||void 0===l?void 0:l.runnerLogs)||void 0===d||d.forEach((e=>{const{level:t,title:i,log:o}=e;t&&this.loggerWrapper[t]?this.loggerWrapper[t](i,o):this.loggerWrapper.info(i,o)}));const f=null===(h=null===(u=null===(c=e.data)||void 0===c?void 0:c.screen)||void 0===u?void 0:u.state)||void 0===h?void 0:h.errorText;(null===(p=e.data)||void 0===p?void 0:p.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:g,authInfo:v,lastAuth:m}=e.data;if("completed"===g)return this.storeLastAuthenticatedUser&&function(e){(null==e?void 0:e.authMethod)&&a&&localStorage.setItem(w,JSON.stringify(e))}(m),void t(this,Ge,"m",ft).call(this,"success",v);const{executionId:b,stepId:y,stepName:I,action:k,screen:C,redirect:A,openInNewTabUrl:S,webauthn:j,error:E,samlIdpResponse:U}=e.data;k!==T?(this.loggerWrapper.info(`Step "${I||`#${y}`}" is ${g}`,"",{screen:C,status:g,stepId:y,stepName:I,action:k,error:E}),this.flowState.update({stepId:y,executionId:b,action:k,redirectTo:null==A?void 0:A.url,openInNewTabUrl:S,screenId:null==C?void 0:C.id,screenState:null==C?void 0:C.state,webauthnTransactionId:null==j?void 0:j.transactionId,webauthnOptions:null==j?void 0:j.options,samlIdpResponseUrl:null==U?void 0:U.url,samlIdpResponseSamlResponse:null==U?void 0:U.samlResponse,samlIdpResponseRelayState:null==U?void 0:U.relayState})):this.flowState.update({action:k})})),ot.set(this,z((()=>e(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)}}))))),ct.set(this,Y(((i,o)=>e(this,void 0,void 0,(function*(){if("true"===i.getAttribute("formnovalidate")||t(this,Ge,"m",st).call(this)){const r=null==i?void 0:i.getAttribute("id");t(this,Ge,"m",lt).call(this,i);const n=yield t(this,Ge,"m",at).call(this),s=(e=i,Array.from((null==e?void 0:e.attributes)||[]).reduce(((e,t)=>{var i;const o=null===(i=new RegExp("^data-descope-(\\S+)$").exec(t.name))||void 0===i?void 0:i[1];return o?Object.assign(e,{[o]:t.value}):e}),{})),a=this.getComponentsContext(),l=Object.assign(Object.assign(Object.assign(Object.assign({},a),s),n),{origin:window.location.origin}),d=yield this.getFlowConfig(),c=yield this.getProjectConfig(),u=yield o(r,d.version,c.componentsVersion,l);t(this,it,"f").call(this,u),t(this,Ge,"m",dt).call(this,n)}var e}))))),this.flowState=o}loadSdkScripts(){return e(this,void 0,void 0,(function*(){const t=(yield this.getFlowConfig()).sdkScripts;null==t||t.forEach((t=>e(this,void 0,void 0,(function*(){(yield function(t){return e(this,void 0,void 0,(function*(){let e;switch(t){case"forter":return e=yield import("./forter-74d50b85.js"),e.default;case"fingerprint":return e=yield import("./fingerprint-84b451f2.js"),e.default;case"fingerprintDescope":return e=yield import("./fingerprintDescope-effc737b.js"),e.default;default:throw new Error(`Unknown script id: ${t}`)}}))}(t.id))(t.initArgs,{baseUrl:this.baseUrl},(e=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[vt(t.id,t.resultKey)]:e},bubbles:!0,composed:!0}))}))}))))}))}connectedCallback(){const i=Object.create(null,{connectedCallback:{get:()=>super.connectedCallback}});var o,r;return e(this,void 0,void 0,(function*(){this.shadowRoot.isConnected&&(null===(o=this.flowState)||void 0===o||o.subscribe(this.onFlowChange.bind(this)),null===(r=this.stepState)||void 0===r||r.subscribe(this.onStepChange.bind(this)),window.addEventListener("visibilitychange",t(this,Ye,"f").visibilitychange)),yield i.connectedCallback.call(this)}))}disconnectedCallback(){var e;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),null===(e=t(this,Xe,"f"))||void 0===e||e.abort(),i(this,Xe,null,"f"),window.removeEventListener("visibilitychange",t(this,Ye,"f").visibilitychange)}getHtmlFilenameWithLocale(t,i){return e(this,void 0,void 0,(function*(){let e;const o=Z(t);return(yield this.getTargetLocales()).includes(o)&&(e=`${i}-${o}.html`),e}))}getPageContent(t,i){return e(this,void 0,void 0,(function*(){if(i)try{const{body:e}=yield _(i,"text");return e}catch(e){this.loggerWrapper.error(`Failed to fetch flow page from ${i}. Fallback to url ${t}`,e)}try{const{body:e}=yield _(t,"text");return e}catch(e){this.loggerWrapper.error("Failed to fetch flow page",e.message)}return null}))}onFlowChange(r,a,l){var d,c;return e(this,void 0,void 0,(function*(){const{projectId:e,flowId:u,tenant:h,stepId:p,executionId:f,action:g,screenId:v,screenState:m,redirectTo:b,openInNewTabUrl:y,redirectUrl:w,token:I,code:k,exchangeError:C,webauthnTransactionId:A,webauthnOptions:S,redirectAuthCodeChallenge:j,redirectAuthCallbackUrl:E,redirectAuthBackupCallbackUri:U,redirectAuthInitiator:x,locale:T,samlIdpResponseUrl:M,samlIdpResponseSamlResponse:P,samlIdpResponseRelayState:N}=r,D=o(r,["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 q,_;const K=(()=>{const e=localStorage.getItem(ge);if(!e){const e=Math.floor(100*Math.random()+1);return localStorage.setItem(ge,e.toString()),e}return Number(e)})(),H=this.sdk.getLastUserLoginId(),B=yield this.getFlowConfig(),J=yield this.getProjectConfig(),z=E&&j?{callbackUrl:E,codeChallenge:j,backupCallbackUri:U}:void 0;if(!f&&(this.loadSdkScripts(),B.fingerprintEnabled&&B.fingerprintKey?yield n(B.fingerprintKey,this.baseUrl):s(),B.conditions?({startScreenId:q,conditionInteractionId:_}=((e,t)=>{const i=null==t?void 0:t.find((({key:t,operator:i,predicate:o})=>{var r;if("ELSE"===t)return!0;const n=null===(r=pe[t])||void 0===r?void 0:r[i];return!!(null==n?void 0:n(e,o))}));return i?{startScreenId:i.met.screenId,conditionInteractionId:i.met.interactionId}:{}})({loginId:H,code:k,token:I,abTestingKey:K},B.conditions)):B.condition?({startScreenId:q,conditionInteractionId:_}=((e,t)=>{var i;const o=null===(i=pe[null==e?void 0:e.key])||void 0===i?void 0:i[e.operator];if(!o)return{};const r=o(t,e.predicate)?e.met:e.unmet;return{startScreenId:null==r?void 0:r.screenId,conditionInteractionId:null==r?void 0:r.interactionId}})(B.condition,{loginId:H,code:k,token:I,abTestingKey:K})):q=B.startScreenId,!G(q,D))){const e=yield this.sdk.flow.start(u,Object.assign(Object.assign(Object.assign(Object.assign({tenant:h,redirectAuth:z},D),{client:this.client}),w&&{redirectUrl:w}),{lastAuth:fe(H),abTestingKey:K,locale:Z(T)}),_,"",B.version,J.componentsVersion,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),k?{exchangeCode:k,idpInitiated:!0}:{}),D.descopeIdpInitiated&&{idpInitiated:!0}),I?{token:I}:{}),D.oidcLoginHint?{externalId:D.oidcLoginHint}:{}));return t(this,it,"f").call(this,e),void("completed"!==(null===(d=null==e?void 0:e.data)||void 0===d?void 0:d.status)&&this.flowState.update({code:void 0,token:void 0}))}if(f&&(l("token")&&I||l("code")&&k||l("exchangeError")&&C)){const e=yield this.sdk.flow.next(f,p,$,B.version,J.componentsVersion,{token:I,exchangeCode:k,exchangeError:C});return t(this,it,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(g===W&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>l(e)))){if(!M||!P)return void this.loggerWrapper.error("Did not get saml idp params data to load");((e,t,i,o)=>{const r=document.createElement("form");r.method="POST",r.action=e,r.innerHTML=`\n <input type="hidden" role="saml-response" name="SAMLResponse" value="${t}" />\n <input type="hidden" role="saml-relay-state" name="RelayState" value="${i}" />\n <input style="display: none;" id="SAMLSubmitButton" type="submit" value="Continue" />\n `,document.body.appendChild(r),o(r)})(M,P,N||"",Q)}if(g===O&&(l("redirectTo")||l("deferredRedirect")))return b?"android"===x&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(b):void this.loggerWrapper.error("Did not get redirect url");if(g===L||g===R){if(!A||!S)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,o;null===(c=t(this,Xe,"f"))||void 0===c||c.abort(),i(this,Xe,null,"f");try{e=g===L?yield this.sdk.webauthn.helpers.create(S):yield this.sdk.webauthn.helpers.get(S)}catch(e){"InvalidStateError"===e.name?this.loggerWrapper.warn("WebAuthn operation failed",e.message):"NotAllowedError"!==e.name&&this.loggerWrapper.error(e.message),o=e.name}const r=yield this.sdk.flow.next(f,p,$,B.version,J.componentsVersion,{transactionId:A,response:e,failure:o});t(this,it,"f").call(this,r)}if(t(this,et,"f").call(this,f,p,g,B.version,J.componentsVersion),!v&&!q)return void this.loggerWrapper.warn("No screen was found to show");const X=q||v,Y=yield this.getHtmlFilenameWithLocale(T,X),{oidcLoginHint:ee,oidcPrompt:te,oidcErrorRedirectUri:ie,samlIdpUsername:oe}=D,re={direction:V(p,a.stepId),screenState:Object.assign(Object.assign({},m),{form:Object.assign(Object.assign({},this.formConfigValues),null==m?void 0:m.form),lastAuth:{loginId:H,name:this.sdk.getLastUserDisplayName()||H}}),htmlUrl:F({projectId:e,filename:`${X}.html`,baseUrl:this.baseStaticUrl}),htmlLocaleUrl:Y&&F({projectId:e,filename:Y,baseUrl:this.baseStaticUrl}),samlIdpUsername:oe,oidcLoginHint:ee,oidcPrompt:te,oidcErrorRedirectUri:ie,openInNewTabUrl:y},ne=fe(H);G(q,D)?re.next=(e,t,i,o)=>this.sdk.flow.start(u,Object.assign(Object.assign(Object.assign(Object.assign({tenant:h,redirectAuth:z},D),{lastAuth:ne,preview:this.preview,abTestingKey:K,client:this.client}),w&&{redirectUrl:w}),{locale:Z(T)}),_,e,t,i,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),o),k&&{exchangeCode:k,idpInitiated:!0}),D.descopeIdpInitiated&&{idpInitiated:!0}),I&&{token:I})):(l("projectId")||l("baseUrl")||l("executionId")||l("stepId"))&&(re.next=(...e)=>this.sdk.flow.next(f,p,...e)),this.stepState.update(re)}))}loadDescopeUiComponents(t){return e(this,void 0,void 0,(function*(){const i=yield gt.descopeUI;if(!i)return;const o=(e=>[...Array.from(e.querySelectorAll("*")).reduce(((e,t)=>t.tagName.startsWith("DESCOPE-")?e.add(t.tagName.toLocaleLowerCase()):e),new Set)])(t);yield Promise.all(o.map((t=>e(this,void 0,void 0,(function*(){if(!!!customElements.get(t))if(i[t])try{return yield i[t]()}catch(e){if("NotSupportedError"!==e.name)throw e;console.debug(`${t} is already registered`)}else this.loggerWrapper.error(`Cannot load UI component "${t}"`,`Descope UI does not have a component named "${t}", available components are: "${Object.keys(i).join(", ")}"`)})))))}))}onStepChange(i,o){var r,n;return e(this,void 0,void 0,(function*(){const{htmlUrl:s,htmlLocaleUrl:a,direction:l,next:d,screenState:c,openInNewTabUrl:u}=i,h=document.createElement("template");h.innerHTML=yield this.getPageContent(s,a);const p=h.content.cloneNode(!0),f=this.loadDescopeUiComponents(h.content);this.sdk.webauthn.helpers.isSupported()?yield t(this,Ge,"m",nt).call(this,p,d):p.querySelectorAll(`descope-button[${x}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true"))),!i.samlIdpUsername||(null===(r=c.form)||void 0===r?void 0:r.loginId)||(null===(n=c.form)||void 0===n?void 0:n.email)||(c.form||(c.form={}),c.form.loginId=i.samlIdpUsername,c.form.email=i.samlIdpUsername),ue(p,c,c.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)}))})(p,g);const v=()=>e(this,void 0,void 0,(function*(){var e,i;yield f;const r=this.shadowRoot.querySelector("div");var n,s;n=r,s=null===(e=null==c?void 0:c.totp)||void 0===e?void 0:e.image,ce(n,"descope-totp-image",s),((e,t)=>{ce(e,"descope-notp-image",t)})(r,null===(i=null==c?void 0:c.notp)||void 0===i?void 0:i.image),this.rootElement.replaceChildren(p),setTimeout((()=>{((e,t)=>{ae(e,null==t?void 0:t.inputs),ae(e,null==t?void 0:t.form)})(this.rootElement,c)}));const a=!o.htmlUrl;((e,t,i)=>{if(!0===t||"skipFirstScreen"===t&&!i){const t=e.querySelector("*[name]");setTimeout((()=>{null==t||t.focus()}))}})(this.rootElement,this.autoFocus,a),this.validateOnBlur&&(e=>{e.querySelectorAll("*[name]").forEach((e=>{e.addEventListener("blur",(()=>{var t;const i=e.focus;e.focus=()=>{},null===(t=e.reportValidity)||void 0===t||t.call(e),setTimeout((()=>{e.focus=i}))}))}))})(this.rootElement),t(this,Ge,"m",ht).call(this,d),a&&t(this,Ge,"m",ft).call(this,"ready",{}),t(this,Ge,"m",ft).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${x}="polling"]`)){const e=yield this.getFlowConfig(),i=yield this.getProjectConfig(),o=yield d(M,e.version,i.componentsVersion,{});t(this,it,"f").call(this,o)}u&&!o.openInNewTabUrl&&window.open(u,"_blank")}));l?t(this,Ge,"m",pt).call(this,v,l):v()}))}}Qe=new WeakMap,Xe=new WeakMap,Ye=new WeakMap,et=new WeakMap,tt=new WeakMap,it=new WeakMap,ot=new WeakMap,ct=new WeakMap,Ge=new WeakSet,Ze=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},rt=function(e){const t=e.getAttribute("name");if(!["email"].includes(t)){const i=`user-${t}`;e.setAttribute("name",i),e.addEventListener("input",(()=>{e.setAttribute("name",e.value?t:i)}))}},nt=function(o,r){var n;return e(this,void 0,void 0,(function*(){null===(n=t(this,Xe,"f"))||void 0===n||n.abort();const s=o.querySelector('*[autocomplete="webauthn"]');if(s&&(yield he())){const{options:o,transactionId:n}=(yield t(this,ot,"f").call(this))||{};if(o&&n){t(this,Ge,"m",rt).call(this,s),i(this,Xe,new AbortController,"f");const a=yield this.getFlowConfig(),l=yield this.getProjectConfig();this.sdk.webauthn.helpers.conditional(o,t(this,Xe,"f")).then((i=>e(this,void 0,void 0,(function*(){const e=yield r(s.id,a.version,l.componentsVersion,{transactionId:n,response:i});t(this,it,"f").call(this,e)})))).catch((e=>{"AbortError"!==e.name&&this.loggerWrapper.error("Conditional login failed",e.message)}))}}}))},st=function(){let e=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((t=>{var i,o;"slot"!==t.localName&&(null===(i=t.reportValidity)||void 0===i||i.call(t),e&&(e=null===(o=t.checkValidity)||void 0===o?void 0:o.call(t)))})),e},at=function(){return e(this,void 0,void 0,(function*(){const t=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${y}])`));return(yield Promise.all(t.map((t=>e(this,void 0,void 0,(function*(){return{name:t.getAttribute("name"),value:t.value}})))))).reduce(((e,t)=>Object.assign(Object.assign({},e),{[t.name]:t.value})),{})}))},lt=function(e){const t=this.nextRequestStatus.subscribe((({isLoading:i})=>{i?e.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(t),e.removeAttribute("loading"))}))},dt=function(e={}){var t,i;const o=X(e,["externalId","email","phone"]),r=X(e,["newPassword","password"]);if(o&&r)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:o,password:r});null===(i=null===(t=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===t?void 0:t.store)||void 0===i||i.call(t,e)}catch(e){this.loggerWrapper.error("Could not store credentials",e.message)}},ut=function(e){this.rootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((i=>{i.addEventListener("input",(()=>{var o;(null===(o=i.checkValidity)||void 0===o?void 0:o.call(i))&&t(this,ct,"f").call(this,i,e)}))}))},ht=function(e){this.rootElement.querySelectorAll("descope-button:not([data-exclude-next])").forEach((i=>{i.onclick=()=>{t(this,ct,"f").call(this,i,e)}})),t(this,Ge,"m",ut).call(this,e)},pt=function(e,t){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),e()}),{once:!0});const i=t===N.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(i)})),this.rootElement.classList.add("fade-out")},ft=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",mt);export{mt as D,ne as S};
|
package/dist/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{D as default}from"./index-
|
|
1
|
+
export{D as default}from"./index-307d94b0.js";import"tslib";import"@descope/web-js-sdk";
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
!function(){"use strict";var t=function(){return t=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},t.apply(this,arguments)};function e(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(t);i<o.length;i++)e.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(t,o[i])&&(n[o[i]]=t[o[i]])}return n}function n(t,e,n,o){return new(n||(n=Promise))((function(i,r){function s(t){try{l(o.next(t))}catch(t){r(t)}}function a(t){try{l(o.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((o=o.apply(t,e||[])).next())}))}function o(t,e,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(t):o?o.value:e.get(t)}function i(t,e,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 e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(t,n):i?i.value=n:e.set(t,n),n}function r(t){this.message=t}"function"==typeof SuppressedError&&SuppressedError,r.prototype=new Error,r.prototype.name="InvalidCharacterError";var s="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new r("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,o,i=0,s=0,a="";o=e.charAt(s++);~o&&(n=i%4?64*n+o:o,i++%4)?a+=String.fromCharCode(255&n>>(-2*i&6)):0)o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);return a};function a(t){this.message=t}function l(t,e){if("string"!=typeof t)throw new a("Invalid token specified");var n=!0===(e=e||{}).header?0:1;try{return JSON.parse(function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(s(t).replace(/(.)/g,(function(t,e){var n=e.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(e)}catch(t){return s(e)}}(t.split(".")[n]))}catch(t){throw new a("Invalid token specified: "+t.message)}}a.prototype=new Error,a.prototype.name="InvalidTokenError";var c="/v1/auth/accesskey/exchange",d="/v1/auth/otp/verify",u="/v1/auth/otp/signin",h="/v1/auth/otp/signup",p={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},f="/v1/auth/otp/signup-in",g="/v1/auth/magiclink/verify",v="/v1/auth/magiclink/signin",m="/v1/auth/magiclink/signup",w={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},b="/v1/auth/magiclink/signup-in",y="/v1/auth/enchantedlink/verify",I="/v1/auth/enchantedlink/signin",k="/v1/auth/enchantedlink/signup",j="/v1/auth/enchantedlink/pending-session",C={email:"/v1/auth/enchantedlink/update/email"},S="/v1/auth/enchantedlink/signup-in",O="/v1/auth/oauth/authorize",A="/v1/auth/oauth/exchange",x="v1/auth/oauth/native/start",U="v1/auth/oauth/native/finish",E="/v1/auth/saml/authorize",T="/v1/auth/saml/exchange",L="/v1/auth/totp/verify",_="/v1/auth/totp/signup",R="/v1/auth/totp/update",P="/v1/auth/notp/whatsapp/signin",$="/v1/auth/notp/whatsapp/signup",M="/v1/auth/notp/whatsapp/signup-in",D="/v1/auth/notp/pending-session",q={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},N={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},W={start:"/v1/auth/webauthn/signup-in/start"},B={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},F="/v1/auth/password/signup",V="/v1/auth/password/signin",H="/v1/auth/password/reset",K="/v1/auth/password/update",J="/v1/auth/password/replace",G="/v1/auth/password/policy",z="/v1/auth/refresh",X="/v1/auth/tenant/select",Q="/v1/auth/logout",Z="/v1/auth/logoutall",Y="/v1/auth/me",tt="/v1/auth/me/history",et="/v1/flow/start",nt="/v1/flow/next";const ot="<region>",it=`https://api.${ot}descope.com`,rt=6e5,st="dct",at=()=>{const t={};return{headers(e){const n="function"==typeof e.entries?Object.fromEntries(e.entries()):e;return t.Headers=JSON.stringify(n),this},body(e){return t.Body=e,this},url(e){return t.Url=e.toString(),this},method(e){return t.Method=e,this},title(e){return t.Title=e,this},status(e){return t.Status=e,this},build:()=>Object.keys(t).flatMap((e=>t[e]?[`${"Title"!==e?`${e}: `:""}${t[e]}`]:[])).join("\n")}};var lt;!function(t){t.get="GET",t.delete="DELETE",t.post="POST",t.put="PUT",t.patch="PATCH"}(lt||(lt={}));const ct=({path:t,baseUrl:e,queryParams:n,projectId:o})=>{const i=o.slice(1,-27);e=e.replace(ot,i?i+".":"");let r=t?`${e.replace(/\/$/,"")}/${null==t?void 0:t.replace(/^\//,"")}`:e;if(n){r=`${r}?`;const t=Object.keys(n);t.forEach(((e,o)=>{r=`${r}${e}=${n[e]}${o===t.length-1?"":"&"}`}))}return r},dt=(...t)=>new Headers(t.reduce(((t,e)=>{const n=(t=>Array.isArray(t)?t:t instanceof Headers?Array.from(t.entries()):t?Object.entries(t):[])(e);return n.reduce(((e,[n,o])=>(t[n]=o,t)),t),t}),{})),ut={"Content-Type":"application/json"},ht=(t,e="")=>{let n=t;return e&&(n=n+":"+e),{Authorization:`Bearer ${n}`}},pt=t=>{try{t=JSON.parse(t)}catch(t){return!1}return"object"==typeof t&&null!==t},ft=({baseUrl:t,projectId:e,baseConfig:n,logger:o,hooks:i,cookiePolicy:r,fetch:s})=>{const a=((t,e)=>{const n=(t=>async(...e)=>{const n=await t(...e),o=await n.text();return n.text=()=>Promise.resolve(o),n.json=()=>Promise.resolve(JSON.parse(o)),n.clone=()=>n,n})(e||fetch);return n||null==t||t.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"),t?async(...e)=>{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");t.log((t=>at().title("Request").url(t[0]).method(t[1].method).headers(t[1].headers).body(t[1].body).build())(e));const o=await n(...e);return t[o.ok?"log":"error"](await(async t=>{const e=await t.text();return at().title("Response").url(t.url.toString()).status(`${t.status} ${t.statusText}`).headers(t.headers).body(e).build()})(o)),o}:n})(o,s),l=async o=>{var s;const l=(null==i?void 0:i.beforeRequest)?i.beforeRequest(o):o,{path:c,body:d,headers:u,queryParams:h,method:p,token:f}=l,g=(t=>void 0===t?void 0:JSON.stringify(t))(d),v={headers:dt(ht(e,f),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.24.0"},(null==n?void 0:n.baseHeaders)||{},pt(g)?ut:{},u),method:p,body:g};null!==r&&(v.credentials=r||"include");const m=await a(ct({path:c,baseUrl:t,queryParams:h,projectId:e}),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 t=await m.json(),e=((null===(s=m.headers)||void 0===s?void 0:s.get("set-cookie"))||"").split(";").reduce(((t,e)=>{const[n,o]=e.split("=");return Object.assign(Object.assign({},t),{[n.trim()]:o})}),{}),n=Object.assign(Object.assign({},m),{json:()=>Promise.resolve(t),cookies:e});return n.clone=()=>n,i.transformResponse(n)}return m};return{get:(t,{headers:e,queryParams:n,token:o}={})=>l({path:t,headers:e,queryParams:n,body:void 0,method:lt.get,token:o}),post:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:lt.post,token:i}),patch:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:lt.patch,token:i}),put:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:lt.put,token:i}),delete:(t,{headers:e,queryParams:n,token:o}={})=>l({path:t,headers:e,queryParams:n,body:void 0,method:lt.delete,token:o}),hooks:i,buildUrl:(n,o)=>ct({projectId:e,baseUrl:t,path:n,queryParams:o})}};var gt=429;function vt(t,e,n){var o;let i=mt(t);if(e){if(!(null==i?void 0:i.tenants)&&(null==i?void 0:i[st])===e)return(null==i?void 0:i[n])||[];i=null===(o=null==i?void 0:i.tenants)||void 0===o?void 0:o[e]}const r=null==i?void 0:i[n];return Array.isArray(r)?r:[]}function mt(t){if("string"!=typeof t||!t)throw new Error("Invalid token provided");return l(t)}function wt(t){const{exp:e}=mt(t);return(new Date).getTime()/1e3>e}function bt(t){let e=mt(t);const n=Object.keys(null==e?void 0:e.tenants);return Array.isArray(n)?n:[]}function yt(t,e){return vt(t,e,"permissions")}function It(t,e){return vt(t,e,"roles")}const kt=(...t)=>t.join("/").replace(/\/{2,}/g,"/");async function jt(t,e){var n;const o=await t,i={code:o.status,ok:o.ok,response:o},r=await o.clone().json();return o.ok?i.data=e?e(r):r:(i.error=r,o.status===gt&&Object.assign(i.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),i}const Ct=(t,e)=>(n=e)=>e=>!t(e)&&n.replace("{val}",e),St=(...t)=>({validate:e=>(t.forEach((t=>{const n=t(e);if(n)throw new Error(n)})),!0)}),Ot=t=>e=>t.test(e),At=Ot(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),xt=Ot(/^\+[1-9]{1}[0-9]{3,14}$/),Ut=Ct(At,'"{val}" is not a valid email'),Et=Ct(xt,'"{val}" is not a valid phone number'),Tt=Ct((1,t=>t.length>=1),"Minimum length is 1");const Lt=Ct((t=>"string"==typeof t),"Input is not a string"),_t=Ct((t=>void 0===t),"Input is defined"),Rt=(Pt=[Lt(),_t()],"Input is not a string or undefined",(t="Input is not a string or undefined")=>e=>{const n=Pt.filter((t=>t(e)));return!(n.length<Pt.length)&&(t?t.replace("{val}",e):n.join(" OR "))});var Pt;const $t=(...t)=>e=>(...n)=>(t.forEach(((t,e)=>St(...t).validate(n[e]))),e(...n)),Mt=t=>[Lt(`"${t}" must be a string`)],Dt=t=>[Lt(`"${t}" must be a string`),Tt(`"${t}" must not be empty`)],qt=t=>[Lt(`"${t}" must be a string`),Ut()],Nt=t=>[Lt(`"${t}" must be a string`),Et()],Wt=$t(Dt("accessKey")),Bt=t=>({exchange:Wt(((e,n)=>jt(t.post(c,{loginOptions:n},{token:e}))))}),Ft=(t,e,n)=>(e.forEach((e=>{const o=e.split(".");let i=o.shift(),r=t;for(;o.length>0;){if(r=r[i],!i||!r)throw Error(`Invalid path "${e}", "${i}" is missing or has no value`);i=o.shift()}if("function"!=typeof r[i])throw Error(`"${e}" is not a function`);const s=r[i];r[i]=n(s)})),t),Vt=({pollingIntervalMs:t=1e3,timeoutMs:e=6e5}={})=>({pollingIntervalMs:Math.max(t||1e3,1e3),timeoutMs:Math.min(e||rt,rt)});var Ht,Kt;!function(t){t.sms="sms",t.voice="voice",t.whatsapp="whatsapp"}(Ht||(Ht={})),function(t){t.email="email"}(Kt||(Kt={}));const Jt=Object.assign(Object.assign({},Ht),Kt);var Gt;!function(t){t.waiting="waiting",t.running="running",t.completed="completed",t.failed="failed"}(Gt||(Gt={}));const zt=Dt("loginId"),Xt=$t(Dt("token")),Qt=$t(zt),Zt=$t(Dt("pendingRef")),Yt=$t(zt,qt("email")),te=t=>({verify:Xt((e=>jt(t.post(y,{token:e})))),signIn:Qt(((e,n,o,i)=>jt(t.post(kt(I,Jt.email),{loginId:e,URI:n,loginOptions:o},{token:i})))),signUpOrIn:Qt(((e,n,o)=>jt(t.post(kt(S,Jt.email),{loginId:e,URI:n,loginOptions:o})))),signUp:Qt(((e,n,o,i)=>jt(t.post(kt(k,Jt.email),{loginId:e,URI:n,user:o,loginOptions:i})))),waitForSession:Zt(((e,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=Vt(n);let s;const a=setInterval((async()=>{const n=await t.post(j,{pendingRef:e});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(jt(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:Yt(((e,n,o,i,r)=>jt(t.post(C.email,Object.assign({loginId:e,email:n,URI:o},r),{token:i}))))}}),ee=$t(Dt("flowId")),ne=$t(Dt("executionId"),Dt("stepId"),Dt("interactionId")),oe=t=>({start:ee(((e,n,o,i,r,s,a)=>jt(t.post(et,{flowId:e,options:n,conditionInteractionId:o,interactionId:i,version:r,componentsVersion:s,input:a})))),next:ne(((e,n,o,i,r,s)=>jt(t.post(nt,{executionId:e,stepId:n,interactionId:o,version:i,componentsVersion:r,input:s}))))}),ie=Dt("loginId"),re=$t(Dt("token")),se=$t(ie),ae=$t(ie,Nt("phone")),le=$t(ie,qt("email")),ce=Object.keys(Jt).filter((t=>t!==Ht.voice)),de=t=>({verify:re((e=>jt(t.post(g,{token:e})))),signIn:ce.reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:se(((e,o,i,r)=>jt(t.post(kt(v,n),{loginId:e,URI:o,loginOptions:i},{token:r}))))})),{}),signUp:ce.reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:se(((e,o,i,r)=>jt(t.post(kt(m,n),{loginId:e,URI:o,user:i,loginOptions:r}))))})),{}),signUpOrIn:ce.reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:se(((e,o,i)=>jt(t.post(kt(b,n),{loginId:e,URI:o,loginOptions:i}))))})),{}),update:{email:le(((e,n,o,i,r)=>jt(t.post(w.email,Object.assign({loginId:e,email:n,URI:o},r),{token:i})))),phone:Object.keys(Ht).filter((t=>t!==Ht.voice)).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ae(((e,o,i,r,s)=>jt(t.post(kt(w.phone,n),Object.assign({loginId:e,phone:o,URI:i},s),{token:r}))))})),{})}});var ue;!function(t){t.facebook="facebook",t.github="github",t.google="google",t.microsoft="microsoft",t.gitlab="gitlab",t.apple="apple",t.discord="discord",t.linkedin="linkedin",t.slack="slack"}(ue||(ue={}));const he=$t(Dt("code")),pe=t=>({start:Object.assign(((e,n,o,i)=>jt(t.post(O,o||{},{queryParams:Object.assign({provider:e},n&&{redirectURL:n}),token:i}))),Object.keys(ue).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:(e,o,i)=>jt(t.post(O,o||{},{queryParams:Object.assign({provider:n},e&&{redirectURL:e}),token:i}))})),{})),exchange:he((e=>jt(t.post(A,{code:e})))),startNative:(e,n,o)=>jt(t.post(x,{provider:e,loginOptions:n,implicit:o})),finishNative:(e,n,o,i,r)=>jt(t.post(U,{provider:e,stateId:n,user:o,code:i,idToken:r}))}),fe=Dt("loginId"),ge=$t(fe,Dt("code")),ve=$t(fe),me=$t(fe,Nt("phone")),we=$t(fe,qt("email")),be=t=>({verify:Object.keys(Jt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ge(((e,o)=>jt(t.post(kt(d,n),{code:o,loginId:e}))))})),{}),signIn:Object.keys(Jt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ve(((e,o,i)=>jt(t.post(kt(u,n),{loginId:e,loginOptions:o},{token:i}))))})),{}),signUp:Object.keys(Jt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ve(((e,o,i)=>jt(t.post(kt(h,n),{loginId:e,user:o,loginOptions:i}))))})),{}),signUpOrIn:Object.keys(Jt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ve(((e,o)=>jt(t.post(kt(f,n),{loginId:e,loginOptions:o}))))})),{}),update:{email:we(((e,n,o,i)=>jt(t.post(p.email,Object.assign({loginId:e,email:n},i),{token:o})))),phone:Object.keys(Ht).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:me(((e,o,i,r)=>jt(t.post(kt(p.phone,n),Object.assign({loginId:e,phone:o},r),{token:i}))))})),{})}}),ye=$t(Dt("tenant")),Ie=$t(Dt("code")),ke=t=>({start:ye(((e,n,o,i)=>jt(t.post(E,o||{},{queryParams:{tenant:e,redirectURL:n},token:i})))),exchange:Ie((e=>jt(t.post(T,{code:e}))))}),je=Dt("loginId"),Ce=$t(je,Dt("code")),Se=$t(je),Oe=$t(je),Ae=t=>({signUp:Se(((e,n)=>jt(t.post(_,{loginId:e,user:n})))),verify:Ce(((e,n,o,i)=>jt(t.post(L,{loginId:e,code:n,loginOptions:o},{token:i})))),update:Oe(((e,n)=>jt(t.post(R,{loginId:e},{token:n}))))}),xe=Dt("loginId"),Ue=Dt("newPassword"),Ee=$t(xe,Dt("password")),Te=$t(xe),Le=$t(xe,Ue),_e=$t(xe,Dt("oldPassword"),Ue),Re=t=>({signUp:Ee(((e,n,o,i)=>jt(t.post(F,{loginId:e,password:n,user:o,loginOptions:i})))),signIn:Ee(((e,n,o)=>jt(t.post(V,{loginId:e,password:n,loginOptions:o})))),sendReset:Te(((e,n,o)=>jt(t.post(H,{loginId:e,redirectUrl:n,templateOptions:o})))),update:Le(((e,n,o)=>jt(t.post(K,{loginId:e,newPassword:n},{token:o})))),replace:_e(((e,n,o)=>jt(t.post(J,{loginId:e,oldPassword:n,newPassword:o})))),policy:()=>jt(t.get(G))}),Pe=Mt("loginId"),$e=Dt("loginId"),Me=Dt("origin"),De=$t($e,Me,Dt("name")),qe=$t($e,Me),Ne=$t(Pe,Me),We=$t($e,Me,Dt("token")),Be=$t(Dt("transactionId"),Dt("response")),Fe=t=>({signUp:{start:De(((e,n,o)=>jt(t.post(q.start,{user:{loginId:e,name:o},origin:n})))),finish:Be(((e,n)=>jt(t.post(q.finish,{transactionId:e,response:n}))))},signIn:{start:Ne(((e,n,o,i)=>jt(t.post(N.start,{loginId:e,origin:n,loginOptions:o},{token:i})))),finish:Be(((e,n)=>jt(t.post(N.finish,{transactionId:e,response:n}))))},signUpOrIn:{start:qe(((e,n)=>jt(t.post(W.start,{loginId:e,origin:n}))))},update:{start:We(((e,n,o)=>jt(t.post(B.start,{loginId:e,origin:n},{token:o})))),finish:Be(((e,n)=>jt(t.post(B.finish,{transactionId:e,response:n}))))}}),Ve=Mt("loginId"),He=$t(Ve),Ke=$t(Dt("pendingRef")),Je=t=>({signUpOrIn:He(((e,n)=>jt(t.post(M,{loginId:e,loginOptions:n})))),signUp:He(((e,n,o)=>jt(t.post($,{loginId:e,user:n,loginOptions:o})))),signIn:He(((e,n,o)=>jt(t.post(P,{loginId:e,loginOptions:n},{token:o})))),waitForSession:Ke(((e,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=Vt(n);let s;const a=setInterval((async()=>{const n=await t.post(D,{pendingRef:e});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(jt(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),Ge=$t(Dt("token")),ze=$t([Rt('"token" must be string or undefined')]);var Xe,Qe=$t([("projectId",Xe=Dt("projectId"),Ct(((t,e)=>n=>St(...e).validate(((t,e,n)=>{const o=(Array.isArray(e)?e.join("."):String(e)).replace(/\[\\?("|')?(\w|d)+\\?("|')?\]/g,((t,e,n)=>"."+n)).split("."),i=o.length;let r=0,s=t===Object(t)?t:void 0;for(;null!=s&&r<i;)s=s[o[r++]];return r&&r===i&&void 0!==s?s:void 0})(n,t)))("projectId",Xe))())])((t=>{var e;return(({projectId:t,logger:e,baseUrl:n,hooks:o,cookiePolicy:i,baseHeaders:r={},fetch:s})=>{return a=ft({baseUrl:n||it,projectId:t,logger:e,hooks:o,cookiePolicy:i,baseConfig:{baseHeaders:r},fetch:s}),{accessKey:Bt(a),otp:be(a),magicLink:de(a),enchantedLink:te(a),oauth:pe(a),saml:ke(a),totp:Ae(a),notp:Je(a),webauthn:Fe(a),password:Re(a),flow:oe(a),refresh:ze((t=>jt(a.post(z,{},{token:t})))),selectTenant:$t([Lt("tenantId")],[Rt('"token" must be string or undefined')])(((t,e)=>jt(a.post(X,{tenant:t},{token:e})))),logout:ze((t=>jt(a.post(Q,{},{token:t})))),logoutAll:ze((t=>jt(a.post(Z,{},{token:t})))),me:ze((t=>jt(a.get(Y,{token:t})))),history:ze((t=>jt(a.get(tt,{token:t})))),isJwtExpired:Ge(wt),getTenants:Ge(bt),getJwtPermissions:Ge(yt),getJwtRoles:Ge(It),httpClient:a};var a})(Object.assign(Object.assign({},t),{hooks:{beforeRequest:e=>{var n;const o=[].concat((null===(n=t.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==o?void 0:o.reduce(((t,e)=>e(t)),e)},afterRequest:async(e,n)=>{var o;const i=[].concat((null===(o=t.hooks)||void 0===o?void 0:o.afterRequest)||[]);0!=i.length&&(await Promise.allSettled(null==i?void 0:i.map((t=>t(e,null==n?void 0:n.clone()))))).forEach((e=>{var n;return"rejected"===e.status&&(null===(n=t.logger)||void 0===n?void 0:n.error(e.reason))}))},transformResponse:null===(e=t.hooks)||void 0===e?void 0:e.transformResponse}}))})),Ze=Object.assign(Qe,{DeliveryMethods:Jt});
|
|
1
|
+
!function(){"use strict";var t=function(){return t=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},t.apply(this,arguments)};function e(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(t);i<o.length;i++)e.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(t,o[i])&&(n[o[i]]=t[o[i]])}return n}function n(t,e,n,o){return new(n||(n=Promise))((function(i,r){function s(t){try{l(o.next(t))}catch(t){r(t)}}function a(t){try{l(o.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((o=o.apply(t,e||[])).next())}))}function o(t,e,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(t):o?o.value:e.get(t)}function i(t,e,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 e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(t,n):i?i.value=n:e.set(t,n),n}function r(t){this.message=t}"function"==typeof SuppressedError&&SuppressedError,r.prototype=new Error,r.prototype.name="InvalidCharacterError";var s="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new r("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,o,i=0,s=0,a="";o=e.charAt(s++);~o&&(n=i%4?64*n+o:o,i++%4)?a+=String.fromCharCode(255&n>>(-2*i&6)):0)o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);return a};function a(t){this.message=t}function l(t,e){if("string"!=typeof t)throw new a("Invalid token specified");var n=!0===(e=e||{}).header?0:1;try{return JSON.parse(function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(s(t).replace(/(.)/g,(function(t,e){var n=e.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(e)}catch(t){return s(e)}}(t.split(".")[n]))}catch(t){throw new a("Invalid token specified: "+t.message)}}a.prototype=new Error,a.prototype.name="InvalidTokenError";var c="/v1/auth/accesskey/exchange",d="/v1/auth/otp/verify",u="/v1/auth/otp/signin",h="/v1/auth/otp/signup",p={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},f="/v1/auth/otp/signup-in",g="/v1/auth/magiclink/verify",v="/v1/auth/magiclink/signin",m="/v1/auth/magiclink/signup",w={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},b="/v1/auth/magiclink/signup-in",y="/v1/auth/enchantedlink/verify",I="/v1/auth/enchantedlink/signin",k="/v1/auth/enchantedlink/signup",j="/v1/auth/enchantedlink/pending-session",C={email:"/v1/auth/enchantedlink/update/email"},O="/v1/auth/enchantedlink/signup-in",S="/v1/auth/oauth/authorize",x="/v1/auth/oauth/exchange",A="v1/auth/oauth/native/start",U="v1/auth/oauth/native/finish",E="/v1/auth/saml/authorize",T="/v1/auth/saml/exchange",L="/v1/auth/totp/verify",_="/v1/auth/totp/signup",R="/v1/auth/totp/update",P="/v1/auth/notp/whatsapp/signin",$="/v1/auth/notp/whatsapp/signup",M="/v1/auth/notp/whatsapp/signup-in",D="/v1/auth/notp/pending-session",q={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},N={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},W={start:"/v1/auth/webauthn/signup-in/start"},F={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},B="/v1/auth/password/signup",V="/v1/auth/password/signin",K="/v1/auth/password/reset",H="/v1/auth/password/update",J="/v1/auth/password/replace",G="/v1/auth/password/policy",z="/v1/auth/refresh",X="/v1/auth/tenant/select",Q="/v1/auth/logout",Z="/v1/auth/logoutall",Y="/v1/auth/me",tt="/v1/auth/me/history",et="/v1/flow/start",nt="/v1/flow/next";const ot="<region>",it=`https://api.${ot}descope.com`,rt=6e5,st="dct",at=()=>{const t={};return{headers(e){const n="function"==typeof e.entries?Object.fromEntries(e.entries()):e;return t.Headers=JSON.stringify(n),this},body(e){return t.Body=e,this},url(e){return t.Url=e.toString(),this},method(e){return t.Method=e,this},title(e){return t.Title=e,this},status(e){return t.Status=e,this},build:()=>Object.keys(t).flatMap((e=>t[e]?[`${"Title"!==e?`${e}: `:""}${t[e]}`]:[])).join("\n")}};var lt;!function(t){t.get="GET",t.delete="DELETE",t.post="POST",t.put="PUT",t.patch="PATCH"}(lt||(lt={}));const ct=({path:t,baseUrl:e,queryParams:n,projectId:o})=>{const i=o.slice(1,-27);e=e.replace(ot,i?i+".":"");let r=t?`${e.replace(/\/$/,"")}/${null==t?void 0:t.replace(/^\//,"")}`:e;if(n){r=`${r}?`;const t=Object.keys(n);t.forEach(((e,o)=>{r=`${r}${e}=${n[e]}${o===t.length-1?"":"&"}`}))}return r},dt=(...t)=>new Headers(t.reduce(((t,e)=>{const n=(t=>Array.isArray(t)?t:t instanceof Headers?Array.from(t.entries()):t?Object.entries(t):[])(e);return n.reduce(((e,[n,o])=>(t[n]=o,t)),t),t}),{})),ut={"Content-Type":"application/json"},ht=(t,e="")=>{let n=t;return e&&(n=n+":"+e),{Authorization:`Bearer ${n}`}},pt=t=>{try{t=JSON.parse(t)}catch(t){return!1}return"object"==typeof t&&null!==t},ft=({baseUrl:t,projectId:e,baseConfig:n,logger:o,hooks:i,cookiePolicy:r,fetch:s})=>{const a=((t,e)=>{const n=(t=>async(...e)=>{const n=await t(...e),o=await n.text();return n.text=()=>Promise.resolve(o),n.json=()=>Promise.resolve(JSON.parse(o)),n.clone=()=>n,n})(e||fetch);return n||null==t||t.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"),t?async(...e)=>{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");t.log((t=>at().title("Request").url(t[0]).method(t[1].method).headers(t[1].headers).body(t[1].body).build())(e));const o=await n(...e);return t[o.ok?"log":"error"](await(async t=>{const e=await t.text();return at().title("Response").url(t.url.toString()).status(`${t.status} ${t.statusText}`).headers(t.headers).body(e).build()})(o)),o}:n})(o,s),l=async o=>{var s;const l=(null==i?void 0:i.beforeRequest)?i.beforeRequest(o):o,{path:c,body:d,headers:u,queryParams:h,method:p,token:f}=l,g=(t=>void 0===t?void 0:JSON.stringify(t))(d),v={headers:dt(ht(e,f),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.24.0"},(null==n?void 0:n.baseHeaders)||{},pt(g)?ut:{},u),method:p,body:g};null!==r&&(v.credentials=r||"include");const m=await a(ct({path:c,baseUrl:t,queryParams:h,projectId:e}),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 t=await m.json(),e=((null===(s=m.headers)||void 0===s?void 0:s.get("set-cookie"))||"").split(";").reduce(((t,e)=>{const[n,o]=e.split("=");return Object.assign(Object.assign({},t),{[n.trim()]:o})}),{}),n=Object.assign(Object.assign({},m),{json:()=>Promise.resolve(t),cookies:e});return n.clone=()=>n,i.transformResponse(n)}return m};return{get:(t,{headers:e,queryParams:n,token:o}={})=>l({path:t,headers:e,queryParams:n,body:void 0,method:lt.get,token:o}),post:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:lt.post,token:i}),patch:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:lt.patch,token:i}),put:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:lt.put,token:i}),delete:(t,{headers:e,queryParams:n,token:o}={})=>l({path:t,headers:e,queryParams:n,body:void 0,method:lt.delete,token:o}),hooks:i,buildUrl:(n,o)=>ct({projectId:e,baseUrl:t,path:n,queryParams:o})}};var gt=429;function vt(t,e,n){var o;let i=mt(t);if(e){if(!(null==i?void 0:i.tenants)&&(null==i?void 0:i[st])===e)return(null==i?void 0:i[n])||[];i=null===(o=null==i?void 0:i.tenants)||void 0===o?void 0:o[e]}const r=null==i?void 0:i[n];return Array.isArray(r)?r:[]}function mt(t){if("string"!=typeof t||!t)throw new Error("Invalid token provided");return l(t)}function wt(t){const{exp:e}=mt(t);return(new Date).getTime()/1e3>e}function bt(t){let e=mt(t);const n=Object.keys(null==e?void 0:e.tenants);return Array.isArray(n)?n:[]}function yt(t,e){return vt(t,e,"permissions")}function It(t,e){return vt(t,e,"roles")}const kt=(...t)=>t.join("/").replace(/\/{2,}/g,"/");async function jt(t,e){var n;const o=await t,i={code:o.status,ok:o.ok,response:o},r=await o.clone().json();return o.ok?i.data=e?e(r):r:(i.error=r,o.status===gt&&Object.assign(i.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),i}const Ct=(t,e)=>(n=e)=>e=>!t(e)&&n.replace("{val}",e),Ot=(...t)=>({validate:e=>(t.forEach((t=>{const n=t(e);if(n)throw new Error(n)})),!0)}),St=t=>e=>t.test(e),xt=St(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),At=St(/^\+[1-9]{1}[0-9]{3,14}$/),Ut=Ct(xt,'"{val}" is not a valid email'),Et=Ct(At,'"{val}" is not a valid phone number'),Tt=Ct((t=>t.length>=1),"Minimum length is 1");const Lt=Ct((t=>"string"==typeof t),"Input is not a string"),_t=Ct((t=>void 0===t),"Input is defined"),Rt=(Pt=[Lt(),_t()],(t="Input is not a string or undefined")=>e=>{const n=Pt.filter((t=>t(e)));return!(n.length<Pt.length)&&(t?t.replace("{val}",e):n.join(" OR "))});var Pt;const $t=(...t)=>e=>(...n)=>(t.forEach(((t,e)=>Ot(...t).validate(n[e]))),e(...n)),Mt=t=>[Lt(`"${t}" must be a string`)],Dt=t=>[Lt(`"${t}" must be a string`),Tt(`"${t}" must not be empty`)],qt=t=>[Lt(`"${t}" must be a string`),Ut()],Nt=t=>[Lt(`"${t}" must be a string`),Et()],Wt=$t(Dt("accessKey")),Ft=t=>({exchange:Wt(((e,n)=>jt(t.post(c,{loginOptions:n},{token:e}))))}),Bt=(t,e,n)=>(e.forEach((e=>{const o=e.split(".");let i=o.shift(),r=t;for(;o.length>0;){if(r=r[i],!i||!r)throw Error(`Invalid path "${e}", "${i}" is missing or has no value`);i=o.shift()}if("function"!=typeof r[i])throw Error(`"${e}" is not a function`);const s=r[i];r[i]=n(s)})),t),Vt=({pollingIntervalMs:t=1e3,timeoutMs:e=6e5}={})=>({pollingIntervalMs:Math.max(t||1e3,1e3),timeoutMs:Math.min(e||rt,rt)});var Kt,Ht;!function(t){t.sms="sms",t.voice="voice",t.whatsapp="whatsapp"}(Kt||(Kt={})),function(t){t.email="email"}(Ht||(Ht={}));const Jt=Object.assign(Object.assign({},Kt),Ht);var Gt;!function(t){t.waiting="waiting",t.running="running",t.completed="completed",t.failed="failed"}(Gt||(Gt={}));const zt=Dt("loginId"),Xt=$t(Dt("token")),Qt=$t(zt),Zt=$t(Dt("pendingRef")),Yt=$t(zt,qt("email")),te=t=>({verify:Xt((e=>jt(t.post(y,{token:e})))),signIn:Qt(((e,n,o,i)=>jt(t.post(kt(I,Jt.email),{loginId:e,URI:n,loginOptions:o},{token:i})))),signUpOrIn:Qt(((e,n,o)=>jt(t.post(kt(O,Jt.email),{loginId:e,URI:n,loginOptions:o})))),signUp:Qt(((e,n,o,i)=>jt(t.post(kt(k,Jt.email),{loginId:e,URI:n,user:o,loginOptions:i})))),waitForSession:Zt(((e,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=Vt(n);let s;const a=setInterval((async()=>{const n=await t.post(j,{pendingRef:e});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(jt(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:Yt(((e,n,o,i,r)=>jt(t.post(C.email,Object.assign({loginId:e,email:n,URI:o},r),{token:i}))))}}),ee=$t(Dt("flowId")),ne=$t(Dt("executionId"),Dt("stepId"),Dt("interactionId")),oe=t=>({start:ee(((e,n,o,i,r,s,a)=>jt(t.post(et,{flowId:e,options:n,conditionInteractionId:o,interactionId:i,version:r,componentsVersion:s,input:a})))),next:ne(((e,n,o,i,r,s)=>jt(t.post(nt,{executionId:e,stepId:n,interactionId:o,version:i,componentsVersion:r,input:s}))))}),ie=Dt("loginId"),re=$t(Dt("token")),se=$t(ie),ae=$t(ie,Nt("phone")),le=$t(ie,qt("email")),ce=Object.keys(Jt).filter((t=>t!==Kt.voice)),de=t=>({verify:re((e=>jt(t.post(g,{token:e})))),signIn:ce.reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:se(((e,o,i,r)=>jt(t.post(kt(v,n),{loginId:e,URI:o,loginOptions:i},{token:r}))))})),{}),signUp:ce.reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:se(((e,o,i,r)=>jt(t.post(kt(m,n),{loginId:e,URI:o,user:i,loginOptions:r}))))})),{}),signUpOrIn:ce.reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:se(((e,o,i)=>jt(t.post(kt(b,n),{loginId:e,URI:o,loginOptions:i}))))})),{}),update:{email:le(((e,n,o,i,r)=>jt(t.post(w.email,Object.assign({loginId:e,email:n,URI:o},r),{token:i})))),phone:Object.keys(Kt).filter((t=>t!==Kt.voice)).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ae(((e,o,i,r,s)=>jt(t.post(kt(w.phone,n),Object.assign({loginId:e,phone:o,URI:i},s),{token:r}))))})),{})}});var ue;!function(t){t.facebook="facebook",t.github="github",t.google="google",t.microsoft="microsoft",t.gitlab="gitlab",t.apple="apple",t.discord="discord",t.linkedin="linkedin",t.slack="slack"}(ue||(ue={}));const he=$t(Dt("code")),pe=t=>({start:Object.assign(((e,n,o,i)=>jt(t.post(S,o||{},{queryParams:Object.assign({provider:e},n&&{redirectURL:n}),token:i}))),Object.keys(ue).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:(e,o,i)=>jt(t.post(S,o||{},{queryParams:Object.assign({provider:n},e&&{redirectURL:e}),token:i}))})),{})),exchange:he((e=>jt(t.post(x,{code:e})))),startNative:(e,n,o)=>jt(t.post(A,{provider:e,loginOptions:n,implicit:o})),finishNative:(e,n,o,i,r)=>jt(t.post(U,{provider:e,stateId:n,user:o,code:i,idToken:r}))}),fe=Dt("loginId"),ge=$t(fe,Dt("code")),ve=$t(fe),me=$t(fe,Nt("phone")),we=$t(fe,qt("email")),be=t=>({verify:Object.keys(Jt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ge(((e,o)=>jt(t.post(kt(d,n),{code:o,loginId:e}))))})),{}),signIn:Object.keys(Jt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ve(((e,o,i)=>jt(t.post(kt(u,n),{loginId:e,loginOptions:o},{token:i}))))})),{}),signUp:Object.keys(Jt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ve(((e,o,i)=>jt(t.post(kt(h,n),{loginId:e,user:o,loginOptions:i}))))})),{}),signUpOrIn:Object.keys(Jt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:ve(((e,o)=>jt(t.post(kt(f,n),{loginId:e,loginOptions:o}))))})),{}),update:{email:we(((e,n,o,i)=>jt(t.post(p.email,Object.assign({loginId:e,email:n},i),{token:o})))),phone:Object.keys(Kt).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:me(((e,o,i,r)=>jt(t.post(kt(p.phone,n),Object.assign({loginId:e,phone:o},r),{token:i}))))})),{})}}),ye=$t(Dt("tenant")),Ie=$t(Dt("code")),ke=t=>({start:ye(((e,n,o,i)=>jt(t.post(E,o||{},{queryParams:{tenant:e,redirectURL:n},token:i})))),exchange:Ie((e=>jt(t.post(T,{code:e}))))}),je=Dt("loginId"),Ce=$t(je,Dt("code")),Oe=$t(je),Se=$t(je),xe=t=>({signUp:Oe(((e,n)=>jt(t.post(_,{loginId:e,user:n})))),verify:Ce(((e,n,o,i)=>jt(t.post(L,{loginId:e,code:n,loginOptions:o},{token:i})))),update:Se(((e,n)=>jt(t.post(R,{loginId:e},{token:n}))))}),Ae=Dt("loginId"),Ue=Dt("newPassword"),Ee=$t(Ae,Dt("password")),Te=$t(Ae),Le=$t(Ae,Ue),_e=$t(Ae,Dt("oldPassword"),Ue),Re=t=>({signUp:Ee(((e,n,o,i)=>jt(t.post(B,{loginId:e,password:n,user:o,loginOptions:i})))),signIn:Ee(((e,n,o)=>jt(t.post(V,{loginId:e,password:n,loginOptions:o})))),sendReset:Te(((e,n,o)=>jt(t.post(K,{loginId:e,redirectUrl:n,templateOptions:o})))),update:Le(((e,n,o)=>jt(t.post(H,{loginId:e,newPassword:n},{token:o})))),replace:_e(((e,n,o)=>jt(t.post(J,{loginId:e,oldPassword:n,newPassword:o})))),policy:()=>jt(t.get(G))}),Pe=Mt("loginId"),$e=Dt("loginId"),Me=Dt("origin"),De=$t($e,Me,Dt("name")),qe=$t($e,Me),Ne=$t(Pe,Me),We=$t($e,Me,Dt("token")),Fe=$t(Dt("transactionId"),Dt("response")),Be=t=>({signUp:{start:De(((e,n,o)=>jt(t.post(q.start,{user:{loginId:e,name:o},origin:n})))),finish:Fe(((e,n)=>jt(t.post(q.finish,{transactionId:e,response:n}))))},signIn:{start:Ne(((e,n,o,i)=>jt(t.post(N.start,{loginId:e,origin:n,loginOptions:o},{token:i})))),finish:Fe(((e,n)=>jt(t.post(N.finish,{transactionId:e,response:n}))))},signUpOrIn:{start:qe(((e,n)=>jt(t.post(W.start,{loginId:e,origin:n}))))},update:{start:We(((e,n,o)=>jt(t.post(F.start,{loginId:e,origin:n},{token:o})))),finish:Fe(((e,n)=>jt(t.post(F.finish,{transactionId:e,response:n}))))}}),Ve=Mt("loginId"),Ke=$t(Ve),He=$t(Dt("pendingRef")),Je=t=>({signUpOrIn:Ke(((e,n)=>jt(t.post(M,{loginId:e,loginOptions:n})))),signUp:Ke(((e,n,o)=>jt(t.post($,{loginId:e,user:n,loginOptions:o})))),signIn:Ke(((e,n,o)=>jt(t.post(P,{loginId:e,loginOptions:n},{token:o})))),waitForSession:He(((e,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=Vt(n);let s;const a=setInterval((async()=>{const n=await t.post(D,{pendingRef:e});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(jt(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),Ge=$t(Dt("token")),ze=$t([Rt('"token" must be string or undefined')]);var Xe,Qe=$t([(Xe=Dt("projectId"),Ct(((t,e)=>n=>Ot(...e).validate(((t,e)=>{const n=(Array.isArray(e)?e.join("."):String(e)).replace(/\[\\?("|')?(\w|d)+\\?("|')?\]/g,((t,e,n)=>"."+n)).split("."),o=n.length;let i=0,r=t===Object(t)?t:void 0;for(;null!=r&&i<o;)r=r[n[i++]];return i&&i===o&&void 0!==r?r:void 0})(n,t)))("projectId",Xe))())])((t=>{var e;return(({projectId:t,logger:e,baseUrl:n,hooks:o,cookiePolicy:i,baseHeaders:r={},fetch:s})=>{return a=ft({baseUrl:n||it,projectId:t,logger:e,hooks:o,cookiePolicy:i,baseConfig:{baseHeaders:r},fetch:s}),{accessKey:Ft(a),otp:be(a),magicLink:de(a),enchantedLink:te(a),oauth:pe(a),saml:ke(a),totp:xe(a),notp:Je(a),webauthn:Be(a),password:Re(a),flow:oe(a),refresh:ze((t=>jt(a.post(z,{},{token:t})))),selectTenant:$t([Lt("tenantId")],[Rt('"token" must be string or undefined')])(((t,e)=>jt(a.post(X,{tenant:t},{token:e})))),logout:ze((t=>jt(a.post(Q,{},{token:t})))),logoutAll:ze((t=>jt(a.post(Z,{},{token:t})))),me:ze((t=>jt(a.get(Y,{token:t})))),history:ze((t=>jt(a.get(tt,{token:t})))),isJwtExpired:Ge(wt),getTenants:Ge(bt),getJwtPermissions:Ge(yt),getJwtRoles:Ge(It),httpClient:a};var a})(Object.assign(Object.assign({},t),{hooks:{beforeRequest:e=>{var n;const o=[].concat((null===(n=t.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==o?void 0:o.reduce(((t,e)=>e(t)),e)},afterRequest:async(e,n)=>{var o;const i=[].concat((null===(o=t.hooks)||void 0===o?void 0:o.afterRequest)||[]);0!=i.length&&(await Promise.allSettled(null==i?void 0:i.map((t=>t(e,null==n?void 0:n.clone()))))).forEach((e=>{var n;return"rejected"===e.status&&(null===(n=t.logger)||void 0===n?void 0:n.error(e.reason))}))},transformResponse:null===(e=t.hooks)||void 0===e?void 0:e.transformResponse}}))})),Ze=Object.assign(Qe,{DeliveryMethods:Jt});
|
|
2
2
|
/*! js-cookie v3.0.5 | MIT */
|
|
3
|
-
function Ye(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)t[o]=n[o]}return t}var tn=function t(e,n){function o(t,o,i){if("undefined"!=typeof document){"number"==typeof(i=Ye({},n,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),t=encodeURIComponent(t).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=t+"="+e.write(o,t)+r}}return Object.create({set:o,get:function(t){if("undefined"!=typeof document&&(!arguments.length||t)){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]=e.read(s,a),t===a)break}catch(t){}}return t?o[t]:o}},remove:function(t,e){o(t,"",Ye({},e,{expires:-1}))},withAttributes:function(e){return t(this.converter,Ye({},this.attributes,e))},withConverter:function(e){return t(Ye({},this.converter,e),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(e)}})}({read:function(t){return'"'===t[0]&&(t=t.slice(1,-1)),t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(t){return encodeURIComponent(t).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"});var en={default:"endpoint"},nn="Blocked by CSP",on="The endpoint parameter is not a valid URL",rn="Failed to load the JS script of the agent",sn="9319";function an(t,e){var n,o,i,r,s=[],a=(n=function(t){var e=function(t,e,n){if(n||2===arguments.length)for(var o,i=0,r=e.length;i<r;i++)!o&&i in e||(o||(o=Array.prototype.slice.call(e,0,i)),o[i]=e[i]);return t.concat(o||Array.prototype.slice.call(e))}([],t,!0);return{current:function(){return e[0]},postpone:function(){var t=e.shift();void 0!==t&&e.push(t)},exclude:function(){e.shift()}}}(t),100,3e3,r=0,o=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,r++))},i=new Set,[n.current(),function(t,e){var r,s=e instanceof Error?e.message:"";if(s===nn||s===on)n.exclude(),r=0;else if(s===sn)n.exclude();else if(s===rn){var a=Date.now()-t.getTime()<50,l=n.current();l&&a&&!i.has(l)&&(i.add(l),r=0),n.postpone()}else n.postpone();var c=n.current();return void 0===c?void 0:[c,null!=r?r:t.getTime()+o()-Date.now()]}]),l=a[0],c=a[1];if(void 0===l)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var d=function(t){var n=new Date,o=function(e){return s.push({url:t,startedAt:n,finishedAt:new Date,error:e})},i=e(t);return i.then((function(){return o()}),o),i.catch((function(t){if(s.length>=5)throw t;var e=c(n,t);if(!e)throw t;var o,i=e[0],r=e[1];return(o=r,new Promise((function(t){return setTimeout(t,o)}))).then((function(){return d(i)}))}))};return d(l).then((function(t){return[t,s]}))}var ln="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",cn=ln;function dn(n){var o;n.scriptUrlPattern;var i=n.token,r=n.apiKey,s=void 0===r?i:r,a=e(n,["scriptUrlPattern","token","apiKey"]),l=null!==(o=function(t,e){return function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(t,e)?t[e]:void 0}(n,"scriptUrlPattern"))&&void 0!==o?o:ln,c=function(){var t=[],e=function(){t.push({time:new Date,state:document.visibilityState})},n=function(t,e,n,o){return t.addEventListener(e,n,o),function(){return t.removeEventListener(e,n,o)}}(document,"visibilitychange",e);return e(),[t,n]}(),d=c[0],u=c[1];return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error("API key required");var t=function(t,e){return(Array.isArray(t)?t:[t]).map((function(t){return function(t,e){var n=encodeURIComponent;return t.replace(/<[^<>]+>/g,(function(t){return"<version>"===t?"3":"<apiKey>"===t?n(e):"<loaderVersion>"===t?n("3.9.9"):t}))}(String(t),e)}))}(l,s);return an(t,un)})).catch((function(t){throw u(),function(t){return t instanceof Error&&t.message===sn?new Error(rn):t}(t)})).then((function(e){var n=e[0],o=e[1];return u(),n.load(t(t({},a),{ldi:{attempts:o,visibilityStates:d}}))}))}function un(t){return function(t,e,n,o){var i,r=document,s="securitypolicyviolation",a=function(e){var n=new URL(t,location.href),o=e.blockedURI;o!==n.href&&o!==n.protocol.slice(0,-1)&&o!==n.origin||(i=e,l())};r.addEventListener(s,a);var l=function(){return r.removeEventListener(s,a)};return null==o||o.then(l,l),Promise.resolve().then(e).then((function(t){return l(),t}),(function(t){return new Promise((function(t){var e=new MessageChannel;e.port1.onmessage=function(){return t()},e.port2.postMessage(null)})).then((function(){if(l(),i)return n(i);throw t}))}))}(t,(function(){return function(t){return new Promise((function(e,n){if(function(t){if(URL.prototype)try{return new URL(t,location.href),!1}catch(t){if(t instanceof Error&&"TypeError"===t.name)return!0;throw t}}(t))throw new Error(on);var o=document.createElement("script"),i=function(){var t;return null===(t=o.parentNode)||void 0===t?void 0:t.removeChild(o)},r=document.head||document.getElementsByTagName("head")[0];o.onload=function(){i(),e()},o.onerror=function(){i(),n(new Error(rn))},o.async=!0,o.src=t,r.appendChild(o)}))}(t)}),(function(){throw new Error(nn)})).then(hn)}function hn(){var t=window,e="__fpjs_p_l_b",n=t[e];if(function(t,e){var n,o=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,t,e);(null==o?void 0:o.configurable)?delete t[e]:o&&!o.writable||(t[e]=void 0)}(t,e),"function"!=typeof(null==n?void 0:n.load))throw new Error(sn);return n}const pn=(t,e)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,o)=>{var i;return n[o]=[].concat((null===(i=t.hooks)||void 0===i?void 0:i[o])||[]).concat((null==e?void 0:e[o])||[]),n}),null!==(n=t.hooks)&&void 0!==n?n:t.hooks={}),t},fn=async t=>{if(!(null==t?void 0:t.ok))return{};const e=await(null==t?void 0:t.clone().json());return(null==e?void 0:e.authInfo)||e||{}},gn=async t=>{const e=await fn(t);return(null==e?void 0:e.user)||((null==e?void 0:e.hasOwnProperty("userId"))?e:void 0)},vn="undefined"!=typeof localStorage,mn=(t,e)=>vn&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(t,e)),wn=t=>vn&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(t)),bn=t=>vn&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(t)),yn=(...t)=>{console.debug(...t)},In="undefined"!=typeof window,kn=Math.pow(2,31)-1,jn="DS",Cn="DSR";function Sn(t=""){return wn(`${t}${Cn}`)||""}function On(t=""){bn(`${t}${Cn}`),bn(`${t}${jn}`),tn.remove(jn)}const An=In&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",xn="fp",Un=(t=!1)=>{const e=localStorage.getItem(xn);if(!e)return null;const n=JSON.parse(e);return(new Date).getTime()>n.expiry&&!t?null:n.value},En=async(t,e=An)=>{try{if(Un())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(e);o.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const i=new URL(e);i.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const r=i.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=dn({apiKey:t,endpoint:[o.toString(),en],scriptUrlPattern:[r,cn]}),a=await s,{requestId:l}=await a.get({linkedId:n}),c=((t,e)=>({vsid:t,vrid:e}))(n,l);(t=>{const e={value:t,expiry:(new Date).getTime()+864e5};localStorage.setItem(xn,JSON.stringify(e))})(c)}catch(t){console.warn("Could not load fingerprint",t)}},Tn=t=>{const e=Un(!0);return e&&t.body&&(t.body.fpData=e),t},Ln="dls_last_user_login_id",_n="dls_last_user_display_name",Rn=()=>wn(Ln),Pn=()=>wn(_n),$n=t=>async(...e)=>{var n;e[1]=e[1]||{};const[,o={}]=e,i=Rn(),r=Pn();return i&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=i,o.lastAuth.name=r),await t(...e)};function Mn(){const t=[];return{pub:e=>{t.forEach((t=>t(e)))},sub:e=>{const n=t.push(e)-1;return()=>t.splice(n,1)}}}async function Dn(t){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=Vn(n.publicKey.challenge),n.publicKey.user.id=Vn(n.publicKey.user.id),null===(e=n.publicKey.excludeCredentials)||void 0===e||e.forEach((t=>{t.id=Vn(t.id)})),n}(t);return n=await navigator.credentials.create(e),JSON.stringify({id:n.id,rawId:Hn(n.rawId),type:n.type,response:{attestationObject:Hn(n.response.attestationObject),clientDataJSON:Hn(n.response.clientDataJSON)}});var n}async function qn(t){const e=Bn(t);return Fn(await navigator.credentials.get(e))}async function Nn(t,e){const n=Bn(t);return n.signal=e.signal,n.mediation="conditional",Fn(await navigator.credentials.get(n))}async function Wn(t=!1){if(!In)return Promise.resolve(!1);const e=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return e&&t&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():e}function Bn(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=Vn(n.publicKey.challenge),null===(e=n.publicKey.allowCredentials)||void 0===e||e.forEach((t=>{t.id=Vn(t.id)})),n}function Fn(t){return JSON.stringify({id:t.id,rawId:Hn(t.rawId),type:t.type,response:{authenticatorData:Hn(t.response.authenticatorData),clientDataJSON:Hn(t.response.clientDataJSON),signature:Hn(t.response.signature),userHandle:t.response.userHandle?Hn(t.response.userHandle):void 0}})}function Vn(t){const e=t.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(e),(t=>t.charCodeAt(0))).buffer}function Hn(t){return btoa(String.fromCharCode.apply(null,new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var Kn,Jn=(Kn=t=>({async signUp(e,n){const o=await t.webauthn.signUp.start(e,window.location.origin,n);if(!o.ok)return o;const i=await Dn(o.data.options);return await t.webauthn.signUp.finish(o.data.transactionId,i)},async signIn(e){const n=await t.webauthn.signIn.start(e,window.location.origin);if(!n.ok)return n;const o=await qn(n.data.options);return await t.webauthn.signIn.finish(n.data.transactionId,o)},async signUpOrIn(e){var n;const o=await t.webauthn.signUpOrIn.start(e,window.location.origin);if(!o.ok)return o;if(null===(n=o.data)||void 0===n?void 0:n.create){const e=await Dn(o.data.options);return await t.webauthn.signUp.finish(o.data.transactionId,e)}{const e=await qn(o.data.options);return await t.webauthn.signIn.finish(o.data.transactionId,e)}},async update(e,n){const o=await t.webauthn.update.start(e,window.location.origin,n);if(!o.ok)return o;const i=await Dn(o.data.options);return await t.webauthn.update.finish(o.data.transactionId,i)},helpers:{create:Dn,get:qn,isSupported:Wn,conditional:Nn}}),(...t)=>{const e=Kn(...t);return Object.assign(e.signUp,t[0].webauthn.signUp),Object.assign(e.signIn,t[0].webauthn.signIn),Object.assign(e.signUpOrIn,t[0].webauthn.signUpOrIn),Object.assign(e.update,t[0].webauthn.update),e});const Gn="/fedcm/config",zn=(t,e)=>({async oneTap(e,n,o,i){const r=null!=e?e:"google",s=await t.oauth.startNative(r,o,!0);if(!s.ok)return s;const{clientId:a,stateId:l,nonce:c}=s.data,d=await async function(){return new Promise(((t,e)=>{if(window.google)return void t(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?t(window.google.accounts.id):e("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){e("Failed to load Google GSI client script - failed to load")}}))}();return new Promise((e=>{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=>{e(t.oauth.finishNative(r,l,"","",n.credential))},nonce:c})),d.prompt((t=>{(null==t?void 0:t.isSkippedMoment())&&(null==i||i())}))}))},async launch(n){var o;const i={identity:{context:n||"signin",providers:[{configURL:t.httpClient.buildUrl(e+Gn),clientId:e}]}},r=await(null===(o=navigator.credentials)||void 0===o?void 0:o.get(i));return t.refresh(r.token)},isSupported:()=>In&&"IdentityCredential"in window});var Xn=t=>Object.assign(Object.assign({},t.flow),{start:async(...e)=>{const n=await Wn(),o=Object.assign(Object.assign({location:window.location.href},e[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return e[1]=o,t.flow.start(...e)}});const Qn=function(...t){return e=>t.reduce(((t,e)=>e(t)),e)}((t=>n=>{var{fpKey:o,fpLoad:i}=n,r=e(n,["fpKey","fpLoad"]);return In?(o&&i&&En(o).catch((()=>null)),t(pn(r,{beforeRequest:Tn}))):t(r)}),(t=>n=>{var{autoRefresh:o}=n,i=e(n,["autoRefresh"]);if(!o)return t(i);const{clearAllTimers:r,setTimer:s}=(()=>{const t=[];return{clearAllTimers:()=>{for(;t.length;)clearTimeout(t.pop())},setTimer:(e,n)=>{t.push(setTimeout(e,n))}}})();let a,c;In&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&new Date>a&&(yn("Expiration time passed, refreshing session"),d.refresh(Sn()||c))}));const d=t(pn(i,{afterRequest:async(t,e)=>{const{refreshJwt:n,sessionJwt:o}=await fn(e);if(401===(null==e?void 0:e.status))yn("Received 401, canceling all timers"),r();else if(o){if(a=(t=>{try{const e=l(t);if(e.exp)return new Date(1e3*e.exp)}catch(t){return null}})(o),!a)return void yn("Could not extract expiration time from session token");c=n;let t=((i=a)?i.getTime()-(new Date).getTime():0)-2e4;t>kn&&(yn(`Timeout is too large (${t}ms), setting it to ${kn}ms`),t=kn),r();const e=new Date(Date.now()+t).toLocaleTimeString("en-US",{hour12:!1});yn(`Setting refresh timer for ${e}. (${t}ms)`),s((()=>{yn("Refreshing session due to timer"),d.refresh(Sn()||n)}),t)}var i}}));return Ft(d,["logout","logoutAll"],(t=>async(...e)=>{const n=await t(...e);return yn("Clearing all timers"),r(),n}))}),(t=>e=>t(Object.assign(Object.assign({},e),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.16.0"},e.baseHeaders)}))),(t=>e=>{const n=Mn(),o=Mn(),i=t(pn(e,{afterRequest:async(t,e)=>{if(401===(null==e?void 0:e.status))n.pub(null),o.pub(null);else{const t=await gn(e);t&&o.pub(t);const{sessionJwt:i}=await fn(e);i&&n.pub(i)}}})),r=Ft(i,["logout","logoutAll"],(t=>async(...e)=>{const i=await t(...e);return n.pub(null),o.pub(null),i}));return Object.assign(r,{onSessionTokenChange:n.sub,onUserChange:o.sub})}),(t=>n=>{var{storeLastAuthenticatedUser:o=!0,keepLastAuthenticatedUserAfterLogout:i=!1}=n,r=e(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!o)return Object.assign(t(r),{getLastUserLoginId:Rn,getLastUserDisplayName:Pn});const s=t(pn(r,{afterRequest:async(t,e)=>{var n;const o=await gn(e),i=null===(n=null==o?void 0:o.loginIds)||void 0===n?void 0:n[0],r=null==o?void 0:o.name;i&&((t=>{mn(Ln,t)})(i),(t=>{mn(_n,t)})(r))}}));let a=Ft(s,["flow.start"],$n);return a=Ft(a,["logout","logoutAll"],(t=>e=>async(...n)=>{const o=await e(...n);return t||(bn(Ln),bn(_n)),o})(i)),Object.assign(a,{getLastUserLoginId:Rn,getLastUserDisplayName:Pn})}),(t=>n=>{var{persistTokens:o,sessionTokenViaCookie:i,storagePrefix:r}=n,s=e(n,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!o||!In)return t(s);const a=t(pn(s,{beforeRequest:(l=r,t=>Object.assign(t,{token:t.token||Sn(l)})),afterRequest:async(t,n)=>{const o=/^\/v\d+\/mgmt\//.test(t.path);401===(null==n?void 0:n.status)?o||On(r):((t={},n,o)=>{var{refreshJwt:i,sessionJwt:r}=t,s=e(t,["refreshJwt","sessionJwt"]);void 0===n&&(n=!1),void 0===o&&(o=""),i&&mn(`${o}${Cn}`,i),r&&(n?function(t,e,{cookiePath:n,cookieDomain:o,cookieExpiration:i}){if(e){const r=new Date(1e3*i),s=function(t){const e=window.location.hostname.split("."),n=t.split(".");return e.slice(-n.length).join(".")===t}(o);tn.set(t,e,{path:n,domain:s?o:void 0,expires:r,sameSite:"Strict",secure:!0})}}(jn,r,s):mn(`${o}${jn}`,r))})(await fn(n),i,r)}}));var l;const c=Ft(a,["logout","logoutAll"],(t=>e=>async(...n)=>{const o=await e(...n);return On(t),o})(r));return Object.assign(c,{getRefreshToken:()=>Sn(r),getSessionToken:()=>function(t=""){return tn.get(jn)||wn(`${t}${jn}`)||""}(r)})}))(((...t)=>{const e=Ze(...t);return Object.assign(Object.assign({},e),{flow:Xn(e),webauthn:Jn(e),fedcm:zn(e,t[0].projectId)})})),Zn="undefined"!=typeof localStorage,Yn=Zn&&localStorage.getItem("base.content.url")||"",to="config.json",eo="base.ui.components.url",no=Zn&&localStorage.getItem(eo)||"https://static.descope.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",oo=Zn&&localStorage.getItem(eo)||"https://cdn.jsdelivr.net/npm/@descope/web-components-ui@<version>/dist/umd/index.js",io="descope-login-flow",ro="code",so="ra-challenge",ao="ra-callback",lo="ra-backup-callback",co="ra-initiator",uo="data-exclude-field",ho="dls_last_auth",po="state_id",fo="saml_idp_state_id",go="saml_idp_username",vo="descope_idp_initiated",mo="sso_app_id",wo="oidc_login_hint",bo="oidc_prompt",yo="oidc_error_redirect_uri",Io="data-type",ko="redirect",jo="poll",Co="webauthnCreate",So="webauthnGet",Oo="loadForm",Ao="submit",xo="polling",Uo=["descope-multi-select-combo-box","descope-text-area"];var Eo;function To(t){return new URLSearchParams(window.location.search).get(t)}function Lo(t){if(window.history.replaceState&&To(t)){const e=new URL(window.location.href),n=new URLSearchParams(e.search);n.delete(t),e.search=n.toString(),window.history.replaceState({},"",e.toString())}}function _o(t,e){return n(this,void 0,void 0,(function*(){const n=yield fetch(t,{cache:"default"});if(!n.ok)throw Error(`Error fetching URL ${t} [${n.status}]`);return{body:yield n[e||"text"](),headers:Object.fromEntries(n.headers.entries())}}))}!function(t){t.backward="backward",t.forward="forward"}(Eo||(Eo={}));function Ro({projectId:t,filename:e,assetsFolder:n="v2-beta",baseUrl:o}){const i=new URL(Yn||o||"https://static.descope.com/pages");return i.pathname=((...t)=>t.join("/").replace(/\/+/g,"/"))(i.pathname,t,n,e),i.toString()}function Po(t,e){if(!e)return;const n=+t,o=+e;return Number.isNaN(n)||Number.isNaN(o)?void 0:n>o?Eo.forward:n<o?Eo.backward:void 0}const $o=()=>{const[t="",e=""]=(To(io)||"").split("_");return{executionId:t,stepId:e}};function Mo(){Lo(io)}const Do=t=>t.replace(/-./g,(t=>t[1].toUpperCase())),qo=()=>{const{executionId:t,stepId:e}=$o();(t||e)&&Mo();const n=To("t")||void 0;n&&Lo("t");const o=To(ro)||void 0;o&&Lo(ro);const i=To("err")||void 0;i&&Lo("err");const{redirectAuthCodeChallenge:r,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:l}={redirectAuthCodeChallenge:To(so),redirectAuthCallbackUrl:To(ao),redirectAuthBackupCallbackUri:To(lo),redirectAuthInitiator:To(co)};(r||s||a||l)&&(Lo(so),Lo(ao),Lo(lo),Lo(co));const c=To(po);c&&Lo(po);const d=To(fo);d&&Lo(fo);const u=To(go);d&&Lo(go);const h=To(vo);h&&Lo(vo);const p=To(mo);p&&Lo(mo);const f=To(wo);f&&Lo(wo);const g=To(bo);g&&Lo(bo);const v=To(yo);v&&Lo(yo);return{executionId:t,stepId:e,token:n,code:o,exchangeError:i,redirectAuthCodeChallenge:r,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:l,ssoQueryParams:{oidcIdpStateId:c,samlIdpStateId:d,samlIdpUsername:u,descopeIdpInitiated:"true"===h,ssoAppId:p,oidcLoginHint:f,oidcPrompt:g,oidcErrorRedirectUri:v}}},No=t=>{let e,n;return(...o)=>{return e&&(r=o,(i=e).length===r.length&&i.every(((t,e)=>t===r[e])))||(e=o,n=t(...o)),n;var i,r}};const Wo=(t,{oidcIdpStateId:e,samlIdpStateId:n,samlIdpUsername:o,ssoAppId:i,oidcLoginHint:r,oidcPrompt:s,oidcErrorRedirectUri:a})=>!(!t||e||n||o||i||r||s||a),Bo=t=>null==t?void 0:t.submit(),Fo=(t,e)=>{const n=e.find((e=>t[e]));return n?t[n]:null},Vo=(t,e=100)=>{let n;return function(...o){n||t.apply(this,o),clearTimeout(n),n=setTimeout((()=>{n=null}),e)}};function Ho(t){let e=navigator.language;return e&&"zh-TW"!==e&&(e=e.split("-")[0]),(t||e||"").toLowerCase()}var Ko,Jo,Go,zo;function Xo(t,e){const n=Object.getOwnPropertyNames(t),o=Object.getOwnPropertyNames(e);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const i=n[o],r=t[i],s=e[i];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!Xo(r,s))return!1}else if(r!==s)return!1}return!0}class Qo{constructor(t={},{updateOnlyOnChange:e=!0}={}){Ko.set(this,void 0),Jo.set(this,{}),Go.set(this,0),zo.set(this,!1),this.update=t=>{const e="function"==typeof t?t(o(this,Ko,"f")):t,n=Object.assign(Object.assign({},o(this,Ko,"f")),e);if(!o(this,zo,"f")||!Xo(o(this,Ko,"f"),n)){const t=o(this,Ko,"f");i(this,Ko,n,"f"),Object.freeze(o(this,Ko,"f")),setTimeout((()=>{Object.values(o(this,Jo,"f")).forEach((e=>e(n,t,((t,e)=>n=>t[n]!==e[n])(n,t))))}),0)}},i(this,Ko,t,"f"),i(this,zo,e,"f")}get current(){return Object.assign({},o(this,Ko,"f"))}subscribe(t){return i(this,Go,o(this,Go,"f")+1,"f"),o(this,Jo,"f")[o(this,Go,"f")]=t,o(this,Go,"f").toString()}unsubscribe(t){const e=!!o(this,Jo,"f")[t];return e&&delete o(this,Jo,"f")[t],e}unsubscribeAll(){return i(this,Jo,{},"f"),!0}}Ko=new WeakMap,Jo=new WeakMap,Go=new WeakMap,zo=new WeakMap;const Zo=["disabled"],Yo=(t,e)=>{Object.entries(e||{}).forEach((([e,n])=>{Array.from(t.querySelectorAll(`*[name="${e}"]:not([${uo}])`)).forEach((t=>{t.value=n}))}))},ti=(t,e)=>t.replace(/{{(.+?)}}/g,((t,n)=>{return o=e,n.split(".").reduce(((t,e)=>(null==t?void 0:t[e])||""),o);var o})),ei=(t,e,n)=>{t.querySelectorAll(`[${Io}="${e}"]`).forEach((t=>{t.setAttribute("href",n)}))},ni=(t,e,n)=>{var o,i;const r=null===(o=customElements.get(e))||void 0===o?void 0:o.cssVarList.url;n&&r&&(null===(i=null==t?void 0:t.style)||void 0===i||i.setProperty(r,`url(data:image/jpg;base64,${n})`))},oi=(t,e,n,o,i,r)=>{var s,a;let l=null==e?void 0:e.errorText;try{l=(null==i?void 0:i({text:null==e?void 0:e.errorText,type:null==e?void 0:e.errorType}))||(null==e?void 0:e.errorText)}catch(t){r.error("Error transforming error message",t.message)}((t,e,n="")=>{t.querySelectorAll(`[${Io}="${e}"]`).forEach((t=>{t.textContent=n,t.classList[n?"remove":"add"]("hide")}))})(t,"error-message",l),ei(t,"totp-link",null===(s=null==e?void 0:e.totp)||void 0===s?void 0:s.provisionUrl),ei(t,"notp-link",null===(a=null==e?void 0:e.notp)||void 0===a?void 0:a.redirectUrl),((t,e)=>{t.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((t=>{t.textContent=ti(t.textContent,e);const n=t.getAttribute("href");n&&t.setAttribute("href",ti(n,e))}))})(t,e),((t,e,n)=>{e&&Object.keys(e).forEach((o=>{t.querySelectorAll(`[name=${o}]`).forEach((t=>{const i=e[o];Object.keys(i).forEach((e=>{let o=i[e];if("string"!=typeof o)try{o=JSON.stringify(o)}catch(t){n.error(`Could not stringify value "${o}" for "${e}"`,t.message),o=""}t.setAttribute(e,o)}))}))}))})(t,n,r),((t,e)=>{t.querySelectorAll("[data-has-dynamic-attr-values]").forEach((t=>{Array.from(t.attributes).forEach((t=>{t.value=ti(t.value,e)}))}))})(t,e),((t,e)=>{Object.entries(e).forEach((([e,n])=>{t.querySelectorAll(`[name="${e}"]`).forEach((t=>{Object.entries(n).forEach((([e,n])=>{Zo.includes(e)&&t.setAttribute(e,n)}))}))}))})(t,o)},ii=No((()=>n(void 0,void 0,void 0,(function*(){var t,e,n,o,i;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const r=Promise.all([null===(t=window.PublicKeyCredential)||void 0===t?void 0:t.isConditionalMediationAvailable(),null===(e=window.PublicKeyCredential)||void 0===e?void 0:e.isUserVerifyingPlatformAuthenticatorAvailable()]).then((t=>t.every((t=>!!t)))),s=(()=>{var t;const e=null===(t=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===t?void 0:t.brands,n=null==e?void 0:e.find((({brand:t,version:e})=>"Chromium"===t&&parseFloat(e)));return n?n.version:0})()>=108;return yield(n=100,o=r,i=s,new Promise(((t,e)=>{let r=!1;const s=setTimeout((()=>{r=!0,void 0!==i?t(i):e(new Error(`Promise timed out after ${n} ms`))}),n);o.then((e=>{r||(clearTimeout(s),t(e))})).catch((t=>{r||(clearTimeout(s),e(t))}))})))}catch(t){return console.error("Conditional login check failed",t),!1}})))),ri=(t,e,n,o={})=>{var i,r,s,a;return[Math.min(Math.max(e,("all"===o.left?t.offsetWidth:null!==(i=o.left)&&void 0!==i?i:0)-t.offsetWidth),window.innerWidth-("all"===o.right?t.offsetWidth:null!==(r=o.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===o.top?t.offsetHeight:null!==(s=o.top)&&void 0!==s?s:0)-t.offsetHeight),window.innerHeight-("all"===o.bottom?t.offsetHeight:null!==(a=o.bottom)&&void 0!==a?a:0))]},si={"lastAuth.loginId":{"not-empty":t=>!!t.loginId,empty:t=>!t.loginId},idpInitiated:{"is-true":t=>!!t.code,"is-false":t=>!t.code},externalToken:{"is-true":t=>!!t.token,"is-false":t=>!t.token},abTestingKey:{"greater-than":(t,e)=>(t.abTestingKey||0)>e,"less-than":(t,e)=>(t.abTestingKey||0)<e}};function ai(t){const e={};if(t)try{Object.assign(e,JSON.parse(localStorage.getItem(ho)))}catch(t){}return e}const li="dls_ab_testing_id",ci=document.createElement("template");ci.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 di=(t,e="")=>Object.keys(t).reduce(((n,o)=>{var i;if("object"==typeof t[o]&&null!==t[o]&&!(null===(i=t[o])||void 0===i?void 0:i.value))return Object.assign(Object.assign({},n),di(t[o],`${e+o}.`));const r="object"==typeof t[o]?t[o]:{value:t[o]},s=Object.assign(Object.assign({},n),{[e+o]:r,[`form.${e}${o}`]:r});return"displayName"===o?Object.assign(Object.assign({},s),{[`${e}fullName`]:r,[`form.${e}fullName`]:r}):s}),[]);var ui,hi,pi,fi,gi,vi,mi,wi,bi,yi,Ii,ki,ji,Ci,Si,Oi,Ai,xi,Ui,Ei,Ti,Li,_i,Ri,Pi,$i,Mi,Di,qi,Ni,Wi,Bi,Fi,Vi,Hi,Ki,Ji,Gi,zi,Xi,Qi,Zi,Yi,tr,er,nr,or,ir,rr,sr,ar,lr,cr,dr,ur,hr,pr,fr,gr,vr,mr,wr;class br 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(t){super(),ui.add(this),this.logger=console,hi.set(this,!1),this.loggerWrapper={error:(t,e="")=>{this.logger.error(t,e,new Error),o(this,ui,"m",Di).call(this,t,e)},warn:(t,e="")=>{this.logger.warn(t,e)},info:(t,e="",n={})=>{this.logger.info(t,e,n)},debug:(t,e="")=>{this.logger.debug(t,e)}},pi.set(this,new Qo),fi.set(this,new Qo),gi.set(this,{}),this.getComponentsContext=()=>o(this,gi,"f"),this.nextRequestStatus=new Qo({isLoading:!1}),vi.set(this,void 0),mi.set(this,{popstate:o(this,ui,"m",ji).bind(this),componentsContext:o(this,ui,"m",Ri).bind(this)}),wi.set(this,void 0),xi.set(this,No((()=>n(this,void 0,void 0,(function*(){const t=Ro({projectId:this.projectId,filename:to,baseUrl:this.baseStaticUrl});try{const{body:e,headers:n}=yield _o(t,"json");return{projectConfig:e,executionContext:{geo:n["x-geo"]}}}catch(t){return{isMissingConfig:!0}}}))))),Ei.set(this,void 0),i(this,wi,t,"f"),o(this,ui,"m",bi).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(t){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 t,e;const n=this.getAttribute("theme");if("os"===n){return window.matchMedia&&(null===(e=null===(t=window.matchMedia)||void 0===t?void 0:t.call(window,"(prefers-color-scheme: dark)"))||void 0===e?void 0:e.matches)?"dark":"light"}return n||"light"}get autoFocus(){var t;const e=null!==(t=this.getAttribute("auto-focus"))&&void 0!==t?t:"true";return"skipFirstScreen"===e?e:"true"===e}get validateOnBlur(){return"true"===this.getAttribute("validate-on-blur")}get storeLastAuthenticatedUser(){var t;return"true"===(null!==(t=this.getAttribute("store-last-authenticated-user"))&&void 0!==t?t:"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(t=>{try{return di(JSON.parse(t))}catch(t){return{}}})(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return t=this.formConfig,e="value",Object.fromEntries(Object.entries(t).map((([t,n])=>[t,n[e]])));var t,e}getExecutionContext(){return n(this,void 0,void 0,(function*(){const{executionContext:t}=yield o(this,xi,"f").call(this);return t}))}getProjectConfig(){return n(this,void 0,void 0,(function*(){const{projectConfig:t}=yield o(this,xi,"f").call(this);return t}))}getFlowConfig(){var t,e;return n(this,void 0,void 0,(function*(){const n=yield this.getProjectConfig(),o=(null===(t=null==n?void 0:n.flows)||void 0===t?void 0:t[this.flowId])||{};return null!==(e=o.version)&&void 0!==e||(o.version=0),o}))}getTargetLocales(){return n(this,void 0,void 0,(function*(){const t=yield this.getFlowConfig();return((null==t?void 0:t.targetLocales)||[]).map((t=>t.toLowerCase()))}))}connectedCallback(){return n(this,void 0,void 0,(function*(){if(this.shadowRoot.isConnected){if(o(this,fi,"f").subscribe(o(this,ui,"m",Mi).bind(this)),o(this,fi,"f").update({isDebug:this.debug}),o(this,ui,"m",yi).call(this))return void o(this,ui,"m",Ii).call(this);if(o(this,ui,"m",ki).call(this),i(this,Ei,o(this,ui,"m",Ui).call(this),"f"),yield o(this,ui,"m",Oi).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,xi,"f").call(this)).isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");o(this,ui,"m",Ti).call(this),yield o(this,ui,"m",Wi).call(this),yield o(this,ui,"m",Li).call(this),o(this,ui,"m",qi).call(this);const{executionId:t,stepId:e,token:n,code:r,exchangeError:s,redirectAuthCallbackUrl:a,redirectAuthBackupCallbackUri:l,redirectAuthCodeChallenge:c,redirectAuthInitiator:d,ssoQueryParams:u}=qo();window.addEventListener("popstate",o(this,mi,"f").popstate),window.addEventListener("components-context",o(this,mi,"f").componentsContext),o(this,pi,"f").subscribe(o(this,ui,"m",Si).bind(this)),o(this,pi,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenant,redirectUrl:this.redirectUrl,locale:this.locale,stepId:e,executionId:t,token:n,code:r,exchangeError:s,redirectAuthCallbackUrl:a,redirectAuthBackupCallbackUri:l,redirectAuthCodeChallenge:c,redirectAuthInitiator:d},u)),i(this,hi,!0,"f")}}))}disconnectedCallback(){o(this,pi,"f").unsubscribeAll(),o(this,fi,"f").unsubscribeAll(),o(this,ui,"m",$i).call(this),window.removeEventListener("popstate",o(this,mi,"f").popstate),window.removeEventListener("components-context",o(this,mi,"f").componentsContext)}attributeChangedCallback(t,e,n){if(this.shadowRoot.isConnected&&o(this,hi,"f")&&e!==n&&br.observedAttributes.includes(t)){o(this,ui,"m",ki).call(this);const i=null===e;o(this,pi,"f").update((({stepId:e,executionId:o})=>{let r=e,s=o;return i||(s=null,r=null,Mo()),{[Do(t)]:n,stepId:r,executionId:s}})),o(this,fi,"f").update({isDebug:this.debug}),"theme"===t&&o(this,ui,"m",Pi).call(this)}}}hi=new WeakMap,pi=new WeakMap,fi=new WeakMap,gi=new WeakMap,vi=new WeakMap,mi=new WeakMap,wi=new WeakMap,xi=new WeakMap,Ei=new WeakMap,ui=new WeakSet,bi=function(){this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(ci.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#wc-root")},yi=function(){return!this.shadowRoot.host.closest("form")&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)},Ii=function(){const t=this.shadowRoot.host,e=document.createElement("form");e.style.width="100%",e.style.height="100%",t.parentElement.appendChild(e),e.appendChild(t)},ki=function(){const t=["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(br.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[Do(e)])throw Error(`${e} 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')},ji=function(){const{stepId:t,executionId:e}=$o();o(this,pi,"f").update({stepId:t,executionId:e})},Ci=function(t,e){this.sdk=Qn(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout},br.sdkConfigOverrides),{projectId:t,baseUrl:e})),["start","next"].forEach((t=>{const e=this.sdk.flow[t];this.sdk.flow[t]=(...t)=>n(this,void 0,void 0,(function*(){this.nextRequestStatus.update({isLoading:!0});try{return yield e(...t)}catch(t){return{error:{errorCode:"J151000",errorDescription:t.toString()}}}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},Si=function(t,e,i){return n(this,void 0,void 0,(function*(){const{projectId:e,baseUrl:n}=t;if(i("projectId")||i("baseUrl")){if(!e)return;o(this,ui,"m",Ci).call(this,e,n)}o(this,wi,"f").call(this,t)}))},Oi=function(){return n(this,void 0,void 0,(function*(){return(yield o(this,xi,"f").call(this)).isMissingConfig&&(yield o(this,ui,"m",Ai).call(this))}))},Ai=function(){return n(this,void 0,void 0,(function*(){const t=Ro({projectId:this.projectId,filename:to,assetsFolder:"v2-alpha",baseUrl:this.baseStaticUrl});try{return yield _o(t,"json"),!0}catch(t){return!1}}))},Ui=function(){return n(this,void 0,void 0,(function*(){const t=Ro({projectId:this.projectId,filename:"theme.json",baseUrl:this.baseStaticUrl});try{const{body:e}=yield _o(t,"json");return e}catch(t){return void this.loggerWrapper.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}}))},Ti=function(){var t,e;return n(this,void 0,void 0,(function*(){const{projectConfig:n}=yield o(this,xi,"f").call(this),i=null===(e=null===(t=null==n?void 0:n.cssTemplate)||void 0===t?void 0:t[this.theme])||void 0===e?void 0:e.fonts;i&&Object.values(i).forEach((t=>(t=>{if(!t)return;const e=document.createElement("link");e.href=t,e.rel="stylesheet",document.head.appendChild(e)})(t.url)))}))},Li=function(){return n(this,void 0,void 0,(function*(){yield o(this,ui,"m",_i).call(this),yield o(this,ui,"m",Pi).call(this)}))},_i=function(){var t,e,i,r;return n(this,void 0,void 0,(function*(){const n=document.createElement("style"),s=yield o(this,Ei,"f");n.innerText=((null===(t=null==s?void 0:s.light)||void 0===t?void 0:t.globals)||"")+((null===(e=null==s?void 0:s.dark)||void 0===e?void 0:e.globals)||"");const a=yield br.descopeUI;(null==a?void 0:a.componentsThemeManager)&&!a.componentsThemeManager.hasThemes&&(a.componentsThemeManager.themes={light:null===(i=null==s?void 0:s.light)||void 0===i?void 0:i.components,dark:null===(r=null==s?void 0:s.dark)||void 0===r?void 0:r.components}),this.shadowRoot.appendChild(n)}))},Ri=function(t){i(this,gi,Object.assign(Object.assign({},o(this,gi,"f")),t.detail),"f")},Pi=function(){return n(this,void 0,void 0,(function*(){this.rootElement.setAttribute("data-theme",this.theme);const t=yield br.descopeUI;(null==t?void 0:t.componentsThemeManager)&&(t.componentsThemeManager.currentThemeName=this.theme)}))},$i=function(){var t;null===(t=o(this,vi,"f"))||void 0===t||t.remove(),i(this,vi,null,"f")},Mi=function({isDebug:t}){return n(this,void 0,void 0,(function*(){t?(i(this,vi,document.createElement("descope-debugger"),"f"),Object.assign(o(this,vi,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return jr})),document.body.appendChild(o(this,vi,"f"))):o(this,ui,"m",$i).call(this)}))},Di=function(t,e){var n;t&&this.debug&&(null===(n=o(this,vi,"f"))||void 0===n||n.updateData({title:t,description:e}))},qi=function(){this.rootElement.onkeydown=t=>{var e,n,o;const i=!!(null===(e=this.shadowRoot.activeElement)||void 0===e?void 0:e.getAttribute("href")),r=Uo.includes(null!==(o=null===(n=this.shadowRoot.activeElement)||void 0===n?void 0:n.localName)&&void 0!==o?o:"");if("Enter"!==t.key||i||r)return;t.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((t=>"true"===t.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const l=Array.from(s).filter((t=>"button"===t.getAttribute("data-type")));if(1===l.length)"false"!==l[0].getAttribute("auto-submit")&&l[0].click();else if(0===l.length){const t=Array.from(s).filter((t=>"sso"===t.getAttribute("data-type")));1===t.length&&"false"!==t[0].getAttribute("auto-submit")&&t[0].click()}}},Ni=function(){var t,e;return n(this,void 0,void 0,(function*(){const n=null===(e=null===(t=yield o(this,xi,"f").call(this))||void 0===t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return n||(this.logger.error("Did not get components version, using latest version"),"latest")}))},Wi=function(){return n(this,void 0,void 0,(function*(){br.descopeUI?this.loggerWrapper.debug("DescopeUI is already loading, probably multiple flows are running on the same page"):br.descopeUI=new Promise((t=>{if(globalThis.DescopeUI)return void t(globalThis.DescopeUI);const e=t=>{const e=document.createElement("script");return e.id="load-descope-ui",e.src=t,e},i=(t,e)=>t.replace("<version>",e),r=(e,n)=>{const o=()=>{this.loggerWrapper.error("Cannot load DescopeUI",`Make sure this URL is valid and return the correct script: "${e.src}"`),n()};e.addEventListener("load",(()=>{globalThis.DescopeUI||o(),t(globalThis.DescopeUI)})),e.addEventListener("error",o)};(()=>{n(this,void 0,void 0,(function*(){const n=yield o(this,ui,"m",Ni).call(this),s=e(i(no,n));r(s,(()=>{s.remove(),this.loggerWrapper.info("Trying to load DescopeUI from a fallback URL");const o=e(i(oo,n));r(o,(()=>{t(void 0)})),document.body.append(o)})),document.body.append(s)}))})()}))}))},br.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.21.0"}};class yr extends br{static set sdkConfigOverrides(t){br.sdkConfigOverrides=t}constructor(){const t=new Qo({deferredRedirect:!1});super(t.update.bind(t)),Bi.add(this),this.stepState=new Qo({},{updateOnlyOnChange:!1}),Fi.set(this,void 0),Vi.set(this,null),Hi.set(this,{visibilitychange:o(this,Bi,"m",Ki).bind(this)}),Ji.set(this,((t,e,r,s,a)=>{r===jo&&i(this,Fi,setTimeout((()=>n(this,void 0,void 0,(function*(){var n;let i;try{i=yield this.sdk.flow.next(t,e,xo,s,a,{})}catch(n){return void o(this,Ji,"f").call(this,t,e,r,s,a)}o(this,zi,"f").call(this,i);const{action:l}=null!==(n=null==i?void 0:i.data)&&void 0!==n?n:{};o(this,Ji,"f").call(this,t,e,l,s,a)}))),2e3),"f")})),Gi.set(this,(()=>{clearTimeout(o(this,Fi,"f")),i(this,Fi,null,"f")})),zi.set(this,(t=>{var e,n,i,r,s,a,l,c,d,u,h;if(!(null==t?void 0:t.ok)){const a=null===(e=null==t?void 0:t.response)||void 0===e?void 0:e.url,l=`${null===(n=null==t?void 0:t.response)||void 0===n?void 0:n.status} - ${null===(i=null==t?void 0:t.response)||void 0===i?void 0:i.statusText}`;return o(this,Bi,"m",lr).call(this,"error",(null==t?void 0:t.error)||{errorCode:"J151001",errorDescription:l,errorMessage:a}),void this.loggerWrapper.error((null===(r=null==t?void 0:t.error)||void 0===r?void 0:r.errorDescription)||a,(null===(s=null==t?void 0:t.error)||void 0===s?void 0:s.errorMessage)||l)}null===(l=null===(a=t.data)||void 0===a?void 0:a.runnerLogs)||void 0===l||l.forEach((t=>{const{level:e,title:n,log:o}=t;e&&this.loggerWrapper[e]?this.loggerWrapper[e](n,o):this.loggerWrapper.info(n,o)}));const p=null===(u=null===(d=null===(c=t.data)||void 0===c?void 0:c.screen)||void 0===d?void 0:d.state)||void 0===u?void 0:u.errorText;(null===(h=t.data)||void 0===h?void 0:h.error)?this.loggerWrapper.error(`[${t.data.error.code}]: ${t.data.error.description}`,`${p?`${p} - `:""}${t.data.error.message}`):p&&this.loggerWrapper.error(p);const{status:f,authInfo:g,lastAuth:v}=t.data;if("completed"===f)return this.storeLastAuthenticatedUser&&function(t){(null==t?void 0:t.authMethod)&&Zn&&localStorage.setItem(ho,JSON.stringify(t))}(v),void o(this,Bi,"m",lr).call(this,"success",g);const{executionId:m,stepId:w,stepName:b,action:y,screen:I,redirect:k,openInNewTabUrl:j,webauthn:C,error:S,samlIdpResponse:O}=t.data;y!==jo?(this.loggerWrapper.info(`Step "${b||`#${w}`}" is ${f}`,"",{screen:I,status:f,stepId:w,stepName:b,action:y,error:S}),this.flowState.update({stepId:w,executionId:m,action:y,redirectTo:null==k?void 0:k.url,openInNewTabUrl:j,screenId:null==I?void 0:I.id,screenState:null==I?void 0:I.state,webauthnTransactionId:null==C?void 0:C.transactionId,webauthnOptions:null==C?void 0:C.options,samlIdpResponseUrl:null==O?void 0:O.url,samlIdpResponseSamlResponse:null==O?void 0:O.samlResponse,samlIdpResponseRelayState:null==O?void 0:O.relayState})):this.flowState.update({action:y})})),Xi.set(this,No((()=>n(this,void 0,void 0,(function*(){var t;try{const e=yield this.sdk.webauthn.signIn.start("",window.location.origin);return e.ok||this.loggerWrapper.warn("Webauthn start failed",null===(t=null==e?void 0:e.error)||void 0===t?void 0:t.errorMessage),e.data}catch(t){this.loggerWrapper.warn("Webauthn start failed",t.message)}}))))),ir.set(this,Vo(((t,e)=>n(this,void 0,void 0,(function*(){if("true"===t.getAttribute("formnovalidate")||o(this,Bi,"m",tr).call(this)){const i=null==t?void 0:t.getAttribute("id");o(this,Bi,"m",nr).call(this,t);const r=yield o(this,Bi,"m",er).call(this),s=(n=t,Array.from((null==n?void 0:n.attributes)||[]).reduce(((t,e)=>{var n;const o=null===(n=new RegExp("^data-descope-(\\S+)$").exec(e.name))||void 0===n?void 0:n[1];return o?Object.assign(t,{[o]:e.value}):t}),{})),a=this.getComponentsContext(),l=Object.assign(Object.assign(Object.assign(Object.assign({},a),s),r),{origin:window.location.origin}),c=yield this.getFlowConfig(),d=yield this.getProjectConfig(),u=yield e(i,c.version,d.componentsVersion,l);o(this,zi,"f").call(this,u),o(this,Bi,"m",or).call(this,r)}var n}))))),this.flowState=t}loadSdkScripts(){return n(this,void 0,void 0,(function*(){const t=(yield this.getFlowConfig()).sdkScripts;null==t||t.forEach((t=>n(this,void 0,void 0,(function*(){(yield function(t){return n(this,void 0,void 0,(function*(){let e;if("forter"===t)return e=yield Promise.resolve().then((function(){return Sr})),e.default;throw new Error(`Unknown script id: ${t}`)}))}(t.id))(t.initArgs,{baseUrl:this.baseUrl},(e=>{var n,o;this.dispatchEvent(new CustomEvent("components-context",{detail:{[(n=t.id,o=t.resultKey,`sdkScriptsResults.${o?`${n}_${o}`:n}`)]:e},bubbles:!0,composed:!0}))}))}))))}))}connectedCallback(){const t=Object.create(null,{connectedCallback:{get:()=>super.connectedCallback}});var e,i;return n(this,void 0,void 0,(function*(){this.shadowRoot.isConnected&&(null===(e=this.flowState)||void 0===e||e.subscribe(this.onFlowChange.bind(this)),null===(i=this.stepState)||void 0===i||i.subscribe(this.onStepChange.bind(this)),window.addEventListener("visibilitychange",o(this,Hi,"f").visibilitychange)),yield t.connectedCallback.call(this)}))}disconnectedCallback(){var t;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),null===(t=o(this,Vi,"f"))||void 0===t||t.abort(),i(this,Vi,null,"f"),window.removeEventListener("visibilitychange",o(this,Hi,"f").visibilitychange)}getHtmlFilenameWithLocale(t,e){return n(this,void 0,void 0,(function*(){let n;const o=Ho(t);return(yield this.getTargetLocales()).includes(o)&&(n=`${e}-${o}.html`),n}))}getPageContent(t,e){return n(this,void 0,void 0,(function*(){if(e)try{const{body:t}=yield _o(e,"text");return t}catch(n){this.loggerWrapper.error(`Failed to fetch flow page from ${e}. Fallback to url ${t}`,n)}try{const{body:e}=yield _o(t,"text");return e}catch(t){this.loggerWrapper.error("Failed to fetch flow page",t.message)}return null}))}onFlowChange(t,r,s){var a,l;return n(this,void 0,void 0,(function*(){const{projectId:n,flowId:c,tenant:d,stepId:u,executionId:h,action:p,screenId:f,screenState:g,redirectTo:v,openInNewTabUrl:m,redirectUrl:w,token:b,code:y,exchangeError:I,webauthnTransactionId:k,webauthnOptions:j,redirectAuthCodeChallenge:C,redirectAuthCallbackUrl:S,redirectAuthBackupCallbackUri:O,redirectAuthInitiator:A,locale:x,samlIdpResponseUrl:U,samlIdpResponseSamlResponse:E,samlIdpResponseRelayState:T}=t,L=e(t,["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 _,R;const P=(()=>{const t=localStorage.getItem(li);if(!t){const t=Math.floor(100*Math.random()+1);return localStorage.setItem(li,t.toString()),t}return Number(t)})(),$=this.sdk.getLastUserLoginId(),M=yield this.getFlowConfig(),D=yield this.getProjectConfig(),q=S&&C?{callbackUrl:S,codeChallenge:C,backupCallbackUri:O}:void 0;if(!h&&(this.loadSdkScripts(),M.fingerprintEnabled&&M.fingerprintKey?yield En(M.fingerprintKey,this.baseUrl):localStorage.removeItem(xn),M.conditions?({startScreenId:_,conditionInteractionId:R}=((t,e)=>{const n=null==e?void 0:e.find((({key:e,operator:n,predicate:o})=>{var i;if("ELSE"===e)return!0;const r=null===(i=si[e])||void 0===i?void 0:i[n];return!!(null==r?void 0:r(t,o))}));return n?{startScreenId:n.met.screenId,conditionInteractionId:n.met.interactionId}:{}})({loginId:$,code:y,token:b,abTestingKey:P},M.conditions)):M.condition?({startScreenId:_,conditionInteractionId:R}=((t,e)=>{var n;const o=null===(n=si[null==t?void 0:t.key])||void 0===n?void 0:n[t.operator];if(!o)return{};const i=o(e,t.predicate)?t.met:t.unmet;return{startScreenId:null==i?void 0:i.screenId,conditionInteractionId:null==i?void 0:i.interactionId}})(M.condition,{loginId:$,code:y,token:b,abTestingKey:P})):_=M.startScreenId,!Wo(_,L))){const t=yield this.sdk.flow.start(c,Object.assign(Object.assign(Object.assign(Object.assign({tenant:d,redirectAuth:q},L),{client:this.client}),w&&{redirectUrl:w}),{lastAuth:ai($),abTestingKey:P,locale:Ho(x)}),R,"",M.version,D.componentsVersion,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),y?{exchangeCode:y,idpInitiated:!0}:{}),L.descopeIdpInitiated&&{idpInitiated:!0}),b?{token:b}:{}),L.oidcLoginHint?{externalId:L.oidcLoginHint}:{}));return o(this,zi,"f").call(this,t),void("completed"!==(null===(a=null==t?void 0:t.data)||void 0===a?void 0:a.status)&&this.flowState.update({code:void 0,token:void 0}))}if(h&&(s("token")&&b||s("code")&&y||s("exchangeError")&&I)){const t=yield this.sdk.flow.next(h,u,Ao,M.version,D.componentsVersion,{token:b,exchangeCode:y,exchangeError:I});return o(this,zi,"f").call(this,t),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(p===Oo&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((t=>s(t)))){if(!U||!E)return void this.loggerWrapper.error("Did not get saml idp params data to load");((t,e,n,o)=>{const i=document.createElement("form");i.method="POST",i.action=t,i.innerHTML=`\n <input type="hidden" role="saml-response" name="SAMLResponse" value="${e}" />\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)})(U,E,T||"",Bo)}if(p===ko&&(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(p===Co||p===So){if(!k||!j)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let t,e;null===(l=o(this,Vi,"f"))||void 0===l||l.abort(),i(this,Vi,null,"f");try{t=p===Co?yield this.sdk.webauthn.helpers.create(j):yield this.sdk.webauthn.helpers.get(j)}catch(t){"InvalidStateError"===t.name?this.loggerWrapper.warn("WebAuthn operation failed",t.message):"NotAllowedError"!==t.name&&this.loggerWrapper.error(t.message),e=t.name}const n=yield this.sdk.flow.next(h,u,Ao,M.version,D.componentsVersion,{transactionId:k,response:t,failure:e});o(this,zi,"f").call(this,n)}if(o(this,Ji,"f").call(this,h,u,p,M.version,D.componentsVersion),!f&&!_)return void this.loggerWrapper.warn("No screen was found to show");const N=_||f,W=yield this.getHtmlFilenameWithLocale(x,N),{oidcLoginHint:B,oidcPrompt:F,oidcErrorRedirectUri:V,samlIdpUsername:H}=L,K={direction:Po(u,r.stepId),screenState:Object.assign(Object.assign({},g),{form:Object.assign(Object.assign({},this.formConfigValues),null==g?void 0:g.form),lastAuth:{loginId:$,name:this.sdk.getLastUserDisplayName()||$}}),htmlUrl:Ro({projectId:n,filename:`${N}.html`,baseUrl:this.baseStaticUrl}),htmlLocaleUrl:W&&Ro({projectId:n,filename:W,baseUrl:this.baseStaticUrl}),samlIdpUsername:H,oidcLoginHint:B,oidcPrompt:F,oidcErrorRedirectUri:V,openInNewTabUrl:m},J=ai($);Wo(_,L)?K.next=(t,e,n,o)=>this.sdk.flow.start(c,Object.assign(Object.assign(Object.assign(Object.assign({tenant:d,redirectAuth:q},L),{lastAuth:J,preview:this.preview,abTestingKey:P,client:this.client}),w&&{redirectUrl:w}),{locale:Ho(x)}),R,t,e,n,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),o),y&&{exchangeCode:y,idpInitiated:!0}),L.descopeIdpInitiated&&{idpInitiated:!0}),b&&{token:b})):(s("projectId")||s("baseUrl")||s("executionId")||s("stepId"))&&(K.next=(...t)=>this.sdk.flow.next(h,u,...t)),this.stepState.update(K)}))}loadDescopeUiComponents(t){return n(this,void 0,void 0,(function*(){const e=yield br.descopeUI;if(!e)return;const o=(t=>[...Array.from(t.querySelectorAll("*")).reduce(((t,e)=>e.tagName.startsWith("DESCOPE-")?t.add(e.tagName.toLocaleLowerCase()):t),new Set)])(t);yield Promise.all(o.map((t=>n(this,void 0,void 0,(function*(){if(!!!customElements.get(t))if(e[t])try{return yield e[t]()}catch(e){if("NotSupportedError"!==e.name)throw e;console.debug(`${t} is already registered`)}else this.loggerWrapper.error(`Cannot load UI component "${t}"`,`Descope UI does not have a component named "${t}", available components are: "${Object.keys(e).join(", ")}"`)})))))}))}onStepChange(t,e){var i,r;return n(this,void 0,void 0,(function*(){const{htmlUrl:s,htmlLocaleUrl:a,direction:l,next:c,screenState:d,openInNewTabUrl:u}=t,h=document.createElement("template");h.innerHTML=yield this.getPageContent(s,a);const p=h.content.cloneNode(!0),f=this.loadDescopeUiComponents(h.content);this.sdk.webauthn.helpers.isSupported()?yield o(this,Bi,"m",Yi).call(this,p,c):p.querySelectorAll(`descope-button[${Io}="biometrics"]`).forEach((t=>t.setAttribute("disabled","true"))),!t.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=t.samlIdpUsername,d.form.email=t.samlIdpUsername),oi(p,d,d.componentsConfig,this.formConfig,this.errorTransformer,this.loggerWrapper);const{geo:g}=yield this.getExecutionContext();((t,e)=>{Array.from(t.querySelectorAll('descope-phone-field[default-code="autoDetect"]')).forEach((t=>{t.setAttribute("default-code",e)}))})(p,g);const v=()=>n(this,void 0,void 0,(function*(){var t,n;yield f;const i=this.shadowRoot.querySelector("div");var r,s;r=i,s=null===(t=null==d?void 0:d.totp)||void 0===t?void 0:t.image,ni(r,"descope-totp-image",s),((t,e)=>{ni(t,"descope-notp-image",e)})(i,null===(n=null==d?void 0:d.notp)||void 0===n?void 0:n.image),this.rootElement.replaceChildren(p),setTimeout((()=>{((t,e)=>{Yo(t,null==e?void 0:e.inputs),Yo(t,null==e?void 0:e.form)})(this.rootElement,d);const t=this.rootElement.querySelectorAll("descope-email-field"),e=this.rootElement.querySelectorAll("descope-password"),n=this.rootElement.querySelectorAll("descope-new-password");document.querySelectorAll('[data-hidden-input="true"]').forEach((t=>t.remove())),[...t,...e,...n].forEach((t=>o(this,Bi,"m",Zi).call(this,t)))}));const a=!e.htmlUrl;((t,e,n)=>{if(!0===e||"skipFirstScreen"===e&&!n){const e=t.querySelector("*[name]");setTimeout((()=>{null==e||e.focus()}))}})(this.rootElement,this.autoFocus,a),this.validateOnBlur&&(t=>{t.querySelectorAll("*[name]").forEach((t=>{t.addEventListener("blur",(()=>{var e;const n=t.focus;t.focus=()=>{},null===(e=t.reportValidity)||void 0===e||e.call(t),setTimeout((()=>{t.focus=n}))}))}))})(this.rootElement),o(this,Bi,"m",sr).call(this,c),a&&o(this,Bi,"m",lr).call(this,"ready",{}),o(this,Bi,"m",lr).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${Io}="polling"]`)){const t=yield this.getFlowConfig(),e=yield this.getProjectConfig(),n=yield c(xo,t.version,e.componentsVersion,{});o(this,zi,"f").call(this,n)}u&&!e.openInNewTabUrl&&window.open(u,"_blank")}));l?o(this,Bi,"m",ar).call(this,v,l):v()}))}}Fi=new WeakMap,Vi=new WeakMap,Hi=new WeakMap,Ji=new WeakMap,Gi=new WeakMap,zi=new WeakMap,Xi=new WeakMap,ir=new WeakMap,Bi=new WeakSet,Ki=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},Qi=function(t){const e=t.getAttribute("name");if(!["email"].includes(e)){const n=`user-${e}`;t.setAttribute("name",n),t.addEventListener("input",(()=>{t.setAttribute("name",t.value?e:n)}))}},Zi=function(t){if(!t)return;if("true"!==t.getAttribute("external-input"))return;t.querySelectorAll("input").forEach((e=>{const n=e.getAttribute("slot"),o=`input-${t.id}-${n}`,i=document.createElement("slot");i.setAttribute("name",o),i.setAttribute("slot",n),t.appendChild(i),e.setAttribute("slot",o),this.appendChild(e)}))},Yi=function(t,e){var r;return n(this,void 0,void 0,(function*(){null===(r=o(this,Vi,"f"))||void 0===r||r.abort();const s=t.querySelector('*[autocomplete="webauthn"]');if(s&&(yield ii())){const{options:t,transactionId:r}=(yield o(this,Xi,"f").call(this))||{};if(t&&r){o(this,Bi,"m",Qi).call(this,s),i(this,Vi,new AbortController,"f");const a=yield this.getFlowConfig(),l=yield this.getProjectConfig();this.sdk.webauthn.helpers.conditional(t,o(this,Vi,"f")).then((t=>n(this,void 0,void 0,(function*(){const n=yield e(s.id,a.version,l.componentsVersion,{transactionId:r,response:t});o(this,zi,"f").call(this,n)})))).catch((t=>{"AbortError"!==t.name&&this.loggerWrapper.error("Conditional login failed",t.message)}))}}}))},tr=function(){let t=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((e=>{var n,o;"slot"!==e.localName&&(null===(n=e.reportValidity)||void 0===n||n.call(e),t&&(t=null===(o=e.checkValidity)||void 0===o?void 0:o.call(e)))})),t},er=function(){return n(this,void 0,void 0,(function*(){const t=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${uo}])`));return(yield Promise.all(t.map((t=>n(this,void 0,void 0,(function*(){return{name:t.getAttribute("name"),value:t.value}})))))).reduce(((t,e)=>Object.assign(Object.assign({},t),{[e.name]:e.value})),{})}))},nr=function(t){const e=this.nextRequestStatus.subscribe((({isLoading:n})=>{n?t.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(e),t.removeAttribute("loading"))}))},or=function(t={}){var e,n;const o=Fo(t,["externalId","email","phone"]),i=Fo(t,["newPassword","password"]);if(o&&i)try{if(!globalThis.PasswordCredential)return;const t=new globalThis.PasswordCredential({id:o,password:i});null===(n=null===(e=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===e?void 0:e.store)||void 0===n||n.call(e,t)}catch(t){this.loggerWrapper.error("Could not store credentials",t.message)}},rr=function(t){this.rootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((e=>{e.addEventListener("input",(()=>{var n;(null===(n=e.checkValidity)||void 0===n?void 0:n.call(e))&&o(this,ir,"f").call(this,e,t)}))}))},sr=function(t){this.rootElement.querySelectorAll("descope-button:not([data-exclude-next])").forEach((e=>{e.onclick=()=>{o(this,ir,"f").call(this,e,t)}})),o(this,Bi,"m",rr).call(this,t)},ar=function(t,e){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),t()}),{once:!0});const n=e===Eo.forward?"slide-forward":"slide-backward";Array.from(this.rootElement.getElementsByClassName("input-container")).forEach(((t,e)=>{t.style["transition-delay"]=40*e+"ms",t.classList.add(n)})),this.rootElement.classList.add("fade-out")},lr=function(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))},customElements.get("descope-wc")?console.log("descope-wc is already defined"):customElements.define("descope-wc",yr);const Ir=document.createElement("template");Ir.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 kr extends HTMLElement{constructor(){super(),cr.add(this),dr.set(this,new Qo({messages:[]})),ur.set(this,void 0),hr.set(this,void 0),pr.set(this,void 0),fr.set(this,{resize:o(this,cr,"m",wr).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Ir.content.cloneNode(!0)),i(this,ur,this.shadowRoot.querySelector(".debugger"),"f"),i(this,hr,o(this,ur,"f").querySelector(".content"),"f"),i(this,pr,o(this,ur,"f").querySelector(".header"),"f")}updateData(t){o(this,dr,"f").update((e=>({messages:e.messages.concat(t)})))}connectedCallback(){var t;((t,e,n)=>{let o=0,i=0,r=0,s=0;function a(e){e.preventDefault(),o=r-e.clientX,i=s-e.clientY,r=e.clientX,s=e.clientY;const[a,l]=ri(t,t.offsetLeft-o,t.offsetTop-i,n);t.style.top=`${l}px`,t.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(t){t.preventDefault(),r=t.clientX,s=t.clientY,document.onmouseup=l,document.onmousemove=a}e?e.onmousedown=c:t.onmousedown=c})(o(this,ur,"f"),o(this,pr,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,fr,"f").resize),(t=o(this,ur,"f")).onmousemove=e=>{(e.target.w&&e.target.w!==e.target.offsetWidth||e.target.h&&e.target.h!==e.target.offsetHeight)&&t.onresize(e),e.target.w=e.target.offsetWidth,e.target.h=e.target.offsetHeight},o(this,ur,"f").onresize=o(this,cr,"m",mr).bind(this),o(this,dr,"f").subscribe(o(this,cr,"m",gr).bind(this))}disconnectedCallback(){o(this,dr,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,fr,"f").resize)}}dr=new WeakMap,ur=new WeakMap,hr=new WeakMap,pr=new WeakMap,fr=new WeakMap,cr=new WeakSet,gr=function(t){o(this,cr,"m",vr).call(this,t),o(this,cr,"m",mr).call(this)},vr=function(t){o(this,hr,"f").innerHTML=t.messages.map((t=>`\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 ${t.title}\n </div>\n <div class="msg_desc">\n ${t.description}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},mr=function(){o(this,hr,"f").querySelectorAll(".msg").forEach((t=>{const e=t.querySelector(".msg_desc"),n=e.scrollWidth>e.clientWidth,o=e.clientHeight>20;n||o?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},wr=function(){const[t,e]=ri(o(this,ur,"f"),Number.parseInt(o(this,ur,"f").style.left,10),Number.parseInt(o(this,ur,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,ur,"f").style.top=`${e}px`,o(this,ur,"f").style.left=`${t}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",kr);var jr=Object.freeze({__proto__:null,default:kr});const Cr='\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';var Sr=Object.freeze({__proto__:null,default:(t,e,o)=>n(void 0,void 0,void 0,(function*(){const{siteId:e}=t,n=Cr.replace(/{{SITE_ID}}/g,e),i=document.createElement("script");i.setAttribute("type","text/javascript"),i.setAttribute("id",e),i.text=n,document.body.appendChild(i),document.addEventListener("ftr:tokenReady",(t=>{o(t.detail)}))}))})}();
|
|
3
|
+
function Ye(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)t[o]=n[o]}return t}var tn=function t(e,n){function o(t,o,i){if("undefined"!=typeof document){"number"==typeof(i=Ye({},n,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),t=encodeURIComponent(t).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=t+"="+e.write(o,t)+r}}return Object.create({set:o,get:function(t){if("undefined"!=typeof document&&(!arguments.length||t)){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]=e.read(s,a),t===a)break}catch(t){}}return t?o[t]:o}},remove:function(t,e){o(t,"",Ye({},e,{expires:-1}))},withAttributes:function(e){return t(this.converter,Ye({},this.attributes,e))},withConverter:function(e){return t(Ye({},this.converter,e),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(e)}})}({read:function(t){return'"'===t[0]&&(t=t.slice(1,-1)),t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(t){return encodeURIComponent(t).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"});var en={default:"endpoint"},nn="Blocked by CSP",on="The endpoint parameter is not a valid URL",rn="Failed to load the JS script of the agent",sn="9319";function an(t,e){var n,o,i,r,s=[],a=(n=function(t){var e=function(t,e,n){if(n||2===arguments.length)for(var o,i=0,r=e.length;i<r;i++)!o&&i in e||(o||(o=Array.prototype.slice.call(e,0,i)),o[i]=e[i]);return t.concat(o||Array.prototype.slice.call(e))}([],t,!0);return{current:function(){return e[0]},postpone:function(){var t=e.shift();void 0!==t&&e.push(t)},exclude:function(){e.shift()}}}(t),r=0,o=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,r++))},i=new Set,[n.current(),function(t,e){var r,s=e instanceof Error?e.message:"";if(s===nn||s===on)n.exclude(),r=0;else if(s===sn)n.exclude();else if(s===rn){var a=Date.now()-t.getTime()<50,l=n.current();l&&a&&!i.has(l)&&(i.add(l),r=0),n.postpone()}else n.postpone();var c=n.current();return void 0===c?void 0:[c,null!=r?r:t.getTime()+o()-Date.now()]}]),l=a[0],c=a[1];if(void 0===l)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var d=function(t){var n=new Date,o=function(e){return s.push({url:t,startedAt:n,finishedAt:new Date,error:e})},i=e(t);return i.then((function(){return o()}),o),i.catch((function(t){if(s.length>=5)throw t;var e=c(n,t);if(!e)throw t;var o,i=e[0],r=e[1];return(o=r,new Promise((function(t){return setTimeout(t,o)}))).then((function(){return d(i)}))}))};return d(l).then((function(t){return[t,s]}))}var ln="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",cn=ln;function dn(n){var o;n.scriptUrlPattern;var i=n.token,r=n.apiKey,s=void 0===r?i:r,a=e(n,["scriptUrlPattern","token","apiKey"]),l=null!==(o=function(t,e){return function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(t,e)?t[e]:void 0}(n,"scriptUrlPattern"))&&void 0!==o?o:ln,c=function(){var t=[],e=function(){t.push({time:new Date,state:document.visibilityState})},n=function(t,e,n,o){return t.addEventListener(e,n,o),function(){return t.removeEventListener(e,n,o)}}(document,"visibilitychange",e);return e(),[t,n]}(),d=c[0],u=c[1];return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error("API key required");var t=function(t,e){return(Array.isArray(t)?t:[t]).map((function(t){return function(t,e){var n=encodeURIComponent;return t.replace(/<[^<>]+>/g,(function(t){return"<version>"===t?"3":"<apiKey>"===t?n(e):"<loaderVersion>"===t?n("3.9.9"):t}))}(String(t),e)}))}(l,s);return an(t,un)})).catch((function(t){throw u(),function(t){return t instanceof Error&&t.message===sn?new Error(rn):t}(t)})).then((function(e){var n=e[0],o=e[1];return u(),n.load(t(t({},a),{ldi:{attempts:o,visibilityStates:d}}))}))}function un(t){return function(t,e,n,o){var i,r=document,s="securitypolicyviolation",a=function(e){var n=new URL(t,location.href),o=e.blockedURI;o!==n.href&&o!==n.protocol.slice(0,-1)&&o!==n.origin||(i=e,l())};r.addEventListener(s,a);var l=function(){return r.removeEventListener(s,a)};return null==o||o.then(l,l),Promise.resolve().then(e).then((function(t){return l(),t}),(function(t){return new Promise((function(t){var e=new MessageChannel;e.port1.onmessage=function(){return t()},e.port2.postMessage(null)})).then((function(){if(l(),i)return n(i);throw t}))}))}(t,(function(){return function(t){return new Promise((function(e,n){if(function(t){if(URL.prototype)try{return new URL(t,location.href),!1}catch(t){if(t instanceof Error&&"TypeError"===t.name)return!0;throw t}}(t))throw new Error(on);var o=document.createElement("script"),i=function(){var t;return null===(t=o.parentNode)||void 0===t?void 0:t.removeChild(o)},r=document.head||document.getElementsByTagName("head")[0];o.onload=function(){i(),e()},o.onerror=function(){i(),n(new Error(rn))},o.async=!0,o.src=t,r.appendChild(o)}))}(t)}),(function(){throw new Error(nn)})).then(hn)}function hn(){var t=window,e="__fpjs_p_l_b",n=t[e];if(function(t,e){var n,o=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,t,e);(null==o?void 0:o.configurable)?delete t[e]:o&&!o.writable||(t[e]=void 0)}(t,e),"function"!=typeof(null==n?void 0:n.load))throw new Error(sn);return n}const pn=(t,e)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,o)=>{var i;return n[o]=[].concat((null===(i=t.hooks)||void 0===i?void 0:i[o])||[]).concat((null==e?void 0:e[o])||[]),n}),null!==(n=t.hooks)&&void 0!==n?n:t.hooks={}),t},fn=async t=>{if(!(null==t?void 0:t.ok))return{};const e=await(null==t?void 0:t.clone().json());return(null==e?void 0:e.authInfo)||e||{}},gn=async t=>{const e=await fn(t);return(null==e?void 0:e.user)||((null==e?void 0:e.hasOwnProperty("userId"))?e:void 0)},vn="undefined"!=typeof localStorage,mn=(t,e)=>vn&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(t,e)),wn=t=>vn&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(t)),bn=t=>vn&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(t)),yn=(...t)=>{console.debug(...t)},In="undefined"!=typeof window,kn=Math.pow(2,31)-1,jn="DS",Cn="DSR";function On(t=""){return wn(`${t}${Cn}`)||""}function Sn(t=""){bn(`${t}${Cn}`),bn(`${t}${jn}`),tn.remove(jn)}const xn=In&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",An="fp",Un=(t=!1)=>{const e=localStorage.getItem(An);if(!e)return null;const n=JSON.parse(e);return(new Date).getTime()>n.expiry&&!t?null:n.value},En=async(t,e=xn)=>{try{if(Un())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(e);o.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const i=new URL(e);i.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const r=i.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=dn({apiKey:t,endpoint:[o.toString(),en],scriptUrlPattern:[r,cn]}),a=await s,{requestId:l}=await a.get({linkedId:n}),c=((t,e)=>({vsid:t,vrid:e}))(n,l);(t=>{const e={value:t,expiry:(new Date).getTime()+864e5};localStorage.setItem(An,JSON.stringify(e))})(c)}catch(t){console.warn("Could not load fingerprint",t)}},Tn=t=>{const e=Un(!0);return e&&t.body&&(t.body.fpData=e),t},Ln="dls_last_user_login_id",_n="dls_last_user_display_name",Rn=()=>wn(Ln),Pn=()=>wn(_n),$n=t=>async(...e)=>{var n;e[1]=e[1]||{};const[,o={}]=e,i=Rn(),r=Pn();return i&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=i,o.lastAuth.name=r),await t(...e)};function Mn(){const t=[];return{pub:e=>{t.forEach((t=>t(e)))},sub:e=>{const n=t.push(e)-1;return()=>t.splice(n,1)}}}async function Dn(t){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=Vn(n.publicKey.challenge),n.publicKey.user.id=Vn(n.publicKey.user.id),null===(e=n.publicKey.excludeCredentials)||void 0===e||e.forEach((t=>{t.id=Vn(t.id)})),n}(t);return n=await navigator.credentials.create(e),JSON.stringify({id:n.id,rawId:Kn(n.rawId),type:n.type,response:{attestationObject:Kn(n.response.attestationObject),clientDataJSON:Kn(n.response.clientDataJSON)}});var n}async function qn(t){const e=Fn(t);return Bn(await navigator.credentials.get(e))}async function Nn(t,e){const n=Fn(t);return n.signal=e.signal,n.mediation="conditional",Bn(await navigator.credentials.get(n))}async function Wn(t=!1){if(!In)return Promise.resolve(!1);const e=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return e&&t&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():e}function Fn(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=Vn(n.publicKey.challenge),null===(e=n.publicKey.allowCredentials)||void 0===e||e.forEach((t=>{t.id=Vn(t.id)})),n}function Bn(t){return JSON.stringify({id:t.id,rawId:Kn(t.rawId),type:t.type,response:{authenticatorData:Kn(t.response.authenticatorData),clientDataJSON:Kn(t.response.clientDataJSON),signature:Kn(t.response.signature),userHandle:t.response.userHandle?Kn(t.response.userHandle):void 0}})}function Vn(t){const e=t.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(e),(t=>t.charCodeAt(0))).buffer}function Kn(t){return btoa(String.fromCharCode.apply(null,new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var Hn,Jn=(Hn=t=>({async signUp(e,n){const o=await t.webauthn.signUp.start(e,window.location.origin,n);if(!o.ok)return o;const i=await Dn(o.data.options);return await t.webauthn.signUp.finish(o.data.transactionId,i)},async signIn(e){const n=await t.webauthn.signIn.start(e,window.location.origin);if(!n.ok)return n;const o=await qn(n.data.options);return await t.webauthn.signIn.finish(n.data.transactionId,o)},async signUpOrIn(e){var n;const o=await t.webauthn.signUpOrIn.start(e,window.location.origin);if(!o.ok)return o;if(null===(n=o.data)||void 0===n?void 0:n.create){const e=await Dn(o.data.options);return await t.webauthn.signUp.finish(o.data.transactionId,e)}{const e=await qn(o.data.options);return await t.webauthn.signIn.finish(o.data.transactionId,e)}},async update(e,n){const o=await t.webauthn.update.start(e,window.location.origin,n);if(!o.ok)return o;const i=await Dn(o.data.options);return await t.webauthn.update.finish(o.data.transactionId,i)},helpers:{create:Dn,get:qn,isSupported:Wn,conditional:Nn}}),(...t)=>{const e=Hn(...t);return Object.assign(e.signUp,t[0].webauthn.signUp),Object.assign(e.signIn,t[0].webauthn.signIn),Object.assign(e.signUpOrIn,t[0].webauthn.signUpOrIn),Object.assign(e.update,t[0].webauthn.update),e});const Gn="/fedcm/config",zn=(t,e)=>({async oneTap(e,n,o,i){const r=null!=e?e:"google",s=await t.oauth.startNative(r,o,!0);if(!s.ok)return s;const{clientId:a,stateId:l,nonce:c}=s.data,d=await async function(){return new Promise(((t,e)=>{if(window.google)return void t(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?t(window.google.accounts.id):e("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){e("Failed to load Google GSI client script - failed to load")}}))}();return new Promise((e=>{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=>{e(t.oauth.finishNative(r,l,"","",n.credential))},nonce:c})),d.prompt((t=>{(null==t?void 0:t.isSkippedMoment())&&(null==i||i())}))}))},async launch(n){var o;const i={identity:{context:n||"signin",providers:[{configURL:t.httpClient.buildUrl(e+Gn),clientId:e}]}},r=await(null===(o=navigator.credentials)||void 0===o?void 0:o.get(i));return t.refresh(r.token)},isSupported:()=>In&&"IdentityCredential"in window});var Xn=t=>Object.assign(Object.assign({},t.flow),{start:async(...e)=>{const n=await Wn(),o=Object.assign(Object.assign({location:window.location.href},e[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return e[1]=o,t.flow.start(...e)}});const Qn=function(...t){return e=>t.reduce(((t,e)=>e(t)),e)}((t=>n=>{var{fpKey:o,fpLoad:i}=n,r=e(n,["fpKey","fpLoad"]);return In?(o&&i&&En(o).catch((()=>null)),t(pn(r,{beforeRequest:Tn}))):t(r)}),(t=>n=>{var{autoRefresh:o}=n,i=e(n,["autoRefresh"]);if(!o)return t(i);const{clearAllTimers:r,setTimer:s}=(()=>{const t=[];return{clearAllTimers:()=>{for(;t.length;)clearTimeout(t.pop())},setTimer:(e,n)=>{t.push(setTimeout(e,n))}}})();let a,c;In&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&new Date>a&&(yn("Expiration time passed, refreshing session"),d.refresh(On()||c))}));const d=t(pn(i,{afterRequest:async(t,e)=>{const{refreshJwt:n,sessionJwt:o}=await fn(e);if(401===(null==e?void 0:e.status))yn("Received 401, canceling all timers"),r();else if(o){if(a=(t=>{try{const e=l(t);if(e.exp)return new Date(1e3*e.exp)}catch(t){return null}})(o),!a)return void yn("Could not extract expiration time from session token");c=n;let t=((i=a)?i.getTime()-(new Date).getTime():0)-2e4;t>kn&&(yn(`Timeout is too large (${t}ms), setting it to ${kn}ms`),t=kn),r();const e=new Date(Date.now()+t).toLocaleTimeString("en-US",{hour12:!1});yn(`Setting refresh timer for ${e}. (${t}ms)`),s((()=>{yn("Refreshing session due to timer"),d.refresh(On()||n)}),t)}var i}}));return Bt(d,["logout","logoutAll"],(t=>async(...e)=>{const n=await t(...e);return yn("Clearing all timers"),r(),n}))}),(t=>e=>t(Object.assign(Object.assign({},e),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.16.0"},e.baseHeaders)}))),(t=>e=>{const n=Mn(),o=Mn(),i=t(pn(e,{afterRequest:async(t,e)=>{if(401===(null==e?void 0:e.status))n.pub(null),o.pub(null);else{const t=await gn(e);t&&o.pub(t);const{sessionJwt:i}=await fn(e);i&&n.pub(i)}}})),r=Bt(i,["logout","logoutAll"],(t=>async(...e)=>{const i=await t(...e);return n.pub(null),o.pub(null),i}));return Object.assign(r,{onSessionTokenChange:n.sub,onUserChange:o.sub})}),(t=>n=>{var{storeLastAuthenticatedUser:o=!0,keepLastAuthenticatedUserAfterLogout:i=!1}=n,r=e(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!o)return Object.assign(t(r),{getLastUserLoginId:Rn,getLastUserDisplayName:Pn});const s=t(pn(r,{afterRequest:async(t,e)=>{var n;const o=await gn(e),i=null===(n=null==o?void 0:o.loginIds)||void 0===n?void 0:n[0],r=null==o?void 0:o.name;i&&((t=>{mn(Ln,t)})(i),(t=>{mn(_n,t)})(r))}}));let a=Bt(s,["flow.start"],$n);return a=Bt(a,["logout","logoutAll"],(t=>e=>async(...n)=>{const o=await e(...n);return t||(bn(Ln),bn(_n)),o})(i)),Object.assign(a,{getLastUserLoginId:Rn,getLastUserDisplayName:Pn})}),(t=>n=>{var{persistTokens:o,sessionTokenViaCookie:i,storagePrefix:r}=n,s=e(n,["persistTokens","sessionTokenViaCookie","storagePrefix"]);if(!o||!In)return t(s);const a=t(pn(s,{beforeRequest:(l=r,t=>Object.assign(t,{token:t.token||On(l)})),afterRequest:async(t,n)=>{const o=/^\/v\d+\/mgmt\//.test(t.path);401===(null==n?void 0:n.status)?o||Sn(r):((t={},n,o)=>{var{refreshJwt:i,sessionJwt:r}=t,s=e(t,["refreshJwt","sessionJwt"]);void 0===n&&(n=!1),void 0===o&&(o=""),i&&mn(`${o}${Cn}`,i),r&&(n?function(t,e,{cookiePath:n,cookieDomain:o,cookieExpiration:i}){if(e){const r=new Date(1e3*i),s=function(t){const e=window.location.hostname.split("."),n=t.split(".");return e.slice(-n.length).join(".")===t}(o);tn.set(t,e,{path:n,domain:s?o:void 0,expires:r,sameSite:"Strict",secure:!0})}}(jn,r,s):mn(`${o}${jn}`,r))})(await fn(n),i,r)}}));var l;const c=Bt(a,["logout","logoutAll"],(t=>e=>async(...n)=>{const o=await e(...n);return Sn(t),o})(r));return Object.assign(c,{getRefreshToken:()=>On(r),getSessionToken:()=>function(t=""){return tn.get(jn)||wn(`${t}${jn}`)||""}(r)})}))(((...t)=>{const e=Ze(...t);return Object.assign(Object.assign({},e),{flow:Xn(e),webauthn:Jn(e),fedcm:zn(e,t[0].projectId)})})),Zn="undefined"!=typeof localStorage,Yn=Zn&&localStorage.getItem("base.content.url")||"",to="config.json",eo="base.ui.components.url",no=Zn&&localStorage.getItem(eo)||"https://static.descope.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",oo=Zn&&localStorage.getItem(eo)||"https://cdn.jsdelivr.net/npm/@descope/web-components-ui@<version>/dist/umd/index.js",io="descope-login-flow",ro="code",so="ra-challenge",ao="ra-callback",lo="ra-backup-callback",co="ra-initiator",uo="data-exclude-field",ho="dls_last_auth",po="state_id",fo="saml_idp_state_id",go="saml_idp_username",vo="descope_idp_initiated",mo="sso_app_id",wo="oidc_login_hint",bo="oidc_prompt",yo="oidc_error_redirect_uri",Io="data-type",ko="redirect",jo="poll",Co="webauthnCreate",Oo="webauthnGet",So="loadForm",xo="submit",Ao="polling",Uo=["descope-multi-select-combo-box","descope-text-area"];var Eo;function To(t){return new URLSearchParams(window.location.search).get(t)}function Lo(t){if(window.history.replaceState&&To(t)){const e=new URL(window.location.href),n=new URLSearchParams(e.search);n.delete(t),e.search=n.toString(),window.history.replaceState({},"",e.toString())}}function _o(t,e){return n(this,void 0,void 0,(function*(){const n=yield fetch(t,{cache:"default"});if(!n.ok)throw Error(`Error fetching URL ${t} [${n.status}]`);return{body:yield n[e||"text"](),headers:Object.fromEntries(n.headers.entries())}}))}!function(t){t.backward="backward",t.forward="forward"}(Eo||(Eo={}));function Ro({projectId:t,filename:e,assetsFolder:n="v2-beta",baseUrl:o}){const i=new URL(Yn||o||"https://static.descope.com/pages");return i.pathname=((...t)=>t.join("/").replace(/\/+/g,"/"))(i.pathname,t,n,e),i.toString()}function Po(t,e){if(!e)return;const n=+t,o=+e;return Number.isNaN(n)||Number.isNaN(o)?void 0:n>o?Eo.forward:n<o?Eo.backward:void 0}const $o=()=>{const[t="",e=""]=(To(io)||"").split("_");return{executionId:t,stepId:e}};function Mo(){Lo(io)}const Do=t=>t.replace(/-./g,(t=>t[1].toUpperCase())),qo=()=>{const{executionId:t,stepId:e}=$o();(t||e)&&Mo();const n=To("t")||void 0;n&&Lo("t");const o=To(ro)||void 0;o&&Lo(ro);const i=To("err")||void 0;i&&Lo("err");const{redirectAuthCodeChallenge:r,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:l}={redirectAuthCodeChallenge:To(so),redirectAuthCallbackUrl:To(ao),redirectAuthBackupCallbackUri:To(lo),redirectAuthInitiator:To(co)};(r||s||a||l)&&(Lo(so),Lo(ao),Lo(lo),Lo(co));const c=To(po);c&&Lo(po);const d=To(fo);d&&Lo(fo);const u=To(go);d&&Lo(go);const h=To(vo);h&&Lo(vo);const p=To(mo);p&&Lo(mo);const f=To(wo);f&&Lo(wo);const g=To(bo);g&&Lo(bo);const v=To(yo);v&&Lo(yo);return{executionId:t,stepId:e,token:n,code:o,exchangeError:i,redirectAuthCodeChallenge:r,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:l,ssoQueryParams:{oidcIdpStateId:c,samlIdpStateId:d,samlIdpUsername:u,descopeIdpInitiated:"true"===h,ssoAppId:p,oidcLoginHint:f,oidcPrompt:g,oidcErrorRedirectUri:v}}},No=t=>{let e,n;return(...o)=>{return e&&(r=o,(i=e).length===r.length&&i.every(((t,e)=>t===r[e])))||(e=o,n=t(...o)),n;var i,r}};const Wo=(t,{oidcIdpStateId:e,samlIdpStateId:n,samlIdpUsername:o,ssoAppId:i,oidcLoginHint:r,oidcPrompt:s,oidcErrorRedirectUri:a})=>!(!t||e||n||o||i||r||s||a),Fo=t=>null==t?void 0:t.submit(),Bo=(t,e)=>{const n=e.find((e=>t[e]));return n?t[n]:null},Vo=(t,e=100)=>{let n;return function(...o){n||t.apply(this,o),clearTimeout(n),n=setTimeout((()=>{n=null}),e)}};function Ko(t){let e=navigator.language;return e&&"zh-TW"!==e&&(e=e.split("-")[0]),(t||e||"").toLowerCase()}var Ho,Jo,Go,zo;function Xo(t,e){const n=Object.getOwnPropertyNames(t),o=Object.getOwnPropertyNames(e);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const i=n[o],r=t[i],s=e[i];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!Xo(r,s))return!1}else if(r!==s)return!1}return!0}class Qo{constructor(t={},{updateOnlyOnChange:e=!0}={}){Ho.set(this,void 0),Jo.set(this,{}),Go.set(this,0),zo.set(this,!1),this.update=t=>{const e="function"==typeof t?t(o(this,Ho,"f")):t,n=Object.assign(Object.assign({},o(this,Ho,"f")),e);if(!o(this,zo,"f")||!Xo(o(this,Ho,"f"),n)){const t=o(this,Ho,"f");i(this,Ho,n,"f"),Object.freeze(o(this,Ho,"f")),setTimeout((()=>{Object.values(o(this,Jo,"f")).forEach((e=>e(n,t,((t,e)=>n=>t[n]!==e[n])(n,t))))}),0)}},i(this,Ho,t,"f"),i(this,zo,e,"f")}get current(){return Object.assign({},o(this,Ho,"f"))}subscribe(t){return i(this,Go,o(this,Go,"f")+1,"f"),o(this,Jo,"f")[o(this,Go,"f")]=t,o(this,Go,"f").toString()}unsubscribe(t){const e=!!o(this,Jo,"f")[t];return e&&delete o(this,Jo,"f")[t],e}unsubscribeAll(){return i(this,Jo,{},"f"),!0}}Ho=new WeakMap,Jo=new WeakMap,Go=new WeakMap,zo=new WeakMap;const Zo=["disabled"],Yo=(t,e)=>{Object.entries(e||{}).forEach((([e,n])=>{Array.from(t.querySelectorAll(`*[name="${e}"]:not([${uo}])`)).forEach((t=>{t.value=n}))}))},ti=(t,e)=>t.replace(/{{(.+?)}}/g,((t,n)=>{return o=e,n.split(".").reduce(((t,e)=>(null==t?void 0:t[e])||""),o);var o})),ei=(t,e,n)=>{t.querySelectorAll(`[${Io}="${e}"]`).forEach((t=>{t.setAttribute("href",n)}))},ni=(t,e,n)=>{var o,i;const r=null===(o=customElements.get(e))||void 0===o?void 0:o.cssVarList.url;n&&r&&(null===(i=null==t?void 0:t.style)||void 0===i||i.setProperty(r,`url(data:image/jpg;base64,${n})`))},oi=(t,e,n,o,i,r)=>{var s,a;let l=null==e?void 0:e.errorText;try{l=(null==i?void 0:i({text:null==e?void 0:e.errorText,type:null==e?void 0:e.errorType}))||(null==e?void 0:e.errorText)}catch(t){r.error("Error transforming error message",t.message)}((t,e,n="")=>{t.querySelectorAll(`[${Io}="${e}"]`).forEach((t=>{t.textContent=n,t.classList[n?"remove":"add"]("hide")}))})(t,"error-message",l),ei(t,"totp-link",null===(s=null==e?void 0:e.totp)||void 0===s?void 0:s.provisionUrl),ei(t,"notp-link",null===(a=null==e?void 0:e.notp)||void 0===a?void 0:a.redirectUrl),((t,e)=>{t.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((t=>{t.textContent=ti(t.textContent,e);const n=t.getAttribute("href");n&&t.setAttribute("href",ti(n,e))}))})(t,e),((t,e,n)=>{e&&Object.keys(e).forEach((o=>{t.querySelectorAll(`[name=${o}]`).forEach((t=>{const i=e[o];Object.keys(i).forEach((e=>{let o=i[e];if("string"!=typeof o)try{o=JSON.stringify(o)}catch(t){n.error(`Could not stringify value "${o}" for "${e}"`,t.message),o=""}t.setAttribute(e,o)}))}))}))})(t,n,r),((t,e)=>{t.querySelectorAll("[data-has-dynamic-attr-values]").forEach((t=>{Array.from(t.attributes).forEach((t=>{t.value=ti(t.value,e)}))}))})(t,e),((t,e)=>{Object.entries(e).forEach((([e,n])=>{t.querySelectorAll(`[name="${e}"]`).forEach((t=>{Object.entries(n).forEach((([e,n])=>{Zo.includes(e)&&t.setAttribute(e,n)}))}))}))})(t,o)},ii=No((()=>n(void 0,void 0,void 0,(function*(){var t,e,n,o,i;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const r=Promise.all([null===(t=window.PublicKeyCredential)||void 0===t?void 0:t.isConditionalMediationAvailable(),null===(e=window.PublicKeyCredential)||void 0===e?void 0:e.isUserVerifyingPlatformAuthenticatorAvailable()]).then((t=>t.every((t=>!!t)))),s=(()=>{var t;const e=null===(t=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===t?void 0:t.brands,n=null==e?void 0:e.find((({brand:t,version:e})=>"Chromium"===t&&parseFloat(e)));return n?n.version:0})()>=108;return yield(n=100,o=r,i=s,new Promise(((t,e)=>{let r=!1;const s=setTimeout((()=>{r=!0,void 0!==i?t(i):e(new Error(`Promise timed out after ${n} ms`))}),n);o.then((e=>{r||(clearTimeout(s),t(e))})).catch((t=>{r||(clearTimeout(s),e(t))}))})))}catch(t){return console.error("Conditional login check failed",t),!1}})))),ri=(t,e,n,o={})=>{var i,r,s,a;return[Math.min(Math.max(e,("all"===o.left?t.offsetWidth:null!==(i=o.left)&&void 0!==i?i:0)-t.offsetWidth),window.innerWidth-("all"===o.right?t.offsetWidth:null!==(r=o.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===o.top?t.offsetHeight:null!==(s=o.top)&&void 0!==s?s:0)-t.offsetHeight),window.innerHeight-("all"===o.bottom?t.offsetHeight:null!==(a=o.bottom)&&void 0!==a?a:0))]},si={"lastAuth.loginId":{"not-empty":t=>!!t.loginId,empty:t=>!t.loginId},idpInitiated:{"is-true":t=>!!t.code,"is-false":t=>!t.code},externalToken:{"is-true":t=>!!t.token,"is-false":t=>!t.token},abTestingKey:{"greater-than":(t,e)=>(t.abTestingKey||0)>e,"less-than":(t,e)=>(t.abTestingKey||0)<e}};function ai(t){const e={};if(t)try{Object.assign(e,JSON.parse(localStorage.getItem(ho)))}catch(t){}return e}const li="dls_ab_testing_id",ci=document.createElement("template");ci.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 di=(t,e="")=>Object.keys(t).reduce(((n,o)=>{var i;if("object"==typeof t[o]&&null!==t[o]&&!(null===(i=t[o])||void 0===i?void 0:i.value))return Object.assign(Object.assign({},n),di(t[o],`${e+o}.`));const r="object"==typeof t[o]?t[o]:{value:t[o]},s=Object.assign(Object.assign({},n),{[e+o]:r,[`form.${e}${o}`]:r});return"displayName"===o?Object.assign(Object.assign({},s),{[`${e}fullName`]:r,[`form.${e}fullName`]:r}):s}),[]);var ui,hi,pi,fi,gi,vi,mi,wi,bi,yi,Ii,ki,ji,Ci,Oi,Si,xi,Ai,Ui,Ei,Ti,Li,_i,Ri,Pi,$i,Mi,Di,qi,Ni,Wi,Fi,Bi,Vi,Ki,Hi,Ji,Gi,zi,Xi,Qi,Zi,Yi,tr,er,nr,or,ir,rr,sr,ar,lr,cr,dr,ur,hr,pr,fr,gr,vr,mr;class wr 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(t){super(),ui.add(this),this.logger=console,hi.set(this,!1),this.loggerWrapper={error:(t,e="")=>{this.logger.error(t,e,new Error),o(this,ui,"m",Di).call(this,t,e)},warn:(t,e="")=>{this.logger.warn(t,e)},info:(t,e="",n={})=>{this.logger.info(t,e,n)},debug:(t,e="")=>{this.logger.debug(t,e)}},pi.set(this,new Qo),fi.set(this,new Qo),gi.set(this,{}),this.getComponentsContext=()=>o(this,gi,"f"),this.nextRequestStatus=new Qo({isLoading:!1}),vi.set(this,void 0),mi.set(this,{popstate:o(this,ui,"m",ji).bind(this),componentsContext:o(this,ui,"m",Ri).bind(this)}),wi.set(this,void 0),Ai.set(this,No((()=>n(this,void 0,void 0,(function*(){const t=Ro({projectId:this.projectId,filename:to,baseUrl:this.baseStaticUrl});try{const{body:e,headers:n}=yield _o(t,"json");return{projectConfig:e,executionContext:{geo:n["x-geo"]}}}catch(t){return{isMissingConfig:!0}}}))))),Ei.set(this,void 0),i(this,wi,t,"f"),o(this,ui,"m",bi).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(t){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 t,e;const n=this.getAttribute("theme");if("os"===n){return window.matchMedia&&(null===(e=null===(t=window.matchMedia)||void 0===t?void 0:t.call(window,"(prefers-color-scheme: dark)"))||void 0===e?void 0:e.matches)?"dark":"light"}return n||"light"}get autoFocus(){var t;const e=null!==(t=this.getAttribute("auto-focus"))&&void 0!==t?t:"true";return"skipFirstScreen"===e?e:"true"===e}get validateOnBlur(){return"true"===this.getAttribute("validate-on-blur")}get storeLastAuthenticatedUser(){var t;return"true"===(null!==(t=this.getAttribute("store-last-authenticated-user"))&&void 0!==t?t:"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(t=>{try{return di(JSON.parse(t))}catch(t){return{}}})(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return t=this.formConfig,e="value",Object.fromEntries(Object.entries(t).map((([t,n])=>[t,n[e]])));var t,e}getExecutionContext(){return n(this,void 0,void 0,(function*(){const{executionContext:t}=yield o(this,Ai,"f").call(this);return t}))}getProjectConfig(){return n(this,void 0,void 0,(function*(){const{projectConfig:t}=yield o(this,Ai,"f").call(this);return t}))}getFlowConfig(){var t,e;return n(this,void 0,void 0,(function*(){const n=yield this.getProjectConfig(),o=(null===(t=null==n?void 0:n.flows)||void 0===t?void 0:t[this.flowId])||{};return null!==(e=o.version)&&void 0!==e||(o.version=0),o}))}getTargetLocales(){return n(this,void 0,void 0,(function*(){const t=yield this.getFlowConfig();return((null==t?void 0:t.targetLocales)||[]).map((t=>t.toLowerCase()))}))}connectedCallback(){return n(this,void 0,void 0,(function*(){if(this.shadowRoot.isConnected){if(o(this,fi,"f").subscribe(o(this,ui,"m",Mi).bind(this)),o(this,fi,"f").update({isDebug:this.debug}),o(this,ui,"m",yi).call(this))return void o(this,ui,"m",Ii).call(this);if(o(this,ui,"m",ki).call(this),i(this,Ei,o(this,ui,"m",Ui).call(this),"f"),yield o(this,ui,"m",Si).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,Ai,"f").call(this)).isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");o(this,ui,"m",Ti).call(this),yield o(this,ui,"m",Wi).call(this),yield o(this,ui,"m",Li).call(this),o(this,ui,"m",qi).call(this);const{executionId:t,stepId:e,token:n,code:r,exchangeError:s,redirectAuthCallbackUrl:a,redirectAuthBackupCallbackUri:l,redirectAuthCodeChallenge:c,redirectAuthInitiator:d,ssoQueryParams:u}=qo();window.addEventListener("popstate",o(this,mi,"f").popstate),window.addEventListener("components-context",o(this,mi,"f").componentsContext),o(this,pi,"f").subscribe(o(this,ui,"m",Oi).bind(this)),o(this,pi,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenant,redirectUrl:this.redirectUrl,locale:this.locale,stepId:e,executionId:t,token:n,code:r,exchangeError:s,redirectAuthCallbackUrl:a,redirectAuthBackupCallbackUri:l,redirectAuthCodeChallenge:c,redirectAuthInitiator:d},u)),i(this,hi,!0,"f")}}))}disconnectedCallback(){o(this,pi,"f").unsubscribeAll(),o(this,fi,"f").unsubscribeAll(),o(this,ui,"m",$i).call(this),window.removeEventListener("popstate",o(this,mi,"f").popstate),window.removeEventListener("components-context",o(this,mi,"f").componentsContext)}attributeChangedCallback(t,e,n){if(this.shadowRoot.isConnected&&o(this,hi,"f")&&e!==n&&wr.observedAttributes.includes(t)){o(this,ui,"m",ki).call(this);const i=null===e;o(this,pi,"f").update((({stepId:e,executionId:o})=>{let r=e,s=o;return i||(s=null,r=null,Mo()),{[Do(t)]:n,stepId:r,executionId:s}})),o(this,fi,"f").update({isDebug:this.debug}),"theme"===t&&o(this,ui,"m",Pi).call(this)}}}function br(t,e){return`sdkScriptsResults.${e?`${t}_${e}`:t}`}hi=new WeakMap,pi=new WeakMap,fi=new WeakMap,gi=new WeakMap,vi=new WeakMap,mi=new WeakMap,wi=new WeakMap,Ai=new WeakMap,Ei=new WeakMap,ui=new WeakSet,bi=function(){this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(ci.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#wc-root")},yi=function(){return!this.shadowRoot.host.closest("form")&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)},Ii=function(){const t=this.shadowRoot.host,e=document.createElement("form");e.style.width="100%",e.style.height="100%",t.parentElement.appendChild(e),e.appendChild(t)},ki=function(){const t=["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(wr.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[Do(e)])throw Error(`${e} 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')},ji=function(){const{stepId:t,executionId:e}=$o();o(this,pi,"f").update({stepId:t,executionId:e})},Ci=function(t,e){this.sdk=Qn(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout},wr.sdkConfigOverrides),{projectId:t,baseUrl:e})),["start","next"].forEach((t=>{const e=this.sdk.flow[t];this.sdk.flow[t]=(...t)=>n(this,void 0,void 0,(function*(){this.nextRequestStatus.update({isLoading:!0});try{return yield e(...t)}catch(t){return{error:{errorCode:"J151000",errorDescription:t.toString()}}}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},Oi=function(t,e,i){return n(this,void 0,void 0,(function*(){const{projectId:e,baseUrl:n}=t;if(i("projectId")||i("baseUrl")){if(!e)return;o(this,ui,"m",Ci).call(this,e,n)}o(this,wi,"f").call(this,t)}))},Si=function(){return n(this,void 0,void 0,(function*(){return(yield o(this,Ai,"f").call(this)).isMissingConfig&&(yield o(this,ui,"m",xi).call(this))}))},xi=function(){return n(this,void 0,void 0,(function*(){const t=Ro({projectId:this.projectId,filename:to,assetsFolder:"v2-alpha",baseUrl:this.baseStaticUrl});try{return yield _o(t,"json"),!0}catch(t){return!1}}))},Ui=function(){return n(this,void 0,void 0,(function*(){const t=Ro({projectId:this.projectId,filename:"theme.json",baseUrl:this.baseStaticUrl});try{const{body:e}=yield _o(t,"json");return e}catch(t){return void this.loggerWrapper.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}}))},Ti=function(){var t,e;return n(this,void 0,void 0,(function*(){const{projectConfig:n}=yield o(this,Ai,"f").call(this),i=null===(e=null===(t=null==n?void 0:n.cssTemplate)||void 0===t?void 0:t[this.theme])||void 0===e?void 0:e.fonts;i&&Object.values(i).forEach((t=>(t=>{if(!t)return;const e=document.createElement("link");e.href=t,e.rel="stylesheet",document.head.appendChild(e)})(t.url)))}))},Li=function(){return n(this,void 0,void 0,(function*(){yield o(this,ui,"m",_i).call(this),yield o(this,ui,"m",Pi).call(this)}))},_i=function(){var t,e,i,r;return n(this,void 0,void 0,(function*(){const n=document.createElement("style"),s=yield o(this,Ei,"f");n.innerText=((null===(t=null==s?void 0:s.light)||void 0===t?void 0:t.globals)||"")+((null===(e=null==s?void 0:s.dark)||void 0===e?void 0:e.globals)||"");const a=yield wr.descopeUI;(null==a?void 0:a.componentsThemeManager)&&!a.componentsThemeManager.hasThemes&&(a.componentsThemeManager.themes={light:null===(i=null==s?void 0:s.light)||void 0===i?void 0:i.components,dark:null===(r=null==s?void 0:s.dark)||void 0===r?void 0:r.components}),this.shadowRoot.appendChild(n)}))},Ri=function(t){i(this,gi,Object.assign(Object.assign({},o(this,gi,"f")),t.detail),"f")},Pi=function(){return n(this,void 0,void 0,(function*(){this.rootElement.setAttribute("data-theme",this.theme);const t=yield wr.descopeUI;(null==t?void 0:t.componentsThemeManager)&&(t.componentsThemeManager.currentThemeName=this.theme)}))},$i=function(){var t;null===(t=o(this,vi,"f"))||void 0===t||t.remove(),i(this,vi,null,"f")},Mi=function({isDebug:t}){return n(this,void 0,void 0,(function*(){t?(i(this,vi,document.createElement("descope-debugger"),"f"),Object.assign(o(this,vi,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return jr})),document.body.appendChild(o(this,vi,"f"))):o(this,ui,"m",$i).call(this)}))},Di=function(t,e){var n;t&&this.debug&&(null===(n=o(this,vi,"f"))||void 0===n||n.updateData({title:t,description:e}))},qi=function(){this.rootElement.onkeydown=t=>{var e,n,o;const i=!!(null===(e=this.shadowRoot.activeElement)||void 0===e?void 0:e.getAttribute("href")),r=Uo.includes(null!==(o=null===(n=this.shadowRoot.activeElement)||void 0===n?void 0:n.localName)&&void 0!==o?o:"");if("Enter"!==t.key||i||r)return;t.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((t=>"true"===t.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const l=Array.from(s).filter((t=>"button"===t.getAttribute("data-type")));if(1===l.length)"false"!==l[0].getAttribute("auto-submit")&&l[0].click();else if(0===l.length){const t=Array.from(s).filter((t=>"sso"===t.getAttribute("data-type")));1===t.length&&"false"!==t[0].getAttribute("auto-submit")&&t[0].click()}}},Ni=function(){var t,e;return n(this,void 0,void 0,(function*(){const n=null===(e=null===(t=yield o(this,Ai,"f").call(this))||void 0===t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return n||(this.logger.error("Did not get components version, using latest version"),"latest")}))},Wi=function(){return n(this,void 0,void 0,(function*(){wr.descopeUI?this.loggerWrapper.debug("DescopeUI is already loading, probably multiple flows are running on the same page"):wr.descopeUI=new Promise((t=>{if(globalThis.DescopeUI)return void t(globalThis.DescopeUI);const e=t=>{const e=document.createElement("script");return e.id="load-descope-ui",e.src=t,e},i=(t,e)=>t.replace("<version>",e),r=(e,n)=>{const o=()=>{this.loggerWrapper.error("Cannot load DescopeUI",`Make sure this URL is valid and return the correct script: "${e.src}"`),n()};e.addEventListener("load",(()=>{globalThis.DescopeUI||o(),t(globalThis.DescopeUI)})),e.addEventListener("error",o)};(()=>{n(this,void 0,void 0,(function*(){const n=yield o(this,ui,"m",Ni).call(this),s=e(i(no,n));r(s,(()=>{s.remove(),this.loggerWrapper.info("Trying to load DescopeUI from a fallback URL");const o=e(i(oo,n));r(o,(()=>{t(void 0)})),document.body.append(o)})),document.body.append(s)}))})()}))}))},wr.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.22.0"}};class yr extends wr{static set sdkConfigOverrides(t){wr.sdkConfigOverrides=t}constructor(){const t=new Qo({deferredRedirect:!1});super(t.update.bind(t)),Fi.add(this),this.stepState=new Qo({},{updateOnlyOnChange:!1}),Bi.set(this,void 0),Vi.set(this,null),Ki.set(this,{visibilitychange:o(this,Fi,"m",Hi).bind(this)}),Ji.set(this,((t,e,r,s,a)=>{r===jo&&i(this,Bi,setTimeout((()=>n(this,void 0,void 0,(function*(){var n;let i;try{i=yield this.sdk.flow.next(t,e,Ao,s,a,{})}catch(n){return void o(this,Ji,"f").call(this,t,e,r,s,a)}o(this,zi,"f").call(this,i);const{action:l}=null!==(n=null==i?void 0:i.data)&&void 0!==n?n:{};o(this,Ji,"f").call(this,t,e,l,s,a)}))),2e3),"f")})),Gi.set(this,(()=>{clearTimeout(o(this,Bi,"f")),i(this,Bi,null,"f")})),zi.set(this,(t=>{var e,n,i,r,s,a,l,c,d,u,h;if(!(null==t?void 0:t.ok)){const a=null===(e=null==t?void 0:t.response)||void 0===e?void 0:e.url,l=`${null===(n=null==t?void 0:t.response)||void 0===n?void 0:n.status} - ${null===(i=null==t?void 0:t.response)||void 0===i?void 0:i.statusText}`;return o(this,Fi,"m",ar).call(this,"error",(null==t?void 0:t.error)||{errorCode:"J151001",errorDescription:l,errorMessage:a}),void this.loggerWrapper.error((null===(r=null==t?void 0:t.error)||void 0===r?void 0:r.errorDescription)||a,(null===(s=null==t?void 0:t.error)||void 0===s?void 0:s.errorMessage)||l)}null===(l=null===(a=t.data)||void 0===a?void 0:a.runnerLogs)||void 0===l||l.forEach((t=>{const{level:e,title:n,log:o}=t;e&&this.loggerWrapper[e]?this.loggerWrapper[e](n,o):this.loggerWrapper.info(n,o)}));const p=null===(u=null===(d=null===(c=t.data)||void 0===c?void 0:c.screen)||void 0===d?void 0:d.state)||void 0===u?void 0:u.errorText;(null===(h=t.data)||void 0===h?void 0:h.error)?this.loggerWrapper.error(`[${t.data.error.code}]: ${t.data.error.description}`,`${p?`${p} - `:""}${t.data.error.message}`):p&&this.loggerWrapper.error(p);const{status:f,authInfo:g,lastAuth:v}=t.data;if("completed"===f)return this.storeLastAuthenticatedUser&&function(t){(null==t?void 0:t.authMethod)&&Zn&&localStorage.setItem(ho,JSON.stringify(t))}(v),void o(this,Fi,"m",ar).call(this,"success",g);const{executionId:m,stepId:w,stepName:b,action:y,screen:I,redirect:k,openInNewTabUrl:j,webauthn:C,error:O,samlIdpResponse:S}=t.data;y!==jo?(this.loggerWrapper.info(`Step "${b||`#${w}`}" is ${f}`,"",{screen:I,status:f,stepId:w,stepName:b,action:y,error:O}),this.flowState.update({stepId:w,executionId:m,action:y,redirectTo:null==k?void 0:k.url,openInNewTabUrl:j,screenId:null==I?void 0:I.id,screenState:null==I?void 0:I.state,webauthnTransactionId:null==C?void 0:C.transactionId,webauthnOptions:null==C?void 0:C.options,samlIdpResponseUrl:null==S?void 0:S.url,samlIdpResponseSamlResponse:null==S?void 0:S.samlResponse,samlIdpResponseRelayState:null==S?void 0:S.relayState})):this.flowState.update({action:y})})),Xi.set(this,No((()=>n(this,void 0,void 0,(function*(){var t;try{const e=yield this.sdk.webauthn.signIn.start("",window.location.origin);return e.ok||this.loggerWrapper.warn("Webauthn start failed",null===(t=null==e?void 0:e.error)||void 0===t?void 0:t.errorMessage),e.data}catch(t){this.loggerWrapper.warn("Webauthn start failed",t.message)}}))))),or.set(this,Vo(((t,e)=>n(this,void 0,void 0,(function*(){if("true"===t.getAttribute("formnovalidate")||o(this,Fi,"m",Yi).call(this)){const i=null==t?void 0:t.getAttribute("id");o(this,Fi,"m",er).call(this,t);const r=yield o(this,Fi,"m",tr).call(this),s=(n=t,Array.from((null==n?void 0:n.attributes)||[]).reduce(((t,e)=>{var n;const o=null===(n=new RegExp("^data-descope-(\\S+)$").exec(e.name))||void 0===n?void 0:n[1];return o?Object.assign(t,{[o]:e.value}):t}),{})),a=this.getComponentsContext(),l=Object.assign(Object.assign(Object.assign(Object.assign({},a),s),r),{origin:window.location.origin}),c=yield this.getFlowConfig(),d=yield this.getProjectConfig(),u=yield e(i,c.version,d.componentsVersion,l);o(this,zi,"f").call(this,u),o(this,Fi,"m",nr).call(this,r)}var n}))))),this.flowState=t}loadSdkScripts(){return n(this,void 0,void 0,(function*(){const t=(yield this.getFlowConfig()).sdkScripts;null==t||t.forEach((t=>n(this,void 0,void 0,(function*(){(yield function(t){return n(this,void 0,void 0,(function*(){let e;switch(t){case"forter":return e=yield Promise.resolve().then((function(){return Or})),e.default;case"fingerprint":return e=yield Promise.resolve().then((function(){return xr})),e.default;case"fingerprintDescope":return e=yield Promise.resolve().then((function(){return Ur})),e.default;default:throw new Error(`Unknown script id: ${t}`)}}))}(t.id))(t.initArgs,{baseUrl:this.baseUrl},(e=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[br(t.id,t.resultKey)]:e},bubbles:!0,composed:!0}))}))}))))}))}connectedCallback(){const t=Object.create(null,{connectedCallback:{get:()=>super.connectedCallback}});var e,i;return n(this,void 0,void 0,(function*(){this.shadowRoot.isConnected&&(null===(e=this.flowState)||void 0===e||e.subscribe(this.onFlowChange.bind(this)),null===(i=this.stepState)||void 0===i||i.subscribe(this.onStepChange.bind(this)),window.addEventListener("visibilitychange",o(this,Ki,"f").visibilitychange)),yield t.connectedCallback.call(this)}))}disconnectedCallback(){var t;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),null===(t=o(this,Vi,"f"))||void 0===t||t.abort(),i(this,Vi,null,"f"),window.removeEventListener("visibilitychange",o(this,Ki,"f").visibilitychange)}getHtmlFilenameWithLocale(t,e){return n(this,void 0,void 0,(function*(){let n;const o=Ko(t);return(yield this.getTargetLocales()).includes(o)&&(n=`${e}-${o}.html`),n}))}getPageContent(t,e){return n(this,void 0,void 0,(function*(){if(e)try{const{body:t}=yield _o(e,"text");return t}catch(n){this.loggerWrapper.error(`Failed to fetch flow page from ${e}. Fallback to url ${t}`,n)}try{const{body:e}=yield _o(t,"text");return e}catch(t){this.loggerWrapper.error("Failed to fetch flow page",t.message)}return null}))}onFlowChange(t,r,s){var a,l;return n(this,void 0,void 0,(function*(){const{projectId:n,flowId:c,tenant:d,stepId:u,executionId:h,action:p,screenId:f,screenState:g,redirectTo:v,openInNewTabUrl:m,redirectUrl:w,token:b,code:y,exchangeError:I,webauthnTransactionId:k,webauthnOptions:j,redirectAuthCodeChallenge:C,redirectAuthCallbackUrl:O,redirectAuthBackupCallbackUri:S,redirectAuthInitiator:x,locale:A,samlIdpResponseUrl:U,samlIdpResponseSamlResponse:E,samlIdpResponseRelayState:T}=t,L=e(t,["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 _,R;const P=(()=>{const t=localStorage.getItem(li);if(!t){const t=Math.floor(100*Math.random()+1);return localStorage.setItem(li,t.toString()),t}return Number(t)})(),$=this.sdk.getLastUserLoginId(),M=yield this.getFlowConfig(),D=yield this.getProjectConfig(),q=O&&C?{callbackUrl:O,codeChallenge:C,backupCallbackUri:S}:void 0;if(!h&&(this.loadSdkScripts(),M.fingerprintEnabled&&M.fingerprintKey?yield En(M.fingerprintKey,this.baseUrl):localStorage.removeItem(An),M.conditions?({startScreenId:_,conditionInteractionId:R}=((t,e)=>{const n=null==e?void 0:e.find((({key:e,operator:n,predicate:o})=>{var i;if("ELSE"===e)return!0;const r=null===(i=si[e])||void 0===i?void 0:i[n];return!!(null==r?void 0:r(t,o))}));return n?{startScreenId:n.met.screenId,conditionInteractionId:n.met.interactionId}:{}})({loginId:$,code:y,token:b,abTestingKey:P},M.conditions)):M.condition?({startScreenId:_,conditionInteractionId:R}=((t,e)=>{var n;const o=null===(n=si[null==t?void 0:t.key])||void 0===n?void 0:n[t.operator];if(!o)return{};const i=o(e,t.predicate)?t.met:t.unmet;return{startScreenId:null==i?void 0:i.screenId,conditionInteractionId:null==i?void 0:i.interactionId}})(M.condition,{loginId:$,code:y,token:b,abTestingKey:P})):_=M.startScreenId,!Wo(_,L))){const t=yield this.sdk.flow.start(c,Object.assign(Object.assign(Object.assign(Object.assign({tenant:d,redirectAuth:q},L),{client:this.client}),w&&{redirectUrl:w}),{lastAuth:ai($),abTestingKey:P,locale:Ko(A)}),R,"",M.version,D.componentsVersion,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),y?{exchangeCode:y,idpInitiated:!0}:{}),L.descopeIdpInitiated&&{idpInitiated:!0}),b?{token:b}:{}),L.oidcLoginHint?{externalId:L.oidcLoginHint}:{}));return o(this,zi,"f").call(this,t),void("completed"!==(null===(a=null==t?void 0:t.data)||void 0===a?void 0:a.status)&&this.flowState.update({code:void 0,token:void 0}))}if(h&&(s("token")&&b||s("code")&&y||s("exchangeError")&&I)){const t=yield this.sdk.flow.next(h,u,xo,M.version,D.componentsVersion,{token:b,exchangeCode:y,exchangeError:I});return o(this,zi,"f").call(this,t),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(p===So&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((t=>s(t)))){if(!U||!E)return void this.loggerWrapper.error("Did not get saml idp params data to load");((t,e,n,o)=>{const i=document.createElement("form");i.method="POST",i.action=t,i.innerHTML=`\n <input type="hidden" role="saml-response" name="SAMLResponse" value="${e}" />\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)})(U,E,T||"",Fo)}if(p===ko&&(s("redirectTo")||s("deferredRedirect")))return v?"android"===x&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(v):void this.loggerWrapper.error("Did not get redirect url");if(p===Co||p===Oo){if(!k||!j)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let t,e;null===(l=o(this,Vi,"f"))||void 0===l||l.abort(),i(this,Vi,null,"f");try{t=p===Co?yield this.sdk.webauthn.helpers.create(j):yield this.sdk.webauthn.helpers.get(j)}catch(t){"InvalidStateError"===t.name?this.loggerWrapper.warn("WebAuthn operation failed",t.message):"NotAllowedError"!==t.name&&this.loggerWrapper.error(t.message),e=t.name}const n=yield this.sdk.flow.next(h,u,xo,M.version,D.componentsVersion,{transactionId:k,response:t,failure:e});o(this,zi,"f").call(this,n)}if(o(this,Ji,"f").call(this,h,u,p,M.version,D.componentsVersion),!f&&!_)return void this.loggerWrapper.warn("No screen was found to show");const N=_||f,W=yield this.getHtmlFilenameWithLocale(A,N),{oidcLoginHint:F,oidcPrompt:B,oidcErrorRedirectUri:V,samlIdpUsername:K}=L,H={direction:Po(u,r.stepId),screenState:Object.assign(Object.assign({},g),{form:Object.assign(Object.assign({},this.formConfigValues),null==g?void 0:g.form),lastAuth:{loginId:$,name:this.sdk.getLastUserDisplayName()||$}}),htmlUrl:Ro({projectId:n,filename:`${N}.html`,baseUrl:this.baseStaticUrl}),htmlLocaleUrl:W&&Ro({projectId:n,filename:W,baseUrl:this.baseStaticUrl}),samlIdpUsername:K,oidcLoginHint:F,oidcPrompt:B,oidcErrorRedirectUri:V,openInNewTabUrl:m},J=ai($);Wo(_,L)?H.next=(t,e,n,o)=>this.sdk.flow.start(c,Object.assign(Object.assign(Object.assign(Object.assign({tenant:d,redirectAuth:q},L),{lastAuth:J,preview:this.preview,abTestingKey:P,client:this.client}),w&&{redirectUrl:w}),{locale:Ko(A)}),R,t,e,n,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),o),y&&{exchangeCode:y,idpInitiated:!0}),L.descopeIdpInitiated&&{idpInitiated:!0}),b&&{token:b})):(s("projectId")||s("baseUrl")||s("executionId")||s("stepId"))&&(H.next=(...t)=>this.sdk.flow.next(h,u,...t)),this.stepState.update(H)}))}loadDescopeUiComponents(t){return n(this,void 0,void 0,(function*(){const e=yield wr.descopeUI;if(!e)return;const o=(t=>[...Array.from(t.querySelectorAll("*")).reduce(((t,e)=>e.tagName.startsWith("DESCOPE-")?t.add(e.tagName.toLocaleLowerCase()):t),new Set)])(t);yield Promise.all(o.map((t=>n(this,void 0,void 0,(function*(){if(!!!customElements.get(t))if(e[t])try{return yield e[t]()}catch(e){if("NotSupportedError"!==e.name)throw e;console.debug(`${t} is already registered`)}else this.loggerWrapper.error(`Cannot load UI component "${t}"`,`Descope UI does not have a component named "${t}", available components are: "${Object.keys(e).join(", ")}"`)})))))}))}onStepChange(t,e){var i,r;return n(this,void 0,void 0,(function*(){const{htmlUrl:s,htmlLocaleUrl:a,direction:l,next:c,screenState:d,openInNewTabUrl:u}=t,h=document.createElement("template");h.innerHTML=yield this.getPageContent(s,a);const p=h.content.cloneNode(!0),f=this.loadDescopeUiComponents(h.content);this.sdk.webauthn.helpers.isSupported()?yield o(this,Fi,"m",Zi).call(this,p,c):p.querySelectorAll(`descope-button[${Io}="biometrics"]`).forEach((t=>t.setAttribute("disabled","true"))),!t.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=t.samlIdpUsername,d.form.email=t.samlIdpUsername),oi(p,d,d.componentsConfig,this.formConfig,this.errorTransformer,this.loggerWrapper);const{geo:g}=yield this.getExecutionContext();((t,e)=>{Array.from(t.querySelectorAll('descope-phone-field[default-code="autoDetect"]')).forEach((t=>{t.setAttribute("default-code",e)}))})(p,g);const v=()=>n(this,void 0,void 0,(function*(){var t,n;yield f;const i=this.shadowRoot.querySelector("div");var r,s;r=i,s=null===(t=null==d?void 0:d.totp)||void 0===t?void 0:t.image,ni(r,"descope-totp-image",s),((t,e)=>{ni(t,"descope-notp-image",e)})(i,null===(n=null==d?void 0:d.notp)||void 0===n?void 0:n.image),this.rootElement.replaceChildren(p),setTimeout((()=>{((t,e)=>{Yo(t,null==e?void 0:e.inputs),Yo(t,null==e?void 0:e.form)})(this.rootElement,d)}));const a=!e.htmlUrl;((t,e,n)=>{if(!0===e||"skipFirstScreen"===e&&!n){const e=t.querySelector("*[name]");setTimeout((()=>{null==e||e.focus()}))}})(this.rootElement,this.autoFocus,a),this.validateOnBlur&&(t=>{t.querySelectorAll("*[name]").forEach((t=>{t.addEventListener("blur",(()=>{var e;const n=t.focus;t.focus=()=>{},null===(e=t.reportValidity)||void 0===e||e.call(t),setTimeout((()=>{t.focus=n}))}))}))})(this.rootElement),o(this,Fi,"m",rr).call(this,c),a&&o(this,Fi,"m",ar).call(this,"ready",{}),o(this,Fi,"m",ar).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${Io}="polling"]`)){const t=yield this.getFlowConfig(),e=yield this.getProjectConfig(),n=yield c(Ao,t.version,e.componentsVersion,{});o(this,zi,"f").call(this,n)}u&&!e.openInNewTabUrl&&window.open(u,"_blank")}));l?o(this,Fi,"m",sr).call(this,v,l):v()}))}}Bi=new WeakMap,Vi=new WeakMap,Ki=new WeakMap,Ji=new WeakMap,Gi=new WeakMap,zi=new WeakMap,Xi=new WeakMap,or=new WeakMap,Fi=new WeakSet,Hi=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},Qi=function(t){const e=t.getAttribute("name");if(!["email"].includes(e)){const n=`user-${e}`;t.setAttribute("name",n),t.addEventListener("input",(()=>{t.setAttribute("name",t.value?e:n)}))}},Zi=function(t,e){var r;return n(this,void 0,void 0,(function*(){null===(r=o(this,Vi,"f"))||void 0===r||r.abort();const s=t.querySelector('*[autocomplete="webauthn"]');if(s&&(yield ii())){const{options:t,transactionId:r}=(yield o(this,Xi,"f").call(this))||{};if(t&&r){o(this,Fi,"m",Qi).call(this,s),i(this,Vi,new AbortController,"f");const a=yield this.getFlowConfig(),l=yield this.getProjectConfig();this.sdk.webauthn.helpers.conditional(t,o(this,Vi,"f")).then((t=>n(this,void 0,void 0,(function*(){const n=yield e(s.id,a.version,l.componentsVersion,{transactionId:r,response:t});o(this,zi,"f").call(this,n)})))).catch((t=>{"AbortError"!==t.name&&this.loggerWrapper.error("Conditional login failed",t.message)}))}}}))},Yi=function(){let t=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((e=>{var n,o;"slot"!==e.localName&&(null===(n=e.reportValidity)||void 0===n||n.call(e),t&&(t=null===(o=e.checkValidity)||void 0===o?void 0:o.call(e)))})),t},tr=function(){return n(this,void 0,void 0,(function*(){const t=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${uo}])`));return(yield Promise.all(t.map((t=>n(this,void 0,void 0,(function*(){return{name:t.getAttribute("name"),value:t.value}})))))).reduce(((t,e)=>Object.assign(Object.assign({},t),{[e.name]:e.value})),{})}))},er=function(t){const e=this.nextRequestStatus.subscribe((({isLoading:n})=>{n?t.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(e),t.removeAttribute("loading"))}))},nr=function(t={}){var e,n;const o=Bo(t,["externalId","email","phone"]),i=Bo(t,["newPassword","password"]);if(o&&i)try{if(!globalThis.PasswordCredential)return;const t=new globalThis.PasswordCredential({id:o,password:i});null===(n=null===(e=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===e?void 0:e.store)||void 0===n||n.call(e,t)}catch(t){this.loggerWrapper.error("Could not store credentials",t.message)}},ir=function(t){this.rootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((e=>{e.addEventListener("input",(()=>{var n;(null===(n=e.checkValidity)||void 0===n?void 0:n.call(e))&&o(this,or,"f").call(this,e,t)}))}))},rr=function(t){this.rootElement.querySelectorAll("descope-button:not([data-exclude-next])").forEach((e=>{e.onclick=()=>{o(this,or,"f").call(this,e,t)}})),o(this,Fi,"m",ir).call(this,t)},sr=function(t,e){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),t()}),{once:!0});const n=e===Eo.forward?"slide-forward":"slide-backward";Array.from(this.rootElement.getElementsByClassName("input-container")).forEach(((t,e)=>{t.style["transition-delay"]=40*e+"ms",t.classList.add(n)})),this.rootElement.classList.add("fade-out")},ar=function(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))},customElements.get("descope-wc")?console.log("descope-wc is already defined"):customElements.define("descope-wc",yr);const Ir=document.createElement("template");Ir.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 kr extends HTMLElement{constructor(){super(),lr.add(this),cr.set(this,new Qo({messages:[]})),dr.set(this,void 0),ur.set(this,void 0),hr.set(this,void 0),pr.set(this,{resize:o(this,lr,"m",mr).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Ir.content.cloneNode(!0)),i(this,dr,this.shadowRoot.querySelector(".debugger"),"f"),i(this,ur,o(this,dr,"f").querySelector(".content"),"f"),i(this,hr,o(this,dr,"f").querySelector(".header"),"f")}updateData(t){o(this,cr,"f").update((e=>({messages:e.messages.concat(t)})))}connectedCallback(){var t;((t,e,n)=>{let o=0,i=0,r=0,s=0;function a(e){e.preventDefault(),o=r-e.clientX,i=s-e.clientY,r=e.clientX,s=e.clientY;const[a,l]=ri(t,t.offsetLeft-o,t.offsetTop-i,n);t.style.top=`${l}px`,t.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(t){t.preventDefault(),r=t.clientX,s=t.clientY,document.onmouseup=l,document.onmousemove=a}e?e.onmousedown=c:t.onmousedown=c})(o(this,dr,"f"),o(this,hr,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,pr,"f").resize),(t=o(this,dr,"f")).onmousemove=e=>{(e.target.w&&e.target.w!==e.target.offsetWidth||e.target.h&&e.target.h!==e.target.offsetHeight)&&t.onresize(e),e.target.w=e.target.offsetWidth,e.target.h=e.target.offsetHeight},o(this,dr,"f").onresize=o(this,lr,"m",vr).bind(this),o(this,cr,"f").subscribe(o(this,lr,"m",fr).bind(this))}disconnectedCallback(){o(this,cr,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,pr,"f").resize)}}cr=new WeakMap,dr=new WeakMap,ur=new WeakMap,hr=new WeakMap,pr=new WeakMap,lr=new WeakSet,fr=function(t){o(this,lr,"m",gr).call(this,t),o(this,lr,"m",vr).call(this)},gr=function(t){o(this,ur,"f").innerHTML=t.messages.map((t=>`\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 ${t.title}\n </div>\n <div class="msg_desc">\n ${t.description}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},vr=function(){o(this,ur,"f").querySelectorAll(".msg").forEach((t=>{const e=t.querySelector(".msg_desc"),n=e.scrollWidth>e.clientWidth,o=e.clientHeight>20;n||o?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},mr=function(){const[t,e]=ri(o(this,dr,"f"),Number.parseInt(o(this,dr,"f").style.left,10),Number.parseInt(o(this,dr,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,dr,"f").style.top=`${e}px`,o(this,dr,"f").style.left=`${t}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",kr);var jr=Object.freeze({__proto__:null,default:kr});const Cr='\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';var Or=Object.freeze({__proto__:null,default:(t,e,o)=>n(void 0,void 0,void 0,(function*(){const{siteId:e}=t,n=Cr.replace(/{{SITE_ID}}/g,e),i=document.createElement("script");i.setAttribute("type","text/javascript"),i.setAttribute("id",e),i.text=n,document.body.appendChild(i),document.addEventListener("ftr:tokenReady",(t=>{o(t.detail)}))}))});const Sr=(t,e,o)=>n(void 0,void 0,void 0,(function*(){try{const{publicApiKey:e,useCloudflareIntegration:n,cloudflareScriptUrl:i,cloudflareEndpointUrl:r}=t;let s=[];s=n&&r?[r,en]:[en];let a=[];if(n&&i){const t=new URL(i);a=[`${t.toString()}?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`,cn]}else a=[cn];const l=dn({apiKey:e,endpoint:s,scriptUrlPattern:a}),c=yield l,{requestId:d}=yield c.get();o(d)}catch(t){console.warn("Could not load fingerprint",t)}}));var xr=Object.freeze({__proto__:null,default:Sr,loadFingerprint:Sr});const Ar=(t,e,o)=>n(void 0,void 0,void 0,(function*(){try{const{customDomain:n,publicApiKey:i,cloudflareEndpointPath:r,cloudflareScriptPath:s}=t,{baseUrl:a}=e;let l;l=n?`https://${n}`:a||"https://api.descope.com";const c=new URL(l);c.pathname=r;const d=new URL(l);d.pathname=s;const u=`${d.toString()}?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`,h=dn({apiKey:i,endpoint:[c.toString(),en],scriptUrlPattern:[u,cn]}),p=yield h,{requestId:f}=yield p.get();o(f)}catch(t){console.warn("Could not load descope fingerprint",t)}}));var Ur=Object.freeze({__proto__:null,default:Ar,loadFingerprint:Ar})}();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@descope/web-component",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.22.0",
|
|
4
4
|
"author": "Descope Team <info@descope.com>",
|
|
5
5
|
"homepage": "https://github.com/descope/descope-js",
|
|
6
6
|
"bugs": {
|
|
@@ -66,6 +66,7 @@
|
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
68
|
"tslib": "2.6.3",
|
|
69
|
+
"@fingerprintjs/fingerprintjs-pro": "3.9.9",
|
|
69
70
|
"@descope/web-js-sdk": "1.16.0"
|
|
70
71
|
},
|
|
71
72
|
"overrides": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{__awaiter as e,__classPrivateFieldGet as t,__classPrivateFieldSet as i,__rest as o}from"tslib";import r,{ensureFingerprintIds as n,clearFingerprintData as s}from"@descope/web-js-sdk";const a="undefined"!=typeof localStorage,l=a&&localStorage.getItem("base.content.url")||"",d="config.json",c="base.ui.components.url",u=a&&localStorage.getItem(c)||"https://static.descope.com/npm/@descope/web-components-ui@<version>/dist/umd/index.js",h=a&&localStorage.getItem(c)||"https://cdn.jsdelivr.net/npm/@descope/web-components-ui@<version>/dist/umd/index.js",p="descope-login-flow",f="code",g="ra-challenge",v="ra-callback",m="ra-backup-callback",b="ra-initiator",y="data-exclude-field",w="dls_last_auth",I="state_id",k="saml_idp_state_id",A="saml_idp_username",C="descope_idp_initiated",S="sso_app_id",E="oidc_login_hint",j="oidc_prompt",U="oidc_error_redirect_uri",x="data-type",O="redirect",T="poll",L="webauthnCreate",R="webauthnGet",W="loadForm",$="submit",M="polling",P=["descope-multi-select-combo-box","descope-text-area"];var N;function q(e){return new URLSearchParams(window.location.search).get(e)}function D(e){if(window.history.replaceState&&q(e)){const t=new URL(window.location.href),i=new URLSearchParams(t.search);i.delete(e),t.search=i.toString(),window.history.replaceState({},"",t.toString())}}function _(t,i){return e(this,void 0,void 0,(function*(){const e=yield fetch(t,{cache:"default"});if(!e.ok)throw Error(`Error fetching URL ${t} [${e.status}]`);return{body:yield e[i||"text"](),headers:Object.fromEntries(e.headers.entries())}}))}!function(e){e.backward="backward",e.forward="forward"}(N||(N={}));function F({projectId:e,filename:t,assetsFolder:i="v2-beta",baseUrl:o}){const r=new URL(l||o||"https://static.descope.com/pages");return r.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(r.pathname,e,i,t),r.toString()}function V(e,t){if(!t)return;const i=+e,o=+t;return Number.isNaN(i)||Number.isNaN(o)?void 0:i>o?N.forward:i<o?N.backward:void 0}const K=()=>{const[e="",t=""]=(q(p)||"").split("_");return{executionId:e,stepId:t}};function H(){D(p)}const B=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),J=()=>{const{executionId:e,stepId:t}=K();(e||t)&&H();const i=q("t")||void 0;i&&D("t");const o=q(f)||void 0;o&&D(f);const r=q("err")||void 0;r&&D("err");const{redirectAuthCodeChallenge:n,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:l}={redirectAuthCodeChallenge:q(g),redirectAuthCallbackUrl:q(v),redirectAuthBackupCallbackUri:q(m),redirectAuthInitiator:q(b)};(n||s||a||l)&&(D(g),D(v),D(m),D(b));const d=q(I);d&&D(I);const c=q(k);c&&D(k);const u=q(A);c&&D(A);const h=q(C);h&&D(C);const p=q(S);p&&D(S);const y=q(E);y&&D(E);const w=q(j);w&&D(j);const x=q(U);x&&D(U);return{executionId:e,stepId:t,token:i,code:o,exchangeError:r,redirectAuthCodeChallenge:n,redirectAuthCallbackUrl:s,redirectAuthBackupCallbackUri:a,redirectAuthInitiator:l,ssoQueryParams:{oidcIdpStateId:d,samlIdpStateId:c,samlIdpUsername:u,descopeIdpInitiated:"true"===h,ssoAppId:p,oidcLoginHint:y,oidcPrompt:w,oidcErrorRedirectUri:x}}},z=e=>{let t,i;return(...o)=>{return t&&(n=o,(r=t).length===n.length&&r.every(((e,t)=>e===n[t])))||(t=o,i=e(...o)),i;var r,n}};const G=(e,{oidcIdpStateId:t,samlIdpStateId:i,samlIdpUsername:o,ssoAppId:r,oidcLoginHint:n,oidcPrompt:s,oidcErrorRedirectUri:a})=>!(!e||t||i||o||r||n||s||a),Q=e=>null==e?void 0:e.submit(),X=(e,t)=>{const i=t.find((t=>e[t]));return i?e[i]:null},Y=(e,t=100)=>{let i;return function(...o){i||e.apply(this,o),clearTimeout(i),i=setTimeout((()=>{i=null}),t)}};function Z(e){let t=navigator.language;return t&&"zh-TW"!==t&&(t=t.split("-")[0]),(e||t||"").toLowerCase()}var ee,te,ie,oe;function re(e,t){const i=Object.getOwnPropertyNames(e),o=Object.getOwnPropertyNames(t);if(i.length!==o.length)return!1;for(let o=0;o<i.length;o+=1){const r=i[o],n=e[r],s=t[r];if(null===n||null===s){if(n!==s)return!1}else if("object"==typeof n&&"object"==typeof s){if(!re(n,s))return!1}else if(n!==s)return!1}return!0}class ne{constructor(e={},{updateOnlyOnChange:o=!0}={}){ee.set(this,void 0),te.set(this,{}),ie.set(this,0),oe.set(this,!1),this.update=e=>{const o="function"==typeof e?e(t(this,ee,"f")):e,r=Object.assign(Object.assign({},t(this,ee,"f")),o);if(!t(this,oe,"f")||!re(t(this,ee,"f"),r)){const e=t(this,ee,"f");i(this,ee,r,"f"),Object.freeze(t(this,ee,"f")),setTimeout((()=>{Object.values(t(this,te,"f")).forEach((t=>t(r,e,((e,t)=>i=>e[i]!==t[i])(r,e))))}),0)}},i(this,ee,e,"f"),i(this,oe,o,"f")}get current(){return Object.assign({},t(this,ee,"f"))}subscribe(e){return i(this,ie,t(this,ie,"f")+1,"f"),t(this,te,"f")[t(this,ie,"f")]=e,t(this,ie,"f").toString()}unsubscribe(e){const i=!!t(this,te,"f")[e];return i&&delete t(this,te,"f")[e],i}unsubscribeAll(){return i(this,te,{},"f"),!0}}ee=new WeakMap,te=new WeakMap,ie=new WeakMap,oe=new WeakMap;const se=["disabled"],ae=(e,t)=>{Object.entries(t||{}).forEach((([t,i])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${y}])`)).forEach((e=>{e.value=i}))}))},le=(e,t)=>e.replace(/{{(.+?)}}/g,((e,i)=>{return o=t,i.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),o);var o})),de=(e,t,i)=>{e.querySelectorAll(`[${x}="${t}"]`).forEach((e=>{e.setAttribute("href",i)}))},ce=(e,t,i)=>{var o,r;const n=null===(o=customElements.get(t))||void 0===o?void 0:o.cssVarList.url;i&&n&&(null===(r=null==e?void 0:e.style)||void 0===r||r.setProperty(n,`url(data:image/jpg;base64,${i})`))},ue=(e,t,i,o,r,n)=>{var s,a;let l=null==t?void 0:t.errorText;try{l=(null==r?void 0:r({text:null==t?void 0:t.errorText,type:null==t?void 0:t.errorType}))||(null==t?void 0:t.errorText)}catch(e){n.error("Error transforming error message",e.message)}((e,t,i="")=>{e.querySelectorAll(`[${x}="${t}"]`).forEach((e=>{e.textContent=i,e.classList[i?"remove":"add"]("hide")}))})(e,"error-message",l),de(e,"totp-link",null===(s=null==t?void 0:t.totp)||void 0===s?void 0:s.provisionUrl),de(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=le(e.textContent,t);const i=e.getAttribute("href");i&&e.setAttribute("href",le(i,t))}))})(e,t),((e,t,i)=>{t&&Object.keys(t).forEach((o=>{e.querySelectorAll(`[name=${o}]`).forEach((e=>{const r=t[o];Object.keys(r).forEach((t=>{let o=r[t];if("string"!=typeof o)try{o=JSON.stringify(o)}catch(e){i.error(`Could not stringify value "${o}" for "${t}"`,e.message),o=""}e.setAttribute(t,o)}))}))}))})(e,i,n),((e,t)=>{e.querySelectorAll("[data-has-dynamic-attr-values]").forEach((e=>{Array.from(e.attributes).forEach((e=>{e.value=le(e.value,t)}))}))})(e,t),((e,t)=>{Object.entries(t).forEach((([t,i])=>{e.querySelectorAll(`[name="${t}"]`).forEach((e=>{Object.entries(i).forEach((([t,i])=>{se.includes(t)&&e.setAttribute(t,i)}))}))}))})(e,o)},he=z((()=>e(void 0,void 0,void 0,(function*(){var e,t,i,o,r;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const n=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)))),s=(()=>{var e;const t=null===(e=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===e?void 0:e.brands,i=null==t?void 0:t.find((({brand:e,version:t})=>"Chromium"===e&&parseFloat(t)));return i?i.version:0})()>=108;return yield(i=100,o=n,r=s,new Promise(((e,t)=>{let n=!1;const s=setTimeout((()=>{n=!0,void 0!==r?e(r):t(new Error(`Promise timed out after ${i} ms`))}),i);o.then((t=>{n||(clearTimeout(s),e(t))})).catch((e=>{n||(clearTimeout(s),t(e))}))})))}catch(e){return console.error("Conditional login check failed",e),!1}})))),pe={"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 fe(e){const t={};if(e)try{Object.assign(t,JSON.parse(localStorage.getItem(w)))}catch(e){}return t}const ge="dls_ab_testing_id",ve=document.createElement("template");ve.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 me=(e,t="")=>Object.keys(e).reduce(((i,o)=>{var r;if("object"==typeof e[o]&&null!==e[o]&&!(null===(r=e[o])||void 0===r?void 0:r.value))return Object.assign(Object.assign({},i),me(e[o],`${t+o}.`));const n="object"==typeof e[o]?e[o]:{value:e[o]},s=Object.assign(Object.assign({},i),{[t+o]:n,[`form.${t}${o}`]:n});return"displayName"===o?Object.assign(Object.assign({},s),{[`${t}fullName`]:n,[`form.${t}fullName`]:n}):s}),[]);var be,ye,we,Ie,ke,Ae,Ce,Se,Ee,je,Ue,xe,Oe,Te,Le,Re,We,$e,Me,Pe,Ne,qe,De,_e,Fe,Ve,Ke,He,Be,Je,ze,Ge,Qe,Xe,Ye,Ze,et,tt,it,ot,rt,nt,st,at,lt,dt,ct,ut,ht,pt,ft,gt;class vt 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(o){super(),be.add(this),this.logger=console,ye.set(this,!1),this.loggerWrapper={error:(e,i="")=>{this.logger.error(e,i,new Error),t(this,be,"m",He).call(this,e,i)},warn:(e,t="")=>{this.logger.warn(e,t)},info:(e,t="",i={})=>{this.logger.info(e,t,i)},debug:(e,t="")=>{this.logger.debug(e,t)}},we.set(this,new ne),Ie.set(this,new ne),ke.set(this,{}),this.getComponentsContext=()=>t(this,ke,"f"),this.nextRequestStatus=new ne({isLoading:!1}),Ae.set(this,void 0),Ce.set(this,{popstate:t(this,be,"m",Oe).bind(this),componentsContext:t(this,be,"m",_e).bind(this)}),Se.set(this,void 0),$e.set(this,z((()=>e(this,void 0,void 0,(function*(){const e=F({projectId:this.projectId,filename:d,baseUrl:this.baseStaticUrl});try{const{body:t,headers:i}=yield _(e,"json");return{projectConfig:t,executionContext:{geo:i["x-geo"]}}}catch(e){return{isMissingConfig:!0}}}))))),Pe.set(this,void 0),i(this,Se,o,"f"),t(this,be,"m",Ee).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 i=this.getAttribute("theme");if("os"===i){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 i||"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 me(JSON.parse(e))}catch(e){return{}}})(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return e=this.formConfig,t="value",Object.fromEntries(Object.entries(e).map((([e,i])=>[e,i[t]])));var e,t}getExecutionContext(){return e(this,void 0,void 0,(function*(){const{executionContext:e}=yield t(this,$e,"f").call(this);return e}))}getProjectConfig(){return e(this,void 0,void 0,(function*(){const{projectConfig:e}=yield t(this,$e,"f").call(this);return e}))}getFlowConfig(){var t,i;return e(this,void 0,void 0,(function*(){const e=yield this.getProjectConfig(),o=(null===(t=null==e?void 0:e.flows)||void 0===t?void 0:t[this.flowId])||{};return null!==(i=o.version)&&void 0!==i||(o.version=0),o}))}getTargetLocales(){return e(this,void 0,void 0,(function*(){const e=yield this.getFlowConfig();return((null==e?void 0:e.targetLocales)||[]).map((e=>e.toLowerCase()))}))}connectedCallback(){return e(this,void 0,void 0,(function*(){if(this.shadowRoot.isConnected){if(t(this,Ie,"f").subscribe(t(this,be,"m",Ke).bind(this)),t(this,Ie,"f").update({isDebug:this.debug}),t(this,be,"m",je).call(this))return void t(this,be,"m",Ue).call(this);if(t(this,be,"m",xe).call(this),i(this,Pe,t(this,be,"m",Me).call(this),"f"),yield t(this,be,"m",Re).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 t(this,$e,"f").call(this)).isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");t(this,be,"m",Ne).call(this),yield t(this,be,"m",ze).call(this),yield t(this,be,"m",qe).call(this),t(this,be,"m",Be).call(this);const{executionId:e,stepId:o,token:r,code:n,exchangeError:s,redirectAuthCallbackUrl:a,redirectAuthBackupCallbackUri:l,redirectAuthCodeChallenge:d,redirectAuthInitiator:c,ssoQueryParams:u}=J();window.addEventListener("popstate",t(this,Ce,"f").popstate),window.addEventListener("components-context",t(this,Ce,"f").componentsContext),t(this,we,"f").subscribe(t(this,be,"m",Le).bind(this)),t(this,we,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenant,redirectUrl:this.redirectUrl,locale:this.locale,stepId:o,executionId:e,token:r,code:n,exchangeError:s,redirectAuthCallbackUrl:a,redirectAuthBackupCallbackUri:l,redirectAuthCodeChallenge:d,redirectAuthInitiator:c},u)),i(this,ye,!0,"f")}}))}disconnectedCallback(){t(this,we,"f").unsubscribeAll(),t(this,Ie,"f").unsubscribeAll(),t(this,be,"m",Ve).call(this),window.removeEventListener("popstate",t(this,Ce,"f").popstate),window.removeEventListener("components-context",t(this,Ce,"f").componentsContext)}attributeChangedCallback(e,i,o){if(this.shadowRoot.isConnected&&t(this,ye,"f")&&i!==o&&vt.observedAttributes.includes(e)){t(this,be,"m",xe).call(this);const r=null===i;t(this,we,"f").update((({stepId:t,executionId:i})=>{let n=t,s=i;return r||(s=null,n=null,H()),{[B(e)]:o,stepId:n,executionId:s}})),t(this,Ie,"f").update({isDebug:this.debug}),"theme"===e&&t(this,be,"m",Fe).call(this)}}}ye=new WeakMap,we=new WeakMap,Ie=new WeakMap,ke=new WeakMap,Ae=new WeakMap,Ce=new WeakMap,Se=new WeakMap,$e=new WeakMap,Pe=new WeakMap,be=new WeakSet,Ee=function(){this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(ve.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#wc-root")},je=function(){return!this.shadowRoot.host.closest("form")&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)},Ue=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)},xe=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(vt.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[B(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')},Oe=function(){const{stepId:e,executionId:i}=K();t(this,we,"f").update({stepId:e,executionId:i})},Te=function(t,i){this.sdk=r(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout},vt.sdkConfigOverrides),{projectId:t,baseUrl:i})),["start","next"].forEach((t=>{const i=this.sdk.flow[t];this.sdk.flow[t]=(...t)=>e(this,void 0,void 0,(function*(){this.nextRequestStatus.update({isLoading:!0});try{return yield i(...t)}catch(e){return{error:{errorCode:"J151000",errorDescription:e.toString()}}}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},Le=function(i,o,r){return e(this,void 0,void 0,(function*(){const{projectId:e,baseUrl:o}=i;if(r("projectId")||r("baseUrl")){if(!e)return;t(this,be,"m",Te).call(this,e,o)}t(this,Se,"f").call(this,i)}))},Re=function(){return e(this,void 0,void 0,(function*(){return(yield t(this,$e,"f").call(this)).isMissingConfig&&(yield t(this,be,"m",We).call(this))}))},We=function(){return e(this,void 0,void 0,(function*(){const e=F({projectId:this.projectId,filename:d,assetsFolder:"v2-alpha",baseUrl:this.baseStaticUrl});try{return yield _(e,"json"),!0}catch(e){return!1}}))},Me=function(){return e(this,void 0,void 0,(function*(){const e=F({projectId:this.projectId,filename:"theme.json",baseUrl:this.baseStaticUrl});try{const{body:t}=yield _(e,"json");return t}catch(e){return void this.loggerWrapper.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}}))},Ne=function(){var i,o;return e(this,void 0,void 0,(function*(){const{projectConfig:e}=yield t(this,$e,"f").call(this),r=null===(o=null===(i=null==e?void 0:e.cssTemplate)||void 0===i?void 0:i[this.theme])||void 0===o?void 0:o.fonts;r&&Object.values(r).forEach((e=>(e=>{if(!e)return;const t=document.createElement("link");t.href=e,t.rel="stylesheet",document.head.appendChild(t)})(e.url)))}))},qe=function(){return e(this,void 0,void 0,(function*(){yield t(this,be,"m",De).call(this),yield t(this,be,"m",Fe).call(this)}))},De=function(){var i,o,r,n;return e(this,void 0,void 0,(function*(){const e=document.createElement("style"),s=yield t(this,Pe,"f");e.innerText=((null===(i=null==s?void 0:s.light)||void 0===i?void 0:i.globals)||"")+((null===(o=null==s?void 0:s.dark)||void 0===o?void 0:o.globals)||"");const a=yield vt.descopeUI;(null==a?void 0:a.componentsThemeManager)&&!a.componentsThemeManager.hasThemes&&(a.componentsThemeManager.themes={light:null===(r=null==s?void 0:s.light)||void 0===r?void 0:r.components,dark:null===(n=null==s?void 0:s.dark)||void 0===n?void 0:n.components}),this.shadowRoot.appendChild(e)}))},_e=function(e){i(this,ke,Object.assign(Object.assign({},t(this,ke,"f")),e.detail),"f")},Fe=function(){return e(this,void 0,void 0,(function*(){this.rootElement.setAttribute("data-theme",this.theme);const e=yield vt.descopeUI;(null==e?void 0:e.componentsThemeManager)&&(e.componentsThemeManager.currentThemeName=this.theme)}))},Ve=function(){var e;null===(e=t(this,Ae,"f"))||void 0===e||e.remove(),i(this,Ae,null,"f")},Ke=function({isDebug:o}){return e(this,void 0,void 0,(function*(){o?(i(this,Ae,document.createElement("descope-debugger"),"f"),Object.assign(t(this,Ae,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield import("./debugger-wc-513433e1.js"),document.body.appendChild(t(this,Ae,"f"))):t(this,be,"m",Ve).call(this)}))},He=function(e,i){var o;e&&this.debug&&(null===(o=t(this,Ae,"f"))||void 0===o||o.updateData({title:e,description:i}))},Be=function(){this.rootElement.onkeydown=e=>{var t,i,o;const r=!!(null===(t=this.shadowRoot.activeElement)||void 0===t?void 0:t.getAttribute("href")),n=P.includes(null!==(o=null===(i=this.shadowRoot.activeElement)||void 0===i?void 0:i.localName)&&void 0!==o?o:"");if("Enter"!==e.key||r||n)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 l=Array.from(s).filter((e=>"button"===e.getAttribute("data-type")));if(1===l.length)"false"!==l[0].getAttribute("auto-submit")&&l[0].click();else if(0===l.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()}}},Je=function(){var i,o;return e(this,void 0,void 0,(function*(){const e=null===(o=null===(i=yield t(this,$e,"f").call(this))||void 0===i?void 0:i.projectConfig)||void 0===o?void 0:o.componentsVersion;return e||(this.logger.error("Did not get components version, using latest version"),"latest")}))},ze=function(){return e(this,void 0,void 0,(function*(){vt.descopeUI?this.loggerWrapper.debug("DescopeUI is already loading, probably multiple flows are running on the same page"):vt.descopeUI=new Promise((i=>{if(globalThis.DescopeUI)return void i(globalThis.DescopeUI);const o=e=>{const t=document.createElement("script");return t.id="load-descope-ui",t.src=e,t},r=(e,t)=>e.replace("<version>",t),n=(e,t)=>{const o=()=>{this.loggerWrapper.error("Cannot load DescopeUI",`Make sure this URL is valid and return the correct script: "${e.src}"`),t()};e.addEventListener("load",(()=>{globalThis.DescopeUI||o(),i(globalThis.DescopeUI)})),e.addEventListener("error",o)};(()=>{e(this,void 0,void 0,(function*(){const e=yield t(this,be,"m",Je).call(this),s=o(r(u,e));n(s,(()=>{s.remove(),this.loggerWrapper.info("Trying to load DescopeUI from a fallback URL");const t=o(r(h,e));n(t,(()=>{i(void 0)})),document.body.append(t)})),document.body.append(s)}))})()}))}))},vt.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.21.0"}};class mt extends vt{static set sdkConfigOverrides(e){vt.sdkConfigOverrides=e}constructor(){const o=new ne({deferredRedirect:!1});super(o.update.bind(o)),Ge.add(this),this.stepState=new ne({},{updateOnlyOnChange:!1}),Qe.set(this,void 0),Xe.set(this,null),Ye.set(this,{visibilitychange:t(this,Ge,"m",Ze).bind(this)}),et.set(this,((o,r,n,s,a)=>{n===T&&i(this,Qe,setTimeout((()=>e(this,void 0,void 0,(function*(){var e;let i;try{i=yield this.sdk.flow.next(o,r,M,s,a,{})}catch(e){return void t(this,et,"f").call(this,o,r,n,s,a)}t(this,it,"f").call(this,i);const{action:l}=null!==(e=null==i?void 0:i.data)&&void 0!==e?e:{};t(this,et,"f").call(this,o,r,l,s,a)}))),2e3),"f")})),tt.set(this,(()=>{clearTimeout(t(this,Qe,"f")),i(this,Qe,null,"f")})),it.set(this,(e=>{var i,o,r,n,s,l,d,c,u,h,p;if(!(null==e?void 0:e.ok)){const a=null===(i=null==e?void 0:e.response)||void 0===i?void 0:i.url,l=`${null===(o=null==e?void 0:e.response)||void 0===o?void 0:o.status} - ${null===(r=null==e?void 0:e.response)||void 0===r?void 0:r.statusText}`;return t(this,Ge,"m",gt).call(this,"error",(null==e?void 0:e.error)||{errorCode:"J151001",errorDescription:l,errorMessage:a}),void this.loggerWrapper.error((null===(n=null==e?void 0:e.error)||void 0===n?void 0:n.errorDescription)||a,(null===(s=null==e?void 0:e.error)||void 0===s?void 0:s.errorMessage)||l)}null===(d=null===(l=e.data)||void 0===l?void 0:l.runnerLogs)||void 0===d||d.forEach((e=>{const{level:t,title:i,log:o}=e;t&&this.loggerWrapper[t]?this.loggerWrapper[t](i,o):this.loggerWrapper.info(i,o)}));const f=null===(h=null===(u=null===(c=e.data)||void 0===c?void 0:c.screen)||void 0===u?void 0:u.state)||void 0===h?void 0:h.errorText;(null===(p=e.data)||void 0===p?void 0:p.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:g,authInfo:v,lastAuth:m}=e.data;if("completed"===g)return this.storeLastAuthenticatedUser&&function(e){(null==e?void 0:e.authMethod)&&a&&localStorage.setItem(w,JSON.stringify(e))}(m),void t(this,Ge,"m",gt).call(this,"success",v);const{executionId:b,stepId:y,stepName:I,action:k,screen:A,redirect:C,openInNewTabUrl:S,webauthn:E,error:j,samlIdpResponse:U}=e.data;k!==T?(this.loggerWrapper.info(`Step "${I||`#${y}`}" is ${g}`,"",{screen:A,status:g,stepId:y,stepName:I,action:k,error:j}),this.flowState.update({stepId:y,executionId:b,action:k,redirectTo:null==C?void 0:C.url,openInNewTabUrl:S,screenId:null==A?void 0:A.id,screenState:null==A?void 0:A.state,webauthnTransactionId:null==E?void 0:E.transactionId,webauthnOptions:null==E?void 0:E.options,samlIdpResponseUrl:null==U?void 0:U.url,samlIdpResponseSamlResponse:null==U?void 0:U.samlResponse,samlIdpResponseRelayState:null==U?void 0:U.relayState})):this.flowState.update({action:k})})),ot.set(this,z((()=>e(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)}}))))),ut.set(this,Y(((i,o)=>e(this,void 0,void 0,(function*(){if("true"===i.getAttribute("formnovalidate")||t(this,Ge,"m",at).call(this)){const r=null==i?void 0:i.getAttribute("id");t(this,Ge,"m",dt).call(this,i);const n=yield t(this,Ge,"m",lt).call(this),s=(e=i,Array.from((null==e?void 0:e.attributes)||[]).reduce(((e,t)=>{var i;const o=null===(i=new RegExp("^data-descope-(\\S+)$").exec(t.name))||void 0===i?void 0:i[1];return o?Object.assign(e,{[o]:t.value}):e}),{})),a=this.getComponentsContext(),l=Object.assign(Object.assign(Object.assign(Object.assign({},a),s),n),{origin:window.location.origin}),d=yield this.getFlowConfig(),c=yield this.getProjectConfig(),u=yield o(r,d.version,c.componentsVersion,l);t(this,it,"f").call(this,u),t(this,Ge,"m",ct).call(this,n)}var e}))))),this.flowState=o}loadSdkScripts(){return e(this,void 0,void 0,(function*(){const t=(yield this.getFlowConfig()).sdkScripts;null==t||t.forEach((t=>e(this,void 0,void 0,(function*(){(yield function(t){return e(this,void 0,void 0,(function*(){let e;if("forter"===t)return e=yield import("./forter-74d50b85.js"),e.default;throw new Error(`Unknown script id: ${t}`)}))}(t.id))(t.initArgs,{baseUrl:this.baseUrl},(e=>{var i,o;this.dispatchEvent(new CustomEvent("components-context",{detail:{[(i=t.id,o=t.resultKey,`sdkScriptsResults.${o?`${i}_${o}`:i}`)]:e},bubbles:!0,composed:!0}))}))}))))}))}connectedCallback(){const i=Object.create(null,{connectedCallback:{get:()=>super.connectedCallback}});var o,r;return e(this,void 0,void 0,(function*(){this.shadowRoot.isConnected&&(null===(o=this.flowState)||void 0===o||o.subscribe(this.onFlowChange.bind(this)),null===(r=this.stepState)||void 0===r||r.subscribe(this.onStepChange.bind(this)),window.addEventListener("visibilitychange",t(this,Ye,"f").visibilitychange)),yield i.connectedCallback.call(this)}))}disconnectedCallback(){var e;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),null===(e=t(this,Xe,"f"))||void 0===e||e.abort(),i(this,Xe,null,"f"),window.removeEventListener("visibilitychange",t(this,Ye,"f").visibilitychange)}getHtmlFilenameWithLocale(t,i){return e(this,void 0,void 0,(function*(){let e;const o=Z(t);return(yield this.getTargetLocales()).includes(o)&&(e=`${i}-${o}.html`),e}))}getPageContent(t,i){return e(this,void 0,void 0,(function*(){if(i)try{const{body:e}=yield _(i,"text");return e}catch(e){this.loggerWrapper.error(`Failed to fetch flow page from ${i}. Fallback to url ${t}`,e)}try{const{body:e}=yield _(t,"text");return e}catch(e){this.loggerWrapper.error("Failed to fetch flow page",e.message)}return null}))}onFlowChange(r,a,l){var d,c;return e(this,void 0,void 0,(function*(){const{projectId:e,flowId:u,tenant:h,stepId:p,executionId:f,action:g,screenId:v,screenState:m,redirectTo:b,openInNewTabUrl:y,redirectUrl:w,token:I,code:k,exchangeError:A,webauthnTransactionId:C,webauthnOptions:S,redirectAuthCodeChallenge:E,redirectAuthCallbackUrl:j,redirectAuthBackupCallbackUri:U,redirectAuthInitiator:x,locale:T,samlIdpResponseUrl:M,samlIdpResponseSamlResponse:P,samlIdpResponseRelayState:N}=r,q=o(r,["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 D,_;const K=(()=>{const e=localStorage.getItem(ge);if(!e){const e=Math.floor(100*Math.random()+1);return localStorage.setItem(ge,e.toString()),e}return Number(e)})(),H=this.sdk.getLastUserLoginId(),B=yield this.getFlowConfig(),J=yield this.getProjectConfig(),z=j&&E?{callbackUrl:j,codeChallenge:E,backupCallbackUri:U}:void 0;if(!f&&(this.loadSdkScripts(),B.fingerprintEnabled&&B.fingerprintKey?yield n(B.fingerprintKey,this.baseUrl):s(),B.conditions?({startScreenId:D,conditionInteractionId:_}=((e,t)=>{const i=null==t?void 0:t.find((({key:t,operator:i,predicate:o})=>{var r;if("ELSE"===t)return!0;const n=null===(r=pe[t])||void 0===r?void 0:r[i];return!!(null==n?void 0:n(e,o))}));return i?{startScreenId:i.met.screenId,conditionInteractionId:i.met.interactionId}:{}})({loginId:H,code:k,token:I,abTestingKey:K},B.conditions)):B.condition?({startScreenId:D,conditionInteractionId:_}=((e,t)=>{var i;const o=null===(i=pe[null==e?void 0:e.key])||void 0===i?void 0:i[e.operator];if(!o)return{};const r=o(t,e.predicate)?e.met:e.unmet;return{startScreenId:null==r?void 0:r.screenId,conditionInteractionId:null==r?void 0:r.interactionId}})(B.condition,{loginId:H,code:k,token:I,abTestingKey:K})):D=B.startScreenId,!G(D,q))){const e=yield this.sdk.flow.start(u,Object.assign(Object.assign(Object.assign(Object.assign({tenant:h,redirectAuth:z},q),{client:this.client}),w&&{redirectUrl:w}),{lastAuth:fe(H),abTestingKey:K,locale:Z(T)}),_,"",B.version,J.componentsVersion,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),k?{exchangeCode:k,idpInitiated:!0}:{}),q.descopeIdpInitiated&&{idpInitiated:!0}),I?{token:I}:{}),q.oidcLoginHint?{externalId:q.oidcLoginHint}:{}));return t(this,it,"f").call(this,e),void("completed"!==(null===(d=null==e?void 0:e.data)||void 0===d?void 0:d.status)&&this.flowState.update({code:void 0,token:void 0}))}if(f&&(l("token")&&I||l("code")&&k||l("exchangeError")&&A)){const e=yield this.sdk.flow.next(f,p,$,B.version,J.componentsVersion,{token:I,exchangeCode:k,exchangeError:A});return t(this,it,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(g===W&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>l(e)))){if(!M||!P)return void this.loggerWrapper.error("Did not get saml idp params data to load");((e,t,i,o)=>{const r=document.createElement("form");r.method="POST",r.action=e,r.innerHTML=`\n <input type="hidden" role="saml-response" name="SAMLResponse" value="${t}" />\n <input type="hidden" role="saml-relay-state" name="RelayState" value="${i}" />\n <input style="display: none;" id="SAMLSubmitButton" type="submit" value="Continue" />\n `,document.body.appendChild(r),o(r)})(M,P,N||"",Q)}if(g===O&&(l("redirectTo")||l("deferredRedirect")))return b?"android"===x&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(b):void this.loggerWrapper.error("Did not get redirect url");if(g===L||g===R){if(!C||!S)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,o;null===(c=t(this,Xe,"f"))||void 0===c||c.abort(),i(this,Xe,null,"f");try{e=g===L?yield this.sdk.webauthn.helpers.create(S):yield this.sdk.webauthn.helpers.get(S)}catch(e){"InvalidStateError"===e.name?this.loggerWrapper.warn("WebAuthn operation failed",e.message):"NotAllowedError"!==e.name&&this.loggerWrapper.error(e.message),o=e.name}const r=yield this.sdk.flow.next(f,p,$,B.version,J.componentsVersion,{transactionId:C,response:e,failure:o});t(this,it,"f").call(this,r)}if(t(this,et,"f").call(this,f,p,g,B.version,J.componentsVersion),!v&&!D)return void this.loggerWrapper.warn("No screen was found to show");const X=D||v,Y=yield this.getHtmlFilenameWithLocale(T,X),{oidcLoginHint:ee,oidcPrompt:te,oidcErrorRedirectUri:ie,samlIdpUsername:oe}=q,re={direction:V(p,a.stepId),screenState:Object.assign(Object.assign({},m),{form:Object.assign(Object.assign({},this.formConfigValues),null==m?void 0:m.form),lastAuth:{loginId:H,name:this.sdk.getLastUserDisplayName()||H}}),htmlUrl:F({projectId:e,filename:`${X}.html`,baseUrl:this.baseStaticUrl}),htmlLocaleUrl:Y&&F({projectId:e,filename:Y,baseUrl:this.baseStaticUrl}),samlIdpUsername:oe,oidcLoginHint:ee,oidcPrompt:te,oidcErrorRedirectUri:ie,openInNewTabUrl:y},ne=fe(H);G(D,q)?re.next=(e,t,i,o)=>this.sdk.flow.start(u,Object.assign(Object.assign(Object.assign(Object.assign({tenant:h,redirectAuth:z},q),{lastAuth:ne,preview:this.preview,abTestingKey:K,client:this.client}),w&&{redirectUrl:w}),{locale:Z(T)}),_,e,t,i,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),o),k&&{exchangeCode:k,idpInitiated:!0}),q.descopeIdpInitiated&&{idpInitiated:!0}),I&&{token:I})):(l("projectId")||l("baseUrl")||l("executionId")||l("stepId"))&&(re.next=(...e)=>this.sdk.flow.next(f,p,...e)),this.stepState.update(re)}))}loadDescopeUiComponents(t){return e(this,void 0,void 0,(function*(){const i=yield vt.descopeUI;if(!i)return;const o=(e=>[...Array.from(e.querySelectorAll("*")).reduce(((e,t)=>t.tagName.startsWith("DESCOPE-")?e.add(t.tagName.toLocaleLowerCase()):e),new Set)])(t);yield Promise.all(o.map((t=>e(this,void 0,void 0,(function*(){if(!!!customElements.get(t))if(i[t])try{return yield i[t]()}catch(e){if("NotSupportedError"!==e.name)throw e;console.debug(`${t} is already registered`)}else this.loggerWrapper.error(`Cannot load UI component "${t}"`,`Descope UI does not have a component named "${t}", available components are: "${Object.keys(i).join(", ")}"`)})))))}))}onStepChange(i,o){var r,n;return e(this,void 0,void 0,(function*(){const{htmlUrl:s,htmlLocaleUrl:a,direction:l,next:d,screenState:c,openInNewTabUrl:u}=i,h=document.createElement("template");h.innerHTML=yield this.getPageContent(s,a);const p=h.content.cloneNode(!0),f=this.loadDescopeUiComponents(h.content);this.sdk.webauthn.helpers.isSupported()?yield t(this,Ge,"m",st).call(this,p,d):p.querySelectorAll(`descope-button[${x}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true"))),!i.samlIdpUsername||(null===(r=c.form)||void 0===r?void 0:r.loginId)||(null===(n=c.form)||void 0===n?void 0:n.email)||(c.form||(c.form={}),c.form.loginId=i.samlIdpUsername,c.form.email=i.samlIdpUsername),ue(p,c,c.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)}))})(p,g);const v=()=>e(this,void 0,void 0,(function*(){var e,i;yield f;const r=this.shadowRoot.querySelector("div");var n,s;n=r,s=null===(e=null==c?void 0:c.totp)||void 0===e?void 0:e.image,ce(n,"descope-totp-image",s),((e,t)=>{ce(e,"descope-notp-image",t)})(r,null===(i=null==c?void 0:c.notp)||void 0===i?void 0:i.image),this.rootElement.replaceChildren(p),setTimeout((()=>{((e,t)=>{ae(e,null==t?void 0:t.inputs),ae(e,null==t?void 0:t.form)})(this.rootElement,c);const e=this.rootElement.querySelectorAll("descope-email-field"),i=this.rootElement.querySelectorAll("descope-password"),o=this.rootElement.querySelectorAll("descope-new-password");document.querySelectorAll('[data-hidden-input="true"]').forEach((e=>e.remove())),[...e,...i,...o].forEach((e=>t(this,Ge,"m",nt).call(this,e)))}));const a=!o.htmlUrl;((e,t,i)=>{if(!0===t||"skipFirstScreen"===t&&!i){const t=e.querySelector("*[name]");setTimeout((()=>{null==t||t.focus()}))}})(this.rootElement,this.autoFocus,a),this.validateOnBlur&&(e=>{e.querySelectorAll("*[name]").forEach((e=>{e.addEventListener("blur",(()=>{var t;const i=e.focus;e.focus=()=>{},null===(t=e.reportValidity)||void 0===t||t.call(e),setTimeout((()=>{e.focus=i}))}))}))})(this.rootElement),t(this,Ge,"m",pt).call(this,d),a&&t(this,Ge,"m",gt).call(this,"ready",{}),t(this,Ge,"m",gt).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${x}="polling"]`)){const e=yield this.getFlowConfig(),i=yield this.getProjectConfig(),o=yield d(M,e.version,i.componentsVersion,{});t(this,it,"f").call(this,o)}u&&!o.openInNewTabUrl&&window.open(u,"_blank")}));l?t(this,Ge,"m",ft).call(this,v,l):v()}))}}Qe=new WeakMap,Xe=new WeakMap,Ye=new WeakMap,et=new WeakMap,tt=new WeakMap,it=new WeakMap,ot=new WeakMap,ut=new WeakMap,Ge=new WeakSet,Ze=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},rt=function(e){const t=e.getAttribute("name");if(!["email"].includes(t)){const i=`user-${t}`;e.setAttribute("name",i),e.addEventListener("input",(()=>{e.setAttribute("name",e.value?t:i)}))}},nt=function(e){if(!e)return;if("true"!==e.getAttribute("external-input"))return;e.querySelectorAll("input").forEach((t=>{const i=t.getAttribute("slot"),o=`input-${e.id}-${i}`,r=document.createElement("slot");r.setAttribute("name",o),r.setAttribute("slot",i),e.appendChild(r),t.setAttribute("slot",o),this.appendChild(t)}))},st=function(o,r){var n;return e(this,void 0,void 0,(function*(){null===(n=t(this,Xe,"f"))||void 0===n||n.abort();const s=o.querySelector('*[autocomplete="webauthn"]');if(s&&(yield he())){const{options:o,transactionId:n}=(yield t(this,ot,"f").call(this))||{};if(o&&n){t(this,Ge,"m",rt).call(this,s),i(this,Xe,new AbortController,"f");const a=yield this.getFlowConfig(),l=yield this.getProjectConfig();this.sdk.webauthn.helpers.conditional(o,t(this,Xe,"f")).then((i=>e(this,void 0,void 0,(function*(){const e=yield r(s.id,a.version,l.componentsVersion,{transactionId:n,response:i});t(this,it,"f").call(this,e)})))).catch((e=>{"AbortError"!==e.name&&this.loggerWrapper.error("Conditional login failed",e.message)}))}}}))},at=function(){let e=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((t=>{var i,o;"slot"!==t.localName&&(null===(i=t.reportValidity)||void 0===i||i.call(t),e&&(e=null===(o=t.checkValidity)||void 0===o?void 0:o.call(t)))})),e},lt=function(){return e(this,void 0,void 0,(function*(){const t=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${y}])`));return(yield Promise.all(t.map((t=>e(this,void 0,void 0,(function*(){return{name:t.getAttribute("name"),value:t.value}})))))).reduce(((e,t)=>Object.assign(Object.assign({},e),{[t.name]:t.value})),{})}))},dt=function(e){const t=this.nextRequestStatus.subscribe((({isLoading:i})=>{i?e.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(t),e.removeAttribute("loading"))}))},ct=function(e={}){var t,i;const o=X(e,["externalId","email","phone"]),r=X(e,["newPassword","password"]);if(o&&r)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:o,password:r});null===(i=null===(t=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===t?void 0:t.store)||void 0===i||i.call(t,e)}catch(e){this.loggerWrapper.error("Could not store credentials",e.message)}},ht=function(e){this.rootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((i=>{i.addEventListener("input",(()=>{var o;(null===(o=i.checkValidity)||void 0===o?void 0:o.call(i))&&t(this,ut,"f").call(this,i,e)}))}))},pt=function(e){this.rootElement.querySelectorAll("descope-button:not([data-exclude-next])").forEach((i=>{i.onclick=()=>{t(this,ut,"f").call(this,i,e)}})),t(this,Ge,"m",ht).call(this,e)},ft=function(e,t){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),e()}),{once:!0});const i=t===N.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(i)})),this.rootElement.classList.add("fade-out")},gt=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",mt);export{mt as D,ne as S};
|