@descope/user-profile-widget 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  /**
3
- * @descope/user-profile-widget v0.13.0
3
+ * @descope/user-profile-widget v0.14.0
4
4
  */
5
- this["descope-user-profile-widget"]=function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},e.apply(this,arguments)};function t(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(e);o<i.length;o++)t.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(n[i[o]]=e[i[o]])}return n}function n(e,t,n,i){return new(n||(n=Promise))((function(o,r){function s(e){try{l(i.next(e))}catch(e){r(e)}}function a(e){try{l(i.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((i=i.apply(e,t||[])).next())}))}function i(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function o(e,t,n,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?o.call(e,n):o?o.value=n:t.set(e,n),n}function r(...e){return t=>e.reduce(((e,t)=>t(e)),t)}"function"==typeof SuppressedError&&SuppressedError;const s=e=>{const t=document.createElement("template");return t.innerHTML=e,t},a=e=>{let t,n;return(...i)=>(t&&((e,t)=>e.length===t.length&&e.every(((e,n)=>e===t[n])))(t,i)||(t=i,n=e(...i)),n)},l=(e={})=>{const t=s("<descope-wc></descope-wc>");return Object.entries(e).forEach((([e,n])=>{t.content.querySelector("descope-wc").setAttribute((e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_.]+/g,"-").toLowerCase())(e),(e=>"string"==typeof e?e:(e=>null!==e&&"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype)(e)?JSON.stringify(e):"")(n))})),t},c=e=>{const t=Symbol((e=>{const t=e.toString();let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n&=n;return n.toString(16)})(e));return n=>{if(n[t])return n;const i=e(n);return i[t]=!0,i}};var d,u,h,p;function f(e,t){const n=Object.getOwnPropertyNames(e),i=Object.getOwnPropertyNames(t);if(n.length!==i.length)return!1;for(let i=0;i<n.length;i+=1){const o=n[i],r=e[o],s=t[o];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!f(r,s))return!1}else if(r!==s)return!1}return!0}let g=class{constructor(e={},{forceUpdate:t=!1}={}){d.set(this,void 0),u.set(this,{}),h.set(this,0),p.set(this,!0),this.update=e=>{const t="function"==typeof e?e(i(this,d,"f")):e,n=Object.assign(Object.assign({},i(this,d,"f")),t);if(i(this,p,"f")||!f(i(this,d,"f"),n)){const e=i(this,d,"f");o(this,d,n,"f"),Object.freeze(i(this,d,"f")),setTimeout((()=>{Object.values(i(this,u,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},o(this,d,e,"f"),o(this,p,t,"f")}get current(){return Object.assign({},i(this,d,"f"))}subscribe(e){return o(this,h,i(this,h,"f")+1,"f"),i(this,u,"f")[i(this,h,"f")]=e,i(this,h,"f").toString()}unsubscribe(e){const t=!!i(this,u,"f")[e];return t&&delete i(this,u,"f")[e],t}unsubscribeAll(){return o(this,u,{},"f"),!0}};d=new WeakMap,u=new WeakMap,h=new WeakMap,p=new WeakMap;function v(e){if(e)return{locale:e.toLowerCase(),fallback:e.toLowerCase()};const t=navigator.language;return t?t.includes("-")?{locale:t.toLowerCase(),fallback:t.split("-")[0].toLowerCase()}:{locale:t.toLowerCase(),fallback:t.toLowerCase()}:{locale:"",fallback:""}}const m=["error","warn","info","debug"],w={error:console.error.bind(console,"[Descope]"),warn:console.warn.bind(console,"[Descope]"),info:console.info.bind(console,"[Descope]"),debug:console.debug.bind(console,"[Descope]")},b=c((e=>{var t,n,r,s;return s=class extends e{constructor(){super(...arguments),t.add(this),n.set(this,i(this,t,"m",r).call(this,w))}set logger(e){o(this,n,i(this,t,"m",r).call(this,e||w),"f")}get logger(){return i(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,r=function(e){return m.reduce(((t,n)=>(t[n]=(...t)=>{var i;this.onLogEvent(n,t),null===(i=e[n])||void 0===i||i.call(e,...t)},t)),{})},s})),y="undefined"!=typeof localStorage,k="https://static.descope.com/pages",S="https://static2.descope.com/pages",I=y&&localStorage.getItem("base.content.url")||"",C=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,A=c((e=>{var t,n;return n=class extends e{constructor(){super(...arguments),t.set(this,!0)}connectedCallback(){var e,n;null===(e=super.connectedCallback)||void 0===e||e.call(this),(null===(n=this.shadowRoot)||void 0===n?void 0:n.isConnected)&&i(this,t,"f")&&(o(this,t,!1,"f"),this.init())}async init(){}},t=new WeakMap,n})),x=c((e=>{var t,n;const o=r(b,A)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,{})}async init(){var e,n,o;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),n=this,o=e=>{var n;null===(n=i(this,t,"f")[e])||void 0===n||n.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(n.attributes).forEach((e=>o(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&o(e.attributeName)}))})).observe(n,{attributes:!0})}observeAttribute(e,n){i(this,t,"f")[e]||(i(this,t,"f")[e]=[]);const o=i(this,t,"f")[e].push(n);return()=>i(this,t,"f")[e].splice(o,1)}observeAttributes(e,t){const n=e.reduce(((e,n)=>(e.push(this.observeAttribute(n,t)),e)),[]);return()=>n.forEach((e=>e()))}},t=new WeakMap,n})),O=e=>t=>{var n,o,s;const a=r(b,A,x)(t),l=Object.keys(e);return s=class extends a{constructor(...e){super(...e),n.add(this),this.observeAttributes(l,i(this,n,"m",o).bind(this))}async init(){var e;l.forEach((e=>i(this,n,"m",o).call(this,e,this.getAttribute(e)))),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},n=new WeakSet,o=function(t,n){const i=e[t],o="function"==typeof i?i(t,n):i;o&&this.logger.error(o)},s};O.missingAttrValidator=C;const E=c((e=>{const t=r(O({"project-id":C}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),j=c((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),R="Trying the next fallback URL...",T=async(e,t,{logger:n}={})=>{try{return await fetch(e,t)}catch(i){return null==n||n.debug(`Network error fetching URL ${e} [${i.message}], retrying...`),fetch(e,t)}};const M=c((e=>{var t,n,s,a,l,c,d;const u=r(b,E,j)(e);return d=class extends u{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),a.set(this,new Set)}async fetchStaticResource(e,n){const r=i(this,t,"m",l).call(this,e),c=Array.isArray(r)?e=>{const{baseUrl:t}=r[e];o(this,s,t,"f");for(let t=0;t<e;t++){const e=r[t].baseUrl;i(this,a,"f").add(e)}}:null;try{const e=await(async(e,t,{logger:n,onSuccess:i}={})=>{const o=Array.isArray(e)?e:[e];for(let e=0;e<o.length;e++){const r=o[e],s=e===o.length-1;try{const o=await T(r.toString(),t,{logger:n});if(o.ok)return null==i||i(e),null==n||n.debug(`Successfully fetched URL ${r}`),o;const a=`Error fetching URL ${r} [${o.status}]`;if(s)throw new Error(a);null==n||n.debug(`${a}. ${R}`)}catch(e){const t=`Error fetching URL ${r} [${e.message}]`;if(s)throw new Error(t);null==n||n.debug(`${t}. ${R}`)}}})(r,{cache:"default"},{logger:this.logger,onSuccess:c});return{body:await e[n](),headers:Object.fromEntries(e.headers.entries())}}catch(e){this.logger.error(e.message)}}get baseStaticUrl(){return this.getAttribute("base-static-url")||""}},n=new WeakMap,s=new WeakMap,a=new WeakMap,t=new WeakSet,l=function(e){const r=I||this.baseStaticUrl;if(r)return i(this,t,"m",c).call(this,e,r);i(this,n,"f")!==this.baseUrl&&(o(this,n,this.baseUrl,"f"),o(this,s,void 0,"f"),i(this,a,"f").clear());const l=[];if(i(this,s,"f"))l.push(i(this,t,"m",c).call(this,e,i(this,s,"f"))),i(this,s,"f")===k&&l.push(i(this,t,"m",c).call(this,e,S));else{const n=this.baseUrl+"/pages";this.baseUrl&&!i(this,a,"f").has(n)&&l.push(i(this,t,"m",c).call(this,e,n)),i(this,a,"f").has(k)||l.push(i(this,t,"m",c).call(this,e,k)),l.push(i(this,t,"m",c).call(this,e,S))}return 1===l.length?l[0]:l},c=function(e,t){return function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:i=k}){const o=new URL(i);return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,n,t),o.baseUrl=i,o}({projectId:this.projectId,filename:e,baseUrl:t})},d})),U=c((e=>{var t,n;const o=r(O({"project-id":C}))(e);return n=class extends o{constructor(){super(...arguments),t.set(this,new Map)}onReset(e,n){if(i(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} already exists`);return i(this,t,"f").set(e,n),()=>{i(this,t,"f").delete(e)}}async reset(...e){0===e.length?await Promise.all(Array.from(i(this,t,"f").values()).map((e=>e()))):await Promise.all(e.map((e=>{var n;if(!i(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} does not exist`);return null===(n=i(this,t,"f").get(e))||void 0===n?void 0:n()})))}},t=new WeakMap,n})),W=c((e=>{var t,n,s,a,l;const c=r(M,U,A)(e);return l=class extends c{constructor(){super(...arguments),t.add(this),s.set(this,void 0),a.set(this,(async()=>{try{const{body:e,headers:t}=await this.fetchStaticResource("config.json","json");return{projectConfig:e,executionContext:{geo:t["x-geo"]}}}catch(e){this.logger.error("Cannot fetch config file","make sure that your projectId & flowId are correct")}}))}async init(){await super.init(),this.onReset("config",i(this,t,"m",n).bind(this))}get config(){return i(this,s,"f")||o(this,s,i(this,a,"f").call(this),"f"),i(this,s,"f")}},s=new WeakMap,a=new WeakMap,t=new WeakSet,n=function(){o(this,s,void 0,"f")},l})),$=c((e=>{var t,n,s,a,l,c,d;return d=class extends(r(A,b)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),this.attributeChangedCallback=(e,n,o)=>{var r;null===(r=super.attributeChangedCallback)||void 0===r||r.call(this,e,n,o),"debug"===e&&i(this,t,"m",l).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(e,n){var o;null===(o=super.onLogEvent)||void 0===o||o.call(this,e,n),"error"===e&&i(this,t,"m",c).call(this,n[0]||"Error",n[1])}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),i(this,t,"m",l).call(this)}},n=new WeakMap,t=new WeakSet,s=function(){var e;null===(e=i(this,n,"f"))||void 0===e||e.remove(),o(this,n,null,"f")},a=async function(){o(this,n,document.createElement("descope-debugger"),"f"),Object.assign(i(this,n,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),await Promise.resolve().then((function(){return gu})),document.body.appendChild(i(this,n,"f"))},l=function(){this.debug?i(this,t,"m",a).call(this):i(this,t,"m",s).call(this)},c=function(e,t){var o;e&&(null===(o=i(this,n,"f"))||void 0===o||o.updateData({title:e,description:t}))},d})),P=["https://descopecdn.com","https://static.descope.com","https://cdn.jsdelivr.net"],_=e=>{let t=0;const n=e.toString();for(let e=0;e<n.length;e++){t=(t<<5)-t+n.charCodeAt(e),t|=0}return`${Math.abs(t).toString()}`},L=(e,t,n)=>new Promise(((i,o)=>{const r=((e,t)=>{const n=document.createElement("script");return n.id=e,t&&(n.integrity=t,n.crossOrigin="anonymous"),window.DESCOPE_NONCE&&n.setAttribute("nonce",window.DESCOPE_NONCE),n})(e,n);r.onerror=e=>{r.setAttribute("status","error"),o(e)},r.onload=()=>{r.setAttribute("status","loaded"),i(r)},r.src=t.toString(),document.body.appendChild(r)})),N=(e,t)=>{if(t){const n=e.integrity;if(n!==t)return Promise.reject(new Error(`Integrity mismatch: expected ${t}, found ${n}`))}return"loaded"===e.getAttribute("status")?Promise.resolve(e):(e=>"error"===e.getAttribute("status"))(e)?Promise.reject():new Promise(((t,n)=>{e.addEventListener("load",(()=>{t(e)})),e.addEventListener("error",(e=>{n(e)}))}))},D=c((e=>{const t=r(b)(e);return class extends t{get baseCdnUrl(){return this.getAttribute("base-cdn-url")||""}injectNpmLib(e,t,n="",i=[],o){return this.logger.debug(`Injecting npm lib: "${e}" with version: "${t}"${o?" with SRI integrity check":""}`),(async(e,t)=>{for(const i of e){const{id:e,url:o,integrity:r}=i,s=(n=e,document.querySelector(`script#${n}`));if(s)try{return await N(s,r),i}catch(e){t(i,!0)}else try{return await L(e,o,r),i}catch(e){t(i,!1)}}var n;throw new Error("All scripts failed to load")})(((e,t,n,i="",o)=>e.reduce(((e,r)=>{const s=r;if(!s)return e;let a;try{a=new URL(s)}catch(e){throw new Error(`Invalid URL: ${s}`)}"/"!==a.pathname||(a.pathname=`/npm/${t}@${n}/${i}`);const l={url:a,id:`npmlib-${t.replaceAll("@","").replaceAll("/","_")}-${_(a)}`};return o&&(l.integrity=o),[...e,l]}),[]))([...i,this.baseCdnUrl,...P],e,t,n,o),((e,t)=>{t?this.logger.error(`Existing script cannot be loaded: "${e.url}"`):this.logger.error(`Cannot load script from URL, Make sure this URL is valid and return the correct script: "${e.url}"`)}))}}})),F="base.ui.components.url",q=y&&localStorage.getItem(F),z=c((e=>{var t,n,s,a,l,c,d;const u=r(b,W,D)(e);return d=class extends u{constructor(){super(...arguments),t.add(this),a.set(this,void 0)}get descopeUi(){return i(this,a,"f")||o(this,a,i(this,t,"m",c).call(this),"f"),i(this,a,"f")}async loadDescopeUiComponents(e){const n=Array.isArray(e)?e:(e=>[...Array.from(e.content.querySelectorAll("*")).reduce(((e,t)=>t.localName.startsWith("descope-")?e.add(t.localName):e),new Set)])(e);return Promise.all(n.map((e=>i(this,t,"m",l).call(this,e))))}},a=new WeakMap,t=new WeakSet,n=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return n?this.logger.debug(`Got component version "${n}"`):this.logger.error("Could not get components version"),n},s=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersionSri;return n&&this.logger.debug("SRI hash available for components"),n},l=async function(e){if(!!customElements.get(e))return void this.logger.debug(`Loading component "${e}" is skipped as it is already defined`);const t=await this.descopeUi;if(t[e])try{return await t[e]()}catch(t){if("NotSupportedError"!==t.name)throw t;console.debug(`Encountered an error while attempting to define the "${e}" component, it is likely that this component is already defined`)}else this.logger.error(`Cannot load UI component "${e}"`,`Descope UI does not have a component named "${e}", available components are: "${Object.keys(t).join(", ")}"`)},c=async function(){if(globalThis.DescopeUI)return globalThis.DescopeUI;try{const e=await i(this,t,"m",n).call(this),o=q?void 0:await i(this,t,"m",s).call(this);return await this.injectNpmLib("@descope/web-components-ui",e,"dist/umd/index.js",[q],o),this.logger.debug("DescopeUI was loaded"),globalThis.DescopeUI}catch(e){throw this.logger.error(e),new Error("DescopeUI was not loaded")}},d})),H=c((e=>{var t,n,o;const s=r(A,x)(e);return o=class extends s{constructor(){super(...arguments),t.add(this)}get nonce(){return this.getAttribute("nonce")||""}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.observeAttribute("nonce",i(this,t,"m",n).bind(this)),i(this,t,"m",n).call(this)}},t=new WeakSet,n=function(){this.nonce&&(window.DESCOPE_NONCE=this.nonce)},o}));class V{constructor(e,t,{prepend:n=!1}={}){this.styleEle=document.createElement("style"),this.styleEle.setAttribute("nonce",t),this.ref=e,this.ref&&(n?this.ref.prepend(this.styleEle):this.ref.append(this.styleEle))}replaceSync(e){this.styleEle.textContent=e}get cssRules(){var e;return null===(e=this.styleEle.sheet)||void 0===e?void 0:e.cssRules}}const B=c((e=>{const t=r(H)(e);return class extends t{injectStyle(e,{prepend:t=!1}={}){let n;try{n=new CSSStyleSheet}catch(e){n=new V(this.shadowRoot,this.nonce,{prepend:t})}if(e&&n.replaceSync(e),n instanceof CSSStyleSheet){const e=this.shadowRoot;if(e&&"adoptedStyleSheets"in e){const i=[...e.adoptedStyleSheets||[]];i[t?"unshift":"push"](n),e.adoptedStyleSheets=i}}return n}}})),J="content-root",K="root",Z=c((e=>{const t=r(B)(e);return class extends t{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${K}">\n <div id="${J}"></div>\n </div>\n `,this.injectStyle(`\n #${K}, #${J} {\n height: 100%;\n }\n #${K} {\n position: relative;\n height: fit-content;\n }\n `),this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById(J),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(K)}}})),X="descope-modal";var G;let Y=class{constructor(e,t){G.set(this,void 0),this.nodeName="",o(this,G,e,"f"),this.logger=t.logger}get asyncEle(){return(async e=>new Promise((t=>{const n=setInterval((()=>{const i="function"==typeof e?e():e;i&&(clearInterval(n),t(i))}),100);setTimeout((()=>{clearInterval(n),t(null)}),1e3)})))(i(this,G,"f"))}get ele(){var e,t;const n="function"==typeof i(this,G,"f")?i(this,G,"f").call(this):i(this,G,"f");return n?(null==n?void 0:n.localName)!==this.nodeName?(null===(t=this.logger)||void 0===t||t.debug(`node name do not match, expected "${this.nodeName}", received "${n.localName}" `,Error()),null):n:(null===(e=this.logger)||void 0===e||e.debug(`Driver element is not available for ${this.nodeName}`,new Error),null)}get isExists(){return!!this.ele}};G=new WeakMap;let Q=class extends Y{constructor(){super(...arguments),this.nodeName="descope-avatar"}set displayName(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("display-name",e)}set image(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("img",e)}get flowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id")}onClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("click",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("click",e)}}},ee=class extends Y{constructor(){super(...arguments),this.nodeName="descope-button"}onClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("click",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("click",e)}}disable(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("disabled","true")}enable(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("disabled")}},te=class extends Y{constructor(){super(...arguments),this.nodeName="descope-wc"}set projectId(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("project-id",e)}set baseUrl(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("base-url",e)}set flowId(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("flow-id",e)}set theme(e){var t,n;e?null===(n=this.ele)||void 0===n||n.setAttribute("theme",e):null===(t=this.ele)||void 0===t||t.removeAttribute("theme")}onSuccess(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("success",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("success",e)}}onPageUpdated(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("page-updated",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("page-updated",e)}}},ne=class extends ee{get flowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id"))||""}get enableMode(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("enable-mode")}};var ie;let oe=class extends Y{constructor(){super(...arguments),ie.set(this,void 0),this.nodeName="descope-modal"}close(){var e,t;null===(e=this.ele)||void 0===e||e.removeAttribute("opened"),null===(t=this.afterClose)||void 0===t||t.call(this)}async open(){var e,t;await(null===(e=this.beforeOpen)||void 0===e?void 0:e.call(this)),null===(t=this.ele)||void 0===t||t.setAttribute("opened","true")}reset(){var e;this.ele&&(this.ele.innerHTML=""),i(this,ie,"f")&&(null===(e=this.ele)||void 0===e||e.append(i(this,ie,"f").content.cloneNode(!0)))}setContent(e){o(this,ie,e,"f"),this.reset()}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}};ie=new WeakMap;let re=class extends Y{constructor(){super(...arguments),this.nodeName="descope-notification"}close(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("opened")}show(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("opened","true")}setContent(e){this.ele.innerHTML="",this.ele.appendChild(e.content.cloneNode(!0))}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}},se=class extends Y{constructor(){super(...arguments),this.nodeName="descope-combo-box"}onInput(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("input",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("input",e)}}get value(){var e;return null===(e=this.ele)||void 0===e?void 0:e.value}set value(e){this.ele&&(this.ele.value=e)}async setData(e){var t;null===(t=await this.asyncEle)||void 0===t||t.setAttribute("data",JSON.stringify(e.sort()))}setAllowCustomValue(e){this.ele&&this.ele.toggleAttribute("allow-custom-value",e)}},ae=class extends Y{constructor(){super(...arguments),this.nodeName="descope-user-attribute"}set value(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("value",e)}set badgeLabel(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("badge-label",e)}get label(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("label"))||""}get editFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("edit-flow-id"))||""}get deleteFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("delete-flow-id"))||""}onEditClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("edit-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("edit-clicked",e)}}onDeleteClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("delete-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("delete-clicked",e)}}},le=class extends Y{constructor(){super(...arguments),this.nodeName="descope-user-auth-method"}set fulfilled(e){var t,n;e?null===(t=this.ele)||void 0===t||t.setAttribute("fulfilled","true"):null===(n=this.ele)||void 0===n||n.removeAttribute("fulfilled")}onUnfulfilledButtonClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("button-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("button-clicked",e)}}onFulfilledButtonClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("fulfilled-button-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("fulfilled-button-clicked",e)}}get flowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id")}get fulfilledFlowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("fulfilled-flow-id")}},ce=class extends Y{constructor(){super(...arguments),this.nodeName="descope-trusted-devices"}set displayName(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("display-name",e)}get ele(){return super.ele}get data(){var e;return null===(e=this.ele)||void 0===e?void 0:e.data}set data(e){this.ele&&(this.ele.data=e)}get flowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id")}onRemoveDeviceClick(e){var t;const n=t=>e(t.detail);return null===(t=this.ele)||void 0===t||t.addEventListener("remove-device-clicked",n),()=>{var e;return null===(e=this.ele)||void 0===e?void 0:e.removeEventListener("remove-device-clicked",n)}}},de=class extends se{get action(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("data-action"))||""}get refreshTimeout(){var e;return Number(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("data-refresh-timeout"))||500}get shouldReload(){return"reload"===this.action}},ue=class extends Y{constructor(){super(...arguments),this.nodeName="descope-user-passkeys"}get ele(){return super.ele}get data(){var e;return null===(e=this.ele)||void 0===e?void 0:e.data}set data(e){this.ele&&(this.ele.data=e)}get addPasskeyFlowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("add-passkey-flow-id")}get removePasskeyFlowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("remove-passkey-flow-id")}onAddPasskeyClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("add-passkey-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("add-passkey-clicked",e)}}onRemovePasskeyClick(e){var t;const n=t=>e(t.detail);return null===(t=this.ele)||void 0===t||t.addEventListener("remove-passkey-clicked",n),()=>{var e;return null===(e=this.ele)||void 0===e?void 0:e.removeEventListener("remove-passkey-clicked",n)}}};const he=c((e=>{var t,n;const o=r(A,Z,z)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends oe{setContent(t){e(t),super.setContent(t)}}})())}createModal(e){const n=((e={})=>{const t=document.createElement(X);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(i(this,t,"f"))(n,{logger:this.logger})}async init(){var e;this.loadDescopeUiComponents([X]),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},t=new WeakMap,n})),pe="descope-notification",fe=c((e=>{var t,n;const o=r(A,Z,z)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends re{setContent(t){const n="string"==typeof t?s(t):t;e(n),super.setContent(n)}}})())}createNotification(e){const n=((e={})=>{const t=document.createElement(pe);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(i(this,t,"f"))(n,{logger:this.logger})}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.loadDescopeUiComponents([pe])}},t=new WeakMap,n})),ge="theme",ve=(e,t,n="")=>Object.entries(e).reduce(((e,[i,o])=>{if(!/^[a-zA-Z0-9-]+$/.test(i))return t("Ignoring invalid override-css token path segment"),e;const r=n?`${n}-${i}`:i;if("object"==typeof o&&null!==o)return e+ve(o,t,r);const s=(e=>"number"==typeof e?Number.isFinite(e)?String(e):null:"string"!=typeof e||/[;{}]/.test(e)?null:e.trim())(o);return null===s?(t("Ignoring invalid override-css token value"),e):`${e}--descope-${r}:${s};`}),"");function me(e,t){const n=Object.assign({},e);for(const[e,i]of Object.entries(t||{}))if(null!=i)if("object"==typeof i){if(0===Object.keys(i).length)continue;n[e]=me(n[e]||{},i)}else n[e]="string"==typeof i?(n[e]||"")+i:i;return n}const we=(e,t)=>null!==t&&!/^[a-zA-Z0-9_-]*$/.test(t)&&"tenant must contain only alphanumeric characters, hyphens, or underscores",be=c((e=>{const t=r(O({tenant:we}))(e);return class extends t{get tenantId(){return this.getAttribute("tenant")||void 0}}})),ye=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',ke=c((e=>{var t,n,s,a,l,c,d,u,h,p,f,g,v,m,w,b,y,k,S,I,C,E;const j=r(O({theme:ye}),be,M,A,z,W,Z,x,B)(e);return E=class extends j{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),a.set(this,void 0),c.set(this,void 0),d.set(this,void 0),S.set(this,(()=>{i(this,t,"m",I).call(this),i(this,C,"f").call(this,"os"===this.getAttribute("theme"))})),C.set(this,(e=>{var n,o,r;const s=e?"addEventListener":"removeEventListener";null===(r=null===(o=null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-color-scheme: dark)"))||void 0===o?void 0:o[s])||void 0===r||r.call(o,"change",(()=>i(this,t,"m",I).call(this)))}))}get theme(){var e,t;const n=this.getAttribute("theme");if("os"===n){return window.matchMedia&&(null===(t=null===(e=window.matchMedia)||void 0===e?void 0:e.call(window,"(prefers-color-scheme: dark)"))||void 0===t?void 0:t.matches)?"dark":"light"}return n||"light"}get styleId(){return this.getAttribute("style-id")||ge}get themeOverride(){const e=this.getAttribute("theme-override");if(!e)return null;try{return JSON.parse(e)}catch(e){return this.logger.error("Failed to parse theme-override attribute. error: ",e),null}}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),i(this,S,"f").call(this),await Promise.all([i(this,t,"m",p).call(this),i(this,t,"m",v).call(this),i(this,t,"m",w).call(this)]),i(this,t,"m",m).call(this),this.observeAttributes(["theme"],i(this,S,"f")),this.observeAttributes(["theme-override"],(()=>i(this,t,"m",m).call(this))),this.observeAttributes(["tenant"],(()=>{o(this,d,null,"f"),i(this,t,"m",v).call(this),i(this,t,"m",w).call(this)})),this.observeAttributes(["style-id"],(()=>{o(this,c,null,"f"),i(this,t,"m",y).call(this),i(this,t,"m",p).call(this),i(this,t,"m",w).call(this)}))}},n=new WeakMap,s=new WeakMap,a=new WeakMap,c=new WeakMap,d=new WeakMap,S=new WeakMap,C=new WeakMap,t=new WeakSet,l=function(){const e=this.themeOverride;return e?["light","dark"].map((t=>{var n,i,o,r,s,a;const l=null===(o=null===(i=null===(n=e[t])||void 0===n?void 0:n.globals)||void 0===i?void 0:i.colors)||void 0===o?void 0:o.primary,c=null===(a=null===(s=null===(r=e[t])||void 0===r?void 0:r.globals)||void 0===s?void 0:s.colors)||void 0===a?void 0:a.secondary;return l||c?`[data-theme="${t}"]{${ve({colors:{primary:l,secondary:c}},(e=>this.logger.error(e)))}}`:""})).join(""):""},u=async function(){try{const{body:e}=await this.fetchStaticResource(`${this.styleId}.json`,"json");if(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(F))try{this.logger.warn("You are in DEV mode, and UI components override URL was found\ntrying to merge project theme with the default theme of the UI components");const t=await(async()=>{const e=localStorage.getItem(F),t=null==e?void 0:e.replace(/[^\/]+$/,"DescopeDev.js");console.warn("Trying to load DescopeDev.js from",t);const n=document.createElement("script");if(n.src=t,document.body.appendChild(n),await new Promise(((e,t)=>{n.onload=e,n.onerror=t})),globalThis.DescopeDev){const{themeToStyle:e,defaultTheme:t,darkTheme:n}=globalThis.DescopeDev;return{light:e(t),dark:e(n)}}})();t&&(e.light.components=Object.assign(Object.assign({},e.light.components),t.light.components),e.dark.components=Object.assign(Object.assign({},e.dark.components),t.dark.components),this.logger.warn("Theme was merged successfully"),console.log("%cNOTICE! This is not the theme that will be used in production!\n\nMake sure to test it without the override UI components URL!","color: black; background-color:yellow; font-size: x-large"))}catch(e){this.logger.error("Failed to merge UI components theme\n",e)}return e}catch(e){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}},h=function(){return i(this,c,"f")||(o(this,c,i(this,t,"m",u).call(this),"f"),i(this,c,"f").then((e=>this.logger.debug("Fetched theme",e)))),i(this,c,"f")},p=async function(){var e,r;const s=await i(this,t,"a",h);if(!s)return;const a=((null===(e=null==s?void 0:s.light)||void 0===e?void 0:e.globals)||"")+((null===(r=null==s?void 0:s.dark)||void 0===r?void 0:r.globals)||"");i(this,n,"f")?i(this,n,"f").replaceSync(a):o(this,n,this.injectStyle(a,{prepend:!0}),"f")},f=async function(){const e=this.tenantId;if(e)try{const{body:t}=await this.fetchStaticResource(`${e}/theme.json`,"json");return t}catch(e){this.logger.error("Cannot fetch tenant theme file","make sure that your tenantId, projectId & flowId are correct")}},g=function(){return i(this,d,"f")||o(this,d,i(this,t,"m",f).call(this),"f"),i(this,d,"f")},v=async function(){var e,n,r,a;if(!this.tenantId)return void(null===(e=i(this,s,"f"))||void 0===e||e.replaceSync(""));const l=await i(this,t,"a",g);if(!l)return void(null===(n=i(this,s,"f"))||void 0===n||n.replaceSync(""));const c=((null===(r=l.light)||void 0===r?void 0:r.globals)||"")+((null===(a=l.dark)||void 0===a?void 0:a.globals)||"");i(this,s,"f")?i(this,s,"f").replaceSync(c):o(this,s,this.injectStyle(c),"f")},m=async function(){var e;if(!this.themeOverride)return void(null===(e=i(this,a,"f"))||void 0===e||e.replaceSync(""));const n=i(this,t,"m",l).call(this);i(this,a,"f")?i(this,a,"f").replaceSync(n):o(this,a,this.injectStyle(n),"f")},w=async function(){var e,n,o,r;const s=await i(this,t,"a",h);if(!s)return;const a=await this.descopeUi;if(!(null==a?void 0:a.componentsThemeManager))return;const l=await i(this,t,"a",g);a.componentsThemeManager.themes={light:me((null===(e=null==s?void 0:s.light)||void 0===e?void 0:e.components)||{},(null===(n=null==l?void 0:l.light)||void 0===n?void 0:n.components)||{}),dark:me((null===(o=null==s?void 0:s.dark)||void 0===o?void 0:o.components)||{},(null===(r=null==l?void 0:l.dark)||void 0===r?void 0:r.components)||{})}},b=async function(){var e,t;const{projectConfig:n}=await this.config||{},i=null===(e=null==n?void 0:n.styles)||void 0===e?void 0:e[this.styleId],o=null==n?void 0:n.cssTemplate,r=i||o;return null===(t=null==r?void 0:r[this.theme])||void 0===t?void 0:t.fonts},y=async function(){const e=await i(this,t,"m",b).call(this);e?Object.values(e).forEach((e=>{e.url&&(this.logger.debug(`Loading font from URL "${e.url}"`),(e=>{const t=document.createElement("link");t.href=e,t.rel="stylesheet",document.head.appendChild(t)})(e.url))})):this.logger.debug("No fonts to load")},k=async function(){this.rootElement.setAttribute("data-theme",this.theme);const e=await this.descopeUi;(null==e?void 0:e.componentsThemeManager)&&(e.componentsThemeManager.currentThemeName=this.theme)},I=function(){i(this,t,"m",y).call(this),i(this,t,"m",k).call(this)},E}));var Se=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),Ie=()=>Math.random().toString(36).substring(7).split("").join("."),Ce={INIT:`@@redux/INIT${Ie()}`,REPLACE:`@@redux/REPLACE${Ie()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${Ie()}`};function Ae(e){if("object"!=typeof e||null===e)return!1;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||null===Object.getPrototypeOf(e)}function xe(e){if(void 0===e)return"undefined";if(null===e)return"null";const t=typeof e;switch(t){case"boolean":case"string":case"number":case"symbol":case"function":return t}if(Array.isArray(e))return"array";if(function(e){return e instanceof Date||"function"==typeof e.toDateString&&"function"==typeof e.getDate&&"function"==typeof e.setDate}(e))return"date";if(function(e){return e instanceof Error||"string"==typeof e.message&&e.constructor&&"number"==typeof e.constructor.stackTraceLimit}(e))return"error";const n=function(e){return"function"==typeof e.constructor?e.constructor.name:null}(e);switch(n){case"Symbol":case"Promise":case"WeakMap":case"WeakSet":case"Map":case"Set":return n}return Object.prototype.toString.call(e).slice(8,-1).toLowerCase().replace(/\s/g,"")}function Oe(e){let t=typeof e;return t=xe(e),t}function Ee(e,t,n){if("function"!=typeof e)throw new Error(`Expected the root reducer to be a function. Instead, received: '${Oe(e)}'`);if("function"==typeof t&&"function"==typeof n||"function"==typeof n&&"function"==typeof arguments[3])throw new Error("It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.");if("function"==typeof t&&void 0===n&&(n=t,t=void 0),void 0!==n){if("function"!=typeof n)throw new Error(`Expected the enhancer to be a function. Instead, received: '${Oe(n)}'`);return n(Ee)(e,t)}let i=e,o=t,r=new Map,s=r,a=0,l=!1;function c(){s===r&&(s=new Map,r.forEach(((e,t)=>{s.set(t,e)})))}function d(){if(l)throw new Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return o}function u(e){if("function"!=typeof e)throw new Error(`Expected the listener to be a function. Instead, received: '${Oe(e)}'`);if(l)throw new Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");let t=!0;c();const n=a++;return s.set(n,e),function(){if(t){if(l)throw new Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");t=!1,c(),s.delete(n),r=null}}}function h(e){if(!Ae(e))throw new Error(`Actions must be plain objects. Instead, the actual type was: '${Oe(e)}'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.`);if(void 0===e.type)throw new Error('Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');if("string"!=typeof e.type)throw new Error(`Action "type" property must be a string. Instead, the actual type was: '${Oe(e.type)}'. Value was: '${e.type}' (stringified)`);if(l)throw new Error("Reducers may not dispatch actions.");try{l=!0,o=i(o,e)}finally{l=!1}return(r=s).forEach((e=>{e()})),e}h({type:Ce.INIT});return{dispatch:h,subscribe:u,getState:d,replaceReducer:function(e){if("function"!=typeof e)throw new Error(`Expected the nextReducer to be a function. Instead, received: '${Oe(e)}`);i=e,h({type:Ce.REPLACE})},[Se]:function(){const e=u;return{subscribe(t){if("object"!=typeof t||null===t)throw new Error(`Expected the observer to be an object. Instead, received: '${Oe(t)}'`);function n(){const e=t;e.next&&e.next(d())}n();return{unsubscribe:e(n)}},[Se](){return this}}}}}function je(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}function Re(e){const t=Object.keys(e),n={};for(let i=0;i<t.length;i++){const o=t[i];void 0===e[o]&&je(`No reducer provided for key "${o}"`),"function"==typeof e[o]&&(n[o]=e[o])}const i=Object.keys(n);let o,r;o={};try{!function(e){Object.keys(e).forEach((t=>{const n=e[t];if(void 0===n(void 0,{type:Ce.INIT}))throw new Error(`The slice reducer for key "${t}" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);if(void 0===n(void 0,{type:Ce.PROBE_UNKNOWN_ACTION()}))throw new Error(`The slice reducer for key "${t}" returned undefined when probed with a random type. Don't try to handle '${Ce.INIT}' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.`)}))}(n)}catch(e){r=e}return function(e={},t){if(r)throw r;{const i=function(e,t,n,i){const o=Object.keys(t),r=n&&n.type===Ce.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(0===o.length)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!Ae(e))return`The ${r} has unexpected type of "${Oe(e)}". Expected argument to be an object with the following keys: "${o.join('", "')}"`;const s=Object.keys(e).filter((e=>!t.hasOwnProperty(e)&&!i[e]));return s.forEach((e=>{i[e]=!0})),n&&n.type===Ce.REPLACE?void 0:s.length>0?`Unexpected ${s.length>1?"keys":"key"} "${s.join('", "')}" found in ${r}. Expected to find one of the known reducer keys instead: "${o.join('", "')}". Unexpected keys will be ignored.`:void 0}(e,n,t,o);i&&je(i)}let s=!1;const a={};for(let o=0;o<i.length;o++){const r=i[o],l=n[r],c=e[r],d=l(c,t);if(void 0===d){const e=t&&t.type;throw new Error(`When called with an action of type ${e?`"${String(e)}"`:"(unknown type)"}, the slice reducer for key "${r}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`)}a[r]=d,s=s||d!==c}return s=s||i.length!==Object.keys(e).length,s?a:e}}function Te(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...n)=>e(t(...n))))}function Me(e){return Ae(e)&&"type"in e&&"string"==typeof e.type}var Ue=Symbol.for("immer-nothing"),We=Symbol.for("immer-draftable"),$e=Symbol.for("immer-state"),Pe=[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}];function _e(e,...t){{const n=Pe[e],i="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${i}`)}}var Le=Object.getPrototypeOf;function Ne(e){return!!e&&!!e[$e]}function De(e){return!!e&&(qe(e)||Array.isArray(e)||!!e[We]||!!e.constructor?.[We]||Je(e)||Ke(e))}var Fe=Object.prototype.constructor.toString();function qe(e){if(!e||"object"!=typeof e)return!1;const t=Le(e);if(null===t)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object||"function"==typeof n&&Function.toString.call(n)===Fe}function ze(e,t){0===He(e)?Object.entries(e).forEach((([n,i])=>{t(n,i,e)})):e.forEach(((n,i)=>t(i,n,e)))}function He(e){const t=e[$e];return t?t.type_:Array.isArray(e)?1:Je(e)?2:Ke(e)?3:0}function Ve(e,t){return 2===He(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Be(e,t,n){const i=He(e);2===i?e.set(t,n):3===i?e.add(n):e[t]=n}function Je(e){return e instanceof Map}function Ke(e){return e instanceof Set}function Ze(e){return e.copy_||e.base_}function Xe(e,t){if(Je(e))return new Map(e);if(Ke(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&qe(e)){if(!Le(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const n=Object.getOwnPropertyDescriptors(e);delete n[$e];let i=Reflect.ownKeys(n);for(let t=0;t<i.length;t++){const o=i[t],r=n[o];!1===r.writable&&(r.writable=!0,r.configurable=!0),(r.get||r.set)&&(n[o]={configurable:!0,writable:!0,enumerable:r.enumerable,value:e[o]})}return Object.create(Le(e),n)}function Ge(e,t=!1){return Qe(e)||Ne(e)||!De(e)||(He(e)>1&&(e.set=e.add=e.clear=e.delete=Ye),Object.freeze(e),t&&ze(e,((e,t)=>Ge(t,!0)))),e}function Ye(){_e(2)}function Qe(e){return Object.isFrozen(e)}var et,tt={};function nt(e){const t=tt[e];return t||_e(0,e),t}function it(){return et}function ot(e,t){t&&(nt("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function rt(e){st(e),e.drafts_.forEach(lt),e.drafts_=null}function st(e){e===et&&(et=e.parent_)}function at(e){return et={drafts_:[],parent_:et,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function lt(e){const t=e[$e];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function ct(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[$e].modified_&&(rt(t),_e(4)),De(e)&&(e=dt(t,e),t.parent_||ht(t,e)),t.patches_&&nt("Patches").generateReplacementPatches_(n[$e].base_,e,t.patches_,t.inversePatches_)):e=dt(t,n,[]),rt(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Ue?e:void 0}function dt(e,t,n){if(Qe(t))return t;const i=t[$e];if(!i)return ze(t,((o,r)=>ut(e,i,t,o,r,n))),t;if(i.scope_!==e)return t;if(!i.modified_)return ht(e,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const t=i.copy_;let o=t,r=!1;3===i.type_&&(o=new Set(t),t.clear(),r=!0),ze(o,((o,s)=>ut(e,i,t,o,s,n,r))),ht(e,t,!1),n&&e.patches_&&nt("Patches").generatePatches_(i,n,e.patches_,e.inversePatches_)}return i.copy_}function ut(e,t,n,i,o,r,s){if(o===n&&_e(5),Ne(o)){const s=dt(e,o,r&&t&&3!==t.type_&&!Ve(t.assigned_,i)?r.concat(i):void 0);if(Be(n,i,s),!Ne(s))return;e.canAutoFreeze_=!1}else s&&n.add(o);if(De(o)&&!Qe(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;dt(e,o),t&&t.scope_.parent_||ht(e,o)}}function ht(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Ge(t,n)}var pt={get(e,t){if(t===$e)return e;const n=Ze(e);if(!Ve(n,t))return function(e,t,n){const i=vt(t,n);return i?"value"in i?i.value:i.get?.call(e.draft_):void 0}(e,n,t);const i=n[t];return e.finalized_||!De(i)?i:i===gt(e.base_,t)?(wt(e),e.copy_[t]=bt(i,e)):i},has:(e,t)=>t in Ze(e),ownKeys:e=>Reflect.ownKeys(Ze(e)),set(e,t,n){const i=vt(Ze(e),t);if(i?.set)return i.set.call(e.draft_,n),!0;if(!e.modified_){const i=gt(Ze(e),t),o=i?.[$e];if(o&&o.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}(n,i)&&(void 0!==n||Ve(e.base_,t)))return!0;wt(e),mt(e)}return e.copy_[t]===n&&(void 0!==n||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty:(e,t)=>(void 0!==gt(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,wt(e),mt(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=Ze(e),i=Reflect.getOwnPropertyDescriptor(n,t);return i?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:i.enumerable,value:n[t]}:i},defineProperty(){_e(11)},getPrototypeOf:e=>Le(e.base_),setPrototypeOf(){_e(12)}},ft={};function gt(e,t){const n=e[$e];return(n?Ze(n):e)[t]}function vt(e,t){if(!(t in e))return;let n=Le(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=Le(n)}}function mt(e){e.modified_||(e.modified_=!0,e.parent_&&mt(e.parent_))}function wt(e){e.copy_||(e.copy_=Xe(e.base_,e.scope_.immer_.useStrictShallowCopy_))}ze(pt,((e,t)=>{ft[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),ft.deleteProperty=function(e,t){return isNaN(parseInt(t))&&_e(13),ft.set.call(this,e,t,void 0)},ft.set=function(e,t,n){return"length"!==t&&isNaN(parseInt(t))&&_e(14),pt.set.call(this,e[0],t,n,e[0])};function bt(e,t){const n=Je(e)?nt("MapSet").proxyMap_(e,t):Ke(e)?nt("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),i={type_:n?1:0,scope_:t?t.scope_:it(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let o=i,r=pt;n&&(o=[i],r=ft);const{revoke:s,proxy:a}=Proxy.revocable(o,r);return i.draft_=a,i.revoke_=s,a}(e,t);return(t?t.scope_:it()).drafts_.push(n),n}function yt(e){return Ne(e)||_e(10,e),kt(e)}function kt(e){if(!De(e)||Qe(e))return e;const t=e[$e];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Xe(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Xe(e,!0);return ze(n,((e,t)=>{Be(n,e,kt(t))})),t&&(t.finalized_=!1),n}var St=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,t,n)=>{if("function"==typeof e&&"function"!=typeof t){const n=t;t=e;const i=this;return function(e=n,...o){return i.produce(e,(e=>t.call(this,e,...o)))}}let i;if("function"!=typeof t&&_e(6),void 0!==n&&"function"!=typeof n&&_e(7),De(e)){const o=at(this),r=bt(e,void 0);let s=!0;try{i=t(r),s=!1}finally{s?rt(o):st(o)}return ot(o,n),ct(i,o)}if(!e||"object"!=typeof e){if(i=t(e),void 0===i&&(i=e),i===Ue&&(i=void 0),this.autoFreeze_&&Ge(i,!0),n){const t=[],o=[];nt("Patches").generateReplacementPatches_(e,i,t,o),n(t,o)}return i}_e(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...n)=>this.produceWithPatches(t,(t=>e(t,...n)));let n,i;const o=this.produce(e,t,((e,t)=>{n=e,i=t}));return[o,n,i]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){De(e)||_e(8),Ne(e)&&(e=yt(e));const t=at(this),n=bt(e,void 0);return n[$e].isManual_=!0,st(t),n}finishDraft(e,t){const n=e&&e[$e];n&&n.isManual_||_e(9);const{scope_:i}=n;return ot(i,t),ct(void 0,i)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const i=t[n];if(0===i.path.length&&"replace"===i.op){e=i.value;break}}n>-1&&(t=t.slice(n+1));const i=nt("Patches").applyPatches_;return Ne(e)?i(e,t):this.produce(e,(e=>i(e,t)))}},It=St.produce;St.produceWithPatches.bind(St),St.setAutoFreeze.bind(St),St.setUseStrictShallowCopy.bind(St),St.applyPatches.bind(St),St.createDraft.bind(St),St.finishDraft.bind(St);var Ct=(e,t,n)=>{if(1===t.length&&t[0]===n){let t=!1;try{const n={};e(n)===n&&(t=!0)}catch{}if(t){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("The result function returned its own inputs without modification. e.g\n`createSelector([state => state.todos], todos => todos)`\nThis could lead to inefficient memoization and unnecessary re-renders.\nEnsure transformation logic is in the result function, and extraction logic is in the input selectors.",{stack:e})}}},At=(e,t,n)=>{const{memoize:i,memoizeOptions:o}=t,{inputSelectorResults:r,inputSelectorResultsCopy:s}=e,a=i((()=>({})),...o);if(!(a.apply(null,r)===a.apply(null,s))){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("An input selector returned a different result when passed same arguments.\nThis means your output selector will likely run more frequently than intended.\nAvoid returning a new reference inside your input selector, e.g.\n`createSelector([state => state.todos.map(todo => todo.id)], todoIds => todoIds.length)`",{arguments:n,firstInputs:r,secondInputs:s,stack:e})}},xt={inputStabilityCheck:"once",identityFunctionCheck:"once"};var Ot=e=>Array.isArray(e)?e:[e];function Et(e){const t=Array.isArray(e[0])?e[0]:e;return function(e,t="expected all items to be functions, instead received the following types: "){if(!e.every((e=>"function"==typeof e))){const n=e.map((e=>"function"==typeof e?`function ${e.name||"unnamed"}()`:typeof e)).join(", ");throw new TypeError(`${t}[${n}]`)}}(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function jt(e,t){const n=[],{length:i}=e;for(let o=0;o<i;o++)n.push(e[o].apply(null,t));return n}var Rt="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}},Tt=0,Mt=1;function Ut(){return{s:Tt,v:void 0,o:null,p:null}}function Wt(e,t={}){let n=Ut();const{resultEqualityCheck:i}=t;let o,r=0;function s(){let t=n;const{length:s}=arguments;for(let e=0,n=s;e<n;e++){const n=arguments[e];if("function"==typeof n||"object"==typeof n&&null!==n){let e=t.o;null===e&&(t.o=e=new WeakMap);const i=e.get(n);void 0===i?(t=Ut(),e.set(n,t)):t=i}else{let e=t.p;null===e&&(t.p=e=new Map);const i=e.get(n);void 0===i?(t=Ut(),e.set(n,t)):t=i}}const a=t;let l;if(t.s===Mt)l=t.v;else if(l=e.apply(null,arguments),r++,i){const e=o?.deref?.()??o;null!=e&&i(e,l)&&(l=e,0!==r&&r--);o="object"==typeof l&&null!==l||"function"==typeof l?new Rt(l):l}return a.s=Mt,a.v=l,l}return s.clearCache=()=>{n=Ut(),s.resetResultsCount()},s.resultsCount=()=>r,s.resetResultsCount=()=>{r=0},s}function $t(e,...t){const n="function"==typeof e?{memoize:e,memoizeOptions:t}:e,i=(...e)=>{let t,i=0,o=0,r={},s=e.pop();"object"==typeof s&&(r=s,s=e.pop()),function(e,t="expected a function, instead received "+typeof e){if("function"!=typeof e)throw new TypeError(t)}(s,`createSelector expects an output function after the inputs, but received: [${typeof s}]`);const a={...n,...r},{memoize:l,memoizeOptions:c=[],argsMemoize:d=Wt,argsMemoizeOptions:u=[],devModeChecks:h={}}=a,p=Ot(c),f=Ot(u),g=Et(e),v=l((function(){return i++,s.apply(null,arguments)}),...p);let m=!0;const w=d((function(){o++;const e=jt(g,arguments);t=v.apply(null,e);{const{identityFunctionCheck:n,inputStabilityCheck:i}=((e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:i}={...xt,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:Ct},inputStabilityCheck:{shouldRun:"always"===i||"once"===i&&e,run:At}}})(m,h);if(n.shouldRun&&n.run(s,e,t),i.shouldRun){const t=jt(g,arguments);i.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:l,memoizeOptions:p},arguments)}m&&(m=!1)}return t}),...f);return Object.assign(w,{resultFunc:s,memoizedResultFunc:v,dependencies:g,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>t,recomputations:()=>i,resetRecomputations:()=>{i=0},memoize:l,argsMemoize:d})};return Object.assign(i,{withTypes:()=>i}),i}var Pt=$t(Wt),_t=Object.assign(((e,t=Pt)=>{!function(e,t="expected an object, instead received "+typeof e){if("object"!=typeof e)throw new TypeError(t)}(e,"createStructuredSelector expects first argument to be an object where each property is a selector, instead received a "+typeof e);const n=Object.keys(e),i=t(n.map((t=>e[t])),((...e)=>e.reduce(((e,t,i)=>(e[n[i]]=t,e)),{})));return i}),{withTypes:()=>_t});function Lt(e){return({dispatch:t,getState:n})=>i=>o=>"function"==typeof o?o(t,n,e):i(o)}var Nt=Lt(),Dt=Lt;((...e)=>{const t=$t(...e)})(Wt);var Ft="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?Te:Te.apply(null,arguments)},qt=e=>e&&"function"==typeof e.match;function zt(e,t){function n(...n){if(t){let i=t(...n);if(!i)throw new Error("prepareAction did not return an object");return{type:e,payload:i.payload,..."meta"in i&&{meta:i.meta},..."error"in i&&{error:i.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>Me(t)&&t.type===e,n}function Ht(e){return"function"==typeof e&&"type"in e&&qt(e)}function Vt(e,t){let n=0;return{measureTime(e){const t=Date.now();try{return e()}finally{const e=Date.now();n+=e-t}},warnIfExceeded(){n>e&&console.warn(`${t} took ${n}ms, which is more than the warning threshold of ${e}ms. \nIf your state or actions are very large, you may want to disable the middleware as it might cause too much of a slowdown in development mode. See https://redux-toolkit.js.org/api/getDefaultMiddleware for instructions.\nIt is disabled in production builds, so you don't need to worry about that.`)}}}var Bt=class e extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,e.prototype)}static get[Symbol.species](){return e}concat(...e){return super.concat.apply(this,e)}prepend(...t){return 1===t.length&&Array.isArray(t[0])?new e(...t[0].concat(this)):new e(...t.concat(this))}};function Jt(e){return De(e)?It(e,(()=>{})):e}function Kt(e,t,n){if(e.has(t)){let i=e.get(t);return n.update&&(i=n.update(i,t,e),e.set(t,i)),i}if(!n.insert)throw new Error("No insert provided for key not already in map");const i=n.insert(t,e);return e.set(t,i),i}function Zt(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function Xt(e,t,n){const i=Gt(e,t,n);return{detectMutations:()=>Yt(e,t,i,n)}}function Gt(e,t=[],n,i="",o=new Set){const r={value:n};if(!e(n)&&!o.has(n)){o.add(n),r.children={};for(const o in n){const s=i?i+"."+o:o;t.length&&-1!==t.indexOf(s)||(r.children[o]=Gt(e,t,n[o],s))}}return r}function Yt(e,t=[],n,i,o=!1,r=""){const s=n?n.value:void 0,a=s===i;if(o&&!a&&!Number.isNaN(i))return{wasMutated:!0,path:r};if(e(s)||e(i))return{wasMutated:!1};const l={};for(let e in n.children)l[e]=!0;for(let e in i)l[e]=!0;const c=t.length>0;for(let o in l){const s=r?r+"."+o:o;if(c){if(t.some((e=>e instanceof RegExp?e.test(s):s===e)))continue}const l=Yt(e,t,n.children[o],i[o],a,s);if(l.wasMutated)return l}return{wasMutated:!1}}function Qt(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||Ae(e)}function en(e,t="",n=Qt,i,o=[],r){let s;if(!n(e))return{keyPath:t||"<root>",value:e};if("object"!=typeof e||null===e)return!1;if(r?.has(e))return!1;const a=null!=i?i(e):Object.entries(e),l=o.length>0;for(const[e,c]of a){const a=t?t+"."+e:e;if(l){if(o.some((e=>e instanceof RegExp?e.test(a):a===e)))continue}if(!n(c))return{keyPath:a,value:c};if("object"==typeof c&&(s=en(c,a,n,i,o,r),s))return s}return r&&tn(e)&&r.add(e),!1}function tn(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!tn(t))return!1;return!0}function nn(e){return"boolean"==typeof e}var on=()=>function(e){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:i=!0,actionCreatorCheck:o=!0}=e??{};let r=new Bt;if(t&&(nn(t)?r.push(Nt):r.push(Dt(t.extraArgument))),n){let e={};nn(n)||(e=n),r.unshift(function(e={}){{let t=function(e,t,i,o){return JSON.stringify(e,n(t,o),i)},n=function(e,t){let n=[],i=[];return t||(t=function(e,t){return n[0]===t?"[Circular ~]":"[Circular ~."+i.slice(0,n.indexOf(t)).join(".")+"]"}),function(o,r){if(n.length>0){var s=n.indexOf(this);~s?n.splice(s+1):n.push(this),~s?i.splice(s,1/0,o):i.push(o),~n.indexOf(r)&&(r=t.call(this,o,r))}else n.push(r);return null==e?r:e.call(this,o,r)}},{isImmutable:i=Zt,ignoredPaths:o,warnAfter:r=32}=e;const s=Xt.bind(null,i,o);return({getState:e})=>{let n,i=e(),o=s(i);return a=>l=>{const c=Vt(r,"ImmutableStateInvariantMiddleware");c.measureTime((()=>{if(i=e(),n=o.detectMutations(),o=s(i),n.wasMutated)throw new Error(`A state mutation was detected between dispatches, in the path '${n.path||""}'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)}));const d=a(l);return c.measureTime((()=>{if(i=e(),n=o.detectMutations(),o=s(i),n.wasMutated)throw new Error(`A state mutation was detected inside a dispatch, in the path: ${n.path||""}. Take a look at the reducer(s) handling the action ${t(l)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)})),c.warnIfExceeded(),d}}}}(e))}if(i){let e={};nn(i)||(e=i),r.push(function(e={}){{const{isSerializable:t=Qt,getEntries:n,ignoredActions:i=[],ignoredActionPaths:o=["meta.arg","meta.baseQueryMeta"],ignoredPaths:r=[],warnAfter:s=32,ignoreState:a=!1,ignoreActions:l=!1,disableCache:c=!1}=e,d=!c&&WeakSet?new WeakSet:void 0;return e=>c=>u=>{if(!Me(u))return c(u);const h=c(u),p=Vt(s,"SerializableStateInvariantMiddleware");return l||i.length&&-1!==i.indexOf(u.type)||p.measureTime((()=>{const e=en(u,"",t,n,o,d);if(e){const{keyPath:t,value:n}=e;console.error(`A non-serializable value was detected in an action, in the path: \`${t}\`. Value:`,n,"\nTake a look at the logic that dispatched this action: ",u,"\n(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)","\n(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)")}})),a||(p.measureTime((()=>{const i=en(e.getState(),"",t,n,r,d);if(i){const{keyPath:e,value:t}=i;console.error(`A non-serializable value was detected in the state, in the path: \`${e}\`. Value:`,t,`\nTake a look at the reducer(s) handling this action type: ${u.type}.\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)`)}})),p.warnIfExceeded()),h}}}(e))}if(o){let e={};nn(o)||(e=o),r.unshift(function(e={}){const{isActionCreator:t=Ht}=e;return()=>e=>n=>(t(n)&&console.warn(function(e){const t=e?`${e}`.split("/"):[],n=t[t.length-1]||"actionCreator";return`Detected an action creator with type "${e||"unknown"}" being dispatched. \nMake sure you're calling the action creator before dispatching, i.e. \`dispatch(${n}())\` instead of \`dispatch(${n})\`. This is necessary even if the action has no payload.`}(n.type)),e(n))}(e))}return r},rn=e=>t=>{setTimeout(t,e)},sn="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:rn(10),an=e=>function(t){const{autoBatch:n=!0}=t??{};let i=new Bt(e);return n&&i.push(((e={type:"raf"})=>t=>(...n)=>{const i=t(...n);let o=!0,r=!1,s=!1;const a=new Set,l="tick"===e.type?queueMicrotask:"raf"===e.type?sn:"callback"===e.type?e.queueNotification:rn(e.timeout),c=()=>{s=!1,r&&(r=!1,a.forEach((e=>e())))};return Object.assign({},i,{subscribe(e){const t=i.subscribe((()=>o&&e()));return a.add(e),()=>{t(),a.delete(e)}},dispatch(e){try{return o=!e?.meta?.RTK_autoBatch,r=!o,r&&(s||(s=!0,l(c))),i.dispatch(e)}finally{o=!0}}})})("object"==typeof n?n:void 0)),i};function ln(e){const t=on(),{reducer:n,middleware:i,devTools:o=!0,preloadedState:r,enhancers:s}=e||{};let a,l;if("function"==typeof n)a=n;else{if(!Ae(n))throw new Error("`reducer` is a required argument, and must be a function or an object of functions that can be passed to combineReducers");a=Re(n)}if(i&&"function"!=typeof i)throw new Error("`middleware` field must be a callback");if("function"==typeof i){if(l=i(t),!Array.isArray(l))throw new Error("when using a middleware builder function, an array of middleware must be returned")}else l=t();if(l.some((e=>"function"!=typeof e)))throw new Error("each middleware provided to configureStore must be a function");let c=Te;o&&(c=Ft({trace:!0,..."object"==typeof o&&o}));const d=function(...e){return t=>(n,i)=>{const o=t(n,i);let r=()=>{throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")};const s={getState:o.getState,dispatch:(e,...t)=>r(e,...t)},a=e.map((e=>e(s)));return r=Te(...a)(o.dispatch),{...o,dispatch:r}}}(...l),u=an(d);if(s&&"function"!=typeof s)throw new Error("`enhancers` field must be a callback");let h="function"==typeof s?s(u):u();if(!Array.isArray(h))throw new Error("`enhancers` callback must return an array");if(h.some((e=>"function"!=typeof e)))throw new Error("each enhancer provided to configureStore must be a function");l.length&&!h.includes(d)&&console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`");return Ee(a,r,c(...h))}function cn(e){const t={},n=[];let i;const o={addCase(e,r){if(n.length>0)throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");if(i)throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`");const s="string"==typeof e?e:e.type;if(!s)throw new Error("`builder.addCase` cannot be called with an empty action type");if(s in t)throw new Error(`\`builder.addCase\` cannot be called with two reducers for the same action type '${s}'`);return t[s]=r,o},addMatcher(e,t){if(i)throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return n.push({matcher:e,reducer:t}),o},addDefaultCase(e){if(i)throw new Error("`builder.addDefaultCase` can only be called once");return i=e,o}};return e(o),[t,n,i]}function dn(...e){return t=>e.some((e=>((e,t)=>qt(e)?e.match(t):e(t))(e,t)))}var un=["name","message","stack","code"],hn=class{constructor(e,t){this.payload=e,this.meta=t}_type},pn=class{constructor(e,t){this.payload=e,this.meta=t}_type},fn=e=>{if("object"==typeof e&&null!==e){const t={};for(const n of un)"string"==typeof e[n]&&(t[n]=e[n]);return t}return{message:String(e)}},gn=(()=>{function e(e,t,n){const i=zt(e+"/fulfilled",((e,t,n,i)=>({payload:e,meta:{...i||{},arg:n,requestId:t,requestStatus:"fulfilled"}}))),o=zt(e+"/pending",((e,t,n)=>({payload:void 0,meta:{...n||{},arg:t,requestId:e,requestStatus:"pending"}}))),r=zt(e+"/rejected",((e,t,i,o,r)=>({payload:o,error:(n&&n.serializeError||fn)(e||"Rejected"),meta:{...r||{},arg:i,requestId:t,rejectedWithValue:!!o,requestStatus:"rejected",aborted:"AbortError"===e?.name,condition:"ConditionError"===e?.name}})));return Object.assign((function(e){return(s,a,l)=>{const c=n?.idGenerator?n.idGenerator(e):((e=21)=>{let t="",n=e;for(;n--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t})(),d=new AbortController;let u;function h(e){u=e,d.abort()}const p=async function(){let p;try{let r=n?.condition?.(e,{getState:a,extra:l});if(null!==(f=r)&&"object"==typeof f&&"function"==typeof f.then&&(r=await r),!1===r||d.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};const g=new Promise(((e,t)=>d.signal.addEventListener("abort",(()=>t({name:"AbortError",message:u||"Aborted"})))));s(o(c,e,n?.getPendingMeta?.({requestId:c,arg:e},{getState:a,extra:l}))),p=await Promise.race([g,Promise.resolve(t(e,{dispatch:s,getState:a,extra:l,requestId:c,signal:d.signal,abort:h,rejectWithValue:(e,t)=>new hn(e,t),fulfillWithValue:(e,t)=>new pn(e,t)})).then((t=>{if(t instanceof hn)throw t;return t instanceof pn?i(t.payload,c,e,t.meta):i(t,c,e)}))])}catch(t){p=t instanceof hn?r(null,c,e,t.payload,t.meta):r(t,c,e)}var f;return n&&!n.dispatchConditionRejection&&r.match(p)&&p.meta.condition||s(p),p}();return Object.assign(p,{abort:h,requestId:c,arg:e,unwrap:()=>p.then(vn)})}}),{pending:o,rejected:r,fulfilled:i,settled:dn(r,i),typePrefix:e})}return e.withTypes=()=>e,e})();function vn(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}var mn=Symbol.for("rtk-slice-createasyncthunk");function wn(e,t){return`${e}/${t}`}function bn(e,t,n,i){function o(o,...r){let s=n.call(e,o);if(void 0===s){if(!i)throw new Error("selectState returned undefined for an uninjected slice reducer");s=e.getInitialState()}return t(s,...r)}return o.unwrapped=t,o}var yn=function({creators:e}={}){const t=e?.asyncThunk?.[mn];return function(e){const{name:n,reducerPath:i=n}=e;if(!n)throw new Error("`name` is a required option for createSlice");"undefined"!=typeof process&&void 0===e.initialState&&console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");const o=("function"==typeof e.reducers?e.reducers(function(){function e(e,t){return{_reducerDefinitionType:"asyncThunk",payloadCreator:e,...t}}return e.withTypes=()=>e,{reducer:e=>Object.assign({[e.name]:(...t)=>e(...t)}[e.name],{_reducerDefinitionType:"reducer"}),preparedReducer:(e,t)=>({_reducerDefinitionType:"reducerWithPrepare",prepare:e,reducer:t}),asyncThunk:e}}()):e.reducers)||{},r=Object.keys(o),s={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},a={addCase(e,t){const n="string"==typeof e?e:e.type;if(!n)throw new Error("`context.addCase` cannot be called with an empty action type");if(n in s.sliceCaseReducersByType)throw new Error("`context.addCase` cannot be called with two reducers for the same action type: "+n);return s.sliceCaseReducersByType[n]=t,a},addMatcher:(e,t)=>(s.sliceMatchers.push({matcher:e,reducer:t}),a),exposeAction:(e,t)=>(s.actionCreators[e]=t,a),exposeCaseReducer:(e,t)=>(s.sliceCaseReducersByName[e]=t,a)};function l(){if("object"==typeof e.extraReducers)throw new Error("The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");const[t={},n=[],i]="function"==typeof e.extraReducers?cn(e.extraReducers):[e.extraReducers],o={...t,...s.sliceCaseReducersByType};return function(e,t){if("object"==typeof t)throw new Error("The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");let n,[i,o,r]=cn(t);if(function(e){return"function"==typeof e}(e))n=()=>Jt(e());else{const t=Jt(e);n=()=>t}function s(e=n(),t){let s=[i[t.type],...o.filter((({matcher:e})=>e(t))).map((({reducer:e})=>e))];return 0===s.filter((e=>!!e)).length&&(s=[r]),s.reduce(((e,n)=>{if(n){if(Ne(e)){const i=n(e,t);return void 0===i?e:i}if(De(e))return It(e,(e=>n(e,t)));{const i=n(e,t);if(void 0===i){if(null===e)return e;throw new Error("A case reducer on a non-draftable value must not return undefined")}return i}}return e}),e)}return s.getInitialState=n,s}(e.initialState,(e=>{for(let t in o)e.addCase(t,o[t]);for(let t of s.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);i&&e.addDefaultCase(i)}))}r.forEach((i=>{const r=o[i],s={reducerName:i,type:wn(n,i),createNotation:"function"==typeof e.reducers};!function(e){return"asyncThunk"===e._reducerDefinitionType}(r)?function({type:e,reducerName:t,createNotation:n},i,o){let r,s;if("reducer"in i){if(n&&!function(e){return"reducerWithPrepare"===e._reducerDefinitionType}(i))throw new Error("Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");r=i.reducer,s=i.prepare}else r=i;o.addCase(e,r).exposeCaseReducer(t,r).exposeAction(t,s?zt(e,s):zt(e))}(s,r,a):function({type:e,reducerName:t},n,i,o){if(!o)throw new Error("Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");const{payloadCreator:r,fulfilled:s,pending:a,rejected:l,settled:c,options:d}=n,u=o(e,r,d);i.exposeAction(t,u),s&&i.addCase(u.fulfilled,s);a&&i.addCase(u.pending,a);l&&i.addCase(u.rejected,l);c&&i.addMatcher(u.settled,c);i.exposeCaseReducer(t,{fulfilled:s||kn,pending:a||kn,rejected:l||kn,settled:c||kn})}(s,r,a,t)}));const c=e=>e,d=new WeakMap;let u;const h={name:n,reducerPath:i,reducer:(e,t)=>(u||(u=l()),u(e,t)),actions:s.actionCreators,caseReducers:s.sliceCaseReducersByName,getInitialState:()=>(u||(u=l()),u.getInitialState()),getSelectors(t=c){const n=Kt(d,this,{insert:()=>new WeakMap});return Kt(n,t,{insert:()=>{const n={};for(const[i,o]of Object.entries(e.selectors??{}))n[i]=bn(this,o,t,this!==h);return n}})},selectSlice(e){let t=e[this.reducerPath];if(void 0===t){if(this===h)throw new Error("selectSlice returned undefined for an uninjected slice reducer");t=this.getInitialState()}return t},get selectors(){return this.getSelectors(this.selectSlice)},injectInto(e,{reducerPath:t,...n}={}){const i=t??this.reducerPath;return e.inject({reducerPath:i,reducer:this.reducer},n),{...this,reducerPath:i}}};return h}}();function kn(){}var Sn="listenerMiddleware";zt(`${Sn}/add`),zt(`${Sn}/removeAll`),zt(`${Sn}/remove`);const In=e=>c((t=>{const n=yn(e),i=Object.assign(Object.assign({},n.actions),e.asyncActions);return class extends(r(b)(t)){constructor(...e){super(...e);const t=ln({reducer:n.reducer,middleware:e=>e({thunk:{extraArgument:this},serializableCheck:!1}),devTools:!1}),o=e=>async(...n)=>{const i=await t.dispatch(e(...n));try{vn(i)}catch(e){this.logger.error(e.message,i.type,e.stack)}return i},r=Object.keys(i).reduce(((e,t)=>(e[t]=o(i[t]),e)),{});this.actions=r,this.subscribe=(e,n=e=>e)=>t.subscribe((()=>e(n(t.getState()))))}}}));c((e=>class extends(b(e)){validateForm(e){return this.getFormInputs(e).every((e=>{var t,n;return null===(t=e.reportValidity)||void 0===t||t.call(e),null===(n=e.checkValidity)||void 0===n?void 0:n.call(e)}))}getFormInputs(e){return e?Array.from(e.querySelectorAll("[name]")):(this.logger.debug("cannot get form inputs, no root element was received"),[])}getFormData(e){return this.getFormInputs(e).reduce(((e,t)=>Object.assign(e,{[t.getAttribute("name")]:t.value})),{})}setFormData(e,t){this.getFormInputs(e).forEach((e=>{t.hasOwnProperty(e.getAttribute("name"))&&(e.value=t[e.getAttribute("name")])}))}resetFormData(e){this.getFormInputs(e).forEach((e=>{e.value="",e.checked=!1}))}getFormFieldNames(e){return this.getFormInputs(e).map((e=>e.name))}disableFormField(e,t){var n;null===(n=this.getFormInputs(e).find((e=>e.name===t)))||void 0===n||n.setAttribute("disabled","true")}removeFormField(e,t){var n;null===(n=this.getFormInputs(e).find((e=>e.name===t)))||void 0===n||n.remove()}}));const Cn=c((e=>{const t=r(O({"widget-id":C}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}}})),An=c((e=>{const t=r(W,Cn)(e);return class extends t{async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this))}async getWidgetConfig(){var e,t;const n=await this.config;return null===(t=null===(e=null==n?void 0:n.projectConfig)||void 0===e?void 0:e.widgets)||void 0===t?void 0:t[this.widgetId]}}})),xn=c((e=>class extends e{get locale(){return this.getAttribute("locale")||""}get localeCandidates(){const{locale:e,fallback:t}=v(this.locale);return[...new Set([e,t].filter(Boolean))]}firstAvailableLocale(e){var t;const n=(null!=e?e:[]).map((e=>e.toLowerCase()));return null!==(t=this.localeCandidates.find((e=>n.includes(e))))&&void 0!==t?t:""}})),On=e=>c((t=>{var n,o,s;const a=r(M,Cn,An,xn)(t);return s=class extends a{constructor(){super(...arguments),n.add(this)}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this))}async fetchWidgetPage(t){const r=await i(this,n,"m",o).call(this,t);if(void 0!==r)return r;const s=await this.fetchStaticResource(`${e}/${this.widgetId}/${t}`,"text");return null==s?void 0:s.body}},n=new WeakSet,o=async function(t){var n;const i=await this.getWidgetConfig(),o=this.firstAvailableLocale(null!==(n=null==i?void 0:i.targetLocales)&&void 0!==n?n:[]);if(!o)return;const r=".html",s=t.endsWith(r)?t.slice(0,-5):t;try{const t=await this.fetchStaticResource(`${e}/${this.widgetId}/${s}-${o}${r}`,"text");return null==t?void 0:t.body}catch(e){return}},s})),En=c((e=>class extends e{get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}})),jn=c((e=>{var n,o,r;return r=class extends(ke(e)){constructor(){super(...arguments),n.add(this)}get clientInput(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(e){return{}}}get formInput(){return this.getAttribute("form")||void 0}createFlowTemplate(e){var{flowId:r,client:s,form:a}=e,c=t(e,["flowId","client","form"]);return l(Object.assign({projectId:this.getAttribute("project-id"),flowId:r,baseUrl:this.getAttribute("base-url")||"",baseStaticUrl:this.getAttribute("base-static-url")||"",baseCdnUrl:this.getAttribute("base-cdn-url")||"",refreshCookieName:this.getAttribute("refresh-cookie-name")||"",theme:this.theme,"style-id":this.styleId,locale:this.getAttribute("locale")||"",form:i(this,n,"m",o).call(this,a),client:Object.assign(Object.assign({},this.clientInput),s)},c))}},n=new WeakSet,o=function(e){const t=this.formInput;if(!e)return t;if(!t)return e;try{return Object.assign(Object.assign({},JSON.parse(t)),e)}catch(t){return e}},r}));function Rn(e){return new URLSearchParams(window.location.search).get(e)}const Tn=e=>(...t)=>n=>{n.addCase(e.pending,((e,n)=>{t.forEach((({onPending:t})=>{null==t||t(e,n)}))})),n.addCase(e.fulfilled,((e,n)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,n)}))})),n.addCase(e.rejected,((e,n)=>{t.forEach((({onRejected:t})=>{null==t||t(e,n)}))}))},Mn=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,n)=>{e(t).loading=!1,e(t).error=n.error}}),Un=gn("users/me",((e,{extra:{api:t}})=>t.user.me())),Wn=Tn(Un)({onFulfilled:(e,t)=>{e.me.data=t.payload}},Mn((e=>e.me))),$n={action:Un,reducer:Wn},Pn=gn("users/devices",((e,{extra:{api:t}})=>t.device.devices(e))),_n=Tn(Pn)({onFulfilled:(e,t)=>{e.devices.data=t.payload.devices}},Mn((e=>e.devices))),Ln={action:Pn,reducer:_n},Nn=gn("users/passkeys",((e,{extra:{api:t}})=>t.passkey.listPasskeys(e))),Dn=Tn(Nn)({onFulfilled:(e,t)=>{e.passkeys.data=t.payload.passkeys}},Mn((e=>e.passkeys))),Fn={action:Nn,reducer:Dn},qn=gn("users/logout",((e,{extra:{api:t}})=>t.user.logout())),zn={action:qn,reducer:Tn(qn)({})};class Hn extends Error{}function Vn(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return function(e){return decodeURIComponent(atob(e).replace(/(.)/g,((e,t)=>{let n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return atob(t)}}function Bn(e,t){if("string"!=typeof e)throw new Hn("Invalid token specified: must be a string");t||(t={});const n=!0===t.header?0:1,i=e.split(".")[n];if("string"!=typeof i)throw new Hn(`Invalid token specified: missing part #${n+1}`);let o;try{o=Vn(i)}catch(e){throw new Hn(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(o)}catch(e){throw new Hn(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}Hn.prototype.name="InvalidTokenError";var Jn={accessKey:{exchange:"/v1/auth/accesskey/exchange"},otp:{verify:"/v1/auth/otp/verify",signIn:"/v1/auth/otp/signin",signUp:"/v1/auth/otp/signup",update:{email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},signUpOrIn:"/v1/auth/otp/signup-in"},magicLink:{verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},signUpOrIn:"/v1/auth/magiclink/signup-in"},enchantedLink:{verify:"/v1/auth/enchantedlink/verify",signIn:"/v1/auth/enchantedlink/signin",signUp:"/v1/auth/enchantedlink/signup",session:"/v1/auth/enchantedlink/pending-session",update:{email:"/v1/auth/enchantedlink/update/email"},signUpOrIn:"/v1/auth/enchantedlink/signup-in"},oauth:{start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange",startNative:"v1/auth/oauth/native/start",finishNative:"v1/auth/oauth/native/finish",oneTap:{getOneTapClientId:"/v1/auth/onetap/clientid/{provider}",exchangeOneTapIDToken:"/v1/auth/onetap/idtoken/exchange",verifyOneTapIDToken:"/v1/auth/onetap/idtoken/verify"}},outbound:{connect:"/v1/outbound/oauth/connect"},saml:{start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},sso:{start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},totp:{verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/auth/totp/update"},notp:{signIn:"/v1/auth/notp/whatsapp/signin",signUp:"/v1/auth/notp/whatsapp/signup",signUpOrIn:"/v1/auth/notp/whatsapp/signup-in",session:"/v1/auth/notp/pending-session"},webauthn:{signUp:{start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},signIn:{start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},signUpOrIn:{start:"/v1/auth/webauthn/signup-in/start"},update:{start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"}},password:{signUp:"/v1/auth/password/signup",signIn:"/v1/auth/password/signin",sendReset:"/v1/auth/password/reset",update:"/v1/auth/password/update",replace:"/v1/auth/password/replace",policy:"/v1/auth/password/policy"},refresh:"/v1/auth/refresh",tryRefresh:"/v1/auth/try-refresh",selectTenant:"/v1/auth/tenant/select",logout:"/v1/auth/logout",logoutAll:"/v1/auth/logoutall",me:"/v1/auth/me",myTenants:"/v1/auth/me/tenants",history:"/v1/auth/me/history",flow:{start:"/v1/flow/start",next:"/v1/flow/next"}};const Kn="<region>",Zn=`https://api.${Kn}descope.com`,Xn=6e5,Gn="dct",Yn=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},retries(t){return e.Retries=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}},Qn=[503,520,521,522,524,530],ei=[100,5e3,5e3],ti=e=>new Promise((t=>setTimeout(t,e))),ni=e=>async function(...t){let n=await e(...t),i=0;for(;Qn.includes(n.status)&&i<ei.length;)await ti(ei[i]),n=await e(...t),i++;i>0&&(n.retries=i);const o=await n.text();return n.text=()=>Promise.resolve(o),n.json=()=>Promise.resolve(JSON.parse(o)),n.clone=()=>n,n};let ii;const oi=()=>{if(ii)return ii;const e=new Date,t=`${e.getUTCFullYear().toString()}-${(e.getUTCMonth()+1).toString().padStart(2,"0")}-${e.getUTCDate().toString().padStart(2,"0")}-${e.getUTCHours().toString().padStart(2,"0")}:${e.getUTCMinutes().toString().padStart(2,"0")}:${e.getUTCSeconds().toString().padStart(2,"0")}:${e.getUTCMilliseconds().toString()}`,n=Math.floor(1e3+9e3*Math.random());return ii=`${t}-${n}`,ii};var ri;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT",e.patch="PATCH"}(ri||(ri={}));const si=({path:e,baseUrl:t,queryParams:n,projectId:i})=>{const o=i.slice(1,-27);t=t.replace(Kn,o?o+".":"");let r=e?`${t.replace(/\/$/,"")}/${null==e?void 0:e.replace(/^\//,"")}`:t;if(n){const e=Object.keys(n);e.forEach(((t,i)=>{r=`${r}${0===i?"?":""}${t}=${encodeURIComponent(n[t])}${i===e.length-1?"":"&"}`}))}return r},ai=(...e)=>new Headers(e.reduce(((e,t)=>((e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t).forEach((([t,n])=>{e[t]="function"==typeof n?n():n})),e)),{})),li={"Content-Type":"application/json"},ci=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},di=(e,t)=>{const n={"x-descope-sdk-session-id":oi(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.66.0","x-descope-project-id":e};return t&&(n["x-descope-refresh-cookie-name"]=t),n},ui=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e};var hi=e=>{var t;return(({baseUrl:e,projectId:t,baseConfig:n,refreshCookieName:i,logger:o,hooks:r,cookiePolicy:s,fetch:a})=>{const l=e||Zn,c=((e,t)=>{const n=t||fetch;return n||null==e||e.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),e?async function(...t){if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");e.log((e=>Yn().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const i=await ni(n)(...t);return e[i.ok?"log":"error"](await(async e=>{const t=await e.text();return Yn().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).retries(e.retries).build()})(i)),i}:ni(n)})(o,a),d=async e=>{var o;const a=(null==r?void 0:r.beforeRequest)?r.beforeRequest(e):e,{path:d,body:u,headers:h,queryParams:p,method:f,token:g}=a,v=(e=>void 0===e?void 0:JSON.stringify(e))(u),m={headers:ai(ci(t,g),di(t,i),(null==n?void 0:n.baseHeaders)||{},ui(v)?li:{},h),method:f,body:v};null!==s&&(m.credentials=s||"include");const w=await c(si({path:d,baseUrl:l,queryParams:p,projectId:t}),m);if((null==r?void 0:r.afterRequest)&&await r.afterRequest(e,null==w?void 0:w.clone()),null==r?void 0:r.transformResponse){const e=await w.json(),t=(b=(null===(o=w.headers)||void 0===o?void 0:o.get("set-cookie"))||"",Object.fromEntries(function(e){if(!e)return[];const t=[];let n=0;function i(){for(;n<e.length&&/\s/.test(e.charAt(n));)n+=1;return n<e.length}function o(){const t=e.charAt(n);return"="!==t&&";"!==t&&","!==t}for(;n<e.length;){const r=n;let s,a,l=!1;for(;i();)if(","===e.charAt(n)){for(s=n,n+=1,i(),a=n;n<e.length&&o();)n+=1;if(n<e.length&&"="===e.charAt(n)){l=!0,n=a,t.push(e.substring(r,s));break}n=s+1}else n+=1;(!l||n>=e.length)&&t.push(e.substring(r,e.length))}return t}(b).map((e=>{const t=e.split(";")[0],n=t.indexOf("=");return n<1?null:[t.substring(0,n).trim(),t.substring(n+1).trim()]})).filter(Boolean))),n=Object.assign(Object.assign({},w),{json:()=>Promise.resolve(e),cookies:t});return n.clone=()=>n,r.transformResponse(n)}var b;return w};return{get:(e,{headers:t,queryParams:n,token:i}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:ri.get,token:i}),post:(e,t,{headers:n,queryParams:i,token:o}={})=>d({path:e,headers:n,queryParams:i,body:t,method:ri.post,token:o}),patch:(e,t,{headers:n,queryParams:i,token:o}={})=>d({path:e,headers:n,queryParams:i,body:t,method:ri.patch,token:o}),put:(e,t,{headers:n,queryParams:i,token:o}={})=>d({path:e,headers:n,queryParams:i,body:t,method:ri.put,token:o}),delete:(e,{headers:t,queryParams:n,token:i}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:ri.delete,token:i}),hooks:r,buildUrl:(e,n)=>si({projectId:t,baseUrl:l,path:e,queryParams:n})}})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var n;const i=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==i?void 0:i.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,n)=>{var i;const o=[].concat((null===(i=e.hooks)||void 0===i?void 0:i.afterRequest)||[]);0!=o.length&&(await Promise.allSettled(null==o?void 0:o.map((e=>e(t,null==n?void 0:n.clone()))))).forEach((t=>{var n;return"rejected"===t.status&&(null===(n=e.logger)||void 0===n?void 0:n.error(t.reason))}))},transformResponse:null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}}))},pi=429;function fi(e,t,n){var i;let o=gi(e);if(t){if(!(null==o?void 0:o.tenants)&&(null==o?void 0:o[Gn])===t)return(null==o?void 0:o[n])||[];o=null===(i=null==o?void 0:o.tenants)||void 0===i?void 0:i[t]}const r=null==o?void 0:o[n];return Array.isArray(r)?r:[]}function gi(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return Bn(e)}function vi(e){const{exp:t}=gi(e);return(new Date).getTime()/1e3>t}function mi(e){let t=gi(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function wi(e,t){return fi(e,t,"permissions")}function bi(e,t){return fi(e,t,"roles")}const yi=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function ki(e,t){var n;const i=await e,o={code:i.status,ok:i.ok,response:i},r=await i.clone().json();return i.ok?o.data=r:(o.error=r,i.status===pi&&Object.assign(o.error,{retryAfter:Number.parseInt(null===(n=i.headers)||void 0===n?void 0:n.get("retry-after"))||0})),o}function Si(e){var t;return(null===(t=gi(e))||void 0===t?void 0:t[Gn])||""}const Ii=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),Ci=(e,t)=>(n=t)=>t=>{const i=e.filter((e=>e(t)));return!(i.length<e.length)&&(n?n.replace("{val}",t):i.join(" OR "))},Ai=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),xi=e=>t=>e.test(t),Oi=xi(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Ei=xi(/^\+[1-9]{1}[0-9]{3,14}$/),ji=Ii(Oi,'"{val}" is not a valid email'),Ri=Ii(Ei,'"{val}" is not a valid phone number'),Ti=Ii((e=>e.length>=1),"Minimum length is 1");const Mi=Ii((e=>"string"==typeof e),"Input is not a string"),Ui=Ii((e=>Array.isArray(e)),"Input is not an array"),Wi=Ii((e=>"boolean"==typeof e),"Input is not a boolean"),$i=Ii((e=>void 0===e),"Input is defined"),Pi=Ci([Mi(),$i()],"Input is not a string or undefined"),_i=Ci([Ui(),Wi()],"Input is not an array or boolean"),Li=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>Ai(...e).validate(n[t]))),t(...n)),Ni=e=>[Mi(`"${e}" must be a string`)],Di=e=>[Pi(`"${e}" must be string or undefined`)],Fi=e=>[Mi(`"${e}" must be a string`),Ti(`"${e}" must not be empty`)],qi=e=>[Mi(`"${e}" must be a string`),ji()],zi=e=>[Mi(`"${e}" must be a string`),Ri()],Hi=Li(Fi("accessKey")),Vi=e=>({exchange:Hi(((t,n)=>ki(e.post(Jn.accessKey.exchange,{loginOptions:n},{token:t}))))}),Bi=(e,t,n)=>(t.forEach((t=>{const i=t.split(".");let o=i.shift(),r=e;for(;i.length>0;){if(r=r[o],!o||!r)throw Error(`Invalid path "${t}", "${o}" is missing or has no value`);o=i.shift()}if("function"!=typeof r[o])throw Error(`"${t}" is not a function`);const s=r[o];r[o]=n(s)})),e),Ji=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||Xn,Xn)});var Ki,Zi;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp",e.im="im"}(Ki||(Ki={})),function(e){e.email="email"}(Zi||(Zi={}));const Xi=Object.assign(Object.assign({},Ki),Zi);var Gi;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(Gi||(Gi={}));const Yi=Fi("loginId"),Qi=Li(Fi("token")),eo=Li(Yi),to=Li(Fi("pendingRef")),no=Li(Yi,qi("email")),io=e=>({verify:Qi((t=>ki(e.post(Jn.enchantedLink.verify,{token:t})))),signIn:eo(((n,i,o={},r)=>{var{providerId:s}=o,a=t(o,["providerId"]);return ki(e.post(yi(Jn.enchantedLink.signIn,Xi.email),{loginId:n,URI:i,loginOptions:a,providerId:s},{token:r}))})),signUpOrIn:eo(((n,i,o={})=>{var{providerId:r}=o,s=t(o,["providerId"]);return ki(e.post(yi(Jn.enchantedLink.signUpOrIn,Xi.email),{loginId:n,URI:i,loginOptions:s,providerId:r}))})),signUp:eo(((n,i,o,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return ki(e.post(yi(Jn.enchantedLink.signUp,Xi.email),{loginId:n,URI:i,user:o,loginOptions:a,providerId:s}))})),waitForSession:to(((t,n)=>new Promise((i=>{const{pollingIntervalMs:o,timeoutMs:r}=Ji(n);let s;const a=setInterval((async()=>{const n=await e.post(Jn.enchantedLink.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),i(ki(Promise.resolve(n))))}),o);s=setTimeout((()=>{i({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:no(((t,n,i,o,r)=>ki(e.post(Jn.enchantedLink.update.email,Object.assign({loginId:t,email:n,URI:i},r),{token:o}))))}}),oo=Li(Fi("flowId")),ro=Li(Fi("executionId"),Fi("stepId"),Fi("interactionId")),so=e=>({start:oo(((t,n,i,o,r,s,a,l=!1)=>ki(e.post(Jn.flow.start,{flowId:t,options:n,conditionInteractionId:i,interactionId:o,componentsVersion:r,flowVersions:s,input:a,isCustomScreen:l})))),next:ro(((t,n,i,o,r,s,a=!1)=>ki(e.post(Jn.flow.next,{executionId:t,stepId:n,interactionId:i,version:o,componentsVersion:r,input:s,isCustomScreen:a}))))}),ao=Fi("loginId"),lo=Li(Fi("token")),co=Li(ao),uo=Li(ao,zi("phone")),ho=Li(ao,qi("email")),po=Object.keys(Xi).filter((e=>e!==Ki.voice&&e!==Ki.im)),fo=e=>({verify:lo((t=>ki(e.post(Jn.magicLink.verify,{token:t})))),signIn:po.reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:co(((n,o,r={},s)=>{var{providerId:a}=r,l=t(r,["providerId"]);return ki(e.post(yi(Jn.magicLink.signIn,i),{loginId:n,URI:o,loginOptions:l,providerId:a},{token:s}))}))})),{}),signUp:po.reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:co(((n,o,r,s={})=>{var{providerId:a}=s,l=t(s,["providerId"]);return ki(e.post(yi(Jn.magicLink.signUp,i),{loginId:n,URI:o,user:r,loginOptions:l,providerId:a}))}))})),{}),signUpOrIn:po.reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:co(((n,o,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return ki(e.post(yi(Jn.magicLink.signUpOrIn,i),{loginId:n,URI:o,loginOptions:a,providerId:s}))}))})),{}),update:{email:ho(((t,n,i,o,r)=>ki(e.post(Jn.magicLink.update.email,Object.assign({loginId:t,email:n,URI:i},r),{token:o})))),phone:Object.keys(Ki).filter((e=>e!==Ki.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:uo(((t,i,o,r,s)=>ki(e.post(yi(Jn.magicLink.update.phone,n),Object.assign({loginId:t,phone:i,URI:o},s),{token:r}))))})),{})}});var go;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple",e.discord="discord",e.linkedin="linkedin",e.slack="slack"}(go||(go={}));const vo=Li(Fi("code")),mo=e=>({start:Object.assign(((t,n,i,o,r)=>ki(e.post(Jn.oauth.start,i||{},{queryParams:Object.assign(Object.assign({provider:t},n&&{redirectURL:n}),r&&{loginHint:r}),token:o}))),Object.keys(go).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,i,o,r)=>ki(e.post(Jn.oauth.start,i||{},{queryParams:Object.assign(Object.assign({provider:n},t&&{redirectURL:t}),r&&{loginHint:r}),token:o}))})),{})),exchange:vo((t=>ki(e.post(Jn.oauth.exchange,{code:t})))),startNative:(t,n,i)=>ki(e.post(Jn.oauth.startNative,{provider:t,loginOptions:n,implicit:i})),finishNative:(t,n,i,o,r)=>ki(e.post(Jn.oauth.finishNative,{provider:t,stateId:n,user:i,code:o,idToken:r})),getOneTapClientId:t=>ki(e.get(Jn.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,n,i,o)=>ki(e.post(Jn.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:n,nonce:i,loginOptions:o})),exchangeOneTapIDToken:(t,n,i,o)=>ki(e.post(Jn.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:n,nonce:i,loginOptions:o}))}),wo=Fi("appId"),bo=Li(wo),yo=e=>({connect:bo(((t,n,i)=>{const o=null==n?void 0:n.tenantId,r=null==n?void 0:n.tenantLevel;return null==n||delete n.tenantId,null==n||delete n.tenantLevel,ki(e.post(Jn.outbound.connect,{appId:t,tenantId:o,tenantLevel:r,options:n},{token:i}))}))}),ko=Fi("loginId"),So=Li(ko,Fi("code")),Io=Li(ko),Co=Li(ko,zi("phone")),Ao=Li(ko,qi("email")),xo=e=>({verify:Object.keys(Xi).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:So(((t,i)=>ki(e.post(yi(Jn.otp.verify,n),{code:i,loginId:t}))))})),{}),signIn:Object.keys(Xi).reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:Io(((n,o={},r)=>{var{providerId:s}=o,a=t(o,["providerId"]);return ki(e.post(yi(Jn.otp.signIn,i),{loginId:n,loginOptions:a,providerId:s},{token:r}))}))})),{}),signUp:Object.keys(Xi).reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:Io(((n,o,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return ki(e.post(yi(Jn.otp.signUp,i),{loginId:n,user:o,loginOptions:a,providerId:s}))}))})),{}),signUpOrIn:Object.keys(Xi).reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:Io(((n,o={})=>{var{providerId:r}=o,s=t(o,["providerId"]);return ki(e.post(yi(Jn.otp.signUpOrIn,i),{loginId:n,loginOptions:s,providerId:r}))}))})),{}),update:{email:Ao(((t,n,i,o)=>ki(e.post(Jn.otp.update.email,Object.assign({loginId:t,email:n},o),{token:i})))),phone:Object.keys(Ki).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Co(((t,i,o,r)=>ki(e.post(yi(Jn.otp.update.phone,n),Object.assign({loginId:t,phone:i},r),{token:o}))))})),{})}}),Oo=Li(Fi("tenant")),Eo=Li(Fi("code")),jo=e=>({start:Oo(((t,n,i,o,r,s,a,l)=>ki(e.post(Jn.sso.start,i||{},Object.assign({queryParams:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({tenant:t},n&&{redirectURL:n}),r&&{ssoId:r}),s&&{forceAuthn:"true"}),a&&{loginHint:a}),l&&{initiatedEmail:t})},o&&{token:o}))))),exchange:Eo((t=>ki(e.post(Jn.sso.exchange,{code:t}))))}),Ro=Fi("loginId"),To=Li(Ro,Fi("code")),Mo=Li(Ro),Uo=Li(Ro),Wo=e=>({signUp:Mo(((t,n)=>ki(e.post(Jn.totp.signUp,{loginId:t,user:n})))),verify:To(((t,n,i,o)=>ki(e.post(Jn.totp.verify,{loginId:t,code:n,loginOptions:i},{token:o})))),update:Uo(((t,n)=>ki(e.post(Jn.totp.update,{loginId:t},{token:n}))))}),$o=Fi("loginId"),Po=Fi("newPassword"),_o=Li($o,Fi("password")),Lo=Li($o),No=Li($o,Po),Do=Li($o,Fi("oldPassword"),Po),Fo=e=>({signUp:_o(((n,i,o,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return ki(e.post(Jn.password.signUp,{loginId:n,password:i,user:o,loginOptions:a,providerId:s}))})),signIn:_o(((n,i,o={})=>{var{providerId:r}=o,s=t(o,["providerId"]);return ki(e.post(Jn.password.signIn,{loginId:n,password:i,loginOptions:s,providerId:r}))})),sendReset:Lo(((t,n,i)=>ki(e.post(Jn.password.sendReset,{loginId:t,redirectUrl:n,templateOptions:i})))),update:No(((t,n,i)=>ki(e.post(Jn.password.update,{loginId:t,newPassword:n},{token:i})))),replace:Do(((t,n,i)=>ki(e.post(Jn.password.replace,{loginId:t,oldPassword:n,newPassword:i})))),policy:()=>ki(e.get(Jn.password.policy))}),qo=Ni("loginId"),zo=Fi("loginId"),Ho=Fi("origin"),Vo=Li(zo,Ho,Fi("name")),Bo=Li(zo,Ho),Jo=Li(qo,Ho),Ko=Li(zo,Ho,Di("token")),Zo=Li(Fi("transactionId"),Fi("response")),Xo=e=>({signUp:{start:Vo(((t,n,i,o,r)=>ki(e.post(Jn.webauthn.signUp.start,{user:{loginId:t,name:i},origin:n,loginOptions:r,passkeyOptions:o})))),finish:Zo(((t,n)=>ki(e.post(Jn.webauthn.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:Jo(((t,n,i,o,r)=>ki(e.post(Jn.webauthn.signIn.start,{loginId:t,origin:n,loginOptions:i,passkeyOptions:r},{token:o})))),finish:Zo(((t,n)=>ki(e.post(Jn.webauthn.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Bo(((t,n,i,o)=>ki(e.post(Jn.webauthn.signUpOrIn.start,{loginId:t,origin:n,loginOptions:o,passkeyOptions:i}))))},update:{start:Ko(((t,n,i,o,r)=>ki(e.post(Jn.webauthn.update.start,{loginId:t,origin:n,passkeyOptions:o,mfa:r},{token:i})))),finish:Zo(((t,n)=>ki(e.post(Jn.webauthn.update.finish,{transactionId:t,response:n}))))}}),Go=Ni("loginId"),Yo=Li(Go),Qo=Li(Fi("pendingRef")),er=e=>({signUpOrIn:Yo(((n,i={})=>{var{providerId:o}=i,r=t(i,["providerId"]);return ki(e.post(Jn.notp.signUpOrIn,{loginId:n,loginOptions:r,providerId:o}))})),signUp:Yo(((n,i,o={})=>{var{providerId:r}=o,s=t(o,["providerId"]);return ki(e.post(Jn.notp.signUp,{loginId:n,user:i,providerId:r,loginOptions:s}))})),signIn:Yo(((n,i={},o)=>{var{providerId:r}=i,s=t(i,["providerId"]);return ki(e.post(Jn.notp.signIn,{loginId:n,loginOptions:s,providerId:r},{token:o}))})),waitForSession:Qo(((t,n)=>new Promise((i=>{const{pollingIntervalMs:o,timeoutMs:r}=Ji(n);let s;const a=setInterval((async()=>{const n=await e.post(Jn.notp.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),i(ki(Promise.resolve(n))))}),o);s=setTimeout((()=>{i({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),tr=Li(Fi("token")),nr=Li(Di("token"));var ir,or=Li([(ir=Fi("projectId"),Ii(((e,t)=>n=>Ai(...t).validate(((e,t)=>{const n=(Array.isArray(t)?t.join("."):String(t)).replace(/\[\\?("|')?(\w|d)+\\?("|')?\]/g,((e,t,n)=>"."+n)).split("."),i=n.length;let o=0,r=e===Object(e)?e:void 0;for(;null!=r&&o<i;)r=r[n[o++]];return o&&o===i&&void 0!==r?r:void 0})(n,e)))("projectId",ir))())])((e=>{const{projectId:t,logger:n,baseUrl:i,cookiePolicy:o,baseHeaders:r={},refreshCookieName:s,fetch:a}=e;return l=hi({baseUrl:i,projectId:t,logger:n,hooks:{get beforeRequest(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.beforeRequest},get afterRequest(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.afterRequest},get transformResponse(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}},cookiePolicy:o,baseConfig:{baseHeaders:r},refreshCookieName:s,fetch:a}),{accessKey:Vi(l),otp:xo(l),magicLink:fo(l),enchantedLink:io(l),oauth:mo(l),outbound:yo(l),sso:jo(l),saml:jo(l),totp:Wo(l),notp:er(l),webauthn:Xo(l),password:Fo(l),flow:so(l),refresh:nr(((e,t,n,i)=>{const o={};n&&(o.externalToken=n);const r=i?Jn.tryRefresh:Jn.refresh;return ki(l.post(r,o,{token:e,queryParams:t}))})),selectTenant:Li([Mi("tenantId")],[Pi('"token" must be string or undefined')])(((e,t)=>ki(l.post(Jn.selectTenant,{tenant:e},{token:t})))),logout:nr((e=>ki(l.post(Jn.logout,{},{token:e})))),logoutAll:nr((e=>ki(l.post(Jn.logoutAll,{},{token:e})))),me:nr((e=>ki(l.get(Jn.me,{token:e})))),myTenants:Li([_i('"tenants" must a string array or a boolean')],[Pi('"token" must be string or undefined')])(((e,t)=>{const n={};return"boolean"==typeof e?n.dct=e:n.ids=e,ki(l.post(Jn.myTenants,n,{token:t}))})),history:nr((e=>ki(l.get(Jn.history,{token:e})))),isJwtExpired:tr(vi),getTenants:tr(mi),getJwtPermissions:tr(wi),getJwtRoles:tr(bi),getCurrentTenant:tr(Si),httpClient:l};var l})),rr=Object.assign(or,{DeliveryMethods:Xi});
6
- /*! js-cookie v3.0.8 | MIT */function sr(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)"__proto__"!==i&&(e[i]=n[i])}return e}var ar=function e(t,n){function i(e,i,o){if("undefined"!=typeof document){"number"==typeof(o=sr({},n,o)).expires&&(o.expires=new Date(Date.now()+864e5*o.expires)),o.expires&&(o.expires=o.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var r="";for(var s in o)o[s]&&(r+="; "+s,!0!==o[s]&&(r+="="+o[s].split(";")[0]));return document.cookie=e+"="+t.write(i,e)+r}}return Object.create({set:i,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],i={},o=0;o<n.length;o++){var r=n[o].split("="),s=r.slice(1).join("=");try{var a=decodeURIComponent(r[0]);if(a in i||(i[a]=t.read(s,a)),e===a)break}catch(e){}}return e?i[e]:i}},remove:function(e,t){i(e,"",sr({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,sr({},this.attributes,t))},withConverter:function(t){return e(sr({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(t)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"});var lr={default:"endpoint"},cr="Blocked by CSP",dr="The endpoint parameter is not a valid URL",ur="Failed to load the JS script of the agent",hr="9319";function pr(e,t){var n,i,o,r,s,a=[],l=(n=function(e){var t=function(e,t,n){if(n||2===arguments.length)for(var i,o=0,r=t.length;o<r;o++)!i&&o in t||(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))}([],e,!0);return{current:function(){return t[0]},postpone:function(){var e=t.shift();void 0!==e&&t.push(e)},exclude:function(){t.shift()}}}(e),r=0,i=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,r++))},o=new Set,[n.current(),function(e,t){var r,s=t instanceof Error?t.message:"";if(s===cr||s===dr)n.exclude(),r=0;else if(s===hr)n.exclude();else if(s===ur){var a=Date.now()-e.getTime()<50,l=n.current();l&&a&&!o.has(l)&&(o.add(l),r=0),n.postpone()}else n.postpone();var c=n.current();return void 0===c?void 0:[c,null!=r?r:e.getTime()+i()-Date.now()]}]),c=l[0],d=l[1];if(void 0===c)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var u=function(e){var n=new Date,i=function(t){return a.push({url:e,startedAt:n,finishedAt:new Date,error:t})},o=t(e);return o.then((function(){return i()}),i),o.catch((function(e){if(null!=s||(s=e),a.length>=5)throw s;var t=d(n,e);if(!t)throw s;var i,o=t[0],r=t[1];return(i=r,new Promise((function(e){return setTimeout(e,i)}))).then((function(){return u(o)}))}))};return u(c).then((function(e){return[e,a]}))}var fr="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",gr=fr;function vr(n){var i;n.scriptUrlPattern;var o=n.token,r=n.apiKey,s=void 0===r?o:r,a=t(n,["scriptUrlPattern","token","apiKey"]),l=null!==(i=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(n,"scriptUrlPattern"))&&void 0!==i?i:fr,c=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},n=function(e,t,n,i){return e.addEventListener(t,n,i),function(){return e.removeEventListener(t,n,i)}}(document,"visibilitychange",t);return t(),[e,n]}(),d=c[0],u=c[1];return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error("API key required");var e=function(e,t){return(Array.isArray(e)?e:[e]).map((function(e){return function(e,t){var n=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?n(t):"<loaderVersion>"===e?n("3.11.6"):e}))}(String(e),t)}))}(l,s);return pr(e,mr)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===hr?new Error(ur):e}(e)})).then((function(t){var n=t[0],i=t[1];return u(),n.load(e(e({},a),{ldi:{attempts:i,visibilityStates:d}}))}))}function mr(e){return function(e,t,n){var i,o=document,r="securitypolicyviolation",s=function(t){var n=new URL(e,location.href),o=t.blockedURI;o!==n.href&&o!==n.protocol.slice(0,-1)&&o!==n.origin||(i=t,a())};o.addEventListener(r,s);var a=function(){return o.removeEventListener(r,s)};return Promise.resolve().then(t).then((function(e){return a(),e}),(function(e){return new Promise((function(e){var t=new MessageChannel;t.port1.onmessage=function(){return e()},t.port2.postMessage(null)})).then((function(){if(a(),i)return n(i);throw e}))}))}(e,(function(){return function(e){return new Promise((function(t,n){if(function(e){if(URL.prototype)try{return new URL(e,location.href),!1}catch(e){if(e instanceof Error&&"TypeError"===e.name)return!0;throw e}}(e))throw new Error(dr);var i=document.createElement("script"),o=function(){var e;return null===(e=i.parentNode)||void 0===e?void 0:e.removeChild(i)},r=document.head||document.getElementsByTagName("head")[0];i.onload=function(){o(),t()},i.onerror=function(){o(),n(new Error(ur))},i.async=!0,i.src=e,r.appendChild(i)}))}(e)}),(function(){throw new Error(cr)})).then(wr)}function wr(){var e=window,t="__fpjs_p_l_b",n=e[t];if(function(e,t){var n,i=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==i?void 0:i.configurable)?delete e[t]:i&&!i.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error(hr);return n}const br="3.2.0",yr="undefined"!=typeof window,kr=Math.pow(2,31)-1,Sr=`https://descopecdn.com/npm/oidc-client-ts@${br}/dist/browser/oidc-client-ts.min.js`,Ir=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${br}/dist/browser/oidc-client-ts.min.js`,Cr=["/v1/auth/refresh","/v1/auth/try-refresh","/v1/auth/me","/v1/auth/me/tenants","/v1/auth/me/history"];let Ar;const xr=e=>{try{return Bn(e).exp}catch(e){return null}},Or=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:xr(n)},Er=e=>{const{expires_in:t,expires_at:n,access_token:i}=e;return n||(t?Math.floor(Date.now()/1e3)+t:i?xr(i):void 0)},jr=e=>{const{access_token:n,id_token:i,refresh_token:o,refresh_expire_in:r}=e,s=t(e,["access_token","id_token","refresh_token","refresh_expire_in"]);return Object.assign({sessionJwt:e.sessionJwt||n,idToken:i,refreshJwt:e.refreshJwt||o,sessionExpiration:e.sessionExpiration||Er(e),cookieExpiration:e.cookieExpiration||Or(e)},s)},Rr=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,i)=>{var o;return n[i]=[].concat((null===(o=e.hooks)||void 0===o?void 0:o[i])||[]).concat((null==t?void 0:t[i])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},Tr=async e=>{if(!(null==e?void 0:e.ok))return{};const t=await(null==e?void 0:e.clone().json()),n=(null==t?void 0:t.authInfo)||t||{};return jr(n)},Mr=()=>yr&&!!window.descopeBridge,Ur=(e,t)=>{if(!((null==t?void 0:t.status)>=400&&(null==t?void 0:t.status)<500))return!1;const n=(null==e?void 0:e.path)||"";return Cr.includes(n)},Wr=void 0!==Ar||yr&&void 0!==window.localStorage,$r=(e,t)=>{var n,i;return null===(i=null===(n=Ar||yr&&window.localStorage)||void 0===n?void 0:n.setItem)||void 0===i?void 0:i.call(n,e,t)},Pr=e=>{var t,n;return null===(n=null===(t=Ar||yr&&window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e)},_r=e=>{var t,n;return null===(n=null===(t=Ar||yr&&window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n?void 0:n.call(t,e)},Lr=e=>{var t,n,i,o,r;return null!==(r=null!==(n=null===(t=null==Ar?void 0:Ar.key)||void 0===t?void 0:t.call(Ar,e))&&void 0!==n?n:yr&&(null===(o=null===(i=window.localStorage)||void 0===i?void 0:i.key)||void 0===o?void 0:o.call(i,e)))&&void 0!==r?r:null},Nr=(...e)=>{console.debug(...e)},Dr=(...e)=>{console.warn(...e)},Fr="DS",qr="DSR",zr="DSI",Hr="DSRCN";function Vr(e,t,n){if(t){const{cookieDomain:i,cookiePath:o,cookieSameSite:r,cookieExpiration:s,cookieSecure:a}=n,l=new Date(1e3*s),c=Br(i);ar.set(e,t,{path:o,domain:c?i:void 0,expires:l,sameSite:r,secure:a})}}function Br(e){const t=window.location.hostname.split("."),n=null==e?void 0:e.split(".");return t.slice(-(null==n?void 0:n.length)).join(".")===e}const Jr=e=>(null==e?void 0:e.cookieName)||Fr,Kr=e=>(null==e?void 0:e.cookieName)||qr;function Zr(e="",t){return ar.get(Kr(t))||Pr(`${e}${qr}`)||""}function Xr(e="",t){return ar.get(Jr(t))||Pr(`${e}${Fr}`)||""}function Gr(e=""){return Pr(`${e}${zr}`)||""}function Yr(e="",t,n,i){_r(`${e}${qr}`),_r(`${e}${Fr}`),_r(`${e}${zr}`),_r(`${e}${Hr}`);const o=Jr(t);ar.remove(o,null==i?void 0:i.session);const r=Kr(n);ar.remove(r,null==i?void 0:i.refresh)}const Qr=(e,t,n)=>i=>{const o=Object.assign(i,{token:i.token||Zr(e,t)});if(!n){const t=function(e=""){return Pr(`${e}${Hr}`)}(e);t&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-refresh-cookie-name":t}))}const r=function(e=""){return Pr(`${e}DTD`)||""}(e);return r&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-trusted-device-token":r})),o},es=yr&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",ts="vsid",ns="vrid",is="fp",os=(e=!1)=>{const t=Pr(is);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},rs=async(e,t=es)=>{try{if(os())return;const n=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),i=new URL(t);i.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const r=o.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=vr({apiKey:e,endpoint:[i.toString(),lr],scriptUrlPattern:[r,gr]}),a=await s,{requestId:l}=await a.get({linkedId:n}),c=((e,t)=>({[ts]:e,[ns]:t}))(n,l);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};$r(is,JSON.stringify(t))})(c)}catch(e){console.warn("Could not load fingerprint",e)}},ss=e=>{const t=os(!0);return t&&e.body&&(e.body.fpData=t),e},as="descopeFlowNonce",ls="X-Descope-Flow-Nonce",cs="/v1/flow/start",ds="/v1/flow/next",us=(e,t=as)=>`${t}${e}`,hs=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||null},ps=e=>{var t;return e.path===ds&&(null===(t=e.body)||void 0===t?void 0:t.executionId)?hs(e.body.executionId):null},fs="dls_last_user_login_id",gs="dls_last_user_display_name",vs=e=>$r(fs,e),ms=()=>Pr(fs),ws=()=>Pr(gs),bs=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,i={}]=t,o=ms(),r=ws();return o&&(null!==(n=i.lastAuth)&&void 0!==n||(i.lastAuth={}),i.lastAuth.loginId=o,i.lastAuth.name=r),await e(...t)},ys="DSLI",ks=e=>async(...t)=>{const n=await e(...t);return _r(ys),n};function Ss(){const e=[];return{pub:t=>{e.forEach((e=>e(t)))},sub:t=>{const n=e.push(t)-1;return()=>e.splice(n,1)}}}async function Is(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Rs(n.publicKey.challenge),n.publicKey.user.id=Rs(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=Rs(e.id)})),n}(e);try{return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:Ts(n.rawId),type:n.type,response:{attestationObject:Ts(n.response.attestationObject),clientDataJSON:Ts(n.response.clientDataJSON)}})}catch(e){throw await xs(e,t,!0)}var n}async function Cs(e){const t=Es(e);try{return js(await navigator.credentials.get(t))}catch(e){throw await xs(e,t,!1)}}async function As(e,t){const n=Es(e);n.signal=t.signal,n.mediation="conditional";try{return js(await navigator.credentials.get(n))}catch(e){throw await xs(e,n,!1)}}async function xs(e,t,n){if(e&&"object"==typeof e)try{e.reason=await async function(e,t,n){var i,o;const r=null==e?void 0:e.name;if("AbortError"===r&&(null==t?void 0:t.signal)instanceof AbortSignal)return"aborted";if("InvalidStateError"===r&&n)return"authenticator_already_registered";if("NotSupportedError"===r)return"no_supported_algorithm";if("ConstraintError"===r)return"authenticator_constraints_unsupported";if("SecurityError"===r){const e=window.location.hostname;return"localhost"===e||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)?"invalid_rpid":"invalid_domain"}if(!await Os())return"webauthn_unsupported";const s="platform"===(null===(o=null===(i=null==t?void 0:t.publicKey)||void 0===i?void 0:i.authenticatorSelection)||void 0===o?void 0:o.authenticatorAttachment);return n&&s&&!await Os(!0)?"platform_authenticator_unsupported":"NotAllowedError"===r?"not_allowed":"unknown"}(e,t,n)}catch(e){}return e}async function Os(e=!1){var t,n;if(!yr)return Promise.resolve(!1);if(Mr()){const e=null===(n=null===(t=window.descopeBridge)||void 0===t?void 0:t.hostInfo)||void 0===n?void 0:n.webauthn;if("boolean"==typeof e)return e}const i=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return i&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():i}function Es(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Rs(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=Rs(e.id)})),n}function js(e){return JSON.stringify({id:e.id,rawId:Ts(e.rawId),type:e.type,response:{authenticatorData:Ts(e.response.authenticatorData),clientDataJSON:Ts(e.response.clientDataJSON),signature:Ts(e.response.signature),userHandle:e.response.userHandle?Ts(e.response.userHandle):void 0}})}function Rs(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function Ts(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var Ms,Us=(Ms=e=>({async signUp(t,n,i){const o=await e.webauthn.signUp.start(t,window.location.origin,n,i);if(!o.ok)return o;const r=await Is(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,r)},async signIn(t,n){const i=await e.webauthn.signIn.start(t,window.location.origin,void 0,void 0,n);if(!i.ok)return i;const o=await Cs(i.data.options);return await e.webauthn.signIn.finish(i.data.transactionId,o)},async signUpOrIn(t,n){var i;const o=await e.webauthn.signUpOrIn.start(t,window.location.origin,n);if(!o.ok)return o;if(null===(i=o.data)||void 0===i?void 0:i.create){const t=await Is(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,t)}{const t=await Cs(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,t)}},async update(t,n,i){const o=await e.webauthn.update.start(t,window.location.origin,n,i);if(!o.ok)return o;const r=await Is(o.data.options);return await e.webauthn.update.finish(o.data.transactionId,r)},helpers:{create:Is,get:Cs,isSupported:Os,conditional:As}}),(...e)=>{const t=Ms(...e);return Object.assign(t.signUp,e[0].webauthn.signUp),Object.assign(t.signIn,e[0].webauthn.signIn),Object.assign(t.signUpOrIn,e[0].webauthn.signUpOrIn),Object.assign(t.update,e[0].webauthn.update),t});const Ws="/fedcm/config",$s=()=>{if(window.crypto&&window.crypto.getRandomValues){const e=new Uint8Array(16);return window.crypto.getRandomValues(e),Array.from(e,(e=>e.toString(16).padStart(2,"0"))).join("")}return Math.random().toString(36).substring(2)};async function Ps(e,t){var n;try{await _s(e,t)}catch(e){null===(n=null==t?void 0:t.onFailed)||void 0===n||n.call(t,e)}}async function _s(e,t){var n,i;const o=await async function(e,t="google",n,i,o){const r=$s(),s=await async function(){return new Promise(((e,t)=>{if(window.google)return void e(window.google.accounts.id);let n=document.getElementById("google-gsi-client-script");n||(n=document.createElement("script"),document.head.appendChild(n),n.async=!0,n.defer=!0,n.id="google-gsi-client-script",n.src="https://accounts.google.com/gsi/client"),n.onload=function(){window.google?e(window.google.accounts.id):t("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){t("Failed to load Google GSI client script - failed to load")}}))}(),a=await e.oauth.getOneTapClientId(t);if(!a.ok)throw new Error("Failed to get OneTap client ID for provider "+t);const l=a.data.clientId;return new Promise((e=>{var a,c;const d=n=>{e({provider:t,nonce:r,credential:null==n?void 0:n.credential})};s.initialize(Object.assign(Object.assign({},n),{itp_support:null===(a=null==n?void 0:n.itp_support)||void 0===a||a,use_fedcm_for_prompt:null===(c=null==n?void 0:n.use_fedcm_for_prompt)||void 0===c||c,client_id:l,callback:d,nonce:r})),s.prompt((e=>{var t,n;if(o&&(null==e?void 0:e.isDismissedMoment())){const n=null===(t=e.getDismissedReason)||void 0===t?void 0:t.call(e);return null==o||o(n),void d()}if(i&&(null==e?void 0:e.isSkippedMoment())){const t=null===(n=e.getSkippedReason)||void 0===n?void 0:n.call(e);return null==i||i(t),void d()}}))}))}(e,t.provider,t.oneTapConfig,t.onSkipped,t.onDismissed);if(!o.credential)return null;if(null==t?void 0:t.onCodeReceived){const i=await e.oauth.verifyOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!i.ok||!i.data)throw new Error("Failed to verify OneTap client ID for provider "+o.provider);null===(n=null==t?void 0:t.onCodeReceived)||void 0===n||n.call(t,i.data.code)}else{const n=await e.oauth.exchangeOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!n.ok||!n.data)throw new Error("Failed to exchange OneTap client ID for provider "+o.provider);null===(i=null==t?void 0:t.onAuthenticated)||void 0===i||i.call(t,n.data)}}var Ls=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await Os(),i=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=i,e.flow.start(...t)}});let Ns;const Ds=(e,t)=>new Promise(((n,i)=>{if(!e.length)return i(new Error("No URLs provided to loadScriptWithFallback"));const o=t();if(o)return n(o);const r=e.shift(),s=document.createElement("script");s.src=r,s.id=(e=>{let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t).toString(16)})(r),s.onload=()=>{const e=t();if(e)return n(e);throw new Error("Could not get entry after loading script from URL")},s.addEventListener("error",(()=>{Ds(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)})),Fs=(e,t,n)=>{const i=async()=>{let i,o;return i&&o||({client:i,stateUserKey:o}=await(async(e,t,n)=>{Ns||(Ns=(async()=>{try{return require("oidc-client-ts")}catch(e){return Ds([Sr,Ir],(()=>window.oidc))}})());const{OidcClient:i,WebStorageStateStore:o}=await Ns;if(!i)throw new Error("oidc-client-ts is not installed. Please install it by running `npm install oidc-client-ts`");const r=(null==n?void 0:n.redirectUri)||window.location.href;let s,a,l,c;if(null==n?void 0:n.issuer){if(!n.clientId)throw new Error("clientId is required when providing a custom issuer/authority");s=n.issuer,a=n.clientId,l=`${a}_user`,c="openid"}else(null==n?void 0:n.applicationId)?(s=e.httpClient.buildUrl(t),s=`${s}/${n.applicationId}`,a=t,l=`${a}_user`,c="openid email roles descope.custom_claims offline_access"):(s=e.httpClient.buildUrl(t),a=t,l=`${a}_user`,c="openid email roles descope.custom_claims offline_access");const d={authority:s,client_id:a,redirect_uri:r,response_type:"code",scope:(null==n?void 0:n.scope)||c,stateStore:new o({store:window.localStorage,prefix:a}),loadUserInfo:!0,fetchRequestCredentials:"same-origin"};return(null==n?void 0:n.redirectUri)&&(d.redirect_uri=n.redirectUri),{client:new i(d),stateUserKey:l}})(e,t,n)),{client:i,stateUserKey:o}},o=async(t="")=>{var n;const{client:o,stateUserKey:r}=await i(),s=await o.processSigninResponse(t||window.location.href);var a;return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(s)))),$r(r,JSON.stringify({id_token:(a=s).id_token,session_state:a.session_state,profile:a.profile})),(()=>{const e=new URL(window.location.href);e.searchParams.delete("code"),e.searchParams.delete("state"),window.history.replaceState({},document.title,e.toString())})(),s};return{loginWithRedirect:async(t={},n=!1)=>{var o;const{client:r}=await i(),s=await r.createSigninRequest(t),{url:a}=s;return n||(await(null===(o=e.httpClient.hooks)||void 0===o?void 0:o.afterRequest({},new Response(JSON.stringify(s)))),window.location.href=a),{ok:!0,data:s}},finishLogin:o,finishLoginIfNeed:async(e="")=>{if(window.location.search.includes("code")&&window.location.search.includes("state"))return await o(e)},refreshToken:async t=>{var n;const{client:o,stateUserKey:r}=await i(),s=(e=>{const t=Pr(e);return t?JSON.parse(t):null})(r);if(!s)throw new Error("User not found in storage to refresh token");let a=t;if(!a){const t={};e.httpClient.hooks.beforeRequest(t),a=t.token}const l=await o.useRefreshToken({state:{refresh_token:a,session_state:s.session_state,profile:s.profile}});return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(l)))),l},logout:async(e,t=!1)=>{const{client:n,stateUserKey:o}=await i();e||(e={}),e.id_token_hint=e.id_token_hint||Gr(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const r=await n.createSignoutRequest(e),{url:s}=r;return _r(o),t||window.location.replace(s),r}}},qs=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>t=>{var n;return n=t.customStorage,Ar=n,e(t)}),(e=>n=>{var{fpKey:i,fpLoad:o}=n,r=t(n,["fpKey","fpLoad"]);return yr?(i&&o&&rs(i).catch((()=>null)),e(Rr(r,{beforeRequest:ss}))):e(r)}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.51.1"},t.baseHeaders)}))),(e=>t=>{const n=Ss(),i=Ss(),o=Ss(),r=Ss(),s=e(Rr(t,{afterRequest:async(e,t)=>{if(Ur(e,t))Nr("Session invalidated, notifying subscribers with empty values"),i.pub(null),o.pub(null),n.pub(null),r.pub(null);else{const e=await(async e=>{const t=await Tr(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)})(t);e&&o.pub(e);const{sessionJwt:s,sessionExpiration:a,claims:l}=await Tr(t);s&&i.pub(s),l&&r.pub(l),(a||s)&&n.pub(a||42)}}})),a=Bi(s,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const s=await e(...t);return i.pub(null),o.pub(null),n.pub(null),r.pub(null),s}));return Object.assign(a,{onSessionTokenChange:i.sub,onUserChange:o.sub,onClaimsChange:r.sub,onIsAuthenticatedChange:e=>n.sub((t=>{e(!!t)}))})}),(e=>n=>{var i;const{enableFlowNonce:o=!0,nonceStoragePrefix:r=as}=n,s=t(n,["enableFlowNonce","nonceStoragePrefix"]);if(!o)return e(s);((e=as)=>{try{if(!Wr)return;for(let o=0;o<(void 0,n=void 0,void 0,null!==(i=null!==(t=null==Ar?void 0:Ar.length)&&void 0!==t?t:yr&&(null===(n=window.localStorage)||void 0===n?void 0:n.length))&&void 0!==i?i:0);o++){const t=Lr(o);if(t&&t.startsWith(e)){const n=Pr(t);if(n)try{JSON.parse(n).expiry<Date.now()&&_r(t)}catch(e){_r(t)}}}}catch(e){console.error("Error cleaning up expired nonces:",e)}var t,n,i})(r);const a=e(Rr(s,{afterRequest:async(e,t)=>{if(e.path!==cs&&e.path!==ds)return;const{nonce:n,executionId:i}=await(async(e,t)=>{try{const n=t.headers.get(ls);let i=await t.clone().json().then((e=>(null==e?void 0:e.executionId)||null)).catch((()=>null));return i||(i=ps(e)),{nonce:n,executionId:hs(i)}}catch(e){return{nonce:null,executionId:null}}})(e,t);n&&i&&((e,t,n,i=as)=>{try{const o=us(e,i),r=n?172800:10800,s={value:t,expiry:Date.now()+1e3*r,isStart:n};$r(o,JSON.stringify(s))}catch(e){console.error("Error setting flow nonce:",e)}})(i,n,e.path===cs,r)},beforeRequest:e=>{if(e.path===ds){const t=ps(e);if(t){const n=((e,t=as)=>{try{const n=us(e,t),i=Pr(n);if(!i)return null;const o=JSON.parse(i);return o.expiry<Date.now()?(((e,t=as)=>{try{const n=us(e,t);_r(n)}catch(e){console.error("Error removing flow nonce:",e)}})(e,t),null):o.value}catch(e){return console.error("Error getting flow nonce:",e),null}})(t,r);n&&(e.headers=e.headers||{},e.headers[ls]=n)}}return e}}));if(null===(i=a.flow)||void 0===i?void 0:i.next){let e=Promise.resolve();const t=a.flow.next.bind(a.flow);a.flow.next=async(...n)=>{const i=e;let o;e=new Promise((e=>{o=e})),await i;try{return await t(...n)}finally{o()}}}return a}),(e=>t=>{const n=e(Rr(t,{afterRequest:async(e,t)=>{if(Ur(e,t))return void _r(ys);const n=await Tr(t);(null==n?void 0:n.sessionExpiration)&&$r(ys,String(n.sessionExpiration))}}));return Bi(n,["logout","logoutAll","oidc.logout"],ks)}),(e=>n=>{var{autoRefresh:i}=n,o=t(n,["autoRefresh"]);const r=!!i,s="object"==typeof i&&(null==i?void 0:i.customActivityTracking);if(!r||Mr())return Object.assign(e(o),{markUserActive:()=>{Dr("markUserActive() called but has no effect")}});const{clearAllTimers:a,setTimer:l}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let c,d,u=null,h=!1,p=!1;s&&(Nr("Activity-based refresh enabled"),u=(()=>{let e=!0;return{hadActivity:()=>e,reset:()=>{e=!1},markActive:()=>{e=!0}}})()),yr&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&c&&new Date>c&&(Nr("Expiration time passed, refreshing session"),f.refresh(Zr()||d))}));const f=e(Rr(o,{afterRequest:async(e,t)=>{const{sessionJwt:n,refreshJwt:i,sessionExpiration:o,nextRefreshSeconds:r}=await Tr(t);if(Ur(e,t))Nr("Session invalidated, canceling all timers"),a();else if(n||o){if(c=((e,t)=>{if(t)return new Date(1e3*t);Nr("Could not extract expiration time from session token, trying to decode the token");try{const t=Bn(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(n,o),!c)return void Nr("Could not extract expiration time from session token");d=i,h=r>0;const e=((e,t)=>{let n;var i;return t>0?(n=1e3*t,Nr(`Using provided nextRefreshSeconds: ${t}s`)):n=((i=e)?i.getTime()-(new Date).getTime():0)-2e4,n>kr&&(Nr(`Timeout is too large (${n}ms), setting it to ${kr}ms`),n=kr),n})(c,r);if(a(),e<=2e4)return void Nr("Session is too close to expiration, not setting refresh timer");const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});Nr(`Setting refresh timer for ${t}. (${e}ms)`),u&&(u.reset(),p=!1),l((()=>{if(yr&&"hidden"===document.visibilityState)Nr("Skipping refresh due to timer - document is hidden");else{if(u&&h&&!u.hadActivity())return Nr("Skipping refresh due to timer - user is idle"),void(p=!0);Nr("Refreshing session due to timer"),f.refresh(Zr()||i)}}),e)}}}));return Object.assign(Bi(f,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return Nr("Clearing all timers"),a(),n})),{markUserActive:u?()=>{Nr("markUserActive() called"),h||Nr("markUserActive() called but server does not have inactivity timeout configured (no nextRefreshSeconds)"),u.markActive(),p&&(Nr("User became active after skipped refresh, triggering refresh"),p=!1,a(),f.refresh(Zr()||d))}:()=>{Dr("markUserActive() called but customActivityTracking is not enabled — this call has no effect")}})}),(e=>n=>{var{storeLastAuthenticatedUser:i=!0,keepLastAuthenticatedUserAfterLogout:o=!1}=n,r=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!i)return Object.assign(e(r),{getLastUserLoginId:ms,getLastUserDisplayName:ws});const s=e(Rr(r,{afterRequest:async(e,t)=>{var n;const{userInfo:i,lastAuth:o}=await(async e=>{if(!(null==e?void 0:e.ok))return{userInfo:void 0,lastAuth:void 0};const t=await(null==e?void 0:e.clone().json()),n=jr((null==t?void 0:t.authInfo)||t||{});return{userInfo:(null==n?void 0:n.user)||((null==n?void 0:n.hasOwnProperty("userId"))?n:void 0),lastAuth:t.lastAuth}})(t),r=null===(n=null==i?void 0:i.loginIds)||void 0===n?void 0:n[0],s=null==i?void 0:i.name;r?(vs(r),(e=>{$r(gs,e)})(s)):(null==o?void 0:o.loginId)&&vs(o.loginId)}}));let a=Bi(s,["flow.start"],bs);return a=Bi(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const i=await t(...n);return e||(_r(fs),_r(gs)),i})(o)),Object.assign(a,{getLastUserLoginId:ms,getLastUserDisplayName:ws})}),(e=>n=>{var{persistTokens:i,sessionTokenViaCookie:o,refreshTokenViaCookie:r,storagePrefix:s,refreshCookieName:a}=n,l=t(n,["persistTokens","sessionTokenViaCookie","refreshTokenViaCookie","storagePrefix","refreshCookieName"]);if(!i||!yr)return e(Object.assign({refreshCookieName:a},l));let c;const d=e(Rr(Object.assign({refreshCookieName:a},l),{beforeRequest:Qr(s,r,a),afterRequest:async(e,t)=>{if(Ur(e,t))Nr("Session invalidated, clearing persisted tokens"),Yr(s,o,r,c);else{const e=await Tr(t);e.cookieName?$r(`${s||""}${Hr}`,e.cookieName):e.refreshJwt&&_r(`${s||""}${Hr}`);const n=((e={},t=!1,n="",i=!1)=>{var o,r,s,a;const{sessionJwt:l,refreshJwt:c,trustedDeviceJwt:d}=e;let u;if(c)if(i){_r(`${n}${qr}`);const t=i.sameSite||"Strict",s=null===(o=i.secure)||void 0===o||o,a=null!==(r=i.domain)&&void 0!==r?r:e.cookieDomain,l=Kr(i);s&&"https:"!==window.location.protocol&&Dr("Refresh token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass refreshTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const d=Object.assign(Object.assign({},e),{cookieSameSite:t,cookieSecure:s,cookieDomain:a});Vr(l,c,d);const h=Br(a);u=Object.assign(Object.assign({},u),{refresh:{path:d.cookiePath,domain:h?a:void 0}})}else{const e=Kr(i);ar.remove(e),$r(`${n}${qr}`,c)}if(l)if(t){const n=t.sameSite||"Strict",i=null===(s=t.secure)||void 0===s||s,o=null!==(a=t.domain)&&void 0!==a?a:e.cookieDomain,r=Jr(t);i&&"https:"!==window.location.protocol&&Dr("Session token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass sessionTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const c=Object.assign(Object.assign({},e),{cookieSameSite:n,cookieSecure:i,cookieDomain:o});Vr(r,l,c);const d=Br(o);u=Object.assign(Object.assign({},u),{session:{path:c.cookiePath,domain:d?o:void 0}})}else $r(`${n}${Fr}`,l);return e.idToken&&$r(`${n}${zr}`,e.idToken),d&&$r(`${n}DTD`,d),u})(e,o,s,r);n&&(c=n)}}})),u=Bi(d,["logout","logoutAll","oidc.logout"],((e,t,n,i)=>o=>async(...r)=>{const s=await o(...r);return Yr(e,t,n,null==i?void 0:i()),s})(s,o,r,(()=>c)));return Object.assign(u,{getRefreshToken:()=>Zr(s,r),getSessionToken:()=>Xr(s,o),getIdToken:()=>Gr(s)})}))((e=>{const t=rr(e),n=Fs(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async(i,o)=>{var r;if(Mr())return Nr(`Refresh called in native flow: ${(new Error).stack}`),Promise.resolve({ok:!1,error:{errorCode:"J171000",errorDescription:"Refresh is not supported in native flows via the web SDK"}});if(e.oidcConfig)try{return await n.refreshToken(i),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161001",errorDescription:e.toString()}})}if(o&&!Pr(ys)&&!Pr(fs)&&!Pr("DSLI_DISABLED"))return Promise.resolve({ok:!0});const s=Xr(),a=Zr();let l="";if(e.getExternalToken)try{l=await(null===(r=e.getExternalToken)||void 0===r?void 0:r.call(e))}catch(e){Nr("Error getting external token while refreshing",e)}return t.refresh(i,{dcs:s?"t":"f",dcr:a?"t":"f"},l,o)},logout:async i=>{if(e.oidcConfig)try{return await n.logout({id_token_hint:i}),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161000",errorDescription:e.toString()}})}return t.logout(i)},flow:Ls(t),webauthn:Us(t),fedcm:(i=t,o=e.projectId,{onetap:{requestExchangeCode(e){Ps(i,e)},requestAuthentication(e){Ps(i,e)}},async oneTap(e,t,n,o,r){await _s(i,{provider:e,oneTapConfig:t,loginOptions:n,onSkipped:o,onDismissed:r})},async launch(e){var t;const n={identity:{context:e||"signin",providers:[{configURL:i.httpClient.buildUrl(o+Ws),clientId:o}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return i.refresh(r.token)},isSupported:()=>yr&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=i.httpClient.buildUrl(o+Ws);try{const i={identity:{context:e||"signin",providers:[{configURL:n,clientId:o}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(i));return!!r&&!!r.token}catch(e){return!1}}}),oidc:n});var i,o})),zs=e=>{if(!e)return null;const t=(e=>{try{const t=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),n=decodeURIComponent(atob(t).split("").map((e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2))).join(""));return JSON.parse(n)}catch(e){return null}})(e);return(null==t?void 0:t.dct)||null},Hs=e=>e.me.data,Vs=Pt(Hs,(e=>e.userId)),Bs=Pt(Hs,(e=>e.picture)),Js=Pt(Hs,(e=>e.email)),Ks=Pt(Hs,(e=>e.verifiedEmail)),Zs=Pt(Hs,(e=>e.name)),Xs=Pt(Hs,(e=>e.phone)),Gs=Pt(Hs,(e=>e.verifiedPhone)),Ys=Pt(Js,Ks,((e,t)=>e&&""!==e.trim()&&!t?"Unverified":"")),Qs=Pt(Xs,Gs,((e,t)=>e&&""!==e.trim()&&!t?"Unverified":"")),ea=Pt(Hs,(e=>e.webauthn));Pt(Hs,(e=>e.password));const ta=Pt(Hs,(e=>e.TOTP)),na=Pt(Hs,(e=>e.customAttributes)),ia=Pt(Hs,(e=>({givenName:e.givenName,middleName:e.middleName,familyName:e.familyName}))),oa=Pt((e=>e.devices.data),(e=>e.map((({id:e,name:t,deviceType:n,lastLoginTime:i,isCurrentDevice:o})=>({id:e,name:t,deviceType:n,lastLoginDate:1e3*parseInt(i,10),isCurrent:o}))))),ra=Pt((e=>e.passkeys.data),(e=>e.map((({id:e,displayName:t,kind:n,createdTime:i})=>({id:e,name:t,passkeyType:n,createdAt:1e3*i}))))),sa=e=>e.notifications,aa=Pt(Hs,(e=>e.userTenants||[])),la=e=>e.tenant.currentTenantId,ca=gn("tenant/select",((e,t)=>n(void 0,[e,t],void 0,(function*(e,{extra:{api:t},getState:n}){if(e===la(n()))return null;const i=yield t.user.setCurrentTenant(e),o=i.sessionJwt||i.sessionToken;try{return{tenantId:zs(o)}}catch(e){return console.error("Failed to switch tenant:",e),null}})))),da={action:ca,reducer:Tn(ca)({onPending:e=>{e.tenant.previousTenantId=e.tenant.currentTenantId},onFulfilled:(e,t)=>{var n;e.tenant.currentTenantId=null===(n=t.payload)||void 0===n?void 0:n.tenantId,e.tenant.previousTenantId=null},onRejected:e=>{e.tenant.currentTenantId=e.tenant.previousTenantId,e.tenant.previousTenantId=null}},Mn((e=>e.selectTenant)),(({getErrorMsg:e,getSuccessMsg:t})=>({onFulfilled:(e,n)=>{if(t){const i=t(n);i&&e.notifications.push({type:"success",msg:i})}},onRejected:(t,n)=>{if(e){const i=e(n);i&&t.notifications.push({type:"error",msg:i})}}}))({getErrorMsg:e=>{var t,n;const i=(null===(t=e.error)||void 0===t?void 0:t.message)||"";return"Error"===(null===(n=e.error)||void 0===n?void 0:n.name)?i:`${i||"Error"}`}}))},ua={me:{loading:!1,error:null,data:{}},devices:{loading:!1,error:null,data:[]},passkeys:{loading:!1,error:null,data:[]},tenant:{currentTenantId:null,previousTenantId:null},selectTenant:{loading:!1,error:null},notifications:[]},ha={me:"/v1/auth/me",devices:"/v1/mgmt/user/trusteddevices/list",passkeys:"/v1/mgmt/user/passkeys/list",selectTenant:"/v1/auth/tenant/select"},pa=e=>n(void 0,void 0,void 0,(function*(){const t=yield e.text(),n=JSON.parse(t);if(!e.ok){const t=`${n.errorDescription}${n.errorMessage?`: ${n.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(n),e.text=()=>Promise.resolve(t)})),fa=[{tenantName:"Tenant 1",tenantId:"tn1",roleNames:["Role"]},{tenantName:"Tenant 2",tenantId:"tn2",roleNames:["Role"]}],ga=()=>n(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({loginIds:["user@company.com"],externalIds:["user@company.com"],userId:"user-1",name:"Test User",email:"user@company.com",roleNames:["Role"],phone:"+1-202-555-010",verifiedEmail:!0,verifiedPhone:!0,userTenants:fa,status:"enabled",editable:!0,createdTime:(new Date).getTime(),customAttributes:{},familyName:"",givenName:"",middleName:"",picture:void 0,password:!0,SAML:!1,test:!1,TOTP:!1,webauthn:!0})}))})),va=()=>({devices:[{id:"device-id-1",name:"Device 1",deviceType:"desktop",lastLoginDate:17359776e5,isCurrent:!1},{id:"device-id-2",name:"Device 2",deviceType:"mobile",lastLoginDate:17387505e5,isCurrentDevice:!0},{id:"device-id-3",name:"Device 3",deviceType:"tablet",lastLoginDate:17412642e5,isCurrent:!1},{id:"device-id-4",name:"Device 4",deviceType:"unknown",lastLoginDate:17440371e5,isCurrent:!1},{id:"device-id-5",name:"Device 5",deviceType:"desktop",lastLoginDate:174672e7,isCurrent:!1}]}),ma=()=>({passkeys:[{id:"vendor-id-1",displayName:"Device 1",kind:"google",createdTime:1735977600,rpId:"example.com"},{id:"vendor-id-2",displayName:"Device 2",kind:"edge",createdTime:1738750500,rpId:"example.com"},{id:"vendor-id-3",displayName:"Device 3",kind:"apple",createdTime:1741264200,rpId:"example.com"}]}),wa=({httpClient:e,mock:t})=>({me:()=>n(void 0,void 0,void 0,(function*(){if(t)return ga();const n=yield e.get(ha.me);return yield pa(n),n.json()})),setCurrentTenant:t=>n(void 0,void 0,void 0,(function*(){const n=yield e.post(ha.selectTenant,{tenant:t});return yield pa(n),n.json()}))}),ba=({httpClient:e,mock:t})=>({devices:i=>n(void 0,[i],void 0,(function*({userId:n}){if(t)return va();const i=yield e.post(ha.devices,{identifiers:[n]});return yield pa(i),i.json()}))}),ya=({httpClient:e,mock:t})=>({listPasskeys:i=>n(void 0,[i],void 0,(function*({userId:n}){if(t)return ma();const i=yield e.post(ha.passkeys,{loginId:n});return yield pa(i),i.json()}))}),ka=c((e=>{var t,s,a,l;const c=r(E,x,b,j,En)(e);return l=class extends c{constructor(){super(...arguments),t.add(this),s.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get styleId(){return this.getAttribute("style-id")||ge}get api(){return i(this,s,"f")||i(this,t,"m",a).call(this),i(this,s,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),this.observeAttributes(["project-id","base-url"],(()=>{i(this,s,"f")&&i(this,t,"m",a).call(this)}))}))}},s=new WeakMap,t=new WeakSet,a=function(){this.logger.debug("creating an sdk instance"),o(this,s,((e,t,i)=>{const o=qs(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":i,"x-descope-widget-version":"0.13.0"}}));return{user:Object.assign(Object.assign({},wa({httpClient:o.httpClient,mock:t})),{logout:t?()=>n(void 0,void 0,void 0,(function*(){})):o.logout}),device:Object.assign({},ba({httpClient:o.httpClient,mock:t})),passkey:Object.assign({},ya({httpClient:o.httpClient,mock:t}))}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},"true"===this.mock,this.widgetId),"f")},l})),Sa=c((e=>{const t=r(In({name:"widget",initialState:ua,reducers:{clearNotifications:e=>{e.notifications=[]},setCurrentTenantId:(e,{payload:t})=>{e.tenant.currentTenantId=t}},extraReducers:e=>{$n.reducer(e),Ln.reducer(e),Fn.reducer(e),zn.reducer(e),da.reducer(e)},asyncActions:{getMe:$n.action,listDevices:Ln.action,listPasskeys:Fn.action,logout:zn.action,selectTenant:da.action}}),A,b,ka)(e);return class extends t{constructor(...e){super(...e),this.state=ua,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),Ia="widget-flow",Ca=c((e=>{var t,o,s;return s=class extends(r(xn,A,he,Sa,En,b,ke,jn)(e)){constructor(){super(...arguments),t.add(this)}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this);const r=Rn(Ia);r&&(!function(e){if(window.history.replaceState&&Rn(e)){const t=new URL(window.location.href),n=new URLSearchParams(t.search);n.delete(e),t.search=n.toString(),window.history.replaceState({},"",t.toString())}}(Ia),i(this,t,"m",o).call(this,r))}))}},t=new WeakSet,o=function(e){const t=this.createModal({"data-id":"redirect-flow"});t.setContent(this.createFlowTemplate({flowId:e}));new te((()=>{var e;return null===(e=t.ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>{t.close(),this.actions.getMe()})),t.afterClose=()=>{t.remove()},t.open()},s})),Aa=c((e=>{var t,o,a;return a=class extends(r(b,A,z,Z,On("user-profile-widget"),Sa)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return n(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),yield this.actions.getMe(),yield i(this,t,"m",o).call(this),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,o=function(){return n(this,void 0,void 0,(function*(){const e=s(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},a})),xa=c((e=>class extends(r(ke,x)(e)){syncFlowTheme(e){e.theme=this.theme,this.observeAttributes(["theme"],(()=>{e.theme=this.theme}))}})),Oa=c((e=>{var t,s,l,c,d,u,h,p,f;return f=class extends(r(xn,xa,ke,Sa,b,En,Aa,he,jn)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),h.set(this,a((e=>{this.avatar.image=e}))),p.set(this,a((e=>{this.avatar.displayName=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",u).call(this),i(this,t,"m",c).call(this),i(this,h,"f").call(this,Bs(this.state)),i(this,p,"f").call(this,Zs(this.state)),this.subscribe(i(this,h,"f").bind(this),Bs),this.subscribe(i(this,p,"f").bind(this),Zs)}))}},s=new WeakMap,l=new WeakMap,h=new WeakMap,p=new WeakMap,t=new WeakSet,c=function(){this.avatar.flowId&&(o(this,s,this.createModal({"data-id":"update-pic"}),"f"),o(this,l,new te((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,s,"f").afterClose=i(this,t,"m",d).bind(this),i(this,t,"m",d).call(this),this.syncFlowTheme(i(this,l,"f")))},d=function(){i(this,s,"f").setContent(this.createFlowTemplate({flowId:this.avatar.flowId})),i(this,l,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe()}))},u=function(){this.avatar=new Q((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-avatar")}),{logger:this.logger}),this.avatar.onClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()}))},f})),Ea=c((e=>{var t,s,l,c,d,u,h,p,f,g,v,m,w;return w=class extends(r(xn,xa,Sa,b,Aa,En,he,jn)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),c.set(this,void 0),d.set(this,void 0),v.set(this,a((e=>{this.emailUserAttr.value=e}))),m.set(this,a((e=>{this.emailUserAttr.badgeLabel=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",g).call(this),i(this,t,"m",u).call(this),i(this,t,"m",p).call(this),i(this,v,"f").call(this,Js(this.state)),i(this,m,"f").call(this,Ys(this.state)),this.subscribe(i(this,v,"f").bind(this),Js),this.subscribe(i(this,m,"f").bind(this),Ys)}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,v=new WeakMap,m=new WeakMap,t=new WeakSet,u=function(){this.emailUserAttr.editFlowId&&(o(this,s,this.createModal({"data-id":"edit-email"}),"f"),o(this,l,new te((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,s,"f").afterClose=i(this,t,"m",h).bind(this),i(this,t,"m",h).call(this),this.syncFlowTheme(i(this,l,"f")))},h=function(){i(this,s,"f").setContent(this.createFlowTemplate({flowId:this.emailUserAttr.editFlowId})),i(this,l,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe()}))},p=function(){this.emailUserAttr.deleteFlowId&&(o(this,c,this.createModal({"data-id":"delete-email"}),"f"),o(this,d,new te((()=>{var e;return null===(e=i(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,c,"f").afterClose=i(this,t,"m",f).bind(this),i(this,t,"m",f).call(this),this.syncFlowTheme(i(this,d,"f")))},f=function(){i(this,c,"f").setContent(this.createFlowTemplate({flowId:this.emailUserAttr.deleteFlowId})),i(this,d,"f").onSuccess((()=>{i(this,c,"f").close(),this.actions.getMe()}))},g=function(){this.emailUserAttr=new ae((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="email"]')}),{logger:this.logger}),this.emailUserAttr.onEditClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()})),this.emailUserAttr.onDeleteClick((()=>{var e;null===(e=i(this,c,"f"))||void 0===e||e.open()}))},w})),ja=c((e=>{var t,o,s;return s=class extends(r(Sa,b,Aa,he)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",o).call(this)}))}},t=new WeakSet,o=function(){this.logout=new ee((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-button[data-id="logout"]')}),{logger:this.logger}),this.logout.onClick((()=>n(this,void 0,void 0,(function*(){yield this.actions.logout(),this.dispatchEvent(new CustomEvent("logout"))}))))},s})),Ra=c((e=>{var t,s,l,c,d,u,h,p,f,g,v,m;return m=class extends(r(xn,xa,Sa,b,Aa,En,he,jn)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),c.set(this,void 0),d.set(this,void 0),v.set(this,a((e=>{this.nameUserAttr.value=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",g).call(this),i(this,t,"m",u).call(this),i(this,t,"m",p).call(this),i(this,v,"f").call(this,Zs(this.state)),this.subscribe(i(this,v,"f").bind(this),Zs)}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,v=new WeakMap,t=new WeakSet,u=function(){this.nameUserAttr.editFlowId&&(o(this,s,this.createModal({"data-id":"edit-name"}),"f"),o(this,l,new te((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,s,"f").afterClose=i(this,t,"m",h).bind(this),i(this,t,"m",h).call(this),this.syncFlowTheme(i(this,l,"f")))},h=function(){i(this,s,"f").setContent(this.createFlowTemplate({flowId:this.nameUserAttr.editFlowId})),i(this,l,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe()}))},p=function(){this.nameUserAttr.deleteFlowId&&(o(this,c,this.createModal({"data-id":"delete-name"}),"f"),o(this,d,new te((()=>{var e;return null===(e=i(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,c,"f").afterClose=i(this,t,"m",f).bind(this),i(this,t,"m",f).call(this),this.syncFlowTheme(i(this,d,"f")))},f=function(){i(this,c,"f").setContent(this.createFlowTemplate({flowId:this.nameUserAttr.deleteFlowId})),i(this,d,"f").onSuccess((()=>{i(this,c,"f").close(),this.actions.getMe()}))},g=function(){this.nameUserAttr=new ae((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="name"]')}),{logger:this.logger}),this.nameUserAttr.onEditClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()})),this.nameUserAttr.onDeleteClick((()=>{var e;null===(e=i(this,c,"f"))||void 0===e||e.open()}))},m})),Ta=c((e=>{var t,s,l,c,d,u,h,p,f,g,v,m;return m=class extends(r(xn,xa,Sa,b,Aa,En,he,jn)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),c.set(this,void 0),d.set(this,void 0),v.set(this,a((e=>{this.passkeyUserAuthMethod.fulfilled=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",g).call(this),i(this,t,"m",u).call(this),i(this,t,"m",p).call(this),i(this,v,"f").call(this,ea(this.state)),this.subscribe(i(this,v,"f").bind(this),ea)}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,v=new WeakMap,t=new WeakSet,u=function(){this.passkeyUserAuthMethod.flowId&&(o(this,s,this.createModal({"data-id":"add-passkey"}),"f"),o(this,l,new te((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,s,"f").afterClose=i(this,t,"m",h).bind(this),i(this,t,"m",h).call(this),this.syncFlowTheme(i(this,l,"f")))},h=function(){i(this,s,"f").setContent(this.createFlowTemplate({flowId:this.passkeyUserAuthMethod.flowId})),i(this,l,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe()}))},p=function(){this.passkeyUserAuthMethod.fulfilledFlowId&&(o(this,c,this.createModal({"data-id":"remove-passkey"}),"f"),o(this,d,new te((()=>{var e;return null===(e=i(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,c,"f").afterClose=i(this,t,"m",f).bind(this),i(this,t,"m",f).call(this),this.syncFlowTheme(i(this,d,"f")))},f=function(){i(this,c,"f").setContent(this.createFlowTemplate({flowId:this.passkeyUserAuthMethod.fulfilledFlowId})),i(this,d,"f").onSuccess((()=>{i(this,c,"f").close(),this.actions.getMe()}))},g=function(){this.passkeyUserAuthMethod=new le((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="passkey"]')}),{logger:this.logger}),this.passkeyUserAuthMethod.onUnfulfilledButtonClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()})),this.passkeyUserAuthMethod.onFulfilledButtonClick((()=>{var e;null===(e=i(this,c,"f"))||void 0===e||e.open()}))},m})),Ma=c((e=>{var t,s,a,l,c,d;return d=class extends(r(xn,xa,Sa,b,Aa,En,he,jn)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),a.set(this,void 0)}initPasswordAuthMethod(){this.passwordUserAuthMethod=new le((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="password"]')}),{logger:this.logger}),this.passwordUserAuthMethod.onUnfulfilledButtonClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),this.initPasswordAuthMethod(),i(this,t,"m",l).call(this)}))}},s=new WeakMap,a=new WeakMap,t=new WeakSet,l=function(){this.passwordUserAuthMethod.flowId&&(o(this,s,this.createModal({"data-id":"password"}),"f"),o(this,a,new te((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,s,"f").afterClose=i(this,t,"m",c).bind(this),i(this,t,"m",c).call(this),this.syncFlowTheme(i(this,a,"f")))},c=function(){i(this,s,"f").setContent(this.createFlowTemplate({flowId:this.passwordUserAuthMethod.flowId})),i(this,a,"f").onSuccess((()=>{i(this,s,"f").close()}))},d})),Ua=c((e=>{var t,s,l,c,d,u,h,p,f,g,v,m,w;return w=class extends(r(xn,xa,Sa,b,Aa,En,he,jn)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),c.set(this,void 0),d.set(this,void 0),v.set(this,a((e=>{this.phoneUserAttr.value=e}))),m.set(this,a((e=>{this.phoneUserAttr.badgeLabel=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",g).call(this),i(this,t,"m",u).call(this),i(this,t,"m",p).call(this),i(this,v,"f").call(this,Xs(this.state)),i(this,m,"f").call(this,Qs(this.state)),this.subscribe(i(this,v,"f").bind(this),Xs),this.subscribe(i(this,m,"f").bind(this),Qs)}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,v=new WeakMap,m=new WeakMap,t=new WeakSet,u=function(){this.phoneUserAttr.editFlowId&&(o(this,s,this.createModal({"data-id":"edit-phone"}),"f"),o(this,l,new te((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,s,"f").afterClose=i(this,t,"m",h).bind(this),i(this,t,"m",h).call(this),this.syncFlowTheme(i(this,l,"f")))},h=function(){i(this,s,"f").setContent(this.createFlowTemplate({flowId:this.phoneUserAttr.editFlowId})),i(this,l,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe()}))},p=function(){this.phoneUserAttr.deleteFlowId&&(o(this,c,this.createModal({"data-id":"delete-phone"}),"f"),o(this,d,new te((()=>{var e;return null===(e=i(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,c,"f").afterClose=i(this,t,"m",f).bind(this),i(this,t,"m",f).call(this),this.syncFlowTheme(i(this,d,"f")))},f=function(){i(this,c,"f").setContent(this.createFlowTemplate({flowId:this.phoneUserAttr.deleteFlowId})),i(this,d,"f").onSuccess((()=>{i(this,c,"f").close(),this.actions.getMe()}))},g=function(){this.phoneUserAttr=new ae((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="phone"]')}),{logger:this.logger}),this.phoneUserAttr.onEditClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()})),this.phoneUserAttr.onDeleteClick((()=>{var e;null===(e=i(this,c,"f"))||void 0===e||e.open()}))},w})),Wa=c((e=>{var t,s,l,c,d,u,h,p,f,g,v,m;return m=class extends(r(xn,xa,Sa,b,Aa,En,he,jn)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),c.set(this,void 0),d.set(this,void 0),v.set(this,a((e=>{this.totpUserAuthMethod.fulfilled=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",g).call(this),i(this,t,"m",u).call(this),i(this,t,"m",p).call(this),i(this,v,"f").call(this,ta(this.state)),this.subscribe(i(this,v,"f").bind(this),ta)}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,v=new WeakMap,t=new WeakSet,u=function(){this.totpUserAuthMethod.flowId&&(o(this,s,this.createModal({"data-id":"totp"}),"f"),o(this,l,new te((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,s,"f").afterClose=i(this,t,"m",h).bind(this),i(this,t,"m",h).call(this),this.syncFlowTheme(i(this,l,"f")))},h=function(){i(this,s,"f").setContent(this.createFlowTemplate({flowId:this.totpUserAuthMethod.flowId})),i(this,l,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe()}))},p=function(){this.totpUserAuthMethod.fulfilledFlowId&&(o(this,c,this.createModal({"data-id":"remove-totp"}),"f"),o(this,d,new te((()=>{var e;return null===(e=i(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,c,"f").afterClose=i(this,t,"m",f).bind(this),i(this,t,"m",f).call(this),this.syncFlowTheme(i(this,d,"f")))},f=function(){i(this,c,"f").setContent(this.createFlowTemplate({flowId:this.totpUserAuthMethod.fulfilledFlowId})),i(this,d,"f").onSuccess((()=>{i(this,c,"f").close(),this.actions.getMe()}))},g=function(){this.totpUserAuthMethod=new le((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="totp"]')}),{logger:this.logger}),this.totpUserAuthMethod.onUnfulfilledButtonClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()})),this.totpUserAuthMethod.onFulfilledButtonClick((()=>{var e;null===(e=i(this,c,"f"))||void 0===e||e.open()}))},m})),$a=c((e=>{var t,o,s,l,c,d,u,h,p,f,g,v,m;return m=class extends(r(xn,xa,Sa,b,Aa,En,he,jn)(e)){constructor(){super(...arguments),t.add(this),o.set(this,{}),s.set(this,{}),l.set(this,{}),c.set(this,{}),d.set(this,{}),v.set(this,a((e=>{Object.keys(i(this,o,"f")).forEach((t=>{i(this,o,"f")[t].value=(e[t]||"").toString()}))})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",g).call(this),i(this,v,"f").call(this,ia(this.state)),this.subscribe(i(this,v,"f").bind(this),ia)}))}},o=new WeakMap,s=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,v=new WeakMap,t=new WeakSet,u=function(e){var t,n;null===(t=i(this,s,"f")[e])||void 0===t||t.setContent(this.createFlowTemplate({flowId:e})),null===(n=i(this,l,"f")[e])||void 0===n||n.onSuccess((()=>{var t;null===(t=i(this,s,"f")[e])||void 0===t||t.close(),this.actions.getMe()}))},h=function(e){var t,n;null===(t=i(this,c,"f")[e])||void 0===t||t.setContent(this.createFlowTemplate({flowId:e})),null===(n=i(this,d,"f")[e])||void 0===n||n.onSuccess((()=>{var t;null===(t=i(this,c,"f")[e])||void 0===t||t.close(),this.actions.getMe()}))},p=function(e,n,o){const r=e.getAttribute("edit-flow-id");r&&(i(this,s,"f")[r]=this.createModal({"data-id":`edit-${n}`}),i(this,l,"f")[r]=new te((()=>{var e,t;return null===(t=null===(e=i(this,s,"f")[r])||void 0===e?void 0:e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),i(this,s,"f")[r].afterClose=i(this,t,"m",u).bind(this,r),o.onEditClick((()=>{var e,t;null===(t=null===(e=i(this,s,"f"))||void 0===e?void 0:e[r])||void 0===t||t.open()})),i(this,t,"m",u).call(this,r),this.syncFlowTheme(i(this,l,"f")[r]))},f=function(e,n,o){const r=e.getAttribute("delete-flow-id");r&&(i(this,c,"f")[r]=this.createModal({"data-id":`delete-${n}`}),i(this,d,"f")[r]=new te((()=>{var e,t;return null===(t=null===(e=i(this,c,"f")[r])||void 0===e?void 0:e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),i(this,c,"f")[r].afterClose=i(this,t,"m",h).bind(this,r),o.onDeleteClick((()=>{var e,t;null===(t=null===(e=i(this,c,"f"))||void 0===e?void 0:e[r])||void 0===t||t.open()})),i(this,t,"m",h).call(this,r),this.syncFlowTheme(i(this,d,"f")[r]))},g=function(){var e;const n=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelectorAll('descope-user-attribute[data-id^="builtin."]');Array.from(n||[]).forEach((e=>{const n=e.getAttribute("data-id").replace("builtin.",""),r=new ae(e,{logger:this.logger});i(this,o,"f")[n]=r,i(this,t,"m",p).call(this,e,n,r),i(this,t,"m",f).call(this,e,n,r)}))},m}));var Pa;!function(e){e.TEXT="text",e.NUMBER="number",e.BOOLEAN="boolean",e.SINGLE_SELECT="singleSelect",e.ARRAY="array",e.DATE="date"}(Pa||(Pa={}));const _a=c((e=>{var t,o,s,l,c,d,u,h,p,f,g;return o=class extends(r(xn,xa,Sa,b,Aa,En,he,jn)(e)){constructor(){super(...arguments),t.add(this),s.set(this,{}),l.set(this,{}),c.set(this,{}),d.set(this,{}),p.set(this,a((e=>{var n;const r=null===(n=this.shadowRoot)||void 0===n?void 0:n.querySelectorAll('descope-user-attribute[data-id^="customAttributes."]');Array.from(r).forEach((n=>{const r=n.getAttribute("data-id").replace("customAttributes.",""),s=n.getAttribute("data-type")||Pa.TEXT,a=e[r],l=new ae(n,{logger:this.logger});l.value=o.getFormattedValue(s,a),i(this,t,"m",f).call(this,n,r,l),i(this,t,"m",g).call(this,n,r,l)}))})))}static getFormattedValue(e,t){return e===Pa.DATE&&t?new Date(t).toLocaleString():e===Pa.BOOLEAN&&void 0!==t?t?"True":"False":(t||"").toString()}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),i(this,p,"f").call(this,na(this.state)),this.subscribe(i(this,p,"f").bind(this),na)}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,p=new WeakMap,t=new WeakSet,u=function(e){var t,n;null===(t=i(this,s,"f")[e])||void 0===t||t.setContent(this.createFlowTemplate({flowId:e})),null===(n=i(this,l,"f")[e])||void 0===n||n.onSuccess((()=>{var t;null===(t=i(this,s,"f")[e])||void 0===t||t.close(),this.actions.getMe()}))},h=function(e){var t,n;null===(t=i(this,c,"f")[e])||void 0===t||t.setContent(this.createFlowTemplate({flowId:e})),null===(n=i(this,d,"f")[e])||void 0===n||n.onSuccess((()=>{var t;null===(t=i(this,c,"f")[e])||void 0===t||t.close(),this.actions.getMe()}))},f=function(e,n,o){const r=e.getAttribute("edit-flow-id");r&&(i(this,s,"f")[r]=this.createModal({"data-id":`edit-${n}`}),i(this,l,"f")[r]=new te((()=>{var e,t;return null===(t=null===(e=i(this,s,"f")[r])||void 0===e?void 0:e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),i(this,s,"f")[r].afterClose=i(this,t,"m",u).bind(this,r),o.onEditClick((()=>{var e,t;null===(t=null===(e=i(this,s,"f"))||void 0===e?void 0:e[r])||void 0===t||t.open()})),i(this,t,"m",u).call(this,r),this.syncFlowTheme(i(this,l,"f")[r]))},g=function(e,n,o){const r=e.getAttribute("delete-flow-id");r&&(i(this,c,"f")[r]=this.createModal({"data-id":`delete-${n}`}),i(this,d,"f")[r]=new te((()=>{var e,t;return null===(t=null===(e=i(this,c,"f")[r])||void 0===e?void 0:e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),i(this,c,"f")[r].afterClose=i(this,t,"m",h).bind(this,r),o.onDeleteClick((()=>{var e,t;null===(t=null===(e=i(this,c,"f"))||void 0===e?void 0:e[r])||void 0===t||t.open()})),i(this,t,"m",h).call(this,r),this.syncFlowTheme(i(this,d,"f")[r]))},o})),La=c((e=>{var t,s,l,c,d,u,h,p;return p=class extends(r(xn,xa,ke,Sa,b,En,Aa,he,jn)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),this.updateDeviceList=a((e=>{this.deviceList.data=e}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),this.deviceList=new ce((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-trusted-devices")}),{logger:this.logger}),this.deviceList.isExists&&(yield i(this,t,"m",h).call(this),i(this,t,"m",u).call(this,oa(this.state)),i(this,t,"m",c).call(this),this.subscribe(this.updateDeviceList.bind(this),oa))}))}},s=new WeakMap,l=new WeakMap,t=new WeakSet,c=function(){this.deviceList.flowId&&(o(this,s,this.createModal({"data-id":"untrust-device"}),"f"),o(this,l,new te((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,s,"f").afterClose=()=>i(this,t,"m",d).call(this,""),this.syncFlowTheme(i(this,l,"f")))},d=function(e=""){i(this,s,"f").setContent(this.createFlowTemplate({flowId:this.deviceList.flowId,form:{deviceId:e}})),i(this,l,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.listDevices({userId:Vs(this.state)})}))},u=function(e){this.deviceList.onRemoveDeviceClick((({id:e})=>{var n;i(this,t,"m",d).call(this,e),null===(n=i(this,s,"f"))||void 0===n||n.open()})),this.deviceList.data=e},h=function(){return n(this,void 0,void 0,(function*(){yield this.actions.listDevices({userId:Vs(this.state)})}))},p})),Na=c((e=>{var t,s,l,c,d,u,h,p,f,g,v,m;return m=class extends(r(xn,xa,Sa,b,Aa,En,he,jn)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),c.set(this,void 0),d.set(this,void 0),g.set(this,a((e=>{this.actions.listPasskeys({userId:e})}))),this.updatePasskeyList=a((e=>{this.userPasskeys.data=e}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),this.userPasskeys=new ue((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-user-passkeys")}),{logger:this.logger}),this.userPasskeys.isExists&&(i(this,t,"m",v).call(this,ra(this.state)),i(this,t,"m",u).call(this),i(this,t,"m",p).call(this),this.subscribe(i(this,g,"f").bind(this),Vs),this.subscribe(this.updatePasskeyList.bind(this),ra))}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,g=new WeakMap,t=new WeakSet,u=function(){this.userPasskeys.addPasskeyFlowId&&(o(this,s,this.createModal({"data-id":"add-user-passkey"}),"f"),o(this,l,new te((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,s,"f").afterClose=i(this,t,"m",h).bind(this),i(this,t,"m",h).call(this),this.syncFlowTheme(i(this,l,"f")))},h=function(){i(this,s,"f").setContent(this.createFlowTemplate({flowId:this.userPasskeys.addPasskeyFlowId})),i(this,l,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe(),this.actions.listPasskeys({userId:Vs(this.state)})}))},p=function(){this.userPasskeys.removePasskeyFlowId&&(o(this,c,this.createModal({"data-id":"remove-user-passkey"}),"f"),o(this,d,new te((()=>{var e;return null===(e=i(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(i(this,d,"f")))},f=function({externalId:e,credentialId:t}){i(this,c,"f").setContent(this.createFlowTemplate({flowId:this.userPasskeys.removePasskeyFlowId,form:{externalId:e,credentialId:t}})),i(this,d,"f").onSuccess((()=>{i(this,c,"f").close(),this.actions.getMe(),this.actions.listPasskeys({userId:Vs(this.state)})}))},v=function(e){this.updatePasskeyList(e),this.userPasskeys.onAddPasskeyClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()})),this.userPasskeys.onRemovePasskeyClick((({id:e})=>{var n;const o=Vs(this.state);i(this,t,"m",f).call(this,{externalId:o,credentialId:e}),null===(n=i(this,c,"f"))||void 0===n||n.open()}))},m}));const Da={success:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Checkmark">\n<path id="Shape" d="M10.0485 15.6396C9.5799 15.171 8.8201 15.171 8.35147 15.6396C7.88284 16.1082 7.88284 16.868 8.35147 17.3367L12.7072 21.6924C13.1759 22.1611 13.9357 22.1611 14.4043 21.6924L24.7152 11.3815C25.1838 10.9129 25.1838 10.1531 24.7152 9.68448C24.2466 9.21585 23.4868 9.21585 23.0181 9.68448L13.5558 19.1469L10.0485 15.6396Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,error:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Vector" d="M15.9998 26.6558C10.1118 26.6558 5.34375 21.8878 5.34375 15.9998C5.34375 10.1118 10.1118 5.34375 15.9998 5.34375C21.8878 5.34375 26.6558 10.1118 26.6558 15.9998C26.6558 21.8878 21.8878 26.6558 15.9998 26.6558ZM15.9998 24.4798C20.6718 24.4798 24.4798 20.7038 24.4798 15.9998C24.4798 11.3278 20.7038 7.51975 15.9998 7.51975C11.3278 7.51975 7.51975 11.2958 7.51975 15.9998C7.51975 20.6718 11.2958 24.4798 15.9998 24.4798ZM15.3278 9.34375H16.6718C17.0558 9.34375 17.3438 9.63175 17.3118 9.98375L16.9598 16.9278C16.9598 17.1838 16.7678 17.3438 16.5438 17.3438H15.4558C15.2318 17.3438 15.0398 17.1518 15.0398 16.9278L14.6878 9.98375C14.6878 9.63175 14.9758 9.34375 15.3278 9.34375ZM15.4558 19.4558H16.5438C16.9278 19.4558 17.2158 19.7438 17.1838 20.1278V21.1838C17.1838 21.5678 16.8958 21.8558 16.5438 21.8558H15.4558C15.0718 21.8558 14.7838 21.5678 14.7838 21.1838V20.1278C14.7838 19.7438 15.0718 19.4558 15.4558 19.4558Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild},Fa=c((e=>{var t,o,s,l,c;return c=class extends(r(b,Sa,fe,A)(e)){constructor(){super(...arguments),t.add(this),l.set(this,a((e=>{e.length&&(e.forEach((({type:e,msg:n})=>{const r=i(this,t,"m",s).call(this,e);r.setContent(i(this,t,"m",o).call(this,{type:e,msg:n})),r.show()})),setTimeout((()=>this.actions.clearNotifications())))})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.subscribe(i(this,l,"f").bind(this),sa)}))}},l=new WeakMap,t=new WeakSet,o=function({type:e,msg:t}){const n=Da[e],i=Object.assign((new DOMParser).parseFromString('<svg width="2em" height="2em" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Shape" d="M10.6712 12L7.27521 8.60406C6.90826 8.23711 6.90826 7.64216 7.27521 7.27521C7.64216 6.90826 8.23711 6.90826 8.60406 7.27521L12 10.6712L15.3959 7.27521C15.7629 6.90826 16.3578 6.90826 16.7248 7.27521C17.0917 7.64216 17.0917 8.23711 16.7248 8.60406L13.3288 12L16.7248 15.3959C17.0917 15.7629 17.0917 16.3578 16.7248 16.7248C16.3578 17.0917 15.7629 17.0917 15.3959 16.7248L12 13.3288L8.60406 16.7248C8.23711 17.0917 7.64216 17.0917 7.27521 16.7248C6.90826 16.3578 6.90826 15.7629 7.27521 15.3959L10.6712 12Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,{slot:"close"});return`${(null==n?void 0:n.outerHTML)||""}${t}${i.outerHTML}`},s=function(e){return this.createNotification({mode:e,duration:"error"===e?0:3e3,position:"bottom-start",size:"sm"})},c})),qa=c((e=>{var t,s,a,l,c,d,u,h,p,f,g;return g=class extends(r(Sa,b,Aa)(e)){constructor(){super(...arguments),t.add(this),s.set(this,null),l.set(this,(e=>n(this,void 0,void 0,(function*(){const t=e.target.value;yield this.actions.selectTenant(t)})))),c.set(this,(e=>{const n=la(e);this.tenantSelector.value!==n&&i(this,t,"m",p).call(this,n);const{loading:r,error:a}=e.selectTenant,l=null!==e.tenant.previousTenantId,c=n!==i(this,s,"f");!n||r||a||l||!c||(o(this,s,n,"f"),i(this,t,"m",d).call(this))}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),this.actions.setCurrentTenantId((()=>{const e=Xr();return zs(e)})()),i(this,t,"m",a).call(this),i(this,t,"m",f).call(this),i(this,t,"m",h).call(this,aa(this.state)),this.subscribe(i(this,c,"f").bind(this))}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,t=new WeakSet,a=function(){this.tenantSelector=new de((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-combo-box[name="tenantSelector"]')}),{logger:this.logger}),this.tenantSelector.onInput(i(this,l,"f"))},d=function(){const e=la(this.state);this.dispatchEvent(new CustomEvent("tenant-changed",{bubbles:!0,composed:!0,detail:{tenantId:e}})),this.tenantSelector.shouldReload&&i(this,t,"m",u).call(this)},u=function(){setTimeout((()=>window.location.reload()),this.tenantSelector.refreshTimeout)},h=function(e){return n(this,void 0,void 0,(function*(){const t=e.map((e=>({label:e.tenantName||e.tenantId,value:e.tenantId})));yield this.tenantSelector.setData(t)}))},p=function(e){e&&(this.tenantSelector.value=e)},f=function(){this.tenantSelector.setAllowCustomValue(!0),setTimeout((()=>{i(this,t,"m",p).call(this,la(this.state)),this.tenantSelector.setAllowCustomValue(!1)}))},g})),za=c((e=>{var t,s,a,l,c,d,u,h,p,f,g;return g=class extends(r(xn,xa,Sa,he,b,Aa,jn)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),a.set(this,void 0),l.set(this,[]),c.set(this,null)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",h).call(this),i(this,t,"m",u).call(this),i(this,l,"f").forEach((e=>e.enable()))}))}},s=new WeakMap,a=new WeakMap,l=new WeakMap,c=new WeakMap,t=new WeakSet,d=function(e){const n=new ne(e,{logger:this.logger});n.onClick((()=>{i(this,t,"m",f).call(this,n.flowId,Vs(this.state))})),i(this,l,"f").push(n)},u=function(){var e;const n=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelectorAll("[data-generic-flow-button-id]");Array.from(n).forEach((e=>{i(this,t,"m",d).call(this,e)}))},h=function(){o(this,s,this.createModal({"data-id":"generic-flow-modal"}),"f"),i(this,s,"f").afterClose=()=>{var e;null===(e=i(this,c,"f"))||void 0===e||e.call(this),o(this,c,null,"f")},o(this,a,new te((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(i(this,a,"f"))},p=function(){var e;i(this,s,"f").open(),null===(e=i(this,c,"f"))||void 0===e||e.call(this)},f=function(e,n){i(this,s,"f").setContent(this.createFlowTemplate({flowId:e,client:{userId:n}}));o(this,c,i(this,a,"f").onPageUpdated((()=>i(this,t,"m",p).call(this))),"f"),i(this,a,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe()}))},g})),Ha=c((e=>class extends(r($,ke,Ca,_a,Ea,Oa,Ra,Ua,Ta,Ma,Wa,$a,ja,La,Na,Fa,qa,za)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),Va=r((e=>class extends(Ha(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this);(customElements.get("descope-wc")||(yield Promise.resolve().then((function(){return eu})).then((e=>e.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.13.0"}}}))}}))(HTMLElement),Ba="undefined"!=typeof localStorage,Ja="J151000",Ka="E103205",Za=Ba&&localStorage.getItem("base.content.url")||"",Xa="base.ui.components.url";Ba&&localStorage.getItem(Xa),Ba&&localStorage.getItem(Xa);const Ga="descope-login-flow",Ya="code",Qa="redirect_mode",el="err",tl="data-exclude-field",nl="data-exclude-next",il="dls_last_auth",ol="state_id",rl="saml_idp_state_id",sl="wsfed_idp_state_id",al="saml_idp_username",ll="descope_idp_initiated",cl="sso_app_id",dl="custom_app_id",ul="third_party_app_id",hl="third_party_app_state_id",pl="oidc_login_hint",fl="oidc_prompt",gl="oidc_resource",vl="oidc_error_redirect_uri",ml="application_scopes",wl="data-type",bl="redirect",yl="poll",kl="webauthnCreate",Sl="webauthnGet",Il="nativeBridge",Cl="loadForm",Al="submit",xl="polling",Ol=["descope-multi-select-combo-box","descope-text-area"],El="dls_last_auth_in_flight",jl=["cssVars","componentsConfig","inputs","errorText","errorType","clientScripts"];var Rl;!function(e){e.backward="backward",e.forward="forward"}(Rl||(Rl={}));const Tl=["descope-enriched-text"];function Ml(e){return new URLSearchParams(window.location.search).get(e)}function Ul(e){if(window.history.replaceState&&Ml(e)){const t=new URL(window.location.href),n=new URLSearchParams(t.search);n.delete(e),t.search=n.toString(),window.history.replaceState({},"",t.toString())}}function Wl(e,t){if(!t)return;const n=+e,i=+t;return Number.isNaN(n)||Number.isNaN(i)?void 0:n>i?Rl.forward:n<i?Rl.backward:void 0}const $l=e=>{let[t="",n=""]=(Ml(Ga)||"").split("_");const i=(e=>{var t;return(null===(t=/(.*)\|#\|.*/.exec(e))||void 0===t?void 0:t[1])||""})(t);return(!e||i&&i!==e)&&(t="",n=""),{executionId:t,stepId:n,executionFlowId:i}};function Pl(){Ul(Ga)}const _l=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),Ll=(e,t)=>{const{executionId:n,stepId:i,executionFlowId:o}=$l(e);if(o&&e!==o)return t.debug("Flow id does not match the execution flow id, skipping url params handling"),{ssoQueryParams:{}};(n||i)&&Pl();const r=Ml("t")||void 0;r&&Ul("t");const s=Ml(Ya)||void 0;s&&Ul(Ya);const a="popup"===Ml(Qa);a&&Ul(Qa);const l=Ml(el)||void 0;l&&Ul(el);const{redirectAuthCodeChallenge:c,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthInitiator:h}={redirectAuthCodeChallenge:Ml("ra-challenge"),redirectAuthCallbackUrl:Ml("ra-callback"),redirectAuthBackupCallbackUri:Ml("ra-backup-callback"),redirectAuthInitiator:Ml("ra-initiator")},p=Ml(ol);p&&Ul(ol);const f=Ml(rl);f&&Ul(rl);const g=Ml(sl);g&&Ul(sl);const v=Ml(al);f&&Ul(al);const m=Ml(ll);m&&Ul(ll);const w=Ml(cl);w&&Ul(cl);const b=Ml(dl);b&&Ul(dl);const y=Ml(ul);y&&Ul(ul);const k=Ml(hl);k&&Ul(hl);const S=Ml(ml);S&&Ul(ml);const I=Ml(pl);I&&Ul(pl);const C=Ml(fl);C&&Ul(fl);const A=Ml(vl);A&&Ul(vl);const x=Ml(gl);return x&&Ul(gl),{executionId:n,stepId:i,token:r,code:s,isPopup:a,exchangeError:l,redirectAuthCodeChallenge:c,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthInitiator:h,ssoQueryParams:{oidcIdpStateId:p,samlIdpStateId:f,wsfedIdpStateId:g,samlIdpUsername:v,descopeIdpInitiated:"true"===m,ssoAppId:w,customAppId:b,oidcLoginHint:I,oidcPrompt:C,oidcErrorRedirectUri:A,oidcResource:x,thirdPartyAppId:y,thirdPartyAppStateId:k,applicationScopes:S}}},Nl=e=>{let t,n;return Object.assign(((...i)=>{return t&&(r=i,(o=t).length===r.length&&o.every(((e,t)=>e===r[t])))||(t=i,n=e(...i)),n;var o,r}),{reset:()=>{t=void 0,n=void 0}})},Dl=(e,t,n)=>{if(!0===t||"skipFirstScreen"===t&&!n){const t=e.querySelector('*[name]:not([auto-focus="false"]):not([aria-hidden="true"])');setTimeout((()=>{null==t||t.focus()}))}};function Fl(e,t,n){return new Promise(((i,o)=>{let r=!1;const s=setTimeout((()=>{r=!0,void 0!==n?i(n):o(new Error(`Promise timed out after ${e} ms`))}),e);t.then((e=>{r||(clearTimeout(s),i(e))})).catch((e=>{r||(clearTimeout(s),o(e))}))}))}const ql=(e,{oidcIdpStateId:t,samlIdpStateId:n,wsfedIdpStateId:i,samlIdpUsername:o,ssoAppId:r,customAppId:s,oidcLoginHint:a,oidcPrompt:l,oidcErrorRedirectUri:c,oidcResource:d,thirdPartyAppId:u,thirdPartyAppStateId:h,applicationScopes:p})=>!(!e||t||n||i||o||r||s||a||l||c||d||u||h||p),zl=e=>null==e?void 0:e.submit(),Hl=(e,t)=>{const n=t.find((t=>e[t]));return n?e[n]:null},Vl=(e,t=100)=>{let n;return function(...i){n||e.apply(this,i),clearTimeout(n),n=setTimeout((()=>{n=null}),t)}},Bl=e=>{const t=Object.assign({},e);return e.inboundAppApproveScopes&&(t.thirdPartyAppApproveScopes=e.inboundAppApproveScopes),t};function Jl(e,t){return`sdkScriptsResults.${t?`${e}_${t}`:e}`}var Kl,Zl,Xl,Gl;function Yl(e,t){const n=Object.getOwnPropertyNames(e),i=Object.getOwnPropertyNames(t);if(n.length!==i.length)return!1;for(let i=0;i<n.length;i+=1){const o=n[i],r=e[o],s=t[o];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!Yl(r,s))return!1}else if(r!==s)return!1}return!0}let Ql=class{constructor(e={},{forceUpdate:t=!1}={}){Kl.set(this,void 0),Zl.set(this,{}),Xl.set(this,0),Gl.set(this,!0),this.update=e=>{const t="function"==typeof e?e(i(this,Kl,"f")):e,n=Object.assign(Object.assign({},i(this,Kl,"f")),t),r=i(this,Kl,"f");o(this,Kl,n,"f"),Object.freeze(i(this,Kl,"f")),setTimeout((()=>{Object.values(i(this,Zl,"f")).forEach((({cb:e,selector:t,forceUpdate:o})=>{const s=t(r),a=t(n);(i(this,Gl,"f")||o||(function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(a)?!Yl(s,a):s!==a))&&e(a,s,((e,t)=>n=>e[n]!==t[n])(a,s))}))}),0)},o(this,Kl,e,"f"),o(this,Gl,t,"f")}get current(){return Object.assign({},i(this,Kl,"f"))}set forceUpdate(e){o(this,Gl,e,"f")}subscribe(e,t=e=>e,{forceUpdate:n=!1}={}){return o(this,Xl,i(this,Xl,"f")+1,"f"),i(this,Zl,"f")[i(this,Xl,"f")]={cb:e,selector:t,forceUpdate:n},i(this,Xl,"f").toString()}unsubscribe(e){const t=!!i(this,Zl,"f")[e];return t&&delete i(this,Zl,"f")[e],t}unsubscribeAll(){return o(this,Zl,{},"f"),!0}};Kl=new WeakMap,Zl=new WeakMap,Xl=new WeakMap,Gl=new WeakMap;const ec=["*","#","/","(",")","[","]","_","<",">","`"],tc=e=>"string"!=typeof e?e:e.replace((e=>{const t=ec.map((t=>`${e}${t}`)).join("|");return new RegExp(`(${t})`,"g")})("\\"),"\\$1"),nc=["disabled"],ic=(e,t)=>{Object.entries(t||{}).forEach((([t,n])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${tl}])`)).forEach((e=>{e.value=n}))}))},oc=(e,t)=>t.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),e),rc=(e,t,n)=>e.replace(/{{(.+?)}}/g,((e,i)=>n?tc(oc(t,i)):oc(t,i))),sc=(e,t,n)=>{e.querySelectorAll(`[${wl}="${t}"]`).forEach((e=>{e.setAttribute("href",n)}))},ac=(e,t,n)=>{var i,o;const r=null===(i=customElements.get(t))||void 0===i?void 0:i.cssVarList.url;n&&r&&(null===(o=null==e?void 0:e.style)||void 0===o||o.setProperty(r,`url(data:image/jpg;base64,${n})`))},lc=(e,n,i,o)=>{var r,s;sc(e,"totp-link",null===(r=null==n?void 0:n.totp)||void 0===r?void 0:r.provisionUrl),sc(e,"notp-link",null===(s=null==n?void 0:n.notp)||void 0===s?void 0:s.redirectUrl),((e,t)=>{e.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((e=>{const n=(e=>Tl.includes(e))(e.localName);e.textContent=rc(e.textContent,t,n);const i=e.getAttribute("href");i&&e.setAttribute("href",rc(i,t))}))})(e,n),((e,n,i)=>{if(!n)return;const{componentsDynamicAttrs:o}=n,r=t(n,["componentsDynamicAttrs"]),s=Object.keys(r).reduce(((e,t)=>(e[`[name=${t}]`]=r[t],e)),{});o&&Object.keys(o).forEach((e=>{const t=o[e];if(t){const{attributes:n}=t;n&&Object.keys(n).length&&(s[e]=n)}})),Object.keys(s).forEach((t=>{e.querySelectorAll(t).forEach((e=>{const n=s[t];Object.keys(n).forEach((t=>{let o=n[t];if("string"!=typeof o)try{o=JSON.stringify(o)}catch(e){i.error(`Could not stringify value "${o}" for "${t}"`,e.message),o=""}e.setAttribute(t,o)}))}))}))})(e,null==n?void 0:n.componentsConfig,o),((e,t)=>{e.querySelectorAll("[data-has-dynamic-attr-values]").forEach((e=>{Array.from(e.attributes).forEach((e=>{e.value=rc(e.value,t)}))}))})(e,n),((e,t)=>{Object.entries(t).forEach((([t,n])=>{e.querySelectorAll(`[name="${t}"]`).forEach((e=>{Object.entries(n).forEach((([t,n])=>{nc.includes(t)&&e.setAttribute(t,n)}))}))}))})(e,i)},cc=Nl((()=>n(void 0,void 0,void 0,(function*(){var e,t;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const n=Promise.all([null===(e=window.PublicKeyCredential)||void 0===e?void 0:e.isConditionalMediationAvailable(),null===(t=window.PublicKeyCredential)||void 0===t?void 0:t.isUserVerifyingPlatformAuthenticatorAvailable()]).then((e=>e.every((e=>!!e)))),i=(()=>{var e;const t=null===(e=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===e?void 0:e.brands,n=null==t?void 0:t.find((({brand:e,version:t})=>"Chromium"===e&&parseFloat(t)));return n?n.version:0})()>=108;return yield Fl(100,n,i)}catch(e){return console.error("Conditional login check failed",e),!1}}))));let dc;const uc=(e,t)=>{dc?dc.setItem(e,t):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.setItem(e,t)},hc=e=>dc?dc.getItem(e):void 0!==(null===window||void 0===window?void 0:window.localStorage)?window.localStorage.getItem(e):null,pc="dls_ab_testing_id",fc={"lastAuth.loginId":{"not-empty":e=>{var t;return!!e.loginId||!!(null===(t=e.lastAuth)||void 0===t?void 0:t.loginId)},empty:e=>{var t;return!e.loginId&&!(null===(t=e.lastAuth)||void 0===t?void 0:t.loginId)}},idpInitiated:{"is-true":e=>!!e.code,"is-false":e=>!e.code},externalToken:{"is-true":e=>!!e.token,"is-false":e=>!e.token},abTestingKey:{"greater-than":(e,t)=>(e.abTestingKey||0)>t,"less-than":(e,t)=>(e.abTestingKey||0)<t,"greater-than-or-equal":(e,t)=>(e.abTestingKey||0)>=t,"less-than-or-equal":(e,t)=>(e.abTestingKey||0)<=t,"in-range":(e,t)=>{const[n,i]=t?t.split(",").map(Number):[void 0,void 0];return(e.abTestingKey||0)>=(null!=n?n:0)&&(e.abTestingKey||0)<=(null!=i?i:0)},"not-in-range":(e,t)=>{const[n,i]=t?t.split(",").map(Number):[void 0,void 0];return!(void 0!==n&&void 0!==i&&!Number.isNaN(n)&&!Number.isNaN(i))||(e.abTestingKey||0)<n||(e.abTestingKey||0)>i},"devised-by":(e,t)=>{const n=Number(t);return!Number.isNaN(n)&&(e.abTestingKey||0)%n==0}}};function gc(e,t){const n={};try{Object.assign(n,JSON.parse(hc(il)))}catch(e){null==t||t.warn("[Descope] Failed to read last auth from storage",String(e))}return n.loginId||e?n:{}}function vc(e,t){(null==e?void 0:e.authMethod)&&(t&&!e.loginId||uc(il,JSON.stringify(e)))}function mc(){try{return JSON.parse(hc(El)||"{}")}catch(e){return{}}}function wc(e){try{(e=>{dc?dc.removeItem(e):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.removeItem(e)})(El)}catch(t){null==e||e.warn("[Descope] Failed to clear in-flight last auth storage",String(t))}}const bc=(e,t="")=>Object.keys(e).reduce(((n,i)=>{var o;if(Array.isArray(e[i]))return Object.assign(Object.assign({},n),{[i]:{value:e[i].map((e=>"object"==typeof e&&null!==e?bc(e):e))}});if("object"==typeof e[i]&&null!==e[i]&&!(null===(o=e[i])||void 0===o?void 0:o.value))return Object.assign(Object.assign({},n),bc(e[i],`${t+i}.`));const r="object"==typeof e[i]?e[i]:{value:e[i]},s=Object.assign(Object.assign({},n),{[t+i]:r,[`form.${t}${i}`]:r});return"displayName"===i?Object.assign(Object.assign({},s),{[`${t}fullName`]:r,[`form.${t}fullName`]:r}):s}),[]),yc=c((e=>{var t,n,o,r;return r=class extends e{constructor(){super(...arguments),t.add(this)}connectedCallback(){var e;i(this,t,"m",n).call(this)&&i(this,t,"m",o).call(this),null===(e=super.connectedCallback)||void 0===e||e.call(this)}},t=new WeakSet,n=function(){return!this.shadowRoot.host.closest("form")&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)},o=function(){const e=this.shadowRoot.host,t=document.createElement("form");t.style.width="100%",t.style.height="100%",e.parentElement.appendChild(t),t.appendChild(e)},r})),kc=["input","change"];function Sc(e){if("number"==typeof e&&Number.isFinite(e))return{value:e,ok:!0};if("boolean"==typeof e)return{value:e?1:0,ok:!0};if("string"==typeof e){if(""===e.trim())return{value:0,ok:!1};const t=Number(e);if(Number.isFinite(t))return{value:t,ok:!0}}return{value:0,ok:!1}}function Ic(e){return null==e?"":"string"==typeof e?e:"boolean"==typeof e?e?"true":"false":"number"==typeof e?Number.isFinite(e)?String(e):"":String(e)}function Cc(e){if("boolean"==typeof e)return{value:e,ok:!0};if("string"==typeof e){if("true"===e)return{value:!0,ok:!0};if("false"===e)return{value:!1,ok:!0}}return"number"==typeof e?{value:0!==e,ok:!0}:{value:!1,ok:!1}}function Ac(e){return Array.isArray(e)?e:"string"==typeof e?e.split(","):null}function xc(e){return null==e||("string"==typeof e?""===e:Array.isArray(e)?0===e.length:"object"==typeof e&&0===Object.keys(e).length)}const Oc=new Map,Ec={equal:(e,t)=>e===t||Ic(e)===Ic(t),"not-equal":(e,t)=>e!==t&&Ic(e)!==Ic(t),contains:(e,t)=>Array.isArray(e)?e.includes(t):"string"==typeof e&&e.includes(Ic(t)),"doesnt-contains":(e,t)=>Array.isArray(e)?!e.includes(t):"string"==typeof e&&!e.includes(Ic(t)),"greater-than":(e,t)=>{const n=Sc(e),i=Sc(t);return n.ok&&i.ok&&n.value>i.value},"greater-than-or-equal":(e,t)=>{const n=Sc(e),i=Sc(t);return n.ok&&i.ok&&n.value>=i.value},"less-than":(e,t)=>{const n=Sc(e),i=Sc(t);return n.ok&&i.ok&&n.value<i.value},"less-than-or-equal":(e,t)=>{const n=Sc(e),i=Sc(t);return n.ok&&i.ok&&n.value<=i.value},empty:e=>xc(e),"not-empty":e=>!xc(e),"is-true":e=>{const t=Cc(e);return t.ok&&t.value},"is-false":e=>{const t=Cc(e);return t.ok&&!t.value},in:(e,t)=>{const n=Ac(t);return null!==n&&n.includes(e)},"not-in":(e,t)=>{const n=Ac(t);return null!==n&&!n.includes(e)},matches:(e,t)=>{if("string"!=typeof e)return!1;const n=function(e){var t;if(Oc.has(e))return null!==(t=Oc.get(e))&&void 0!==t?t:null;let n;try{n=new RegExp(e)}catch(e){n=null}return Oc.set(e,n),n}(Ic(t));return null!==n&&n.test(e)}};function jc(e,t){var n;if(e)return"form"===e.kind&&e.form?t[e.form]:"list"===e.kind?(null!==(n=e.items)&&void 0!==n?n:[]).map((e=>jc(e,t))):e.value}function Rc(e,t){const n=Ec[e.operator];return!!n&&n(jc(e.target,t),jc(e.predicate,t))}function Tc(e,t){const n={};return(null!=e?e:[]).forEach((e=>{var i;(function(e,t){var n;return(null!==(n=e.rules)&&void 0!==n?n:[]).some((e=>function(e,t){var n;const i=null!==(n=e.atomicConditions)&&void 0!==n?n:[];return!!i.length&&(e.logicalOr?i.some((e=>Rc(e,t))):i.every((e=>Rc(e,t))))}(e,t)))})(e,t)&&(null!==(i=e.componentIds)&&void 0!==i?i:[]).forEach((t=>{n[t]=e.action}))})),n}const Mc=["hide","disable","read-only"];const Uc=/(["\\])/g;function Wc(e){return"undefined"!=typeof CSS&&"function"==typeof CSS.escape?CSS.escape(e):e.replace(Uc,"\\$1")}function $c(e,t){return Array.from(e.querySelectorAll(`[id="${Wc(t)}"]`))}function Pc(e,t,n){return Object.keys(t).forEach((i=>{const o=t[i];n[i]!==o&&$c(e,i).forEach((e=>function(e,t){switch(t){case"hide":e.classList.remove("hidden");break;case"disable":e.removeAttribute("disabled");break;case"read-only":e.removeAttribute("readonly")}}(e,o)))})),Object.keys(n).forEach((i=>{const o=n[i],r=t[i];o!==r&&$c(e,i).forEach((e=>function(e,t){switch(t){case"hide":e.classList.add("hidden");break;case"disable":e.setAttribute("disabled","true");break;case"read-only":e.setAttribute("readonly","true")}}(e,o)))})),Object.assign({},n)}const _c="component-conditions:";function Lc(e){return e instanceof HTMLInputElement?"checkbox"===e.type?e.checked:e.value:"checked"in e?e.checked:"value"in e?e.value:void 0}function Nc(e,t){const n=Object.keys(e),i=Object.keys(t);return n.length===i.length&&n.every((n=>e[n]===t[n]))}function Dc(){return{conditions:[],touchedIds:new Set,snapshot:{},applied:{},serverBaseline:{},debounceTimer:null,paused:!1,unsubscribePauseListener:null,inputHandler:()=>{},root:null}}function Fc(e,t,n){const i={};return n.forEach((n=>{e[n]?i[n]=e[n]:t[n]&&(i[n]=t[n])})),i}const qc=c((e=>{var t,n,s,a,l,c;const d=r(b)(e);return c=class extends d{constructor(){super(...arguments),t.add(this),n.set(this,Dc())}applyComponentsState(e,t){t&&(Object.entries(t).forEach((([e,t])=>{Mc.includes(t)||this.logger.error(`Unknown component action "${t}" for component with id "${e}"`,`Valid actions are ${Mc.map((e=>`"${e}"`)).join(", ")}`)})),Pc(e,{},t))}initRealtimeConditions(e,r){var a,c,d,u;i(this,t,"m",l).call(this);const h=null!==(a=null==r?void 0:r.realtimeComponentsConditions)&&void 0!==a?a:[];if(!h.length)return void this.logger.debug(`${_c} no real-time rules to apply on this screen`);this.logger.info(`${_c} found ${h.length} real-time rule(s) for this screen`);const p={};Object.entries(null!==(c=null==r?void 0:r.form)&&void 0!==c?c:{}).forEach((([e,t])=>{p[`form.${e}`]=t})),function(e){const t=new Set,n=e=>{var i;e&&("form"===e.kind&&e.form?t.add(e.form):"list"===e.kind&&(null!==(i=e.items)&&void 0!==i?i:[]).forEach(n))};return(null!=e?e:[]).forEach((e=>{var t;return(null!==(t=e.rules)&&void 0!==t?t:[]).forEach((e=>{var t;return(null!==(t=e.atomicConditions)&&void 0!==t?t:[]).forEach((e=>{n(e.target),n(e.predicate)}))}))})),t}(h).forEach((t=>{const n=function(e,t){const n=t.startsWith("form.")?t.slice(5):t;return e.querySelector(`[name="${Wc(t)}"]`)||e.querySelector(`[name="${Wc(n)}"]`)}(e,t);if(!n)return;const i=Lc(n);void 0!==i&&(p[t]=i)}));const f=function(e){const t=new Set;return(null!=e?e:[]).forEach((e=>{var n;(null!==(n=e.componentIds)&&void 0!==n?n:[]).forEach((e=>t.add(e)))})),t}(h),g={},v={};Object.entries(null!==(d=null==r?void 0:r.componentsState)&&void 0!==d?d:{}).forEach((([e,t])=>{f.has(e)&&(v[e]=t)})),Object.entries(null!==(u=null==r?void 0:r.serverOnlyComponentsState)&&void 0!==u?u:{}).forEach((([e,t])=>{f.has(e)&&(g[e]=t)}));const m={conditions:h,touchedIds:f,snapshot:p,applied:v,serverBaseline:g,debounceTimer:null,paused:!1,unsubscribePauseListener:null,inputHandler:()=>{},root:e},w=Fc(Tc(h,p),g,f);Nc(v,w)||(m.applied=Pc(e,v,w)),m.inputHandler=e=>i(this,t,"m",s).call(this,e),kc.forEach((t=>{e.addEventListener(t,m.inputHandler,!0)})),this.logger.debug(`${_c} listening for "${kc.join('" and "')}" events on form fields; ${Object.keys(v).length} component(s) start hidden / disabled / read-only by these rules`);const b=this.nextRequestStatus;if(null==b?void 0:b.subscribe){const e=({isLoading:e})=>{m.paused=e,e&&m.debounceTimer&&(clearTimeout(m.debounceTimer),m.debounceTimer=null)},t=b.subscribe(e);m.unsubscribePauseListener=()=>{var e;null!=t&&(null===(e=b.unsubscribe)||void 0===e||e.call(b,t))}}o(this,n,m,"f")}disconnectedCallback(){var e;null===(e=super.disconnectedCallback)||void 0===e||e.call(this),i(this,t,"m",l).call(this)}},n=new WeakMap,t=new WeakSet,s=function(e){var o,r;const s=i(this,n,"f");if(!s.root||s.paused)return;const l=e.target;if(!l)return;if(null===(o=l.hasAttribute)||void 0===o?void 0:o.call(l,tl))return;const c=null===(r=l.getAttribute)||void 0===r?void 0:r.call(l,"name");if(!c)return;const d=function(e){return e.startsWith("form.")?e:`form.${e}`}(c);s.snapshot[d]=Lc(l),s.debounceTimer&&clearTimeout(s.debounceTimer),s.debounceTimer=setTimeout((()=>{s.debounceTimer=null,i(this,t,"m",a).call(this)}),50)},a=function(){const e=i(this,n,"f");if(!e.root)return;let t;try{t=Fc(Tc(e.conditions,e.snapshot),e.serverBaseline,e.touchedIds)}catch(e){return void this.logger.error(`${_c} failed to evaluate real-time rules — keeping the previous state`,null==e?void 0:e.message)}const o=e.applied;Nc(o,t)||(this.logger.debug(`${_c} form changed — updating components: was ${JSON.stringify(o)}, now ${JSON.stringify(t)}`),e.applied=Pc(e.root,o,t))},l=function(){const e=i(this,n,"f");e.debounceTimer&&clearTimeout(e.debounceTimer),e.unsubscribePauseListener&&e.unsubscribePauseListener(),e.root&&(Object.keys(e.applied).length>0&&e.root.isConnected&&Pc(e.root,e.applied,{}),kc.forEach((t=>{e.root.removeEventListener(t,e.inputHandler,!0)}))),o(this,n,Dc(),"f")},c}));var zc,Hc,Vc,Bc,Jc,Kc,Zc,Xc,Gc,Yc,Qc,ed,td,nd,id,od,rd,sd,ad,ld,cd,dd;const ud=r(ke,M,yc,qc,B)(HTMLElement);class hd extends ud{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","validate-on-blur","style-id"]}constructor(e){super(),zc.add(this),Vc.set(this,!1),Bc.set(this,void 0),this.flowStatus="initial",this.loggerWrapper={error:(e,t="")=>{this.logger.error(e,t,new Error),i(this,zc,"m",dd).call(this,e,t)},warn:(e,t="")=>{this.logger.warn(e,t)},info:(e,t="",n={})=>{this.logger.info(e,t,n)},debug:(e,t="")=>{this.logger.debug(e,t)}},Jc.set(this,new Ql),Kc.set(this,new Ql),Zc.set(this,{}),this.getComponentsContext=()=>i(this,Zc,"f"),this.nextRequestStatus=new Ql({isLoading:!1}),Xc.set(this,void 0),Gc.set(this,{popstate:i(this,zc,"m",nd).bind(this),componentsContext:i(this,zc,"m",ad).bind(this)}),Yc.set(this,void 0),this.getConfig=()=>n(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),o(this,Yc,e,"f"),i(this,zc,"m",ed).call(this)}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(e){return{}}}get redirectUrl(){return this.getAttribute("redirect-url")||void 0}get debug(){return"true"===this.getAttribute("debug")}get locale(){return this.getAttribute("locale")||void 0}get autoFocus(){var e;const t=null!==(e=this.getAttribute("auto-focus"))&&void 0!==e?e:"true";return"skipFirstScreen"===t?t:"true"===t}get validateOnBlur(){return"true"===this.getAttribute("validate-on-blur")}get storeLastAuthenticatedUser(){var e;return"true"===(null!==(e=this.getAttribute("store-last-authenticated-user"))&&void 0!==e?e:"true")}get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}get keepLastAuthenticatedUserAfterLogout(){return"true"===this.getAttribute("keep-last-authenticated-user-after-logout")}get storagePrefix(){return this.getAttribute("storage-prefix")||""}get preview(){return!!this.getAttribute("preview")}get formConfig(){return(e=>{try{return bc(JSON.parse(e))}catch(e){return{}}})(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return((e,t)=>Object.fromEntries(Object.entries(e).map((([e,n])=>[e,n[t]]))))(this.formConfig,"value")}get outboundAppId(){return this.getAttribute("outbound-app-id")}get outboundAppScopes(){try{return JSON.parse(this.getAttribute("outbound-app-scopes"))||null}catch(e){return null}}get popupOrigin(){return this.getAttribute("popup-origin")}get customStorage(){return i(this,Bc,"f")}set customStorage(e){if(e&&"function"!=typeof e.getItem)throw new Error("Custom storage must have a getItem method");if(e&&"function"!=typeof e.setItem)throw new Error("Custom storage must have a setItem method");if(e&&"function"!=typeof e.removeItem)throw new Error("Custom storage must have a removeItem method");o(this,Bc,e,"f"),(e=>{dc=e})(e)}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"executionContext"in e?e.executionContext:void 0}))}getProjectConfig(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"projectConfig"in e?e.projectConfig:void 0}))}getFlowConfig(){return n(this,void 0,void 0,(function*(){var e,t;const n=yield this.getProjectConfig(),i=(null===(e=null==n?void 0:n.flows)||void 0===e?void 0:e[this.flowId])||{};return null!==(t=i.version)&&void 0!==t||(i.version=0),i}))}getTargetLocales(){return n(this,void 0,void 0,(function*(){const e=yield this.getFlowConfig();return((null==e?void 0:e.targetLocales)||[]).map((e=>e.toLowerCase()))}))}handleKeyPress(){this.logger.debug("Enable key press handler"),this.rootElement.onkeydown=e=>{var t,n,i;const o=!!(null===(t=this.shadowRoot.activeElement)||void 0===t?void 0:t.getAttribute("href")),r=Ol.includes(null!==(i=null===(n=this.shadowRoot.activeElement)||void 0===n?void 0:n.localName)&&void 0!==i?i:"");if("Enter"!==e.key||o||r)return;e.preventDefault();const s=this.rootElement.querySelectorAll("descope-button");if(1===s.length&&"false"!==s[0].getAttribute("auto-submit"))return void s[0].click();const a=Array.from(s).filter((e=>"true"===e.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const l=Array.from(s).filter((e=>"button"===e.getAttribute("data-type")));if(1===l.length)"false"!==l[0].getAttribute("auto-submit")&&l[0].click();else if(0===l.length){const e=Array.from(s).filter((e=>"sso"===e.getAttribute("data-type")));1===e.length&&"false"!==e[0].getAttribute("auto-submit")&&e[0].click()}}}disableKeyPressHandler(){this.logger.debug("Disable key press handler"),this.rootElement.onkeydown=null}getComponentsVersion(){return n(this,void 0,void 0,(function*(){var e;const t=yield this.getConfig();return("projectConfig"in t?null===(e=t.projectConfig)||void 0===e?void 0:e.componentsVersion:{})||(this.logger.error("Did not get components version, using latest version"),"latest")}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;if(this.flowStatus="loading",["ready","error","success"].forEach((e=>this.addEventListener(e,(()=>{this.flowStatus=e})))),yield null===(t=e.init)||void 0===t?void 0:t.call(this),i(this,Kc,"f").subscribe(i(this,zc,"m",cd).bind(this)),i(this,Kc,"f").update({isDebug:this.debug}),i(this,zc,"m",td).call(this),yield i(this,zc,"m",rd).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");const n=yield this.getConfig();if("isMissingConfig"in n&&n.isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");const{executionId:r,stepId:s,token:a,code:l,isPopup:c,exchangeError:d,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthCodeChallenge:p,redirectAuthInitiator:f,ssoQueryParams:g}=Ll(this.flowId,this.loggerWrapper);window.addEventListener("popstate",i(this,Gc,"f").popstate),window.addEventListener("components-context",i(this,Gc,"f").componentsContext),i(this,Jc,"f").subscribe(i(this,zc,"m",od).bind(this)),i(this,Jc,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenantId,redirectUrl:this.redirectUrl,locale:this.locale,stepId:s,executionId:r,token:a,code:l,isPopup:c,exchangeError:d,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthCodeChallenge:p,redirectAuthInitiator:f},g)),o(this,Vc,!0,"f")}))}disconnectedCallback(){var e;i(this,Jc,"f").unsubscribeAll(),i(this,Kc,"f").unsubscribeAll(),i(this,zc,"m",ld).call(this),window.removeEventListener("popstate",i(this,Gc,"f").popstate),window.removeEventListener("components-context",i(this,Gc,"f").componentsContext),null===(e=super.disconnectedCallback)||void 0===e||e.call(this)}attributeChangedCallback(e,t,n){if(this.shadowRoot.isConnected&&i(this,Vc,"f")&&t!==n&&Hc.observedAttributes.includes(e)){i(this,zc,"m",td).call(this);const o=null===t;i(this,Jc,"f").update((({stepId:t,executionId:i})=>{let r=t,s=i;return o||(s=null,r=null,Pl()),{[_l(e)]:n,stepId:r,executionId:s}})),i(this,Kc,"f").update({isDebug:this.debug})}}}var pd,fd,gd,vd,md,wd,bd,yd,kd,Sd,Id,Cd,Ad,xd,Od,Ed,jd,Rd,Td,Md,Ud,Wd,$d,Pd,_d,Ld,Nd,Dd,Fd,qd,zd,Hd,Vd,Bd,Jd,Kd,Zd,Xd,Gd,Yd;Hc=hd,Vc=new WeakMap,Bc=new WeakMap,Jc=new WeakMap,Kc=new WeakMap,Zc=new WeakMap,Xc=new WeakMap,Gc=new WeakMap,Yc=new WeakMap,zc=new WeakSet,Qc=function(){this.injectStyle("\n :host {\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n display: flex;\n flex-direction: column;\n\t\t}\n\n #content-root {\n all: initial;\n transition: opacity 200ms ease-in-out;\n }\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1!important;\n\t\t}\n\n .hidden {\n display: none;\n }\n ")},ed=function(){i(this,zc,"m",Qc).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},td=function(){const e=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","style-id","outbound-app-id","outbound-app-scopes","theme-override"];Hc.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[_l(t)])throw Error(`${t} cannot be empty`)}))},nd=function(){const{stepId:e,executionId:t}=$l(this.flowId);i(this,Jc,"f").update({stepId:e,executionId:t})},id=function(e,t){qs&&"function"==typeof qs||this.logger.error("SDK was not loaded properly",qs,JSON.stringify(qs));const o=Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},Hc.sdkConfigOverrides),{projectId:e,baseUrl:t});i(this,Bc,"f")&&(o.customStorage=i(this,Bc,"f")),this.sdk=qs(o),["start","next"].forEach((e=>{const t=function(e,t,i){return(...o)=>n(this,void 0,void 0,(function*(){let n;const r=i+1;for(let s=0;s<r;s++)try{return yield e(...o)}catch(e){n=e,s<i&&(yield new Promise((e=>{setTimeout(e,t*Math.pow(2,s+1))})))}throw n}))}(this.sdk.flow[e],1e3,3);this.sdk.flow[e]=(...i)=>n(this,void 0,void 0,(function*(){try{return yield t(...i)}catch(t){return this.logger.error(`Error in sdk flow ${e} function`,t),{error:{errorCode:Ja,errorDescription:t.toString()}}}}))}))},od=function(e,t,o){return n(this,void 0,void 0,(function*(){const{projectId:t,baseUrl:n}=e;if(o("projectId")||o("baseUrl")){if(!t)return;i(this,zc,"m",id).call(this,t,n)}i(this,Yc,"f").call(this,e)}))},rd=function(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield i(this,zc,"m",sd).call(this))}))},sd=function(){return n(this,void 0,void 0,(function*(){const e=function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:i}){const o=new URL(Za||i||"https://static.descope.com/pages");return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,n,t),o.toString()}({projectId:this.projectId,filename:"config.json",assetsFolder:"v2-alpha",baseUrl:this.baseStaticUrl});try{return yield function(e,t){return n(this,void 0,void 0,(function*(){const n=yield fetch(e,{cache:"default"});if(!n.ok)throw Error(`Error fetching URL ${e} [${n.status}]`);return{body:yield n[t](),headers:Object.fromEntries(n.headers.entries())}}))}(e,"json"),!0}catch(e){return!1}}))},ad=function(e){o(this,Zc,Object.assign(Object.assign({},i(this,Zc,"f")),e.detail),"f")},ld=function(){var e;null===(e=i(this,Xc,"f"))||void 0===e||e.remove(),o(this,Xc,null,"f")},cd=function(e){return n(this,arguments,void 0,(function*({isDebug:e}){e?(o(this,Xc,document.createElement("descope-debugger"),"f"),Object.assign(i(this,Xc,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return Mu})),document.body.appendChild(i(this,Xc,"f"))):i(this,zc,"m",ld).call(this)}))},dd=function(e,t){var n;e&&this.debug&&(null===(n=i(this,Xc,"f"))||void 0===n||n.updateData({title:e,description:t}))},hd.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.69.4"}};class Qd extends hd{static set sdkConfigOverrides(e){hd.sdkConfigOverrides=e}static get sdkConfigOverrides(){return hd.sdkConfigOverrides}constructor(){const e=new Ql({deferredRedirect:!1,deferredPolling:!1});super(e.update.bind(e)),pd.add(this),this.stepState=new Ql({}),fd.set(this,void 0),gd.set(this,null),vd.set(this,null),md.set(this,{visibilitychange:i(this,pd,"m",wd).bind(this)}),this.bridgeVersion=2,this.nativeCallbacks={},xd.set(this,!1),this.handleRedirect=e=>{window.location.assign(e)},Ed.set(this,(e=>{const t=()=>{this.contentRootElement.classList.toggle("hidden",e),this.slotElement.classList.toggle("hidden",!e),e&&(this.contentRootElement.innerHTML="")};e&&this.contentRootElement.hasChildNodes()?i(this,pd,"m",jd).call(this,t):t()})),Rd.set(this,((e,t,r,s,a=!1)=>{const l=[Ka,"E103202"];if(this.flowState.current.action===yl){if(i(this,Md,"f").call(this)&&document.hidden)return this.logger.debug("polling - Deferring polling until in foreground"),void this.flowState.update({deferredPolling:!0});this.logger.debug("polling - Scheduling polling request");const c=Date.now(),d=a?500:2e3;o(this,fd,setTimeout((()=>n(this,void 0,void 0,(function*(){var n,o;this.logger.debug("polling - Calling next");const u=this.sdk.flow.next(e,t,xl,r,s,{}),h=document.hidden&&!a&&Date.now()-c>d+500;let p;h&&this.logger.debug("polling - The polling seems to be throttled");try{const e=h?1e3:6e3;p=yield Fl(e,u)}catch(n){return this.logger.warn(`polling - The ${h?"throttled fetch":"fetch"} call timed out or was aborted`),void i(this,Rd,"f").call(this,e,t,r,s,h)}if((null===(n=null==p?void 0:p.error)||void 0===n?void 0:n.errorCode)===Ja)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void i(this,Rd,"f").call(this,e,t,r,s);this.logger.debug("polling - Got a response"),(null==p?void 0:p.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(p.error,null,4)),(null===(o=null==p?void 0:p.error)||void 0===o?void 0:o.errorCode)&&l.includes(p.error.errorCode)?this.logger.debug("polling - Stopping polling due to error"):i(this,Rd,"f").call(this,e,t,r,s),i(this,Ud,"f").call(this,p)}))),d),"f")}})),Td.set(this,(()=>{clearTimeout(i(this,fd,"f")),o(this,fd,null,"f")})),Md.set(this,(()=>!!window.descopeBridge||/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))),Ud.set(this,(e=>{var t,n,r,s,a,l,c,d,u,h,p,f,g;if(!(null==e?void 0:e.ok)){const o=null===(t=null==e?void 0:e.response)||void 0===t?void 0:t.url,c=`${null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.status} - ${null===(r=null==e?void 0:e.response)||void 0===r?void 0:r.statusText}`;i(this,pd,"m",Gd).call(this,"error",(null==e?void 0:e.error)||{errorCode:"J151001",errorDescription:c,errorMessage:o}),this.loggerWrapper.error((null===(s=null==e?void 0:e.error)||void 0===s?void 0:s.errorDescription)||o,(null===(a=null==e?void 0:e.error)||void 0===a?void 0:a.errorMessage)||c);const d=null===(l=null==e?void 0:e.error)||void 0===l?void 0:l.errorCode;return void("E102004"!==d&&d!==Ka||!this.isRestartOnError||i(this,pd,"m",Ad).call(this))}null===(d=null===(c=e.data)||void 0===c?void 0:c.runnerLogs)||void 0===d||d.forEach((e=>{const{level:t,title:n,log:i}=e;t&&this.loggerWrapper[t]?this.loggerWrapper[t](n,i):this.loggerWrapper.info(n,i)}));const v=null===(p=null===(h=null===(u=e.data)||void 0===u?void 0:u.screen)||void 0===h?void 0:h.state)||void 0===p?void 0:p.errorText;(null===(f=e.data)||void 0===f?void 0:f.error)?this.loggerWrapper.error(`[${e.data.error.code}]: ${e.data.error.description}`,`${v?`${v} - `:""}${e.data.error.message}`):v&&this.loggerWrapper.error(v);const{status:m,authInfo:w,lastAuth:b,action:y,openInNewTabUrl:k}=e.data;if(y!==yl&&i(this,Td,"f").call(this),"completed"===m){this.storeLastAuthenticatedUser&&vc(Object.assign(Object.assign({},b),{lastUsedPerScreen:mc()})),wc(this.loggerWrapper);const t=Object.assign({},w);return e.data.output&&Object.keys(e.data.output).length>0&&(t.flowOutput=e.data.output),void i(this,pd,"m",Gd).call(this,"success",t)}this.storeLastAuthenticatedUser&&vc(b,!0),k&&window.open(k,"_blank");const{executionId:S,stepId:I,stepName:C,screen:A,redirect:x,webauthn:O,error:E,samlIdpResponse:j,wsFedIdpResponse:R,nativeResponse:T}=e.data,M=Date.now();y!==yl?(this.loggerWrapper.info(`Step "${C||`#${I}`}" is ${m}`,"",{screen:A,status:m,stepId:I,stepName:C,action:y,error:E}),(null===(g=A.state)||void 0===g?void 0:g.clientScripts)&&o(this,vd,this.loadSdkScripts(A.state.clientScripts),"f"),this.flowState.update({stepId:I,stepName:C,executionId:S,action:y,redirectTo:null==x?void 0:x.url,redirectIsPopup:null==x?void 0:x.isPopup,screenId:null==A?void 0:A.id,screenState:null==A?void 0:A.state,webauthnTransactionId:null==O?void 0:O.transactionId,webauthnOptions:null==O?void 0:O.options,samlIdpResponseUrl:null==j?void 0:j.url,samlIdpResponseSamlResponse:null==j?void 0:j.samlResponse,samlIdpResponseRelayState:null==j?void 0:j.relayState,wsFedIdpResponseUrl:null==R?void 0:R.url,wsFedIdpResponseWresult:null==R?void 0:R.wresult,wsFedIdpResponseWctx:null==R?void 0:R.wctx,nativeResponseType:null==T?void 0:T.type,nativePayload:null==T?void 0:T.payload,reqTimestamp:M})):this.flowState.update({action:y,reqTimestamp:M})})),Wd.set(this,Nl((()=>n(this,void 0,void 0,(function*(){var e;try{const t=yield this.sdk.webauthn.signIn.start("",window.location.origin);return t.ok||this.loggerWrapper.warn("Webauthn start failed",null===(e=null==t?void 0:t.error)||void 0===e?void 0:e.errorMessage),t.data}catch(e){this.loggerWrapper.warn("Webauthn start failed",e.message)}}))))),Dd.set(this,null),Vd.set(this,Vl(((e,t,o)=>n(this,void 0,void 0,(function*(){var n;if("true"===e.getAttribute("formnovalidate")||i(this,pd,"m",Ld).call(this)){const r=null==e?void 0:e.getAttribute("id");i(this,pd,"m",Kd).call(this,e,r,o),i(this,pd,"m",Fd).call(this,e);const s=yield i(this,pd,"m",Nd).call(this),a=(e=>Array.from((null==e?void 0:e.attributes)||[]).reduce(((e,t)=>{var n;const i=null===(n=new RegExp("^data-descope-(\\S+)$").exec(t.name))||void 0===n?void 0:n[1];return i?Object.assign(e,{[i]:t.value}):e}),{}))(e);this.nextRequestStatus.update({isLoading:!0});const l=Object.assign(Object.assign(Object.assign({},a),s),{origin:(null===(n=this.nativeOptions)||void 0===n?void 0:n.origin)||window.location.origin});yield t(r,l),this.nextRequestStatus.update({isLoading:!1}),i(this,pd,"m",qd).call(this,s)}}))))),this.flowState=e}nativeResume(e,t){var n,o,r,s,a,l;const c=JSON.parse(t);if("oauthWeb"===e||"sso"===e){let e,{exchangeCode:t}=c;if(!t){const i=new URL(c.url);t=null===(n=i.searchParams)||void 0===n?void 0:n.get(Ya),e=(null===(o=i.searchParams)||void 0===o?void 0:o.get(el))||void 0}null===(s=(r=this.nativeCallbacks).complete)||void 0===s||s.call(r,{exchangeCode:t,exchangeError:e,idpInitiated:!0})}else if("magicLink"===e){const e=new URL(c.url),t=e.searchParams.get("t"),n=e.searchParams.get(Ga).split("_").pop();i(this,Td,"f").call(this),this.flowState.update({token:t,stepId:n,action:void 0})}else if("beforeScreen"===e){const{screenResolve:e}=this.nativeCallbacks;this.nativeCallbacks.screenResolve=null;const{override:t}=c;t||(this.nativeCallbacks.screenNext=null),null==e||e(t)}else if("resumeScreen"===e){const{interactionId:e,form:t}=c,{screenNext:n}=this.nativeCallbacks;this.nativeCallbacks.screenNext=null,null==n||n(e,t)}else null===(l=(a=this.nativeCallbacks).complete)||void 0===l||l.call(a,c)}loadSdkScriptsModules(){const e=this.shadowRoot.querySelectorAll("div[data-script-id]");return Array.from(e).map((e=>e.moduleRes)).filter((e=>!!e))}loadSdkScripts(e){if(!(null==e?void 0:e.length))return null;const t=(e,t)=>n=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[Jl(e.id,e.resultKey)]:n},bubbles:!0,composed:!0})),t(e.id)};this.loggerWrapper.debug(`Preparing to load scripts: ${e.map((e=>e.id)).join(", ")}`);const i=Promise.all(null==e?void 0:e.map((e=>n(this,void 0,void 0,(function*(){var n,i,o;const r=this.shadowRoot.querySelector(`[data-script-id="${e.id}"]`);if(r){this.loggerWrapper.debug("Script already loaded",e.id);const{moduleRes:t}=r;return null===(n=null==t?void 0:t.start)||void 0===n||n.call(t),t}(null===(i=globalThis.descope)||void 0===i?void 0:i[e.id])||(yield this.injectNpmLib("@descope/flow-scripts","1.0.17",`dist/${e.id}.js`));const s=null===(o=globalThis.descope)||void 0===o?void 0:o[e.id];return new Promise(((n,i)=>{try{const i=s(e.initArgs,{baseUrl:this.baseUrl,ref:this},t(e,n),this.loggerWrapper);if(i){const t=document.createElement("div");t.setAttribute("data-script-id",e.id),t.moduleRes=i,this.shadowRoot.appendChild(t);const n=this.nextRequestStatus.subscribe((()=>{var o;this.loggerWrapper.debug("Stopping script",e.id),(null===(o=i.stop)||void 0===o?void 0:o.call(i))&&(this.nextRequestStatus.unsubscribe(n),this.loggerWrapper.debug("Removing script",e.id),this.shadowRoot.removeChild(t))}))}}catch(e){i(e)}}))}))))),o=new Promise((e=>{setTimeout((()=>{this.loggerWrapper.warn("SDK scripts loading timeout"),e(!0)}),5e3)}));return Promise.race([i,o])}get isDismissScreenErrorOnInput(){return"true"===this.getAttribute("dismiss-screen-error-on-input")}init(){if(!window.descopeBridge)return this._init();this.lazyInit=this._init}_init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t,n;this.shadowRoot.isConnected&&(null===(t=this.flowState)||void 0===t||t.subscribe(this.onFlowChange.bind(this)),i(this,pd,"m",Id).call(this),window.addEventListener("visibilitychange",i(this,md,"f").visibilitychange)),yield null===(n=e.init)||void 0===n?void 0:n.call(this)}))}disconnectedCallback(){var e;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),i(this,Td,"f").call(this),null===(e=i(this,gd,"f"))||void 0===e||e.abort(),o(this,gd,null,"f"),window.removeEventListener("visibilitychange",i(this,md,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return n(this,void 0,void 0,(function*(){let n;const i=v(e),o=yield this.getTargetLocales();return o.includes(i.locale)?n=`${t}-${i.locale}.html`:o.includes(i.fallback)&&(n=`${t}-${i.fallback}.html`),n}))}getPageContent(e,t){return n(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield this.fetchStaticResource(t,"text");return e}catch(n){this.loggerWrapper.error(`Failed to fetch flow page from ${t}. Fallback to url ${e}`,n)}try{const{body:t}=yield this.fetchStaticResource(e,"text");return t}catch(e){this.loggerWrapper.error("Failed to fetch flow page",e.message)}return null}))}onFlowChange(e,r,s){return n(this,void 0,void 0,(function*(){var a,l;const{projectId:c,flowId:d,tenant:u,stepId:h,executionId:p,action:f,screenId:g,screenState:m,redirectTo:w,redirectIsPopup:b,redirectUrl:y,token:k,code:S,isPopup:I,exchangeError:C,webauthnTransactionId:A,webauthnOptions:x,redirectAuthCodeChallenge:O,redirectAuthCallbackUrl:E,redirectAuthBackupCallbackUri:j,redirectAuthInitiator:R,locale:T,samlIdpResponseUrl:M,samlIdpResponseSamlResponse:U,samlIdpResponseRelayState:W,wsFedIdpResponseUrl:$,wsFedIdpResponseWresult:P,wsFedIdpResponseWctx:_,nativeResponseType:L,nativePayload:N,reqTimestamp:D}=e,F=t(e,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","redirectIsPopup","redirectUrl","token","code","isPopup","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState","wsFedIdpResponseUrl","wsFedIdpResponseWresult","wsFedIdpResponseWctx","nativeResponseType","nativePayload","reqTimestamp"]);let q,z,H;const V=(()=>{const e=hc(pc);if(!e){const e=Math.floor(100*Math.random()+1);return uc(pc,e.toString()),e}return Number(e)})(),{outboundAppId:B}=this,{outboundAppScopes:J}=this,K=this.sdk.getLastUserLoginId(),Z=yield this.getFlowConfig(),X=yield this.getProjectConfig(),G=Object.entries(X.flows||{}).reduce(((e,[t,n])=>(e[t]=n.version,e)),{}),Y=E&&O?{callbackUrl:E,codeChallenge:O,backupCallbackUri:j}:void 0,Q=this.nativeOptions?{platform:this.nativeOptions.platform,bridgeVersion:this.nativeOptions.bridgeVersion,oauthProvider:this.nativeOptions.oauthProvider,oauthRedirect:this.nativeOptions.oauthRedirect,magicLinkRedirect:this.nativeOptions.magicLinkRedirect,ssoRedirect:this.nativeOptions.ssoRedirect,externalAuthRedirect:this.nativeOptions.externalAuthRedirect}:void 0;let ee={};if(!p){wc(this.loggerWrapper);const e=[...Z.clientScripts||[],...Z.sdkScripts||[]];if(Z.conditions){let t=[];({startScreenId:q,conditionInteractionId:H,startScreenName:z,clientScripts:t,componentsConfig:ee}=((e,t)=>{const n=null==t?void 0:t.find((({key:t,operator:n,predicate:i})=>{var o;if("ELSE"===t)return!0;const r=null===(o=fc[t])||void 0===o?void 0:o[n];return!!(null==r?void 0:r(e,i))}));return n?{startScreenId:n.met.screenId,startScreenName:n.met.screenName,conditionInteractionId:n.met.interactionId,clientScripts:n.met.clientScripts,componentsConfig:n.met.componentsConfig}:{}})({loginId:K,code:S,token:k,abTestingKey:V,lastAuth:gc(K,this.loggerWrapper)},Z.conditions)),e.push(...t||[])}else Z.condition?({startScreenId:q,conditionInteractionId:H}=((e,t)=>{var n;const i=null===(n=fc[null==e?void 0:e.key])||void 0===n?void 0:n[e.operator];if(!i)return{};const o=i(t,e.predicate)?e.met:e.unmet;return{startScreenId:null==o?void 0:o.screenId,startScreenName:null==o?void 0:o.screenName,conditionInteractionId:null==o?void 0:o.interactionId}})(Z.condition,{loginId:K,code:S,token:k,abTestingKey:V,lastAuth:gc(K,this.loggerWrapper)})):(z=Z.startScreenName,q=Z.startScreenId);if(o(this,vd,this.loadSdkScripts(e),"f"),Z.fingerprintEnabled&&Z.fingerprintKey?yield rs(Z.fingerprintKey,this.baseUrl):_r(is),!ql(q,F)){const e=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:Y},F),{client:this.client}),y&&{redirectUrl:y}),{lastAuth:gc(K,this.loggerWrapper),abTestingKey:V,locale:v(T).locale,nativeOptions:Q,outboundAppId:B,outboundAppScopes:J}),H,"",X.componentsVersion,G,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),S?{exchangeCode:S,idpInitiated:!0}:{}),F.descopeIdpInitiated&&{idpInitiated:!0}),k?{token:k}:{}),F.oidcLoginHint?{externalId:F.oidcLoginHint}:{}));return i(this,Ud,"f").call(this,e),void("completed"!==(null===(a=null==e?void 0:e.data)||void 0===a?void 0:a.status)&&this.flowState.update({code:void 0,token:void 0}))}}if(this.loggerWrapper.debug("Before popup postmessage send",JSON.stringify({isPopup:I,code:S,exchangeError:C,isCodeChanged:s("code"),isExchangeErrorChanged:s("exchangeError")})),I&&(s("code")&&S||s("exchangeError")&&C))return void i(this,pd,"m",Yd).call(this,p,S,C);if(p&&(s("token")&&k||s("code")&&S||s("exchangeError")&&C)){const e=yield this.sdk.flow.next(p,h,Al,Z.version,X.componentsVersion,{token:k,exchangeCode:S,exchangeError:C});return i(this,Ud,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(f===Cl&&M&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>s(e)))){if(!U)return void this.loggerWrapper.error("Did not get saml idp params data to load");((e,t,n,i)=>{const o=document.createElement("form");o.method="POST",o.action=e,o.innerHTML=`\n <input type="hidden" role="saml-response" name="SAMLResponse" value="${t}" />\n <input type="hidden" role="saml-relay-state" name="RelayState" value="${n}" />\n <input style="display: none;" id="SAMLSubmitButton" type="submit" value="Continue" />\n `,document.body.appendChild(o),i(o)})(M,U,W||"",zl)}if(f===Cl&&$&&["wsFedIdpResponseUrl","wsFedIdpResponseWresult","wsFedIdpResponseWctx"].some((e=>s(e)))){if(!P)return void this.loggerWrapper.error("Did not get wsfed idp params data to load");((e,t,n,i)=>{const o=document.createElement("form");o.method="POST",o.action=e;const r=(e,t)=>{const n=document.createElement("input");return n.type="hidden",n.name=e,n.value=t,n};o.appendChild(r("wa","wsignin1.0")),o.appendChild(r("wresult",t)),o.appendChild(r("wctx",n));const s=document.createElement("input");s.type="submit",s.id="WSFedSubmitButton",s.value="Continue",s.style.display="none",o.appendChild(s),document.body.appendChild(o),i(o)})($,P,_||"",zl)}if(f===bl&&(s("redirectTo")||s("deferredRedirect"))){if(!w)return void this.loggerWrapper.error("Did not get redirect url");if("no-op"===w)return;if("android"===R&&document.hidden)return void this.flowState.update({deferredRedirect:!0});if(this.loggerWrapper.debug(`Redirect is popup ${b}`),b){this.loggerWrapper.debug("Opening redirect in popup");const e=((e,t,n,i)=>{const o=void 0!==window.screenLeft?window.screenLeft:window.screen.left,r=void 0!==window.screenTop?window.screenTop:window.screen.top,s=((window.innerWidth||document.documentElement.clientWidth||window.screen.width)-n)/2+o,a=((window.innerHeight||document.documentElement.clientHeight||window.screen.height)-i)/2+r,l=function(){const e=navigator.userAgent||"",t=/\b(iPhone)\b/.test(e),n=/Safari/.test(e)&&!/CriOS|FxiOS|OPiOS|EdgiOS|Chrome|Chromium/.test(e);return t&&n}()?"about:blank":"",c=window.open(l,t,`width=${n},height=${i},top=${a},left=${s},scrollbars=yes,resizable=yes`);return c.location.href=e,c.focus(),c})(w,"?",598,700),t=this.shouldUsePopupPostMessage();t&&(e.name=`descope-wc|${window.location.origin}`),this.loggerWrapper.debug("Popup communication method: "+(t?"postMessage":"BroadcastChannel"));const n=e=>{this.loggerWrapper.debug("Received popup message",JSON.stringify(e.data));const n=t?this.popupOrigin:window.location.origin;if(e.origin!==n)return void this.loggerWrapper.debug(`Ignoring message from unexpected origin. received: "${e.origin}", expected: "${n}"`);const{action:i,data:o}=e.data||{};"code"===i&&this.flowState.update({code:o.code,exchangeError:o.exchangeError})};let o;this.loggerWrapper.debug("Starting popup closed detection");const r=setInterval((()=>{e.closed&&(this.loggerWrapper.debug("Popup closed, dispatching popupclosed event"),clearInterval(r),i(this,pd,"m",Gd).call(this,"popupclosed",{}),this.loggerWrapper.debug("Cleaning up popup listeners"),null==o||o())}),1e3);if(t)window.addEventListener("message",n),o=()=>{this.loggerWrapper.debug("Cleaning up popup postMessage listener"),window.removeEventListener("message",n)};else{this.loggerWrapper.debug("Creating broadcast channel");const e=new BroadcastChannel(p);e.onmessage=n,o=()=>{this.loggerWrapper.debug("Closing channel"),e.close()}}}else this.handleRedirect(w),this.flowState.update({redirectTo:"no-op"}),i(this,pd,"m",Gd).call(this,"popupclosed",{});return}if(f===kl||f===Sl){if(!A||!x)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,t,n,r;null===(l=i(this,gd,"f"))||void 0===l||l.abort(),o(this,gd,null,"f");try{e=f===kl?yield this.sdk.webauthn.helpers.create(x):yield this.sdk.webauthn.helpers.get(x)}catch(e){"InvalidStateError"===e.name?this.loggerWrapper.warn("WebAuthn operation failed",e.message):"NotAllowedError"!==e.name&&this.loggerWrapper.error(e.message),t=e.name,n=e.reason,r=e.message}const s=yield this.sdk.flow.next(p,h,Al,Z.version,X.componentsVersion,{transactionId:A,response:e,failure:t,failureReason:n,failureMessage:r});i(this,Ud,"f").call(this,s)}if(f===Il)return this.nativeCallbacks.complete=e=>n(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,h,Al,Z.version,X.componentsVersion,e);i(this,Ud,"f").call(this,t)})),i(this,pd,"m",kd).call(this,L,N),void setTimeout((()=>{this.dispatchEvent(new Event("popupclosed"))}),500);if((s("action")||s("deferredPolling"))&&i(this,Rd,"f").call(this,p,h,Z.version,X.componentsVersion),!g&&!q)return void this.loggerWrapper.warn("No screen was found to show");const te=q||g,ne=yield this.getHtmlFilenameWithLocale(T,te),{oidcLoginHint:ie,oidcPrompt:oe,oidcErrorRedirectUri:re,oidcResource:se,samlIdpUsername:ae}=F,le={direction:Wl(h,r.stepId),screenState:Object.assign(Object.assign({},m),{form:Object.assign(Object.assign({},this.formConfigValues),null==m?void 0:m.form),lastAuth:{loginId:K,name:this.sdk.getLastUserDisplayName()||K},componentsConfig:Object.assign(Object.assign(Object.assign({},Z.componentsConfig),ee),null==m?void 0:m.componentsConfig)}),htmlFilename:`${te}.html`,htmlLocaleFilename:ne,screenId:te,stepName:e.stepName||z,samlIdpUsername:ae,oidcLoginHint:ie,oidcPrompt:oe,oidcErrorRedirectUri:re,oidcResource:se,action:f,locale:v(T).locale},ce=gc(K,this.loggerWrapper);ql(q,F)?le.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=(null==Z?void 0:Z.clientScripts)||[];yield i(this,pd,"m",Bd).call(this,n);const o=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:Y},F),{lastAuth:ce,preview:this.preview,abTestingKey:V,client:this.client}),y&&{redirectUrl:y}),{locale:v(T).locale,nativeOptions:Q,outboundAppId:B,outboundAppScopes:J}),H,e,X.componentsVersion,G,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),this.getComponentsContext()),Bl(t)),S&&{exchangeCode:S,idpInitiated:!0}),F.descopeIdpInitiated&&{idpInitiated:!0}),k&&{token:k}),le.next.isCustomScreen);return i(this,Ud,"f").call(this,o),o})):(s("projectId")||s("baseUrl")||s("executionId")||s("stepId"))&&(le.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=(null==m?void 0:m.clientScripts)||[];yield i(this,pd,"m",Bd).call(this,n);const o=yield this.sdk.flow.next(p,h,e,Z.version,X.componentsVersion,Object.assign(Object.assign({},this.getComponentsContext()),Bl(t)),le.next.isCustomScreen);return i(this,Ud,"f").call(this,o),o}))),this.loggerWrapper.debug("Got a screen with id",le.screenId),yield i(this,pd,"m",Od).call(this,le),this.stepState.update(le)}))}onStepChange(e,t){return n(this,void 0,void 0,(function*(){var o,r,s;const{htmlFilename:a,htmlLocaleFilename:l,direction:c,next:d,screenState:u,screenId:h}=e;this.loggerWrapper.debug("Rendering a flow screen");const p=document.createElement("template");p.innerHTML=yield this.getPageContent(a,l);const f=p.content.cloneNode(!0),g=this.loadDescopeUiComponents(p);this.sdk.webauthn.helpers.isSupported()?yield i(this,pd,"m",Pd).call(this,f,d):(e=>{e.querySelectorAll(`descope-button[${wl}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true")))})(f),!e.samlIdpUsername||(null===(o=u.form)||void 0===o?void 0:o.loginId)||(null===(r=u.form)||void 0===r?void 0:r.email)||(u.form||(u.form={}),u.form.loginId=e.samlIdpUsername,u.form.email=e.samlIdpUsername),lc(f,u,this.formConfig,this.loggerWrapper),this.applyComponentsState(f,null==u?void 0:u.componentsState);const{geo:v}=null!==(s=yield this.getExecutionContext())&&void 0!==s?s:{};((e,t)=>{Object.entries({"default-code":"autoDetect","default-country":"autoDetect"}).forEach((([n,i])=>{Array.from(e.querySelectorAll(`[${n}="${i}"]`)).forEach((e=>{e.setAttribute(n,t||i)}))}))})(f,v),((e,t)=>{let n=t;if(t)try{const[e]=Intl.getCanonicalLocales(t);e&&(n=e)}catch(e){}Object.entries({lang:"autoDetect"}).forEach((([t,i])=>{Array.from(e.querySelectorAll(`[${t}="${i}"]`)).forEach((e=>{e.setAttribute(t,n||i)}))}))})(f,e.locale);const m=()=>n(this,void 0,void 0,(function*(){var n,o;yield g;const r=this.contentRootElement;((e,t)=>{ac(e,"descope-totp-image",t)})(r,null===(n=null==u?void 0:u.totp)||void 0===n?void 0:n.image),((e,t)=>{ac(e,"descope-notp-image",t)})(r,null===(o=null==u?void 0:u.notp)||void 0===o?void 0:o.image),((e,t,n,i)=>{n&&Object.keys(n).forEach((o=>{if(!t.querySelector(o))return void i.debug(`Skipping css vars for component "${o}"`,`Got css vars for component ${o} but Could not find it on next page`);const r=customElements.get(o);r?Object.keys(n[o]).forEach((t=>{var s;const a=n[o],l=null===(s=null==r?void 0:r.cssVarList)||void 0===s?void 0:s[t];if(!l)return void i.info(`Could not find css variable name for ${t} in ${o}`,"Check if the css variable is defined in the component");const c=a[t];e.style.setProperty(l,c)})):i.debug(`Could not find component class for ${o}`,"Check if the component is registered")}))})(r,f,u.cssVars,this.loggerWrapper),r.replaceChildren(f);const s=!t.htmlFilename;setTimeout((()=>{i(this,pd,"m",zd).call(this),this.validateOnBlur&&(e=>{e.querySelectorAll("*[name]").forEach((t=>{t.addEventListener("blur",(()=>{var n;const i=()=>{var e;const n=t.focus;t.focus=()=>{},null===(e=t.reportValidity)||void 0===e||e.call(t),setTimeout((()=>{t.focus=n}))};if("true"===t.getAttribute("invalid")||(null===(n=t.value)||void 0===n?void 0:n.length))return void i();const o={timer:void 0},r=e=>{"true"===e.target.getAttribute("formnovalidate")&&(clearTimeout(o.timer),o.timer=void 0)};o.timer=setTimeout((()=>{e.removeEventListener("click",r),i(),o.timer=void 0}),150),e.addEventListener("click",r,{once:!0})}))}))})(r),((e,t)=>{ic(e,null==t?void 0:t.inputs),ic(e,null==t?void 0:t.form)})(r,u),this.initRealtimeConditions(r,u),i(this,pd,"m",_d).call(this,{isFirstScreen:s,isCustomScreen:!1,stepName:e.stepName}),Dl(r,this.autoFocus,s),i(this,pd,"m",Zd).call(this,h)})),i(this,pd,"m",Xd).call(this,d,h),r.querySelector(`[${wl}="polling"]`)&&d(xl,{})}));c?i(this,pd,"m",jd).call(this,m):m()}))}getInputs(){return Array.from(this.shadowRoot.querySelectorAll(`*:not(slot)[name]:not([${tl}])`))}shouldUsePopupPostMessage(){if(!this.popupOrigin)return!1;try{new URL(this.popupOrigin)}catch(e){return!1}return!0}}fd=new WeakMap,gd=new WeakMap,vd=new WeakMap,md=new WeakMap,xd=new WeakMap,Ed=new WeakMap,Rd=new WeakMap,Td=new WeakMap,Md=new WeakMap,Ud=new WeakMap,Wd=new WeakMap,Dd=new WeakMap,Vd=new WeakMap,pd=new WeakSet,wd=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1,deferredPolling:!1})}),300)},bd=function(e,t,o){return n(this,void 0,void 0,(function*(){var n;return(null===(n=this.nativeOptions)||void 0===n?void 0:n.bridgeVersion)>=2&&new Promise((n=>{this.nativeCallbacks.screenNext=o,this.nativeCallbacks.screenResolve=n,i(this,pd,"m",kd).call(this,"beforeScreen",{screen:e,context:t})}))}))},yd=function(e){var t;(null===(t=this.nativeOptions)||void 0===t?void 0:t.bridgeVersion)>=2&&i(this,pd,"m",kd).call(this,"afterScreen",{screen:e})},kd=function(e,t){i(this,pd,"m",Gd).call(this,"bridge",{type:e,payload:t})},Sd=function({errorText:e,errorType:t}){const n=()=>{var n;let i=e;try{i=(null===(n=this.errorTransformer)||void 0===n?void 0:n.call(this,{text:e,type:t}))||e}catch(e){this.loggerWrapper.error("Error transforming error message",e.message)}((e,t,n="")=>{e.querySelectorAll(`[${wl}="${t}"]`).forEach((e=>{e.textContent=n,e.classList[n?"remove":"add"]("hide")}))})(this.contentRootElement,"error-message",i)};this.addEventListener("screen-updated",n,{once:!0}),n()},Id=function(){var e,n,o;null===(e=this.stepState)||void 0===e||e.subscribe(this.onStepChange.bind(this),(e=>{var n=e.screenState,i=t(void 0===n?{}:n,["errorText","errorType"]),o=t(e,["screenState"]);return Object.assign(Object.assign({},o),{screenState:i})})),null===(n=this.stepState)||void 0===n||n.subscribe(i(this,pd,"m",Sd).bind(this),(e=>{var t,n;return{errorText:null===(t=null==e?void 0:e.screenState)||void 0===t?void 0:t.errorText,errorType:null===(n=null==e?void 0:e.screenState)||void 0===n?void 0:n.errorType}}),{forceUpdate:!0}),null===(o=this.stepState)||void 0===o||o.subscribe(i(this,pd,"m",Cd).bind(this),(e=>{var t,n;return{errorText:null===(t=null==e?void 0:e.screenState)||void 0===t?void 0:t.errorText,errorType:null===(n=null==e?void 0:e.screenState)||void 0===n?void 0:n.errorType}}),{forceUpdate:!0})},Cd=function({errorText:e,errorType:t}){(t||e)&&(this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((e=>{e.shadowRoot.querySelectorAll("descope-text-field[data-id]").forEach((e=>{e.value=""}))})),Dl(this.contentRootElement,this.autoFocus,!1))},Ad=function(){return n(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Trying to restart the flow");const e=yield this.getComponentsVersion();this.reset(),e===(yield this.getComponentsVersion())?(this.loggerWrapper.debug("Components version was not changed, restarting flow"),this.flowState.update({stepId:null,executionId:null})):this.loggerWrapper.error("Components version mismatch, please reload the page")}))},Od=function(e){return n(this,void 0,void 0,(function*(){var n;const r=Object.assign(Object.assign({},this.stepState.current),e),{next:s,stepName:a}=r,l=(e=>{var t,n,i;const o=(r=e.screenState,s=(e,t)=>jl.includes(t)||t.startsWith("_"),Object.fromEntries(Object.entries(r).filter((([e,t])=>!s(0,e)))));var r,s;const{screenState:{errorText:a,errorType:l}}=e;return(a||l)&&(o.error={text:a,type:l}),e.action&&(o.action=e.action),(null===(i=null===(n=null===(t=e.screenState)||void 0===t?void 0:t.componentsConfig)||void 0===n?void 0:n.thirdPartyAppApproveScopes)||void 0===i?void 0:i.data)&&(o.inboundAppApproveScopes=e.screenState.componentsConfig.thirdPartyAppApproveScopes.data),o})(t(r,["next","stepName"]));let c=yield i(this,pd,"m",bd).call(this,a,l,s);c||(c=Boolean(yield null===(n=this.onScreenUpdate)||void 0===n?void 0:n.call(this,a,l,s,this)));const d=!this.stepState.current.htmlFilename;if(i(this,Ed,"f").call(this,c),s&&(s.isCustomScreen=c),i(this,xd,"f")!==c){const[e,t]=["flow","custom"].sort((()=>c?-1:1));this.loggerWrapper.debug(`Switching from ${t} screen to ${e} screen`),o(this,xd,c,"f"),c?this.stepState.unsubscribeAll():i(this,pd,"m",Id).call(this)}c?(this.loggerWrapper.debug("Showing a custom screen"),i(this,pd,"m",_d).call(this,{isFirstScreen:d,isCustomScreen:c,stepName:e.stepName}),this.disableKeyPressHandler()):this.handleKeyPress(),this.stepState.forceUpdate=c}))},jd=function(e){this.contentRootElement.addEventListener("transitionend",(()=>{this.loggerWrapper.debug("page switch transition end"),this.contentRootElement.classList.remove("fade-out"),e()}),{once:!0}),this.loggerWrapper.debug("page switch transition start"),this.contentRootElement.classList.add("fade-out")},$d=function(e){const t=e.getAttribute("name");if(!["email"].includes(t)){const n=`user-${t}`;e.setAttribute("name",n),e.addEventListener("input",(()=>{e.setAttribute("name",e.value?t:n)}))}},Pd=function(e,t){return n(this,void 0,void 0,(function*(){var r;null===(r=i(this,gd,"f"))||void 0===r||r.abort();const s=e.querySelector('*[autocomplete="webauthn"]');if(s&&(yield cc())){const{options:e,transactionId:r}=(yield i(this,Wd,"f").call(this))||{};e&&r&&(i(this,pd,"m",$d).call(this,s),o(this,gd,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(e,i(this,gd,"f")).then((e=>n(this,void 0,void 0,(function*(){t(s.id,{transactionId:r,response:e})})))).catch((e=>{"AbortError"!==e.name&&this.loggerWrapper.error("Conditional login failed",e.message)})))}}))},_d=function({isFirstScreen:e,isCustomScreen:t,stepName:n}){e&&i(this,pd,"m",Gd).call(this,"ready",{}),t||i(this,pd,"m",yd).call(this,n),i(this,pd,"m",Gd).call(this,"page-updated",{screenName:n}),i(this,pd,"m",Gd).call(this,"screen-updated",{screenName:n})},Ld=function(){let e=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((t=>{var n,i;"slot"===t.localName||t.classList.contains("hidden")||(null===(n=t.reportValidity)||void 0===n||n.call(t),e&&(e=null===(i=t.checkValidity)||void 0===i?void 0:i.call(t)))})),e},Nd=function(){return n(this,void 0,void 0,(function*(){const e=this.getInputs();return(yield Promise.all(e.map((e=>n(this,void 0,void 0,(function*(){return{name:e.getAttribute("name"),value:e.value}})))))).reduce(((e,t)=>Object.assign(Object.assign({},e),{[t.name]:t.value})),{})}))},Fd=function(e){const t=Array.from(this.contentRootElement.querySelectorAll(':not([disabled]), [disabled="false"]')).filter((t=>t!==e)),r=()=>{e.removeAttribute("loading"),t.forEach((e=>{e.removeAttribute("disabled")}))},s=()=>n(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Restoring components state"),this.removeEventListener("popupclosed",s),r();const e=yield this.getFlowConfig(),t=[...e.clientScripts||[],...e.sdkScripts||[]];this.loadSdkScripts(t)})),a=()=>{var e;window.removeEventListener("pageshow",i(this,Dd,"f")),o(this,Dd,(e=>{e.persisted&&(this.logger.debug("Page was loaded from cache, restoring components state"),s())}),"f"),window.addEventListener("pageshow",i(this,Dd,"f"),{once:!0});const t=null===(e=this.stepState)||void 0===e?void 0:e.subscribe(((e,n)=>{e===n&&s(),this.removeEventListener("popupclosed",s),this.stepState.unsubscribe(t)}),(e=>e.screenId),{forceUpdate:!0})},l=this.nextRequestStatus.subscribe((({isLoading:n})=>{n?(this.addEventListener("popupclosed",s,{once:!0}),e.setAttribute("loading","true"),t.forEach((e=>e.setAttribute("disabled","true")))):(this.nextRequestStatus.unsubscribe(l),"success"===this.flowStatus?(this.removeEventListener("popupclosed",s),r()):a())}))},qd=function(e={}){var t,n;const i=Hl(e,["externalId","email","phone"]),o=Hl(e,["newPassword","password"]);if(i&&o)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:i,password:o});null===(n=null===(t=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===t?void 0:t.store)||void 0===n||n.call(t,e)}catch(e){this.loggerWrapper.error("Could not store credentials",e.message)}},zd=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((e=>e.remove())),this.contentRootElement.querySelectorAll('[external-input="true"]').forEach((e=>i(this,pd,"m",Hd).call(this,e)))},Hd=function(e){e&&e.querySelectorAll("input").forEach((t=>{const n=t.getAttribute("slot"),i=`input-${e.id}-${n}`,o=document.createElement("slot");o.setAttribute("name",i),o.setAttribute("slot",n),e.appendChild(o),t.setAttribute("slot",i),this.appendChild(t)}))},Bd=function(e){return n(this,void 0,void 0,(function*(){if(i(this,vd,"f")){this.loggerWrapper.debug("Waiting for sdk scripts to load");const e=Date.now();yield i(this,vd,"f"),this.loggerWrapper.debug("Sdk scripts loaded for",(Date.now()-e).toString())}const t=this.loadSdkScriptsModules(),n=e.map((e=>e.id));for(const e of t)if(n.includes(e.id))try{"function"==typeof e.present&&((yield e.present())||this.loggerWrapper.debug(`Sdk script ${e.id} was cancelled`))}catch(t){this.loggerWrapper.error(`Failed to present ${e.id} script module`,t.message)}const o=[];for(const e of t)"function"==typeof e.refresh&&o.push(e.refresh());if(o.length>0)try{yield Fl(5e3,Promise.all(o),null)}catch(e){this.loggerWrapper.error("Failed to refresh script module",e.message)}}))},Jd=function(e,t){this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((n=>{n.addEventListener("input",(()=>{var o;(null===(o=n.checkValidity)||void 0===o?void 0:o.call(n))&&i(this,Vd,"f").call(this,n,e,t)}))}))},Kd=function(e,t,n){t&&n&&"true"===e.getAttribute("data-opt-in-last-used-auth")&&function(e,t,n){try{const n=mc();n[e]=t,uc(El,JSON.stringify(n))}catch(e){null==n||n.warn("[Descope] Failed to update in-flight last auth storage",String(e))}}(n,t,this.loggerWrapper)},Zd=function(e){var t;const n=null===(t=gc(this.sdk.getLastUserLoginId(),this.loggerWrapper).lastUsedPerScreen)||void 0===t?void 0:t[e];if(!n)return;const i=this.contentRootElement.querySelector('descope-attachment[data-type="last-auth-badge"]'),o=this.contentRootElement.querySelector(`#${CSS.escape(n)}`);i&&o&&(o.replaceWith(i),i.appendChild(o))},Xd=function(e,t){this.contentRootElement.querySelectorAll(`descope-button:not([${nl}]), [data-type="button"]:not([${nl}]`).forEach((n=>{n.onclick=()=>{i(this,Vd,"f").call(this,n,e,t)}})),i(this,pd,"m",Jd).call(this,e,t),this.isDismissScreenErrorOnInput&&this.contentRootElement.querySelectorAll(`*[name]:not([${tl}])`).forEach((e=>{e.addEventListener("input",(()=>{this.stepState.update((e=>Object.assign(Object.assign({},e),{screenState:Object.assign(Object.assign({},e.screenState),{errorText:"",errorType:""})})))}))}))},Gd=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},Yd=function(e,t,n){var i;const[o,r]=(null===(i=window.name)||void 0===i?void 0:i.split("|"))||[],s={data:{code:t,exchangeError:n},action:"code"};if("descope-wc"===o&&r){this.loggerWrapper.debug("Using postMessage fallback to notify opener in origin",r);try{window.opener.postMessage(s,r)}catch(e){this.loggerWrapper.error("Failed to send postMessage fallback (likely COOP isolation)",null==e?void 0:e.message)}}else{this.loggerWrapper.debug("Creating popup channel",e);const t=new BroadcastChannel(e);t.postMessage(s),t.close()}try{window.close()}catch(e){}},customElements.get("descope-wc")?console.log("descope-wc is already defined"):customElements.define("descope-wc",Qd);var eu=Object.freeze({__proto__:null,default:Qd});customElements.define("descope-user-profile-widget",Va);const tu=(e,t,n,i={})=>{var o,r,s,a;return[Math.min(Math.max(t,("all"===i.left?e.offsetWidth:null!==(o=i.left)&&void 0!==o?o:0)-e.offsetWidth),window.innerWidth-("all"===i.right?e.offsetWidth:null!==(r=i.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===i.top?e.offsetHeight:null!==(s=i.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===i.bottom?e.offsetHeight:null!==(a=i.bottom)&&void 0!==a?a:0))]};var nu,iu,ou,ru,su,au,lu,cu,du,uu;const hu=document.createElement("template");hu.innerHTML=`\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`;const pu=r(B)(HTMLElement);class fu extends pu{constructor(){var e;super(),nu.add(this),iu.set(this,new g({messages:[]})),ou.set(this,void 0),ru.set(this,void 0),su.set(this,void 0),au.set(this,{resize:i(this,nu,"m",uu).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(hu.content.cloneNode(!0)),this.injectStyle('\n.debugger {\n all: initial;\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n'),o(this,ou,this.shadowRoot.querySelector(".debugger"),"f"),o(this,ru,i(this,ou,"f").querySelector(".content"),"f"),o(this,su,i(this,ou,"f").querySelector(".header"),"f")}updateData(e){i(this,iu,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let i=0,o=0,r=0,s=0;function a(t){t.preventDefault(),i=r-t.clientX,o=s-t.clientY,r=t.clientX,s=t.clientY;const[a,l]=tu(e,e.offsetLeft-i,e.offsetTop-o,n);e.style.top=`${l}px`,e.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=l,document.onmousemove=a}t?t.onmousedown=c:e.onmousedown=c})(i(this,ou,"f"),i(this,su,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",i(this,au,"f").resize),(e=i(this,ou,"f")).onmousemove=t=>{var n;const i=t.target;(i.w&&i.w!==i.offsetWidth||i.h&&i.h!==i.offsetHeight)&&(null===(n=e.onresize)||void 0===n||n.call(e,t)),i.w=i.offsetWidth,i.h=i.offsetHeight},i(this,ou,"f").onresize=i(this,nu,"m",du).bind(this),i(this,iu,"f").subscribe(i(this,nu,"m",lu).bind(this))}disconnectedCallback(){i(this,iu,"f").unsubscribeAll(),window.removeEventListener("resize",i(this,au,"f").resize)}}iu=new WeakMap,ou=new WeakMap,ru=new WeakMap,su=new WeakMap,au=new WeakMap,nu=new WeakSet,lu=function(e){i(this,nu,"m",cu).call(this,e),i(this,nu,"m",du).call(this)},cu=function(e){i(this,ru,"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("")},du=function(){i(this,ru,"f").querySelectorAll(".msg").forEach((e=>{const t=e,n=t.querySelector(".msg_desc"),i=n.scrollWidth>n.clientWidth,o=n.clientHeight>20;i||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)}))},uu=function(){const[e,t]=tu(i(this,ou,"f"),Number.parseInt(i(this,ou,"f").style.left,10),Number.parseInt(i(this,ou,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});i(this,ou,"f").style.top=`${t}px`,i(this,ou,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",fu);var gu=Object.freeze({__proto__:null,default:fu});const vu=(e,t,n,i={})=>{var o,r,s,a;return[Math.min(Math.max(t,("all"===i.left?e.offsetWidth:null!==(o=i.left)&&void 0!==o?o:0)-e.offsetWidth),window.innerWidth-("all"===i.right?e.offsetWidth:null!==(r=i.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===i.top?e.offsetHeight:null!==(s=i.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===i.bottom?e.offsetHeight:null!==(a=i.bottom)&&void 0!==a?a:0))]},mu=(e,t,n)=>{let i=0,o=0,r=0,s=0;function a(t){t.preventDefault(),i=r-t.clientX,o=s-t.clientY,r=t.clientX,s=t.clientY;const[a,l]=vu(e,e.offsetLeft-i,e.offsetTop-o,n);e.style.top=`${l}px`,e.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=l,document.onmousemove=a}t?t.onmousedown=c:e.onmousedown=c};var wu,bu,yu,ku,Su,Iu,Cu,Au,xu,Ou,Eu;const ju=document.createElement("template");ju.innerHTML='\n<div 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';const Ru=r(B)(HTMLElement);class Tu extends Ru{constructor(){super(),wu.add(this),bu.set(this,new Ql({messages:[]})),yu.set(this,void 0),ku.set(this,void 0),Su.set(this,void 0),Iu.set(this,{resize:i(this,wu,"m",Eu).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(ju.content.cloneNode(!0)),o(this,yu,this.shadowRoot.querySelector(".debugger"),"f"),o(this,ku,i(this,yu,"f").querySelector(".content"),"f"),o(this,Su,i(this,yu,"f").querySelector(".header"),"f"),i(this,wu,"m",Cu).call(this)}updateData(e){i(this,bu,"f").update((t=>({messages:t.messages.concat(e)})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;null===(t=e.init)||void 0===t||t.call(this),mu(i(this,yu,"f"),i(this,Su,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",i(this,Iu,"f").resize),(e=>{e.onmousemove=t=>{(t.target.w&&t.target.w!==t.target.offsetWidth||t.target.h&&t.target.h!==t.target.offsetHeight)&&e.onresize(t),t.target.w=t.target.offsetWidth,t.target.h=t.target.offsetHeight}})(i(this,yu,"f")),i(this,yu,"f").onresize=i(this,wu,"m",Ou).bind(this),i(this,bu,"f").subscribe(i(this,wu,"m",Au).bind(this))}))}disconnectedCallback(){i(this,bu,"f").unsubscribeAll(),window.removeEventListener("resize",i(this,Iu,"f").resize)}}bu=new WeakMap,yu=new WeakMap,ku=new WeakMap,Su=new WeakMap,Iu=new WeakMap,wu=new WeakSet,Cu=function(){this.injectStyle('\n .debugger {\n all: initial;\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n'),i(this,yu,"f").style.top="32px",i(this,yu,"f").style.left=window.innerWidth-300-32+"px"},Au=function(e){i(this,wu,"m",xu).call(this,e),i(this,wu,"m",Ou).call(this)},xu=function(e){i(this,ku,"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("")},Ou=function(){i(this,ku,"f").querySelectorAll(".msg").forEach((e=>{const t=e.querySelector(".msg_desc"),n=t.scrollWidth>t.clientWidth,i=t.clientHeight>20;n||i?(e.classList.add("collapsible"),e.onclick=t=>{t.target.classList.contains("msg_desc")||e.classList.toggle("collapsed")}):(e.classList.remove("collapsible"),e.onclick=null)}))},Eu=function(){const[e,t]=vu(i(this,yu,"f"),Number.parseInt(i(this,yu,"f").style.left,10),Number.parseInt(i(this,yu,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});i(this,yu,"f").style.top=`${t}px`,i(this,yu,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",Tu);var Mu=Object.freeze({__proto__:null,default:Tu});return Va}();
5
+ this["descope-user-profile-widget"]=function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},e.apply(this,arguments)};function t(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(e);o<i.length;o++)t.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(n[i[o]]=e[i[o]])}return n}function n(e,t,n,i){return new(n||(n=Promise))((function(o,r){function s(e){try{l(i.next(e))}catch(e){r(e)}}function a(e){try{l(i.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((i=i.apply(e,t||[])).next())}))}function i(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function o(e,t,n,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?o.call(e,n):o?o.value=n:t.set(e,n),n}function r(...e){return t=>e.reduce(((e,t)=>t(e)),t)}"function"==typeof SuppressedError&&SuppressedError;const s=e=>{const t=document.createElement("template");return t.innerHTML=e,t},a=e=>{let t,n;return(...i)=>(t&&((e,t)=>e.length===t.length&&e.every(((e,n)=>e===t[n])))(t,i)||(t=i,n=e(...i)),n)},l=(e={})=>{const t=s("<descope-wc></descope-wc>");return Object.entries(e).forEach((([e,n])=>{t.content.querySelector("descope-wc").setAttribute((e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_.]+/g,"-").toLowerCase())(e),(e=>"string"==typeof e?e:(e=>null!==e&&"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype)(e)?JSON.stringify(e):"")(n))})),t},c=e=>{const t=Symbol((e=>{const t=e.toString();let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n&=n;return n.toString(16)})(e));return n=>{if(n[t])return n;const i=e(n);return i[t]=!0,i}};var d,u,h,p;function f(e,t){const n=Object.getOwnPropertyNames(e),i=Object.getOwnPropertyNames(t);if(n.length!==i.length)return!1;for(let i=0;i<n.length;i+=1){const o=n[i],r=e[o],s=t[o];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!f(r,s))return!1}else if(r!==s)return!1}return!0}let g=class{constructor(e={},{forceUpdate:t=!1}={}){d.set(this,void 0),u.set(this,{}),h.set(this,0),p.set(this,!0),this.update=e=>{const t="function"==typeof e?e(i(this,d,"f")):e,n=Object.assign(Object.assign({},i(this,d,"f")),t);if(i(this,p,"f")||!f(i(this,d,"f"),n)){const e=i(this,d,"f");o(this,d,n,"f"),Object.freeze(i(this,d,"f")),setTimeout((()=>{Object.values(i(this,u,"f")).forEach((t=>t(n,e,((e,t)=>n=>e[n]!==t[n])(n,e))))}),0)}},o(this,d,e,"f"),o(this,p,t,"f")}get current(){return Object.assign({},i(this,d,"f"))}subscribe(e){return o(this,h,i(this,h,"f")+1,"f"),i(this,u,"f")[i(this,h,"f")]=e,i(this,h,"f").toString()}unsubscribe(e){const t=!!i(this,u,"f")[e];return t&&delete i(this,u,"f")[e],t}unsubscribeAll(){return o(this,u,{},"f"),!0}};d=new WeakMap,u=new WeakMap,h=new WeakMap,p=new WeakMap;function v(e){if(e)return{locale:e.toLowerCase(),fallback:e.toLowerCase()};const t=navigator.language;return t?t.includes("-")?{locale:t.toLowerCase(),fallback:t.split("-")[0].toLowerCase()}:{locale:t.toLowerCase(),fallback:t.toLowerCase()}:{locale:"",fallback:""}}const m=["error","warn","info","debug"],w={error:console.error.bind(console,"[Descope]"),warn:console.warn.bind(console,"[Descope]"),info:console.info.bind(console,"[Descope]"),debug:console.debug.bind(console,"[Descope]")},b=c((e=>{var t,n,r,s;return s=class extends e{constructor(){super(...arguments),t.add(this),n.set(this,i(this,t,"m",r).call(this,w))}set logger(e){o(this,n,i(this,t,"m",r).call(this,e||w),"f")}get logger(){return i(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,r=function(e){return m.reduce(((t,n)=>(t[n]=(...t)=>{var i;this.onLogEvent(n,t),null===(i=e[n])||void 0===i||i.call(e,...t)},t)),{})},s})),y="undefined"!=typeof localStorage,k="https://static.descope.com/pages",S="https://static2.descope.com/pages",I=y&&localStorage.getItem("base.content.url")||"",C=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,A=c((e=>{var t,n;return n=class extends e{constructor(){super(...arguments),t.set(this,!0)}connectedCallback(){var e,n;null===(e=super.connectedCallback)||void 0===e||e.call(this),(null===(n=this.shadowRoot)||void 0===n?void 0:n.isConnected)&&i(this,t,"f")&&(o(this,t,!1,"f"),this.init())}async init(){}},t=new WeakMap,n})),x=c((e=>{var t,n;const o=r(b,A)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,{})}async init(){var e,n,o;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),n=this,o=e=>{var n;null===(n=i(this,t,"f")[e])||void 0===n||n.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(n.attributes).forEach((e=>o(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&o(e.attributeName)}))})).observe(n,{attributes:!0})}observeAttribute(e,n){i(this,t,"f")[e]||(i(this,t,"f")[e]=[]);const o=i(this,t,"f")[e].push(n);return()=>i(this,t,"f")[e].splice(o,1)}observeAttributes(e,t){const n=e.reduce(((e,n)=>(e.push(this.observeAttribute(n,t)),e)),[]);return()=>n.forEach((e=>e()))}},t=new WeakMap,n})),O=e=>t=>{var n,o,s;const a=r(b,A,x)(t),l=Object.keys(e);return s=class extends a{constructor(...e){super(...e),n.add(this),this.observeAttributes(l,i(this,n,"m",o).bind(this))}async init(){var e;l.forEach((e=>i(this,n,"m",o).call(this,e,this.getAttribute(e)))),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},n=new WeakSet,o=function(t,n){const i=e[t],o="function"==typeof i?i(t,n):i;o&&this.logger.error(o)},s};O.missingAttrValidator=C;const E=c((e=>{const t=r(O({"project-id":C}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),j=c((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),R="Trying the next fallback URL...",T=async(e,t,{logger:n}={})=>{try{return await fetch(e,t)}catch(i){return null==n||n.debug(`Network error fetching URL ${e} [${i.message}], retrying...`),fetch(e,t)}};const M=c((e=>{var t,n,s,a,l,c,d;const u=r(b,E,j)(e);return d=class extends u{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),a.set(this,new Set)}async fetchStaticResource(e,n){const r=i(this,t,"m",l).call(this,e),c=Array.isArray(r)?e=>{const{baseUrl:t}=r[e];o(this,s,t,"f");for(let t=0;t<e;t++){const e=r[t].baseUrl;i(this,a,"f").add(e)}}:null;try{const e=await(async(e,t,{logger:n,onSuccess:i}={})=>{const o=Array.isArray(e)?e:[e];for(let e=0;e<o.length;e++){const r=o[e],s=e===o.length-1;try{const o=await T(r.toString(),t,{logger:n});if(o.ok)return null==i||i(e),null==n||n.debug(`Successfully fetched URL ${r}`),o;const a=`Error fetching URL ${r} [${o.status}]`;if(s)throw new Error(a);null==n||n.debug(`${a}. ${R}`)}catch(e){const t=`Error fetching URL ${r} [${e.message}]`;if(s)throw new Error(t);null==n||n.debug(`${t}. ${R}`)}}})(r,{cache:"default"},{logger:this.logger,onSuccess:c});return{body:await e[n](),headers:Object.fromEntries(e.headers.entries())}}catch(e){this.logger.error(e.message)}}get baseStaticUrl(){return this.getAttribute("base-static-url")||""}},n=new WeakMap,s=new WeakMap,a=new WeakMap,t=new WeakSet,l=function(e){const r=I||this.baseStaticUrl;if(r)return i(this,t,"m",c).call(this,e,r);i(this,n,"f")!==this.baseUrl&&(o(this,n,this.baseUrl,"f"),o(this,s,void 0,"f"),i(this,a,"f").clear());const l=[];if(i(this,s,"f"))l.push(i(this,t,"m",c).call(this,e,i(this,s,"f"))),i(this,s,"f")===k&&l.push(i(this,t,"m",c).call(this,e,S));else{const n=this.baseUrl+"/pages";this.baseUrl&&!i(this,a,"f").has(n)&&l.push(i(this,t,"m",c).call(this,e,n)),i(this,a,"f").has(k)||l.push(i(this,t,"m",c).call(this,e,k)),l.push(i(this,t,"m",c).call(this,e,S))}return 1===l.length?l[0]:l},c=function(e,t){return function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:i=k}){const o=new URL(i);return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,n,t),o.baseUrl=i,o}({projectId:this.projectId,filename:e,baseUrl:t})},d})),U=c((e=>{var t,n;const o=r(O({"project-id":C}))(e);return n=class extends o{constructor(){super(...arguments),t.set(this,new Map)}onReset(e,n){if(i(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} already exists`);return i(this,t,"f").set(e,n),()=>{i(this,t,"f").delete(e)}}async reset(...e){0===e.length?await Promise.all(Array.from(i(this,t,"f").values()).map((e=>e()))):await Promise.all(e.map((e=>{var n;if(!i(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} does not exist`);return null===(n=i(this,t,"f").get(e))||void 0===n?void 0:n()})))}},t=new WeakMap,n})),W=c((e=>{var t,n,s,a,l;const c=r(M,U,A)(e);return l=class extends c{constructor(){super(...arguments),t.add(this),s.set(this,void 0),a.set(this,(async()=>{try{const{body:e,headers:t}=await this.fetchStaticResource("config.json","json");return{projectConfig:e,executionContext:{geo:t["x-geo"]}}}catch(e){this.logger.error("Cannot fetch config file","make sure that your projectId & flowId are correct")}}))}async init(){await super.init(),this.onReset("config",i(this,t,"m",n).bind(this))}get config(){return i(this,s,"f")||o(this,s,i(this,a,"f").call(this),"f"),i(this,s,"f")}},s=new WeakMap,a=new WeakMap,t=new WeakSet,n=function(){o(this,s,void 0,"f")},l})),$=c((e=>{var t,n,s,a,l,c,d;return d=class extends(r(A,b)(e)){constructor(){super(...arguments),t.add(this),n.set(this,void 0),this.attributeChangedCallback=(e,n,o)=>{var r;null===(r=super.attributeChangedCallback)||void 0===r||r.call(this,e,n,o),"debug"===e&&i(this,t,"m",l).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(e,n){var o;null===(o=super.onLogEvent)||void 0===o||o.call(this,e,n),"error"===e&&i(this,t,"m",c).call(this,n[0]||"Error",n[1])}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),i(this,t,"m",l).call(this)}},n=new WeakMap,t=new WeakSet,s=function(){var e;null===(e=i(this,n,"f"))||void 0===e||e.remove(),o(this,n,null,"f")},a=async function(){o(this,n,document.createElement("descope-debugger"),"f"),Object.assign(i(this,n,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),await Promise.resolve().then((function(){return wu})),document.body.appendChild(i(this,n,"f"))},l=function(){this.debug?i(this,t,"m",a).call(this):i(this,t,"m",s).call(this)},c=function(e,t){var o;e&&(null===(o=i(this,n,"f"))||void 0===o||o.updateData({title:e,description:t}))},d})),P=["https://descopecdn.com","https://static.descope.com","https://cdn.jsdelivr.net"],_=e=>{let t=0;const n=e.toString();for(let e=0;e<n.length;e++){t=(t<<5)-t+n.charCodeAt(e),t|=0}return`${Math.abs(t).toString()}`},L=(e,t,n)=>new Promise(((i,o)=>{const r=((e,t)=>{const n=document.createElement("script");return n.id=e,t&&(n.integrity=t,n.crossOrigin="anonymous"),window.DESCOPE_NONCE&&n.setAttribute("nonce",window.DESCOPE_NONCE),n})(e,n);r.onerror=e=>{r.setAttribute("status","error"),o(e)},r.onload=()=>{r.setAttribute("status","loaded"),i(r)},r.src=t.toString(),document.body.appendChild(r)})),N=(e,t)=>{if(t){const n=e.integrity;if(n!==t)return Promise.reject(new Error(`Integrity mismatch: expected ${t}, found ${n}`))}return"loaded"===e.getAttribute("status")?Promise.resolve(e):(e=>"error"===e.getAttribute("status"))(e)?Promise.reject():new Promise(((t,n)=>{e.addEventListener("load",(()=>{t(e)})),e.addEventListener("error",(e=>{n(e)}))}))},D=c((e=>{const t=r(b)(e);return class extends t{get baseCdnUrl(){return this.getAttribute("base-cdn-url")||""}injectNpmLib(e,t,n="",i=[],o){return this.logger.debug(`Injecting npm lib: "${e}" with version: "${t}"${o?" with SRI integrity check":""}`),(async(e,t)=>{for(const i of e){const{id:e,url:o,integrity:r}=i,s=(n=e,document.querySelector(`script#${n}`));if(s)try{return await N(s,r),i}catch(e){t(i,!0)}else try{return await L(e,o,r),i}catch(e){t(i,!1)}}var n;throw new Error("All scripts failed to load")})(((e,t,n,i="",o)=>e.reduce(((e,r)=>{const s=r;if(!s)return e;let a;try{a=new URL(s)}catch(e){throw new Error(`Invalid URL: ${s}`)}"/"!==a.pathname||(a.pathname=`/npm/${t}@${n}/${i}`);const l={url:a,id:`npmlib-${t.replaceAll("@","").replaceAll("/","_")}-${_(a)}`};return o&&(l.integrity=o),[...e,l]}),[]))([...i,this.baseCdnUrl,...P],e,t,n,o),((e,t)=>{t?this.logger.error(`Existing script cannot be loaded: "${e.url}"`):this.logger.error(`Cannot load script from URL, Make sure this URL is valid and return the correct script: "${e.url}"`)}))}}})),F="base.ui.components.url",q=y&&localStorage.getItem(F),z=c((e=>{var t,n,s,a,l,c,d;const u=r(b,W,D)(e);return d=class extends u{constructor(){super(...arguments),t.add(this),a.set(this,void 0)}get descopeUi(){return i(this,a,"f")||o(this,a,i(this,t,"m",c).call(this),"f"),i(this,a,"f")}async loadDescopeUiComponents(e){const n=Array.isArray(e)?e:(e=>[...Array.from(e.content.querySelectorAll("*")).reduce(((e,t)=>t.localName.startsWith("descope-")?e.add(t.localName):e),new Set)])(e);return Promise.all(n.map((e=>i(this,t,"m",l).call(this,e))))}},a=new WeakMap,t=new WeakSet,n=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return n?this.logger.debug(`Got component version "${n}"`):this.logger.error("Could not get components version"),n},s=async function(){var e;const t=await this.config,n=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersionSri;return n&&this.logger.debug("SRI hash available for components"),n},l=async function(e){if(!!customElements.get(e))return void this.logger.debug(`Loading component "${e}" is skipped as it is already defined`);const t=await this.descopeUi;if(t[e])try{return await t[e]()}catch(t){if("NotSupportedError"!==t.name)throw t;console.debug(`Encountered an error while attempting to define the "${e}" component, it is likely that this component is already defined`)}else this.logger.error(`Cannot load UI component "${e}"`,`Descope UI does not have a component named "${e}", available components are: "${Object.keys(t).join(", ")}"`)},c=async function(){if(globalThis.DescopeUI)return globalThis.DescopeUI;try{const e=await i(this,t,"m",n).call(this),o=q?void 0:await i(this,t,"m",s).call(this);return await this.injectNpmLib("@descope/web-components-ui",e,"dist/umd/index.js",[q],o),this.logger.debug("DescopeUI was loaded"),globalThis.DescopeUI}catch(e){throw this.logger.error(e),new Error("DescopeUI was not loaded")}},d})),V=c((e=>{var t,n,o;const s=r(A,x)(e);return o=class extends s{constructor(){super(...arguments),t.add(this)}get nonce(){return this.getAttribute("nonce")||""}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.observeAttribute("nonce",i(this,t,"m",n).bind(this)),i(this,t,"m",n).call(this)}},t=new WeakSet,n=function(){this.nonce&&(window.DESCOPE_NONCE=this.nonce)},o}));class H{constructor(e,t,{prepend:n=!1}={}){this.styleEle=document.createElement("style"),this.styleEle.setAttribute("nonce",t),this.ref=e,this.ref&&(n?this.ref.prepend(this.styleEle):this.ref.append(this.styleEle))}replaceSync(e){this.styleEle.textContent=e}get cssRules(){var e;return null===(e=this.styleEle.sheet)||void 0===e?void 0:e.cssRules}}const B=c((e=>{const t=r(V)(e);return class extends t{injectStyle(e,{prepend:t=!1}={}){let n;try{n=new CSSStyleSheet}catch(e){n=new H(this.shadowRoot,this.nonce,{prepend:t})}if(e&&n.replaceSync(e),n instanceof CSSStyleSheet){const e=this.shadowRoot;if(e&&"adoptedStyleSheets"in e){const i=[...e.adoptedStyleSheets||[]];i[t?"unshift":"push"](n),e.adoptedStyleSheets=i}}return n}}})),J="content-root",K="root",Z=c((e=>{const t=r(B)(e);return class extends t{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${K}">\n <div id="${J}"></div>\n </div>\n `,this.injectStyle(`\n #${K}, #${J} {\n height: 100%;\n }\n #${K} {\n position: relative;\n height: fit-content;\n }\n `),this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById(J),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(K)}}})),X="descope-modal";var G;let Y=class{constructor(e,t){G.set(this,void 0),this.nodeName="",o(this,G,e,"f"),this.logger=t.logger}get asyncEle(){return(async e=>new Promise((t=>{const n=setInterval((()=>{const i="function"==typeof e?e():e;i&&(clearInterval(n),t(i))}),100);setTimeout((()=>{clearInterval(n),t(null)}),1e3)})))(i(this,G,"f"))}get ele(){var e,t;const n="function"==typeof i(this,G,"f")?i(this,G,"f").call(this):i(this,G,"f");return n?(null==n?void 0:n.localName)!==this.nodeName?(null===(t=this.logger)||void 0===t||t.debug(`node name do not match, expected "${this.nodeName}", received "${n.localName}" `,Error()),null):n:(null===(e=this.logger)||void 0===e||e.debug(`Driver element is not available for ${this.nodeName}`,new Error),null)}get isExists(){return!!this.ele}};G=new WeakMap;let Q=class extends Y{constructor(){super(...arguments),this.nodeName="descope-avatar"}set displayName(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("display-name",e)}set image(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("img",e)}get flowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id")}onClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("click",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("click",e)}}},ee=class extends Y{constructor(){super(...arguments),this.nodeName="descope-button"}onClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("click",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("click",e)}}disable(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("disabled","true")}enable(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("disabled")}},te=class extends Y{constructor(){super(...arguments),this.nodeName="descope-wc"}set projectId(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("project-id",e)}set baseUrl(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("base-url",e)}set flowId(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("flow-id",e)}set theme(e){var t,n;e?null===(n=this.ele)||void 0===n||n.setAttribute("theme",e):null===(t=this.ele)||void 0===t||t.removeAttribute("theme")}onSuccess(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("success",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("success",e)}}onPageUpdated(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("page-updated",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("page-updated",e)}}},ne=class extends ee{get flowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id"))||""}get enableMode(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("enable-mode")}};var ie,oe,re,se;let ae=class extends Y{constructor(...e){super(...e),ie.add(this),oe.set(this,void 0),re.set(this,void 0),this.nodeName="descope-modal",i(this,ie,"m",se).call(this)}close(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("opened")}async open(){var e,t;await(null===(e=this.beforeOpen)||void 0===e?void 0:e.call(this)),i(this,ie,"m",se).call(this),null===(t=this.ele)||void 0===t||t.setAttribute("opened","true")}reset(){var e;this.ele&&(this.ele.innerHTML=""),i(this,oe,"f")&&(null===(e=this.ele)||void 0===e||e.append(i(this,oe,"f").content.cloneNode(!0)))}setContent(e){o(this,oe,e,"f"),this.reset()}remove(){var e,t;null===(e=i(this,re,"f"))||void 0===e||e.disconnect(),null===(t=this.ele)||void 0===t||t.remove()}};oe=new WeakMap,re=new WeakMap,ie=new WeakSet,se=function(){if(i(this,re,"f"))return;const e=this.ele;e&&(o(this,re,new MutationObserver((t=>{t.forEach(((n,i)=>{var o;const r="true"===n.oldValue,s=t[i+1]?t[i+1].oldValue:e.getAttribute("opened");r&&"true"!==s&&(null===(o=this.afterClose)||void 0===o||o.call(this))}))})),"f"),i(this,re,"f").observe(e,{attributes:!0,attributeFilter:["opened"],attributeOldValue:!0}))};let le=class extends Y{constructor(){super(...arguments),this.nodeName="descope-notification"}close(){var e;null===(e=this.ele)||void 0===e||e.removeAttribute("opened")}show(){var e;null===(e=this.ele)||void 0===e||e.setAttribute("opened","true")}setContent(e){this.ele.innerHTML="",this.ele.appendChild(e.content.cloneNode(!0))}remove(){var e;null===(e=this.ele)||void 0===e||e.remove()}},ce=class extends Y{constructor(){super(...arguments),this.nodeName="descope-combo-box"}onInput(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("input",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("input",e)}}get value(){var e;return null===(e=this.ele)||void 0===e?void 0:e.value}set value(e){this.ele&&(this.ele.value=e)}async setData(e){var t;null===(t=await this.asyncEle)||void 0===t||t.setAttribute("data",JSON.stringify(e.sort()))}setAllowCustomValue(e){this.ele&&this.ele.toggleAttribute("allow-custom-value",e)}},de=class extends Y{constructor(){super(...arguments),this.nodeName="descope-user-attribute"}set value(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("value",e)}set badgeLabel(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("badge-label",e)}get label(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("label"))||""}get editFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("edit-flow-id"))||""}get deleteFlowId(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("delete-flow-id"))||""}onEditClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("edit-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("edit-clicked",e)}}onDeleteClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("delete-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("delete-clicked",e)}}},ue=class extends Y{constructor(){super(...arguments),this.nodeName="descope-user-auth-method"}set fulfilled(e){var t,n;e?null===(t=this.ele)||void 0===t||t.setAttribute("fulfilled","true"):null===(n=this.ele)||void 0===n||n.removeAttribute("fulfilled")}onUnfulfilledButtonClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("button-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("button-clicked",e)}}onFulfilledButtonClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("fulfilled-button-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("fulfilled-button-clicked",e)}}get flowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id")}get fulfilledFlowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("fulfilled-flow-id")}},he=class extends Y{constructor(){super(...arguments),this.nodeName="descope-trusted-devices"}set displayName(e){var t;null===(t=this.ele)||void 0===t||t.setAttribute("display-name",e)}get ele(){return super.ele}get data(){var e;return null===(e=this.ele)||void 0===e?void 0:e.data}set data(e){this.ele&&(this.ele.data=e)}get flowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("flow-id")}onRemoveDeviceClick(e){var t;const n=t=>e(t.detail);return null===(t=this.ele)||void 0===t||t.addEventListener("remove-device-clicked",n),()=>{var e;return null===(e=this.ele)||void 0===e?void 0:e.removeEventListener("remove-device-clicked",n)}}},pe=class extends ce{get action(){var e;return(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("data-action"))||""}get refreshTimeout(){var e;return Number(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("data-refresh-timeout"))||500}get shouldReload(){return"reload"===this.action}},fe=class extends Y{constructor(){super(...arguments),this.nodeName="descope-user-passkeys"}get ele(){return super.ele}get data(){var e;return null===(e=this.ele)||void 0===e?void 0:e.data}set data(e){this.ele&&(this.ele.data=e)}get addPasskeyFlowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("add-passkey-flow-id")}get removePasskeyFlowId(){var e;return null===(e=this.ele)||void 0===e?void 0:e.getAttribute("remove-passkey-flow-id")}onAddPasskeyClick(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("add-passkey-clicked",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("add-passkey-clicked",e)}}onRemovePasskeyClick(e){var t;const n=t=>e(t.detail);return null===(t=this.ele)||void 0===t||t.addEventListener("remove-passkey-clicked",n),()=>{var e;return null===(e=this.ele)||void 0===e?void 0:e.removeEventListener("remove-passkey-clicked",n)}}};const ge=c((e=>{var t,n;const o=r(A,Z,z)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends ae{setContent(t){e(t),super.setContent(t)}}})())}createModal(e){const n=((e={})=>{const t=document.createElement(X);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(i(this,t,"f"))(n,{logger:this.logger})}async init(){var e;this.loadDescopeUiComponents([X]),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},t=new WeakMap,n})),ve="descope-notification",me=c((e=>{var t,n;const o=r(A,Z,z)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends le{setContent(t){const n="string"==typeof t?s(t):t;e(n),super.setContent(n)}}})())}createNotification(e){const n=((e={})=>{const t=document.createElement(ve);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(n),new(i(this,t,"f"))(n,{logger:this.logger})}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.loadDescopeUiComponents([ve])}},t=new WeakMap,n})),we="theme",be=(e,t,n="")=>Object.entries(e).reduce(((e,[i,o])=>{if(!/^[a-zA-Z0-9-]+$/.test(i))return t("Ignoring invalid override-css token path segment"),e;const r=n?`${n}-${i}`:i;if("object"==typeof o&&null!==o)return e+be(o,t,r);const s=(e=>"number"==typeof e?Number.isFinite(e)?String(e):null:"string"!=typeof e||/[;{}]/.test(e)?null:e.trim())(o);return null===s?(t("Ignoring invalid override-css token value"),e):`${e}--descope-${r}:${s};`}),"");function ye(e,t){const n=Object.assign({},e);for(const[e,i]of Object.entries(t||{}))if(null!=i)if("object"==typeof i){if(0===Object.keys(i).length)continue;n[e]=ye(n[e]||{},i)}else n[e]="string"==typeof i?(n[e]||"")+i:i;return n}const ke=(e,t)=>null!==t&&!/^[a-zA-Z0-9_-]*$/.test(t)&&"tenant must contain only alphanumeric characters, hyphens, or underscores",Se=c((e=>{const t=r(O({tenant:ke}))(e);return class extends t{get tenantId(){return this.getAttribute("tenant")||void 0}}})),Ie=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',Ce=c((e=>{var t,n,s,a,l,c,d,u,h,p,f,g,v,m,w,b,y,k,S,I,C,E;const j=r(O({theme:Ie}),Se,M,A,z,W,Z,x,B)(e);return E=class extends j{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,void 0),a.set(this,void 0),c.set(this,void 0),d.set(this,void 0),S.set(this,(()=>{i(this,t,"m",I).call(this),i(this,C,"f").call(this,"os"===this.getAttribute("theme"))})),C.set(this,(e=>{var n,o,r;const s=e?"addEventListener":"removeEventListener";null===(r=null===(o=null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-color-scheme: dark)"))||void 0===o?void 0:o[s])||void 0===r||r.call(o,"change",(()=>i(this,t,"m",I).call(this)))}))}get theme(){var e,t;const n=this.getAttribute("theme");if("os"===n){return window.matchMedia&&(null===(t=null===(e=window.matchMedia)||void 0===e?void 0:e.call(window,"(prefers-color-scheme: dark)"))||void 0===t?void 0:t.matches)?"dark":"light"}return n||"light"}get styleId(){return this.getAttribute("style-id")||we}get themeOverride(){const e=this.getAttribute("theme-override");if(!e)return null;try{return JSON.parse(e)}catch(e){return this.logger.error("Failed to parse theme-override attribute. error: ",e),null}}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),i(this,S,"f").call(this),await Promise.all([i(this,t,"m",p).call(this),i(this,t,"m",v).call(this),i(this,t,"m",w).call(this)]),i(this,t,"m",m).call(this),this.observeAttributes(["theme"],i(this,S,"f")),this.observeAttributes(["theme-override"],(()=>i(this,t,"m",m).call(this))),this.observeAttributes(["tenant"],(()=>{o(this,d,null,"f"),i(this,t,"m",v).call(this),i(this,t,"m",w).call(this)})),this.observeAttributes(["style-id"],(()=>{o(this,c,null,"f"),i(this,t,"m",y).call(this),i(this,t,"m",p).call(this),i(this,t,"m",w).call(this)}))}},n=new WeakMap,s=new WeakMap,a=new WeakMap,c=new WeakMap,d=new WeakMap,S=new WeakMap,C=new WeakMap,t=new WeakSet,l=function(){const e=this.themeOverride;return e?["light","dark"].map((t=>{var n,i,o,r,s,a;const l=null===(o=null===(i=null===(n=e[t])||void 0===n?void 0:n.globals)||void 0===i?void 0:i.colors)||void 0===o?void 0:o.primary,c=null===(a=null===(s=null===(r=e[t])||void 0===r?void 0:r.globals)||void 0===s?void 0:s.colors)||void 0===a?void 0:a.secondary;return l||c?`[data-theme="${t}"]{${be({colors:{primary:l,secondary:c}},(e=>this.logger.error(e)))}}`:""})).join(""):""},u=async function(){try{const{body:e}=await this.fetchStaticResource(`${this.styleId}.json`,"json");if(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(F))try{this.logger.warn("You are in DEV mode, and UI components override URL was found\ntrying to merge project theme with the default theme of the UI components");const t=await(async()=>{const e=localStorage.getItem(F),t=null==e?void 0:e.replace(/[^\/]+$/,"DescopeDev.js");console.warn("Trying to load DescopeDev.js from",t);const n=document.createElement("script");if(n.src=t,document.body.appendChild(n),await new Promise(((e,t)=>{n.onload=e,n.onerror=t})),globalThis.DescopeDev){const{themeToStyle:e,defaultTheme:t,darkTheme:n}=globalThis.DescopeDev;return{light:e(t),dark:e(n)}}})();t&&(e.light.components=Object.assign(Object.assign({},e.light.components),t.light.components),e.dark.components=Object.assign(Object.assign({},e.dark.components),t.dark.components),this.logger.warn("Theme was merged successfully"),console.log("%cNOTICE! This is not the theme that will be used in production!\n\nMake sure to test it without the override UI components URL!","color: black; background-color:yellow; font-size: x-large"))}catch(e){this.logger.error("Failed to merge UI components theme\n",e)}return e}catch(e){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}},h=function(){return i(this,c,"f")||(o(this,c,i(this,t,"m",u).call(this),"f"),i(this,c,"f").then((e=>this.logger.debug("Fetched theme",e)))),i(this,c,"f")},p=async function(){var e,r;const s=await i(this,t,"a",h);if(!s)return;const a=((null===(e=null==s?void 0:s.light)||void 0===e?void 0:e.globals)||"")+((null===(r=null==s?void 0:s.dark)||void 0===r?void 0:r.globals)||"");i(this,n,"f")?i(this,n,"f").replaceSync(a):o(this,n,this.injectStyle(a,{prepend:!0}),"f")},f=async function(){const e=this.tenantId;if(e)try{const{body:t}=await this.fetchStaticResource(`${e}/theme.json`,"json");return t}catch(e){this.logger.error("Cannot fetch tenant theme file","make sure that your tenantId, projectId & flowId are correct")}},g=function(){return i(this,d,"f")||o(this,d,i(this,t,"m",f).call(this),"f"),i(this,d,"f")},v=async function(){var e,n,r,a;if(!this.tenantId)return void(null===(e=i(this,s,"f"))||void 0===e||e.replaceSync(""));const l=await i(this,t,"a",g);if(!l)return void(null===(n=i(this,s,"f"))||void 0===n||n.replaceSync(""));const c=((null===(r=l.light)||void 0===r?void 0:r.globals)||"")+((null===(a=l.dark)||void 0===a?void 0:a.globals)||"");i(this,s,"f")?i(this,s,"f").replaceSync(c):o(this,s,this.injectStyle(c),"f")},m=async function(){var e;if(!this.themeOverride)return void(null===(e=i(this,a,"f"))||void 0===e||e.replaceSync(""));const n=i(this,t,"m",l).call(this);i(this,a,"f")?i(this,a,"f").replaceSync(n):o(this,a,this.injectStyle(n),"f")},w=async function(){var e,n,o,r;const s=await i(this,t,"a",h);if(!s)return;const a=await this.descopeUi;if(!(null==a?void 0:a.componentsThemeManager))return;const l=await i(this,t,"a",g);a.componentsThemeManager.themes={light:ye((null===(e=null==s?void 0:s.light)||void 0===e?void 0:e.components)||{},(null===(n=null==l?void 0:l.light)||void 0===n?void 0:n.components)||{}),dark:ye((null===(o=null==s?void 0:s.dark)||void 0===o?void 0:o.components)||{},(null===(r=null==l?void 0:l.dark)||void 0===r?void 0:r.components)||{})}},b=async function(){var e,t;const{projectConfig:n}=await this.config||{},i=null===(e=null==n?void 0:n.styles)||void 0===e?void 0:e[this.styleId],o=null==n?void 0:n.cssTemplate,r=i||o;return null===(t=null==r?void 0:r[this.theme])||void 0===t?void 0:t.fonts},y=async function(){const e=await i(this,t,"m",b).call(this);e?Object.values(e).forEach((e=>{e.url&&(this.logger.debug(`Loading font from URL "${e.url}"`),(e=>{const t=document.createElement("link");t.href=e,t.rel="stylesheet",document.head.appendChild(t)})(e.url))})):this.logger.debug("No fonts to load")},k=async function(){this.rootElement.setAttribute("data-theme",this.theme);const e=await this.descopeUi;(null==e?void 0:e.componentsThemeManager)&&(e.componentsThemeManager.currentThemeName=this.theme)},I=function(){i(this,t,"m",y).call(this),i(this,t,"m",k).call(this)},E}));var Ae=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),xe=()=>Math.random().toString(36).substring(7).split("").join("."),Oe={INIT:`@@redux/INIT${xe()}`,REPLACE:`@@redux/REPLACE${xe()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${xe()}`};function Ee(e){if("object"!=typeof e||null===e)return!1;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||null===Object.getPrototypeOf(e)}function je(e){if(void 0===e)return"undefined";if(null===e)return"null";const t=typeof e;switch(t){case"boolean":case"string":case"number":case"symbol":case"function":return t}if(Array.isArray(e))return"array";if(function(e){return e instanceof Date||"function"==typeof e.toDateString&&"function"==typeof e.getDate&&"function"==typeof e.setDate}(e))return"date";if(function(e){return e instanceof Error||"string"==typeof e.message&&e.constructor&&"number"==typeof e.constructor.stackTraceLimit}(e))return"error";const n=function(e){return"function"==typeof e.constructor?e.constructor.name:null}(e);switch(n){case"Symbol":case"Promise":case"WeakMap":case"WeakSet":case"Map":case"Set":return n}return Object.prototype.toString.call(e).slice(8,-1).toLowerCase().replace(/\s/g,"")}function Re(e){let t=typeof e;return t=je(e),t}function Te(e,t,n){if("function"!=typeof e)throw new Error(`Expected the root reducer to be a function. Instead, received: '${Re(e)}'`);if("function"==typeof t&&"function"==typeof n||"function"==typeof n&&"function"==typeof arguments[3])throw new Error("It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.");if("function"==typeof t&&void 0===n&&(n=t,t=void 0),void 0!==n){if("function"!=typeof n)throw new Error(`Expected the enhancer to be a function. Instead, received: '${Re(n)}'`);return n(Te)(e,t)}let i=e,o=t,r=new Map,s=r,a=0,l=!1;function c(){s===r&&(s=new Map,r.forEach(((e,t)=>{s.set(t,e)})))}function d(){if(l)throw new Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return o}function u(e){if("function"!=typeof e)throw new Error(`Expected the listener to be a function. Instead, received: '${Re(e)}'`);if(l)throw new Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");let t=!0;c();const n=a++;return s.set(n,e),function(){if(t){if(l)throw new Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");t=!1,c(),s.delete(n),r=null}}}function h(e){if(!Ee(e))throw new Error(`Actions must be plain objects. Instead, the actual type was: '${Re(e)}'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.`);if(void 0===e.type)throw new Error('Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');if("string"!=typeof e.type)throw new Error(`Action "type" property must be a string. Instead, the actual type was: '${Re(e.type)}'. Value was: '${e.type}' (stringified)`);if(l)throw new Error("Reducers may not dispatch actions.");try{l=!0,o=i(o,e)}finally{l=!1}return(r=s).forEach((e=>{e()})),e}h({type:Oe.INIT});return{dispatch:h,subscribe:u,getState:d,replaceReducer:function(e){if("function"!=typeof e)throw new Error(`Expected the nextReducer to be a function. Instead, received: '${Re(e)}`);i=e,h({type:Oe.REPLACE})},[Ae]:function(){const e=u;return{subscribe(t){if("object"!=typeof t||null===t)throw new Error(`Expected the observer to be an object. Instead, received: '${Re(t)}'`);function n(){const e=t;e.next&&e.next(d())}n();return{unsubscribe:e(n)}},[Ae](){return this}}}}}function Me(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}function Ue(e){const t=Object.keys(e),n={};for(let i=0;i<t.length;i++){const o=t[i];void 0===e[o]&&Me(`No reducer provided for key "${o}"`),"function"==typeof e[o]&&(n[o]=e[o])}const i=Object.keys(n);let o,r;o={};try{!function(e){Object.keys(e).forEach((t=>{const n=e[t];if(void 0===n(void 0,{type:Oe.INIT}))throw new Error(`The slice reducer for key "${t}" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);if(void 0===n(void 0,{type:Oe.PROBE_UNKNOWN_ACTION()}))throw new Error(`The slice reducer for key "${t}" returned undefined when probed with a random type. Don't try to handle '${Oe.INIT}' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.`)}))}(n)}catch(e){r=e}return function(e={},t){if(r)throw r;{const i=function(e,t,n,i){const o=Object.keys(t),r=n&&n.type===Oe.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(0===o.length)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!Ee(e))return`The ${r} has unexpected type of "${Re(e)}". Expected argument to be an object with the following keys: "${o.join('", "')}"`;const s=Object.keys(e).filter((e=>!t.hasOwnProperty(e)&&!i[e]));return s.forEach((e=>{i[e]=!0})),n&&n.type===Oe.REPLACE?void 0:s.length>0?`Unexpected ${s.length>1?"keys":"key"} "${s.join('", "')}" found in ${r}. Expected to find one of the known reducer keys instead: "${o.join('", "')}". Unexpected keys will be ignored.`:void 0}(e,n,t,o);i&&Me(i)}let s=!1;const a={};for(let o=0;o<i.length;o++){const r=i[o],l=n[r],c=e[r],d=l(c,t);if(void 0===d){const e=t&&t.type;throw new Error(`When called with an action of type ${e?`"${String(e)}"`:"(unknown type)"}, the slice reducer for key "${r}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`)}a[r]=d,s=s||d!==c}return s=s||i.length!==Object.keys(e).length,s?a:e}}function We(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...n)=>e(t(...n))))}function $e(e){return Ee(e)&&"type"in e&&"string"==typeof e.type}var Pe=Symbol.for("immer-nothing"),_e=Symbol.for("immer-draftable"),Le=Symbol.for("immer-state"),Ne=[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}];function De(e,...t){{const n=Ne[e],i="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${i}`)}}var Fe=Object.getPrototypeOf;function qe(e){return!!e&&!!e[Le]}function ze(e){return!!e&&(He(e)||Array.isArray(e)||!!e[_e]||!!e.constructor?.[_e]||Xe(e)||Ge(e))}var Ve=Object.prototype.constructor.toString();function He(e){if(!e||"object"!=typeof e)return!1;const t=Fe(e);if(null===t)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object||"function"==typeof n&&Function.toString.call(n)===Ve}function Be(e,t){0===Je(e)?Object.entries(e).forEach((([n,i])=>{t(n,i,e)})):e.forEach(((n,i)=>t(i,n,e)))}function Je(e){const t=e[Le];return t?t.type_:Array.isArray(e)?1:Xe(e)?2:Ge(e)?3:0}function Ke(e,t){return 2===Je(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Ze(e,t,n){const i=Je(e);2===i?e.set(t,n):3===i?e.add(n):e[t]=n}function Xe(e){return e instanceof Map}function Ge(e){return e instanceof Set}function Ye(e){return e.copy_||e.base_}function Qe(e,t){if(Xe(e))return new Map(e);if(Ge(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&He(e)){if(!Fe(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const n=Object.getOwnPropertyDescriptors(e);delete n[Le];let i=Reflect.ownKeys(n);for(let t=0;t<i.length;t++){const o=i[t],r=n[o];!1===r.writable&&(r.writable=!0,r.configurable=!0),(r.get||r.set)&&(n[o]={configurable:!0,writable:!0,enumerable:r.enumerable,value:e[o]})}return Object.create(Fe(e),n)}function et(e,t=!1){return nt(e)||qe(e)||!ze(e)||(Je(e)>1&&(e.set=e.add=e.clear=e.delete=tt),Object.freeze(e),t&&Be(e,((e,t)=>et(t,!0)))),e}function tt(){De(2)}function nt(e){return Object.isFrozen(e)}var it,ot={};function rt(e){const t=ot[e];return t||De(0,e),t}function st(){return it}function at(e,t){t&&(rt("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function lt(e){ct(e),e.drafts_.forEach(ut),e.drafts_=null}function ct(e){e===it&&(it=e.parent_)}function dt(e){return it={drafts_:[],parent_:it,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function ut(e){const t=e[Le];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function ht(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[Le].modified_&&(lt(t),De(4)),ze(e)&&(e=pt(t,e),t.parent_||gt(t,e)),t.patches_&&rt("Patches").generateReplacementPatches_(n[Le].base_,e,t.patches_,t.inversePatches_)):e=pt(t,n,[]),lt(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Pe?e:void 0}function pt(e,t,n){if(nt(t))return t;const i=t[Le];if(!i)return Be(t,((o,r)=>ft(e,i,t,o,r,n))),t;if(i.scope_!==e)return t;if(!i.modified_)return gt(e,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const t=i.copy_;let o=t,r=!1;3===i.type_&&(o=new Set(t),t.clear(),r=!0),Be(o,((o,s)=>ft(e,i,t,o,s,n,r))),gt(e,t,!1),n&&e.patches_&&rt("Patches").generatePatches_(i,n,e.patches_,e.inversePatches_)}return i.copy_}function ft(e,t,n,i,o,r,s){if(o===n&&De(5),qe(o)){const s=pt(e,o,r&&t&&3!==t.type_&&!Ke(t.assigned_,i)?r.concat(i):void 0);if(Ze(n,i,s),!qe(s))return;e.canAutoFreeze_=!1}else s&&n.add(o);if(ze(o)&&!nt(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;pt(e,o),t&&t.scope_.parent_||gt(e,o)}}function gt(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&et(t,n)}var vt={get(e,t){if(t===Le)return e;const n=Ye(e);if(!Ke(n,t))return function(e,t,n){const i=bt(t,n);return i?"value"in i?i.value:i.get?.call(e.draft_):void 0}(e,n,t);const i=n[t];return e.finalized_||!ze(i)?i:i===wt(e.base_,t)?(kt(e),e.copy_[t]=St(i,e)):i},has:(e,t)=>t in Ye(e),ownKeys:e=>Reflect.ownKeys(Ye(e)),set(e,t,n){const i=bt(Ye(e),t);if(i?.set)return i.set.call(e.draft_,n),!0;if(!e.modified_){const i=wt(Ye(e),t),o=i?.[Le];if(o&&o.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}(n,i)&&(void 0!==n||Ke(e.base_,t)))return!0;kt(e),yt(e)}return e.copy_[t]===n&&(void 0!==n||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty:(e,t)=>(void 0!==wt(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,kt(e),yt(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=Ye(e),i=Reflect.getOwnPropertyDescriptor(n,t);return i?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:i.enumerable,value:n[t]}:i},defineProperty(){De(11)},getPrototypeOf:e=>Fe(e.base_),setPrototypeOf(){De(12)}},mt={};function wt(e,t){const n=e[Le];return(n?Ye(n):e)[t]}function bt(e,t){if(!(t in e))return;let n=Fe(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=Fe(n)}}function yt(e){e.modified_||(e.modified_=!0,e.parent_&&yt(e.parent_))}function kt(e){e.copy_||(e.copy_=Qe(e.base_,e.scope_.immer_.useStrictShallowCopy_))}Be(vt,((e,t)=>{mt[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),mt.deleteProperty=function(e,t){return isNaN(parseInt(t))&&De(13),mt.set.call(this,e,t,void 0)},mt.set=function(e,t,n){return"length"!==t&&isNaN(parseInt(t))&&De(14),vt.set.call(this,e[0],t,n,e[0])};function St(e,t){const n=Xe(e)?rt("MapSet").proxyMap_(e,t):Ge(e)?rt("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),i={type_:n?1:0,scope_:t?t.scope_:st(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let o=i,r=vt;n&&(o=[i],r=mt);const{revoke:s,proxy:a}=Proxy.revocable(o,r);return i.draft_=a,i.revoke_=s,a}(e,t);return(t?t.scope_:st()).drafts_.push(n),n}function It(e){return qe(e)||De(10,e),Ct(e)}function Ct(e){if(!ze(e)||nt(e))return e;const t=e[Le];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Qe(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Qe(e,!0);return Be(n,((e,t)=>{Ze(n,e,Ct(t))})),t&&(t.finalized_=!1),n}var At=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,t,n)=>{if("function"==typeof e&&"function"!=typeof t){const n=t;t=e;const i=this;return function(e=n,...o){return i.produce(e,(e=>t.call(this,e,...o)))}}let i;if("function"!=typeof t&&De(6),void 0!==n&&"function"!=typeof n&&De(7),ze(e)){const o=dt(this),r=St(e,void 0);let s=!0;try{i=t(r),s=!1}finally{s?lt(o):ct(o)}return at(o,n),ht(i,o)}if(!e||"object"!=typeof e){if(i=t(e),void 0===i&&(i=e),i===Pe&&(i=void 0),this.autoFreeze_&&et(i,!0),n){const t=[],o=[];rt("Patches").generateReplacementPatches_(e,i,t,o),n(t,o)}return i}De(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...n)=>this.produceWithPatches(t,(t=>e(t,...n)));let n,i;const o=this.produce(e,t,((e,t)=>{n=e,i=t}));return[o,n,i]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){ze(e)||De(8),qe(e)&&(e=It(e));const t=dt(this),n=St(e,void 0);return n[Le].isManual_=!0,ct(t),n}finishDraft(e,t){const n=e&&e[Le];n&&n.isManual_||De(9);const{scope_:i}=n;return at(i,t),ht(void 0,i)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const i=t[n];if(0===i.path.length&&"replace"===i.op){e=i.value;break}}n>-1&&(t=t.slice(n+1));const i=rt("Patches").applyPatches_;return qe(e)?i(e,t):this.produce(e,(e=>i(e,t)))}},xt=At.produce;At.produceWithPatches.bind(At),At.setAutoFreeze.bind(At),At.setUseStrictShallowCopy.bind(At),At.applyPatches.bind(At),At.createDraft.bind(At),At.finishDraft.bind(At);var Ot=(e,t,n)=>{if(1===t.length&&t[0]===n){let t=!1;try{const n={};e(n)===n&&(t=!0)}catch{}if(t){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("The result function returned its own inputs without modification. e.g\n`createSelector([state => state.todos], todos => todos)`\nThis could lead to inefficient memoization and unnecessary re-renders.\nEnsure transformation logic is in the result function, and extraction logic is in the input selectors.",{stack:e})}}},Et=(e,t,n)=>{const{memoize:i,memoizeOptions:o}=t,{inputSelectorResults:r,inputSelectorResultsCopy:s}=e,a=i((()=>({})),...o);if(!(a.apply(null,r)===a.apply(null,s))){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("An input selector returned a different result when passed same arguments.\nThis means your output selector will likely run more frequently than intended.\nAvoid returning a new reference inside your input selector, e.g.\n`createSelector([state => state.todos.map(todo => todo.id)], todoIds => todoIds.length)`",{arguments:n,firstInputs:r,secondInputs:s,stack:e})}},jt={inputStabilityCheck:"once",identityFunctionCheck:"once"};var Rt=e=>Array.isArray(e)?e:[e];function Tt(e){const t=Array.isArray(e[0])?e[0]:e;return function(e,t="expected all items to be functions, instead received the following types: "){if(!e.every((e=>"function"==typeof e))){const n=e.map((e=>"function"==typeof e?`function ${e.name||"unnamed"}()`:typeof e)).join(", ");throw new TypeError(`${t}[${n}]`)}}(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function Mt(e,t){const n=[],{length:i}=e;for(let o=0;o<i;o++)n.push(e[o].apply(null,t));return n}var Ut="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}},Wt=0,$t=1;function Pt(){return{s:Wt,v:void 0,o:null,p:null}}function _t(e,t={}){let n=Pt();const{resultEqualityCheck:i}=t;let o,r=0;function s(){let t=n;const{length:s}=arguments;for(let e=0,n=s;e<n;e++){const n=arguments[e];if("function"==typeof n||"object"==typeof n&&null!==n){let e=t.o;null===e&&(t.o=e=new WeakMap);const i=e.get(n);void 0===i?(t=Pt(),e.set(n,t)):t=i}else{let e=t.p;null===e&&(t.p=e=new Map);const i=e.get(n);void 0===i?(t=Pt(),e.set(n,t)):t=i}}const a=t;let l;if(t.s===$t)l=t.v;else if(l=e.apply(null,arguments),r++,i){const e=o?.deref?.()??o;null!=e&&i(e,l)&&(l=e,0!==r&&r--);o="object"==typeof l&&null!==l||"function"==typeof l?new Ut(l):l}return a.s=$t,a.v=l,l}return s.clearCache=()=>{n=Pt(),s.resetResultsCount()},s.resultsCount=()=>r,s.resetResultsCount=()=>{r=0},s}function Lt(e,...t){const n="function"==typeof e?{memoize:e,memoizeOptions:t}:e,i=(...e)=>{let t,i=0,o=0,r={},s=e.pop();"object"==typeof s&&(r=s,s=e.pop()),function(e,t="expected a function, instead received "+typeof e){if("function"!=typeof e)throw new TypeError(t)}(s,`createSelector expects an output function after the inputs, but received: [${typeof s}]`);const a={...n,...r},{memoize:l,memoizeOptions:c=[],argsMemoize:d=_t,argsMemoizeOptions:u=[],devModeChecks:h={}}=a,p=Rt(c),f=Rt(u),g=Tt(e),v=l((function(){return i++,s.apply(null,arguments)}),...p);let m=!0;const w=d((function(){o++;const e=Mt(g,arguments);t=v.apply(null,e);{const{identityFunctionCheck:n,inputStabilityCheck:i}=((e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:i}={...jt,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:Ot},inputStabilityCheck:{shouldRun:"always"===i||"once"===i&&e,run:Et}}})(m,h);if(n.shouldRun&&n.run(s,e,t),i.shouldRun){const t=Mt(g,arguments);i.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:l,memoizeOptions:p},arguments)}m&&(m=!1)}return t}),...f);return Object.assign(w,{resultFunc:s,memoizedResultFunc:v,dependencies:g,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>t,recomputations:()=>i,resetRecomputations:()=>{i=0},memoize:l,argsMemoize:d})};return Object.assign(i,{withTypes:()=>i}),i}var Nt=Lt(_t),Dt=Object.assign(((e,t=Nt)=>{!function(e,t="expected an object, instead received "+typeof e){if("object"!=typeof e)throw new TypeError(t)}(e,"createStructuredSelector expects first argument to be an object where each property is a selector, instead received a "+typeof e);const n=Object.keys(e),i=t(n.map((t=>e[t])),((...e)=>e.reduce(((e,t,i)=>(e[n[i]]=t,e)),{})));return i}),{withTypes:()=>Dt});function Ft(e){return({dispatch:t,getState:n})=>i=>o=>"function"==typeof o?o(t,n,e):i(o)}var qt=Ft(),zt=Ft;((...e)=>{const t=Lt(...e)})(_t);var Vt="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?We:We.apply(null,arguments)},Ht=e=>e&&"function"==typeof e.match;function Bt(e,t){function n(...n){if(t){let i=t(...n);if(!i)throw new Error("prepareAction did not return an object");return{type:e,payload:i.payload,..."meta"in i&&{meta:i.meta},..."error"in i&&{error:i.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>$e(t)&&t.type===e,n}function Jt(e){return"function"==typeof e&&"type"in e&&Ht(e)}function Kt(e,t){let n=0;return{measureTime(e){const t=Date.now();try{return e()}finally{const e=Date.now();n+=e-t}},warnIfExceeded(){n>e&&console.warn(`${t} took ${n}ms, which is more than the warning threshold of ${e}ms. \nIf your state or actions are very large, you may want to disable the middleware as it might cause too much of a slowdown in development mode. See https://redux-toolkit.js.org/api/getDefaultMiddleware for instructions.\nIt is disabled in production builds, so you don't need to worry about that.`)}}}var Zt=class e extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,e.prototype)}static get[Symbol.species](){return e}concat(...e){return super.concat.apply(this,e)}prepend(...t){return 1===t.length&&Array.isArray(t[0])?new e(...t[0].concat(this)):new e(...t.concat(this))}};function Xt(e){return ze(e)?xt(e,(()=>{})):e}function Gt(e,t,n){if(e.has(t)){let i=e.get(t);return n.update&&(i=n.update(i,t,e),e.set(t,i)),i}if(!n.insert)throw new Error("No insert provided for key not already in map");const i=n.insert(t,e);return e.set(t,i),i}function Yt(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function Qt(e,t,n){const i=en(e,t,n);return{detectMutations:()=>tn(e,t,i,n)}}function en(e,t=[],n,i="",o=new Set){const r={value:n};if(!e(n)&&!o.has(n)){o.add(n),r.children={};for(const o in n){const s=i?i+"."+o:o;t.length&&-1!==t.indexOf(s)||(r.children[o]=en(e,t,n[o],s))}}return r}function tn(e,t=[],n,i,o=!1,r=""){const s=n?n.value:void 0,a=s===i;if(o&&!a&&!Number.isNaN(i))return{wasMutated:!0,path:r};if(e(s)||e(i))return{wasMutated:!1};const l={};for(let e in n.children)l[e]=!0;for(let e in i)l[e]=!0;const c=t.length>0;for(let o in l){const s=r?r+"."+o:o;if(c){if(t.some((e=>e instanceof RegExp?e.test(s):s===e)))continue}const l=tn(e,t,n.children[o],i[o],a,s);if(l.wasMutated)return l}return{wasMutated:!1}}function nn(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||Ee(e)}function on(e,t="",n=nn,i,o=[],r){let s;if(!n(e))return{keyPath:t||"<root>",value:e};if("object"!=typeof e||null===e)return!1;if(r?.has(e))return!1;const a=null!=i?i(e):Object.entries(e),l=o.length>0;for(const[e,c]of a){const a=t?t+"."+e:e;if(l){if(o.some((e=>e instanceof RegExp?e.test(a):a===e)))continue}if(!n(c))return{keyPath:a,value:c};if("object"==typeof c&&(s=on(c,a,n,i,o,r),s))return s}return r&&rn(e)&&r.add(e),!1}function rn(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!rn(t))return!1;return!0}function sn(e){return"boolean"==typeof e}var an=()=>function(e){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:i=!0,actionCreatorCheck:o=!0}=e??{};let r=new Zt;if(t&&(sn(t)?r.push(qt):r.push(zt(t.extraArgument))),n){let e={};sn(n)||(e=n),r.unshift(function(e={}){{let t=function(e,t,i,o){return JSON.stringify(e,n(t,o),i)},n=function(e,t){let n=[],i=[];return t||(t=function(e,t){return n[0]===t?"[Circular ~]":"[Circular ~."+i.slice(0,n.indexOf(t)).join(".")+"]"}),function(o,r){if(n.length>0){var s=n.indexOf(this);~s?n.splice(s+1):n.push(this),~s?i.splice(s,1/0,o):i.push(o),~n.indexOf(r)&&(r=t.call(this,o,r))}else n.push(r);return null==e?r:e.call(this,o,r)}},{isImmutable:i=Yt,ignoredPaths:o,warnAfter:r=32}=e;const s=Qt.bind(null,i,o);return({getState:e})=>{let n,i=e(),o=s(i);return a=>l=>{const c=Kt(r,"ImmutableStateInvariantMiddleware");c.measureTime((()=>{if(i=e(),n=o.detectMutations(),o=s(i),n.wasMutated)throw new Error(`A state mutation was detected between dispatches, in the path '${n.path||""}'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)}));const d=a(l);return c.measureTime((()=>{if(i=e(),n=o.detectMutations(),o=s(i),n.wasMutated)throw new Error(`A state mutation was detected inside a dispatch, in the path: ${n.path||""}. Take a look at the reducer(s) handling the action ${t(l)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)})),c.warnIfExceeded(),d}}}}(e))}if(i){let e={};sn(i)||(e=i),r.push(function(e={}){{const{isSerializable:t=nn,getEntries:n,ignoredActions:i=[],ignoredActionPaths:o=["meta.arg","meta.baseQueryMeta"],ignoredPaths:r=[],warnAfter:s=32,ignoreState:a=!1,ignoreActions:l=!1,disableCache:c=!1}=e,d=!c&&WeakSet?new WeakSet:void 0;return e=>c=>u=>{if(!$e(u))return c(u);const h=c(u),p=Kt(s,"SerializableStateInvariantMiddleware");return l||i.length&&-1!==i.indexOf(u.type)||p.measureTime((()=>{const e=on(u,"",t,n,o,d);if(e){const{keyPath:t,value:n}=e;console.error(`A non-serializable value was detected in an action, in the path: \`${t}\`. Value:`,n,"\nTake a look at the logic that dispatched this action: ",u,"\n(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)","\n(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)")}})),a||(p.measureTime((()=>{const i=on(e.getState(),"",t,n,r,d);if(i){const{keyPath:e,value:t}=i;console.error(`A non-serializable value was detected in the state, in the path: \`${e}\`. Value:`,t,`\nTake a look at the reducer(s) handling this action type: ${u.type}.\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)`)}})),p.warnIfExceeded()),h}}}(e))}if(o){let e={};sn(o)||(e=o),r.unshift(function(e={}){const{isActionCreator:t=Jt}=e;return()=>e=>n=>(t(n)&&console.warn(function(e){const t=e?`${e}`.split("/"):[],n=t[t.length-1]||"actionCreator";return`Detected an action creator with type "${e||"unknown"}" being dispatched. \nMake sure you're calling the action creator before dispatching, i.e. \`dispatch(${n}())\` instead of \`dispatch(${n})\`. This is necessary even if the action has no payload.`}(n.type)),e(n))}(e))}return r},ln=e=>t=>{setTimeout(t,e)},cn="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:ln(10),dn=e=>function(t){const{autoBatch:n=!0}=t??{};let i=new Zt(e);return n&&i.push(((e={type:"raf"})=>t=>(...n)=>{const i=t(...n);let o=!0,r=!1,s=!1;const a=new Set,l="tick"===e.type?queueMicrotask:"raf"===e.type?cn:"callback"===e.type?e.queueNotification:ln(e.timeout),c=()=>{s=!1,r&&(r=!1,a.forEach((e=>e())))};return Object.assign({},i,{subscribe(e){const t=i.subscribe((()=>o&&e()));return a.add(e),()=>{t(),a.delete(e)}},dispatch(e){try{return o=!e?.meta?.RTK_autoBatch,r=!o,r&&(s||(s=!0,l(c))),i.dispatch(e)}finally{o=!0}}})})("object"==typeof n?n:void 0)),i};function un(e){const t=an(),{reducer:n,middleware:i,devTools:o=!0,preloadedState:r,enhancers:s}=e||{};let a,l;if("function"==typeof n)a=n;else{if(!Ee(n))throw new Error("`reducer` is a required argument, and must be a function or an object of functions that can be passed to combineReducers");a=Ue(n)}if(i&&"function"!=typeof i)throw new Error("`middleware` field must be a callback");if("function"==typeof i){if(l=i(t),!Array.isArray(l))throw new Error("when using a middleware builder function, an array of middleware must be returned")}else l=t();if(l.some((e=>"function"!=typeof e)))throw new Error("each middleware provided to configureStore must be a function");let c=We;o&&(c=Vt({trace:!0,..."object"==typeof o&&o}));const d=function(...e){return t=>(n,i)=>{const o=t(n,i);let r=()=>{throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")};const s={getState:o.getState,dispatch:(e,...t)=>r(e,...t)},a=e.map((e=>e(s)));return r=We(...a)(o.dispatch),{...o,dispatch:r}}}(...l),u=dn(d);if(s&&"function"!=typeof s)throw new Error("`enhancers` field must be a callback");let h="function"==typeof s?s(u):u();if(!Array.isArray(h))throw new Error("`enhancers` callback must return an array");if(h.some((e=>"function"!=typeof e)))throw new Error("each enhancer provided to configureStore must be a function");l.length&&!h.includes(d)&&console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`");return Te(a,r,c(...h))}function hn(e){const t={},n=[];let i;const o={addCase(e,r){if(n.length>0)throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");if(i)throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`");const s="string"==typeof e?e:e.type;if(!s)throw new Error("`builder.addCase` cannot be called with an empty action type");if(s in t)throw new Error(`\`builder.addCase\` cannot be called with two reducers for the same action type '${s}'`);return t[s]=r,o},addMatcher(e,t){if(i)throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return n.push({matcher:e,reducer:t}),o},addDefaultCase(e){if(i)throw new Error("`builder.addDefaultCase` can only be called once");return i=e,o}};return e(o),[t,n,i]}function pn(...e){return t=>e.some((e=>((e,t)=>Ht(e)?e.match(t):e(t))(e,t)))}var fn=["name","message","stack","code"],gn=class{constructor(e,t){this.payload=e,this.meta=t}_type},vn=class{constructor(e,t){this.payload=e,this.meta=t}_type},mn=e=>{if("object"==typeof e&&null!==e){const t={};for(const n of fn)"string"==typeof e[n]&&(t[n]=e[n]);return t}return{message:String(e)}},wn=(()=>{function e(e,t,n){const i=Bt(e+"/fulfilled",((e,t,n,i)=>({payload:e,meta:{...i||{},arg:n,requestId:t,requestStatus:"fulfilled"}}))),o=Bt(e+"/pending",((e,t,n)=>({payload:void 0,meta:{...n||{},arg:t,requestId:e,requestStatus:"pending"}}))),r=Bt(e+"/rejected",((e,t,i,o,r)=>({payload:o,error:(n&&n.serializeError||mn)(e||"Rejected"),meta:{...r||{},arg:i,requestId:t,rejectedWithValue:!!o,requestStatus:"rejected",aborted:"AbortError"===e?.name,condition:"ConditionError"===e?.name}})));return Object.assign((function(e){return(s,a,l)=>{const c=n?.idGenerator?n.idGenerator(e):((e=21)=>{let t="",n=e;for(;n--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t})(),d=new AbortController;let u;function h(e){u=e,d.abort()}const p=async function(){let p;try{let r=n?.condition?.(e,{getState:a,extra:l});if(null!==(f=r)&&"object"==typeof f&&"function"==typeof f.then&&(r=await r),!1===r||d.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};const g=new Promise(((e,t)=>d.signal.addEventListener("abort",(()=>t({name:"AbortError",message:u||"Aborted"})))));s(o(c,e,n?.getPendingMeta?.({requestId:c,arg:e},{getState:a,extra:l}))),p=await Promise.race([g,Promise.resolve(t(e,{dispatch:s,getState:a,extra:l,requestId:c,signal:d.signal,abort:h,rejectWithValue:(e,t)=>new gn(e,t),fulfillWithValue:(e,t)=>new vn(e,t)})).then((t=>{if(t instanceof gn)throw t;return t instanceof vn?i(t.payload,c,e,t.meta):i(t,c,e)}))])}catch(t){p=t instanceof gn?r(null,c,e,t.payload,t.meta):r(t,c,e)}var f;return n&&!n.dispatchConditionRejection&&r.match(p)&&p.meta.condition||s(p),p}();return Object.assign(p,{abort:h,requestId:c,arg:e,unwrap:()=>p.then(bn)})}}),{pending:o,rejected:r,fulfilled:i,settled:pn(r,i),typePrefix:e})}return e.withTypes=()=>e,e})();function bn(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}var yn=Symbol.for("rtk-slice-createasyncthunk");function kn(e,t){return`${e}/${t}`}function Sn(e,t,n,i){function o(o,...r){let s=n.call(e,o);if(void 0===s){if(!i)throw new Error("selectState returned undefined for an uninjected slice reducer");s=e.getInitialState()}return t(s,...r)}return o.unwrapped=t,o}var In=function({creators:e}={}){const t=e?.asyncThunk?.[yn];return function(e){const{name:n,reducerPath:i=n}=e;if(!n)throw new Error("`name` is a required option for createSlice");"undefined"!=typeof process&&void 0===e.initialState&&console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");const o=("function"==typeof e.reducers?e.reducers(function(){function e(e,t){return{_reducerDefinitionType:"asyncThunk",payloadCreator:e,...t}}return e.withTypes=()=>e,{reducer:e=>Object.assign({[e.name]:(...t)=>e(...t)}[e.name],{_reducerDefinitionType:"reducer"}),preparedReducer:(e,t)=>({_reducerDefinitionType:"reducerWithPrepare",prepare:e,reducer:t}),asyncThunk:e}}()):e.reducers)||{},r=Object.keys(o),s={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},a={addCase(e,t){const n="string"==typeof e?e:e.type;if(!n)throw new Error("`context.addCase` cannot be called with an empty action type");if(n in s.sliceCaseReducersByType)throw new Error("`context.addCase` cannot be called with two reducers for the same action type: "+n);return s.sliceCaseReducersByType[n]=t,a},addMatcher:(e,t)=>(s.sliceMatchers.push({matcher:e,reducer:t}),a),exposeAction:(e,t)=>(s.actionCreators[e]=t,a),exposeCaseReducer:(e,t)=>(s.sliceCaseReducersByName[e]=t,a)};function l(){if("object"==typeof e.extraReducers)throw new Error("The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");const[t={},n=[],i]="function"==typeof e.extraReducers?hn(e.extraReducers):[e.extraReducers],o={...t,...s.sliceCaseReducersByType};return function(e,t){if("object"==typeof t)throw new Error("The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");let n,[i,o,r]=hn(t);if(function(e){return"function"==typeof e}(e))n=()=>Xt(e());else{const t=Xt(e);n=()=>t}function s(e=n(),t){let s=[i[t.type],...o.filter((({matcher:e})=>e(t))).map((({reducer:e})=>e))];return 0===s.filter((e=>!!e)).length&&(s=[r]),s.reduce(((e,n)=>{if(n){if(qe(e)){const i=n(e,t);return void 0===i?e:i}if(ze(e))return xt(e,(e=>n(e,t)));{const i=n(e,t);if(void 0===i){if(null===e)return e;throw new Error("A case reducer on a non-draftable value must not return undefined")}return i}}return e}),e)}return s.getInitialState=n,s}(e.initialState,(e=>{for(let t in o)e.addCase(t,o[t]);for(let t of s.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);i&&e.addDefaultCase(i)}))}r.forEach((i=>{const r=o[i],s={reducerName:i,type:kn(n,i),createNotation:"function"==typeof e.reducers};!function(e){return"asyncThunk"===e._reducerDefinitionType}(r)?function({type:e,reducerName:t,createNotation:n},i,o){let r,s;if("reducer"in i){if(n&&!function(e){return"reducerWithPrepare"===e._reducerDefinitionType}(i))throw new Error("Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");r=i.reducer,s=i.prepare}else r=i;o.addCase(e,r).exposeCaseReducer(t,r).exposeAction(t,s?Bt(e,s):Bt(e))}(s,r,a):function({type:e,reducerName:t},n,i,o){if(!o)throw new Error("Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");const{payloadCreator:r,fulfilled:s,pending:a,rejected:l,settled:c,options:d}=n,u=o(e,r,d);i.exposeAction(t,u),s&&i.addCase(u.fulfilled,s);a&&i.addCase(u.pending,a);l&&i.addCase(u.rejected,l);c&&i.addMatcher(u.settled,c);i.exposeCaseReducer(t,{fulfilled:s||Cn,pending:a||Cn,rejected:l||Cn,settled:c||Cn})}(s,r,a,t)}));const c=e=>e,d=new WeakMap;let u;const h={name:n,reducerPath:i,reducer:(e,t)=>(u||(u=l()),u(e,t)),actions:s.actionCreators,caseReducers:s.sliceCaseReducersByName,getInitialState:()=>(u||(u=l()),u.getInitialState()),getSelectors(t=c){const n=Gt(d,this,{insert:()=>new WeakMap});return Gt(n,t,{insert:()=>{const n={};for(const[i,o]of Object.entries(e.selectors??{}))n[i]=Sn(this,o,t,this!==h);return n}})},selectSlice(e){let t=e[this.reducerPath];if(void 0===t){if(this===h)throw new Error("selectSlice returned undefined for an uninjected slice reducer");t=this.getInitialState()}return t},get selectors(){return this.getSelectors(this.selectSlice)},injectInto(e,{reducerPath:t,...n}={}){const i=t??this.reducerPath;return e.inject({reducerPath:i,reducer:this.reducer},n),{...this,reducerPath:i}}};return h}}();function Cn(){}var An="listenerMiddleware";Bt(`${An}/add`),Bt(`${An}/removeAll`),Bt(`${An}/remove`);const xn=e=>c((t=>{const n=In(e),i=Object.assign(Object.assign({},n.actions),e.asyncActions);return class extends(r(b)(t)){constructor(...e){super(...e);const t=un({reducer:n.reducer,middleware:e=>e({thunk:{extraArgument:this},serializableCheck:!1}),devTools:!1}),o=e=>async(...n)=>{const i=await t.dispatch(e(...n));try{bn(i)}catch(e){this.logger.error(e.message,i.type,e.stack)}return i},r=Object.keys(i).reduce(((e,t)=>(e[t]=o(i[t]),e)),{});this.actions=r,this.subscribe=(e,n=e=>e)=>t.subscribe((()=>e(n(t.getState()))))}}}));c((e=>class extends(b(e)){validateForm(e){return this.getFormInputs(e).every((e=>{var t,n;return null===(t=e.reportValidity)||void 0===t||t.call(e),null===(n=e.checkValidity)||void 0===n?void 0:n.call(e)}))}getFormInputs(e){return e?Array.from(e.querySelectorAll("[name]")):(this.logger.debug("cannot get form inputs, no root element was received"),[])}getFormData(e){return this.getFormInputs(e).reduce(((e,t)=>Object.assign(e,{[t.getAttribute("name")]:t.value})),{})}setFormData(e,t){this.getFormInputs(e).forEach((e=>{t.hasOwnProperty(e.getAttribute("name"))&&(e.value=t[e.getAttribute("name")])}))}resetFormData(e){this.getFormInputs(e).forEach((e=>{e.value="",e.checked=!1}))}getFormFieldNames(e){return this.getFormInputs(e).map((e=>e.name))}disableFormField(e,t){var n;null===(n=this.getFormInputs(e).find((e=>e.name===t)))||void 0===n||n.setAttribute("disabled","true")}removeFormField(e,t){var n;null===(n=this.getFormInputs(e).find((e=>e.name===t)))||void 0===n||n.remove()}}));const On=c((e=>{const t=r(O({"widget-id":C}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}}})),En=c((e=>{const t=r(W,On)(e);return class extends t{async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this))}async getWidgetConfig(){var e,t;const n=await this.config;return null===(t=null===(e=null==n?void 0:n.projectConfig)||void 0===e?void 0:e.widgets)||void 0===t?void 0:t[this.widgetId]}}})),jn=c((e=>class extends e{get locale(){return this.getAttribute("locale")||""}get localeCandidates(){const{locale:e,fallback:t}=v(this.locale);return[...new Set([e,t].filter(Boolean))]}firstAvailableLocale(e){var t;const n=(null!=e?e:[]).map((e=>e.toLowerCase()));return null!==(t=this.localeCandidates.find((e=>n.includes(e))))&&void 0!==t?t:""}})),Rn=e=>c((t=>{var n,o,s;const a=r(M,On,En,jn)(t);return s=class extends a{constructor(){super(...arguments),n.add(this)}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this))}async fetchWidgetPage(t){const r=await i(this,n,"m",o).call(this,t);if(void 0!==r)return r;const s=await this.fetchStaticResource(`${e}/${this.widgetId}/${t}`,"text");return null==s?void 0:s.body}},n=new WeakSet,o=async function(t){var n;const i=await this.getWidgetConfig(),o=this.firstAvailableLocale(null!==(n=null==i?void 0:i.targetLocales)&&void 0!==n?n:[]);if(!o)return;const r=".html",s=t.endsWith(r)?t.slice(0,-5):t;try{const t=await this.fetchStaticResource(`${e}/${this.widgetId}/${s}-${o}${r}`,"text");return null==t?void 0:t.body}catch(e){return}},s})),Tn=c((e=>class extends e{get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}})),Mn=c((e=>{var n,o,r;return r=class extends(Ce(e)){constructor(){super(...arguments),n.add(this)}get clientInput(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(e){return{}}}get formInput(){return this.getAttribute("form")||void 0}createFlowTemplate(e){var{flowId:r,client:s,form:a}=e,c=t(e,["flowId","client","form"]);return l(Object.assign({projectId:this.getAttribute("project-id"),flowId:r,baseUrl:this.getAttribute("base-url")||"",baseStaticUrl:this.getAttribute("base-static-url")||"",baseCdnUrl:this.getAttribute("base-cdn-url")||"",refreshCookieName:this.getAttribute("refresh-cookie-name")||"",theme:this.theme,"style-id":this.styleId,locale:this.getAttribute("locale")||"",form:i(this,n,"m",o).call(this,a),client:Object.assign(Object.assign({},this.clientInput),s)},c))}},n=new WeakSet,o=function(e){const t=this.formInput;if(!e)return t;if(!t)return e;try{return Object.assign(Object.assign({},JSON.parse(t)),e)}catch(t){return e}},r}));function Un(e){return new URLSearchParams(window.location.search).get(e)}const Wn=e=>(...t)=>n=>{n.addCase(e.pending,((e,n)=>{t.forEach((({onPending:t})=>{null==t||t(e,n)}))})),n.addCase(e.fulfilled,((e,n)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,n)}))})),n.addCase(e.rejected,((e,n)=>{t.forEach((({onRejected:t})=>{null==t||t(e,n)}))}))},$n=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,n)=>{e(t).loading=!1,e(t).error=n.error}}),Pn=wn("users/me",((e,{extra:{api:t}})=>t.user.me())),_n=Wn(Pn)({onFulfilled:(e,t)=>{e.me.data=t.payload}},$n((e=>e.me))),Ln={action:Pn,reducer:_n},Nn=wn("users/devices",((e,{extra:{api:t}})=>t.device.devices(e))),Dn=Wn(Nn)({onFulfilled:(e,t)=>{e.devices.data=t.payload.devices}},$n((e=>e.devices))),Fn={action:Nn,reducer:Dn},qn=wn("users/passkeys",((e,{extra:{api:t}})=>t.passkey.listPasskeys(e))),zn=Wn(qn)({onFulfilled:(e,t)=>{e.passkeys.data=t.payload.passkeys}},$n((e=>e.passkeys))),Vn={action:qn,reducer:zn},Hn=wn("users/logout",((e,{extra:{api:t}})=>t.user.logout())),Bn={action:Hn,reducer:Wn(Hn)({})};class Jn extends Error{}function Kn(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return function(e){return decodeURIComponent(atob(e).replace(/(.)/g,((e,t)=>{let n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return atob(t)}}function Zn(e,t){if("string"!=typeof e)throw new Jn("Invalid token specified: must be a string");t||(t={});const n=!0===t.header?0:1,i=e.split(".")[n];if("string"!=typeof i)throw new Jn(`Invalid token specified: missing part #${n+1}`);let o;try{o=Kn(i)}catch(e){throw new Jn(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(o)}catch(e){throw new Jn(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}Jn.prototype.name="InvalidTokenError";var Xn={accessKey:{exchange:"/v1/auth/accesskey/exchange"},otp:{verify:"/v1/auth/otp/verify",signIn:"/v1/auth/otp/signin",signUp:"/v1/auth/otp/signup",update:{email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},signUpOrIn:"/v1/auth/otp/signup-in"},magicLink:{verify:"/v1/auth/magiclink/verify",signIn:"/v1/auth/magiclink/signin",signUp:"/v1/auth/magiclink/signup",update:{email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},signUpOrIn:"/v1/auth/magiclink/signup-in"},enchantedLink:{verify:"/v1/auth/enchantedlink/verify",signIn:"/v1/auth/enchantedlink/signin",signUp:"/v1/auth/enchantedlink/signup",session:"/v1/auth/enchantedlink/pending-session",update:{email:"/v1/auth/enchantedlink/update/email"},signUpOrIn:"/v1/auth/enchantedlink/signup-in"},oauth:{start:"/v1/auth/oauth/authorize",exchange:"/v1/auth/oauth/exchange",startNative:"v1/auth/oauth/native/start",finishNative:"v1/auth/oauth/native/finish",oneTap:{getOneTapClientId:"/v1/auth/onetap/clientid/{provider}",exchangeOneTapIDToken:"/v1/auth/onetap/idtoken/exchange",verifyOneTapIDToken:"/v1/auth/onetap/idtoken/verify"}},outbound:{connect:"/v1/outbound/oauth/connect"},saml:{start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},sso:{start:"/v1/auth/saml/authorize",exchange:"/v1/auth/saml/exchange"},totp:{verify:"/v1/auth/totp/verify",signUp:"/v1/auth/totp/signup",update:"/v1/auth/totp/update"},notp:{signIn:"/v1/auth/notp/whatsapp/signin",signUp:"/v1/auth/notp/whatsapp/signup",signUpOrIn:"/v1/auth/notp/whatsapp/signup-in",session:"/v1/auth/notp/pending-session"},webauthn:{signUp:{start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},signIn:{start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},signUpOrIn:{start:"/v1/auth/webauthn/signup-in/start"},update:{start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"}},password:{signUp:"/v1/auth/password/signup",signIn:"/v1/auth/password/signin",sendReset:"/v1/auth/password/reset",update:"/v1/auth/password/update",replace:"/v1/auth/password/replace",policy:"/v1/auth/password/policy"},refresh:"/v1/auth/refresh",tryRefresh:"/v1/auth/try-refresh",selectTenant:"/v1/auth/tenant/select",logout:"/v1/auth/logout",logoutAll:"/v1/auth/logoutall",me:"/v1/auth/me",myTenants:"/v1/auth/me/tenants",history:"/v1/auth/me/history",flow:{start:"/v1/flow/start",next:"/v1/flow/next"}};const Gn="<region>",Yn=`https://api.${Gn}descope.com`,Qn=6e5,ei="dct",ti=()=>{const e={};return{headers(t){const n="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(n),this},body(t){return e.Body=t,this},url(t){return e.Url=t.toString(),this},method(t){return e.Method=t,this},title(t){return e.Title=t,this},status(t){return e.Status=t,this},retries(t){return e.Retries=t,this},build:()=>Object.keys(e).flatMap((t=>e[t]?[`${"Title"!==t?`${t}: `:""}${e[t]}`]:[])).join("\n")}},ni=[503,520,521,522,524,530],ii=[100,5e3,5e3],oi=e=>new Promise((t=>setTimeout(t,e))),ri=e=>async function(...t){let n=await e(...t),i=0;for(;ni.includes(n.status)&&i<ii.length;)await oi(ii[i]),n=await e(...t),i++;i>0&&(n.retries=i);const o=await n.text();return n.text=()=>Promise.resolve(o),n.json=()=>Promise.resolve(JSON.parse(o)),n.clone=()=>n,n};let si;const ai=()=>{if(si)return si;const e=new Date,t=`${e.getUTCFullYear().toString()}-${(e.getUTCMonth()+1).toString().padStart(2,"0")}-${e.getUTCDate().toString().padStart(2,"0")}-${e.getUTCHours().toString().padStart(2,"0")}:${e.getUTCMinutes().toString().padStart(2,"0")}:${e.getUTCSeconds().toString().padStart(2,"0")}:${e.getUTCMilliseconds().toString()}`,n=Math.floor(1e3+9e3*Math.random());return si=`${t}-${n}`,si};var li;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT",e.patch="PATCH"}(li||(li={}));const ci=({path:e,baseUrl:t,queryParams:n,projectId:i})=>{const o=i.slice(1,-27);t=t.replace(Gn,o?o+".":"");let r=e?`${t.replace(/\/$/,"")}/${null==e?void 0:e.replace(/^\//,"")}`:t;if(n){const e=Object.keys(n);e.forEach(((t,i)=>{r=`${r}${0===i?"?":""}${t}=${encodeURIComponent(n[t])}${i===e.length-1?"":"&"}`}))}return r},di=(...e)=>new Headers(e.reduce(((e,t)=>((e=>Array.isArray(e)?e:e instanceof Headers?Array.from(e.entries()):e?Object.entries(e):[])(t).forEach((([t,n])=>{e[t]="function"==typeof n?n():n})),e)),{})),ui={"Content-Type":"application/json"},hi=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},pi=(e,t)=>{const n={"x-descope-sdk-session-id":ai(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.66.0","x-descope-project-id":e};return t&&(n["x-descope-refresh-cookie-name"]=t),n},fi=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e};var gi=e=>{var t;return(({baseUrl:e,projectId:t,baseConfig:n,refreshCookieName:i,logger:o,hooks:r,cookiePolicy:s,fetch:a})=>{const l=e||Yn,c=((e,t)=>{const n=t||fetch;return n||null==e||e.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),e?async function(...t){if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");e.log((e=>ti().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const i=await ri(n)(...t);return e[i.ok?"log":"error"](await(async e=>{const t=await e.text();return ti().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).retries(e.retries).build()})(i)),i}:ri(n)})(o,a),d=async e=>{var o;const a=(null==r?void 0:r.beforeRequest)?r.beforeRequest(e):e,{path:d,body:u,headers:h,queryParams:p,method:f,token:g}=a,v=(e=>void 0===e?void 0:JSON.stringify(e))(u),m={headers:di(hi(t,g),pi(t,i),(null==n?void 0:n.baseHeaders)||{},fi(v)?ui:{},h),method:f,body:v};null!==s&&(m.credentials=s||"include");const w=await c(ci({path:d,baseUrl:l,queryParams:p,projectId:t}),m);if((null==r?void 0:r.afterRequest)&&await r.afterRequest(e,null==w?void 0:w.clone()),null==r?void 0:r.transformResponse){const e=await w.json(),t=(b=(null===(o=w.headers)||void 0===o?void 0:o.get("set-cookie"))||"",Object.fromEntries(function(e){if(!e)return[];const t=[];let n=0;function i(){for(;n<e.length&&/\s/.test(e.charAt(n));)n+=1;return n<e.length}function o(){const t=e.charAt(n);return"="!==t&&";"!==t&&","!==t}for(;n<e.length;){const r=n;let s,a,l=!1;for(;i();)if(","===e.charAt(n)){for(s=n,n+=1,i(),a=n;n<e.length&&o();)n+=1;if(n<e.length&&"="===e.charAt(n)){l=!0,n=a,t.push(e.substring(r,s));break}n=s+1}else n+=1;(!l||n>=e.length)&&t.push(e.substring(r,e.length))}return t}(b).map((e=>{const t=e.split(";")[0],n=t.indexOf("=");return n<1?null:[t.substring(0,n).trim(),t.substring(n+1).trim()]})).filter(Boolean))),n=Object.assign(Object.assign({},w),{json:()=>Promise.resolve(e),cookies:t});return n.clone=()=>n,r.transformResponse(n)}var b;return w};return{get:(e,{headers:t,queryParams:n,token:i}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:li.get,token:i}),post:(e,t,{headers:n,queryParams:i,token:o}={})=>d({path:e,headers:n,queryParams:i,body:t,method:li.post,token:o}),patch:(e,t,{headers:n,queryParams:i,token:o}={})=>d({path:e,headers:n,queryParams:i,body:t,method:li.patch,token:o}),put:(e,t,{headers:n,queryParams:i,token:o}={})=>d({path:e,headers:n,queryParams:i,body:t,method:li.put,token:o}),delete:(e,{headers:t,queryParams:n,token:i}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:li.delete,token:i}),hooks:r,buildUrl:(e,n)=>ci({projectId:t,baseUrl:l,path:e,queryParams:n})}})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var n;const i=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.beforeRequest)||[]);return null==i?void 0:i.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,n)=>{var i;const o=[].concat((null===(i=e.hooks)||void 0===i?void 0:i.afterRequest)||[]);0!=o.length&&(await Promise.allSettled(null==o?void 0:o.map((e=>e(t,null==n?void 0:n.clone()))))).forEach((t=>{var n;return"rejected"===t.status&&(null===(n=e.logger)||void 0===n?void 0:n.error(t.reason))}))},transformResponse:null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}}))},vi=429;function mi(e,t,n){var i;let o=wi(e);if(t){if(!(null==o?void 0:o.tenants)&&(null==o?void 0:o[ei])===t)return(null==o?void 0:o[n])||[];o=null===(i=null==o?void 0:o.tenants)||void 0===i?void 0:i[t]}const r=null==o?void 0:o[n];return Array.isArray(r)?r:[]}function wi(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return Zn(e)}function bi(e){const{exp:t}=wi(e);return(new Date).getTime()/1e3>t}function yi(e){let t=wi(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function ki(e,t){return mi(e,t,"permissions")}function Si(e,t){return mi(e,t,"roles")}const Ii=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function Ci(e,t){var n;const i=await e,o={code:i.status,ok:i.ok,response:i},r=await i.clone().json();return i.ok?o.data=r:(o.error=r,i.status===vi&&Object.assign(o.error,{retryAfter:Number.parseInt(null===(n=i.headers)||void 0===n?void 0:n.get("retry-after"))||0})),o}function Ai(e){var t;return(null===(t=wi(e))||void 0===t?void 0:t[ei])||""}const xi=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),Oi=(e,t)=>(n=t)=>t=>{const i=e.filter((e=>e(t)));return!(i.length<e.length)&&(n?n.replace("{val}",t):i.join(" OR "))},Ei=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),ji=e=>t=>e.test(t),Ri=ji(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Ti=ji(/^\+[1-9]{1}[0-9]{3,14}$/),Mi=xi(Ri,'"{val}" is not a valid email'),Ui=xi(Ti,'"{val}" is not a valid phone number'),Wi=xi((e=>e.length>=1),"Minimum length is 1");const $i=xi((e=>"string"==typeof e),"Input is not a string"),Pi=xi((e=>Array.isArray(e)),"Input is not an array"),_i=xi((e=>"boolean"==typeof e),"Input is not a boolean"),Li=xi((e=>void 0===e),"Input is defined"),Ni=Oi([$i(),Li()],"Input is not a string or undefined"),Di=Oi([Pi(),_i()],"Input is not an array or boolean"),Fi=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>Ei(...e).validate(n[t]))),t(...n)),qi=e=>[$i(`"${e}" must be a string`)],zi=e=>[Ni(`"${e}" must be string or undefined`)],Vi=e=>[$i(`"${e}" must be a string`),Wi(`"${e}" must not be empty`)],Hi=e=>[$i(`"${e}" must be a string`),Mi()],Bi=e=>[$i(`"${e}" must be a string`),Ui()],Ji=Fi(Vi("accessKey")),Ki=e=>({exchange:Ji(((t,n)=>Ci(e.post(Xn.accessKey.exchange,{loginOptions:n},{token:t}))))}),Zi=(e,t,n)=>(t.forEach((t=>{const i=t.split(".");let o=i.shift(),r=e;for(;i.length>0;){if(r=r[o],!o||!r)throw Error(`Invalid path "${t}", "${o}" is missing or has no value`);o=i.shift()}if("function"!=typeof r[o])throw Error(`"${t}" is not a function`);const s=r[o];r[o]=n(s)})),e),Xi=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||Qn,Qn)});var Gi,Yi;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp",e.im="im"}(Gi||(Gi={})),function(e){e.email="email"}(Yi||(Yi={}));const Qi=Object.assign(Object.assign({},Gi),Yi);var eo;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(eo||(eo={}));const to=Vi("loginId"),no=Fi(Vi("token")),io=Fi(to),oo=Fi(Vi("pendingRef")),ro=Fi(to,Hi("email")),so=e=>({verify:no((t=>Ci(e.post(Xn.enchantedLink.verify,{token:t})))),signIn:io(((n,i,o={},r)=>{var{providerId:s}=o,a=t(o,["providerId"]);return Ci(e.post(Ii(Xn.enchantedLink.signIn,Qi.email),{loginId:n,URI:i,loginOptions:a,providerId:s},{token:r}))})),signUpOrIn:io(((n,i,o={})=>{var{providerId:r}=o,s=t(o,["providerId"]);return Ci(e.post(Ii(Xn.enchantedLink.signUpOrIn,Qi.email),{loginId:n,URI:i,loginOptions:s,providerId:r}))})),signUp:io(((n,i,o,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return Ci(e.post(Ii(Xn.enchantedLink.signUp,Qi.email),{loginId:n,URI:i,user:o,loginOptions:a,providerId:s}))})),waitForSession:oo(((t,n)=>new Promise((i=>{const{pollingIntervalMs:o,timeoutMs:r}=Xi(n);let s;const a=setInterval((async()=>{const n=await e.post(Xn.enchantedLink.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),i(Ci(Promise.resolve(n))))}),o);s=setTimeout((()=>{i({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:ro(((t,n,i,o,r)=>Ci(e.post(Xn.enchantedLink.update.email,Object.assign({loginId:t,email:n,URI:i},r),{token:o}))))}}),ao=Fi(Vi("flowId")),lo=Fi(Vi("executionId"),Vi("stepId"),Vi("interactionId")),co=e=>({start:ao(((t,n,i,o,r,s,a,l=!1)=>Ci(e.post(Xn.flow.start,{flowId:t,options:n,conditionInteractionId:i,interactionId:o,componentsVersion:r,flowVersions:s,input:a,isCustomScreen:l})))),next:lo(((t,n,i,o,r,s,a=!1)=>Ci(e.post(Xn.flow.next,{executionId:t,stepId:n,interactionId:i,version:o,componentsVersion:r,input:s,isCustomScreen:a}))))}),uo=Vi("loginId"),ho=Fi(Vi("token")),po=Fi(uo),fo=Fi(uo,Bi("phone")),go=Fi(uo,Hi("email")),vo=Object.keys(Qi).filter((e=>e!==Gi.voice&&e!==Gi.im)),mo=e=>({verify:ho((t=>Ci(e.post(Xn.magicLink.verify,{token:t})))),signIn:vo.reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:po(((n,o,r={},s)=>{var{providerId:a}=r,l=t(r,["providerId"]);return Ci(e.post(Ii(Xn.magicLink.signIn,i),{loginId:n,URI:o,loginOptions:l,providerId:a},{token:s}))}))})),{}),signUp:vo.reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:po(((n,o,r,s={})=>{var{providerId:a}=s,l=t(s,["providerId"]);return Ci(e.post(Ii(Xn.magicLink.signUp,i),{loginId:n,URI:o,user:r,loginOptions:l,providerId:a}))}))})),{}),signUpOrIn:vo.reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:po(((n,o,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return Ci(e.post(Ii(Xn.magicLink.signUpOrIn,i),{loginId:n,URI:o,loginOptions:a,providerId:s}))}))})),{}),update:{email:go(((t,n,i,o,r)=>Ci(e.post(Xn.magicLink.update.email,Object.assign({loginId:t,email:n,URI:i},r),{token:o})))),phone:Object.keys(Gi).filter((e=>e!==Gi.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:fo(((t,i,o,r,s)=>Ci(e.post(Ii(Xn.magicLink.update.phone,n),Object.assign({loginId:t,phone:i,URI:o},s),{token:r}))))})),{})}});var wo;!function(e){e.facebook="facebook",e.github="github",e.google="google",e.microsoft="microsoft",e.gitlab="gitlab",e.apple="apple",e.discord="discord",e.linkedin="linkedin",e.slack="slack"}(wo||(wo={}));const bo=Fi(Vi("code")),yo=e=>({start:Object.assign(((t,n,i,o,r)=>Ci(e.post(Xn.oauth.start,i||{},{queryParams:Object.assign(Object.assign({provider:t},n&&{redirectURL:n}),r&&{loginHint:r}),token:o}))),Object.keys(wo).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,i,o,r)=>Ci(e.post(Xn.oauth.start,i||{},{queryParams:Object.assign(Object.assign({provider:n},t&&{redirectURL:t}),r&&{loginHint:r}),token:o}))})),{})),exchange:bo((t=>Ci(e.post(Xn.oauth.exchange,{code:t})))),startNative:(t,n,i)=>Ci(e.post(Xn.oauth.startNative,{provider:t,loginOptions:n,implicit:i})),finishNative:(t,n,i,o,r)=>Ci(e.post(Xn.oauth.finishNative,{provider:t,stateId:n,user:i,code:o,idToken:r})),getOneTapClientId:t=>Ci(e.get(Xn.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,n,i,o)=>Ci(e.post(Xn.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:n,nonce:i,loginOptions:o})),exchangeOneTapIDToken:(t,n,i,o)=>Ci(e.post(Xn.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:n,nonce:i,loginOptions:o}))}),ko=Vi("appId"),So=Fi(ko),Io=e=>({connect:So(((t,n,i)=>{const o=null==n?void 0:n.tenantId,r=null==n?void 0:n.tenantLevel;return null==n||delete n.tenantId,null==n||delete n.tenantLevel,Ci(e.post(Xn.outbound.connect,{appId:t,tenantId:o,tenantLevel:r,options:n},{token:i}))}))}),Co=Vi("loginId"),Ao=Fi(Co,Vi("code")),xo=Fi(Co),Oo=Fi(Co,Bi("phone")),Eo=Fi(Co,Hi("email")),jo=e=>({verify:Object.keys(Qi).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Ao(((t,i)=>Ci(e.post(Ii(Xn.otp.verify,n),{code:i,loginId:t}))))})),{}),signIn:Object.keys(Qi).reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:xo(((n,o={},r)=>{var{providerId:s}=o,a=t(o,["providerId"]);return Ci(e.post(Ii(Xn.otp.signIn,i),{loginId:n,loginOptions:a,providerId:s},{token:r}))}))})),{}),signUp:Object.keys(Qi).reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:xo(((n,o,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return Ci(e.post(Ii(Xn.otp.signUp,i),{loginId:n,user:o,loginOptions:a,providerId:s}))}))})),{}),signUpOrIn:Object.keys(Qi).reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:xo(((n,o={})=>{var{providerId:r}=o,s=t(o,["providerId"]);return Ci(e.post(Ii(Xn.otp.signUpOrIn,i),{loginId:n,loginOptions:s,providerId:r}))}))})),{}),update:{email:Eo(((t,n,i,o)=>Ci(e.post(Xn.otp.update.email,Object.assign({loginId:t,email:n},o),{token:i})))),phone:Object.keys(Gi).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:Oo(((t,i,o,r)=>Ci(e.post(Ii(Xn.otp.update.phone,n),Object.assign({loginId:t,phone:i},r),{token:o}))))})),{})}}),Ro=Fi(Vi("tenant")),To=Fi(Vi("code")),Mo=e=>({start:Ro(((t,n,i,o,r,s,a,l)=>Ci(e.post(Xn.sso.start,i||{},Object.assign({queryParams:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({tenant:t},n&&{redirectURL:n}),r&&{ssoId:r}),s&&{forceAuthn:"true"}),a&&{loginHint:a}),l&&{initiatedEmail:t})},o&&{token:o}))))),exchange:To((t=>Ci(e.post(Xn.sso.exchange,{code:t}))))}),Uo=Vi("loginId"),Wo=Fi(Uo,Vi("code")),$o=Fi(Uo),Po=Fi(Uo),_o=e=>({signUp:$o(((t,n)=>Ci(e.post(Xn.totp.signUp,{loginId:t,user:n})))),verify:Wo(((t,n,i,o)=>Ci(e.post(Xn.totp.verify,{loginId:t,code:n,loginOptions:i},{token:o})))),update:Po(((t,n)=>Ci(e.post(Xn.totp.update,{loginId:t},{token:n}))))}),Lo=Vi("loginId"),No=Vi("newPassword"),Do=Fi(Lo,Vi("password")),Fo=Fi(Lo),qo=Fi(Lo,No),zo=Fi(Lo,Vi("oldPassword"),No),Vo=e=>({signUp:Do(((n,i,o,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return Ci(e.post(Xn.password.signUp,{loginId:n,password:i,user:o,loginOptions:a,providerId:s}))})),signIn:Do(((n,i,o={})=>{var{providerId:r}=o,s=t(o,["providerId"]);return Ci(e.post(Xn.password.signIn,{loginId:n,password:i,loginOptions:s,providerId:r}))})),sendReset:Fo(((t,n,i)=>Ci(e.post(Xn.password.sendReset,{loginId:t,redirectUrl:n,templateOptions:i})))),update:qo(((t,n,i)=>Ci(e.post(Xn.password.update,{loginId:t,newPassword:n},{token:i})))),replace:zo(((t,n,i)=>Ci(e.post(Xn.password.replace,{loginId:t,oldPassword:n,newPassword:i})))),policy:()=>Ci(e.get(Xn.password.policy))}),Ho=qi("loginId"),Bo=Vi("loginId"),Jo=Vi("origin"),Ko=Fi(Bo,Jo,Vi("name")),Zo=Fi(Bo,Jo),Xo=Fi(Ho,Jo),Go=Fi(Bo,Jo,zi("token")),Yo=Fi(Vi("transactionId"),Vi("response")),Qo=e=>({signUp:{start:Ko(((t,n,i,o,r)=>Ci(e.post(Xn.webauthn.signUp.start,{user:{loginId:t,name:i},origin:n,loginOptions:r,passkeyOptions:o})))),finish:Yo(((t,n)=>Ci(e.post(Xn.webauthn.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:Xo(((t,n,i,o,r)=>Ci(e.post(Xn.webauthn.signIn.start,{loginId:t,origin:n,loginOptions:i,passkeyOptions:r},{token:o})))),finish:Yo(((t,n)=>Ci(e.post(Xn.webauthn.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Zo(((t,n,i,o)=>Ci(e.post(Xn.webauthn.signUpOrIn.start,{loginId:t,origin:n,loginOptions:o,passkeyOptions:i}))))},update:{start:Go(((t,n,i,o,r)=>Ci(e.post(Xn.webauthn.update.start,{loginId:t,origin:n,passkeyOptions:o,mfa:r},{token:i})))),finish:Yo(((t,n)=>Ci(e.post(Xn.webauthn.update.finish,{transactionId:t,response:n}))))}}),er=qi("loginId"),tr=Fi(er),nr=Fi(Vi("pendingRef")),ir=e=>({signUpOrIn:tr(((n,i={})=>{var{providerId:o}=i,r=t(i,["providerId"]);return Ci(e.post(Xn.notp.signUpOrIn,{loginId:n,loginOptions:r,providerId:o}))})),signUp:tr(((n,i,o={})=>{var{providerId:r}=o,s=t(o,["providerId"]);return Ci(e.post(Xn.notp.signUp,{loginId:n,user:i,providerId:r,loginOptions:s}))})),signIn:tr(((n,i={},o)=>{var{providerId:r}=i,s=t(i,["providerId"]);return Ci(e.post(Xn.notp.signIn,{loginId:n,loginOptions:s,providerId:r},{token:o}))})),waitForSession:nr(((t,n)=>new Promise((i=>{const{pollingIntervalMs:o,timeoutMs:r}=Xi(n);let s;const a=setInterval((async()=>{const n=await e.post(Xn.notp.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),i(Ci(Promise.resolve(n))))}),o);s=setTimeout((()=>{i({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),or=Fi(Vi("token")),rr=Fi(zi("token"));var sr,ar=Fi([(sr=Vi("projectId"),xi(((e,t)=>n=>Ei(...t).validate(((e,t)=>{const n=(Array.isArray(t)?t.join("."):String(t)).replace(/\[\\?("|')?(\w|d)+\\?("|')?\]/g,((e,t,n)=>"."+n)).split("."),i=n.length;let o=0,r=e===Object(e)?e:void 0;for(;null!=r&&o<i;)r=r[n[o++]];return o&&o===i&&void 0!==r?r:void 0})(n,e)))("projectId",sr))())])((e=>{const{projectId:t,logger:n,baseUrl:i,cookiePolicy:o,baseHeaders:r={},refreshCookieName:s,fetch:a}=e;return l=gi({baseUrl:i,projectId:t,logger:n,hooks:{get beforeRequest(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.beforeRequest},get afterRequest(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.afterRequest},get transformResponse(){var t;return null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}},cookiePolicy:o,baseConfig:{baseHeaders:r},refreshCookieName:s,fetch:a}),{accessKey:Ki(l),otp:jo(l),magicLink:mo(l),enchantedLink:so(l),oauth:yo(l),outbound:Io(l),sso:Mo(l),saml:Mo(l),totp:_o(l),notp:ir(l),webauthn:Qo(l),password:Vo(l),flow:co(l),refresh:rr(((e,t,n,i)=>{const o={};n&&(o.externalToken=n);const r=i?Xn.tryRefresh:Xn.refresh;return Ci(l.post(r,o,{token:e,queryParams:t}))})),selectTenant:Fi([$i("tenantId")],[Ni('"token" must be string or undefined')])(((e,t)=>Ci(l.post(Xn.selectTenant,{tenant:e},{token:t})))),logout:rr((e=>Ci(l.post(Xn.logout,{},{token:e})))),logoutAll:rr((e=>Ci(l.post(Xn.logoutAll,{},{token:e})))),me:rr((e=>Ci(l.get(Xn.me,{token:e})))),myTenants:Fi([Di('"tenants" must a string array or a boolean')],[Ni('"token" must be string or undefined')])(((e,t)=>{const n={};return"boolean"==typeof e?n.dct=e:n.ids=e,Ci(l.post(Xn.myTenants,n,{token:t}))})),history:rr((e=>Ci(l.get(Xn.history,{token:e})))),isJwtExpired:or(bi),getTenants:or(yi),getJwtPermissions:or(ki),getJwtRoles:or(Si),getCurrentTenant:or(Ai),httpClient:l};var l})),lr=Object.assign(ar,{DeliveryMethods:Qi});
6
+ /*! js-cookie v3.0.8 | MIT */function cr(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)"__proto__"!==i&&(e[i]=n[i])}return e}var dr=function e(t,n){function i(e,i,o){if("undefined"!=typeof document){"number"==typeof(o=cr({},n,o)).expires&&(o.expires=new Date(Date.now()+864e5*o.expires)),o.expires&&(o.expires=o.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var r="";for(var s in o)o[s]&&(r+="; "+s,!0!==o[s]&&(r+="="+o[s].split(";")[0]));return document.cookie=e+"="+t.write(i,e)+r}}return Object.create({set:i,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],i={},o=0;o<n.length;o++){var r=n[o].split("="),s=r.slice(1).join("=");try{var a=decodeURIComponent(r[0]);if(a in i||(i[a]=t.read(s,a)),e===a)break}catch(e){}}return e?i[e]:i}},remove:function(e,t){i(e,"",cr({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,cr({},this.attributes,t))},withConverter:function(t){return e(cr({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(t)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"});var ur={default:"endpoint"},hr="Blocked by CSP",pr="The endpoint parameter is not a valid URL",fr="Failed to load the JS script of the agent",gr="9319";function vr(e,t){var n,i,o,r,s,a=[],l=(n=function(e){var t=function(e,t,n){if(n||2===arguments.length)for(var i,o=0,r=t.length;o<r;o++)!i&&o in t||(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))}([],e,!0);return{current:function(){return t[0]},postpone:function(){var e=t.shift();void 0!==e&&t.push(e)},exclude:function(){t.shift()}}}(e),r=0,i=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,r++))},o=new Set,[n.current(),function(e,t){var r,s=t instanceof Error?t.message:"";if(s===hr||s===pr)n.exclude(),r=0;else if(s===gr)n.exclude();else if(s===fr){var a=Date.now()-e.getTime()<50,l=n.current();l&&a&&!o.has(l)&&(o.add(l),r=0),n.postpone()}else n.postpone();var c=n.current();return void 0===c?void 0:[c,null!=r?r:e.getTime()+i()-Date.now()]}]),c=l[0],d=l[1];if(void 0===c)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var u=function(e){var n=new Date,i=function(t){return a.push({url:e,startedAt:n,finishedAt:new Date,error:t})},o=t(e);return o.then((function(){return i()}),i),o.catch((function(e){if(null!=s||(s=e),a.length>=5)throw s;var t=d(n,e);if(!t)throw s;var i,o=t[0],r=t[1];return(i=r,new Promise((function(e){return setTimeout(e,i)}))).then((function(){return u(o)}))}))};return u(c).then((function(e){return[e,a]}))}var mr="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",wr=mr;function br(n){var i;n.scriptUrlPattern;var o=n.token,r=n.apiKey,s=void 0===r?o:r,a=t(n,["scriptUrlPattern","token","apiKey"]),l=null!==(i=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(n,"scriptUrlPattern"))&&void 0!==i?i:mr,c=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},n=function(e,t,n,i){return e.addEventListener(t,n,i),function(){return e.removeEventListener(t,n,i)}}(document,"visibilitychange",t);return t(),[e,n]}(),d=c[0],u=c[1];return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error("API key required");var e=function(e,t){return(Array.isArray(e)?e:[e]).map((function(e){return function(e,t){var n=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?n(t):"<loaderVersion>"===e?n("3.11.6"):e}))}(String(e),t)}))}(l,s);return vr(e,yr)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===gr?new Error(fr):e}(e)})).then((function(t){var n=t[0],i=t[1];return u(),n.load(e(e({},a),{ldi:{attempts:i,visibilityStates:d}}))}))}function yr(e){return function(e,t,n){var i,o=document,r="securitypolicyviolation",s=function(t){var n=new URL(e,location.href),o=t.blockedURI;o!==n.href&&o!==n.protocol.slice(0,-1)&&o!==n.origin||(i=t,a())};o.addEventListener(r,s);var a=function(){return o.removeEventListener(r,s)};return Promise.resolve().then(t).then((function(e){return a(),e}),(function(e){return new Promise((function(e){var t=new MessageChannel;t.port1.onmessage=function(){return e()},t.port2.postMessage(null)})).then((function(){if(a(),i)return n(i);throw e}))}))}(e,(function(){return function(e){return new Promise((function(t,n){if(function(e){if(URL.prototype)try{return new URL(e,location.href),!1}catch(e){if(e instanceof Error&&"TypeError"===e.name)return!0;throw e}}(e))throw new Error(pr);var i=document.createElement("script"),o=function(){var e;return null===(e=i.parentNode)||void 0===e?void 0:e.removeChild(i)},r=document.head||document.getElementsByTagName("head")[0];i.onload=function(){o(),t()},i.onerror=function(){o(),n(new Error(fr))},i.async=!0,i.src=e,r.appendChild(i)}))}(e)}),(function(){throw new Error(hr)})).then(kr)}function kr(){var e=window,t="__fpjs_p_l_b",n=e[t];if(function(e,t){var n,i=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,e,t);(null==i?void 0:i.configurable)?delete e[t]:i&&!i.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==n?void 0:n.load))throw new Error(gr);return n}const Sr="3.2.0",Ir="undefined"!=typeof window,Cr=Math.pow(2,31)-1,Ar=`https://descopecdn.com/npm/oidc-client-ts@${Sr}/dist/browser/oidc-client-ts.min.js`,xr=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${Sr}/dist/browser/oidc-client-ts.min.js`,Or=["/v1/auth/refresh","/v1/auth/try-refresh","/v1/auth/me","/v1/auth/me/tenants","/v1/auth/me/history"];let Er;const jr=e=>{try{return Zn(e).exp}catch(e){return null}},Rr=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:jr(n)},Tr=e=>{const{expires_in:t,expires_at:n,access_token:i}=e;return n||(t?Math.floor(Date.now()/1e3)+t:i?jr(i):void 0)},Mr=e=>{const{access_token:n,id_token:i,refresh_token:o,refresh_expire_in:r}=e,s=t(e,["access_token","id_token","refresh_token","refresh_expire_in"]);return Object.assign({sessionJwt:e.sessionJwt||n,idToken:i,refreshJwt:e.refreshJwt||o,sessionExpiration:e.sessionExpiration||Tr(e),cookieExpiration:e.cookieExpiration||Rr(e)},s)},Ur=(e,t)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,i)=>{var o;return n[i]=[].concat((null===(o=e.hooks)||void 0===o?void 0:o[i])||[]).concat((null==t?void 0:t[i])||[]),n}),null!==(n=e.hooks)&&void 0!==n?n:e.hooks={}),e},Wr=async e=>{if(!(null==e?void 0:e.ok))return{};const t=await(null==e?void 0:e.clone().json()),n=(null==t?void 0:t.authInfo)||t||{};return Mr(n)},$r=()=>Ir&&!!window.descopeBridge,Pr=(e,t)=>{if(!((null==t?void 0:t.status)>=400&&(null==t?void 0:t.status)<500))return!1;const n=(null==e?void 0:e.path)||"";return Or.includes(n)},_r=void 0!==Er||Ir&&void 0!==window.localStorage,Lr=(e,t)=>{var n,i;return null===(i=null===(n=Er||Ir&&window.localStorage)||void 0===n?void 0:n.setItem)||void 0===i?void 0:i.call(n,e,t)},Nr=e=>{var t,n;return null===(n=null===(t=Er||Ir&&window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e)},Dr=e=>{var t,n;return null===(n=null===(t=Er||Ir&&window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n?void 0:n.call(t,e)},Fr=e=>{var t,n,i,o,r;return null!==(r=null!==(n=null===(t=null==Er?void 0:Er.key)||void 0===t?void 0:t.call(Er,e))&&void 0!==n?n:Ir&&(null===(o=null===(i=window.localStorage)||void 0===i?void 0:i.key)||void 0===o?void 0:o.call(i,e)))&&void 0!==r?r:null},qr=(...e)=>{console.debug(...e)},zr=(...e)=>{console.warn(...e)},Vr="DS",Hr="DSR",Br="DSI",Jr="DSRCN";function Kr(e,t,n){if(t){const{cookieDomain:i,cookiePath:o,cookieSameSite:r,cookieExpiration:s,cookieSecure:a}=n,l=new Date(1e3*s),c=Zr(i);dr.set(e,t,{path:o,domain:c?i:void 0,expires:l,sameSite:r,secure:a})}}function Zr(e){const t=window.location.hostname.split("."),n=null==e?void 0:e.split(".");return t.slice(-(null==n?void 0:n.length)).join(".")===e}const Xr=e=>(null==e?void 0:e.cookieName)||Vr,Gr=e=>(null==e?void 0:e.cookieName)||Hr;function Yr(e="",t){return dr.get(Gr(t))||Nr(`${e}${Hr}`)||""}function Qr(e="",t){return dr.get(Xr(t))||Nr(`${e}${Vr}`)||""}function es(e=""){return Nr(`${e}${Br}`)||""}function ts(e="",t,n,i){Dr(`${e}${Hr}`),Dr(`${e}${Vr}`),Dr(`${e}${Br}`),Dr(`${e}${Jr}`);const o=Xr(t);dr.remove(o,null==i?void 0:i.session);const r=Gr(n);dr.remove(r,null==i?void 0:i.refresh)}const ns=(e,t,n)=>i=>{const o=Object.assign(i,{token:i.token||Yr(e,t)});if(!n){const t=function(e=""){return Nr(`${e}${Jr}`)}(e);t&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-refresh-cookie-name":t}))}const r=function(e=""){return Nr(`${e}DTD`)||""}(e);return r&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-trusted-device-token":r})),o},is=Ir&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",os="vsid",rs="vrid",ss="fp",as=(e=!1)=>{const t=Nr(ss);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},ls=async(e,t=is)=>{try{if(as())return;const n=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),i=new URL(t);i.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const r=o.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",s=br({apiKey:e,endpoint:[i.toString(),ur],scriptUrlPattern:[r,wr]}),a=await s,{requestId:l}=await a.get({linkedId:n}),c=((e,t)=>({[os]:e,[rs]:t}))(n,l);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};Lr(ss,JSON.stringify(t))})(c)}catch(e){console.warn("Could not load fingerprint",e)}},cs=e=>{const t=as(!0);return t&&e.body&&(e.body.fpData=t),e},ds="descopeFlowNonce",us="X-Descope-Flow-Nonce",hs="/v1/flow/start",ps="/v1/flow/next",fs=(e,t=ds)=>`${t}${e}`,gs=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||null},vs=e=>{var t;return e.path===ps&&(null===(t=e.body)||void 0===t?void 0:t.executionId)?gs(e.body.executionId):null},ms="dls_last_user_login_id",ws="dls_last_user_display_name",bs=e=>Lr(ms,e),ys=()=>Nr(ms),ks=()=>Nr(ws),Ss=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,i={}]=t,o=ys(),r=ks();return o&&(null!==(n=i.lastAuth)&&void 0!==n||(i.lastAuth={}),i.lastAuth.loginId=o,i.lastAuth.name=r),await e(...t)},Is="DSLI",Cs=e=>async(...t)=>{const n=await e(...t);return Dr(Is),n};function As(){const e=[];return{pub:t=>{e.forEach((e=>e(t)))},sub:t=>{const n=e.push(t)-1;return()=>e.splice(n,1)}}}async function xs(e){const t=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Us(n.publicKey.challenge),n.publicKey.user.id=Us(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=Us(e.id)})),n}(e);try{return n=await navigator.credentials.create(t),JSON.stringify({id:n.id,rawId:Ws(n.rawId),type:n.type,response:{attestationObject:Ws(n.response.attestationObject),clientDataJSON:Ws(n.response.clientDataJSON)}})}catch(e){throw await js(e,t,!0)}var n}async function Os(e){const t=Ts(e);try{return Ms(await navigator.credentials.get(t))}catch(e){throw await js(e,t,!1)}}async function Es(e,t){const n=Ts(e);n.signal=t.signal,n.mediation="conditional";try{return Ms(await navigator.credentials.get(n))}catch(e){throw await js(e,n,!1)}}async function js(e,t,n){if(e&&"object"==typeof e)try{e.reason=await async function(e,t,n){var i,o;const r=null==e?void 0:e.name;if("AbortError"===r&&(null==t?void 0:t.signal)instanceof AbortSignal)return"aborted";if("InvalidStateError"===r&&n)return"authenticator_already_registered";if("NotSupportedError"===r)return"no_supported_algorithm";if("ConstraintError"===r)return"authenticator_constraints_unsupported";if("SecurityError"===r){const e=window.location.hostname;return"localhost"===e||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)?"invalid_rpid":"invalid_domain"}if(!await Rs())return"webauthn_unsupported";const s="platform"===(null===(o=null===(i=null==t?void 0:t.publicKey)||void 0===i?void 0:i.authenticatorSelection)||void 0===o?void 0:o.authenticatorAttachment);return n&&s&&!await Rs(!0)?"platform_authenticator_unsupported":"NotAllowedError"===r?"not_allowed":"unknown"}(e,t,n)}catch(e){}return e}async function Rs(e=!1){var t,n;if(!Ir)return Promise.resolve(!1);if($r()){const e=null===(n=null===(t=window.descopeBridge)||void 0===t?void 0:t.hostInfo)||void 0===n?void 0:n.webauthn;if("boolean"==typeof e)return e}const i=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return i&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():i}function Ts(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=Us(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=Us(e.id)})),n}function Ms(e){return JSON.stringify({id:e.id,rawId:Ws(e.rawId),type:e.type,response:{authenticatorData:Ws(e.response.authenticatorData),clientDataJSON:Ws(e.response.clientDataJSON),signature:Ws(e.response.signature),userHandle:e.response.userHandle?Ws(e.response.userHandle):void 0}})}function Us(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function Ws(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var $s,Ps=($s=e=>({async signUp(t,n,i){const o=await e.webauthn.signUp.start(t,window.location.origin,n,i);if(!o.ok)return o;const r=await xs(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,r)},async signIn(t,n){const i=await e.webauthn.signIn.start(t,window.location.origin,void 0,void 0,n);if(!i.ok)return i;const o=await Os(i.data.options);return await e.webauthn.signIn.finish(i.data.transactionId,o)},async signUpOrIn(t,n){var i;const o=await e.webauthn.signUpOrIn.start(t,window.location.origin,n);if(!o.ok)return o;if(null===(i=o.data)||void 0===i?void 0:i.create){const t=await xs(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,t)}{const t=await Os(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,t)}},async update(t,n,i){const o=await e.webauthn.update.start(t,window.location.origin,n,i);if(!o.ok)return o;const r=await xs(o.data.options);return await e.webauthn.update.finish(o.data.transactionId,r)},helpers:{create:xs,get:Os,isSupported:Rs,conditional:Es}}),(...e)=>{const t=$s(...e);return Object.assign(t.signUp,e[0].webauthn.signUp),Object.assign(t.signIn,e[0].webauthn.signIn),Object.assign(t.signUpOrIn,e[0].webauthn.signUpOrIn),Object.assign(t.update,e[0].webauthn.update),t});const _s="/fedcm/config",Ls=()=>{if(window.crypto&&window.crypto.getRandomValues){const e=new Uint8Array(16);return window.crypto.getRandomValues(e),Array.from(e,(e=>e.toString(16).padStart(2,"0"))).join("")}return Math.random().toString(36).substring(2)};async function Ns(e,t){var n;try{await Ds(e,t)}catch(e){null===(n=null==t?void 0:t.onFailed)||void 0===n||n.call(t,e)}}async function Ds(e,t){var n,i;const o=await async function(e,t="google",n,i,o){const r=Ls(),s=await async function(){return new Promise(((e,t)=>{if(window.google)return void e(window.google.accounts.id);let n=document.getElementById("google-gsi-client-script");n||(n=document.createElement("script"),document.head.appendChild(n),n.async=!0,n.defer=!0,n.id="google-gsi-client-script",n.src="https://accounts.google.com/gsi/client"),n.onload=function(){window.google?e(window.google.accounts.id):t("Failed to load Google GSI client script - not loaded properly")},n.onerror=function(){t("Failed to load Google GSI client script - failed to load")}}))}(),a=await e.oauth.getOneTapClientId(t);if(!a.ok)throw new Error("Failed to get OneTap client ID for provider "+t);const l=a.data.clientId;return new Promise((e=>{var a,c;const d=n=>{e({provider:t,nonce:r,credential:null==n?void 0:n.credential})};s.initialize(Object.assign(Object.assign({},n),{itp_support:null===(a=null==n?void 0:n.itp_support)||void 0===a||a,use_fedcm_for_prompt:null===(c=null==n?void 0:n.use_fedcm_for_prompt)||void 0===c||c,client_id:l,callback:d,nonce:r})),s.prompt((e=>{var t,n;if(o&&(null==e?void 0:e.isDismissedMoment())){const n=null===(t=e.getDismissedReason)||void 0===t?void 0:t.call(e);return null==o||o(n),void d()}if(i&&(null==e?void 0:e.isSkippedMoment())){const t=null===(n=e.getSkippedReason)||void 0===n?void 0:n.call(e);return null==i||i(t),void d()}}))}))}(e,t.provider,t.oneTapConfig,t.onSkipped,t.onDismissed);if(!o.credential)return null;if(null==t?void 0:t.onCodeReceived){const i=await e.oauth.verifyOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!i.ok||!i.data)throw new Error("Failed to verify OneTap client ID for provider "+o.provider);null===(n=null==t?void 0:t.onCodeReceived)||void 0===n||n.call(t,i.data.code)}else{const n=await e.oauth.exchangeOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!n.ok||!n.data)throw new Error("Failed to exchange OneTap client ID for provider "+o.provider);null===(i=null==t?void 0:t.onAuthenticated)||void 0===i||i.call(t,n.data)}}var Fs=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await Rs(),i=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:n},startOptionsVersion:1});return t[1]=i,e.flow.start(...t)}});let qs;const zs=(e,t)=>new Promise(((n,i)=>{if(!e.length)return i(new Error("No URLs provided to loadScriptWithFallback"));const o=t();if(o)return n(o);const r=e.shift(),s=document.createElement("script");s.src=r,s.id=(e=>{let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t).toString(16)})(r),s.onload=()=>{const e=t();if(e)return n(e);throw new Error("Could not get entry after loading script from URL")},s.addEventListener("error",(()=>{zs(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)})),Vs=(e,t,n)=>{const i=async()=>{let i,o;return i&&o||({client:i,stateUserKey:o}=await(async(e,t,n)=>{qs||(qs=(async()=>{try{return require("oidc-client-ts")}catch(e){return zs([Ar,xr],(()=>window.oidc))}})());const{OidcClient:i,WebStorageStateStore:o}=await qs;if(!i)throw new Error("oidc-client-ts is not installed. Please install it by running `npm install oidc-client-ts`");const r=(null==n?void 0:n.redirectUri)||window.location.href;let s,a,l,c;if(null==n?void 0:n.issuer){if(!n.clientId)throw new Error("clientId is required when providing a custom issuer/authority");s=n.issuer,a=n.clientId,l=`${a}_user`,c="openid"}else(null==n?void 0:n.applicationId)?(s=e.httpClient.buildUrl(t),s=`${s}/${n.applicationId}`,a=t,l=`${a}_user`,c="openid email roles descope.custom_claims offline_access"):(s=e.httpClient.buildUrl(t),a=t,l=`${a}_user`,c="openid email roles descope.custom_claims offline_access");const d={authority:s,client_id:a,redirect_uri:r,response_type:"code",scope:(null==n?void 0:n.scope)||c,stateStore:new o({store:window.localStorage,prefix:a}),loadUserInfo:!0,fetchRequestCredentials:"same-origin"};return(null==n?void 0:n.redirectUri)&&(d.redirect_uri=n.redirectUri),{client:new i(d),stateUserKey:l}})(e,t,n)),{client:i,stateUserKey:o}},o=async(t="")=>{var n;const{client:o,stateUserKey:r}=await i(),s=await o.processSigninResponse(t||window.location.href);var a;return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(s)))),Lr(r,JSON.stringify({id_token:(a=s).id_token,session_state:a.session_state,profile:a.profile})),(()=>{const e=new URL(window.location.href);e.searchParams.delete("code"),e.searchParams.delete("state"),window.history.replaceState({},document.title,e.toString())})(),s};return{loginWithRedirect:async(t={},n=!1)=>{var o;const{client:r}=await i(),s=await r.createSigninRequest(t),{url:a}=s;return n||(await(null===(o=e.httpClient.hooks)||void 0===o?void 0:o.afterRequest({},new Response(JSON.stringify(s)))),window.location.href=a),{ok:!0,data:s}},finishLogin:o,finishLoginIfNeed:async(e="")=>{if(window.location.search.includes("code")&&window.location.search.includes("state"))return await o(e)},refreshToken:async t=>{var n;const{client:o,stateUserKey:r}=await i(),s=(e=>{const t=Nr(e);return t?JSON.parse(t):null})(r);if(!s)throw new Error("User not found in storage to refresh token");let a=t;if(!a){const t={};e.httpClient.hooks.beforeRequest(t),a=t.token}const l=await o.useRefreshToken({state:{refresh_token:a,session_state:s.session_state,profile:s.profile}});return await(null===(n=e.httpClient.hooks)||void 0===n?void 0:n.afterRequest({},new Response(JSON.stringify(l)))),l},logout:async(e,t=!1)=>{const{client:n,stateUserKey:o}=await i();e||(e={}),e.id_token_hint=e.id_token_hint||es(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const r=await n.createSignoutRequest(e),{url:s}=r;return Dr(o),t||window.location.replace(s),r}}},Hs=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>t=>{var n;return n=t.customStorage,Er=n,e(t)}),(e=>n=>{var{fpKey:i,fpLoad:o}=n,r=t(n,["fpKey","fpLoad"]);return Ir?(i&&o&&ls(i).catch((()=>null)),e(Ur(r,{beforeRequest:cs}))):e(r)}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.51.1"},t.baseHeaders)}))),(e=>t=>{const n=As(),i=As(),o=As(),r=As(),s=e(Ur(t,{afterRequest:async(e,t)=>{if(Pr(e,t))qr("Session invalidated, notifying subscribers with empty values"),i.pub(null),o.pub(null),n.pub(null),r.pub(null);else{const e=await(async e=>{const t=await Wr(e);return(null==t?void 0:t.user)||((null==t?void 0:t.hasOwnProperty("userId"))?t:void 0)})(t);e&&o.pub(e);const{sessionJwt:s,sessionExpiration:a,claims:l}=await Wr(t);s&&i.pub(s),l&&r.pub(l),(a||s)&&n.pub(a||42)}}})),a=Zi(s,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const s=await e(...t);return i.pub(null),o.pub(null),n.pub(null),r.pub(null),s}));return Object.assign(a,{onSessionTokenChange:i.sub,onUserChange:o.sub,onClaimsChange:r.sub,onIsAuthenticatedChange:e=>n.sub((t=>{e(!!t)}))})}),(e=>n=>{var i;const{enableFlowNonce:o=!0,nonceStoragePrefix:r=ds}=n,s=t(n,["enableFlowNonce","nonceStoragePrefix"]);if(!o)return e(s);((e=ds)=>{try{if(!_r)return;for(let o=0;o<(void 0,n=void 0,void 0,null!==(i=null!==(t=null==Er?void 0:Er.length)&&void 0!==t?t:Ir&&(null===(n=window.localStorage)||void 0===n?void 0:n.length))&&void 0!==i?i:0);o++){const t=Fr(o);if(t&&t.startsWith(e)){const n=Nr(t);if(n)try{JSON.parse(n).expiry<Date.now()&&Dr(t)}catch(e){Dr(t)}}}}catch(e){console.error("Error cleaning up expired nonces:",e)}var t,n,i})(r);const a=e(Ur(s,{afterRequest:async(e,t)=>{if(e.path!==hs&&e.path!==ps)return;const{nonce:n,executionId:i}=await(async(e,t)=>{try{const n=t.headers.get(us);let i=await t.clone().json().then((e=>(null==e?void 0:e.executionId)||null)).catch((()=>null));return i||(i=vs(e)),{nonce:n,executionId:gs(i)}}catch(e){return{nonce:null,executionId:null}}})(e,t);n&&i&&((e,t,n,i=ds)=>{try{const o=fs(e,i),r=n?172800:10800,s={value:t,expiry:Date.now()+1e3*r,isStart:n};Lr(o,JSON.stringify(s))}catch(e){console.error("Error setting flow nonce:",e)}})(i,n,e.path===hs,r)},beforeRequest:e=>{if(e.path===ps){const t=vs(e);if(t){const n=((e,t=ds)=>{try{const n=fs(e,t),i=Nr(n);if(!i)return null;const o=JSON.parse(i);return o.expiry<Date.now()?(((e,t=ds)=>{try{const n=fs(e,t);Dr(n)}catch(e){console.error("Error removing flow nonce:",e)}})(e,t),null):o.value}catch(e){return console.error("Error getting flow nonce:",e),null}})(t,r);n&&(e.headers=e.headers||{},e.headers[us]=n)}}return e}}));if(null===(i=a.flow)||void 0===i?void 0:i.next){let e=Promise.resolve();const t=a.flow.next.bind(a.flow);a.flow.next=async(...n)=>{const i=e;let o;e=new Promise((e=>{o=e})),await i;try{return await t(...n)}finally{o()}}}return a}),(e=>t=>{const n=e(Ur(t,{afterRequest:async(e,t)=>{if(Pr(e,t))return void Dr(Is);const n=await Wr(t);(null==n?void 0:n.sessionExpiration)&&Lr(Is,String(n.sessionExpiration))}}));return Zi(n,["logout","logoutAll","oidc.logout"],Cs)}),(e=>n=>{var{autoRefresh:i}=n,o=t(n,["autoRefresh"]);const r=!!i,s="object"==typeof i&&(null==i?void 0:i.customActivityTracking);if(!r||$r())return Object.assign(e(o),{markUserActive:()=>{zr("markUserActive() called but has no effect")}});const{clearAllTimers:a,setTimer:l}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,n)=>{e.push(setTimeout(t,n))}}})();let c,d,u=null,h=!1,p=!1;s&&(qr("Activity-based refresh enabled"),u=(()=>{let e=!0;return{hadActivity:()=>e,reset:()=>{e=!1},markActive:()=>{e=!0}}})()),Ir&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&c&&new Date>c&&(qr("Expiration time passed, refreshing session"),f.refresh(Yr()||d))}));const f=e(Ur(o,{afterRequest:async(e,t)=>{const{sessionJwt:n,refreshJwt:i,sessionExpiration:o,nextRefreshSeconds:r}=await Wr(t);if(Pr(e,t))qr("Session invalidated, canceling all timers"),a();else if(n||o){if(c=((e,t)=>{if(t)return new Date(1e3*t);qr("Could not extract expiration time from session token, trying to decode the token");try{const t=Zn(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(n,o),!c)return void qr("Could not extract expiration time from session token");d=i,h=r>0;const e=((e,t)=>{let n;var i;return t>0?(n=1e3*t,qr(`Using provided nextRefreshSeconds: ${t}s`)):n=((i=e)?i.getTime()-(new Date).getTime():0)-2e4,n>Cr&&(qr(`Timeout is too large (${n}ms), setting it to ${Cr}ms`),n=Cr),n})(c,r);if(a(),e<=2e4)return void qr("Session is too close to expiration, not setting refresh timer");const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});qr(`Setting refresh timer for ${t}. (${e}ms)`),u&&(u.reset(),p=!1),l((()=>{if(Ir&&"hidden"===document.visibilityState)qr("Skipping refresh due to timer - document is hidden");else{if(u&&h&&!u.hadActivity())return qr("Skipping refresh due to timer - user is idle"),void(p=!0);qr("Refreshing session due to timer"),f.refresh(Yr()||i)}}),e)}}}));return Object.assign(Zi(f,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return qr("Clearing all timers"),a(),n})),{markUserActive:u?()=>{qr("markUserActive() called"),h||qr("markUserActive() called but server does not have inactivity timeout configured (no nextRefreshSeconds)"),u.markActive(),p&&(qr("User became active after skipped refresh, triggering refresh"),p=!1,a(),f.refresh(Yr()||d))}:()=>{zr("markUserActive() called but customActivityTracking is not enabled — this call has no effect")}})}),(e=>n=>{var{storeLastAuthenticatedUser:i=!0,keepLastAuthenticatedUserAfterLogout:o=!1}=n,r=t(n,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!i)return Object.assign(e(r),{getLastUserLoginId:ys,getLastUserDisplayName:ks});const s=e(Ur(r,{afterRequest:async(e,t)=>{var n;const{userInfo:i,lastAuth:o}=await(async e=>{if(!(null==e?void 0:e.ok))return{userInfo:void 0,lastAuth:void 0};const t=await(null==e?void 0:e.clone().json()),n=Mr((null==t?void 0:t.authInfo)||t||{});return{userInfo:(null==n?void 0:n.user)||((null==n?void 0:n.hasOwnProperty("userId"))?n:void 0),lastAuth:t.lastAuth}})(t),r=null===(n=null==i?void 0:i.loginIds)||void 0===n?void 0:n[0],s=null==i?void 0:i.name;r?(bs(r),(e=>{Lr(ws,e)})(s)):(null==o?void 0:o.loginId)&&bs(o.loginId)}}));let a=Zi(s,["flow.start"],Ss);return a=Zi(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const i=await t(...n);return e||(Dr(ms),Dr(ws)),i})(o)),Object.assign(a,{getLastUserLoginId:ys,getLastUserDisplayName:ks})}),(e=>n=>{var{persistTokens:i,sessionTokenViaCookie:o,refreshTokenViaCookie:r,storagePrefix:s,refreshCookieName:a}=n,l=t(n,["persistTokens","sessionTokenViaCookie","refreshTokenViaCookie","storagePrefix","refreshCookieName"]);if(!i||!Ir)return e(Object.assign({refreshCookieName:a},l));let c;const d=e(Ur(Object.assign({refreshCookieName:a},l),{beforeRequest:ns(s,r,a),afterRequest:async(e,t)=>{if(Pr(e,t))qr("Session invalidated, clearing persisted tokens"),ts(s,o,r,c);else{const e=await Wr(t);e.cookieName?Lr(`${s||""}${Jr}`,e.cookieName):e.refreshJwt&&Dr(`${s||""}${Jr}`);const n=((e={},t=!1,n="",i=!1)=>{var o,r,s,a;const{sessionJwt:l,refreshJwt:c,trustedDeviceJwt:d}=e;let u;if(c)if(i){Dr(`${n}${Hr}`);const t=i.sameSite||"Strict",s=null===(o=i.secure)||void 0===o||o,a=null!==(r=i.domain)&&void 0!==r?r:e.cookieDomain,l=Gr(i);s&&"https:"!==window.location.protocol&&zr("Refresh token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass refreshTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const d=Object.assign(Object.assign({},e),{cookieSameSite:t,cookieSecure:s,cookieDomain:a});Kr(l,c,d);const h=Zr(a);u=Object.assign(Object.assign({},u),{refresh:{path:d.cookiePath,domain:h?a:void 0}})}else{const e=Gr(i);dr.remove(e),Lr(`${n}${Hr}`,c)}if(l)if(t){const n=t.sameSite||"Strict",i=null===(s=t.secure)||void 0===s||s,o=null!==(a=t.domain)&&void 0!==a?a:e.cookieDomain,r=Xr(t);i&&"https:"!==window.location.protocol&&zr("Session token cookie is configured with secure=true but the page is not using HTTPS. The cookie will not be set. To fix this, pass sessionTokenViaCookie: { secure: process.env['NODE_ENV'] !== 'development' }");const c=Object.assign(Object.assign({},e),{cookieSameSite:n,cookieSecure:i,cookieDomain:o});Kr(r,l,c);const d=Zr(o);u=Object.assign(Object.assign({},u),{session:{path:c.cookiePath,domain:d?o:void 0}})}else Lr(`${n}${Vr}`,l);return e.idToken&&Lr(`${n}${Br}`,e.idToken),d&&Lr(`${n}DTD`,d),u})(e,o,s,r);n&&(c=n)}}})),u=Zi(d,["logout","logoutAll","oidc.logout"],((e,t,n,i)=>o=>async(...r)=>{const s=await o(...r);return ts(e,t,n,null==i?void 0:i()),s})(s,o,r,(()=>c)));return Object.assign(u,{getRefreshToken:()=>Yr(s,r),getSessionToken:()=>Qr(s,o),getIdToken:()=>es(s)})}))((e=>{const t=lr(e),n=Vs(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async(i,o)=>{var r;if($r())return qr(`Refresh called in native flow: ${(new Error).stack}`),Promise.resolve({ok:!1,error:{errorCode:"J171000",errorDescription:"Refresh is not supported in native flows via the web SDK"}});if(e.oidcConfig)try{return await n.refreshToken(i),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161001",errorDescription:e.toString()}})}if(o&&!Nr(Is)&&!Nr(ms)&&!Nr("DSLI_DISABLED"))return Promise.resolve({ok:!0});const s=Qr(),a=Yr();let l="";if(e.getExternalToken)try{l=await(null===(r=e.getExternalToken)||void 0===r?void 0:r.call(e))}catch(e){qr("Error getting external token while refreshing",e)}return t.refresh(i,{dcs:s?"t":"f",dcr:a?"t":"f"},l,o)},logout:async i=>{if(e.oidcConfig)try{return await n.logout({id_token_hint:i}),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161000",errorDescription:e.toString()}})}return t.logout(i)},flow:Fs(t),webauthn:Ps(t),fedcm:(i=t,o=e.projectId,{onetap:{requestExchangeCode(e){Ns(i,e)},requestAuthentication(e){Ns(i,e)}},async oneTap(e,t,n,o,r){await Ds(i,{provider:e,oneTapConfig:t,loginOptions:n,onSkipped:o,onDismissed:r})},async launch(e){var t;const n={identity:{context:e||"signin",providers:[{configURL:i.httpClient.buildUrl(o+_s),clientId:o}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return i.refresh(r.token)},isSupported:()=>Ir&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=i.httpClient.buildUrl(o+_s);try{const i={identity:{context:e||"signin",providers:[{configURL:n,clientId:o}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(i));return!!r&&!!r.token}catch(e){return!1}}}),oidc:n});var i,o})),Bs=e=>{if(!e)return null;const t=(e=>{try{const t=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),n=decodeURIComponent(atob(t).split("").map((e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2))).join(""));return JSON.parse(n)}catch(e){return null}})(e);return(null==t?void 0:t.dct)||null},Js=e=>e.me.data,Ks=Nt(Js,(e=>e.userId)),Zs=Nt(Js,(e=>e.picture)),Xs=Nt(Js,(e=>e.email)),Gs=Nt(Js,(e=>e.verifiedEmail)),Ys=Nt(Js,(e=>e.name)),Qs=Nt(Js,(e=>e.phone)),ea=Nt(Js,(e=>e.verifiedPhone)),ta=Nt(Xs,Gs,((e,t)=>e&&""!==e.trim()&&!t?"Unverified":"")),na=Nt(Qs,ea,((e,t)=>e&&""!==e.trim()&&!t?"Unverified":"")),ia=Nt(Js,(e=>e.webauthn));Nt(Js,(e=>e.password));const oa=Nt(Js,(e=>e.TOTP)),ra=Nt(Js,(e=>e.customAttributes)),sa=Nt(Js,(e=>({givenName:e.givenName,middleName:e.middleName,familyName:e.familyName}))),aa=Nt((e=>e.devices.data),(e=>e.map((({id:e,name:t,deviceType:n,lastLoginTime:i,isCurrentDevice:o})=>({id:e,name:t,deviceType:n,lastLoginDate:1e3*parseInt(i,10),isCurrent:o}))))),la=Nt((e=>e.passkeys.data),(e=>e.map((({id:e,displayName:t,kind:n,createdTime:i})=>({id:e,name:t,passkeyType:n,createdAt:1e3*i}))))),ca=e=>e.notifications,da=Nt(Js,(e=>e.userTenants||[])),ua=e=>e.tenant.currentTenantId,ha=wn("tenant/select",((e,t)=>n(void 0,[e,t],void 0,(function*(e,{extra:{api:t},getState:n}){if(e===ua(n()))return null;const i=yield t.user.setCurrentTenant(e),o=i.sessionJwt||i.sessionToken;try{return{tenantId:Bs(o)}}catch(e){return console.error("Failed to switch tenant:",e),null}})))),pa={action:ha,reducer:Wn(ha)({onPending:e=>{e.tenant.previousTenantId=e.tenant.currentTenantId},onFulfilled:(e,t)=>{var n;e.tenant.currentTenantId=null===(n=t.payload)||void 0===n?void 0:n.tenantId,e.tenant.previousTenantId=null},onRejected:e=>{e.tenant.currentTenantId=e.tenant.previousTenantId,e.tenant.previousTenantId=null}},$n((e=>e.selectTenant)),(({getErrorMsg:e,getSuccessMsg:t})=>({onFulfilled:(e,n)=>{if(t){const i=t(n);i&&e.notifications.push({type:"success",msg:i})}},onRejected:(t,n)=>{if(e){const i=e(n);i&&t.notifications.push({type:"error",msg:i})}}}))({getErrorMsg:e=>{var t,n;const i=(null===(t=e.error)||void 0===t?void 0:t.message)||"";return"Error"===(null===(n=e.error)||void 0===n?void 0:n.name)?i:`${i||"Error"}`}}))},fa={me:{loading:!1,error:null,data:{}},devices:{loading:!1,error:null,data:[]},passkeys:{loading:!1,error:null,data:[]},tenant:{currentTenantId:null,previousTenantId:null},selectTenant:{loading:!1,error:null},notifications:[]},ga={me:"/v1/auth/me",devices:"/v1/mgmt/user/trusteddevices/list",passkeys:"/v1/mgmt/user/passkeys/list",selectTenant:"/v1/auth/tenant/select"},va=e=>n(void 0,void 0,void 0,(function*(){const t=yield e.text(),n=JSON.parse(t);if(!e.ok){const t=`${n.errorDescription}${n.errorMessage?`: ${n.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(n),e.text=()=>Promise.resolve(t)})),ma=[{tenantName:"Tenant 1",tenantId:"tn1",roleNames:["Role"]},{tenantName:"Tenant 2",tenantId:"tn2",roleNames:["Role"]}],wa=()=>n(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({loginIds:["user@company.com"],externalIds:["user@company.com"],userId:"user-1",name:"Test User",email:"user@company.com",roleNames:["Role"],phone:"+1-202-555-010",verifiedEmail:!0,verifiedPhone:!0,userTenants:ma,status:"enabled",editable:!0,createdTime:(new Date).getTime(),customAttributes:{},familyName:"",givenName:"",middleName:"",picture:void 0,password:!0,SAML:!1,test:!1,TOTP:!1,webauthn:!0})}))})),ba=()=>({devices:[{id:"device-id-1",name:"Device 1",deviceType:"desktop",lastLoginDate:17359776e5,isCurrent:!1},{id:"device-id-2",name:"Device 2",deviceType:"mobile",lastLoginDate:17387505e5,isCurrentDevice:!0},{id:"device-id-3",name:"Device 3",deviceType:"tablet",lastLoginDate:17412642e5,isCurrent:!1},{id:"device-id-4",name:"Device 4",deviceType:"unknown",lastLoginDate:17440371e5,isCurrent:!1},{id:"device-id-5",name:"Device 5",deviceType:"desktop",lastLoginDate:174672e7,isCurrent:!1}]}),ya=()=>({passkeys:[{id:"vendor-id-1",displayName:"Device 1",kind:"google",createdTime:1735977600,rpId:"example.com"},{id:"vendor-id-2",displayName:"Device 2",kind:"edge",createdTime:1738750500,rpId:"example.com"},{id:"vendor-id-3",displayName:"Device 3",kind:"apple",createdTime:1741264200,rpId:"example.com"}]}),ka=({httpClient:e,mock:t})=>({me:()=>n(void 0,void 0,void 0,(function*(){if(t)return wa();const n=yield e.get(ga.me);return yield va(n),n.json()})),setCurrentTenant:t=>n(void 0,void 0,void 0,(function*(){const n=yield e.post(ga.selectTenant,{tenant:t});return yield va(n),n.json()}))}),Sa=({httpClient:e,mock:t})=>({devices:i=>n(void 0,[i],void 0,(function*({userId:n}){if(t)return ba();const i=yield e.post(ga.devices,{identifiers:[n]});return yield va(i),i.json()}))}),Ia=({httpClient:e,mock:t})=>({listPasskeys:i=>n(void 0,[i],void 0,(function*({userId:n}){if(t)return ya();const i=yield e.post(ga.passkeys,{loginId:n});return yield va(i),i.json()}))}),Ca=c((e=>{var t,s,a,l;const c=r(E,x,b,j,Tn)(e);return l=class extends c{constructor(){super(...arguments),t.add(this),s.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get styleId(){return this.getAttribute("style-id")||we}get api(){return i(this,s,"f")||i(this,t,"m",a).call(this),i(this,s,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),this.observeAttributes(["project-id","base-url"],(()=>{i(this,s,"f")&&i(this,t,"m",a).call(this)}))}))}},s=new WeakMap,t=new WeakSet,a=function(){this.logger.debug("creating an sdk instance"),o(this,s,((e,t,i)=>{const o=Hs(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":i,"x-descope-widget-version":"0.14.0"}}));return{user:Object.assign(Object.assign({},ka({httpClient:o.httpClient,mock:t})),{logout:t?()=>n(void 0,void 0,void 0,(function*(){})):o.logout}),device:Object.assign({},Sa({httpClient:o.httpClient,mock:t})),passkey:Object.assign({},Ia({httpClient:o.httpClient,mock:t}))}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},"true"===this.mock,this.widgetId),"f")},l})),Aa=c((e=>{const t=r(xn({name:"widget",initialState:fa,reducers:{clearNotifications:e=>{e.notifications=[]},setCurrentTenantId:(e,{payload:t})=>{e.tenant.currentTenantId=t}},extraReducers:e=>{Ln.reducer(e),Fn.reducer(e),Vn.reducer(e),Bn.reducer(e),pa.reducer(e)},asyncActions:{getMe:Ln.action,listDevices:Fn.action,listPasskeys:Vn.action,logout:Bn.action,selectTenant:pa.action}}),A,b,Ca)(e);return class extends t{constructor(...e){super(...e),this.state=fa,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),xa="widget-flow",Oa=c((e=>{var t,o,s;return s=class extends(r(jn,A,ge,Aa,Tn,b,Ce,Mn)(e)){constructor(){super(...arguments),t.add(this)}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this);const r=Un(xa);r&&(!function(e){if(window.history.replaceState&&Un(e)){const t=new URL(window.location.href),n=new URLSearchParams(t.search);n.delete(e),t.search=n.toString(),window.history.replaceState({},"",t.toString())}}(xa),i(this,t,"m",o).call(this,r))}))}},t=new WeakSet,o=function(e){const t=this.createModal({"data-id":"redirect-flow"});t.setContent(this.createFlowTemplate({flowId:e}));new te((()=>{var e;return null===(e=t.ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>{t.close(),this.actions.getMe()})),t.afterClose=()=>{t.remove()},t.open()},s})),Ea=c((e=>{var t,o,a;return a=class extends(r(b,A,z,Z,Rn("user-profile-widget"),Aa)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return n(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.init)||void 0===n?void 0:n.call(this),yield this.actions.getMe(),yield i(this,t,"m",o).call(this),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,o=function(){return n(this,void 0,void 0,(function*(){const e=s(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},a})),ja=c((e=>class extends(r(Ce,x)(e)){syncFlowTheme(e){e.theme=this.theme,this.observeAttributes(["theme"],(()=>{e.theme=this.theme}))}})),Ra=c((e=>{var t,s,l,c,d,u,h,p,f;return f=class extends(r(jn,ja,Ce,Aa,b,Tn,Ea,ge,Mn)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),h.set(this,a((e=>{this.avatar.image=e}))),p.set(this,a((e=>{this.avatar.displayName=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",u).call(this),i(this,t,"m",c).call(this),i(this,h,"f").call(this,Zs(this.state)),i(this,p,"f").call(this,Ys(this.state)),this.subscribe(i(this,h,"f").bind(this),Zs),this.subscribe(i(this,p,"f").bind(this),Ys)}))}},s=new WeakMap,l=new WeakMap,h=new WeakMap,p=new WeakMap,t=new WeakSet,c=function(){this.avatar.flowId&&(o(this,s,this.createModal({"data-id":"update-pic","close-on-outside-click":"true"}),"f"),o(this,l,new te((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,s,"f").afterClose=i(this,t,"m",d).bind(this),i(this,t,"m",d).call(this),this.syncFlowTheme(i(this,l,"f")))},d=function(){i(this,s,"f").setContent(this.createFlowTemplate({flowId:this.avatar.flowId})),i(this,l,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe()}))},u=function(){this.avatar=new Q((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-avatar")}),{logger:this.logger}),this.avatar.onClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()}))},f})),Ta=c((e=>{var t,s,l,c,d,u,h,p,f,g,v,m,w;return w=class extends(r(jn,ja,Aa,b,Ea,Tn,ge,Mn)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),c.set(this,void 0),d.set(this,void 0),v.set(this,a((e=>{this.emailUserAttr.value=e}))),m.set(this,a((e=>{this.emailUserAttr.badgeLabel=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",g).call(this),i(this,t,"m",u).call(this),i(this,t,"m",p).call(this),i(this,v,"f").call(this,Xs(this.state)),i(this,m,"f").call(this,ta(this.state)),this.subscribe(i(this,v,"f").bind(this),Xs),this.subscribe(i(this,m,"f").bind(this),ta)}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,v=new WeakMap,m=new WeakMap,t=new WeakSet,u=function(){this.emailUserAttr.editFlowId&&(o(this,s,this.createModal({"data-id":"edit-email","close-on-outside-click":"true"}),"f"),o(this,l,new te((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,s,"f").afterClose=i(this,t,"m",h).bind(this),i(this,t,"m",h).call(this),this.syncFlowTheme(i(this,l,"f")))},h=function(){i(this,s,"f").setContent(this.createFlowTemplate({flowId:this.emailUserAttr.editFlowId})),i(this,l,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe()}))},p=function(){this.emailUserAttr.deleteFlowId&&(o(this,c,this.createModal({"data-id":"delete-email","close-on-outside-click":"true"}),"f"),o(this,d,new te((()=>{var e;return null===(e=i(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,c,"f").afterClose=i(this,t,"m",f).bind(this),i(this,t,"m",f).call(this),this.syncFlowTheme(i(this,d,"f")))},f=function(){i(this,c,"f").setContent(this.createFlowTemplate({flowId:this.emailUserAttr.deleteFlowId})),i(this,d,"f").onSuccess((()=>{i(this,c,"f").close(),this.actions.getMe()}))},g=function(){this.emailUserAttr=new de((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="email"]')}),{logger:this.logger}),this.emailUserAttr.onEditClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()})),this.emailUserAttr.onDeleteClick((()=>{var e;null===(e=i(this,c,"f"))||void 0===e||e.open()}))},w})),Ma=c((e=>{var t,o,s;return s=class extends(r(Aa,b,Ea,ge)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",o).call(this)}))}},t=new WeakSet,o=function(){this.logout=new ee((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-button[data-id="logout"]')}),{logger:this.logger}),this.logout.onClick((()=>n(this,void 0,void 0,(function*(){yield this.actions.logout(),this.dispatchEvent(new CustomEvent("logout"))}))))},s})),Ua=c((e=>{var t,s,l,c,d,u,h,p,f,g,v,m;return m=class extends(r(jn,ja,Aa,b,Ea,Tn,ge,Mn)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),c.set(this,void 0),d.set(this,void 0),v.set(this,a((e=>{this.nameUserAttr.value=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",g).call(this),i(this,t,"m",u).call(this),i(this,t,"m",p).call(this),i(this,v,"f").call(this,Ys(this.state)),this.subscribe(i(this,v,"f").bind(this),Ys)}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,v=new WeakMap,t=new WeakSet,u=function(){this.nameUserAttr.editFlowId&&(o(this,s,this.createModal({"data-id":"edit-name","close-on-outside-click":"true"}),"f"),o(this,l,new te((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,s,"f").afterClose=i(this,t,"m",h).bind(this),i(this,t,"m",h).call(this),this.syncFlowTheme(i(this,l,"f")))},h=function(){i(this,s,"f").setContent(this.createFlowTemplate({flowId:this.nameUserAttr.editFlowId})),i(this,l,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe()}))},p=function(){this.nameUserAttr.deleteFlowId&&(o(this,c,this.createModal({"data-id":"delete-name","close-on-outside-click":"true"}),"f"),o(this,d,new te((()=>{var e;return null===(e=i(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,c,"f").afterClose=i(this,t,"m",f).bind(this),i(this,t,"m",f).call(this),this.syncFlowTheme(i(this,d,"f")))},f=function(){i(this,c,"f").setContent(this.createFlowTemplate({flowId:this.nameUserAttr.deleteFlowId})),i(this,d,"f").onSuccess((()=>{i(this,c,"f").close(),this.actions.getMe()}))},g=function(){this.nameUserAttr=new de((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="name"]')}),{logger:this.logger}),this.nameUserAttr.onEditClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()})),this.nameUserAttr.onDeleteClick((()=>{var e;null===(e=i(this,c,"f"))||void 0===e||e.open()}))},m})),Wa=c((e=>{var t,s,l,c,d,u,h,p,f,g,v,m;return m=class extends(r(jn,ja,Aa,b,Ea,Tn,ge,Mn)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),c.set(this,void 0),d.set(this,void 0),v.set(this,a((e=>{this.passkeyUserAuthMethod.fulfilled=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",g).call(this),i(this,t,"m",u).call(this),i(this,t,"m",p).call(this),i(this,v,"f").call(this,ia(this.state)),this.subscribe(i(this,v,"f").bind(this),ia)}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,v=new WeakMap,t=new WeakSet,u=function(){this.passkeyUserAuthMethod.flowId&&(o(this,s,this.createModal({"data-id":"add-passkey","close-on-outside-click":"true"}),"f"),o(this,l,new te((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,s,"f").afterClose=i(this,t,"m",h).bind(this),i(this,t,"m",h).call(this),this.syncFlowTheme(i(this,l,"f")))},h=function(){i(this,s,"f").setContent(this.createFlowTemplate({flowId:this.passkeyUserAuthMethod.flowId})),i(this,l,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe()}))},p=function(){this.passkeyUserAuthMethod.fulfilledFlowId&&(o(this,c,this.createModal({"data-id":"remove-passkey","close-on-outside-click":"true"}),"f"),o(this,d,new te((()=>{var e;return null===(e=i(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,c,"f").afterClose=i(this,t,"m",f).bind(this),i(this,t,"m",f).call(this),this.syncFlowTheme(i(this,d,"f")))},f=function(){i(this,c,"f").setContent(this.createFlowTemplate({flowId:this.passkeyUserAuthMethod.fulfilledFlowId})),i(this,d,"f").onSuccess((()=>{i(this,c,"f").close(),this.actions.getMe()}))},g=function(){this.passkeyUserAuthMethod=new ue((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="passkey"]')}),{logger:this.logger}),this.passkeyUserAuthMethod.onUnfulfilledButtonClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()})),this.passkeyUserAuthMethod.onFulfilledButtonClick((()=>{var e;null===(e=i(this,c,"f"))||void 0===e||e.open()}))},m})),$a=c((e=>{var t,s,a,l,c,d;return d=class extends(r(jn,ja,Aa,b,Ea,Tn,ge,Mn)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),a.set(this,void 0)}initPasswordAuthMethod(){this.passwordUserAuthMethod=new ue((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="password"]')}),{logger:this.logger}),this.passwordUserAuthMethod.onUnfulfilledButtonClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),this.initPasswordAuthMethod(),i(this,t,"m",l).call(this)}))}},s=new WeakMap,a=new WeakMap,t=new WeakSet,l=function(){this.passwordUserAuthMethod.flowId&&(o(this,s,this.createModal({"data-id":"password","close-on-outside-click":"true"}),"f"),o(this,a,new te((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,s,"f").afterClose=i(this,t,"m",c).bind(this),i(this,t,"m",c).call(this),this.syncFlowTheme(i(this,a,"f")))},c=function(){i(this,s,"f").setContent(this.createFlowTemplate({flowId:this.passwordUserAuthMethod.flowId})),i(this,a,"f").onSuccess((()=>{i(this,s,"f").close()}))},d})),Pa=c((e=>{var t,s,l,c,d,u,h,p,f,g,v,m,w;return w=class extends(r(jn,ja,Aa,b,Ea,Tn,ge,Mn)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),c.set(this,void 0),d.set(this,void 0),v.set(this,a((e=>{this.phoneUserAttr.value=e}))),m.set(this,a((e=>{this.phoneUserAttr.badgeLabel=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",g).call(this),i(this,t,"m",u).call(this),i(this,t,"m",p).call(this),i(this,v,"f").call(this,Qs(this.state)),i(this,m,"f").call(this,na(this.state)),this.subscribe(i(this,v,"f").bind(this),Qs),this.subscribe(i(this,m,"f").bind(this),na)}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,v=new WeakMap,m=new WeakMap,t=new WeakSet,u=function(){this.phoneUserAttr.editFlowId&&(o(this,s,this.createModal({"data-id":"edit-phone","close-on-outside-click":"true"}),"f"),o(this,l,new te((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,s,"f").afterClose=i(this,t,"m",h).bind(this),i(this,t,"m",h).call(this),this.syncFlowTheme(i(this,l,"f")))},h=function(){i(this,s,"f").setContent(this.createFlowTemplate({flowId:this.phoneUserAttr.editFlowId})),i(this,l,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe()}))},p=function(){this.phoneUserAttr.deleteFlowId&&(o(this,c,this.createModal({"data-id":"delete-phone","close-on-outside-click":"true"}),"f"),o(this,d,new te((()=>{var e;return null===(e=i(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,c,"f").afterClose=i(this,t,"m",f).bind(this),i(this,t,"m",f).call(this),this.syncFlowTheme(i(this,d,"f")))},f=function(){i(this,c,"f").setContent(this.createFlowTemplate({flowId:this.phoneUserAttr.deleteFlowId})),i(this,d,"f").onSuccess((()=>{i(this,c,"f").close(),this.actions.getMe()}))},g=function(){this.phoneUserAttr=new de((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="phone"]')}),{logger:this.logger}),this.phoneUserAttr.onEditClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()})),this.phoneUserAttr.onDeleteClick((()=>{var e;null===(e=i(this,c,"f"))||void 0===e||e.open()}))},w})),_a=c((e=>{var t,s,l,c,d,u,h,p,f,g,v,m;return m=class extends(r(jn,ja,Aa,b,Ea,Tn,ge,Mn)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),c.set(this,void 0),d.set(this,void 0),v.set(this,a((e=>{this.totpUserAuthMethod.fulfilled=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",g).call(this),i(this,t,"m",u).call(this),i(this,t,"m",p).call(this),i(this,v,"f").call(this,oa(this.state)),this.subscribe(i(this,v,"f").bind(this),oa)}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,v=new WeakMap,t=new WeakSet,u=function(){this.totpUserAuthMethod.flowId&&(o(this,s,this.createModal({"data-id":"totp","close-on-outside-click":"true"}),"f"),o(this,l,new te((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,s,"f").afterClose=i(this,t,"m",h).bind(this),i(this,t,"m",h).call(this),this.syncFlowTheme(i(this,l,"f")))},h=function(){i(this,s,"f").setContent(this.createFlowTemplate({flowId:this.totpUserAuthMethod.flowId})),i(this,l,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe()}))},p=function(){this.totpUserAuthMethod.fulfilledFlowId&&(o(this,c,this.createModal({"data-id":"remove-totp","close-on-outside-click":"true"}),"f"),o(this,d,new te((()=>{var e;return null===(e=i(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,c,"f").afterClose=i(this,t,"m",f).bind(this),i(this,t,"m",f).call(this),this.syncFlowTheme(i(this,d,"f")))},f=function(){i(this,c,"f").setContent(this.createFlowTemplate({flowId:this.totpUserAuthMethod.fulfilledFlowId})),i(this,d,"f").onSuccess((()=>{i(this,c,"f").close(),this.actions.getMe()}))},g=function(){this.totpUserAuthMethod=new ue((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-auth-method[data-id="totp"]')}),{logger:this.logger}),this.totpUserAuthMethod.onUnfulfilledButtonClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()})),this.totpUserAuthMethod.onFulfilledButtonClick((()=>{var e;null===(e=i(this,c,"f"))||void 0===e||e.open()}))},m})),La=c((e=>{var t,o,s,l,c,d,u,h,p,f,g,v,m;return m=class extends(r(jn,ja,Aa,b,Ea,Tn,ge,Mn)(e)){constructor(){super(...arguments),t.add(this),o.set(this,{}),s.set(this,{}),l.set(this,{}),c.set(this,{}),d.set(this,{}),v.set(this,a((e=>{Object.keys(i(this,o,"f")).forEach((t=>{i(this,o,"f")[t].value=(e[t]||"").toString()}))})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",g).call(this),i(this,v,"f").call(this,sa(this.state)),this.subscribe(i(this,v,"f").bind(this),sa)}))}},o=new WeakMap,s=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,v=new WeakMap,t=new WeakSet,u=function(e){var t,n;null===(t=i(this,s,"f")[e])||void 0===t||t.setContent(this.createFlowTemplate({flowId:e})),null===(n=i(this,l,"f")[e])||void 0===n||n.onSuccess((()=>{var t;null===(t=i(this,s,"f")[e])||void 0===t||t.close(),this.actions.getMe()}))},h=function(e){var t,n;null===(t=i(this,c,"f")[e])||void 0===t||t.setContent(this.createFlowTemplate({flowId:e})),null===(n=i(this,d,"f")[e])||void 0===n||n.onSuccess((()=>{var t;null===(t=i(this,c,"f")[e])||void 0===t||t.close(),this.actions.getMe()}))},p=function(e,n,o){const r=e.getAttribute("edit-flow-id");r&&(i(this,s,"f")[r]=this.createModal({"data-id":`edit-${n}`,"close-on-outside-click":"true"}),i(this,l,"f")[r]=new te((()=>{var e,t;return null===(t=null===(e=i(this,s,"f")[r])||void 0===e?void 0:e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),i(this,s,"f")[r].afterClose=i(this,t,"m",u).bind(this,r),o.onEditClick((()=>{var e,t;null===(t=null===(e=i(this,s,"f"))||void 0===e?void 0:e[r])||void 0===t||t.open()})),i(this,t,"m",u).call(this,r),this.syncFlowTheme(i(this,l,"f")[r]))},f=function(e,n,o){const r=e.getAttribute("delete-flow-id");r&&(i(this,c,"f")[r]=this.createModal({"data-id":`delete-${n}`,"close-on-outside-click":"true"}),i(this,d,"f")[r]=new te((()=>{var e,t;return null===(t=null===(e=i(this,c,"f")[r])||void 0===e?void 0:e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),i(this,c,"f")[r].afterClose=i(this,t,"m",h).bind(this,r),o.onDeleteClick((()=>{var e,t;null===(t=null===(e=i(this,c,"f"))||void 0===e?void 0:e[r])||void 0===t||t.open()})),i(this,t,"m",h).call(this,r),this.syncFlowTheme(i(this,d,"f")[r]))},g=function(){var e;const n=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelectorAll('descope-user-attribute[data-id^="builtin."]');Array.from(n||[]).forEach((e=>{const n=e.getAttribute("data-id").replace("builtin.",""),r=new de(e,{logger:this.logger});i(this,o,"f")[n]=r,i(this,t,"m",p).call(this,e,n,r),i(this,t,"m",f).call(this,e,n,r)}))},m}));var Na;!function(e){e.TEXT="text",e.NUMBER="number",e.BOOLEAN="boolean",e.SINGLE_SELECT="singleSelect",e.ARRAY="array",e.DATE="date"}(Na||(Na={}));const Da=c((e=>{var t,o,s,l,c,d,u,h,p,f,g;return o=class extends(r(jn,ja,Aa,b,Ea,Tn,ge,Mn)(e)){constructor(){super(...arguments),t.add(this),s.set(this,{}),l.set(this,{}),c.set(this,{}),d.set(this,{}),p.set(this,a((e=>{var n;const r=null===(n=this.shadowRoot)||void 0===n?void 0:n.querySelectorAll('descope-user-attribute[data-id^="customAttributes."]');Array.from(r).forEach((n=>{const r=n.getAttribute("data-id").replace("customAttributes.",""),s=n.getAttribute("data-type")||Na.TEXT,a=e[r],l=new de(n,{logger:this.logger});l.value=o.getFormattedValue(s,a),i(this,t,"m",f).call(this,n,r,l),i(this,t,"m",g).call(this,n,r,l)}))})))}static getFormattedValue(e,t){return e===Na.DATE&&t?new Date(t).toLocaleString():e===Na.BOOLEAN&&void 0!==t?t?"True":"False":(t||"").toString()}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),i(this,p,"f").call(this,ra(this.state)),this.subscribe(i(this,p,"f").bind(this),ra)}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,p=new WeakMap,t=new WeakSet,u=function(e){var t,n;null===(t=i(this,s,"f")[e])||void 0===t||t.setContent(this.createFlowTemplate({flowId:e})),null===(n=i(this,l,"f")[e])||void 0===n||n.onSuccess((()=>{var t;null===(t=i(this,s,"f")[e])||void 0===t||t.close(),this.actions.getMe()}))},h=function(e){var t,n;null===(t=i(this,c,"f")[e])||void 0===t||t.setContent(this.createFlowTemplate({flowId:e})),null===(n=i(this,d,"f")[e])||void 0===n||n.onSuccess((()=>{var t;null===(t=i(this,c,"f")[e])||void 0===t||t.close(),this.actions.getMe()}))},f=function(e,n,o){const r=e.getAttribute("edit-flow-id");r&&(i(this,s,"f")[r]=this.createModal({"data-id":`edit-${n}`,"close-on-outside-click":"true"}),i(this,l,"f")[r]=new te((()=>{var e,t;return null===(t=null===(e=i(this,s,"f")[r])||void 0===e?void 0:e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),i(this,s,"f")[r].afterClose=i(this,t,"m",u).bind(this,r),o.onEditClick((()=>{var e,t;null===(t=null===(e=i(this,s,"f"))||void 0===e?void 0:e[r])||void 0===t||t.open()})),i(this,t,"m",u).call(this,r),this.syncFlowTheme(i(this,l,"f")[r]))},g=function(e,n,o){const r=e.getAttribute("delete-flow-id");r&&(i(this,c,"f")[r]=this.createModal({"data-id":`delete-${n}`,"close-on-outside-click":"true"}),i(this,d,"f")[r]=new te((()=>{var e,t;return null===(t=null===(e=i(this,c,"f")[r])||void 0===e?void 0:e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),i(this,c,"f")[r].afterClose=i(this,t,"m",h).bind(this,r),o.onDeleteClick((()=>{var e,t;null===(t=null===(e=i(this,c,"f"))||void 0===e?void 0:e[r])||void 0===t||t.open()})),i(this,t,"m",h).call(this,r),this.syncFlowTheme(i(this,d,"f")[r]))},o})),Fa=c((e=>{var t,s,l,c,d,u,h,p;return p=class extends(r(jn,ja,Ce,Aa,b,Tn,Ea,ge,Mn)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),this.updateDeviceList=a((e=>{this.deviceList.data=e}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),this.deviceList=new he((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-trusted-devices")}),{logger:this.logger}),this.deviceList.isExists&&(yield i(this,t,"m",h).call(this),i(this,t,"m",u).call(this,aa(this.state)),i(this,t,"m",c).call(this),this.subscribe(this.updateDeviceList.bind(this),aa))}))}},s=new WeakMap,l=new WeakMap,t=new WeakSet,c=function(){this.deviceList.flowId&&(o(this,s,this.createModal({"data-id":"untrust-device","close-on-outside-click":"true"}),"f"),o(this,l,new te((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,s,"f").afterClose=()=>i(this,t,"m",d).call(this,""),this.syncFlowTheme(i(this,l,"f")))},d=function(e=""){i(this,s,"f").setContent(this.createFlowTemplate({flowId:this.deviceList.flowId,form:{deviceId:e}})),i(this,l,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.listDevices({userId:Ks(this.state)})}))},u=function(e){this.deviceList.onRemoveDeviceClick((({id:e})=>{var n;i(this,t,"m",d).call(this,e),null===(n=i(this,s,"f"))||void 0===n||n.open()})),this.deviceList.data=e},h=function(){return n(this,void 0,void 0,(function*(){yield this.actions.listDevices({userId:Ks(this.state)})}))},p})),qa=c((e=>{var t,s,l,c,d,u,h,p,f,g,v,m;return m=class extends(r(jn,ja,Aa,b,Ea,Tn,ge,Mn)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),c.set(this,void 0),d.set(this,void 0),g.set(this,a((e=>{this.actions.listPasskeys({userId:e})}))),this.updatePasskeyList=a((e=>{this.userPasskeys.data=e}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),this.userPasskeys=new fe((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-user-passkeys")}),{logger:this.logger}),this.userPasskeys.isExists&&(i(this,t,"m",v).call(this,la(this.state)),i(this,t,"m",u).call(this),i(this,t,"m",p).call(this),this.subscribe(i(this,g,"f").bind(this),Ks),this.subscribe(this.updatePasskeyList.bind(this),la))}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,g=new WeakMap,t=new WeakSet,u=function(){this.userPasskeys.addPasskeyFlowId&&(o(this,s,this.createModal({"data-id":"add-user-passkey","close-on-outside-click":"true"}),"f"),o(this,l,new te((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),i(this,s,"f").afterClose=i(this,t,"m",h).bind(this),i(this,t,"m",h).call(this),this.syncFlowTheme(i(this,l,"f")))},h=function(){i(this,s,"f").setContent(this.createFlowTemplate({flowId:this.userPasskeys.addPasskeyFlowId})),i(this,l,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe(),this.actions.listPasskeys({userId:Ks(this.state)})}))},p=function(){this.userPasskeys.removePasskeyFlowId&&(o(this,c,this.createModal({"data-id":"remove-user-passkey","close-on-outside-click":"true"}),"f"),o(this,d,new te((()=>{var e;return null===(e=i(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(i(this,d,"f")))},f=function({externalId:e,credentialId:t}){i(this,c,"f").setContent(this.createFlowTemplate({flowId:this.userPasskeys.removePasskeyFlowId,form:{externalId:e,credentialId:t}})),i(this,d,"f").onSuccess((()=>{i(this,c,"f").close(),this.actions.getMe(),this.actions.listPasskeys({userId:Ks(this.state)})}))},v=function(e){this.updatePasskeyList(e),this.userPasskeys.onAddPasskeyClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()})),this.userPasskeys.onRemovePasskeyClick((({id:e})=>{var n;const o=Ks(this.state);i(this,t,"m",f).call(this,{externalId:o,credentialId:e}),null===(n=i(this,c,"f"))||void 0===n||n.open()}))},m}));const za={success:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Checkmark">\n<path id="Shape" d="M10.0485 15.6396C9.5799 15.171 8.8201 15.171 8.35147 15.6396C7.88284 16.1082 7.88284 16.868 8.35147 17.3367L12.7072 21.6924C13.1759 22.1611 13.9357 22.1611 14.4043 21.6924L24.7152 11.3815C25.1838 10.9129 25.1838 10.1531 24.7152 9.68448C24.2466 9.21585 23.4868 9.21585 23.0181 9.68448L13.5558 19.1469L10.0485 15.6396Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,error:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Vector" d="M15.9998 26.6558C10.1118 26.6558 5.34375 21.8878 5.34375 15.9998C5.34375 10.1118 10.1118 5.34375 15.9998 5.34375C21.8878 5.34375 26.6558 10.1118 26.6558 15.9998C26.6558 21.8878 21.8878 26.6558 15.9998 26.6558ZM15.9998 24.4798C20.6718 24.4798 24.4798 20.7038 24.4798 15.9998C24.4798 11.3278 20.7038 7.51975 15.9998 7.51975C11.3278 7.51975 7.51975 11.2958 7.51975 15.9998C7.51975 20.6718 11.2958 24.4798 15.9998 24.4798ZM15.3278 9.34375H16.6718C17.0558 9.34375 17.3438 9.63175 17.3118 9.98375L16.9598 16.9278C16.9598 17.1838 16.7678 17.3438 16.5438 17.3438H15.4558C15.2318 17.3438 15.0398 17.1518 15.0398 16.9278L14.6878 9.98375C14.6878 9.63175 14.9758 9.34375 15.3278 9.34375ZM15.4558 19.4558H16.5438C16.9278 19.4558 17.2158 19.7438 17.1838 20.1278V21.1838C17.1838 21.5678 16.8958 21.8558 16.5438 21.8558H15.4558C15.0718 21.8558 14.7838 21.5678 14.7838 21.1838V20.1278C14.7838 19.7438 15.0718 19.4558 15.4558 19.4558Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild},Va=c((e=>{var t,o,s,l,c;return c=class extends(r(b,Aa,me,A)(e)){constructor(){super(...arguments),t.add(this),l.set(this,a((e=>{e.length&&(e.forEach((({type:e,msg:n})=>{const r=i(this,t,"m",s).call(this,e);r.setContent(i(this,t,"m",o).call(this,{type:e,msg:n})),r.show()})),setTimeout((()=>this.actions.clearNotifications())))})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.subscribe(i(this,l,"f").bind(this),ca)}))}},l=new WeakMap,t=new WeakSet,o=function({type:e,msg:t}){const n=za[e],i=Object.assign((new DOMParser).parseFromString('<svg width="2em" height="2em" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Shape" d="M10.6712 12L7.27521 8.60406C6.90826 8.23711 6.90826 7.64216 7.27521 7.27521C7.64216 6.90826 8.23711 6.90826 8.60406 7.27521L12 10.6712L15.3959 7.27521C15.7629 6.90826 16.3578 6.90826 16.7248 7.27521C17.0917 7.64216 17.0917 8.23711 16.7248 8.60406L13.3288 12L16.7248 15.3959C17.0917 15.7629 17.0917 16.3578 16.7248 16.7248C16.3578 17.0917 15.7629 17.0917 15.3959 16.7248L12 13.3288L8.60406 16.7248C8.23711 17.0917 7.64216 17.0917 7.27521 16.7248C6.90826 16.3578 6.90826 15.7629 7.27521 15.3959L10.6712 12Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,{slot:"close"});return`${(null==n?void 0:n.outerHTML)||""}${t}${i.outerHTML}`},s=function(e){return this.createNotification({mode:e,duration:"error"===e?0:3e3,position:"bottom-start",size:"sm"})},c})),Ha=c((e=>{var t,s,a,l,c,d,u,h,p,f,g;return g=class extends(r(Aa,b,Ea)(e)){constructor(){super(...arguments),t.add(this),s.set(this,null),l.set(this,(e=>n(this,void 0,void 0,(function*(){const t=e.target.value;yield this.actions.selectTenant(t)})))),c.set(this,(e=>{const n=ua(e);this.tenantSelector.value!==n&&i(this,t,"m",p).call(this,n);const{loading:r,error:a}=e.selectTenant,l=null!==e.tenant.previousTenantId,c=n!==i(this,s,"f");!n||r||a||l||!c||(o(this,s,n,"f"),i(this,t,"m",d).call(this))}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),this.actions.setCurrentTenantId((()=>{const e=Qr();return Bs(e)})()),i(this,t,"m",a).call(this),i(this,t,"m",f).call(this),i(this,t,"m",h).call(this,da(this.state)),this.subscribe(i(this,c,"f").bind(this))}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,t=new WeakSet,a=function(){this.tenantSelector=new pe((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-combo-box[name="tenantSelector"]')}),{logger:this.logger}),this.tenantSelector.onInput(i(this,l,"f"))},d=function(){const e=ua(this.state);this.dispatchEvent(new CustomEvent("tenant-changed",{bubbles:!0,composed:!0,detail:{tenantId:e}})),this.tenantSelector.shouldReload&&i(this,t,"m",u).call(this)},u=function(){setTimeout((()=>window.location.reload()),this.tenantSelector.refreshTimeout)},h=function(e){return n(this,void 0,void 0,(function*(){const t=e.map((e=>({label:e.tenantName||e.tenantId,value:e.tenantId})));yield this.tenantSelector.setData(t)}))},p=function(e){e&&(this.tenantSelector.value=e)},f=function(){this.tenantSelector.setAllowCustomValue(!0),setTimeout((()=>{i(this,t,"m",p).call(this,ua(this.state)),this.tenantSelector.setAllowCustomValue(!1)}))},g})),Ba=c((e=>{var t,s,a,l,c,d,u,h,p,f,g;return g=class extends(r(jn,ja,Aa,ge,b,Ea,Mn)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),a.set(this,void 0),l.set(this,[]),c.set(this,null)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",h).call(this),i(this,t,"m",u).call(this),i(this,l,"f").forEach((e=>e.enable()))}))}},s=new WeakMap,a=new WeakMap,l=new WeakMap,c=new WeakMap,t=new WeakSet,d=function(e){const n=new ne(e,{logger:this.logger});n.onClick((()=>{i(this,t,"m",f).call(this,n.flowId,Ks(this.state))})),i(this,l,"f").push(n)},u=function(){var e;const n=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelectorAll("[data-generic-flow-button-id]");Array.from(n).forEach((e=>{i(this,t,"m",d).call(this,e)}))},h=function(){o(this,s,this.createModal({"data-id":"generic-flow-modal","close-on-outside-click":"true"}),"f"),i(this,s,"f").afterClose=()=>{var e;null===(e=i(this,c,"f"))||void 0===e||e.call(this),o(this,c,null,"f")},o(this,a,new te((()=>{var e;return null===(e=i(this,s,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(i(this,a,"f"))},p=function(){var e;i(this,s,"f").open(),null===(e=i(this,c,"f"))||void 0===e||e.call(this)},f=function(e,n){i(this,s,"f").setContent(this.createFlowTemplate({flowId:e,client:{userId:n}}));o(this,c,i(this,a,"f").onPageUpdated((()=>i(this,t,"m",p).call(this))),"f"),i(this,a,"f").onSuccess((()=>{i(this,s,"f").close(),this.actions.getMe()}))},g})),Ja=c((e=>class extends(r($,Ce,Oa,Da,Ta,Ra,Ua,Pa,Wa,$a,_a,La,Ma,Fa,qa,Va,Ha,Ba)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),Ka=r((e=>class extends(Ja(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this);(customElements.get("descope-wc")||(yield Promise.resolve().then((function(){return iu})).then((e=>e.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.14.0"}}}))}}))(HTMLElement),Za="undefined"!=typeof localStorage,Xa="J151000",Ga="E103205",Ya=Za&&localStorage.getItem("base.content.url")||"",Qa="base.ui.components.url";Za&&localStorage.getItem(Qa),Za&&localStorage.getItem(Qa);const el="descope-login-flow",tl="code",nl="redirect_mode",il="err",ol="data-exclude-field",rl="data-exclude-next",sl="dls_last_auth",al="state_id",ll="saml_idp_state_id",cl="wsfed_idp_state_id",dl="saml_idp_username",ul="descope_idp_initiated",hl="sso_app_id",pl="custom_app_id",fl="third_party_app_id",gl="third_party_app_state_id",vl="oidc_login_hint",ml="oidc_prompt",wl="oidc_resource",bl="oidc_error_redirect_uri",yl="application_scopes",kl="data-type",Sl="redirect",Il="poll",Cl="webauthnCreate",Al="webauthnGet",xl="nativeBridge",Ol="loadForm",El="submit",jl="polling",Rl=["descope-multi-select-combo-box","descope-text-area"],Tl="dls_last_auth_in_flight",Ml=["cssVars","componentsConfig","inputs","errorText","errorType","clientScripts"];var Ul;!function(e){e.backward="backward",e.forward="forward"}(Ul||(Ul={}));const Wl=["descope-enriched-text"];function $l(e){return new URLSearchParams(window.location.search).get(e)}function Pl(e){if(window.history.replaceState&&$l(e)){const t=new URL(window.location.href),n=new URLSearchParams(t.search);n.delete(e),t.search=n.toString(),window.history.replaceState({},"",t.toString())}}function _l(e,t){if(!t)return;const n=+e,i=+t;return Number.isNaN(n)||Number.isNaN(i)?void 0:n>i?Ul.forward:n<i?Ul.backward:void 0}const Ll=e=>{let[t="",n=""]=($l(el)||"").split("_");const i=(e=>{var t;return(null===(t=/(.*)\|#\|.*/.exec(e))||void 0===t?void 0:t[1])||""})(t);return(!e||i&&i!==e)&&(t="",n=""),{executionId:t,stepId:n,executionFlowId:i}};function Nl(){Pl(el)}const Dl=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),Fl=(e,t)=>{const{executionId:n,stepId:i,executionFlowId:o}=Ll(e);if(o&&e!==o)return t.debug("Flow id does not match the execution flow id, skipping url params handling"),{ssoQueryParams:{}};(n||i)&&Nl();const r=$l("t")||void 0;r&&Pl("t");const s=$l(tl)||void 0;s&&Pl(tl);const a="popup"===$l(nl);a&&Pl(nl);const l=$l(il)||void 0;l&&Pl(il);const{redirectAuthCodeChallenge:c,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthInitiator:h}={redirectAuthCodeChallenge:$l("ra-challenge"),redirectAuthCallbackUrl:$l("ra-callback"),redirectAuthBackupCallbackUri:$l("ra-backup-callback"),redirectAuthInitiator:$l("ra-initiator")},p=$l(al);p&&Pl(al);const f=$l(ll);f&&Pl(ll);const g=$l(cl);g&&Pl(cl);const v=$l(dl);f&&Pl(dl);const m=$l(ul);m&&Pl(ul);const w=$l(hl);w&&Pl(hl);const b=$l(pl);b&&Pl(pl);const y=$l(fl);y&&Pl(fl);const k=$l(gl);k&&Pl(gl);const S=$l(yl);S&&Pl(yl);const I=$l(vl);I&&Pl(vl);const C=$l(ml);C&&Pl(ml);const A=$l(bl);A&&Pl(bl);const x=$l(wl);return x&&Pl(wl),{executionId:n,stepId:i,token:r,code:s,isPopup:a,exchangeError:l,redirectAuthCodeChallenge:c,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:u,redirectAuthInitiator:h,ssoQueryParams:{oidcIdpStateId:p,samlIdpStateId:f,wsfedIdpStateId:g,samlIdpUsername:v,descopeIdpInitiated:"true"===m,ssoAppId:w,customAppId:b,oidcLoginHint:I,oidcPrompt:C,oidcErrorRedirectUri:A,oidcResource:x,thirdPartyAppId:y,thirdPartyAppStateId:k,applicationScopes:S}}},ql=e=>{let t,n;return Object.assign(((...i)=>{return t&&(r=i,(o=t).length===r.length&&o.every(((e,t)=>e===r[t])))||(t=i,n=e(...i)),n;var o,r}),{reset:()=>{t=void 0,n=void 0}})},zl=(e,t,n)=>{if(!0===t||"skipFirstScreen"===t&&!n){const t=e.querySelector('*[name]:not([auto-focus="false"]):not([aria-hidden="true"])');setTimeout((()=>{null==t||t.focus()}))}};function Vl(e,t,n){return new Promise(((i,o)=>{let r=!1;const s=setTimeout((()=>{r=!0,void 0!==n?i(n):o(new Error(`Promise timed out after ${e} ms`))}),e);t.then((e=>{r||(clearTimeout(s),i(e))})).catch((e=>{r||(clearTimeout(s),o(e))}))}))}const Hl=(e,{oidcIdpStateId:t,samlIdpStateId:n,wsfedIdpStateId:i,samlIdpUsername:o,ssoAppId:r,customAppId:s,oidcLoginHint:a,oidcPrompt:l,oidcErrorRedirectUri:c,oidcResource:d,thirdPartyAppId:u,thirdPartyAppStateId:h,applicationScopes:p})=>!(!e||t||n||i||o||r||s||a||l||c||d||u||h||p),Bl=e=>null==e?void 0:e.submit(),Jl=(e,t)=>{const n=t.find((t=>e[t]));return n?e[n]:null},Kl=(e,t=100)=>{let n;return function(...i){n||e.apply(this,i),clearTimeout(n),n=setTimeout((()=>{n=null}),t)}},Zl=e=>{const t=Object.assign({},e);return e.inboundAppApproveScopes&&(t.thirdPartyAppApproveScopes=e.inboundAppApproveScopes),t};function Xl(e,t){return`sdkScriptsResults.${t?`${e}_${t}`:e}`}var Gl,Yl,Ql,ec;function tc(e,t){const n=Object.getOwnPropertyNames(e),i=Object.getOwnPropertyNames(t);if(n.length!==i.length)return!1;for(let i=0;i<n.length;i+=1){const o=n[i],r=e[o],s=t[o];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!tc(r,s))return!1}else if(r!==s)return!1}return!0}let nc=class{constructor(e={},{forceUpdate:t=!1}={}){Gl.set(this,void 0),Yl.set(this,{}),Ql.set(this,0),ec.set(this,!0),this.update=e=>{const t="function"==typeof e?e(i(this,Gl,"f")):e,n=Object.assign(Object.assign({},i(this,Gl,"f")),t),r=i(this,Gl,"f");o(this,Gl,n,"f"),Object.freeze(i(this,Gl,"f")),setTimeout((()=>{Object.values(i(this,Yl,"f")).forEach((({cb:e,selector:t,forceUpdate:o})=>{const s=t(r),a=t(n);(i(this,ec,"f")||o||(function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(a)?!tc(s,a):s!==a))&&e(a,s,((e,t)=>n=>e[n]!==t[n])(a,s))}))}),0)},o(this,Gl,e,"f"),o(this,ec,t,"f")}get current(){return Object.assign({},i(this,Gl,"f"))}set forceUpdate(e){o(this,ec,e,"f")}subscribe(e,t=e=>e,{forceUpdate:n=!1}={}){return o(this,Ql,i(this,Ql,"f")+1,"f"),i(this,Yl,"f")[i(this,Ql,"f")]={cb:e,selector:t,forceUpdate:n},i(this,Ql,"f").toString()}unsubscribe(e){const t=!!i(this,Yl,"f")[e];return t&&delete i(this,Yl,"f")[e],t}unsubscribeAll(){return o(this,Yl,{},"f"),!0}};Gl=new WeakMap,Yl=new WeakMap,Ql=new WeakMap,ec=new WeakMap;const ic=["*","#","/","(",")","[","]","_","<",">","`"],oc=e=>"string"!=typeof e?e:e.replace((e=>{const t=ic.map((t=>`${e}${t}`)).join("|");return new RegExp(`(${t})`,"g")})("\\"),"\\$1"),rc=["disabled"],sc=(e,t)=>{Object.entries(t||{}).forEach((([t,n])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${ol}])`)).forEach((e=>{e.value=n}))}))},ac=(e,t)=>t.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),e),lc=(e,t,n)=>e.replace(/{{(.+?)}}/g,((e,i)=>n?oc(ac(t,i)):ac(t,i))),cc=(e,t,n)=>{e.querySelectorAll(`[${kl}="${t}"]`).forEach((e=>{e.setAttribute("href",n)}))},dc=(e,t,n)=>{var i,o;const r=null===(i=customElements.get(t))||void 0===i?void 0:i.cssVarList.url;n&&r&&(null===(o=null==e?void 0:e.style)||void 0===o||o.setProperty(r,`url(data:image/jpg;base64,${n})`))},uc=(e,n,i,o)=>{var r,s;cc(e,"totp-link",null===(r=null==n?void 0:n.totp)||void 0===r?void 0:r.provisionUrl),cc(e,"notp-link",null===(s=null==n?void 0:n.notp)||void 0===s?void 0:s.redirectUrl),((e,t)=>{e.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((e=>{const n=(e=>Wl.includes(e))(e.localName);e.textContent=lc(e.textContent,t,n);const i=e.getAttribute("href");i&&e.setAttribute("href",lc(i,t))}))})(e,n),((e,n,i)=>{if(!n)return;const{componentsDynamicAttrs:o}=n,r=t(n,["componentsDynamicAttrs"]),s=Object.keys(r).reduce(((e,t)=>(e[`[name=${t}]`]=r[t],e)),{});o&&Object.keys(o).forEach((e=>{const t=o[e];if(t){const{attributes:n}=t;n&&Object.keys(n).length&&(s[e]=n)}})),Object.keys(s).forEach((t=>{e.querySelectorAll(t).forEach((e=>{const n=s[t];Object.keys(n).forEach((t=>{let o=n[t];if("string"!=typeof o)try{o=JSON.stringify(o)}catch(e){i.error(`Could not stringify value "${o}" for "${t}"`,e.message),o=""}e.setAttribute(t,o)}))}))}))})(e,null==n?void 0:n.componentsConfig,o),((e,t)=>{e.querySelectorAll("[data-has-dynamic-attr-values]").forEach((e=>{Array.from(e.attributes).forEach((e=>{e.value=lc(e.value,t)}))}))})(e,n),((e,t)=>{Object.entries(t).forEach((([t,n])=>{e.querySelectorAll(`[name="${t}"]`).forEach((e=>{Object.entries(n).forEach((([t,n])=>{rc.includes(t)&&e.setAttribute(t,n)}))}))}))})(e,i)},hc=ql((()=>n(void 0,void 0,void 0,(function*(){var e,t;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const n=Promise.all([null===(e=window.PublicKeyCredential)||void 0===e?void 0:e.isConditionalMediationAvailable(),null===(t=window.PublicKeyCredential)||void 0===t?void 0:t.isUserVerifyingPlatformAuthenticatorAvailable()]).then((e=>e.every((e=>!!e)))),i=(()=>{var e;const t=null===(e=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===e?void 0:e.brands,n=null==t?void 0:t.find((({brand:e,version:t})=>"Chromium"===e&&parseFloat(t)));return n?n.version:0})()>=108;return yield Vl(100,n,i)}catch(e){return console.error("Conditional login check failed",e),!1}}))));let pc;const fc=(e,t)=>{pc?pc.setItem(e,t):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.setItem(e,t)},gc=e=>pc?pc.getItem(e):void 0!==(null===window||void 0===window?void 0:window.localStorage)?window.localStorage.getItem(e):null,vc="dls_ab_testing_id",mc={"lastAuth.loginId":{"not-empty":e=>{var t;return!!e.loginId||!!(null===(t=e.lastAuth)||void 0===t?void 0:t.loginId)},empty:e=>{var t;return!e.loginId&&!(null===(t=e.lastAuth)||void 0===t?void 0:t.loginId)}},idpInitiated:{"is-true":e=>!!e.code,"is-false":e=>!e.code},externalToken:{"is-true":e=>!!e.token,"is-false":e=>!e.token},abTestingKey:{"greater-than":(e,t)=>(e.abTestingKey||0)>t,"less-than":(e,t)=>(e.abTestingKey||0)<t,"greater-than-or-equal":(e,t)=>(e.abTestingKey||0)>=t,"less-than-or-equal":(e,t)=>(e.abTestingKey||0)<=t,"in-range":(e,t)=>{const[n,i]=t?t.split(",").map(Number):[void 0,void 0];return(e.abTestingKey||0)>=(null!=n?n:0)&&(e.abTestingKey||0)<=(null!=i?i:0)},"not-in-range":(e,t)=>{const[n,i]=t?t.split(",").map(Number):[void 0,void 0];return!(void 0!==n&&void 0!==i&&!Number.isNaN(n)&&!Number.isNaN(i))||(e.abTestingKey||0)<n||(e.abTestingKey||0)>i},"devised-by":(e,t)=>{const n=Number(t);return!Number.isNaN(n)&&(e.abTestingKey||0)%n==0}}};function wc(e,t){const n={};try{Object.assign(n,JSON.parse(gc(sl)))}catch(e){null==t||t.warn("[Descope] Failed to read last auth from storage",String(e))}return n.loginId||e?n:{}}function bc(e,t){(null==e?void 0:e.authMethod)&&(t&&!e.loginId||fc(sl,JSON.stringify(e)))}function yc(){try{return JSON.parse(gc(Tl)||"{}")}catch(e){return{}}}function kc(e){try{(e=>{pc?pc.removeItem(e):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.removeItem(e)})(Tl)}catch(t){null==e||e.warn("[Descope] Failed to clear in-flight last auth storage",String(t))}}const Sc=(e,t="")=>Object.keys(e).reduce(((n,i)=>{var o;if(Array.isArray(e[i]))return Object.assign(Object.assign({},n),{[i]:{value:e[i].map((e=>"object"==typeof e&&null!==e?Sc(e):e))}});if("object"==typeof e[i]&&null!==e[i]&&!(null===(o=e[i])||void 0===o?void 0:o.value))return Object.assign(Object.assign({},n),Sc(e[i],`${t+i}.`));const r="object"==typeof e[i]?e[i]:{value:e[i]},s=Object.assign(Object.assign({},n),{[t+i]:r,[`form.${t}${i}`]:r});return"displayName"===i?Object.assign(Object.assign({},s),{[`${t}fullName`]:r,[`form.${t}fullName`]:r}):s}),[]),Ic=c((e=>{var t,n,o,r;return r=class extends e{constructor(){super(...arguments),t.add(this)}connectedCallback(){var e;i(this,t,"m",n).call(this)&&i(this,t,"m",o).call(this),null===(e=super.connectedCallback)||void 0===e||e.call(this)}},t=new WeakSet,n=function(){return!this.shadowRoot.host.closest("form")&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)},o=function(){const e=this.shadowRoot.host,t=document.createElement("form");t.style.width="100%",t.style.height="100%",e.parentElement.appendChild(t),t.appendChild(e)},r})),Cc=["input","change"];function Ac(e){if("number"==typeof e&&Number.isFinite(e))return{value:e,ok:!0};if("boolean"==typeof e)return{value:e?1:0,ok:!0};if("string"==typeof e){if(""===e.trim())return{value:0,ok:!1};const t=Number(e);if(Number.isFinite(t))return{value:t,ok:!0}}return{value:0,ok:!1}}function xc(e){return null==e?"":"string"==typeof e?e:"boolean"==typeof e?e?"true":"false":"number"==typeof e?Number.isFinite(e)?String(e):"":String(e)}function Oc(e){if("boolean"==typeof e)return{value:e,ok:!0};if("string"==typeof e){if("true"===e)return{value:!0,ok:!0};if("false"===e)return{value:!1,ok:!0}}return"number"==typeof e?{value:0!==e,ok:!0}:{value:!1,ok:!1}}function Ec(e){return Array.isArray(e)?e:"string"==typeof e?e.split(","):null}function jc(e){return null==e||("string"==typeof e?""===e:Array.isArray(e)?0===e.length:"object"==typeof e&&0===Object.keys(e).length)}const Rc=new Map,Tc={equal:(e,t)=>e===t||xc(e)===xc(t),"not-equal":(e,t)=>e!==t&&xc(e)!==xc(t),contains:(e,t)=>Array.isArray(e)?e.includes(t):"string"==typeof e&&e.includes(xc(t)),"doesnt-contains":(e,t)=>Array.isArray(e)?!e.includes(t):"string"==typeof e&&!e.includes(xc(t)),"greater-than":(e,t)=>{const n=Ac(e),i=Ac(t);return n.ok&&i.ok&&n.value>i.value},"greater-than-or-equal":(e,t)=>{const n=Ac(e),i=Ac(t);return n.ok&&i.ok&&n.value>=i.value},"less-than":(e,t)=>{const n=Ac(e),i=Ac(t);return n.ok&&i.ok&&n.value<i.value},"less-than-or-equal":(e,t)=>{const n=Ac(e),i=Ac(t);return n.ok&&i.ok&&n.value<=i.value},empty:e=>jc(e),"not-empty":e=>!jc(e),"is-true":e=>{const t=Oc(e);return t.ok&&t.value},"is-false":e=>{const t=Oc(e);return t.ok&&!t.value},in:(e,t)=>{const n=Ec(t);return null!==n&&n.includes(e)},"not-in":(e,t)=>{const n=Ec(t);return null!==n&&!n.includes(e)},matches:(e,t)=>{if("string"!=typeof e)return!1;const n=function(e){var t;if(Rc.has(e))return null!==(t=Rc.get(e))&&void 0!==t?t:null;let n;try{n=new RegExp(e)}catch(e){n=null}return Rc.set(e,n),n}(xc(t));return null!==n&&n.test(e)}};function Mc(e,t){var n;if(e)return"form"===e.kind&&e.form?t[e.form]:"list"===e.kind?(null!==(n=e.items)&&void 0!==n?n:[]).map((e=>Mc(e,t))):e.value}function Uc(e,t){const n=Tc[e.operator];return!!n&&n(Mc(e.target,t),Mc(e.predicate,t))}function Wc(e,t){const n={};return(null!=e?e:[]).forEach((e=>{var i;(function(e,t){var n;return(null!==(n=e.rules)&&void 0!==n?n:[]).some((e=>function(e,t){var n;const i=null!==(n=e.atomicConditions)&&void 0!==n?n:[];return!!i.length&&(e.logicalOr?i.some((e=>Uc(e,t))):i.every((e=>Uc(e,t))))}(e,t)))})(e,t)&&(null!==(i=e.componentIds)&&void 0!==i?i:[]).forEach((t=>{n[t]=e.action}))})),n}const $c=["hide","disable","read-only"];const Pc=/(["\\])/g;function _c(e){return"undefined"!=typeof CSS&&"function"==typeof CSS.escape?CSS.escape(e):e.replace(Pc,"\\$1")}function Lc(e,t){return Array.from(e.querySelectorAll(`[id="${_c(t)}"]`))}function Nc(e,t,n){return Object.keys(t).forEach((i=>{const o=t[i];n[i]!==o&&Lc(e,i).forEach((e=>function(e,t){switch(t){case"hide":e.classList.remove("hidden");break;case"disable":e.removeAttribute("disabled");break;case"read-only":e.removeAttribute("readonly")}}(e,o)))})),Object.keys(n).forEach((i=>{const o=n[i],r=t[i];o!==r&&Lc(e,i).forEach((e=>function(e,t){switch(t){case"hide":e.classList.add("hidden");break;case"disable":e.setAttribute("disabled","true");break;case"read-only":e.setAttribute("readonly","true")}}(e,o)))})),Object.assign({},n)}const Dc="component-conditions:";function Fc(e){return e instanceof HTMLInputElement?"checkbox"===e.type?e.checked:e.value:"checked"in e?e.checked:"value"in e?e.value:void 0}function qc(e,t){const n=Object.keys(e),i=Object.keys(t);return n.length===i.length&&n.every((n=>e[n]===t[n]))}function zc(){return{conditions:[],touchedIds:new Set,snapshot:{},applied:{},serverBaseline:{},debounceTimer:null,paused:!1,unsubscribePauseListener:null,inputHandler:()=>{},root:null}}function Vc(e,t,n){const i={};return n.forEach((n=>{e[n]?i[n]=e[n]:t[n]&&(i[n]=t[n])})),i}const Hc=c((e=>{var t,n,s,a,l,c;const d=r(b)(e);return c=class extends d{constructor(){super(...arguments),t.add(this),n.set(this,zc())}applyComponentsState(e,t){t&&(Object.entries(t).forEach((([e,t])=>{$c.includes(t)||this.logger.error(`Unknown component action "${t}" for component with id "${e}"`,`Valid actions are ${$c.map((e=>`"${e}"`)).join(", ")}`)})),Nc(e,{},t))}initRealtimeConditions(e,r){var a,c,d,u;i(this,t,"m",l).call(this);const h=null!==(a=null==r?void 0:r.realtimeComponentsConditions)&&void 0!==a?a:[];if(!h.length)return void this.logger.debug(`${Dc} no real-time rules to apply on this screen`);this.logger.info(`${Dc} found ${h.length} real-time rule(s) for this screen`);const p={};Object.entries(null!==(c=null==r?void 0:r.form)&&void 0!==c?c:{}).forEach((([e,t])=>{p[`form.${e}`]=t})),function(e){const t=new Set,n=e=>{var i;e&&("form"===e.kind&&e.form?t.add(e.form):"list"===e.kind&&(null!==(i=e.items)&&void 0!==i?i:[]).forEach(n))};return(null!=e?e:[]).forEach((e=>{var t;return(null!==(t=e.rules)&&void 0!==t?t:[]).forEach((e=>{var t;return(null!==(t=e.atomicConditions)&&void 0!==t?t:[]).forEach((e=>{n(e.target),n(e.predicate)}))}))})),t}(h).forEach((t=>{const n=function(e,t){const n=t.startsWith("form.")?t.slice(5):t;return e.querySelector(`[name="${_c(t)}"]`)||e.querySelector(`[name="${_c(n)}"]`)}(e,t);if(!n)return;const i=Fc(n);void 0!==i&&(p[t]=i)}));const f=function(e){const t=new Set;return(null!=e?e:[]).forEach((e=>{var n;(null!==(n=e.componentIds)&&void 0!==n?n:[]).forEach((e=>t.add(e)))})),t}(h),g={},v={};Object.entries(null!==(d=null==r?void 0:r.componentsState)&&void 0!==d?d:{}).forEach((([e,t])=>{f.has(e)&&(v[e]=t)})),Object.entries(null!==(u=null==r?void 0:r.serverOnlyComponentsState)&&void 0!==u?u:{}).forEach((([e,t])=>{f.has(e)&&(g[e]=t)}));const m={conditions:h,touchedIds:f,snapshot:p,applied:v,serverBaseline:g,debounceTimer:null,paused:!1,unsubscribePauseListener:null,inputHandler:()=>{},root:e},w=Vc(Wc(h,p),g,f);qc(v,w)||(m.applied=Nc(e,v,w)),m.inputHandler=e=>i(this,t,"m",s).call(this,e),Cc.forEach((t=>{e.addEventListener(t,m.inputHandler,!0)})),this.logger.debug(`${Dc} listening for "${Cc.join('" and "')}" events on form fields; ${Object.keys(v).length} component(s) start hidden / disabled / read-only by these rules`);const b=this.nextRequestStatus;if(null==b?void 0:b.subscribe){const e=({isLoading:e})=>{m.paused=e,e&&m.debounceTimer&&(clearTimeout(m.debounceTimer),m.debounceTimer=null)},t=b.subscribe(e);m.unsubscribePauseListener=()=>{var e;null!=t&&(null===(e=b.unsubscribe)||void 0===e||e.call(b,t))}}o(this,n,m,"f")}disconnectedCallback(){var e;null===(e=super.disconnectedCallback)||void 0===e||e.call(this),i(this,t,"m",l).call(this)}},n=new WeakMap,t=new WeakSet,s=function(e){var o,r;const s=i(this,n,"f");if(!s.root||s.paused)return;const l=e.target;if(!l)return;if(null===(o=l.hasAttribute)||void 0===o?void 0:o.call(l,ol))return;const c=null===(r=l.getAttribute)||void 0===r?void 0:r.call(l,"name");if(!c)return;const d=function(e){return e.startsWith("form.")?e:`form.${e}`}(c);s.snapshot[d]=Fc(l),s.debounceTimer&&clearTimeout(s.debounceTimer),s.debounceTimer=setTimeout((()=>{s.debounceTimer=null,i(this,t,"m",a).call(this)}),50)},a=function(){const e=i(this,n,"f");if(!e.root)return;let t;try{t=Vc(Wc(e.conditions,e.snapshot),e.serverBaseline,e.touchedIds)}catch(e){return void this.logger.error(`${Dc} failed to evaluate real-time rules — keeping the previous state`,null==e?void 0:e.message)}const o=e.applied;qc(o,t)||(this.logger.debug(`${Dc} form changed — updating components: was ${JSON.stringify(o)}, now ${JSON.stringify(t)}`),e.applied=Nc(e.root,o,t))},l=function(){const e=i(this,n,"f");e.debounceTimer&&clearTimeout(e.debounceTimer),e.unsubscribePauseListener&&e.unsubscribePauseListener(),e.root&&(Object.keys(e.applied).length>0&&e.root.isConnected&&Nc(e.root,e.applied,{}),Cc.forEach((t=>{e.root.removeEventListener(t,e.inputHandler,!0)}))),o(this,n,zc(),"f")},c}));var Bc,Jc,Kc,Zc,Xc,Gc,Yc,Qc,ed,td,nd,id,od,rd,sd,ad,ld,cd,dd,ud,hd,pd;const fd=r(Ce,M,Ic,Hc,B)(HTMLElement);class gd extends fd{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","validate-on-blur","style-id"]}constructor(e){super(),Bc.add(this),Kc.set(this,!1),Zc.set(this,void 0),this.flowStatus="initial",this.loggerWrapper={error:(e,t="")=>{this.logger.error(e,t,new Error),i(this,Bc,"m",pd).call(this,e,t)},warn:(e,t="")=>{this.logger.warn(e,t)},info:(e,t="",n={})=>{this.logger.info(e,t,n)},debug:(e,t="")=>{this.logger.debug(e,t)}},Xc.set(this,new nc),Gc.set(this,new nc),Yc.set(this,{}),this.getComponentsContext=()=>i(this,Yc,"f"),this.nextRequestStatus=new nc({isLoading:!1}),Qc.set(this,void 0),ed.set(this,{popstate:i(this,Bc,"m",rd).bind(this),componentsContext:i(this,Bc,"m",dd).bind(this)}),td.set(this,void 0),this.getConfig=()=>n(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),o(this,td,e,"f"),i(this,Bc,"m",id).call(this)}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(e){return{}}}get redirectUrl(){return this.getAttribute("redirect-url")||void 0}get debug(){return"true"===this.getAttribute("debug")}get locale(){return this.getAttribute("locale")||void 0}get autoFocus(){var e;const t=null!==(e=this.getAttribute("auto-focus"))&&void 0!==e?e:"true";return"skipFirstScreen"===t?t:"true"===t}get validateOnBlur(){return"true"===this.getAttribute("validate-on-blur")}get storeLastAuthenticatedUser(){var e;return"true"===(null!==(e=this.getAttribute("store-last-authenticated-user"))&&void 0!==e?e:"true")}get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}get keepLastAuthenticatedUserAfterLogout(){return"true"===this.getAttribute("keep-last-authenticated-user-after-logout")}get storagePrefix(){return this.getAttribute("storage-prefix")||""}get preview(){return!!this.getAttribute("preview")}get formConfig(){return(e=>{try{return Sc(JSON.parse(e))}catch(e){return{}}})(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return((e,t)=>Object.fromEntries(Object.entries(e).map((([e,n])=>[e,n[t]]))))(this.formConfig,"value")}get outboundAppId(){return this.getAttribute("outbound-app-id")}get outboundAppScopes(){try{return JSON.parse(this.getAttribute("outbound-app-scopes"))||null}catch(e){return null}}get popupOrigin(){return this.getAttribute("popup-origin")}get customStorage(){return i(this,Zc,"f")}set customStorage(e){if(e&&"function"!=typeof e.getItem)throw new Error("Custom storage must have a getItem method");if(e&&"function"!=typeof e.setItem)throw new Error("Custom storage must have a setItem method");if(e&&"function"!=typeof e.removeItem)throw new Error("Custom storage must have a removeItem method");o(this,Zc,e,"f"),(e=>{pc=e})(e)}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"executionContext"in e?e.executionContext:void 0}))}getProjectConfig(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"projectConfig"in e?e.projectConfig:void 0}))}getFlowConfig(){return n(this,void 0,void 0,(function*(){var e,t;const n=yield this.getProjectConfig(),i=(null===(e=null==n?void 0:n.flows)||void 0===e?void 0:e[this.flowId])||{};return null!==(t=i.version)&&void 0!==t||(i.version=0),i}))}getTargetLocales(){return n(this,void 0,void 0,(function*(){const e=yield this.getFlowConfig();return((null==e?void 0:e.targetLocales)||[]).map((e=>e.toLowerCase()))}))}handleKeyPress(){this.logger.debug("Enable key press handler"),this.rootElement.onkeydown=e=>{var t,n,i;const o=!!(null===(t=this.shadowRoot.activeElement)||void 0===t?void 0:t.getAttribute("href")),r=Rl.includes(null!==(i=null===(n=this.shadowRoot.activeElement)||void 0===n?void 0:n.localName)&&void 0!==i?i:"");if("Enter"!==e.key||o||r)return;e.preventDefault();const s=this.rootElement.querySelectorAll("descope-button");if(1===s.length&&"false"!==s[0].getAttribute("auto-submit"))return void s[0].click();const a=Array.from(s).filter((e=>"true"===e.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const l=Array.from(s).filter((e=>"button"===e.getAttribute("data-type")));if(1===l.length)"false"!==l[0].getAttribute("auto-submit")&&l[0].click();else if(0===l.length){const e=Array.from(s).filter((e=>"sso"===e.getAttribute("data-type")));1===e.length&&"false"!==e[0].getAttribute("auto-submit")&&e[0].click()}}}disableKeyPressHandler(){this.logger.debug("Disable key press handler"),this.rootElement.onkeydown=null}getComponentsVersion(){return n(this,void 0,void 0,(function*(){var e;const t=yield this.getConfig();return("projectConfig"in t?null===(e=t.projectConfig)||void 0===e?void 0:e.componentsVersion:{})||(this.logger.error("Did not get components version, using latest version"),"latest")}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;if(this.flowStatus="loading",["ready","error","success"].forEach((e=>this.addEventListener(e,(()=>{this.flowStatus=e})))),yield null===(t=e.init)||void 0===t?void 0:t.call(this),i(this,Gc,"f").subscribe(i(this,Bc,"m",hd).bind(this)),i(this,Gc,"f").update({isDebug:this.debug}),i(this,Bc,"m",od).call(this),yield i(this,Bc,"m",ld).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");const n=yield this.getConfig();if("isMissingConfig"in n&&n.isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");const{executionId:r,stepId:s,token:a,code:l,isPopup:c,exchangeError:d,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthCodeChallenge:p,redirectAuthInitiator:f,ssoQueryParams:g}=Fl(this.flowId,this.loggerWrapper);window.addEventListener("popstate",i(this,ed,"f").popstate),window.addEventListener("components-context",i(this,ed,"f").componentsContext),i(this,Xc,"f").subscribe(i(this,Bc,"m",ad).bind(this)),i(this,Xc,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenantId,redirectUrl:this.redirectUrl,locale:this.locale,stepId:s,executionId:r,token:a,code:l,isPopup:c,exchangeError:d,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthCodeChallenge:p,redirectAuthInitiator:f},g)),o(this,Kc,!0,"f")}))}disconnectedCallback(){var e;i(this,Xc,"f").unsubscribeAll(),i(this,Gc,"f").unsubscribeAll(),i(this,Bc,"m",ud).call(this),window.removeEventListener("popstate",i(this,ed,"f").popstate),window.removeEventListener("components-context",i(this,ed,"f").componentsContext),null===(e=super.disconnectedCallback)||void 0===e||e.call(this)}attributeChangedCallback(e,t,n){if(this.shadowRoot.isConnected&&i(this,Kc,"f")&&t!==n&&Jc.observedAttributes.includes(e)){i(this,Bc,"m",od).call(this);const o=null===t;i(this,Xc,"f").update((({stepId:t,executionId:i})=>{let r=t,s=i;return o||(s=null,r=null,Nl()),{[Dl(e)]:n,stepId:r,executionId:s}})),i(this,Gc,"f").update({isDebug:this.debug})}}}var vd,md,wd,bd,yd,kd,Sd,Id,Cd,Ad,xd,Od,Ed,jd,Rd,Td,Md,Ud,Wd,$d,Pd,_d,Ld,Nd,Dd,Fd,qd,zd,Vd,Hd,Bd,Jd,Kd,Zd,Xd,Gd,Yd,Qd,eu,tu;Jc=gd,Kc=new WeakMap,Zc=new WeakMap,Xc=new WeakMap,Gc=new WeakMap,Yc=new WeakMap,Qc=new WeakMap,ed=new WeakMap,td=new WeakMap,Bc=new WeakSet,nd=function(){this.injectStyle("\n :host {\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n display: flex;\n flex-direction: column;\n\t\t}\n\n #content-root {\n all: initial;\n transition: opacity 200ms ease-in-out;\n }\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1!important;\n\t\t}\n\n .hidden {\n display: none;\n }\n ")},id=function(){i(this,Bc,"m",nd).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},od=function(){const e=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","refresh-cookie-name","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","style-id","outbound-app-id","outbound-app-scopes","theme-override"];Jc.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[Dl(t)])throw Error(`${t} cannot be empty`)}))},rd=function(){const{stepId:e,executionId:t}=Ll(this.flowId);i(this,Xc,"f").update({stepId:e,executionId:t})},sd=function(e,t){Hs&&"function"==typeof Hs||this.logger.error("SDK was not loaded properly",Hs,JSON.stringify(Hs));const o=Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},Jc.sdkConfigOverrides),{projectId:e,baseUrl:t});i(this,Zc,"f")&&(o.customStorage=i(this,Zc,"f")),this.sdk=Hs(o),["start","next"].forEach((e=>{const t=function(e,t,i){return(...o)=>n(this,void 0,void 0,(function*(){let n;const r=i+1;for(let s=0;s<r;s++)try{return yield e(...o)}catch(e){n=e,s<i&&(yield new Promise((e=>{setTimeout(e,t*Math.pow(2,s+1))})))}throw n}))}(this.sdk.flow[e],1e3,3);this.sdk.flow[e]=(...i)=>n(this,void 0,void 0,(function*(){try{return yield t(...i)}catch(t){return this.logger.error(`Error in sdk flow ${e} function`,t),{error:{errorCode:Xa,errorDescription:t.toString()}}}}))}))},ad=function(e,t,o){return n(this,void 0,void 0,(function*(){const{projectId:t,baseUrl:n}=e;if(o("projectId")||o("baseUrl")){if(!t)return;i(this,Bc,"m",sd).call(this,t,n)}i(this,td,"f").call(this,e)}))},ld=function(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield i(this,Bc,"m",cd).call(this))}))},cd=function(){return n(this,void 0,void 0,(function*(){const e=function({projectId:e,filename:t,assetsFolder:n="v2-beta",baseUrl:i}){const o=new URL(Ya||i||"https://static.descope.com/pages");return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,n,t),o.toString()}({projectId:this.projectId,filename:"config.json",assetsFolder:"v2-alpha",baseUrl:this.baseStaticUrl});try{return yield function(e,t){return n(this,void 0,void 0,(function*(){const n=yield fetch(e,{cache:"default"});if(!n.ok)throw Error(`Error fetching URL ${e} [${n.status}]`);return{body:yield n[t](),headers:Object.fromEntries(n.headers.entries())}}))}(e,"json"),!0}catch(e){return!1}}))},dd=function(e){o(this,Yc,Object.assign(Object.assign({},i(this,Yc,"f")),e.detail),"f")},ud=function(){var e;null===(e=i(this,Qc,"f"))||void 0===e||e.remove(),o(this,Qc,null,"f")},hd=function(e){return n(this,arguments,void 0,(function*({isDebug:e}){e?(o(this,Qc,document.createElement("descope-debugger"),"f"),Object.assign(i(this,Qc,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return $u})),document.body.appendChild(i(this,Qc,"f"))):i(this,Bc,"m",ud).call(this)}))},pd=function(e,t){var n;e&&this.debug&&(null===(n=i(this,Qc,"f"))||void 0===n||n.updateData({title:e,description:t}))},gd.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"3.69.5"}};class nu extends gd{static set sdkConfigOverrides(e){gd.sdkConfigOverrides=e}static get sdkConfigOverrides(){return gd.sdkConfigOverrides}constructor(){const e=new nc({deferredRedirect:!1,deferredPolling:!1});super(e.update.bind(e)),vd.add(this),this.stepState=new nc({}),md.set(this,void 0),wd.set(this,null),bd.set(this,null),yd.set(this,{visibilitychange:i(this,vd,"m",kd).bind(this)}),this.bridgeVersion=2,this.nativeCallbacks={},jd.set(this,!1),this.handleRedirect=e=>{window.location.assign(e)},Td.set(this,(e=>{const t=()=>{this.contentRootElement.classList.toggle("hidden",e),this.slotElement.classList.toggle("hidden",!e),e&&(this.contentRootElement.innerHTML="")};e&&this.contentRootElement.hasChildNodes()?i(this,vd,"m",Md).call(this,t):t()})),Ud.set(this,((e,t,r,s,a=!1)=>{const l=[Ga,"E103202"];if(this.flowState.current.action===Il){if(i(this,$d,"f").call(this)&&document.hidden)return this.logger.debug("polling - Deferring polling until in foreground"),void this.flowState.update({deferredPolling:!0});this.logger.debug("polling - Scheduling polling request");const c=Date.now(),d=a?500:2e3;o(this,md,setTimeout((()=>n(this,void 0,void 0,(function*(){var n,o;this.logger.debug("polling - Calling next");const u=this.sdk.flow.next(e,t,jl,r,s,{}),h=document.hidden&&!a&&Date.now()-c>d+500;let p;h&&this.logger.debug("polling - The polling seems to be throttled");try{const e=h?1e3:6e3;p=yield Vl(e,u)}catch(n){return this.logger.warn(`polling - The ${h?"throttled fetch":"fetch"} call timed out or was aborted`),void i(this,Ud,"f").call(this,e,t,r,s,h)}if((null===(n=null==p?void 0:p.error)||void 0===n?void 0:n.errorCode)===Xa)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void i(this,Ud,"f").call(this,e,t,r,s);this.logger.debug("polling - Got a response"),(null==p?void 0:p.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(p.error,null,4)),(null===(o=null==p?void 0:p.error)||void 0===o?void 0:o.errorCode)&&l.includes(p.error.errorCode)?this.logger.debug("polling - Stopping polling due to error"):i(this,Ud,"f").call(this,e,t,r,s),i(this,Pd,"f").call(this,p)}))),d),"f")}})),Wd.set(this,(()=>{clearTimeout(i(this,md,"f")),o(this,md,null,"f")})),$d.set(this,(()=>!!window.descopeBridge||/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))),Pd.set(this,(e=>{var t,n,r,s,a,l,c,d,u,h,p,f,g;if(!(null==e?void 0:e.ok)){const o=null===(t=null==e?void 0:e.response)||void 0===t?void 0:t.url,c=`${null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.status} - ${null===(r=null==e?void 0:e.response)||void 0===r?void 0:r.statusText}`;i(this,vd,"m",eu).call(this,"error",(null==e?void 0:e.error)||{errorCode:"J151001",errorDescription:c,errorMessage:o}),this.loggerWrapper.error((null===(s=null==e?void 0:e.error)||void 0===s?void 0:s.errorDescription)||o,(null===(a=null==e?void 0:e.error)||void 0===a?void 0:a.errorMessage)||c);const d=null===(l=null==e?void 0:e.error)||void 0===l?void 0:l.errorCode;return void("E102004"!==d&&d!==Ga||!this.isRestartOnError||i(this,vd,"m",Ed).call(this))}null===(d=null===(c=e.data)||void 0===c?void 0:c.runnerLogs)||void 0===d||d.forEach((e=>{const{level:t,title:n,log:i}=e;t&&this.loggerWrapper[t]?this.loggerWrapper[t](n,i):this.loggerWrapper.info(n,i)}));const v=null===(p=null===(h=null===(u=e.data)||void 0===u?void 0:u.screen)||void 0===h?void 0:h.state)||void 0===p?void 0:p.errorText;(null===(f=e.data)||void 0===f?void 0:f.error)?this.loggerWrapper.error(`[${e.data.error.code}]: ${e.data.error.description}`,`${v?`${v} - `:""}${e.data.error.message}`):v&&this.loggerWrapper.error(v);const{status:m,authInfo:w,lastAuth:b,action:y,openInNewTabUrl:k}=e.data;if(y!==Il&&i(this,Wd,"f").call(this),"completed"===m){this.storeLastAuthenticatedUser&&bc(Object.assign(Object.assign({},b),{lastUsedPerScreen:yc()})),kc(this.loggerWrapper);const t=Object.assign({},w);return e.data.output&&Object.keys(e.data.output).length>0&&(t.flowOutput=e.data.output),void i(this,vd,"m",eu).call(this,"success",t)}this.storeLastAuthenticatedUser&&bc(b,!0),k&&window.open(k,"_blank");const{executionId:S,stepId:I,stepName:C,screen:A,redirect:x,webauthn:O,error:E,samlIdpResponse:j,wsFedIdpResponse:R,nativeResponse:T}=e.data,M=Date.now();y!==Il?(this.loggerWrapper.info(`Step "${C||`#${I}`}" is ${m}`,"",{screen:A,status:m,stepId:I,stepName:C,action:y,error:E}),(null===(g=A.state)||void 0===g?void 0:g.clientScripts)&&o(this,bd,this.loadSdkScripts(A.state.clientScripts),"f"),this.flowState.update({stepId:I,stepName:C,executionId:S,action:y,redirectTo:null==x?void 0:x.url,redirectIsPopup:null==x?void 0:x.isPopup,screenId:null==A?void 0:A.id,screenState:null==A?void 0:A.state,webauthnTransactionId:null==O?void 0:O.transactionId,webauthnOptions:null==O?void 0:O.options,samlIdpResponseUrl:null==j?void 0:j.url,samlIdpResponseSamlResponse:null==j?void 0:j.samlResponse,samlIdpResponseRelayState:null==j?void 0:j.relayState,wsFedIdpResponseUrl:null==R?void 0:R.url,wsFedIdpResponseWresult:null==R?void 0:R.wresult,wsFedIdpResponseWctx:null==R?void 0:R.wctx,nativeResponseType:null==T?void 0:T.type,nativePayload:null==T?void 0:T.payload,reqTimestamp:M})):this.flowState.update({action:y,reqTimestamp:M})})),_d.set(this,ql((()=>n(this,void 0,void 0,(function*(){var e;try{const t=yield this.sdk.webauthn.signIn.start("",window.location.origin);return t.ok||this.loggerWrapper.warn("Webauthn start failed",null===(e=null==t?void 0:t.error)||void 0===e?void 0:e.errorMessage),t.data}catch(e){this.loggerWrapper.warn("Webauthn start failed",e.message)}}))))),zd.set(this,null),Kd.set(this,Kl(((e,t,o)=>n(this,void 0,void 0,(function*(){var n;if("true"===e.getAttribute("formnovalidate")||i(this,vd,"m",Fd).call(this)){const r=null==e?void 0:e.getAttribute("id");i(this,vd,"m",Gd).call(this,e,r,o),i(this,vd,"m",Vd).call(this,e);const s=yield i(this,vd,"m",qd).call(this),a=(e=>Array.from((null==e?void 0:e.attributes)||[]).reduce(((e,t)=>{var n;const i=null===(n=new RegExp("^data-descope-(\\S+)$").exec(t.name))||void 0===n?void 0:n[1];return i?Object.assign(e,{[i]:t.value}):e}),{}))(e);this.nextRequestStatus.update({isLoading:!0});const l=Object.assign(Object.assign(Object.assign({},a),s),{origin:(null===(n=this.nativeOptions)||void 0===n?void 0:n.origin)||window.location.origin});yield t(r,l),this.nextRequestStatus.update({isLoading:!1}),i(this,vd,"m",Hd).call(this,s)}}))))),this.flowState=e}nativeResume(e,t){var n,o,r,s,a,l;const c=JSON.parse(t);if("oauthWeb"===e||"sso"===e){let e,{exchangeCode:t}=c;if(!t){const i=new URL(c.url);t=null===(n=i.searchParams)||void 0===n?void 0:n.get(tl),e=(null===(o=i.searchParams)||void 0===o?void 0:o.get(il))||void 0}null===(s=(r=this.nativeCallbacks).complete)||void 0===s||s.call(r,{exchangeCode:t,exchangeError:e,idpInitiated:!0})}else if("magicLink"===e){const e=new URL(c.url),t=e.searchParams.get("t"),n=e.searchParams.get(el).split("_").pop();i(this,Wd,"f").call(this),this.flowState.update({token:t,stepId:n,action:void 0})}else if("beforeScreen"===e){const{screenResolve:e}=this.nativeCallbacks;this.nativeCallbacks.screenResolve=null;const{override:t}=c;t||(this.nativeCallbacks.screenNext=null),null==e||e(t)}else if("resumeScreen"===e){const{interactionId:e,form:t}=c,{screenNext:n}=this.nativeCallbacks;this.nativeCallbacks.screenNext=null,null==n||n(e,t)}else null===(l=(a=this.nativeCallbacks).complete)||void 0===l||l.call(a,c)}loadSdkScriptsModules(){const e=this.shadowRoot.querySelectorAll("div[data-script-id]");return Array.from(e).map((e=>e.moduleRes)).filter((e=>!!e))}loadSdkScripts(e){if(!(null==e?void 0:e.length))return null;const t=(e,t)=>n=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[Xl(e.id,e.resultKey)]:n},bubbles:!0,composed:!0})),t(e.id)};this.loggerWrapper.debug(`Preparing to load scripts: ${e.map((e=>e.id)).join(", ")}`);const i=Promise.all(null==e?void 0:e.map((e=>n(this,void 0,void 0,(function*(){var n,i,o;const r=this.shadowRoot.querySelector(`[data-script-id="${e.id}"]`);if(r){this.loggerWrapper.debug("Script already loaded",e.id);const{moduleRes:t}=r;return null===(n=null==t?void 0:t.start)||void 0===n||n.call(t),t}(null===(i=globalThis.descope)||void 0===i?void 0:i[e.id])||(yield this.injectNpmLib("@descope/flow-scripts","1.0.17",`dist/${e.id}.js`));const s=null===(o=globalThis.descope)||void 0===o?void 0:o[e.id];return new Promise(((n,i)=>{try{const i=s(e.initArgs,{baseUrl:this.baseUrl,ref:this},t(e,n),this.loggerWrapper);if(i){const t=document.createElement("div");t.setAttribute("data-script-id",e.id),t.moduleRes=i,this.shadowRoot.appendChild(t);const n=this.nextRequestStatus.subscribe((()=>{var o;this.loggerWrapper.debug("Stopping script",e.id),(null===(o=i.stop)||void 0===o?void 0:o.call(i))&&(this.nextRequestStatus.unsubscribe(n),this.loggerWrapper.debug("Removing script",e.id),this.shadowRoot.removeChild(t))}))}}catch(e){i(e)}}))}))))),o=new Promise((e=>{setTimeout((()=>{this.loggerWrapper.warn("SDK scripts loading timeout"),e(!0)}),5e3)}));return Promise.race([i,o])}get isDismissScreenErrorOnInput(){return"true"===this.getAttribute("dismiss-screen-error-on-input")}init(){if(!window.descopeBridge)return this._init();this.lazyInit=this._init}_init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t,n;this.shadowRoot.isConnected&&(null===(t=this.flowState)||void 0===t||t.subscribe(this.onFlowChange.bind(this)),i(this,vd,"m",xd).call(this),window.addEventListener("visibilitychange",i(this,yd,"f").visibilitychange)),yield null===(n=e.init)||void 0===n?void 0:n.call(this)}))}disconnectedCallback(){var e;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),i(this,Wd,"f").call(this),null===(e=i(this,wd,"f"))||void 0===e||e.abort(),o(this,wd,null,"f"),window.removeEventListener("visibilitychange",i(this,yd,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return n(this,void 0,void 0,(function*(){let n;const i=v(e),o=yield this.getTargetLocales();return o.includes(i.locale)?n=`${t}-${i.locale}.html`:o.includes(i.fallback)&&(n=`${t}-${i.fallback}.html`),n}))}getPageContent(e,t){return n(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield this.fetchStaticResource(t,"text");return e}catch(n){this.loggerWrapper.error(`Failed to fetch flow page from ${t}. Fallback to url ${e}`,n)}try{const{body:t}=yield this.fetchStaticResource(e,"text");return t}catch(e){this.loggerWrapper.error("Failed to fetch flow page",e.message)}return null}))}onFlowChange(e,r,s){return n(this,void 0,void 0,(function*(){var a,l;const{projectId:c,flowId:d,tenant:u,stepId:h,executionId:p,action:f,screenId:g,screenState:m,redirectTo:w,redirectIsPopup:b,redirectUrl:y,token:k,code:S,isPopup:I,exchangeError:C,webauthnTransactionId:A,webauthnOptions:x,redirectAuthCodeChallenge:O,redirectAuthCallbackUrl:E,redirectAuthBackupCallbackUri:j,redirectAuthInitiator:R,locale:T,samlIdpResponseUrl:M,samlIdpResponseSamlResponse:U,samlIdpResponseRelayState:W,wsFedIdpResponseUrl:$,wsFedIdpResponseWresult:P,wsFedIdpResponseWctx:_,nativeResponseType:L,nativePayload:N,reqTimestamp:D}=e,F=t(e,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","redirectIsPopup","redirectUrl","token","code","isPopup","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState","wsFedIdpResponseUrl","wsFedIdpResponseWresult","wsFedIdpResponseWctx","nativeResponseType","nativePayload","reqTimestamp"]);let q,z,V;const H=(()=>{const e=gc(vc);if(!e){const e=Math.floor(100*Math.random()+1);return fc(vc,e.toString()),e}return Number(e)})(),{outboundAppId:B}=this,{outboundAppScopes:J}=this,K=this.sdk.getLastUserLoginId(),Z=yield this.getFlowConfig(),X=yield this.getProjectConfig(),G=Object.entries(X.flows||{}).reduce(((e,[t,n])=>(e[t]=n.version,e)),{}),Y=E&&O?{callbackUrl:E,codeChallenge:O,backupCallbackUri:j}:void 0,Q=this.nativeOptions?{platform:this.nativeOptions.platform,bridgeVersion:this.nativeOptions.bridgeVersion,oauthProvider:this.nativeOptions.oauthProvider,oauthRedirect:this.nativeOptions.oauthRedirect,magicLinkRedirect:this.nativeOptions.magicLinkRedirect,ssoRedirect:this.nativeOptions.ssoRedirect,externalAuthRedirect:this.nativeOptions.externalAuthRedirect}:void 0;let ee={};if(!p){kc(this.loggerWrapper);const e=[...Z.clientScripts||[],...Z.sdkScripts||[]];if(Z.conditions){let t=[];({startScreenId:q,conditionInteractionId:V,startScreenName:z,clientScripts:t,componentsConfig:ee}=((e,t)=>{const n=null==t?void 0:t.find((({key:t,operator:n,predicate:i})=>{var o;if("ELSE"===t)return!0;const r=null===(o=mc[t])||void 0===o?void 0:o[n];return!!(null==r?void 0:r(e,i))}));return n?{startScreenId:n.met.screenId,startScreenName:n.met.screenName,conditionInteractionId:n.met.interactionId,clientScripts:n.met.clientScripts,componentsConfig:n.met.componentsConfig}:{}})({loginId:K,code:S,token:k,abTestingKey:H,lastAuth:wc(K,this.loggerWrapper)},Z.conditions)),e.push(...t||[])}else Z.condition?({startScreenId:q,conditionInteractionId:V}=((e,t)=>{var n;const i=null===(n=mc[null==e?void 0:e.key])||void 0===n?void 0:n[e.operator];if(!i)return{};const o=i(t,e.predicate)?e.met:e.unmet;return{startScreenId:null==o?void 0:o.screenId,startScreenName:null==o?void 0:o.screenName,conditionInteractionId:null==o?void 0:o.interactionId}})(Z.condition,{loginId:K,code:S,token:k,abTestingKey:H,lastAuth:wc(K,this.loggerWrapper)})):(z=Z.startScreenName,q=Z.startScreenId);if(o(this,bd,this.loadSdkScripts(e),"f"),Z.fingerprintEnabled&&Z.fingerprintKey?yield ls(Z.fingerprintKey,this.baseUrl):Dr(ss),!Hl(q,F)){const e=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:Y},F),{client:this.client}),y&&{redirectUrl:y}),{lastAuth:wc(K,this.loggerWrapper),abTestingKey:H,locale:v(T).locale,nativeOptions:Q,outboundAppId:B,outboundAppScopes:J}),V,"",X.componentsVersion,G,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),S?{exchangeCode:S,idpInitiated:!0}:{}),F.descopeIdpInitiated&&{idpInitiated:!0}),k?{token:k}:{}),F.oidcLoginHint?{externalId:F.oidcLoginHint}:{}));return i(this,Pd,"f").call(this,e),void("completed"!==(null===(a=null==e?void 0:e.data)||void 0===a?void 0:a.status)&&this.flowState.update({code:void 0,token:void 0}))}}if(this.loggerWrapper.debug("Before popup postmessage send",JSON.stringify({isPopup:I,code:S,exchangeError:C,isCodeChanged:s("code"),isExchangeErrorChanged:s("exchangeError")})),I&&(s("code")&&S||s("exchangeError")&&C))return void i(this,vd,"m",tu).call(this,p,S,C);if(p&&(s("token")&&k||s("code")&&S||s("exchangeError")&&C)){const e=yield this.sdk.flow.next(p,h,El,Z.version,X.componentsVersion,{token:k,exchangeCode:S,exchangeError:C});return i(this,Pd,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(f===Ol&&M&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>s(e)))){if(!U)return void this.loggerWrapper.error("Did not get saml idp params data to load");((e,t,n,i)=>{const o=document.createElement("form");o.method="POST",o.action=e,o.innerHTML=`\n <input type="hidden" role="saml-response" name="SAMLResponse" value="${t}" />\n <input type="hidden" role="saml-relay-state" name="RelayState" value="${n}" />\n <input style="display: none;" id="SAMLSubmitButton" type="submit" value="Continue" />\n `,document.body.appendChild(o),i(o)})(M,U,W||"",Bl)}if(f===Ol&&$&&["wsFedIdpResponseUrl","wsFedIdpResponseWresult","wsFedIdpResponseWctx"].some((e=>s(e)))){if(!P)return void this.loggerWrapper.error("Did not get wsfed idp params data to load");((e,t,n,i)=>{const o=document.createElement("form");o.method="POST",o.action=e;const r=(e,t)=>{const n=document.createElement("input");return n.type="hidden",n.name=e,n.value=t,n};o.appendChild(r("wa","wsignin1.0")),o.appendChild(r("wresult",t)),o.appendChild(r("wctx",n));const s=document.createElement("input");s.type="submit",s.id="WSFedSubmitButton",s.value="Continue",s.style.display="none",o.appendChild(s),document.body.appendChild(o),i(o)})($,P,_||"",Bl)}if(f===Sl&&(s("redirectTo")||s("deferredRedirect"))){if(!w)return void this.loggerWrapper.error("Did not get redirect url");if("no-op"===w)return;if("android"===R&&document.hidden)return void this.flowState.update({deferredRedirect:!0});if(this.loggerWrapper.debug(`Redirect is popup ${b}`),b){this.loggerWrapper.debug("Opening redirect in popup");const e=((e,t,n,i)=>{const o=void 0!==window.screenLeft?window.screenLeft:window.screen.left,r=void 0!==window.screenTop?window.screenTop:window.screen.top,s=((window.innerWidth||document.documentElement.clientWidth||window.screen.width)-n)/2+o,a=((window.innerHeight||document.documentElement.clientHeight||window.screen.height)-i)/2+r,l=function(){const e=navigator.userAgent||"",t=/\b(iPhone)\b/.test(e),n=/Safari/.test(e)&&!/CriOS|FxiOS|OPiOS|EdgiOS|Chrome|Chromium/.test(e);return t&&n}()?"about:blank":"",c=window.open(l,t,`width=${n},height=${i},top=${a},left=${s},scrollbars=yes,resizable=yes`);return c.location.href=e,c.focus(),c})(w,"?",598,700),t=this.shouldUsePopupPostMessage();t&&(e.name=`descope-wc|${window.location.origin}`),this.loggerWrapper.debug("Popup communication method: "+(t?"postMessage":"BroadcastChannel"));const n=e=>{this.loggerWrapper.debug("Received popup message",JSON.stringify(e.data));const n=t?this.popupOrigin:window.location.origin;if(e.origin!==n)return void this.loggerWrapper.debug(`Ignoring message from unexpected origin. received: "${e.origin}", expected: "${n}"`);const{action:i,data:o}=e.data||{};"code"===i&&this.flowState.update({code:o.code,exchangeError:o.exchangeError})};let o;this.loggerWrapper.debug("Starting popup closed detection");const r=setInterval((()=>{e.closed&&(this.loggerWrapper.debug("Popup closed, dispatching popupclosed event"),clearInterval(r),i(this,vd,"m",eu).call(this,"popupclosed",{}),this.loggerWrapper.debug("Cleaning up popup listeners"),null==o||o())}),1e3);if(t)window.addEventListener("message",n),o=()=>{this.loggerWrapper.debug("Cleaning up popup postMessage listener"),window.removeEventListener("message",n)};else{this.loggerWrapper.debug("Creating broadcast channel");const e=new BroadcastChannel(p);e.onmessage=n,o=()=>{this.loggerWrapper.debug("Closing channel"),e.close()}}}else this.handleRedirect(w),this.flowState.update({redirectTo:"no-op"}),i(this,vd,"m",eu).call(this,"popupclosed",{});return}if(f===Cl||f===Al){if(!A||!x)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,t,n,r;null===(l=i(this,wd,"f"))||void 0===l||l.abort(),o(this,wd,null,"f");try{e=f===Cl?yield this.sdk.webauthn.helpers.create(x):yield this.sdk.webauthn.helpers.get(x)}catch(e){"InvalidStateError"===e.name?this.loggerWrapper.warn("WebAuthn operation failed",e.message):"NotAllowedError"!==e.name&&this.loggerWrapper.error(e.message),t=e.name,n=e.reason,r=e.message}const s=yield this.sdk.flow.next(p,h,El,Z.version,X.componentsVersion,{transactionId:A,response:e,failure:t,failureReason:n,failureMessage:r});i(this,Pd,"f").call(this,s)}if(f===xl)return this.nativeCallbacks.complete=e=>n(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,h,El,Z.version,X.componentsVersion,e);i(this,Pd,"f").call(this,t)})),i(this,vd,"m",Cd).call(this,L,N),void setTimeout((()=>{this.dispatchEvent(new Event("popupclosed"))}),500);if((s("action")||s("deferredPolling"))&&i(this,Ud,"f").call(this,p,h,Z.version,X.componentsVersion),!g&&!q)return void this.loggerWrapper.warn("No screen was found to show");const te=q||g,ne=yield this.getHtmlFilenameWithLocale(T,te),{oidcLoginHint:ie,oidcPrompt:oe,oidcErrorRedirectUri:re,oidcResource:se,samlIdpUsername:ae}=F,le={direction:_l(h,r.stepId),screenState:Object.assign(Object.assign({},m),{form:Object.assign(Object.assign({},this.formConfigValues),null==m?void 0:m.form),lastAuth:{loginId:K,name:this.sdk.getLastUserDisplayName()||K},componentsConfig:Object.assign(Object.assign(Object.assign({},Z.componentsConfig),ee),null==m?void 0:m.componentsConfig)}),htmlFilename:`${te}.html`,htmlLocaleFilename:ne,screenId:te,stepName:e.stepName||z,samlIdpUsername:ae,oidcLoginHint:ie,oidcPrompt:oe,oidcErrorRedirectUri:re,oidcResource:se,action:f,locale:v(T).locale},ce=wc(K,this.loggerWrapper);Hl(q,F)?le.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=(null==Z?void 0:Z.clientScripts)||[];yield i(this,vd,"m",Zd).call(this,n);const o=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:Y},F),{lastAuth:ce,preview:this.preview,abTestingKey:H,client:this.client}),y&&{redirectUrl:y}),{locale:v(T).locale,nativeOptions:Q,outboundAppId:B,outboundAppScopes:J}),V,e,X.componentsVersion,G,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),this.getComponentsContext()),Zl(t)),S&&{exchangeCode:S,idpInitiated:!0}),F.descopeIdpInitiated&&{idpInitiated:!0}),k&&{token:k}),le.next.isCustomScreen);return i(this,Pd,"f").call(this,o),o})):(s("projectId")||s("baseUrl")||s("executionId")||s("stepId"))&&(le.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=(null==m?void 0:m.clientScripts)||[];yield i(this,vd,"m",Zd).call(this,n);const o=yield this.sdk.flow.next(p,h,e,Z.version,X.componentsVersion,Object.assign(Object.assign({},this.getComponentsContext()),Zl(t)),le.next.isCustomScreen);return i(this,Pd,"f").call(this,o),o}))),this.loggerWrapper.debug("Got a screen with id",le.screenId),yield i(this,vd,"m",Rd).call(this,le),this.stepState.update(le)}))}onStepChange(e,t){return n(this,void 0,void 0,(function*(){var o,r,s;const{htmlFilename:a,htmlLocaleFilename:l,direction:c,next:d,screenState:u,screenId:h}=e;this.loggerWrapper.debug("Rendering a flow screen");const p=document.createElement("template");p.innerHTML=yield this.getPageContent(a,l);const f=p.content.cloneNode(!0),g=this.loadDescopeUiComponents(p);this.sdk.webauthn.helpers.isSupported()?yield i(this,vd,"m",Nd).call(this,f,d):(e=>{e.querySelectorAll(`descope-button[${kl}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true")))})(f),!e.samlIdpUsername||(null===(o=u.form)||void 0===o?void 0:o.loginId)||(null===(r=u.form)||void 0===r?void 0:r.email)||(u.form||(u.form={}),u.form.loginId=e.samlIdpUsername,u.form.email=e.samlIdpUsername),uc(f,u,this.formConfig,this.loggerWrapper),this.applyComponentsState(f,null==u?void 0:u.componentsState);const{geo:v}=null!==(s=yield this.getExecutionContext())&&void 0!==s?s:{};((e,t)=>{Object.entries({"default-code":"autoDetect","default-country":"autoDetect"}).forEach((([n,i])=>{Array.from(e.querySelectorAll(`[${n}="${i}"]`)).forEach((e=>{e.setAttribute(n,t||i)}))}))})(f,v),((e,t)=>{let n=t;if(t)try{const[e]=Intl.getCanonicalLocales(t);e&&(n=e)}catch(e){}Object.entries({lang:"autoDetect"}).forEach((([t,i])=>{Array.from(e.querySelectorAll(`[${t}="${i}"]`)).forEach((e=>{e.setAttribute(t,n||i)}))}))})(f,e.locale);const m=()=>n(this,void 0,void 0,(function*(){var n,o;yield g;const r=this.contentRootElement;((e,t)=>{dc(e,"descope-totp-image",t)})(r,null===(n=null==u?void 0:u.totp)||void 0===n?void 0:n.image),((e,t)=>{dc(e,"descope-notp-image",t)})(r,null===(o=null==u?void 0:u.notp)||void 0===o?void 0:o.image),((e,t,n,i)=>{n&&Object.keys(n).forEach((o=>{if(!t.querySelector(o))return void i.debug(`Skipping css vars for component "${o}"`,`Got css vars for component ${o} but Could not find it on next page`);const r=customElements.get(o);r?Object.keys(n[o]).forEach((t=>{var s;const a=n[o],l=null===(s=null==r?void 0:r.cssVarList)||void 0===s?void 0:s[t];if(!l)return void i.info(`Could not find css variable name for ${t} in ${o}`,"Check if the css variable is defined in the component");const c=a[t];e.style.setProperty(l,c)})):i.debug(`Could not find component class for ${o}`,"Check if the component is registered")}))})(r,f,u.cssVars,this.loggerWrapper),r.replaceChildren(f);const s=!t.htmlFilename;setTimeout((()=>{i(this,vd,"m",Bd).call(this),this.validateOnBlur&&(e=>{e.querySelectorAll("*[name]").forEach((t=>{t.addEventListener("blur",(()=>{var n;const i=()=>{var e;const n=t.focus;t.focus=()=>{},null===(e=t.reportValidity)||void 0===e||e.call(t),setTimeout((()=>{t.focus=n}))};if("true"===t.getAttribute("invalid")||(null===(n=t.value)||void 0===n?void 0:n.length))return void i();const o={timer:void 0},r=e=>{"true"===e.target.getAttribute("formnovalidate")&&(clearTimeout(o.timer),o.timer=void 0)};o.timer=setTimeout((()=>{e.removeEventListener("click",r),i(),o.timer=void 0}),150),e.addEventListener("click",r,{once:!0})}))}))})(r),((e,t)=>{sc(e,null==t?void 0:t.inputs),sc(e,null==t?void 0:t.form)})(r,u),this.initRealtimeConditions(r,u),i(this,vd,"m",Dd).call(this,{isFirstScreen:s,isCustomScreen:!1,stepName:e.stepName}),zl(r,this.autoFocus,s),i(this,vd,"m",Yd).call(this,h)})),i(this,vd,"m",Qd).call(this,d,h),r.querySelector(`[${kl}="polling"]`)&&d(jl,{})}));c?i(this,vd,"m",Md).call(this,m):m()}))}getInputs(){return Array.from(this.shadowRoot.querySelectorAll(`*:not(slot)[name]:not([${ol}])`))}shouldUsePopupPostMessage(){if(!this.popupOrigin)return!1;try{new URL(this.popupOrigin)}catch(e){return!1}return!0}}md=new WeakMap,wd=new WeakMap,bd=new WeakMap,yd=new WeakMap,jd=new WeakMap,Td=new WeakMap,Ud=new WeakMap,Wd=new WeakMap,$d=new WeakMap,Pd=new WeakMap,_d=new WeakMap,zd=new WeakMap,Kd=new WeakMap,vd=new WeakSet,kd=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1,deferredPolling:!1})}),300)},Sd=function(e,t,o){return n(this,void 0,void 0,(function*(){var n;return(null===(n=this.nativeOptions)||void 0===n?void 0:n.bridgeVersion)>=2&&new Promise((n=>{this.nativeCallbacks.screenNext=o,this.nativeCallbacks.screenResolve=n,i(this,vd,"m",Cd).call(this,"beforeScreen",{screen:e,context:t})}))}))},Id=function(e){var t;(null===(t=this.nativeOptions)||void 0===t?void 0:t.bridgeVersion)>=2&&i(this,vd,"m",Cd).call(this,"afterScreen",{screen:e})},Cd=function(e,t){i(this,vd,"m",eu).call(this,"bridge",{type:e,payload:t})},Ad=function({errorText:e,errorType:t}){const n=()=>{var n;let i=e;try{i=(null===(n=this.errorTransformer)||void 0===n?void 0:n.call(this,{text:e,type:t}))||e}catch(e){this.loggerWrapper.error("Error transforming error message",e.message)}((e,t,n="")=>{e.querySelectorAll(`[${kl}="${t}"]`).forEach((e=>{e.textContent=n,e.classList[n?"remove":"add"]("hide")}))})(this.contentRootElement,"error-message",i)};this.addEventListener("screen-updated",n,{once:!0}),n()},xd=function(){var e,n,o;null===(e=this.stepState)||void 0===e||e.subscribe(this.onStepChange.bind(this),(e=>{var n=e.screenState,i=t(void 0===n?{}:n,["errorText","errorType"]),o=t(e,["screenState"]);return Object.assign(Object.assign({},o),{screenState:i})})),null===(n=this.stepState)||void 0===n||n.subscribe(i(this,vd,"m",Ad).bind(this),(e=>{var t,n;return{errorText:null===(t=null==e?void 0:e.screenState)||void 0===t?void 0:t.errorText,errorType:null===(n=null==e?void 0:e.screenState)||void 0===n?void 0:n.errorType}}),{forceUpdate:!0}),null===(o=this.stepState)||void 0===o||o.subscribe(i(this,vd,"m",Od).bind(this),(e=>{var t,n;return{errorText:null===(t=null==e?void 0:e.screenState)||void 0===t?void 0:t.errorText,errorType:null===(n=null==e?void 0:e.screenState)||void 0===n?void 0:n.errorType}}),{forceUpdate:!0})},Od=function({errorText:e,errorType:t}){(t||e)&&(this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((e=>{e.shadowRoot.querySelectorAll("descope-text-field[data-id]").forEach((e=>{e.value=""}))})),zl(this.contentRootElement,this.autoFocus,!1))},Ed=function(){return n(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Trying to restart the flow");const e=yield this.getComponentsVersion();this.reset(),e===(yield this.getComponentsVersion())?(this.loggerWrapper.debug("Components version was not changed, restarting flow"),this.flowState.update({stepId:null,executionId:null})):this.loggerWrapper.error("Components version mismatch, please reload the page")}))},Rd=function(e){return n(this,void 0,void 0,(function*(){var n;const r=Object.assign(Object.assign({},this.stepState.current),e),{next:s,stepName:a}=r,l=(e=>{var t,n,i;const o=(r=e.screenState,s=(e,t)=>Ml.includes(t)||t.startsWith("_"),Object.fromEntries(Object.entries(r).filter((([e,t])=>!s(0,e)))));var r,s;const{screenState:{errorText:a,errorType:l}}=e;return(a||l)&&(o.error={text:a,type:l}),e.action&&(o.action=e.action),(null===(i=null===(n=null===(t=e.screenState)||void 0===t?void 0:t.componentsConfig)||void 0===n?void 0:n.thirdPartyAppApproveScopes)||void 0===i?void 0:i.data)&&(o.inboundAppApproveScopes=e.screenState.componentsConfig.thirdPartyAppApproveScopes.data),o})(t(r,["next","stepName"]));let c=yield i(this,vd,"m",Sd).call(this,a,l,s);c||(c=Boolean(yield null===(n=this.onScreenUpdate)||void 0===n?void 0:n.call(this,a,l,s,this)));const d=!this.stepState.current.htmlFilename;if(i(this,Td,"f").call(this,c),s&&(s.isCustomScreen=c),i(this,jd,"f")!==c){const[e,t]=["flow","custom"].sort((()=>c?-1:1));this.loggerWrapper.debug(`Switching from ${t} screen to ${e} screen`),o(this,jd,c,"f"),c?this.stepState.unsubscribeAll():i(this,vd,"m",xd).call(this)}c?(this.loggerWrapper.debug("Showing a custom screen"),i(this,vd,"m",Dd).call(this,{isFirstScreen:d,isCustomScreen:c,stepName:e.stepName}),this.disableKeyPressHandler()):this.handleKeyPress(),this.stepState.forceUpdate=c}))},Md=function(e){this.contentRootElement.addEventListener("transitionend",(()=>{this.loggerWrapper.debug("page switch transition end"),this.contentRootElement.classList.remove("fade-out"),e()}),{once:!0}),this.loggerWrapper.debug("page switch transition start"),this.contentRootElement.classList.add("fade-out")},Ld=function(e){const t=e.getAttribute("name");if(!["email"].includes(t)){const n=`user-${t}`;e.setAttribute("name",n),e.addEventListener("input",(()=>{e.setAttribute("name",e.value?t:n)}))}},Nd=function(e,t){return n(this,void 0,void 0,(function*(){var r;null===(r=i(this,wd,"f"))||void 0===r||r.abort();const s=e.querySelector('*[autocomplete="webauthn"]');if(s&&(yield hc())){const{options:e,transactionId:r}=(yield i(this,_d,"f").call(this))||{};e&&r&&(i(this,vd,"m",Ld).call(this,s),o(this,wd,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(e,i(this,wd,"f")).then((e=>n(this,void 0,void 0,(function*(){t(s.id,{transactionId:r,response:e})})))).catch((e=>{"AbortError"!==e.name&&this.loggerWrapper.error("Conditional login failed",e.message)})))}}))},Dd=function({isFirstScreen:e,isCustomScreen:t,stepName:n}){e&&i(this,vd,"m",eu).call(this,"ready",{}),t||i(this,vd,"m",Id).call(this,n),i(this,vd,"m",eu).call(this,"page-updated",{screenName:n}),i(this,vd,"m",eu).call(this,"screen-updated",{screenName:n})},Fd=function(){let e=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((t=>{var n,i;"slot"===t.localName||t.classList.contains("hidden")||(null===(n=t.reportValidity)||void 0===n||n.call(t),e&&(e=null===(i=t.checkValidity)||void 0===i?void 0:i.call(t)))})),e},qd=function(){return n(this,void 0,void 0,(function*(){const e=this.getInputs();return(yield Promise.all(e.map((e=>n(this,void 0,void 0,(function*(){return{name:e.getAttribute("name"),value:e.value}})))))).reduce(((e,t)=>Object.assign(Object.assign({},e),{[t.name]:t.value})),{})}))},Vd=function(e){const t=Array.from(this.contentRootElement.querySelectorAll(':not([disabled]), [disabled="false"]')).filter((t=>t!==e)),r=()=>{e.removeAttribute("loading"),t.forEach((e=>{e.removeAttribute("disabled")}))},s=()=>n(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Restoring components state"),this.removeEventListener("popupclosed",s),r();const e=yield this.getFlowConfig(),t=[...e.clientScripts||[],...e.sdkScripts||[]];this.loadSdkScripts(t)})),a=()=>{var e;window.removeEventListener("pageshow",i(this,zd,"f")),o(this,zd,(e=>{e.persisted&&(this.logger.debug("Page was loaded from cache, restoring components state"),s())}),"f"),window.addEventListener("pageshow",i(this,zd,"f"),{once:!0});const t=null===(e=this.stepState)||void 0===e?void 0:e.subscribe(((e,n)=>{e===n&&s(),this.removeEventListener("popupclosed",s),this.stepState.unsubscribe(t)}),(e=>e.screenId),{forceUpdate:!0})},l=this.nextRequestStatus.subscribe((({isLoading:n})=>{n?(this.addEventListener("popupclosed",s,{once:!0}),e.setAttribute("loading","true"),t.forEach((e=>e.setAttribute("disabled","true")))):(this.nextRequestStatus.unsubscribe(l),"success"===this.flowStatus?(this.removeEventListener("popupclosed",s),r()):a())}))},Hd=function(e={}){var t,n;const i=Jl(e,["externalId","email","phone"]),o=Jl(e,["newPassword","password"]);if(i&&o)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:i,password:o});null===(n=null===(t=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===t?void 0:t.store)||void 0===n||n.call(t,e)}catch(e){this.loggerWrapper.error("Could not store credentials",e.message)}},Bd=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((e=>e.remove())),this.contentRootElement.querySelectorAll('[external-input="true"]').forEach((e=>i(this,vd,"m",Jd).call(this,e)))},Jd=function(e){e&&e.querySelectorAll("input").forEach((t=>{const n=t.getAttribute("slot"),i=`input-${e.id}-${n}`,o=document.createElement("slot");o.setAttribute("name",i),o.setAttribute("slot",n),e.appendChild(o),t.setAttribute("slot",i),this.appendChild(t)}))},Zd=function(e){return n(this,void 0,void 0,(function*(){if(i(this,bd,"f")){this.loggerWrapper.debug("Waiting for sdk scripts to load");const e=Date.now();yield i(this,bd,"f"),this.loggerWrapper.debug("Sdk scripts loaded for",(Date.now()-e).toString())}const t=this.loadSdkScriptsModules(),n=e.map((e=>e.id));for(const e of t)if(n.includes(e.id))try{"function"==typeof e.present&&((yield e.present())||this.loggerWrapper.debug(`Sdk script ${e.id} was cancelled`))}catch(t){this.loggerWrapper.error(`Failed to present ${e.id} script module`,t.message)}const o=[];for(const e of t)"function"==typeof e.refresh&&o.push(e.refresh());if(o.length>0)try{yield Vl(5e3,Promise.all(o),null)}catch(e){this.loggerWrapper.error("Failed to refresh script module",e.message)}}))},Xd=function(e,t){this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((n=>{n.addEventListener("input",(()=>{var o;(null===(o=n.checkValidity)||void 0===o?void 0:o.call(n))&&i(this,Kd,"f").call(this,n,e,t)}))}))},Gd=function(e,t,n){t&&n&&"true"===e.getAttribute("data-opt-in-last-used-auth")&&function(e,t,n){try{const n=yc();n[e]=t,fc(Tl,JSON.stringify(n))}catch(e){null==n||n.warn("[Descope] Failed to update in-flight last auth storage",String(e))}}(n,t,this.loggerWrapper)},Yd=function(e){var t;const n=null===(t=wc(this.sdk.getLastUserLoginId(),this.loggerWrapper).lastUsedPerScreen)||void 0===t?void 0:t[e];if(!n)return;const i=this.contentRootElement.querySelector('descope-attachment[data-type="last-auth-badge"]'),o=this.contentRootElement.querySelector(`#${CSS.escape(n)}`);i&&o&&(o.replaceWith(i),i.appendChild(o))},Qd=function(e,t){this.contentRootElement.querySelectorAll(`descope-button:not([${rl}]), [data-type="button"]:not([${rl}]`).forEach((n=>{n.onclick=()=>{i(this,Kd,"f").call(this,n,e,t)}})),i(this,vd,"m",Xd).call(this,e,t),this.isDismissScreenErrorOnInput&&this.contentRootElement.querySelectorAll(`*[name]:not([${ol}])`).forEach((e=>{e.addEventListener("input",(()=>{this.stepState.update((e=>Object.assign(Object.assign({},e),{screenState:Object.assign(Object.assign({},e.screenState),{errorText:"",errorType:""})})))}))}))},eu=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},tu=function(e,t,n){var i;const[o,r]=(null===(i=window.name)||void 0===i?void 0:i.split("|"))||[],s={data:{code:t,exchangeError:n},action:"code"};if("descope-wc"===o&&r){this.loggerWrapper.debug("Using postMessage fallback to notify opener in origin",r);try{window.opener.postMessage(s,r)}catch(e){this.loggerWrapper.error("Failed to send postMessage fallback (likely COOP isolation)",null==e?void 0:e.message)}}else{this.loggerWrapper.debug("Creating popup channel",e);const t=new BroadcastChannel(e);t.postMessage(s),t.close()}try{window.close()}catch(e){}},customElements.get("descope-wc")?console.log("descope-wc is already defined"):customElements.define("descope-wc",nu);var iu=Object.freeze({__proto__:null,default:nu});customElements.define("descope-user-profile-widget",Ka);const ou=(e,t,n,i={})=>{var o,r,s,a;return[Math.min(Math.max(t,("all"===i.left?e.offsetWidth:null!==(o=i.left)&&void 0!==o?o:0)-e.offsetWidth),window.innerWidth-("all"===i.right?e.offsetWidth:null!==(r=i.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===i.top?e.offsetHeight:null!==(s=i.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===i.bottom?e.offsetHeight:null!==(a=i.bottom)&&void 0!==a?a:0))]};var ru,su,au,lu,cu,du,uu,hu,pu,fu;const gu=document.createElement("template");gu.innerHTML=`\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`;const vu=r(B)(HTMLElement);class mu extends vu{constructor(){var e;super(),ru.add(this),su.set(this,new g({messages:[]})),au.set(this,void 0),lu.set(this,void 0),cu.set(this,void 0),du.set(this,{resize:i(this,ru,"m",fu).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(gu.content.cloneNode(!0)),this.injectStyle('\n.debugger {\n all: initial;\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n'),o(this,au,this.shadowRoot.querySelector(".debugger"),"f"),o(this,lu,i(this,au,"f").querySelector(".content"),"f"),o(this,cu,i(this,au,"f").querySelector(".header"),"f")}updateData(e){i(this,su,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,n)=>{let i=0,o=0,r=0,s=0;function a(t){t.preventDefault(),i=r-t.clientX,o=s-t.clientY,r=t.clientX,s=t.clientY;const[a,l]=ou(e,e.offsetLeft-i,e.offsetTop-o,n);e.style.top=`${l}px`,e.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=l,document.onmousemove=a}t?t.onmousedown=c:e.onmousedown=c})(i(this,au,"f"),i(this,cu,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",i(this,du,"f").resize),(e=i(this,au,"f")).onmousemove=t=>{var n;const i=t.target;(i.w&&i.w!==i.offsetWidth||i.h&&i.h!==i.offsetHeight)&&(null===(n=e.onresize)||void 0===n||n.call(e,t)),i.w=i.offsetWidth,i.h=i.offsetHeight},i(this,au,"f").onresize=i(this,ru,"m",pu).bind(this),i(this,su,"f").subscribe(i(this,ru,"m",uu).bind(this))}disconnectedCallback(){i(this,su,"f").unsubscribeAll(),window.removeEventListener("resize",i(this,du,"f").resize)}}su=new WeakMap,au=new WeakMap,lu=new WeakMap,cu=new WeakMap,du=new WeakMap,ru=new WeakSet,uu=function(e){i(this,ru,"m",hu).call(this,e),i(this,ru,"m",pu).call(this)},hu=function(e){i(this,lu,"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("")},pu=function(){i(this,lu,"f").querySelectorAll(".msg").forEach((e=>{const t=e,n=t.querySelector(".msg_desc"),i=n.scrollWidth>n.clientWidth,o=n.clientHeight>20;i||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)}))},fu=function(){const[e,t]=ou(i(this,au,"f"),Number.parseInt(i(this,au,"f").style.left,10),Number.parseInt(i(this,au,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});i(this,au,"f").style.top=`${t}px`,i(this,au,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",mu);var wu=Object.freeze({__proto__:null,default:mu});const bu=(e,t,n,i={})=>{var o,r,s,a;return[Math.min(Math.max(t,("all"===i.left?e.offsetWidth:null!==(o=i.left)&&void 0!==o?o:0)-e.offsetWidth),window.innerWidth-("all"===i.right?e.offsetWidth:null!==(r=i.right)&&void 0!==r?r:0)),Math.min(Math.max(n,("all"===i.top?e.offsetHeight:null!==(s=i.top)&&void 0!==s?s:0)-e.offsetHeight),window.innerHeight-("all"===i.bottom?e.offsetHeight:null!==(a=i.bottom)&&void 0!==a?a:0))]},yu=(e,t,n)=>{let i=0,o=0,r=0,s=0;function a(t){t.preventDefault(),i=r-t.clientX,o=s-t.clientY,r=t.clientX,s=t.clientY;const[a,l]=bu(e,e.offsetLeft-i,e.offsetTop-o,n);e.style.top=`${l}px`,e.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),r=e.clientX,s=e.clientY,document.onmouseup=l,document.onmousemove=a}t?t.onmousedown=c:e.onmousedown=c};var ku,Su,Iu,Cu,Au,xu,Ou,Eu,ju,Ru,Tu;const Mu=document.createElement("template");Mu.innerHTML='\n<div 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';const Uu=r(B)(HTMLElement);class Wu extends Uu{constructor(){super(),ku.add(this),Su.set(this,new nc({messages:[]})),Iu.set(this,void 0),Cu.set(this,void 0),Au.set(this,void 0),xu.set(this,{resize:i(this,ku,"m",Tu).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Mu.content.cloneNode(!0)),o(this,Iu,this.shadowRoot.querySelector(".debugger"),"f"),o(this,Cu,i(this,Iu,"f").querySelector(".content"),"f"),o(this,Au,i(this,Iu,"f").querySelector(".header"),"f"),i(this,ku,"m",Ou).call(this)}updateData(e){i(this,Su,"f").update((t=>({messages:t.messages.concat(e)})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;null===(t=e.init)||void 0===t||t.call(this),yu(i(this,Iu,"f"),i(this,Au,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",i(this,xu,"f").resize),(e=>{e.onmousemove=t=>{(t.target.w&&t.target.w!==t.target.offsetWidth||t.target.h&&t.target.h!==t.target.offsetHeight)&&e.onresize(t),t.target.w=t.target.offsetWidth,t.target.h=t.target.offsetHeight}})(i(this,Iu,"f")),i(this,Iu,"f").onresize=i(this,ku,"m",Ru).bind(this),i(this,Su,"f").subscribe(i(this,ku,"m",Eu).bind(this))}))}disconnectedCallback(){i(this,Su,"f").unsubscribeAll(),window.removeEventListener("resize",i(this,xu,"f").resize)}}Su=new WeakMap,Iu=new WeakMap,Cu=new WeakMap,Au=new WeakMap,xu=new WeakMap,ku=new WeakSet,Ou=function(){this.injectStyle('\n .debugger {\n all: initial;\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n'),i(this,Iu,"f").style.top="32px",i(this,Iu,"f").style.left=window.innerWidth-300-32+"px"},Eu=function(e){i(this,ku,"m",ju).call(this,e),i(this,ku,"m",Ru).call(this)},ju=function(e){i(this,Cu,"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("")},Ru=function(){i(this,Cu,"f").querySelectorAll(".msg").forEach((e=>{const t=e.querySelector(".msg_desc"),n=t.scrollWidth>t.clientWidth,i=t.clientHeight>20;n||i?(e.classList.add("collapsible"),e.onclick=t=>{t.target.classList.contains("msg_desc")||e.classList.toggle("collapsed")}):(e.classList.remove("collapsible"),e.onclick=null)}))},Tu=function(){const[e,t]=bu(i(this,Iu,"f"),Number.parseInt(i(this,Iu,"f").style.left,10),Number.parseInt(i(this,Iu,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});i(this,Iu,"f").style.top=`${t}px`,i(this,Iu,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",Wu);var $u=Object.freeze({__proto__:null,default:Wu});return Ka}();
7
7
  //# sourceMappingURL=index.js.map