@descope/web-component 2.3.2 → 2.3.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{S as e,_ as n,a as t}from"./index-78a0ebca.js";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 e({messages:[]})),l.set(this,void 0),a.set(this,void 0),r.set(this,void 0),d.set(this,{resize:n(this,i,"m",g).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(f.content.cloneNode(!0)),t(this,l,this.shadowRoot.querySelector(".debugger"),"f"),t(this,a,n(this,l,"f").querySelector(".content"),"f"),t(this,r,n(this,l,"f").querySelector(".header"),"f")}updateData(e){n(this,o,"f").update((n=>({messages:n.messages.concat(e)})))}connectedCallback(){var e;((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})(n(this,l,"f"),n(this,r,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",n(this,d,"f").resize),(e=n(this,l,"f")).onmousemove=n=>{(n.target.w&&n.target.w!==n.target.offsetWidth||n.target.h&&n.target.h!==n.target.offsetHeight)&&e.onresize(n),n.target.w=n.target.offsetWidth,n.target.h=n.target.offsetHeight},n(this,l,"f").onresize=n(this,i,"m",p).bind(this),n(this,o,"f").subscribe(n(this,i,"m",c).bind(this))}disconnectedCallback(){n(this,o,"f").unsubscribeAll(),window.removeEventListener("resize",n(this,d,"f").resize)}}o=new WeakMap,l=new WeakMap,a=new WeakMap,r=new WeakMap,d=new WeakMap,i=new WeakSet,c=function(e){n(this,i,"m",h).call(this,e),n(this,i,"m",p).call(this)},h=function(e){n(this,a,"f").innerHTML=e.messages.map((e=>`\n <div class="msg">\n <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.99984 13.167L8.99984 10.167L11.9998 13.167L13.1665 12.0003L10.1665 9.00033L13.1665 6.00033L11.9998 4.83366L8.99984 7.83366L5.99984 4.83366L4.83317 6.00033L7.83317 9.00033L4.83317 12.0003L5.99984 13.167ZM8.99984 17.3337C7.84706 17.3337 6.76373 17.1148 5.74984 16.677C4.73595 16.2398 3.854 15.6462 3.104 14.8962C2.354 14.1462 1.76039 13.2642 1.32317 12.2503C0.885393 11.2364 0.666504 10.1531 0.666504 9.00033C0.666504 7.84755 0.885393 6.76421 1.32317 5.75033C1.76039 4.73644 2.354 3.85449 3.104 3.10449C3.854 2.35449 4.73595 1.7606 5.74984 1.32283C6.76373 0.885603 7.84706 0.666992 8.99984 0.666992C10.1526 0.666992 11.2359 0.885603 12.2498 1.32283C13.2637 1.7606 14.1457 2.35449 14.8957 3.10449C15.6457 3.85449 16.2393 4.73644 16.6765 5.75033C17.1143 6.76421 17.3332 7.84755 17.3332 9.00033C17.3332 10.1531 17.1143 11.2364 16.6765 12.2503C16.2393 13.2642 15.6457 14.1462 14.8957 14.8962C14.1457 15.6462 13.2637 16.2398 12.2498 16.677C11.2359 17.1148 10.1526 17.3337 8.99984 17.3337ZM8.99984 15.667C10.8609 15.667 12.4373 15.0212 13.729 13.7295C15.0207 12.4378 15.6665 10.8614 15.6665 9.00033C15.6665 7.13921 15.0207 5.56283 13.729 4.27116C12.4373 2.97949 10.8609 2.33366 8.99984 2.33366C7.13873 2.33366 5.56234 2.97949 4.27067 4.27116C2.979 5.56283 2.33317 7.13921 2.33317 9.00033C2.33317 10.8614 2.979 12.4378 4.27067 13.7295C5.56234 15.0212 7.13873 15.667 8.99984 15.667Z" fill="#ED404A"/>\n</svg>\n\n <div class="msg_content">\n <div class="msg_title">\n ${e.title}\n </div>\n <div class="msg_desc">\n ${e.description}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},p=function(){n(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[e,t]=s(n(this,l,"f"),Number.parseInt(n(this,l,"f").style.left,10),Number.parseInt(n(this,l,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});n(this,l,"f").style.top=`${t}px`,n(this,l,"f").style.left=`${e}px`},customElements.define("descope-debugger",m);export{m as default};
1
+ import{S as e,_ as n,a as t}from"./index-63a41376.js";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 e({messages:[]})),l.set(this,void 0),a.set(this,void 0),r.set(this,void 0),d.set(this,{resize:n(this,i,"m",g).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(f.content.cloneNode(!0)),t(this,l,this.shadowRoot.querySelector(".debugger"),"f"),t(this,a,n(this,l,"f").querySelector(".content"),"f"),t(this,r,n(this,l,"f").querySelector(".header"),"f")}updateData(e){n(this,o,"f").update((n=>({messages:n.messages.concat(e)})))}connectedCallback(){var e;((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})(n(this,l,"f"),n(this,r,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",n(this,d,"f").resize),(e=n(this,l,"f")).onmousemove=n=>{(n.target.w&&n.target.w!==n.target.offsetWidth||n.target.h&&n.target.h!==n.target.offsetHeight)&&e.onresize(n),n.target.w=n.target.offsetWidth,n.target.h=n.target.offsetHeight},n(this,l,"f").onresize=n(this,i,"m",p).bind(this),n(this,o,"f").subscribe(n(this,i,"m",c).bind(this))}disconnectedCallback(){n(this,o,"f").unsubscribeAll(),window.removeEventListener("resize",n(this,d,"f").resize)}}o=new WeakMap,l=new WeakMap,a=new WeakMap,r=new WeakMap,d=new WeakMap,i=new WeakSet,c=function(e){n(this,i,"m",h).call(this,e),n(this,i,"m",p).call(this)},h=function(e){n(this,a,"f").innerHTML=e.messages.map((e=>`\n <div class="msg">\n <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.99984 13.167L8.99984 10.167L11.9998 13.167L13.1665 12.0003L10.1665 9.00033L13.1665 6.00033L11.9998 4.83366L8.99984 7.83366L5.99984 4.83366L4.83317 6.00033L7.83317 9.00033L4.83317 12.0003L5.99984 13.167ZM8.99984 17.3337C7.84706 17.3337 6.76373 17.1148 5.74984 16.677C4.73595 16.2398 3.854 15.6462 3.104 14.8962C2.354 14.1462 1.76039 13.2642 1.32317 12.2503C0.885393 11.2364 0.666504 10.1531 0.666504 9.00033C0.666504 7.84755 0.885393 6.76421 1.32317 5.75033C1.76039 4.73644 2.354 3.85449 3.104 3.10449C3.854 2.35449 4.73595 1.7606 5.74984 1.32283C6.76373 0.885603 7.84706 0.666992 8.99984 0.666992C10.1526 0.666992 11.2359 0.885603 12.2498 1.32283C13.2637 1.7606 14.1457 2.35449 14.8957 3.10449C15.6457 3.85449 16.2393 4.73644 16.6765 5.75033C17.1143 6.76421 17.3332 7.84755 17.3332 9.00033C17.3332 10.1531 17.1143 11.2364 16.6765 12.2503C16.2393 13.2642 15.6457 14.1462 14.8957 14.8962C14.1457 15.6462 13.2637 16.2398 12.2498 16.677C11.2359 17.1148 10.1526 17.3337 8.99984 17.3337ZM8.99984 15.667C10.8609 15.667 12.4373 15.0212 13.729 13.7295C15.0207 12.4378 15.6665 10.8614 15.6665 9.00033C15.6665 7.13921 15.0207 5.56283 13.729 4.27116C12.4373 2.97949 10.8609 2.33366 8.99984 2.33366C7.13873 2.33366 5.56234 2.97949 4.27067 4.27116C2.979 5.56283 2.33317 7.13921 2.33317 9.00033C2.33317 10.8614 2.979 12.4378 4.27067 13.7295C5.56234 15.0212 7.13873 15.667 8.99984 15.667Z" fill="#ED404A"/>\n</svg>\n\n <div class="msg_content">\n <div class="msg_title">\n ${e.title}\n </div>\n <div class="msg_desc">\n ${e.description}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},p=function(){n(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[e,t]=s(n(this,l,"f"),Number.parseInt(n(this,l,"f").style.left,10),Number.parseInt(n(this,l,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});n(this,l,"f").style.top=`${t}px`,n(this,l,"f").style.left=`${e}px`},customElements.define("descope-debugger",m);export{m as default};
@@ -1,2 +1,2 @@
1
- var t=function(){return t=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);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 r=0;for(o=Object.getOwnPropertySymbols(t);r<o.length;r++)e.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(n[o[r]]=t[o[r]])}return n}function n(t,e,n,o){return new(n||(n=Promise))((function(r,i){function s(t){try{l(o.next(t))}catch(t){i(t)}}function a(t){try{l(o.throw(t))}catch(t){i(t)}}function l(t){var e;t.done?r(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 r(t,e,n,o,r){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?r.call(t,n):r?r.value=n:e.set(t,n),n}const i="undefined"!=typeof localStorage,s=i&&localStorage.getItem("base.content.url")||"https://static.descope.com/pages",a="descope-login-flow",l="t",c="code",u="err",d="ra-challenge",h="ra-callback",p="data-exclude-field",f="dls_last_auth",g="data-type",v="redirect",b="poll",w="webauthnCreate",m="webauthnGet",y="v2-alpha",k="submit",I="polling";var O,j,S;function C(t){return new URLSearchParams(window.location.search).get(t)}function E(t){if(window.history.replaceState&&C(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 A(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"}(O||(O={}));const x=(...t)=>t.join("/").replace(/\/+/g,"/");function U(t,e){const n=new URL(s);return n.pathname=x(n.pathname,t,y,e),n.toString()}function _(t,e){if(!Number.isNaN(t)&&!Number.isNaN(e))return t>e?O.forward:t<e?O.backward:void 0}const P=()=>{const[t="",e=""]=(C(a)||"").split("_");return{executionId:t,stepId:e}};function R(){E(a)}const T=t=>t.replace(/-./g,(t=>t[1].toUpperCase())),q=()=>{const{executionId:t,stepId:e}=P();(t||e)&&R();const n=C(l)||void 0;n&&E(l);const o=C(c)||void 0;o&&E(c);const r=C(u)||void 0;r&&E(u);const{redirectAuthCodeChallenge:i,redirectAuthCallbackUrl:s}={redirectAuthCodeChallenge:C(d),redirectAuthCallbackUrl:C(h)};return(i||s)&&(E(d),E(h)),{executionId:t,stepId:e,token:n,code:o,exchangeError:r,redirectAuthCodeChallenge:i,redirectAuthCallbackUrl:s}},M=t=>{let e,n;return(...o)=>{return e&&(i=o,(r=e).length===i.length&&r.every(((t,e)=>t===i[e])))||(e=o,n=t(...o)),n;var r,i}},$=null===(S=null===(j=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===j?void 0:j.brands)||void 0===S?void 0:S.find((({brand:t,version:e})=>"Chromium"===t&&parseFloat(e)));var L,D,N,K;function J(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 r=n[o],i=t[r],s=e[r];if(null===i||null===s){if(i!==s)return!1}else if("object"==typeof i&&"object"==typeof s){if(!J(i,s))return!1}else if(i!==s)return!1}return!0}class F{constructor(t={},{updateOnlyOnChange:e=!0}={}){L.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,L,"f")):t,n=Object.assign(Object.assign({},o(this,L,"f")),e);if(!o(this,K,"f")||!J(o(this,L,"f"),n)){const t=o(this,L,"f");r(this,L,n,"f"),Object.freeze(o(this,L,"f")),setTimeout((()=>{Object.values(o(this,D,"f")).forEach((e=>e(n,t,((t,e)=>n=>t[n]!==e[n])(n,t))))}),0)}},r(this,L,t,"f"),r(this,K,e,"f")}get current(){return Object.assign({},o(this,L,"f"))}subscribe(t){return r(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 r(this,D,{},"f"),!0}}L=new WeakMap,D=new WeakMap,N=new WeakMap,K=new WeakMap;const W=(t,e)=>{var n;((t,e,n="")=>{t.querySelectorAll(`[${g}="${e}"]`).forEach((t=>{t.textContent=n,t.classList[n?"remove":"add"]("hide")}))})(t,"error-message",null==e?void 0:e.errorText),((t,e)=>{Object.entries(e||{}).forEach((([e,n])=>{Array.from(t.querySelectorAll(`.descope-input[name="${e}"]:not([${p}])`)).forEach((t=>{t.value=n}))}))})(t,null==e?void 0:e.inputs),((t,e)=>{t.querySelectorAll(`[${g}="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,n)=>{return o=e,n.split(".").reduce(((t,e)=>(null==t?void 0:t[e])||""),o);var o})))(t.textContent,e)}))})(t,e)},H=M((()=>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 r=Promise.all([null===(t=window.PublicKeyCredential)||void 0===t?void 0:t.isConditionalMediationAvailable(),null===(e=window.PublicKeyCredential)||void 0===e?void 0:e.isUserVerifyingPlatformAuthenticatorAvailable()]).then((t=>t.every((t=>!!t)))),i=108;return yield Promise.race([r,(n=100,new Promise(((t,e)=>{const r=setTimeout((()=>{e(new Error(`Promise timed out after ${n} ms`))}),n);null==o||o((e=>{clearTimeout(r),t(e)}),(t=>{clearTimeout(r),e(t)}))}))).catch((()=>$()>=i))])}catch(t){return console.warn("webauthn","Conditional login check failed",t),!1}})))),B={"lastAuth.loginId":{"not-empty":t=>!!t.loginId,empty:t=>!t.loginId},idpInitiated:{"is-true":t=>!!t.code,"is-false":t=>!t.code}};function V(t){this.message=t}V.prototype=new Error,V.prototype.name="InvalidCharacterError";var z="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new V("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,o,r=0,i=0,s="";o=e.charAt(i++);~o&&(n=r%4?64*n+o:o,r++%4)?s+=String.fromCharCode(255&n>>(-2*r&6)):0)o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);return s};function G(t){this.message=t}function Z(t,e){if("string"!=typeof t)throw new G("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(z(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 z(e)}}(t.split(".")[n]))}catch(t){throw new G("Invalid token specified: "+t.message)}}G.prototype=new Error,G.prototype.name="InvalidTokenError";var Q="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},Y="Expected a function",X="__lodash_hash_undefined__",tt=1/0,et="[object Function]",nt="[object GeneratorFunction]",ot="[object Symbol]",rt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,it=/^\w*$/,st=/^\./,at=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,lt=/\\(\\)?/g,ct=/^\[object .+?Constructor\]$/,ut="object"==typeof Q&&Q&&Q.Object===Object&&Q,dt="object"==typeof self&&self&&self.Object===Object&&self,ht=ut||dt||Function("return this")();var pt,ft=Array.prototype,gt=Function.prototype,vt=Object.prototype,bt=ht["__core-js_shared__"],wt=(pt=/[^.]+$/.exec(bt&&bt.keys&&bt.keys.IE_PROTO||""))?"Symbol(src)_1."+pt:"",mt=gt.toString,yt=vt.hasOwnProperty,kt=vt.toString,It=RegExp("^"+mt.call(yt).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ot=ht.Symbol,jt=ft.splice,St=Mt(ht,"Map"),Ct=Mt(Object,"create"),Et=Ot?Ot.prototype:void 0,At=Et?Et.toString:void 0;function xt(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 Ut(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 _t(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,e){for(var n,o,r=t.length;r--;)if((n=t[r][0])===(o=e)||n!=n&&o!=o)return r;return-1}function Rt(t,e){var n;e=function(t,e){if(Nt(t))return!1;var n=typeof t;if("number"==n||"symbol"==n||"boolean"==n||null==t||Jt(t))return!0;return it.test(t)||!rt.test(t)||null!=e&&t in Object(e)}(e,t)?[e]:Nt(n=e)?n:$t(n);for(var o=0,r=e.length;null!=t&&o<r;)t=t[Lt(e[o++])];return o&&o==r?t:void 0}function Tt(t){if(!Kt(t)||(e=t,wt&&wt in e))return!1;var e,n=function(t){var e=Kt(t)?kt.call(t):"";return e==et||e==nt}(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t)?It:ct;return n.test(function(t){if(null!=t){try{return mt.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}function qt(t,e){var n,o,r=t.__data__;return("string"==(o=typeof(n=e))||"number"==o||"symbol"==o||"boolean"==o?"__proto__"!==n:null===n)?r["string"==typeof e?"string":"hash"]:r.map}function Mt(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return Tt(n)?n:void 0}xt.prototype.clear=function(){this.__data__=Ct?Ct(null):{}},xt.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},xt.prototype.get=function(t){var e=this.__data__;if(Ct){var n=e[t];return n===X?void 0:n}return yt.call(e,t)?e[t]:void 0},xt.prototype.has=function(t){var e=this.__data__;return Ct?void 0!==e[t]:yt.call(e,t)},xt.prototype.set=function(t,e){return this.__data__[t]=Ct&&void 0===e?X:e,this},Ut.prototype.clear=function(){this.__data__=[]},Ut.prototype.delete=function(t){var e=this.__data__,n=Pt(e,t);return!(n<0)&&(n==e.length-1?e.pop():jt.call(e,n,1),!0)},Ut.prototype.get=function(t){var e=this.__data__,n=Pt(e,t);return n<0?void 0:e[n][1]},Ut.prototype.has=function(t){return Pt(this.__data__,t)>-1},Ut.prototype.set=function(t,e){var n=this.__data__,o=Pt(n,t);return o<0?n.push([t,e]):n[o][1]=e,this},_t.prototype.clear=function(){this.__data__={hash:new xt,map:new(St||Ut),string:new xt}},_t.prototype.delete=function(t){return qt(this,t).delete(t)},_t.prototype.get=function(t){return qt(this,t).get(t)},_t.prototype.has=function(t){return qt(this,t).has(t)},_t.prototype.set=function(t,e){return qt(this,t).set(t,e),this};var $t=Dt((function(t){var e;t=null==(e=t)?"":function(t){if("string"==typeof t)return t;if(Jt(t))return At?At.call(t):"";var e=t+"";return"0"==e&&1/t==-tt?"-0":e}(e);var n=[];return st.test(t)&&n.push(""),t.replace(at,(function(t,e,o,r){n.push(o?r.replace(lt,"$1"):e||t)})),n}));function Lt(t){if("string"==typeof t||Jt(t))return t;var e=t+"";return"0"==e&&1/t==-tt?"-0":e}function Dt(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError(Y);var n=function(){var o=arguments,r=e?e.apply(this,o):o[0],i=n.cache;if(i.has(r))return i.get(r);var s=t.apply(this,o);return n.cache=i.set(r,s),s};return n.cache=new(Dt.Cache||_t),n}Dt.Cache=_t;var Nt=Array.isArray;function Kt(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)&&kt.call(t)==ot}var Ft=function(t,e,n){var o=null==t?void 0:Rt(t,e);return void 0===o?n:o},Wt="/v1/auth/accesskey/exchange",Ht="/v1/auth/otp/verify",Bt="/v1/auth/otp/signin",Vt="/v1/auth/otp/signup",zt={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},Gt="/v1/auth/otp/signup-in",Zt="/v1/auth/magiclink/verify",Qt="/v1/auth/magiclink/signin",Yt="/v1/auth/magiclink/signup",Xt={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},te="/v1/auth/magiclink/signup-in",ee="/v1/auth/enchantedlink/verify",ne="/v1/auth/enchantedlink/signin",oe="/v1/auth/enchantedlink/signup",re="/v1/auth/enchantedlink/pending-session",ie={email:"/v1/auth/enchantedlink/update/email"},se="/v1/auth/enchantedlink/signup-in",ae="/v1/auth/oauth/authorize",le="/v1/auth/oauth/exchange",ce="/v1/auth/saml/authorize",ue="/v1/auth/saml/exchange",de="/v1/auth/totp/verify",he="/v1/auth/totp/signup",pe="/v1/auth/totp/update",fe={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},ge={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},ve={start:"/v1/auth/webauthn/signup-in/start"},be={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},we="/v1/auth/password/signup",me="/v1/auth/password/signin",ye="/v1/auth/password/reset",ke="/v1/auth/password/update",Ie="/v1/auth/password/replace",Oe="/v1/auth/password/policy",je="/v1/auth/refresh",Se="/v1/auth/logout",Ce="/v1/auth/logoutall",Ee="/v1/auth/me",Ae="/v1/flow/start",xe="/v1/flow/next";const Ue=6e5,_e=()=>{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 Pe;!function(t){t.get="GET",t.delete="DELETE",t.post="POST",t.put="PUT"}(Pe||(Pe={}));const Re=(...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}),{})),Te=t=>void 0===t?void 0:JSON.stringify(t),qe=(t,e="")=>{let n=t;return e&&(n=n+":"+e),{Authorization:`Bearer ${n}`}},Me=({baseUrl:t,projectId:e,baseConfig:n,logger:o,hooks:r,cookiePolicy:i,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=>_e().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 _e().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==r?void 0:r.beforeRequest)?r.beforeRequest(o):o,{path:l,body:c,headers:u,queryParams:d,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:d}),{headers:Re(qe(e,p),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"1.3.2"},(null==n?void 0:n.baseHeaders)||{},u),method:h,body:Te(c),credentials:i||"include"});return(null==r?void 0:r.afterRequest)&&await r.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:Pe.get,token:o}),post:(t,e,{headers:n,queryParams:o,token:r}={})=>l({path:t,headers:n,queryParams:o,body:e,method:Pe.post,token:r}),put:(t,e,{headers:n,queryParams:o,token:r}={})=>l({path:t,headers:n,queryParams:o,body:e,method:Pe.put,token:r}),delete:(t,e,{headers:n,queryParams:o,token:r}={})=>l({path:t,headers:n,queryParams:o,body:e,method:Pe.delete,token:r}),hooks:r}};var $e={TOO_MANY_REQUESTS:429};function Le(t,e,n){var o;let r=De(t);e&&(r=null===(o=null==r?void 0:r.tenants)||void 0===o?void 0:o[e]);const i=null==r?void 0:r[n];return Array.isArray(i)?i:[]}function De(t){if("string"!=typeof t||!t)throw new Error("Invalid token provided");return Z(t)}function Ne(t){const{exp:e}=De(t);return(new Date).getTime()/1e3>e}function Ke(t,e){return Le(t,e,"permissions")}function Je(t,e){return Le(t,e,"roles")}const Fe=(...t)=>t.join("/").replace(/\/{2,}/g,"/");async function We(t,e){var n;const o=await t,r={code:o.status,ok:o.ok,response:o},i=await o.clone().json();return o.ok?r.data=e?e(i):i:(r.error=i,o.status===$e.TOO_MANY_REQUESTS&&Object.assign(r.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),r}const He=(t,e)=>(n=e)=>e=>!t(e)&&n.replace("{val}",e),Be=(...t)=>({validate:e=>(t.forEach((t=>{const n=t(e);if(n)throw new Error(n)})),!0)}),Ve=t=>e=>t.test(e),ze=Ve(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Ge=Ve(/^\+[1-9]{1}[0-9]{3,14}$/),Ze=He(ze,'"{val}" is not a valid email'),Qe=He(Ge,'"{val}" is not a valid phone number'),Ye=He((1,t=>t.length>=1),"Minimum length is 1");const Xe=He((t=>"string"==typeof t),"Input is not a string"),tn=(...t)=>e=>(...n)=>(t.forEach(((t,e)=>Be(...t).validate(n[e]))),e(...n)),en=t=>[Xe(`"${t}" must be a string`),Ye(`"${t}" must not be empty`)],nn=t=>[Xe(`"${t}" must be a string`),Ze()],on=t=>[Xe(`"${t}" must be a string`),Qe()],rn=tn(en("accessKey")),sn=t=>({exchange:rn((e=>We(t.post(Wt,{},{token:e}))))});var an,ln;!function(t){t.sms="sms",t.whatsapp="whatsapp"}(an||(an={})),(ln||(ln={})).email="email";const cn=Object.assign(Object.assign({},an),ln);var un;!function(t){t.waiting="waiting",t.running="running",t.completed="completed",t.failed="failed"}(un||(un={}));const dn=en("loginId"),hn=tn(en("token")),pn=tn(dn),fn=tn(en("pendingRef")),gn=tn(dn,nn("email")),vn=t=>({verify:hn((e=>We(t.post(ee,{token:e})))),signIn:pn(((e,n,o,r)=>We(t.post(Fe(ne,cn.email),{loginId:e,URI:n,loginOptions:o},{token:r})))),signUpOrIn:pn(((e,n)=>We(t.post(Fe(se,cn.email),{loginId:e,URI:n})))),signUp:pn(((e,n,o)=>We(t.post(Fe(oe,cn.email),{loginId:e,URI:n,user:o})))),waitForSession:fn(((e,n)=>new Promise((o=>{const{pollingIntervalMs:r,timeoutMs:i}=(({pollingIntervalMs:t=1e3,timeoutMs:e=6e5}={})=>({pollingIntervalMs:Math.max(t||1e3,1e3),timeoutMs:Math.min(e||Ue,Ue)}))(n);let s;const a=setInterval((async()=>{const n=await t.post(re,{pendingRef:e});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(We(Promise.resolve(n))))}),r);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${i}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),i)})))),update:{email:gn(((e,n,o,r,i)=>We(t.post(ie.email,Object.assign({loginId:e,email:n,URI:o},i),{token:r}))))}}),bn=tn(en("flowId")),wn=tn(en("executionId"),en("stepId"),en("interactionId")),mn=t=>({start:bn(((e,n,o,r,i,s)=>We(t.post(Ae,{flowId:e,options:n,conditionInteractionId:o,interactionId:r,input:i,version:s})))),next:wn(((e,n,o,r,i)=>We(t.post(xe,{executionId:e,stepId:n,interactionId:o,input:r,version:i}))))}),yn=en("loginId"),kn=tn(en("token")),In=tn(yn),On=tn(yn,on("phone")),jn=tn(yn,nn("email")),Sn=t=>({verify:kn((e=>We(t.post(Zt,{token:e})))),signIn:Object.keys(cn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:In(((e,o,r,i)=>We(t.post(Fe(Qt,n),{loginId:e,URI:o,loginOptions:r},{token:i}))))})),{}),signUp:Object.keys(cn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:In(((e,o,r)=>We(t.post(Fe(Yt,n),{loginId:e,URI:o,user:r}))))})),{}),signUpOrIn:Object.keys(cn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:In(((e,o)=>We(t.post(Fe(te,n),{loginId:e,URI:o}))))})),{}),update:{email:jn(((e,n,o,r,i)=>We(t.post(Xt.email,Object.assign({loginId:e,email:n,URI:o},i),{token:r})))),phone:Object.keys(an).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:On(((e,o,r,i,s)=>We(t.post(Fe(Xt.phone,n),Object.assign({loginId:e,phone:o,URI:r},s),{token:i}))))})),{})}});var Cn;!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"}(Cn||(Cn={}));const En=tn(en("code")),An=t=>({start:Object.keys(Cn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:(e,o,r)=>We(t.post(ae,o||{},{queryParams:Object.assign({provider:n},e&&{redirectURL:e}),token:r}))})),{}),exchange:En((e=>We(t.post(le,{code:e}))))}),xn=en("loginId"),Un=tn(xn,en("code")),_n=tn(xn),Pn=tn(xn,on("phone")),Rn=tn(xn,nn("email")),Tn=t=>({verify:Object.keys(cn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Un(((e,o)=>We(t.post(Fe(Ht,n),{code:o,loginId:e}))))})),{}),signIn:Object.keys(cn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:_n(((e,o,r)=>We(t.post(Fe(Bt,n),{loginId:e,loginOptions:o},{token:r}))))})),{}),signUp:Object.keys(cn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:_n(((e,o)=>We(t.post(Fe(Vt,n),{loginId:e,user:o}))))})),{}),signUpOrIn:Object.keys(cn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:_n((e=>We(t.post(Fe(Gt,n),{loginId:e}))))})),{}),update:{email:Rn(((e,n,o,r)=>We(t.post(zt.email,Object.assign({loginId:e,email:n},r),{token:o})))),phone:Object.keys(an).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Pn(((e,o,r,i)=>We(t.post(Fe(zt.phone,n),Object.assign({loginId:e,phone:o},i),{token:r}))))})),{})}}),qn=tn(en("tenant")),Mn=tn(en("code")),$n=t=>({start:qn(((e,n,o,r)=>We(t.post(ce,o||{},{queryParams:{tenant:e,redirectURL:n},token:r})))),exchange:Mn((e=>We(t.post(ue,{code:e}))))}),Ln=en("loginId"),Dn=tn(Ln,en("code")),Nn=tn(Ln),Kn=tn(Ln),Jn=t=>({signUp:Nn(((e,n)=>We(t.post(he,{loginId:e,user:n})))),verify:Dn(((e,n,o,r)=>We(t.post(de,{loginId:e,code:n,loginOptions:o},{token:r})))),update:Kn(((e,n)=>We(t.post(pe,{loginId:e},{token:n}))))}),Fn=en("loginId"),Wn=en("newPassword"),Hn=tn(Fn,en("password")),Bn=tn(Fn),Vn=tn(Fn,Wn),zn=tn(Fn,en("oldPassword"),Wn),Gn=t=>({signUp:Hn(((e,n,o)=>We(t.post(we,{loginId:e,password:n,user:o})))),signIn:Hn(((e,n)=>We(t.post(me,{loginId:e,password:n})))),sendReset:Bn(((e,n)=>We(t.post(ye,{loginId:e,redirectUrl:n})))),update:Vn(((e,n,o)=>We(t.post(ke,{loginId:e,newPassword:n},{token:o})))),replace:zn(((e,n,o)=>We(t.post(Ie,{loginId:e,oldPassword:n,newPassword:o})))),policy:()=>We(t.get(Oe))}),Zn=[Xe('"loginId" must be a string')],Qn=en("loginId"),Yn=en("origin"),Xn=tn(Qn,Yn,en("name")),to=tn(Qn,Yn),eo=tn(Zn,Yn),no=tn(Qn,Yn,en("token")),oo=tn(en("transactionId"),en("response")),ro=t=>({signUp:{start:Xn(((e,n,o)=>We(t.post(fe.start,{user:{loginId:e,name:o},origin:n})))),finish:oo(((e,n)=>We(t.post(fe.finish,{transactionId:e,response:n}))))},signIn:{start:eo(((e,n,o,r)=>We(t.post(ge.start,{loginId:e,origin:n,loginOptions:o},{token:r})))),finish:oo(((e,n)=>We(t.post(ge.finish,{transactionId:e,response:n}))))},signUpOrIn:{start:to(((e,n)=>We(t.post(ve.start,{loginId:e,origin:n}))))},update:{start:no(((e,n,o)=>We(t.post(be.start,{loginId:e,origin:n},{token:o})))),finish:oo(((e,n)=>We(t.post(be.finish,{transactionId:e,response:n}))))}}),io=tn(en("token"));var so,ao=tn([("projectId",so=en("projectId"),He(((t,e)=>n=>Be(...e).validate(Ft(n,t)))("projectId",so))())])((t=>{var e,n;const o=[].concat((null===(e=t.hooks)||void 0===e?void 0:e.beforeRequest)||[]),r=[].concat((null===(n=t.hooks)||void 0===n?void 0:n.afterRequest)||[]);return(({projectId:t,logger:e,baseUrl:n,hooks:o,cookiePolicy:r,baseHeaders:i={},fetch:s})=>{return a=Me({baseUrl:n||"https://api.descope.com",projectId:t,logger:e,hooks:o,cookiePolicy:r,baseConfig:{baseHeaders:i},fetch:s}),{accessKey:sn(a),otp:Tn(a),magicLink:Sn(a),enchantedLink:vn(a),oauth:An(a),saml:$n(a),totp:Jn(a),webauthn:ro(a),password:Gn(a),flow:mn(a),refresh:t=>We(a.post(je,{},{token:t})),logout:t=>We(a.post(Se,{},{token:t})),logoutAll:t=>We(a.post(Ce,{},{token:t})),me:t=>We(a.get(Ee,{token:t})),isJwtExpired:io(Ne),getJwtPermissions:io(Ke),getJwtRoles:io(Je),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==r?void 0:r.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 lo=(t,e,n)=>(e.forEach((e=>{const o=e.split(".");let r=o.shift(),i=t;for(;o.length>0;){if(i=i[r],!r||!i)throw Error(`Invalid path "${e}", "${r}" is missing or has no value`);r=o.shift()}if("function"!=typeof i[r])throw Error(`"${e}" is not a function`);const s=i[r];i[r]=n(s)})),t);var co=Object.assign(ao,{DeliveryMethods:cn});var uo="Blocked by CSP",ho="API key required",po="3.8.3",fo="9319";function go(t,e){var n=[];return function(t,e){var n,o,r=(o=function(t,e,n){if(n||2===arguments.length)for(var o,r=0,i=e.length;r<i;r++)!o&&r in e||(o||(o=Array.prototype.slice.call(e,0,r)),o[r]=e[r]);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()}}),i=(100,3e3,n=0,function(){return Math.random()*Math.min(3e3,100*Math.pow(2,n++))}),s=r.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===uo||e===fo}(t)?r.postpone():r.exclude();var e,o=r.current();if(void 0===o)throw t;return(e=i(),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,r=function(){return n.push({url:t,startedAt:o,finishedAt:new Date})},i=e(t);return i.then(r,r),i})).then((function(t){return[t,{attempts:n}]}))}var vo="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",bo="Failed to load the JS script of the agent";function wo(n){var o;n.scriptUrlPattern;var r=n.token,i=n.apiKey,s=void 0===i?r:i,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:vo;return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error(ho);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(po):t}))}(String(t),e)}))}(l,s);return go(t,mo).catch(ko)})).then((function(e){var n=e[0],o=e[1];return n.load(t(t({},a),{ldi:o}))}))}function mo(t){return function(t,e,n,o){var r,i=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||(r=e,l())};i.addEventListener(s,a);var l=function(){return i.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(),r)return function(){throw new Error(uo)}();throw t}))}))}(t,(function(){return function(t){return new Promise((function(e,n){var o=document.createElement("script"),r=function(){var t;return null===(t=o.parentNode)||void 0===t?void 0:t.removeChild(o)},i=document.head||document.getElementsByTagName("head")[0];o.onload=function(){r(),e()},o.onerror=function(){r(),n(new Error(bo))},o.async=!0,o.src=t,i.appendChild(o)}))}(t)})).then(yo)}function yo(){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(fo);return n}function ko(t){throw t instanceof Error&&t.message===fo?new Error(bo):t}
2
- /*! js-cookie v3.0.5 | MIT */function Io(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 Oo=function t(e,n){function o(t,o,r){if("undefined"!=typeof document){"number"==typeof(r=Io({},n,r)).expires&&(r.expires=new Date(Date.now()+864e5*r.expires)),r.expires&&(r.expires=r.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var i="";for(var s in r)r[s]&&(i+="; "+s,!0!==r[s]&&(i+="="+r[s].split(";")[0]));return document.cookie=t+"="+e.write(o,t)+i}}return Object.create({set:o,get:function(t){if("undefined"!=typeof document&&(!arguments.length||t)){for(var n=document.cookie?document.cookie.split("; "):[],o={},r=0;r<n.length;r++){var i=n[r].split("="),s=i.slice(1).join("=");try{var a=decodeURIComponent(i[0]);if(o[a]=e.read(s,a),t===a)break}catch(t){}}return t?o[t]:o}},remove:function(t,e){o(t,"",Io({},e,{expires:-1}))},withAttributes:function(e){return t(this.converter,Io({},this.attributes,e))},withConverter:function(e){return t(Io({},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 jo=(t,e)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,o)=>{var r;return n[o]=[].concat((null===(r=t.hooks)||void 0===r?void 0:r[o])||[]).concat((null==e?void 0:e[o])||[]),n}),null!==(n=t.hooks)&&void 0!==n?n:t.hooks={}),t},So=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||{}},Co=async t=>{const e=await So(t);return(null==e?void 0:e.user)||((null==e?void 0:e.hasOwnProperty("userId"))?e:void 0)},Eo="undefined"!=typeof localStorage,Ao=(t,e)=>Eo&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(t,e)),xo=t=>Eo&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(t)),Uo=t=>Eo&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(t)),_o="undefined"!=typeof window,Po=_o&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://fp.descope.com",Ro=(t="",e="")=>({vsid:t,vrid:e}),To=(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},qo=t=>(t.body&&(t.body.fpData=To(!0)||Ro()),t),Mo="dls_last_user_login_id",$o="dls_last_user_display_name",Lo=()=>xo(Mo),Do=()=>xo($o),No=t=>async(...e)=>{var n;e[1]=e[1]||{};const[,o={}]=e,r=Lo(),i=Do();return r&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=r,o.lastAuth.name=i),await t(...e)},Ko=t=>async(...e)=>{const n=await t(...e);return Uo(Mo),Uo($o),n};function Jo(){const t=[];return{pub:e=>{t.forEach((t=>t(e)))},sub:e=>{const n=t.push(e)-1;return()=>t.splice(n,1)}}}const Fo="DS",Wo="DSR",Ho=(t={},n)=>{var{refreshJwt:o,sessionJwt:r}=t,i=e(t,["refreshJwt","sessionJwt"]);void 0===n&&(n=!1),o&&Ao(Wo,o),r&&(n?function(t,e,{cookiePath:n,cookieDomain:o,cookieExpiration:r}){if(e){const i=new Date(1e3*r);Oo.set(t,e,{path:n,domain:o,expires:i,sameSite:"Strict",secure:!0})}}(Fo,r,i):Ao(Fo,r))};function Bo(){return xo(Wo)||""}function Vo(){return Oo.get(Fo)||xo(Fo)||""}function zo(){Uo(Wo),Uo(Fo),Oo.remove(Fo)}const Go=t=>Object.assign(t,{token:t.token||Bo()}),Zo=t=>async(...e)=>{const n=await t(...e);return zo(),n};async function Qo(t){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=or(n.publicKey.challenge),n.publicKey.user.id=or(n.publicKey.user.id),null===(e=n.publicKey.excludeCredentials)||void 0===e||e.forEach((t=>{t.id=or(t.id)})),n}(t);return n=await navigator.credentials.create(e),JSON.stringify({id:n.id,rawId:rr(n.rawId),type:n.type,response:{attestationObject:rr(n.response.attestationObject),clientDataJSON:rr(n.response.clientDataJSON)}});var n}async function Yo(t){const e=er(t);return nr(await navigator.credentials.get(e))}async function Xo(t,e){const n=er(t);return n.signal=e.signal,n.mediation="conditional",nr(await navigator.credentials.get(n))}async function tr(t=!1){if(!_o)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 er(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=or(n.publicKey.challenge),null===(e=n.publicKey.allowCredentials)||void 0===e||e.forEach((t=>{t.id=or(t.id)})),n}function nr(t){return JSON.stringify({id:t.id,rawId:rr(t.rawId),type:t.type,response:{authenticatorData:rr(t.response.authenticatorData),clientDataJSON:rr(t.response.clientDataJSON),signature:rr(t.response.signature),userHandle:t.response.userHandle?rr(t.response.userHandle):void 0}})}function or(t){const e=t.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(e),(t=>t.charCodeAt(0))).buffer}function rr(t){return btoa(String.fromCharCode.apply(null,new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var ir,sr=(ir=t=>({async signUp(e,n){const o=await t.webauthn.signUp.start(e,window.location.origin,n);if(!o.ok)return o;const r=await Qo(o.data.options);return await t.webauthn.signUp.finish(o.data.transactionId,r)},async signIn(e){const n=await t.webauthn.signIn.start(e,window.location.origin);if(!n.ok)return n;const o=await Yo(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 Qo(o.data.options);return await t.webauthn.signUp.finish(o.data.transactionId,e)}{const e=await Yo(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 r=await Qo(o.data.options);return await t.webauthn.update.finish(o.data.transactionId,r)},helpers:{create:Qo,get:Yo,isSupported:tr,conditional:Xo}}),(...t)=>{const e=ir(...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}),ar=t=>Object.assign(Object.assign({},t.flow),{start:async(...e)=>{const n=await tr(),o=Object.assign(Object.assign({redirectUrl:window.location.href},e[1]),{deviceInfo:{webAuthnSupport:n}});return e[1]=o,t.flow.start(...e)}});const lr=function(...t){return e=>t.reduce(((t,e)=>e(t)),e)}((t=>n=>{var{fpKey:o,fpLoad:r}=n,i=e(n,["fpKey","fpLoad"]);return o?(_o?r&&(async t=>{try{if(To())return;const e=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),n=wo({apiKey:t,endpoint:Po}),o=await n,{requestId:r}=await o.get({linkedId:e});(t=>{const e={value:t,expiry:(new Date).getTime()+864e5};localStorage.setItem("fp",JSON.stringify(e))})(Ro(e,r))}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(jo(i,{beforeRequest:qo}))):t(Object.assign({},i))}),(t=>n=>{var{autoRefresh:o}=n,r=e(n,["autoRefresh"]);if(!o)return t(r);const{clearAllTimers:i,setTimer:s}=(()=>{const t=[];return{clearAllTimers:()=>{for(;t.length;)clearTimeout(t.pop())},setTimer:(e,n)=>{t.push(setTimeout(e,n))}}})(),a=t(jo(r,{afterRequest:async(t,e)=>{const{refreshJwt:n,sessionJwt:o}=await So(e);if(401===(null==e?void 0:e.status))i();else if(o){const t=((r=(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))?r.getTime()-(new Date).getTime():0)-2e4;i(),s((()=>a.refresh(n)),t)}var r}}));return lo(a,["logout","logoutAll"],(t=>async(...e)=>{const n=await t(...e);return i(),n}))}),(t=>e=>t(Object.assign(Object.assign({},e),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.2.2"},e.baseHeaders)}))),(t=>e=>{const n=Jo(),o=Jo(),r=t(jo(e,{afterRequest:async(t,e)=>{if(401===(null==e?void 0:e.status))n.pub(null),o.pub(null);else{const t=await Co(e);t&&o.pub(t);const{sessionJwt:r}=await So(e);r&&n.pub(r)}}})),i=lo(r,["logout","logoutAll"],(t=>async(...e)=>{const r=await t(...e);return n.pub(null),o.pub(null),r}));return Object.assign(i,{onSessionTokenChange:n.sub,onUserChange:o.sub})}),(t=>e=>{const n=t(jo(e,{afterRequest:async(t,e)=>{var n;const o=await Co(e),r=null===(n=null==o?void 0:o.loginIds)||void 0===n?void 0:n[0],i=null==o?void 0:o.name;r&&((t=>{Ao(Mo,t)})(r),(t=>{Ao($o,t)})(i))}}));let o=lo(n,["flow.start"],No);return o=lo(o,["logout","logoutAll"],Ko),Object.assign(o,{getLastUserLoginId:Lo,getLastUserDisplayName:Do})}),(t=>n=>{var{persistTokens:o,sessionTokenViaCookie:r}=n,i=e(n,["persistTokens","sessionTokenViaCookie"]);if(!o||!_o)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(i);const s=t(jo(i,{beforeRequest:Go,afterRequest:async(t,e)=>{401===(null==e?void 0:e.status)?zo():Ho(await So(e),r)}})),a=lo(s,["logout","logoutAll"],Zo);return Object.assign(a,{getRefreshToken:Bo,getSessionToken:Vo})}))(((...t)=>{const e=co(...t);return Object.assign(Object.assign({},e),{flow:ar(e),webauthn:sr(e)})})),cr=document.createElement("template");var ur,dr,hr,pr,fr,gr,vr,br,wr,mr,yr,kr,Ir,Or,jr,Sr,Cr,Er,Ar,xr,Ur,_r,Pr,Rr,Tr,qr,Mr,$r,Lr,Dr,Nr,Kr,Jr,Fr,Wr,Hr,Br,Vr;cr.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 zr extends HTMLElement{constructor(t){super(),ur.add(this),dr.set(this,!1),hr.set(this,new F),pr.set(this,new F),this.nextRequestStatus=new F({isLoading:!1}),fr.set(this,void 0),gr.set(this,{popstate:o(this,ur,"m",kr).bind(this)}),vr.set(this,void 0),jr.set(this,M((()=>n(this,void 0,void 0,(function*(){const t=U(this.projectId,"config.json");try{const{body:e,headers:n}=yield A(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,ur,"m",_r).call(this,t,e)},info:(t,e="")=>{console.log(t,e)}},r(this,vr,t,"f"),o(this,ur,"m",br).call(this)}static get observedAttributes(){return["project-id","flow-id","base-url","tenant","theme","debug","telemetryKey","redirect-url","auto-focus"]}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}getExecutionContext(){return n(this,void 0,void 0,(function*(){const{executionContext:t}=yield o(this,jr,"f").call(this);return t}))}getFlowConfig(){var t,e;return n(this,void 0,void 0,(function*(){const{projectConfig:n}=yield o(this,jr,"f").call(this),r=(null===(t=null==n?void 0:n.flows)||void 0===t?void 0:t[this.flowId])||{};return null!==(e=r.version)&&void 0!==e||(r.version=0),r}))}connectedCallback(){return n(this,void 0,void 0,(function*(){if(this.shadowRoot.isConnected){if(o(this,ur,"m",wr).call(this))return void o(this,ur,"m",mr).call(this);o(this,ur,"m",yr).call(this),o(this,ur,"m",Cr).call(this),o(this,ur,"m",Sr).call(this),o(this,ur,"m",Pr).call(this);const{executionId:t,stepId:e,token:n,code:i,exchangeError:s,redirectAuthCallbackUrl:a,redirectAuthCodeChallenge:l}=q();window.addEventListener("popstate",o(this,gr,"f").popstate),o(this,hr,"f").subscribe(o(this,ur,"m",Or).bind(this)),o(this,pr,"f").subscribe(o(this,ur,"m",Ur).bind(this)),o(this,hr,"f").update({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenant,redirectUrl:this.redirectUrl,stepId:e,executionId:t,token:n,code:i,exchangeError:s,telemetryKey:this.telemetryKey,redirectAuthCallbackUrl:a,redirectAuthCodeChallenge:l}),o(this,pr,"f").update({isDebug:this.debug}),r(this,dr,!0,"f")}}))}disconnectedCallback(){o(this,hr,"f").unsubscribeAll(),o(this,pr,"f").unsubscribeAll(),o(this,ur,"m",xr).call(this),window.removeEventListener("popstate",o(this,gr,"f").popstate)}attributeChangedCallback(t,e,n){if(this.shadowRoot.isConnected&&o(this,dr,"f")&&e!==n&&zr.observedAttributes.includes(t)){o(this,ur,"m",yr).call(this);const r=null===e;o(this,hr,"f").update((({stepId:e,executionId:o})=>{let i=e,s=o;return r||(s=null,i=null,R()),{[T(t)]:n,stepId:i,executionId:s}})),o(this,pr,"f").update({isDebug:this.debug})}}}dr=new WeakMap,hr=new WeakMap,pr=new WeakMap,fr=new WeakMap,gr=new WeakMap,vr=new WeakMap,jr=new WeakMap,ur=new WeakSet,br=function(){this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(cr.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#wc-root")},wr=function(){const t=/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor);return!this.shadowRoot.host.closest("form")&&t},mr=function(){const t=this.shadowRoot.host,e=document.createElement("form");t.parentElement.appendChild(e),e.appendChild(t)},yr=function(){const t=["base-url","tenant","theme","debug","telemetryKey","redirect-url","auto-focus"];if(zr.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[T(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')},kr=function(){const{stepId:t,executionId:e}=P();o(this,hr,"f").update({stepId:t,executionId:e})},Ir=function(t,e,o){const r=o||void 0,i=!!r;this.sdk=lr(Object.assign(Object.assign({persistTokens:!0},zr.sdkConfigOverrides),{projectId:t,baseUrl:e,fpKey:r,fpLoad:i})),["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})}}))}))},Or=function(t,e,r){return n(this,void 0,void 0,(function*(){const{projectId:e,baseUrl:n,telemetryKey:i}=t;if(r("projectId")||r("baseUrl")||r("telemetryKey")){if(!e)return;o(this,ur,"m",Ir).call(this,e,n,i)}o(this,vr,"f").call(this,t)}))},Sr=function(){var t,e,r,i;return n(this,void 0,void 0,(function*(){const{projectConfig:n}=yield o(this,jr,"f").call(this);null===(i=null===(r=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===r?void 0:r.fontFamilies)||void 0===i||i.forEach((t=>(t=>{if(!t)return;const e=document.createElement("link");e.href=t,e.rel="stylesheet",document.head.appendChild(e)})(t.url)))}))},Cr=function(){o(this,ur,"m",Er).call(this),o(this,ur,"m",Ar).call(this)},Er=function(){return n(this,void 0,void 0,(function*(){const t=document.createElement("style"),e=U(this.projectId,"theme.css");try{const{body:n}=yield A(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)}))},Ar=function(){this.rootElement.setAttribute("data-theme",this.theme)},xr=function(){var t;null===(t=o(this,fr,"f"))||void 0===t||t.remove(),r(this,fr,null,"f")},Ur=function({isDebug:t}){return n(this,void 0,void 0,(function*(){t?(yield import("./debugger-wc-47b70d7e.js"),r(this,fr,document.createElement("descope-debugger"),"f"),Object.assign(o(this,fr,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),document.body.appendChild(o(this,fr,"f"))):o(this,ur,"m",xr).call(this)}))},_r=function(t,e){var n;t&&this.debug&&(null===(n=o(this,fr,"f"))||void 0===n||n.updateData({title:t,description:e}))},Pr=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()}},zr.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"2.3.2"}};class Gr extends zr{constructor(){const t=new F;super(t.update.bind(t)),Rr.add(this),this.stepState=new F({},{updateOnlyOnChange:!1}),Tr.set(this,void 0),qr.set(this,null),Mr.set(this,(()=>{clearInterval(o(this,Tr,"f")),r(this,Tr,null,"f")})),$r.set(this,(t=>{var e,n,r,s,a,l,c,u,d;if(!(null==t?void 0:t.ok)){o(this,Mr,"f").call(this),o(this,Rr,"m",Vr).call(this,"error",null==t?void 0:t.error);const i=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===(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)||i,(null===(a=null==t?void 0:t.error)||void 0===a?void 0:a.errorMessage)||l)}const h=null===(u=null===(c=null===(l=t.data)||void 0===l?void 0:l.screen)||void 0===c?void 0:c.state)||void 0===u?void 0:u.errorText;h&&this.logger.error(h),(null===(d=t.data)||void 0===d?void 0:d.error)&&this.logger.error(`[${t.data.error.code}]: ${t.data.error.description}`,t.data.error.message);const{status:p,authInfo:g,lastAuth:v}=t.data;if("completed"===p)return function(t){(null==t?void 0:t.authMethod)&&i&&localStorage.setItem(f,JSON.stringify(t))}(v),o(this,Mr,"f").call(this),void o(this,Rr,"m",Vr).call(this,"success",g);const{executionId:w,stepId:m,action:y,screen:k,redirect:I,webauthn:O}=t.data;y!==b?this.flowState.update({stepId:m,executionId:w,action:y,redirectTo:null==I?void 0:I.url,screenId:null==k?void 0:k.id,screenState:null==k?void 0:k.state,webauthnTransactionId:null==O?void 0:O.transactionId,webauthnOptions:null==O?void 0:O.options}):this.flowState.update({action:y})})),Lr.set(this,M((()=>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}static set sdkConfigOverrides(t){zr.sdkConfigOverrides=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,i){var s,a;return n(this,void 0,void 0,(function*(){const{projectId:l,flowId:c,tenant:u,stepId:d,executionId:h,action:p,screenId:g,screenState:y,redirectTo:O,redirectUrl:j,token:S,code:C,exchangeError:E,webauthnTransactionId:A,webauthnOptions:x,redirectAuthCodeChallenge:P,redirectAuthCallbackUrl:R}=t;let T,q;o(this,Tr,"f")&&o(this,Mr,"f").call(this);const M=this.sdk.getLastUserLoginId(),$=yield this.getFlowConfig(),L=R&&P?{callbackUrl:R,codeChallenge:P}:void 0;if(!h&&($.conditions?({startScreenId:T,conditionInteractionId:q}=((t,e)=>{const n=null==e?void 0:e.find((({key:e,operator:n})=>{var o;if("ELSE"===e)return!0;const r=null===(o=B[e])||void 0===o?void 0:o[n];return!!(null==r?void 0:r(t))}));return n?{startScreenId:n.met.screenId,conditionInteractionId:n.met.interactionId}:{}})({loginId:M,code:C},$.conditions)):$.condition?({startScreenId:T,conditionInteractionId:q}=((t,e)=>{var n;const o=null===(n=B[null==t?void 0:t.key])||void 0===n?void 0:n[t.operator];if(!o)return{};const r=o(e)?t.met:t.unmet;return{startScreenId:null==r?void 0:r.screenId,conditionInteractionId:null==r?void 0:r.interactionId}})($.condition,{loginId:M,code:C})):T=$.startScreenId,!T)){const t=C?{exchangeCode:C,idpInitiated:!0}:void 0,e=yield this.sdk.flow.start(c,Object.assign({tenant:u,redirectAuth:L},j&&{redirectUrl:j}),q,"",t,$.version);return o(this,$r,"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(h&&(i("token")&&S||i("code")&&C||i("exchangeError")&&E)){const t=yield this.sdk.flow.next(h,d,k,{token:S,exchangeCode:C,exchangeError:E},$.version);return o(this,$r,"f").call(this,t),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(p===v)return O||this.logger.error("Did not get redirect url"),void window.location.assign(O);if(p===w||p===m){if(!A||!x)return void this.logger.error("Did not get webauthn transaction id or options");let t,e;null===(a=o(this,qr,"f"))||void 0===a||a.abort(),r(this,qr,null,"f");try{t=p===w?yield this.sdk.webauthn.helpers.create(x):yield this.sdk.webauthn.helpers.get(x)}catch(t){if("NotAllowedError"!==t.name)return void this.logger.error(t.message);e=!0}const n=yield this.sdk.flow.next(h,d,k,{transactionId:A,response:t,cancelWebauthn:e},$.version);o(this,$r,"f").call(this,n)}if(p===b&&r(this,Tr,setInterval((()=>n(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(h,d,I,{},$.version);o(this,$r,"f").call(this,t)}))),2e3),"f"),!g&&!T)return void this.logger.info("Refreshing the page during a flow is not supported yet");const D={direction:_(+d,+e.stepId),screenState:Object.assign(Object.assign({},y),{lastAuth:{loginId:M,name:this.sdk.getLastUserDisplayName()||M}}),htmlUrl:U(l,`${T||g}.html`)},N=function(t){const e={};if(t)try{Object.assign(e,JSON.parse(localStorage.getItem(f)))}catch(t){}return e}(M);T?D.next=(t,e)=>this.sdk.flow.start(c,Object.assign({tenant:u,redirectAuth:L,lastAuth:N},j&&{redirectUrl:j}),q,t,Object.assign(Object.assign({},e),C&&{exchangeCode:C,idpInitiated:!0}),$.version):(i("projectId")||i("baseUrl")||i("executionId")||i("stepId"))&&(D.next=(...t)=>this.sdk.flow.next(h,d,...t)),this.stepState.update(D)}))}onStepChange(t,e){var r;return n(this,void 0,void 0,(function*(){const{htmlUrl:i,direction:s,next:a,screenState:l}=t,c=document.createElement("template"),{body:u}=yield A(i,"text");c.innerHTML=u;const d=c.content.cloneNode(!0),h=((t,e)=>{var n;const o=Array.from(t.querySelectorAll("script[data-id]")).map((n=>{var o;const r=n.getAttribute("data-id"),i=null===(o=t.getElementById(r))||void 0===o?void 0:o.innerHTML,s=Function(i).bind(n.previousSibling,e);return n.remove(),s}));return null===(n=t.querySelector("scripts"))||void 0===n||n.remove(),o})(d,yield this.getExecutionContext());this.sdk.webauthn.helpers.isSupported()?yield o(this,Rr,"m",Nr).call(this,d,a):d.querySelectorAll(`button[${g}="biometrics"]`).forEach((t=>t.setAttribute("disabled","true"))),W(d,l),((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})`))})(d.querySelector("div"),null===(r=null==l?void 0:l.totp)||void 0===r?void 0:r.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(d);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,Rr,"m",Hr).call(this,a),o(this,Rr,"m",Vr).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${g}="polling"]`)){const t=yield a(I,{});o(this,$r,"f").call(this,t)}}));s?o(this,Rr,"m",Br).call(this,p,s):p()}))}}Tr=new WeakMap,qr=new WeakMap,Mr=new WeakMap,$r=new WeakMap,Lr=new WeakMap,Rr=new WeakSet,Dr=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}))}},Nr=function(t,e){var i;return n(this,void 0,void 0,(function*(){null===(i=o(this,qr,"f"))||void 0===i||i.abort();const s=t.querySelector('input[autocomplete="webauthn"]');if(s&&(yield H())){const{options:t,transactionId:i}=(yield o(this,Lr,"f").call(this))||{};t&&i&&(o(this,Rr,"m",Dr).call(this,s),r(this,qr,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(t,o(this,qr,"f")).then((t=>n(this,void 0,void 0,(function*(){const n=yield e(s.id,{transactionId:i,response:t});o(this,$r,"f").call(this,n)})))).catch((t=>{"AbortError"!==t.name&&this.logger.error("Conditional login failed",t.message)})))}}))},Kr=function(){return Array.from(this.shadowRoot.querySelectorAll(".descope-input")).every((t=>(t.reportValidity(),t.checkValidity())))},Jr=function(){return Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${p}])`)).reduce(((t,e)=>e.name?Object.assign(t,{[e.name]:e["checkbox"===e.type?"checked":"value"]}):t),{})},Fr=function(t){const e=this.nextRequestStatus.subscribe((({isLoading:n})=>{var o,r;n?null===(o=null==t?void 0:t.classList)||void 0===o||o.add("loading"):(this.nextRequestStatus.unsubscribe(e),null===(r=null==t?void 0:t.classList)||void 0===r||r.remove("loading"))}))},Wr=function(t,e){return n(this,void 0,void 0,(function*(){if(t.formNoValidate||o(this,Rr,"m",Kr).call(this)){const r=null==t?void 0:t.getAttribute("id");o(this,Rr,"m",Fr).call(this,t);const i=o(this,Rr,"m",Jr).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),i),{origin:window.location.origin}),l=yield e(r,a);o(this,$r,"f").call(this,l)}var n}))},Hr=function(t){this.rootElement.querySelectorAll("button").forEach((e=>{e.onclick=()=>{o(this,Rr,"m",Wr).call(this,e,t)}}))},Br=function(t,e){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),t()}),{once:!0});const n=e===O.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")},Vr=function(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))},customElements.define("descope-wc",Gr);export{Gr as D,F as S,o as _,r as a};
1
+ var t=function(){return t=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);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 r=0;for(o=Object.getOwnPropertySymbols(t);r<o.length;r++)e.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(n[o[r]]=t[o[r]])}return n}function n(t,e,n,o){return new(n||(n=Promise))((function(r,i){function s(t){try{l(o.next(t))}catch(t){i(t)}}function a(t){try{l(o.throw(t))}catch(t){i(t)}}function l(t){var e;t.done?r(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 r(t,e,n,o,r){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?r.call(t,n):r?r.value=n:e.set(t,n),n}const i="undefined"!=typeof localStorage,s=i&&localStorage.getItem("base.content.url")||"https://static.descope.com/pages",a="descope-login-flow",l="t",c="code",u="err",d="ra-challenge",h="ra-callback",p="data-exclude-field",f="dls_last_auth",g="data-type",v="redirect",b="poll",w="webauthnCreate",m="webauthnGet",y="v2-alpha",k="submit",I="polling";var O,j,S;function C(t){return new URLSearchParams(window.location.search).get(t)}function E(t){if(window.history.replaceState&&C(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 A(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"}(O||(O={}));const x=(...t)=>t.join("/").replace(/\/+/g,"/");function U(t,e){const n=new URL(s);return n.pathname=x(n.pathname,t,y,e),n.toString()}function _(t,e){if(!Number.isNaN(t)&&!Number.isNaN(e))return t>e?O.forward:t<e?O.backward:void 0}const P=()=>{const[t="",e=""]=(C(a)||"").split("_");return{executionId:t,stepId:e}};function R(){E(a)}const T=t=>t.replace(/-./g,(t=>t[1].toUpperCase())),q=()=>{const{executionId:t,stepId:e}=P();(t||e)&&R();const n=C(l)||void 0;n&&E(l);const o=C(c)||void 0;o&&E(c);const r=C(u)||void 0;r&&E(u);const{redirectAuthCodeChallenge:i,redirectAuthCallbackUrl:s}={redirectAuthCodeChallenge:C(d),redirectAuthCallbackUrl:C(h)};return(i||s)&&(E(d),E(h)),{executionId:t,stepId:e,token:n,code:o,exchangeError:r,redirectAuthCodeChallenge:i,redirectAuthCallbackUrl:s}},M=t=>{let e,n;return(...o)=>{return e&&(i=o,(r=e).length===i.length&&r.every(((t,e)=>t===i[e])))||(e=o,n=t(...o)),n;var r,i}},$=null===(S=null===(j=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===j?void 0:j.brands)||void 0===S?void 0:S.find((({brand:t,version:e})=>"Chromium"===t&&parseFloat(e)));var L,D,N,K;function J(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 r=n[o],i=t[r],s=e[r];if(null===i||null===s){if(i!==s)return!1}else if("object"==typeof i&&"object"==typeof s){if(!J(i,s))return!1}else if(i!==s)return!1}return!0}class F{constructor(t={},{updateOnlyOnChange:e=!0}={}){L.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,L,"f")):t,n=Object.assign(Object.assign({},o(this,L,"f")),e);if(!o(this,K,"f")||!J(o(this,L,"f"),n)){const t=o(this,L,"f");r(this,L,n,"f"),Object.freeze(o(this,L,"f")),setTimeout((()=>{Object.values(o(this,D,"f")).forEach((e=>e(n,t,((t,e)=>n=>t[n]!==e[n])(n,t))))}),0)}},r(this,L,t,"f"),r(this,K,e,"f")}get current(){return Object.assign({},o(this,L,"f"))}subscribe(t){return r(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 r(this,D,{},"f"),!0}}L=new WeakMap,D=new WeakMap,N=new WeakMap,K=new WeakMap;const W=(t,e)=>{var n;((t,e,n="")=>{t.querySelectorAll(`[${g}="${e}"]`).forEach((t=>{t.textContent=n,t.classList[n?"remove":"add"]("hide")}))})(t,"error-message",null==e?void 0:e.errorText),((t,e)=>{Object.entries(e||{}).forEach((([e,n])=>{Array.from(t.querySelectorAll(`.descope-input[name="${e}"]:not([${p}])`)).forEach((t=>{t.value=n}))}))})(t,null==e?void 0:e.inputs),((t,e)=>{t.querySelectorAll(`[${g}="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,n)=>{return o=e,n.split(".").reduce(((t,e)=>(null==t?void 0:t[e])||""),o);var o})))(t.textContent,e)}))})(t,e)},H=M((()=>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 r=Promise.all([null===(t=window.PublicKeyCredential)||void 0===t?void 0:t.isConditionalMediationAvailable(),null===(e=window.PublicKeyCredential)||void 0===e?void 0:e.isUserVerifyingPlatformAuthenticatorAvailable()]).then((t=>t.every((t=>!!t)))),i=108;return yield Promise.race([r,(n=100,new Promise(((t,e)=>{const r=setTimeout((()=>{e(new Error(`Promise timed out after ${n} ms`))}),n);null==o||o((e=>{clearTimeout(r),t(e)}),(t=>{clearTimeout(r),e(t)}))}))).catch((()=>$()>=i))])}catch(t){return console.warn("webauthn","Conditional login check failed",t),!1}})))),B={"lastAuth.loginId":{"not-empty":t=>!!t.loginId,empty:t=>!t.loginId},idpInitiated:{"is-true":t=>!!t.code,"is-false":t=>!t.code}};function V(t){this.message=t}V.prototype=new Error,V.prototype.name="InvalidCharacterError";var z="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new V("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,o,r=0,i=0,s="";o=e.charAt(i++);~o&&(n=r%4?64*n+o:o,r++%4)?s+=String.fromCharCode(255&n>>(-2*r&6)):0)o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);return s};function G(t){this.message=t}function Z(t,e){if("string"!=typeof t)throw new G("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(z(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 z(e)}}(t.split(".")[n]))}catch(t){throw new G("Invalid token specified: "+t.message)}}G.prototype=new Error,G.prototype.name="InvalidTokenError";var Q="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},Y="Expected a function",X="__lodash_hash_undefined__",tt=1/0,et="[object Function]",nt="[object GeneratorFunction]",ot="[object Symbol]",rt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,it=/^\w*$/,st=/^\./,at=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,lt=/\\(\\)?/g,ct=/^\[object .+?Constructor\]$/,ut="object"==typeof Q&&Q&&Q.Object===Object&&Q,dt="object"==typeof self&&self&&self.Object===Object&&self,ht=ut||dt||Function("return this")();var pt,ft=Array.prototype,gt=Function.prototype,vt=Object.prototype,bt=ht["__core-js_shared__"],wt=(pt=/[^.]+$/.exec(bt&&bt.keys&&bt.keys.IE_PROTO||""))?"Symbol(src)_1."+pt:"",mt=gt.toString,yt=vt.hasOwnProperty,kt=vt.toString,It=RegExp("^"+mt.call(yt).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ot=ht.Symbol,jt=ft.splice,St=Mt(ht,"Map"),Ct=Mt(Object,"create"),Et=Ot?Ot.prototype:void 0,At=Et?Et.toString:void 0;function xt(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 Ut(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 _t(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,e){for(var n,o,r=t.length;r--;)if((n=t[r][0])===(o=e)||n!=n&&o!=o)return r;return-1}function Rt(t,e){var n;e=function(t,e){if(Nt(t))return!1;var n=typeof t;if("number"==n||"symbol"==n||"boolean"==n||null==t||Jt(t))return!0;return it.test(t)||!rt.test(t)||null!=e&&t in Object(e)}(e,t)?[e]:Nt(n=e)?n:$t(n);for(var o=0,r=e.length;null!=t&&o<r;)t=t[Lt(e[o++])];return o&&o==r?t:void 0}function Tt(t){if(!Kt(t)||(e=t,wt&&wt in e))return!1;var e,n=function(t){var e=Kt(t)?kt.call(t):"";return e==et||e==nt}(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t)?It:ct;return n.test(function(t){if(null!=t){try{return mt.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}function qt(t,e){var n,o,r=t.__data__;return("string"==(o=typeof(n=e))||"number"==o||"symbol"==o||"boolean"==o?"__proto__"!==n:null===n)?r["string"==typeof e?"string":"hash"]:r.map}function Mt(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return Tt(n)?n:void 0}xt.prototype.clear=function(){this.__data__=Ct?Ct(null):{}},xt.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},xt.prototype.get=function(t){var e=this.__data__;if(Ct){var n=e[t];return n===X?void 0:n}return yt.call(e,t)?e[t]:void 0},xt.prototype.has=function(t){var e=this.__data__;return Ct?void 0!==e[t]:yt.call(e,t)},xt.prototype.set=function(t,e){return this.__data__[t]=Ct&&void 0===e?X:e,this},Ut.prototype.clear=function(){this.__data__=[]},Ut.prototype.delete=function(t){var e=this.__data__,n=Pt(e,t);return!(n<0)&&(n==e.length-1?e.pop():jt.call(e,n,1),!0)},Ut.prototype.get=function(t){var e=this.__data__,n=Pt(e,t);return n<0?void 0:e[n][1]},Ut.prototype.has=function(t){return Pt(this.__data__,t)>-1},Ut.prototype.set=function(t,e){var n=this.__data__,o=Pt(n,t);return o<0?n.push([t,e]):n[o][1]=e,this},_t.prototype.clear=function(){this.__data__={hash:new xt,map:new(St||Ut),string:new xt}},_t.prototype.delete=function(t){return qt(this,t).delete(t)},_t.prototype.get=function(t){return qt(this,t).get(t)},_t.prototype.has=function(t){return qt(this,t).has(t)},_t.prototype.set=function(t,e){return qt(this,t).set(t,e),this};var $t=Dt((function(t){var e;t=null==(e=t)?"":function(t){if("string"==typeof t)return t;if(Jt(t))return At?At.call(t):"";var e=t+"";return"0"==e&&1/t==-tt?"-0":e}(e);var n=[];return st.test(t)&&n.push(""),t.replace(at,(function(t,e,o,r){n.push(o?r.replace(lt,"$1"):e||t)})),n}));function Lt(t){if("string"==typeof t||Jt(t))return t;var e=t+"";return"0"==e&&1/t==-tt?"-0":e}function Dt(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError(Y);var n=function(){var o=arguments,r=e?e.apply(this,o):o[0],i=n.cache;if(i.has(r))return i.get(r);var s=t.apply(this,o);return n.cache=i.set(r,s),s};return n.cache=new(Dt.Cache||_t),n}Dt.Cache=_t;var Nt=Array.isArray;function Kt(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)&&kt.call(t)==ot}var Ft=function(t,e,n){var o=null==t?void 0:Rt(t,e);return void 0===o?n:o},Wt="/v1/auth/accesskey/exchange",Ht="/v1/auth/otp/verify",Bt="/v1/auth/otp/signin",Vt="/v1/auth/otp/signup",zt={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},Gt="/v1/auth/otp/signup-in",Zt="/v1/auth/magiclink/verify",Qt="/v1/auth/magiclink/signin",Yt="/v1/auth/magiclink/signup",Xt={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},te="/v1/auth/magiclink/signup-in",ee="/v1/auth/enchantedlink/verify",ne="/v1/auth/enchantedlink/signin",oe="/v1/auth/enchantedlink/signup",re="/v1/auth/enchantedlink/pending-session",ie={email:"/v1/auth/enchantedlink/update/email"},se="/v1/auth/enchantedlink/signup-in",ae="/v1/auth/oauth/authorize",le="/v1/auth/oauth/exchange",ce="/v1/auth/saml/authorize",ue="/v1/auth/saml/exchange",de="/v1/auth/totp/verify",he="/v1/auth/totp/signup",pe="/v1/auth/totp/update",fe={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},ge={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},ve={start:"/v1/auth/webauthn/signup-in/start"},be={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},we="/v1/auth/password/signup",me="/v1/auth/password/signin",ye="/v1/auth/password/reset",ke="/v1/auth/password/update",Ie="/v1/auth/password/replace",Oe="/v1/auth/password/policy",je="/v1/auth/refresh",Se="/v1/auth/logout",Ce="/v1/auth/logoutall",Ee="/v1/auth/me",Ae="/v1/flow/start",xe="/v1/flow/next";const Ue=6e5,_e=()=>{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 Pe;!function(t){t.get="GET",t.delete="DELETE",t.post="POST",t.put="PUT"}(Pe||(Pe={}));const Re=(...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}),{})),Te=t=>void 0===t?void 0:JSON.stringify(t),qe=(t,e="")=>{let n=t;return e&&(n=n+":"+e),{Authorization:`Bearer ${n}`}},Me=({baseUrl:t,projectId:e,baseConfig:n,logger:o,hooks:r,cookiePolicy:i,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=>_e().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 _e().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==r?void 0:r.beforeRequest)?r.beforeRequest(o):o,{path:l,body:c,headers:u,queryParams:d,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:d}),{headers:Re(qe(e,p),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"1.3.3"},(null==n?void 0:n.baseHeaders)||{},u),method:h,body:Te(c),credentials:i||"include"});return(null==r?void 0:r.afterRequest)&&await r.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:Pe.get,token:o}),post:(t,e,{headers:n,queryParams:o,token:r}={})=>l({path:t,headers:n,queryParams:o,body:e,method:Pe.post,token:r}),put:(t,e,{headers:n,queryParams:o,token:r}={})=>l({path:t,headers:n,queryParams:o,body:e,method:Pe.put,token:r}),delete:(t,e,{headers:n,queryParams:o,token:r}={})=>l({path:t,headers:n,queryParams:o,body:e,method:Pe.delete,token:r}),hooks:r}};var $e={TOO_MANY_REQUESTS:429};function Le(t,e,n){var o;let r=De(t);e&&(r=null===(o=null==r?void 0:r.tenants)||void 0===o?void 0:o[e]);const i=null==r?void 0:r[n];return Array.isArray(i)?i:[]}function De(t){if("string"!=typeof t||!t)throw new Error("Invalid token provided");return Z(t)}function Ne(t){const{exp:e}=De(t);return(new Date).getTime()/1e3>e}function Ke(t,e){return Le(t,e,"permissions")}function Je(t,e){return Le(t,e,"roles")}const Fe=(...t)=>t.join("/").replace(/\/{2,}/g,"/");async function We(t,e){var n;const o=await t,r={code:o.status,ok:o.ok,response:o},i=await o.clone().json();return o.ok?r.data=e?e(i):i:(r.error=i,o.status===$e.TOO_MANY_REQUESTS&&Object.assign(r.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),r}const He=(t,e)=>(n=e)=>e=>!t(e)&&n.replace("{val}",e),Be=(...t)=>({validate:e=>(t.forEach((t=>{const n=t(e);if(n)throw new Error(n)})),!0)}),Ve=t=>e=>t.test(e),ze=Ve(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Ge=Ve(/^\+[1-9]{1}[0-9]{3,14}$/),Ze=He(ze,'"{val}" is not a valid email'),Qe=He(Ge,'"{val}" is not a valid phone number'),Ye=He((1,t=>t.length>=1),"Minimum length is 1");const Xe=He((t=>"string"==typeof t),"Input is not a string"),tn=(...t)=>e=>(...n)=>(t.forEach(((t,e)=>Be(...t).validate(n[e]))),e(...n)),en=t=>[Xe(`"${t}" must be a string`),Ye(`"${t}" must not be empty`)],nn=t=>[Xe(`"${t}" must be a string`),Ze()],on=t=>[Xe(`"${t}" must be a string`),Qe()],rn=tn(en("accessKey")),sn=t=>({exchange:rn((e=>We(t.post(Wt,{},{token:e}))))});var an,ln;!function(t){t.sms="sms",t.whatsapp="whatsapp"}(an||(an={})),(ln||(ln={})).email="email";const cn=Object.assign(Object.assign({},an),ln);var un;!function(t){t.waiting="waiting",t.running="running",t.completed="completed",t.failed="failed"}(un||(un={}));const dn=en("loginId"),hn=tn(en("token")),pn=tn(dn),fn=tn(en("pendingRef")),gn=tn(dn,nn("email")),vn=t=>({verify:hn((e=>We(t.post(ee,{token:e})))),signIn:pn(((e,n,o,r)=>We(t.post(Fe(ne,cn.email),{loginId:e,URI:n,loginOptions:o},{token:r})))),signUpOrIn:pn(((e,n)=>We(t.post(Fe(se,cn.email),{loginId:e,URI:n})))),signUp:pn(((e,n,o)=>We(t.post(Fe(oe,cn.email),{loginId:e,URI:n,user:o})))),waitForSession:fn(((e,n)=>new Promise((o=>{const{pollingIntervalMs:r,timeoutMs:i}=(({pollingIntervalMs:t=1e3,timeoutMs:e=6e5}={})=>({pollingIntervalMs:Math.max(t||1e3,1e3),timeoutMs:Math.min(e||Ue,Ue)}))(n);let s;const a=setInterval((async()=>{const n=await t.post(re,{pendingRef:e});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(We(Promise.resolve(n))))}),r);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${i}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),i)})))),update:{email:gn(((e,n,o,r,i)=>We(t.post(ie.email,Object.assign({loginId:e,email:n,URI:o},i),{token:r}))))}}),bn=tn(en("flowId")),wn=tn(en("executionId"),en("stepId"),en("interactionId")),mn=t=>({start:bn(((e,n,o,r,i,s)=>We(t.post(Ae,{flowId:e,options:n,conditionInteractionId:o,interactionId:r,input:i,version:s})))),next:wn(((e,n,o,r,i)=>We(t.post(xe,{executionId:e,stepId:n,interactionId:o,input:r,version:i}))))}),yn=en("loginId"),kn=tn(en("token")),In=tn(yn),On=tn(yn,on("phone")),jn=tn(yn,nn("email")),Sn=t=>({verify:kn((e=>We(t.post(Zt,{token:e})))),signIn:Object.keys(cn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:In(((e,o,r,i)=>We(t.post(Fe(Qt,n),{loginId:e,URI:o,loginOptions:r},{token:i}))))})),{}),signUp:Object.keys(cn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:In(((e,o,r)=>We(t.post(Fe(Yt,n),{loginId:e,URI:o,user:r}))))})),{}),signUpOrIn:Object.keys(cn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:In(((e,o)=>We(t.post(Fe(te,n),{loginId:e,URI:o}))))})),{}),update:{email:jn(((e,n,o,r,i)=>We(t.post(Xt.email,Object.assign({loginId:e,email:n,URI:o},i),{token:r})))),phone:Object.keys(an).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:On(((e,o,r,i,s)=>We(t.post(Fe(Xt.phone,n),Object.assign({loginId:e,phone:o,URI:r},s),{token:i}))))})),{})}});var Cn;!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"}(Cn||(Cn={}));const En=tn(en("code")),An=t=>({start:Object.keys(Cn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:(e,o,r)=>We(t.post(ae,o||{},{queryParams:Object.assign({provider:n},e&&{redirectURL:e}),token:r}))})),{}),exchange:En((e=>We(t.post(le,{code:e}))))}),xn=en("loginId"),Un=tn(xn,en("code")),_n=tn(xn),Pn=tn(xn,on("phone")),Rn=tn(xn,nn("email")),Tn=t=>({verify:Object.keys(cn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Un(((e,o)=>We(t.post(Fe(Ht,n),{code:o,loginId:e}))))})),{}),signIn:Object.keys(cn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:_n(((e,o,r)=>We(t.post(Fe(Bt,n),{loginId:e,loginOptions:o},{token:r}))))})),{}),signUp:Object.keys(cn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:_n(((e,o)=>We(t.post(Fe(Vt,n),{loginId:e,user:o}))))})),{}),signUpOrIn:Object.keys(cn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:_n((e=>We(t.post(Fe(Gt,n),{loginId:e}))))})),{}),update:{email:Rn(((e,n,o,r)=>We(t.post(zt.email,Object.assign({loginId:e,email:n},r),{token:o})))),phone:Object.keys(an).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Pn(((e,o,r,i)=>We(t.post(Fe(zt.phone,n),Object.assign({loginId:e,phone:o},i),{token:r}))))})),{})}}),qn=tn(en("tenant")),Mn=tn(en("code")),$n=t=>({start:qn(((e,n,o,r)=>We(t.post(ce,o||{},{queryParams:{tenant:e,redirectURL:n},token:r})))),exchange:Mn((e=>We(t.post(ue,{code:e}))))}),Ln=en("loginId"),Dn=tn(Ln,en("code")),Nn=tn(Ln),Kn=tn(Ln),Jn=t=>({signUp:Nn(((e,n)=>We(t.post(he,{loginId:e,user:n})))),verify:Dn(((e,n,o,r)=>We(t.post(de,{loginId:e,code:n,loginOptions:o},{token:r})))),update:Kn(((e,n)=>We(t.post(pe,{loginId:e},{token:n}))))}),Fn=en("loginId"),Wn=en("newPassword"),Hn=tn(Fn,en("password")),Bn=tn(Fn),Vn=tn(Fn,Wn),zn=tn(Fn,en("oldPassword"),Wn),Gn=t=>({signUp:Hn(((e,n,o)=>We(t.post(we,{loginId:e,password:n,user:o})))),signIn:Hn(((e,n)=>We(t.post(me,{loginId:e,password:n})))),sendReset:Bn(((e,n)=>We(t.post(ye,{loginId:e,redirectUrl:n})))),update:Vn(((e,n,o)=>We(t.post(ke,{loginId:e,newPassword:n},{token:o})))),replace:zn(((e,n,o)=>We(t.post(Ie,{loginId:e,oldPassword:n,newPassword:o})))),policy:()=>We(t.get(Oe))}),Zn=[Xe('"loginId" must be a string')],Qn=en("loginId"),Yn=en("origin"),Xn=tn(Qn,Yn,en("name")),to=tn(Qn,Yn),eo=tn(Zn,Yn),no=tn(Qn,Yn,en("token")),oo=tn(en("transactionId"),en("response")),ro=t=>({signUp:{start:Xn(((e,n,o)=>We(t.post(fe.start,{user:{loginId:e,name:o},origin:n})))),finish:oo(((e,n)=>We(t.post(fe.finish,{transactionId:e,response:n}))))},signIn:{start:eo(((e,n,o,r)=>We(t.post(ge.start,{loginId:e,origin:n,loginOptions:o},{token:r})))),finish:oo(((e,n)=>We(t.post(ge.finish,{transactionId:e,response:n}))))},signUpOrIn:{start:to(((e,n)=>We(t.post(ve.start,{loginId:e,origin:n}))))},update:{start:no(((e,n,o)=>We(t.post(be.start,{loginId:e,origin:n},{token:o})))),finish:oo(((e,n)=>We(t.post(be.finish,{transactionId:e,response:n}))))}}),io=tn(en("token"));var so,ao=tn([("projectId",so=en("projectId"),He(((t,e)=>n=>Be(...e).validate(Ft(n,t)))("projectId",so))())])((t=>{var e,n;const o=[].concat((null===(e=t.hooks)||void 0===e?void 0:e.beforeRequest)||[]),r=[].concat((null===(n=t.hooks)||void 0===n?void 0:n.afterRequest)||[]);return(({projectId:t,logger:e,baseUrl:n,hooks:o,cookiePolicy:r,baseHeaders:i={},fetch:s})=>{return a=Me({baseUrl:n||"https://api.descope.com",projectId:t,logger:e,hooks:o,cookiePolicy:r,baseConfig:{baseHeaders:i},fetch:s}),{accessKey:sn(a),otp:Tn(a),magicLink:Sn(a),enchantedLink:vn(a),oauth:An(a),saml:$n(a),totp:Jn(a),webauthn:ro(a),password:Gn(a),flow:mn(a),refresh:t=>We(a.post(je,{},{token:t})),logout:t=>We(a.post(Se,{},{token:t})),logoutAll:t=>We(a.post(Ce,{},{token:t})),me:t=>We(a.get(Ee,{token:t})),isJwtExpired:io(Ne),getJwtPermissions:io(Ke),getJwtRoles:io(Je),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==r?void 0:r.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 lo=(t,e,n)=>(e.forEach((e=>{const o=e.split(".");let r=o.shift(),i=t;for(;o.length>0;){if(i=i[r],!r||!i)throw Error(`Invalid path "${e}", "${r}" is missing or has no value`);r=o.shift()}if("function"!=typeof i[r])throw Error(`"${e}" is not a function`);const s=i[r];i[r]=n(s)})),t);var co=Object.assign(ao,{DeliveryMethods:cn});var uo="Blocked by CSP",ho="API key required",po="3.8.3",fo="9319";function go(t,e){var n=[];return function(t,e){var n,o,r=(o=function(t,e,n){if(n||2===arguments.length)for(var o,r=0,i=e.length;r<i;r++)!o&&r in e||(o||(o=Array.prototype.slice.call(e,0,r)),o[r]=e[r]);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()}}),i=(100,3e3,n=0,function(){return Math.random()*Math.min(3e3,100*Math.pow(2,n++))}),s=r.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===uo||e===fo}(t)?r.postpone():r.exclude();var e,o=r.current();if(void 0===o)throw t;return(e=i(),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,r=function(){return n.push({url:t,startedAt:o,finishedAt:new Date})},i=e(t);return i.then(r,r),i})).then((function(t){return[t,{attempts:n}]}))}var vo="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",bo="Failed to load the JS script of the agent";function wo(n){var o;n.scriptUrlPattern;var r=n.token,i=n.apiKey,s=void 0===i?r:i,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:vo;return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error(ho);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(po):t}))}(String(t),e)}))}(l,s);return go(t,mo).catch(ko)})).then((function(e){var n=e[0],o=e[1];return n.load(t(t({},a),{ldi:o}))}))}function mo(t){return function(t,e,n,o){var r,i=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||(r=e,l())};i.addEventListener(s,a);var l=function(){return i.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(),r)return function(){throw new Error(uo)}();throw t}))}))}(t,(function(){return function(t){return new Promise((function(e,n){var o=document.createElement("script"),r=function(){var t;return null===(t=o.parentNode)||void 0===t?void 0:t.removeChild(o)},i=document.head||document.getElementsByTagName("head")[0];o.onload=function(){r(),e()},o.onerror=function(){r(),n(new Error(bo))},o.async=!0,o.src=t,i.appendChild(o)}))}(t)})).then(yo)}function yo(){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(fo);return n}function ko(t){throw t instanceof Error&&t.message===fo?new Error(bo):t}
2
+ /*! js-cookie v3.0.5 | MIT */function Io(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 Oo=function t(e,n){function o(t,o,r){if("undefined"!=typeof document){"number"==typeof(r=Io({},n,r)).expires&&(r.expires=new Date(Date.now()+864e5*r.expires)),r.expires&&(r.expires=r.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var i="";for(var s in r)r[s]&&(i+="; "+s,!0!==r[s]&&(i+="="+r[s].split(";")[0]));return document.cookie=t+"="+e.write(o,t)+i}}return Object.create({set:o,get:function(t){if("undefined"!=typeof document&&(!arguments.length||t)){for(var n=document.cookie?document.cookie.split("; "):[],o={},r=0;r<n.length;r++){var i=n[r].split("="),s=i.slice(1).join("=");try{var a=decodeURIComponent(i[0]);if(o[a]=e.read(s,a),t===a)break}catch(t){}}return t?o[t]:o}},remove:function(t,e){o(t,"",Io({},e,{expires:-1}))},withAttributes:function(e){return t(this.converter,Io({},this.attributes,e))},withConverter:function(e){return t(Io({},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 jo=(t,e)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,o)=>{var r;return n[o]=[].concat((null===(r=t.hooks)||void 0===r?void 0:r[o])||[]).concat((null==e?void 0:e[o])||[]),n}),null!==(n=t.hooks)&&void 0!==n?n:t.hooks={}),t},So=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||{}},Co=async t=>{const e=await So(t);return(null==e?void 0:e.user)||((null==e?void 0:e.hasOwnProperty("userId"))?e:void 0)},Eo="undefined"!=typeof localStorage,Ao=(t,e)=>Eo&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(t,e)),xo=t=>Eo&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(t)),Uo=t=>Eo&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(t)),_o="undefined"!=typeof window,Po=_o&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://fp.descope.com",Ro=(t="",e="")=>({vsid:t,vrid:e}),To=(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},qo=t=>(t.body&&(t.body.fpData=To(!0)||Ro()),t),Mo="dls_last_user_login_id",$o="dls_last_user_display_name",Lo=()=>xo(Mo),Do=()=>xo($o),No=t=>async(...e)=>{var n;e[1]=e[1]||{};const[,o={}]=e,r=Lo(),i=Do();return r&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=r,o.lastAuth.name=i),await t(...e)},Ko=t=>async(...e)=>{const n=await t(...e);return Uo(Mo),Uo($o),n};function Jo(){const t=[];return{pub:e=>{t.forEach((t=>t(e)))},sub:e=>{const n=t.push(e)-1;return()=>t.splice(n,1)}}}const Fo="DS",Wo="DSR",Ho=(t={},n)=>{var{refreshJwt:o,sessionJwt:r}=t,i=e(t,["refreshJwt","sessionJwt"]);void 0===n&&(n=!1),o&&Ao(Wo,o),r&&(n?function(t,e,{cookiePath:n,cookieDomain:o,cookieExpiration:r}){if(e){const i=new Date(1e3*r);Oo.set(t,e,{path:n,domain:o,expires:i,sameSite:"Strict",secure:!0})}}(Fo,r,i):Ao(Fo,r))};function Bo(){return xo(Wo)||""}function Vo(){return Oo.get(Fo)||xo(Fo)||""}function zo(){Uo(Wo),Uo(Fo),Oo.remove(Fo)}const Go=t=>Object.assign(t,{token:t.token||Bo()}),Zo=t=>async(...e)=>{const n=await t(...e);return zo(),n};async function Qo(t){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=or(n.publicKey.challenge),n.publicKey.user.id=or(n.publicKey.user.id),null===(e=n.publicKey.excludeCredentials)||void 0===e||e.forEach((t=>{t.id=or(t.id)})),n}(t);return n=await navigator.credentials.create(e),JSON.stringify({id:n.id,rawId:rr(n.rawId),type:n.type,response:{attestationObject:rr(n.response.attestationObject),clientDataJSON:rr(n.response.clientDataJSON)}});var n}async function Yo(t){const e=er(t);return nr(await navigator.credentials.get(e))}async function Xo(t,e){const n=er(t);return n.signal=e.signal,n.mediation="conditional",nr(await navigator.credentials.get(n))}async function tr(t=!1){if(!_o)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 er(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=or(n.publicKey.challenge),null===(e=n.publicKey.allowCredentials)||void 0===e||e.forEach((t=>{t.id=or(t.id)})),n}function nr(t){return JSON.stringify({id:t.id,rawId:rr(t.rawId),type:t.type,response:{authenticatorData:rr(t.response.authenticatorData),clientDataJSON:rr(t.response.clientDataJSON),signature:rr(t.response.signature),userHandle:t.response.userHandle?rr(t.response.userHandle):void 0}})}function or(t){const e=t.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(e),(t=>t.charCodeAt(0))).buffer}function rr(t){return btoa(String.fromCharCode.apply(null,new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var ir,sr=(ir=t=>({async signUp(e,n){const o=await t.webauthn.signUp.start(e,window.location.origin,n);if(!o.ok)return o;const r=await Qo(o.data.options);return await t.webauthn.signUp.finish(o.data.transactionId,r)},async signIn(e){const n=await t.webauthn.signIn.start(e,window.location.origin);if(!n.ok)return n;const o=await Yo(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 Qo(o.data.options);return await t.webauthn.signUp.finish(o.data.transactionId,e)}{const e=await Yo(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 r=await Qo(o.data.options);return await t.webauthn.update.finish(o.data.transactionId,r)},helpers:{create:Qo,get:Yo,isSupported:tr,conditional:Xo}}),(...t)=>{const e=ir(...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}),ar=t=>Object.assign(Object.assign({},t.flow),{start:async(...e)=>{const n=await tr(),o=Object.assign(Object.assign({redirectUrl:window.location.href},e[1]),{deviceInfo:{webAuthnSupport:n}});return e[1]=o,t.flow.start(...e)}});const lr=function(...t){return e=>t.reduce(((t,e)=>e(t)),e)}((t=>n=>{var{fpKey:o,fpLoad:r}=n,i=e(n,["fpKey","fpLoad"]);return o?(_o?r&&(async t=>{try{if(To())return;const e=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),n=wo({apiKey:t,endpoint:Po}),o=await n,{requestId:r}=await o.get({linkedId:e});(t=>{const e={value:t,expiry:(new Date).getTime()+864e5};localStorage.setItem("fp",JSON.stringify(e))})(Ro(e,r))}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(jo(i,{beforeRequest:qo}))):t(Object.assign({},i))}),(t=>n=>{var{autoRefresh:o}=n,r=e(n,["autoRefresh"]);if(!o)return t(r);const{clearAllTimers:i,setTimer:s}=(()=>{const t=[];return{clearAllTimers:()=>{for(;t.length;)clearTimeout(t.pop())},setTimer:(e,n)=>{t.push(setTimeout(e,n))}}})(),a=t(jo(r,{afterRequest:async(t,e)=>{const{refreshJwt:n,sessionJwt:o}=await So(e);if(401===(null==e?void 0:e.status))i();else if(o){const t=((r=(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))?r.getTime()-(new Date).getTime():0)-2e4;i(),s((()=>a.refresh(n)),t)}var r}}));return lo(a,["logout","logoutAll"],(t=>async(...e)=>{const n=await t(...e);return i(),n}))}),(t=>e=>t(Object.assign(Object.assign({},e),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.2.3"},e.baseHeaders)}))),(t=>e=>{const n=Jo(),o=Jo(),r=t(jo(e,{afterRequest:async(t,e)=>{if(401===(null==e?void 0:e.status))n.pub(null),o.pub(null);else{const t=await Co(e);t&&o.pub(t);const{sessionJwt:r}=await So(e);r&&n.pub(r)}}})),i=lo(r,["logout","logoutAll"],(t=>async(...e)=>{const r=await t(...e);return n.pub(null),o.pub(null),r}));return Object.assign(i,{onSessionTokenChange:n.sub,onUserChange:o.sub})}),(t=>e=>{const n=t(jo(e,{afterRequest:async(t,e)=>{var n;const o=await Co(e),r=null===(n=null==o?void 0:o.loginIds)||void 0===n?void 0:n[0],i=null==o?void 0:o.name;r&&((t=>{Ao(Mo,t)})(r),(t=>{Ao($o,t)})(i))}}));let o=lo(n,["flow.start"],No);return o=lo(o,["logout","logoutAll"],Ko),Object.assign(o,{getLastUserLoginId:Lo,getLastUserDisplayName:Do})}),(t=>n=>{var{persistTokens:o,sessionTokenViaCookie:r}=n,i=e(n,["persistTokens","sessionTokenViaCookie"]);if(!o||!_o)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(i);const s=t(jo(i,{beforeRequest:Go,afterRequest:async(t,e)=>{401===(null==e?void 0:e.status)?zo():Ho(await So(e),r)}})),a=lo(s,["logout","logoutAll"],Zo);return Object.assign(a,{getRefreshToken:Bo,getSessionToken:Vo})}))(((...t)=>{const e=co(...t);return Object.assign(Object.assign({},e),{flow:ar(e),webauthn:sr(e)})})),cr=document.createElement("template");var ur,dr,hr,pr,fr,gr,vr,br,wr,mr,yr,kr,Ir,Or,jr,Sr,Cr,Er,Ar,xr,Ur,_r,Pr,Rr,Tr,qr,Mr,$r,Lr,Dr,Nr,Kr,Jr,Fr,Wr,Hr,Br,Vr;cr.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 zr extends HTMLElement{constructor(t){super(),ur.add(this),dr.set(this,!1),hr.set(this,new F),pr.set(this,new F),this.nextRequestStatus=new F({isLoading:!1}),fr.set(this,void 0),gr.set(this,{popstate:o(this,ur,"m",kr).bind(this)}),vr.set(this,void 0),jr.set(this,M((()=>n(this,void 0,void 0,(function*(){const t=U(this.projectId,"config.json");try{const{body:e,headers:n}=yield A(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,ur,"m",_r).call(this,t,e)},info:(t,e="")=>{console.log(t,e)}},r(this,vr,t,"f"),o(this,ur,"m",br).call(this)}static get observedAttributes(){return["project-id","flow-id","base-url","tenant","theme","debug","telemetryKey","redirect-url","auto-focus"]}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}getExecutionContext(){return n(this,void 0,void 0,(function*(){const{executionContext:t}=yield o(this,jr,"f").call(this);return t}))}getFlowConfig(){var t,e;return n(this,void 0,void 0,(function*(){const{projectConfig:n}=yield o(this,jr,"f").call(this),r=(null===(t=null==n?void 0:n.flows)||void 0===t?void 0:t[this.flowId])||{};return null!==(e=r.version)&&void 0!==e||(r.version=0),r}))}connectedCallback(){return n(this,void 0,void 0,(function*(){if(this.shadowRoot.isConnected){if(o(this,ur,"m",wr).call(this))return void o(this,ur,"m",mr).call(this);o(this,ur,"m",yr).call(this),o(this,ur,"m",Cr).call(this),o(this,ur,"m",Sr).call(this),o(this,ur,"m",Pr).call(this);const{executionId:t,stepId:e,token:n,code:i,exchangeError:s,redirectAuthCallbackUrl:a,redirectAuthCodeChallenge:l}=q();window.addEventListener("popstate",o(this,gr,"f").popstate),o(this,hr,"f").subscribe(o(this,ur,"m",Or).bind(this)),o(this,pr,"f").subscribe(o(this,ur,"m",Ur).bind(this)),o(this,hr,"f").update({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenant,redirectUrl:this.redirectUrl,stepId:e,executionId:t,token:n,code:i,exchangeError:s,telemetryKey:this.telemetryKey,redirectAuthCallbackUrl:a,redirectAuthCodeChallenge:l}),o(this,pr,"f").update({isDebug:this.debug}),r(this,dr,!0,"f")}}))}disconnectedCallback(){o(this,hr,"f").unsubscribeAll(),o(this,pr,"f").unsubscribeAll(),o(this,ur,"m",xr).call(this),window.removeEventListener("popstate",o(this,gr,"f").popstate)}attributeChangedCallback(t,e,n){if(this.shadowRoot.isConnected&&o(this,dr,"f")&&e!==n&&zr.observedAttributes.includes(t)){o(this,ur,"m",yr).call(this);const r=null===e;o(this,hr,"f").update((({stepId:e,executionId:o})=>{let i=e,s=o;return r||(s=null,i=null,R()),{[T(t)]:n,stepId:i,executionId:s}})),o(this,pr,"f").update({isDebug:this.debug})}}}dr=new WeakMap,hr=new WeakMap,pr=new WeakMap,fr=new WeakMap,gr=new WeakMap,vr=new WeakMap,jr=new WeakMap,ur=new WeakSet,br=function(){this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(cr.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#wc-root")},wr=function(){const t=/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor);return!this.shadowRoot.host.closest("form")&&t},mr=function(){const t=this.shadowRoot.host,e=document.createElement("form");t.parentElement.appendChild(e),e.appendChild(t)},yr=function(){const t=["base-url","tenant","theme","debug","telemetryKey","redirect-url","auto-focus"];if(zr.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[T(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')},kr=function(){const{stepId:t,executionId:e}=P();o(this,hr,"f").update({stepId:t,executionId:e})},Ir=function(t,e,o){const r=o||void 0,i=!!r;this.sdk=lr(Object.assign(Object.assign({persistTokens:!0},zr.sdkConfigOverrides),{projectId:t,baseUrl:e,fpKey:r,fpLoad:i})),["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})}}))}))},Or=function(t,e,r){return n(this,void 0,void 0,(function*(){const{projectId:e,baseUrl:n,telemetryKey:i}=t;if(r("projectId")||r("baseUrl")||r("telemetryKey")){if(!e)return;o(this,ur,"m",Ir).call(this,e,n,i)}o(this,vr,"f").call(this,t)}))},Sr=function(){var t,e,r,i;return n(this,void 0,void 0,(function*(){const{projectConfig:n}=yield o(this,jr,"f").call(this);null===(i=null===(r=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===r?void 0:r.fontFamilies)||void 0===i||i.forEach((t=>(t=>{if(!t)return;const e=document.createElement("link");e.href=t,e.rel="stylesheet",document.head.appendChild(e)})(t.url)))}))},Cr=function(){o(this,ur,"m",Er).call(this),o(this,ur,"m",Ar).call(this)},Er=function(){return n(this,void 0,void 0,(function*(){const t=document.createElement("style"),e=U(this.projectId,"theme.css");try{const{body:n}=yield A(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)}))},Ar=function(){this.rootElement.setAttribute("data-theme",this.theme)},xr=function(){var t;null===(t=o(this,fr,"f"))||void 0===t||t.remove(),r(this,fr,null,"f")},Ur=function({isDebug:t}){return n(this,void 0,void 0,(function*(){t?(yield import("./debugger-wc-dc66f09e.js"),r(this,fr,document.createElement("descope-debugger"),"f"),Object.assign(o(this,fr,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),document.body.appendChild(o(this,fr,"f"))):o(this,ur,"m",xr).call(this)}))},_r=function(t,e){var n;t&&this.debug&&(null===(n=o(this,fr,"f"))||void 0===n||n.updateData({title:t,description:e}))},Pr=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()}},zr.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"2.3.3"}};class Gr extends zr{constructor(){const t=new F;super(t.update.bind(t)),Rr.add(this),this.stepState=new F({},{updateOnlyOnChange:!1}),Tr.set(this,void 0),qr.set(this,null),Mr.set(this,(()=>{clearInterval(o(this,Tr,"f")),r(this,Tr,null,"f")})),$r.set(this,(t=>{var e,n,r,s,a,l,c,u,d;if(!(null==t?void 0:t.ok)){o(this,Mr,"f").call(this),o(this,Rr,"m",Vr).call(this,"error",null==t?void 0:t.error);const i=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===(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)||i,(null===(a=null==t?void 0:t.error)||void 0===a?void 0:a.errorMessage)||l)}const h=null===(u=null===(c=null===(l=t.data)||void 0===l?void 0:l.screen)||void 0===c?void 0:c.state)||void 0===u?void 0:u.errorText;h&&this.logger.error(h),(null===(d=t.data)||void 0===d?void 0:d.error)&&this.logger.error(`[${t.data.error.code}]: ${t.data.error.description}`,t.data.error.message);const{status:p,authInfo:g,lastAuth:v}=t.data;if("completed"===p)return function(t){(null==t?void 0:t.authMethod)&&i&&localStorage.setItem(f,JSON.stringify(t))}(v),o(this,Mr,"f").call(this),void o(this,Rr,"m",Vr).call(this,"success",g);const{executionId:w,stepId:m,action:y,screen:k,redirect:I,webauthn:O}=t.data;y!==b?this.flowState.update({stepId:m,executionId:w,action:y,redirectTo:null==I?void 0:I.url,screenId:null==k?void 0:k.id,screenState:null==k?void 0:k.state,webauthnTransactionId:null==O?void 0:O.transactionId,webauthnOptions:null==O?void 0:O.options}):this.flowState.update({action:y})})),Lr.set(this,M((()=>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}static set sdkConfigOverrides(t){zr.sdkConfigOverrides=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,i){var s,a;return n(this,void 0,void 0,(function*(){const{projectId:l,flowId:c,tenant:u,stepId:d,executionId:h,action:p,screenId:g,screenState:y,redirectTo:O,redirectUrl:j,token:S,code:C,exchangeError:E,webauthnTransactionId:A,webauthnOptions:x,redirectAuthCodeChallenge:P,redirectAuthCallbackUrl:R}=t;let T,q;o(this,Tr,"f")&&o(this,Mr,"f").call(this);const M=this.sdk.getLastUserLoginId(),$=yield this.getFlowConfig(),L=R&&P?{callbackUrl:R,codeChallenge:P}:void 0;if(!h&&($.conditions?({startScreenId:T,conditionInteractionId:q}=((t,e)=>{const n=null==e?void 0:e.find((({key:e,operator:n})=>{var o;if("ELSE"===e)return!0;const r=null===(o=B[e])||void 0===o?void 0:o[n];return!!(null==r?void 0:r(t))}));return n?{startScreenId:n.met.screenId,conditionInteractionId:n.met.interactionId}:{}})({loginId:M,code:C},$.conditions)):$.condition?({startScreenId:T,conditionInteractionId:q}=((t,e)=>{var n;const o=null===(n=B[null==t?void 0:t.key])||void 0===n?void 0:n[t.operator];if(!o)return{};const r=o(e)?t.met:t.unmet;return{startScreenId:null==r?void 0:r.screenId,conditionInteractionId:null==r?void 0:r.interactionId}})($.condition,{loginId:M,code:C})):T=$.startScreenId,!T)){const t=C?{exchangeCode:C,idpInitiated:!0}:void 0,e=yield this.sdk.flow.start(c,Object.assign({tenant:u,redirectAuth:L},j&&{redirectUrl:j}),q,"",t,$.version);return o(this,$r,"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(h&&(i("token")&&S||i("code")&&C||i("exchangeError")&&E)){const t=yield this.sdk.flow.next(h,d,k,{token:S,exchangeCode:C,exchangeError:E},$.version);return o(this,$r,"f").call(this,t),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(p===v)return O||this.logger.error("Did not get redirect url"),void window.location.assign(O);if(p===w||p===m){if(!A||!x)return void this.logger.error("Did not get webauthn transaction id or options");let t,e;null===(a=o(this,qr,"f"))||void 0===a||a.abort(),r(this,qr,null,"f");try{t=p===w?yield this.sdk.webauthn.helpers.create(x):yield this.sdk.webauthn.helpers.get(x)}catch(t){if("NotAllowedError"!==t.name)return void this.logger.error(t.message);e=!0}const n=yield this.sdk.flow.next(h,d,k,{transactionId:A,response:t,cancelWebauthn:e},$.version);o(this,$r,"f").call(this,n)}if(p===b&&r(this,Tr,setInterval((()=>n(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(h,d,I,{},$.version);o(this,$r,"f").call(this,t)}))),2e3),"f"),!g&&!T)return void this.logger.info("Refreshing the page during a flow is not supported yet");const D={direction:_(+d,+e.stepId),screenState:Object.assign(Object.assign({},y),{lastAuth:{loginId:M,name:this.sdk.getLastUserDisplayName()||M}}),htmlUrl:U(l,`${T||g}.html`)},N=function(t){const e={};if(t)try{Object.assign(e,JSON.parse(localStorage.getItem(f)))}catch(t){}return e}(M);T?D.next=(t,e)=>this.sdk.flow.start(c,Object.assign({tenant:u,redirectAuth:L,lastAuth:N},j&&{redirectUrl:j}),q,t,Object.assign(Object.assign({},e),C&&{exchangeCode:C,idpInitiated:!0}),$.version):(i("projectId")||i("baseUrl")||i("executionId")||i("stepId"))&&(D.next=(...t)=>this.sdk.flow.next(h,d,...t)),this.stepState.update(D)}))}onStepChange(t,e){var r;return n(this,void 0,void 0,(function*(){const{htmlUrl:i,direction:s,next:a,screenState:l}=t,c=document.createElement("template"),{body:u}=yield A(i,"text");c.innerHTML=u;const d=c.content.cloneNode(!0),h=((t,e)=>{var n;const o=Array.from(t.querySelectorAll("script[data-id]")).map((n=>{var o;const r=n.getAttribute("data-id"),i=null===(o=t.getElementById(r))||void 0===o?void 0:o.innerHTML,s=Function(i).bind(n.previousSibling,e);return n.remove(),s}));return null===(n=t.querySelector("scripts"))||void 0===n||n.remove(),o})(d,yield this.getExecutionContext());this.sdk.webauthn.helpers.isSupported()?yield o(this,Rr,"m",Nr).call(this,d,a):d.querySelectorAll(`button[${g}="biometrics"]`).forEach((t=>t.setAttribute("disabled","true"))),W(d,l),((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})`))})(d.querySelector("div"),null===(r=null==l?void 0:l.totp)||void 0===r?void 0:r.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(d);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,Rr,"m",Hr).call(this,a),o(this,Rr,"m",Vr).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${g}="polling"]`)){const t=yield a(I,{});o(this,$r,"f").call(this,t)}}));s?o(this,Rr,"m",Br).call(this,p,s):p()}))}}Tr=new WeakMap,qr=new WeakMap,Mr=new WeakMap,$r=new WeakMap,Lr=new WeakMap,Rr=new WeakSet,Dr=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}))}},Nr=function(t,e){var i;return n(this,void 0,void 0,(function*(){null===(i=o(this,qr,"f"))||void 0===i||i.abort();const s=t.querySelector('input[autocomplete="webauthn"]');if(s&&(yield H())){const{options:t,transactionId:i}=(yield o(this,Lr,"f").call(this))||{};t&&i&&(o(this,Rr,"m",Dr).call(this,s),r(this,qr,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(t,o(this,qr,"f")).then((t=>n(this,void 0,void 0,(function*(){const n=yield e(s.id,{transactionId:i,response:t});o(this,$r,"f").call(this,n)})))).catch((t=>{"AbortError"!==t.name&&this.logger.error("Conditional login failed",t.message)})))}}))},Kr=function(){return Array.from(this.shadowRoot.querySelectorAll(".descope-input")).every((t=>(t.reportValidity(),t.checkValidity())))},Jr=function(){return Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${p}])`)).reduce(((t,e)=>e.name?Object.assign(t,{[e.name]:e["checkbox"===e.type?"checked":"value"]}):t),{})},Fr=function(t){const e=this.nextRequestStatus.subscribe((({isLoading:n})=>{var o,r;n?null===(o=null==t?void 0:t.classList)||void 0===o||o.add("loading"):(this.nextRequestStatus.unsubscribe(e),null===(r=null==t?void 0:t.classList)||void 0===r||r.remove("loading"))}))},Wr=function(t,e){return n(this,void 0,void 0,(function*(){if(t.formNoValidate||o(this,Rr,"m",Kr).call(this)){const r=null==t?void 0:t.getAttribute("id");o(this,Rr,"m",Fr).call(this,t);const i=o(this,Rr,"m",Jr).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),i),{origin:window.location.origin}),l=yield e(r,a);o(this,$r,"f").call(this,l)}var n}))},Hr=function(t){this.rootElement.querySelectorAll("button").forEach((e=>{e.onclick=()=>{o(this,Rr,"m",Wr).call(this,e,t)}}))},Br=function(t,e){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),t()}),{once:!0});const n=e===O.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")},Vr=function(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))},customElements.define("descope-wc",Gr);export{Gr as D,F as S,o as _,r as a};
package/dist/esm/index.js CHANGED
@@ -1 +1 @@
1
- export{D as default}from"./index-78a0ebca.js";
1
+ export{D as default}from"./index-63a41376.js";
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="t",c="code",d="err",u="ra-challenge",h="ra-callback",p="data-exclude-field",f="dls_last_auth",g="data-type",v="redirect",m="poll",b="webauthnCreate",w="webauthnGet",y="v2-alpha",k="submit",I="polling";var O,x,j;function C(t){return new URLSearchParams(window.location.search).get(t)}function S(t){if(window.history.replaceState&&C(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 E(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"}(O||(O={}));const A=(...t)=>t.join("/").replace(/\/+/g,"/");function U(t,e){const n=new URL(s);return n.pathname=A(n.pathname,t,y,e),n.toString()}function _(t,e){if(!Number.isNaN(t)&&!Number.isNaN(e))return t>e?O.forward:t<e?O.backward:void 0}const P=()=>{const[t="",e=""]=(C(a)||"").split("_");return{executionId:t,stepId:e}};function R(){S(a)}const T=t=>t.replace(/-./g,(t=>t[1].toUpperCase())),L=()=>{const{executionId:t,stepId:e}=P();(t||e)&&R();const n=C(l)||void 0;n&&S(l);const o=C(c)||void 0;o&&S(c);const i=C(d)||void 0;i&&S(d);const{redirectAuthCodeChallenge:r,redirectAuthCallbackUrl:s}={redirectAuthCodeChallenge:C(u),redirectAuthCallbackUrl:C(h)};return(r||s)&&(S(u),S(h)),{executionId:t,stepId:e,token:n,code:o,exchangeError:i,redirectAuthCodeChallenge:r,redirectAuthCallbackUrl:s}},M=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}},q=null===(j=null===(x=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===x?void 0:x.brands)||void 0===j?void 0:j.find((({brand:t,version:e})=>"Chromium"===t&&parseFloat(e)));var $,D,N,W;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 K{constructor(t={},{updateOnlyOnChange:e=!0}={}){$.set(this,void 0),D.set(this,{}),N.set(this,0),W.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,W,"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,W,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,W=new WeakMap;const J=(t,e)=>{var n;((t,e,n="")=>{t.querySelectorAll(`[${g}="${e}"]`).forEach((t=>{t.textContent=n,t.classList[n?"remove":"add"]("hide")}))})(t,"error-message",null==e?void 0:e.errorText),((t,e)=>{Object.entries(e||{}).forEach((([e,n])=>{Array.from(t.querySelectorAll(`.descope-input[name="${e}"]:not([${p}])`)).forEach((t=>{t.value=n}))}))})(t,null==e?void 0:e.inputs),((t,e)=>{t.querySelectorAll(`[${g}="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,n)=>{return o=e,n.split(".").reduce(((t,e)=>(null==t?void 0:t[e])||""),o);var o})))(t.textContent,e)}))})(t,e)},H=M((()=>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((()=>q()>=r))])}catch(t){return console.warn("webauthn","Conditional login check failed",t),!1}})))),z=(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))]},B={"lastAuth.loginId":{"not-empty":t=>!!t.loginId,empty:t=>!t.loginId},idpInitiated:{"is-true":t=>!!t.code,"is-false":t=>!t.code}};function V(t){this.message=t}V.prototype=new Error,V.prototype.name="InvalidCharacterError";var Z="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new V("'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 G(t){this.message=t}function X(t,e){if("string"!=typeof t)throw new G("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(Z(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 Z(e)}}(t.split(".")[n]))}catch(t){throw new G("Invalid token specified: "+t.message)}}G.prototype=new Error,G.prototype.name="InvalidTokenError";var Y="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},Q="Expected a function",tt="__lodash_hash_undefined__",et=1/0,nt="[object Function]",ot="[object GeneratorFunction]",it="[object Symbol]",rt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,st=/^\w*$/,at=/^\./,lt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ct=/\\(\\)?/g,dt=/^\[object .+?Constructor\]$/,ut="object"==typeof Y&&Y&&Y.Object===Object&&Y,ht="object"==typeof self&&self&&self.Object===Object&&self,pt=ut||ht||Function("return this")();var ft,gt=Array.prototype,vt=Function.prototype,mt=Object.prototype,bt=pt["__core-js_shared__"],wt=(ft=/[^.]+$/.exec(bt&&bt.keys&&bt.keys.IE_PROTO||""))?"Symbol(src)_1."+ft:"",yt=vt.toString,kt=mt.hasOwnProperty,It=mt.toString,Ot=RegExp("^"+yt.call(kt).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),xt=pt.Symbol,jt=gt.splice,Ct=qt(pt,"Map"),St=qt(Object,"create"),Et=xt?xt.prototype:void 0,At=Et?Et.toString:void 0;function Ut(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 _t(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 Rt(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 Tt(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||Kt(t))return!0;return st.test(t)||!rt.test(t)||null!=e&&t in Object(e)}(e,t)?[e]:Wt(n=e)?n:$t(n);for(var o=0,i=e.length;null!=t&&o<i;)t=t[Dt(e[o++])];return o&&o==i?t:void 0}function Lt(t){if(!Ft(t)||(e=t,wt&&wt in e))return!1;var e,n=function(t){var e=Ft(t)?It.call(t):"";return e==nt||e==ot}(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t)?Ot:dt;return n.test(function(t){if(null!=t){try{return yt.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}function Mt(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 qt(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return Lt(n)?n:void 0}Ut.prototype.clear=function(){this.__data__=St?St(null):{}},Ut.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},Ut.prototype.get=function(t){var e=this.__data__;if(St){var n=e[t];return n===tt?void 0:n}return kt.call(e,t)?e[t]:void 0},Ut.prototype.has=function(t){var e=this.__data__;return St?void 0!==e[t]:kt.call(e,t)},Ut.prototype.set=function(t,e){return this.__data__[t]=St&&void 0===e?tt:e,this},_t.prototype.clear=function(){this.__data__=[]},_t.prototype.delete=function(t){var e=this.__data__,n=Rt(e,t);return!(n<0)&&(n==e.length-1?e.pop():jt.call(e,n,1),!0)},_t.prototype.get=function(t){var e=this.__data__,n=Rt(e,t);return n<0?void 0:e[n][1]},_t.prototype.has=function(t){return Rt(this.__data__,t)>-1},_t.prototype.set=function(t,e){var n=this.__data__,o=Rt(n,t);return o<0?n.push([t,e]):n[o][1]=e,this},Pt.prototype.clear=function(){this.__data__={hash:new Ut,map:new(Ct||_t),string:new Ut}},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 $t=Nt((function(t){var e;t=null==(e=t)?"":function(t){if("string"==typeof t)return t;if(Kt(t))return At?At.call(t):"";var e=t+"";return"0"==e&&1/t==-et?"-0":e}(e);var n=[];return at.test(t)&&n.push(""),t.replace(lt,(function(t,e,o,i){n.push(o?i.replace(ct,"$1"):e||t)})),n}));function Dt(t){if("string"==typeof t||Kt(t))return t;var e=t+"";return"0"==e&&1/t==-et?"-0":e}function Nt(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError(Q);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(Nt.Cache||Pt),n}Nt.Cache=Pt;var Wt=Array.isArray;function Ft(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Kt(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&It.call(t)==it}var Jt=function(t,e,n){var o=null==t?void 0:Tt(t,e);return void 0===o?n:o},Ht="/v1/auth/accesskey/exchange",zt="/v1/auth/otp/verify",Bt="/v1/auth/otp/signin",Vt="/v1/auth/otp/signup",Zt={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},Gt="/v1/auth/otp/signup-in",Xt="/v1/auth/magiclink/verify",Yt="/v1/auth/magiclink/signin",Qt="/v1/auth/magiclink/signup",te={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},ee="/v1/auth/magiclink/signup-in",ne="/v1/auth/enchantedlink/verify",oe="/v1/auth/enchantedlink/signin",ie="/v1/auth/enchantedlink/signup",re="/v1/auth/enchantedlink/pending-session",se={email:"/v1/auth/enchantedlink/update/email"},ae="/v1/auth/enchantedlink/signup-in",le="/v1/auth/oauth/authorize",ce="/v1/auth/oauth/exchange",de="/v1/auth/saml/authorize",ue="/v1/auth/saml/exchange",he="/v1/auth/totp/verify",pe="/v1/auth/totp/signup",fe="/v1/auth/totp/update",ge={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},ve={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},me={start:"/v1/auth/webauthn/signup-in/start"},be={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},we="/v1/auth/password/signup",ye="/v1/auth/password/signin",ke="/v1/auth/password/reset",Ie="/v1/auth/password/update",Oe="/v1/auth/password/replace",xe="/v1/auth/password/policy",je="/v1/auth/refresh",Ce="/v1/auth/logout",Se="/v1/auth/logoutall",Ee="/v1/auth/me",Ae="/v1/flow/start",Ue="/v1/flow/next";const _e=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 Re;!function(t){t.get="GET",t.delete="DELETE",t.post="POST",t.put="PUT"}(Re||(Re={}));const Te=(...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}),{})),Le=t=>void 0===t?void 0:JSON.stringify(t),Me=(t,e="")=>{let n=t;return e&&(n=n+":"+e),{Authorization:`Bearer ${n}`}},qe=({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=>Pe().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 Pe().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:Te(Me(e,p),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"1.3.2"},(null==n?void 0:n.baseHeaders)||{},d),method:h,body:Le(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:Re.get,token:o}),post:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:Re.post,token:i}),put:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:Re.put,token:i}),delete:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:Re.delete,token:i}),hooks:i}};var $e={TOO_MANY_REQUESTS:429};function De(t,e,n){var o;let i=Ne(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 Ne(t){if("string"!=typeof t||!t)throw new Error("Invalid token provided");return X(t)}function We(t){const{exp:e}=Ne(t);return(new Date).getTime()/1e3>e}function Fe(t,e){return De(t,e,"permissions")}function Ke(t,e){return De(t,e,"roles")}const Je=(...t)=>t.join("/").replace(/\/{2,}/g,"/");async function He(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===$e.TOO_MANY_REQUESTS&&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),Be=(...t)=>({validate:e=>(t.forEach((t=>{const n=t(e);if(n)throw new Error(n)})),!0)}),Ve=t=>e=>t.test(e),Ze=Ve(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Ge=Ve(/^\+[1-9]{1}[0-9]{3,14}$/),Xe=ze(Ze,'"{val}" is not a valid email'),Ye=ze(Ge,'"{val}" is not a valid phone number'),Qe=ze((1,t=>t.length>=1),"Minimum length is 1");const tn=ze((t=>"string"==typeof t),"Input is not a string"),en=(...t)=>e=>(...n)=>(t.forEach(((t,e)=>Be(...t).validate(n[e]))),e(...n)),nn=t=>[tn(`"${t}" must be a string`),Qe(`"${t}" must not be empty`)],on=t=>[tn(`"${t}" must be a string`),Xe()],rn=t=>[tn(`"${t}" must be a string`),Ye()],sn=en(nn("accessKey")),an=t=>({exchange:sn((e=>He(t.post(Ht,{},{token:e}))))});var ln,cn;!function(t){t.sms="sms",t.whatsapp="whatsapp"}(ln||(ln={})),function(t){t.email="email"}(cn||(cn={}));const dn=Object.assign(Object.assign({},ln),cn);var un;!function(t){t.waiting="waiting",t.running="running",t.completed="completed",t.failed="failed"}(un||(un={}));const hn=nn("loginId"),pn=en(nn("token")),fn=en(hn),gn=en(nn("pendingRef")),vn=en(hn,on("email")),mn=t=>({verify:pn((e=>He(t.post(ne,{token:e})))),signIn:fn(((e,n,o,i)=>He(t.post(Je(oe,dn.email),{loginId:e,URI:n,loginOptions:o},{token:i})))),signUpOrIn:fn(((e,n)=>He(t.post(Je(ae,dn.email),{loginId:e,URI:n})))),signUp:fn(((e,n,o)=>He(t.post(Je(ie,dn.email),{loginId:e,URI:n,user:o})))),waitForSession:gn(((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||_e,_e)}))(n);let s;const a=setInterval((async()=>{const n=await t.post(re,{pendingRef:e});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(He(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:vn(((e,n,o,i,r)=>He(t.post(se.email,Object.assign({loginId:e,email:n,URI:o},r),{token:i}))))}}),bn=en(nn("flowId")),wn=en(nn("executionId"),nn("stepId"),nn("interactionId")),yn=t=>({start:bn(((e,n,o,i,r,s)=>He(t.post(Ae,{flowId:e,options:n,conditionInteractionId:o,interactionId:i,input:r,version:s})))),next:wn(((e,n,o,i,r)=>He(t.post(Ue,{executionId:e,stepId:n,interactionId:o,input:i,version:r}))))}),kn=nn("loginId"),In=en(nn("token")),On=en(kn),xn=en(kn,rn("phone")),jn=en(kn,on("email")),Cn=t=>({verify:In((e=>He(t.post(Xt,{token:e})))),signIn:Object.keys(dn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:On(((e,o,i,r)=>He(t.post(Je(Yt,n),{loginId:e,URI:o,loginOptions:i},{token:r}))))})),{}),signUp:Object.keys(dn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:On(((e,o,i)=>He(t.post(Je(Qt,n),{loginId:e,URI:o,user:i}))))})),{}),signUpOrIn:Object.keys(dn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:On(((e,o)=>He(t.post(Je(ee,n),{loginId:e,URI:o}))))})),{}),update:{email:jn(((e,n,o,i,r)=>He(t.post(te.email,Object.assign({loginId:e,email:n,URI:o},r),{token:i})))),phone:Object.keys(ln).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:xn(((e,o,i,r,s)=>He(t.post(Je(te.phone,n),Object.assign({loginId:e,phone:o,URI:i},s),{token:r}))))})),{})}});var Sn;!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"}(Sn||(Sn={}));const En=en(nn("code")),An=t=>({start:Object.keys(Sn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:(e,o,i)=>He(t.post(le,o||{},{queryParams:Object.assign({provider:n},e&&{redirectURL:e}),token:i}))})),{}),exchange:En((e=>He(t.post(ce,{code:e}))))}),Un=nn("loginId"),_n=en(Un,nn("code")),Pn=en(Un),Rn=en(Un,rn("phone")),Tn=en(Un,on("email")),Ln=t=>({verify:Object.keys(dn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:_n(((e,o)=>He(t.post(Je(zt,n),{code:o,loginId:e}))))})),{}),signIn:Object.keys(dn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Pn(((e,o,i)=>He(t.post(Je(Bt,n),{loginId:e,loginOptions:o},{token:i}))))})),{}),signUp:Object.keys(dn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Pn(((e,o)=>He(t.post(Je(Vt,n),{loginId:e,user:o}))))})),{}),signUpOrIn:Object.keys(dn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Pn((e=>He(t.post(Je(Gt,n),{loginId:e}))))})),{}),update:{email:Tn(((e,n,o,i)=>He(t.post(Zt.email,Object.assign({loginId:e,email:n},i),{token:o})))),phone:Object.keys(ln).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Rn(((e,o,i,r)=>He(t.post(Je(Zt.phone,n),Object.assign({loginId:e,phone:o},r),{token:i}))))})),{})}}),Mn=en(nn("tenant")),qn=en(nn("code")),$n=t=>({start:Mn(((e,n,o,i)=>He(t.post(de,o||{},{queryParams:{tenant:e,redirectURL:n},token:i})))),exchange:qn((e=>He(t.post(ue,{code:e}))))}),Dn=nn("loginId"),Nn=en(Dn,nn("code")),Wn=en(Dn),Fn=en(Dn),Kn=t=>({signUp:Wn(((e,n)=>He(t.post(pe,{loginId:e,user:n})))),verify:Nn(((e,n,o,i)=>He(t.post(he,{loginId:e,code:n,loginOptions:o},{token:i})))),update:Fn(((e,n)=>He(t.post(fe,{loginId:e},{token:n}))))}),Jn=nn("loginId"),Hn=nn("newPassword"),zn=en(Jn,nn("password")),Bn=en(Jn),Vn=en(Jn,Hn),Zn=en(Jn,nn("oldPassword"),Hn),Gn=t=>({signUp:zn(((e,n,o)=>He(t.post(we,{loginId:e,password:n,user:o})))),signIn:zn(((e,n)=>He(t.post(ye,{loginId:e,password:n})))),sendReset:Bn(((e,n)=>He(t.post(ke,{loginId:e,redirectUrl:n})))),update:Vn(((e,n,o)=>He(t.post(Ie,{loginId:e,newPassword:n},{token:o})))),replace:Zn(((e,n,o)=>He(t.post(Oe,{loginId:e,oldPassword:n,newPassword:o})))),policy:()=>He(t.get(xe))}),Xn=[tn('"loginId" must be a string')],Yn=nn("loginId"),Qn=nn("origin"),to=en(Yn,Qn,nn("name")),eo=en(Yn,Qn),no=en(Xn,Qn),oo=en(Yn,Qn,nn("token")),io=en(nn("transactionId"),nn("response")),ro=t=>({signUp:{start:to(((e,n,o)=>He(t.post(ge.start,{user:{loginId:e,name:o},origin:n})))),finish:io(((e,n)=>He(t.post(ge.finish,{transactionId:e,response:n}))))},signIn:{start:no(((e,n,o,i)=>He(t.post(ve.start,{loginId:e,origin:n,loginOptions:o},{token:i})))),finish:io(((e,n)=>He(t.post(ve.finish,{transactionId:e,response:n}))))},signUpOrIn:{start:eo(((e,n)=>He(t.post(me.start,{loginId:e,origin:n}))))},update:{start:oo(((e,n,o)=>He(t.post(be.start,{loginId:e,origin:n},{token:o})))),finish:io(((e,n)=>He(t.post(be.finish,{transactionId:e,response:n}))))}}),so=en(nn("token"));var ao,lo=en([("projectId",ao=nn("projectId"),ze(((t,e)=>n=>Be(...e).validate(Jt(n,t)))("projectId",ao))())])((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=qe({baseUrl:n||"https://api.descope.com",projectId:t,logger:e,hooks:o,cookiePolicy:i,baseConfig:{baseHeaders:r},fetch:s}),{accessKey:an(a),otp:Ln(a),magicLink:Cn(a),enchantedLink:mn(a),oauth:An(a),saml:$n(a),totp:Kn(a),webauthn:ro(a),password:Gn(a),flow:yn(a),refresh:t=>He(a.post(je,{},{token:t})),logout:t=>He(a.post(Ce,{},{token:t})),logoutAll:t=>He(a.post(Se,{},{token:t})),me:t=>He(a.get(Ee,{token:t})),isJwtExpired:so(We),getJwtPermissions:so(Fe),getJwtRoles:so(Ke),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 co=(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 uo=Object.assign(lo,{DeliveryMethods:dn});var ho="Blocked by CSP",po="API key required",fo="3.8.3",go="9319";function vo(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===ho||e===go}(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 mo="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",bo="Failed to load the JS script of the agent";function wo(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:mo;return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error(po);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(fo):t}))}(String(t),e)}))}(l,s);return vo(t,yo).catch(Io)})).then((function(e){var n=e[0],o=e[1];return n.load(t(t({},a),{ldi:o}))}))}function yo(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(ho)}();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(bo))},o.async=!0,o.src=t,r.appendChild(o)}))}(t)})).then(ko)}function ko(){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(go);return n}function Io(t){throw t instanceof Error&&t.message===go?new Error(bo):t}
2
- /*! js-cookie v3.0.5 | MIT */function Oo(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 xo=function t(e,n){function o(t,o,i){if("undefined"!=typeof document){"number"==typeof(i=Oo({},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,"",Oo({},e,{expires:-1}))},withAttributes:function(e){return t(this.converter,Oo({},this.attributes,e))},withConverter:function(e){return t(Oo({},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 jo=(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},Co=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||{}},So=async t=>{const e=await Co(t);return(null==e?void 0:e.user)||((null==e?void 0:e.hasOwnProperty("userId"))?e:void 0)},Eo="undefined"!=typeof localStorage,Ao=(t,e)=>Eo&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(t,e)),Uo=t=>Eo&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(t)),_o=t=>Eo&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(t)),Po="undefined"!=typeof window,Ro=Po&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://fp.descope.com",To=(t="",e="")=>({vsid:t,vrid:e}),Lo=(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},Mo=t=>(t.body&&(t.body.fpData=Lo(!0)||To()),t),qo="dls_last_user_login_id",$o="dls_last_user_display_name",Do=()=>Uo(qo),No=()=>Uo($o),Wo=t=>async(...e)=>{var n;e[1]=e[1]||{};const[,o={}]=e,i=Do(),r=No();return i&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=i,o.lastAuth.name=r),await t(...e)},Fo=t=>async(...e)=>{const n=await t(...e);return _o(qo),_o($o),n};function Ko(){const t=[];return{pub:e=>{t.forEach((t=>t(e)))},sub:e=>{const n=t.push(e)-1;return()=>t.splice(n,1)}}}const Jo="DS",Ho="DSR",zo=(t={},n)=>{var{refreshJwt:o,sessionJwt:i}=t,r=e(t,["refreshJwt","sessionJwt"]);void 0===n&&(n=!1),o&&Ao(Ho,o),i&&(n?function(t,e,{cookiePath:n,cookieDomain:o,cookieExpiration:i}){if(e){const r=new Date(1e3*i);xo.set(t,e,{path:n,domain:o,expires:r,sameSite:"Strict",secure:!0})}}(Jo,i,r):Ao(Jo,i))};function Bo(){return Uo(Ho)||""}function Vo(){return xo.get(Jo)||Uo(Jo)||""}function Zo(){_o(Ho),_o(Jo),xo.remove(Jo)}const Go=t=>Object.assign(t,{token:t.token||Bo()}),Xo=t=>async(...e)=>{const n=await t(...e);return Zo(),n};async function Yo(t){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=ii(n.publicKey.challenge),n.publicKey.user.id=ii(n.publicKey.user.id),null===(e=n.publicKey.excludeCredentials)||void 0===e||e.forEach((t=>{t.id=ii(t.id)})),n}(t);return n=await navigator.credentials.create(e),JSON.stringify({id:n.id,rawId:ri(n.rawId),type:n.type,response:{attestationObject:ri(n.response.attestationObject),clientDataJSON:ri(n.response.clientDataJSON)}});var n}async function Qo(t){const e=ni(t);return oi(await navigator.credentials.get(e))}async function ti(t,e){const n=ni(t);return n.signal=e.signal,n.mediation="conditional",oi(await navigator.credentials.get(n))}async function ei(t=!1){if(!Po)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 ni(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=ii(n.publicKey.challenge),null===(e=n.publicKey.allowCredentials)||void 0===e||e.forEach((t=>{t.id=ii(t.id)})),n}function oi(t){return JSON.stringify({id:t.id,rawId:ri(t.rawId),type:t.type,response:{authenticatorData:ri(t.response.authenticatorData),clientDataJSON:ri(t.response.clientDataJSON),signature:ri(t.response.signature),userHandle:t.response.userHandle?ri(t.response.userHandle):void 0}})}function ii(t){const e=t.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(e),(t=>t.charCodeAt(0))).buffer}function ri(t){return btoa(String.fromCharCode.apply(null,new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var si,ai=(si=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 Yo(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 Qo(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 Yo(o.data.options);return await t.webauthn.signUp.finish(o.data.transactionId,e)}{const e=await Qo(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 Yo(o.data.options);return await t.webauthn.update.finish(o.data.transactionId,i)},helpers:{create:Yo,get:Qo,isSupported:ei,conditional:ti}}),(...t)=>{const e=si(...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}),li=t=>Object.assign(Object.assign({},t.flow),{start:async(...e)=>{const n=await ei(),o=Object.assign(Object.assign({redirectUrl:window.location.href},e[1]),{deviceInfo:{webAuthnSupport:n}});return e[1]=o,t.flow.start(...e)}});const ci=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?(Po?i&&(async t=>{try{if(Lo())return;const e=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),n=wo({apiKey:t,endpoint:Ro}),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))})(To(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(jo(r,{beforeRequest:Mo}))):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(jo(i,{afterRequest:async(t,e)=>{const{refreshJwt:n,sessionJwt:o}=await Co(e);if(401===(null==e?void 0:e.status))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(),s((()=>a.refresh(n)),t)}var i}}));return co(a,["logout","logoutAll"],(t=>async(...e)=>{const n=await t(...e);return r(),n}))}),(t=>e=>t(Object.assign(Object.assign({},e),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.2.2"},e.baseHeaders)}))),(t=>e=>{const n=Ko(),o=Ko(),i=t(jo(e,{afterRequest:async(t,e)=>{if(401===(null==e?void 0:e.status))n.pub(null),o.pub(null);else{const t=await So(e);t&&o.pub(t);const{sessionJwt:i}=await Co(e);i&&n.pub(i)}}})),r=co(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(jo(e,{afterRequest:async(t,e)=>{var n;const o=await So(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=>{Ao(qo,t)})(i),(t=>{Ao($o,t)})(r))}}));let o=co(n,["flow.start"],Wo);return o=co(o,["logout","logoutAll"],Fo),Object.assign(o,{getLastUserLoginId:Do,getLastUserDisplayName:No})}),(t=>n=>{var{persistTokens:o,sessionTokenViaCookie:i}=n,r=e(n,["persistTokens","sessionTokenViaCookie"]);if(!o||!Po)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(jo(r,{beforeRequest:Go,afterRequest:async(t,e)=>{401===(null==e?void 0:e.status)?Zo():zo(await Co(e),i)}})),a=co(s,["logout","logoutAll"],Xo);return Object.assign(a,{getRefreshToken:Bo,getSessionToken:Vo})}))(((...t)=>{const e=uo(...t);return Object.assign(Object.assign({},e),{flow:li(e),webauthn:ai(e)})})),di=document.createElement("template");var ui,hi,pi,fi,gi,vi,mi,bi,wi,yi,ki,Ii,Oi,xi,ji,Ci,Si,Ei,Ai,Ui,_i,Pi,Ri,Ti,Li,Mi,qi,$i,Di,Ni,Wi,Fi,Ki,Ji,Hi,zi,Bi,Vi,Zi,Gi,Xi,Yi,Qi,tr,er,nr,or,ir;di.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 rr extends HTMLElement{constructor(t){super(),ui.add(this),hi.set(this,!1),pi.set(this,new K),fi.set(this,new K),this.nextRequestStatus=new K({isLoading:!1}),gi.set(this,void 0),vi.set(this,{popstate:o(this,ui,"m",Ii).bind(this)}),mi.set(this,void 0),ji.set(this,M((()=>n(this,void 0,void 0,(function*(){const t=U(this.projectId,"config.json");try{const{body:e,headers:n}=yield E(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,ui,"m",Pi).call(this,t,e)},info:(t,e="")=>{console.log(t,e)}},i(this,mi,t,"f"),o(this,ui,"m",bi).call(this)}static get observedAttributes(){return["project-id","flow-id","base-url","tenant","theme","debug","telemetryKey","redirect-url","auto-focus"]}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}getExecutionContext(){return n(this,void 0,void 0,(function*(){const{executionContext:t}=yield o(this,ji,"f").call(this);return t}))}getFlowConfig(){var t,e;return n(this,void 0,void 0,(function*(){const{projectConfig:n}=yield o(this,ji,"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,ui,"m",wi).call(this))return void o(this,ui,"m",yi).call(this);o(this,ui,"m",ki).call(this),o(this,ui,"m",Si).call(this),o(this,ui,"m",Ci).call(this),o(this,ui,"m",Ri).call(this);const{executionId:t,stepId:e,token:n,code:r,exchangeError:s,redirectAuthCallbackUrl:a,redirectAuthCodeChallenge:l}=L();window.addEventListener("popstate",o(this,vi,"f").popstate),o(this,pi,"f").subscribe(o(this,ui,"m",xi).bind(this)),o(this,fi,"f").subscribe(o(this,ui,"m",_i).bind(this)),o(this,pi,"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}),o(this,fi,"f").update({isDebug:this.debug}),i(this,hi,!0,"f")}}))}disconnectedCallback(){o(this,pi,"f").unsubscribeAll(),o(this,fi,"f").unsubscribeAll(),o(this,ui,"m",Ui).call(this),window.removeEventListener("popstate",o(this,vi,"f").popstate)}attributeChangedCallback(t,e,n){if(this.shadowRoot.isConnected&&o(this,hi,"f")&&e!==n&&rr.observedAttributes.includes(t)){o(this,ui,"m",ki).call(this);const i=null===e;o(this,pi,"f").update((({stepId:e,executionId:o})=>{let r=e,s=o;return i||(s=null,r=null,R()),{[T(t)]:n,stepId:r,executionId:s}})),o(this,fi,"f").update({isDebug:this.debug})}}}hi=new WeakMap,pi=new WeakMap,fi=new WeakMap,gi=new WeakMap,vi=new WeakMap,mi=new WeakMap,ji=new WeakMap,ui=new WeakSet,bi=function(){this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(di.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#wc-root")},wi=function(){const t=/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor);return!this.shadowRoot.host.closest("form")&&t},yi=function(){const t=this.shadowRoot.host,e=document.createElement("form");t.parentElement.appendChild(e),e.appendChild(t)},ki=function(){const t=["base-url","tenant","theme","debug","telemetryKey","redirect-url","auto-focus"];if(rr.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[T(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')},Ii=function(){const{stepId:t,executionId:e}=P();o(this,pi,"f").update({stepId:t,executionId:e})},Oi=function(t,e,o){const i=o||void 0,r=!!i;this.sdk=ci(Object.assign(Object.assign({persistTokens:!0},rr.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})}}))}))},xi=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,ui,"m",Oi).call(this,e,n,r)}o(this,mi,"f").call(this,t)}))},Ci=function(){var t,e,i,r;return n(this,void 0,void 0,(function*(){const{projectConfig:n}=yield o(this,ji,"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)))}))},Si=function(){o(this,ui,"m",Ei).call(this),o(this,ui,"m",Ai).call(this)},Ei=function(){return n(this,void 0,void 0,(function*(){const t=document.createElement("style"),e=U(this.projectId,"theme.css");try{const{body:n}=yield E(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)}))},Ai=function(){this.rootElement.setAttribute("data-theme",this.theme)},Ui=function(){var t;null===(t=o(this,gi,"f"))||void 0===t||t.remove(),i(this,gi,null,"f")},_i=function({isDebug:t}){return n(this,void 0,void 0,(function*(){t?(yield Promise.resolve().then((function(){return cr})),i(this,gi,document.createElement("descope-debugger"),"f"),Object.assign(o(this,gi,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),document.body.appendChild(o(this,gi,"f"))):o(this,ui,"m",Ui).call(this)}))},Pi=function(t,e){var n;t&&this.debug&&(null===(n=o(this,gi,"f"))||void 0===n||n.updateData({title:t,description:e}))},Ri=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()}},rr.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"2.3.2"}};class sr extends rr{constructor(){const t=new K;super(t.update.bind(t)),Ti.add(this),this.stepState=new K({},{updateOnlyOnChange:!1}),Li.set(this,void 0),Mi.set(this,null),qi.set(this,(()=>{clearInterval(o(this,Li,"f")),i(this,Li,null,"f")})),$i.set(this,(t=>{var e,n,i,s,a,l,c,d,u;if(!(null==t?void 0:t.ok)){o(this,qi,"f").call(this),o(this,Ti,"m",Vi).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:p,authInfo:g,lastAuth:v}=t.data;if("completed"===p)return function(t){(null==t?void 0:t.authMethod)&&r&&localStorage.setItem(f,JSON.stringify(t))}(v),o(this,qi,"f").call(this),void o(this,Ti,"m",Vi).call(this,"success",g);const{executionId:b,stepId:w,action:y,screen:k,redirect:I,webauthn:O}=t.data;y!==m?this.flowState.update({stepId:w,executionId:b,action:y,redirectTo:null==I?void 0:I.url,screenId:null==k?void 0:k.id,screenState:null==k?void 0:k.state,webauthnTransactionId:null==O?void 0:O.transactionId,webauthnOptions:null==O?void 0:O.options}):this.flowState.update({action:y})})),Di.set(this,M((()=>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}static set sdkConfigOverrides(t){rr.sdkConfigOverrides=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;return n(this,void 0,void 0,(function*(){const{projectId:l,flowId:c,tenant:d,stepId:u,executionId:h,action:p,screenId:g,screenState:y,redirectTo:O,redirectUrl:x,token:j,code:C,exchangeError:S,webauthnTransactionId:E,webauthnOptions:A,redirectAuthCodeChallenge:P,redirectAuthCallbackUrl:R}=t;let T,L;o(this,Li,"f")&&o(this,qi,"f").call(this);const M=this.sdk.getLastUserLoginId(),q=yield this.getFlowConfig(),$=R&&P?{callbackUrl:R,codeChallenge:P}:void 0;if(!h&&(q.conditions?({startScreenId:T,conditionInteractionId:L}=((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=B[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:M,code:C},q.conditions)):q.condition?({startScreenId:T,conditionInteractionId:L}=((t,e)=>{var n;const o=null===(n=B[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}})(q.condition,{loginId:M,code:C})):T=q.startScreenId,!T)){const t=C?{exchangeCode:C,idpInitiated:!0}:void 0,e=yield this.sdk.flow.start(c,Object.assign({tenant:d,redirectAuth:$},x&&{redirectUrl:x}),L,"",t,q.version);return o(this,$i,"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(h&&(r("token")&&j||r("code")&&C||r("exchangeError")&&S)){const t=yield this.sdk.flow.next(h,u,k,{token:j,exchangeCode:C,exchangeError:S},q.version);return o(this,$i,"f").call(this,t),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(p===v)return O||this.logger.error("Did not get redirect url"),void window.location.assign(O);if(p===b||p===w){if(!E||!A)return void this.logger.error("Did not get webauthn transaction id or options");let t,e;null===(a=o(this,Mi,"f"))||void 0===a||a.abort(),i(this,Mi,null,"f");try{t=p===b?yield this.sdk.webauthn.helpers.create(A):yield this.sdk.webauthn.helpers.get(A)}catch(t){if("NotAllowedError"!==t.name)return void this.logger.error(t.message);e=!0}const n=yield this.sdk.flow.next(h,u,k,{transactionId:E,response:t,cancelWebauthn:e},q.version);o(this,$i,"f").call(this,n)}if(p===m&&i(this,Li,setInterval((()=>n(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(h,u,I,{},q.version);o(this,$i,"f").call(this,t)}))),2e3),"f"),!g&&!T)return void this.logger.info("Refreshing the page during a flow is not supported yet");const D={direction:_(+u,+e.stepId),screenState:Object.assign(Object.assign({},y),{lastAuth:{loginId:M,name:this.sdk.getLastUserDisplayName()||M}}),htmlUrl:U(l,`${T||g}.html`)},N=function(t){const e={};if(t)try{Object.assign(e,JSON.parse(localStorage.getItem(f)))}catch(t){}return e}(M);T?D.next=(t,e)=>this.sdk.flow.start(c,Object.assign({tenant:d,redirectAuth:$,lastAuth:N},x&&{redirectUrl:x}),L,t,Object.assign(Object.assign({},e),C&&{exchangeCode:C,idpInitiated:!0}),q.version):(r("projectId")||r("baseUrl")||r("executionId")||r("stepId"))&&(D.next=(...t)=>this.sdk.flow.next(h,u,...t)),this.stepState.update(D)}))}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 E(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,Ti,"m",Wi).call(this,u,a):u.querySelectorAll(`button[${g}="biometrics"]`).forEach((t=>t.setAttribute("disabled","true"))),J(u,l),((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,Ti,"m",zi).call(this,a),o(this,Ti,"m",Vi).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${g}="polling"]`)){const t=yield a(I,{});o(this,$i,"f").call(this,t)}}));s?o(this,Ti,"m",Bi).call(this,p,s):p()}))}}Li=new WeakMap,Mi=new WeakMap,qi=new WeakMap,$i=new WeakMap,Di=new WeakMap,Ti=new WeakSet,Ni=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}))}},Wi=function(t,e){var r;return n(this,void 0,void 0,(function*(){null===(r=o(this,Mi,"f"))||void 0===r||r.abort();const s=t.querySelector('input[autocomplete="webauthn"]');if(s&&(yield H())){const{options:t,transactionId:r}=(yield o(this,Di,"f").call(this))||{};t&&r&&(o(this,Ti,"m",Ni).call(this,s),i(this,Mi,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(t,o(this,Mi,"f")).then((t=>n(this,void 0,void 0,(function*(){const n=yield e(s.id,{transactionId:r,response:t});o(this,$i,"f").call(this,n)})))).catch((t=>{"AbortError"!==t.name&&this.logger.error("Conditional login failed",t.message)})))}}))},Fi=function(){return Array.from(this.shadowRoot.querySelectorAll(".descope-input")).every((t=>(t.reportValidity(),t.checkValidity())))},Ki=function(){return Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${p}])`)).reduce(((t,e)=>e.name?Object.assign(t,{[e.name]:e["checkbox"===e.type?"checked":"value"]}):t),{})},Ji=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"))}))},Hi=function(t,e){return n(this,void 0,void 0,(function*(){if(t.formNoValidate||o(this,Ti,"m",Fi).call(this)){const i=null==t?void 0:t.getAttribute("id");o(this,Ti,"m",Ji).call(this,t);const r=o(this,Ti,"m",Ki).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,$i,"f").call(this,l)}var n}))},zi=function(t){this.rootElement.querySelectorAll("button").forEach((e=>{e.onclick=()=>{o(this,Ti,"m",Hi).call(this,e,t)}}))},Bi=function(t,e){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),t()}),{once:!0});const n=e===O.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")},Vi=function(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))},customElements.define("descope-wc",sr);const ar=document.createElement("template");ar.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 lr extends HTMLElement{constructor(){super(),Zi.add(this),Gi.set(this,new K({messages:[]})),Xi.set(this,void 0),Yi.set(this,void 0),Qi.set(this,void 0),tr.set(this,{resize:o(this,Zi,"m",ir).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(ar.content.cloneNode(!0)),i(this,Xi,this.shadowRoot.querySelector(".debugger"),"f"),i(this,Yi,o(this,Xi,"f").querySelector(".content"),"f"),i(this,Qi,o(this,Xi,"f").querySelector(".header"),"f")}updateData(t){o(this,Gi,"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]=z(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,Xi,"f"),o(this,Qi,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,tr,"f").resize),(t=o(this,Xi,"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,Xi,"f").onresize=o(this,Zi,"m",or).bind(this),o(this,Gi,"f").subscribe(o(this,Zi,"m",er).bind(this))}disconnectedCallback(){o(this,Gi,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,tr,"f").resize)}}Gi=new WeakMap,Xi=new WeakMap,Yi=new WeakMap,Qi=new WeakMap,tr=new WeakMap,Zi=new WeakSet,er=function(t){o(this,Zi,"m",nr).call(this,t),o(this,Zi,"m",or).call(this)},nr=function(t){o(this,Yi,"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("")},or=function(){o(this,Yi,"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)}))},ir=function(){const[t,e]=z(o(this,Xi,"f"),Number.parseInt(o(this,Xi,"f").style.left,10),Number.parseInt(o(this,Xi,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,Xi,"f").style.top=`${e}px`,o(this,Xi,"f").style.left=`${t}px`},customElements.define("descope-debugger",lr);var cr=Object.freeze({__proto__:null,default:lr})}();
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="t",c="code",d="err",u="ra-challenge",h="ra-callback",p="data-exclude-field",f="dls_last_auth",g="data-type",v="redirect",m="poll",b="webauthnCreate",w="webauthnGet",y="v2-alpha",k="submit",I="polling";var O,x,j;function C(t){return new URLSearchParams(window.location.search).get(t)}function S(t){if(window.history.replaceState&&C(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 E(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"}(O||(O={}));const A=(...t)=>t.join("/").replace(/\/+/g,"/");function U(t,e){const n=new URL(s);return n.pathname=A(n.pathname,t,y,e),n.toString()}function _(t,e){if(!Number.isNaN(t)&&!Number.isNaN(e))return t>e?O.forward:t<e?O.backward:void 0}const P=()=>{const[t="",e=""]=(C(a)||"").split("_");return{executionId:t,stepId:e}};function R(){S(a)}const T=t=>t.replace(/-./g,(t=>t[1].toUpperCase())),L=()=>{const{executionId:t,stepId:e}=P();(t||e)&&R();const n=C(l)||void 0;n&&S(l);const o=C(c)||void 0;o&&S(c);const i=C(d)||void 0;i&&S(d);const{redirectAuthCodeChallenge:r,redirectAuthCallbackUrl:s}={redirectAuthCodeChallenge:C(u),redirectAuthCallbackUrl:C(h)};return(r||s)&&(S(u),S(h)),{executionId:t,stepId:e,token:n,code:o,exchangeError:i,redirectAuthCodeChallenge:r,redirectAuthCallbackUrl:s}},M=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}},q=null===(j=null===(x=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===x?void 0:x.brands)||void 0===j?void 0:j.find((({brand:t,version:e})=>"Chromium"===t&&parseFloat(e)));var $,D,N,W;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 K{constructor(t={},{updateOnlyOnChange:e=!0}={}){$.set(this,void 0),D.set(this,{}),N.set(this,0),W.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,W,"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,W,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,W=new WeakMap;const J=(t,e)=>{var n;((t,e,n="")=>{t.querySelectorAll(`[${g}="${e}"]`).forEach((t=>{t.textContent=n,t.classList[n?"remove":"add"]("hide")}))})(t,"error-message",null==e?void 0:e.errorText),((t,e)=>{Object.entries(e||{}).forEach((([e,n])=>{Array.from(t.querySelectorAll(`.descope-input[name="${e}"]:not([${p}])`)).forEach((t=>{t.value=n}))}))})(t,null==e?void 0:e.inputs),((t,e)=>{t.querySelectorAll(`[${g}="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,n)=>{return o=e,n.split(".").reduce(((t,e)=>(null==t?void 0:t[e])||""),o);var o})))(t.textContent,e)}))})(t,e)},H=M((()=>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((()=>q()>=r))])}catch(t){return console.warn("webauthn","Conditional login check failed",t),!1}})))),z=(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))]},B={"lastAuth.loginId":{"not-empty":t=>!!t.loginId,empty:t=>!t.loginId},idpInitiated:{"is-true":t=>!!t.code,"is-false":t=>!t.code}};function V(t){this.message=t}V.prototype=new Error,V.prototype.name="InvalidCharacterError";var Z="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new V("'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 G(t){this.message=t}function X(t,e){if("string"!=typeof t)throw new G("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(Z(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 Z(e)}}(t.split(".")[n]))}catch(t){throw new G("Invalid token specified: "+t.message)}}G.prototype=new Error,G.prototype.name="InvalidTokenError";var Y="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},Q="Expected a function",tt="__lodash_hash_undefined__",et=1/0,nt="[object Function]",ot="[object GeneratorFunction]",it="[object Symbol]",rt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,st=/^\w*$/,at=/^\./,lt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ct=/\\(\\)?/g,dt=/^\[object .+?Constructor\]$/,ut="object"==typeof Y&&Y&&Y.Object===Object&&Y,ht="object"==typeof self&&self&&self.Object===Object&&self,pt=ut||ht||Function("return this")();var ft,gt=Array.prototype,vt=Function.prototype,mt=Object.prototype,bt=pt["__core-js_shared__"],wt=(ft=/[^.]+$/.exec(bt&&bt.keys&&bt.keys.IE_PROTO||""))?"Symbol(src)_1."+ft:"",yt=vt.toString,kt=mt.hasOwnProperty,It=mt.toString,Ot=RegExp("^"+yt.call(kt).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),xt=pt.Symbol,jt=gt.splice,Ct=qt(pt,"Map"),St=qt(Object,"create"),Et=xt?xt.prototype:void 0,At=Et?Et.toString:void 0;function Ut(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 _t(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 Rt(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 Tt(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||Kt(t))return!0;return st.test(t)||!rt.test(t)||null!=e&&t in Object(e)}(e,t)?[e]:Wt(n=e)?n:$t(n);for(var o=0,i=e.length;null!=t&&o<i;)t=t[Dt(e[o++])];return o&&o==i?t:void 0}function Lt(t){if(!Ft(t)||(e=t,wt&&wt in e))return!1;var e,n=function(t){var e=Ft(t)?It.call(t):"";return e==nt||e==ot}(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t)?Ot:dt;return n.test(function(t){if(null!=t){try{return yt.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}function Mt(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 qt(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return Lt(n)?n:void 0}Ut.prototype.clear=function(){this.__data__=St?St(null):{}},Ut.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},Ut.prototype.get=function(t){var e=this.__data__;if(St){var n=e[t];return n===tt?void 0:n}return kt.call(e,t)?e[t]:void 0},Ut.prototype.has=function(t){var e=this.__data__;return St?void 0!==e[t]:kt.call(e,t)},Ut.prototype.set=function(t,e){return this.__data__[t]=St&&void 0===e?tt:e,this},_t.prototype.clear=function(){this.__data__=[]},_t.prototype.delete=function(t){var e=this.__data__,n=Rt(e,t);return!(n<0)&&(n==e.length-1?e.pop():jt.call(e,n,1),!0)},_t.prototype.get=function(t){var e=this.__data__,n=Rt(e,t);return n<0?void 0:e[n][1]},_t.prototype.has=function(t){return Rt(this.__data__,t)>-1},_t.prototype.set=function(t,e){var n=this.__data__,o=Rt(n,t);return o<0?n.push([t,e]):n[o][1]=e,this},Pt.prototype.clear=function(){this.__data__={hash:new Ut,map:new(Ct||_t),string:new Ut}},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 $t=Nt((function(t){var e;t=null==(e=t)?"":function(t){if("string"==typeof t)return t;if(Kt(t))return At?At.call(t):"";var e=t+"";return"0"==e&&1/t==-et?"-0":e}(e);var n=[];return at.test(t)&&n.push(""),t.replace(lt,(function(t,e,o,i){n.push(o?i.replace(ct,"$1"):e||t)})),n}));function Dt(t){if("string"==typeof t||Kt(t))return t;var e=t+"";return"0"==e&&1/t==-et?"-0":e}function Nt(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError(Q);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(Nt.Cache||Pt),n}Nt.Cache=Pt;var Wt=Array.isArray;function Ft(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Kt(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&It.call(t)==it}var Jt=function(t,e,n){var o=null==t?void 0:Tt(t,e);return void 0===o?n:o},Ht="/v1/auth/accesskey/exchange",zt="/v1/auth/otp/verify",Bt="/v1/auth/otp/signin",Vt="/v1/auth/otp/signup",Zt={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},Gt="/v1/auth/otp/signup-in",Xt="/v1/auth/magiclink/verify",Yt="/v1/auth/magiclink/signin",Qt="/v1/auth/magiclink/signup",te={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},ee="/v1/auth/magiclink/signup-in",ne="/v1/auth/enchantedlink/verify",oe="/v1/auth/enchantedlink/signin",ie="/v1/auth/enchantedlink/signup",re="/v1/auth/enchantedlink/pending-session",se={email:"/v1/auth/enchantedlink/update/email"},ae="/v1/auth/enchantedlink/signup-in",le="/v1/auth/oauth/authorize",ce="/v1/auth/oauth/exchange",de="/v1/auth/saml/authorize",ue="/v1/auth/saml/exchange",he="/v1/auth/totp/verify",pe="/v1/auth/totp/signup",fe="/v1/auth/totp/update",ge={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},ve={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},me={start:"/v1/auth/webauthn/signup-in/start"},be={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},we="/v1/auth/password/signup",ye="/v1/auth/password/signin",ke="/v1/auth/password/reset",Ie="/v1/auth/password/update",Oe="/v1/auth/password/replace",xe="/v1/auth/password/policy",je="/v1/auth/refresh",Ce="/v1/auth/logout",Se="/v1/auth/logoutall",Ee="/v1/auth/me",Ae="/v1/flow/start",Ue="/v1/flow/next";const _e=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 Re;!function(t){t.get="GET",t.delete="DELETE",t.post="POST",t.put="PUT"}(Re||(Re={}));const Te=(...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}),{})),Le=t=>void 0===t?void 0:JSON.stringify(t),Me=(t,e="")=>{let n=t;return e&&(n=n+":"+e),{Authorization:`Bearer ${n}`}},qe=({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=>Pe().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 Pe().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:Te(Me(e,p),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"1.3.3"},(null==n?void 0:n.baseHeaders)||{},d),method:h,body:Le(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:Re.get,token:o}),post:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:Re.post,token:i}),put:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:Re.put,token:i}),delete:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:Re.delete,token:i}),hooks:i}};var $e={TOO_MANY_REQUESTS:429};function De(t,e,n){var o;let i=Ne(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 Ne(t){if("string"!=typeof t||!t)throw new Error("Invalid token provided");return X(t)}function We(t){const{exp:e}=Ne(t);return(new Date).getTime()/1e3>e}function Fe(t,e){return De(t,e,"permissions")}function Ke(t,e){return De(t,e,"roles")}const Je=(...t)=>t.join("/").replace(/\/{2,}/g,"/");async function He(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===$e.TOO_MANY_REQUESTS&&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),Be=(...t)=>({validate:e=>(t.forEach((t=>{const n=t(e);if(n)throw new Error(n)})),!0)}),Ve=t=>e=>t.test(e),Ze=Ve(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Ge=Ve(/^\+[1-9]{1}[0-9]{3,14}$/),Xe=ze(Ze,'"{val}" is not a valid email'),Ye=ze(Ge,'"{val}" is not a valid phone number'),Qe=ze((1,t=>t.length>=1),"Minimum length is 1");const tn=ze((t=>"string"==typeof t),"Input is not a string"),en=(...t)=>e=>(...n)=>(t.forEach(((t,e)=>Be(...t).validate(n[e]))),e(...n)),nn=t=>[tn(`"${t}" must be a string`),Qe(`"${t}" must not be empty`)],on=t=>[tn(`"${t}" must be a string`),Xe()],rn=t=>[tn(`"${t}" must be a string`),Ye()],sn=en(nn("accessKey")),an=t=>({exchange:sn((e=>He(t.post(Ht,{},{token:e}))))});var ln,cn;!function(t){t.sms="sms",t.whatsapp="whatsapp"}(ln||(ln={})),function(t){t.email="email"}(cn||(cn={}));const dn=Object.assign(Object.assign({},ln),cn);var un;!function(t){t.waiting="waiting",t.running="running",t.completed="completed",t.failed="failed"}(un||(un={}));const hn=nn("loginId"),pn=en(nn("token")),fn=en(hn),gn=en(nn("pendingRef")),vn=en(hn,on("email")),mn=t=>({verify:pn((e=>He(t.post(ne,{token:e})))),signIn:fn(((e,n,o,i)=>He(t.post(Je(oe,dn.email),{loginId:e,URI:n,loginOptions:o},{token:i})))),signUpOrIn:fn(((e,n)=>He(t.post(Je(ae,dn.email),{loginId:e,URI:n})))),signUp:fn(((e,n,o)=>He(t.post(Je(ie,dn.email),{loginId:e,URI:n,user:o})))),waitForSession:gn(((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||_e,_e)}))(n);let s;const a=setInterval((async()=>{const n=await t.post(re,{pendingRef:e});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(He(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:vn(((e,n,o,i,r)=>He(t.post(se.email,Object.assign({loginId:e,email:n,URI:o},r),{token:i}))))}}),bn=en(nn("flowId")),wn=en(nn("executionId"),nn("stepId"),nn("interactionId")),yn=t=>({start:bn(((e,n,o,i,r,s)=>He(t.post(Ae,{flowId:e,options:n,conditionInteractionId:o,interactionId:i,input:r,version:s})))),next:wn(((e,n,o,i,r)=>He(t.post(Ue,{executionId:e,stepId:n,interactionId:o,input:i,version:r}))))}),kn=nn("loginId"),In=en(nn("token")),On=en(kn),xn=en(kn,rn("phone")),jn=en(kn,on("email")),Cn=t=>({verify:In((e=>He(t.post(Xt,{token:e})))),signIn:Object.keys(dn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:On(((e,o,i,r)=>He(t.post(Je(Yt,n),{loginId:e,URI:o,loginOptions:i},{token:r}))))})),{}),signUp:Object.keys(dn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:On(((e,o,i)=>He(t.post(Je(Qt,n),{loginId:e,URI:o,user:i}))))})),{}),signUpOrIn:Object.keys(dn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:On(((e,o)=>He(t.post(Je(ee,n),{loginId:e,URI:o}))))})),{}),update:{email:jn(((e,n,o,i,r)=>He(t.post(te.email,Object.assign({loginId:e,email:n,URI:o},r),{token:i})))),phone:Object.keys(ln).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:xn(((e,o,i,r,s)=>He(t.post(Je(te.phone,n),Object.assign({loginId:e,phone:o,URI:i},s),{token:r}))))})),{})}});var Sn;!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"}(Sn||(Sn={}));const En=en(nn("code")),An=t=>({start:Object.keys(Sn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:(e,o,i)=>He(t.post(le,o||{},{queryParams:Object.assign({provider:n},e&&{redirectURL:e}),token:i}))})),{}),exchange:En((e=>He(t.post(ce,{code:e}))))}),Un=nn("loginId"),_n=en(Un,nn("code")),Pn=en(Un),Rn=en(Un,rn("phone")),Tn=en(Un,on("email")),Ln=t=>({verify:Object.keys(dn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:_n(((e,o)=>He(t.post(Je(zt,n),{code:o,loginId:e}))))})),{}),signIn:Object.keys(dn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Pn(((e,o,i)=>He(t.post(Je(Bt,n),{loginId:e,loginOptions:o},{token:i}))))})),{}),signUp:Object.keys(dn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Pn(((e,o)=>He(t.post(Je(Vt,n),{loginId:e,user:o}))))})),{}),signUpOrIn:Object.keys(dn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Pn((e=>He(t.post(Je(Gt,n),{loginId:e}))))})),{}),update:{email:Tn(((e,n,o,i)=>He(t.post(Zt.email,Object.assign({loginId:e,email:n},i),{token:o})))),phone:Object.keys(ln).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:Rn(((e,o,i,r)=>He(t.post(Je(Zt.phone,n),Object.assign({loginId:e,phone:o},r),{token:i}))))})),{})}}),Mn=en(nn("tenant")),qn=en(nn("code")),$n=t=>({start:Mn(((e,n,o,i)=>He(t.post(de,o||{},{queryParams:{tenant:e,redirectURL:n},token:i})))),exchange:qn((e=>He(t.post(ue,{code:e}))))}),Dn=nn("loginId"),Nn=en(Dn,nn("code")),Wn=en(Dn),Fn=en(Dn),Kn=t=>({signUp:Wn(((e,n)=>He(t.post(pe,{loginId:e,user:n})))),verify:Nn(((e,n,o,i)=>He(t.post(he,{loginId:e,code:n,loginOptions:o},{token:i})))),update:Fn(((e,n)=>He(t.post(fe,{loginId:e},{token:n}))))}),Jn=nn("loginId"),Hn=nn("newPassword"),zn=en(Jn,nn("password")),Bn=en(Jn),Vn=en(Jn,Hn),Zn=en(Jn,nn("oldPassword"),Hn),Gn=t=>({signUp:zn(((e,n,o)=>He(t.post(we,{loginId:e,password:n,user:o})))),signIn:zn(((e,n)=>He(t.post(ye,{loginId:e,password:n})))),sendReset:Bn(((e,n)=>He(t.post(ke,{loginId:e,redirectUrl:n})))),update:Vn(((e,n,o)=>He(t.post(Ie,{loginId:e,newPassword:n},{token:o})))),replace:Zn(((e,n,o)=>He(t.post(Oe,{loginId:e,oldPassword:n,newPassword:o})))),policy:()=>He(t.get(xe))}),Xn=[tn('"loginId" must be a string')],Yn=nn("loginId"),Qn=nn("origin"),to=en(Yn,Qn,nn("name")),eo=en(Yn,Qn),no=en(Xn,Qn),oo=en(Yn,Qn,nn("token")),io=en(nn("transactionId"),nn("response")),ro=t=>({signUp:{start:to(((e,n,o)=>He(t.post(ge.start,{user:{loginId:e,name:o},origin:n})))),finish:io(((e,n)=>He(t.post(ge.finish,{transactionId:e,response:n}))))},signIn:{start:no(((e,n,o,i)=>He(t.post(ve.start,{loginId:e,origin:n,loginOptions:o},{token:i})))),finish:io(((e,n)=>He(t.post(ve.finish,{transactionId:e,response:n}))))},signUpOrIn:{start:eo(((e,n)=>He(t.post(me.start,{loginId:e,origin:n}))))},update:{start:oo(((e,n,o)=>He(t.post(be.start,{loginId:e,origin:n},{token:o})))),finish:io(((e,n)=>He(t.post(be.finish,{transactionId:e,response:n}))))}}),so=en(nn("token"));var ao,lo=en([("projectId",ao=nn("projectId"),ze(((t,e)=>n=>Be(...e).validate(Jt(n,t)))("projectId",ao))())])((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=qe({baseUrl:n||"https://api.descope.com",projectId:t,logger:e,hooks:o,cookiePolicy:i,baseConfig:{baseHeaders:r},fetch:s}),{accessKey:an(a),otp:Ln(a),magicLink:Cn(a),enchantedLink:mn(a),oauth:An(a),saml:$n(a),totp:Kn(a),webauthn:ro(a),password:Gn(a),flow:yn(a),refresh:t=>He(a.post(je,{},{token:t})),logout:t=>He(a.post(Ce,{},{token:t})),logoutAll:t=>He(a.post(Se,{},{token:t})),me:t=>He(a.get(Ee,{token:t})),isJwtExpired:so(We),getJwtPermissions:so(Fe),getJwtRoles:so(Ke),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 co=(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 uo=Object.assign(lo,{DeliveryMethods:dn});var ho="Blocked by CSP",po="API key required",fo="3.8.3",go="9319";function vo(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===ho||e===go}(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 mo="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",bo="Failed to load the JS script of the agent";function wo(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:mo;return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error(po);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(fo):t}))}(String(t),e)}))}(l,s);return vo(t,yo).catch(Io)})).then((function(e){var n=e[0],o=e[1];return n.load(t(t({},a),{ldi:o}))}))}function yo(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(ho)}();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(bo))},o.async=!0,o.src=t,r.appendChild(o)}))}(t)})).then(ko)}function ko(){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(go);return n}function Io(t){throw t instanceof Error&&t.message===go?new Error(bo):t}
2
+ /*! js-cookie v3.0.5 | MIT */function Oo(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 xo=function t(e,n){function o(t,o,i){if("undefined"!=typeof document){"number"==typeof(i=Oo({},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,"",Oo({},e,{expires:-1}))},withAttributes:function(e){return t(this.converter,Oo({},this.attributes,e))},withConverter:function(e){return t(Oo({},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 jo=(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},Co=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||{}},So=async t=>{const e=await Co(t);return(null==e?void 0:e.user)||((null==e?void 0:e.hasOwnProperty("userId"))?e:void 0)},Eo="undefined"!=typeof localStorage,Ao=(t,e)=>Eo&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(t,e)),Uo=t=>Eo&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(t)),_o=t=>Eo&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(t)),Po="undefined"!=typeof window,Ro=Po&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://fp.descope.com",To=(t="",e="")=>({vsid:t,vrid:e}),Lo=(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},Mo=t=>(t.body&&(t.body.fpData=Lo(!0)||To()),t),qo="dls_last_user_login_id",$o="dls_last_user_display_name",Do=()=>Uo(qo),No=()=>Uo($o),Wo=t=>async(...e)=>{var n;e[1]=e[1]||{};const[,o={}]=e,i=Do(),r=No();return i&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=i,o.lastAuth.name=r),await t(...e)},Fo=t=>async(...e)=>{const n=await t(...e);return _o(qo),_o($o),n};function Ko(){const t=[];return{pub:e=>{t.forEach((t=>t(e)))},sub:e=>{const n=t.push(e)-1;return()=>t.splice(n,1)}}}const Jo="DS",Ho="DSR",zo=(t={},n)=>{var{refreshJwt:o,sessionJwt:i}=t,r=e(t,["refreshJwt","sessionJwt"]);void 0===n&&(n=!1),o&&Ao(Ho,o),i&&(n?function(t,e,{cookiePath:n,cookieDomain:o,cookieExpiration:i}){if(e){const r=new Date(1e3*i);xo.set(t,e,{path:n,domain:o,expires:r,sameSite:"Strict",secure:!0})}}(Jo,i,r):Ao(Jo,i))};function Bo(){return Uo(Ho)||""}function Vo(){return xo.get(Jo)||Uo(Jo)||""}function Zo(){_o(Ho),_o(Jo),xo.remove(Jo)}const Go=t=>Object.assign(t,{token:t.token||Bo()}),Xo=t=>async(...e)=>{const n=await t(...e);return Zo(),n};async function Yo(t){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=ii(n.publicKey.challenge),n.publicKey.user.id=ii(n.publicKey.user.id),null===(e=n.publicKey.excludeCredentials)||void 0===e||e.forEach((t=>{t.id=ii(t.id)})),n}(t);return n=await navigator.credentials.create(e),JSON.stringify({id:n.id,rawId:ri(n.rawId),type:n.type,response:{attestationObject:ri(n.response.attestationObject),clientDataJSON:ri(n.response.clientDataJSON)}});var n}async function Qo(t){const e=ni(t);return oi(await navigator.credentials.get(e))}async function ti(t,e){const n=ni(t);return n.signal=e.signal,n.mediation="conditional",oi(await navigator.credentials.get(n))}async function ei(t=!1){if(!Po)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 ni(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=ii(n.publicKey.challenge),null===(e=n.publicKey.allowCredentials)||void 0===e||e.forEach((t=>{t.id=ii(t.id)})),n}function oi(t){return JSON.stringify({id:t.id,rawId:ri(t.rawId),type:t.type,response:{authenticatorData:ri(t.response.authenticatorData),clientDataJSON:ri(t.response.clientDataJSON),signature:ri(t.response.signature),userHandle:t.response.userHandle?ri(t.response.userHandle):void 0}})}function ii(t){const e=t.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(e),(t=>t.charCodeAt(0))).buffer}function ri(t){return btoa(String.fromCharCode.apply(null,new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var si,ai=(si=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 Yo(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 Qo(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 Yo(o.data.options);return await t.webauthn.signUp.finish(o.data.transactionId,e)}{const e=await Qo(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 Yo(o.data.options);return await t.webauthn.update.finish(o.data.transactionId,i)},helpers:{create:Yo,get:Qo,isSupported:ei,conditional:ti}}),(...t)=>{const e=si(...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}),li=t=>Object.assign(Object.assign({},t.flow),{start:async(...e)=>{const n=await ei(),o=Object.assign(Object.assign({redirectUrl:window.location.href},e[1]),{deviceInfo:{webAuthnSupport:n}});return e[1]=o,t.flow.start(...e)}});const ci=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?(Po?i&&(async t=>{try{if(Lo())return;const e=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),n=wo({apiKey:t,endpoint:Ro}),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))})(To(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(jo(r,{beforeRequest:Mo}))):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(jo(i,{afterRequest:async(t,e)=>{const{refreshJwt:n,sessionJwt:o}=await Co(e);if(401===(null==e?void 0:e.status))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(),s((()=>a.refresh(n)),t)}var i}}));return co(a,["logout","logoutAll"],(t=>async(...e)=>{const n=await t(...e);return r(),n}))}),(t=>e=>t(Object.assign(Object.assign({},e),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.2.3"},e.baseHeaders)}))),(t=>e=>{const n=Ko(),o=Ko(),i=t(jo(e,{afterRequest:async(t,e)=>{if(401===(null==e?void 0:e.status))n.pub(null),o.pub(null);else{const t=await So(e);t&&o.pub(t);const{sessionJwt:i}=await Co(e);i&&n.pub(i)}}})),r=co(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(jo(e,{afterRequest:async(t,e)=>{var n;const o=await So(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=>{Ao(qo,t)})(i),(t=>{Ao($o,t)})(r))}}));let o=co(n,["flow.start"],Wo);return o=co(o,["logout","logoutAll"],Fo),Object.assign(o,{getLastUserLoginId:Do,getLastUserDisplayName:No})}),(t=>n=>{var{persistTokens:o,sessionTokenViaCookie:i}=n,r=e(n,["persistTokens","sessionTokenViaCookie"]);if(!o||!Po)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(jo(r,{beforeRequest:Go,afterRequest:async(t,e)=>{401===(null==e?void 0:e.status)?Zo():zo(await Co(e),i)}})),a=co(s,["logout","logoutAll"],Xo);return Object.assign(a,{getRefreshToken:Bo,getSessionToken:Vo})}))(((...t)=>{const e=uo(...t);return Object.assign(Object.assign({},e),{flow:li(e),webauthn:ai(e)})})),di=document.createElement("template");var ui,hi,pi,fi,gi,vi,mi,bi,wi,yi,ki,Ii,Oi,xi,ji,Ci,Si,Ei,Ai,Ui,_i,Pi,Ri,Ti,Li,Mi,qi,$i,Di,Ni,Wi,Fi,Ki,Ji,Hi,zi,Bi,Vi,Zi,Gi,Xi,Yi,Qi,tr,er,nr,or,ir;di.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 rr extends HTMLElement{constructor(t){super(),ui.add(this),hi.set(this,!1),pi.set(this,new K),fi.set(this,new K),this.nextRequestStatus=new K({isLoading:!1}),gi.set(this,void 0),vi.set(this,{popstate:o(this,ui,"m",Ii).bind(this)}),mi.set(this,void 0),ji.set(this,M((()=>n(this,void 0,void 0,(function*(){const t=U(this.projectId,"config.json");try{const{body:e,headers:n}=yield E(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,ui,"m",Pi).call(this,t,e)},info:(t,e="")=>{console.log(t,e)}},i(this,mi,t,"f"),o(this,ui,"m",bi).call(this)}static get observedAttributes(){return["project-id","flow-id","base-url","tenant","theme","debug","telemetryKey","redirect-url","auto-focus"]}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}getExecutionContext(){return n(this,void 0,void 0,(function*(){const{executionContext:t}=yield o(this,ji,"f").call(this);return t}))}getFlowConfig(){var t,e;return n(this,void 0,void 0,(function*(){const{projectConfig:n}=yield o(this,ji,"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,ui,"m",wi).call(this))return void o(this,ui,"m",yi).call(this);o(this,ui,"m",ki).call(this),o(this,ui,"m",Si).call(this),o(this,ui,"m",Ci).call(this),o(this,ui,"m",Ri).call(this);const{executionId:t,stepId:e,token:n,code:r,exchangeError:s,redirectAuthCallbackUrl:a,redirectAuthCodeChallenge:l}=L();window.addEventListener("popstate",o(this,vi,"f").popstate),o(this,pi,"f").subscribe(o(this,ui,"m",xi).bind(this)),o(this,fi,"f").subscribe(o(this,ui,"m",_i).bind(this)),o(this,pi,"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}),o(this,fi,"f").update({isDebug:this.debug}),i(this,hi,!0,"f")}}))}disconnectedCallback(){o(this,pi,"f").unsubscribeAll(),o(this,fi,"f").unsubscribeAll(),o(this,ui,"m",Ui).call(this),window.removeEventListener("popstate",o(this,vi,"f").popstate)}attributeChangedCallback(t,e,n){if(this.shadowRoot.isConnected&&o(this,hi,"f")&&e!==n&&rr.observedAttributes.includes(t)){o(this,ui,"m",ki).call(this);const i=null===e;o(this,pi,"f").update((({stepId:e,executionId:o})=>{let r=e,s=o;return i||(s=null,r=null,R()),{[T(t)]:n,stepId:r,executionId:s}})),o(this,fi,"f").update({isDebug:this.debug})}}}hi=new WeakMap,pi=new WeakMap,fi=new WeakMap,gi=new WeakMap,vi=new WeakMap,mi=new WeakMap,ji=new WeakMap,ui=new WeakSet,bi=function(){this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(di.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#wc-root")},wi=function(){const t=/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor);return!this.shadowRoot.host.closest("form")&&t},yi=function(){const t=this.shadowRoot.host,e=document.createElement("form");t.parentElement.appendChild(e),e.appendChild(t)},ki=function(){const t=["base-url","tenant","theme","debug","telemetryKey","redirect-url","auto-focus"];if(rr.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[T(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')},Ii=function(){const{stepId:t,executionId:e}=P();o(this,pi,"f").update({stepId:t,executionId:e})},Oi=function(t,e,o){const i=o||void 0,r=!!i;this.sdk=ci(Object.assign(Object.assign({persistTokens:!0},rr.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})}}))}))},xi=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,ui,"m",Oi).call(this,e,n,r)}o(this,mi,"f").call(this,t)}))},Ci=function(){var t,e,i,r;return n(this,void 0,void 0,(function*(){const{projectConfig:n}=yield o(this,ji,"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)))}))},Si=function(){o(this,ui,"m",Ei).call(this),o(this,ui,"m",Ai).call(this)},Ei=function(){return n(this,void 0,void 0,(function*(){const t=document.createElement("style"),e=U(this.projectId,"theme.css");try{const{body:n}=yield E(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)}))},Ai=function(){this.rootElement.setAttribute("data-theme",this.theme)},Ui=function(){var t;null===(t=o(this,gi,"f"))||void 0===t||t.remove(),i(this,gi,null,"f")},_i=function({isDebug:t}){return n(this,void 0,void 0,(function*(){t?(yield Promise.resolve().then((function(){return cr})),i(this,gi,document.createElement("descope-debugger"),"f"),Object.assign(o(this,gi,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),document.body.appendChild(o(this,gi,"f"))):o(this,ui,"m",Ui).call(this)}))},Pi=function(t,e){var n;t&&this.debug&&(null===(n=o(this,gi,"f"))||void 0===n||n.updateData({title:t,description:e}))},Ri=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()}},rr.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"2.3.3"}};class sr extends rr{constructor(){const t=new K;super(t.update.bind(t)),Ti.add(this),this.stepState=new K({},{updateOnlyOnChange:!1}),Li.set(this,void 0),Mi.set(this,null),qi.set(this,(()=>{clearInterval(o(this,Li,"f")),i(this,Li,null,"f")})),$i.set(this,(t=>{var e,n,i,s,a,l,c,d,u;if(!(null==t?void 0:t.ok)){o(this,qi,"f").call(this),o(this,Ti,"m",Vi).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:p,authInfo:g,lastAuth:v}=t.data;if("completed"===p)return function(t){(null==t?void 0:t.authMethod)&&r&&localStorage.setItem(f,JSON.stringify(t))}(v),o(this,qi,"f").call(this),void o(this,Ti,"m",Vi).call(this,"success",g);const{executionId:b,stepId:w,action:y,screen:k,redirect:I,webauthn:O}=t.data;y!==m?this.flowState.update({stepId:w,executionId:b,action:y,redirectTo:null==I?void 0:I.url,screenId:null==k?void 0:k.id,screenState:null==k?void 0:k.state,webauthnTransactionId:null==O?void 0:O.transactionId,webauthnOptions:null==O?void 0:O.options}):this.flowState.update({action:y})})),Di.set(this,M((()=>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}static set sdkConfigOverrides(t){rr.sdkConfigOverrides=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;return n(this,void 0,void 0,(function*(){const{projectId:l,flowId:c,tenant:d,stepId:u,executionId:h,action:p,screenId:g,screenState:y,redirectTo:O,redirectUrl:x,token:j,code:C,exchangeError:S,webauthnTransactionId:E,webauthnOptions:A,redirectAuthCodeChallenge:P,redirectAuthCallbackUrl:R}=t;let T,L;o(this,Li,"f")&&o(this,qi,"f").call(this);const M=this.sdk.getLastUserLoginId(),q=yield this.getFlowConfig(),$=R&&P?{callbackUrl:R,codeChallenge:P}:void 0;if(!h&&(q.conditions?({startScreenId:T,conditionInteractionId:L}=((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=B[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:M,code:C},q.conditions)):q.condition?({startScreenId:T,conditionInteractionId:L}=((t,e)=>{var n;const o=null===(n=B[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}})(q.condition,{loginId:M,code:C})):T=q.startScreenId,!T)){const t=C?{exchangeCode:C,idpInitiated:!0}:void 0,e=yield this.sdk.flow.start(c,Object.assign({tenant:d,redirectAuth:$},x&&{redirectUrl:x}),L,"",t,q.version);return o(this,$i,"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(h&&(r("token")&&j||r("code")&&C||r("exchangeError")&&S)){const t=yield this.sdk.flow.next(h,u,k,{token:j,exchangeCode:C,exchangeError:S},q.version);return o(this,$i,"f").call(this,t),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(p===v)return O||this.logger.error("Did not get redirect url"),void window.location.assign(O);if(p===b||p===w){if(!E||!A)return void this.logger.error("Did not get webauthn transaction id or options");let t,e;null===(a=o(this,Mi,"f"))||void 0===a||a.abort(),i(this,Mi,null,"f");try{t=p===b?yield this.sdk.webauthn.helpers.create(A):yield this.sdk.webauthn.helpers.get(A)}catch(t){if("NotAllowedError"!==t.name)return void this.logger.error(t.message);e=!0}const n=yield this.sdk.flow.next(h,u,k,{transactionId:E,response:t,cancelWebauthn:e},q.version);o(this,$i,"f").call(this,n)}if(p===m&&i(this,Li,setInterval((()=>n(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(h,u,I,{},q.version);o(this,$i,"f").call(this,t)}))),2e3),"f"),!g&&!T)return void this.logger.info("Refreshing the page during a flow is not supported yet");const D={direction:_(+u,+e.stepId),screenState:Object.assign(Object.assign({},y),{lastAuth:{loginId:M,name:this.sdk.getLastUserDisplayName()||M}}),htmlUrl:U(l,`${T||g}.html`)},N=function(t){const e={};if(t)try{Object.assign(e,JSON.parse(localStorage.getItem(f)))}catch(t){}return e}(M);T?D.next=(t,e)=>this.sdk.flow.start(c,Object.assign({tenant:d,redirectAuth:$,lastAuth:N},x&&{redirectUrl:x}),L,t,Object.assign(Object.assign({},e),C&&{exchangeCode:C,idpInitiated:!0}),q.version):(r("projectId")||r("baseUrl")||r("executionId")||r("stepId"))&&(D.next=(...t)=>this.sdk.flow.next(h,u,...t)),this.stepState.update(D)}))}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 E(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,Ti,"m",Wi).call(this,u,a):u.querySelectorAll(`button[${g}="biometrics"]`).forEach((t=>t.setAttribute("disabled","true"))),J(u,l),((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,Ti,"m",zi).call(this,a),o(this,Ti,"m",Vi).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${g}="polling"]`)){const t=yield a(I,{});o(this,$i,"f").call(this,t)}}));s?o(this,Ti,"m",Bi).call(this,p,s):p()}))}}Li=new WeakMap,Mi=new WeakMap,qi=new WeakMap,$i=new WeakMap,Di=new WeakMap,Ti=new WeakSet,Ni=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}))}},Wi=function(t,e){var r;return n(this,void 0,void 0,(function*(){null===(r=o(this,Mi,"f"))||void 0===r||r.abort();const s=t.querySelector('input[autocomplete="webauthn"]');if(s&&(yield H())){const{options:t,transactionId:r}=(yield o(this,Di,"f").call(this))||{};t&&r&&(o(this,Ti,"m",Ni).call(this,s),i(this,Mi,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(t,o(this,Mi,"f")).then((t=>n(this,void 0,void 0,(function*(){const n=yield e(s.id,{transactionId:r,response:t});o(this,$i,"f").call(this,n)})))).catch((t=>{"AbortError"!==t.name&&this.logger.error("Conditional login failed",t.message)})))}}))},Fi=function(){return Array.from(this.shadowRoot.querySelectorAll(".descope-input")).every((t=>(t.reportValidity(),t.checkValidity())))},Ki=function(){return Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${p}])`)).reduce(((t,e)=>e.name?Object.assign(t,{[e.name]:e["checkbox"===e.type?"checked":"value"]}):t),{})},Ji=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"))}))},Hi=function(t,e){return n(this,void 0,void 0,(function*(){if(t.formNoValidate||o(this,Ti,"m",Fi).call(this)){const i=null==t?void 0:t.getAttribute("id");o(this,Ti,"m",Ji).call(this,t);const r=o(this,Ti,"m",Ki).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,$i,"f").call(this,l)}var n}))},zi=function(t){this.rootElement.querySelectorAll("button").forEach((e=>{e.onclick=()=>{o(this,Ti,"m",Hi).call(this,e,t)}}))},Bi=function(t,e){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),t()}),{once:!0});const n=e===O.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")},Vi=function(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))},customElements.define("descope-wc",sr);const ar=document.createElement("template");ar.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 lr extends HTMLElement{constructor(){super(),Zi.add(this),Gi.set(this,new K({messages:[]})),Xi.set(this,void 0),Yi.set(this,void 0),Qi.set(this,void 0),tr.set(this,{resize:o(this,Zi,"m",ir).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(ar.content.cloneNode(!0)),i(this,Xi,this.shadowRoot.querySelector(".debugger"),"f"),i(this,Yi,o(this,Xi,"f").querySelector(".content"),"f"),i(this,Qi,o(this,Xi,"f").querySelector(".header"),"f")}updateData(t){o(this,Gi,"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]=z(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,Xi,"f"),o(this,Qi,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",o(this,tr,"f").resize),(t=o(this,Xi,"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,Xi,"f").onresize=o(this,Zi,"m",or).bind(this),o(this,Gi,"f").subscribe(o(this,Zi,"m",er).bind(this))}disconnectedCallback(){o(this,Gi,"f").unsubscribeAll(),window.removeEventListener("resize",o(this,tr,"f").resize)}}Gi=new WeakMap,Xi=new WeakMap,Yi=new WeakMap,Qi=new WeakMap,tr=new WeakMap,Zi=new WeakSet,er=function(t){o(this,Zi,"m",nr).call(this,t),o(this,Zi,"m",or).call(this)},nr=function(t){o(this,Yi,"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("")},or=function(){o(this,Yi,"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)}))},ir=function(){const[t,e]=z(o(this,Xi,"f"),Number.parseInt(o(this,Xi,"f").style.left,10),Number.parseInt(o(this,Xi,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});o(this,Xi,"f").style.top=`${e}px`,o(this,Xi,"f").style.left=`${t}px`},customElements.define("descope-debugger",lr);var cr=Object.freeze({__proto__:null,default:lr})}();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@descope/web-component",
3
- "version": "2.3.2",
3
+ "version": "2.3.3",
4
4
  "author": "Descope Team <info@descope.com>",
5
5
  "homepage": "https://github.com/descope/web-component",
6
6
  "bugs": {
@@ -31,7 +31,7 @@
31
31
  "@types/jest": "^29.0.0",
32
32
  "@types/node": "18.15.0",
33
33
  "dotenv": "^16.0.3",
34
- "eslint": "8.39.0",
34
+ "eslint": "8.40.0",
35
35
  "eslint-config-airbnb": "19.0.4",
36
36
  "eslint-config-airbnb-typescript": "17.0.0",
37
37
  "eslint-config-prettier": "8.8.0",
@@ -65,7 +65,7 @@
65
65
  "typescript": "^4.5.3"
66
66
  },
67
67
  "dependencies": {
68
- "@descope/web-js-sdk": "1.2.2"
68
+ "@descope/web-js-sdk": "1.2.3"
69
69
  },
70
70
  "overrides": {
71
71
  "terser": "5.17.1"