@descope/web-component 2.6.2 → 2.6.3

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.
@@ -1 +1 @@
1
- import{__classPrivateFieldGet as e,__classPrivateFieldSet as n}from"tslib";import{S as t}from"./index-f2ed8e71.js";import"@descope/web-js-sdk";const s=(e,n,t,s={})=>{var i,o,l,a;return[Math.min(Math.max(n,("all"===s.left?e.offsetWidth:null!==(i=s.left)&&void 0!==i?i:0)-e.offsetWidth),window.innerWidth-("all"===s.right?e.offsetWidth:null!==(o=s.right)&&void 0!==o?o: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!==(a=s.bottom)&&void 0!==a?a:0))]};var i,o,l,a,r,d,c,h,p,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 } \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(),i.add(this),o.set(this,new t({messages:[]})),l.set(this,void 0),a.set(this,void 0),r.set(this,void 0),d.set(this,{resize:e(this,i,"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,a,e(this,l,"f").querySelector(".content"),"f"),n(this,r,e(this,l,"f").querySelector(".header"),"f")}updateData(n){e(this,o,"f").update((e=>({messages:e.messages.concat(n)})))}connectedCallback(){var n;((e,n,t)=>{let i=0,o=0,l=0,a=0;function r(n){n.preventDefault(),i=l-n.clientX,o=a-n.clientY,l=n.clientX,a=n.clientY;const[r,d]=s(e,e.offsetLeft-i,e.offsetTop-o,t);e.style.top=`${d}px`,e.style.left=`${r}px`}function d(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),l=e.clientX,a=e.clientY,document.onmouseup=d,document.onmousemove=r}n?n.onmousedown=c:e.onmousedown=c})(e(this,l,"f"),e(this,r,"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,i,"m",p).bind(this),e(this,o,"f").subscribe(e(this,i,"m",c).bind(this))}disconnectedCallback(){e(this,o,"f").unsubscribeAll(),window.removeEventListener("resize",e(this,d,"f").resize)}}o=new WeakMap,l=new WeakMap,a=new WeakMap,r=new WeakMap,d=new WeakMap,i=new WeakSet,c=function(n){e(this,i,"m",h).call(this,n),e(this,i,"m",p).call(this)},h=function(n){e(this,a,"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("")},p=function(){e(this,a,"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.define("descope-debugger",m);export{m as default};
1
+ import{__classPrivateFieldGet as e,__classPrivateFieldSet as n}from"tslib";import{S as t}from"./index-e6406c7c.js";import"@descope/web-js-sdk";const s=(e,n,t,s={})=>{var i,o,l,a;return[Math.min(Math.max(n,("all"===s.left?e.offsetWidth:null!==(i=s.left)&&void 0!==i?i:0)-e.offsetWidth),window.innerWidth-("all"===s.right?e.offsetWidth:null!==(o=s.right)&&void 0!==o?o: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!==(a=s.bottom)&&void 0!==a?a:0))]};var i,o,l,a,r,d,c,h,p,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 } \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(),i.add(this),o.set(this,new t({messages:[]})),l.set(this,void 0),a.set(this,void 0),r.set(this,void 0),d.set(this,{resize:e(this,i,"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,a,e(this,l,"f").querySelector(".content"),"f"),n(this,r,e(this,l,"f").querySelector(".header"),"f")}updateData(n){e(this,o,"f").update((e=>({messages:e.messages.concat(n)})))}connectedCallback(){var n;((e,n,t)=>{let i=0,o=0,l=0,a=0;function r(n){n.preventDefault(),i=l-n.clientX,o=a-n.clientY,l=n.clientX,a=n.clientY;const[r,d]=s(e,e.offsetLeft-i,e.offsetTop-o,t);e.style.top=`${d}px`,e.style.left=`${r}px`}function d(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),l=e.clientX,a=e.clientY,document.onmouseup=d,document.onmousemove=r}n?n.onmousedown=c:e.onmousedown=c})(e(this,l,"f"),e(this,r,"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,i,"m",p).bind(this),e(this,o,"f").subscribe(e(this,i,"m",c).bind(this))}disconnectedCallback(){e(this,o,"f").unsubscribeAll(),window.removeEventListener("resize",e(this,d,"f").resize)}}o=new WeakMap,l=new WeakMap,a=new WeakMap,r=new WeakMap,d=new WeakMap,i=new WeakSet,c=function(n){e(this,i,"m",h).call(this,n),e(this,i,"m",p).call(this)},h=function(n){e(this,a,"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("")},p=function(){e(this,a,"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.define("descope-debugger",m);export{m as default};
@@ -1 +1 @@
1
- import{__awaiter as t,__classPrivateFieldGet as e,__classPrivateFieldSet as i}from"tslib";import o from"@descope/web-js-sdk";const n="undefined"!=typeof localStorage,r=n&&localStorage.getItem("base.content.url")||"https://static.descope.com/pages",s="descope-login-flow",l="code",a="ra-challenge",d="ra-callback",c="ra-initiator",u="data-exclude-field",h="dls_last_auth",f="state_id",v="data-type",p="redirect",g="poll",m="webauthnCreate",b="webauthnGet",w="submit",y="polling";var I,k,C;function S(t){return new URLSearchParams(window.location.search).get(t)}function A(t){if(window.history.replaceState&&S(t)){const e=new URL(window.location.href),i=new URLSearchParams(e.search);i.delete(t),e.search=i.toString(),window.history.replaceState({},"",e.toString())}}function x(e,i){return t(this,void 0,void 0,(function*(){const t=yield fetch(e,{cache:"default"});if(!t.ok)throw Error(`Error fetching URL ${e}`);return{body:yield t[i||"text"](),headers:Object.fromEntries(t.headers.entries())}}))}!function(t){t.backward="backward",t.forward="forward"}(I||(I={}));function E(t,e){const i=new URL(r);return i.pathname=((...t)=>t.join("/").replace(/\/+/g,"/"))(i.pathname,t,"v2-alpha",e),i.toString()}function j(t,e){if(!Number.isNaN(t)&&!Number.isNaN(e))return t>e?I.forward:t<e?I.backward:void 0}const O=()=>{const[t="",e=""]=(S(s)||"").split("_");return{executionId:t,stepId:e}};function U(){return/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)}function L(){A(s)}const M=t=>t.replace(/-./g,(t=>t[1].toUpperCase())),R=()=>{const{executionId:t,stepId:e}=O();(t||e)&&L();const i=S("t")||void 0;i&&A("t");const o=S(l)||void 0;o&&A(l);const n=S("err")||void 0;n&&A("err");const{redirectAuthCodeChallenge:r,redirectAuthCallbackUrl:s,redirectAuthInitiator:u}={redirectAuthCodeChallenge:S(a),redirectAuthCallbackUrl:S(d),redirectAuthInitiator:S(c)};(r||s||u)&&(A(a),A(d),A(c));const h=S(f);return h&&A(f),{executionId:t,stepId:e,token:i,code:o,exchangeError:n,redirectAuthCodeChallenge:r,redirectAuthCallbackUrl:s,redirectAuthInitiator:u,oidcIdpStateId:h}},T=t=>{let e,i;return(...o)=>{return e&&(r=o,(n=e).length===r.length&&n.every(((t,e)=>t===r[e])))||(e=o,i=t(...o)),i;var n,r}},q=null===(C=null===(k=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===k?void 0:k.brands)||void 0===C?void 0:C.find((({brand:t,version:e})=>"Chromium"===t&&parseFloat(e))),W=(t,e)=>t&&!e;var $,K,N,P;function F(t,e){const i=Object.getOwnPropertyNames(t),o=Object.getOwnPropertyNames(e);if(i.length!==o.length)return!1;for(let o=0;o<i.length;o+=1){const n=i[o],r=t[n],s=e[n];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!F(r,s))return!1}else if(r!==s)return!1}return!0}class D{constructor(t={},{updateOnlyOnChange:o=!0}={}){$.set(this,void 0),K.set(this,{}),N.set(this,0),P.set(this,!1),this.update=t=>{const o="function"==typeof t?t(e(this,$,"f")):t,n=Object.assign(Object.assign({},e(this,$,"f")),o);if(!e(this,P,"f")||!F(e(this,$,"f"),n)){const t=e(this,$,"f");i(this,$,n,"f"),Object.freeze(e(this,$,"f")),setTimeout((()=>{Object.values(e(this,K,"f")).forEach((e=>e(n,t,((t,e)=>i=>t[i]!==e[i])(n,t))))}),0)}},i(this,$,t,"f"),i(this,P,o,"f")}get current(){return Object.assign({},e(this,$,"f"))}subscribe(t){return i(this,N,e(this,N,"f")+1,"f"),e(this,K,"f")[e(this,N,"f")]=t,e(this,N,"f").toString()}unsubscribe(t){const i=!!e(this,K,"f")[t];return i&&delete e(this,K,"f")[t],i}unsubscribeAll(){return i(this,K,{},"f"),!0}}$=new WeakMap,K=new WeakMap,N=new WeakMap,P=new WeakMap;const V=(t,e)=>{Object.entries(e||{}).forEach((([e,i])=>{Array.from(t.querySelectorAll(`.descope-input[name="${e}"]:not([${u}])`)).forEach((t=>{t.value=i}))}))},H=(t,e,i,o)=>{var n;let r=null==e?void 0:e.errorText;try{r=(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){o.error("Error transforming error message",t.message)}((t,e,i="")=>{t.querySelectorAll(`[${v}="${e}"]`).forEach((t=>{t.textContent=i,t.classList[i?"remove":"add"]("hide")}))})(t,"error-message",r),V(t,null==e?void 0:e.inputs),V(t,null==e?void 0:e.form),((t,e)=>{t.querySelectorAll(`[${v}="totp-link"]`).forEach((t=>{t.href=e}))})(t,null===(n=null==e?void 0:e.totp)||void 0===n?void 0:n.provisionUrl),((t,e)=>{t.querySelectorAll(".descope-text,.descope-link").forEach((t=>{t.textContent=((t,e)=>t.replace(/{{(.+?)}}/g,((t,i)=>{return o=e,i.split(".").reduce(((t,e)=>(null==t?void 0:t[e])||""),o);var o})))(t.textContent,e)}))})(t,e)},B=T((()=>t(void 0,void 0,void 0,(function*(){var t,e,i,o;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return console.warn("webauthn","Conditional UI is not supported"),!1;try{const n=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)))),r=108;return yield Promise.race([n,(i=100,new Promise(((t,e)=>{const n=setTimeout((()=>{e(new Error(`Promise timed out after ${i} ms`))}),i);null==o||o((e=>{clearTimeout(n),t(e)}),(t=>{clearTimeout(n),e(t)}))}))).catch((()=>q()>=r))])}catch(t){return console.warn("webauthn","Conditional login check failed",t),!1}})))),J={"lastAuth.loginId":{"not-empty":t=>!!t.loginId,empty:t=>!t.loginId},idpInitiated:{"is-true":t=>!!t.code,"is-false":t=>!t.code}};function _(t){const e={};if(t)try{Object.assign(e,JSON.parse(localStorage.getItem(h)))}catch(t){}return e}const z=document.createElement("template");var G,Q,X,Y,Z,tt,et,it,ot,nt,rt,st,lt,at,dt,ct,ut,ht,ft,vt,pt,gt,mt,bt,wt,yt,It,kt,Ct,St,At,xt,Et,jt,Ot,Ut,Lt,Mt,Rt;z.innerHTML='\n\t<style>\n\t\t:host {\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t}\n\t\t\n\t\t#wc-root {\n\t\t\theight: 100%;\n\t\t\ttransition: opacity 300ms ease-in-out;\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';class Tt extends HTMLElement{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","theme","debug","telemetryKey","redirect-url","auto-focus","prefer-biometrics"]}constructor(o){super(),G.add(this),Q.set(this,!1),X.set(this,new D({deferredRedirect:!1})),Y.set(this,new D),this.nextRequestStatus=new D({isLoading:!1}),Z.set(this,void 0),tt.set(this,{popstate:e(this,G,"m",st).bind(this),visibilitychange:e(this,G,"m",lt).bind(this)}),et.set(this,void 0),ct.set(this,T((()=>t(this,void 0,void 0,(function*(){const t=E(this.projectId,"config.json");try{const{body:e,headers:i}=yield x(t,"json");return{projectConfig:e,executionContext:{geo:i["x-geo"]}}}catch(t){this.logger.error("Cannot get config file","make sure that your projectId & flowId are correct")}return{}}))))),this.logger={error:(t,i="")=>{console.error(t,i,new Error),e(this,G,"m",mt).call(this,t,i)},info:(t,e="")=>{console.log(t,e)}},i(this,et,o,"f"),e(this,G,"m",it).call(this)}get projectId(){return this.getAttribute("project-id")}get flowId(){return this.getAttribute("flow-id")}get baseUrl(){return this.getAttribute("base-url")||void 0}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 theme(){var t,e;const i=this.getAttribute("theme");if("os"===i){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 i||"light"}get telemetryKey(){return this.getAttribute("telemetryKey")||void 0}get autoFocus(){var t;const e=null!==(t=this.getAttribute("auto-focus"))&&void 0!==t?t:"true";return"skipFirstScreen"===e?e:"true"===e}get preferBiometrics(){var t;return"true"===(null!==(t=this.getAttribute("prefer-biometrics"))&&void 0!==t?t:"true")}getExecutionContext(){return t(this,void 0,void 0,(function*(){const{executionContext:t}=yield e(this,ct,"f").call(this);return t}))}getFlowConfig(){var i,o;return t(this,void 0,void 0,(function*(){const{projectConfig:t}=yield e(this,ct,"f").call(this),n=(null===(i=null==t?void 0:t.flows)||void 0===i?void 0:i[this.flowId])||{};return null!==(o=n.version)&&void 0!==o||(n.version=0),n}))}connectedCallback(){return t(this,void 0,void 0,(function*(){if(this.shadowRoot.isConnected){if(e(this,G,"m",ot).call(this))return void e(this,G,"m",nt).call(this);e(this,G,"m",rt).call(this),e(this,G,"m",ht).call(this),e(this,G,"m",ut).call(this),e(this,G,"m",bt).call(this);const{executionId:t,stepId:o,token:n,code:r,exchangeError:s,redirectAuthCallbackUrl:l,redirectAuthCodeChallenge:a,redirectAuthInitiator:d,oidcIdpStateId:c}=R();window.addEventListener("popstate",e(this,tt,"f").popstate),window.addEventListener("visibilitychange",e(this,tt,"f").visibilitychange),e(this,X,"f").subscribe(e(this,G,"m",dt).bind(this)),e(this,Y,"f").subscribe(e(this,G,"m",gt).bind(this)),e(this,X,"f").update({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenant,redirectUrl:this.redirectUrl,stepId:o,executionId:t,token:n,code:r,exchangeError:s,telemetryKey:this.telemetryKey,redirectAuthCallbackUrl:l,redirectAuthCodeChallenge:a,redirectAuthInitiator:d,oidcIdpStateId:c}),e(this,Y,"f").update({isDebug:this.debug}),i(this,Q,!0,"f")}}))}disconnectedCallback(){e(this,X,"f").unsubscribeAll(),e(this,Y,"f").unsubscribeAll(),e(this,G,"m",pt).call(this),window.removeEventListener("popstate",e(this,tt,"f").popstate)}attributeChangedCallback(t,i,o){if(this.shadowRoot.isConnected&&e(this,Q,"f")&&i!==o&&Tt.observedAttributes.includes(t)){e(this,G,"m",rt).call(this);const n=null===i;e(this,X,"f").update((({stepId:e,executionId:i})=>{let r=e,s=i;return n||(s=null,r=null,L()),{[M(t)]:o,stepId:r,executionId:s}})),e(this,Y,"f").update({isDebug:this.debug})}}}Q=new WeakMap,X=new WeakMap,Y=new WeakMap,Z=new WeakMap,tt=new WeakMap,et=new WeakMap,ct=new WeakMap,G=new WeakSet,it=function(){this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(z.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#wc-root")},ot=function(){return!this.shadowRoot.host.closest("form")&&U()},nt=function(){const t=this.shadowRoot.host,e=document.createElement("form");t.parentElement.appendChild(e),e.appendChild(t)},rt=function(){const t=["base-url","tenant","theme","debug","telemetryKey","redirect-url","auto-focus","prefer-biometrics"];if(Tt.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[M(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')},st=function(){const{stepId:t,executionId:i}=O();e(this,X,"f").update({stepId:t,executionId:i})},lt=function(){document.hidden||setTimeout((()=>{e(this,X,"f").update({deferredRedirect:!1})}),300)},at=function(e,i,n){const r=n||void 0,s=!!r;this.sdk=o(Object.assign(Object.assign({persistTokens:!0},Tt.sdkConfigOverrides),{projectId:e,baseUrl:i,fpKey:r,fpLoad:s})),["start","next"].forEach((e=>{const i=this.sdk.flow[e];this.sdk.flow[e]=(...e)=>t(this,void 0,void 0,(function*(){this.nextRequestStatus.update({isLoading:!0});try{return yield i(...e)}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},dt=function(i,o,n){return t(this,void 0,void 0,(function*(){const{projectId:t,baseUrl:o,telemetryKey:r}=i;if(n("projectId")||n("baseUrl")||n("telemetryKey")){if(!t)return;e(this,G,"m",at).call(this,t,o,r)}e(this,et,"f").call(this,i)}))},ut=function(){var i,o,n,r;return t(this,void 0,void 0,(function*(){const{projectConfig:t}=yield e(this,ct,"f").call(this);null===(r=null===(n=null===(o=null===(i=null==t?void 0:t.cssTemplate)||void 0===i?void 0:i[this.theme])||void 0===o?void 0:o.typography)||void 0===n?void 0:n.fontFamilies)||void 0===r||r.forEach((t=>(t=>{if(!t)return;const e=document.createElement("link");e.href=t,e.rel="stylesheet",document.head.appendChild(e)})(t.url)))}))},ht=function(){e(this,G,"m",ft).call(this),e(this,G,"m",vt).call(this)},ft=function(){return t(this,void 0,void 0,(function*(){const t=document.createElement("style"),e=E(this.projectId,"theme.css");try{const{body:i}=yield x(e,"text");t.innerText=i}catch(t){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}this.shadowRoot.appendChild(t)}))},vt=function(){this.rootElement.setAttribute("data-theme",this.theme)},pt=function(){var t;null===(t=e(this,Z,"f"))||void 0===t||t.remove(),i(this,Z,null,"f")},gt=function({isDebug:o}){return t(this,void 0,void 0,(function*(){o?(yield import("./debugger-wc-7ba8871a.js"),i(this,Z,document.createElement("descope-debugger"),"f"),Object.assign(e(this,Z,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),document.body.appendChild(e(this,Z,"f"))):e(this,G,"m",pt).call(this)}))},mt=function(t,i){var o;t&&this.debug&&(null===(o=e(this,Z,"f"))||void 0===o||o.updateData({title:t,description:i}))},bt=function(){this.rootElement.onkeydown=t=>{if("Enter"!==t.key)return;t.preventDefault();const e=this.rootElement.querySelectorAll("button");if(1===e.length)return void e[0].click();const i=Array.from(e).filter((t=>"button"===t.getAttribute("data-type")));1===i.length&&i[0].click()}},Tt.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"2.6.2"}};class qt extends Tt{static set sdkConfigOverrides(t){Tt.sdkConfigOverrides=t}constructor(){const o=new D;super(o.update.bind(o)),wt.add(this),this.stepState=new D({},{updateOnlyOnChange:!1}),yt.set(this,void 0),It.set(this,null),kt.set(this,(()=>{clearInterval(e(this,yt,"f")),i(this,yt,null,"f")})),Ct.set(this,(t=>{var i,o,r,s,l,a,d,c,u;if(!(null==t?void 0:t.ok)){e(this,kt,"f").call(this),e(this,wt,"m",Rt).call(this,"error",null==t?void 0:t.error);const n=null===(i=null==t?void 0:t.response)||void 0===i?void 0:i.url,a=`${null===(o=null==t?void 0:t.response)||void 0===o?void 0:o.status} - ${null===(r=null==t?void 0:t.response)||void 0===r?void 0:r.statusText}`;return void this.logger.error((null===(s=null==t?void 0:t.error)||void 0===s?void 0:s.errorDescription)||n,(null===(l=null==t?void 0:t.error)||void 0===l?void 0:l.errorMessage)||a)}const f=null===(c=null===(d=null===(a=t.data)||void 0===a?void 0:a.screen)||void 0===d?void 0:d.state)||void 0===c?void 0:c.errorText;f&&this.logger.error(f),(null===(u=t.data)||void 0===u?void 0:u.error)&&this.logger.error(`[${t.data.error.code}]: ${t.data.error.description}`,t.data.error.message);const{status:v,authInfo:p,lastAuth:m}=t.data;if("completed"===v)return function(t){(null==t?void 0:t.authMethod)&&n&&localStorage.setItem(h,JSON.stringify(t))}(m),e(this,kt,"f").call(this),void e(this,wt,"m",Rt).call(this,"success",p);const{executionId:b,stepId:w,action:y,screen:I,redirect:k,webauthn:C}=t.data;y!==g?this.flowState.update({stepId:w,executionId:b,action:y,redirectTo:null==k?void 0:k.url,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}):this.flowState.update({action:y})})),St.set(this,T((()=>t(this,void 0,void 0,(function*(){var t;try{const e=yield this.sdk.webauthn.signIn.start("",window.location.origin);return e.ok||this.logger.error("Webauthn start failed",null===(t=null==e?void 0:e.error)||void 0===t?void 0:t.errorMessage),e.data}catch(t){this.logger.error("Webauthn start failed",t.message)}}))))),this.flowState=o}connectedCallback(){const e=Object.create(null,{connectedCallback:{get:()=>super.connectedCallback}});var i,o;return t(this,void 0,void 0,(function*(){this.shadowRoot.isConnected&&(null===(i=this.flowState)||void 0===i||i.subscribe(this.onFlowChange.bind(this)),null===(o=this.stepState)||void 0===o||o.subscribe(this.onStepChange.bind(this))),yield e.connectedCallback.call(this)}))}disconnectedCallback(){super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll()}onFlowChange(o,n,r){var s,l,a,d,c,u;return t(this,void 0,void 0,(function*(){const{projectId:h,flowId:f,tenant:v,stepId:I,executionId:k,action:C,screenId:S,screenState:A,redirectTo:x,redirectUrl:O,token:L,code:M,exchangeError:R,webauthnTransactionId:T,webauthnOptions:q,redirectAuthCodeChallenge:$,redirectAuthCallbackUrl:K,redirectAuthInitiator:N,oidcIdpStateId:P}=o;let F,D;e(this,yt,"f")&&e(this,kt,"f").call(this);const V=this.sdk.getLastUserLoginId(),H=yield this.getFlowConfig(),B=K&&$?{callbackUrl:K,codeChallenge:$}:void 0;if(!k&&(H.conditions?({startScreenId:F,conditionInteractionId:D}=((t,e)=>{const i=null==e?void 0:e.find((({key:e,operator:i})=>{var o;if("ELSE"===e)return!0;const n=null===(o=J[e])||void 0===o?void 0:o[i];return!!(null==n?void 0:n(t))}));return i?{startScreenId:i.met.screenId,conditionInteractionId:i.met.interactionId}:{}})({loginId:V,code:M},H.conditions)):H.condition?({startScreenId:F,conditionInteractionId:D}=((t,e)=>{var i;const o=null===(i=J[null==t?void 0:t.key])||void 0===i?void 0:i[t.operator];if(!o)return{};const n=o(e)?t.met:t.unmet;return{startScreenId:null==n?void 0:n.screenId,conditionInteractionId:null==n?void 0:n.interactionId}})(H.condition,{loginId:V,code:M})):F=H.startScreenId,!W(F,P))){const t=M?{exchangeCode:M,idpInitiated:!0}:void 0,i=yield this.sdk.flow.start(f,Object.assign(Object.assign({tenant:v,redirectAuth:B,oidcIdpStateId:P},O&&{redirectUrl:O}),{lastAuth:_(V)}),D,"",t,H.version);return e(this,Ct,"f").call(this,i),void("completed"!==(null===(s=null==i?void 0:i.data)||void 0===s?void 0:s.status)&&this.flowState.update({code:void 0}))}if(k&&(r("token")&&L||r("code")&&M||r("exchangeError")&&R)){const t=yield this.sdk.flow.next(k,I,w,{token:L,exchangeCode:M,exchangeError:R},H.version);return e(this,Ct,"f").call(this,t),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(C===p&&(r("redirectTo")||r("deferredRedirect")))return x?"android"===N&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(x):void this.logger.error("Did not get redirect url");if(C===m||C===b){if(!T||!q)return void this.logger.error("Did not get webauthn transaction id or options");let t,o,n=q;if(this.preferBiometrics&&C===m&&U()&&(yield null===(a=null===(l=window.PublicKeyCredential)||void 0===l?void 0:l.isUserVerifyingPlatformAuthenticatorAvailable)||void 0===a?void 0:a.call(l)))try{const t=JSON.parse(n);t.publicKey&&((c=t.publicKey).authenticatorSelection||(c.authenticatorSelection={}),(u=t.publicKey.authenticatorSelection).authenticatorAttachment||(u.authenticatorAttachment="platform"),n=JSON.stringify(t))}catch(t){this.logger.info("Failed to modify webauthn create options")}null===(d=e(this,It,"f"))||void 0===d||d.abort(),i(this,It,null,"f");try{t=C===m?yield this.sdk.webauthn.helpers.create(n):yield this.sdk.webauthn.helpers.get(n)}catch(t){if("NotAllowedError"!==t.name)return void this.logger.error(t.message);o=!0}const r=yield this.sdk.flow.next(k,I,w,{transactionId:T,response:t,cancelWebauthn:o},H.version);e(this,Ct,"f").call(this,r)}if(C===g&&i(this,yt,setInterval((()=>t(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(k,I,y,{},H.version);e(this,Ct,"f").call(this,t)}))),2e3),"f"),!S&&!F)return void this.logger.info("Refreshing the page during a flow is not supported yet");const z={direction:j(+I,+n.stepId),screenState:Object.assign(Object.assign({},A),{lastAuth:{loginId:V,name:this.sdk.getLastUserDisplayName()||V}}),htmlUrl:E(h,`${F||S}.html`)},G=_(V);W(F,P)?z.next=(t,e)=>this.sdk.flow.start(f,Object.assign({tenant:v,redirectAuth:B,oidcIdpStateId:P,lastAuth:G},O&&{redirectUrl:O}),D,t,Object.assign(Object.assign({},e),M&&{exchangeCode:M,idpInitiated:!0}),H.version):(r("projectId")||r("baseUrl")||r("executionId")||r("stepId"))&&(z.next=(...t)=>this.sdk.flow.next(k,I,...t)),this.stepState.update(z)}))}onStepChange(i,o){var n;return t(this,void 0,void 0,(function*(){const{htmlUrl:r,direction:s,next:l,screenState:a}=i,d=document.createElement("template"),{body:c}=yield x(r,"text");d.innerHTML=c;const u=d.content.cloneNode(!0),h=((t,e)=>{var i;const o=Array.from(t.querySelectorAll("script[data-id]")).map((i=>{var o;const n=i.getAttribute("data-id"),r=null===(o=t.getElementById(n))||void 0===o?void 0:o.innerHTML,s=Function(r).bind(i.previousSibling,e);return i.remove(),s}));return null===(i=t.querySelector("scripts"))||void 0===i||i.remove(),o})(u,yield this.getExecutionContext());this.sdk.webauthn.helpers.isSupported()?yield e(this,wt,"m",xt).call(this,u,l):u.querySelectorAll(`button[${v}="biometrics"]`).forEach((t=>t.setAttribute("disabled","true"))),H(u,a,this.errorTransformer,this.logger),((t,e)=>{var i;e&&(null===(i=null==t?void 0:t.style)||void 0===i||i.setProperty("--totp-image",`url(data:image/jpg;base64,${e})`))})(u.querySelector("div"),null===(n=null==a?void 0:a.totp)||void 0===n?void 0:n.image);const f=()=>t(this,void 0,void 0,(function*(){try{h.forEach((t=>{t()}))}catch(t){this.logger.error(t.message)}this.rootElement.replaceChildren(u);const t=!o.htmlUrl;((t,e,i)=>{if(!0===e||"skipFirstScreen"===e&&!i){const e=t.querySelector('input:not([aria-hidden="true"])');null==e||e.focus()}})(this.rootElement,this.autoFocus,t),e(this,wt,"m",Lt).call(this,l),e(this,wt,"m",Rt).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${v}="polling"]`)){const t=yield l(y,{});e(this,Ct,"f").call(this,t)}}));s?e(this,wt,"m",Mt).call(this,f,s):f()}))}}yt=new WeakMap,It=new WeakMap,kt=new WeakMap,Ct=new WeakMap,St=new WeakMap,wt=new WeakSet,At=function(t){const e=t.name;if(!["email"].includes(e)){const i=`user-${e}`;t.name=i,t.addEventListener("input",(()=>{t.name=t.value?e:i}))}},xt=function(o,n){var r;return t(this,void 0,void 0,(function*(){null===(r=e(this,It,"f"))||void 0===r||r.abort();const s=o.querySelector('input[autocomplete="webauthn"]');if(s&&(yield B())){const{options:o,transactionId:r}=(yield e(this,St,"f").call(this))||{};o&&r&&(e(this,wt,"m",At).call(this,s),i(this,It,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(o,e(this,It,"f")).then((i=>t(this,void 0,void 0,(function*(){const t=yield n(s.id,{transactionId:r,response:i});e(this,Ct,"f").call(this,t)})))).catch((t=>{"AbortError"!==t.name&&this.logger.error("Conditional login failed",t.message)})))}}))},Et=function(){return Array.from(this.shadowRoot.querySelectorAll(".descope-input")).every((t=>(t.reportValidity(),t.checkValidity())))},jt=function(){return Array.from(this.shadowRoot.querySelectorAll(`.descope-input[name]:not([${u}])`)).reduce(((t,e)=>e.name?Object.assign(t,{[e.name]:e["checkbox"===e.type?"checked":"value"]}):t),{})},Ot=function(t){const e=this.nextRequestStatus.subscribe((({isLoading:i})=>{var o,n;i?null===(o=null==t?void 0:t.classList)||void 0===o||o.add("loading"):(this.nextRequestStatus.unsubscribe(e),null===(n=null==t?void 0:t.classList)||void 0===n||n.remove("loading"))}))},Ut=function(i,o){return t(this,void 0,void 0,(function*(){if(i.formNoValidate||e(this,wt,"m",Et).call(this)){const n=null==i?void 0:i.getAttribute("id");e(this,wt,"m",Ot).call(this,i);const r=e(this,wt,"m",jt).call(this),s=(t=i,Array.from((null==t?void 0:t.attributes)||[]).reduce(((t,e)=>{var i;const o=null===(i=new RegExp("^data-descope-(\\S+)$").exec(e.name))||void 0===i?void 0:i[1];return o?Object.assign(t,{[o]:e.value}):t}),{})),l=Object.assign(Object.assign(Object.assign({},s),r),{origin:window.location.origin}),a=yield o(n,l);e(this,Ct,"f").call(this,a)}var t}))},Lt=function(t){this.rootElement.querySelectorAll("button").forEach((i=>{i.onclick=()=>{e(this,wt,"m",Ut).call(this,i,t)}}))},Mt=function(t,e){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),t()}),{once:!0});const i=e===I.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(i)})),this.rootElement.classList.add("fade-out")},Rt=function(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))},customElements.define("descope-wc",qt);export{qt as D,D as S};
1
+ import{__awaiter as t,__classPrivateFieldGet as e,__classPrivateFieldSet as i}from"tslib";import o from"@descope/web-js-sdk";const n="undefined"!=typeof localStorage,r=n&&localStorage.getItem("base.content.url")||"https://static.descope.com/pages",s="descope-login-flow",l="code",a="ra-challenge",d="ra-callback",c="ra-initiator",u="data-exclude-field",h="dls_last_auth",f="state_id",v="data-type",p="redirect",g="poll",m="webauthnCreate",b="webauthnGet",w="submit",y="polling";var I,k,C;function S(t){return new URLSearchParams(window.location.search).get(t)}function A(t){if(window.history.replaceState&&S(t)){const e=new URL(window.location.href),i=new URLSearchParams(e.search);i.delete(t),e.search=i.toString(),window.history.replaceState({},"",e.toString())}}function x(e,i){return t(this,void 0,void 0,(function*(){const t=yield fetch(e,{cache:"default"});if(!t.ok)throw Error(`Error fetching URL ${e}`);return{body:yield t[i||"text"](),headers:Object.fromEntries(t.headers.entries())}}))}!function(t){t.backward="backward",t.forward="forward"}(I||(I={}));function E(t,e){const i=new URL(r);return i.pathname=((...t)=>t.join("/").replace(/\/+/g,"/"))(i.pathname,t,"v2-alpha",e),i.toString()}function j(t,e){if(!Number.isNaN(t)&&!Number.isNaN(e))return t>e?I.forward:t<e?I.backward:void 0}const O=()=>{const[t="",e=""]=(S(s)||"").split("_");return{executionId:t,stepId:e}};function U(){return/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)}function L(){A(s)}const M=t=>t.replace(/-./g,(t=>t[1].toUpperCase())),R=()=>{const{executionId:t,stepId:e}=O();(t||e)&&L();const i=S("t")||void 0;i&&A("t");const o=S(l)||void 0;o&&A(l);const n=S("err")||void 0;n&&A("err");const{redirectAuthCodeChallenge:r,redirectAuthCallbackUrl:s,redirectAuthInitiator:u}={redirectAuthCodeChallenge:S(a),redirectAuthCallbackUrl:S(d),redirectAuthInitiator:S(c)};(r||s||u)&&(A(a),A(d),A(c));const h=S(f);return h&&A(f),{executionId:t,stepId:e,token:i,code:o,exchangeError:n,redirectAuthCodeChallenge:r,redirectAuthCallbackUrl:s,redirectAuthInitiator:u,oidcIdpStateId:h}},T=t=>{let e,i;return(...o)=>{return e&&(r=o,(n=e).length===r.length&&n.every(((t,e)=>t===r[e])))||(e=o,i=t(...o)),i;var n,r}},q=null===(C=null===(k=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===k?void 0:k.brands)||void 0===C?void 0:C.find((({brand:t,version:e})=>"Chromium"===t&&parseFloat(e))),W=(t,e)=>t&&!e;var $,K,N,P;function F(t,e){const i=Object.getOwnPropertyNames(t),o=Object.getOwnPropertyNames(e);if(i.length!==o.length)return!1;for(let o=0;o<i.length;o+=1){const n=i[o],r=t[n],s=e[n];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!F(r,s))return!1}else if(r!==s)return!1}return!0}class D{constructor(t={},{updateOnlyOnChange:o=!0}={}){$.set(this,void 0),K.set(this,{}),N.set(this,0),P.set(this,!1),this.update=t=>{const o="function"==typeof t?t(e(this,$,"f")):t,n=Object.assign(Object.assign({},e(this,$,"f")),o);if(!e(this,P,"f")||!F(e(this,$,"f"),n)){const t=e(this,$,"f");i(this,$,n,"f"),Object.freeze(e(this,$,"f")),setTimeout((()=>{Object.values(e(this,K,"f")).forEach((e=>e(n,t,((t,e)=>i=>t[i]!==e[i])(n,t))))}),0)}},i(this,$,t,"f"),i(this,P,o,"f")}get current(){return Object.assign({},e(this,$,"f"))}subscribe(t){return i(this,N,e(this,N,"f")+1,"f"),e(this,K,"f")[e(this,N,"f")]=t,e(this,N,"f").toString()}unsubscribe(t){const i=!!e(this,K,"f")[t];return i&&delete e(this,K,"f")[t],i}unsubscribeAll(){return i(this,K,{},"f"),!0}}$=new WeakMap,K=new WeakMap,N=new WeakMap,P=new WeakMap;const V=(t,e)=>{Object.entries(e||{}).forEach((([e,i])=>{Array.from(t.querySelectorAll(`.descope-input[name="${e}"]:not([${u}])`)).forEach((t=>{t.value=i}))}))},H=(t,e,i,o)=>{var n;let r=null==e?void 0:e.errorText;try{r=(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){o.error("Error transforming error message",t.message)}((t,e,i="")=>{t.querySelectorAll(`[${v}="${e}"]`).forEach((t=>{t.textContent=i,t.classList[i?"remove":"add"]("hide")}))})(t,"error-message",r),V(t,null==e?void 0:e.inputs),V(t,null==e?void 0:e.form),((t,e)=>{t.querySelectorAll(`[${v}="totp-link"]`).forEach((t=>{t.href=e}))})(t,null===(n=null==e?void 0:e.totp)||void 0===n?void 0:n.provisionUrl),((t,e)=>{t.querySelectorAll(".descope-text,.descope-link").forEach((t=>{t.textContent=((t,e)=>t.replace(/{{(.+?)}}/g,((t,i)=>{return o=e,i.split(".").reduce(((t,e)=>(null==t?void 0:t[e])||""),o);var o})))(t.textContent,e)}))})(t,e)},B=T((()=>t(void 0,void 0,void 0,(function*(){var t,e,i,o;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return console.warn("webauthn","Conditional UI is not supported"),!1;try{const n=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)))),r=108;return yield Promise.race([n,(i=100,new Promise(((t,e)=>{const n=setTimeout((()=>{e(new Error(`Promise timed out after ${i} ms`))}),i);null==o||o((e=>{clearTimeout(n),t(e)}),(t=>{clearTimeout(n),e(t)}))}))).catch((()=>q()>=r))])}catch(t){return console.warn("webauthn","Conditional login check failed",t),!1}})))),J={"lastAuth.loginId":{"not-empty":t=>!!t.loginId,empty:t=>!t.loginId},idpInitiated:{"is-true":t=>!!t.code,"is-false":t=>!t.code}};function _(t){const e={};if(t)try{Object.assign(e,JSON.parse(localStorage.getItem(h)))}catch(t){}return e}const z=document.createElement("template");var G,Q,X,Y,Z,tt,et,it,ot,nt,rt,st,lt,at,dt,ct,ut,ht,ft,vt,pt,gt,mt,bt,wt,yt,It,kt,Ct,St,At,xt,Et,jt,Ot,Ut,Lt,Mt,Rt;z.innerHTML='\n\t<style>\n\t\t:host {\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t}\n\t\t\n\t\t#wc-root {\n\t\t\theight: 100%;\n\t\t\ttransition: opacity 300ms ease-in-out;\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';class Tt extends HTMLElement{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","theme","debug","telemetryKey","redirect-url","auto-focus","prefer-biometrics"]}constructor(o){super(),G.add(this),Q.set(this,!1),X.set(this,new D({deferredRedirect:!1})),Y.set(this,new D),this.nextRequestStatus=new D({isLoading:!1}),Z.set(this,void 0),tt.set(this,{popstate:e(this,G,"m",st).bind(this),visibilitychange:e(this,G,"m",lt).bind(this)}),et.set(this,void 0),ct.set(this,T((()=>t(this,void 0,void 0,(function*(){const t=E(this.projectId,"config.json");try{const{body:e,headers:i}=yield x(t,"json");return{projectConfig:e,executionContext:{geo:i["x-geo"]}}}catch(t){this.logger.error("Cannot get config file","make sure that your projectId & flowId are correct")}return{}}))))),this.logger={error:(t,i="")=>{console.error(t,i,new Error),e(this,G,"m",mt).call(this,t,i)},info:(t,e="")=>{console.log(t,e)}},i(this,et,o,"f"),e(this,G,"m",it).call(this)}get projectId(){return this.getAttribute("project-id")}get flowId(){return this.getAttribute("flow-id")}get baseUrl(){return this.getAttribute("base-url")||void 0}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 theme(){var t,e;const i=this.getAttribute("theme");if("os"===i){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 i||"light"}get telemetryKey(){return this.getAttribute("telemetryKey")||void 0}get autoFocus(){var t;const e=null!==(t=this.getAttribute("auto-focus"))&&void 0!==t?t:"true";return"skipFirstScreen"===e?e:"true"===e}get preferBiometrics(){var t;return"true"===(null!==(t=this.getAttribute("prefer-biometrics"))&&void 0!==t?t:"true")}getExecutionContext(){return t(this,void 0,void 0,(function*(){const{executionContext:t}=yield e(this,ct,"f").call(this);return t}))}getFlowConfig(){var i,o;return t(this,void 0,void 0,(function*(){const{projectConfig:t}=yield e(this,ct,"f").call(this),n=(null===(i=null==t?void 0:t.flows)||void 0===i?void 0:i[this.flowId])||{};return null!==(o=n.version)&&void 0!==o||(n.version=0),n}))}connectedCallback(){return t(this,void 0,void 0,(function*(){if(this.shadowRoot.isConnected){if(e(this,G,"m",ot).call(this))return void e(this,G,"m",nt).call(this);e(this,G,"m",rt).call(this),e(this,G,"m",ht).call(this),e(this,G,"m",ut).call(this),e(this,G,"m",bt).call(this);const{executionId:t,stepId:o,token:n,code:r,exchangeError:s,redirectAuthCallbackUrl:l,redirectAuthCodeChallenge:a,redirectAuthInitiator:d,oidcIdpStateId:c}=R();window.addEventListener("popstate",e(this,tt,"f").popstate),window.addEventListener("visibilitychange",e(this,tt,"f").visibilitychange),e(this,X,"f").subscribe(e(this,G,"m",dt).bind(this)),e(this,Y,"f").subscribe(e(this,G,"m",gt).bind(this)),e(this,X,"f").update({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenant,redirectUrl:this.redirectUrl,stepId:o,executionId:t,token:n,code:r,exchangeError:s,telemetryKey:this.telemetryKey,redirectAuthCallbackUrl:l,redirectAuthCodeChallenge:a,redirectAuthInitiator:d,oidcIdpStateId:c}),e(this,Y,"f").update({isDebug:this.debug}),i(this,Q,!0,"f")}}))}disconnectedCallback(){e(this,X,"f").unsubscribeAll(),e(this,Y,"f").unsubscribeAll(),e(this,G,"m",pt).call(this),window.removeEventListener("popstate",e(this,tt,"f").popstate)}attributeChangedCallback(t,i,o){if(this.shadowRoot.isConnected&&e(this,Q,"f")&&i!==o&&Tt.observedAttributes.includes(t)){e(this,G,"m",rt).call(this);const n=null===i;e(this,X,"f").update((({stepId:e,executionId:i})=>{let r=e,s=i;return n||(s=null,r=null,L()),{[M(t)]:o,stepId:r,executionId:s}})),e(this,Y,"f").update({isDebug:this.debug})}}}Q=new WeakMap,X=new WeakMap,Y=new WeakMap,Z=new WeakMap,tt=new WeakMap,et=new WeakMap,ct=new WeakMap,G=new WeakSet,it=function(){this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(z.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#wc-root")},ot=function(){return!this.shadowRoot.host.closest("form")&&U()},nt=function(){const t=this.shadowRoot.host,e=document.createElement("form");t.parentElement.appendChild(e),e.appendChild(t)},rt=function(){const t=["base-url","tenant","theme","debug","telemetryKey","redirect-url","auto-focus","prefer-biometrics"];if(Tt.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[M(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')},st=function(){const{stepId:t,executionId:i}=O();e(this,X,"f").update({stepId:t,executionId:i})},lt=function(){document.hidden||setTimeout((()=>{e(this,X,"f").update({deferredRedirect:!1})}),300)},at=function(e,i,n){const r=n||void 0,s=!!r;this.sdk=o(Object.assign(Object.assign({persistTokens:!0},Tt.sdkConfigOverrides),{projectId:e,baseUrl:i,fpKey:r,fpLoad:s})),["start","next"].forEach((e=>{const i=this.sdk.flow[e];this.sdk.flow[e]=(...e)=>t(this,void 0,void 0,(function*(){this.nextRequestStatus.update({isLoading:!0});try{return yield i(...e)}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},dt=function(i,o,n){return t(this,void 0,void 0,(function*(){const{projectId:t,baseUrl:o,telemetryKey:r}=i;if(n("projectId")||n("baseUrl")||n("telemetryKey")){if(!t)return;e(this,G,"m",at).call(this,t,o,r)}e(this,et,"f").call(this,i)}))},ut=function(){var i,o,n,r;return t(this,void 0,void 0,(function*(){const{projectConfig:t}=yield e(this,ct,"f").call(this);null===(r=null===(n=null===(o=null===(i=null==t?void 0:t.cssTemplate)||void 0===i?void 0:i[this.theme])||void 0===o?void 0:o.typography)||void 0===n?void 0:n.fontFamilies)||void 0===r||r.forEach((t=>(t=>{if(!t)return;const e=document.createElement("link");e.href=t,e.rel="stylesheet",document.head.appendChild(e)})(t.url)))}))},ht=function(){e(this,G,"m",ft).call(this),e(this,G,"m",vt).call(this)},ft=function(){return t(this,void 0,void 0,(function*(){const t=document.createElement("style"),e=E(this.projectId,"theme.css");try{const{body:i}=yield x(e,"text");t.innerText=i}catch(t){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}this.shadowRoot.appendChild(t)}))},vt=function(){this.rootElement.setAttribute("data-theme",this.theme)},pt=function(){var t;null===(t=e(this,Z,"f"))||void 0===t||t.remove(),i(this,Z,null,"f")},gt=function({isDebug:o}){return t(this,void 0,void 0,(function*(){o?(yield import("./debugger-wc-b1cf5d64.js"),i(this,Z,document.createElement("descope-debugger"),"f"),Object.assign(e(this,Z,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),document.body.appendChild(e(this,Z,"f"))):e(this,G,"m",pt).call(this)}))},mt=function(t,i){var o;t&&this.debug&&(null===(o=e(this,Z,"f"))||void 0===o||o.updateData({title:t,description:i}))},bt=function(){this.rootElement.onkeydown=t=>{if("Enter"!==t.key)return;t.preventDefault();const e=this.rootElement.querySelectorAll("button");if(1===e.length)return void e[0].click();const i=Array.from(e).filter((t=>"button"===t.getAttribute("data-type")));1===i.length&&i[0].click()}},Tt.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"2.6.3"}};class qt extends Tt{static set sdkConfigOverrides(t){Tt.sdkConfigOverrides=t}constructor(){const o=new D;super(o.update.bind(o)),wt.add(this),this.stepState=new D({},{updateOnlyOnChange:!1}),yt.set(this,void 0),It.set(this,null),kt.set(this,(()=>{clearInterval(e(this,yt,"f")),i(this,yt,null,"f")})),Ct.set(this,(t=>{var i,o,r,s,l,a,d,c,u;if(!(null==t?void 0:t.ok)){e(this,kt,"f").call(this),e(this,wt,"m",Rt).call(this,"error",null==t?void 0:t.error);const n=null===(i=null==t?void 0:t.response)||void 0===i?void 0:i.url,a=`${null===(o=null==t?void 0:t.response)||void 0===o?void 0:o.status} - ${null===(r=null==t?void 0:t.response)||void 0===r?void 0:r.statusText}`;return void this.logger.error((null===(s=null==t?void 0:t.error)||void 0===s?void 0:s.errorDescription)||n,(null===(l=null==t?void 0:t.error)||void 0===l?void 0:l.errorMessage)||a)}const f=null===(c=null===(d=null===(a=t.data)||void 0===a?void 0:a.screen)||void 0===d?void 0:d.state)||void 0===c?void 0:c.errorText;f&&this.logger.error(f),(null===(u=t.data)||void 0===u?void 0:u.error)&&this.logger.error(`[${t.data.error.code}]: ${t.data.error.description}`,t.data.error.message);const{status:v,authInfo:p,lastAuth:m}=t.data;if("completed"===v)return function(t){(null==t?void 0:t.authMethod)&&n&&localStorage.setItem(h,JSON.stringify(t))}(m),e(this,kt,"f").call(this),void e(this,wt,"m",Rt).call(this,"success",p);const{executionId:b,stepId:w,action:y,screen:I,redirect:k,webauthn:C}=t.data;y!==g?this.flowState.update({stepId:w,executionId:b,action:y,redirectTo:null==k?void 0:k.url,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}):this.flowState.update({action:y})})),St.set(this,T((()=>t(this,void 0,void 0,(function*(){var t;try{const e=yield this.sdk.webauthn.signIn.start("",window.location.origin);return e.ok||this.logger.error("Webauthn start failed",null===(t=null==e?void 0:e.error)||void 0===t?void 0:t.errorMessage),e.data}catch(t){this.logger.error("Webauthn start failed",t.message)}}))))),this.flowState=o}connectedCallback(){const e=Object.create(null,{connectedCallback:{get:()=>super.connectedCallback}});var i,o;return t(this,void 0,void 0,(function*(){this.shadowRoot.isConnected&&(null===(i=this.flowState)||void 0===i||i.subscribe(this.onFlowChange.bind(this)),null===(o=this.stepState)||void 0===o||o.subscribe(this.onStepChange.bind(this))),yield e.connectedCallback.call(this)}))}disconnectedCallback(){super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll()}onFlowChange(o,n,r){var s,l,a,d,c,u;return t(this,void 0,void 0,(function*(){const{projectId:h,flowId:f,tenant:v,stepId:I,executionId:k,action:C,screenId:S,screenState:A,redirectTo:x,redirectUrl:O,token:L,code:M,exchangeError:R,webauthnTransactionId:T,webauthnOptions:q,redirectAuthCodeChallenge:$,redirectAuthCallbackUrl:K,redirectAuthInitiator:N,oidcIdpStateId:P}=o;let F,D;e(this,yt,"f")&&e(this,kt,"f").call(this);const V=this.sdk.getLastUserLoginId(),H=yield this.getFlowConfig(),B=K&&$?{callbackUrl:K,codeChallenge:$}:void 0;if(!k&&(H.conditions?({startScreenId:F,conditionInteractionId:D}=((t,e)=>{const i=null==e?void 0:e.find((({key:e,operator:i})=>{var o;if("ELSE"===e)return!0;const n=null===(o=J[e])||void 0===o?void 0:o[i];return!!(null==n?void 0:n(t))}));return i?{startScreenId:i.met.screenId,conditionInteractionId:i.met.interactionId}:{}})({loginId:V,code:M},H.conditions)):H.condition?({startScreenId:F,conditionInteractionId:D}=((t,e)=>{var i;const o=null===(i=J[null==t?void 0:t.key])||void 0===i?void 0:i[t.operator];if(!o)return{};const n=o(e)?t.met:t.unmet;return{startScreenId:null==n?void 0:n.screenId,conditionInteractionId:null==n?void 0:n.interactionId}})(H.condition,{loginId:V,code:M})):F=H.startScreenId,!W(F,P))){const t=M?{exchangeCode:M,idpInitiated:!0}:void 0,i=yield this.sdk.flow.start(f,Object.assign(Object.assign({tenant:v,redirectAuth:B,oidcIdpStateId:P},O&&{redirectUrl:O}),{lastAuth:_(V)}),D,"",t,H.version);return e(this,Ct,"f").call(this,i),void("completed"!==(null===(s=null==i?void 0:i.data)||void 0===s?void 0:s.status)&&this.flowState.update({code:void 0}))}if(k&&(r("token")&&L||r("code")&&M||r("exchangeError")&&R)){const t=yield this.sdk.flow.next(k,I,w,{token:L,exchangeCode:M,exchangeError:R},H.version);return e(this,Ct,"f").call(this,t),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(C===p&&(r("redirectTo")||r("deferredRedirect")))return x?"android"===N&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(x):void this.logger.error("Did not get redirect url");if(C===m||C===b){if(!T||!q)return void this.logger.error("Did not get webauthn transaction id or options");let t,o,n=q;if(this.preferBiometrics&&C===m&&U()&&(yield null===(a=null===(l=window.PublicKeyCredential)||void 0===l?void 0:l.isUserVerifyingPlatformAuthenticatorAvailable)||void 0===a?void 0:a.call(l)))try{const t=JSON.parse(n);t.publicKey&&((c=t.publicKey).authenticatorSelection||(c.authenticatorSelection={}),(u=t.publicKey.authenticatorSelection).authenticatorAttachment||(u.authenticatorAttachment="platform"),n=JSON.stringify(t))}catch(t){this.logger.info("Failed to modify webauthn create options")}null===(d=e(this,It,"f"))||void 0===d||d.abort(),i(this,It,null,"f");try{t=C===m?yield this.sdk.webauthn.helpers.create(n):yield this.sdk.webauthn.helpers.get(n)}catch(t){if("NotAllowedError"!==t.name)return void this.logger.error(t.message);o=!0}const r=yield this.sdk.flow.next(k,I,w,{transactionId:T,response:t,cancelWebauthn:o},H.version);e(this,Ct,"f").call(this,r)}if(C===g&&i(this,yt,setInterval((()=>t(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(k,I,y,{},H.version);e(this,Ct,"f").call(this,t)}))),2e3),"f"),!S&&!F)return void this.logger.info("Refreshing the page during a flow is not supported yet");const z={direction:j(+I,+n.stepId),screenState:Object.assign(Object.assign({},A),{lastAuth:{loginId:V,name:this.sdk.getLastUserDisplayName()||V}}),htmlUrl:E(h,`${F||S}.html`)},G=_(V);W(F,P)?z.next=(t,e)=>this.sdk.flow.start(f,Object.assign({tenant:v,redirectAuth:B,oidcIdpStateId:P,lastAuth:G},O&&{redirectUrl:O}),D,t,Object.assign(Object.assign({},e),M&&{exchangeCode:M,idpInitiated:!0}),H.version):(r("projectId")||r("baseUrl")||r("executionId")||r("stepId"))&&(z.next=(...t)=>this.sdk.flow.next(k,I,...t)),this.stepState.update(z)}))}onStepChange(i,o){var n;return t(this,void 0,void 0,(function*(){const{htmlUrl:r,direction:s,next:l,screenState:a}=i,d=document.createElement("template"),{body:c}=yield x(r,"text");d.innerHTML=c;const u=d.content.cloneNode(!0),h=((t,e)=>{var i;const o=Array.from(t.querySelectorAll("script[data-id]")).map((i=>{var o;const n=i.getAttribute("data-id"),r=null===(o=t.getElementById(n))||void 0===o?void 0:o.innerHTML,s=Function(r).bind(i.previousSibling,e);return i.remove(),s}));return null===(i=t.querySelector("scripts"))||void 0===i||i.remove(),o})(u,yield this.getExecutionContext());this.sdk.webauthn.helpers.isSupported()?yield e(this,wt,"m",xt).call(this,u,l):u.querySelectorAll(`button[${v}="biometrics"]`).forEach((t=>t.setAttribute("disabled","true"))),H(u,a,this.errorTransformer,this.logger),((t,e)=>{var i;e&&(null===(i=null==t?void 0:t.style)||void 0===i||i.setProperty("--totp-image",`url(data:image/jpg;base64,${e})`))})(u.querySelector("div"),null===(n=null==a?void 0:a.totp)||void 0===n?void 0:n.image);const f=()=>t(this,void 0,void 0,(function*(){try{h.forEach((t=>{t()}))}catch(t){this.logger.error(t.message)}this.rootElement.replaceChildren(u);const t=!o.htmlUrl;((t,e,i)=>{if(!0===e||"skipFirstScreen"===e&&!i){const e=t.querySelector('input:not([aria-hidden="true"])');null==e||e.focus()}})(this.rootElement,this.autoFocus,t),e(this,wt,"m",Lt).call(this,l),e(this,wt,"m",Rt).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${v}="polling"]`)){const t=yield l(y,{});e(this,Ct,"f").call(this,t)}}));s?e(this,wt,"m",Mt).call(this,f,s):f()}))}}yt=new WeakMap,It=new WeakMap,kt=new WeakMap,Ct=new WeakMap,St=new WeakMap,wt=new WeakSet,At=function(t){const e=t.name;if(!["email"].includes(e)){const i=`user-${e}`;t.name=i,t.addEventListener("input",(()=>{t.name=t.value?e:i}))}},xt=function(o,n){var r;return t(this,void 0,void 0,(function*(){null===(r=e(this,It,"f"))||void 0===r||r.abort();const s=o.querySelector('input[autocomplete="webauthn"]');if(s&&(yield B())){const{options:o,transactionId:r}=(yield e(this,St,"f").call(this))||{};o&&r&&(e(this,wt,"m",At).call(this,s),i(this,It,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(o,e(this,It,"f")).then((i=>t(this,void 0,void 0,(function*(){const t=yield n(s.id,{transactionId:r,response:i});e(this,Ct,"f").call(this,t)})))).catch((t=>{"AbortError"!==t.name&&this.logger.error("Conditional login failed",t.message)})))}}))},Et=function(){return Array.from(this.shadowRoot.querySelectorAll(".descope-input")).every((t=>(t.reportValidity(),t.checkValidity())))},jt=function(){return Array.from(this.shadowRoot.querySelectorAll(`.descope-input[name]:not([${u}])`)).reduce(((t,e)=>e.name?Object.assign(t,{[e.name]:e["checkbox"===e.type?"checked":"value"]}):t),{})},Ot=function(t){const e=this.nextRequestStatus.subscribe((({isLoading:i})=>{var o,n;i?null===(o=null==t?void 0:t.classList)||void 0===o||o.add("loading"):(this.nextRequestStatus.unsubscribe(e),null===(n=null==t?void 0:t.classList)||void 0===n||n.remove("loading"))}))},Ut=function(i,o){return t(this,void 0,void 0,(function*(){if(i.formNoValidate||e(this,wt,"m",Et).call(this)){const n=null==i?void 0:i.getAttribute("id");e(this,wt,"m",Ot).call(this,i);const r=e(this,wt,"m",jt).call(this),s=(t=i,Array.from((null==t?void 0:t.attributes)||[]).reduce(((t,e)=>{var i;const o=null===(i=new RegExp("^data-descope-(\\S+)$").exec(e.name))||void 0===i?void 0:i[1];return o?Object.assign(t,{[o]:e.value}):t}),{})),l=Object.assign(Object.assign(Object.assign({},s),r),{origin:window.location.origin}),a=yield o(n,l);e(this,Ct,"f").call(this,a)}var t}))},Lt=function(t){this.rootElement.querySelectorAll("button").forEach((i=>{i.onclick=()=>{e(this,wt,"m",Ut).call(this,i,t)}}))},Mt=function(t,e){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),t()}),{once:!0});const i=e===I.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(i)})),this.rootElement.classList.add("fade-out")},Rt=function(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))},customElements.define("descope-wc",qt);export{qt as D,D as S};
package/dist/esm/index.js CHANGED
@@ -1 +1 @@
1
- export{D as default}from"./index-f2ed8e71.js";import"tslib";import"@descope/web-js-sdk";
1
+ export{D as default}from"./index-e6406c7c.js";import"tslib";import"@descope/web-js-sdk";
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
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}const r="undefined"!=typeof localStorage,s=r&&localStorage.getItem("base.content.url")||"https://static.descope.com/pages",a="descope-login-flow",l="code",c="ra-challenge",d="ra-callback",u="ra-initiator",h="data-exclude-field",p="dls_last_auth",f="state_id",g="data-type",v="redirect",m="poll",b="webauthnCreate",w="webauthnGet",y="submit",I="polling";var k,O,x;function j(t){return new URLSearchParams(window.location.search).get(t)}function S(t){if(window.history.replaceState&&j(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 C(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}`);return{body:yield n[e||"text"](),headers:Object.fromEntries(n.headers.entries())}}))}!function(t){t.backward="backward",t.forward="forward"}(k||(k={}));function A(t,e){const n=new URL(s);return n.pathname=((...t)=>t.join("/").replace(/\/+/g,"/"))(n.pathname,t,"v2-alpha",e),n.toString()}function E(t,e){if(!Number.isNaN(t)&&!Number.isNaN(e))return t>e?k.forward:t<e?k.backward:void 0}const U=()=>{const[t="",e=""]=(j(a)||"").split("_");return{executionId:t,stepId:e}};function _(){return/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)}function R(){S(a)}const P=t=>t.replace(/-./g,(t=>t[1].toUpperCase())),T=()=>{const{executionId:t,stepId:e}=U();(t||e)&&R();const n=j("t")||void 0;n&&S("t");const o=j(l)||void 0;o&&S(l);const i=j("err")||void 0;i&&S("err");const{redirectAuthCodeChallenge:r,redirectAuthCallbackUrl:s,redirectAuthInitiator:a}={redirectAuthCodeChallenge:j(c),redirectAuthCallbackUrl:j(d),redirectAuthInitiator:j(u)};(r||s||a)&&(S(c),S(d),S(u));const h=j(f);return h&&S(f),{executionId:t,stepId:e,token:n,code:o,exchangeError:i,redirectAuthCodeChallenge:r,redirectAuthCallbackUrl:s,redirectAuthInitiator:a,oidcIdpStateId:h}},L=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}},M=null===(x=null===(O=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===O?void 0:O.brands)||void 0===x?void 0:x.find((({brand:t,version:e})=>"Chromium"===t&&parseFloat(e))),q=(t,e)=>t&&!e;var $,D,N,K;function F(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(!F(r,s))return!1}else if(r!==s)return!1}return!0}class W{constructor(t={},{updateOnlyOnChange:e=!0}={}){$.set(this,void 0),D.set(this,{}),N.set(this,0),K.set(this,!1),this.update=t=>{const e="function"==typeof t?t(o(this,$,"f")):t,n=Object.assign(Object.assign({},o(this,$,"f")),e);if(!o(this,K,"f")||!F(o(this,$,"f"),n)){const t=o(this,$,"f");i(this,$,n,"f"),Object.freeze(o(this,$,"f")),setTimeout((()=>{Object.values(o(this,D,"f")).forEach((e=>e(n,t,((t,e)=>n=>t[n]!==e[n])(n,t))))}),0)}},i(this,$,t,"f"),i(this,K,e,"f")}get current(){return Object.assign({},o(this,$,"f"))}subscribe(t){return i(this,N,o(this,N,"f")+1,"f"),o(this,D,"f")[o(this,N,"f")]=t,o(this,N,"f").toString()}unsubscribe(t){const e=!!o(this,D,"f")[t];return e&&delete o(this,D,"f")[t],e}unsubscribeAll(){return i(this,D,{},"f"),!0}}$=new WeakMap,D=new WeakMap,N=new WeakMap,K=new WeakMap;const J=(t,e)=>{Object.entries(e||{}).forEach((([e,n])=>{Array.from(t.querySelectorAll(`.descope-input[name="${e}"]:not([${h}])`)).forEach((t=>{t.value=n}))}))},H=(t,e,n,o)=>{var i;let r=null==e?void 0:e.errorText;try{r=(null==n?void 0:n({text:null==e?void 0:e.errorText,type:null==e?void 0:e.errorType}))||(null==e?void 0:e.errorText)}catch(t){o.error("Error transforming error message",t.message)}((t,e,n="")=>{t.querySelectorAll(`[${g}="${e}"]`).forEach((t=>{t.textContent=n,t.classList[n?"remove":"add"]("hide")}))})(t,"error-message",r),J(t,null==e?void 0:e.inputs),J(t,null==e?void 0:e.form),((t,e)=>{t.querySelectorAll(`[${g}="totp-link"]`).forEach((t=>{t.href=e}))})(t,null===(i=null==e?void 0:e.totp)||void 0===i?void 0:i.provisionUrl),((t,e)=>{t.querySelectorAll(".descope-text,.descope-link").forEach((t=>{t.textContent=((t,e)=>t.replace(/{{(.+?)}}/g,((t,n)=>{return o=e,n.split(".").reduce(((t,e)=>(null==t?void 0:t[e])||""),o);var o})))(t.textContent,e)}))})(t,e)},z=L((()=>n(void 0,void 0,void 0,(function*(){var t,e,n,o;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return console.warn("webauthn","Conditional UI is not supported"),!1;try{const i=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)))),r=108;return yield Promise.race([i,(n=100,new Promise(((t,e)=>{const i=setTimeout((()=>{e(new Error(`Promise timed out after ${n} ms`))}),n);null==o||o((e=>{clearTimeout(i),t(e)}),(t=>{clearTimeout(i),e(t)}))}))).catch((()=>M()>=r))])}catch(t){return console.warn("webauthn","Conditional login check failed",t),!1}})))),B=(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))]},V={"lastAuth.loginId":{"not-empty":t=>!!t.loginId,empty:t=>!t.loginId},idpInitiated:{"is-true":t=>!!t.code,"is-false":t=>!t.code}};function Z(t){const e={};if(t)try{Object.assign(e,JSON.parse(localStorage.getItem(p)))}catch(t){}return e}function G(t){this.message=t}G.prototype=new Error,G.prototype.name="InvalidCharacterError";var X="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new G("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,o,i=0,r=0,s="";o=e.charAt(r++);~o&&(n=i%4?64*n+o:o,i++%4)?s+=String.fromCharCode(255&n>>(-2*i&6)):0)o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);return s};function Y(t){this.message=t}function Q(t,e){if("string"!=typeof t)throw new Y("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(X(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 X(e)}}(t.split(".")[n]))}catch(t){throw new Y("Invalid token specified: "+t.message)}}Y.prototype=new Error,Y.prototype.name="InvalidTokenError";var tt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function et(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var nt="__lodash_hash_undefined__",ot=1/0,it="[object Function]",rt="[object GeneratorFunction]",st="[object Symbol]",at=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,lt=/^\w*$/,ct=/^\./,dt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ut=/\\(\\)?/g,ht=/^\[object .+?Constructor\]$/,pt="object"==typeof tt&&tt&&tt.Object===Object&&tt,ft="object"==typeof self&&self&&self.Object===Object&&self,gt=pt||ft||Function("return this")();var vt,mt=Array.prototype,bt=Function.prototype,wt=Object.prototype,yt=gt["__core-js_shared__"],It=(vt=/[^.]+$/.exec(yt&&yt.keys&&yt.keys.IE_PROTO||""))?"Symbol(src)_1."+vt:"",kt=bt.toString,Ot=wt.hasOwnProperty,xt=wt.toString,jt=RegExp("^"+kt.call(Ot).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),St=gt.Symbol,Ct=mt.splice,At=Dt(gt,"Map"),Et=Dt(Object,"create"),Ut=St?St.prototype:void 0,_t=Ut?Ut.toString:void 0;function Rt(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var o=t[e];this.set(o[0],o[1])}}function Pt(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var o=t[e];this.set(o[0],o[1])}}function Tt(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var o=t[e];this.set(o[0],o[1])}}function Lt(t,e){for(var n,o,i=t.length;i--;)if((n=t[i][0])===(o=e)||n!=n&&o!=o)return i;return-1}function Mt(t,e){var n;e=function(t,e){if(Wt(t))return!1;var n=typeof t;if("number"==n||"symbol"==n||"boolean"==n||null==t||Ht(t))return!0;return lt.test(t)||!at.test(t)||null!=e&&t in Object(e)}(e,t)?[e]:Wt(n=e)?n:Nt(n);for(var o=0,i=e.length;null!=t&&o<i;)t=t[Kt(e[o++])];return o&&o==i?t:void 0}function qt(t){if(!Jt(t)||(e=t,It&&It in e))return!1;var e,n=function(t){var e=Jt(t)?xt.call(t):"";return e==it||e==rt}(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t)?jt:ht;return n.test(function(t){if(null!=t){try{return kt.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}function $t(t,e){var n,o,i=t.__data__;return("string"==(o=typeof(n=e))||"number"==o||"symbol"==o||"boolean"==o?"__proto__"!==n:null===n)?i["string"==typeof e?"string":"hash"]:i.map}function Dt(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return qt(n)?n:void 0}Rt.prototype.clear=function(){this.__data__=Et?Et(null):{}},Rt.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},Rt.prototype.get=function(t){var e=this.__data__;if(Et){var n=e[t];return n===nt?void 0:n}return Ot.call(e,t)?e[t]:void 0},Rt.prototype.has=function(t){var e=this.__data__;return Et?void 0!==e[t]:Ot.call(e,t)},Rt.prototype.set=function(t,e){return this.__data__[t]=Et&&void 0===e?nt:e,this},Pt.prototype.clear=function(){this.__data__=[]},Pt.prototype.delete=function(t){var e=this.__data__,n=Lt(e,t);return!(n<0)&&(n==e.length-1?e.pop():Ct.call(e,n,1),!0)},Pt.prototype.get=function(t){var e=this.__data__,n=Lt(e,t);return n<0?void 0:e[n][1]},Pt.prototype.has=function(t){return Lt(this.__data__,t)>-1},Pt.prototype.set=function(t,e){var n=this.__data__,o=Lt(n,t);return o<0?n.push([t,e]):n[o][1]=e,this},Tt.prototype.clear=function(){this.__data__={hash:new Rt,map:new(At||Pt),string:new Rt}},Tt.prototype.delete=function(t){return $t(this,t).delete(t)},Tt.prototype.get=function(t){return $t(this,t).get(t)},Tt.prototype.has=function(t){return $t(this,t).has(t)},Tt.prototype.set=function(t,e){return $t(this,t).set(t,e),this};var Nt=Ft((function(t){var e;t=null==(e=t)?"":function(t){if("string"==typeof t)return t;if(Ht(t))return _t?_t.call(t):"";var e=t+"";return"0"==e&&1/t==-ot?"-0":e}(e);var n=[];return ct.test(t)&&n.push(""),t.replace(dt,(function(t,e,o,i){n.push(o?i.replace(ut,"$1"):e||t)})),n}));function Kt(t){if("string"==typeof t||Ht(t))return t;var e=t+"";return"0"==e&&1/t==-ot?"-0":e}function Ft(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError("Expected a function");var n=function(){var o=arguments,i=e?e.apply(this,o):o[0],r=n.cache;if(r.has(i))return r.get(i);var s=t.apply(this,o);return n.cache=r.set(i,s),s};return n.cache=new(Ft.Cache||Tt),n}Ft.Cache=Tt;var Wt=Array.isArray;function Jt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Ht(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&xt.call(t)==st}var zt=et((function(t,e,n){var o=null==t?void 0:Mt(t,e);return void 0===o?n:o})),Bt="/v1/auth/accesskey/exchange",Vt="/v1/auth/otp/verify",Zt="/v1/auth/otp/signin",Gt="/v1/auth/otp/signup",Xt={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},Yt="/v1/auth/otp/signup-in",Qt="/v1/auth/magiclink/verify",te="/v1/auth/magiclink/signin",ee="/v1/auth/magiclink/signup",ne={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},oe="/v1/auth/magiclink/signup-in",ie="/v1/auth/enchantedlink/verify",re="/v1/auth/enchantedlink/signin",se="/v1/auth/enchantedlink/signup",ae="/v1/auth/enchantedlink/pending-session",le={email:"/v1/auth/enchantedlink/update/email"},ce="/v1/auth/enchantedlink/signup-in",de="/v1/auth/oauth/authorize",ue="/v1/auth/oauth/exchange",he="/v1/auth/saml/authorize",pe="/v1/auth/saml/exchange",fe="/v1/auth/totp/verify",ge="/v1/auth/totp/signup",ve="/v1/auth/totp/update",me={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},be={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},we={start:"/v1/auth/webauthn/signup-in/start"},ye={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},Ie="/v1/auth/password/signup",ke="/v1/auth/password/signin",Oe="/v1/auth/password/reset",xe="/v1/auth/password/update",je="/v1/auth/password/replace",Se="/v1/auth/password/policy",Ce="/v1/auth/refresh",Ae="/v1/auth/logout",Ee="/v1/auth/logoutall",Ue="/v1/auth/me",_e="/v1/flow/start",Re="/v1/flow/next";const Pe=6e5,Te=()=>{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 Le;!function(t){t.get="GET",t.delete="DELETE",t.post="POST",t.put="PUT"}(Le||(Le={}));const Me=(...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}),{})),qe=t=>void 0===t?void 0:JSON.stringify(t),$e=(t,e="")=>{let n=t;return e&&(n=n+":"+e),{Authorization:`Bearer ${n}`}},De=({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=>Te().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 Te().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=>{const s=(null==i?void 0:i.beforeRequest)?i.beforeRequest(o):o,{path:l,body:c,headers:d,queryParams:u,method:h,token:p}=s,f=await a((({path:t,baseUrl:e,queryParams:n})=>{const o=new URL(t,e);return n&&(o.search=new URLSearchParams(n).toString()),o})({path:l,baseUrl:t,queryParams:u}),{headers:Me($e(e,p),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"1.4.5"},(null==n?void 0:n.baseHeaders)||{},d),method:h,body:qe(c),credentials:r||"include"});return(null==i?void 0:i.afterRequest)&&await i.afterRequest(o,null==f?void 0:f.clone()),f};return{get:(t,{headers:e,queryParams:n,token:o}={})=>l({path:t,headers:e,queryParams:n,body:void 0,method:Le.get,token:o}),post:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:Le.post,token:i}),put:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:Le.put,token:i}),delete:(t,{headers:e,queryParams:n,token:o}={})=>l({path:t,headers:e,queryParams:n,body:void 0,method:Le.delete,token:o}),hooks:i}};var Ne=429;function Ke(t,e,n){var o;let i=Fe(t);e&&(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 Fe(t){if("string"!=typeof t||!t)throw new Error("Invalid token provided");return Q(t)}function We(t){const{exp:e}=Fe(t);return(new Date).getTime()/1e3>e}function Je(t){let e=Fe(t);const n=Object.keys(null==e?void 0:e.tenants);return Array.isArray(n)?n:[]}function He(t,e){return Ke(t,e,"permissions")}function ze(t,e){return Ke(t,e,"roles")}const Be=(...t)=>t.join("/").replace(/\/{2,}/g,"/");async function Ve(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===Ne&&Object.assign(i.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),i}const Ze=(t,e)=>(n=e)=>e=>!t(e)&&n.replace("{val}",e),Ge=(...t)=>({validate:e=>(t.forEach((t=>{const n=t(e);if(n)throw new Error(n)})),!0)}),Xe=t=>e=>t.test(e),Ye=Xe(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Qe=Xe(/^\+[1-9]{1}[0-9]{3,14}$/),tn=Ze(Ye,'"{val}" is not a valid email'),en=Ze(Qe,'"{val}" is not a valid phone number'),nn=Ze((1,t=>t.length>=1),"Minimum length is 1");const on=Ze((t=>"string"==typeof t),"Input is not a string"),rn=Ze((t=>void 0===t),"Input is defined"),sn=(an=[on(),rn()],"Input is not a string or undefined",(t="Input is not a string or undefined")=>e=>{const n=an.filter((t=>t(e)));return!(n.length<an.length)&&(t?t.replace("{val}",e):n.join(" OR "))});var an;const ln=(...t)=>e=>(...n)=>(t.forEach(((t,e)=>Ge(...t).validate(n[e]))),e(...n)),cn=t=>[on(`"${t}" must be a string`),nn(`"${t}" must not be empty`)],dn=t=>[on(`"${t}" must be a string`),tn()],un=t=>[on(`"${t}" must be a string`),en()],hn=ln(cn("accessKey")),pn=t=>({exchange:hn((e=>Ve(t.post(Bt,{},{token:e}))))});var fn,gn;!function(t){t.sms="sms",t.whatsapp="whatsapp"}(fn||(fn={})),function(t){t.email="email"}(gn||(gn={}));const vn=Object.assign(Object.assign({},fn),gn);var mn;!function(t){t.waiting="waiting",t.running="running",t.completed="completed",t.failed="failed"}(mn||(mn={}));const bn=cn("loginId"),wn=ln(cn("token")),yn=ln(bn),In=ln(cn("pendingRef")),kn=ln(bn,dn("email")),On=t=>({verify:wn((e=>Ve(t.post(ie,{token:e})))),signIn:yn(((e,n,o,i)=>Ve(t.post(Be(re,vn.email),{loginId:e,URI:n,loginOptions:o},{token:i})))),signUpOrIn:yn(((e,n)=>Ve(t.post(Be(ce,vn.email),{loginId:e,URI:n})))),signUp:yn(((e,n,o)=>Ve(t.post(Be(se,vn.email),{loginId:e,URI:n,user:o})))),waitForSession:In(((e,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=(({pollingIntervalMs:t=1e3,timeoutMs:e=6e5}={})=>({pollingIntervalMs:Math.max(t||1e3,1e3),timeoutMs:Math.min(e||Pe,Pe)}))(n);let s;const a=setInterval((async()=>{const n=await t.post(ae,{pendingRef:e});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(Ve(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:kn(((e,n,o,i,r)=>Ve(t.post(le.email,Object.assign({loginId:e,email:n,URI:o},r),{token:i}))))}}),xn=ln(cn("flowId")),jn=ln(cn("executionId"),cn("stepId"),cn("interactionId")),Sn=t=>({start:xn(((e,n,o,i,r,s)=>Ve(t.post(_e,{flowId:e,options:n,conditionInteractionId:o,interactionId:i,input:r,version:s})))),next:jn(((e,n,o,i,r)=>Ve(t.post(Re,{executionId:e,stepId:n,interactionId:o,input:i,version:r}))))}),Cn=cn("loginId"),An=ln(cn("token")),En=ln(Cn),Un=ln(Cn,un("phone")),_n=ln(Cn,dn("email")),Rn=t=>({verify:An((e=>Ve(t.post(Qt,{token:e})))),signIn:Object.keys(vn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:En(((e,o,i,r)=>Ve(t.post(Be(te,n),{loginId:e,URI:o,loginOptions:i},{token:r}))))})),{}),signUp:Object.keys(vn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:En(((e,o,i)=>Ve(t.post(Be(ee,n),{loginId:e,URI:o,user:i}))))})),{}),signUpOrIn:Object.keys(vn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:En(((e,o)=>Ve(t.post(Be(oe,n),{loginId:e,URI:o}))))})),{}),update:{email:_n(((e,n,o,i,r)=>Ve(t.post(ne.email,Object.assign({loginId:e,email:n,URI:o},r),{token:i})))),phone:Object.keys(fn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Un(((e,o,i,r,s)=>Ve(t.post(Be(ne.phone,n),Object.assign({loginId:e,phone:o,URI:i},s),{token:r}))))})),{})}});var Pn;!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"}(Pn||(Pn={}));const Tn=ln(cn("code")),Ln=t=>({start:Object.keys(Pn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:(e,o,i)=>Ve(t.post(de,o||{},{queryParams:Object.assign({provider:n},e&&{redirectURL:e}),token:i}))})),{}),exchange:Tn((e=>Ve(t.post(ue,{code:e}))))}),Mn=cn("loginId"),qn=ln(Mn,cn("code")),$n=ln(Mn),Dn=ln(Mn,un("phone")),Nn=ln(Mn,dn("email")),Kn=t=>({verify:Object.keys(vn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:qn(((e,o)=>Ve(t.post(Be(Vt,n),{code:o,loginId:e}))))})),{}),signIn:Object.keys(vn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:$n(((e,o,i)=>Ve(t.post(Be(Zt,n),{loginId:e,loginOptions:o},{token:i}))))})),{}),signUp:Object.keys(vn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:$n(((e,o)=>Ve(t.post(Be(Gt,n),{loginId:e,user:o}))))})),{}),signUpOrIn:Object.keys(vn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:$n((e=>Ve(t.post(Be(Yt,n),{loginId:e}))))})),{}),update:{email:Nn(((e,n,o,i)=>Ve(t.post(Xt.email,Object.assign({loginId:e,email:n},i),{token:o})))),phone:Object.keys(fn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Dn(((e,o,i,r)=>Ve(t.post(Be(Xt.phone,n),Object.assign({loginId:e,phone:o},r),{token:i}))))})),{})}}),Fn=ln(cn("tenant")),Wn=ln(cn("code")),Jn=t=>({start:Fn(((e,n,o,i)=>Ve(t.post(he,o||{},{queryParams:{tenant:e,redirectURL:n},token:i})))),exchange:Wn((e=>Ve(t.post(pe,{code:e}))))}),Hn=cn("loginId"),zn=ln(Hn,cn("code")),Bn=ln(Hn),Vn=ln(Hn),Zn=t=>({signUp:Bn(((e,n)=>Ve(t.post(ge,{loginId:e,user:n})))),verify:zn(((e,n,o,i)=>Ve(t.post(fe,{loginId:e,code:n,loginOptions:o},{token:i})))),update:Vn(((e,n)=>Ve(t.post(ve,{loginId:e},{token:n}))))}),Gn=cn("loginId"),Xn=cn("newPassword"),Yn=ln(Gn,cn("password")),Qn=ln(Gn),to=ln(Gn,Xn),eo=ln(Gn,cn("oldPassword"),Xn),no=t=>({signUp:Yn(((e,n,o)=>Ve(t.post(Ie,{loginId:e,password:n,user:o})))),signIn:Yn(((e,n)=>Ve(t.post(ke,{loginId:e,password:n})))),sendReset:Qn(((e,n)=>Ve(t.post(Oe,{loginId:e,redirectUrl:n})))),update:to(((e,n,o)=>Ve(t.post(xe,{loginId:e,newPassword:n},{token:o})))),replace:eo(((e,n,o)=>Ve(t.post(je,{loginId:e,oldPassword:n,newPassword:o})))),policy:()=>Ve(t.get(Se))}),oo=[on('"loginId" must be a string')],io=cn("loginId"),ro=cn("origin"),so=ln(io,ro,cn("name")),ao=ln(io,ro),lo=ln(oo,ro),co=ln(io,ro,cn("token")),uo=ln(cn("transactionId"),cn("response")),ho=t=>({signUp:{start:so(((e,n,o)=>Ve(t.post(me.start,{user:{loginId:e,name:o},origin:n})))),finish:uo(((e,n)=>Ve(t.post(me.finish,{transactionId:e,response:n}))))},signIn:{start:lo(((e,n,o,i)=>Ve(t.post(be.start,{loginId:e,origin:n,loginOptions:o},{token:i})))),finish:uo(((e,n)=>Ve(t.post(be.finish,{transactionId:e,response:n}))))},signUpOrIn:{start:ao(((e,n)=>Ve(t.post(we.start,{loginId:e,origin:n}))))},update:{start:co(((e,n,o)=>Ve(t.post(ye.start,{loginId:e,origin:n},{token:o})))),finish:uo(((e,n)=>Ve(t.post(ye.finish,{transactionId:e,response:n}))))}}),po=ln(cn("token")),fo=ln([sn('"token" must be string or undefined')]);var go,vo=ln([("projectId",go=cn("projectId"),Ze(((t,e)=>n=>Ge(...e).validate(zt(n,t)))("projectId",go))())])((t=>{var e,n;const o=[].concat((null===(e=t.hooks)||void 0===e?void 0:e.beforeRequest)||[]),i=[].concat((null===(n=t.hooks)||void 0===n?void 0:n.afterRequest)||[]);return(({projectId:t,logger:e,baseUrl:n,hooks:o,cookiePolicy:i,baseHeaders:r={},fetch:s})=>{return a=De({baseUrl:n||"https://api.descope.com",projectId:t,logger:e,hooks:o,cookiePolicy:i,baseConfig:{baseHeaders:r},fetch:s}),{accessKey:pn(a),otp:Kn(a),magicLink:Rn(a),enchantedLink:On(a),oauth:Ln(a),saml:Jn(a),totp:Zn(a),webauthn:ho(a),password:no(a),flow:Sn(a),refresh:fo((t=>Ve(a.post(Ce,{},{token:t})))),logout:fo((t=>Ve(a.post(Ae,{},{token:t})))),logoutAll:fo((t=>Ve(a.post(Ee,{},{token:t})))),me:fo((t=>Ve(a.get(Ue,{token:t})))),isJwtExpired:po(We),getTenants:po(Je),getJwtPermissions:po(He),getJwtRoles:po(ze),httpClient:a};var a})(Object.assign(Object.assign({},t),{hooks:{beforeRequest:t=>null==o?void 0:o.reduce(((t,e)=>e(t)),t),afterRequest:async(e,n)=>{(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))}))}}}))}));const mo=(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);var bo=Object.assign(vo,{DeliveryMethods:vn});var wo="Blocked by CSP",yo="9319";function Io(t,e){var n=[];return function(t,e){var n,o,i=(o=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),{current:function(){return o[0]},postpone:function(){var t=o.shift();void 0!==t&&o.push(t)},exclude:function(){o.shift()}}),r=(100,3e3,n=0,function(){return Math.random()*Math.min(3e3,100*Math.pow(2,n++))}),s=i.current();if(void 0===s)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var a=function(t,n){return e(t).catch((function(t){if(n+1>=5)throw t;!function(t){if(!(t instanceof Error))return!1;var e=t.message;return e===wo||e===yo}(t)?i.postpone():i.exclude();var e,o=i.current();if(void 0===o)throw t;return(e=r(),new Promise((function(t){return setTimeout(t,e)}))).then((function(){return a(o,n+1)}))}))};return a(s,0)}(t,(function(t){var o=new Date,i=function(){return n.push({url:t,startedAt:o,finishedAt:new Date})},r=e(t);return r.then(i,i),r})).then((function(t){return[t,{attempts:n}]}))}var ko="Failed to load the JS script of the agent";function Oo(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:"https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js";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.8.3"):t}))}(String(t),e)}))}(l,s);return Io(t,xo).catch(So)})).then((function(e){var n=e[0],o=e[1];return n.load(t(t({},a),{ldi:o}))}))}function xo(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 Promise.resolve().then(e).then((function(t){return l(),t}),(function(t){return new Promise((function(t){return setTimeout(t)})).then((function(){if(l(),i)return function(){throw new Error(wo)}();throw t}))}))}(t,(function(){return function(t){return new Promise((function(e,n){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(ko))},o.async=!0,o.src=t,r.appendChild(o)}))}(t)})).then(jo)}function jo(){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(yo);return n}function So(t){throw t instanceof Error&&t.message===yo?new Error(ko):t}
2
- /*! js-cookie v3.0.5 | MIT */function Co(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 Ao=function t(e,n){function o(t,o,i){if("undefined"!=typeof document){"number"==typeof(i=Co({},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,"",Co({},e,{expires:-1}))},withAttributes:function(e){return t(this.converter,Co({},this.attributes,e))},withConverter:function(e){return t(Co({},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:"/"});const Eo=(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},Uo=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||{}},_o=async t=>{const e=await Uo(t);return(null==e?void 0:e.user)||((null==e?void 0:e.hasOwnProperty("userId"))?e:void 0)},Ro="undefined"!=typeof localStorage,Po=(t,e)=>Ro&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(t,e)),To=t=>Ro&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(t)),Lo=t=>Ro&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(t)),Mo=(...t)=>{console.debug(...t)},qo="undefined"!=typeof window,$o=qo&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://fp.descope.com",Do=(t="",e="")=>({vsid:t,vrid:e}),No=(t=!1)=>{const e=localStorage.getItem("fp");if(!e)return null;const n=JSON.parse(e);return(new Date).getTime()>n.expiry&&!t?null:n.value},Ko=t=>(t.body&&(t.body.fpData=No(!0)||Do()),t),Fo="dls_last_user_login_id",Wo="dls_last_user_display_name",Jo=()=>To(Fo),Ho=()=>To(Wo),zo=t=>async(...e)=>{var n;e[1]=e[1]||{};const[,o={}]=e,i=Jo(),r=Ho();return i&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=i,o.lastAuth.name=r),await t(...e)},Bo=t=>async(...e)=>{const n=await t(...e);return Lo(Fo),Lo(Wo),n};function Vo(){const t=[];return{pub:e=>{t.forEach((t=>t(e)))},sub:e=>{const n=t.push(e)-1;return()=>t.splice(n,1)}}}const Zo="DS",Go="DSR",Xo=(t={},n)=>{var{refreshJwt:o,sessionJwt:i}=t,r=e(t,["refreshJwt","sessionJwt"]);void 0===n&&(n=!1),o&&Po(Go,o),i&&(n?function(t,e,{cookiePath:n,cookieDomain:o,cookieExpiration:i}){if(e){const r=new Date(1e3*i);Ao.set(t,e,{path:n,domain:o,expires:r,sameSite:"Strict",secure:!0})}}(Zo,i,r):Po(Zo,i))};function Yo(){return To(Go)||""}function Qo(){return Ao.get(Zo)||To(Zo)||""}function ti(){Lo(Go),Lo(Zo),Ao.remove(Zo)}const ei=t=>Object.assign(t,{token:t.token||Yo()}),ni=t=>async(...e)=>{const n=await t(...e);return ti(),n};async function oi(t){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=ci(n.publicKey.challenge),n.publicKey.user.id=ci(n.publicKey.user.id),null===(e=n.publicKey.excludeCredentials)||void 0===e||e.forEach((t=>{t.id=ci(t.id)})),n}(t);return n=await navigator.credentials.create(e),JSON.stringify({id:n.id,rawId:di(n.rawId),type:n.type,response:{attestationObject:di(n.response.attestationObject),clientDataJSON:di(n.response.clientDataJSON)}});var n}async function ii(t){const e=ai(t);return li(await navigator.credentials.get(e))}async function ri(t,e){const n=ai(t);return n.signal=e.signal,n.mediation="conditional",li(await navigator.credentials.get(n))}async function si(t=!1){if(!qo)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 ai(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=ci(n.publicKey.challenge),null===(e=n.publicKey.allowCredentials)||void 0===e||e.forEach((t=>{t.id=ci(t.id)})),n}function li(t){return JSON.stringify({id:t.id,rawId:di(t.rawId),type:t.type,response:{authenticatorData:di(t.response.authenticatorData),clientDataJSON:di(t.response.clientDataJSON),signature:di(t.response.signature),userHandle:t.response.userHandle?di(t.response.userHandle):void 0}})}function ci(t){const e=t.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(e),(t=>t.charCodeAt(0))).buffer}function di(t){return btoa(String.fromCharCode.apply(null,new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var ui,hi=(ui=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 oi(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 ii(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 oi(o.data.options);return await t.webauthn.signUp.finish(o.data.transactionId,e)}{const e=await ii(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 oi(o.data.options);return await t.webauthn.update.finish(o.data.transactionId,i)},helpers:{create:oi,get:ii,isSupported:si,conditional:ri}}),(...t)=>{const e=ui(...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}),pi=t=>Object.assign(Object.assign({},t.flow),{start:async(...e)=>{const n=await si(),o=Object.assign(Object.assign({redirectUrl:window.location.href},e[1]),{deviceInfo:{webAuthnSupport:n}});return e[1]=o,t.flow.start(...e)}});const fi=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 o?(qo?i&&(async t=>{try{if(No())return;const e=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),n=Oo({apiKey:t,endpoint:$o}),o=await n,{requestId:i}=await o.get({linkedId:e});(t=>{const e={value:t,expiry:(new Date).getTime()+864e5};localStorage.setItem("fp",JSON.stringify(e))})(Do(e,i))}catch(t){global.FB_DEBUG&&console.error(t)}})(o).catch((()=>null)):console.warn("Fingerprint is a client side only capability and will not work when running in the server"),t(Eo(r,{beforeRequest:Ko}))):t(Object.assign({},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))}}})(),a=t(Eo(i,{afterRequest:async(t,e)=>{const{refreshJwt:n,sessionJwt:o}=await Uo(e);if(401===(null==e?void 0:e.status))Mo("Received 401, canceling all timers"),r();else if(o){const t=((i=(t=>{const e=t.split(".");try{if(3===e.length){const t=JSON.parse(window.atob(e[1]));if(t.exp)return new Date(1e3*t.exp)}}catch(t){}return null})(o))?i.getTime()-(new Date).getTime():0)-2e4;r(),Mo(`Setting refresh timer for ${t}ms`),s((()=>{Mo("Refreshing session"),a.refresh(n)}),t)}var i}}));return mo(a,["logout","logoutAll"],(t=>async(...e)=>{const n=await t(...e);return Mo("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.3.6"},e.baseHeaders)}))),(t=>e=>{const n=Vo(),o=Vo(),i=t(Eo(e,{afterRequest:async(t,e)=>{if(401===(null==e?void 0:e.status))n.pub(null),o.pub(null);else{const t=await _o(e);t&&o.pub(t);const{sessionJwt:i}=await Uo(e);i&&n.pub(i)}}})),r=mo(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=>e=>{const n=t(Eo(e,{afterRequest:async(t,e)=>{var n;const o=await _o(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=>{Po(Fo,t)})(i),(t=>{Po(Wo,t)})(r))}}));let o=mo(n,["flow.start"],zo);return o=mo(o,["logout","logoutAll"],Bo),Object.assign(o,{getLastUserLoginId:Jo,getLastUserDisplayName:Ho})}),(t=>n=>{var{persistTokens:o,sessionTokenViaCookie:i}=n,r=e(n,["persistTokens","sessionTokenViaCookie"]);if(!o||!qo)return o&&console.warn("Storing auth tokens in local storage and cookies are a client side only capabilities and will not be done when running in the server"),t(r);const s=t(Eo(r,{beforeRequest:ei,afterRequest:async(t,e)=>{401===(null==e?void 0:e.status)?ti():Xo(await Uo(e),i)}})),a=mo(s,["logout","logoutAll"],ni);return Object.assign(a,{getRefreshToken:Yo,getSessionToken:Qo})}))(((...t)=>{const e=bo(...t);return Object.assign(Object.assign({},e),{flow:pi(e),webauthn:hi(e)})})),gi=document.createElement("template");var vi,mi,bi,wi,yi,Ii,ki,Oi,xi,ji,Si,Ci,Ai,Ei,Ui,_i,Ri,Pi,Ti,Li,Mi,qi,$i,Di,Ni,Ki,Fi,Wi,Ji,Hi,zi,Bi,Vi,Zi,Gi,Xi,Yi,Qi,tr,er,nr,or,ir,rr,sr,ar,lr,cr,dr;gi.innerHTML='\n\t<style>\n\t\t:host {\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t}\n\t\t\n\t\t#wc-root {\n\t\t\theight: 100%;\n\t\t\ttransition: opacity 300ms ease-in-out;\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';class ur extends HTMLElement{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","theme","debug","telemetryKey","redirect-url","auto-focus","prefer-biometrics"]}constructor(t){super(),vi.add(this),mi.set(this,!1),bi.set(this,new W({deferredRedirect:!1})),wi.set(this,new W),this.nextRequestStatus=new W({isLoading:!1}),yi.set(this,void 0),Ii.set(this,{popstate:o(this,vi,"m",Ci).bind(this),visibilitychange:o(this,vi,"m",Ai).bind(this)}),ki.set(this,void 0),_i.set(this,L((()=>n(this,void 0,void 0,(function*(){const t=A(this.projectId,"config.json");try{const{body:e,headers:n}=yield C(t,"json");return{projectConfig:e,executionContext:{geo:n["x-geo"]}}}catch(t){this.logger.error("Cannot get config file","make sure that your projectId & flowId are correct")}return{}}))))),this.logger={error:(t,e="")=>{console.error(t,e,new Error),o(this,vi,"m",$i).call(this,t,e)},info:(t,e="")=>{console.log(t,e)}},i(this,ki,t,"f"),o(this,vi,"m",Oi).call(this)}get projectId(){return this.getAttribute("project-id")}get flowId(){return this.getAttribute("flow-id")}get baseUrl(){return this.getAttribute("base-url")||void 0}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 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 telemetryKey(){return this.getAttribute("telemetryKey")||void 0}get autoFocus(){var t;const e=null!==(t=this.getAttribute("auto-focus"))&&void 0!==t?t:"true";return"skipFirstScreen"===e?e:"true"===e}get preferBiometrics(){var t;return"true"===(null!==(t=this.getAttribute("prefer-biometrics"))&&void 0!==t?t:"true")}getExecutionContext(){return n(this,void 0,void 0,(function*(){const{executionContext:t}=yield o(this,_i,"f").call(this);return t}))}getFlowConfig(){var t,e;return n(this,void 0,void 0,(function*(){const{projectConfig:n}=yield o(this,_i,"f").call(this),i=(null===(t=null==n?void 0:n.flows)||void 0===t?void 0:t[this.flowId])||{};return null!==(e=i.version)&&void 0!==e||(i.version=0),i}))}connectedCallback(){return n(this,void 0,void 0,(function*(){if(this.shadowRoot.isConnected){if(o(this,vi,"m",xi).call(this))return void o(this,vi,"m",ji).call(this);o(this,vi,"m",Si).call(this),o(this,vi,"m",Pi).call(this),o(this,vi,"m",Ri).call(this),o(this,vi,"m",Di).call(this);const{executionId:t,stepId:e,token:n,code:r,exchangeError:s,redirectAuthCallbackUrl:a,redirectAuthCodeChallenge:l,redirectAuthInitiator:c,oidcIdpStateId:d}=T();window.addEventListener("popstate",o(this,Ii,"f").popstate),window.addEventListener("visibilitychange",o(this,Ii,"f").visibilitychange),o(this,bi,"f").subscribe(o(this,vi,"m",Ui).bind(this)),o(this,wi,"f").subscribe(o(this,vi,"m",qi).bind(this)),o(this,bi,"f").update({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenant,redirectUrl:this.redirectUrl,stepId:e,executionId:t,token:n,code:r,exchangeError:s,telemetryKey:this.telemetryKey,redirectAuthCallbackUrl:a,redirectAuthCodeChallenge:l,redirectAuthInitiator:c,oidcIdpStateId:d}),o(this,wi,"f").update({isDebug:this.debug}),i(this,mi,!0,"f")}}))}disconnectedCallback(){o(this,bi,"f").unsubscribeAll(),o(this,wi,"f").unsubscribeAll(),o(this,vi,"m",Mi).call(this),window.removeEventListener("popstate",o(this,Ii,"f").popstate)}attributeChangedCallback(t,e,n){if(this.shadowRoot.isConnected&&o(this,mi,"f")&&e!==n&&ur.observedAttributes.includes(t)){o(this,vi,"m",Si).call(this);const i=null===e;o(this,bi,"f").update((({stepId:e,executionId:o})=>{let r=e,s=o;return i||(s=null,r=null,R()),{[P(t)]:n,stepId:r,executionId:s}})),o(this,wi,"f").update({isDebug:this.debug})}}}mi=new WeakMap,bi=new WeakMap,wi=new WeakMap,yi=new WeakMap,Ii=new WeakMap,ki=new WeakMap,_i=new WeakMap,vi=new WeakSet,Oi=function(){this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(gi.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#wc-root")},xi=function(){return!this.shadowRoot.host.closest("form")&&_()},ji=function(){const t=this.shadowRoot.host,e=document.createElement("form");t.parentElement.appendChild(e),e.appendChild(t)},Si=function(){const t=["base-url","tenant","theme","debug","telemetryKey","redirect-url","auto-focus","prefer-biometrics"];if(ur.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[P(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')},Ci=function(){const{stepId:t,executionId:e}=U();o(this,bi,"f").update({stepId:t,executionId:e})},Ai=function(){document.hidden||setTimeout((()=>{o(this,bi,"f").update({deferredRedirect:!1})}),300)},Ei=function(t,e,o){const i=o||void 0,r=!!i;this.sdk=fi(Object.assign(Object.assign({persistTokens:!0},ur.sdkConfigOverrides),{projectId:t,baseUrl:e,fpKey:i,fpLoad:r})),["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)}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},Ui=function(t,e,i){return n(this,void 0,void 0,(function*(){const{projectId:e,baseUrl:n,telemetryKey:r}=t;if(i("projectId")||i("baseUrl")||i("telemetryKey")){if(!e)return;o(this,vi,"m",Ei).call(this,e,n,r)}o(this,ki,"f").call(this,t)}))},Ri=function(){var t,e,i,r;return n(this,void 0,void 0,(function*(){const{projectConfig:n}=yield o(this,_i,"f").call(this);null===(r=null===(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.typography)||void 0===i?void 0:i.fontFamilies)||void 0===r||r.forEach((t=>(t=>{if(!t)return;const e=document.createElement("link");e.href=t,e.rel="stylesheet",document.head.appendChild(e)})(t.url)))}))},Pi=function(){o(this,vi,"m",Ti).call(this),o(this,vi,"m",Li).call(this)},Ti=function(){return n(this,void 0,void 0,(function*(){const t=document.createElement("style"),e=A(this.projectId,"theme.css");try{const{body:n}=yield C(e,"text");t.innerText=n}catch(t){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}this.shadowRoot.appendChild(t)}))},Li=function(){this.rootElement.setAttribute("data-theme",this.theme)},Mi=function(){var t;null===(t=o(this,yi,"f"))||void 0===t||t.remove(),i(this,yi,null,"f")},qi=function({isDebug:t}){return n(this,void 0,void 0,(function*(){t?(yield Promise.resolve().then((function(){return gr})),i(this,yi,document.createElement("descope-debugger"),"f"),Object.assign(o(this,yi,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),document.body.appendChild(o(this,yi,"f"))):o(this,vi,"m",Mi).call(this)}))},$i=function(t,e){var n;t&&this.debug&&(null===(n=o(this,yi,"f"))||void 0===n||n.updateData({title:t,description:e}))},Di=function(){this.rootElement.onkeydown=t=>{if("Enter"!==t.key)return;t.preventDefault();const e=this.rootElement.querySelectorAll("button");if(1===e.length)return void e[0].click();const n=Array.from(e).filter((t=>"button"===t.getAttribute("data-type")));1===n.length&&n[0].click()}},ur.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"2.6.2"}};class hr extends ur{static set sdkConfigOverrides(t){ur.sdkConfigOverrides=t}constructor(){const t=new W;super(t.update.bind(t)),Ni.add(this),this.stepState=new W({},{updateOnlyOnChange:!1}),Ki.set(this,void 0),Fi.set(this,null),Wi.set(this,(()=>{clearInterval(o(this,Ki,"f")),i(this,Ki,null,"f")})),Ji.set(this,(t=>{var e,n,i,s,a,l,c,d,u;if(!(null==t?void 0:t.ok)){o(this,Wi,"f").call(this),o(this,Ni,"m",tr).call(this,"error",null==t?void 0:t.error);const r=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 void this.logger.error((null===(s=null==t?void 0:t.error)||void 0===s?void 0:s.errorDescription)||r,(null===(a=null==t?void 0:t.error)||void 0===a?void 0:a.errorMessage)||l)}const h=null===(d=null===(c=null===(l=t.data)||void 0===l?void 0:l.screen)||void 0===c?void 0:c.state)||void 0===d?void 0:d.errorText;h&&this.logger.error(h),(null===(u=t.data)||void 0===u?void 0:u.error)&&this.logger.error(`[${t.data.error.code}]: ${t.data.error.description}`,t.data.error.message);const{status:f,authInfo:g,lastAuth:v}=t.data;if("completed"===f)return function(t){(null==t?void 0:t.authMethod)&&r&&localStorage.setItem(p,JSON.stringify(t))}(v),o(this,Wi,"f").call(this),void o(this,Ni,"m",tr).call(this,"success",g);const{executionId:b,stepId:w,action:y,screen:I,redirect:k,webauthn:O}=t.data;y!==m?this.flowState.update({stepId:w,executionId:b,action:y,redirectTo:null==k?void 0:k.url,screenId:null==I?void 0:I.id,screenState:null==I?void 0:I.state,webauthnTransactionId:null==O?void 0:O.transactionId,webauthnOptions:null==O?void 0:O.options}):this.flowState.update({action:y})})),Hi.set(this,L((()=>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.logger.error("Webauthn start failed",null===(t=null==e?void 0:e.error)||void 0===t?void 0:t.errorMessage),e.data}catch(t){this.logger.error("Webauthn start failed",t.message)}}))))),this.flowState=t}connectedCallback(){const t=Object.create(null,{connectedCallback:{get:()=>super.connectedCallback}});var e,o;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===(o=this.stepState)||void 0===o||o.subscribe(this.onStepChange.bind(this))),yield t.connectedCallback.call(this)}))}disconnectedCallback(){super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll()}onFlowChange(t,e,r){var s,a,l,c,d,u;return n(this,void 0,void 0,(function*(){const{projectId:h,flowId:p,tenant:f,stepId:g,executionId:k,action:O,screenId:x,screenState:j,redirectTo:S,redirectUrl:C,token:U,code:R,exchangeError:P,webauthnTransactionId:T,webauthnOptions:L,redirectAuthCodeChallenge:M,redirectAuthCallbackUrl:$,redirectAuthInitiator:D,oidcIdpStateId:N}=t;let K,F;o(this,Ki,"f")&&o(this,Wi,"f").call(this);const W=this.sdk.getLastUserLoginId(),J=yield this.getFlowConfig(),H=$&&M?{callbackUrl:$,codeChallenge:M}:void 0;if(!k&&(J.conditions?({startScreenId:K,conditionInteractionId:F}=((t,e)=>{const n=null==e?void 0:e.find((({key:e,operator:n})=>{var o;if("ELSE"===e)return!0;const i=null===(o=V[e])||void 0===o?void 0:o[n];return!!(null==i?void 0:i(t))}));return n?{startScreenId:n.met.screenId,conditionInteractionId:n.met.interactionId}:{}})({loginId:W,code:R},J.conditions)):J.condition?({startScreenId:K,conditionInteractionId:F}=((t,e)=>{var n;const o=null===(n=V[null==t?void 0:t.key])||void 0===n?void 0:n[t.operator];if(!o)return{};const i=o(e)?t.met:t.unmet;return{startScreenId:null==i?void 0:i.screenId,conditionInteractionId:null==i?void 0:i.interactionId}})(J.condition,{loginId:W,code:R})):K=J.startScreenId,!q(K,N))){const t=R?{exchangeCode:R,idpInitiated:!0}:void 0,e=yield this.sdk.flow.start(p,Object.assign(Object.assign({tenant:f,redirectAuth:H,oidcIdpStateId:N},C&&{redirectUrl:C}),{lastAuth:Z(W)}),F,"",t,J.version);return o(this,Ji,"f").call(this,e),void("completed"!==(null===(s=null==e?void 0:e.data)||void 0===s?void 0:s.status)&&this.flowState.update({code:void 0}))}if(k&&(r("token")&&U||r("code")&&R||r("exchangeError")&&P)){const t=yield this.sdk.flow.next(k,g,y,{token:U,exchangeCode:R,exchangeError:P},J.version);return o(this,Ji,"f").call(this,t),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(O===v&&(r("redirectTo")||r("deferredRedirect")))return S?"android"===D&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(S):void this.logger.error("Did not get redirect url");if(O===b||O===w){if(!T||!L)return void this.logger.error("Did not get webauthn transaction id or options");let t,e,n=L;if(this.preferBiometrics&&O===b&&_()&&(yield null===(l=null===(a=window.PublicKeyCredential)||void 0===a?void 0:a.isUserVerifyingPlatformAuthenticatorAvailable)||void 0===l?void 0:l.call(a)))try{const t=JSON.parse(n);t.publicKey&&((d=t.publicKey).authenticatorSelection||(d.authenticatorSelection={}),(u=t.publicKey.authenticatorSelection).authenticatorAttachment||(u.authenticatorAttachment="platform"),n=JSON.stringify(t))}catch(t){this.logger.info("Failed to modify webauthn create options")}null===(c=o(this,Fi,"f"))||void 0===c||c.abort(),i(this,Fi,null,"f");try{t=O===b?yield this.sdk.webauthn.helpers.create(n):yield this.sdk.webauthn.helpers.get(n)}catch(t){if("NotAllowedError"!==t.name)return void this.logger.error(t.message);e=!0}const r=yield this.sdk.flow.next(k,g,y,{transactionId:T,response:t,cancelWebauthn:e},J.version);o(this,Ji,"f").call(this,r)}if(O===m&&i(this,Ki,setInterval((()=>n(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(k,g,I,{},J.version);o(this,Ji,"f").call(this,t)}))),2e3),"f"),!x&&!K)return void this.logger.info("Refreshing the page during a flow is not supported yet");const z={direction:E(+g,+e.stepId),screenState:Object.assign(Object.assign({},j),{lastAuth:{loginId:W,name:this.sdk.getLastUserDisplayName()||W}}),htmlUrl:A(h,`${K||x}.html`)},B=Z(W);q(K,N)?z.next=(t,e)=>this.sdk.flow.start(p,Object.assign({tenant:f,redirectAuth:H,oidcIdpStateId:N,lastAuth:B},C&&{redirectUrl:C}),F,t,Object.assign(Object.assign({},e),R&&{exchangeCode:R,idpInitiated:!0}),J.version):(r("projectId")||r("baseUrl")||r("executionId")||r("stepId"))&&(z.next=(...t)=>this.sdk.flow.next(k,g,...t)),this.stepState.update(z)}))}onStepChange(t,e){var i;return n(this,void 0,void 0,(function*(){const{htmlUrl:r,direction:s,next:a,screenState:l}=t,c=document.createElement("template"),{body:d}=yield C(r,"text");c.innerHTML=d;const u=c.content.cloneNode(!0),h=((t,e)=>{var n;const o=Array.from(t.querySelectorAll("script[data-id]")).map((n=>{var o;const i=n.getAttribute("data-id"),r=null===(o=t.getElementById(i))||void 0===o?void 0:o.innerHTML,s=Function(r).bind(n.previousSibling,e);return n.remove(),s}));return null===(n=t.querySelector("scripts"))||void 0===n||n.remove(),o})(u,yield this.getExecutionContext());this.sdk.webauthn.helpers.isSupported()?yield o(this,Ni,"m",Bi).call(this,u,a):u.querySelectorAll(`button[${g}="biometrics"]`).forEach((t=>t.setAttribute("disabled","true"))),H(u,l,this.errorTransformer,this.logger),((t,e)=>{var n;e&&(null===(n=null==t?void 0:t.style)||void 0===n||n.setProperty("--totp-image",`url(data:image/jpg;base64,${e})`))})(u.querySelector("div"),null===(i=null==l?void 0:l.totp)||void 0===i?void 0:i.image);const p=()=>n(this,void 0,void 0,(function*(){try{h.forEach((t=>{t()}))}catch(t){this.logger.error(t.message)}this.rootElement.replaceChildren(u);const t=!e.htmlUrl;((t,e,n)=>{if(!0===e||"skipFirstScreen"===e&&!n){const e=t.querySelector('input:not([aria-hidden="true"])');null==e||e.focus()}})(this.rootElement,this.autoFocus,t),o(this,Ni,"m",Yi).call(this,a),o(this,Ni,"m",tr).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${g}="polling"]`)){const t=yield a(I,{});o(this,Ji,"f").call(this,t)}}));s?o(this,Ni,"m",Qi).call(this,p,s):p()}))}}Ki=new WeakMap,Fi=new WeakMap,Wi=new WeakMap,Ji=new WeakMap,Hi=new WeakMap,Ni=new WeakSet,zi=function(t){const e=t.name;if(!["email"].includes(e)){const n=`user-${e}`;t.name=n,t.addEventListener("input",(()=>{t.name=t.value?e:n}))}},Bi=function(t,e){var r;return n(this,void 0,void 0,(function*(){null===(r=o(this,Fi,"f"))||void 0===r||r.abort();const s=t.querySelector('input[autocomplete="webauthn"]');if(s&&(yield z())){const{options:t,transactionId:r}=(yield o(this,Hi,"f").call(this))||{};t&&r&&(o(this,Ni,"m",zi).call(this,s),i(this,Fi,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(t,o(this,Fi,"f")).then((t=>n(this,void 0,void 0,(function*(){const n=yield e(s.id,{transactionId:r,response:t});o(this,Ji,"f").call(this,n)})))).catch((t=>{"AbortError"!==t.name&&this.logger.error("Conditional login failed",t.message)})))}}))},Vi=function(){return Array.from(this.shadowRoot.querySelectorAll(".descope-input")).every((t=>(t.reportValidity(),t.checkValidity())))},Zi=function(){return Array.from(this.shadowRoot.querySelectorAll(`.descope-input[name]:not([${h}])`)).reduce(((t,e)=>e.name?Object.assign(t,{[e.name]:e["checkbox"===e.type?"checked":"value"]}):t),{})},Gi=function(t){const e=this.nextRequestStatus.subscribe((({isLoading:n})=>{var o,i;n?null===(o=null==t?void 0:t.classList)||void 0===o||o.add("loading"):(this.nextRequestStatus.unsubscribe(e),null===(i=null==t?void 0:t.classList)||void 0===i||i.remove("loading"))}))},Xi=function(t,e){return n(this,void 0,void 0,(function*(){if(t.formNoValidate||o(this,Ni,"m",Vi).call(this)){const i=null==t?void 0:t.getAttribute("id");o(this,Ni,"m",Gi).call(this,t);const r=o(this,Ni,"m",Zi).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=Object.assign(Object.assign(Object.assign({},s),r),{origin:window.location.origin}),l=yield e(i,a);o(this,Ji,"f").call(this,l)}var n}))},Yi=function(t){this.rootElement.querySelectorAll("button").forEach((e=>{e.onclick=()=>{o(this,Ni,"m",Xi).call(this,e,t)}}))},Qi=function(t,e){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),t()}),{once:!0});const n=e===k.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")},tr=function(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))},customElements.define("descope-wc",hr);const pr=document.createElement("template");pr.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 } \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 fr extends HTMLElement{constructor(){super(),er.add(this),nr.set(this,new W({messages:[]})),or.set(this,void 0),ir.set(this,void 0),rr.set(this,void 0),sr.set(this,{resize:o(this,er,"m",dr).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(pr.content.cloneNode(!0)),i(this,or,this.shadowRoot.querySelector(".debugger"),"f"),i(this,ir,o(this,or,"f").querySelector(".content"),"f"),i(this,rr,o(this,or,"f").querySelector(".header"),"f")}updateData(t){o(this,nr,"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]=B(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,or,"f"),o(this,rr,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,sr,"f").resize),(t=o(this,or,"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,or,"f").onresize=o(this,er,"m",cr).bind(this),o(this,nr,"f").subscribe(o(this,er,"m",ar).bind(this))}disconnectedCallback(){o(this,nr,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,sr,"f").resize)}}nr=new WeakMap,or=new WeakMap,ir=new WeakMap,rr=new WeakMap,sr=new WeakMap,er=new WeakSet,ar=function(t){o(this,er,"m",lr).call(this,t),o(this,er,"m",cr).call(this)},lr=function(t){o(this,ir,"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("")},cr=function(){o(this,ir,"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)}))},dr=function(){const[t,e]=B(o(this,or,"f"),Number.parseInt(o(this,or,"f").style.left,10),Number.parseInt(o(this,or,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,or,"f").style.top=`${e}px`,o(this,or,"f").style.left=`${t}px`},customElements.define("descope-debugger",fr);var gr=Object.freeze({__proto__:null,default:fr})}();
1
+ !function(){"use strict";var t=function(){return t=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},t.apply(this,arguments)};function e(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(t);o<i.length;o++)e.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(t,i[o])&&(n[i[o]]=t[i[o]])}return n}function n(t,e,n,i){return new(n||(n=Promise))((function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((i=i.apply(t,e||[])).next())}))}function i(t,e,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(t):i?i.value:e.get(t)}function o(t,e,n,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?o.call(t,n):o?o.value=n:e.set(t,n),n}const r="undefined"!=typeof localStorage,s=r&&localStorage.getItem("base.content.url")||"https://static.descope.com/pages",a="descope-login-flow",l="code",c="ra-challenge",d="ra-callback",u="ra-initiator",h="data-exclude-field",p="dls_last_auth",f="state_id",g="data-type",v="redirect",m="poll",b="webauthnCreate",w="webauthnGet",y="submit",I="polling";var k,x,O;function j(t){return new URLSearchParams(window.location.search).get(t)}function S(t){if(window.history.replaceState&&j(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 C(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}`);return{body:yield n[e||"text"](),headers:Object.fromEntries(n.headers.entries())}}))}!function(t){t.backward="backward",t.forward="forward"}(k||(k={}));function A(t,e){const n=new URL(s);return n.pathname=((...t)=>t.join("/").replace(/\/+/g,"/"))(n.pathname,t,"v2-alpha",e),n.toString()}function E(t,e){if(!Number.isNaN(t)&&!Number.isNaN(e))return t>e?k.forward:t<e?k.backward:void 0}const U=()=>{const[t="",e=""]=(j(a)||"").split("_");return{executionId:t,stepId:e}};function _(){return/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)}function R(){S(a)}const P=t=>t.replace(/-./g,(t=>t[1].toUpperCase())),T=()=>{const{executionId:t,stepId:e}=U();(t||e)&&R();const n=j("t")||void 0;n&&S("t");const i=j(l)||void 0;i&&S(l);const o=j("err")||void 0;o&&S("err");const{redirectAuthCodeChallenge:r,redirectAuthCallbackUrl:s,redirectAuthInitiator:a}={redirectAuthCodeChallenge:j(c),redirectAuthCallbackUrl:j(d),redirectAuthInitiator:j(u)};(r||s||a)&&(S(c),S(d),S(u));const h=j(f);return h&&S(f),{executionId:t,stepId:e,token:n,code:i,exchangeError:o,redirectAuthCodeChallenge:r,redirectAuthCallbackUrl:s,redirectAuthInitiator:a,oidcIdpStateId:h}},L=t=>{let e,n;return(...i)=>{return e&&(r=i,(o=e).length===r.length&&o.every(((t,e)=>t===r[e])))||(e=i,n=t(...i)),n;var o,r}},q=null===(O=null===(x=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===x?void 0:x.brands)||void 0===O?void 0:O.find((({brand:t,version:e})=>"Chromium"===t&&parseFloat(e))),M=(t,e)=>t&&!e;var $,D,N,K;function F(t,e){const n=Object.getOwnPropertyNames(t),i=Object.getOwnPropertyNames(e);if(n.length!==i.length)return!1;for(let i=0;i<n.length;i+=1){const o=n[i],r=t[o],s=e[o];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!F(r,s))return!1}else if(r!==s)return!1}return!0}class W{constructor(t={},{updateOnlyOnChange:e=!0}={}){$.set(this,void 0),D.set(this,{}),N.set(this,0),K.set(this,!1),this.update=t=>{const e="function"==typeof t?t(i(this,$,"f")):t,n=Object.assign(Object.assign({},i(this,$,"f")),e);if(!i(this,K,"f")||!F(i(this,$,"f"),n)){const t=i(this,$,"f");o(this,$,n,"f"),Object.freeze(i(this,$,"f")),setTimeout((()=>{Object.values(i(this,D,"f")).forEach((e=>e(n,t,((t,e)=>n=>t[n]!==e[n])(n,t))))}),0)}},o(this,$,t,"f"),o(this,K,e,"f")}get current(){return Object.assign({},i(this,$,"f"))}subscribe(t){return o(this,N,i(this,N,"f")+1,"f"),i(this,D,"f")[i(this,N,"f")]=t,i(this,N,"f").toString()}unsubscribe(t){const e=!!i(this,D,"f")[t];return e&&delete i(this,D,"f")[t],e}unsubscribeAll(){return o(this,D,{},"f"),!0}}$=new WeakMap,D=new WeakMap,N=new WeakMap,K=new WeakMap;const J=(t,e)=>{Object.entries(e||{}).forEach((([e,n])=>{Array.from(t.querySelectorAll(`.descope-input[name="${e}"]:not([${h}])`)).forEach((t=>{t.value=n}))}))},H=(t,e,n,i)=>{var o;let r=null==e?void 0:e.errorText;try{r=(null==n?void 0:n({text:null==e?void 0:e.errorText,type:null==e?void 0:e.errorType}))||(null==e?void 0:e.errorText)}catch(t){i.error("Error transforming error message",t.message)}((t,e,n="")=>{t.querySelectorAll(`[${g}="${e}"]`).forEach((t=>{t.textContent=n,t.classList[n?"remove":"add"]("hide")}))})(t,"error-message",r),J(t,null==e?void 0:e.inputs),J(t,null==e?void 0:e.form),((t,e)=>{t.querySelectorAll(`[${g}="totp-link"]`).forEach((t=>{t.href=e}))})(t,null===(o=null==e?void 0:e.totp)||void 0===o?void 0:o.provisionUrl),((t,e)=>{t.querySelectorAll(".descope-text,.descope-link").forEach((t=>{t.textContent=((t,e)=>t.replace(/{{(.+?)}}/g,((t,n)=>{return i=e,n.split(".").reduce(((t,e)=>(null==t?void 0:t[e])||""),i);var i})))(t.textContent,e)}))})(t,e)},z=L((()=>n(void 0,void 0,void 0,(function*(){var t,e,n,i;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return console.warn("webauthn","Conditional UI is not supported"),!1;try{const o=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)))),r=108;return yield Promise.race([o,(n=100,new Promise(((t,e)=>{const o=setTimeout((()=>{e(new Error(`Promise timed out after ${n} ms`))}),n);null==i||i((e=>{clearTimeout(o),t(e)}),(t=>{clearTimeout(o),e(t)}))}))).catch((()=>q()>=r))])}catch(t){return console.warn("webauthn","Conditional login check failed",t),!1}})))),B=(t,e,n,i={})=>{var o,r,s,a;return[Math.min(Math.max(e,("all"===i.left?t.offsetWidth:null!==(o=i.left)&&void 0!==o?o:0)-t.offsetWidth),window.innerWidth-("all"===i.right?t.offsetWidth:null!==(r=i.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===i.top?t.offsetHeight:null!==(s=i.top)&&void 0!==s?s:0)-t.offsetHeight),window.innerHeight-("all"===i.bottom?t.offsetHeight:null!==(a=i.bottom)&&void 0!==a?a:0))]},V={"lastAuth.loginId":{"not-empty":t=>!!t.loginId,empty:t=>!t.loginId},idpInitiated:{"is-true":t=>!!t.code,"is-false":t=>!t.code}};function Z(t){const e={};if(t)try{Object.assign(e,JSON.parse(localStorage.getItem(p)))}catch(t){}return e}function G(t){this.message=t}G.prototype=new Error,G.prototype.name="InvalidCharacterError";var X="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new G("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,i,o=0,r=0,s="";i=e.charAt(r++);~i&&(n=o%4?64*n+i:i,o++%4)?s+=String.fromCharCode(255&n>>(-2*o&6)):0)i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(i);return s};function Y(t){this.message=t}function Q(t,e){if("string"!=typeof t)throw new Y("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(X(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 X(e)}}(t.split(".")[n]))}catch(t){throw new Y("Invalid token specified: "+t.message)}}Y.prototype=new Error,Y.prototype.name="InvalidTokenError";var tt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},et="__lodash_hash_undefined__",nt=1/0,it="[object Function]",ot="[object GeneratorFunction]",rt="[object Symbol]",st=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,at=/^\w*$/,lt=/^\./,ct=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,dt=/\\(\\)?/g,ut=/^\[object .+?Constructor\]$/,ht="object"==typeof tt&&tt&&tt.Object===Object&&tt,pt="object"==typeof self&&self&&self.Object===Object&&self,ft=ht||pt||Function("return this")();var gt,vt=Array.prototype,mt=Function.prototype,bt=Object.prototype,wt=ft["__core-js_shared__"],yt=(gt=/[^.]+$/.exec(wt&&wt.keys&&wt.keys.IE_PROTO||""))?"Symbol(src)_1."+gt:"",It=mt.toString,kt=bt.hasOwnProperty,xt=bt.toString,Ot=RegExp("^"+It.call(kt).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),jt=ft.Symbol,St=vt.splice,Ct=$t(ft,"Map"),At=$t(Object,"create"),Et=jt?jt.prototype:void 0,Ut=Et?Et.toString:void 0;function _t(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}function Rt(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}function Pt(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}function Tt(t,e){for(var n,i,o=t.length;o--;)if((n=t[o][0])===(i=e)||n!=n&&i!=i)return o;return-1}function Lt(t,e){var n;e=function(t,e){if(Ft(t))return!1;var n=typeof t;if("number"==n||"symbol"==n||"boolean"==n||null==t||Jt(t))return!0;return at.test(t)||!st.test(t)||null!=e&&t in Object(e)}(e,t)?[e]:Ft(n=e)?n:Dt(n);for(var i=0,o=e.length;null!=t&&i<o;)t=t[Nt(e[i++])];return i&&i==o?t:void 0}function qt(t){if(!Wt(t)||(e=t,yt&&yt in e))return!1;var e,n=function(t){var e=Wt(t)?xt.call(t):"";return e==it||e==ot}(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t)?Ot:ut;return n.test(function(t){if(null!=t){try{return It.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}function Mt(t,e){var n,i,o=t.__data__;return("string"==(i=typeof(n=e))||"number"==i||"symbol"==i||"boolean"==i?"__proto__"!==n:null===n)?o["string"==typeof e?"string":"hash"]:o.map}function $t(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return qt(n)?n:void 0}_t.prototype.clear=function(){this.__data__=At?At(null):{}},_t.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},_t.prototype.get=function(t){var e=this.__data__;if(At){var n=e[t];return n===et?void 0:n}return kt.call(e,t)?e[t]:void 0},_t.prototype.has=function(t){var e=this.__data__;return At?void 0!==e[t]:kt.call(e,t)},_t.prototype.set=function(t,e){return this.__data__[t]=At&&void 0===e?et:e,this},Rt.prototype.clear=function(){this.__data__=[]},Rt.prototype.delete=function(t){var e=this.__data__,n=Tt(e,t);return!(n<0)&&(n==e.length-1?e.pop():St.call(e,n,1),!0)},Rt.prototype.get=function(t){var e=this.__data__,n=Tt(e,t);return n<0?void 0:e[n][1]},Rt.prototype.has=function(t){return Tt(this.__data__,t)>-1},Rt.prototype.set=function(t,e){var n=this.__data__,i=Tt(n,t);return i<0?n.push([t,e]):n[i][1]=e,this},Pt.prototype.clear=function(){this.__data__={hash:new _t,map:new(Ct||Rt),string:new _t}},Pt.prototype.delete=function(t){return Mt(this,t).delete(t)},Pt.prototype.get=function(t){return Mt(this,t).get(t)},Pt.prototype.has=function(t){return Mt(this,t).has(t)},Pt.prototype.set=function(t,e){return Mt(this,t).set(t,e),this};var Dt=Kt((function(t){var e;t=null==(e=t)?"":function(t){if("string"==typeof t)return t;if(Jt(t))return Ut?Ut.call(t):"";var e=t+"";return"0"==e&&1/t==-nt?"-0":e}(e);var n=[];return lt.test(t)&&n.push(""),t.replace(ct,(function(t,e,i,o){n.push(i?o.replace(dt,"$1"):e||t)})),n}));function Nt(t){if("string"==typeof t||Jt(t))return t;var e=t+"";return"0"==e&&1/t==-nt?"-0":e}function Kt(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError("Expected a function");var n=function(){var i=arguments,o=e?e.apply(this,i):i[0],r=n.cache;if(r.has(o))return r.get(o);var s=t.apply(this,i);return n.cache=r.set(o,s),s};return n.cache=new(Kt.Cache||Pt),n}Kt.Cache=Pt;var Ft=Array.isArray;function Wt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Jt(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&xt.call(t)==rt}var Ht=function(t,e,n){var i=null==t?void 0:Lt(t,e);return void 0===i?n:i},zt="/v1/auth/accesskey/exchange",Bt="/v1/auth/otp/verify",Vt="/v1/auth/otp/signin",Zt="/v1/auth/otp/signup",Gt={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},Xt="/v1/auth/otp/signup-in",Yt="/v1/auth/magiclink/verify",Qt="/v1/auth/magiclink/signin",te="/v1/auth/magiclink/signup",ee={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},ne="/v1/auth/magiclink/signup-in",ie="/v1/auth/enchantedlink/verify",oe="/v1/auth/enchantedlink/signin",re="/v1/auth/enchantedlink/signup",se="/v1/auth/enchantedlink/pending-session",ae={email:"/v1/auth/enchantedlink/update/email"},le="/v1/auth/enchantedlink/signup-in",ce="/v1/auth/oauth/authorize",de="/v1/auth/oauth/exchange",ue="/v1/auth/saml/authorize",he="/v1/auth/saml/exchange",pe="/v1/auth/totp/verify",fe="/v1/auth/totp/signup",ge="/v1/auth/totp/update",ve={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},me={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},be={start:"/v1/auth/webauthn/signup-in/start"},we={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},ye="/v1/auth/password/signup",Ie="/v1/auth/password/signin",ke="/v1/auth/password/reset",xe="/v1/auth/password/update",Oe="/v1/auth/password/replace",je="/v1/auth/password/policy",Se="/v1/auth/refresh",Ce="/v1/auth/logout",Ae="/v1/auth/logoutall",Ee="/v1/auth/me",Ue="/v1/flow/start",_e="/v1/flow/next";const Re=6e5,Pe=()=>{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 Te;!function(t){t.get="GET",t.delete="DELETE",t.post="POST",t.put="PUT"}(Te||(Te={}));const Le=(...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,i])=>(t[n]=i,t)),t),t}),{})),qe=t=>void 0===t?void 0:JSON.stringify(t),Me=(t,e="")=>{let n=t;return e&&(n=n+":"+e),{Authorization:`Bearer ${n}`}},$e=({baseUrl:t,projectId:e,baseConfig:n,logger:i,hooks:o,cookiePolicy:r,fetch:s})=>{const a=((t,e)=>{const n=(t=>async(...e)=>{const n=await t(...e),i=await n.text();return n.text=()=>Promise.resolve(i),n.json=()=>Promise.resolve(JSON.parse(i)),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=>Pe().title("Request").url(t[0]).method(t[1].method).headers(t[1].headers).body(t[1].body).build())(e));const i=await n(...e);return t[i.ok?"log":"error"](await(async t=>{const e=await t.text();return Pe().title("Response").url(t.url.toString()).status(`${t.status} ${t.statusText}`).headers(t.headers).body(e).build()})(i)),i}:n})(i,s),l=async i=>{const s=(null==o?void 0:o.beforeRequest)?o.beforeRequest(i):i,{path:l,body:c,headers:d,queryParams:u,method:h,token:p}=s,f=await a((({path:t,baseUrl:e,queryParams:n})=>{const i=new URL(t,e);return n&&(i.search=new URLSearchParams(n).toString()),i})({path:l,baseUrl:t,queryParams:u}),{headers:Le(Me(e,p),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"1.4.6"},(null==n?void 0:n.baseHeaders)||{},d),method:h,body:qe(c),credentials:r||"include"});return(null==o?void 0:o.afterRequest)&&await o.afterRequest(i,null==f?void 0:f.clone()),f};return{get:(t,{headers:e,queryParams:n,token:i}={})=>l({path:t,headers:e,queryParams:n,body:void 0,method:Te.get,token:i}),post:(t,e,{headers:n,queryParams:i,token:o}={})=>l({path:t,headers:n,queryParams:i,body:e,method:Te.post,token:o}),put:(t,e,{headers:n,queryParams:i,token:o}={})=>l({path:t,headers:n,queryParams:i,body:e,method:Te.put,token:o}),delete:(t,{headers:e,queryParams:n,token:i}={})=>l({path:t,headers:e,queryParams:n,body:void 0,method:Te.delete,token:i}),hooks:o}};var De=429;function Ne(t,e,n){var i;let o=Ke(t);e&&(o=null===(i=null==o?void 0:o.tenants)||void 0===i?void 0:i[e]);const r=null==o?void 0:o[n];return Array.isArray(r)?r:[]}function Ke(t){if("string"!=typeof t||!t)throw new Error("Invalid token provided");return Q(t)}function Fe(t){const{exp:e}=Ke(t);return(new Date).getTime()/1e3>e}function We(t){let e=Ke(t);const n=Object.keys(null==e?void 0:e.tenants);return Array.isArray(n)?n:[]}function Je(t,e){return Ne(t,e,"permissions")}function He(t,e){return Ne(t,e,"roles")}const ze=(...t)=>t.join("/").replace(/\/{2,}/g,"/");async function Be(t,e){var n;const i=await t,o={code:i.status,ok:i.ok,response:i},r=await i.clone().json();return i.ok?o.data=e?e(r):r:(o.error=r,i.status===De&&Object.assign(o.error,{retryAfter:Number.parseInt(null===(n=i.headers)||void 0===n?void 0:n.get("retry-after"))||0})),o}const Ve=(t,e)=>(n=e)=>e=>!t(e)&&n.replace("{val}",e),Ze=(...t)=>({validate:e=>(t.forEach((t=>{const n=t(e);if(n)throw new Error(n)})),!0)}),Ge=t=>e=>t.test(e),Xe=Ge(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Ye=Ge(/^\+[1-9]{1}[0-9]{3,14}$/),Qe=Ve(Xe,'"{val}" is not a valid email'),tn=Ve(Ye,'"{val}" is not a valid phone number'),en=Ve((1,t=>t.length>=1),"Minimum length is 1");const nn=Ve((t=>"string"==typeof t),"Input is not a string"),on=Ve((t=>void 0===t),"Input is defined"),rn=(sn=[nn(),on()],"Input is not a string or undefined",(t="Input is not a string or undefined")=>e=>{const n=sn.filter((t=>t(e)));return!(n.length<sn.length)&&(t?t.replace("{val}",e):n.join(" OR "))});var sn;const an=(...t)=>e=>(...n)=>(t.forEach(((t,e)=>Ze(...t).validate(n[e]))),e(...n)),ln=t=>[nn(`"${t}" must be a string`),en(`"${t}" must not be empty`)],cn=t=>[nn(`"${t}" must be a string`),Qe()],dn=t=>[nn(`"${t}" must be a string`),tn()],un=an(ln("accessKey")),hn=t=>({exchange:un((e=>Be(t.post(zt,{},{token:e}))))});var pn,fn;!function(t){t.sms="sms",t.whatsapp="whatsapp"}(pn||(pn={})),function(t){t.email="email"}(fn||(fn={}));const gn=Object.assign(Object.assign({},pn),fn);var vn;!function(t){t.waiting="waiting",t.running="running",t.completed="completed",t.failed="failed"}(vn||(vn={}));const mn=ln("loginId"),bn=an(ln("token")),wn=an(mn),yn=an(ln("pendingRef")),In=an(mn,cn("email")),kn=t=>({verify:bn((e=>Be(t.post(ie,{token:e})))),signIn:wn(((e,n,i,o)=>Be(t.post(ze(oe,gn.email),{loginId:e,URI:n,loginOptions:i},{token:o})))),signUpOrIn:wn(((e,n)=>Be(t.post(ze(le,gn.email),{loginId:e,URI:n})))),signUp:wn(((e,n,i)=>Be(t.post(ze(re,gn.email),{loginId:e,URI:n,user:i})))),waitForSession:yn(((e,n)=>new Promise((i=>{const{pollingIntervalMs:o,timeoutMs:r}=(({pollingIntervalMs:t=1e3,timeoutMs:e=6e5}={})=>({pollingIntervalMs:Math.max(t||1e3,1e3),timeoutMs:Math.min(e||Re,Re)}))(n);let s;const a=setInterval((async()=>{const n=await t.post(se,{pendingRef:e});n.ok&&(clearInterval(a),s&&clearTimeout(s),i(Be(Promise.resolve(n))))}),o);s=setTimeout((()=>{i({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:In(((e,n,i,o,r)=>Be(t.post(ae.email,Object.assign({loginId:e,email:n,URI:i},r),{token:o}))))}}),xn=an(ln("flowId")),On=an(ln("executionId"),ln("stepId"),ln("interactionId")),jn=t=>({start:xn(((e,n,i,o,r,s)=>Be(t.post(Ue,{flowId:e,options:n,conditionInteractionId:i,interactionId:o,input:r,version:s})))),next:On(((e,n,i,o,r)=>Be(t.post(_e,{executionId:e,stepId:n,interactionId:i,input:o,version:r}))))}),Sn=ln("loginId"),Cn=an(ln("token")),An=an(Sn),En=an(Sn,dn("phone")),Un=an(Sn,cn("email")),_n=t=>({verify:Cn((e=>Be(t.post(Yt,{token:e})))),signIn:Object.keys(gn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:An(((e,i,o,r)=>Be(t.post(ze(Qt,n),{loginId:e,URI:i,loginOptions:o},{token:r}))))})),{}),signUp:Object.keys(gn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:An(((e,i,o)=>Be(t.post(ze(te,n),{loginId:e,URI:i,user:o}))))})),{}),signUpOrIn:Object.keys(gn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:An(((e,i)=>Be(t.post(ze(ne,n),{loginId:e,URI:i}))))})),{}),update:{email:Un(((e,n,i,o,r)=>Be(t.post(ee.email,Object.assign({loginId:e,email:n,URI:i},r),{token:o})))),phone:Object.keys(pn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:En(((e,i,o,r,s)=>Be(t.post(ze(ee.phone,n),Object.assign({loginId:e,phone:i,URI:o},s),{token:r}))))})),{})}});var Rn;!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"}(Rn||(Rn={}));const Pn=an(ln("code")),Tn=t=>({start:Object.keys(Rn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:(e,i,o)=>Be(t.post(ce,i||{},{queryParams:Object.assign({provider:n},e&&{redirectURL:e}),token:o}))})),{}),exchange:Pn((e=>Be(t.post(de,{code:e}))))}),Ln=ln("loginId"),qn=an(Ln,ln("code")),Mn=an(Ln),$n=an(Ln,dn("phone")),Dn=an(Ln,cn("email")),Nn=t=>({verify:Object.keys(gn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:qn(((e,i)=>Be(t.post(ze(Bt,n),{code:i,loginId:e}))))})),{}),signIn:Object.keys(gn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Mn(((e,i,o)=>Be(t.post(ze(Vt,n),{loginId:e,loginOptions:i},{token:o}))))})),{}),signUp:Object.keys(gn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Mn(((e,i)=>Be(t.post(ze(Zt,n),{loginId:e,user:i}))))})),{}),signUpOrIn:Object.keys(gn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Mn((e=>Be(t.post(ze(Xt,n),{loginId:e}))))})),{}),update:{email:Dn(((e,n,i,o)=>Be(t.post(Gt.email,Object.assign({loginId:e,email:n},o),{token:i})))),phone:Object.keys(pn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:$n(((e,i,o,r)=>Be(t.post(ze(Gt.phone,n),Object.assign({loginId:e,phone:i},r),{token:o}))))})),{})}}),Kn=an(ln("tenant")),Fn=an(ln("code")),Wn=t=>({start:Kn(((e,n,i,o)=>Be(t.post(ue,i||{},{queryParams:{tenant:e,redirectURL:n},token:o})))),exchange:Fn((e=>Be(t.post(he,{code:e}))))}),Jn=ln("loginId"),Hn=an(Jn,ln("code")),zn=an(Jn),Bn=an(Jn),Vn=t=>({signUp:zn(((e,n)=>Be(t.post(fe,{loginId:e,user:n})))),verify:Hn(((e,n,i,o)=>Be(t.post(pe,{loginId:e,code:n,loginOptions:i},{token:o})))),update:Bn(((e,n)=>Be(t.post(ge,{loginId:e},{token:n}))))}),Zn=ln("loginId"),Gn=ln("newPassword"),Xn=an(Zn,ln("password")),Yn=an(Zn),Qn=an(Zn,Gn),ti=an(Zn,ln("oldPassword"),Gn),ei=t=>({signUp:Xn(((e,n,i)=>Be(t.post(ye,{loginId:e,password:n,user:i})))),signIn:Xn(((e,n)=>Be(t.post(Ie,{loginId:e,password:n})))),sendReset:Yn(((e,n)=>Be(t.post(ke,{loginId:e,redirectUrl:n})))),update:Qn(((e,n,i)=>Be(t.post(xe,{loginId:e,newPassword:n},{token:i})))),replace:ti(((e,n,i)=>Be(t.post(Oe,{loginId:e,oldPassword:n,newPassword:i})))),policy:()=>Be(t.get(je))}),ni=[nn('"loginId" must be a string')],ii=ln("loginId"),oi=ln("origin"),ri=an(ii,oi,ln("name")),si=an(ii,oi),ai=an(ni,oi),li=an(ii,oi,ln("token")),ci=an(ln("transactionId"),ln("response")),di=t=>({signUp:{start:ri(((e,n,i)=>Be(t.post(ve.start,{user:{loginId:e,name:i},origin:n})))),finish:ci(((e,n)=>Be(t.post(ve.finish,{transactionId:e,response:n}))))},signIn:{start:ai(((e,n,i,o)=>Be(t.post(me.start,{loginId:e,origin:n,loginOptions:i},{token:o})))),finish:ci(((e,n)=>Be(t.post(me.finish,{transactionId:e,response:n}))))},signUpOrIn:{start:si(((e,n)=>Be(t.post(be.start,{loginId:e,origin:n}))))},update:{start:li(((e,n,i)=>Be(t.post(we.start,{loginId:e,origin:n},{token:i})))),finish:ci(((e,n)=>Be(t.post(we.finish,{transactionId:e,response:n}))))}}),ui=an(ln("token")),hi=an([rn('"token" must be string or undefined')]);var pi,fi=an([("projectId",pi=ln("projectId"),Ve(((t,e)=>n=>Ze(...e).validate(Ht(n,t)))("projectId",pi))())])((t=>{var e,n;const i=[].concat((null===(e=t.hooks)||void 0===e?void 0:e.beforeRequest)||[]),o=[].concat((null===(n=t.hooks)||void 0===n?void 0:n.afterRequest)||[]);return(({projectId:t,logger:e,baseUrl:n,hooks:i,cookiePolicy:o,baseHeaders:r={},fetch:s})=>{return a=$e({baseUrl:n||"https://api.descope.com",projectId:t,logger:e,hooks:i,cookiePolicy:o,baseConfig:{baseHeaders:r},fetch:s}),{accessKey:hn(a),otp:Nn(a),magicLink:_n(a),enchantedLink:kn(a),oauth:Tn(a),saml:Wn(a),totp:Vn(a),webauthn:di(a),password:ei(a),flow:jn(a),refresh:hi((t=>Be(a.post(Se,{},{token:t})))),logout:hi((t=>Be(a.post(Ce,{},{token:t})))),logoutAll:hi((t=>Be(a.post(Ae,{},{token:t})))),me:hi((t=>Be(a.get(Ee,{token:t})))),isJwtExpired:ui(Fe),getTenants:ui(We),getJwtPermissions:ui(Je),getJwtRoles:ui(He),httpClient:a};var a})(Object.assign(Object.assign({},t),{hooks:{beforeRequest:t=>null==i?void 0:i.reduce(((t,e)=>e(t)),t),afterRequest:async(e,n)=>{(await Promise.allSettled(null==o?void 0:o.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))}))}}}))}));const gi=(t,e,n)=>(e.forEach((e=>{const i=e.split(".");let o=i.shift(),r=t;for(;i.length>0;){if(r=r[o],!o||!r)throw Error(`Invalid path "${e}", "${o}" is missing or has no value`);o=i.shift()}if("function"!=typeof r[o])throw Error(`"${e}" is not a function`);const s=r[o];r[o]=n(s)})),t);var vi=Object.assign(fi,{DeliveryMethods:gn});var mi="Blocked by CSP",bi="9319";function wi(t,e){var n=[];return function(t,e){var n,i,o=(i=function(t,e,n){if(n||2===arguments.length)for(var i,o=0,r=e.length;o<r;o++)!i&&o in e||(i||(i=Array.prototype.slice.call(e,0,o)),i[o]=e[o]);return t.concat(i||Array.prototype.slice.call(e))}([],t,!0),{current:function(){return i[0]},postpone:function(){var t=i.shift();void 0!==t&&i.push(t)},exclude:function(){i.shift()}}),r=(100,3e3,n=0,function(){return Math.random()*Math.min(3e3,100*Math.pow(2,n++))}),s=o.current();if(void 0===s)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var a=function(t,n){return e(t).catch((function(t){if(n+1>=5)throw t;!function(t){if(!(t instanceof Error))return!1;var e=t.message;return e===mi||e===bi}(t)?o.postpone():o.exclude();var e,i=o.current();if(void 0===i)throw t;return(e=r(),new Promise((function(t){return setTimeout(t,e)}))).then((function(){return a(i,n+1)}))}))};return a(s,0)}(t,(function(t){var i=new Date,o=function(){return n.push({url:t,startedAt:i,finishedAt:new Date})},r=e(t);return r.then(o,o),r})).then((function(t){return[t,{attempts:n}]}))}var yi="Failed to load the JS script of the agent";function Ii(n){var i;n.scriptUrlPattern;var o=n.token,r=n.apiKey,s=void 0===r?o:r,a=e(n,["scriptUrlPattern","token","apiKey"]),l=null!==(i=function(t,e){return function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(t,e)?t[e]:void 0}(n,"scriptUrlPattern"))&&void 0!==i?i:"https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js";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.8.3"):t}))}(String(t),e)}))}(l,s);return wi(t,ki).catch(Oi)})).then((function(e){var n=e[0],i=e[1];return n.load(t(t({},a),{ldi:i}))}))}function ki(t){return function(t,e,n,i){var o,r=document,s="securitypolicyviolation",a=function(e){var n=new URL(t,location.href),i=e.blockedURI;i!==n.href&&i!==n.protocol.slice(0,-1)&&i!==n.origin||(o=e,l())};r.addEventListener(s,a);var l=function(){return r.removeEventListener(s,a)};return Promise.resolve().then(e).then((function(t){return l(),t}),(function(t){return new Promise((function(t){return setTimeout(t)})).then((function(){if(l(),o)return function(){throw new Error(mi)}();throw t}))}))}(t,(function(){return function(t){return new Promise((function(e,n){var i=document.createElement("script"),o=function(){var t;return null===(t=i.parentNode)||void 0===t?void 0:t.removeChild(i)},r=document.head||document.getElementsByTagName("head")[0];i.onload=function(){o(),e()},i.onerror=function(){o(),n(new Error(yi))},i.async=!0,i.src=t,r.appendChild(i)}))}(t)})).then(xi)}function xi(){var t=window,e="__fpjs_p_l_b",n=t[e];if(function(t,e){var n,i=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,t,e);(null==i?void 0:i.configurable)?delete t[e]:i&&!i.writable||(t[e]=void 0)}(t,e),"function"!=typeof(null==n?void 0:n.load))throw new Error(bi);return n}function Oi(t){throw t instanceof Error&&t.message===bi?new Error(yi):t}
2
+ /*! js-cookie v3.0.5 | MIT */function ji(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)t[i]=n[i]}return t}var Si=function t(e,n){function i(t,i,o){if("undefined"!=typeof document){"number"==typeof(o=ji({},n,o)).expires&&(o.expires=new Date(Date.now()+864e5*o.expires)),o.expires&&(o.expires=o.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var r="";for(var s in o)o[s]&&(r+="; "+s,!0!==o[s]&&(r+="="+o[s].split(";")[0]));return document.cookie=t+"="+e.write(i,t)+r}}return Object.create({set:i,get:function(t){if("undefined"!=typeof document&&(!arguments.length||t)){for(var n=document.cookie?document.cookie.split("; "):[],i={},o=0;o<n.length;o++){var r=n[o].split("="),s=r.slice(1).join("=");try{var a=decodeURIComponent(r[0]);if(i[a]=e.read(s,a),t===a)break}catch(t){}}return t?i[t]:i}},remove:function(t,e){i(t,"",ji({},e,{expires:-1}))},withAttributes:function(e){return t(this.converter,ji({},this.attributes,e))},withConverter:function(e){return t(ji({},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:"/"});const Ci=(t,e)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,i)=>{var o;return n[i]=[].concat((null===(o=t.hooks)||void 0===o?void 0:o[i])||[]).concat((null==e?void 0:e[i])||[]),n}),null!==(n=t.hooks)&&void 0!==n?n:t.hooks={}),t},Ai=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||{}},Ei=async t=>{const e=await Ai(t);return(null==e?void 0:e.user)||((null==e?void 0:e.hasOwnProperty("userId"))?e:void 0)},Ui="undefined"!=typeof localStorage,_i=(t,e)=>Ui&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(t,e)),Ri=t=>Ui&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(t)),Pi=t=>Ui&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(t)),Ti=(...t)=>{console.debug(...t)},Li="undefined"!=typeof window,qi=Li&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://fp.descope.com",Mi=(t="",e="")=>({vsid:t,vrid:e}),$i=(t=!1)=>{const e=localStorage.getItem("fp");if(!e)return null;const n=JSON.parse(e);return(new Date).getTime()>n.expiry&&!t?null:n.value},Di=t=>(t.body&&(t.body.fpData=$i(!0)||Mi()),t),Ni="dls_last_user_login_id",Ki="dls_last_user_display_name",Fi=()=>Ri(Ni),Wi=()=>Ri(Ki),Ji=t=>async(...e)=>{var n;e[1]=e[1]||{};const[,i={}]=e,o=Fi(),r=Wi();return o&&(null!==(n=i.lastAuth)&&void 0!==n||(i.lastAuth={}),i.lastAuth.loginId=o,i.lastAuth.name=r),await t(...e)},Hi=t=>async(...e)=>{const n=await t(...e);return Pi(Ni),Pi(Ki),n};function zi(){const t=[];return{pub:e=>{t.forEach((t=>t(e)))},sub:e=>{const n=t.push(e)-1;return()=>t.splice(n,1)}}}const Bi="DS",Vi="DSR",Zi=(t={},n)=>{var{refreshJwt:i,sessionJwt:o}=t,r=e(t,["refreshJwt","sessionJwt"]);void 0===n&&(n=!1),i&&_i(Vi,i),o&&(n?function(t,e,{cookiePath:n,cookieDomain:i,cookieExpiration:o}){if(e){const r=new Date(1e3*o);Si.set(t,e,{path:n,domain:i,expires:r,sameSite:"Strict",secure:!0})}}(Bi,o,r):_i(Bi,o))};function Gi(){return Ri(Vi)||""}function Xi(){return Si.get(Bi)||Ri(Bi)||""}function Yi(){Pi(Vi),Pi(Bi),Si.remove(Bi)}const Qi=t=>Object.assign(t,{token:t.token||Gi()}),to=t=>async(...e)=>{const n=await t(...e);return Yi(),n};async function eo(t){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=ao(n.publicKey.challenge),n.publicKey.user.id=ao(n.publicKey.user.id),null===(e=n.publicKey.excludeCredentials)||void 0===e||e.forEach((t=>{t.id=ao(t.id)})),n}(t);return n=await navigator.credentials.create(e),JSON.stringify({id:n.id,rawId:lo(n.rawId),type:n.type,response:{attestationObject:lo(n.response.attestationObject),clientDataJSON:lo(n.response.clientDataJSON)}});var n}async function no(t){const e=ro(t);return so(await navigator.credentials.get(e))}async function io(t,e){const n=ro(t);return n.signal=e.signal,n.mediation="conditional",so(await navigator.credentials.get(n))}async function oo(t=!1){if(!Li)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 ro(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=ao(n.publicKey.challenge),null===(e=n.publicKey.allowCredentials)||void 0===e||e.forEach((t=>{t.id=ao(t.id)})),n}function so(t){return JSON.stringify({id:t.id,rawId:lo(t.rawId),type:t.type,response:{authenticatorData:lo(t.response.authenticatorData),clientDataJSON:lo(t.response.clientDataJSON),signature:lo(t.response.signature),userHandle:t.response.userHandle?lo(t.response.userHandle):void 0}})}function ao(t){const e=t.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(e),(t=>t.charCodeAt(0))).buffer}function lo(t){return btoa(String.fromCharCode.apply(null,new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var co,uo=(co=t=>({async signUp(e,n){const i=await t.webauthn.signUp.start(e,window.location.origin,n);if(!i.ok)return i;const o=await eo(i.data.options);return await t.webauthn.signUp.finish(i.data.transactionId,o)},async signIn(e){const n=await t.webauthn.signIn.start(e,window.location.origin);if(!n.ok)return n;const i=await no(n.data.options);return await t.webauthn.signIn.finish(n.data.transactionId,i)},async signUpOrIn(e){var n;const i=await t.webauthn.signUpOrIn.start(e,window.location.origin);if(!i.ok)return i;if(null===(n=i.data)||void 0===n?void 0:n.create){const e=await eo(i.data.options);return await t.webauthn.signUp.finish(i.data.transactionId,e)}{const e=await no(i.data.options);return await t.webauthn.signIn.finish(i.data.transactionId,e)}},async update(e,n){const i=await t.webauthn.update.start(e,window.location.origin,n);if(!i.ok)return i;const o=await eo(i.data.options);return await t.webauthn.update.finish(i.data.transactionId,o)},helpers:{create:eo,get:no,isSupported:oo,conditional:io}}),(...t)=>{const e=co(...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}),ho=t=>Object.assign(Object.assign({},t.flow),{start:async(...e)=>{const n=await oo(),i=Object.assign(Object.assign({redirectUrl:window.location.href},e[1]),{deviceInfo:{webAuthnSupport:n}});return e[1]=i,t.flow.start(...e)}});const po=function(...t){return e=>t.reduce(((t,e)=>e(t)),e)}((t=>n=>{var{fpKey:i,fpLoad:o}=n,r=e(n,["fpKey","fpLoad"]);return i?(Li?o&&(async t=>{try{if($i())return;const e=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),n=Ii({apiKey:t,endpoint:qi}),i=await n,{requestId:o}=await i.get({linkedId:e});(t=>{const e={value:t,expiry:(new Date).getTime()+864e5};localStorage.setItem("fp",JSON.stringify(e))})(Mi(e,o))}catch(t){global.FB_DEBUG&&console.error(t)}})(i).catch((()=>null)):console.warn("Fingerprint is a client side only capability and will not work when running in the server"),t(Ci(r,{beforeRequest:Di}))):t(Object.assign({},r))}),(t=>n=>{var{autoRefresh:i}=n,o=e(n,["autoRefresh"]);if(!i)return t(o);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,l;document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&new Date>a&&(Ti("Expiration time passed, refreshing session"),c.refresh(l))}));const c=t(Ci(o,{afterRequest:async(t,e)=>{const{refreshJwt:n,sessionJwt:i}=await Ai(e);if(401===(null==e?void 0:e.status))Ti("Received 401, canceling all timers"),r();else if(i){a=(t=>{const e=t.split(".");try{if(3===e.length){const t=JSON.parse(window.atob(e[1]));if(t.exp)return new Date(1e3*t.exp)}}catch(t){}return null})(i),l=n;const t=((o=a)?o.getTime()-(new Date).getTime():0)-2e4;r();const e=new Date(Date.now()+t).toLocaleTimeString("en-US",{hour12:!1});Ti(`Setting refresh timer for ${e}. (${t}ms)`),s((()=>{Ti("Refreshing session due to timer"),c.refresh(n)}),t)}var o}}));return gi(c,["logout","logoutAll"],(t=>async(...e)=>{const n=await t(...e);return Ti("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.3.7"},e.baseHeaders)}))),(t=>e=>{const n=zi(),i=zi(),o=t(Ci(e,{afterRequest:async(t,e)=>{if(401===(null==e?void 0:e.status))n.pub(null),i.pub(null);else{const t=await Ei(e);t&&i.pub(t);const{sessionJwt:o}=await Ai(e);o&&n.pub(o)}}})),r=gi(o,["logout","logoutAll"],(t=>async(...e)=>{const o=await t(...e);return n.pub(null),i.pub(null),o}));return Object.assign(r,{onSessionTokenChange:n.sub,onUserChange:i.sub})}),(t=>e=>{const n=t(Ci(e,{afterRequest:async(t,e)=>{var n;const i=await Ei(e),o=null===(n=null==i?void 0:i.loginIds)||void 0===n?void 0:n[0],r=null==i?void 0:i.name;o&&((t=>{_i(Ni,t)})(o),(t=>{_i(Ki,t)})(r))}}));let i=gi(n,["flow.start"],Ji);return i=gi(i,["logout","logoutAll"],Hi),Object.assign(i,{getLastUserLoginId:Fi,getLastUserDisplayName:Wi})}),(t=>n=>{var{persistTokens:i,sessionTokenViaCookie:o}=n,r=e(n,["persistTokens","sessionTokenViaCookie"]);if(!i||!Li)return i&&console.warn("Storing auth tokens in local storage and cookies are a client side only capabilities and will not be done when running in the server"),t(r);const s=t(Ci(r,{beforeRequest:Qi,afterRequest:async(t,e)=>{401===(null==e?void 0:e.status)?Yi():Zi(await Ai(e),o)}})),a=gi(s,["logout","logoutAll"],to);return Object.assign(a,{getRefreshToken:Gi,getSessionToken:Xi})}))(((...t)=>{const e=vi(...t);return Object.assign(Object.assign({},e),{flow:ho(e),webauthn:uo(e)})})),fo=document.createElement("template");var go,vo,mo,bo,wo,yo,Io,ko,xo,Oo,jo,So,Co,Ao,Eo,Uo,_o,Ro,Po,To,Lo,qo,Mo,$o,Do,No,Ko,Fo,Wo,Jo,Ho,zo,Bo,Vo,Zo,Go,Xo,Yo,Qo,tr,er,nr,ir,or,rr,sr,ar,lr,cr;fo.innerHTML='\n\t<style>\n\t\t:host {\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t}\n\t\t\n\t\t#wc-root {\n\t\t\theight: 100%;\n\t\t\ttransition: opacity 300ms ease-in-out;\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';class dr extends HTMLElement{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","theme","debug","telemetryKey","redirect-url","auto-focus","prefer-biometrics"]}constructor(t){super(),go.add(this),vo.set(this,!1),mo.set(this,new W({deferredRedirect:!1})),bo.set(this,new W),this.nextRequestStatus=new W({isLoading:!1}),wo.set(this,void 0),yo.set(this,{popstate:i(this,go,"m",So).bind(this),visibilitychange:i(this,go,"m",Co).bind(this)}),Io.set(this,void 0),Uo.set(this,L((()=>n(this,void 0,void 0,(function*(){const t=A(this.projectId,"config.json");try{const{body:e,headers:n}=yield C(t,"json");return{projectConfig:e,executionContext:{geo:n["x-geo"]}}}catch(t){this.logger.error("Cannot get config file","make sure that your projectId & flowId are correct")}return{}}))))),this.logger={error:(t,e="")=>{console.error(t,e,new Error),i(this,go,"m",Mo).call(this,t,e)},info:(t,e="")=>{console.log(t,e)}},o(this,Io,t,"f"),i(this,go,"m",ko).call(this)}get projectId(){return this.getAttribute("project-id")}get flowId(){return this.getAttribute("flow-id")}get baseUrl(){return this.getAttribute("base-url")||void 0}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 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 telemetryKey(){return this.getAttribute("telemetryKey")||void 0}get autoFocus(){var t;const e=null!==(t=this.getAttribute("auto-focus"))&&void 0!==t?t:"true";return"skipFirstScreen"===e?e:"true"===e}get preferBiometrics(){var t;return"true"===(null!==(t=this.getAttribute("prefer-biometrics"))&&void 0!==t?t:"true")}getExecutionContext(){return n(this,void 0,void 0,(function*(){const{executionContext:t}=yield i(this,Uo,"f").call(this);return t}))}getFlowConfig(){var t,e;return n(this,void 0,void 0,(function*(){const{projectConfig:n}=yield i(this,Uo,"f").call(this),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}))}connectedCallback(){return n(this,void 0,void 0,(function*(){if(this.shadowRoot.isConnected){if(i(this,go,"m",xo).call(this))return void i(this,go,"m",Oo).call(this);i(this,go,"m",jo).call(this),i(this,go,"m",Ro).call(this),i(this,go,"m",_o).call(this),i(this,go,"m",$o).call(this);const{executionId:t,stepId:e,token:n,code:r,exchangeError:s,redirectAuthCallbackUrl:a,redirectAuthCodeChallenge:l,redirectAuthInitiator:c,oidcIdpStateId:d}=T();window.addEventListener("popstate",i(this,yo,"f").popstate),window.addEventListener("visibilitychange",i(this,yo,"f").visibilitychange),i(this,mo,"f").subscribe(i(this,go,"m",Eo).bind(this)),i(this,bo,"f").subscribe(i(this,go,"m",qo).bind(this)),i(this,mo,"f").update({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenant,redirectUrl:this.redirectUrl,stepId:e,executionId:t,token:n,code:r,exchangeError:s,telemetryKey:this.telemetryKey,redirectAuthCallbackUrl:a,redirectAuthCodeChallenge:l,redirectAuthInitiator:c,oidcIdpStateId:d}),i(this,bo,"f").update({isDebug:this.debug}),o(this,vo,!0,"f")}}))}disconnectedCallback(){i(this,mo,"f").unsubscribeAll(),i(this,bo,"f").unsubscribeAll(),i(this,go,"m",Lo).call(this),window.removeEventListener("popstate",i(this,yo,"f").popstate)}attributeChangedCallback(t,e,n){if(this.shadowRoot.isConnected&&i(this,vo,"f")&&e!==n&&dr.observedAttributes.includes(t)){i(this,go,"m",jo).call(this);const o=null===e;i(this,mo,"f").update((({stepId:e,executionId:i})=>{let r=e,s=i;return o||(s=null,r=null,R()),{[P(t)]:n,stepId:r,executionId:s}})),i(this,bo,"f").update({isDebug:this.debug})}}}vo=new WeakMap,mo=new WeakMap,bo=new WeakMap,wo=new WeakMap,yo=new WeakMap,Io=new WeakMap,Uo=new WeakMap,go=new WeakSet,ko=function(){this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(fo.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#wc-root")},xo=function(){return!this.shadowRoot.host.closest("form")&&_()},Oo=function(){const t=this.shadowRoot.host,e=document.createElement("form");t.parentElement.appendChild(e),e.appendChild(t)},jo=function(){const t=["base-url","tenant","theme","debug","telemetryKey","redirect-url","auto-focus","prefer-biometrics"];if(dr.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[P(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')},So=function(){const{stepId:t,executionId:e}=U();i(this,mo,"f").update({stepId:t,executionId:e})},Co=function(){document.hidden||setTimeout((()=>{i(this,mo,"f").update({deferredRedirect:!1})}),300)},Ao=function(t,e,i){const o=i||void 0,r=!!o;this.sdk=po(Object.assign(Object.assign({persistTokens:!0},dr.sdkConfigOverrides),{projectId:t,baseUrl:e,fpKey:o,fpLoad:r})),["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)}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},Eo=function(t,e,o){return n(this,void 0,void 0,(function*(){const{projectId:e,baseUrl:n,telemetryKey:r}=t;if(o("projectId")||o("baseUrl")||o("telemetryKey")){if(!e)return;i(this,go,"m",Ao).call(this,e,n,r)}i(this,Io,"f").call(this,t)}))},_o=function(){var t,e,o,r;return n(this,void 0,void 0,(function*(){const{projectConfig:n}=yield i(this,Uo,"f").call(this);null===(r=null===(o=null===(e=null===(t=null==n?void 0:n.cssTemplate)||void 0===t?void 0:t[this.theme])||void 0===e?void 0:e.typography)||void 0===o?void 0:o.fontFamilies)||void 0===r||r.forEach((t=>(t=>{if(!t)return;const e=document.createElement("link");e.href=t,e.rel="stylesheet",document.head.appendChild(e)})(t.url)))}))},Ro=function(){i(this,go,"m",Po).call(this),i(this,go,"m",To).call(this)},Po=function(){return n(this,void 0,void 0,(function*(){const t=document.createElement("style"),e=A(this.projectId,"theme.css");try{const{body:n}=yield C(e,"text");t.innerText=n}catch(t){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}this.shadowRoot.appendChild(t)}))},To=function(){this.rootElement.setAttribute("data-theme",this.theme)},Lo=function(){var t;null===(t=i(this,wo,"f"))||void 0===t||t.remove(),o(this,wo,null,"f")},qo=function({isDebug:t}){return n(this,void 0,void 0,(function*(){t?(yield Promise.resolve().then((function(){return fr})),o(this,wo,document.createElement("descope-debugger"),"f"),Object.assign(i(this,wo,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),document.body.appendChild(i(this,wo,"f"))):i(this,go,"m",Lo).call(this)}))},Mo=function(t,e){var n;t&&this.debug&&(null===(n=i(this,wo,"f"))||void 0===n||n.updateData({title:t,description:e}))},$o=function(){this.rootElement.onkeydown=t=>{if("Enter"!==t.key)return;t.preventDefault();const e=this.rootElement.querySelectorAll("button");if(1===e.length)return void e[0].click();const n=Array.from(e).filter((t=>"button"===t.getAttribute("data-type")));1===n.length&&n[0].click()}},dr.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"2.6.3"}};class ur extends dr{static set sdkConfigOverrides(t){dr.sdkConfigOverrides=t}constructor(){const t=new W;super(t.update.bind(t)),Do.add(this),this.stepState=new W({},{updateOnlyOnChange:!1}),No.set(this,void 0),Ko.set(this,null),Fo.set(this,(()=>{clearInterval(i(this,No,"f")),o(this,No,null,"f")})),Wo.set(this,(t=>{var e,n,o,s,a,l,c,d,u;if(!(null==t?void 0:t.ok)){i(this,Fo,"f").call(this),i(this,Do,"m",Qo).call(this,"error",null==t?void 0:t.error);const r=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===(o=null==t?void 0:t.response)||void 0===o?void 0:o.statusText}`;return void this.logger.error((null===(s=null==t?void 0:t.error)||void 0===s?void 0:s.errorDescription)||r,(null===(a=null==t?void 0:t.error)||void 0===a?void 0:a.errorMessage)||l)}const h=null===(d=null===(c=null===(l=t.data)||void 0===l?void 0:l.screen)||void 0===c?void 0:c.state)||void 0===d?void 0:d.errorText;h&&this.logger.error(h),(null===(u=t.data)||void 0===u?void 0:u.error)&&this.logger.error(`[${t.data.error.code}]: ${t.data.error.description}`,t.data.error.message);const{status:f,authInfo:g,lastAuth:v}=t.data;if("completed"===f)return function(t){(null==t?void 0:t.authMethod)&&r&&localStorage.setItem(p,JSON.stringify(t))}(v),i(this,Fo,"f").call(this),void i(this,Do,"m",Qo).call(this,"success",g);const{executionId:b,stepId:w,action:y,screen:I,redirect:k,webauthn:x}=t.data;y!==m?this.flowState.update({stepId:w,executionId:b,action:y,redirectTo:null==k?void 0:k.url,screenId:null==I?void 0:I.id,screenState:null==I?void 0:I.state,webauthnTransactionId:null==x?void 0:x.transactionId,webauthnOptions:null==x?void 0:x.options}):this.flowState.update({action:y})})),Jo.set(this,L((()=>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.logger.error("Webauthn start failed",null===(t=null==e?void 0:e.error)||void 0===t?void 0:t.errorMessage),e.data}catch(t){this.logger.error("Webauthn start failed",t.message)}}))))),this.flowState=t}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))),yield t.connectedCallback.call(this)}))}disconnectedCallback(){super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll()}onFlowChange(t,e,r){var s,a,l,c,d,u;return n(this,void 0,void 0,(function*(){const{projectId:h,flowId:p,tenant:f,stepId:g,executionId:k,action:x,screenId:O,screenState:j,redirectTo:S,redirectUrl:C,token:U,code:R,exchangeError:P,webauthnTransactionId:T,webauthnOptions:L,redirectAuthCodeChallenge:q,redirectAuthCallbackUrl:$,redirectAuthInitiator:D,oidcIdpStateId:N}=t;let K,F;i(this,No,"f")&&i(this,Fo,"f").call(this);const W=this.sdk.getLastUserLoginId(),J=yield this.getFlowConfig(),H=$&&q?{callbackUrl:$,codeChallenge:q}:void 0;if(!k&&(J.conditions?({startScreenId:K,conditionInteractionId:F}=((t,e)=>{const n=null==e?void 0:e.find((({key:e,operator:n})=>{var i;if("ELSE"===e)return!0;const o=null===(i=V[e])||void 0===i?void 0:i[n];return!!(null==o?void 0:o(t))}));return n?{startScreenId:n.met.screenId,conditionInteractionId:n.met.interactionId}:{}})({loginId:W,code:R},J.conditions)):J.condition?({startScreenId:K,conditionInteractionId:F}=((t,e)=>{var n;const i=null===(n=V[null==t?void 0:t.key])||void 0===n?void 0:n[t.operator];if(!i)return{};const o=i(e)?t.met:t.unmet;return{startScreenId:null==o?void 0:o.screenId,conditionInteractionId:null==o?void 0:o.interactionId}})(J.condition,{loginId:W,code:R})):K=J.startScreenId,!M(K,N))){const t=R?{exchangeCode:R,idpInitiated:!0}:void 0,e=yield this.sdk.flow.start(p,Object.assign(Object.assign({tenant:f,redirectAuth:H,oidcIdpStateId:N},C&&{redirectUrl:C}),{lastAuth:Z(W)}),F,"",t,J.version);return i(this,Wo,"f").call(this,e),void("completed"!==(null===(s=null==e?void 0:e.data)||void 0===s?void 0:s.status)&&this.flowState.update({code:void 0}))}if(k&&(r("token")&&U||r("code")&&R||r("exchangeError")&&P)){const t=yield this.sdk.flow.next(k,g,y,{token:U,exchangeCode:R,exchangeError:P},J.version);return i(this,Wo,"f").call(this,t),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(x===v&&(r("redirectTo")||r("deferredRedirect")))return S?"android"===D&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(S):void this.logger.error("Did not get redirect url");if(x===b||x===w){if(!T||!L)return void this.logger.error("Did not get webauthn transaction id or options");let t,e,n=L;if(this.preferBiometrics&&x===b&&_()&&(yield null===(l=null===(a=window.PublicKeyCredential)||void 0===a?void 0:a.isUserVerifyingPlatformAuthenticatorAvailable)||void 0===l?void 0:l.call(a)))try{const t=JSON.parse(n);t.publicKey&&((d=t.publicKey).authenticatorSelection||(d.authenticatorSelection={}),(u=t.publicKey.authenticatorSelection).authenticatorAttachment||(u.authenticatorAttachment="platform"),n=JSON.stringify(t))}catch(t){this.logger.info("Failed to modify webauthn create options")}null===(c=i(this,Ko,"f"))||void 0===c||c.abort(),o(this,Ko,null,"f");try{t=x===b?yield this.sdk.webauthn.helpers.create(n):yield this.sdk.webauthn.helpers.get(n)}catch(t){if("NotAllowedError"!==t.name)return void this.logger.error(t.message);e=!0}const r=yield this.sdk.flow.next(k,g,y,{transactionId:T,response:t,cancelWebauthn:e},J.version);i(this,Wo,"f").call(this,r)}if(x===m&&o(this,No,setInterval((()=>n(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(k,g,I,{},J.version);i(this,Wo,"f").call(this,t)}))),2e3),"f"),!O&&!K)return void this.logger.info("Refreshing the page during a flow is not supported yet");const z={direction:E(+g,+e.stepId),screenState:Object.assign(Object.assign({},j),{lastAuth:{loginId:W,name:this.sdk.getLastUserDisplayName()||W}}),htmlUrl:A(h,`${K||O}.html`)},B=Z(W);M(K,N)?z.next=(t,e)=>this.sdk.flow.start(p,Object.assign({tenant:f,redirectAuth:H,oidcIdpStateId:N,lastAuth:B},C&&{redirectUrl:C}),F,t,Object.assign(Object.assign({},e),R&&{exchangeCode:R,idpInitiated:!0}),J.version):(r("projectId")||r("baseUrl")||r("executionId")||r("stepId"))&&(z.next=(...t)=>this.sdk.flow.next(k,g,...t)),this.stepState.update(z)}))}onStepChange(t,e){var o;return n(this,void 0,void 0,(function*(){const{htmlUrl:r,direction:s,next:a,screenState:l}=t,c=document.createElement("template"),{body:d}=yield C(r,"text");c.innerHTML=d;const u=c.content.cloneNode(!0),h=((t,e)=>{var n;const i=Array.from(t.querySelectorAll("script[data-id]")).map((n=>{var i;const o=n.getAttribute("data-id"),r=null===(i=t.getElementById(o))||void 0===i?void 0:i.innerHTML,s=Function(r).bind(n.previousSibling,e);return n.remove(),s}));return null===(n=t.querySelector("scripts"))||void 0===n||n.remove(),i})(u,yield this.getExecutionContext());this.sdk.webauthn.helpers.isSupported()?yield i(this,Do,"m",zo).call(this,u,a):u.querySelectorAll(`button[${g}="biometrics"]`).forEach((t=>t.setAttribute("disabled","true"))),H(u,l,this.errorTransformer,this.logger),((t,e)=>{var n;e&&(null===(n=null==t?void 0:t.style)||void 0===n||n.setProperty("--totp-image",`url(data:image/jpg;base64,${e})`))})(u.querySelector("div"),null===(o=null==l?void 0:l.totp)||void 0===o?void 0:o.image);const p=()=>n(this,void 0,void 0,(function*(){try{h.forEach((t=>{t()}))}catch(t){this.logger.error(t.message)}this.rootElement.replaceChildren(u);const t=!e.htmlUrl;((t,e,n)=>{if(!0===e||"skipFirstScreen"===e&&!n){const e=t.querySelector('input:not([aria-hidden="true"])');null==e||e.focus()}})(this.rootElement,this.autoFocus,t),i(this,Do,"m",Xo).call(this,a),i(this,Do,"m",Qo).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${g}="polling"]`)){const t=yield a(I,{});i(this,Wo,"f").call(this,t)}}));s?i(this,Do,"m",Yo).call(this,p,s):p()}))}}No=new WeakMap,Ko=new WeakMap,Fo=new WeakMap,Wo=new WeakMap,Jo=new WeakMap,Do=new WeakSet,Ho=function(t){const e=t.name;if(!["email"].includes(e)){const n=`user-${e}`;t.name=n,t.addEventListener("input",(()=>{t.name=t.value?e:n}))}},zo=function(t,e){var r;return n(this,void 0,void 0,(function*(){null===(r=i(this,Ko,"f"))||void 0===r||r.abort();const s=t.querySelector('input[autocomplete="webauthn"]');if(s&&(yield z())){const{options:t,transactionId:r}=(yield i(this,Jo,"f").call(this))||{};t&&r&&(i(this,Do,"m",Ho).call(this,s),o(this,Ko,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(t,i(this,Ko,"f")).then((t=>n(this,void 0,void 0,(function*(){const n=yield e(s.id,{transactionId:r,response:t});i(this,Wo,"f").call(this,n)})))).catch((t=>{"AbortError"!==t.name&&this.logger.error("Conditional login failed",t.message)})))}}))},Bo=function(){return Array.from(this.shadowRoot.querySelectorAll(".descope-input")).every((t=>(t.reportValidity(),t.checkValidity())))},Vo=function(){return Array.from(this.shadowRoot.querySelectorAll(`.descope-input[name]:not([${h}])`)).reduce(((t,e)=>e.name?Object.assign(t,{[e.name]:e["checkbox"===e.type?"checked":"value"]}):t),{})},Zo=function(t){const e=this.nextRequestStatus.subscribe((({isLoading:n})=>{var i,o;n?null===(i=null==t?void 0:t.classList)||void 0===i||i.add("loading"):(this.nextRequestStatus.unsubscribe(e),null===(o=null==t?void 0:t.classList)||void 0===o||o.remove("loading"))}))},Go=function(t,e){return n(this,void 0,void 0,(function*(){if(t.formNoValidate||i(this,Do,"m",Bo).call(this)){const o=null==t?void 0:t.getAttribute("id");i(this,Do,"m",Zo).call(this,t);const r=i(this,Do,"m",Vo).call(this),s=(n=t,Array.from((null==n?void 0:n.attributes)||[]).reduce(((t,e)=>{var n;const i=null===(n=new RegExp("^data-descope-(\\S+)$").exec(e.name))||void 0===n?void 0:n[1];return i?Object.assign(t,{[i]:e.value}):t}),{})),a=Object.assign(Object.assign(Object.assign({},s),r),{origin:window.location.origin}),l=yield e(o,a);i(this,Wo,"f").call(this,l)}var n}))},Xo=function(t){this.rootElement.querySelectorAll("button").forEach((e=>{e.onclick=()=>{i(this,Do,"m",Go).call(this,e,t)}}))},Yo=function(t,e){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),t()}),{once:!0});const n=e===k.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")},Qo=function(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))},customElements.define("descope-wc",ur);const hr=document.createElement("template");hr.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 } \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 pr extends HTMLElement{constructor(){super(),tr.add(this),er.set(this,new W({messages:[]})),nr.set(this,void 0),ir.set(this,void 0),or.set(this,void 0),rr.set(this,{resize:i(this,tr,"m",cr).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(hr.content.cloneNode(!0)),o(this,nr,this.shadowRoot.querySelector(".debugger"),"f"),o(this,ir,i(this,nr,"f").querySelector(".content"),"f"),o(this,or,i(this,nr,"f").querySelector(".header"),"f")}updateData(t){i(this,er,"f").update((e=>({messages:e.messages.concat(t)})))}connectedCallback(){var t;((t,e,n)=>{let i=0,o=0,r=0,s=0;function a(e){e.preventDefault(),i=r-e.clientX,o=s-e.clientY,r=e.clientX,s=e.clientY;const[a,l]=B(t,t.offsetLeft-i,t.offsetTop-o,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})(i(this,nr,"f"),i(this,or,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",i(this,rr,"f").resize),(t=i(this,nr,"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},i(this,nr,"f").onresize=i(this,tr,"m",lr).bind(this),i(this,er,"f").subscribe(i(this,tr,"m",sr).bind(this))}disconnectedCallback(){i(this,er,"f").unsubscribeAll(),window.removeEventListener("resize",i(this,rr,"f").resize)}}er=new WeakMap,nr=new WeakMap,ir=new WeakMap,or=new WeakMap,rr=new WeakMap,tr=new WeakSet,sr=function(t){i(this,tr,"m",ar).call(this,t),i(this,tr,"m",lr).call(this)},ar=function(t){i(this,ir,"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("")},lr=function(){i(this,ir,"f").querySelectorAll(".msg").forEach((t=>{const e=t.querySelector(".msg_desc"),n=e.scrollWidth>e.clientWidth,i=e.clientHeight>20;n||i?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},cr=function(){const[t,e]=B(i(this,nr,"f"),Number.parseInt(i(this,nr,"f").style.left,10),Number.parseInt(i(this,nr,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});i(this,nr,"f").style.top=`${e}px`,i(this,nr,"f").style.left=`${t}px`},customElements.define("descope-debugger",pr);var fr=Object.freeze({__proto__:null,default:pr})}();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@descope/web-component",
3
- "version": "2.6.2",
3
+ "version": "2.6.3",
4
4
  "author": "Descope Team <info@descope.com>",
5
5
  "homepage": "https://github.com/descope/web-component",
6
6
  "bugs": {
@@ -51,7 +51,7 @@
51
51
  "lint-staged": "^13.0.3",
52
52
  "prettier": "^2.6.2",
53
53
  "pretty-quick": "^3.1.3",
54
- "rollup": "^2.62.0",
54
+ "rollup": "^2.78.0",
55
55
  "rollup-plugin-browsersync": "^1.3.3",
56
56
  "rollup-plugin-define": "^1.0.1",
57
57
  "rollup-plugin-delete": "^2.0.0",
@@ -66,7 +66,7 @@
66
66
  },
67
67
  "dependencies": {
68
68
  "tslib": "2.5.3",
69
- "@descope/web-js-sdk": "1.3.6"
69
+ "@descope/web-js-sdk": "1.3.7"
70
70
  },
71
71
  "overrides": {
72
72
  "terser": "5.18.0"