@descope/user-profile-widget 0.20.3 → 0.21.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.20.3
3
+ * @descope/user-profile-widget v0.21.0
4
4
  */
5
- this["descope-user-profile-widget"]=function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,i=1,n=arguments.length;i<n;i++)for(var o in t=arguments[i])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},e.apply(this,arguments)};function t(e,t){var i={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(i[n[o]]=e[n[o]])}return i}function i(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{l(n.next(e))}catch(e){s(e)}}function a(e){try{l(n.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}l((n=n.apply(e,t||[])).next())}))}function n(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)}function o(e,t,i,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!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"===n?o.call(e,i):o?o.value=i:t.set(e,i),i}function s(...e){return t=>e.reduce(((e,t)=>t(e)),t)}"function"==typeof SuppressedError&&SuppressedError;const r=e=>{const t=document.createElement("template");return t.innerHTML=e,t},a=e=>{let t,i;return(...n)=>(t&&((e,t)=>e.length===t.length&&e.every(((e,i)=>e===t[i])))(t,n)||(t=n,i=e(...n)),i)},l=(e={})=>{const t=r("<descope-wc></descope-wc>");return Object.entries(e).forEach((([e,i])=>{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:"boolean"==typeof e?String(e):(e=>null!==e&&"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype)(e)?JSON.stringify(e):"")(i))})),t},c=e=>{const t=Symbol((e=>{const t=e.toString();let i=0;for(let e=0;e<t.length;e++)i=(i<<5)-i+t.charCodeAt(e),i&=i;return i.toString(16)})(e));return i=>{if(i[t])return i;const n=e(i);return n[t]=!0,n}};var d,u,h,p;function f(e,t){const i=Object.getOwnPropertyNames(e),n=Object.getOwnPropertyNames(t);if(i.length!==n.length)return!1;for(let n=0;n<i.length;n+=1){const o=i[n],s=e[o],r=t[o];if(null===s||null===r){if(s!==r)return!1}else if("object"==typeof s&&"object"==typeof r){if(!f(s,r))return!1}else if(s!==r)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(n(this,d,"f")):e,i=Object.assign(Object.assign({},n(this,d,"f")),t);if(n(this,p,"f")||!f(n(this,d,"f"),i)){const e=n(this,d,"f");o(this,d,i,"f"),Object.freeze(n(this,d,"f")),setTimeout((()=>{Object.values(n(this,u,"f")).forEach((t=>t(i,e,((e,t)=>i=>e[i]!==t[i])(i,e))))}),0)}},o(this,d,e,"f"),o(this,p,t,"f")}get current(){return Object.assign({},n(this,d,"f"))}subscribe(e){return o(this,h,n(this,h,"f")+1,"f"),n(this,u,"f")[n(this,h,"f")]=e,n(this,h,"f").toString()}unsubscribe(e){const t=!!n(this,u,"f")[e];return t&&delete n(this,u,"f")[e],t}unsubscribeAll(){return o(this,u,{},"f"),!0}};d=new WeakMap,u=new WeakMap,h=new WeakMap,p=new WeakMap;const v=e=>String(null!=e?e:"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;");function m(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 w=["error","warn","info","debug"],b={error:console.error.bind(console,"[Descope]"),warn:console.warn.bind(console,"[Descope]"),info:console.info.bind(console,"[Descope]"),debug:console.debug.bind(console,"[Descope]")},y=c((e=>{var t,i,s,r;return r=class extends e{constructor(){super(...arguments),t.add(this),i.set(this,n(this,t,"m",s).call(this,b))}set logger(e){o(this,i,n(this,t,"m",s).call(this,e||b),"f")}get logger(){return n(this,i,"f")}onLogEvent(e,t){}},i=new WeakMap,t=new WeakSet,s=function(e){return w.reduce(((t,i)=>(t[i]=(...t)=>{var n;this.onLogEvent(i,t),null===(n=e[i])||void 0===n||n.call(e,...t)},t)),{})},r})),k="undefined"!=typeof localStorage,S="https://static.descope.com/pages",I="https://static2.descope.com/pages",C=k&&localStorage.getItem("base.content.url")||"",E=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,A=c((e=>{var t,i;return i=class extends e{constructor(){super(...arguments),t.set(this,!0)}connectedCallback(){var e,i;null===(e=super.connectedCallback)||void 0===e||e.call(this),(null===(i=this.shadowRoot)||void 0===i?void 0:i.isConnected)&&n(this,t,"f")&&(o(this,t,!1,"f"),this.init())}async init(){}},t=new WeakMap,i})),x=c((e=>{var t,i;const o=s(y,A)(e);return i=class extends o{constructor(){super(...arguments),t.set(this,{})}async init(){var e,i,o;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),i=this,o=e=>{var i;null===(i=n(this,t,"f")[e])||void 0===i||i.forEach((t=>{t(e,this.getAttribute(e))}))},Array.from(i.attributes).forEach((e=>o(e.name))),new MutationObserver((e=>{e.forEach((e=>{"attributes"===e.type&&e.oldValue!==i.getAttribute(e.attributeName)&&o(e.attributeName)}))})).observe(i,{attributes:!0,attributeOldValue:!0})}observeAttribute(e,i){n(this,t,"f")[e]||(n(this,t,"f")[e]=[]);const o=n(this,t,"f")[e].push(i);return()=>n(this,t,"f")[e].splice(o,1)}observeAttributes(e,t){const i=e.reduce(((e,i)=>(e.push(this.observeAttribute(i,t)),e)),[]);return()=>i.forEach((e=>e()))}},t=new WeakMap,i})),O=e=>t=>{var i,o,r;const a=s(y,A,x)(t),l=Object.keys(e);return r=class extends a{constructor(...e){super(...e),i.add(this),this.observeAttributes(l,n(this,i,"m",o).bind(this))}async init(){var e;l.forEach((e=>n(this,i,"m",o).call(this,e,this.getAttribute(e)))),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},i=new WeakSet,o=function(t,i){const n=e[t],o="function"==typeof n?n(t,i):n;o&&this.logger.error(o)},r};O.missingAttrValidator=E;const j=c((e=>{const t=s(O({"project-id":E}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),R=c((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),T="Trying the next fallback URL...",M=async(e,t,{logger:i}={})=>{try{return await fetch(e,t)}catch(n){return null==i||i.debug(`Network error fetching URL ${e} [${n.message}], retrying...`),fetch(e,t)}};const W=c((e=>{var t,i,r,a,l,c,d;const u=s(y,j,R)(e);return d=class extends u{constructor(){super(...arguments),t.add(this),i.set(this,void 0),r.set(this,void 0),a.set(this,new Set)}async fetchStaticResource(e,i){const s=n(this,t,"m",l).call(this,e),c=Array.isArray(s)?e=>{const{baseUrl:t}=s[e];o(this,r,t,"f");for(let t=0;t<e;t++){const e=s[t].baseUrl;n(this,a,"f").add(e)}}:null;try{const e=await(async(e,t,{logger:i,onSuccess:n}={})=>{const o=Array.isArray(e)?e:[e];for(let e=0;e<o.length;e++){const s=o[e],r=e===o.length-1;try{const o=await M(s.toString(),t,{logger:i});if(o.ok)return null==n||n(e),null==i||i.debug(`Successfully fetched URL ${s}`),o;const a=`Error fetching URL ${s} [${o.status}]`;if(r)throw new Error(a);null==i||i.debug(`${a}. ${T}`)}catch(e){const t=`Error fetching URL ${s} [${e.message}]`;if(r)throw new Error(t);null==i||i.debug(`${t}. ${T}`)}}})(s,{cache:"default"},{logger:this.logger,onSuccess:c});return{body:await e[i](),headers:Object.fromEntries(e.headers.entries())}}catch(e){this.logger.error(e.message)}}get baseStaticUrl(){return this.getAttribute("base-static-url")||""}},i=new WeakMap,r=new WeakMap,a=new WeakMap,t=new WeakSet,l=function(e){const s=C||this.baseStaticUrl;if(s)return n(this,t,"m",c).call(this,e,s);n(this,i,"f")!==this.baseUrl&&(o(this,i,this.baseUrl,"f"),o(this,r,void 0,"f"),n(this,a,"f").clear());const l=[];if(n(this,r,"f"))l.push(n(this,t,"m",c).call(this,e,n(this,r,"f"))),n(this,r,"f")===S&&l.push(n(this,t,"m",c).call(this,e,I));else{const i=this.baseUrl+"/pages";this.baseUrl&&!n(this,a,"f").has(i)&&l.push(n(this,t,"m",c).call(this,e,i)),n(this,a,"f").has(S)||l.push(n(this,t,"m",c).call(this,e,S)),l.push(n(this,t,"m",c).call(this,e,I))}return 1===l.length?l[0]:l},c=function(e,t){return function({projectId:e,filename:t,assetsFolder:i="v2-beta",baseUrl:n=S}){const o=new URL(n);return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,i,t),o.baseUrl=n,o}({projectId:this.projectId,filename:e,baseUrl:t})},d})),U=c((e=>{var t,i;const o=s(O({"project-id":E}))(e);return i=class extends o{constructor(){super(...arguments),t.set(this,new Map)}onReset(e,i){if(n(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} already exists`);return n(this,t,"f").set(e,i),()=>{n(this,t,"f").delete(e)}}async reset(...e){0===e.length?await Promise.all(Array.from(n(this,t,"f").values()).map((e=>e()))):await Promise.all(e.map((e=>{var i;if(!n(this,t,"f").has(e))throw new Error(`Callback for sectionId ${e} does not exist`);return null===(i=n(this,t,"f").get(e))||void 0===i?void 0:i()})))}},t=new WeakMap,i})),P=c((e=>{var t,i,r,a,l;const c=s(W,U,A)(e);return l=class extends c{constructor(){super(...arguments),t.add(this),r.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",n(this,t,"m",i).bind(this))}get config(){return n(this,r,"f")||o(this,r,n(this,a,"f").call(this),"f"),n(this,r,"f")}},r=new WeakMap,a=new WeakMap,t=new WeakSet,i=function(){o(this,r,void 0,"f")},l})),_=c((e=>{var t,i,r,a,l,c,d;return d=class extends(s(A,y)(e)){constructor(){super(...arguments),t.add(this),i.set(this,void 0),this.attributeChangedCallback=(e,i,o)=>{var s;null===(s=super.attributeChangedCallback)||void 0===s||s.call(this,e,i,o),"debug"===e&&n(this,t,"m",l).call(this)}}get debug(){return"true"===this.getAttribute("debug")}onLogEvent(e,i){var o;null===(o=super.onLogEvent)||void 0===o||o.call(this,e,i),"error"===e&&n(this,t,"m",c).call(this,i[0]||"Error",i[1])}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),n(this,t,"m",l).call(this)}},i=new WeakMap,t=new WeakSet,r=function(){var e;null===(e=n(this,i,"f"))||void 0===e||e.remove(),o(this,i,null,"f")},a=async function(){o(this,i,document.createElement("descope-debugger"),"f"),Object.assign(n(this,i,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),await Promise.resolve().then((function(){return Th})),document.body.appendChild(n(this,i,"f"))},l=function(){this.debug?n(this,t,"m",a).call(this):n(this,t,"m",r).call(this)},c=function(e,t){var o;e&&(null===(o=n(this,i,"f"))||void 0===o||o.updateData({title:e,description:t}))},d})),L=["https://descopecdn.com","https://static.descope.com","https://cdn.jsdelivr.net"],$=e=>{let t=0;const i=e.toString();for(let e=0;e<i.length;e++){t=(t<<5)-t+i.charCodeAt(e),t|=0}return`${Math.abs(t).toString()}`},N=(e,t,i)=>new Promise(((n,o)=>{const s=((e,t)=>{const i=document.createElement("script");return i.id=e,t&&(i.integrity=t,i.crossOrigin="anonymous"),window.DESCOPE_NONCE&&i.setAttribute("nonce",window.DESCOPE_NONCE),i})(e,i);s.onerror=e=>{s.setAttribute("status","error"),o(e)},s.onload=()=>{s.setAttribute("status","loaded"),n(s)},s.src=t.toString(),document.body.appendChild(s)})),D=(e,t)=>{if(t){const i=e.integrity;if(i!==t)return Promise.reject(new Error(`Integrity mismatch: expected ${t}, found ${i}`))}return"loaded"===e.getAttribute("status")?Promise.resolve(e):(e=>"error"===e.getAttribute("status"))(e)?Promise.reject():new Promise(((t,i)=>{e.addEventListener("load",(()=>{t(e)})),e.addEventListener("error",(e=>{i(e)}))}))},F=c((e=>{const t=s(y)(e);return class extends t{get baseCdnUrl(){return this.getAttribute("base-cdn-url")||""}injectNpmLib(e,t,i="",n=[],o){return this.logger.debug(`Injecting npm lib: "${e}" with version: "${t}"${o?" with SRI integrity check":""}`),(async(e,t)=>{for(const n of e){const{id:e,url:o,integrity:s}=n,r=(i=e,document.querySelector(`script#${i}`));if(r)try{return await D(r,s),n}catch(e){t(n,!0)}else try{return await N(e,o,s),n}catch(e){t(n,!1)}}var i;throw new Error("All scripts failed to load")})(((e,t,i,n="",o)=>e.reduce(((e,s)=>{const r=s;if(!r)return e;let a;try{a=new URL(r)}catch(e){throw new Error(`Invalid URL: ${r}`)}"/"!==a.pathname||(a.pathname=`/npm/${t}@${i}/${n}`);const l={url:a,id:`npmlib-${t.replaceAll("@","").replaceAll("/","_")}-${$(a)}`};return o&&(l.integrity=o),[...e,l]}),[]))([...n,this.baseCdnUrl,...L],e,t,i,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}"`)}))}}})),q="base.ui.components.url",z=k&&localStorage.getItem(q),V=c((e=>{var t,i,r,a,l,c,d;const u=s(y,P,F)(e);return d=class extends u{constructor(){super(...arguments),t.add(this),a.set(this,void 0)}get descopeUi(){return n(this,a,"f")||o(this,a,n(this,t,"m",c).call(this),"f"),n(this,a,"f")}async loadDescopeUiComponents(e){const i=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(i.map((e=>n(this,t,"m",l).call(this,e))))}},a=new WeakMap,t=new WeakSet,i=async function(){var e;const t=await this.config,i=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return i?this.logger.debug(`Got component version "${i}"`):this.logger.error("Could not get components version"),i},r=async function(){var e;const t=await this.config,i=null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersionSri;return i&&this.logger.debug("SRI hash available for components"),i},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 n(this,t,"m",i).call(this),o=z?void 0:await n(this,t,"m",r).call(this);return await this.injectNpmLib("@descope/web-components-ui",e,"dist/umd/index.js",[z],o),this.logger.debug("DescopeUI was loaded"),globalThis.DescopeUI}catch(e){throw this.logger.error(e),new Error("DescopeUI was not loaded")}},d})),J=c((e=>{var t,i,o;const r=s(A,x)(e);return o=class extends r{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",n(this,t,"m",i).bind(this)),n(this,t,"m",i).call(this)}},t=new WeakSet,i=function(){this.nonce&&(window.DESCOPE_NONCE=this.nonce)},o}));class B{constructor(e,t,{prepend:i=!1}={}){this.styleEle=document.createElement("style"),this.styleEle.setAttribute("nonce",t),this.ref=e,this.ref&&(i?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 H=c((e=>{const t=s(J)(e);return class extends t{injectStyle(e,{prepend:t=!1}={}){let i;try{i=new CSSStyleSheet}catch(e){i=new B(this.shadowRoot,this.nonce,{prepend:t})}if(e&&i.replaceSync(e),i instanceof CSSStyleSheet){const e=this.shadowRoot;if(e&&"adoptedStyleSheets"in e){const n=[...e.adoptedStyleSheets||[]];n[t?"unshift":"push"](i),e.adoptedStyleSheets=n}}return i}}})),K="content-root",Y="root",G=c((e=>{const t=s(H)(e);return class extends t{constructor(...e){var t,i;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${Y}">\n <div id="${K}"></div>\n </div>\n `,this.injectStyle(`\n #${Y}, #${K} {\n height: 100%;\n }\n #${Y} {\n position: relative;\n height: fit-content;\n }\n #${Y}:has(> #${K} > #ROOT[st-host-height="100%"]) {\n height: 100%;\n }\n `),this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById(K),this.rootElement=null===(i=this.shadowRoot)||void 0===i?void 0:i.getElementById(Y)}}})),Z="descope-modal";var X;let Q=class{constructor(e,t){X.set(this,void 0),this.nodeName="",o(this,X,e,"f"),this.logger=t.logger}get asyncEle(){return(async e=>new Promise((t=>{const i=setInterval((()=>{const n="function"==typeof e?e():e;n&&(clearInterval(i),t(n))}),100);setTimeout((()=>{clearInterval(i),t(null)}),1e3)})))(n(this,X,"f"))}get ele(){var e,t;const i="function"==typeof n(this,X,"f")?n(this,X,"f").call(this):n(this,X,"f");return i?(null==i?void 0:i.localName)!==this.nodeName?(null===(t=this.logger)||void 0===t||t.debug(`node name do not match, expected "${this.nodeName}", received "${i.localName}" `,Error()),null):i:(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}};X=new WeakMap;let ee=class extends Q{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)}}},te=class extends Q{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")}},ie=class extends Q{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,i;e?null===(i=this.ele)||void 0===i||i.setAttribute("theme",e):null===(t=this.ele)||void 0===t||t.removeAttribute("theme")}start(){var e,t;null===(t=null===(e=this.ele)||void 0===e?void 0:e.start)||void 0===t||t.call(e)}onSuccess(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("success",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("success",e)}}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 te{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 oe,se,re,ae;let le=class extends Q{constructor(...e){super(...e),oe.add(this),se.set(this,void 0),re.set(this,void 0),this.nodeName="descope-modal",n(this,oe,"m",ae).call(this)}get isOpen(){var e;return"true"===(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("opened"))}get isClosed(){return!this.isOpen}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)),n(this,oe,"m",ae).call(this),null===(t=this.ele)||void 0===t||t.setAttribute("opened","true")}reset(){var e;this.ele&&(this.ele.innerHTML=""),n(this,se,"f")&&(null===(e=this.ele)||void 0===e||e.append(n(this,se,"f").content.cloneNode(!0)))}setContent(e){o(this,se,e,"f"),this.reset()}remove(){var e,t;null===(e=n(this,re,"f"))||void 0===e||e.disconnect(),null===(t=this.ele)||void 0===t||t.remove()}};se=new WeakMap,re=new WeakMap,oe=new WeakSet,ae=function(){if(n(this,re,"f"))return;const e=this.ele;e&&(o(this,re,new MutationObserver((t=>{t.forEach(((i,n)=>{var o;const s="true"===i.oldValue,r=t[n+1]?t[n+1].oldValue:e.getAttribute("opened");s&&"true"!==r&&(null===(o=this.afterClose)||void 0===o||o.call(this))}))})),"f"),n(this,re,"f").observe(e,{attributes:!0,attributeFilter:["opened"],attributeOldValue:!0}))};let ce=class extends Q{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()}},de=class extends Q{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)}},ue=class extends Q{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)}}},he=class extends Q{constructor(){super(...arguments),this.nodeName="descope-user-auth-method"}set fulfilled(e){var t,i;e?null===(t=this.ele)||void 0===t||t.setAttribute("fulfilled","true"):null===(i=this.ele)||void 0===i||i.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")}},pe=class extends Q{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 i=t=>e(t.detail);return null===(t=this.ele)||void 0===t||t.addEventListener("remove-device-clicked",i),()=>{var e;return null===(e=this.ele)||void 0===e?void 0:e.removeEventListener("remove-device-clicked",i)}}},fe=class extends de{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}},ge=class extends Q{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 i=t=>e(t.detail);return null===(t=this.ele)||void 0===t||t.addEventListener("remove-passkey-clicked",i),()=>{var e;return null===(e=this.ele)||void 0===e?void 0:e.removeEventListener("remove-passkey-clicked",i)}}};const ve=c((e=>{var t,i;const o=s(A,G,V)(e);return i=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends le{setContent(t){e(t),super.setContent(t)}}})())}get modalDriverClass(){return n(this,t,"f")}createModal(e,i=n(this,t,"f")){const o=((e={})=>{const t=document.createElement(Z);return Object.keys(e).forEach((i=>{t.setAttribute(i,e[i])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(o),new i(o,{logger:this.logger})}async init(){var e;this.loadDescopeUiComponents([Z]),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},t=new WeakMap,i})),me=c((e=>class extends(ve(e)){createFlowModal(e){const t=this.modalDriverClass;return this.createModal(e,class extends t{setContent(e){const t=e.content.querySelector("descope-wc");t&&!t.hasAttribute("lazy-start")&&t.setAttribute("lazy-start","true"),super.setContent(e)}async open(){var e,t,i;await super.open(),null===(i=null===(t=null===(e=this.ele)||void 0===e?void 0:e.querySelector("descope-wc"))||void 0===t?void 0:t.start)||void 0===i||i.call(t)}})}})),we="descope-notification",be=c((e=>{var t,i;const o=s(A,G,V)(e);return i=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends ce{setContent(t){const i="string"==typeof t?r(t):t;e(i),super.setContent(i)}}})())}createNotification(e){const i=((e={})=>{const t=document.createElement(we);return Object.keys(e).forEach((i=>{t.setAttribute(i,e[i])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(i),new(n(this,t,"f"))(i,{logger:this.logger})}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this)),this.loadDescopeUiComponents([we])}},t=new WeakMap,i})),ye="theme",ke=(e,t,i="")=>Object.entries(e).reduce(((e,[n,o])=>{if(!/^[a-zA-Z0-9-]+$/.test(n))return t("Ignoring invalid override-css token path segment"),e;const s=i?`${i}-${n}`:n;if("object"==typeof o&&null!==o)return e+ke(o,t,s);const r=(e=>"number"==typeof e?Number.isFinite(e)?String(e):null:"string"!=typeof e||/[;{}]/.test(e)?null:e.trim())(o);return null===r?(t("Ignoring invalid override-css token value"),e):`${e}--descope-${s}:${r};`}),""),Se=e=>{const t=document.createElement("link");t.href=e,t.rel="stylesheet",document.head.appendChild(t)};function Ie(e,t){const i=Object.assign({},e);for(const[e,n]of Object.entries(t||{}))if(null!=n)if("object"==typeof n){if(0===Object.keys(n).length)continue;i[e]=Ie(i[e]||{},n)}else i[e]="string"==typeof n?(i[e]||"")+n:n;return i}const Ce=(e,t)=>null!==t&&!/^[a-zA-Z0-9_-]*$/.test(t)&&"tenant must contain only alphanumeric characters, hyphens, or underscores",Ee=c((e=>{const t=s(O({tenant:Ce}))(e);return class extends t{get tenantId(){return this.getAttribute("tenant")||void 0}}})),Ae=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',xe=c((e=>{var t,i,r,a,l,c,d,u,h,p,f,g,v,m,w,b,y,k,S,I,C,E,j;const R=s(O({theme:Ae}),Ee,W,A,V,P,G,x,H)(e);return j=class extends R{constructor(){super(...arguments),t.add(this),i.set(this,void 0),r.set(this,void 0),a.set(this,void 0),c.set(this,void 0),d.set(this,void 0),I.set(this,(()=>{n(this,t,"m",C).call(this),n(this,E,"f").call(this,"os"===this.getAttribute("theme"))})),E.set(this,(e=>{var i,o,s;const r=e?"addEventListener":"removeEventListener";null===(s=null===(o=null===(i=window.matchMedia)||void 0===i?void 0:i.call(window,"(prefers-color-scheme: dark)"))||void 0===o?void 0:o[r])||void 0===s||s.call(o,"change",(()=>n(this,t,"m",C).call(this)))}))}get theme(){var e,t;const i=this.getAttribute("theme");if("os"===i){return window.matchMedia&&(null===(t=null===(e=window.matchMedia)||void 0===e?void 0:e.call(window,"(prefers-color-scheme: dark)"))||void 0===t?void 0:t.matches)?"dark":"light"}return i||"light"}get styleId(){return this.getAttribute("style-id")||ye}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)),n(this,I,"f").call(this),await Promise.all([n(this,t,"m",p).call(this),n(this,t,"m",v).call(this),n(this,t,"m",w).call(this)]),n(this,t,"m",m).call(this),this.observeAttributes(["theme"],n(this,I,"f")),this.observeAttributes(["theme-override"],(()=>n(this,t,"m",m).call(this))),this.observeAttributes(["tenant"],(()=>{o(this,d,null,"f"),n(this,t,"m",v).call(this),n(this,t,"m",w).call(this),n(this,t,"m",k).call(this)})),this.observeAttributes(["style-id"],(()=>{o(this,c,null,"f"),n(this,t,"m",y).call(this),n(this,t,"m",p).call(this),n(this,t,"m",w).call(this)}))}},i=new WeakMap,r=new WeakMap,a=new WeakMap,c=new WeakMap,d=new WeakMap,I=new WeakMap,E=new WeakMap,t=new WeakSet,l=function(){const e=this.themeOverride;return e?["light","dark"].map((t=>{var i,n,o,s,r,a;const l=null===(o=null===(n=null===(i=e[t])||void 0===i?void 0:i.globals)||void 0===n?void 0:n.colors)||void 0===o?void 0:o.primary,c=null===(a=null===(r=null===(s=e[t])||void 0===s?void 0:s.globals)||void 0===r?void 0:r.colors)||void 0===a?void 0:a.secondary;return l||c?`[data-theme="${t}"]{${ke({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(q))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(q),t=null==e?void 0:e.replace(/[^\/]+$/,"DescopeDev.js");console.warn("Trying to load DescopeDev.js from",t);const i=document.createElement("script");if(i.src=t,document.body.appendChild(i),await new Promise(((e,t)=>{i.onload=e,i.onerror=t})),globalThis.DescopeDev){const{themeToStyle:e,defaultTheme:t,darkTheme:i}=globalThis.DescopeDev;return{light:e(t),dark:e(i)}}})();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 n(this,c,"f")||(o(this,c,n(this,t,"m",u).call(this),"f"),n(this,c,"f").then((e=>this.logger.debug("Fetched theme",e)))),n(this,c,"f")},p=async function(){var e,s;const r=await n(this,t,"a",h);if(!r)return;const a=((null===(e=null==r?void 0:r.light)||void 0===e?void 0:e.globals)||"")+((null===(s=null==r?void 0:r.dark)||void 0===s?void 0:s.globals)||"");n(this,i,"f")?n(this,i,"f").replaceSync(a):o(this,i,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.warn("No tenant style exists, using project default theme.")}},g=function(){return n(this,d,"f")||o(this,d,n(this,t,"m",f).call(this),"f"),n(this,d,"f")},v=async function(){var e,i,s,a;if(!this.tenantId)return void(null===(e=n(this,r,"f"))||void 0===e||e.replaceSync(""));const l=await n(this,t,"a",g);if(!l)return void(null===(i=n(this,r,"f"))||void 0===i||i.replaceSync(""));const c=((null===(s=l.light)||void 0===s?void 0:s.globals)||"")+((null===(a=l.dark)||void 0===a?void 0:a.globals)||"");n(this,r,"f")?n(this,r,"f").replaceSync(c):o(this,r,this.injectStyle(c),"f")},m=async function(){var e;if(!this.themeOverride)return void(null===(e=n(this,a,"f"))||void 0===e||e.replaceSync(""));const i=n(this,t,"m",l).call(this);n(this,a,"f")?n(this,a,"f").replaceSync(i):o(this,a,this.injectStyle(i),"f")},w=async function(){var e,i,o,s;const r=await n(this,t,"a",h);if(!r)return;const a=await this.descopeUi;if(!(null==a?void 0:a.componentsThemeManager))return;const l=await n(this,t,"a",g);a.componentsThemeManager.themes={light:Ie((null===(e=null==r?void 0:r.light)||void 0===e?void 0:e.components)||{},(null===(i=null==l?void 0:l.light)||void 0===i?void 0:i.components)||{}),dark:Ie((null===(o=null==r?void 0:r.dark)||void 0===o?void 0:o.components)||{},(null===(s=null==l?void 0:l.dark)||void 0===s?void 0:s.components)||{})}},b=async function(){var e,t;const{projectConfig:i}=await this.config||{},n=null===(e=null==i?void 0:i.styles)||void 0===e?void 0:e[this.styleId],o=null==i?void 0:i.cssTemplate,s=n||o;return null===(t=null==s?void 0:s[this.theme])||void 0===t?void 0:t.fonts},y=async function(){const e=await n(this,t,"m",b).call(this);e?Object.values(e).forEach((e=>{e.url&&(this.logger.debug(`Loading font from URL "${e.url}"`),Se(e.url))})):this.logger.debug("No fonts to load"),n(this,t,"m",k).call(this)},k=async function(){var e;if(!this.tenantId)return;const i=await n(this,t,"a",g),o=null===(e=null==i?void 0:i[this.theme])||void 0===e?void 0:e.fonts;Object.values(o||{}).forEach((e=>{(null==e?void 0:e.url)&&(this.logger.debug(`Loading tenant font from URL "${e.url}"`),Se(e.url))}))},S=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)},C=function(){n(this,t,"m",y).call(this),n(this,t,"m",S).call(this)},j}));var Oe=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),je=()=>Math.random().toString(36).substring(7).split("").join("."),Re={INIT:`@@redux/INIT${je()}`,REPLACE:`@@redux/REPLACE${je()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${je()}`};function Te(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 Me(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 i=function(e){return"function"==typeof e.constructor?e.constructor.name:null}(e);switch(i){case"Symbol":case"Promise":case"WeakMap":case"WeakSet":case"Map":case"Set":return i}return Object.prototype.toString.call(e).slice(8,-1).toLowerCase().replace(/\s/g,"")}function We(e){let t=typeof e;return t=Me(e),t}function Ue(e,t,i){if("function"!=typeof e)throw new Error(`Expected the root reducer to be a function. Instead, received: '${We(e)}'`);if("function"==typeof t&&"function"==typeof i||"function"==typeof i&&"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===i&&(i=t,t=void 0),void 0!==i){if("function"!=typeof i)throw new Error(`Expected the enhancer to be a function. Instead, received: '${We(i)}'`);return i(Ue)(e,t)}let n=e,o=t,s=new Map,r=s,a=0,l=!1;function c(){r===s&&(r=new Map,s.forEach(((e,t)=>{r.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: '${We(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 i=a++;return r.set(i,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(),r.delete(i),s=null}}}function h(e){if(!Te(e))throw new Error(`Actions must be plain objects. Instead, the actual type was: '${We(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: '${We(e.type)}'. Value was: '${e.type}' (stringified)`);if(l)throw new Error("Reducers may not dispatch actions.");try{l=!0,o=n(o,e)}finally{l=!1}return(s=r).forEach((e=>{e()})),e}h({type:Re.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: '${We(e)}`);n=e,h({type:Re.REPLACE})},[Oe]: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: '${We(t)}'`);function i(){const e=t;e.next&&e.next(d())}i();return{unsubscribe:e(i)}},[Oe](){return this}}}}}function Pe(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}function _e(e){const t=Object.keys(e),i={};for(let n=0;n<t.length;n++){const o=t[n];void 0===e[o]&&Pe(`No reducer provided for key "${o}"`),"function"==typeof e[o]&&(i[o]=e[o])}const n=Object.keys(i);let o,s;o={};try{!function(e){Object.keys(e).forEach((t=>{const i=e[t];if(void 0===i(void 0,{type:Re.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===i(void 0,{type:Re.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 '${Re.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.`)}))}(i)}catch(e){s=e}return function(e={},t){if(s)throw s;{const n=function(e,t,i,n){const o=Object.keys(t),s=i&&i.type===Re.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(!Te(e))return`The ${s} has unexpected type of "${We(e)}". Expected argument to be an object with the following keys: "${o.join('", "')}"`;const r=Object.keys(e).filter((e=>!t.hasOwnProperty(e)&&!n[e]));return r.forEach((e=>{n[e]=!0})),i&&i.type===Re.REPLACE?void 0:r.length>0?`Unexpected ${r.length>1?"keys":"key"} "${r.join('", "')}" found in ${s}. Expected to find one of the known reducer keys instead: "${o.join('", "')}". Unexpected keys will be ignored.`:void 0}(e,i,t,o);n&&Pe(n)}let r=!1;const a={};for(let o=0;o<n.length;o++){const s=n[o],l=i[s],c=e[s],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 "${s}" 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[s]=d,r=r||d!==c}return r=r||n.length!==Object.keys(e).length,r?a:e}}function Le(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...i)=>e(t(...i))))}function $e(e){return Te(e)&&"type"in e&&"string"==typeof e.type}var Ne=Symbol.for("immer-nothing"),De=Symbol.for("immer-draftable"),Fe=Symbol.for("immer-state"),qe=[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 ze(e,...t){{const i=qe[e],n="function"==typeof i?i.apply(null,t):i;throw new Error(`[Immer] ${n}`)}}var Ve=Object.getPrototypeOf;function Je(e){return!!e&&!!e[Fe]}function Be(e){return!!e&&(Ke(e)||Array.isArray(e)||!!e[De]||!!e.constructor?.[De]||Qe(e)||et(e))}var He=Object.prototype.constructor.toString();function Ke(e){if(!e||"object"!=typeof e)return!1;const t=Ve(e);if(null===t)return!0;const i=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return i===Object||"function"==typeof i&&Function.toString.call(i)===He}function Ye(e,t){0===Ge(e)?Object.entries(e).forEach((([i,n])=>{t(i,n,e)})):e.forEach(((i,n)=>t(n,i,e)))}function Ge(e){const t=e[Fe];return t?t.type_:Array.isArray(e)?1:Qe(e)?2:et(e)?3:0}function Ze(e,t){return 2===Ge(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Xe(e,t,i){const n=Ge(e);2===n?e.set(t,i):3===n?e.add(i):e[t]=i}function Qe(e){return e instanceof Map}function et(e){return e instanceof Set}function tt(e){return e.copy_||e.base_}function it(e,t){if(Qe(e))return new Map(e);if(et(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&Ke(e)){if(!Ve(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const i=Object.getOwnPropertyDescriptors(e);delete i[Fe];let n=Reflect.ownKeys(i);for(let t=0;t<n.length;t++){const o=n[t],s=i[o];!1===s.writable&&(s.writable=!0,s.configurable=!0),(s.get||s.set)&&(i[o]={configurable:!0,writable:!0,enumerable:s.enumerable,value:e[o]})}return Object.create(Ve(e),i)}function nt(e,t=!1){return st(e)||Je(e)||!Be(e)||(Ge(e)>1&&(e.set=e.add=e.clear=e.delete=ot),Object.freeze(e),t&&Ye(e,((e,t)=>nt(t,!0)))),e}function ot(){ze(2)}function st(e){return Object.isFrozen(e)}var rt,at={};function lt(e){const t=at[e];return t||ze(0,e),t}function ct(){return rt}function dt(e,t){t&&(lt("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function ut(e){ht(e),e.drafts_.forEach(ft),e.drafts_=null}function ht(e){e===rt&&(rt=e.parent_)}function pt(e){return rt={drafts_:[],parent_:rt,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function ft(e){const t=e[Fe];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function gt(e,t){t.unfinalizedDrafts_=t.drafts_.length;const i=t.drafts_[0];return void 0!==e&&e!==i?(i[Fe].modified_&&(ut(t),ze(4)),Be(e)&&(e=vt(t,e),t.parent_||wt(t,e)),t.patches_&&lt("Patches").generateReplacementPatches_(i[Fe].base_,e,t.patches_,t.inversePatches_)):e=vt(t,i,[]),ut(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Ne?e:void 0}function vt(e,t,i){if(st(t))return t;const n=t[Fe];if(!n)return Ye(t,((o,s)=>mt(e,n,t,o,s,i))),t;if(n.scope_!==e)return t;if(!n.modified_)return wt(e,n.base_,!0),n.base_;if(!n.finalized_){n.finalized_=!0,n.scope_.unfinalizedDrafts_--;const t=n.copy_;let o=t,s=!1;3===n.type_&&(o=new Set(t),t.clear(),s=!0),Ye(o,((o,r)=>mt(e,n,t,o,r,i,s))),wt(e,t,!1),i&&e.patches_&&lt("Patches").generatePatches_(n,i,e.patches_,e.inversePatches_)}return n.copy_}function mt(e,t,i,n,o,s,r){if(o===i&&ze(5),Je(o)){const r=vt(e,o,s&&t&&3!==t.type_&&!Ze(t.assigned_,n)?s.concat(n):void 0);if(Xe(i,n,r),!Je(r))return;e.canAutoFreeze_=!1}else r&&i.add(o);if(Be(o)&&!st(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;vt(e,o),t&&t.scope_.parent_||wt(e,o)}}function wt(e,t,i=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&nt(t,i)}var bt={get(e,t){if(t===Fe)return e;const i=tt(e);if(!Ze(i,t))return function(e,t,i){const n=St(t,i);return n?"value"in n?n.value:n.get?.call(e.draft_):void 0}(e,i,t);const n=i[t];return e.finalized_||!Be(n)?n:n===kt(e.base_,t)?(Ct(e),e.copy_[t]=Et(n,e)):n},has:(e,t)=>t in tt(e),ownKeys:e=>Reflect.ownKeys(tt(e)),set(e,t,i){const n=St(tt(e),t);if(n?.set)return n.set.call(e.draft_,i),!0;if(!e.modified_){const n=kt(tt(e),t),o=n?.[Fe];if(o&&o.base_===i)return e.copy_[t]=i,e.assigned_[t]=!1,!0;if(function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}(i,n)&&(void 0!==i||Ze(e.base_,t)))return!0;Ct(e),It(e)}return e.copy_[t]===i&&(void 0!==i||t in e.copy_)||Number.isNaN(i)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=i,e.assigned_[t]=!0),!0},deleteProperty:(e,t)=>(void 0!==kt(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,Ct(e),It(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const i=tt(e),n=Reflect.getOwnPropertyDescriptor(i,t);return n?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:n.enumerable,value:i[t]}:n},defineProperty(){ze(11)},getPrototypeOf:e=>Ve(e.base_),setPrototypeOf(){ze(12)}},yt={};function kt(e,t){const i=e[Fe];return(i?tt(i):e)[t]}function St(e,t){if(!(t in e))return;let i=Ve(e);for(;i;){const e=Object.getOwnPropertyDescriptor(i,t);if(e)return e;i=Ve(i)}}function It(e){e.modified_||(e.modified_=!0,e.parent_&&It(e.parent_))}function Ct(e){e.copy_||(e.copy_=it(e.base_,e.scope_.immer_.useStrictShallowCopy_))}Ye(bt,((e,t)=>{yt[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),yt.deleteProperty=function(e,t){return isNaN(parseInt(t))&&ze(13),yt.set.call(this,e,t,void 0)},yt.set=function(e,t,i){return"length"!==t&&isNaN(parseInt(t))&&ze(14),bt.set.call(this,e[0],t,i,e[0])};function Et(e,t){const i=Qe(e)?lt("MapSet").proxyMap_(e,t):et(e)?lt("MapSet").proxySet_(e,t):function(e,t){const i=Array.isArray(e),n={type_:i?1:0,scope_:t?t.scope_:ct(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let o=n,s=bt;i&&(o=[n],s=yt);const{revoke:r,proxy:a}=Proxy.revocable(o,s);return n.draft_=a,n.revoke_=r,a}(e,t);return(t?t.scope_:ct()).drafts_.push(i),i}function At(e){return Je(e)||ze(10,e),xt(e)}function xt(e){if(!Be(e)||st(e))return e;const t=e[Fe];let i;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,i=it(e,t.scope_.immer_.useStrictShallowCopy_)}else i=it(e,!0);return Ye(i,((e,t)=>{Xe(i,e,xt(t))})),t&&(t.finalized_=!1),i}var Ot=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,t,i)=>{if("function"==typeof e&&"function"!=typeof t){const i=t;t=e;const n=this;return function(e=i,...o){return n.produce(e,(e=>t.call(this,e,...o)))}}let n;if("function"!=typeof t&&ze(6),void 0!==i&&"function"!=typeof i&&ze(7),Be(e)){const o=pt(this),s=Et(e,void 0);let r=!0;try{n=t(s),r=!1}finally{r?ut(o):ht(o)}return dt(o,i),gt(n,o)}if(!e||"object"!=typeof e){if(n=t(e),void 0===n&&(n=e),n===Ne&&(n=void 0),this.autoFreeze_&&nt(n,!0),i){const t=[],o=[];lt("Patches").generateReplacementPatches_(e,n,t,o),i(t,o)}return n}ze(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...i)=>this.produceWithPatches(t,(t=>e(t,...i)));let i,n;const o=this.produce(e,t,((e,t)=>{i=e,n=t}));return[o,i,n]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){Be(e)||ze(8),Je(e)&&(e=At(e));const t=pt(this),i=Et(e,void 0);return i[Fe].isManual_=!0,ht(t),i}finishDraft(e,t){const i=e&&e[Fe];i&&i.isManual_||ze(9);const{scope_:n}=i;return dt(n,t),gt(void 0,n)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let i;for(i=t.length-1;i>=0;i--){const n=t[i];if(0===n.path.length&&"replace"===n.op){e=n.value;break}}i>-1&&(t=t.slice(i+1));const n=lt("Patches").applyPatches_;return Je(e)?n(e,t):this.produce(e,(e=>n(e,t)))}},jt=Ot.produce;Ot.produceWithPatches.bind(Ot),Ot.setAutoFreeze.bind(Ot),Ot.setUseStrictShallowCopy.bind(Ot),Ot.applyPatches.bind(Ot),Ot.createDraft.bind(Ot),Ot.finishDraft.bind(Ot);var Rt=(e,t,i)=>{if(1===t.length&&t[0]===i){let t=!1;try{const i={};e(i)===i&&(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})}}},Tt=(e,t,i)=>{const{memoize:n,memoizeOptions:o}=t,{inputSelectorResults:s,inputSelectorResultsCopy:r}=e,a=n((()=>({})),...o);if(!(a.apply(null,s)===a.apply(null,r))){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:i,firstInputs:s,secondInputs:r,stack:e})}},Mt={inputStabilityCheck:"once",identityFunctionCheck:"once"};var Wt=e=>Array.isArray(e)?e:[e];function Ut(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 i=e.map((e=>"function"==typeof e?`function ${e.name||"unnamed"}()`:typeof e)).join(", ");throw new TypeError(`${t}[${i}]`)}}(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function Pt(e,t){const i=[],{length:n}=e;for(let o=0;o<n;o++)i.push(e[o].apply(null,t));return i}var _t="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}},Lt=0,$t=1;function Nt(){return{s:Lt,v:void 0,o:null,p:null}}function Dt(e,t={}){let i=Nt();const{resultEqualityCheck:n}=t;let o,s=0;function r(){let t=i;const{length:r}=arguments;for(let e=0,i=r;e<i;e++){const i=arguments[e];if("function"==typeof i||"object"==typeof i&&null!==i){let e=t.o;null===e&&(t.o=e=new WeakMap);const n=e.get(i);void 0===n?(t=Nt(),e.set(i,t)):t=n}else{let e=t.p;null===e&&(t.p=e=new Map);const n=e.get(i);void 0===n?(t=Nt(),e.set(i,t)):t=n}}const a=t;let l;if(t.s===$t)l=t.v;else if(l=e.apply(null,arguments),s++,n){const e=o?.deref?.()??o;null!=e&&n(e,l)&&(l=e,0!==s&&s--);o="object"==typeof l&&null!==l||"function"==typeof l?new _t(l):l}return a.s=$t,a.v=l,l}return r.clearCache=()=>{i=Nt(),r.resetResultsCount()},r.resultsCount=()=>s,r.resetResultsCount=()=>{s=0},r}function Ft(e,...t){const i="function"==typeof e?{memoize:e,memoizeOptions:t}:e,n=(...e)=>{let t,n=0,o=0,s={},r=e.pop();"object"==typeof r&&(s=r,r=e.pop()),function(e,t="expected a function, instead received "+typeof e){if("function"!=typeof e)throw new TypeError(t)}(r,`createSelector expects an output function after the inputs, but received: [${typeof r}]`);const a={...i,...s},{memoize:l,memoizeOptions:c=[],argsMemoize:d=Dt,argsMemoizeOptions:u=[],devModeChecks:h={}}=a,p=Wt(c),f=Wt(u),g=Ut(e),v=l((function(){return n++,r.apply(null,arguments)}),...p);let m=!0;const w=d((function(){o++;const e=Pt(g,arguments);t=v.apply(null,e);{const{identityFunctionCheck:i,inputStabilityCheck:n}=((e,t)=>{const{identityFunctionCheck:i,inputStabilityCheck:n}={...Mt,...t};return{identityFunctionCheck:{shouldRun:"always"===i||"once"===i&&e,run:Rt},inputStabilityCheck:{shouldRun:"always"===n||"once"===n&&e,run:Tt}}})(m,h);if(i.shouldRun&&i.run(r,e,t),n.shouldRun){const t=Pt(g,arguments);n.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:l,memoizeOptions:p},arguments)}m&&(m=!1)}return t}),...f);return Object.assign(w,{resultFunc:r,memoizedResultFunc:v,dependencies:g,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>t,recomputations:()=>n,resetRecomputations:()=>{n=0},memoize:l,argsMemoize:d})};return Object.assign(n,{withTypes:()=>n}),n}var qt=Ft(Dt),zt=Object.assign(((e,t=qt)=>{!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 i=Object.keys(e),n=t(i.map((t=>e[t])),((...e)=>e.reduce(((e,t,n)=>(e[i[n]]=t,e)),{})));return n}),{withTypes:()=>zt});function Vt(e){return({dispatch:t,getState:i})=>n=>o=>"function"==typeof o?o(t,i,e):n(o)}var Jt=Vt(),Bt=Vt;((...e)=>{const t=Ft(...e)})(Dt);var Ht="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?Le:Le.apply(null,arguments)},Kt=e=>e&&"function"==typeof e.match;function Yt(e,t){function i(...i){if(t){let n=t(...i);if(!n)throw new Error("prepareAction did not return an object");return{type:e,payload:n.payload,..."meta"in n&&{meta:n.meta},..."error"in n&&{error:n.error}}}return{type:e,payload:i[0]}}return i.toString=()=>`${e}`,i.type=e,i.match=t=>$e(t)&&t.type===e,i}function Gt(e){return"function"==typeof e&&"type"in e&&Kt(e)}function Zt(e,t){let i=0;return{measureTime(e){const t=Date.now();try{return e()}finally{const e=Date.now();i+=e-t}},warnIfExceeded(){i>e&&console.warn(`${t} took ${i}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 Xt=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 Qt(e){return Be(e)?jt(e,(()=>{})):e}function ei(e,t,i){if(e.has(t)){let n=e.get(t);return i.update&&(n=i.update(n,t,e),e.set(t,n)),n}if(!i.insert)throw new Error("No insert provided for key not already in map");const n=i.insert(t,e);return e.set(t,n),n}function ti(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function ii(e,t,i){const n=ni(e,t,i);return{detectMutations:()=>oi(e,t,n,i)}}function ni(e,t=[],i,n="",o=new Set){const s={value:i};if(!e(i)&&!o.has(i)){o.add(i),s.children={};for(const o in i){const r=n?n+"."+o:o;t.length&&-1!==t.indexOf(r)||(s.children[o]=ni(e,t,i[o],r))}}return s}function oi(e,t=[],i,n,o=!1,s=""){const r=i?i.value:void 0,a=r===n;if(o&&!a&&!Number.isNaN(n))return{wasMutated:!0,path:s};if(e(r)||e(n))return{wasMutated:!1};const l={};for(let e in i.children)l[e]=!0;for(let e in n)l[e]=!0;const c=t.length>0;for(let o in l){const r=s?s+"."+o:o;if(c){if(t.some((e=>e instanceof RegExp?e.test(r):r===e)))continue}const l=oi(e,t,i.children[o],n[o],a,r);if(l.wasMutated)return l}return{wasMutated:!1}}function si(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||Te(e)}function ri(e,t="",i=si,n,o=[],s){let r;if(!i(e))return{keyPath:t||"<root>",value:e};if("object"!=typeof e||null===e)return!1;if(s?.has(e))return!1;const a=null!=n?n(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(!i(c))return{keyPath:a,value:c};if("object"==typeof c&&(r=ri(c,a,i,n,o,s),r))return r}return s&&ai(e)&&s.add(e),!1}function ai(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!ai(t))return!1;return!0}function li(e){return"boolean"==typeof e}var ci=()=>function(e){const{thunk:t=!0,immutableCheck:i=!0,serializableCheck:n=!0,actionCreatorCheck:o=!0}=e??{};let s=new Xt;if(t&&(li(t)?s.push(Jt):s.push(Bt(t.extraArgument))),i){let e={};li(i)||(e=i),s.unshift(function(e={}){{let t=function(e,t,n,o){return JSON.stringify(e,i(t,o),n)},i=function(e,t){let i=[],n=[];return t||(t=function(e,t){return i[0]===t?"[Circular ~]":"[Circular ~."+n.slice(0,i.indexOf(t)).join(".")+"]"}),function(o,s){if(i.length>0){var r=i.indexOf(this);~r?i.splice(r+1):i.push(this),~r?n.splice(r,1/0,o):n.push(o),~i.indexOf(s)&&(s=t.call(this,o,s))}else i.push(s);return null==e?s:e.call(this,o,s)}},{isImmutable:n=ti,ignoredPaths:o,warnAfter:s=32}=e;const r=ii.bind(null,n,o);return({getState:e})=>{let i,n=e(),o=r(n);return a=>l=>{const c=Zt(s,"ImmutableStateInvariantMiddleware");c.measureTime((()=>{if(n=e(),i=o.detectMutations(),o=r(n),i.wasMutated)throw new Error(`A state mutation was detected between dispatches, in the path '${i.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(n=e(),i=o.detectMutations(),o=r(n),i.wasMutated)throw new Error(`A state mutation was detected inside a dispatch, in the path: ${i.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(n){let e={};li(n)||(e=n),s.push(function(e={}){{const{isSerializable:t=si,getEntries:i,ignoredActions:n=[],ignoredActionPaths:o=["meta.arg","meta.baseQueryMeta"],ignoredPaths:s=[],warnAfter:r=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=Zt(r,"SerializableStateInvariantMiddleware");return l||n.length&&-1!==n.indexOf(u.type)||p.measureTime((()=>{const e=ri(u,"",t,i,o,d);if(e){const{keyPath:t,value:i}=e;console.error(`A non-serializable value was detected in an action, in the path: \`${t}\`. Value:`,i,"\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 n=ri(e.getState(),"",t,i,s,d);if(n){const{keyPath:e,value:t}=n;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={};li(o)||(e=o),s.unshift(function(e={}){const{isActionCreator:t=Gt}=e;return()=>e=>i=>(t(i)&&console.warn(function(e){const t=e?`${e}`.split("/"):[],i=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(${i}())\` instead of \`dispatch(${i})\`. This is necessary even if the action has no payload.`}(i.type)),e(i))}(e))}return s},di=e=>t=>{setTimeout(t,e)},ui="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:di(10),hi=e=>function(t){const{autoBatch:i=!0}=t??{};let n=new Xt(e);return i&&n.push(((e={type:"raf"})=>t=>(...i)=>{const n=t(...i);let o=!0,s=!1,r=!1;const a=new Set,l="tick"===e.type?queueMicrotask:"raf"===e.type?ui:"callback"===e.type?e.queueNotification:di(e.timeout),c=()=>{r=!1,s&&(s=!1,a.forEach((e=>e())))};return Object.assign({},n,{subscribe(e){const t=n.subscribe((()=>o&&e()));return a.add(e),()=>{t(),a.delete(e)}},dispatch(e){try{return o=!e?.meta?.RTK_autoBatch,s=!o,s&&(r||(r=!0,l(c))),n.dispatch(e)}finally{o=!0}}})})("object"==typeof i?i:void 0)),n};function pi(e){const t=ci(),{reducer:i,middleware:n,devTools:o=!0,preloadedState:s,enhancers:r}=e||{};let a,l;if("function"==typeof i)a=i;else{if(!Te(i))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=_e(i)}if(n&&"function"!=typeof n)throw new Error("`middleware` field must be a callback");if("function"==typeof n){if(l=n(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=Le;o&&(c=Ht({trace:!0,..."object"==typeof o&&o}));const d=function(...e){return t=>(i,n)=>{const o=t(i,n);let s=()=>{throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")};const r={getState:o.getState,dispatch:(e,...t)=>s(e,...t)},a=e.map((e=>e(r)));return s=Le(...a)(o.dispatch),{...o,dispatch:s}}}(...l),u=hi(d);if(r&&"function"!=typeof r)throw new Error("`enhancers` field must be a callback");let h="function"==typeof r?r(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 Ue(a,s,c(...h))}function fi(e){const t={},i=[];let n;const o={addCase(e,s){if(i.length>0)throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");if(n)throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`");const r="string"==typeof e?e:e.type;if(!r)throw new Error("`builder.addCase` cannot be called with an empty action type");if(r in t)throw new Error(`\`builder.addCase\` cannot be called with two reducers for the same action type '${r}'`);return t[r]=s,o},addMatcher(e,t){if(n)throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return i.push({matcher:e,reducer:t}),o},addDefaultCase(e){if(n)throw new Error("`builder.addDefaultCase` can only be called once");return n=e,o}};return e(o),[t,i,n]}function gi(...e){return t=>e.some((e=>((e,t)=>Kt(e)?e.match(t):e(t))(e,t)))}var vi=["name","message","stack","code"],mi=class{constructor(e,t){this.payload=e,this.meta=t}_type},wi=class{constructor(e,t){this.payload=e,this.meta=t}_type},bi=e=>{if("object"==typeof e&&null!==e){const t={};for(const i of vi)"string"==typeof e[i]&&(t[i]=e[i]);return t}return{message:String(e)}},yi=(()=>{function e(e,t,i){const n=Yt(e+"/fulfilled",((e,t,i,n)=>({payload:e,meta:{...n||{},arg:i,requestId:t,requestStatus:"fulfilled"}}))),o=Yt(e+"/pending",((e,t,i)=>({payload:void 0,meta:{...i||{},arg:t,requestId:e,requestStatus:"pending"}}))),s=Yt(e+"/rejected",((e,t,n,o,s)=>({payload:o,error:(i&&i.serializeError||bi)(e||"Rejected"),meta:{...s||{},arg:n,requestId:t,rejectedWithValue:!!o,requestStatus:"rejected",aborted:"AbortError"===e?.name,condition:"ConditionError"===e?.name}})));return Object.assign((function(e){return(r,a,l)=>{const c=i?.idGenerator?i.idGenerator(e):((e=21)=>{let t="",i=e;for(;i--;)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 s=i?.condition?.(e,{getState:a,extra:l});if(null!==(f=s)&&"object"==typeof f&&"function"==typeof f.then&&(s=await s),!1===s||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"})))));r(o(c,e,i?.getPendingMeta?.({requestId:c,arg:e},{getState:a,extra:l}))),p=await Promise.race([g,Promise.resolve(t(e,{dispatch:r,getState:a,extra:l,requestId:c,signal:d.signal,abort:h,rejectWithValue:(e,t)=>new mi(e,t),fulfillWithValue:(e,t)=>new wi(e,t)})).then((t=>{if(t instanceof mi)throw t;return t instanceof wi?n(t.payload,c,e,t.meta):n(t,c,e)}))])}catch(t){p=t instanceof mi?s(null,c,e,t.payload,t.meta):s(t,c,e)}var f;return i&&!i.dispatchConditionRejection&&s.match(p)&&p.meta.condition||r(p),p}();return Object.assign(p,{abort:h,requestId:c,arg:e,unwrap:()=>p.then(ki)})}}),{pending:o,rejected:s,fulfilled:n,settled:gi(s,n),typePrefix:e})}return e.withTypes=()=>e,e})();function ki(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}var Si=Symbol.for("rtk-slice-createasyncthunk");function Ii(e,t){return`${e}/${t}`}function Ci(e,t,i,n){function o(o,...s){let r=i.call(e,o);if(void 0===r){if(!n)throw new Error("selectState returned undefined for an uninjected slice reducer");r=e.getInitialState()}return t(r,...s)}return o.unwrapped=t,o}var Ei=function({creators:e}={}){const t=e?.asyncThunk?.[Si];return function(e){const{name:i,reducerPath:n=i}=e;if(!i)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)||{},s=Object.keys(o),r={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},a={addCase(e,t){const i="string"==typeof e?e:e.type;if(!i)throw new Error("`context.addCase` cannot be called with an empty action type");if(i in r.sliceCaseReducersByType)throw new Error("`context.addCase` cannot be called with two reducers for the same action type: "+i);return r.sliceCaseReducersByType[i]=t,a},addMatcher:(e,t)=>(r.sliceMatchers.push({matcher:e,reducer:t}),a),exposeAction:(e,t)=>(r.actionCreators[e]=t,a),exposeCaseReducer:(e,t)=>(r.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={},i=[],n]="function"==typeof e.extraReducers?fi(e.extraReducers):[e.extraReducers],o={...t,...r.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 i,[n,o,s]=fi(t);if(function(e){return"function"==typeof e}(e))i=()=>Qt(e());else{const t=Qt(e);i=()=>t}function r(e=i(),t){let r=[n[t.type],...o.filter((({matcher:e})=>e(t))).map((({reducer:e})=>e))];return 0===r.filter((e=>!!e)).length&&(r=[s]),r.reduce(((e,i)=>{if(i){if(Je(e)){const n=i(e,t);return void 0===n?e:n}if(Be(e))return jt(e,(e=>i(e,t)));{const n=i(e,t);if(void 0===n){if(null===e)return e;throw new Error("A case reducer on a non-draftable value must not return undefined")}return n}}return e}),e)}return r.getInitialState=i,r}(e.initialState,(e=>{for(let t in o)e.addCase(t,o[t]);for(let t of r.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of i)e.addMatcher(t.matcher,t.reducer);n&&e.addDefaultCase(n)}))}s.forEach((n=>{const s=o[n],r={reducerName:n,type:Ii(i,n),createNotation:"function"==typeof e.reducers};!function(e){return"asyncThunk"===e._reducerDefinitionType}(s)?function({type:e,reducerName:t,createNotation:i},n,o){let s,r;if("reducer"in n){if(i&&!function(e){return"reducerWithPrepare"===e._reducerDefinitionType}(n))throw new Error("Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");s=n.reducer,r=n.prepare}else s=n;o.addCase(e,s).exposeCaseReducer(t,s).exposeAction(t,r?Yt(e,r):Yt(e))}(r,s,a):function({type:e,reducerName:t},i,n,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:s,fulfilled:r,pending:a,rejected:l,settled:c,options:d}=i,u=o(e,s,d);n.exposeAction(t,u),r&&n.addCase(u.fulfilled,r);a&&n.addCase(u.pending,a);l&&n.addCase(u.rejected,l);c&&n.addMatcher(u.settled,c);n.exposeCaseReducer(t,{fulfilled:r||Ai,pending:a||Ai,rejected:l||Ai,settled:c||Ai})}(r,s,a,t)}));const c=e=>e,d=new WeakMap;let u;const h={name:i,reducerPath:n,reducer:(e,t)=>(u||(u=l()),u(e,t)),actions:r.actionCreators,caseReducers:r.sliceCaseReducersByName,getInitialState:()=>(u||(u=l()),u.getInitialState()),getSelectors(t=c){const i=ei(d,this,{insert:()=>new WeakMap});return ei(i,t,{insert:()=>{const i={};for(const[n,o]of Object.entries(e.selectors??{}))i[n]=Ci(this,o,t,this!==h);return i}})},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,...i}={}){const n=t??this.reducerPath;return e.inject({reducerPath:n,reducer:this.reducer},i),{...this,reducerPath:n}}};return h}}();function Ai(){}var xi="listenerMiddleware";Yt(`${xi}/add`),Yt(`${xi}/removeAll`),Yt(`${xi}/remove`);const Oi=e=>c((t=>{const i=Ei(e),n=Object.assign(Object.assign({},i.actions),e.asyncActions);return class extends(s(y)(t)){constructor(...e){super(...e);const t=pi({reducer:i.reducer,middleware:e=>e({thunk:{extraArgument:this},serializableCheck:!1}),devTools:!1}),o=e=>async(...i)=>{const n=await t.dispatch(e(...i));try{ki(n)}catch(e){this.logger.error(e.message,n.type,e.stack)}return n},s=Object.keys(n).reduce(((e,t)=>(e[t]=o(n[t]),e)),{});this.actions=s,this.subscribe=(e,i=e=>e)=>t.subscribe((()=>e(i(t.getState()))))}}}));c((e=>class extends(y(e)){validateForm(e){return this.getFormInputs(e).every((e=>{var t,i;return null===(t=e.reportValidity)||void 0===t||t.call(e),null===(i=e.checkValidity)||void 0===i?void 0:i.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 i;null===(i=this.getFormInputs(e).find((e=>e.name===t)))||void 0===i||i.setAttribute("disabled","true")}removeFormField(e,t){var i;null===(i=this.getFormInputs(e).find((e=>e.name===t)))||void 0===i||i.remove()}}));const ji=c((e=>{const t=s(O({"widget-id":E}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}}})),Ri=c((e=>{const t=s(P,ji)(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 i=await this.config;return null===(t=null===(e=null==i?void 0:i.projectConfig)||void 0===e?void 0:e.widgets)||void 0===t?void 0:t[this.widgetId]}}})),Ti=c((e=>class extends e{get locale(){return this.getAttribute("locale")||""}get localeCandidates(){const{locale:e,fallback:t}=m(this.locale);return[...new Set([e,t].filter(Boolean))]}firstAvailableLocale(e){var t;const i=(null!=e?e:[]).map((e=>e.toLowerCase()));return null!==(t=this.localeCandidates.find((e=>i.includes(e))))&&void 0!==t?t:""}})),Mi=e=>c((t=>{var i,o,r;const a=s(W,ji,Ri,Ti)(t);return r=class extends a{constructor(){super(...arguments),i.add(this)}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this))}async fetchWidgetPage(t){const s=await n(this,i,"m",o).call(this,t);if(void 0!==s)return s;const r=await this.fetchStaticResource(`${e}/${this.widgetId}/${t}`,"text");return null==r?void 0:r.body}},i=new WeakSet,o=async function(t){var i;const n=await this.getWidgetConfig(),o=this.firstAvailableLocale(null!==(i=null==n?void 0:n.targetLocales)&&void 0!==i?i:[]);if(!o)return;const s=".html",r=t.endsWith(s)?t.slice(0,-5):t;try{const t=await this.fetchStaticResource(`${e}/${this.widgetId}/${r}-${o}${s}`,"text");return null==t?void 0:t.body}catch(e){return}},r})),Wi=c((e=>class extends e{get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}})),Ui=k&&localStorage.getItem("base.debug.logs.url"),Pi=c((e=>{const t=s(O({"flow-id":E}))(e);return class extends t{get flowId(){return this.getAttribute("flow-id")}}}));function _i(e){const t=Math.floor(e/1e3);if(t<60)return`${t} seconds`;const i=Math.floor(t/60);if(i<60)return`${i} minutes`;const n=Math.floor(i/60);return n<24?`${n} hours`:`${Math.floor(n/24)} days`}const Li=c((e=>{var t,i,r,a,l,c,d,u,h,p,f,g;const v=s(F,y,A,P,j,Pi)(e);return g=class extends v{constructor(){super(...arguments),t.add(this),i.set(this,null),r.set(this,!1),a.set(this,null),f.set(this,null)}get telemetryManager(){return n(this,i,"f")}updateTelemetryContext(e){if(n(this,i,"f"))try{n(this,i,"f").updateContext(e)}catch(e){this.logger.error("Error updating telemetry context:",e)}}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this));const i=this.sdkVersion||"1.0.0";o(this,f,n(this,t,"m",h).call(this).then((e=>n(this,t,"m",l).call(this,e,{projectId:this.projectId,flowId:this.flowId,sdkVersion:i}))).catch((e=>{this.logger.error("Failed to start telemetry:",e)})),"f")}get telemetryReady(){var e;return null!==(e=n(this,f,"f"))&&void 0!==e?e:Promise.resolve()}disconnectedCallback(){var e;null===(e=super.disconnectedCallback)||void 0===e||e.call(this),n(this,t,"m",d).call(this)}},i=new WeakMap,r=new WeakMap,a=new WeakMap,f=new WeakMap,t=new WeakSet,l=async function(e,s){if(null==e?void 0:e.enabled)if(n(this,r,"f"))this.logger.debug("Telemetry already initialized");else if(e.expiration&&Date.now()>=e.expiration)this.logger.info(`Telemetry expiration time has passed (${new Date(e.expiration).toISOString()}), skipping initialization`);else try{this.logger.debug("Initializing telemetry...");const a=e.version||"latest";await this.injectNpmLib("@descope/debug-logs",a,"dist/index.js",[Ui]);const l=window.DescopeDebugLogs;if(!l)throw new Error("DescopeDebugLogs not found after loading @descope/debug-logs. This likely means the UMD build failed to load from CDN.");if(o(this,i,new l({enabled:!0,rumConfig:e.rumConfig,capture:e.capture},{projectId:s.projectId,flowId:s.flowId,version:s.sdkVersion||"1.0.0"},this.logger),"f"),!n(this,i,"f").isReady())return this.logger.error("Telemetry manager failed to initialize (RUM client not ready)"),void o(this,i,null,"f");o(this,r,!0,"f"),this.logger.info("Telemetry initialized successfully"),e.expiration&&n(this,t,"m",c).call(this,e.expiration)}catch(e){this.logger.error("Failed to initialize telemetry:",e),o(this,r,!1,"f")}else this.logger.debug("Telemetry is disabled, skipping initialization")},c=function(e){const i=e-Date.now();if(i<=0)return this.logger.info("Telemetry expiration time reached, shutting down"),void n(this,t,"m",d).call(this);const s=864e5,r=Math.min(i,s);i>s&&this.logger.warn(`Telemetry expiration is beyond maximum timeout (${_i(i)}). Setting to maximum.`),this.logger.info(`Telemetry will expire at ${new Date(e).toISOString()} (in ${_i(r)})`),o(this,a,setTimeout((()=>{this.logger.info("Telemetry expiration time reached, shutting down"),n(this,t,"m",d).call(this)}),r),"f")},d=function(){if(n(this,a,"f")&&(clearTimeout(n(this,a,"f")),o(this,a,null,"f")),n(this,i,"f"))try{this.logger.debug("Shutting down telemetry..."),n(this,i,"f").shutdown(),o(this,i,null,"f"),o(this,r,!1,"f"),this.logger.info("Telemetry shutdown complete")}catch(e){this.logger.error("Error shutting down telemetry:",e)}},u=function(e){return Boolean((null==e?void 0:e.applicationId)&&(null==e?void 0:e.identityPoolId)&&(null==e?void 0:e.region))},h=async function(){var e;const i=await this.config,o=null===(e=null==i?void 0:i.projectConfig)||void 0===e?void 0:e.telemetry;let s;try{const e=Number(process.env.DESCOPE_TELEMETRY_SESSION_SAMPLE_RATE);s={enabled:"true"===(process.env.DESCOPE_TELEMETRY_ENABLED||"").toLowerCase(),rumConfig:Object.assign({applicationId:process.env.DESCOPE_TELEMETRY_APPLICATION_ID||"",identityPoolId:process.env.DESCOPE_TELEMETRY_IDENTITY_POOL_ID||"",region:process.env.DESCOPE_TELEMETRY_REGION||"",sessionSampleRate:Number.isFinite(e)&&e>0?e:1},process.env.DESCOPE_TELEMETRY_GUEST_ROLE_ARN&&{guestRoleArn:process.env.DESCOPE_TELEMETRY_GUEST_ROLE_ARN})}}catch(e){s={enabled:!1,rumConfig:{applicationId:"",identityPoolId:"",region:"",sessionSampleRate:1}}}const r=Object.assign(Object.assign(Object.assign({},s),o),{rumConfig:Object.assign(Object.assign({},s.rumConfig),null==o?void 0:o.rumConfig),capture:n(this,t,"m",p).call(this,null==o?void 0:o.capture)});return r.enabled&&!n(this,t,"m",u).call(this,r.rumConfig)&&(this.logger.warn("Telemetry enabled but rumConfig is incomplete (applicationId/identityPoolId/region required). Skipping initialization."),r.enabled=!1),o||(r.expiration=Date.now()+3e5,this.logger.debug("No backend telemetry config present; applying a 5-minute safety cap on the session.")),r},p=function(e){const t=null==e?void 0:e.dom;return!1===t?Object.assign(Object.assign({console:!0,network:!0,navigation:!0},e),{dom:!1}):Object.assign(Object.assign({console:!0,network:!0,navigation:!0},e),{dom:Object.assign(Object.assign({throttleMs:2e3},"object"==typeof t?t:{}),{rootElement:this.shadowRoot})})},g})),$i=c((e=>{var i,o,s;return s=class extends(xe(e)){constructor(){super(...arguments),i.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:s,client:r,form:a}=e,c=t(e,["flowId","client","form"]);return l(Object.assign({projectId:this.getAttribute("project-id"),flowId:s,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:n(this,i,"m",o).call(this,a),client:Object.assign(Object.assign({},this.clientInput),r)},c))}},i=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}},s})),Ni=/(["\\])/g;function Di(e,t){return Array.from(e.querySelectorAll(`[data-id="${i=t,"undefined"!=typeof CSS&&"function"==typeof CSS.escape?CSS.escape(i):i.replace(Ni,"\\$1")}"]`));var i}function Fi(e,t){e&&t&&Object.entries(t).forEach((([t,i])=>{Di(e,t).forEach((e=>function(e,t){var i;switch(t){case"hide":e.setAttribute("hidden",""),null===(i=e.style)||void 0===i||i.setProperty("display","none","important");break;case"disable":e.setAttribute("disabled","true");break;case"read-only":e.setAttribute("readonly","true")}}(e,i)))}))}const qi=c((e=>{var t,i,r,a,l,c;const d=s(y,G)(e);return c=class extends d{constructor(){super(...arguments),t.add(this),i.set(this,void 0),r.set(this,{})}async init(){var e,s;if("true"===this.getAttribute("mock"))return o(this,i,Promise.resolve({}),"f"),void await(null===(e=super.init)||void 0===e?void 0:e.call(this));const r=n(this,t,"m",a).call(this);o(this,i,n(this,t,"m",l).call(this,r),"f"),await(null===(s=super.init)||void 0===s?void 0:s.call(this))}async onWidgetRootReady(){var e,t;await(null===(e=super.onWidgetRootReady)||void 0===e?void 0:e.call(this)),o(this,r,null!==(t=await n(this,i,"f"))&&void 0!==t?t:{},"f"),Fi(this.contentRootElement,n(this,r,"f"))}async reevaluateComponentsState(){const e=n(this,t,"m",a).call(this);var i,s;i=this.contentRootElement,s=n(this,r,"f"),i&&s&&Object.entries(s).forEach((([e,t])=>{Di(i,e).forEach((e=>function(e,t){var i;switch(t){case"hide":e.removeAttribute("hidden"),null===(i=e.style)||void 0===i||i.removeProperty("display");break;case"disable":e.removeAttribute("disabled");break;case"read-only":e.removeAttribute("readonly")}}(e,t)))})),o(this,r,await n(this,t,"m",l).call(this,e),"f"),Fi(this.contentRootElement,n(this,r,"f"))}},i=new WeakMap,r=new WeakMap,t=new WeakSet,a=function(){var e;const t=null===(e=this.api)||void 0===e?void 0:e.httpClient;if(!t)throw new Error("componentsConditionsMixin: the widget sdk must expose `httpClient`. Compose apiMixin and return `webSdk.httpClient` from createSdk.");return t},l=async function(e){var t;try{const i=await e.get("/v1/mgmt/widget/components-state");if(!(null==i?void 0:i.ok))return{};const n=await i.json();return null!==(t=null==n?void 0:n.componentsState)&&void 0!==t?t:{}}catch(e){return this.logger.debug("components-conditions: failed to fetch, showing all components",null==e?void 0:e.message),{}}},c}));function zi(e){return new URLSearchParams(window.location.search).get(e)}const Vi=e=>(...t)=>i=>{i.addCase(e.pending,((e,i)=>{t.forEach((({onPending:t})=>{null==t||t(e,i)}))})),i.addCase(e.fulfilled,((e,i)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,i)}))})),i.addCase(e.rejected,((e,i)=>{t.forEach((({onRejected:t})=>{null==t||t(e,i)}))}))},Ji=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,i)=>{e(t).loading=!1,e(t).error=i.error}}),Bi=yi("users/me",((e,{extra:{api:t}})=>t.user.me())),Hi=Vi(Bi)({onFulfilled:(e,t)=>{e.me.data=t.payload}},Ji((e=>e.me))),Ki={action:Bi,reducer:Hi},Yi=yi("users/devices",((e,{extra:{api:t}})=>t.device.devices(e))),Gi=Vi(Yi)({onFulfilled:(e,t)=>{e.devices.data=t.payload.devices}},Ji((e=>e.devices))),Zi={action:Yi,reducer:Gi},Xi=yi("users/passkeys",((e,{extra:{api:t}})=>t.passkey.listPasskeys(e))),Qi=Vi(Xi)({onFulfilled:(e,t)=>{e.passkeys.data=t.payload.passkeys}},Ji((e=>e.passkeys))),en={action:Xi,reducer:Qi},tn=yi("users/logout",((e,{extra:{api:t}})=>t.user.logout())),nn={action:tn,reducer:Vi(tn)({})};class on extends Error{}function sn(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 i=t.charCodeAt(0).toString(16).toUpperCase();return i.length<2&&(i="0"+i),"%"+i})))}(t)}catch(e){return atob(t)}}function rn(e,t){if("string"!=typeof e)throw new on("Invalid token specified: must be a string");t||(t={});const i=!0===t.header?0:1,n=e.split(".")[i];if("string"!=typeof n)throw new on(`Invalid token specified: missing part #${i+1}`);let o;try{o=sn(n)}catch(e){throw new on(`Invalid token specified: invalid base64 for part #${i+1} (${e.message})`)}try{return JSON.parse(o)}catch(e){throw new on(`Invalid token specified: invalid json for part #${i+1} (${e.message})`)}}on.prototype.name="InvalidTokenError";var an={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",phone:"/v1/auth/enchantedlink/update/phone"},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"},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",event:"/v1/flow/event"}};const ln="<region>",cn=`https://api.${ln}descope.com`,dn=6e5,un=()=>{const e={};return{headers(t){const i="function"==typeof t.entries?Object.fromEntries(t.entries()):t;return e.Headers=JSON.stringify(i),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")}},hn=[503,520,521,522,524,530],pn=[100,5e3,5e3],fn=e=>new Promise((t=>setTimeout(t,e))),gn=e=>async function(...t){let i=await e(...t);const n=!!(null==(o=t[1])?void 0:o.disableRetry);var o;let s=0;for(;!n&&hn.includes(i.status)&&s<pn.length;)await fn(pn[s]),i=await e(...t),s++;s>0&&(i.retries=s);const r=await i.text();return i.text=()=>Promise.resolve(r),i.json=()=>Promise.resolve(JSON.parse(r)),i.clone=()=>i,i};let vn;const mn=()=>{if(vn)return vn;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()}`,i=Math.floor(1e3+9e3*Math.random());return vn=`${t}-${i}`,vn};var wn;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT",e.patch="PATCH"}(wn||(wn={}));const bn=({path:e,baseUrl:t,queryParams:i,projectId:n})=>{const o=n.slice(1,-27);t=t.replace(ln,o?o+".":"");let s=e?`${t.replace(/\/$/,"")}/${null==e?void 0:e.replace(/^\//,"")}`:t;if(i){const e=Object.keys(i);e.forEach(((t,n)=>{s=`${s}${0===n?"?":""}${t}=${encodeURIComponent(i[t])}${n===e.length-1?"":"&"}`}))}return s},yn=(...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,i])=>{e[t]="function"==typeof i?i():i})),e)),{})),kn={"Content-Type":"application/json"},Sn=(e,t="")=>{let i=e;return t&&(i=i+":"+t),{Authorization:`Bearer ${i}`}},In=(e,t)=>{const i={"x-descope-sdk-session-id":mn(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.77.0","x-descope-project-id":e};return t&&(i["x-descope-refresh-cookie-name"]=t),i},Cn=e=>{try{e=JSON.parse(e)}catch(e){return!1}return"object"==typeof e&&null!==e};var En=e=>{var t;return(({baseUrl:e,projectId:t,baseConfig:i,refreshCookieName:n,logger:o,hooks:s,cookiePolicy:r,fetch:a})=>{const l=e||cn,c=((e,t)=>{const i=t||fetch;return i||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(!i)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=>un().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const n=await gn(i)(...t);return e[n.ok?"log":"error"](await(async e=>{const t=await e.text();return un().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).retries(e.retries).build()})(n)),n}:gn(i)})(o,a),d=async e=>{var o;const a=(null==s?void 0:s.beforeRequest)?s.beforeRequest(e):e,{path:d,body:u,headers:h,queryParams:p,method:f,token:g,keepalive:v,disableRetry:m}=a,w=(e=>void 0===e?void 0:JSON.stringify(e))(u),b=Object.assign(Object.assign({headers:yn(Sn(t,g),In(t,n),(null==i?void 0:i.baseHeaders)||{},Cn(w)?kn:{},h),method:f,body:w},v?{keepalive:!0}:{}),m?{disableRetry:!0}:{});null!==r&&(b.credentials=r||"include");const y=await c(bn({path:d,baseUrl:l,queryParams:p,projectId:t}),b);if((null==s?void 0:s.afterRequest)&&await s.afterRequest(e,null==y?void 0:y.clone()),null==s?void 0:s.transformResponse){const e=await y.json(),t=(k=(null===(o=y.headers)||void 0===o?void 0:o.get("set-cookie"))||"",Object.fromEntries(function(e){if(!e)return[];const t=[];let i=0;function n(){for(;i<e.length&&/\s/.test(e.charAt(i));)i+=1;return i<e.length}function o(){const t=e.charAt(i);return"="!==t&&";"!==t&&","!==t}for(;i<e.length;){const s=i;let r,a,l=!1;for(;n();)if(","===e.charAt(i)){for(r=i,i+=1,n(),a=i;i<e.length&&o();)i+=1;if(i<e.length&&"="===e.charAt(i)){l=!0,i=a,t.push(e.substring(s,r));break}i=r+1}else i+=1;(!l||i>=e.length)&&t.push(e.substring(s,e.length))}return t}(k).map((e=>{const t=e.split(";")[0],i=t.indexOf("=");return i<1?null:[t.substring(0,i).trim(),t.substring(i+1).trim()]})).filter(Boolean))),i=Object.assign(Object.create(null),{json:()=>Promise.resolve(e),cookies:t}),n=new Proxy(y,{get:(e,t)=>{if(t in i)return i[t];const n=e[t];return"function"==typeof n?n.bind(e):n},set:(e,t,n)=>(i[t]=n,!0),has:(e,t)=>t in i||t in e});return i.clone=()=>n,s.transformResponse(n)}var k;return y};return{get:(e,{headers:t,queryParams:i,token:n,keepalive:o,disableRetry:s}={})=>d({path:e,headers:t,queryParams:i,body:void 0,method:wn.get,token:n,keepalive:o,disableRetry:s}),post:(e,t,{headers:i,queryParams:n,token:o,keepalive:s,disableRetry:r}={})=>d({path:e,headers:i,queryParams:n,body:t,method:wn.post,token:o,keepalive:s,disableRetry:r}),patch:(e,t,{headers:i,queryParams:n,token:o,keepalive:s,disableRetry:r}={})=>d({path:e,headers:i,queryParams:n,body:t,method:wn.patch,token:o,keepalive:s,disableRetry:r}),put:(e,t,{headers:i,queryParams:n,token:o,keepalive:s,disableRetry:r}={})=>d({path:e,headers:i,queryParams:n,body:t,method:wn.put,token:o,keepalive:s,disableRetry:r}),delete:(e,{headers:t,queryParams:i,token:n,keepalive:o,disableRetry:s}={})=>d({path:e,headers:t,queryParams:i,body:void 0,method:wn.delete,token:n,keepalive:o,disableRetry:s}),hooks:s,buildUrl:(e,i)=>bn({projectId:t,baseUrl:l,path:e,queryParams:i})}})(Object.assign(Object.assign({},e),{hooks:{beforeRequest:t=>{var i;const n=[].concat((null===(i=e.hooks)||void 0===i?void 0:i.beforeRequest)||[]);return null==n?void 0:n.reduce(((e,t)=>t(e)),t)},afterRequest:async(t,i)=>{var n;const o=[].concat((null===(n=e.hooks)||void 0===n?void 0:n.afterRequest)||[]);0!=o.length&&(await Promise.allSettled(null==o?void 0:o.map((e=>e(t,null==i?void 0:i.clone()))))).forEach((t=>{var i;return"rejected"===t.status&&(null===(i=e.logger)||void 0===i?void 0:i.error(t.reason))}))},transformResponse:null===(t=e.hooks)||void 0===t?void 0:t.transformResponse}}))},An=429;function xn(e,t,i){var n;let o=On(e);if(t){if(!(null==o?void 0:o.tenants)&&(null==o?void 0:o.dct)===t)return(null==o?void 0:o[i])||[];o=null===(n=null==o?void 0:o.tenants)||void 0===n?void 0:n[t]}const s=null==o?void 0:o[i];return Array.isArray(s)?s:[]}function On(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return rn(e)}function jn(e){const{exp:t}=On(e);return(new Date).getTime()/1e3>t}function Rn(e){let t=On(e);const i=Object.keys(null==t?void 0:t.tenants);return Array.isArray(i)?i:[]}function Tn(e,t){return xn(e,t,"permissions")}function Mn(e,t){return xn(e,t,"roles")}const Wn=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function Un(e,t){var i,n;const o=await e,s={code:o.status,ok:o.ok,response:o},r=await o.clone().json();if(o.ok)s.data=r;else{s.error=r,o.status===An&&Object.assign(s.error,{retryAfter:Number.parseInt(null===(i=o.headers)||void 0===i?void 0:i.get("retry-after"))||0});const e=null===(n=o.headers)||void 0===n?void 0:n.get("cf-ray");e&&s.error&&Object.assign(s.error,{traceId:e})}return s}function Pn(e){var t;return(null===(t=On(e))||void 0===t?void 0:t.dct)||""}const _n=(e,t)=>(i=t)=>t=>!e(t)&&i.replace("{val}",t),Ln=(e,t)=>(i=t)=>t=>{const n=e.filter((e=>e(t)));return!(n.length<e.length)&&(i?i.replace("{val}",t):n.join(" OR "))},$n=(...e)=>({validate:t=>(e.forEach((e=>{const i=e(t);if(i)throw new Error(i)})),!0)}),Nn=e=>t=>e.test(t),Dn=Nn(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Fn=Nn(/^\+[1-9]{1}[0-9]{3,14}$/),qn=_n(Dn,'"{val}" is not a valid email'),zn=_n(Fn,'"{val}" is not a valid phone number'),Vn=_n((e=>e.length>=1),"Minimum length is 1");const Jn=_n((e=>"string"==typeof e),"Input is not a string"),Bn=_n((e=>Array.isArray(e)),"Input is not an array"),Hn=_n((e=>"boolean"==typeof e),"Input is not a boolean"),Kn=_n((e=>void 0===e),"Input is defined"),Yn=Ln([Jn(),Kn()],"Input is not a string or undefined"),Gn=Ln([Bn(),Hn()],"Input is not an array or boolean"),Zn=(...e)=>t=>(...i)=>(e.forEach(((e,t)=>$n(...e).validate(i[t]))),t(...i)),Xn=e=>[Jn(`"${e}" must be a string`)],Qn=e=>[Yn(`"${e}" must be string or undefined`)],eo=e=>[Jn(`"${e}" must be a string`),Vn(`"${e}" must not be empty`)],to=e=>[Jn(`"${e}" must be a string`),qn()],io=e=>[Jn(`"${e}" must be a string`),zn()],no=Zn(eo("accessKey")),oo=e=>({exchange:no(((t,i)=>Un(e.post(an.accessKey.exchange,{loginOptions:i},{token:t}))))}),so=(e,t,i)=>(t.forEach((t=>{const n=t.split(".");let o=n.shift(),s=e;for(;n.length>0;){if(s=s[o],!o||!s)throw Error(`Invalid path "${t}", "${o}" is missing or has no value`);o=n.shift()}if("function"!=typeof s[o])throw Error(`"${t}" is not a function`);const r=s[o];s[o]=i(r)})),e),ro=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||dn,dn)});var ao,lo;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp",e.im="im"}(ao||(ao={})),function(e){e.email="email"}(lo||(lo={}));const co=Object.assign(Object.assign({},ao),lo);var uo;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(uo||(uo={}));const ho=eo("loginId"),po=Zn(eo("token")),fo=Zn(ho),go=Zn(eo("pendingRef")),vo=Zn(ho,io("phone")),mo=Zn(ho,to("email")),wo=e=>{const i=i=>(n,o,s={},r)=>{var{providerId:a}=s,l=t(s,["providerId"]);return Un(e.post(Wn(an.enchantedLink.signIn,i),{loginId:n,URI:o,loginOptions:l,providerId:a},{token:r}))},n=i=>(n,o,s={})=>{var{providerId:r}=s,a=t(s,["providerId"]);return Un(e.post(Wn(an.enchantedLink.signUpOrIn,i),{loginId:n,URI:o,loginOptions:a,providerId:r}))},o=i=>(n,o,s,r={})=>{var{providerId:a}=r,l=t(r,["providerId"]);return Un(e.post(Wn(an.enchantedLink.signUp,i),{loginId:n,URI:o,user:s,loginOptions:l,providerId:a}))};return{verify:po((t=>Un(e.post(an.enchantedLink.verify,{token:t})))),signIn:fo(i(co.email)),signInWithPhone:fo(i(ao.sms)),signUpOrIn:fo(n(co.email)),signUpOrInWithPhone:fo(n(ao.sms)),signUp:fo(o(co.email)),signUpWithPhone:fo(o(ao.sms)),waitForSession:go(((t,i)=>new Promise((n=>{const{pollingIntervalMs:o,timeoutMs:s}=ro(i);let r;const a=setInterval((async()=>{const i=await e.post(an.enchantedLink.session,{pendingRef:t});i.ok&&(clearInterval(a),r&&clearTimeout(r),n(Un(Promise.resolve(i))))}),o);r=setTimeout((()=>{n({error:{errorDescription:`Session polling timeout exceeded: ${s}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),s)})))),update:{email:mo(((t,i,n,o,s)=>Un(e.post(an.enchantedLink.update.email,Object.assign({loginId:t,email:i,URI:n},s),{token:o})))),phone:{sms:vo(((t,i,n,o,s)=>Un(e.post(Wn(an.enchantedLink.update.phone,ao.sms),Object.assign({loginId:t,phone:i,URI:n},s),{token:o}))))}}}},bo=Zn(eo("flowId")),yo=Zn(eo("executionId"),eo("stepId"),eo("interactionId")),ko=Zn(eo("executionId")),So=e=>({start:bo(((t,i,n,o,s,r,a,l=!1)=>Un(e.post(an.flow.start,{flowId:t,options:i,conditionInteractionId:n,interactionId:o,componentsVersion:s,flowVersions:r,input:a,isCustomScreen:l})))),next:yo(((t,i,n,o,s,r,a=!1,l)=>Un(e.post(an.flow.next,{executionId:t,stepId:i,interactionId:n,version:o,componentsVersion:s,input:r,isCustomScreen:a,options:l})))),event:ko(((t,i,n)=>Un(e.post(an.flow.event,{executionId:t,events:i},{keepalive:n,disableRetry:!0}))))}),Io=eo("loginId"),Co=Zn(eo("token")),Eo=Zn(Io);Zn(eo("pendingRef"));const Ao=Zn(Io,io("phone")),xo=Zn(Io,to("email")),Oo=Object.keys(co).filter((e=>e!==ao.voice&&e!==ao.im)),jo=e=>({verify:Co((t=>Un(e.post(an.magicLink.verify,{token:t})))),signIn:Oo.reduce(((i,n)=>Object.assign(Object.assign({},i),{[n]:Eo(((i,o,s={},r)=>{var{providerId:a}=s,l=t(s,["providerId"]);return Un(e.post(Wn(an.magicLink.signIn,n),{loginId:i,URI:o,loginOptions:l,providerId:a},{token:r}))}))})),{}),signUp:Oo.reduce(((i,n)=>Object.assign(Object.assign({},i),{[n]:Eo(((i,o,s,r={})=>{var{providerId:a}=r,l=t(r,["providerId"]);return Un(e.post(Wn(an.magicLink.signUp,n),{loginId:i,URI:o,user:s,loginOptions:l,providerId:a}))}))})),{}),signUpOrIn:Oo.reduce(((i,n)=>Object.assign(Object.assign({},i),{[n]:Eo(((i,o,s={})=>{var{providerId:r}=s,a=t(s,["providerId"]);return Un(e.post(Wn(an.magicLink.signUpOrIn,n),{loginId:i,URI:o,loginOptions:a,providerId:r}))}))})),{}),update:{email:xo(((t,i,n,o,s)=>Un(e.post(an.magicLink.update.email,Object.assign({loginId:t,email:i,URI:n},s),{token:o})))),phone:Object.keys(ao).filter((e=>e!==ao.voice)).reduce(((t,i)=>Object.assign(Object.assign({},t),{[i]:Ao(((t,n,o,s,r)=>Un(e.post(Wn(an.magicLink.update.phone,i),Object.assign({loginId:t,phone:n,URI:o},r),{token:s}))))})),{})}});var Ro;!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"}(Ro||(Ro={}));const To=Zn(eo("code")),Mo=e=>({start:Object.assign(((t,i,n,o,s)=>Un(e.post(an.oauth.start,n||{},{queryParams:Object.assign(Object.assign({provider:t},i&&{redirectURL:i}),s&&{loginHint:s}),token:o}))),Object.keys(Ro).reduce(((t,i)=>Object.assign(Object.assign({},t),{[i]:(t,n,o,s)=>Un(e.post(an.oauth.start,n||{},{queryParams:Object.assign(Object.assign({provider:i},t&&{redirectURL:t}),s&&{loginHint:s}),token:o}))})),{})),exchange:To((t=>Un(e.post(an.oauth.exchange,{code:t})))),startNative:(t,i,n)=>Un(e.post(an.oauth.startNative,{provider:t,loginOptions:i,implicit:n})),finishNative:(t,i,n,o,s)=>Un(e.post(an.oauth.finishNative,{provider:t,stateId:i,user:n,code:o,idToken:s})),getOneTapClientId:t=>Un(e.get(an.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,i,n,o)=>Un(e.post(an.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:i,nonce:n,loginOptions:o})),exchangeOneTapIDToken:(t,i,n,o)=>Un(e.post(an.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:i,nonce:n,loginOptions:o}))}),Wo=eo("appId"),Uo=Zn(Wo),Po=e=>({connect:Uo(((t,i,n)=>{const o=null==i?void 0:i.tenantId,s=null==i?void 0:i.tenantLevel;return null==i||delete i.tenantId,null==i||delete i.tenantLevel,Un(e.post(an.outbound.connect,{appId:t,tenantId:o,tenantLevel:s,options:i},{token:n}))}))}),_o=eo("loginId"),Lo=Zn(_o,eo("code")),$o=Zn(_o),No=Zn(_o,io("phone")),Do=Zn(_o,to("email")),Fo=e=>({verify:Object.keys(co).reduce(((t,i)=>Object.assign(Object.assign({},t),{[i]:Lo(((t,n)=>Un(e.post(Wn(an.otp.verify,i),{code:n,loginId:t}))))})),{}),signIn:Object.keys(co).reduce(((i,n)=>Object.assign(Object.assign({},i),{[n]:$o(((i,o={},s)=>{var{providerId:r}=o,a=t(o,["providerId"]);return Un(e.post(Wn(an.otp.signIn,n),{loginId:i,loginOptions:a,providerId:r},{token:s}))}))})),{}),signUp:Object.keys(co).reduce(((i,n)=>Object.assign(Object.assign({},i),{[n]:$o(((i,o,s={})=>{var{providerId:r}=s,a=t(s,["providerId"]);return Un(e.post(Wn(an.otp.signUp,n),{loginId:i,user:o,loginOptions:a,providerId:r}))}))})),{}),signUpOrIn:Object.keys(co).reduce(((i,n)=>Object.assign(Object.assign({},i),{[n]:$o(((i,o={})=>{var{providerId:s}=o,r=t(o,["providerId"]);return Un(e.post(Wn(an.otp.signUpOrIn,n),{loginId:i,loginOptions:r,providerId:s}))}))})),{}),update:{email:Do(((t,i,n,o)=>Un(e.post(an.otp.update.email,Object.assign({loginId:t,email:i},o),{token:n})))),phone:Object.keys(ao).reduce(((t,i)=>Object.assign(Object.assign({},t),{[i]:No(((t,n,o,s)=>Un(e.post(Wn(an.otp.update.phone,i),Object.assign({loginId:t,phone:n},s),{token:o}))))})),{})}}),qo=Zn(eo("tenant")),zo=Zn(eo("code")),Vo=e=>({start:qo(((t,i,n,o,s,r,a,l)=>Un(e.post(an.sso.start,n||{},Object.assign({queryParams:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({tenant:t},i&&{redirectURL:i}),s&&{ssoId:s}),r&&{forceAuthn:"true"}),a&&{loginHint:a}),l&&{initiatedEmail:t})},o&&{token:o}))))),exchange:zo((t=>Un(e.post(an.sso.exchange,{code:t}))))}),Jo=eo("loginId"),Bo=Zn(Jo,eo("code")),Ho=Zn(Jo),Ko=Zn(Jo),Yo=e=>({signUp:Ho(((t,i)=>Un(e.post(an.totp.signUp,{loginId:t,user:i})))),verify:Bo(((t,i,n,o)=>Un(e.post(an.totp.verify,{loginId:t,code:i,loginOptions:n},{token:o})))),update:Ko(((t,i)=>Un(e.post(an.totp.update,{loginId:t},{token:i}))))}),Go=eo("loginId"),Zo=eo("newPassword"),Xo=Zn(Go,eo("password")),Qo=Zn(Go),es=Zn(Go,Zo),ts=Zn(Go,eo("oldPassword"),Zo),is=e=>({signUp:Xo(((i,n,o,s={})=>{var{providerId:r}=s,a=t(s,["providerId"]);return Un(e.post(an.password.signUp,{loginId:i,password:n,user:o,loginOptions:a,providerId:r}))})),signIn:Xo(((i,n,o={})=>{var{providerId:s}=o,r=t(o,["providerId"]);return Un(e.post(an.password.signIn,{loginId:i,password:n,loginOptions:r,providerId:s}))})),sendReset:Qo(((t,i,n)=>Un(e.post(an.password.sendReset,{loginId:t,redirectUrl:i,templateOptions:n})))),update:es(((t,i,n)=>Un(e.post(an.password.update,{loginId:t,newPassword:i},{token:n})))),replace:ts(((t,i,n)=>Un(e.post(an.password.replace,{loginId:t,oldPassword:i,newPassword:n})))),policy:()=>Un(e.get(an.password.policy))}),ns=Xn("loginId"),os=eo("loginId"),ss=Xn("origin"),rs=Zn(os,ss,eo("name")),as=Zn(os,ss),ls=Zn(ns,ss),cs=Zn(os,ss,Qn("token")),ds=Zn(eo("transactionId"),eo("response")),us=e=>({signUp:{start:rs(((t,i,n,o,s)=>Un(e.post(an.webauthn.signUp.start,{user:{loginId:t,name:n},origin:i,loginOptions:s,passkeyOptions:o})))),finish:ds(((t,i)=>Un(e.post(an.webauthn.signUp.finish,{transactionId:t,response:i}))))},signIn:{start:ls(((t,i,n,o,s)=>Un(e.post(an.webauthn.signIn.start,{loginId:t,origin:i,loginOptions:n,passkeyOptions:s},{token:o})))),finish:ds(((t,i)=>Un(e.post(an.webauthn.signIn.finish,{transactionId:t,response:i}))))},signUpOrIn:{start:as(((t,i,n,o)=>Un(e.post(an.webauthn.signUpOrIn.start,{loginId:t,origin:i,loginOptions:o,passkeyOptions:n}))))},update:{start:cs(((t,i,n,o,s)=>Un(e.post(an.webauthn.update.start,{loginId:t,origin:i,passkeyOptions:o,mfa:s},{token:n})))),finish:ds(((t,i)=>Un(e.post(an.webauthn.update.finish,{transactionId:t,response:i}))))}}),hs=Xn("loginId"),ps=Zn(hs),fs=Zn(eo("pendingRef")),gs=e=>({signUpOrIn:ps(((i,n={})=>{var{providerId:o}=n,s=t(n,["providerId"]);return Un(e.post(an.notp.signUpOrIn,{loginId:i,loginOptions:s,providerId:o}))})),signUp:ps(((i,n,o={})=>{var{providerId:s}=o,r=t(o,["providerId"]);return Un(e.post(an.notp.signUp,{loginId:i,user:n,providerId:s,loginOptions:r}))})),signIn:ps(((i,n={},o)=>{var{providerId:s}=n,r=t(n,["providerId"]);return Un(e.post(an.notp.signIn,{loginId:i,loginOptions:r,providerId:s},{token:o}))})),waitForSession:fs(((t,i)=>new Promise((n=>{const{pollingIntervalMs:o,timeoutMs:s}=ro(i);let r;const a=setInterval((async()=>{const i=await e.post(an.notp.session,{pendingRef:t});i.ok&&(clearInterval(a),r&&clearTimeout(r),n(Un(Promise.resolve(i))))}),o);r=setTimeout((()=>{n({error:{errorDescription:`Session polling timeout exceeded: ${s}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),s)}))))}),vs=Zn(eo("token")),ms=Zn(Qn("token"));var ws,bs=Zn([(ws=eo("projectId"),_n(((e,t)=>i=>$n(...t).validate(((e,t)=>{const i=(Array.isArray(t)?t.join("."):String(t)).replace(/\[\\?("|')?(\w|d)+\\?("|')?\]/g,((e,t,i)=>"."+i)).split("."),n=i.length;let o=0,s=e===Object(e)?e:void 0;for(;null!=s&&o<n;)s=s[i[o++]];return o&&o===n&&void 0!==s?s:void 0})(i,e)))("projectId",ws))())])((e=>{const{projectId:t,logger:i,baseUrl:n,cookiePolicy:o,baseHeaders:s={},refreshCookieName:r,fetch:a}=e;return l=En({baseUrl:n,projectId:t,logger:i,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:s},refreshCookieName:r,fetch:a}),{accessKey:oo(l),otp:Fo(l),magicLink:jo(l),enchantedLink:wo(l),oauth:Mo(l),outbound:Po(l),sso:Vo(l),saml:Vo(l),totp:Yo(l),notp:gs(l),webauthn:us(l),password:is(l),flow:So(l),refresh:ms(((e,t,i,n)=>{const o={};i&&(o.externalToken=i);const s=n?an.tryRefresh:an.refresh;return Un(l.post(s,o,{token:e,queryParams:t}))})),selectTenant:Zn([Jn("tenantId")],[Yn('"token" must be string or undefined')])(((e,t)=>Un(l.post(an.selectTenant,{tenant:e},{token:t})))),logout:ms((e=>Un(l.post(an.logout,{},{token:e})))),logoutAll:ms((e=>Un(l.post(an.logoutAll,{},{token:e})))),me:ms((e=>Un(l.get(an.me,{token:e})))),myTenants:Zn([Gn('"tenants" must a string array or a boolean')],[Yn('"token" must be string or undefined')])(((e,t)=>{const i={};return"boolean"==typeof e?i.dct=e:i.ids=e,Un(l.post(an.myTenants,i,{token:t}))})),history:ms((e=>Un(l.get(an.history,{token:e})))),isJwtExpired:vs(jn),getTenants:vs(Rn),getJwtPermissions:vs(Tn),getJwtRoles:vs(Mn),getCurrentTenant:vs(Pn),httpClient:l};var l})),ys=Object.assign(bs,{DeliveryMethods:co});
6
- /*! js-cookie v3.0.8 | MIT */function ks(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var n in i)"__proto__"!==n&&(e[n]=i[n])}return e}var Ss=function e(t,i){function n(e,n,o){if("undefined"!=typeof document){"number"==typeof(o=ks({},i,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 s="";for(var r in o)o[r]&&(s+="; "+r,!0!==o[r]&&(s+="="+o[r].split(";")[0]));return document.cookie=e+"="+t.write(n,e)+s}}return Object.create({set:n,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var i=document.cookie?document.cookie.split("; "):[],n={},o=0;o<i.length;o++){var s=i[o].split("="),r=s.slice(1).join("=");try{var a=decodeURIComponent(s[0]);if(a in n||(n[a]=t.read(r,a)),e===a)break}catch(e){}}return e?n[e]:n}},remove:function(e,t){n(e,"",ks({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,ks({},this.attributes,t))},withConverter:function(t){return e(ks({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(i)},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 Is={default:"endpoint"},Cs="Blocked by CSP",Es="The endpoint parameter is not a valid URL",As="Failed to load the JS script of the agent",xs="9319";function Os(e,t){var i,n,o,s,r,a=[],l=(i=function(e){var t=function(e,t,i){if(i||2===arguments.length)for(var n,o=0,s=t.length;o<s;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||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),s=0,n=function(){return Math.random()*Math.min(3e3,100*Math.pow(2,s++))},o=new Set,[i.current(),function(e,t){var s,r=t instanceof Error?t.message:"";if(r===Cs||r===Es)i.exclude(),s=0;else if(r===xs)i.exclude();else if(r===As){var a=Date.now()-e.getTime()<50,l=i.current();l&&a&&!o.has(l)&&(o.add(l),s=0),i.postpone()}else i.postpone();var c=i.current();return void 0===c?void 0:[c,null!=s?s:e.getTime()+n()-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 i=new Date,n=function(t){return a.push({url:e,startedAt:i,finishedAt:new Date,error:t})},o=t(e);return o.then((function(){return n()}),n),o.catch((function(e){if(null!=r||(r=e),a.length>=5)throw r;var t=d(i,e);if(!t)throw r;var n,o=t[0],s=t[1];return(n=s,new Promise((function(e){return setTimeout(e,n)}))).then((function(){return u(o)}))}))};return u(c).then((function(e){return[e,a]}))}var js="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",Rs=js;function Ts(i){var n;i.scriptUrlPattern;var o=i.token,s=i.apiKey,r=void 0===s?o:s,a=t(i,["scriptUrlPattern","token","apiKey"]),l=null!==(n=function(e,t){return function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,t)?e[t]:void 0}(i,"scriptUrlPattern"))&&void 0!==n?n:js,c=function(){var e=[],t=function(){e.push({time:new Date,state:document.visibilityState})},i=function(e,t,i,n){return e.addEventListener(t,i,n),function(){return e.removeEventListener(t,i,n)}}(document,"visibilitychange",t);return t(),[e,i]}(),d=c[0],u=c[1];return Promise.resolve().then((function(){if(!r||"string"!=typeof r)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 i=encodeURIComponent;return e.replace(/<[^<>]+>/g,(function(e){return"<version>"===e?"3":"<apiKey>"===e?i(t):"<loaderVersion>"===e?i("3.11.6"):e}))}(String(e),t)}))}(l,r);return Os(e,Ms)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===xs?new Error(As):e}(e)})).then((function(t){var i=t[0],n=t[1];return u(),i.load(e(e({},a),{ldi:{attempts:n,visibilityStates:d}}))}))}function Ms(e){return function(e,t,i){var n,o=document,s="securitypolicyviolation",r=function(t){var i=new URL(e,location.href),o=t.blockedURI;o!==i.href&&o!==i.protocol.slice(0,-1)&&o!==i.origin||(n=t,a())};o.addEventListener(s,r);var a=function(){return o.removeEventListener(s,r)};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(),n)return i(n);throw e}))}))}(e,(function(){return function(e){return new Promise((function(t,i){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(Es);var n=document.createElement("script"),o=function(){var e;return null===(e=n.parentNode)||void 0===e?void 0:e.removeChild(n)},s=document.head||document.getElementsByTagName("head")[0];n.onload=function(){o(),t()},n.onerror=function(){o(),i(new Error(As))},n.async=!0,n.src=e,s.appendChild(n)}))}(e)}),(function(){throw new Error(Cs)})).then(Ws)}function Ws(){var e=window,t="__fpjs_p_l_b",i=e[t];if(function(e,t){var i,n=null===(i=Object.getOwnPropertyDescriptor)||void 0===i?void 0:i.call(Object,e,t);(null==n?void 0:n.configurable)?delete e[t]:n&&!n.writable||(e[t]=void 0)}(e,t),"function"!=typeof(null==i?void 0:i.load))throw new Error(xs);return i}const Us="3.2.0",Ps="undefined"!=typeof window,_s=Math.pow(2,31)-1,Ls=`https://descopecdn.com/npm/oidc-client-ts@${Us}/dist/browser/oidc-client-ts.min.js`,$s=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${Us}/dist/browser/oidc-client-ts.min.js`,Ns=["/v1/auth/refresh","/v1/auth/try-refresh","/v1/auth/me","/v1/auth/me/tenants","/v1/auth/me/history"];let Ds;const Fs=e=>{try{return rn(e).exp}catch(e){return null}},qs=e=>{const{refresh_expire_in:t,refresh_token:i}=e;return t?Math.floor(Date.now()/1e3)+t:Fs(i)},zs=e=>{const{expires_in:t,expires_at:i,access_token:n}=e;return i||(t?Math.floor(Date.now()/1e3)+t:n?Fs(n):void 0)},Vs=e=>{const{access_token:i,id_token:n,refresh_token:o,refresh_expire_in:s}=e,r=t(e,["access_token","id_token","refresh_token","refresh_expire_in"]);return Object.assign({sessionJwt:e.sessionJwt||i,idToken:n,refreshJwt:e.refreshJwt||o,sessionExpiration:e.sessionExpiration||zs(e),cookieExpiration:e.cookieExpiration||qs(e)},r)},Js=(e,t)=>{var i;return["beforeRequest","afterRequest"].reduce(((i,n)=>{var o;return i[n]=[].concat((null===(o=e.hooks)||void 0===o?void 0:o[n])||[]).concat((null==t?void 0:t[n])||[]),i}),null!==(i=e.hooks)&&void 0!==i?i:e.hooks={}),e},Bs=async e=>{if(!(null==e?void 0:e.ok))return{};const t=await(null==e?void 0:e.clone().json()),i=(null==t?void 0:t.authInfo)||t||{};return Vs(i)},Hs=()=>Ps&&!!window.descopeBridge,Ks=(e,t)=>{if(!((null==t?void 0:t.status)>=400&&(null==t?void 0:t.status)<500))return!1;const i=(null==e?void 0:e.path)||"";return Ns.includes(i)},Ys=void 0!==Ds||Ps&&void 0!==window.localStorage,Gs=(e,t)=>{var i,n;return null===(n=null===(i=Ds||Ps&&window.localStorage)||void 0===i?void 0:i.setItem)||void 0===n?void 0:n.call(i,e,t)},Zs=e=>{var t,i;return null===(i=null===(t=Ds||Ps&&window.localStorage)||void 0===t?void 0:t.getItem)||void 0===i?void 0:i.call(t,e)},Xs=e=>{var t,i;return null===(i=null===(t=Ds||Ps&&window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===i?void 0:i.call(t,e)},Qs=e=>{var t,i,n,o,s;return null!==(s=null!==(i=null===(t=null==Ds?void 0:Ds.key)||void 0===t?void 0:t.call(Ds,e))&&void 0!==i?i:Ps&&(null===(o=null===(n=window.localStorage)||void 0===n?void 0:n.key)||void 0===o?void 0:o.call(n,e)))&&void 0!==s?s:null},er=e=>{var t,i;return Ps&&(null===(i=null===(t=window.localStorage)||void 0===t?void 0:t.getItem)||void 0===i?void 0:i.call(t,e))||null},tr=e=>{var t,i;try{Ps&&(null===(i=null===(t=window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===i||i.call(t,e))}catch(e){}},ir=(...e)=>{console.debug(...e)},nr=(...e)=>{console.warn(...e)},or="DS",sr="DSR",rr="DSI",ar="DSRCN";function lr(e,t,i){if(t){const{cookieDomain:n,cookiePath:o,cookieSameSite:s,cookieExpiration:r,cookieSecure:a}=i,l=new Date(1e3*r),c=cr(n);Ss.set(e,t,{path:o,domain:c?n:void 0,expires:l,sameSite:s,secure:a})}}function cr(e){const t=window.location.hostname.split("."),i=null==e?void 0:e.split(".");return t.slice(-(null==i?void 0:i.length)).join(".")===e}const dr=e=>(null==e?void 0:e.cookieName)||or,ur=e=>(null==e?void 0:e.cookieName)||sr;function hr(e="",t){return Ss.get(ur(t))||Zs(`${e}${sr}`)||""}function pr(e="",t){return Ss.get(dr(t))||Zs(`${e}${or}`)||""}function fr(e=""){return Zs(`${e}${rr}`)||""}function gr(e="",t,i,n){Xs(`${e}${sr}`),Xs(`${e}${or}`),Xs(`${e}${rr}`),Xs(`${e}${ar}`);const o=dr(t);Ss.remove(o,null==n?void 0:n.session);const s=ur(i);Ss.remove(s,null==n?void 0:n.refresh)}const vr=(e,t,i)=>n=>{const o=Object.assign(n,{token:n.token||hr(e,t)});if(!i){const t=function(e=""){return Zs(`${e}${ar}`)}(e);t&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-refresh-cookie-name":t}))}const s=function(e=""){return Zs(`${e}DTD`)||""}(e);s&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-trusted-device-token":s}));const r=function(e=""){return Zs(`${e}DKD`)||""}(e);return r&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-known-device-token":r})),o},mr=Ps&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",wr="vsid",br="vrid",yr="fp",kr=(e=!1)=>{const t=Zs(yr);if(!t)return null;const i=JSON.parse(t);return(new Date).getTime()>i.expiry&&!e?null:i.value},Sr=async(e,t=mr)=>{try{if(kr())return;const i=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),n=new URL(t);n.pathname="/fXj8gt3x8VulJBna/x96Emn69oZwcd7I6";const o=new URL(t);o.pathname="/fXj8gt3x8VulJBna/w78aRZnnDZ3Aqw0I";const s=o.toString()+"?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>",r=Ts({apiKey:e,endpoint:[n.toString(),Is],scriptUrlPattern:[s,Rs]}),a=await r,{requestId:l}=await a.get({linkedId:i}),c=((e,t)=>({[wr]:e,[br]:t}))(i,l);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};Gs(yr,JSON.stringify(t))})(c)}catch(e){console.warn("Could not load fingerprint",e)}},Ir=e=>{const t=kr(!0);return t&&e.body&&(e.body.fpData=t),e},Cr="descopeFlowNonce",Er="X-Descope-Flow-Nonce",Ar="/v1/flow/start",xr="/v1/flow/next",Or=(e,t=Cr)=>`${t}${e}`,jr=(e,t=Cr)=>{try{const i=Or(e,t),n=Zs(i);if(!n)return null;const o=JSON.parse(n);return o.expiry<Date.now()?(Rr(e,t),null):{value:o.value,seq:o.seq}}catch(e){return console.error("Error getting flow nonce:",e),null}},Rr=(e,t=Cr)=>{try{const i=Or(e,t);Xs(i)}catch(e){console.error("Error removing flow nonce:",e)}},Tr=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||null},Mr=e=>{var t;return e.path===xr&&(null===(t=e.body)||void 0===t?void 0:t.executionId)?Tr(e.body.executionId):null},Wr="dls_last_user_login_id",Ur="dls_last_user_display_name",Pr=e=>Gs(Wr,e),_r=()=>Zs(Wr),Lr=()=>Zs(Ur),$r=e=>async(...t)=>{var i;t[1]=t[1]||{};const[,n={}]=t,o=_r(),s=Lr();return o&&(null!==(i=n.lastAuth)&&void 0!==i||(n.lastAuth={}),n.lastAuth.loginId=o,n.lastAuth.name=s),await e(...t)},Nr="DSLI",Dr=e=>async(...t)=>{const i=await e(...t);return tr(Nr),i};function Fr(){const e=[];return{pub:t=>{e.forEach((e=>e(t)))},sub:t=>{const i=e.push(t)-1;return()=>e.splice(i,1)}}}async function qr(e,t){const i=function(e){var t;const i=JSON.parse(e);return i.publicKey.challenge=Yr(i.publicKey.challenge),i.publicKey.user.id=Yr(i.publicKey.user.id),null===(t=i.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=Yr(e.id)})),i}(e);t&&(i.signal=t.signal);try{return n=await navigator.credentials.create(i),JSON.stringify({id:n.id,rawId:Gr(n.rawId),type:n.type,response:{attestationObject:Gr(n.response.attestationObject),clientDataJSON:Gr(n.response.clientDataJSON)}})}catch(e){throw await Jr(e,i,!0)}var n}async function zr(e,t){const i=Hr(e);t&&(i.signal=t.signal);try{return Kr(await navigator.credentials.get(i))}catch(e){throw await Jr(e,i,!1)}}async function Vr(e,t){const i=Hr(e);i.signal=t.signal,i.mediation="conditional";try{return Kr(await navigator.credentials.get(i))}catch(e){throw await Jr(e,i,!1)}}async function Jr(e,t,i){if(e&&"object"==typeof e)try{e.reason=await async function(e,t,i){var n,o;const s=null==e?void 0:e.name;if("AbortError"===s&&(null==t?void 0:t.signal)instanceof AbortSignal)return"aborted";if("InvalidStateError"===s&&i)return"authenticator_already_registered";if("NotSupportedError"===s)return"no_supported_algorithm";if("ConstraintError"===s)return"authenticator_constraints_unsupported";if("SecurityError"===s){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 Br())return"webauthn_unsupported";const r="platform"===(null===(o=null===(n=null==t?void 0:t.publicKey)||void 0===n?void 0:n.authenticatorSelection)||void 0===o?void 0:o.authenticatorAttachment);return i&&r&&!await Br(!0)?"platform_authenticator_unsupported":"NotAllowedError"===s?"not_allowed":"unknown"}(e,t,i)}catch(e){}return e}async function Br(e=!1){var t,i;if(!Ps)return Promise.resolve(!1);if(Hs()){const e=null===(i=null===(t=window.descopeBridge)||void 0===t?void 0:t.hostInfo)||void 0===i?void 0:i.webauthn;if("boolean"==typeof e)return e}const n=!!(window.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return n&&e&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():n}function Hr(e){var t;const i=JSON.parse(e);return i.publicKey.challenge=Yr(i.publicKey.challenge),null===(t=i.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=Yr(e.id)})),i}function Kr(e){return JSON.stringify({id:e.id,rawId:Gr(e.rawId),type:e.type,response:{authenticatorData:Gr(e.response.authenticatorData),clientDataJSON:Gr(e.response.clientDataJSON),signature:Gr(e.response.signature),userHandle:e.response.userHandle?Gr(e.response.userHandle):void 0}})}function Yr(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function Gr(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var Zr,Xr=(Zr=e=>({async signUp(t,i,n){const o=await e.webauthn.signUp.start(t,window.location.origin,i,n);if(!o.ok)return o;const s=await qr(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,s)},async signIn(t,i){const n=await e.webauthn.signIn.start(t,window.location.origin,void 0,void 0,i);if(!n.ok)return n;const o=await zr(n.data.options);return await e.webauthn.signIn.finish(n.data.transactionId,o)},async signUpOrIn(t,i){var n;const o=await e.webauthn.signUpOrIn.start(t,window.location.origin,i);if(!o.ok)return o;if(null===(n=o.data)||void 0===n?void 0:n.create){const t=await qr(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,t)}{const t=await zr(o.data.options);return await e.webauthn.signIn.finish(o.data.transactionId,t)}},async update(t,i,n){const o=await e.webauthn.update.start(t,window.location.origin,i,n);if(!o.ok)return o;const s=await qr(o.data.options);return await e.webauthn.update.finish(o.data.transactionId,s)},helpers:{create:qr,get:zr,isSupported:Br,conditional:Vr}}),(...e)=>{const t=Zr(...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 Qr="/fedcm/config";async function ea(e,t){var i;try{await ta(e,t)}catch(e){null===(i=null==t?void 0:t.onFailed)||void 0===i||i.call(t,e)}}async function ta(e,t){var i,n;const o=await async function(e,t="google",i,n,o){const 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)})(),r=await async function(){return new Promise(((e,t)=>{if(window.google)return void e(window.google.accounts.id);let i=document.getElementById("google-gsi-client-script");i||(i=document.createElement("script"),document.head.appendChild(i),i.async=!0,i.defer=!0,i.id="google-gsi-client-script",i.src="https://accounts.google.com/gsi/client"),i.onload=function(){window.google?e(window.google.accounts.id):t("Failed to load Google GSI client script - not loaded properly")},i.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=i=>{e({provider:t,nonce:s,credential:null==i?void 0:i.credential})};r.initialize(Object.assign(Object.assign({},i),{itp_support:null===(a=null==i?void 0:i.itp_support)||void 0===a||a,use_fedcm_for_prompt:null===(c=null==i?void 0:i.use_fedcm_for_prompt)||void 0===c||c,client_id:l,callback:d,nonce:s})),r.prompt((e=>{var t,i;if(o&&(null==e?void 0:e.isDismissedMoment())){const i=null===(t=e.getDismissedReason)||void 0===t?void 0:t.call(e);return null==o||o(i),void d()}if(n&&(null==e?void 0:e.isSkippedMoment())){const t=null===(i=e.getSkippedReason)||void 0===i?void 0:i.call(e);return null==n||n(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 n=await e.oauth.verifyOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!n.ok||!n.data)throw new Error("Failed to verify OneTap client ID for provider "+o.provider);null===(i=null==t?void 0:t.onCodeReceived)||void 0===i||i.call(t,n.data.code)}else{const i=await e.oauth.exchangeOneTapIDToken(o.provider,o.credential,o.nonce,null==t?void 0:t.loginOptions);if(!i.ok||!i.data)throw new Error("Failed to exchange OneTap client ID for provider "+o.provider);null===(n=null==t?void 0:t.onAuthenticated)||void 0===n||n.call(t,i.data)}}var ia=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const i=await Br(),n=Object.assign(Object.assign({location:window.location.href},t[1]),{deviceInfo:{webAuthnSupport:i},startOptionsVersion:1});return t[1]=n,e.flow.start(...t)}});let na;const oa=(e,t)=>new Promise(((i,n)=>{if(!e.length)return n(new Error("No URLs provided to loadScriptWithFallback"));const o=t();if(o)return i(o);const s=e.shift(),r=document.createElement("script");r.src=s,r.id=(e=>{let t=0;for(let i=0;i<e.length;i++)t=(t<<5)-t+e.charCodeAt(i),t|=0;return Math.abs(t).toString(16)})(s),r.onload=()=>{const e=t();if(e)return i(e);throw new Error("Could not get entry after loading script from URL")},r.addEventListener("error",(()=>{oa(e,t),r.setAttribute("data-error","true")})),document.body.appendChild(r)})),sa=(e,t,i)=>{const n=async()=>{let n,o;return n&&o||({client:n,stateUserKey:o}=await(async(e,t,i)=>{na||(na=(async()=>{try{return require("oidc-client-ts")}catch(e){return oa([Ls,$s],(()=>window.oidc))}})());const{OidcClient:n,WebStorageStateStore:o}=await na;if(!n)throw new Error("oidc-client-ts is not installed. Please install it by running `npm install oidc-client-ts`");const s=(null==i?void 0:i.redirectUri)||window.location.href;let r,a,l,c;if(null==i?void 0:i.issuer){if(!i.clientId)throw new Error("clientId is required when providing a custom issuer/authority");r=i.issuer,a=i.clientId,l=`${a}_user`,c="openid"}else(null==i?void 0:i.applicationId)?(r=e.httpClient.buildUrl(t),r=`${r}/${i.applicationId}`,a=t,l=`${a}_user`,c="openid email roles descope.custom_claims offline_access"):(r=e.httpClient.buildUrl(t),a=t,l=`${a}_user`,c="openid email roles descope.custom_claims offline_access");const d={authority:r,client_id:a,redirect_uri:s,response_type:"code",scope:(null==i?void 0:i.scope)||c,stateStore:new o({store:window.localStorage,prefix:a}),loadUserInfo:!0,fetchRequestCredentials:"same-origin"};return(null==i?void 0:i.redirectUri)&&(d.redirect_uri=i.redirectUri),{client:new n(d),stateUserKey:l}})(e,t,i)),{client:n,stateUserKey:o}},o=async(t="")=>{var i;const{client:o,stateUserKey:s}=await n(),r=await o.processSigninResponse(t||window.location.href);var a;return await(null===(i=e.httpClient.hooks)||void 0===i?void 0:i.afterRequest({},new Response(JSON.stringify(r)))),Gs(s,JSON.stringify({id_token:(a=r).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())})(),r};return{loginWithRedirect:async(t={},i=!1)=>{var o;const{client:s}=await n(),r=await s.createSigninRequest(t),{url:a}=r;return i||(await(null===(o=e.httpClient.hooks)||void 0===o?void 0:o.afterRequest({},new Response(JSON.stringify(r)))),window.location.href=a),{ok:!0,data:r}},finishLogin:o,finishLoginIfNeed:async(e="")=>{if(window.location.search.includes("code")&&window.location.search.includes("state"))return await o(e)},refreshToken:async t=>{var i;const{client:o,stateUserKey:s}=await n(),r=(e=>{const t=Zs(e);return t?JSON.parse(t):null})(s);if(!r)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:r.session_state,profile:r.profile}});return await(null===(i=e.httpClient.hooks)||void 0===i?void 0:i.afterRequest({},new Response(JSON.stringify(l)))),l},logout:async(e,t=!1)=>{const{client:i,stateUserKey:o}=await n();e||(e={}),e.id_token_hint=e.id_token_hint||fr(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const s=await i.createSignoutRequest(e),{url:r}=s;return Xs(o),t||window.location.replace(r),s}}},ra=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>t=>{var i;return i=t.customStorage,Ds=i,e(t)}),(e=>i=>{var{fpKey:n,fpLoad:o}=i,s=t(i,["fpKey","fpLoad"]);return Ps?(n&&o&&Sr(n).catch((()=>null)),e(Js(s,{beforeRequest:Ir}))):e(s)}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.54.4"},t.baseHeaders)}))),(e=>t=>{const i=Fr(),n=Fr(),o=Fr(),s=Fr(),r=e(Js(t,{afterRequest:async(e,t)=>{if(Ks(e,t))ir("Session invalidated, notifying subscribers with empty values"),n.pub(null),o.pub(null),i.pub(null),s.pub(null);else{const e=await(async e=>{const t=await Bs(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:r,sessionExpiration:a,claims:l}=await Bs(t);r&&n.pub(r),l&&s.pub(l),(a||r)&&i.pub(a||42)}}})),a=so(r,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const r=await e(...t);return n.pub(null),o.pub(null),i.pub(null),s.pub(null),r}));return Object.assign(a,{onSessionTokenChange:n.sub,onUserChange:o.sub,onClaimsChange:s.sub,onIsAuthenticatedChange:e=>i.sub((t=>{e(!!t)}))})}),(e=>i=>{var n;const{enableFlowNonce:o=!0,nonceStoragePrefix:s=Cr}=i,r=t(i,["enableFlowNonce","nonceStoragePrefix"]);if(!o)return e(r);((e=Cr)=>{try{if(!Ys)return;for(let o=0;o<(void 0,i=void 0,void 0,null!==(n=null!==(t=null==Ds?void 0:Ds.length)&&void 0!==t?t:Ps&&(null===(i=window.localStorage)||void 0===i?void 0:i.length))&&void 0!==n?n:0);o++){const t=Qs(o);if(t&&t.startsWith(e)){const i=Zs(t);if(i)try{JSON.parse(i).expiry<Date.now()&&Xs(t)}catch(e){Xs(t)}}}}catch(e){console.error("Error cleaning up expired nonces:",e)}var t,i,n})(s);const a=e(Js(r,{afterRequest:async(e,t)=>{var i;if(e.path!==Ar&&e.path!==xr)return;const{nonce:n,seq:o,executionId:r}=await(async(e,t)=>{try{const i=t.headers.get(Er),n=null===i?void 0:(e=>{const t=e.indexOf(".");if(t<=0)return;const i=e.slice(0,t);if(!/^\d+$/.test(i))return;const n=Number(i);return Number.isSafeInteger(n)?n:void 0})(i);let o=await t.clone().json().then((e=>(null==e?void 0:e.executionId)||null)).catch((()=>null));return o||(o=Mr(e)),{nonce:i,seq:n,executionId:Tr(o)}}catch(e){return{nonce:null,seq:void 0,executionId:null}}})(e,t);if(!n||!r)return;const a=e.path===Ar,l=null===(i=jr(r,s))||void 0===i?void 0:i.seq;!a&&void 0!==o&&void 0!==l&&o<=l||((e,t,i,n=Cr,o)=>{try{const s=Or(e,n),r=i?172800:10800,a={value:t,expiry:Date.now()+1e3*r,isStart:i,seq:o};Gs(s,JSON.stringify(a))}catch(e){console.error("Error setting flow nonce:",e)}})(r,n,a,s,null!=o?o:a?void 0:l)},beforeRequest:e=>{if(e.path===xr){const t=Mr(e);if(t){const i=((e,t=Cr)=>{var i,n;return null!==(n=null===(i=jr(e,t))||void 0===i?void 0:i.value)&&void 0!==n?n:null})(t,s);i&&(e.headers=e.headers||{},e.headers[Er]=i)}}return e}}));if(null===(n=a.flow)||void 0===n?void 0:n.next){let e=Promise.resolve();const t=a.flow.next.bind(a.flow);a.flow.next=async(...i)=>{const n=e;let o;e=new Promise((e=>{o=e})),await n;try{return await t(...i)}finally{o()}}}return a}),(e=>t=>{const i=e(Js(t,{afterRequest:async(e,t)=>{if(Ks(e,t))return void tr(Nr);const i=await Bs(t);(null==i?void 0:i.sessionExpiration)&&((e,t)=>{var i,n;try{Ps&&(null===(n=null===(i=window.localStorage)||void 0===i?void 0:i.setItem)||void 0===n||n.call(i,e,t))}catch(e){}})(Nr,String(i.sessionExpiration))}}));return so(i,["logout","logoutAll","oidc.logout"],Dr)}),(e=>i=>{var{autoRefresh:n}=i,o=t(i,["autoRefresh"]);const s=!!n,r="object"==typeof n&&(null==n?void 0:n.customActivityTracking);if(!s||Hs())return Object.assign(e(o),{markUserActive:()=>{nr("markUserActive() called but has no effect")}});const{clearAllTimers:a,setTimer:l}=(()=>{const e=[];return{clearAllTimers:()=>{for(;e.length;)clearTimeout(e.pop())},setTimer:(t,i)=>{e.push(setTimeout(t,i))}}})();let c,d,u=null,h=!1,p=!1;r&&(ir("Activity-based refresh enabled"),u=(()=>{let e=!0;return{hadActivity:()=>e,reset:()=>{e=!1},markActive:()=>{e=!0}}})()),Ps&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&c&&new Date>c&&(ir("Expiration time passed, refreshing session"),g())}));const f=e(Js(o,{afterRequest:async(e,t)=>{const{sessionJwt:i,refreshJwt:n,sessionExpiration:o,nextRefreshSeconds:s}=await Bs(t);if(Ks(e,t))ir("Session invalidated, canceling all timers"),a(),c=void 0;else if(i||o){if(c=((e,t)=>{if(t)return new Date(1e3*t);ir("Could not extract expiration time from session token, trying to decode the token");try{const t=rn(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(i,o),!c)return void ir("Could not extract expiration time from session token");d=n,h=s>0;const e=((e,t)=>{let i;var n;return t>0?(i=1e3*t,ir(`Using provided nextRefreshSeconds: ${t}s`)):i=((n=e)?n.getTime()-(new Date).getTime():0)-2e4,i>_s&&(ir(`Timeout is too large (${i}ms), setting it to ${_s}ms`),i=_s),i})(c,s);if(a(),e<=2e4)return void ir("Session is too close to expiration, not setting refresh timer");const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});ir(`Setting refresh timer for ${t}. (${e}ms)`),u&&(u.reset(),p=!1),l((()=>{if(Ps&&"hidden"===document.visibilityState)ir("Skipping refresh due to timer - document is hidden");else{if(u&&h&&!u.hadActivity())return ir("Skipping refresh due to timer - user is idle"),void(p=!0);ir("Refreshing session due to timer"),g()}}),e)}}})),g=()=>f.refresh(hr()||d).catch((e=>{nr("Automatic session refresh failed",e)}));return Object.assign(so(f,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const i=await e(...t);return ir("Clearing all timers"),a(),i})),{markUserActive:u?()=>{ir("markUserActive() called"),h||ir("markUserActive() called but server does not have inactivity timeout configured (no nextRefreshSeconds)"),u.markActive(),p&&(ir("User became active after skipped refresh, triggering refresh"),p=!1,a(),g())}:()=>{nr("markUserActive() called but customActivityTracking is not enabled — this call has no effect")}})}),(e=>i=>{var{storeLastAuthenticatedUser:n=!0,keepLastAuthenticatedUserAfterLogout:o=!1}=i,s=t(i,["storeLastAuthenticatedUser","keepLastAuthenticatedUserAfterLogout"]);if(!n)return Object.assign(e(s),{getLastUserLoginId:_r,getLastUserDisplayName:Lr});const r=e(Js(s,{afterRequest:async(e,t)=>{var i;const{userInfo:n,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()),i=Vs((null==t?void 0:t.authInfo)||t||{});return{userInfo:(null==i?void 0:i.user)||((null==i?void 0:i.hasOwnProperty("userId"))?i:void 0),lastAuth:t.lastAuth}})(t),s=null===(i=null==n?void 0:n.loginIds)||void 0===i?void 0:i[0],r=null==n?void 0:n.name;s?(Pr(s),(e=>{Gs(Ur,e)})(r)):(null==o?void 0:o.loginId)&&Pr(o.loginId)}}));let a=so(r,["flow.start"],$r);return a=so(a,["logout","logoutAll"],(e=>t=>async(...i)=>{const n=await t(...i);return e||(Xs(Wr),Xs(Ur)),n})(o)),Object.assign(a,{getLastUserLoginId:_r,getLastUserDisplayName:Lr})}),(e=>i=>{var{persistTokens:n,sessionTokenViaCookie:o,refreshTokenViaCookie:s,storagePrefix:r,refreshCookieName:a}=i,l=t(i,["persistTokens","sessionTokenViaCookie","refreshTokenViaCookie","storagePrefix","refreshCookieName"]);if(!n||!Ps)return e(Object.assign({refreshCookieName:a},l));let c;const d=e(Js(Object.assign({refreshCookieName:a},l),{beforeRequest:vr(r,s,a),afterRequest:async(e,t)=>{if(Ks(e,t))ir("Session invalidated, clearing persisted tokens"),gr(r,o,s,c);else{const e=await Bs(t);e.cookieName?Gs(`${r||""}${ar}`,e.cookieName):e.refreshJwt&&Xs(`${r||""}${ar}`);const i=((e={},t=!1,i="",n=!1)=>{var o,s,r,a;const{sessionJwt:l,refreshJwt:c,trustedDeviceJwt:d,knownDeviceJwt:u}=e;let h;if(c)if(n){Xs(`${i}${sr}`);const t=n.sameSite||"Strict",r=null===(o=n.secure)||void 0===o||o,a=null!==(s=n.domain)&&void 0!==s?s:e.cookieDomain,l=ur(n);r&&"https:"!==window.location.protocol&&nr("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:r,cookieDomain:a});lr(l,c,d);const u=cr(a);h=Object.assign(Object.assign({},h),{refresh:{path:d.cookiePath,domain:u?a:void 0}})}else{const e=ur(n);Ss.remove(e),Gs(`${i}${sr}`,c)}if(l)if(t){const i=t.sameSite||"Strict",n=null===(r=t.secure)||void 0===r||r,o=null!==(a=t.domain)&&void 0!==a?a:e.cookieDomain,s=dr(t);n&&"https:"!==window.location.protocol&&nr("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:i,cookieSecure:n,cookieDomain:o});lr(s,l,c);const d=cr(o);h=Object.assign(Object.assign({},h),{session:{path:c.cookiePath,domain:d?o:void 0}})}else Gs(`${i}${or}`,l);return e.idToken&&Gs(`${i}${rr}`,e.idToken),d&&Gs(`${i}DTD`,d),u&&Gs(`${i}DKD`,u),h})(e,o,r,s);i&&(c=i)}}})),u=so(d,["logout","logoutAll","oidc.logout"],((e,t,i,n)=>o=>async(...s)=>{const r=await o(...s);return gr(e,t,i,null==n?void 0:n()),r})(r,o,s,(()=>c)));return Object.assign(u,{getRefreshToken:()=>hr(r,s),getSessionToken:()=>pr(r,o),getIdToken:()=>fr(r)})}))((e=>{const t=ys(e),i=sa(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async(n,o)=>{var s;if(Hs())return ir(`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 i.refreshToken(n),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161001",errorDescription:e.toString()}})}if(o&&Ps&&void 0!==window.localStorage&&!er(Nr)&&!Zs(Wr)&&!er("DSLI_DISABLED"))return Promise.resolve({ok:!0});const r=pr(),a=hr();let l="";if(e.getExternalToken)try{l=await(null===(s=e.getExternalToken)||void 0===s?void 0:s.call(e))}catch(e){ir("Error getting external token while refreshing",e)}return t.refresh(n,{dcs:r?"t":"f",dcr:a?"t":"f"},l,o)},logout:async n=>{if(e.oidcConfig)try{return await i.logout({id_token_hint:n}),Promise.resolve({ok:!0})}catch(e){return Promise.resolve({ok:!1,error:{errorCode:"J161000",errorDescription:e.toString()}})}return t.logout(n)},flow:ia(t),webauthn:Xr(t),fedcm:(n=t,o=e.projectId,{onetap:{requestExchangeCode(e){ea(n,e)},requestAuthentication(e){ea(n,e)}},async oneTap(e,t,i,o,s){await ta(n,{provider:e,oneTapConfig:t,loginOptions:i,onSkipped:o,onDismissed:s})},async launch(e){var t;const i={identity:{context:e||"signin",providers:[{configURL:n.httpClient.buildUrl(o+Qr),clientId:o}]}},s=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(i));return n.refresh(s.token)},isSupported:()=>Ps&&"IdentityCredential"in window,async isLoggedIn(e){var t;const i=n.httpClient.buildUrl(o+Qr);try{const n={identity:{context:e||"signin",providers:[{configURL:i,clientId:o}]}},s=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return!!s&&!!s.token}catch(e){return!1}}}),oidc:i});var n,o})),aa=e=>{if(!e)return null;const t=(e=>{try{const t=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),i=decodeURIComponent(atob(t).split("").map((e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2))).join(""));return JSON.parse(i)}catch(e){return null}})(e);return(null==t?void 0:t.dct)||null},la=e=>e.me.data,ca=qt(la,(e=>e.userId)),da=qt(la,(e=>e.picture)),ua=qt(la,(e=>e.email)),ha=qt(la,(e=>e.verifiedEmail)),pa=qt(la,(e=>e.name)),fa=qt(la,(e=>e.phone)),ga=qt(la,(e=>e.verifiedPhone)),va=qt(ua,ha,((e,t)=>e&&""!==e.trim()&&!t?"Unverified":"")),ma=qt(fa,ga,((e,t)=>e&&""!==e.trim()&&!t?"Unverified":"")),wa=qt(la,(e=>e.recoveryEmail)),ba=qt(la,(e=>e.verifiedRecoveryEmail)),ya=qt(la,(e=>e.recoveryPhone)),ka=qt(la,(e=>e.verifiedRecoveryPhone)),Sa=qt(wa,ba,((e,t)=>t?e:"")),Ia=qt(ya,ka,((e,t)=>t?e:"")),Ca=qt(la,(e=>e.webauthn));qt(la,(e=>e.password));const Ea=qt(la,(e=>e.TOTP)),Aa={},xa=qt(la,(e=>{var t;return null!==(t=e.customAttributes)&&void 0!==t?t:Aa})),Oa=qt(la,(e=>({givenName:e.givenName,middleName:e.middleName,familyName:e.familyName}))),ja=qt((e=>e.devices.data),(e=>e.map((({id:e,name:t,deviceType:i,lastLoginTime:n,isCurrentDevice:o})=>({id:e,name:t,deviceType:i,lastLoginDate:1e3*parseInt(n,10),isCurrent:o}))))),Ra=qt((e=>e.passkeys.data),(e=>e.map((({id:e,displayName:t,kind:i,createdTime:n})=>({id:e,name:t,passkeyType:i,createdAt:1e3*n}))))),Ta=e=>e.notifications,Ma=qt(la,(e=>e.userTenants||[])),Wa=e=>e.tenant.currentTenantId,Ua=yi("tenant/select",((e,t)=>i(void 0,[e,t],void 0,(function*(e,{extra:{api:t},getState:i}){if(e===Wa(i()))return null;const n=yield t.user.setCurrentTenant(e),o=n.sessionJwt||n.sessionToken;try{return{tenantId:aa(o)}}catch(e){return console.error("Failed to switch tenant:",e),null}})))),Pa={action:Ua,reducer:Vi(Ua)({onPending:e=>{e.tenant.previousTenantId=e.tenant.currentTenantId},onFulfilled:(e,t)=>{var i;e.tenant.currentTenantId=null===(i=t.payload)||void 0===i?void 0:i.tenantId,e.tenant.previousTenantId=null},onRejected:e=>{e.tenant.currentTenantId=e.tenant.previousTenantId,e.tenant.previousTenantId=null}},Ji((e=>e.selectTenant)),(({getErrorMsg:e,getSuccessMsg:t})=>({onFulfilled:(e,i)=>{if(t){const n=t(i);n&&e.notifications.push({type:"success",msg:n})}},onRejected:(t,i)=>{if(e){const n=e(i);n&&t.notifications.push({type:"error",msg:n})}}}))({getErrorMsg:e=>{var t;return v(null===(t=e.error)||void 0===t?void 0:t.message).trim()||"Error"}}))},_a={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:[]},La={me:"/v1/auth/me",devices:"/v1/mgmt/user/trusteddevices/list",passkeys:"/v1/mgmt/user/passkeys/list",selectTenant:"/v1/auth/tenant/select"},$a=e=>i(void 0,void 0,void 0,(function*(){const t=yield e.text(),i=JSON.parse(t);if(!e.ok){const t=`${i.errorDescription}${i.errorMessage?`: ${i.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(i),e.text=()=>Promise.resolve(t)})),Na=[{tenantName:"Tenant 1",tenantId:"tn1",roleNames:["Role"]},{tenantName:"Tenant 2",tenantId:"tn2",roleNames:["Role"]}],Da=()=>i(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",recoveryEmail:"recovery@company.com",recoveryPhone:"+1-202-555-020",verifiedEmail:!0,verifiedPhone:!0,verifiedRecoveryEmail:!0,verifiedRecoveryPhone:!0,userTenants:Na,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})}))})),Fa=()=>({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}]}),qa=()=>({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"}]}),za=({httpClient:e,mock:t})=>({me:()=>i(void 0,void 0,void 0,(function*(){if(t)return Da();const i=yield e.get(La.me);return yield $a(i),i.json()})),setCurrentTenant:t=>i(void 0,void 0,void 0,(function*(){const i=yield e.post(La.selectTenant,{tenant:t});return yield $a(i),i.json()}))}),Va=({httpClient:e,mock:t})=>({devices:n=>i(void 0,[n],void 0,(function*({userId:i}){if(t)return Fa();const n=yield e.post(La.devices,{identifiers:[i]});return yield $a(n),n.json()}))}),Ja=({httpClient:e,mock:t})=>({listPasskeys:n=>i(void 0,[n],void 0,(function*({userId:i}){if(t)return qa();const n=yield e.post(La.passkeys,{loginId:i});return yield $a(n),n.json()}))}),Ba=c((e=>{var t,r,a,l,c;const d=s(j,x,y,R,Wi)(e);return c=class extends d{constructor(){super(...arguments),t.add(this),r.set(this,void 0)}get sessionTokenViaCookie(){return n(this,t,"m",l).call(this,"session-token-via-cookie")}get refreshTokenViaCookie(){return n(this,t,"m",l).call(this,"refresh-token-via-cookie")}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get styleId(){return this.getAttribute("style-id")||ye}get api(){return n(this,r,"f")||n(this,t,"m",a).call(this),n(this,r,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return i(this,void 0,void 0,(function*(){var i;yield null===(i=e.init)||void 0===i?void 0:i.call(this),this.observeAttributes(["project-id","base-url","session-token-via-cookie","refresh-token-via-cookie"],(()=>{n(this,r,"f")&&n(this,t,"m",a).call(this)}))}))}},r=new WeakMap,t=new WeakSet,a=function(){this.logger.debug("creating an sdk instance"),o(this,r,((e,t,n)=>{const o=ra(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":n,"x-descope-widget-version":"0.20.3"}}));return{user:Object.assign(Object.assign({},za({httpClient:o.httpClient,mock:t})),{logout:t?()=>i(void 0,void 0,void 0,(function*(){})):o.logout}),device:Object.assign({},Va({httpClient:o.httpClient,mock:t})),passkey:Object.assign({},Ja({httpClient:o.httpClient,mock:t})),httpClient:o.httpClient}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName,sessionTokenViaCookie:this.sessionTokenViaCookie,refreshTokenViaCookie:this.refreshTokenViaCookie},"true"===this.mock,this.widgetId),"f")},l=function(e){var t;try{return null!==(t=JSON.parse(this.getAttribute(e)))&&void 0!==t?t:void 0}catch(t){return void this.logger.warn(`invalid JSON in "${e}" attribute, ignoring it`)}},c})),Ha=c((e=>{const t=s(Oi({name:"widget",initialState:_a,reducers:{clearNotifications:e=>{e.notifications=[]},setCurrentTenantId:(e,{payload:t})=>{e.tenant.currentTenantId=t}},extraReducers:e=>{Ki.reducer(e),Zi.reducer(e),en.reducer(e),nn.reducer(e),Pa.reducer(e)},asyncActions:{getMe:Ki.action,listDevices:Zi.action,listPasskeys:en.action,logout:nn.action,selectTenant:Pa.action}}),A,y,Ba)(e);return class extends t{constructor(...e){super(...e),this.state=_a,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),Ka="widget-flow",Ya=c((e=>{var t,o,r;return r=class extends(s(Ti,A,me,Ha,Wi,y,xe,$i)(e)){constructor(){super(...arguments),t.add(this)}init(){const e=Object.create(null,{init:{get:()=>super.init}});return i(this,void 0,void 0,(function*(){var i;yield null===(i=e.init)||void 0===i?void 0:i.call(this);const s=zi(Ka);s&&(!function(e){if(window.history.replaceState&&zi(e)){const t=new URL(window.location.href),i=new URLSearchParams(t.search);i.delete(e),t.search=i.toString(),window.history.replaceState({},"",t.toString())}}(Ka),n(this,t,"m",o).call(this,s))}))}},t=new WeakSet,o=function(e){const t=this.createFlowModal({"data-id":"redirect-flow"});t.setContent(this.createFlowTemplate({flowId:e}));new ie((()=>{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()},r})),Ga=()=>{var e;return"function"==typeof(null===(e=window.descopeBridge)||void 0===e?void 0:e.registerWidget)},Za=c((e=>{const t=e;return class extends t{init(){const e=Object.create(null,{init:{get:()=>super.init}});return i(this,void 0,void 0,(function*(){var t;Ga()&&window.descopeBridge.registerWidget(this),yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}handleLogout(){const e=Object.create(null,{handleLogout:{get:()=>super.handleLogout}});return i(this,void 0,void 0,(function*(){var t;Ga()?this.dispatchEvent(new CustomEvent("widget-logout")):yield null===(t=e.handleLogout)||void 0===t?void 0:t.call(this)}))}}})),Xa=c((e=>{var t,o,a;return a=class extends(s(y,A,V,G,Mi("user-profile-widget"),Ha)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return i(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return i(this,void 0,void 0,(function*(){var i;yield null===(i=e.init)||void 0===i?void 0:i.call(this);try{yield this.actions.getMe(),yield n(this,t,"m",o).call(this),yield this.onWidgetRootReady()}catch(e){const t=null==e?void 0:e.code,i=(null==e?void 0:e.message)||("string"==typeof e?e:"Widget failed to initialize");throw this.dispatchEvent(new CustomEvent("error",{detail:{code:t,description:"Widget failed to initialize",message:i}})),e}this.dispatchEvent(new CustomEvent("ready"))}))}},t=new WeakSet,o=function(){return i(this,void 0,void 0,(function*(){const e=r(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},a})),Qa=c((e=>class extends(s(xe,x)(e)){syncFlowTheme(e){e.theme=this.theme,this.observeAttributes(["theme"],(()=>{e.theme=this.theme}))}})),el=c((e=>{var t,r,l,c,d,u,h,p,f;return f=class extends(s(Ti,Qa,xe,Ha,y,Wi,Xa,me,$i)(e)){constructor(){super(...arguments),t.add(this),r.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 i(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),n(this,t,"m",u).call(this),n(this,t,"m",c).call(this),n(this,h,"f").call(this,da(this.state)),n(this,p,"f").call(this,pa(this.state)),this.subscribe(n(this,h,"f").bind(this),da),this.subscribe(n(this,p,"f").bind(this),pa)}))}},r=new WeakMap,l=new WeakMap,h=new WeakMap,p=new WeakMap,t=new WeakSet,c=function(){this.avatar.flowId&&(o(this,r,this.createFlowModal({"data-id":"update-pic","close-on-outside-click":"true"}),"f"),o(this,l,new ie((()=>{var e;return null===(e=n(this,r,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),n(this,r,"f").afterClose=n(this,t,"m",d).bind(this),n(this,t,"m",d).call(this),this.syncFlowTheme(n(this,l,"f")))},d=function(){n(this,r,"f").setContent(this.createFlowTemplate({flowId:this.avatar.flowId})),n(this,l,"f").onSuccess((()=>{n(this,r,"f").close(),this.actions.getMe()}))},u=function(){this.avatar=new ee((()=>{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=n(this,r,"f"))||void 0===e||e.open()}))},f})),tl=c((e=>{var t,r,l,c,d,u,h,p,f,g,v,m,w,b;return b=class extends(s(Ti,Qa,Ha,y,Xa,Wi,me,$i)(e)){constructor(){super(...arguments),t.add(this),r.set(this,void 0),l.set(this,void 0),c.set(this,void 0),d.set(this,void 0),m.set(this,a((e=>{this.emailUserAttr.value=e,n(this,t,"m",v).call(this)}))),w.set(this,a((e=>{this.emailUserAttr.badgeLabel=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return i(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),n(this,t,"m",g).call(this),n(this,t,"m",u).call(this),n(this,t,"m",p).call(this),n(this,m,"f").call(this,ua(this.state)),n(this,w,"f").call(this,va(this.state)),this.subscribe(n(this,m,"f").bind(this),ua),this.subscribe(n(this,w,"f").bind(this),va)}))}},r=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,m=new WeakMap,w=new WeakMap,t=new WeakSet,u=function(){this.emailUserAttr.editFlowId&&(o(this,r,this.createFlowModal({"data-id":"edit-email","close-on-outside-click":"true"}),"f"),o(this,l,new ie((()=>{var e;return null===(e=n(this,r,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),n(this,r,"f").afterClose=n(this,t,"m",h).bind(this),this.syncFlowTheme(n(this,l,"f")))},h=function(){n(this,r,"f").setContent(this.createFlowTemplate({flowId:this.emailUserAttr.editFlowId})),n(this,l,"f").onSuccess((()=>{n(this,r,"f").close(),this.actions.getMe()}))},p=function(){this.emailUserAttr.deleteFlowId&&(o(this,c,this.createFlowModal({"data-id":"delete-email","close-on-outside-click":"true"}),"f"),o(this,d,new ie((()=>{var e;return null===(e=n(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),n(this,c,"f").afterClose=n(this,t,"m",f).bind(this),this.syncFlowTheme(n(this,d,"f")))},f=function(){n(this,c,"f").setContent(this.createFlowTemplate({flowId:this.emailUserAttr.deleteFlowId})),n(this,d,"f").onSuccess((()=>{n(this,c,"f").close(),this.actions.getMe()}))},g=function(){this.emailUserAttr=new ue((()=>{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=n(this,r,"f"))||void 0===e||e.open()})),this.emailUserAttr.onDeleteClick((()=>{var e;null===(e=n(this,c,"f"))||void 0===e||e.open()}))},v=function(){var e,i;(null===(e=n(this,r,"f"))||void 0===e?void 0:e.isClosed)&&n(this,t,"m",h).call(this),(null===(i=n(this,c,"f"))||void 0===i?void 0:i.isClosed)&&n(this,t,"m",f).call(this)},b})),il=c((e=>{var t,o,r;return r=class extends(s(Ha,y,Xa,ve)(e)){constructor(){super(...arguments),t.add(this)}handleLogout(){return i(this,void 0,void 0,(function*(){yield this.actions.logout(),this.dispatchEvent(new CustomEvent("logout"))}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return i(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),n(this,t,"m",o).call(this)}))}},t=new WeakSet,o=function(){this.logout=new te((()=>{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((()=>this.handleLogout()))},r})),nl=c((e=>{var t,r,l,c,d,u,h,p,f,g,v,m,w;return w=class extends(s(Ti,Qa,Ha,y,Xa,Wi,me,$i)(e)){constructor(){super(...arguments),t.add(this),r.set(this,void 0),l.set(this,void 0),c.set(this,void 0),d.set(this,void 0),m.set(this,a((e=>{this.nameUserAttr.value=e,n(this,t,"m",v).call(this)})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return i(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),n(this,t,"m",g).call(this),n(this,t,"m",u).call(this),n(this,t,"m",p).call(this),n(this,m,"f").call(this,pa(this.state)),this.subscribe(n(this,m,"f").bind(this),pa)}))}},r=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,m=new WeakMap,t=new WeakSet,u=function(){this.nameUserAttr.editFlowId&&(o(this,r,this.createFlowModal({"data-id":"edit-name","close-on-outside-click":"true"}),"f"),o(this,l,new ie((()=>{var e;return null===(e=n(this,r,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),n(this,r,"f").afterClose=n(this,t,"m",h).bind(this),this.syncFlowTheme(n(this,l,"f")))},h=function(){n(this,r,"f").setContent(this.createFlowTemplate({flowId:this.nameUserAttr.editFlowId})),n(this,l,"f").onSuccess((()=>{n(this,r,"f").close(),this.actions.getMe()}))},p=function(){this.nameUserAttr.deleteFlowId&&(o(this,c,this.createFlowModal({"data-id":"delete-name","close-on-outside-click":"true"}),"f"),o(this,d,new ie((()=>{var e;return null===(e=n(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),n(this,c,"f").afterClose=n(this,t,"m",f).bind(this),this.syncFlowTheme(n(this,d,"f")))},f=function(){n(this,c,"f").setContent(this.createFlowTemplate({flowId:this.nameUserAttr.deleteFlowId})),n(this,d,"f").onSuccess((()=>{n(this,c,"f").close(),this.actions.getMe()}))},g=function(){this.nameUserAttr=new ue((()=>{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=n(this,r,"f"))||void 0===e||e.open()})),this.nameUserAttr.onDeleteClick((()=>{var e;null===(e=n(this,c,"f"))||void 0===e||e.open()}))},v=function(){var e,i;(null===(e=n(this,r,"f"))||void 0===e?void 0:e.isClosed)&&n(this,t,"m",h).call(this),(null===(i=n(this,c,"f"))||void 0===i?void 0:i.isClosed)&&n(this,t,"m",f).call(this)},w})),ol=c((e=>{var t,r,l,c,d,u,h,p,f,g,v,m;return m=class extends(s(Ti,Qa,Ha,y,Xa,Wi,me,$i)(e)){constructor(){super(...arguments),t.add(this),r.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 i(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),n(this,t,"m",g).call(this),n(this,t,"m",u).call(this),n(this,t,"m",p).call(this),n(this,v,"f").call(this,Ca(this.state)),this.subscribe(n(this,v,"f").bind(this),Ca)}))}},r=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,v=new WeakMap,t=new WeakSet,u=function(){this.passkeyUserAuthMethod.flowId&&(o(this,r,this.createFlowModal({"data-id":"add-passkey","close-on-outside-click":"true"}),"f"),o(this,l,new ie((()=>{var e;return null===(e=n(this,r,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),n(this,r,"f").afterClose=n(this,t,"m",h).bind(this),n(this,t,"m",h).call(this),this.syncFlowTheme(n(this,l,"f")))},h=function(){n(this,r,"f").setContent(this.createFlowTemplate({flowId:this.passkeyUserAuthMethod.flowId})),n(this,l,"f").onSuccess((()=>{n(this,r,"f").close(),this.actions.getMe()}))},p=function(){this.passkeyUserAuthMethod.fulfilledFlowId&&(o(this,c,this.createFlowModal({"data-id":"remove-passkey","close-on-outside-click":"true"}),"f"),o(this,d,new ie((()=>{var e;return null===(e=n(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),n(this,c,"f").afterClose=n(this,t,"m",f).bind(this),n(this,t,"m",f).call(this),this.syncFlowTheme(n(this,d,"f")))},f=function(){n(this,c,"f").setContent(this.createFlowTemplate({flowId:this.passkeyUserAuthMethod.fulfilledFlowId})),n(this,d,"f").onSuccess((()=>{n(this,c,"f").close(),this.actions.getMe()}))},g=function(){this.passkeyUserAuthMethod=new he((()=>{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=n(this,r,"f"))||void 0===e||e.open()})),this.passkeyUserAuthMethod.onFulfilledButtonClick((()=>{var e;null===(e=n(this,c,"f"))||void 0===e||e.open()}))},m})),sl=c((e=>{var t,r,a,l,c,d;return d=class extends(s(Ti,Qa,Ha,y,Xa,Wi,me,$i)(e)){constructor(){super(...arguments),t.add(this),r.set(this,void 0),a.set(this,void 0)}initPasswordAuthMethod(){this.passwordUserAuthMethod=new he((()=>{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=n(this,r,"f"))||void 0===e||e.open()}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return i(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),this.initPasswordAuthMethod(),n(this,t,"m",l).call(this)}))}},r=new WeakMap,a=new WeakMap,t=new WeakSet,l=function(){this.passwordUserAuthMethod.flowId&&(o(this,r,this.createFlowModal({"data-id":"password","close-on-outside-click":"true"}),"f"),o(this,a,new ie((()=>{var e;return null===(e=n(this,r,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),n(this,r,"f").afterClose=n(this,t,"m",c).bind(this),n(this,t,"m",c).call(this),this.syncFlowTheme(n(this,a,"f")))},c=function(){n(this,r,"f").setContent(this.createFlowTemplate({flowId:this.passwordUserAuthMethod.flowId})),n(this,a,"f").onSuccess((()=>{n(this,r,"f").close()}))},d})),rl=c((e=>{var t,r,l,c,d,u,h,p,f,g,v,m,w,b;return b=class extends(s(Ti,Qa,Ha,y,Xa,Wi,me,$i)(e)){constructor(){super(...arguments),t.add(this),r.set(this,void 0),l.set(this,void 0),c.set(this,void 0),d.set(this,void 0),m.set(this,a((e=>{this.phoneUserAttr.value=e,n(this,t,"m",v).call(this)}))),w.set(this,a((e=>{this.phoneUserAttr.badgeLabel=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return i(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),n(this,t,"m",g).call(this),n(this,t,"m",u).call(this),n(this,t,"m",p).call(this),n(this,m,"f").call(this,fa(this.state)),n(this,w,"f").call(this,ma(this.state)),this.subscribe(n(this,m,"f").bind(this),fa),this.subscribe(n(this,w,"f").bind(this),ma)}))}},r=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,m=new WeakMap,w=new WeakMap,t=new WeakSet,u=function(){this.phoneUserAttr.editFlowId&&(o(this,r,this.createFlowModal({"data-id":"edit-phone","close-on-outside-click":"true"}),"f"),o(this,l,new ie((()=>{var e;return null===(e=n(this,r,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),n(this,r,"f").afterClose=n(this,t,"m",h).bind(this),this.syncFlowTheme(n(this,l,"f")))},h=function(){n(this,r,"f").setContent(this.createFlowTemplate({flowId:this.phoneUserAttr.editFlowId})),n(this,l,"f").onSuccess((()=>{n(this,r,"f").close(),this.actions.getMe()}))},p=function(){this.phoneUserAttr.deleteFlowId&&(o(this,c,this.createFlowModal({"data-id":"delete-phone","close-on-outside-click":"true"}),"f"),o(this,d,new ie((()=>{var e;return null===(e=n(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),n(this,c,"f").afterClose=n(this,t,"m",f).bind(this),this.syncFlowTheme(n(this,d,"f")))},f=function(){n(this,c,"f").setContent(this.createFlowTemplate({flowId:this.phoneUserAttr.deleteFlowId})),n(this,d,"f").onSuccess((()=>{n(this,c,"f").close(),this.actions.getMe()}))},g=function(){this.phoneUserAttr=new ue((()=>{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=n(this,r,"f"))||void 0===e||e.open()})),this.phoneUserAttr.onDeleteClick((()=>{var e;null===(e=n(this,c,"f"))||void 0===e||e.open()}))},v=function(){var e,i;(null===(e=n(this,r,"f"))||void 0===e?void 0:e.isClosed)&&n(this,t,"m",h).call(this),(null===(i=n(this,c,"f"))||void 0===i?void 0:i.isClosed)&&n(this,t,"m",f).call(this)},b})),al=c((e=>{var t,r,l,c,d,u,h,p,f,g,v,m;return m=class extends(s(Ti,Qa,Ha,y,Xa,Wi,me,$i)(e)){constructor(){super(...arguments),t.add(this),r.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.recoveryEmailUserAttr.value=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return i(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),n(this,t,"m",g).call(this),n(this,t,"m",u).call(this),n(this,t,"m",p).call(this),n(this,v,"f").call(this,Sa(this.state)),this.subscribe(n(this,v,"f").bind(this),Sa)}))}},r=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,v=new WeakMap,t=new WeakSet,u=function(){this.recoveryEmailUserAttr.editFlowId&&(o(this,r,this.createFlowModal({"data-id":"edit-recovery-email","close-on-outside-click":"true"}),"f"),o(this,l,new ie((()=>{var e;return null===(e=n(this,r,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),n(this,r,"f").afterClose=n(this,t,"m",h).bind(this),n(this,t,"m",h).call(this),this.syncFlowTheme(n(this,l,"f")))},h=function(){n(this,r,"f").setContent(this.createFlowTemplate({flowId:this.recoveryEmailUserAttr.editFlowId})),n(this,l,"f").onSuccess((()=>{n(this,r,"f").close(),this.actions.getMe()}))},p=function(){this.recoveryEmailUserAttr.deleteFlowId&&(o(this,c,this.createFlowModal({"data-id":"delete-recovery-email","close-on-outside-click":"true"}),"f"),o(this,d,new ie((()=>{var e;return null===(e=n(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),n(this,c,"f").afterClose=n(this,t,"m",f).bind(this),n(this,t,"m",f).call(this),this.syncFlowTheme(n(this,d,"f")))},f=function(){n(this,c,"f").setContent(this.createFlowTemplate({flowId:this.recoveryEmailUserAttr.deleteFlowId})),n(this,d,"f").onSuccess((()=>{n(this,c,"f").close(),this.actions.getMe()}))},g=function(){this.recoveryEmailUserAttr=new ue((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="recoveryEmail"]')}),{logger:this.logger}),this.recoveryEmailUserAttr.onEditClick((()=>{var e;null===(e=n(this,r,"f"))||void 0===e||e.open()})),this.recoveryEmailUserAttr.onDeleteClick((()=>{var e;null===(e=n(this,c,"f"))||void 0===e||e.open()}))},m})),ll=c((e=>{var t,r,l,c,d,u,h,p,f,g,v,m;return m=class extends(s(Ti,Qa,Ha,y,Xa,Wi,me,$i)(e)){constructor(){super(...arguments),t.add(this),r.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.recoveryPhoneUserAttr.value=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return i(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),n(this,t,"m",g).call(this),n(this,t,"m",u).call(this),n(this,t,"m",p).call(this),n(this,v,"f").call(this,Ia(this.state)),this.subscribe(n(this,v,"f").bind(this),Ia)}))}},r=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,v=new WeakMap,t=new WeakSet,u=function(){this.recoveryPhoneUserAttr.editFlowId&&(o(this,r,this.createFlowModal({"data-id":"edit-recovery-phone","close-on-outside-click":"true"}),"f"),o(this,l,new ie((()=>{var e;return null===(e=n(this,r,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),n(this,r,"f").afterClose=n(this,t,"m",h).bind(this),n(this,t,"m",h).call(this),this.syncFlowTheme(n(this,l,"f")))},h=function(){n(this,r,"f").setContent(this.createFlowTemplate({flowId:this.recoveryPhoneUserAttr.editFlowId})),n(this,l,"f").onSuccess((()=>{n(this,r,"f").close(),this.actions.getMe()}))},p=function(){this.recoveryPhoneUserAttr.deleteFlowId&&(o(this,c,this.createFlowModal({"data-id":"delete-recovery-phone","close-on-outside-click":"true"}),"f"),o(this,d,new ie((()=>{var e;return null===(e=n(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),n(this,c,"f").afterClose=n(this,t,"m",f).bind(this),n(this,t,"m",f).call(this),this.syncFlowTheme(n(this,d,"f")))},f=function(){n(this,c,"f").setContent(this.createFlowTemplate({flowId:this.recoveryPhoneUserAttr.deleteFlowId})),n(this,d,"f").onSuccess((()=>{n(this,c,"f").close(),this.actions.getMe()}))},g=function(){this.recoveryPhoneUserAttr=new ue((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="recoveryPhone"]')}),{logger:this.logger}),this.recoveryPhoneUserAttr.onEditClick((()=>{var e;null===(e=n(this,r,"f"))||void 0===e||e.open()})),this.recoveryPhoneUserAttr.onDeleteClick((()=>{var e;null===(e=n(this,c,"f"))||void 0===e||e.open()}))},m})),cl=c((e=>{var t,r,l,c,d,u,h,p,f,g,v,m;return m=class extends(s(Ti,Qa,Ha,y,Xa,Wi,me,$i)(e)){constructor(){super(...arguments),t.add(this),r.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 i(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),n(this,t,"m",g).call(this),n(this,t,"m",u).call(this),n(this,t,"m",p).call(this),n(this,v,"f").call(this,Ea(this.state)),this.subscribe(n(this,v,"f").bind(this),Ea)}))}},r=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,v=new WeakMap,t=new WeakSet,u=function(){this.totpUserAuthMethod.flowId&&(o(this,r,this.createFlowModal({"data-id":"totp","close-on-outside-click":"true"}),"f"),o(this,l,new ie((()=>{var e;return null===(e=n(this,r,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),n(this,r,"f").afterClose=n(this,t,"m",h).bind(this),n(this,t,"m",h).call(this),this.syncFlowTheme(n(this,l,"f")))},h=function(){n(this,r,"f").setContent(this.createFlowTemplate({flowId:this.totpUserAuthMethod.flowId})),n(this,l,"f").onSuccess((()=>{n(this,r,"f").close(),this.actions.getMe()}))},p=function(){this.totpUserAuthMethod.fulfilledFlowId&&(o(this,c,this.createFlowModal({"data-id":"remove-totp","close-on-outside-click":"true"}),"f"),o(this,d,new ie((()=>{var e;return null===(e=n(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),n(this,c,"f").afterClose=n(this,t,"m",f).bind(this),n(this,t,"m",f).call(this),this.syncFlowTheme(n(this,d,"f")))},f=function(){n(this,c,"f").setContent(this.createFlowTemplate({flowId:this.totpUserAuthMethod.fulfilledFlowId})),n(this,d,"f").onSuccess((()=>{n(this,c,"f").close(),this.actions.getMe()}))},g=function(){this.totpUserAuthMethod=new he((()=>{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=n(this,r,"f"))||void 0===e||e.open()})),this.totpUserAuthMethod.onFulfilledButtonClick((()=>{var e;null===(e=n(this,c,"f"))||void 0===e||e.open()}))},m})),dl=c((e=>{var t,o,r,l,c,d,u,h,p,f,g,v,m,w;return w=class extends(s(Ti,Qa,Ha,y,Xa,Wi,me,$i)(e)){constructor(){super(...arguments),t.add(this),o.set(this,{}),r.set(this,{}),l.set(this,{}),c.set(this,{}),d.set(this,{}),m.set(this,a((e=>{Object.keys(n(this,o,"f")).forEach((t=>{n(this,o,"f")[t].value=(e[t]||"").toString()})),n(this,t,"m",v).call(this)})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return i(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),n(this,t,"m",g).call(this),n(this,m,"f").call(this,Oa(this.state)),this.subscribe(n(this,m,"f").bind(this),Oa)}))}},o=new WeakMap,r=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,m=new WeakMap,t=new WeakSet,u=function(e){var t,i;null===(t=n(this,r,"f")[e])||void 0===t||t.setContent(this.createFlowTemplate({flowId:e})),null===(i=n(this,l,"f")[e])||void 0===i||i.onSuccess((()=>{var t;null===(t=n(this,r,"f")[e])||void 0===t||t.close(),this.actions.getMe()}))},h=function(e){var t,i;null===(t=n(this,c,"f")[e])||void 0===t||t.setContent(this.createFlowTemplate({flowId:e})),null===(i=n(this,d,"f")[e])||void 0===i||i.onSuccess((()=>{var t;null===(t=n(this,c,"f")[e])||void 0===t||t.close(),this.actions.getMe()}))},p=function(e,i,o){const s=e.getAttribute("edit-flow-id");s&&(n(this,r,"f")[s]=this.createFlowModal({"data-id":`edit-${i}`,"close-on-outside-click":"true"}),n(this,l,"f")[s]=new ie((()=>{var e,t;return null===(t=null===(e=n(this,r,"f")[s])||void 0===e?void 0:e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),n(this,r,"f")[s].afterClose=n(this,t,"m",u).bind(this,s),o.onEditClick((()=>{var e,t;null===(t=null===(e=n(this,r,"f"))||void 0===e?void 0:e[s])||void 0===t||t.open()})),this.syncFlowTheme(n(this,l,"f")[s]))},f=function(e,i,o){const s=e.getAttribute("delete-flow-id");s&&(n(this,c,"f")[s]=this.createFlowModal({"data-id":`delete-${i}`,"close-on-outside-click":"true"}),n(this,d,"f")[s]=new ie((()=>{var e,t;return null===(t=null===(e=n(this,c,"f")[s])||void 0===e?void 0:e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),n(this,c,"f")[s].afterClose=n(this,t,"m",h).bind(this,s),o.onDeleteClick((()=>{var e,t;null===(t=null===(e=n(this,c,"f"))||void 0===e?void 0:e[s])||void 0===t||t.open()})),this.syncFlowTheme(n(this,d,"f")[s]))},g=function(){var e;const i=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelectorAll('descope-user-attribute[data-id^="builtin."]');Array.from(i||[]).forEach((e=>{const i=e.getAttribute("data-id").replace("builtin.",""),s=new ue(e,{logger:this.logger});n(this,o,"f")[i]=s,n(this,t,"m",p).call(this,e,i,s),n(this,t,"m",f).call(this,e,i,s)}))},v=function(){Object.entries(n(this,r,"f")).forEach((([e,i])=>{i.isClosed&&n(this,t,"m",u).call(this,e)})),Object.entries(n(this,c,"f")).forEach((([e,i])=>{i.isClosed&&n(this,t,"m",h).call(this,e)}))},w}));var ul;!function(e){e.TEXT="text",e.NUMBER="number",e.BOOLEAN="boolean",e.SINGLE_SELECT="singleSelect",e.ARRAY="array",e.DATE="date"}(ul||(ul={}));const hl=c((e=>{var t,o,r,l,c,d,u,h,p,f,g;return o=class extends(s(Ti,Qa,Ha,y,Xa,Wi,me,$i)(e)){constructor(){super(...arguments),t.add(this),r.set(this,{}),l.set(this,{}),c.set(this,{}),d.set(this,{}),p.set(this,a((e=>{var i;const s=null===(i=this.shadowRoot)||void 0===i?void 0:i.querySelectorAll('descope-user-attribute[data-id^="customAttributes."]');Array.from(s).forEach((i=>{const s=i.getAttribute("data-id").replace("customAttributes.",""),r=i.getAttribute("data-type")||ul.TEXT,a=e[s],l=new ue(i,{logger:this.logger});l.value=o.getFormattedValue(r,a),n(this,t,"m",f).call(this,i,s,l),n(this,t,"m",g).call(this,i,s,l)}))})))}static getFormattedValue(e,t){return e===ul.DATE&&t?new Date(t).toLocaleString():e===ul.BOOLEAN&&void 0!==t?t?"True":"False":(t||"").toString()}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return i(this,void 0,void 0,(function*(){var t;yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),n(this,p,"f").call(this,xa(this.state)),this.subscribe(n(this,p,"f").bind(this),xa)}))}},r=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,p=new WeakMap,t=new WeakSet,u=function(e){var t,i;null===(t=n(this,r,"f")[e])||void 0===t||t.setContent(this.createFlowTemplate({flowId:e})),null===(i=n(this,l,"f")[e])||void 0===i||i.onSuccess((()=>{var t;null===(t=n(this,r,"f")[e])||void 0===t||t.close(),this.actions.getMe()}))},h=function(e){var t,i;null===(t=n(this,c,"f")[e])||void 0===t||t.setContent(this.createFlowTemplate({flowId:e})),null===(i=n(this,d,"f")[e])||void 0===i||i.onSuccess((()=>{var t;null===(t=n(this,c,"f")[e])||void 0===t||t.close(),this.actions.getMe()}))},f=function(e,i,o){const s=e.getAttribute("edit-flow-id");s&&(n(this,r,"f")[s]=this.createFlowModal({"data-id":`edit-${i}`,"close-on-outside-click":"true"}),n(this,l,"f")[s]=new ie((()=>{var e,t;return null===(t=null===(e=n(this,r,"f")[s])||void 0===e?void 0:e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),n(this,r,"f")[s].afterClose=n(this,t,"m",u).bind(this,s),o.onEditClick((()=>{var e,t;null===(t=null===(e=n(this,r,"f"))||void 0===e?void 0:e[s])||void 0===t||t.open()})),n(this,t,"m",u).call(this,s),this.syncFlowTheme(n(this,l,"f")[s]))},g=function(e,i,o){const s=e.getAttribute("delete-flow-id");s&&(n(this,c,"f")[s]=this.createFlowModal({"data-id":`delete-${i}`,"close-on-outside-click":"true"}),n(this,d,"f")[s]=new ie((()=>{var e,t;return null===(t=null===(e=n(this,c,"f")[s])||void 0===e?void 0:e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),n(this,c,"f")[s].afterClose=n(this,t,"m",h).bind(this,s),o.onDeleteClick((()=>{var e,t;null===(t=null===(e=n(this,c,"f"))||void 0===e?void 0:e[s])||void 0===t||t.open()})),n(this,t,"m",h).call(this,s),this.syncFlowTheme(n(this,d,"f")[s]))},o})),pl=c((e=>{var t,r,l,c,d,u,h,p;return p=class extends(s(Ti,Qa,xe,Ha,y,Wi,Xa,me,$i)(e)){constructor(){super(...arguments),t.add(this),r.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 i(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),this.deviceList=new pe((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-trusted-devices")}),{logger:this.logger}),this.deviceList.isExists&&(yield n(this,t,"m",h).call(this),n(this,t,"m",u).call(this,ja(this.state)),n(this,t,"m",c).call(this),this.subscribe(this.updateDeviceList.bind(this),ja))}))}},r=new WeakMap,l=new WeakMap,t=new WeakSet,c=function(){this.deviceList.flowId&&(o(this,r,this.createFlowModal({"data-id":"untrust-device","close-on-outside-click":"true"}),"f"),o(this,l,new ie((()=>{var e;return null===(e=n(this,r,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),n(this,r,"f").afterClose=()=>n(this,t,"m",d).call(this,""),this.syncFlowTheme(n(this,l,"f")))},d=function(e=""){n(this,r,"f").setContent(this.createFlowTemplate({flowId:this.deviceList.flowId,form:{deviceId:e}})),n(this,l,"f").onSuccess((()=>{n(this,r,"f").close(),this.actions.listDevices({userId:ca(this.state)})}))},u=function(e){this.deviceList.onRemoveDeviceClick((({id:e})=>{var i;n(this,t,"m",d).call(this,e),null===(i=n(this,r,"f"))||void 0===i||i.open()})),this.deviceList.data=e},h=function(){return i(this,void 0,void 0,(function*(){yield this.actions.listDevices({userId:ca(this.state)})}))},p})),fl=c((e=>{var t,r,l,c,d,u,h,p,f,g,v,m;return m=class extends(s(Ti,Qa,Ha,y,Xa,Wi,me,$i)(e)){constructor(){super(...arguments),t.add(this),r.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 i(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),this.userPasskeys=new ge((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector("descope-user-passkeys")}),{logger:this.logger}),this.userPasskeys.isExists&&(n(this,t,"m",v).call(this,Ra(this.state)),n(this,t,"m",u).call(this),n(this,t,"m",p).call(this),this.subscribe(n(this,g,"f").bind(this),ca),this.subscribe(this.updatePasskeyList.bind(this),Ra))}))}},r=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,g=new WeakMap,t=new WeakSet,u=function(){this.userPasskeys.addPasskeyFlowId&&(o(this,r,this.createFlowModal({"data-id":"add-user-passkey","close-on-outside-click":"true"}),"f"),o(this,l,new ie((()=>{var e;return null===(e=n(this,r,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),n(this,r,"f").afterClose=n(this,t,"m",h).bind(this),n(this,t,"m",h).call(this),this.syncFlowTheme(n(this,l,"f")))},h=function(){n(this,r,"f").setContent(this.createFlowTemplate({flowId:this.userPasskeys.addPasskeyFlowId})),n(this,l,"f").onSuccess((()=>{n(this,r,"f").close(),this.actions.getMe(),this.actions.listPasskeys({userId:ca(this.state)})}))},p=function(){this.userPasskeys.removePasskeyFlowId&&(o(this,c,this.createFlowModal({"data-id":"remove-user-passkey","close-on-outside-click":"true"}),"f"),o(this,d,new ie((()=>{var e;return null===(e=n(this,c,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(n(this,d,"f")))},f=function({externalId:e,credentialId:t}){n(this,c,"f").setContent(this.createFlowTemplate({flowId:this.userPasskeys.removePasskeyFlowId,form:{externalId:e,credentialId:t}})),n(this,d,"f").onSuccess((()=>{n(this,c,"f").close(),this.actions.getMe(),this.actions.listPasskeys({userId:ca(this.state)})}))},v=function(e){this.updatePasskeyList(e),this.userPasskeys.onAddPasskeyClick((()=>{var e;null===(e=n(this,r,"f"))||void 0===e||e.open()})),this.userPasskeys.onRemovePasskeyClick((({id:e})=>{var i;const o=ca(this.state);n(this,t,"m",f).call(this,{externalId:o,credentialId:e}),null===(i=n(this,c,"f"))||void 0===i||i.open()}))},m}));const gl={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},vl=c((e=>{var t,o,r,l,c;return c=class extends(s(y,Ha,be,A)(e)){constructor(){super(...arguments),t.add(this),l.set(this,a((e=>{e.length&&(e.forEach((({type:e,msg:i})=>{const s=n(this,t,"m",r).call(this,e);s.setContent(n(this,t,"m",o).call(this,{type:e,msg:i})),s.show()})),setTimeout((()=>this.actions.clearNotifications())))})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return i(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.subscribe(n(this,l,"f").bind(this),Ta)}))}},l=new WeakMap,t=new WeakSet,o=function({type:e,msg:t}){const i=gl[e],n=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==i?void 0:i.outerHTML)||""}${t}${n.outerHTML}`},r=function(e){return this.createNotification({mode:e,duration:"error"===e?0:3e3,position:"bottom-start",size:"sm"})},c})),ml=c((e=>{var t,r,a,l,c,d,u,h,p,f,g;return g=class extends(s(Ha,y,Xa)(e)){constructor(){super(...arguments),t.add(this),r.set(this,null),l.set(this,(e=>i(this,void 0,void 0,(function*(){const t=e.target.value;yield this.actions.selectTenant(t)})))),c.set(this,(e=>{const i=Wa(e);this.tenantSelector.value!==i&&n(this,t,"m",p).call(this,i);const{loading:s,error:a}=e.selectTenant,l=null!==e.tenant.previousTenantId,c=i!==n(this,r,"f");!i||s||a||l||!c||(o(this,r,i,"f"),n(this,t,"m",d).call(this))}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return i(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),this.actions.setCurrentTenantId((()=>{const e=pr();return aa(e)})()),n(this,t,"m",a).call(this),n(this,t,"m",f).call(this),n(this,t,"m",h).call(this,Ma(this.state)),this.subscribe(n(this,c,"f").bind(this))}))}},r=new WeakMap,l=new WeakMap,c=new WeakMap,t=new WeakSet,a=function(){this.tenantSelector=new fe((()=>{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(n(this,l,"f"))},d=function(){const e=Wa(this.state);this.dispatchEvent(new CustomEvent("tenant-changed",{bubbles:!0,composed:!0,detail:{tenantId:e}})),this.tenantSelector.shouldReload&&n(this,t,"m",u).call(this)},u=function(){setTimeout((()=>window.location.reload()),this.tenantSelector.refreshTimeout)},h=function(e){return i(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((()=>{n(this,t,"m",p).call(this,Wa(this.state)),this.tenantSelector.setAllowCustomValue(!1)}))},g})),wl=c((e=>{var t,r,a,l,c,d,u,h,p,f,g;return g=class extends(s(Ti,Qa,Ha,me,y,Xa,$i)(e)){constructor(){super(...arguments),t.add(this),r.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 i(this,void 0,void 0,(function*(){var i;yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),n(this,t,"m",h).call(this),n(this,t,"m",u).call(this),n(this,l,"f").forEach((e=>e.enable()))}))}},r=new WeakMap,a=new WeakMap,l=new WeakMap,c=new WeakMap,t=new WeakSet,d=function(e){const i=new ne(e,{logger:this.logger});i.onClick((()=>{n(this,t,"m",f).call(this,i.flowId,ca(this.state))})),n(this,l,"f").push(i)},u=function(){var e;const i=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelectorAll("[data-generic-flow-button-id]");Array.from(i).forEach((e=>{n(this,t,"m",d).call(this,e)}))},h=function(){o(this,r,this.createFlowModal({"data-id":"generic-flow-modal","close-on-outside-click":"true"}),"f"),n(this,r,"f").afterClose=()=>{var e;null===(e=n(this,c,"f"))||void 0===e||e.call(this),o(this,c,null,"f")},o(this,a,new ie((()=>{var e;return null===(e=n(this,r,"f").ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(n(this,a,"f"))},p=function(){var e;n(this,r,"f").open(),null===(e=n(this,c,"f"))||void 0===e||e.call(this)},f=function(e,i){n(this,r,"f").setContent(this.createFlowTemplate({flowId:e,client:{userId:i},lazyStart:!1}));o(this,c,n(this,a,"f").onPageUpdated((()=>n(this,t,"m",p).call(this))),"f"),n(this,a,"f").onSuccess((()=>{n(this,r,"f").close(),this.actions.getMe()}))},g})),bl=c((e=>class extends(s(_,xe,Ya,hl,tl,el,nl,rl,al,ll,ol,sl,cl,dl,il,Za,pl,fl,vl,ml,wl,qi)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return i(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),yl=s((e=>class extends(bl(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return i(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this);const i=customElements.get("descope-wc")||(yield Promise.resolve().then((function(){return vh})).then((e=>e.default))),n=this;i.sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.20.3"},get sessionTokenViaCookie(){return n.sessionTokenViaCookie},get refreshTokenViaCookie(){return n.refreshTokenViaCookie}}}))}}))(HTMLElement),kl="undefined"!=typeof localStorage,Sl="J151000",Il="E103205",Cl="E108201",El=kl&&localStorage.getItem("base.content.url")||"",Al="base.ui.components.url";kl&&localStorage.getItem(Al),kl&&localStorage.getItem(Al);const xl="descope-login-flow",Ol="code",jl="redirect_mode",Rl="err",Tl="data-exclude-field",Ml="data-exclude-next",Wl="dls_last_auth",Ul="dls_last_submitted_login_id",Pl="state_id",_l="saml_idp_state_id",Ll="wsfed_idp_state_id",$l="saml_idp_username",Nl="descope_idp_initiated",Dl="sso_app_id",Fl="custom_app_id",ql="third_party_app_id",zl="third_party_app_state_id",Vl="oidc_login_hint",Jl="oidc_prompt",Bl="oidc_resource",Hl="oidc_error_redirect_uri",Kl="application_scopes",Yl="data-type",Gl="redirect",Zl="poll",Xl="webauthnCreate",Ql="webauthnGet",ec="nativeBridge",tc="loadForm",ic="submit",nc="polling",oc=["descope-multi-select-combo-box","descope-text-area"],sc="dls_last_auth_in_flight",rc=["cssVars","componentsConfig","inputs","errorText","errorType","clientScripts","data","totp","notp","sentTo","sso","selfProvisionDomains"],ac=["hide","disable","read-only"],lc="hidden";function cc(e,t){const i=e.closest(`.${lc}`);return!!i&&i!==t}const dc=/(["\\])/g;function uc(e){return"undefined"!=typeof CSS&&"function"==typeof CSS.escape?CSS.escape(e):e.replace(dc,"\\$1")}function hc(e,t){return Array.from(e.querySelectorAll(`[id="${uc(t)}"]`))}function pc(e,t,i){return Object.keys(t).forEach((n=>{const o=t[n];i[n]!==o&&hc(e,n).forEach((e=>function(e,t){switch(t){case"hide":e.classList.remove(lc);break;case"disable":e.removeAttribute("disabled");break;case"read-only":e.removeAttribute("readonly")}}(e,o)))})),Object.keys(i).forEach((n=>{const o=i[n],s=t[n];o!==s&&hc(e,n).forEach((e=>function(e,t){switch(t){case"hide":e.classList.add(lc);break;case"disable":e.setAttribute("disabled","true");break;case"read-only":e.setAttribute("readonly","true")}}(e,o)))})),Object.assign({},i)}var fc;!function(e){e.backward="backward",e.forward="forward"}(fc||(fc={}));const gc=new Set,vc=(e,t)=>({origin:window.location.origin,pathname:window.location.pathname,hash:window.location.hash,projectId:e,flowId:t}),mc=(e,t)=>`dls_sso_query_params_${e}_${t}`,wc=e=>Object.values(null!=e?e:{}).some(Boolean),bc=()=>{var e,t,i;try{const[n]=null!==(i=null===(t=null===(e=window.performance)||void 0===e?void 0:e.getEntriesByType)||void 0===t?void 0:t.call(e,"navigation"))&&void 0!==i?i:[],o=n;if("reload"!==(null==o?void 0:o.type)||!o.name)return!1;const s=new URL(o.name,window.location.href);return s.origin===window.location.origin&&s.pathname===window.location.pathname&&s.hash===window.location.hash}catch(e){return!1}},yc=(e,t)=>(null==e?void 0:e.origin)===t.origin&&(null==e?void 0:e.pathname)===t.pathname&&(null==e?void 0:e.hash)===t.hash&&(null==e?void 0:e.projectId)===t.projectId&&(null==e?void 0:e.flowId)===t.flowId,kc=(e,t)=>{var i,n;try{const o=null===(i=window.sessionStorage)||void 0===i?void 0:i.getItem(mc(e,t));if(!o)return;const s=JSON.parse(o);yc(null==s?void 0:s.scope,vc(e,t))&&(null===(n=window.sessionStorage)||void 0===n||n.removeItem(mc(e,t)))}catch(e){}},Sc=["descope-enriched-text"];function Ic(e){return new URLSearchParams(window.location.search).get(e)}function Cc(e){if(window.history.replaceState&&Ic(e)){const t=new URL(window.location.href),i=new URLSearchParams(t.search);i.delete(e),t.search=i.toString(),window.history.replaceState({},"",t.toString())}}function Ec(e,t){if(!t)return;const i=+e,n=+t;return Number.isNaN(i)||Number.isNaN(n)?void 0:i>n?fc.forward:i<n?fc.backward:void 0}const Ac=e=>{let[t="",i=""]=(Ic(xl)||"").split("_");const n=(e=>{var t;return(null===(t=/(.*)\|#\|.*/.exec(e))||void 0===t?void 0:t[1])||""})(t);return(!e||n&&n!==e)&&(t="",i=""),{executionId:t,stepId:i,executionFlowId:n}};function xc(){Cc(xl)}function Oc(){return Ic($l)}function jc(){Cc($l)}const Rc=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),Tc=(e,t,i)=>{const{executionId:n,stepId:o,executionFlowId:s}=Ac(e);if(s&&e!==s)return i.debug("Flow id does not match the execution flow id, skipping url params handling"),{ssoQueryParams:{}};(n||o)&&xc();const r=Ic("t")||void 0;r&&Cc("t");const a=Ic(Ol)||void 0;a&&Cc(Ol);const l="popup"===Ic(jl);l&&Cc(jl);const c=Ic(Rl)||void 0;c&&Cc(Rl);const{redirectAuthCodeChallenge:d,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthInitiator:p}={redirectAuthCodeChallenge:Ic("ra-challenge"),redirectAuthCallbackUrl:Ic("ra-callback"),redirectAuthBackupCallbackUri:Ic("ra-backup-callback"),redirectAuthInitiator:Ic("ra-initiator")},f=Ic(Pl);f&&Cc(Pl);const g=Ic(_l);g&&Cc(_l);const v=Ic(Ll);v&&Cc(Ll);const m=Oc();g&&jc();const w=Ic(Nl);w&&Cc(Nl);const b=Ic(Dl);b&&Cc(Dl);const y=Ic(Fl);y&&Cc(Fl);const k=Ic(ql);k&&Cc(ql);const S=Ic(zl);S&&Cc(zl);const I=Ic(Kl);I&&Cc(Kl);const C=Ic(Vl);C&&Cc(Vl);const E=Ic(Jl);E&&Cc(Jl);const A=Ic(Hl);A&&Cc(Hl);const x=Ic(Bl);x&&Cc(Bl);const O={oidcIdpStateId:f,samlIdpStateId:g,wsfedIdpStateId:v,samlIdpUsername:m,descopeIdpInitiated:"true"===w,ssoAppId:b,customAppId:y,oidcLoginHint:C,oidcPrompt:E,oidcErrorRedirectUri:A,oidcResource:x,thirdPartyAppId:k,thirdPartyAppStateId:S,applicationScopes:I},j=((e,t)=>{const i=[(n=vc(e,t)).origin,n.pathname,n.hash,n.projectId,n.flowId].join("|");var n;return!gc.has(i)&&(gc.add(i),!0)})(t,e);let R=O;if(wc(O))((e,t,i)=>{var n;if(wc(e))try{const o={params:e,scope:vc(t,i),ts:Date.now()};null===(n=window.sessionStorage)||void 0===n||n.setItem(mc(t,i),JSON.stringify(o))}catch(e){}})(O,t,e);else if(!s){const n=j?((e,t)=>{var i;if(!bc())return null;try{const n=null===(i=window.sessionStorage)||void 0===i?void 0:i.getItem(mc(e,t));if(!n)return null;const o=JSON.parse(n);return yc(null==o?void 0:o.scope,vc(e,t))?Date.now()-o.ts>=6e5?null:o.params:null}catch(e){return null}})(t,e):null;n?(i.debug("Restored SSO query params after a page reload"),R=n):((e,t)=>{bc()||kc(e,t)})(t,e)}return{executionId:n,stepId:o,token:r,code:a,isPopup:l,exchangeError:c,redirectAuthCodeChallenge:d,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthInitiator:p,ssoQueryParams:R}},Mc=e=>{let t,i;return Object.assign(((...n)=>{return t&&(s=n,(o=t).length===s.length&&o.every(((e,t)=>e===s[t])))||(t=n,i=e(...n)),i;var o,s}),{reset:()=>{t=void 0,i=void 0}})},Wc=(e,t,i)=>{if(!0===t||"skipFirstScreen"===t&&!i){const t=Array.from(e.querySelectorAll('*[name]:not([auto-focus="false"]):not([aria-hidden="true"])')).find((t=>!cc(t,e)));setTimeout((()=>{null==t||t.focus()}))}};function Uc(e,t,i){return new Promise(((n,o)=>{let s=!1;const r=setTimeout((()=>{s=!0,void 0!==i?n(i):o(new Error(`Promise timed out after ${e} ms`))}),e);t.then((e=>{s||(clearTimeout(r),n(e))})).catch((e=>{s||(clearTimeout(r),o(e))}))}))}const Pc=(e,{oidcIdpStateId:t,samlIdpStateId:i,wsfedIdpStateId:n,samlIdpUsername:o,ssoAppId:s,customAppId:r,oidcLoginHint:a,oidcPrompt:l,oidcErrorRedirectUri:c,oidcResource:d,thirdPartyAppId:u,thirdPartyAppStateId:h,applicationScopes:p})=>!(!e||t||i||n||o||s||r||a||l||c||d||u||h||p),_c=(e,t,i)=>{const n=document.createElement("input");return n.type="hidden",n.name=e,n.value=t,i&&n.setAttribute("role",i),n},Lc=e=>null==e?void 0:e.submit(),$c=(e,t)=>{const i=t.find((t=>e[t]));return i?e[i]:null},Nc=(e,t=100)=>{let i;return function(...n){i||e.apply(this,n),clearTimeout(i),i=setTimeout((()=>{i=null}),t)}},Dc={minLength:"data-password-policy-value-minlength",strength:"data-password-policy-value-passwordstrength",disallowedChars:"data-password-policy-value-disallowedchars",email:"data-password-policy-value-email",reuse:"data-password-policy-value-reuse",activePolicies:"active-policies",availablePolicies:"available-policies"},Fc=(e,t)=>{var i;const n=null==e?void 0:e.componentsDynamicAttrs;if(!n)return;const o=Object.entries(n).find((([e])=>(e=>{var t;return null===(t=e.match(/\[data-name=["']([^"']+)["']\]/))||void 0===t?void 0:t[1]})(e)===t));return null===(i=null==o?void 0:o[1])||void 0===i?void 0:i.attributes},qc=[{key:"totp",from:e=>e.totp},{key:"notp",from:e=>e.notp},{key:"sentTo",from:e=>e.sentTo},{key:"sso",from:e=>e.sso},{key:"selfProvisionDomains",from:e=>e.selfProvisionDomains},{key:"inboundAppApproveScopes",from:e=>{var t,i;return null===(i=null===(t=e.componentsConfig)||void 0===t?void 0:t.thirdPartyAppApproveScopes)||void 0===i?void 0:i.data}},{key:"securityQuestionsSetup",from:e=>{var t;return null===(t=e.componentsConfig)||void 0===t?void 0:t.sqSetup}},{key:"securityQuestionsVerify",from:e=>{var t;return null===(t=e.componentsConfig)||void 0===t?void 0:t.sqVerify}},{key:"userTenants",from:e=>{var t,i;return null===(i=null===(t=e.componentsConfig)||void 0===t?void 0:t.userSelectedTenant)||void 0===i?void 0:i.data}},{key:"userRoles",from:e=>{var t,i;return null===(i=null===(t=e.componentsConfig)||void 0===t?void 0:t.userRoles)||void 0===i?void 0:i.data}},{key:"ssoApplications",from:e=>{var t,i;return null===(i=null===(t=e.componentsConfig)||void 0===t?void 0:t.ssoApplications)||void 0===i?void 0:i.data}},{key:"ssoConfigurations",from:e=>{var t,i;return null===(i=null===(t=e.componentsConfig)||void 0===t?void 0:t.ssoConfigurations)||void 0===i?void 0:i.data}},{key:"samlAttributeMappings",from:e=>{var t,i;return null===(i=null===(t=e.componentsConfig)||void 0===t?void 0:t.samlMappings)||void 0===i?void 0:i.options}},{key:"oidcAttributeMappings",from:e=>{var t,i;return null===(i=null===(t=e.componentsConfig)||void 0===t?void 0:t.oidcMappings)||void 0===i?void 0:i.options}},{key:"samlGroupMappings",from:e=>{var t,i;return null===(i=null===(t=e.componentsConfig)||void 0===t?void 0:t.samlGroupMappings)||void 0===i?void 0:i.options}},{key:"passwordPolicy",from:e=>{var t;return(e=>{if(!e)return;const t=Object.fromEntries(Object.entries(Dc).map((([t,i])=>[t,e[i]])).filter((([,e])=>void 0!==e)));return Object.keys(t).length?t:void 0})(null===(t=e.componentsConfig)||void 0===t?void 0:t.newPassword)}},{key:"recoveryCodes",from:e=>(e=>{const t=Fc(e,"recoveryCodes");if(t)return Array.isArray(t.data)?t.data.map((e=>e.value)):[]})(e.componentsConfig)},{key:"outboundApp",from:e=>(e=>{const t=Fc(e,"outboundApp");if(t)return{label:t.label,iconSrc:t["icon-src"],appId:t["data-descope-outbound-oauth-app-id"]}})(e.componentsConfig)}],zc=e=>{const t=Object.assign({},e);return e.inboundAppApproveScopes&&(t.thirdPartyAppApproveScopes=e.inboundAppApproveScopes),t};function Vc(e,t){return`sdkScriptsResults.${t?`${e}_${t}`:e}`}var Jc,Bc,Hc,Kc;function Yc(e,t){const i=Object.getOwnPropertyNames(e),n=Object.getOwnPropertyNames(t);if(i.length!==n.length)return!1;for(let n=0;n<i.length;n+=1){const o=i[n],s=e[o],r=t[o];if(null===s||null===r){if(s!==r)return!1}else if("object"==typeof s&&"object"==typeof r){if(!Yc(s,r))return!1}else if(s!==r)return!1}return!0}let Gc=class{constructor(e={},{forceUpdate:t=!1}={}){Jc.set(this,void 0),Bc.set(this,{}),Hc.set(this,0),Kc.set(this,!0),this.update=e=>{const t="function"==typeof e?e(n(this,Jc,"f")):e,i=Object.assign(Object.assign({},n(this,Jc,"f")),t),s=n(this,Jc,"f");o(this,Jc,i,"f"),Object.freeze(n(this,Jc,"f")),setTimeout((()=>{Object.values(n(this,Bc,"f")).forEach((({cb:e,selector:t,forceUpdate:o})=>{const r=t(s),a=t(i);(n(this,Kc,"f")||o||(function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(a)?!Yc(r,a):r!==a))&&e(a,r,((e,t)=>i=>e[i]!==t[i])(a,r))}))}),0)},o(this,Jc,e,"f"),o(this,Kc,t,"f")}get current(){return Object.assign({},n(this,Jc,"f"))}set forceUpdate(e){o(this,Kc,e,"f")}subscribe(e,t=e=>e,{forceUpdate:i=!1}={}){return o(this,Hc,n(this,Hc,"f")+1,"f"),n(this,Bc,"f")[n(this,Hc,"f")]={cb:e,selector:t,forceUpdate:i},n(this,Hc,"f").toString()}unsubscribe(e){const t=!!n(this,Bc,"f")[e];return t&&delete n(this,Bc,"f")[e],t}unsubscribeAll(){return o(this,Bc,{},"f"),!0}};Jc=new WeakMap,Bc=new WeakMap,Hc=new WeakMap,Kc=new WeakMap;const Zc=["*","#","/","(",")","[","]","_","<",">","`"],Xc=e=>"string"!=typeof e?e:e.replace((e=>{const t=Zc.map((t=>`${e}${t}`)).join("|");return new RegExp(`(${t})`,"g")})("\\"),"\\$1"),Qc=["disabled"],ed=(e,t)=>{Object.entries(t||{}).forEach((([t,i])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${Tl}])`)).forEach((e=>{e.value=i}))}))},td=(e,t)=>t.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),e),id=(e,t,i)=>e.replace(/{{(.+?)}}/g,((e,n)=>i?Xc(td(t,n)):td(t,n))),nd=(e,t,i)=>{e.querySelectorAll(`[${Yl}="${t}"]`).forEach((e=>{e.setAttribute("href",i)}))},od=(e,t,i)=>{var n,o;const s=null===(n=customElements.get(t))||void 0===n?void 0:n.cssVarList.url;i&&s&&(null===(o=null==e?void 0:e.style)||void 0===o||o.setProperty(s,`url(data:image/jpg;base64,${i})`))},sd=(e,i,n,o)=>{var s,r;nd(e,"totp-link",null===(s=null==i?void 0:i.totp)||void 0===s?void 0:s.provisionUrl),nd(e,"notp-link",null===(r=null==i?void 0:i.notp)||void 0===r?void 0:r.redirectUrl),((e,t)=>{e.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((e=>{const i=(e=>Sc.includes(e))(e.localName);e.textContent=id(e.textContent,t,i);const n=e.getAttribute("href");n&&e.setAttribute("href",id(n,t))}))})(e,i),((e,i,n)=>{if(!i)return;const{componentsDynamicAttrs:o}=i,s=t(i,["componentsDynamicAttrs"]),r=Object.keys(s).reduce(((e,t)=>(e[`[name=${t}]`]=s[t],e)),{});o&&Object.keys(o).forEach((e=>{const t=o[e];if(t){const{attributes:i}=t;i&&Object.keys(i).length&&(r[e]=i)}})),Object.keys(r).forEach((t=>{e.querySelectorAll(t).forEach((e=>{const i=r[t];Object.keys(i).forEach((t=>{let o=i[t];if("string"!=typeof o)try{o=JSON.stringify(o)}catch(e){n.error(`Could not stringify value "${o}" for "${t}"`,e.message),o=""}e.setAttribute(t,o)}))}))}))})(e,null==i?void 0:i.componentsConfig,o),((e,t)=>{e.querySelectorAll("[data-has-dynamic-attr-values]").forEach((e=>{Array.from(e.attributes).forEach((e=>{e.value=id(e.value,t)}))}))})(e,i),((e,t)=>{Object.entries(t).forEach((([t,i])=>{e.querySelectorAll(`[name="${t}"]`).forEach((e=>{Object.entries(i).forEach((([t,i])=>{Qc.includes(t)&&e.setAttribute(t,i)}))}))}))})(e,n)},rd=Mc((()=>i(void 0,void 0,void 0,(function*(){var e,t;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const i=Promise.all([null===(e=window.PublicKeyCredential)||void 0===e?void 0:e.isConditionalMediationAvailable(),null===(t=window.PublicKeyCredential)||void 0===t?void 0:t.isUserVerifyingPlatformAuthenticatorAvailable()]).then((e=>e.every((e=>!!e)))),n=(()=>{var e;const t=null===(e=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===e?void 0:e.brands,i=null==t?void 0:t.find((({brand:e,version:t})=>"Chromium"===e&&parseFloat(t)));return i?i.version:0})()>=108;return yield Uc(100,i,n)}catch(e){return console.error("Conditional login check failed",e),!1}}))));let ad;const ld=(e,t)=>{ad?ad.setItem(e,t):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.setItem(e,t)},cd=e=>ad?ad.getItem(e):void 0!==(null===window||void 0===window?void 0:window.localStorage)?window.localStorage.getItem(e):null,dd="dls_ab_testing_id",ud={"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[i,n]=t?t.split(",").map(Number):[void 0,void 0];return(e.abTestingKey||0)>=(null!=i?i:0)&&(e.abTestingKey||0)<=(null!=n?n:0)},"not-in-range":(e,t)=>{const[i,n]=t?t.split(",").map(Number):[void 0,void 0];return!(void 0!==i&&void 0!==n&&!Number.isNaN(i)&&!Number.isNaN(n))||(e.abTestingKey||0)<i||(e.abTestingKey||0)>n},"devised-by":(e,t)=>{const i=Number(t);return!Number.isNaN(i)&&(e.abTestingKey||0)%i==0}}};function hd(e,t){const i={};try{Object.assign(i,JSON.parse(cd(Wl)))}catch(e){null==t||t.warn("[Descope] Failed to read last auth from storage",String(e))}return i.loginId||e?i:{}}function pd(e,t){(null==e?void 0:e.authMethod)&&(t&&!e.loginId||ld(Wl,JSON.stringify(e)))}function fd(){try{return JSON.parse(cd(sc)||"{}")}catch(e){return{}}}function gd(e){try{(e=>{ad?ad.removeItem(e):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.removeItem(e)})(sc)}catch(t){null==e||e.warn("[Descope] Failed to clear in-flight last auth storage",String(t))}}const vd=(e,t="")=>Object.keys(e).reduce(((i,n)=>{var o;if(Array.isArray(e[n]))return Object.assign(Object.assign({},i),{[n]:{value:e[n].map((e=>"object"==typeof e&&null!==e?vd(e):e))}});if("object"==typeof e[n]&&null!==e[n]&&!(null===(o=e[n])||void 0===o?void 0:o.value))return Object.assign(Object.assign({},i),vd(e[n],`${t+n}.`));const s="object"==typeof e[n]?e[n]:{value:e[n]},r=Object.assign(Object.assign({},i),{[t+n]:s,[`form.${t}${n}`]:s});return"displayName"===n?Object.assign(Object.assign({},r),{[`${t}fullName`]:s,[`form.${t}fullName`]:s}):r}),[]),md=c((e=>{var t,i,o,s;return s=class extends e{constructor(){super(...arguments),t.add(this)}connectedCallback(){var e;n(this,t,"m",i).call(this)&&n(this,t,"m",o).call(this),null===(e=super.connectedCallback)||void 0===e||e.call(this)}},t=new WeakSet,i=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)},s})),wd=["input","change"];function bd(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 yd(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 kd(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 Sd(e){return Array.isArray(e)?e:"string"==typeof e?e.split(","):null}function Id(e){return null==e||("string"==typeof e?""===e:Array.isArray(e)?0===e.length:"object"==typeof e&&0===Object.keys(e).length)}const Cd=new Map,Ed={equal:(e,t)=>e===t||yd(e)===yd(t),"not-equal":(e,t)=>e!==t&&yd(e)!==yd(t),contains:(e,t)=>Array.isArray(e)?e.includes(t):"string"==typeof e&&e.includes(yd(t)),"doesnt-contains":(e,t)=>Array.isArray(e)?!e.includes(t):"string"==typeof e&&!e.includes(yd(t)),"greater-than":(e,t)=>{const i=bd(e),n=bd(t);return i.ok&&n.ok&&i.value>n.value},"greater-than-or-equal":(e,t)=>{const i=bd(e),n=bd(t);return i.ok&&n.ok&&i.value>=n.value},"less-than":(e,t)=>{const i=bd(e),n=bd(t);return i.ok&&n.ok&&i.value<n.value},"less-than-or-equal":(e,t)=>{const i=bd(e),n=bd(t);return i.ok&&n.ok&&i.value<=n.value},empty:e=>Id(e),"not-empty":e=>!Id(e),"is-true":e=>{const t=kd(e);return t.ok&&t.value},"is-false":e=>{const t=kd(e);return t.ok&&!t.value},in:(e,t)=>{const i=Sd(t);return null!==i&&i.includes(e)},"not-in":(e,t)=>{const i=Sd(t);return null!==i&&!i.includes(e)},matches:(e,t)=>{if("string"!=typeof e)return!1;const i=function(e){var t;if(Cd.has(e))return null!==(t=Cd.get(e))&&void 0!==t?t:null;let i;try{i=new RegExp(e)}catch(e){i=null}return Cd.set(e,i),i}(yd(t));return null!==i&&i.test(e)}};function Ad(e,t){var i;if(e)return"form"===e.kind&&e.form?t[e.form]:"list"===e.kind?(null!==(i=e.items)&&void 0!==i?i:[]).map((e=>Ad(e,t))):e.value}function xd(e,t){const i=Ed[e.operator];return!!i&&i(Ad(e.target,t),Ad(e.predicate,t))}function Od(e,t){const i={};return(null!=e?e:[]).forEach((e=>{var n;(function(e,t){var i;return(null!==(i=e.rules)&&void 0!==i?i:[]).some((e=>function(e,t){var i;const n=null!==(i=e.atomicConditions)&&void 0!==i?i:[];return!!n.length&&(e.logicalOr?n.some((e=>xd(e,t))):n.every((e=>xd(e,t))))}(e,t)))})(e,t)&&(null!==(n=e.componentIds)&&void 0!==n?n:[]).forEach((t=>{i[t]=e.action}))})),i}const jd="component-conditions:";function Rd(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 Td(e,t){const i=Object.keys(e),n=Object.keys(t);return i.length===n.length&&i.every((i=>e[i]===t[i]))}function Md(){return{conditions:[],touchedIds:new Set,snapshot:{},applied:{},serverBaseline:{},debounceTimer:null,paused:!1,unsubscribePauseListener:null,inputHandler:()=>{},root:null}}function Wd(e,t,i){const n={};return i.forEach((i=>{e[i]?n[i]=e[i]:t[i]&&(n[i]=t[i])})),n}const Ud=c((e=>{var t,i,r,a,l,c;const d=s(y)(e);return c=class extends d{constructor(){super(...arguments),t.add(this),i.set(this,Md())}applyComponentsState(e,t){t&&(Object.entries(t).forEach((([e,t])=>{ac.includes(t)||this.logger.error(`Unknown component action "${t}" for component with id "${e}"`,`Valid actions are ${ac.map((e=>`"${e}"`)).join(", ")}`)})),pc(e,{},t))}initRealtimeConditions(e,s){var a,c,d,u;n(this,t,"m",l).call(this);const h=null!==(a=null==s?void 0:s.realtimeComponentsConditions)&&void 0!==a?a:[];if(!h.length)return void this.logger.debug(`${jd} no real-time rules to apply on this screen`);this.logger.info(`${jd} found ${h.length} real-time rule(s) for this screen`);const p={};Object.entries(null!==(c=null==s?void 0:s.form)&&void 0!==c?c:{}).forEach((([e,t])=>{p[`form.${e}`]=t})),function(e){const t=new Set,i=e=>{var n;e&&("form"===e.kind&&e.form?t.add(e.form):"list"===e.kind&&(null!==(n=e.items)&&void 0!==n?n:[]).forEach(i))};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=>{i(e.target),i(e.predicate)}))}))})),t}(h).forEach((t=>{const i=function(e,t){const i=t.startsWith("form.")?t.slice(5):t;return e.querySelector(`[name="${uc(t)}"]`)||e.querySelector(`[name="${uc(i)}"]`)}(e,t);if(!i)return;const n=Rd(i);void 0!==n&&(p[t]=n)}));const f=function(e){const t=new Set;return(null!=e?e:[]).forEach((e=>{var i;(null!==(i=e.componentIds)&&void 0!==i?i:[]).forEach((e=>t.add(e)))})),t}(h),g={},v={};Object.entries(null!==(d=null==s?void 0:s.componentsState)&&void 0!==d?d:{}).forEach((([e,t])=>{f.has(e)&&(v[e]=t)})),Object.entries(null!==(u=null==s?void 0:s.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=Wd(Od(h,p),g,f);Td(v,w)||(m.applied=pc(e,v,w)),m.inputHandler=e=>n(this,t,"m",r).call(this,e),wd.forEach((t=>{e.addEventListener(t,m.inputHandler,!0)})),this.logger.debug(`${jd} listening for "${wd.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,i,m,"f")}disconnectedCallback(){var e;null===(e=super.disconnectedCallback)||void 0===e||e.call(this),n(this,t,"m",l).call(this)}},i=new WeakMap,t=new WeakSet,r=function(e){var o,s;const r=n(this,i,"f");if(!r.root||r.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===(s=l.getAttribute)||void 0===s?void 0:s.call(l,"name");if(!c)return;const d=function(e){return e.startsWith("form.")?e:`form.${e}`}(c);r.snapshot[d]=Rd(l),r.debounceTimer&&clearTimeout(r.debounceTimer),r.debounceTimer=setTimeout((()=>{r.debounceTimer=null,n(this,t,"m",a).call(this)}),50)},a=function(){const e=n(this,i,"f");if(!e.root)return;let t;try{t=Wd(Od(e.conditions,e.snapshot),e.serverBaseline,e.touchedIds)}catch(e){return void this.logger.error(`${jd} failed to evaluate real-time rules — keeping the previous state`,null==e?void 0:e.message)}const o=e.applied;Td(o,t)||(this.logger.debug(`${jd} form changed — updating components: was ${JSON.stringify(o)}, now ${JSON.stringify(t)}`),e.applied=pc(e.root,o,t))},l=function(){const e=n(this,i,"f");e.debounceTimer&&clearTimeout(e.debounceTimer),e.unsubscribePauseListener&&e.unsubscribePauseListener(),e.root&&wd.forEach((t=>{e.root.removeEventListener(t,e.inputHandler,!0)})),o(this,i,Md(),"f")},c})),Pd="project-id",_d="flow-id",Ld=e=>{const t=(e=>{const t=e.getAttribute(Pd),i=e.getAttribute(_d);return t&&i?Array.from(e.ownerDocument.querySelectorAll("descope-wc")).filter((e=>e.getAttribute(Pd)===t&&e.getAttribute(_d)===i)):[]})(e);return t.length>1&&t[0]!==e},$d=c((e=>{var t,i,r,a;const l=s(y)(e);return a=class extends l{constructor(){super(...arguments),t.add(this),i.set(this,void 0)}connectedCallback(){var e;null===(e=super.connectedCallback)||void 0===e||e.call(this),n(this,t,"m",r).call(this)}attributeChangedCallback(e,i,o){var s;null===(s=super.attributeChangedCallback)||void 0===s||s.call(this,e,i,o),i===o||e!==Pd&&e!==_d||n(this,t,"m",r).call(this)}},i=new WeakMap,t=new WeakSet,r=function(){queueMicrotask((()=>{if(!this.isConnected)return;const e=this.getAttribute(Pd),t=this.getAttribute(_d),s=`${e}|${t}`;n(this,i,"f")!==s&&Ld(this)&&(o(this,i,s,"f"),this.logger.warn("Multiple Descope flow components detected on the same page",`The same flow ("${t}") and project ("${e}") are running more than once on this page. This is not supported and may cause the flow to behave unexpectedly.`))}))},a})),Nd=["externalId","email","phone"],Dd=["newPassword","password"],Fd="data-username-anchor",qd=e=>{var t;if(!e)return"";try{const i=null===(t=window.sessionStorage)||void 0===t?void 0:t.getItem(Ul);if(!i)return"";const n=JSON.parse(i);return n.executionId===e&&n.loginId||""}catch(e){return""}},zd=c((e=>{var t,i,r,a,l;const c=s(y)(e);return l=class extends c{constructor(){super(...arguments),t.add(this),i.set(this,void 0)}updateScreenUser(e){var s,l,c;o(this,i,{email:null==e?void 0:e.email,loginIds:(null===(s=null==e?void 0:e.loginIds)||void 0===s?void 0:s.length)?e.loginIds:[qd(n(this,t,"a",a))||(null===(c=null===(l=n(this,t,"a",r).sdk)||void 0===l?void 0:l.getLastUserLoginId)||void 0===c?void 0:c.call(l))].filter(Boolean)},"f")}updateUsernameAnchor(){document.querySelectorAll(`[${Fd}="true"]`).forEach((e=>e.remove())),((e,t,i,n)=>{var o;const s=(null==i?void 0:i.email)||(null===(o=null==i?void 0:i.loginIds)||void 0===o?void 0:o[0]);(e=>e.querySelector("descope-new-password")||e.querySelector("descope-password"))(t)?s?(e=>{const t=['input[autocomplete="username"]',...Nd.map((e=>`[name="${e}"]`))].join(", ");return e.some((e=>e.querySelector(t)))})([e,t])?n.debug("Username anchor: screen already has an identifier field"):(n.debug("Username anchor: injecting hidden username input"),e.appendChild((e=>{const t=document.createElement("input");return t.setAttribute("autocomplete","username"),t.setAttribute("name","username"),t.setAttribute("type","email"),t.setAttribute("readonly","true"),t.setAttribute("tabindex","-1"),t.setAttribute("aria-hidden","true"),t.setAttribute(Tl,"true"),t.setAttribute(Fd,"true"),t.setAttribute("value",e),t.value=e,Object.assign(t.style,{position:"absolute",opacity:"0",pointerEvents:"none",height:"0",border:"0"}),t})(s))):n.debug("Username anchor: no user identifier available"):n.debug("Username anchor: no password component on screen")})(this,n(this,t,"a",r).contentRootElement,n(this,i,"f"),this.logger)}captureLastSubmittedLoginId(e={},i){const o=$c(e,Nd);o&&((e,t)=>{var i;if(e&&t)try{null===(i=window.sessionStorage)||void 0===i||i.setItem(Ul,JSON.stringify({executionId:t,loginId:e}))}catch(e){}})(o,i||n(this,t,"a",a))}storeCredentials(e={}){var t,o,s,r,a,l;const c=$c(e,Nd)||(null===(t=n(this,i,"f"))||void 0===t?void 0:t.email)||(null===(s=null===(o=n(this,i,"f"))||void 0===o?void 0:o.loginIds)||void 0===s?void 0:s[0]),d=$c(e,Dd);if(c&&d)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:c,password:d});null===(l=null===(a=null===(r=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===r?void 0:r.store)||void 0===a?void 0:a.call(r,e))||void 0===l||l.catch((e=>{this.logger.debug("Could not store credentials",null==e?void 0:e.message)}))}catch(e){this.logger.warn("Could not store credentials",e.message)}}},i=new WeakMap,t=new WeakSet,r=function(){return this},a=function(){var e,i;return(null===(i=null===(e=n(this,t,"a",r).flowState)||void 0===e?void 0:e.current)||void 0===i?void 0:i.executionId)||""},l})),Vd=e=>`${e.screenId}|${e.field}|${e.rule}`,Jd=()=>{try{return crypto.randomUUID()}catch(e){return`${Date.now()}-${Math.round(1e9*Math.random())}`}},Bd=(e,t)=>e?e.badInput?"bad-input":e.valueMissing?"required":e.typeMismatch?"email"===t||"url"===t?t:"type-mismatch":e.patternMismatch?"pattern":e.tooShort?"too-short":e.tooLong?"too-long":e.rangeUnderflow||e.rangeOverflow||e.stepMismatch?"range":e.customError?"custom":"unknown":"unknown",Hd=c((e=>{var t,i,r,a,l,c,d,u,h,p,f,g,v,m,w,b,k,S,I,C;const E=s(y)(e);return C=class extends E{constructor(){super(...arguments),t.add(this),i.set(this,[]),r.set(this,void 0),a.set(this,void 0),l.set(this,new Set),c.set(this,!1),d.set(this,0),u.set(this,void 0),h.set(this,!1),p.set(this,(()=>n(this,t,"m",b).call(this,!1))),f.set(this,(()=>{"hidden"===document.visibilityState&&n(this,t,"m",b).call(this,!0)})),g.set(this,(()=>n(this,t,"m",b).call(this,!0)))}setValidationTrackingEnabled(e){n(this,h,"f")!==e&&(o(this,h,e,"f"),e||n(this,t,"m",w).call(this))}setValidationTrackingSender(e){o(this,u,e,"f")}setValidationTrackingExecution(e){n(this,h,"f")&&e&&n(this,i,"f").length&&(o(this,r,e,"f"),n(this,t,"m",b).call(this,!1))}trackValidationErrors(e,i){var o,s;try{n(this,t,"m",v).call(this,e,i)}catch(e){null===(s=null===(o=this.logger)||void 0===o?void 0:o.debug)||void 0===s||s.call(o,"Failed to track validation errors",String(e))}}teardownValidationTracking(){n(this,t,"m",b).call(this,!1),o(this,d,n(this,d,"f")+1,"f"),n(this,l,"f").forEach(clearTimeout),n(this,l,"f").clear(),n(this,c,"f")&&(o(this,c,!1,"f"),this.removeEventListener("screen-updated",n(this,p,"f")),this.removeEventListener("success",n(this,p,"f")),this.removeEventListener("error",n(this,p,"f")),document.removeEventListener("visibilitychange",n(this,f,"f")),window.removeEventListener("pagehide",n(this,g,"f")))}},i=new WeakMap,r=new WeakMap,a=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,u=new WeakMap,h=new WeakMap,p=new WeakMap,f=new WeakMap,g=new WeakMap,t=new WeakSet,v=function(e,s){if(!n(this,h,"f")||!(null==e?void 0:e.length))return;const a=s||{};n(this,t,"m",I).call(this),e.forEach((e=>{if(n(this,i,"f").length>=20)return;const s=((e,t)=>{var i;const n=null===(i=null==e?void 0:e.getAttribute)||void 0===i?void 0:i.call(e,"name");return n?{id:Jd(),field:n,rule:Bd(e.validity,e.type),message:e.validationMessage||"",screenId:t.screenId||"",screenName:t.screenName||"",ts:Date.now()}:null})(e,a);if(!s)return;const l=Vd(s);n(this,i,"f").some((e=>Vd(e)===l))||(n(this,i,"f").push(s),o(this,r,a.executionId||n(this,r,"f"),"f"),n(this,i,"f").length>=20&&n(this,t,"m",b).call(this,!1))})),n(this,i,"f").length>=20?n(this,t,"m",b).call(this,!1):n(this,t,"m",m).call(this)},m=function(){clearTimeout(n(this,a,"f")),o(this,a,setTimeout((()=>n(this,t,"m",b).call(this,!1)),2e3),"f")},w=function(){clearTimeout(n(this,a,"f")),o(this,d,n(this,d,"f")+1,"f"),n(this,l,"f").forEach(clearTimeout),n(this,l,"f").clear(),o(this,i,[],"f"),o(this,r,void 0,"f")},b=function(e){var s,l;if(clearTimeout(n(this,a,"f")),!n(this,i,"f").length)return void o(this,r,void 0,"f");if(!n(this,r,"f"))return;if(!n(this,u,"f"))return;const c=n(this,i,"f"),h=n(this,r,"f");o(this,i,[],"f"),o(this,r,void 0,"f");try{const i={executionId:h,events:c};e?n(this,u,"f").call(this,i,{keepalive:!0}).catch((()=>{})):n(this,t,"m",k).call(this,i,2,n(this,d,"f"))}catch(e){null===(l=null===(s=this.logger)||void 0===s?void 0:s.debug)||void 0===l||l.call(s,"Failed to send validation events",String(e))}},k=function(e,i,o){n(this,u,"f").call(this,e,{keepalive:!1}).then((s=>{!s.ok&&s.retryable&&i>0&&n(this,t,"m",S).call(this,e,i,o)})).catch((()=>{i>0&&n(this,t,"m",S).call(this,e,i,o)}))},S=function(e,i,o){if(o!==n(this,d,"f"))return;const s=setTimeout((()=>{n(this,l,"f").delete(s),o===n(this,d,"f")&&n(this,t,"m",k).call(this,e,i-1,o)}),800*(2-i+1));n(this,l,"f").add(s)},I=function(){n(this,c,"f")||(o(this,c,!0,"f"),this.addEventListener("screen-updated",n(this,p,"f")),this.addEventListener("success",n(this,p,"f")),this.addEventListener("error",n(this,p,"f")),document.addEventListener("visibilitychange",n(this,f,"f")),window.addEventListener("pagehide",n(this,g,"f")))},C}));var Kd,Yd,Gd,Zd,Xd,Qd,eu,tu,iu,nu,ou,su,ru,au,lu,cu,du,uu,hu,pu,fu,gu,vu,mu,wu,bu;const yu=s(xe,W,md,Ud,$d,zd,H,Li,Hd)(HTMLElement);let ku=class extends yu{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","send-session-token","style-id"]}constructor(e){super(),Kd.add(this),this.sdkVersion="4.6.1",Gd.set(this,!1),Zd.set(this,void 0),this.flowStatus="initial",this.loggerWrapper={error:(e,t="")=>{this.logger.error(e,t,new Error),n(this,Kd,"m",bu).call(this,e,t)},warn:(e,t="")=>{this.logger.warn(e,t)},info:(e,t="",i={})=>{this.logger.info(e,t,i)},debug:(e,t="")=>{this.logger.debug(e,t)}},Xd.set(this,new Gc),Qd.set(this,new Gc),eu.set(this,{}),this.getComponentsContext=()=>n(this,eu,"f"),this.nextRequestStatus=new Gc({isLoading:!1}),tu.set(this,void 0),iu.set(this,{popstate:n(this,Kd,"m",au).bind(this),componentsContext:n(this,Kd,"m",pu).bind(this)}),nu.set(this,void 0),this.getConfig=()=>i(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),fu.set(this,void 0),gu.set(this,void 0),o(this,nu,e,"f"),n(this,Kd,"m",su).call(this)}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 sendSessionToken(){return"true"===this.getAttribute("send-session-token")}get preview(){return!!this.getAttribute("preview")}get formConfig(){return(e=>{try{return vd(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,i])=>[e,i[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 n(this,Zd,"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,Zd,e,"f"),(e=>{ad=e})(e)}get lazyStart(){return"true"===this.getAttribute("lazy-start")}start(){var e;null===(e=n(this,gu,"f"))||void 0===e||e.call(this),o(this,fu,Promise.resolve(),"f")}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return i(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"executionContext"in e?e.executionContext:void 0}))}getProjectConfig(){return i(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"projectConfig"in e?e.projectConfig:void 0}))}getFlowConfig(){return i(this,void 0,void 0,(function*(){var e,t;const i=yield this.getProjectConfig(),n=(null===(e=null==i?void 0:i.flows)||void 0===e?void 0:e[this.flowId])||{};return null!==(t=n.version)&&void 0!==t||(n.version=0),n}))}getTargetLocales(){return i(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,i,n;const o=!!(null===(t=this.shadowRoot.activeElement)||void 0===t?void 0:t.getAttribute("href")),s=oc.includes(null!==(n=null===(i=this.shadowRoot.activeElement)||void 0===i?void 0:i.localName)&&void 0!==n?n:"");if("Enter"!==e.key||o||s)return;e.preventDefault();const r=this.rootElement.querySelectorAll("descope-button");if(1===r.length&&"false"!==r[0].getAttribute("auto-submit"))return void r[0].click();const a=Array.from(r).filter((e=>"true"===e.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const l=Array.from(r).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(r).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 i(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 i(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),n(this,Qd,"f").subscribe(n(this,Kd,"m",wu).bind(this)),n(this,Qd,"f").update({isDebug:this.debug}),n(this,Kd,"m",ru).call(this),yield n(this,Kd,"m",uu).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 i=yield this.getConfig();if("isMissingConfig"in i&&i.isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");const{executionId:s,stepId:r,token:a,code:l,isPopup:c,exchangeError:d,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthCodeChallenge:p,redirectAuthInitiator:f,ssoQueryParams:g}=Tc(this.flowId,this.projectId,this.loggerWrapper);window.addEventListener("popstate",n(this,iu,"f").popstate),window.addEventListener("components-context",n(this,iu,"f").componentsContext),n(this,Xd,"f").subscribe(n(this,Kd,"m",du).bind(this)),n(this,Xd,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenantId,redirectUrl:this.redirectUrl,locale:this.locale,stepId:r,executionId:s,token:a,code:l,isPopup:c,exchangeError:d,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthCodeChallenge:p,redirectAuthInitiator:f},g)),o(this,Gd,!0,"f")}))}disconnectedCallback(){var e;n(this,Xd,"f").unsubscribeAll(),n(this,Qd,"f").unsubscribeAll(),n(this,Kd,"m",mu).call(this),window.removeEventListener("popstate",n(this,iu,"f").popstate),window.removeEventListener("components-context",n(this,iu,"f").componentsContext),null===(e=super.disconnectedCallback)||void 0===e||e.call(this)}attributeChangedCallback(e,t,i){var o;if(null===(o=super.attributeChangedCallback)||void 0===o||o.call(this,e,t,i),this.shadowRoot.isConnected&&n(this,Gd,"f")&&t!==i&&Yd.observedAttributes.includes(e)){n(this,Kd,"m",ru).call(this);const o=null===t;n(this,Xd,"f").update((({stepId:t,executionId:n})=>{let s=t,r=n;return o||(r=null,s=null,xc()),{[Rc(e)]:i,stepId:s,executionId:r}})),n(this,Qd,"f").update({isDebug:this.debug})}}};var Su,Iu,Cu,Eu,Au,xu,Ou,ju,Ru,Tu,Mu,Wu,Uu,Pu,_u,Lu,$u,Nu,Du,Fu,qu,zu,Vu,Ju,Bu,Hu,Ku,Yu,Gu,Zu,Xu,Qu,eh,th,ih,nh,oh,sh,rh,ah,lh,ch,dh,uh,hh,ph;Yd=ku,Gd=new WeakMap,Zd=new WeakMap,Xd=new WeakMap,Qd=new WeakMap,eu=new WeakMap,tu=new WeakMap,iu=new WeakMap,nu=new WeakMap,fu=new WeakMap,gu=new WeakMap,Kd=new WeakSet,ou=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 ")},su=function(){n(this,Kd,"m",ou).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},ru=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","send-session-token","style-id","outbound-app-id","outbound-app-scopes","theme-override"];Yd.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[Rc(t)])throw Error(`${t} cannot be empty`)}))},au=function(){const{stepId:e,executionId:t}=Ac(this.flowId);n(this,Xd,"f").update({stepId:e,executionId:t})},lu=function(e,t){ra&&"function"==typeof ra||this.logger.error("SDK was not loaded properly",ra,JSON.stringify(ra));const o=Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},Yd.sdkConfigOverrides),{projectId:e,baseUrl:t});n(this,Zd,"f")&&(o.customStorage=n(this,Zd,"f")),this.sdk=ra(o);const s={start:1,next:7};["start","next"].forEach((e=>{const t=function(e,t,n){return(...o)=>i(this,void 0,void 0,(function*(){let i;const s=n+1;for(let r=0;r<s;r++)try{return yield e(...o)}catch(e){i=e,r<n&&(yield new Promise((e=>{setTimeout(e,t*Math.pow(2,r+1))})))}throw i}))}(this.sdk.flow[e],1e3,3);this.sdk.flow[e]=(...o)=>i(this,void 0,void 0,(function*(){const i=[...o],r=s[e],a=n(this,Kd,"m",cu).call(this,i[r]);void 0!==a&&(i[r]=a);try{return yield t(...i)}catch(t){return this.logger.error(`Error in sdk flow ${e} function`,t),{error:{errorCode:Sl,errorDescription:t.toString()}}}}))}));const r=this.sdk.flow.start;this.sdk.flow.start=(...e)=>i(this,void 0,void 0,(function*(){return yield n(this,Kd,"m",vu).call(this),r.apply(this.sdk.flow,e)}))},cu=function(e){if(!this.sendSessionToken)return e;const t=null==pr?void 0:pr(this.storagePrefix);return t?Object.assign(Object.assign({},null!=e?e:{}),{sessionJwt:t}):e},du=function(e,t,o){return i(this,void 0,void 0,(function*(){const{projectId:t,baseUrl:i}=e;if(o("projectId")||o("baseUrl")){if(!t)return;n(this,Kd,"m",lu).call(this,t,i)}n(this,nu,"f").call(this,e)}))},uu=function(){return i(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield n(this,Kd,"m",hu).call(this))}))},hu=function(){return i(this,void 0,void 0,(function*(){const e=function({projectId:e,filename:t,assetsFolder:i="v2-beta",baseUrl:n}){const o=new URL(El||n||"https://static.descope.com/pages");return o.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(o.pathname,e,i,t),o.toString()}({projectId:this.projectId,filename:"config.json",assetsFolder:"v2-alpha",baseUrl:this.baseStaticUrl});try{return yield function(e,t){return i(this,void 0,void 0,(function*(){const i=yield fetch(e,{cache:"default"});if(!i.ok)throw Error(`Error fetching URL ${e} [${i.status}]`);return{body:yield i[t](),headers:Object.fromEntries(i.headers.entries())}}))}(e,"json"),!0}catch(e){return!1}}))},pu=function(e){o(this,eu,Object.assign(Object.assign({},n(this,eu,"f")),e.detail),"f")},vu=function(){return this.lazyStart?(n(this,fu,"f")||o(this,fu,new Promise((e=>{o(this,gu,e,"f")})),"f"),n(this,fu,"f")):Promise.resolve()},mu=function(){var e;null===(e=n(this,tu,"f"))||void 0===e||e.remove(),o(this,tu,null,"f")},wu=function(e){return i(this,arguments,void 0,(function*({isDebug:e}){e?(o(this,tu,document.createElement("descope-debugger"),"f"),Object.assign(n(this,tu,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return Kh})),document.body.appendChild(n(this,tu,"f"))):n(this,Kd,"m",mu).call(this)}))},bu=function(e,t){var i;e&&this.debug&&(null===(i=n(this,tu,"f"))||void 0===i||i.updateData({title:e,description:t}))},ku.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"4.6.1"}};const fh="__descope_webauthn_timed_out__";class gh extends ku{static set sdkConfigOverrides(e){ku.sdkConfigOverrides=e}static get sdkConfigOverrides(){return ku.sdkConfigOverrides}constructor(){const e=new Gc({deferredRedirect:!1,deferredPolling:!1});super(e.update.bind(e)),Su.add(this),this.stepState=new Gc({}),Iu.set(this,void 0),Cu.set(this,null),Eu.set(this,null),Au.set(this,{visibilitychange:n(this,Su,"m",xu).bind(this)}),this.bridgeVersion=gh.bridgeVersion,Ou.set(this,void 0),this.nativeCallbacks={},_u.set(this,!1),this.handleRedirect=e=>{window.location.assign(e)},Nu.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()?n(this,Su,"m",Du).call(this,t):t()})),Fu.set(this,((e,t,s,r,a=!1)=>{const l=[Il,"E103202",Cl];if(this.flowState.current.action===Zl){if(n(this,zu,"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,Iu,setTimeout((()=>i(this,void 0,void 0,(function*(){var i,o;this.logger.debug("polling - Calling next");const u=this.sdk.flow.next(e,t,nc,s,r,{}),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 Uc(e,u)}catch(i){return this.logger.warn(`polling - The ${h?"throttled fetch":"fetch"} call timed out or was aborted`),void n(this,Fu,"f").call(this,e,t,s,r,h)}if((null===(i=null==p?void 0:p.error)||void 0===i?void 0:i.errorCode)===Sl)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void n(this,Fu,"f").call(this,e,t,s,r);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"):n(this,Fu,"f").call(this,e,t,s,r),n(this,Vu,"f").call(this,p)}))),d),"f")}})),qu.set(this,(()=>{clearTimeout(n(this,Iu,"f")),o(this,Iu,null,"f")})),zu.set(this,(()=>!!window.descopeBridge||/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))),Vu.set(this,(e=>{var t,i,s,r,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===(i=null==e?void 0:e.response)||void 0===i?void 0:i.status} - ${null===(s=null==e?void 0:e.response)||void 0===s?void 0:s.statusText}`;n(this,Su,"m",hh).call(this,"error",(null==e?void 0:e.error)||{errorCode:"J151001",errorDescription:c,errorMessage:o}),this.loggerWrapper.error((null===(r=null==e?void 0:e.error)||void 0===r?void 0:r.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!==Il&&d!==Cl||!this.isRestartOnError||n(this,Su,"m",Pu).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:i,log:n}=e;t&&this.loggerWrapper[t]?this.loggerWrapper[t](i,n):this.loggerWrapper.info(i,n)}));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!==Zl&&n(this,qu,"f").call(this),"completed"===m){this.storeLastAuthenticatedUser&&pd(Object.assign(Object.assign({},b),{lastUsedPerScreen:fd()})),gd(this.loggerWrapper);const t=Object.assign({},w);return e.data.output&&Object.keys(e.data.output).length>0&&(t.flowOutput=e.data.output),this.setValidationTrackingExecution(e.data.executionId),((e,t)=>{kc(e,t)})(this.projectId,this.flowId),void n(this,Su,"m",hh).call(this,"success",t)}this.storeLastAuthenticatedUser&&pd(b,!0),k&&window.open(k,"_blank");const{executionId:S,stepId:I,stepName:C,screen:E,redirect:A,webauthn:x,error:O,samlIdpResponse:j,wsFedIdpResponse:R,nativeResponse:T}=e.data,M=Date.now();y!==Zl?(this.loggerWrapper.info(`Step "${C||`#${I}`}" is ${m}`,"",{screen:E,status:m,stepId:I,stepName:C,action:y,error:O}),(null===(g=E.state)||void 0===g?void 0:g.clientScripts)&&o(this,Eu,this.loadSdkScripts(E.state.clientScripts),"f"),this.flowState.update({stepId:I,stepName:C,executionId:S,action:y,redirectTo:null==A?void 0:A.url,redirectIsPopup:null==A?void 0:A.isPopup,screenId:null==E?void 0:E.id,screenState:null==E?void 0:E.state,webauthnTransactionId:null==x?void 0:x.transactionId,webauthnOptions:null==x?void 0:x.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})})),Ju.set(this,Mc((()=>i(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)}}))))),Yu.set(this,void 0),Gu.set(this,void 0),ih.set(this,null),rh.set(this,Nc(((e,t,o)=>i(this,void 0,void 0,(function*(){var i;if("true"!==e.getAttribute("loading")&&"true"!==e.getAttribute("disabled")){if("true"===e.getAttribute("formnovalidate")||n(this,Su,"m",eh).call(this)){const s=null==e?void 0:e.getAttribute("id");n(this,Su,"m",ch).call(this,e,s,o);const r=n(this,Su,"m",nh).call(this,e);try{const o=yield n(this,Su,"m",th).call(this),r=(e=>Array.from((null==e?void 0:e.attributes)||[]).reduce(((e,t)=>{var i;const n=null===(i=new RegExp("^data-descope-(\\S+)$").exec(t.name))||void 0===i?void 0:i[1];return n?Object.assign(e,{[n]:t.value}):e}),{}))(e);this.nextRequestStatus.update({isLoading:!0});const a=Object.assign(Object.assign(Object.assign({},r),o),{origin:n(this,Su,"a",Qu)}),l=yield t(s,a);this.nextRequestStatus.update({isLoading:!1}),this.captureLastSubmittedLoginId(o,null===(i=null==l?void 0:l.data)||void 0===i?void 0:i.executionId),this.storeCredentials(o)}catch(e){throw r(),e}}}else this.loggerWrapper.debug("Submit already in flight, ignoring")}))))),this.flowState=e,this.setValidationTrackingSender(((e,t)=>i(this,[e,t],void 0,(function*({executionId:e,events:t},{keepalive:i}){const n=yield this.sdk.flow.event(e,t,i);return{ok:n.ok,retryable:n.code>=500||429===n.code}}))))}nativeResume(e,t){var i,o,s,r,a,l;const c=JSON.parse(t);if("oauthWeb"===e||"sso"===e){let e,{exchangeCode:t}=c;if(!t){const n=new URL(c.url);t=null===(i=n.searchParams)||void 0===i?void 0:i.get(Ol),e=(null===(o=n.searchParams)||void 0===o?void 0:o.get(Rl))||void 0}null===(r=(s=this.nativeCallbacks).complete)||void 0===r||r.call(s,{exchangeCode:t,exchangeError:e,idpInitiated:!0})}else if("magicLink"===e){const e=new URL(c.url),t=e.searchParams.get("t"),i=e.searchParams.get(xl).split("_").pop();n(this,qu,"f").call(this),this.flowState.update({token:t,stepId:i,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:i}=this.nativeCallbacks;this.nativeCallbacks.screenNext=null,null==i||i(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)=>i=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[Vc(e.id,e.resultKey)]:i},bubbles:!0,composed:!0})),t(e.id)};this.loggerWrapper.debug(`Preparing to load scripts: ${e.map((e=>e.id)).join(", ")}`);const n=Promise.all(null==e?void 0:e.map((e=>i(this,void 0,void 0,(function*(){var i,n,o;const s=this.shadowRoot.querySelector(`[data-script-id="${e.id}"]`);if(s){this.loggerWrapper.debug("Script already loaded",e.id);const{moduleRes:t}=s;return null===(i=null==t?void 0:t.start)||void 0===i||i.call(t),t}(null===(n=globalThis.descope)||void 0===n?void 0:n[e.id])||(yield this.injectNpmLib("@descope/flow-scripts","1.0.21",`dist/${e.id}.js`));const r=null===(o=globalThis.descope)||void 0===o?void 0:o[e.id];return new Promise(((i,n)=>{try{const n=r(e.initArgs,{baseUrl:this.baseUrl,ref:this},t(e,i),this.loggerWrapper);if(n){const t=document.createElement("div");t.setAttribute("data-script-id",e.id),t.moduleRes=n,this.shadowRoot.appendChild(t);const o=this.nextRequestStatus.subscribe((()=>{var i;this.loggerWrapper.debug("Stopping script",e.id),(null===(i=n.stop)||void 0===i?void 0:i.call(n))&&(this.nextRequestStatus.unsubscribe(o),this.loggerWrapper.debug("Removing script",e.id),this.shadowRoot.removeChild(t))}));"function"==typeof n.present&&i(e.id)}}catch(e){n(e)}}))})))));let o;const s=new Promise((e=>{o=setTimeout((()=>{this.loggerWrapper.warn("SDK scripts loading timeout"),e(!0)}),5e3)}));return Promise.race([n,s]).finally((()=>clearTimeout(o)))}get isDismissScreenErrorOnInput(){return"true"===this.getAttribute("dismiss-screen-error-on-input")}init(){var e,t;if(!window.descopeBridge)return this._init();this.lazyInit=this._init,o(this,Ou,null===(t=null===(e=null===window||void 0===window?void 0:window.descopeBridge)||void 0===e?void 0:e.registerFlow)||void 0===t?void 0:t.call(e,this),"f")}_init(){const e=Object.create(null,{init:{get:()=>super.init}});return i(this,void 0,void 0,(function*(){var t,i;this.shadowRoot.isConnected&&(null===(t=this.flowState)||void 0===t||t.subscribe(this.onFlowChange.bind(this)),n(this,Su,"m",Wu).call(this),window.addEventListener("visibilitychange",n(this,Au,"f").visibilitychange)),yield null===(i=e.init)||void 0===i?void 0:i.call(this)}))}disconnectedCallback(){var e,t,i;super.disconnectedCallback(),this.teardownValidationTracking(),n(this,Ou,"f")&&(null===(t=null===(e=window.descopeBridge)||void 0===e?void 0:e.unregisterFlow)||void 0===t||t.call(e,n(this,Ou,"f")),o(this,Ou,void 0,"f")),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),n(this,qu,"f").call(this),null===(i=n(this,Cu,"f"))||void 0===i||i.abort(),o(this,Cu,null,"f"),window.removeEventListener("visibilitychange",n(this,Au,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return i(this,void 0,void 0,(function*(){let i;const n=m(e),o=yield this.getTargetLocales();return o.includes(n.locale)?i=`${t}-${n.locale}.html`:o.includes(n.fallback)&&(i=`${t}-${n.fallback}.html`),i}))}getPageContent(e,t){return i(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield this.fetchStaticResource(t,"text");return e}catch(i){this.loggerWrapper.error(`Failed to fetch flow page from ${t}. Fallback to url ${e}`,i)}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,s,r){return i(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:v,redirectTo:w,redirectIsPopup:b,redirectUrl:y,token:k,code:S,isPopup:I,exchangeError:C,webauthnTransactionId:E,webauthnOptions:A,redirectAuthCodeChallenge:x,redirectAuthCallbackUrl:O,redirectAuthBackupCallbackUri:j,redirectAuthInitiator:R,locale:T,samlIdpResponseUrl:M,samlIdpResponseSamlResponse:W,samlIdpResponseRelayState:U,wsFedIdpResponseUrl:P,wsFedIdpResponseWresult:_,wsFedIdpResponseWctx:L,nativeResponseType:$,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 J=(()=>{const e=cd(dd);if(!e){const e=Math.floor(100*Math.random()+1);return ld(dd,e.toString()),e}return Number(e)})(),{outboundAppId:B,outboundAppScopes:H}=this,K=this.sdk.getLastUserLoginId();r("flowId")&&this.setValidationTrackingEnabled(!1);const Y=yield this.getFlowConfig();n(this,Su,"m",Zu).call(this,Y,p,r);const G=yield this.getProjectConfig(),Z=Object.entries(G.flows||{}).reduce(((e,[t,i])=>(e[t]=i.version,e)),{}),X=O&&x?{callbackUrl:O,codeChallenge:x,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){gd(this.loggerWrapper);const e=[...Y.clientScripts||[],...Y.sdkScripts||[]];if(Y.conditions){let t=[];({startScreenId:q,conditionInteractionId:V,startScreenName:z,clientScripts:t,componentsConfig:ee}=((e,t)=>{const i=null==t?void 0:t.find((({key:t,operator:i,predicate:n})=>{var o;if("ELSE"===t)return!0;const s=null===(o=ud[t])||void 0===o?void 0:o[i];return!!(null==s?void 0:s(e,n))}));return i?{startScreenId:i.met.screenId,startScreenName:i.met.screenName,conditionInteractionId:i.met.interactionId,clientScripts:i.met.clientScripts,componentsConfig:i.met.componentsConfig}:{}})({loginId:K,code:S,token:k,abTestingKey:J,lastAuth:hd(K,this.loggerWrapper)},Y.conditions)),e.push(...t||[])}else Y.condition?({startScreenId:q,startScreenName:z,conditionInteractionId:V}=((e,t)=>{var i;const n=null===(i=ud[null==e?void 0:e.key])||void 0===i?void 0:i[e.operator];if(!n)return{};const o=n(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}})(Y.condition,{loginId:K,code:S,token:k,abTestingKey:J,lastAuth:hd(K,this.loggerWrapper)})):(z=Y.startScreenName,q=Y.startScreenId);if(o(this,Yu,q,"f"),o(this,Gu,z,"f"),o(this,Eu,this.loadSdkScripts(e),"f"),Y.fingerprintEnabled&&Y.fingerprintKey?yield Sr(Y.fingerprintKey,this.baseUrl):Xs(yr),!Pc(q,F)){const e=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:X},F),{client:this.client}),y&&{redirectUrl:y}),{lastAuth:hd(K,this.loggerWrapper),abTestingKey:J,locale:m(T).locale,nativeOptions:Q,outboundAppId:B,outboundAppScopes:H}),V,"",G.componentsVersion,Z,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:n(this,Su,"a",Qu)},this.formConfigValues),S?{exchangeCode:S,idpInitiated:!0}:{}),F.descopeIdpInitiated&&{idpInitiated:!0}),k?{token:k}:{}),F.oidcLoginHint?{externalId:F.oidcLoginHint}:{}));return n(this,Vu,"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:r("code"),isExchangeErrorChanged:r("exchangeError")})),I&&(r("code")&&S||r("exchangeError")&&C))return void n(this,Su,"m",ph).call(this,p,S,C);if(p&&(r("token")&&k||r("code")&&S||r("exchangeError")&&C)){const e=yield this.sdk.flow.next(p,h,ic,Y.version,G.componentsVersion,{token:k,exchangeCode:S,exchangeError:C,origin:n(this,Su,"a",Qu)});return n(this,Vu,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(f===tc&&M&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>r(e)))){if(!W)return void this.loggerWrapper.error("Did not get saml idp params data to load");((e,t,i,n)=>{const o=document.createElement("form");o.method="POST",o.action=e,o.appendChild(_c("SAMLResponse",t,"saml-response")),o.appendChild(_c("RelayState",i,"saml-relay-state")),document.body.appendChild(o),n(o)})(M,W,U||"",Lc)}if(f===tc&&P&&["wsFedIdpResponseUrl","wsFedIdpResponseWresult","wsFedIdpResponseWctx"].some((e=>r(e)))){if(!_)return void this.loggerWrapper.error("Did not get wsfed idp params data to load");((e,t,i,n)=>{const o=document.createElement("form");o.method="POST",o.action=e,o.appendChild(_c("wa","wsignin1.0")),o.appendChild(_c("wresult",t)),o.appendChild(_c("wctx",i)),document.body.appendChild(o),n(o)})(P,_,L||"",Lc)}if(f===Gl&&(r("redirectTo")||r("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,i,n)=>{const o=void 0!==window.screenLeft?window.screenLeft:window.screen.left,s=void 0!==window.screenTop?window.screenTop:window.screen.top,r=((window.innerWidth||document.documentElement.clientWidth||window.screen.width)-i)/2+o,a=((window.innerHeight||document.documentElement.clientHeight||window.screen.height)-n)/2+s,l=function(){const e=navigator.userAgent||"",t=/\b(iPhone)\b/.test(e),i=/Safari/.test(e)&&!/CriOS|FxiOS|OPiOS|EdgiOS|Chrome|Chromium/.test(e);return t&&i}()?"about:blank":"",c=window.open(l,t,`width=${i},height=${n},top=${a},left=${r},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"));let i=!1;const o=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:o,data:s}=e.data||{};"code"===o&&(i=!0,this.flowState.update({code:s.code,exchangeError:s.exchangeError}))};let s;this.loggerWrapper.debug("Starting popup closed detection");const r=setInterval((()=>{e.closed&&(this.loggerWrapper.debug("Popup closed, dispatching popupclosed event"),clearInterval(r),n(this,Su,"m",hh).call(this,"popupclosed",{abandoned:!i}),this.loggerWrapper.debug("Cleaning up popup listeners"),null==s||s())}),1e3);if(t)window.addEventListener("message",o),s=()=>{this.loggerWrapper.debug("Cleaning up popup postMessage listener"),window.removeEventListener("message",o)};else{this.loggerWrapper.debug("Creating broadcast channel");const e=new BroadcastChannel(p);e.onmessage=o,s=()=>{this.loggerWrapper.debug("Closing channel"),e.close()}}}else this.handleRedirect(w),this.flowState.update({redirectTo:"no-op"}),n(this,Su,"m",hh).call(this,"popupclosed",{});return}if(f===Xl||f===Ql){if(!E||!A)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");null===(l=n(this,Cu,"f"))||void 0===l||l.abort(),o(this,Cu,null,"f");const e=yield n(this,Su,"m",$u).call(this,f,A),t=yield this.sdk.flow.next(p,h,ic,Y.version,G.componentsVersion,Object.assign({transactionId:E},e));n(this,Vu,"f").call(this,t)}if(f===ec)return this.nativeCallbacks.complete=e=>i(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,h,ic,Y.version,G.componentsVersion,e);n(this,Vu,"f").call(this,t)})),n(this,Su,"m",Tu).call(this,$,N),void setTimeout((()=>{this.dispatchEvent(new Event("popupclosed"))}),500);if((r("action")||r("deferredPolling"))&&n(this,Fu,"f").call(this,p,h,Y.version,G.componentsVersion),!g&&!q)return void this.loggerWrapper.warn("No screen was found to show");const te=q||g,ie=yield this.getHtmlFilenameWithLocale(T,te),{oidcLoginHint:ne,oidcPrompt:oe,oidcErrorRedirectUri:se,oidcResource:re,samlIdpUsername:ae}=F,le={direction:Ec(h,s.stepId),screenState:Object.assign(Object.assign({},v),{form:Object.assign(Object.assign({},this.formConfigValues),null==v?void 0:v.form),lastAuth:{loginId:K,name:this.sdk.getLastUserDisplayName()||K},componentsConfig:Object.assign(Object.assign(Object.assign({},Y.componentsConfig),ee),null==v?void 0:v.componentsConfig)}),htmlFilename:`${te}.html`,htmlLocaleFilename:ie,screenId:te,stepName:e.stepName||z,samlIdpUsername:ae,oidcLoginHint:ne,oidcPrompt:oe,oidcErrorRedirectUri:se,oidcResource:re,action:f,locale:m(T).locale},ce=hd(K,this.loggerWrapper);Pc(q,F)?le.next=(e,t)=>i(this,void 0,void 0,(function*(){const i=(null==Y?void 0:Y.clientScripts)||[];yield n(this,Su,"m",ah).call(this,i);const o=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:X},F),{lastAuth:ce,preview:this.preview,abTestingKey:J,client:this.client}),y&&{redirectUrl:y}),{locale:m(T).locale,nativeOptions:Q,outboundAppId:B,outboundAppScopes:H}),V,e,G.componentsVersion,Z,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),this.getComponentsContext()),zc(t)),S&&{exchangeCode:S,idpInitiated:!0}),F.descopeIdpInitiated&&{idpInitiated:!0}),k&&{token:k}),le.next.isCustomScreen);return n(this,Vu,"f").call(this,o),o})):(r("projectId")||r("baseUrl")||r("executionId")||r("stepId"))&&(le.next=(e,t)=>i(this,void 0,void 0,(function*(){const i=(null==v?void 0:v.clientScripts)||[];yield n(this,Su,"m",ah).call(this,i);const o=yield this.sdk.flow.next(p,h,e,Y.version,G.componentsVersion,Object.assign(Object.assign({},this.getComponentsContext()),zc(t)),le.next.isCustomScreen);return n(this,Vu,"f").call(this,o),o}))),this.loggerWrapper.debug("Got a screen with id",le.screenId),yield n(this,Su,"m",Lu).call(this,le),this.stepState.update(le)}))}onStepChange(e,t){return i(this,void 0,void 0,(function*(){var o,s,r;const{htmlFilename:a,htmlLocaleFilename:l,direction:c,next:d,screenState:u,screenId:h}=e;this.loggerWrapper.debug("Rendering a flow screen"),this.updateScreenUser(null==u?void 0:u.user);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 n(this,Su,"m",Hu).call(this,f,d):(e=>{e.querySelectorAll(`descope-button[${Yl}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true")))})(f),!e.samlIdpUsername||(null===(o=u.form)||void 0===o?void 0:o.loginId)||(null===(s=u.form)||void 0===s?void 0:s.email)||(u.form||(u.form={}),u.form.loginId=e.samlIdpUsername,u.form.email=e.samlIdpUsername),sd(f,u,this.formConfig,this.loggerWrapper),this.applyComponentsState(f,null==u?void 0:u.componentsState);const{geo:v}=null!==(r=yield this.getExecutionContext())&&void 0!==r?r:{};((e,t)=>{Object.entries({"default-code":"autoDetect","default-country":"autoDetect"}).forEach((([i,n])=>{Array.from(e.querySelectorAll(`[${i}="${n}"]`)).forEach((e=>{e.setAttribute(i,t||n)}))}))})(f,v),((e,t)=>{let i=t;if(t)try{const[e]=Intl.getCanonicalLocales(t);e&&(i=e)}catch(e){}Object.entries({lang:"autoDetect"}).forEach((([t,n])=>{Array.from(e.querySelectorAll(`[${t}="${n}"]`)).forEach((e=>{e.setAttribute(t,i||n)}))}))})(f,e.locale);const m=()=>i(this,void 0,void 0,(function*(){var i,o;yield g;const s=this.contentRootElement;((e,t)=>{od(e,"descope-totp-image",t)})(s,null===(i=null==u?void 0:u.totp)||void 0===i?void 0:i.image),((e,t)=>{od(e,"descope-notp-image",t)})(s,null===(o=null==u?void 0:u.notp)||void 0===o?void 0:o.image),((e,t,i,n)=>{i&&Object.keys(i).forEach((o=>{if(!t.querySelector(o))return void n.debug(`Skipping css vars for component "${o}"`,`Got css vars for component ${o} but Could not find it on next page`);const s=customElements.get(o);s?Object.keys(i[o]).forEach((t=>{var r;const a=i[o],l=null===(r=null==s?void 0:s.cssVarList)||void 0===r?void 0:r[t];if(!l)return void n.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)})):n.debug(`Could not find component class for ${o}`,"Check if the component is registered")}))})(s,f,u.cssVars,this.loggerWrapper),s.replaceChildren(f);const r=!t.htmlFilename;setTimeout((()=>{n(this,Su,"m",oh).call(this),this.updateUsernameAnchor(),this.validateOnBlur&&((e,t)=>{e.querySelectorAll("*[name]").forEach((i=>{i.addEventListener("blur",(()=>{var n;if(cc(i,e))return;const o=()=>{var e;const n=i.focus;i.focus=()=>{};const o=null===(e=i.reportValidity)||void 0===e?void 0:e.call(i);t&&!1===o&&t(i),setTimeout((()=>{i.focus=n}))};if("true"===i.getAttribute("invalid")||(null===(n=i.value)||void 0===n?void 0:n.length))return void o();const s={timer:void 0},r=e=>{"true"===e.target.getAttribute("formnovalidate")&&(clearTimeout(s.timer),s.timer=void 0)};s.timer=setTimeout((()=>{e.removeEventListener("click",r),o(),s.timer=void 0}),150),e.addEventListener("click",r,{once:!0})}))}))})(s,(e=>this.trackValidationErrors([e],n(this,Su,"a",Xu)))),((e,t)=>{ed(e,null==t?void 0:t.inputs),ed(e,null==t?void 0:t.form)})(s,u),this.initRealtimeConditions(s,u),n(this,Su,"m",Ku).call(this,{isFirstScreen:r,isCustomScreen:!1,stepName:e.stepName}),Wc(s,this.autoFocus,r),n(this,Su,"m",dh).call(this,h)})),n(this,Su,"m",uh).call(this,d,h),s.querySelector(`[${Yl}="polling"]`)&&d(nc,{})}));c?n(this,Su,"m",Du).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}}Iu=new WeakMap,Cu=new WeakMap,Eu=new WeakMap,Au=new WeakMap,Ou=new WeakMap,_u=new WeakMap,Nu=new WeakMap,Fu=new WeakMap,qu=new WeakMap,zu=new WeakMap,Vu=new WeakMap,Ju=new WeakMap,Yu=new WeakMap,Gu=new WeakMap,ih=new WeakMap,rh=new WeakMap,Su=new WeakSet,xu=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1,deferredPolling:!1})}),300)},ju=function(e,t,o){return i(this,void 0,void 0,(function*(){var i;return(null===(i=this.nativeOptions)||void 0===i?void 0:i.bridgeVersion)>=2&&new Promise((i=>{this.nativeCallbacks.screenNext=o,this.nativeCallbacks.screenResolve=i,n(this,Su,"m",Tu).call(this,"beforeScreen",{screen:e,context:t})}))}))},Ru=function(e){var t;(null===(t=this.nativeOptions)||void 0===t?void 0:t.bridgeVersion)>=2&&n(this,Su,"m",Tu).call(this,"afterScreen",{screen:e})},Tu=function(e,t){n(this,Su,"m",hh).call(this,"bridge",{type:e,payload:t})},Mu=function({errorText:e,errorType:t}){const i=()=>{var i;let n=e;try{n=(null===(i=this.errorTransformer)||void 0===i?void 0:i.call(this,{text:e,type:t}))||e}catch(e){this.loggerWrapper.error("Error transforming error message",e.message)}((e,t,i="")=>{e.querySelectorAll(`[${Yl}="${t}"]`).forEach((e=>{e.textContent=i,e.classList[i?"remove":"add"]("hide")}))})(this.contentRootElement,"error-message",n)};this.addEventListener("screen-updated",i,{once:!0}),i()},Wu=function(){var e,i,o,s;null===(e=this.stepState)||void 0===e||e.subscribe(this.onStepChange.bind(this),(e=>{var i=e.screenState,n=void 0===i?{}:i,{errorText:o,errorType:s}=n,r=t(n,["errorText","errorType"]),a=t(e,["screenState"]);return Object.assign(Object.assign({},a),{screenState:r})})),null===(i=this.stepState)||void 0===i||i.subscribe(n(this,Su,"m",Mu).bind(this),(e=>{var t,i;return{errorText:null===(t=null==e?void 0:e.screenState)||void 0===t?void 0:t.errorText,errorType:null===(i=null==e?void 0:e.screenState)||void 0===i?void 0:i.errorType}}),{forceUpdate:!0}),null===(o=this.stepState)||void 0===o||o.subscribe(n(this,Su,"m",Uu).bind(this),(e=>{var t,i;return{errorText:null===(t=null==e?void 0:e.screenState)||void 0===t?void 0:t.errorText,errorType:null===(i=null==e?void 0:e.screenState)||void 0===i?void 0:i.errorType}}),{forceUpdate:!0}),null===(s=this.flowState)||void 0===s||s.subscribe((({screenId:e,executionId:t})=>{var i;try{this.updateTelemetryContext({screenId:e,executionId:t})}catch(e){null===(i=this.logger)||void 0===i||i.error("Error updating telemetry screenId:",e)}}),(e=>({screenId:e.screenId,executionId:e.executionId})))},Uu=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=""}))})),Wc(this.contentRootElement,this.autoFocus,!1))},Pu=function(){return i(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")}))},Lu=function(e){return i(this,void 0,void 0,(function*(){var i;const s=Object.assign(Object.assign({},this.stepState.current),e),{next:r,stepName:a}=s,l=(e=>{const t=(i=e.screenState,n=(e,t)=>rc.includes(t)||t.startsWith("_"),Object.fromEntries(Object.entries(i).filter((([e,t])=>!n(0,e)))));var i,n;const{screenState:{errorText:o,errorType:s}}=e;(o||s)&&(t.error={text:o,type:s}),e.action&&(t.action=e.action);const r=(e=>{if(!e)return;const t={};return qc.forEach((({key:i,from:n})=>{const o=n(e);void 0!==o&&(t[i]=o)})),Object.keys(t).length?t:void 0})(e.screenState);return r&&(t.data=r),t})(t(s,["next","stepName"]));let c=yield n(this,Su,"m",ju).call(this,a,l,r);c||(c=Boolean(yield null===(i=this.onScreenUpdate)||void 0===i?void 0:i.call(this,a,l,r,this)));const d=!this.stepState.current.htmlFilename;if(n(this,Nu,"f").call(this,c),r&&(r.isCustomScreen=c),n(this,_u,"f")!==c){const[e,t]=["flow","custom"].sort((()=>c?-1:1));this.loggerWrapper.debug(`Switching from ${t} screen to ${e} screen`),o(this,_u,c,"f"),c?this.stepState.unsubscribeAll():n(this,Su,"m",Wu).call(this)}c?(this.loggerWrapper.debug("Showing a custom screen"),n(this,Su,"m",Ku).call(this,{isFirstScreen:d,isCustomScreen:c,stepName:e.stepName}),this.disableKeyPressHandler()):this.handleKeyPress(),this.stepState.forceUpdate=c}))},$u=function(e,t){return i(this,void 0,void 0,(function*(){const i=new AbortController;try{const n=e===Xl?this.sdk.webauthn.helpers.create(t,i):this.sdk.webauthn.helpers.get(t,i),o=yield Uc(9e4,n,fh);return o!==fh?{response:o}:(i.abort(),this.loggerWrapper.warn("WebAuthn operation timed out after 90000ms"),{failure:"AbortError",failureReason:"aborted",failureMessage:"Passkey operation timed out"})}catch(e){return"InvalidStateError"===e.name?this.loggerWrapper.warn("WebAuthn operation failed",e.message):"NotAllowedError"!==e.name&&this.loggerWrapper.error(e.message),{failure:e.name,failureReason:e.reason,failureMessage:e.message}}}))},Du=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")},Bu=function(e){const t=e.getAttribute("name");if(!["email"].includes(t)){const i=`user-${t}`;e.setAttribute("name",i),e.addEventListener("input",(()=>{e.setAttribute("name",e.value?t:i)}))}},Hu=function(e,t){return i(this,void 0,void 0,(function*(){var s;null===(s=n(this,Cu,"f"))||void 0===s||s.abort();const r=e.querySelector('*[autocomplete="webauthn"]');if(r&&(yield rd())){const{options:e,transactionId:s}=(yield n(this,Ju,"f").call(this))||{};e&&s&&(n(this,Su,"m",Bu).call(this,r),o(this,Cu,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(e,n(this,Cu,"f")).then((e=>i(this,void 0,void 0,(function*(){t(r.id,{transactionId:s,response:e})})))).catch((e=>{"AbortError"!==e.name&&this.loggerWrapper.error("Conditional login failed",e.message)})))}}))},Ku=function({isFirstScreen:e,isCustomScreen:t,stepName:i}){e&&n(this,Su,"m",hh).call(this,"ready",{}),t||n(this,Su,"m",Ru).call(this,i),n(this,Su,"m",hh).call(this,"page-updated",{screenName:i}),n(this,Su,"m",hh).call(this,"screen-updated",{screenName:i})},Zu=function(e,t,i){this.setValidationTrackingEnabled(!!e.clientValidationTrackingEnabled),t&&i("executionId")&&this.setValidationTrackingExecution(t)},Xu=function(){var e,t,i,o,s,r,a;const l=null===(e=this.flowState)||void 0===e?void 0:e.current;return(null==l?void 0:l.executionId)?{executionId:l.executionId,screenId:l.screenId,screenName:(null===(a=null===(r=this.stepState)||void 0===r?void 0:r.current)||void 0===a?void 0:a.stepName)||l.stepName}:{executionId:void 0,screenId:null!==(t=n(this,Yu,"f"))&&void 0!==t?t:null==l?void 0:l.screenId,screenName:null!==(i=n(this,Gu,"f"))&&void 0!==i?i:(null===(s=null===(o=this.stepState)||void 0===o?void 0:o.current)||void 0===s?void 0:s.stepName)||(null==l?void 0:l.stepName)}},Qu=function(){var e;return(null===(e=this.nativeOptions)||void 0===e?void 0:e.origin)||window.location.origin},eh=function(){let e=!0;const t=[];return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((i=>{var n,o,s;"slot"===i.localName||cc(i,this.contentRootElement)||(null===(n=i.reportValidity)||void 0===n||n.call(i),i.validity&&!i.validity.valid&&t.push(i),e&&(e=null===(s=null===(o=i.checkValidity)||void 0===o?void 0:o.call(i))||void 0===s||s))})),t.length&&this.trackValidationErrors(t,n(this,Su,"a",Xu)),e},th=function(){return i(this,void 0,void 0,(function*(){const e=this.getInputs();return(yield Promise.all(e.map((e=>i(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})),{})}))},nh=function(e){var t,s;const r=Array.from(this.contentRootElement.querySelectorAll(':not([disabled]), [disabled="false"]')).filter((t=>t!==e)),a=(null===(s=null===(t=this.flowState.current)||void 0===t?void 0:t.screenState)||void 0===s?void 0:s.clientScripts)||[];e.setAttribute("loading","true"),r.forEach((e=>e.setAttribute("disabled","true")));const l=()=>{e.removeAttribute("loading"),r.forEach((e=>{e.removeAttribute("disabled")}))},c=e=>i(this,void 0,void 0,(function*(){var t;if(this.loggerWrapper.debug("Restoring components state"),this.removeEventListener("popupclosed",c),!0===(null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.abandoned)&&a.length)return o(this,Eu,(()=>i(this,void 0,void 0,(function*(){try{yield this.loadSdkScripts(a)}catch(e){this.loggerWrapper.warn("Failed to refresh client scripts on popup close",null==e?void 0:e.message)}})))(),"f"),void l();l();const n=yield this.getFlowConfig(),s=[...n.clientScripts||[],...n.sdkScripts||[]];this.loadSdkScripts(s)})),d=()=>{var e;window.removeEventListener("pageshow",n(this,ih,"f")),o(this,ih,(e=>{e.persisted&&(this.logger.debug("Page was loaded from cache, restoring components state"),c())}),"f"),window.addEventListener("pageshow",n(this,ih,"f"),{once:!0});const t=null===(e=this.stepState)||void 0===e?void 0:e.subscribe(((e,i)=>{e===i&&c(),this.removeEventListener("popupclosed",c),this.stepState.unsubscribe(t)}),(e=>e.screenId),{forceUpdate:!0})},u=this.nextRequestStatus.subscribe((({isLoading:e})=>{e?this.addEventListener("popupclosed",c,{once:!0}):(this.nextRequestStatus.unsubscribe(u),"success"===this.flowStatus?(this.removeEventListener("popupclosed",c),l()):d())}));return l},oh=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((e=>e.remove())),this.contentRootElement.querySelectorAll('[external-input="true"]').forEach((e=>n(this,Su,"m",sh).call(this,e)))},sh=function(e){e&&e.querySelectorAll("input").forEach((t=>{const i=t.getAttribute("slot"),n=`input-${e.id}-${i}`,o=document.createElement("slot");o.setAttribute("name",n),o.setAttribute("slot",i),e.appendChild(o),t.setAttribute("slot",n),this.appendChild(t)}))},ah=function(e){return i(this,void 0,void 0,(function*(){if(n(this,Eu,"f")){this.loggerWrapper.debug("Waiting for sdk scripts to load");const e=Date.now();yield n(this,Eu,"f"),this.loggerWrapper.debug("Sdk scripts loaded for",(Date.now()-e).toString())}const t=this.loadSdkScriptsModules(),i=e.map((e=>e.id));for(const e of t)if(i.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 Uc(5e3,Promise.all(o),null)}catch(e){this.loggerWrapper.error("Failed to refresh script module",e.message)}}))},lh=function(e,t){this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((i=>{i.addEventListener("input",(()=>{var o;(null===(o=i.checkValidity)||void 0===o?void 0:o.call(i))&&n(this,rh,"f").call(this,i,e,t)}))}))},ch=function(e,t,i){t&&i&&"true"===e.getAttribute("data-opt-in-last-used-auth")&&function(e,t,i){try{const i=fd();i[e]=t,ld(sc,JSON.stringify(i))}catch(e){null==i||i.warn("[Descope] Failed to update in-flight last auth storage",String(e))}}(i,t,this.loggerWrapper)},dh=function(e){var t;const i=null===(t=hd(this.sdk.getLastUserLoginId(),this.loggerWrapper).lastUsedPerScreen)||void 0===t?void 0:t[e];if(!i)return;const n=this.contentRootElement.querySelector('descope-attachment[data-type="last-auth-badge"]'),o=this.contentRootElement.querySelector(`#${CSS.escape(i)}`);n&&o&&(o.replaceWith(n),n.appendChild(o))},uh=function(e,t){this.contentRootElement.querySelectorAll(`descope-button:not([${Ml}]), [data-type="button"]:not([${Ml}]`).forEach((i=>{i.onclick=()=>{n(this,rh,"f").call(this,i,e,t)}})),n(this,Su,"m",lh).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:""})})))}))}))},hh=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},ph=function(e,t,i){var n;const[o,s]=(null===(n=window.name)||void 0===n?void 0:n.split("|"))||[],r={data:{code:t,exchangeError:i},action:"code"};if("descope-wc"===o&&s){this.loggerWrapper.debug("Using postMessage fallback to notify opener in origin",s);try{window.opener.postMessage(r,s)}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(r),t.close()}try{window.close()}catch(e){}},gh.bridgeVersion=3,customElements.get("descope-wc")?console.log("descope-wc is already defined"):customElements.define("descope-wc",gh);var vh=Object.freeze({__proto__:null,default:gh});customElements.define("descope-user-profile-widget",yl);const mh=(e,t,i,n={})=>{var o,s,r,a;return[Math.min(Math.max(t,("all"===n.left?e.offsetWidth:null!==(o=n.left)&&void 0!==o?o:0)-e.offsetWidth),window.innerWidth-("all"===n.right?e.offsetWidth:null!==(s=n.right)&&void 0!==s?s:0)),Math.min(Math.max(i,("all"===n.top?e.offsetHeight:null!==(r=n.top)&&void 0!==r?r:0)-e.offsetHeight),window.innerHeight-("all"===n.bottom?e.offsetHeight:null!==(a=n.bottom)&&void 0!==a?a:0))]};var wh,bh,yh,kh,Sh,Ih,Ch,Eh,Ah,xh;const Oh=document.createElement("template");Oh.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 jh=s(H)(HTMLElement);class Rh extends jh{constructor(){var e;super(),wh.add(this),bh.set(this,new g({messages:[]})),yh.set(this,void 0),kh.set(this,void 0),Sh.set(this,void 0),Ih.set(this,{resize:n(this,wh,"m",xh).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(Oh.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,yh,this.shadowRoot.querySelector(".debugger"),"f"),n(this,yh,"f").style.top="32px",n(this,yh,"f").style.left=window.innerWidth-300-32+"px",o(this,kh,n(this,yh,"f").querySelector(".content"),"f"),o(this,Sh,n(this,yh,"f").querySelector(".header"),"f")}updateData(e){n(this,bh,"f").update((t=>({messages:t.messages.concat(e)})))}connectedCallback(){var e;((e,t,i)=>{let n=0,o=0,s=0,r=0;function a(t){t.preventDefault(),n=s-t.clientX,o=r-t.clientY,s=t.clientX,r=t.clientY;const[a,l]=mh(e,e.offsetLeft-n,e.offsetTop-o,i);e.style.top=`${l}px`,e.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),s=e.clientX,r=e.clientY,document.onmouseup=l,document.onmousemove=a}t?t.onmousedown=c:e.onmousedown=c})(n(this,yh,"f"),n(this,Sh,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",n(this,Ih,"f").resize),(e=n(this,yh,"f")).onmousemove=t=>{var i;const n=t.target;(n.w&&n.w!==n.offsetWidth||n.h&&n.h!==n.offsetHeight)&&(null===(i=e.onresize)||void 0===i||i.call(e,t)),n.w=n.offsetWidth,n.h=n.offsetHeight},n(this,yh,"f").onresize=n(this,wh,"m",Ah).bind(this),n(this,bh,"f").subscribe(n(this,wh,"m",Ch).bind(this))}disconnectedCallback(){n(this,bh,"f").unsubscribeAll(),window.removeEventListener("resize",n(this,Ih,"f").resize)}}bh=new WeakMap,yh=new WeakMap,kh=new WeakMap,Sh=new WeakMap,Ih=new WeakMap,wh=new WeakSet,Ch=function(e){n(this,wh,"m",Eh).call(this,e),n(this,wh,"m",Ah).call(this)},Eh=function(e){n(this,kh,"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 ${v(e.title)}\n </div>\n <div class="msg_desc">\n ${v(e.description)}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},Ah=function(){n(this,kh,"f").querySelectorAll(".msg").forEach((e=>{const t=e,i=t.querySelector(".msg_desc"),n=i.scrollWidth>i.clientWidth,o=i.clientHeight>20;n||o?(t.classList.add("collapsible"),t.onclick=e=>{e.target.classList.contains("msg_desc")||t.classList.toggle("collapsed")}):(t.classList.remove("collapsible"),t.onclick=null)}))},xh=function(){const[e,t]=mh(n(this,yh,"f"),Number.parseInt(n(this,yh,"f").style.left,10),Number.parseInt(n(this,yh,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});n(this,yh,"f").style.top=`${t}px`,n(this,yh,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",Rh);var Th=Object.freeze({__proto__:null});const Mh=(e,t,i,n={})=>{var o,s,r,a;return[Math.min(Math.max(t,("all"===n.left?e.offsetWidth:null!==(o=n.left)&&void 0!==o?o:0)-e.offsetWidth),window.innerWidth-("all"===n.right?e.offsetWidth:null!==(s=n.right)&&void 0!==s?s:0)),Math.min(Math.max(i,("all"===n.top?e.offsetHeight:null!==(r=n.top)&&void 0!==r?r:0)-e.offsetHeight),window.innerHeight-("all"===n.bottom?e.offsetHeight:null!==(a=n.bottom)&&void 0!==a?a:0))]},Wh=(e,t,i)=>{let n=0,o=0,s=0,r=0;function a(t){t.preventDefault(),n=s-t.clientX,o=r-t.clientY,s=t.clientX,r=t.clientY;const[a,l]=Mh(e,e.offsetLeft-n,e.offsetTop-o,i);e.style.top=`${l}px`,e.style.left=`${a}px`}function l(){document.onmouseup=null,document.onmousemove=null}function c(e){e.preventDefault(),s=e.clientX,r=e.clientY,document.onmouseup=l,document.onmousemove=a}t?t.onmousedown=c:e.onmousedown=c};var Uh,Ph,_h,Lh,$h,Nh,Dh,Fh,qh,zh,Vh;const Jh=document.createElement("template");Jh.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 Bh=s(H)(HTMLElement);class Hh extends Bh{constructor(){super(),Uh.add(this),Ph.set(this,new Gc({messages:[]})),_h.set(this,void 0),Lh.set(this,void 0),$h.set(this,void 0),Nh.set(this,{resize:n(this,Uh,"m",Vh).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Jh.content.cloneNode(!0)),o(this,_h,this.shadowRoot.querySelector(".debugger"),"f"),o(this,Lh,n(this,_h,"f").querySelector(".content"),"f"),o(this,$h,n(this,_h,"f").querySelector(".header"),"f"),n(this,Uh,"m",Dh).call(this)}updateData(e){n(this,Ph,"f").update((t=>({messages:t.messages.concat(e)})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return i(this,void 0,void 0,(function*(){var t;null===(t=e.init)||void 0===t||t.call(this),Wh(n(this,_h,"f"),n(this,$h,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",n(this,Nh,"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}})(n(this,_h,"f")),n(this,_h,"f").onresize=n(this,Uh,"m",zh).bind(this),n(this,Ph,"f").subscribe(n(this,Uh,"m",Fh).bind(this))}))}disconnectedCallback(){n(this,Ph,"f").unsubscribeAll(),window.removeEventListener("resize",n(this,Nh,"f").resize)}}Ph=new WeakMap,_h=new WeakMap,Lh=new WeakMap,$h=new WeakMap,Nh=new WeakMap,Uh=new WeakSet,Dh=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'),n(this,_h,"f").style.top="32px",n(this,_h,"f").style.left=window.innerWidth-300-32+"px"},Fh=function(e){n(this,Uh,"m",qh).call(this,e),n(this,Uh,"m",zh).call(this)},qh=function(e){n(this,Lh,"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 ${v(e.title)}\n </div>\n <div class="msg_desc">\n ${v(e.description)}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},zh=function(){n(this,Lh,"f").querySelectorAll(".msg").forEach((e=>{const t=e.querySelector(".msg_desc"),i=t.scrollWidth>t.clientWidth,n=t.clientHeight>20;i||n?(e.classList.add("collapsible"),e.onclick=t=>{t.target.classList.contains("msg_desc")||e.classList.toggle("collapsed")}):(e.classList.remove("collapsible"),e.onclick=null)}))},Vh=function(){const[e,t]=Mh(n(this,_h,"f"),Number.parseInt(n(this,_h,"f").style.left,10),Number.parseInt(n(this,_h,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});n(this,_h,"f").style.top=`${t}px`,n(this,_h,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",Hh);var Kh=Object.freeze({__proto__:null,default:Hh});return yl}();
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:"boolean"==typeof e?String(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;const v=e=>String(null!=e?e:"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;");function m(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 w=["error","warn","info","debug"],b={error:console.error.bind(console,"[Descope]"),warn:console.warn.bind(console,"[Descope]"),info:console.info.bind(console,"[Descope]"),debug:console.debug.bind(console,"[Descope]")},y=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,b))}set logger(e){o(this,n,i(this,t,"m",r).call(this,e||b),"f")}get logger(){return i(this,n,"f")}onLogEvent(e,t){}},n=new WeakMap,t=new WeakSet,r=function(e){return w.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})),k="undefined"!=typeof localStorage,I="https://static.descope.com/pages",S="https://static2.descope.com/pages",C=k&&localStorage.getItem("base.content.url")||"",E=(e,t)=>!t&&`${e} cannot be empty, please make sure to set this attribute`,O=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})),A=c((e=>{var t,n;const o=r(y,O)(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&&e.oldValue!==n.getAttribute(e.attributeName)&&o(e.attributeName)}))})).observe(n,{attributes:!0,attributeOldValue:!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})),x=e=>t=>{var n,o,s;const a=r(y,O,A)(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};x.missingAttrValidator=E;const j=c((e=>{const t=r(x({"project-id":E}))(e);return class extends t{get projectId(){return this.getAttribute("project-id")}}})),R=c((e=>class extends e{get baseUrl(){return this.getAttribute("base-url")||""}})),T="Trying the next fallback URL...",W=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(y,j,R)(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 W(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}. ${T}`)}catch(e){const t=`Error fetching URL ${r} [${e.message}]`;if(s)throw new Error(t);null==n||n.debug(`${t}. ${T}`)}}})(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=C||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")===I&&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(I)||l.push(i(this,t,"m",c).call(this,e,I)),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=I}){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(x({"project-id":E}))(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})),P=c((e=>{var t,n,s,a,l;const c=r(M,U,O)(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})),L=c((e=>{var t,n,s,a,l,c,d;return d=class extends(r(O,y)(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 ip})),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})),$=["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()}`},N=(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)})),D=(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)}))}))},F=c((e=>{const t=r(y)(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 D(s,r),i}catch(e){t(i,!0)}else try{return await N(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,...$],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}"`)}))}}})),q="base.ui.components.url",z=k&&localStorage.getItem(q),V=c((e=>{var t,n,s,a,l,c,d;const u=r(y,P,F)(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=z?void 0:await i(this,t,"m",s).call(this);return await this.injectNpmLib("@descope/web-components-ui",e,"dist/umd/index.js",[z],o),this.logger.debug("DescopeUI was loaded"),globalThis.DescopeUI}catch(e){throw this.logger.error(e),new Error("DescopeUI was not loaded")}},d})),B=c((e=>{var t,n,o;const s=r(O,A)(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 J=c((e=>{const t=r(B)(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}}})),K="content-root",Y="root",G=c((e=>{const t=r(J)(e);return class extends t{constructor(...e){var t,n;super(...e),this.attachShadow({mode:"open"}).innerHTML=`\n <div id="${Y}">\n <div id="${K}"></div>\n </div>\n `,this.injectStyle(`\n #${Y}, #${K} {\n height: 100%;\n }\n #${Y} {\n position: relative;\n height: fit-content;\n }\n #${Y}:has(> #${K} > #ROOT[st-host-height="100%"]) {\n height: 100%;\n }\n `),this.contentRootElement=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById(K),this.rootElement=null===(n=this.shadowRoot)||void 0===n?void 0:n.getElementById(Y)}}})),Z="descope-modal";var X;let Q=class{constructor(e,t){X.set(this,void 0),this.nodeName="",o(this,X,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,X,"f"))}get ele(){var e,t;const n="function"==typeof i(this,X,"f")?i(this,X,"f").call(this):i(this,X,"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}};X=new WeakMap;let ee=class extends Q{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)}}},te=class extends Q{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")}},ne=class extends Q{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")}start(){var e,t;null===(t=null===(e=this.ele)||void 0===e?void 0:e.start)||void 0===t||t.call(e)}onSuccess(e){var t;return null===(t=this.ele)||void 0===t||t.addEventListener("success",e),()=>{var t;return null===(t=this.ele)||void 0===t?void 0:t.removeEventListener("success",e)}}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)}}},ie=class extends te{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 oe,re,se,ae,le,ce,de,ue,he,pe,fe,ge,ve,me,we,be,ye,ke,Ie;let Se=class extends Q{constructor(...e){super(...e),oe.add(this),re.set(this,void 0),se.set(this,void 0),this.nodeName="descope-modal",i(this,oe,"m",ae).call(this)}get isOpen(){var e;return"true"===(null===(e=this.ele)||void 0===e?void 0:e.getAttribute("opened"))}get isClosed(){return!this.isOpen}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,oe,"m",ae).call(this),null===(t=this.ele)||void 0===t||t.setAttribute("opened","true")}reset(){var e;this.ele&&(this.ele.innerHTML=""),i(this,re,"f")&&(null===(e=this.ele)||void 0===e||e.append(i(this,re,"f").content.cloneNode(!0)))}setContent(e){o(this,re,e,"f"),this.reset()}remove(){var e,t;null===(e=i(this,se,"f"))||void 0===e||e.disconnect(),null===(t=this.ele)||void 0===t||t.remove()}};re=new WeakMap,se=new WeakMap,oe=new WeakSet,ae=function(){if(i(this,se,"f"))return;const e=this.ele;e&&(o(this,se,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,se,"f").observe(e,{attributes:!0,attributeFilter:["opened"],attributeOldValue:!0}))};let Ce=null,Ee=class{constructor(e={}){le.add(this),ce.set(this,null),de.set(this,""),ue.set(this,void 0),he.set(this,void 0),pe.set(this,!1),fe.set(this,[]),ge.set(this,[]),ve.set(this,[]),me.set(this,[]),we.set(this,void 0),be.set(this,!1),this.logger=e.logger}onDone(e){return i(this,fe,"f").push(e),()=>{o(this,fe,i(this,fe,"f").filter((t=>t!==e)),"f")}}onClosed(e){return i(this,ge,"f").push(e),()=>{o(this,ge,i(this,ge,"f").filter((t=>t!==e)),"f")}}onParentFocus(e){return i(this,me,"f").push(e),()=>{o(this,me,i(this,me,"f").filter((t=>t!==e)),"f")}}onUnauthenticated(e){return i(this,ve,"f").push(e),()=>{o(this,ve,i(this,ve,"f").filter((t=>t!==e)),"f")}}get isOpen(){return!!i(this,ce,"f")&&!i(this,ce,"f").closed}open(e){var t,n;Ce&&Ce!==this&&Ce.standDown(),i(this,le,"m",Ie).call(this),o(this,pe,!1,"f"),o(this,be,!1,"f");try{o(this,de,new URL(e).origin,"f")}catch(n){return null===(t=this.logger)||void 0===t||t.error("Invalid flow popup url",e),!1}const r=`descope-widget-flow|${window.location.origin}`;return o(this,ce,((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?(c.location.href=e,c.focus(),c):null})(e,r,480,650),"f"),i(this,ce,"f")?(o(this,he,(e=>{var t,n,o,r,s,a;i(this,ce,"f")&&e.source&&e.source!==i(this,ce,"f")||(e.origin===i(this,de,"f")?"widget-flow-hello"!==(null===(n=e.data)||void 0===n?void 0:n.action)?"widget-flow-unauthenticated"!==(null===(s=e.data)||void 0===s?void 0:s.action)?"widget-flow-done"===(null===(a=e.data)||void 0===a?void 0:a.action)&&i(this,le,"m",ke).call(this,i(this,fe,"f")):i(this,le,"m",ke).call(this,i(this,ve,"f")):null===(o=e.source)||void 0===o||o.postMessage({action:"widget-flow-hello-ack",nonce:null===(r=e.data)||void 0===r?void 0:r.nonce},e.origin):null===(t=this.logger)||void 0===t||t.debug(`Ignoring popup message from unexpected origin "${e.origin}"`))}),"f"),window.addEventListener("message",i(this,he,"f")),o(this,ue,setInterval((()=>{var e;(null===(e=i(this,ce,"f"))||void 0===e?void 0:e.closed)&&i(this,le,"m",ke).call(this,i(this,ge,"f"))}),1e3),"f"),o(this,we,(()=>{"hidden"!==document.visibilityState&&(i(this,be,"f")||i(this,pe,"f")||(o(this,be,!0,"f"),i(this,me,"f").forEach((e=>e()))))}),"f"),window.addEventListener("focus",i(this,we,"f")),document.addEventListener("visibilitychange",i(this,we,"f")),Ce=this,!0):(null===(n=this.logger)||void 0===n||n.warn("Flow popup was blocked by the browser"),!1)}close(){var e;try{null===(e=i(this,ce,"f"))||void 0===e||e.close()}catch(e){}i(this,le,"m",ke).call(this,i(this,ge,"f"))}remove(){i(this,le,"m",ye).call(this)}standDown(){o(this,pe,!0,"f"),i(this,le,"m",Ie).call(this),o(this,ce,null,"f")}};ce=new WeakMap,de=new WeakMap,ue=new WeakMap,he=new WeakMap,pe=new WeakMap,fe=new WeakMap,ge=new WeakMap,ve=new WeakMap,me=new WeakMap,we=new WeakMap,be=new WeakMap,le=new WeakSet,ye=function(){i(this,le,"m",Ie).call(this),Ce===this&&(Ce=null)},ke=function(e){i(this,pe,"f")||(o(this,pe,!0,"f"),i(this,le,"m",ye).call(this),e.forEach((e=>e())))},Ie=function(){i(this,ue,"f")&&(clearInterval(i(this,ue,"f")),o(this,ue,void 0,"f")),i(this,he,"f")&&(window.removeEventListener("message",i(this,he,"f")),o(this,he,void 0,"f")),i(this,we,"f")&&(window.removeEventListener("focus",i(this,we,"f")),document.removeEventListener("visibilitychange",i(this,we,"f")),o(this,we,void 0,"f"))};let Oe=class extends Q{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()}},Ae=class extends Q{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)}},xe=class extends Q{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)}}},je=class extends Q{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")}},Re=class extends Q{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)}}},Te=class extends Ae{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}},We=class extends Q{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 Me=c((e=>{var t,n;const o=r(O,G,V)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends Se{setContent(t){e(t),super.setContent(t)}}})())}get modalDriverClass(){return i(this,t,"f")}createModal(e,n=i(this,t,"f")){const o=((e={})=>{const t=document.createElement(Z);return Object.keys(e).forEach((n=>{t.setAttribute(n,e[n])})),t})(Object.assign(Object.assign({},{}),e));return this.rootElement.append(o),new n(o,{logger:this.logger})}async init(){var e;this.loadDescopeUiComponents([Z]),await(null===(e=super.init)||void 0===e?void 0:e.call(this))}},t=new WeakMap,n})),Ue=c((e=>class extends(Me(e)){createFlowModal(e){const t=this.modalDriverClass;return this.createModal(e,class extends t{setContent(e){const t=e.content.querySelector("descope-wc");t&&!t.hasAttribute("lazy-start")&&t.setAttribute("lazy-start","true"),super.setContent(e)}async open(){var e,t,n;await super.open(),null===(n=null===(t=null===(e=this.ele)||void 0===e?void 0:e.querySelector("descope-wc"))||void 0===t?void 0:t.start)||void 0===n||n.call(t)}})}})),Pe="descope-notification",Le=c((e=>{var t,n;const o=r(O,G,V)(e);return n=class extends o{constructor(){super(...arguments),t.set(this,(()=>{const e=this.loadDescopeUiComponents.bind(this);return class extends Oe{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})),$e="theme",_e=(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+_e(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};`}),""),Ne=e=>{const t=document.createElement("link");t.href=e,t.rel="stylesheet",document.head.appendChild(t)};function De(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]=De(n[e]||{},i)}else n[e]="string"==typeof i?(n[e]||"")+i:i;return n}const Fe=(e,t)=>null!==t&&!/^[a-zA-Z0-9_-]*$/.test(t)&&"tenant must contain only alphanumeric characters, hyphens, or underscores",qe=c((e=>{const t=r(x({tenant:Fe}))(e);return class extends t{get tenantId(){return this.getAttribute("tenant")||void 0}}})),ze=(e,t)=>!!t&&"light"!==t&&"dark"!==t&&'Supported theme values are "light", "dark", or leave empty for using the OS theme',Ve=c((e=>{var t,n,s,a,l,c,d,u,h,p,f,g,v,m,w,b,y,k,I,S,C,E,j;const R=r(x({theme:ze}),qe,M,O,V,P,G,A,J)(e);return j=class extends R{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",C).call(this),i(this,E,"f").call(this,"os"===this.getAttribute("theme"))})),E.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",C).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")||$e}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),i(this,t,"m",k).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,E=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}"]{${_e({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(q))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(q),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.warn("No tenant style exists, using project default theme.")}},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:De((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:De((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}"`),Ne(e.url))})):this.logger.debug("No fonts to load"),i(this,t,"m",k).call(this)},k=async function(){var e;if(!this.tenantId)return;const n=await i(this,t,"a",g),o=null===(e=null==n?void 0:n[this.theme])||void 0===e?void 0:e.fonts;Object.values(o||{}).forEach((e=>{(null==e?void 0:e.url)&&(this.logger.debug(`Loading tenant font from URL "${e.url}"`),Ne(e.url))}))},I=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)},C=function(){i(this,t,"m",y).call(this),i(this,t,"m",I).call(this)},j}));var Be=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),He=()=>Math.random().toString(36).substring(7).split("").join("."),Je={INIT:`@@redux/INIT${He()}`,REPLACE:`@@redux/REPLACE${He()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${He()}`};function Ke(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 Ye(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 Ge(e){let t=typeof e;return t=Ye(e),t}function Ze(e,t,n){if("function"!=typeof e)throw new Error(`Expected the root reducer to be a function. Instead, received: '${Ge(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: '${Ge(n)}'`);return n(Ze)(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: '${Ge(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(!Ke(e))throw new Error(`Actions must be plain objects. Instead, the actual type was: '${Ge(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: '${Ge(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:Je.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: '${Ge(e)}`);i=e,h({type:Je.REPLACE})},[Be]: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: '${Ge(t)}'`);function n(){const e=t;e.next&&e.next(d())}n();return{unsubscribe:e(n)}},[Be](){return this}}}}}function Xe(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}function Qe(e){const t=Object.keys(e),n={};for(let i=0;i<t.length;i++){const o=t[i];void 0===e[o]&&Xe(`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:Je.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:Je.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 '${Je.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===Je.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(!Ke(e))return`The ${r} has unexpected type of "${Ge(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===Je.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&&Xe(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 et(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce(((e,t)=>(...n)=>e(t(...n))))}function tt(e){return Ke(e)&&"type"in e&&"string"==typeof e.type}var nt=Symbol.for("immer-nothing"),it=Symbol.for("immer-draftable"),ot=Symbol.for("immer-state"),rt=[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 st(e,...t){{const n=rt[e],i="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${i}`)}}var at=Object.getPrototypeOf;function lt(e){return!!e&&!!e[ot]}function ct(e){return!!e&&(ut(e)||Array.isArray(e)||!!e[it]||!!e.constructor?.[it]||vt(e)||mt(e))}var dt=Object.prototype.constructor.toString();function ut(e){if(!e||"object"!=typeof e)return!1;const t=at(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)===dt}function ht(e,t){0===pt(e)?Object.entries(e).forEach((([n,i])=>{t(n,i,e)})):e.forEach(((n,i)=>t(i,n,e)))}function pt(e){const t=e[ot];return t?t.type_:Array.isArray(e)?1:vt(e)?2:mt(e)?3:0}function ft(e,t){return 2===pt(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function gt(e,t,n){const i=pt(e);2===i?e.set(t,n):3===i?e.add(n):e[t]=n}function vt(e){return e instanceof Map}function mt(e){return e instanceof Set}function wt(e){return e.copy_||e.base_}function bt(e,t){if(vt(e))return new Map(e);if(mt(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&ut(e)){if(!at(e)){const t=Object.create(null);return Object.assign(t,e)}return{...e}}const n=Object.getOwnPropertyDescriptors(e);delete n[ot];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(at(e),n)}function yt(e,t=!1){return It(e)||lt(e)||!ct(e)||(pt(e)>1&&(e.set=e.add=e.clear=e.delete=kt),Object.freeze(e),t&&ht(e,((e,t)=>yt(t,!0)))),e}function kt(){st(2)}function It(e){return Object.isFrozen(e)}var St,Ct={};function Et(e){const t=Ct[e];return t||st(0,e),t}function Ot(){return St}function At(e,t){t&&(Et("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function xt(e){jt(e),e.drafts_.forEach(Tt),e.drafts_=null}function jt(e){e===St&&(St=e.parent_)}function Rt(e){return St={drafts_:[],parent_:St,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Tt(e){const t=e[ot];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function Wt(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[ot].modified_&&(xt(t),st(4)),ct(e)&&(e=Mt(t,e),t.parent_||Pt(t,e)),t.patches_&&Et("Patches").generateReplacementPatches_(n[ot].base_,e,t.patches_,t.inversePatches_)):e=Mt(t,n,[]),xt(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==nt?e:void 0}function Mt(e,t,n){if(It(t))return t;const i=t[ot];if(!i)return ht(t,((o,r)=>Ut(e,i,t,o,r,n))),t;if(i.scope_!==e)return t;if(!i.modified_)return Pt(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),ht(o,((o,s)=>Ut(e,i,t,o,s,n,r))),Pt(e,t,!1),n&&e.patches_&&Et("Patches").generatePatches_(i,n,e.patches_,e.inversePatches_)}return i.copy_}function Ut(e,t,n,i,o,r,s){if(o===n&&st(5),lt(o)){const s=Mt(e,o,r&&t&&3!==t.type_&&!ft(t.assigned_,i)?r.concat(i):void 0);if(gt(n,i,s),!lt(s))return;e.canAutoFreeze_=!1}else s&&n.add(o);if(ct(o)&&!It(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Mt(e,o),t&&t.scope_.parent_||Pt(e,o)}}function Pt(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&yt(t,n)}var Lt={get(e,t){if(t===ot)return e;const n=wt(e);if(!ft(n,t))return function(e,t,n){const i=Nt(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_||!ct(i)?i:i===_t(e.base_,t)?(Ft(e),e.copy_[t]=qt(i,e)):i},has:(e,t)=>t in wt(e),ownKeys:e=>Reflect.ownKeys(wt(e)),set(e,t,n){const i=Nt(wt(e),t);if(i?.set)return i.set.call(e.draft_,n),!0;if(!e.modified_){const i=_t(wt(e),t),o=i?.[ot];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||ft(e.base_,t)))return!0;Ft(e),Dt(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!==_t(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,Ft(e),Dt(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=wt(e),i=Reflect.getOwnPropertyDescriptor(n,t);return i?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:i.enumerable,value:n[t]}:i},defineProperty(){st(11)},getPrototypeOf:e=>at(e.base_),setPrototypeOf(){st(12)}},$t={};function _t(e,t){const n=e[ot];return(n?wt(n):e)[t]}function Nt(e,t){if(!(t in e))return;let n=at(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=at(n)}}function Dt(e){e.modified_||(e.modified_=!0,e.parent_&&Dt(e.parent_))}function Ft(e){e.copy_||(e.copy_=bt(e.base_,e.scope_.immer_.useStrictShallowCopy_))}ht(Lt,((e,t)=>{$t[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),$t.deleteProperty=function(e,t){return isNaN(parseInt(t))&&st(13),$t.set.call(this,e,t,void 0)},$t.set=function(e,t,n){return"length"!==t&&isNaN(parseInt(t))&&st(14),Lt.set.call(this,e[0],t,n,e[0])};function qt(e,t){const n=vt(e)?Et("MapSet").proxyMap_(e,t):mt(e)?Et("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),i={type_:n?1:0,scope_:t?t.scope_:Ot(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let o=i,r=Lt;n&&(o=[i],r=$t);const{revoke:s,proxy:a}=Proxy.revocable(o,r);return i.draft_=a,i.revoke_=s,a}(e,t);return(t?t.scope_:Ot()).drafts_.push(n),n}function zt(e){return lt(e)||st(10,e),Vt(e)}function Vt(e){if(!ct(e)||It(e))return e;const t=e[ot];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=bt(e,t.scope_.immer_.useStrictShallowCopy_)}else n=bt(e,!0);return ht(n,((e,t)=>{gt(n,e,Vt(t))})),t&&(t.finalized_=!1),n}var Bt=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&&st(6),void 0!==n&&"function"!=typeof n&&st(7),ct(e)){const o=Rt(this),r=qt(e,void 0);let s=!0;try{i=t(r),s=!1}finally{s?xt(o):jt(o)}return At(o,n),Wt(i,o)}if(!e||"object"!=typeof e){if(i=t(e),void 0===i&&(i=e),i===nt&&(i=void 0),this.autoFreeze_&&yt(i,!0),n){const t=[],o=[];Et("Patches").generateReplacementPatches_(e,i,t,o),n(t,o)}return i}st(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){ct(e)||st(8),lt(e)&&(e=zt(e));const t=Rt(this),n=qt(e,void 0);return n[ot].isManual_=!0,jt(t),n}finishDraft(e,t){const n=e&&e[ot];n&&n.isManual_||st(9);const{scope_:i}=n;return At(i,t),Wt(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=Et("Patches").applyPatches_;return lt(e)?i(e,t):this.produce(e,(e=>i(e,t)))}},Ht=Bt.produce;Bt.produceWithPatches.bind(Bt),Bt.setAutoFreeze.bind(Bt),Bt.setUseStrictShallowCopy.bind(Bt),Bt.applyPatches.bind(Bt),Bt.createDraft.bind(Bt),Bt.finishDraft.bind(Bt);var Jt=(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})}}},Kt=(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})}},Yt={inputStabilityCheck:"once",identityFunctionCheck:"once"};var Gt=e=>Array.isArray(e)?e:[e];function Zt(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 Xt(e,t){const n=[],{length:i}=e;for(let o=0;o<i;o++)n.push(e[o].apply(null,t));return n}var Qt="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}},en=0,tn=1;function nn(){return{s:en,v:void 0,o:null,p:null}}function on(e,t={}){let n=nn();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=nn(),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=nn(),e.set(n,t)):t=i}}const a=t;let l;if(t.s===tn)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 Qt(l):l}return a.s=tn,a.v=l,l}return s.clearCache=()=>{n=nn(),s.resetResultsCount()},s.resultsCount=()=>r,s.resetResultsCount=()=>{r=0},s}function rn(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=on,argsMemoizeOptions:u=[],devModeChecks:h={}}=a,p=Gt(c),f=Gt(u),g=Zt(e),v=l((function(){return i++,s.apply(null,arguments)}),...p);let m=!0;const w=d((function(){o++;const e=Xt(g,arguments);t=v.apply(null,e);{const{identityFunctionCheck:n,inputStabilityCheck:i}=((e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:i}={...Yt,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:Jt},inputStabilityCheck:{shouldRun:"always"===i||"once"===i&&e,run:Kt}}})(m,h);if(n.shouldRun&&n.run(s,e,t),i.shouldRun){const t=Xt(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 sn=rn(on),an=Object.assign(((e,t=sn)=>{!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:()=>an});function ln(e){return({dispatch:t,getState:n})=>i=>o=>"function"==typeof o?o(t,n,e):i(o)}var cn=ln(),dn=ln;((...e)=>{const t=rn(...e)})(on);var un="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?et:et.apply(null,arguments)},hn=e=>e&&"function"==typeof e.match;function pn(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=>tt(t)&&t.type===e,n}function fn(e){return"function"==typeof e&&"type"in e&&hn(e)}function gn(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 vn=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 mn(e){return ct(e)?Ht(e,(()=>{})):e}function wn(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 bn(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function yn(e,t,n){const i=kn(e,t,n);return{detectMutations:()=>In(e,t,i,n)}}function kn(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]=kn(e,t,n[o],s))}}return r}function In(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=In(e,t,n.children[o],i[o],a,s);if(l.wasMutated)return l}return{wasMutated:!1}}function Sn(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||Ke(e)}function Cn(e,t="",n=Sn,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=Cn(c,a,n,i,o,r),s))return s}return r&&En(e)&&r.add(e),!1}function En(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!En(t))return!1;return!0}function On(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 vn;if(t&&(On(t)?r.push(cn):r.push(dn(t.extraArgument))),n){let e={};On(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=bn,ignoredPaths:o,warnAfter:r=32}=e;const s=yn.bind(null,i,o);return({getState:e})=>{let n,i=e(),o=s(i);return a=>l=>{const c=gn(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={};On(i)||(e=i),r.push(function(e={}){{const{isSerializable:t=Sn,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(!tt(u))return c(u);const h=c(u),p=gn(s,"SerializableStateInvariantMiddleware");return l||i.length&&-1!==i.indexOf(u.type)||p.measureTime((()=>{const e=Cn(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=Cn(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={};On(o)||(e=o),r.unshift(function(e={}){const{isActionCreator:t=fn}=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},xn=e=>t=>{setTimeout(t,e)},jn="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:xn(10),Rn=e=>function(t){const{autoBatch:n=!0}=t??{};let i=new vn(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?jn:"callback"===e.type?e.queueNotification:xn(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 Tn(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(!Ke(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=Qe(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=et;o&&(c=un({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=et(...a)(o.dispatch),{...o,dispatch:r}}}(...l),u=Rn(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 Ze(a,r,c(...h))}function Wn(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 Mn(...e){return t=>e.some((e=>((e,t)=>hn(e)?e.match(t):e(t))(e,t)))}var Un=["name","message","stack","code"],Pn=class{constructor(e,t){this.payload=e,this.meta=t}_type},Ln=class{constructor(e,t){this.payload=e,this.meta=t}_type},$n=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)}},_n=(()=>{function e(e,t,n){const i=pn(e+"/fulfilled",((e,t,n,i)=>({payload:e,meta:{...i||{},arg:n,requestId:t,requestStatus:"fulfilled"}}))),o=pn(e+"/pending",((e,t,n)=>({payload:void 0,meta:{...n||{},arg:t,requestId:e,requestStatus:"pending"}}))),r=pn(e+"/rejected",((e,t,i,o,r)=>({payload:o,error:(n&&n.serializeError||$n)(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 Pn(e,t),fulfillWithValue:(e,t)=>new Ln(e,t)})).then((t=>{if(t instanceof Pn)throw t;return t instanceof Ln?i(t.payload,c,e,t.meta):i(t,c,e)}))])}catch(t){p=t instanceof Pn?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(Nn)})}}),{pending:o,rejected:r,fulfilled:i,settled:Mn(r,i),typePrefix:e})}return e.withTypes=()=>e,e})();function Nn(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}var Dn=Symbol.for("rtk-slice-createasyncthunk");function Fn(e,t){return`${e}/${t}`}function qn(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 zn=function({creators:e}={}){const t=e?.asyncThunk?.[Dn];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?Wn(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]=Wn(t);if(function(e){return"function"==typeof e}(e))n=()=>mn(e());else{const t=mn(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(lt(e)){const i=n(e,t);return void 0===i?e:i}if(ct(e))return Ht(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:Fn(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?pn(e,s):pn(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||Vn,pending:a||Vn,rejected:l||Vn,settled:c||Vn})}(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=wn(d,this,{insert:()=>new WeakMap});return wn(n,t,{insert:()=>{const n={};for(const[i,o]of Object.entries(e.selectors??{}))n[i]=qn(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 Vn(){}var Bn="listenerMiddleware";pn(`${Bn}/add`),pn(`${Bn}/removeAll`),pn(`${Bn}/remove`);const Hn=e=>c((t=>{const n=zn(e),i=Object.assign(Object.assign({},n.actions),e.asyncActions);return class extends(r(y)(t)){constructor(...e){super(...e);const t=Tn({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{Nn(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(y(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 Jn=c((e=>{const t=r(x({"widget-id":E}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}}})),Kn=c((e=>{const t=r(P,Jn)(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]}async getHostedPageBaseUrl(){var e;const t=await this.config;return null===(e=null==t?void 0:t.projectConfig)||void 0===e?void 0:e.hostedPageBaseUrl}}})),Yn=c((e=>class extends e{get locale(){return this.getAttribute("locale")||""}get localeCandidates(){const{locale:e,fallback:t}=m(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:""}})),Gn=e=>c((t=>{var n,o,s;const a=r(M,Jn,Kn,Yn)(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})),Zn=c((e=>class extends e{get refreshCookieName(){return this.getAttribute("refresh-cookie-name")||""}})),Xn=k&&localStorage.getItem("base.debug.logs.url"),Qn=c((e=>{const t=r(x({"flow-id":E}))(e);return class extends t{get flowId(){return this.getAttribute("flow-id")}}}));function ei(e){const t=Math.floor(e/1e3);if(t<60)return`${t} seconds`;const n=Math.floor(t/60);if(n<60)return`${n} minutes`;const i=Math.floor(n/60);return i<24?`${i} hours`:`${Math.floor(i/24)} days`}const ti=c((e=>{var t,n,s,a,l,c,d,u,h,p,f,g;const v=r(F,y,O,P,j,Qn)(e);return g=class extends v{constructor(){super(...arguments),t.add(this),n.set(this,null),s.set(this,!1),a.set(this,null),f.set(this,null)}get telemetryManager(){return i(this,n,"f")}updateTelemetryContext(e){if(i(this,n,"f"))try{i(this,n,"f").updateContext(e)}catch(e){this.logger.error("Error updating telemetry context:",e)}}async init(){var e;await(null===(e=super.init)||void 0===e?void 0:e.call(this));const n=this.sdkVersion||"1.0.0";o(this,f,i(this,t,"m",h).call(this).then((e=>i(this,t,"m",l).call(this,e,{projectId:this.projectId,flowId:this.flowId,sdkVersion:n}))).catch((e=>{this.logger.error("Failed to start telemetry:",e)})),"f")}get telemetryReady(){var e;return null!==(e=i(this,f,"f"))&&void 0!==e?e:Promise.resolve()}disconnectedCallback(){var e;null===(e=super.disconnectedCallback)||void 0===e||e.call(this),i(this,t,"m",d).call(this)}},n=new WeakMap,s=new WeakMap,a=new WeakMap,f=new WeakMap,t=new WeakSet,l=async function(e,r){if(null==e?void 0:e.enabled)if(i(this,s,"f"))this.logger.debug("Telemetry already initialized");else if(e.expiration&&Date.now()>=e.expiration)this.logger.info(`Telemetry expiration time has passed (${new Date(e.expiration).toISOString()}), skipping initialization`);else try{this.logger.debug("Initializing telemetry...");const a=e.version||"latest";await this.injectNpmLib("@descope/debug-logs",a,"dist/index.js",[Xn]);const l=window.DescopeDebugLogs;if(!l)throw new Error("DescopeDebugLogs not found after loading @descope/debug-logs. This likely means the UMD build failed to load from CDN.");if(o(this,n,new l({enabled:!0,rumConfig:e.rumConfig,capture:e.capture},{projectId:r.projectId,flowId:r.flowId,version:r.sdkVersion||"1.0.0"},this.logger),"f"),!i(this,n,"f").isReady())return this.logger.error("Telemetry manager failed to initialize (RUM client not ready)"),void o(this,n,null,"f");o(this,s,!0,"f"),this.logger.info("Telemetry initialized successfully"),e.expiration&&i(this,t,"m",c).call(this,e.expiration)}catch(e){this.logger.error("Failed to initialize telemetry:",e),o(this,s,!1,"f")}else this.logger.debug("Telemetry is disabled, skipping initialization")},c=function(e){const n=e-Date.now();if(n<=0)return this.logger.info("Telemetry expiration time reached, shutting down"),void i(this,t,"m",d).call(this);const r=864e5,s=Math.min(n,r);n>r&&this.logger.warn(`Telemetry expiration is beyond maximum timeout (${ei(n)}). Setting to maximum.`),this.logger.info(`Telemetry will expire at ${new Date(e).toISOString()} (in ${ei(s)})`),o(this,a,setTimeout((()=>{this.logger.info("Telemetry expiration time reached, shutting down"),i(this,t,"m",d).call(this)}),s),"f")},d=function(){if(i(this,a,"f")&&(clearTimeout(i(this,a,"f")),o(this,a,null,"f")),i(this,n,"f"))try{this.logger.debug("Shutting down telemetry..."),i(this,n,"f").shutdown(),o(this,n,null,"f"),o(this,s,!1,"f"),this.logger.info("Telemetry shutdown complete")}catch(e){this.logger.error("Error shutting down telemetry:",e)}},u=function(e){return Boolean((null==e?void 0:e.applicationId)&&(null==e?void 0:e.identityPoolId)&&(null==e?void 0:e.region))},h=async function(){var e;const n=await this.config,o=null===(e=null==n?void 0:n.projectConfig)||void 0===e?void 0:e.telemetry;let r;try{const e=Number(process.env.DESCOPE_TELEMETRY_SESSION_SAMPLE_RATE);r={enabled:"true"===(process.env.DESCOPE_TELEMETRY_ENABLED||"").toLowerCase(),rumConfig:Object.assign({applicationId:process.env.DESCOPE_TELEMETRY_APPLICATION_ID||"",identityPoolId:process.env.DESCOPE_TELEMETRY_IDENTITY_POOL_ID||"",region:process.env.DESCOPE_TELEMETRY_REGION||"",sessionSampleRate:Number.isFinite(e)&&e>0?e:1},process.env.DESCOPE_TELEMETRY_GUEST_ROLE_ARN&&{guestRoleArn:process.env.DESCOPE_TELEMETRY_GUEST_ROLE_ARN})}}catch(e){r={enabled:!1,rumConfig:{applicationId:"",identityPoolId:"",region:"",sessionSampleRate:1}}}const s=Object.assign(Object.assign(Object.assign({},r),o),{rumConfig:Object.assign(Object.assign({},r.rumConfig),null==o?void 0:o.rumConfig),capture:i(this,t,"m",p).call(this,null==o?void 0:o.capture)});return s.enabled&&!i(this,t,"m",u).call(this,s.rumConfig)&&(this.logger.warn("Telemetry enabled but rumConfig is incomplete (applicationId/identityPoolId/region required). Skipping initialization."),s.enabled=!1),o||(s.expiration=Date.now()+3e5,this.logger.debug("No backend telemetry config present; applying a 5-minute safety cap on the session.")),s},p=function(e){const t=null==e?void 0:e.dom;return!1===t?Object.assign(Object.assign({console:!0,network:!0,navigation:!0},e),{dom:!1}):Object.assign(Object.assign({console:!0,network:!0,navigation:!0},e),{dom:Object.assign(Object.assign({throttleMs:2e3},"object"==typeof t?t:{}),{rootElement:this.shadowRoot})})},g})),ni=c((e=>{var n,o,r;return r=class extends(Ve(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})),ii=/(["\\])/g;function oi(e,t){return Array.from(e.querySelectorAll(`[data-id="${n=t,"undefined"!=typeof CSS&&"function"==typeof CSS.escape?CSS.escape(n):n.replace(ii,"\\$1")}"]`));var n}function ri(e,t){e&&t&&Object.entries(t).forEach((([t,n])=>{oi(e,t).forEach((e=>function(e,t){var n;switch(t){case"hide":e.setAttribute("hidden",""),null===(n=e.style)||void 0===n||n.setProperty("display","none","important");break;case"disable":e.setAttribute("disabled","true");break;case"read-only":e.setAttribute("readonly","true")}}(e,n)))}))}const si=c((e=>{var t,n,s,a,l,c;const d=r(y,G)(e);return c=class extends d{constructor(){super(...arguments),t.add(this),n.set(this,void 0),s.set(this,{})}async init(){var e,r;if("true"===this.getAttribute("mock"))return o(this,n,Promise.resolve({}),"f"),void await(null===(e=super.init)||void 0===e?void 0:e.call(this));const s=i(this,t,"m",a).call(this);o(this,n,i(this,t,"m",l).call(this,s),"f"),await(null===(r=super.init)||void 0===r?void 0:r.call(this))}async onWidgetRootReady(){var e,t;await(null===(e=super.onWidgetRootReady)||void 0===e?void 0:e.call(this)),o(this,s,null!==(t=await i(this,n,"f"))&&void 0!==t?t:{},"f"),ri(this.contentRootElement,i(this,s,"f"))}async reevaluateComponentsState(){const e=i(this,t,"m",a).call(this);var n,r;n=this.contentRootElement,r=i(this,s,"f"),n&&r&&Object.entries(r).forEach((([e,t])=>{oi(n,e).forEach((e=>function(e,t){var n;switch(t){case"hide":e.removeAttribute("hidden"),null===(n=e.style)||void 0===n||n.removeProperty("display");break;case"disable":e.removeAttribute("disabled");break;case"read-only":e.removeAttribute("readonly")}}(e,t)))})),o(this,s,await i(this,t,"m",l).call(this,e),"f"),ri(this.contentRootElement,i(this,s,"f"))}},n=new WeakMap,s=new WeakMap,t=new WeakSet,a=function(){var e;const t=null===(e=this.api)||void 0===e?void 0:e.httpClient;if(!t)throw new Error("componentsConditionsMixin: the widget sdk must expose `httpClient`. Compose apiMixin and return `webSdk.httpClient` from createSdk.");return t},l=async function(e){var t;try{const n=await e.get("/v1/mgmt/widget/components-state");if(!(null==n?void 0:n.ok))return{};const i=await n.json();return null!==(t=null==i?void 0:i.componentsState)&&void 0!==t?t:{}}catch(e){return this.logger.debug("components-conditions: failed to fetch, showing all components",null==e?void 0:e.message),{}}},c}));function ai(e){return new URLSearchParams(window.location.search).get(e)}const li=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)}))}))},ci=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}}),di=_n("users/me",((e,{extra:{api:t}})=>t.user.me())),ui=li(di)({onFulfilled:(e,t)=>{e.me.data=t.payload}},ci((e=>e.me))),hi={action:di,reducer:ui},pi=_n("users/devices",((e,{extra:{api:t}})=>t.device.devices(e))),fi=li(pi)({onFulfilled:(e,t)=>{e.devices.data=t.payload.devices}},ci((e=>e.devices))),gi={action:pi,reducer:fi},vi=_n("users/passkeys",((e,{extra:{api:t}})=>t.passkey.listPasskeys(e))),mi=li(vi)({onFulfilled:(e,t)=>{e.passkeys.data=t.payload.passkeys}},ci((e=>e.passkeys))),wi={action:vi,reducer:mi},bi=_n("users/logout",((e,{extra:{api:t}})=>t.user.logout())),yi={action:bi,reducer:li(bi)({})};class ki extends Error{}function Ii(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 Si(e,t){if("string"!=typeof e)throw new ki("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 ki(`Invalid token specified: missing part #${n+1}`);let o;try{o=Ii(i)}catch(e){throw new ki(`Invalid token specified: invalid base64 for part #${n+1} (${e.message})`)}try{return JSON.parse(o)}catch(e){throw new ki(`Invalid token specified: invalid json for part #${n+1} (${e.message})`)}}ki.prototype.name="InvalidTokenError";var Ci={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",phone:"/v1/auth/enchantedlink/update/phone"},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"},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",event:"/v1/flow/event"}};const Ei="<region>",Oi=`https://api.${Ei}descope.com`,Ai=6e5,xi=()=>{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")}},ji=[503,520,521,522,524,530],Ri=[100,5e3,5e3],Ti=e=>new Promise((t=>setTimeout(t,e))),Wi=e=>async function(...t){let n=await e(...t);const i=!!(null==(o=t[1])?void 0:o.disableRetry);var o;let r=0;for(;!i&&ji.includes(n.status)&&r<Ri.length;)await Ti(Ri[r]),n=await e(...t),r++;r>0&&(n.retries=r);const s=await n.text();return n.text=()=>Promise.resolve(s),n.json=()=>Promise.resolve(JSON.parse(s)),n.clone=()=>n,n};let Mi;const Ui=()=>{if(Mi)return Mi;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 Mi=`${t}-${n}`,Mi};var Pi;!function(e){e.get="GET",e.delete="DELETE",e.post="POST",e.put="PUT",e.patch="PATCH"}(Pi||(Pi={}));const Li=({path:e,baseUrl:t,queryParams:n,projectId:i})=>{const o=i.slice(1,-27);t=t.replace(Ei,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},$i=(...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)),{})),_i={"Content-Type":"application/json"},Ni=(e,t="")=>{let n=e;return t&&(n=n+":"+t),{Authorization:`Bearer ${n}`}},Di=(e,t)=>{const n={"x-descope-sdk-session-id":Ui(),"x-descope-sdk-name":"core-js","x-descope-sdk-version":"2.77.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 qi=e=>{var t;return(({baseUrl:e,projectId:t,baseConfig:n,refreshCookieName:i,logger:o,hooks:r,cookiePolicy:s,fetch:a})=>{const l=e||Oi,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=>xi().title("Request").url(e[0]).method(e[1].method).headers(e[1].headers).body(e[1].body).build())(t));const i=await Wi(n)(...t);return e[i.ok?"log":"error"](await(async e=>{const t=await e.text();return xi().title("Response").url(e.url.toString()).status(`${e.status} ${e.statusText}`).headers(e.headers).body(t).retries(e.retries).build()})(i)),i}:Wi(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,keepalive:v,disableRetry:m}=a,w=(e=>void 0===e?void 0:JSON.stringify(e))(u),b=Object.assign(Object.assign({headers:$i(Ni(t,g),Di(t,i),(null==n?void 0:n.baseHeaders)||{},Fi(w)?_i:{},h),method:f,body:w},v?{keepalive:!0}:{}),m?{disableRetry:!0}:{});null!==s&&(b.credentials=s||"include");const y=await c(Li({path:d,baseUrl:l,queryParams:p,projectId:t}),b);if((null==r?void 0:r.afterRequest)&&await r.afterRequest(e,null==y?void 0:y.clone()),null==r?void 0:r.transformResponse){const e=await y.json(),t=(k=(null===(o=y.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}(k).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.create(null),{json:()=>Promise.resolve(e),cookies:t}),i=new Proxy(y,{get:(e,t)=>{if(t in n)return n[t];const i=e[t];return"function"==typeof i?i.bind(e):i},set:(e,t,i)=>(n[t]=i,!0),has:(e,t)=>t in n||t in e});return n.clone=()=>i,r.transformResponse(i)}var k;return y};return{get:(e,{headers:t,queryParams:n,token:i,keepalive:o,disableRetry:r}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:Pi.get,token:i,keepalive:o,disableRetry:r}),post:(e,t,{headers:n,queryParams:i,token:o,keepalive:r,disableRetry:s}={})=>d({path:e,headers:n,queryParams:i,body:t,method:Pi.post,token:o,keepalive:r,disableRetry:s}),patch:(e,t,{headers:n,queryParams:i,token:o,keepalive:r,disableRetry:s}={})=>d({path:e,headers:n,queryParams:i,body:t,method:Pi.patch,token:o,keepalive:r,disableRetry:s}),put:(e,t,{headers:n,queryParams:i,token:o,keepalive:r,disableRetry:s}={})=>d({path:e,headers:n,queryParams:i,body:t,method:Pi.put,token:o,keepalive:r,disableRetry:s}),delete:(e,{headers:t,queryParams:n,token:i,keepalive:o,disableRetry:r}={})=>d({path:e,headers:t,queryParams:n,body:void 0,method:Pi.delete,token:i,keepalive:o,disableRetry:r}),hooks:r,buildUrl:(e,n)=>Li({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}}))},zi=429;function Vi(e,t,n){var i;let o=Bi(e);if(t){if(!(null==o?void 0:o.tenants)&&(null==o?void 0:o.dct)===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 Bi(e){if("string"!=typeof e||!e)throw new Error("Invalid token provided");return Si(e)}function Hi(e){const{exp:t}=Bi(e);return(new Date).getTime()/1e3>t}function Ji(e){let t=Bi(e);const n=Object.keys(null==t?void 0:t.tenants);return Array.isArray(n)?n:[]}function Ki(e,t){return Vi(e,t,"permissions")}function Yi(e,t){return Vi(e,t,"roles")}const Gi=(...e)=>e.join("/").replace(/\/{2,}/g,"/");async function Zi(e,t){var n,i;const o=await e,r={code:o.status,ok:o.ok,response:o},s=await o.clone().json();if(o.ok)r.data=s;else{r.error=s,o.status===zi&&Object.assign(r.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0});const e=null===(i=o.headers)||void 0===i?void 0:i.get("cf-ray");e&&r.error&&Object.assign(r.error,{traceId:e})}return r}function Xi(e){var t;return(null===(t=Bi(e))||void 0===t?void 0:t.dct)||""}const Qi=(e,t)=>(n=t)=>t=>!e(t)&&n.replace("{val}",t),eo=(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 "))},to=(...e)=>({validate:t=>(e.forEach((e=>{const n=e(t);if(n)throw new Error(n)})),!0)}),no=e=>t=>e.test(t),io=no(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),oo=no(/^\+[1-9]{1}[0-9]{3,14}$/),ro=Qi(io,'"{val}" is not a valid email'),so=Qi(oo,'"{val}" is not a valid phone number'),ao=Qi((e=>e.length>=1),"Minimum length is 1");const lo=Qi((e=>"string"==typeof e),"Input is not a string"),co=Qi((e=>Array.isArray(e)),"Input is not an array"),uo=Qi((e=>"boolean"==typeof e),"Input is not a boolean"),ho=Qi((e=>void 0===e),"Input is defined"),po=eo([lo(),ho()],"Input is not a string or undefined"),fo=eo([co(),uo()],"Input is not an array or boolean"),go=(...e)=>t=>(...n)=>(e.forEach(((e,t)=>to(...e).validate(n[t]))),t(...n)),vo=e=>[lo(`"${e}" must be a string`)],mo=e=>[po(`"${e}" must be string or undefined`)],wo=e=>[lo(`"${e}" must be a string`),ao(`"${e}" must not be empty`)],bo=e=>[lo(`"${e}" must be a string`),ro()],yo=e=>[lo(`"${e}" must be a string`),so()],ko=go(wo("accessKey")),Io=e=>({exchange:ko(((t,n)=>Zi(e.post(Ci.accessKey.exchange,{loginOptions:n},{token:t}))))}),So=(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),Co=({pollingIntervalMs:e=1e3,timeoutMs:t=6e5}={})=>({pollingIntervalMs:Math.max(e||1e3,1e3),timeoutMs:Math.min(t||Ai,Ai)});var Eo,Oo;!function(e){e.sms="sms",e.voice="voice",e.whatsapp="whatsapp",e.im="im"}(Eo||(Eo={})),function(e){e.email="email"}(Oo||(Oo={}));const Ao=Object.assign(Object.assign({},Eo),Oo);var xo;!function(e){e.waiting="waiting",e.running="running",e.completed="completed",e.failed="failed"}(xo||(xo={}));const jo=wo("loginId"),Ro=go(wo("token")),To=go(jo),Wo=go(wo("pendingRef")),Mo=go(jo,yo("phone")),Uo=go(jo,bo("email")),Po=e=>{const n=n=>(i,o,r={},s)=>{var{providerId:a}=r,l=t(r,["providerId"]);return Zi(e.post(Gi(Ci.enchantedLink.signIn,n),{loginId:i,URI:o,loginOptions:l,providerId:a},{token:s}))},i=n=>(i,o,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return Zi(e.post(Gi(Ci.enchantedLink.signUpOrIn,n),{loginId:i,URI:o,loginOptions:a,providerId:s}))},o=n=>(i,o,r,s={})=>{var{providerId:a}=s,l=t(s,["providerId"]);return Zi(e.post(Gi(Ci.enchantedLink.signUp,n),{loginId:i,URI:o,user:r,loginOptions:l,providerId:a}))};return{verify:Ro((t=>Zi(e.post(Ci.enchantedLink.verify,{token:t})))),signIn:To(n(Ao.email)),signInWithPhone:To(n(Eo.sms)),signUpOrIn:To(i(Ao.email)),signUpOrInWithPhone:To(i(Eo.sms)),signUp:To(o(Ao.email)),signUpWithPhone:To(o(Eo.sms)),waitForSession:Wo(((t,n)=>new Promise((i=>{const{pollingIntervalMs:o,timeoutMs:r}=Co(n);let s;const a=setInterval((async()=>{const n=await e.post(Ci.enchantedLink.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),i(Zi(Promise.resolve(n))))}),o);s=setTimeout((()=>{i({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:Uo(((t,n,i,o,r)=>Zi(e.post(Ci.enchantedLink.update.email,Object.assign({loginId:t,email:n,URI:i},r),{token:o})))),phone:{sms:Mo(((t,n,i,o,r)=>Zi(e.post(Gi(Ci.enchantedLink.update.phone,Eo.sms),Object.assign({loginId:t,phone:n,URI:i},r),{token:o}))))}}}},Lo=go(wo("flowId")),$o=go(wo("executionId"),wo("stepId"),wo("interactionId")),_o=go(wo("executionId")),No=e=>({start:Lo(((t,n,i,o,r,s,a,l=!1)=>Zi(e.post(Ci.flow.start,{flowId:t,options:n,conditionInteractionId:i,interactionId:o,componentsVersion:r,flowVersions:s,input:a,isCustomScreen:l})))),next:$o(((t,n,i,o,r,s,a=!1,l)=>Zi(e.post(Ci.flow.next,{executionId:t,stepId:n,interactionId:i,version:o,componentsVersion:r,input:s,isCustomScreen:a,options:l})))),event:_o(((t,n,i)=>Zi(e.post(Ci.flow.event,{executionId:t,events:n},{keepalive:i,disableRetry:!0}))))}),Do=wo("loginId"),Fo=go(wo("token")),qo=go(Do);go(wo("pendingRef"));const zo=go(Do,yo("phone")),Vo=go(Do,bo("email")),Bo=Object.keys(Ao).filter((e=>e!==Eo.voice&&e!==Eo.im)),Ho=e=>({verify:Fo((t=>Zi(e.post(Ci.magicLink.verify,{token:t})))),signIn:Bo.reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:qo(((n,o,r={},s)=>{var{providerId:a}=r,l=t(r,["providerId"]);return Zi(e.post(Gi(Ci.magicLink.signIn,i),{loginId:n,URI:o,loginOptions:l,providerId:a},{token:s}))}))})),{}),signUp:Bo.reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:qo(((n,o,r,s={})=>{var{providerId:a}=s,l=t(s,["providerId"]);return Zi(e.post(Gi(Ci.magicLink.signUp,i),{loginId:n,URI:o,user:r,loginOptions:l,providerId:a}))}))})),{}),signUpOrIn:Bo.reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:qo(((n,o,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return Zi(e.post(Gi(Ci.magicLink.signUpOrIn,i),{loginId:n,URI:o,loginOptions:a,providerId:s}))}))})),{}),update:{email:Vo(((t,n,i,o,r)=>Zi(e.post(Ci.magicLink.update.email,Object.assign({loginId:t,email:n,URI:i},r),{token:o})))),phone:Object.keys(Eo).filter((e=>e!==Eo.voice)).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:zo(((t,i,o,r,s)=>Zi(e.post(Gi(Ci.magicLink.update.phone,n),Object.assign({loginId:t,phone:i,URI:o},s),{token:r}))))})),{})}});var Jo;!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"}(Jo||(Jo={}));const Ko=go(wo("code")),Yo=e=>({start:Object.assign(((t,n,i,o,r)=>Zi(e.post(Ci.oauth.start,i||{},{queryParams:Object.assign(Object.assign({provider:t},n&&{redirectURL:n}),r&&{loginHint:r}),token:o}))),Object.keys(Jo).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:(t,i,o,r)=>Zi(e.post(Ci.oauth.start,i||{},{queryParams:Object.assign(Object.assign({provider:n},t&&{redirectURL:t}),r&&{loginHint:r}),token:o}))})),{})),exchange:Ko((t=>Zi(e.post(Ci.oauth.exchange,{code:t})))),startNative:(t,n,i)=>Zi(e.post(Ci.oauth.startNative,{provider:t,loginOptions:n,implicit:i})),finishNative:(t,n,i,o,r)=>Zi(e.post(Ci.oauth.finishNative,{provider:t,stateId:n,user:i,code:o,idToken:r})),getOneTapClientId:t=>Zi(e.get(Ci.oauth.oneTap.getOneTapClientId.replace("{provider}",t))),verifyOneTapIDToken:(t,n,i,o)=>Zi(e.post(Ci.oauth.oneTap.verifyOneTapIDToken,{provider:t,idToken:n,nonce:i,loginOptions:o})),exchangeOneTapIDToken:(t,n,i,o)=>Zi(e.post(Ci.oauth.oneTap.exchangeOneTapIDToken,{provider:t,idToken:n,nonce:i,loginOptions:o}))}),Go=wo("appId"),Zo=go(Go),Xo=e=>({connect:Zo(((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,Zi(e.post(Ci.outbound.connect,{appId:t,tenantId:o,tenantLevel:r,options:n},{token:i}))}))}),Qo=wo("loginId"),er=go(Qo,wo("code")),tr=go(Qo),nr=go(Qo,yo("phone")),ir=go(Qo,bo("email")),or=e=>({verify:Object.keys(Ao).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:er(((t,i)=>Zi(e.post(Gi(Ci.otp.verify,n),{code:i,loginId:t}))))})),{}),signIn:Object.keys(Ao).reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:tr(((n,o={},r)=>{var{providerId:s}=o,a=t(o,["providerId"]);return Zi(e.post(Gi(Ci.otp.signIn,i),{loginId:n,loginOptions:a,providerId:s},{token:r}))}))})),{}),signUp:Object.keys(Ao).reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:tr(((n,o,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return Zi(e.post(Gi(Ci.otp.signUp,i),{loginId:n,user:o,loginOptions:a,providerId:s}))}))})),{}),signUpOrIn:Object.keys(Ao).reduce(((n,i)=>Object.assign(Object.assign({},n),{[i]:tr(((n,o={})=>{var{providerId:r}=o,s=t(o,["providerId"]);return Zi(e.post(Gi(Ci.otp.signUpOrIn,i),{loginId:n,loginOptions:s,providerId:r}))}))})),{}),update:{email:ir(((t,n,i,o)=>Zi(e.post(Ci.otp.update.email,Object.assign({loginId:t,email:n},o),{token:i})))),phone:Object.keys(Eo).reduce(((t,n)=>Object.assign(Object.assign({},t),{[n]:nr(((t,i,o,r)=>Zi(e.post(Gi(Ci.otp.update.phone,n),Object.assign({loginId:t,phone:i},r),{token:o}))))})),{})}}),rr=go(wo("tenant")),sr=go(wo("code")),ar=e=>({start:rr(((t,n,i,o,r,s,a,l)=>Zi(e.post(Ci.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:sr((t=>Zi(e.post(Ci.sso.exchange,{code:t}))))}),lr=wo("loginId"),cr=go(lr,wo("code")),dr=go(lr),ur=go(lr),hr=e=>({signUp:dr(((t,n)=>Zi(e.post(Ci.totp.signUp,{loginId:t,user:n})))),verify:cr(((t,n,i,o)=>Zi(e.post(Ci.totp.verify,{loginId:t,code:n,loginOptions:i},{token:o})))),update:ur(((t,n)=>Zi(e.post(Ci.totp.update,{loginId:t},{token:n}))))}),pr=wo("loginId"),fr=wo("newPassword"),gr=go(pr,wo("password")),vr=go(pr),mr=go(pr,fr),wr=go(pr,wo("oldPassword"),fr),br=e=>({signUp:gr(((n,i,o,r={})=>{var{providerId:s}=r,a=t(r,["providerId"]);return Zi(e.post(Ci.password.signUp,{loginId:n,password:i,user:o,loginOptions:a,providerId:s}))})),signIn:gr(((n,i,o={})=>{var{providerId:r}=o,s=t(o,["providerId"]);return Zi(e.post(Ci.password.signIn,{loginId:n,password:i,loginOptions:s,providerId:r}))})),sendReset:vr(((t,n,i)=>Zi(e.post(Ci.password.sendReset,{loginId:t,redirectUrl:n,templateOptions:i})))),update:mr(((t,n,i)=>Zi(e.post(Ci.password.update,{loginId:t,newPassword:n},{token:i})))),replace:wr(((t,n,i)=>Zi(e.post(Ci.password.replace,{loginId:t,oldPassword:n,newPassword:i})))),policy:()=>Zi(e.get(Ci.password.policy))}),yr=vo("loginId"),kr=wo("loginId"),Ir=vo("origin"),Sr=go(kr,Ir,wo("name")),Cr=go(kr,Ir),Er=go(yr,Ir),Or=go(kr,Ir,mo("token")),Ar=go(wo("transactionId"),wo("response")),xr=e=>({signUp:{start:Sr(((t,n,i,o,r)=>Zi(e.post(Ci.webauthn.signUp.start,{user:{loginId:t,name:i},origin:n,loginOptions:r,passkeyOptions:o})))),finish:Ar(((t,n)=>Zi(e.post(Ci.webauthn.signUp.finish,{transactionId:t,response:n}))))},signIn:{start:Er(((t,n,i,o,r)=>Zi(e.post(Ci.webauthn.signIn.start,{loginId:t,origin:n,loginOptions:i,passkeyOptions:r},{token:o})))),finish:Ar(((t,n)=>Zi(e.post(Ci.webauthn.signIn.finish,{transactionId:t,response:n}))))},signUpOrIn:{start:Cr(((t,n,i,o)=>Zi(e.post(Ci.webauthn.signUpOrIn.start,{loginId:t,origin:n,loginOptions:o,passkeyOptions:i}))))},update:{start:Or(((t,n,i,o,r)=>Zi(e.post(Ci.webauthn.update.start,{loginId:t,origin:n,passkeyOptions:o,mfa:r},{token:i})))),finish:Ar(((t,n)=>Zi(e.post(Ci.webauthn.update.finish,{transactionId:t,response:n}))))}}),jr=vo("loginId"),Rr=go(jr),Tr=go(wo("pendingRef")),Wr=e=>({signUpOrIn:Rr(((n,i={})=>{var{providerId:o}=i,r=t(i,["providerId"]);return Zi(e.post(Ci.notp.signUpOrIn,{loginId:n,loginOptions:r,providerId:o}))})),signUp:Rr(((n,i,o={})=>{var{providerId:r}=o,s=t(o,["providerId"]);return Zi(e.post(Ci.notp.signUp,{loginId:n,user:i,providerId:r,loginOptions:s}))})),signIn:Rr(((n,i={},o)=>{var{providerId:r}=i,s=t(i,["providerId"]);return Zi(e.post(Ci.notp.signIn,{loginId:n,loginOptions:s,providerId:r},{token:o}))})),waitForSession:Tr(((t,n)=>new Promise((i=>{const{pollingIntervalMs:o,timeoutMs:r}=Co(n);let s;const a=setInterval((async()=>{const n=await e.post(Ci.notp.session,{pendingRef:t});n.ok&&(clearInterval(a),s&&clearTimeout(s),i(Zi(Promise.resolve(n))))}),o);s=setTimeout((()=>{i({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)}))))}),Mr=go(wo("token")),Ur=go(mo("token"));var Pr,Lr=go([(Pr=wo("projectId"),Qi(((e,t)=>n=>to(...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",Pr))())])((e=>{const{projectId:t,logger:n,baseUrl:i,cookiePolicy:o,baseHeaders:r={},refreshCookieName:s,fetch:a}=e;return l=qi({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:Io(l),otp:or(l),magicLink:Ho(l),enchantedLink:Po(l),oauth:Yo(l),outbound:Xo(l),sso:ar(l),saml:ar(l),totp:hr(l),notp:Wr(l),webauthn:xr(l),password:br(l),flow:No(l),refresh:Ur(((e,t,n,i)=>{const o={};n&&(o.externalToken=n);const r=i?Ci.tryRefresh:Ci.refresh;return Zi(l.post(r,o,{token:e,queryParams:t}))})),selectTenant:go([lo("tenantId")],[po('"token" must be string or undefined')])(((e,t)=>Zi(l.post(Ci.selectTenant,{tenant:e},{token:t})))),logout:Ur((e=>Zi(l.post(Ci.logout,{},{token:e})))),logoutAll:Ur((e=>Zi(l.post(Ci.logoutAll,{},{token:e})))),me:Ur((e=>Zi(l.get(Ci.me,{token:e})))),myTenants:go([fo('"tenants" must a string array or a boolean')],[po('"token" must be string or undefined')])(((e,t)=>{const n={};return"boolean"==typeof e?n.dct=e:n.ids=e,Zi(l.post(Ci.myTenants,n,{token:t}))})),history:Ur((e=>Zi(l.get(Ci.history,{token:e})))),isJwtExpired:Mr(Hi),getTenants:Mr(Ji),getJwtPermissions:Mr(Ki),getJwtRoles:Mr(Yi),getCurrentTenant:Mr(Xi),httpClient:l};var l})),$r=Object.assign(Lr,{DeliveryMethods:Ao});
6
+ /*! js-cookie v3.0.8 | MIT */function _r(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 Nr=function e(t,n){function i(e,i,o){if("undefined"!=typeof document){"number"==typeof(o=_r({},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,"",_r({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,_r({},this.attributes,t))},withConverter:function(t){return e(_r({},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 Dr={default:"endpoint"},Fr="Blocked by CSP",qr="The endpoint parameter is not a valid URL",zr="Failed to load the JS script of the agent",Vr="9319";function Br(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===Fr||s===qr)n.exclude(),r=0;else if(s===Vr)n.exclude();else if(s===zr){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 Hr="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",Jr=Hr;function Kr(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:Hr,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 Br(e,Yr)})).catch((function(e){throw u(),function(e){return e instanceof Error&&e.message===Vr?new Error(zr):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(qr);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(zr))},i.async=!0,i.src=e,r.appendChild(i)}))}(e)}),(function(){throw new Error(Fr)})).then(Gr)}function Gr(){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(Vr);return n}const Zr="3.2.0",Xr="undefined"!=typeof window,Qr=Math.pow(2,31)-1,es=2e4,ts=`https://descopecdn.com/npm/oidc-client-ts@${Zr}/dist/browser/oidc-client-ts.min.js`,ns=`https://cdn.jsdelivr.net/npm/oidc-client-ts@${Zr}/dist/browser/oidc-client-ts.min.js`,is=["/v1/auth/refresh","/v1/auth/try-refresh","/v1/auth/me","/v1/auth/me/tenants","/v1/auth/me/history"];let os;const rs=e=>{try{return Si(e).exp}catch(e){return null}},ss=e=>{const{refresh_expire_in:t,refresh_token:n}=e;return t?Math.floor(Date.now()/1e3)+t:rs(n)},as=e=>{const{expires_in:t,expires_at:n,access_token:i}=e;return n||(t?Math.floor(Date.now()/1e3)+t:i?rs(i):void 0)},ls=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||as(e),cookieExpiration:e.cookieExpiration||ss(e)},s)},cs=(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},ds=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 ls(n)},us=()=>Xr&&!!window.descopeBridge,hs=(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 is.includes(n)},ps=void 0!==os||Xr&&void 0!==window.localStorage,fs=(e,t)=>{var n,i;return null===(i=null===(n=os||Xr&&window.localStorage)||void 0===n?void 0:n.setItem)||void 0===i?void 0:i.call(n,e,t)},gs=e=>{var t,n;return null===(n=null===(t=os||Xr&&window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e)},vs=e=>{var t,n;return null===(n=null===(t=os||Xr&&window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n?void 0:n.call(t,e)},ms=e=>{var t,n,i,o,r;return null!==(r=null!==(n=null===(t=null==os?void 0:os.key)||void 0===t?void 0:t.call(os,e))&&void 0!==n?n:Xr&&(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},ws=e=>{var t,n;return Xr&&(null===(n=null===(t=window.localStorage)||void 0===t?void 0:t.getItem)||void 0===n?void 0:n.call(t,e))||null},bs=e=>{var t,n;try{Xr&&(null===(n=null===(t=window.localStorage)||void 0===t?void 0:t.removeItem)||void 0===n||n.call(t,e))}catch(e){}},ys=(...e)=>{console.debug(...e)},ks=(...e)=>{console.warn(...e)},Is=e=>e?e.getTime()-(new Date).getTime():0,Ss="DS",Cs="DSR",Es="DSI",Os="DSRCN";function As(e,t,n){if(t){const{cookieDomain:i,cookiePath:o,cookieSameSite:r,cookieExpiration:s,cookieSecure:a}=n,l=new Date(1e3*s),c=xs(i);Nr.set(e,t,{path:o,domain:c?i:void 0,expires:l,sameSite:r,secure:a})}}function xs(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 js=e=>(null==e?void 0:e.cookieName)||Ss,Rs=e=>(null==e?void 0:e.cookieName)||Cs;function Ts(e="",t){return Nr.get(Rs(t))||gs(`${e}${Cs}`)||""}function Ws(e="",t){return Nr.get(js(t))||gs(`${e}${Ss}`)||""}function Ms(e=""){return gs(`${e}${Es}`)||""}function Us(e="",t,n,i){vs(`${e}${Cs}`),vs(`${e}${Ss}`),vs(`${e}${Es}`),vs(`${e}${Os}`);const o=js(t);Nr.remove(o,null==i?void 0:i.session);const r=Rs(n);Nr.remove(r,null==i?void 0:i.refresh)}const Ps=(e,t,n)=>i=>{const o=Object.assign(i,{token:i.token||Ts(e,t)});if(!n){const t=function(e=""){return gs(`${e}${Os}`)}(e);t&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-refresh-cookie-name":t}))}const r=function(e=""){return gs(`${e}DTD`)||""}(e);r&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-trusted-device-token":r}));const s=function(e=""){return gs(`${e}DKD`)||""}(e);return s&&(o.headers=Object.assign(Object.assign({},o.headers||{}),{"x-descope-known-device-token":s})),o},Ls=Xr&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://api.descope.com",$s="vsid",_s="vrid",Ns="fp",Ds=(e=!1)=>{const t=gs(Ns);if(!t)return null;const n=JSON.parse(t);return(new Date).getTime()>n.expiry&&!e?null:n.value},Fs=async(e,t=Ls)=>{try{if(Ds())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=Kr({apiKey:e,endpoint:[i.toString(),Dr],scriptUrlPattern:[r,Jr]}),a=await s,{requestId:l}=await a.get({linkedId:n}),c=((e,t)=>({[$s]:e,[_s]:t}))(n,l);(e=>{const t={value:e,expiry:(new Date).getTime()+864e5};fs(Ns,JSON.stringify(t))})(c)}catch(e){console.warn("Could not load fingerprint",e)}},qs=e=>{const t=Ds(!0);return t&&e.body&&(e.body.fpData=t),e},zs="descopeFlowNonce",Vs="X-Descope-Flow-Nonce",Bs="/v1/flow/start",Hs="/v1/flow/next",Js=(e,t=zs)=>`${t}${e}`,Ks=(e,t=zs)=>{try{const n=Js(e,t),i=gs(n);if(!i)return null;const o=JSON.parse(i);return o.expiry<Date.now()?(Ys(e,t),null):{value:o.value,seq:o.seq}}catch(e){return console.error("Error getting flow nonce:",e),null}},Ys=(e,t=zs)=>{try{const n=Js(e,t);vs(n)}catch(e){console.error("Error removing flow nonce:",e)}},Gs=e=>{var t;return(null===(t=/.*\|#\|(.*)/.exec(e))||void 0===t?void 0:t[1])||null},Zs=e=>{var t;return e.path===Hs&&(null===(t=e.body)||void 0===t?void 0:t.executionId)?Gs(e.body.executionId):null},Xs="dls_last_user_login_id",Qs="dls_last_user_display_name",ea=e=>fs(Xs,e),ta=()=>gs(Xs),na=()=>gs(Qs),ia=e=>async(...t)=>{var n;t[1]=t[1]||{};const[,i={}]=t,o=ta(),r=na();return o&&(null!==(n=i.lastAuth)&&void 0!==n||(i.lastAuth={}),i.lastAuth.loginId=o,i.lastAuth.name=r),await e(...t)},oa="DSLI",ra=e=>async(...t)=>{const n=await e(...t);return bs(oa),n};function sa(){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 aa(e,t){const n=function(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=fa(n.publicKey.challenge),n.publicKey.user.id=fa(n.publicKey.user.id),null===(t=n.publicKey.excludeCredentials)||void 0===t||t.forEach((e=>{e.id=fa(e.id)})),n}(e);t&&(n.signal=t.signal);try{return i=await navigator.credentials.create(n),JSON.stringify({id:i.id,rawId:ga(i.rawId),type:i.type,response:{attestationObject:ga(i.response.attestationObject),clientDataJSON:ga(i.response.clientDataJSON)}})}catch(e){throw await da(e,n,!0)}var i}async function la(e,t){const n=ha(e);t&&(n.signal=t.signal);try{return pa(await navigator.credentials.get(n))}catch(e){throw await da(e,n,!1)}}async function ca(e,t){const n=ha(e);n.signal=t.signal,n.mediation="conditional";try{return pa(await navigator.credentials.get(n))}catch(e){throw await da(e,n,!1)}}async function da(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 ua())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 ua(!0)?"platform_authenticator_unsupported":"NotAllowedError"===r?"not_allowed":"unknown"}(e,t,n)}catch(e){}return e}async function ua(e=!1){var t,n;if(!Xr)return Promise.resolve(!1);if(us()){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 ha(e){var t;const n=JSON.parse(e);return n.publicKey.challenge=fa(n.publicKey.challenge),null===(t=n.publicKey.allowCredentials)||void 0===t||t.forEach((e=>{e.id=fa(e.id)})),n}function pa(e){return JSON.stringify({id:e.id,rawId:ga(e.rawId),type:e.type,response:{authenticatorData:ga(e.response.authenticatorData),clientDataJSON:ga(e.response.clientDataJSON),signature:ga(e.response.signature),userHandle:e.response.userHandle?ga(e.response.userHandle):void 0}})}function fa(e){const t=e.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(t),(e=>e.charCodeAt(0))).buffer}function ga(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var va,ma=(va=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 aa(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 la(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 aa(o.data.options);return await e.webauthn.signUp.finish(o.data.transactionId,t)}{const t=await la(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 aa(o.data.options);return await e.webauthn.update.finish(o.data.transactionId,r)},helpers:{create:aa,get:la,isSupported:ua,conditional:ca}}),(...e)=>{const t=va(...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 wa="/fedcm/config";async function ba(e,t){var n;try{await ya(e,t)}catch(e){null===(n=null==t?void 0:t.onFailed)||void 0===n||n.call(t,e)}}async function ya(e,t){var n,i;const o=await async function(e,t="google",n,i,o){const r=(()=>{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)})(),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 ka=e=>Object.assign(Object.assign({},e.flow),{start:async(...t)=>{const n=await ua(),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 Ia;const Sa=(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",(()=>{Sa(e,t),s.setAttribute("data-error","true")})),document.body.appendChild(s)})),Ca=(e,t,n)=>{const i=async()=>{let i,o;return i&&o||({client:i,stateUserKey:o}=await(async(e,t,n)=>{Ia||(Ia=(async()=>{try{return require("oidc-client-ts")}catch(e){return Sa([ts,ns],(()=>window.oidc))}})());const{OidcClient:i,WebStorageStateStore:o}=await Ia;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)))),fs(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=gs(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||Ms(),e.post_logout_redirect_uri=e.post_logout_redirect_uri||window.location.href;const r=await n.createSignoutRequest(e),{url:s}=r;return vs(o),t||window.location.replace(s),r}}},Ea=function(...e){return t=>e.reduce(((e,t)=>t(e)),t)}((e=>t=>{var n;return n=t.customStorage,os=n,e(t)}),(e=>n=>{var{fpKey:i,fpLoad:o}=n,r=t(n,["fpKey","fpLoad"]);return Xr?(i&&o&&Fs(i).catch((()=>null)),e(cs(r,{beforeRequest:qs}))):e(r)}),(e=>t=>e(Object.assign(Object.assign({},t),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.54.5"},t.baseHeaders)}))),(e=>t=>{const n=sa(),i=sa(),o=sa(),r=sa(),s=e(cs(t,{afterRequest:async(e,t)=>{if(hs(e,t))ys("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 ds(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 ds(t);s&&i.pub(s),l&&r.pub(l),(a||s)&&n.pub(a||42)}}})),a=So(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=zs}=n,s=t(n,["enableFlowNonce","nonceStoragePrefix"]);if(!o)return e(s);((e=zs)=>{try{if(!ps)return;for(let o=0;o<(void 0,n=void 0,void 0,null!==(i=null!==(t=null==os?void 0:os.length)&&void 0!==t?t:Xr&&(null===(n=window.localStorage)||void 0===n?void 0:n.length))&&void 0!==i?i:0);o++){const t=ms(o);if(t&&t.startsWith(e)){const n=gs(t);if(n)try{JSON.parse(n).expiry<Date.now()&&vs(t)}catch(e){vs(t)}}}}catch(e){console.error("Error cleaning up expired nonces:",e)}var t,n,i})(r);const a=e(cs(s,{afterRequest:async(e,t)=>{var n;if(e.path!==Bs&&e.path!==Hs)return;const{nonce:i,seq:o,executionId:s}=await(async(e,t)=>{try{const n=t.headers.get(Vs),i=null===n?void 0:(e=>{const t=e.indexOf(".");if(t<=0)return;const n=e.slice(0,t);if(!/^\d+$/.test(n))return;const i=Number(n);return Number.isSafeInteger(i)?i:void 0})(n);let o=await t.clone().json().then((e=>(null==e?void 0:e.executionId)||null)).catch((()=>null));return o||(o=Zs(e)),{nonce:n,seq:i,executionId:Gs(o)}}catch(e){return{nonce:null,seq:void 0,executionId:null}}})(e,t);if(!i||!s)return;const a=e.path===Bs,l=null===(n=Ks(s,r))||void 0===n?void 0:n.seq;!a&&void 0!==o&&void 0!==l&&o<=l||((e,t,n,i=zs,o)=>{try{const r=Js(e,i),s=n?172800:10800,a={value:t,expiry:Date.now()+1e3*s,isStart:n,seq:o};fs(r,JSON.stringify(a))}catch(e){console.error("Error setting flow nonce:",e)}})(s,i,a,r,null!=o?o:a?void 0:l)},beforeRequest:e=>{if(e.path===Hs){const t=Zs(e);if(t){const n=((e,t=zs)=>{var n,i;return null!==(i=null===(n=Ks(e,t))||void 0===n?void 0:n.value)&&void 0!==i?i:null})(t,r);n&&(e.headers=e.headers||{},e.headers[Vs]=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(cs(t,{afterRequest:async(e,t)=>{if(hs(e,t))return void bs(oa);const n=await ds(t);(null==n?void 0:n.sessionExpiration)&&((e,t)=>{var n,i;try{Xr&&(null===(i=null===(n=window.localStorage)||void 0===n?void 0:n.setItem)||void 0===i||i.call(n,e,t))}catch(e){}})(oa,String(n.sessionExpiration))}}));return So(n,["logout","logoutAll","oidc.logout"],ra)}),(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||us())return Object.assign(e(o),{markUserActive:()=>{ks("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&&(ys("Activity-based refresh enabled"),u=(()=>{let e=!0;return{hadActivity:()=>e,reset:()=>{e=!1},markActive:()=>{e=!0}}})()),Xr&&document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&c&&new Date>c&&(ys("Expiration time passed, refreshing session"),g())}));const f=e(cs(o,{afterRequest:async(e,t)=>{const{sessionJwt:n,refreshJwt:i,sessionExpiration:o,nextRefreshSeconds:r}=await ds(t);if(hs(e,t))ys("Session invalidated, canceling all timers"),a(),c=void 0;else if(n||o){if(c=((e,t)=>{if(t)return new Date(1e3*t);ys("Could not extract expiration time from session token, trying to decode the token");try{const t=Si(e);if(t.exp)return new Date(1e3*t.exp)}catch(e){return null}})(n,o),!c)return void ys("Could not extract expiration time from session token");d=i,h=r>0;let e=((e,t)=>{let n;return t>0?(n=1e3*t,ys(`Using provided nextRefreshSeconds: ${t}s`)):n=Is(e)-es,n>Qr&&(ys(`Timeout is too large (${n}ms), setting it to ${Qr}ms`),n=Qr),n})(c,r);a(),e<=es&&(e=Math.max(Is(c),es));const t=new Date(Date.now()+e).toLocaleTimeString("en-US",{hour12:!1});ys(`Setting refresh timer for ${t}. (${e}ms)`),u&&(u.reset(),p=!1),l((()=>{if(Xr&&"hidden"===document.visibilityState)ys("Skipping refresh due to timer - document is hidden");else{if(u&&h&&!u.hadActivity())return ys("Skipping refresh due to timer - user is idle"),void(p=!0);ys("Refreshing session due to timer"),g()}}),e)}}})),g=()=>f.refresh(Ts()||d).catch((e=>{ks("Automatic session refresh failed",e)}));return Object.assign(So(f,["logout","logoutAll","oidc.logout"],(e=>async(...t)=>{const n=await e(...t);return ys("Clearing all timers"),a(),n})),{markUserActive:u?()=>{ys("markUserActive() called"),h||ys("markUserActive() called but server does not have inactivity timeout configured (no nextRefreshSeconds)"),u.markActive(),p&&(ys("User became active after skipped refresh, triggering refresh"),p=!1,a(),g())}:()=>{ks("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:ta,getLastUserDisplayName:na});const s=e(cs(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=ls((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?(ea(r),(e=>{fs(Qs,e)})(s)):(null==o?void 0:o.loginId)&&ea(o.loginId)}}));let a=So(s,["flow.start"],ia);return a=So(a,["logout","logoutAll"],(e=>t=>async(...n)=>{const i=await t(...n);return e||(vs(Xs),vs(Qs)),i})(o)),Object.assign(a,{getLastUserLoginId:ta,getLastUserDisplayName:na})}),(e=>n=>{var{persistTokens:i,sessionTokenViaCookie:o,refreshTokenViaCookie:r,storagePrefix:s,refreshCookieName:a}=n,l=t(n,["persistTokens","sessionTokenViaCookie","refreshTokenViaCookie","storagePrefix","refreshCookieName"]);if(!i||!Xr)return e(Object.assign({refreshCookieName:a},l));let c;const d=e(cs(Object.assign({refreshCookieName:a},l),{beforeRequest:Ps(s,r,a),afterRequest:async(e,t)=>{if(hs(e,t))ys("Session invalidated, clearing persisted tokens"),Us(s,o,r,c);else{const e=await ds(t);e.cookieName?fs(`${s||""}${Os}`,e.cookieName):e.refreshJwt&&vs(`${s||""}${Os}`);const n=((e={},t=!1,n="",i=!1)=>{var o,r,s,a;const{sessionJwt:l,refreshJwt:c,trustedDeviceJwt:d,knownDeviceJwt:u}=e;let h;if(c)if(i){vs(`${n}${Cs}`);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=Rs(i);s&&"https:"!==window.location.protocol&&ks("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});As(l,c,d);const u=xs(a);h=Object.assign(Object.assign({},h),{refresh:{path:d.cookiePath,domain:u?a:void 0}})}else{const e=Rs(i);Nr.remove(e),fs(`${n}${Cs}`,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=js(t);i&&"https:"!==window.location.protocol&&ks("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});As(r,l,c);const d=xs(o);h=Object.assign(Object.assign({},h),{session:{path:c.cookiePath,domain:d?o:void 0}})}else fs(`${n}${Ss}`,l);return e.idToken&&fs(`${n}${Es}`,e.idToken),d&&fs(`${n}DTD`,d),u&&fs(`${n}DKD`,u),h})(e,o,s,r);n&&(c=n)}}})),u=So(d,["logout","logoutAll","oidc.logout"],((e,t,n,i)=>o=>async(...r)=>{const s=await o(...r);return Us(e,t,n,null==i?void 0:i()),s})(s,o,r,(()=>c)));return Object.assign(u,{getRefreshToken:()=>Ts(s,r),getSessionToken:()=>Ws(s,o),getIdToken:()=>Ms(s)})}))((e=>{const t=$r(e),n=Ca(t,e.projectId,e.oidcConfig);return Object.assign(Object.assign({},t),{refresh:async(i,o)=>{var r;if(us())return ys(`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&&Xr&&void 0!==window.localStorage&&!ws(oa)&&!gs(Xs)&&!ws("DSLI_DISABLED"))return Promise.resolve({ok:!0});const s=Ws(),a=Ts();let l="";if(e.getExternalToken)try{l=await(null===(r=e.getExternalToken)||void 0===r?void 0:r.call(e))}catch(e){ys("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:ka(t),webauthn:ma(t),fedcm:(i=t,o=e.projectId,{onetap:{requestExchangeCode(e){ba(i,e)},requestAuthentication(e){ba(i,e)}},async oneTap(e,t,n,o,r){await ya(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+wa),clientId:o}]}},r=await(null===(t=navigator.credentials)||void 0===t?void 0:t.get(n));return i.refresh(r.token)},isSupported:()=>Xr&&"IdentityCredential"in window,async isLoggedIn(e){var t;const n=i.httpClient.buildUrl(o+wa);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})),Oa=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},Aa=e=>e.me.data,xa=sn(Aa,(e=>e.userId)),ja=sn(Aa,(e=>e.picture)),Ra=sn(Aa,(e=>e.email)),Ta=sn(Aa,(e=>e.verifiedEmail)),Wa=sn(Aa,(e=>e.name)),Ma=sn(Aa,(e=>e.phone)),Ua=sn(Aa,(e=>e.verifiedPhone)),Pa=sn(Ra,Ta,((e,t)=>e&&""!==e.trim()&&!t?"Unverified":"")),La=sn(Ma,Ua,((e,t)=>e&&""!==e.trim()&&!t?"Unverified":"")),$a=sn(Aa,(e=>e.recoveryEmail)),_a=sn(Aa,(e=>e.verifiedRecoveryEmail)),Na=sn(Aa,(e=>e.recoveryPhone)),Da=sn(Aa,(e=>e.verifiedRecoveryPhone)),Fa=sn($a,_a,((e,t)=>t?e:"")),qa=sn(Na,Da,((e,t)=>t?e:"")),za=sn(Aa,(e=>e.webauthn));sn(Aa,(e=>e.password));const Va=sn(Aa,(e=>e.TOTP)),Ba={},Ha=sn(Aa,(e=>{var t;return null!==(t=e.customAttributes)&&void 0!==t?t:Ba})),Ja=sn(Aa,(e=>({givenName:e.givenName,middleName:e.middleName,familyName:e.familyName}))),Ka=sn((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}))))),Ya=sn((e=>e.passkeys.data),(e=>e.map((({id:e,displayName:t,kind:n,createdTime:i})=>({id:e,name:t,passkeyType:n,createdAt:1e3*i}))))),Ga=e=>e.notifications,Za=sn(Aa,(e=>e.userTenants||[])),Xa=e=>e.tenant.currentTenantId,Qa=_n("tenant/select",((e,t)=>n(void 0,[e,t],void 0,(function*(e,{extra:{api:t},getState:n}){if(e===Xa(n()))return null;const i=yield t.user.setCurrentTenant(e),o=i.sessionJwt||i.sessionToken;try{return{tenantId:Oa(o)}}catch(e){return console.error("Failed to switch tenant:",e),null}})))),el={action:Qa,reducer:li(Qa)({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}},ci((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;return v(null===(t=e.error)||void 0===t?void 0:t.message).trim()||"Error"}}))},tl={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:[]},nl={me:"/v1/auth/me",devices:"/v1/mgmt/user/trusteddevices/list",passkeys:"/v1/mgmt/user/passkeys/list",selectTenant:"/v1/auth/tenant/select"},il=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)})),ol=[{tenantName:"Tenant 1",tenantId:"tn1",roleNames:["Role"]},{tenantName:"Tenant 2",tenantId:"tn2",roleNames:["Role"]}],rl=()=>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",recoveryEmail:"recovery@company.com",recoveryPhone:"+1-202-555-020",verifiedEmail:!0,verifiedPhone:!0,verifiedRecoveryEmail:!0,verifiedRecoveryPhone:!0,userTenants:ol,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})}))})),sl=()=>({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}]}),al=()=>({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"}]}),ll=({httpClient:e,mock:t})=>({me:()=>n(void 0,void 0,void 0,(function*(){if(t)return rl();const n=yield e.get(nl.me);return yield il(n),n.json()})),setCurrentTenant:t=>n(void 0,void 0,void 0,(function*(){const n=yield e.post(nl.selectTenant,{tenant:t});return yield il(n),n.json()}))}),cl=({httpClient:e,mock:t})=>({devices:i=>n(void 0,[i],void 0,(function*({userId:n}){if(t)return sl();const i=yield e.post(nl.devices,{identifiers:[n]});return yield il(i),i.json()}))}),dl=({httpClient:e,mock:t})=>({listPasskeys:i=>n(void 0,[i],void 0,(function*({userId:n}){if(t)return al();const i=yield e.post(nl.passkeys,{loginId:n});return yield il(i),i.json()}))}),ul=c((e=>{var t,s,a,l,c;const d=r(j,A,y,R,Zn)(e);return c=class extends d{constructor(){super(...arguments),t.add(this),s.set(this,void 0)}get sessionTokenViaCookie(){return i(this,t,"m",l).call(this,"session-token-via-cookie")}get refreshTokenViaCookie(){return i(this,t,"m",l).call(this,"refresh-token-via-cookie")}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get styleId(){return this.getAttribute("style-id")||$e}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","session-token-via-cookie","refresh-token-via-cookie"],(()=>{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=Ea(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.21.0"}}));return{user:Object.assign(Object.assign({},ll({httpClient:o.httpClient,mock:t})),{logout:t?()=>n(void 0,void 0,void 0,(function*(){})):o.logout}),device:Object.assign({},cl({httpClient:o.httpClient,mock:t})),passkey:Object.assign({},dl({httpClient:o.httpClient,mock:t})),refresh:t?()=>n(void 0,void 0,void 0,(function*(){return{ok:!0}})):o.refresh,httpClient:o.httpClient}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName,sessionTokenViaCookie:this.sessionTokenViaCookie,refreshTokenViaCookie:this.refreshTokenViaCookie},"true"===this.mock,this.widgetId),"f")},l=function(e){var t;try{return null!==(t=JSON.parse(this.getAttribute(e)))&&void 0!==t?t:void 0}catch(t){return void this.logger.warn(`invalid JSON in "${e}" attribute, ignoring it`)}},c})),hl=c((e=>{const t=r(Hn({name:"widget",initialState:tl,reducers:{clearNotifications:e=>{e.notifications=[]},setCurrentTenantId:(e,{payload:t})=>{e.tenant.currentTenantId=t}},extraReducers:e=>{hi.reducer(e),gi.reducer(e),wi.reducer(e),yi.reducer(e),el.reducer(e)},asyncActions:{getMe:hi.action,listDevices:gi.action,listPasskeys:wi.action,logout:yi.action,selectTenant:el.action}}),O,y,ul)(e);return class extends t{constructor(...e){super(...e),this.state=tl,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),pl="widget-flow",fl=c((e=>{var t,o,s;return s=class extends(r(Yn,O,Ue,hl,Zn,y,Ve,ni)(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=ai(pl);r&&(!function(e){if(window.history.replaceState&&ai(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())}}(pl),i(this,t,"m",o).call(this,r))}))}},t=new WeakSet,o=function(e){const t=this.createFlowModal({"data-id":"redirect-flow"});t.setContent(this.createFlowTemplate({flowId:e}));new ne((()=>{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})),gl=()=>{var e;return"function"==typeof(null===(e=window.descopeBridge)||void 0===e?void 0:e.registerWidget)},vl=c((e=>{const t=e;return class extends t{init(){const e=Object.create(null,{init:{get:()=>super.init}});return n(this,void 0,void 0,(function*(){var t;gl()&&window.descopeBridge.registerWidget(this),yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}handleLogout(){const e=Object.create(null,{handleLogout:{get:()=>super.handleLogout}});return n(this,void 0,void 0,(function*(){var t;gl()?this.dispatchEvent(new CustomEvent("widget-logout")):yield null===(t=e.handleLogout)||void 0===t?void 0:t.call(this)}))}}})),ml=c((e=>{var t,o,a;return a=class extends(r(y,O,V,G,Gn("user-profile-widget"),hl)(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);try{yield this.actions.getMe(),yield i(this,t,"m",o).call(this),yield this.onWidgetRootReady()}catch(e){const t=null==e?void 0:e.code,n=(null==e?void 0:e.message)||("string"==typeof e?e:"Widget failed to initialize");throw this.dispatchEvent(new CustomEvent("error",{detail:{code:t,description:"Widget failed to initialize",message:n}})),e}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})),wl=c((e=>class extends(r(Ve,A)(e)){syncFlowTheme(e){e.theme=this.theme,this.observeAttributes(["theme"],(()=>{e.theme=this.theme}))}})),bl=c((e=>{var t,s,a,l,c;return c=class extends(r(y,hl)(e)){constructor(){super(...arguments),t.add(this),a.set(this,null)}onFlowPopupClosed(){return n(this,void 0,void 0,(function*(){var e;return o(this,a,null!==(e=i(this,a,"f"))&&void 0!==e?e:i(this,t,"m",l).call(this).finally((()=>{o(this,a,null,"f")})),"f"),i(this,a,"f")}))}},a=new WeakMap,t=new WeakSet,s=function(){return n(this,void 0,void 0,(function*(){var e;try{const e=yield this.api.refresh();return(null==e?void 0:e.ok)?"ok":401===(null==e?void 0:e.code)?"unauthenticated":"failed"}catch(t){return null===(e=this.logger)||void 0===e||e.debug("Session refresh threw",t),"failed"}}))},l=function(){return n(this,void 0,void 0,(function*(){var e;let n=yield i(this,t,"m",s).call(this);if("failed"===n&&(n=yield i(this,t,"m",s).call(this)),"unauthenticated"!==n)return"failed"===n?(null===(e=this.logger)||void 0===e||e.error("Could not refresh the session after a popup flow; the widget may be showing stale data"),void this.dispatchEvent(new CustomEvent("error",{detail:{message:"session-refresh-failed"}}))):void this.actions.getMe();this.dispatchEvent(new CustomEvent("logout"))}))},c})),yl={"flow-id":"flow",theme:"theme","style-id":"style",locale:"locale",tenant:"tenant"},kl=["client","form"],Il=c((e=>{var t,s,a,l,c,d,u,h;return h=class extends(r(y,Ue,ni,wl,Kn,bl,ml)(e)){constructor(){super(...arguments),t.add(this),s.set(this,"modal"),a.set(this,""),l.set(this,void 0)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n,r;o(this,l,null!==(n=i(this,l,"f"))&&void 0!==n?n:i(this,t,"m",c).call(this),"f"),yield i(this,l,"f"),yield null===(r=e.onWidgetRootReady)||void 0===r?void 0:r.call(this)}))}createFlowRunner({dataId:e,flowId:n,closeOnOutsideClick:o=!0,presetContent:r=!0,deferOpenUntilFirstPage:a=!1,onSuccess:l}){if(!n)return;if("popup"===i(this,s,"f")){const e=i(this,t,"m",u).call(this,n,l);if(e)return e}const c=this.createFlowModal(Object.assign({"data-id":e},o?{"close-on-outside-click":"true"}:{})),d=new ne((()=>{var e;return null===(e=c.ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger});this.syncFlowTheme(d);let h=null;const p=()=>{null==h||h(),h=null},f=e=>{c.setContent(this.createFlowTemplate(Object.assign(Object.assign({flowId:n},a?{lazyStart:!1}:{}),e))),a&&(p(),h=d.onPageUpdated((()=>{c.open(),p()}))),d.onSuccess((()=>{c.close(),null==l||l()}))};return a?c.afterClose=p:r&&(c.afterClose=()=>f(),f()),{open:e=>{(e||!r||a)&&f(e),a||c.open()},close:()=>c.close(),remove:()=>c.remove(),refresh:()=>{r&&!a&&c.isClosed&&f()}}}},s=new WeakMap,a=new WeakMap,l=new WeakMap,t=new WeakSet,c=function(){return n(this,void 0,void 0,(function*(){const e=yield this.getWidgetConfig(),t=yield this.getHostedPageBaseUrl();o(this,s,((e,t,n)=>"popup"!==e?"modal":t?"popup":(null==n||n(),"modal"))(null==e?void 0:e.flowTarget,t,(()=>{var e;return null===(e=this.logger)||void 0===e?void 0:e.error("Flows are configured to open in a popup, but this project has no custom domain, so they will open in a modal instead")})),"f"),o(this,a,t||"","f")}))},d=function(e,t){const n=this.createFlowTemplate(Object.assign({flowId:e},t));return((e,t,n,i,o)=>{const r=(null==t?void 0:t.getAttribute("project-id"))||"",s=new URL(`${e.replace(/\/$/,"")}/${r}`);Object.entries(yl).forEach((([e,n])=>{const i=null==t?void 0:t.getAttribute(e);i&&s.searchParams.set(n,i)})),kl.forEach((e=>{const i=null==t?void 0:t.getAttribute(e);if(i)try{Object.entries(JSON.parse(i)).forEach((([t,n])=>{null===n||"object"!=typeof n?s.searchParams.set(`${e}.${t}`,String(n)):null==o||o(e,t)}))}catch(t){null==n||n(e,i)}}));const a=s.toString();return a.length>2e3&&(null==i||i(a.length)),a})(i(this,a,"f"),n.content.querySelector("descope-wc"),((e,t)=>{var n;return null===(n=this.logger)||void 0===n?void 0:n.error(`Could not parse flow ${e} inputs`,t)}),(e=>{var t;return null===(t=this.logger)||void 0===t?void 0:t.error(`The flow popup url is ${e} characters, past the 2000 that is safe everywhere, so the popup may be refused before the flow starts. Pass identifiers in form and client inputs rather than data.`)}),((e,t)=>{var n;return null===(n=this.logger)||void 0===n?void 0:n.error(`The flow ${e} input "${t}" is an object, and a popup flow can only take text, so it was not sent. Pass an id instead.`)}))},u=function(e,n){if(!i(this,a,"f"))return;const o=new Ee({logger:this.logger}),r=()=>{var e;return null===(e=this.onFlowPopupClosed)||void 0===e?void 0:e.call(this)};o.onUnauthenticated((()=>{var e;null===(e=this.logger)||void 0===e||e.info("The auth domain does not recognise this user; asking the app to sign in again"),this.dispatchEvent(new CustomEvent("flow-popup-unauthenticated"))}));const s=()=>{null==n||n(),r()};return o.onDone(s),o.onClosed(s),o.onParentFocus(s),{open:n=>{var r;o.open(i(this,t,"m",d).call(this,e,n))||(null===(r=this.logger)||void 0===r||r.error("The browser blocked the flow popup, so the flow did not start"),this.dispatchEvent(new CustomEvent("error",{detail:{message:"flow-popup-blocked"}})))},close:()=>o.close(),remove:()=>o.remove(),refresh:()=>{}}},h})),Sl=c((e=>{var t,s,l,c,d,u;return u=class extends(r(Yn,Ve,hl,y,ml,Il)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),c.set(this,a((e=>{this.avatar.image=e}))),d.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",l).call(this),o(this,s,this.createFlowRunner({dataId:"update-pic",flowId:this.avatar.flowId,onSuccess:()=>this.actions.getMe()}),"f"),i(this,c,"f").call(this,ja(this.state)),i(this,d,"f").call(this,Wa(this.state)),this.subscribe(i(this,c,"f").bind(this),ja),this.subscribe(i(this,d,"f").bind(this),Wa)}))}},s=new WeakMap,c=new WeakMap,d=new WeakMap,t=new WeakSet,l=function(){this.avatar=new ee((()=>{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()}))},u})),Cl=c((e=>{var t,s,l,c,d,u,h;return h=class extends(r(Yn,hl,y,ml,Il)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),d.set(this,a((e=>{var t,n;this.emailUserAttr.value=e,null===(t=i(this,s,"f"))||void 0===t||t.refresh(),null===(n=i(this,l,"f"))||void 0===n||n.refresh()}))),u.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",c).call(this),o(this,s,this.createFlowRunner({dataId:"edit-email",flowId:this.emailUserAttr.editFlowId,onSuccess:()=>this.actions.getMe()}),"f"),o(this,l,this.createFlowRunner({dataId:"delete-email",flowId:this.emailUserAttr.deleteFlowId,onSuccess:()=>this.actions.getMe()}),"f"),i(this,d,"f").call(this,Ra(this.state)),i(this,u,"f").call(this,Pa(this.state)),this.subscribe(i(this,d,"f").bind(this),Ra),this.subscribe(i(this,u,"f").bind(this),Pa)}))}},s=new WeakMap,l=new WeakMap,d=new WeakMap,u=new WeakMap,t=new WeakSet,c=function(){this.emailUserAttr=new xe((()=>{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,l,"f"))||void 0===e||e.open()}))},h})),El=c((e=>{var t,o,s;return s=class extends(r(hl,y,ml,Me)(e)){constructor(){super(...arguments),t.add(this)}handleLogout(){return n(this,void 0,void 0,(function*(){yield this.actions.logout(),this.dispatchEvent(new CustomEvent("logout"))}))}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 te((()=>{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((()=>this.handleLogout()))},s})),Ol=c((e=>{var t,s,l,c,d,u;return u=class extends(r(Yn,hl,y,ml,Il)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),d.set(this,a((e=>{var t,n;this.nameUserAttr.value=e,null===(t=i(this,s,"f"))||void 0===t||t.refresh(),null===(n=i(this,l,"f"))||void 0===n||n.refresh()})))}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",c).call(this),o(this,s,this.createFlowRunner({dataId:"edit-name",flowId:this.nameUserAttr.editFlowId,onSuccess:()=>this.actions.getMe()}),"f"),o(this,l,this.createFlowRunner({dataId:"delete-name",flowId:this.nameUserAttr.deleteFlowId,onSuccess:()=>this.actions.getMe()}),"f"),i(this,d,"f").call(this,Wa(this.state)),this.subscribe(i(this,d,"f").bind(this),Wa)}))}},s=new WeakMap,l=new WeakMap,d=new WeakMap,t=new WeakSet,c=function(){this.nameUserAttr=new xe((()=>{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,l,"f"))||void 0===e||e.open()}))},u})),Al=c((e=>{var t,s,l,c,d,u;return u=class extends(r(Yn,hl,y,ml,Zn,Il)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),d.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",c).call(this),o(this,s,this.createFlowRunner({dataId:"add-passkey",flowId:this.passkeyUserAuthMethod.flowId,onSuccess:()=>this.actions.getMe()}),"f"),o(this,l,this.createFlowRunner({dataId:"remove-passkey",flowId:this.passkeyUserAuthMethod.fulfilledFlowId,onSuccess:()=>this.actions.getMe()}),"f"),i(this,d,"f").call(this,za(this.state)),this.subscribe(i(this,d,"f").bind(this),za)}))}},s=new WeakMap,l=new WeakMap,d=new WeakMap,t=new WeakSet,c=function(){this.passkeyUserAuthMethod=new je((()=>{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,l,"f"))||void 0===e||e.open()}))},u})),xl=c((e=>{var t,s;return s=class extends(r(Yn,hl,y,ml,Il)(e)){constructor(){super(...arguments),t.set(this,void 0)}initPasswordAuthMethod(){this.passwordUserAuthMethod=new je((()=>{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,t,"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(),o(this,t,this.createFlowRunner({dataId:"password",flowId:this.passwordUserAuthMethod.flowId}),"f")}))}},t=new WeakMap,s})),jl=c((e=>{var t,s,l,c,d,u,h;return h=class extends(r(Yn,hl,y,ml,Il)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),d.set(this,a((e=>{var t,n;this.phoneUserAttr.value=e,null===(t=i(this,s,"f"))||void 0===t||t.refresh(),null===(n=i(this,l,"f"))||void 0===n||n.refresh()}))),u.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",c).call(this),o(this,s,this.createFlowRunner({dataId:"edit-phone",flowId:this.phoneUserAttr.editFlowId,onSuccess:()=>this.actions.getMe()}),"f"),o(this,l,this.createFlowRunner({dataId:"delete-phone",flowId:this.phoneUserAttr.deleteFlowId,onSuccess:()=>this.actions.getMe()}),"f"),i(this,d,"f").call(this,Ma(this.state)),i(this,u,"f").call(this,La(this.state)),this.subscribe(i(this,d,"f").bind(this),Ma),this.subscribe(i(this,u,"f").bind(this),La)}))}},s=new WeakMap,l=new WeakMap,d=new WeakMap,u=new WeakMap,t=new WeakSet,c=function(){this.phoneUserAttr=new xe((()=>{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,l,"f"))||void 0===e||e.open()}))},h})),Rl=c((e=>{var t,s,l,c,d,u;return u=class extends(r(Yn,hl,y,ml,Il)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),d.set(this,a((e=>{this.recoveryEmailUserAttr.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",c).call(this),o(this,s,this.createFlowRunner({dataId:"edit-recovery-email",flowId:this.recoveryEmailUserAttr.editFlowId,onSuccess:()=>this.actions.getMe()}),"f"),o(this,l,this.createFlowRunner({dataId:"delete-recovery-email",flowId:this.recoveryEmailUserAttr.deleteFlowId,onSuccess:()=>this.actions.getMe()}),"f"),i(this,d,"f").call(this,Fa(this.state)),this.subscribe(i(this,d,"f").bind(this),Fa)}))}},s=new WeakMap,l=new WeakMap,d=new WeakMap,t=new WeakSet,c=function(){this.recoveryEmailUserAttr=new xe((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="recoveryEmail"]')}),{logger:this.logger}),this.recoveryEmailUserAttr.onEditClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()})),this.recoveryEmailUserAttr.onDeleteClick((()=>{var e;null===(e=i(this,l,"f"))||void 0===e||e.open()}))},u})),Tl=c((e=>{var t,s,l,c,d,u;return u=class extends(r(Yn,hl,y,ml,Il)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),d.set(this,a((e=>{this.recoveryPhoneUserAttr.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",c).call(this),o(this,s,this.createFlowRunner({dataId:"edit-recovery-phone",flowId:this.recoveryPhoneUserAttr.editFlowId,onSuccess:()=>this.actions.getMe()}),"f"),o(this,l,this.createFlowRunner({dataId:"delete-recovery-phone",flowId:this.recoveryPhoneUserAttr.deleteFlowId,onSuccess:()=>this.actions.getMe()}),"f"),i(this,d,"f").call(this,qa(this.state)),this.subscribe(i(this,d,"f").bind(this),qa)}))}},s=new WeakMap,l=new WeakMap,d=new WeakMap,t=new WeakSet,c=function(){this.recoveryPhoneUserAttr=new xe((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="recoveryPhone"]')}),{logger:this.logger}),this.recoveryPhoneUserAttr.onEditClick((()=>{var e;null===(e=i(this,s,"f"))||void 0===e||e.open()})),this.recoveryPhoneUserAttr.onDeleteClick((()=>{var e;null===(e=i(this,l,"f"))||void 0===e||e.open()}))},u})),Wl=c((e=>{var t,s,l,c,d,u;return u=class extends(r(Yn,hl,y,ml,Il)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),d.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",c).call(this),o(this,s,this.createFlowRunner({dataId:"totp",flowId:this.totpUserAuthMethod.flowId,onSuccess:()=>this.actions.getMe()}),"f"),o(this,l,this.createFlowRunner({dataId:"remove-totp",flowId:this.totpUserAuthMethod.fulfilledFlowId,onSuccess:()=>this.actions.getMe()}),"f"),i(this,d,"f").call(this,Va(this.state)),this.subscribe(i(this,d,"f").bind(this),Va)}))}},s=new WeakMap,l=new WeakMap,d=new WeakMap,t=new WeakSet,c=function(){this.totpUserAuthMethod=new je((()=>{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,l,"f"))||void 0===e||e.open()}))},u})),Ml=c((e=>{var t,o,s,l,c,d,u,h,p,f;return f=class extends(r(Yn,hl,y,ml,Il)(e)){constructor(){super(...arguments),t.add(this),o.set(this,{}),s.set(this,{}),l.set(this,{}),p.set(this,a((e=>{Object.keys(i(this,o,"f")).forEach((t=>{i(this,o,"f")[t].value=(e[t]||"").toString()})),i(this,t,"m",h).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),i(this,t,"m",u).call(this),i(this,p,"f").call(this,Ja(this.state)),this.subscribe(i(this,p,"f").bind(this),Ja)}))}},o=new WeakMap,s=new WeakMap,l=new WeakMap,p=new WeakMap,t=new WeakSet,c=function(e,t,n){const o=e.getAttribute("edit-flow-id");o&&(i(this,s,"f")[o]=this.createFlowRunner({dataId:`edit-${t}`,flowId:o,onSuccess:()=>this.actions.getMe()}),n.onEditClick((()=>{var e,t;null===(t=null===(e=i(this,s,"f"))||void 0===e?void 0:e[o])||void 0===t||t.open()})))},d=function(e,t,n){const o=e.getAttribute("delete-flow-id");o&&(i(this,l,"f")[o]=this.createFlowRunner({dataId:`delete-${t}`,flowId:o,onSuccess:()=>this.actions.getMe()}),n.onDeleteClick((()=>{var e,t;null===(t=null===(e=i(this,l,"f"))||void 0===e?void 0:e[o])||void 0===t||t.open()})))},u=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 xe(e,{logger:this.logger});i(this,o,"f")[n]=r,i(this,t,"m",c).call(this,e,n,r),i(this,t,"m",d).call(this,e,n,r)}))},h=function(){Object.values(i(this,s,"f")).forEach((e=>null==e?void 0:e.refresh())),Object.values(i(this,l,"f")).forEach((e=>null==e?void 0:e.refresh()))},f}));var Ul;!function(e){e.TEXT="text",e.NUMBER="number",e.BOOLEAN="boolean",e.SINGLE_SELECT="singleSelect",e.ARRAY="array",e.DATE="date"}(Ul||(Ul={}));const Pl=c((e=>{var t,o,s,l,c,d,u;return o=class extends(r(Yn,hl,y,ml,Il)(e)){constructor(){super(...arguments),t.add(this),s.set(this,{}),l.set(this,{}),c.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")||Ul.TEXT,a=e[r],l=new xe(n,{logger:this.logger});l.value=o.getFormattedValue(s,a),i(this,t,"m",d).call(this,n,r,l),i(this,t,"m",u).call(this,n,r,l)}))})))}static getFormattedValue(e,t){return e===Ul.DATE&&t?new Date(t).toLocaleString():e===Ul.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,c,"f").call(this,Ha(this.state)),this.subscribe(i(this,c,"f").bind(this),Ha)}))}},s=new WeakMap,l=new WeakMap,c=new WeakMap,t=new WeakSet,d=function(e,t,n){const o=e.getAttribute("edit-flow-id");o&&(i(this,s,"f")[o]=this.createFlowRunner({dataId:`edit-${t}`,flowId:o,onSuccess:()=>this.actions.getMe()}),n.onEditClick((()=>{var e,t;null===(t=null===(e=i(this,s,"f"))||void 0===e?void 0:e[o])||void 0===t||t.open()})))},u=function(e,t,n){const o=e.getAttribute("delete-flow-id");o&&(i(this,l,"f")[o]=this.createFlowRunner({dataId:`delete-${t}`,flowId:o,onSuccess:()=>this.actions.getMe()}),n.onDeleteClick((()=>{var e,t;null===(t=null===(e=i(this,l,"f"))||void 0===e?void 0:e[o])||void 0===t||t.open()})))},o})),Ll=c((e=>{var t,s,l,c,d;return d=class extends(r(Yn,Ve,hl,y,ml,Il)(e)){constructor(){super(...arguments),t.add(this),s.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 Re((()=>{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",c).call(this),i(this,t,"m",l).call(this,Ka(this.state)),o(this,s,this.createFlowRunner({dataId:"untrust-device",flowId:this.deviceList.flowId,presetContent:!1,onSuccess:()=>this.actions.listDevices({userId:xa(this.state)})}),"f"),this.subscribe(this.updateDeviceList.bind(this),Ka))}))}},s=new WeakMap,t=new WeakSet,l=function(e){this.deviceList.onRemoveDeviceClick((({id:e})=>{var t;null===(t=i(this,s,"f"))||void 0===t||t.open({form:{deviceId:e}})})),this.deviceList.data=e},c=function(){return n(this,void 0,void 0,(function*(){yield this.actions.listDevices({userId:xa(this.state)})}))},d})),$l=c((e=>{var t,s,l,c,d,u,h;return h=class extends(r(Yn,hl,y,ml,Zn,Il)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),l.set(this,void 0),d.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 We((()=>{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",u).call(this,Ya(this.state)),o(this,s,this.createFlowRunner({dataId:"add-user-passkey",flowId:this.userPasskeys.addPasskeyFlowId,onSuccess:()=>i(this,t,"m",c).call(this)}),"f"),o(this,l,this.createFlowRunner({dataId:"remove-user-passkey",flowId:this.userPasskeys.removePasskeyFlowId,presetContent:!1,onSuccess:()=>i(this,t,"m",c).call(this)}),"f"),this.subscribe(i(this,d,"f").bind(this),xa),this.subscribe(this.updatePasskeyList.bind(this),Ya))}))}},s=new WeakMap,l=new WeakMap,d=new WeakMap,t=new WeakSet,c=function(){this.actions.getMe(),this.actions.listPasskeys({userId:xa(this.state)})},u=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 t;null===(t=i(this,l,"f"))||void 0===t||t.open({form:{externalId:xa(this.state),credentialId:e}})}))},h}));const _l={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},Nl=c((e=>{var t,o,s,l,c;return c=class extends(r(y,hl,Le,O)(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),Ga)}))}},l=new WeakMap,t=new WeakSet,o=function({type:e,msg:t}){const n=_l[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})),Dl=c((e=>{var t,s,a,l,c,d,u,h,p,f,g;return g=class extends(r(hl,y,ml)(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=Xa(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=Ws();return Oa(e)})()),i(this,t,"m",a).call(this),i(this,t,"m",f).call(this),i(this,t,"m",h).call(this,Za(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 Te((()=>{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=Xa(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,Xa(this.state)),this.tenantSelector.setAllowCustomValue(!1)}))},g})),Fl=c((e=>{var t,s,a,l,c,d;return d=class extends(r(Yn,hl,y,ml,Il)(e)){constructor(){super(...arguments),t.add(this),s.set(this,[]),a.set(this,void 0)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return n(this,void 0,void 0,(function*(){var n,r;yield null===(n=e.onWidgetRootReady)||void 0===n?void 0:n.call(this),i(this,t,"m",c).call(this),o(this,a,this.createFlowRunner({dataId:"generic-flow-modal",flowId:null===(r=i(this,s,"f")[0])||void 0===r?void 0:r.flowId,presetContent:!1,deferOpenUntilFirstPage:!0,onSuccess:()=>this.actions.getMe()}),"f"),i(this,s,"f").forEach((e=>e.enable()))}))}},s=new WeakMap,a=new WeakMap,t=new WeakSet,l=function(e){const t=new ie(e,{logger:this.logger});t.onClick((()=>{var e;null===(e=i(this,a,"f"))||void 0===e||e.open({flowId:t.flowId,client:{userId:xa(this.state)}})})),i(this,s,"f").push(t)},c=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",l).call(this,e)}))},d})),ql=c((e=>class extends(r(L,Ve,fl,Pl,Cl,Sl,Ol,jl,Rl,Tl,Al,xl,Wl,Ml,El,vl,Ll,$l,Nl,Dl,Fl,si)(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)}))}})),zl=r((e=>class extends(ql(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);const n=customElements.get("descope-wc")||(yield Promise.resolve().then((function(){return qh})).then((e=>e.default))),i=this;n.sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"user-profile-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.21.0"},get sessionTokenViaCookie(){return i.sessionTokenViaCookie},get refreshTokenViaCookie(){return i.refreshTokenViaCookie}}}))}}))(HTMLElement),Vl="undefined"!=typeof localStorage,Bl="J151000",Hl="E103205",Jl="E108201",Kl=Vl&&localStorage.getItem("base.content.url")||"",Yl="base.ui.components.url";Vl&&localStorage.getItem(Yl),Vl&&localStorage.getItem(Yl);const Gl="descope-login-flow",Zl="code",Xl="redirect_mode",Ql="err",ec="data-exclude-field",tc="data-exclude-next",nc="dls_last_auth",ic="dls_last_submitted_login_id",oc="state_id",rc="saml_idp_state_id",sc="wsfed_idp_state_id",ac="saml_idp_username",lc="descope_idp_initiated",cc="sso_app_id",dc="custom_app_id",uc="third_party_app_id",hc="third_party_app_state_id",pc="oidc_login_hint",fc="oidc_prompt",gc="oidc_resource",vc="oidc_error_redirect_uri",mc="application_scopes",wc="data-type",bc="redirect",yc="poll",kc="webauthnCreate",Ic="webauthnGet",Sc="nativeBridge",Cc="loadForm",Ec="submit",Oc="polling",Ac=["descope-multi-select-combo-box","descope-text-area"],xc="dls_last_auth_in_flight",jc=["cssVars","componentsConfig","inputs","errorText","errorType","clientScripts","data","totp","notp","sentTo","sso","selfProvisionDomains"],Rc=["hide","disable","read-only"],Tc="hidden";function Wc(e,t){const n=e.closest(`.${Tc}`);return!!n&&n!==t}const Mc=/(["\\])/g;function Uc(e){return"undefined"!=typeof CSS&&"function"==typeof CSS.escape?CSS.escape(e):e.replace(Mc,"\\$1")}function Pc(e,t){return Array.from(e.querySelectorAll(`[id="${Uc(t)}"]`))}function Lc(e,t,n){return Object.keys(t).forEach((i=>{const o=t[i];n[i]!==o&&Pc(e,i).forEach((e=>function(e,t){switch(t){case"hide":e.classList.remove(Tc);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&&Pc(e,i).forEach((e=>function(e,t){switch(t){case"hide":e.classList.add(Tc);break;case"disable":e.setAttribute("disabled","true");break;case"read-only":e.setAttribute("readonly","true")}}(e,o)))})),Object.assign({},n)}var $c;!function(e){e.backward="backward",e.forward="forward"}($c||($c={}));const _c=new Set,Nc=(e,t)=>({origin:window.location.origin,pathname:window.location.pathname,hash:window.location.hash,projectId:e,flowId:t}),Dc=(e,t)=>`dls_sso_query_params_${e}_${t}`,Fc=e=>Object.values(null!=e?e:{}).some(Boolean),qc=()=>{var e,t,n;try{const[i]=null!==(n=null===(t=null===(e=window.performance)||void 0===e?void 0:e.getEntriesByType)||void 0===t?void 0:t.call(e,"navigation"))&&void 0!==n?n:[],o=i;if("reload"!==(null==o?void 0:o.type)||!o.name)return!1;const r=new URL(o.name,window.location.href);return r.origin===window.location.origin&&r.pathname===window.location.pathname&&r.hash===window.location.hash}catch(e){return!1}},zc=(e,t)=>(null==e?void 0:e.origin)===t.origin&&(null==e?void 0:e.pathname)===t.pathname&&(null==e?void 0:e.hash)===t.hash&&(null==e?void 0:e.projectId)===t.projectId&&(null==e?void 0:e.flowId)===t.flowId,Vc=(e,t)=>{var n,i;try{const o=null===(n=window.sessionStorage)||void 0===n?void 0:n.getItem(Dc(e,t));if(!o)return;const r=JSON.parse(o);zc(null==r?void 0:r.scope,Nc(e,t))&&(null===(i=window.sessionStorage)||void 0===i||i.removeItem(Dc(e,t)))}catch(e){}},Bc=["descope-enriched-text"];function Hc(e){return new URLSearchParams(window.location.search).get(e)}function Jc(e){if(window.history.replaceState&&Hc(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 Kc(e,t){if(!t)return;const n=+e,i=+t;return Number.isNaN(n)||Number.isNaN(i)?void 0:n>i?$c.forward:n<i?$c.backward:void 0}const Yc=e=>{let[t="",n=""]=(Hc(Gl)||"").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 Gc(){Jc(Gl)}function Zc(e){try{const{origin:t}=new URL(e);return"null"===t?void 0:t}catch(e){return}}function Xc(){return Hc(sc)}function Qc(){Jc(sc)}function ed(){return Hc(mc)}function td(){Jc(mc)}const nd=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),id=(e,t,n)=>{const{executionId:i,stepId:o,executionFlowId:r}=Yc(e);if(r&&e!==r)return n.debug("Flow id does not match the execution flow id, skipping url params handling"),{ssoQueryParams:{}};(i||o)&&Gc();const s=Hc("t")||void 0;s&&Jc("t");const a=Hc(Zl)||void 0;a&&Jc(Zl);const l="popup"===Hc(Xl);l&&Jc(Xl);const c=Hc(Ql)||void 0;c&&Jc(Ql);const{redirectAuthCodeChallenge:d,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthInitiator:p}={redirectAuthCodeChallenge:Hc("ra-challenge"),redirectAuthCallbackUrl:Hc("ra-callback"),redirectAuthBackupCallbackUri:Hc("ra-backup-callback"),redirectAuthInitiator:Hc("ra-initiator")},f=Hc(oc);f&&Jc(oc);const g=Hc(rc);g&&Jc(rc);const v=Xc();v&&Qc();const m=Hc(ac);g&&Jc(ac);const w=Hc(lc);w&&Jc(lc);const b=Hc(cc);b&&Jc(cc);const y=Hc(dc);y&&Jc(dc);const k=Hc(uc);k&&Jc(uc);const I=Hc(hc);I&&Jc(hc);const S=ed();S&&td();const C=Hc(pc);C&&Jc(pc);const E=Hc(fc);E&&Jc(fc);const O=Hc(vc);O&&Jc(vc);const A=Hc(gc);A&&Jc(gc);const x={oidcIdpStateId:f,samlIdpStateId:g,wsfedIdpStateId:v,samlIdpUsername:m,descopeIdpInitiated:"true"===w,ssoAppId:b,customAppId:y,oidcLoginHint:C,oidcPrompt:E,oidcErrorRedirectUri:O,oidcResource:A,thirdPartyAppId:k,thirdPartyAppStateId:I,applicationScopes:S},j=((e,t)=>{const n=[(i=Nc(e,t)).origin,i.pathname,i.hash,i.projectId,i.flowId].join("|");var i;return!_c.has(n)&&(_c.add(n),!0)})(t,e);let R=x;if(Fc(x))((e,t,n)=>{var i;if(Fc(e))try{const o={params:e,scope:Nc(t,n),ts:Date.now()};null===(i=window.sessionStorage)||void 0===i||i.setItem(Dc(t,n),JSON.stringify(o))}catch(e){}})(x,t,e);else if(!r){const i=j?((e,t)=>{var n;if(!qc())return null;try{const i=null===(n=window.sessionStorage)||void 0===n?void 0:n.getItem(Dc(e,t));if(!i)return null;const o=JSON.parse(i);return zc(null==o?void 0:o.scope,Nc(e,t))?Date.now()-o.ts>=6e5?null:o.params:null}catch(e){return null}})(t,e):null;i?(n.debug("Restored SSO query params after a page reload"),R=i):((e,t)=>{qc()||Vc(e,t)})(t,e)}return{executionId:i,stepId:o,token:s,code:a,isPopup:l,exchangeError:c,redirectAuthCodeChallenge:d,redirectAuthCallbackUrl:u,redirectAuthBackupCallbackUri:h,redirectAuthInitiator:p,ssoQueryParams:R}},od=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}})},rd=(e,t,n)=>{if(!0===t||"skipFirstScreen"===t&&!n){const t=Array.from(e.querySelectorAll('*[name]:not([auto-focus="false"]):not([aria-hidden="true"])')).find((t=>!Wc(t,e)));setTimeout((()=>{null==t||t.focus()}))}};function sd(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 ad=(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),ld=(e,t,n)=>{const i=document.createElement("input");return i.type="hidden",i.name=e,i.value=t,n&&i.setAttribute("role",n),i},cd=e=>null==e?void 0:e.submit(),dd=(e,t)=>{const n=t.find((t=>e[t]));return n?e[n]:null},ud=(e,t=100)=>{let n;return function(...i){n||e.apply(this,i),clearTimeout(n),n=setTimeout((()=>{n=null}),t)}},hd={minLength:"data-password-policy-value-minlength",strength:"data-password-policy-value-passwordstrength",disallowedChars:"data-password-policy-value-disallowedchars",email:"data-password-policy-value-email",reuse:"data-password-policy-value-reuse",activePolicies:"active-policies",availablePolicies:"available-policies"},pd=(e,t)=>{var n;const i=null==e?void 0:e.componentsDynamicAttrs;if(!i)return;const o=Object.entries(i).find((([e])=>(e=>{var t;return null===(t=e.match(/\[data-name=["']([^"']+)["']\]/))||void 0===t?void 0:t[1]})(e)===t));return null===(n=null==o?void 0:o[1])||void 0===n?void 0:n.attributes},fd=[{key:"totp",from:e=>e.totp},{key:"notp",from:e=>e.notp},{key:"sentTo",from:e=>e.sentTo},{key:"sso",from:e=>e.sso},{key:"selfProvisionDomains",from:e=>e.selfProvisionDomains},{key:"inboundAppApproveScopes",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.thirdPartyAppApproveScopes)||void 0===n?void 0:n.data}},{key:"securityQuestionsSetup",from:e=>{var t;return null===(t=e.componentsConfig)||void 0===t?void 0:t.sqSetup}},{key:"securityQuestionsVerify",from:e=>{var t;return null===(t=e.componentsConfig)||void 0===t?void 0:t.sqVerify}},{key:"userTenants",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.userSelectedTenant)||void 0===n?void 0:n.data}},{key:"userRoles",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.userRoles)||void 0===n?void 0:n.data}},{key:"ssoApplications",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.ssoApplications)||void 0===n?void 0:n.data}},{key:"ssoConfigurations",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.ssoConfigurations)||void 0===n?void 0:n.data}},{key:"samlAttributeMappings",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.samlMappings)||void 0===n?void 0:n.options}},{key:"oidcAttributeMappings",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.oidcMappings)||void 0===n?void 0:n.options}},{key:"samlGroupMappings",from:e=>{var t,n;return null===(n=null===(t=e.componentsConfig)||void 0===t?void 0:t.samlGroupMappings)||void 0===n?void 0:n.options}},{key:"passwordPolicy",from:e=>{var t;return(e=>{if(!e)return;const t=Object.fromEntries(Object.entries(hd).map((([t,n])=>[t,e[n]])).filter((([,e])=>void 0!==e)));return Object.keys(t).length?t:void 0})(null===(t=e.componentsConfig)||void 0===t?void 0:t.newPassword)}},{key:"recoveryCodes",from:e=>(e=>{const t=pd(e,"recoveryCodes");if(t)return Array.isArray(t.data)?t.data.map((e=>e.value)):[]})(e.componentsConfig)},{key:"outboundApp",from:e=>(e=>{const t=pd(e,"outboundApp");if(t)return{label:t.label,iconSrc:t["icon-src"],appId:t["data-descope-outbound-oauth-app-id"]}})(e.componentsConfig)}],gd=e=>{const t=Object.assign({},e);return e.inboundAppApproveScopes&&(t.thirdPartyAppApproveScopes=e.inboundAppApproveScopes),t};function vd(e,t){return`sdkScriptsResults.${t?`${e}_${t}`:e}`}var md,wd,bd,yd;function kd(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(!kd(r,s))return!1}else if(r!==s)return!1}return!0}let Id=class{constructor(e={},{forceUpdate:t=!1}={}){md.set(this,void 0),wd.set(this,{}),bd.set(this,0),yd.set(this,!0),this.update=e=>{const t="function"==typeof e?e(i(this,md,"f")):e,n=Object.assign(Object.assign({},i(this,md,"f")),t),r=i(this,md,"f");o(this,md,n,"f"),Object.freeze(i(this,md,"f")),setTimeout((()=>{Object.values(i(this,wd,"f")).forEach((({cb:e,selector:t,forceUpdate:o})=>{const s=t(r),a=t(n);(i(this,yd,"f")||o||(function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(a)?!kd(s,a):s!==a))&&e(a,s,((e,t)=>n=>e[n]!==t[n])(a,s))}))}),0)},o(this,md,e,"f"),o(this,yd,t,"f")}get current(){return Object.assign({},i(this,md,"f"))}set forceUpdate(e){o(this,yd,e,"f")}subscribe(e,t=e=>e,{forceUpdate:n=!1}={}){return o(this,bd,i(this,bd,"f")+1,"f"),i(this,wd,"f")[i(this,bd,"f")]={cb:e,selector:t,forceUpdate:n},i(this,bd,"f").toString()}unsubscribe(e){const t=!!i(this,wd,"f")[e];return t&&delete i(this,wd,"f")[e],t}unsubscribeAll(){return o(this,wd,{},"f"),!0}};md=new WeakMap,wd=new WeakMap,bd=new WeakMap,yd=new WeakMap;const Sd=["*","#","/","(",")","[","]","_","<",">","`"],Cd=e=>"string"!=typeof e?e:e.replace((e=>{const t=Sd.map((t=>`${e}${t}`)).join("|");return new RegExp(`(${t})`,"g")})("\\"),"\\$1"),Ed=["disabled"],Od=(e,t)=>{Object.entries(t||{}).forEach((([t,n])=>{Array.from(e.querySelectorAll(`*[name="${t}"]:not([${ec}])`)).forEach((e=>{e.value=n}))}))},Ad=(e,t)=>t.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),e),xd=(e,t,n)=>e.replace(/{{(.+?)}}/g,((e,i)=>n?Cd(Ad(t,i)):Ad(t,i))),jd=(e,t,n)=>{e.querySelectorAll(`[${wc}="${t}"]`).forEach((e=>{e.setAttribute("href",n)}))},Rd=(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})`))},Td=(e,n,i,o)=>{var r,s;jd(e,"totp-link",null===(r=null==n?void 0:n.totp)||void 0===r?void 0:r.provisionUrl),jd(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=>Bc.includes(e))(e.localName);e.textContent=xd(e.textContent,t,n);const i=e.getAttribute("href");i&&e.setAttribute("href",xd(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=xd(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])=>{Ed.includes(t)&&e.setAttribute(t,n)}))}))}))})(e,i)},Wd=od((()=>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 sd(100,n,i)}catch(e){return console.error("Conditional login check failed",e),!1}}))));let Md;const Ud=(e,t)=>{Md?Md.setItem(e,t):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.setItem(e,t)},Pd=e=>Md?Md.getItem(e):void 0!==(null===window||void 0===window?void 0:window.localStorage)?window.localStorage.getItem(e):null,Ld="dls_ab_testing_id",$d={"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 _d(e,t){const n={};try{Object.assign(n,JSON.parse(Pd(nc)))}catch(e){null==t||t.warn("[Descope] Failed to read last auth from storage",String(e))}return n.loginId||e?n:{}}function Nd(e,t){(null==e?void 0:e.authMethod)&&(t&&!e.loginId||Ud(nc,JSON.stringify(e)))}function Dd(){try{return JSON.parse(Pd(xc)||"{}")}catch(e){return{}}}function Fd(e){try{(e=>{Md?Md.removeItem(e):void 0!==(null===window||void 0===window?void 0:window.localStorage)&&window.localStorage.removeItem(e)})(xc)}catch(t){null==e||e.warn("[Descope] Failed to clear in-flight last auth storage",String(t))}}const qd=(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?qd(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),qd(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}),[]),zd=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})),Vd=["input","change"];function Bd(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 Hd(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 Jd(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 Kd(e){return Array.isArray(e)?e:"string"==typeof e?e.split(","):null}function Yd(e){return null==e||("string"==typeof e?""===e:Array.isArray(e)?0===e.length:"object"==typeof e&&0===Object.keys(e).length)}const Gd=new Map,Zd={equal:(e,t)=>e===t||Hd(e)===Hd(t),"not-equal":(e,t)=>e!==t&&Hd(e)!==Hd(t),contains:(e,t)=>Array.isArray(e)?e.includes(t):"string"==typeof e&&e.includes(Hd(t)),"doesnt-contains":(e,t)=>Array.isArray(e)?!e.includes(t):"string"==typeof e&&!e.includes(Hd(t)),"greater-than":(e,t)=>{const n=Bd(e),i=Bd(t);return n.ok&&i.ok&&n.value>i.value},"greater-than-or-equal":(e,t)=>{const n=Bd(e),i=Bd(t);return n.ok&&i.ok&&n.value>=i.value},"less-than":(e,t)=>{const n=Bd(e),i=Bd(t);return n.ok&&i.ok&&n.value<i.value},"less-than-or-equal":(e,t)=>{const n=Bd(e),i=Bd(t);return n.ok&&i.ok&&n.value<=i.value},empty:e=>Yd(e),"not-empty":e=>!Yd(e),"is-true":e=>{const t=Jd(e);return t.ok&&t.value},"is-false":e=>{const t=Jd(e);return t.ok&&!t.value},in:(e,t)=>{const n=Kd(t);return null!==n&&n.includes(e)},"not-in":(e,t)=>{const n=Kd(t);return null!==n&&!n.includes(e)},matches:(e,t)=>{if("string"!=typeof e)return!1;const n=function(e){var t;if(Gd.has(e))return null!==(t=Gd.get(e))&&void 0!==t?t:null;let n;try{n=new RegExp(e)}catch(e){n=null}return Gd.set(e,n),n}(Hd(t));return null!==n&&n.test(e)}};function Xd(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=>Xd(e,t))):e.value}function Qd(e,t){const n=Zd[e.operator];return!!n&&n(Xd(e.target,t),Xd(e.predicate,t))}function eu(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=>Qd(e,t))):i.every((e=>Qd(e,t))))}(e,t)))})(e,t)&&(null!==(i=e.componentIds)&&void 0!==i?i:[]).forEach((t=>{n[t]=e.action}))})),n}const tu="component-conditions:";function nu(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 iu(e,t){const n=Object.keys(e),i=Object.keys(t);return n.length===i.length&&n.every((n=>e[n]===t[n]))}function ou(){return{conditions:[],touchedIds:new Set,snapshot:{},applied:{},serverBaseline:{},debounceTimer:null,paused:!1,unsubscribePauseListener:null,inputHandler:()=>{},root:null}}function ru(e,t,n){const i={};return n.forEach((n=>{e[n]?i[n]=e[n]:t[n]&&(i[n]=t[n])})),i}const su=c((e=>{var t,n,s,a,l,c;const d=r(y)(e);return c=class extends d{constructor(){super(...arguments),t.add(this),n.set(this,ou())}applyComponentsState(e,t){t&&(Object.entries(t).forEach((([e,t])=>{Rc.includes(t)||this.logger.error(`Unknown component action "${t}" for component with id "${e}"`,`Valid actions are ${Rc.map((e=>`"${e}"`)).join(", ")}`)})),Lc(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(`${tu} no real-time rules to apply on this screen`);this.logger.info(`${tu} 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="${Uc(t)}"]`)||e.querySelector(`[name="${Uc(n)}"]`)}(e,t);if(!n)return;const i=nu(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=ru(eu(h,p),g,f);iu(v,w)||(m.applied=Lc(e,v,w)),m.inputHandler=e=>i(this,t,"m",s).call(this,e),Vd.forEach((t=>{e.addEventListener(t,m.inputHandler,!0)})),this.logger.debug(`${tu} listening for "${Vd.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,ec))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]=nu(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=ru(eu(e.conditions,e.snapshot),e.serverBaseline,e.touchedIds)}catch(e){return void this.logger.error(`${tu} failed to evaluate real-time rules — keeping the previous state`,null==e?void 0:e.message)}const o=e.applied;iu(o,t)||(this.logger.debug(`${tu} form changed — updating components: was ${JSON.stringify(o)}, now ${JSON.stringify(t)}`),e.applied=Lc(e.root,o,t))},l=function(){const e=i(this,n,"f");e.debounceTimer&&clearTimeout(e.debounceTimer),e.unsubscribePauseListener&&e.unsubscribePauseListener(),e.root&&Vd.forEach((t=>{e.root.removeEventListener(t,e.inputHandler,!0)})),o(this,n,ou(),"f")},c})),au="project-id",lu="flow-id",cu=e=>{const t=(e=>{const t=e.getAttribute(au),n=e.getAttribute(lu);return t&&n?Array.from(e.ownerDocument.querySelectorAll("descope-wc")).filter((e=>e.getAttribute(au)===t&&e.getAttribute(lu)===n)):[]})(e);return t.length>1&&t[0]!==e},du=c((e=>{var t,n,s,a;const l=r(y)(e);return a=class extends l{constructor(){super(...arguments),t.add(this),n.set(this,void 0)}connectedCallback(){var e;null===(e=super.connectedCallback)||void 0===e||e.call(this),i(this,t,"m",s).call(this)}attributeChangedCallback(e,n,o){var r;null===(r=super.attributeChangedCallback)||void 0===r||r.call(this,e,n,o),n===o||e!==au&&e!==lu||i(this,t,"m",s).call(this)}},n=new WeakMap,t=new WeakSet,s=function(){queueMicrotask((()=>{if(!this.isConnected)return;const e=this.getAttribute(au),t=this.getAttribute(lu),r=`${e}|${t}`;i(this,n,"f")!==r&&cu(this)&&(o(this,n,r,"f"),this.logger.warn("Multiple Descope flow components detected on the same page",`The same flow ("${t}") and project ("${e}") are running more than once on this page. This is not supported and may cause the flow to behave unexpectedly.`))}))},a})),uu=["externalId","email","phone"],hu=["newPassword","password"],pu="data-username-anchor",fu=e=>{var t;if(!e)return"";try{const n=null===(t=window.sessionStorage)||void 0===t?void 0:t.getItem(ic);if(!n)return"";const i=JSON.parse(n);return i.executionId===e&&i.loginId||""}catch(e){return""}},gu=c((e=>{var t,n,s,a,l;const c=r(y)(e);return l=class extends c{constructor(){super(...arguments),t.add(this),n.set(this,void 0)}updateScreenUser(e){var r,l,c;o(this,n,{email:null==e?void 0:e.email,loginIds:(null===(r=null==e?void 0:e.loginIds)||void 0===r?void 0:r.length)?e.loginIds:[fu(i(this,t,"a",a))||(null===(c=null===(l=i(this,t,"a",s).sdk)||void 0===l?void 0:l.getLastUserLoginId)||void 0===c?void 0:c.call(l))].filter(Boolean)},"f")}updateUsernameAnchor(){document.querySelectorAll(`[${pu}="true"]`).forEach((e=>e.remove())),((e,t,n,i)=>{var o;const r=(null==n?void 0:n.email)||(null===(o=null==n?void 0:n.loginIds)||void 0===o?void 0:o[0]);(e=>e.querySelector("descope-new-password")||e.querySelector("descope-password"))(t)?r?(e=>{const t=['input[autocomplete="username"]',...uu.map((e=>`[name="${e}"]`))].join(", ");return e.some((e=>e.querySelector(t)))})([e,t])?i.debug("Username anchor: screen already has an identifier field"):(i.debug("Username anchor: injecting hidden username input"),e.appendChild((e=>{const t=document.createElement("input");return t.setAttribute("autocomplete","username"),t.setAttribute("name","username"),t.setAttribute("type","email"),t.setAttribute("readonly","true"),t.setAttribute("tabindex","-1"),t.setAttribute("aria-hidden","true"),t.setAttribute(ec,"true"),t.setAttribute(pu,"true"),t.setAttribute("value",e),t.value=e,Object.assign(t.style,{position:"absolute",opacity:"0",pointerEvents:"none",height:"0",border:"0"}),t})(r))):i.debug("Username anchor: no user identifier available"):i.debug("Username anchor: no password component on screen")})(this,i(this,t,"a",s).contentRootElement,i(this,n,"f"),this.logger)}captureLastSubmittedLoginId(e={},n){const o=dd(e,uu);o&&((e,t)=>{var n;if(e&&t)try{null===(n=window.sessionStorage)||void 0===n||n.setItem(ic,JSON.stringify({executionId:t,loginId:e}))}catch(e){}})(o,n||i(this,t,"a",a))}storeCredentials(e={}){var t,o,r,s,a,l;const c=dd(e,uu)||(null===(t=i(this,n,"f"))||void 0===t?void 0:t.email)||(null===(r=null===(o=i(this,n,"f"))||void 0===o?void 0:o.loginIds)||void 0===r?void 0:r[0]),d=dd(e,hu);if(c&&d)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:c,password:d});null===(l=null===(a=null===(s=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===s?void 0:s.store)||void 0===a?void 0:a.call(s,e))||void 0===l||l.catch((e=>{this.logger.debug("Could not store credentials",null==e?void 0:e.message)}))}catch(e){this.logger.warn("Could not store credentials",e.message)}}},n=new WeakMap,t=new WeakSet,s=function(){return this},a=function(){var e,n;return(null===(n=null===(e=i(this,t,"a",s).flowState)||void 0===e?void 0:e.current)||void 0===n?void 0:n.executionId)||""},l})),vu=e=>`${e.screenId}|${e.field}|${e.rule}`,mu=()=>{try{return crypto.randomUUID()}catch(e){return`${Date.now()}-${Math.round(1e9*Math.random())}`}},wu=(e,t)=>e?e.badInput?"bad-input":e.valueMissing?"required":e.typeMismatch?"email"===t||"url"===t?t:"type-mismatch":e.patternMismatch?"pattern":e.tooShort?"too-short":e.tooLong?"too-long":e.rangeUnderflow||e.rangeOverflow||e.stepMismatch?"range":e.customError?"custom":"unknown":"unknown",bu=c((e=>{var t,n,s,a,l,c,d,u,h,p,f,g,v,m,w,b,k,I,S,C;const E=r(y)(e);return C=class extends E{constructor(){super(...arguments),t.add(this),n.set(this,[]),s.set(this,void 0),a.set(this,void 0),l.set(this,new Set),c.set(this,!1),d.set(this,0),u.set(this,void 0),h.set(this,!1),p.set(this,(()=>i(this,t,"m",b).call(this,!1))),f.set(this,(()=>{"hidden"===document.visibilityState&&i(this,t,"m",b).call(this,!0)})),g.set(this,(()=>i(this,t,"m",b).call(this,!0)))}setValidationTrackingEnabled(e){i(this,h,"f")!==e&&(o(this,h,e,"f"),e||i(this,t,"m",w).call(this))}setValidationTrackingSender(e){o(this,u,e,"f")}setValidationTrackingExecution(e){i(this,h,"f")&&e&&i(this,n,"f").length&&(o(this,s,e,"f"),i(this,t,"m",b).call(this,!1))}trackValidationErrors(e,n){var o,r;try{i(this,t,"m",v).call(this,e,n)}catch(e){null===(r=null===(o=this.logger)||void 0===o?void 0:o.debug)||void 0===r||r.call(o,"Failed to track validation errors",String(e))}}teardownValidationTracking(){i(this,t,"m",b).call(this,!1),o(this,d,i(this,d,"f")+1,"f"),i(this,l,"f").forEach(clearTimeout),i(this,l,"f").clear(),i(this,c,"f")&&(o(this,c,!1,"f"),this.removeEventListener("screen-updated",i(this,p,"f")),this.removeEventListener("success",i(this,p,"f")),this.removeEventListener("error",i(this,p,"f")),document.removeEventListener("visibilitychange",i(this,f,"f")),window.removeEventListener("pagehide",i(this,g,"f")))}},n=new WeakMap,s=new WeakMap,a=new WeakMap,l=new WeakMap,c=new WeakMap,d=new WeakMap,u=new WeakMap,h=new WeakMap,p=new WeakMap,f=new WeakMap,g=new WeakMap,t=new WeakSet,v=function(e,r){if(!i(this,h,"f")||!(null==e?void 0:e.length))return;const a=r||{};i(this,t,"m",S).call(this),e.forEach((e=>{if(i(this,n,"f").length>=20)return;const r=((e,t)=>{var n;const i=null===(n=null==e?void 0:e.getAttribute)||void 0===n?void 0:n.call(e,"name");return i?{id:mu(),field:i,rule:wu(e.validity,e.type),message:e.validationMessage||"",screenId:t.screenId||"",screenName:t.screenName||"",ts:Date.now()}:null})(e,a);if(!r)return;const l=vu(r);i(this,n,"f").some((e=>vu(e)===l))||(i(this,n,"f").push(r),o(this,s,a.executionId||i(this,s,"f"),"f"),i(this,n,"f").length>=20&&i(this,t,"m",b).call(this,!1))})),i(this,n,"f").length>=20?i(this,t,"m",b).call(this,!1):i(this,t,"m",m).call(this)},m=function(){clearTimeout(i(this,a,"f")),o(this,a,setTimeout((()=>i(this,t,"m",b).call(this,!1)),2e3),"f")},w=function(){clearTimeout(i(this,a,"f")),o(this,d,i(this,d,"f")+1,"f"),i(this,l,"f").forEach(clearTimeout),i(this,l,"f").clear(),o(this,n,[],"f"),o(this,s,void 0,"f")},b=function(e){var r,l;if(clearTimeout(i(this,a,"f")),!i(this,n,"f").length)return void o(this,s,void 0,"f");if(!i(this,s,"f"))return;if(!i(this,u,"f"))return;const c=i(this,n,"f"),h=i(this,s,"f");o(this,n,[],"f"),o(this,s,void 0,"f");try{const n={executionId:h,events:c};e?i(this,u,"f").call(this,n,{keepalive:!0}).catch((()=>{})):i(this,t,"m",k).call(this,n,2,i(this,d,"f"))}catch(e){null===(l=null===(r=this.logger)||void 0===r?void 0:r.debug)||void 0===l||l.call(r,"Failed to send validation events",String(e))}},k=function(e,n,o){i(this,u,"f").call(this,e,{keepalive:!1}).then((r=>{!r.ok&&r.retryable&&n>0&&i(this,t,"m",I).call(this,e,n,o)})).catch((()=>{n>0&&i(this,t,"m",I).call(this,e,n,o)}))},I=function(e,n,o){if(o!==i(this,d,"f"))return;const r=setTimeout((()=>{i(this,l,"f").delete(r),o===i(this,d,"f")&&i(this,t,"m",k).call(this,e,n-1,o)}),800*(2-n+1));i(this,l,"f").add(r)},S=function(){i(this,c,"f")||(o(this,c,!0,"f"),this.addEventListener("screen-updated",i(this,p,"f")),this.addEventListener("success",i(this,p,"f")),this.addEventListener("error",i(this,p,"f")),document.addEventListener("visibilitychange",i(this,f,"f")),window.addEventListener("pagehide",i(this,g,"f")))},C}));var yu,ku,Iu,Su,Cu,Eu,Ou,Au,xu,ju,Ru,Tu,Wu,Mu,Uu,Pu,Lu,$u,_u,Nu,Du,Fu,qu,zu,Vu,Bu;const Hu=r(Ve,M,zd,su,du,gu,J,ti,bu)(HTMLElement);let Ju=class extends Hu{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","send-session-token","style-id"]}constructor(e){super(),yu.add(this),this.sdkVersion="4.6.3",Iu.set(this,!1),Su.set(this,void 0),this.flowStatus="initial",this.loggerWrapper={error:(e,t="")=>{this.logger.error(e,t,new Error),i(this,yu,"m",Bu).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)}},Cu.set(this,new Id),Eu.set(this,new Id),Ou.set(this,{}),this.getComponentsContext=()=>i(this,Ou,"f"),this.nextRequestStatus=new Id({isLoading:!1}),Au.set(this,void 0),xu.set(this,{popstate:i(this,yu,"m",Mu).bind(this),componentsContext:i(this,yu,"m",Nu).bind(this)}),ju.set(this,void 0),this.getConfig=()=>n(this,void 0,void 0,(function*(){return(yield this.config)||{isMissingConfig:!0}})),Du.set(this,void 0),Fu.set(this,void 0),o(this,ju,e,"f"),i(this,yu,"m",Tu).call(this)}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 sendSessionToken(){return"true"===this.getAttribute("send-session-token")}get preview(){return!!this.getAttribute("preview")}get formConfig(){return(e=>{try{return qd(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,Su,"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,Su,e,"f"),(e=>{Md=e})(e)}get lazyStart(){return"true"===this.getAttribute("lazy-start")}start(){var e;null===(e=i(this,Fu,"f"))||void 0===e||e.call(this),o(this,Du,Promise.resolve(),"f")}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=Ac.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,Eu,"f").subscribe(i(this,yu,"m",Vu).bind(this)),i(this,Eu,"f").update({isDebug:this.debug}),i(this,yu,"m",Wu).call(this),yield i(this,yu,"m",$u).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}=id(this.flowId,this.projectId,this.loggerWrapper);window.addEventListener("popstate",i(this,xu,"f").popstate),window.addEventListener("components-context",i(this,xu,"f").componentsContext),i(this,Cu,"f").subscribe(i(this,yu,"m",Lu).bind(this)),i(this,Cu,"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,Iu,!0,"f")}))}disconnectedCallback(){var e;i(this,Cu,"f").unsubscribeAll(),i(this,Eu,"f").unsubscribeAll(),i(this,yu,"m",zu).call(this),window.removeEventListener("popstate",i(this,xu,"f").popstate),window.removeEventListener("components-context",i(this,xu,"f").componentsContext),null===(e=super.disconnectedCallback)||void 0===e||e.call(this)}attributeChangedCallback(e,t,n){var o;if(null===(o=super.attributeChangedCallback)||void 0===o||o.call(this,e,t,n),this.shadowRoot.isConnected&&i(this,Iu,"f")&&t!==n&&ku.observedAttributes.includes(e)){i(this,yu,"m",Wu).call(this);const o=null===t;i(this,Cu,"f").update((({stepId:t,executionId:i})=>{let r=t,s=i;return o||(s=null,r=null,Gc()),{[nd(e)]:n,stepId:r,executionId:s}})),i(this,Eu,"f").update({isDebug:this.debug})}}};var Ku,Yu,Gu,Zu,Xu,Qu,eh,th,nh,ih,oh,rh,sh,ah,lh,ch,dh,uh,hh,ph,fh,gh,vh,mh,wh,bh,yh,kh,Ih,Sh,Ch,Eh,Oh,Ah,xh,jh,Rh,Th,Wh,Mh,Uh,Ph,Lh,$h,_h,Nh;ku=Ju,Iu=new WeakMap,Su=new WeakMap,Cu=new WeakMap,Eu=new WeakMap,Ou=new WeakMap,Au=new WeakMap,xu=new WeakMap,ju=new WeakMap,Du=new WeakMap,Fu=new WeakMap,yu=new WeakSet,Ru=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 ")},Tu=function(){i(this,yu,"m",Ru).call(this),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},Wu=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","send-session-token","style-id","outbound-app-id","outbound-app-scopes","theme-override"];ku.observedAttributes.forEach((t=>{if(!e.includes(t)&&!this[nd(t)])throw Error(`${t} cannot be empty`)}))},Mu=function(){const{stepId:e,executionId:t}=Yc(this.flowId);i(this,Cu,"f").update({stepId:e,executionId:t})},Uu=function(e,t){Ea&&"function"==typeof Ea||this.logger.error("SDK was not loaded properly",Ea,JSON.stringify(Ea));const o=Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout,refreshCookieName:this.refreshCookieName},ku.sdkConfigOverrides),{projectId:e,baseUrl:t});i(this,Su,"f")&&(o.customStorage=i(this,Su,"f")),this.sdk=Ea(o);const r={start:1,next:7};["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]=(...o)=>n(this,void 0,void 0,(function*(){const n=[...o],s=r[e],a=i(this,yu,"m",Pu).call(this,n[s]);void 0!==a&&(n[s]=a);try{return yield t(...n)}catch(t){return this.logger.error(`Error in sdk flow ${e} function`,t),{error:{errorCode:Bl,errorDescription:t.toString()}}}}))}));const s=this.sdk.flow.start;this.sdk.flow.start=(...e)=>n(this,void 0,void 0,(function*(){return yield i(this,yu,"m",qu).call(this),s.apply(this.sdk.flow,e)}))},Pu=function(e){if(!this.sendSessionToken)return e;const t=null==Ws?void 0:Ws(this.storagePrefix);return t?Object.assign(Object.assign({},null!=e?e:{}),{sessionJwt:t}):e},Lu=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,yu,"m",Uu).call(this,t,n)}i(this,ju,"f").call(this,e)}))},$u=function(){return n(this,void 0,void 0,(function*(){const e=yield this.getConfig();return"isMissingConfig"in e&&e.isMissingConfig&&(yield i(this,yu,"m",_u).call(this))}))},_u=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(Kl||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}}))},Nu=function(e){o(this,Ou,Object.assign(Object.assign({},i(this,Ou,"f")),e.detail),"f")},qu=function(){return this.lazyStart?(i(this,Du,"f")||o(this,Du,new Promise((e=>{o(this,Fu,e,"f")})),"f"),i(this,Du,"f")):Promise.resolve()},zu=function(){var e;null===(e=i(this,Au,"f"))||void 0===e||e.remove(),o(this,Au,null,"f")},Vu=function(e){return n(this,arguments,void 0,(function*({isDebug:e}){e?(o(this,Au,document.createElement("descope-debugger"),"f"),Object.assign(i(this,Au,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return yp})),document.body.appendChild(i(this,Au,"f"))):i(this,yu,"m",zu).call(this)}))},Bu=function(e,t){var n;e&&this.debug&&(null===(n=i(this,Au,"f"))||void 0===n||n.updateData({title:e,description:t}))},Ju.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"4.6.3"}};const Dh="__descope_webauthn_timed_out__";class Fh extends Ju{static set sdkConfigOverrides(e){Ju.sdkConfigOverrides=e}static get sdkConfigOverrides(){return Ju.sdkConfigOverrides}constructor(){const e=new Id({deferredRedirect:!1,deferredPolling:!1});super(e.update.bind(e)),Ku.add(this),this.stepState=new Id({}),Yu.set(this,void 0),Gu.set(this,null),Zu.set(this,null),Xu.set(this,{visibilitychange:i(this,Ku,"m",Qu).bind(this)}),this.bridgeVersion=Fh.bridgeVersion,eh.set(this,void 0),this.nativeCallbacks={},lh.set(this,!1),this.handleRedirect=e=>{window.location.assign(e)},uh.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,Ku,"m",hh).call(this,t):t()})),ph.set(this,((e,t,r,s,a=!1)=>{const l=[Hl,"E103202",Jl];if(this.flowState.current.action===yc){if(i(this,gh,"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,Yu,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,Oc,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 sd(e,u)}catch(n){return this.logger.warn(`polling - The ${h?"throttled fetch":"fetch"} call timed out or was aborted`),void i(this,ph,"f").call(this,e,t,r,s,h)}if((null===(n=null==p?void 0:p.error)||void 0===n?void 0:n.errorCode)===Bl)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void i(this,ph,"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,ph,"f").call(this,e,t,r,s),i(this,vh,"f").call(this,p)}))),d),"f")}})),fh.set(this,(()=>{clearTimeout(i(this,Yu,"f")),o(this,Yu,null,"f")})),gh.set(this,(()=>!!window.descopeBridge||/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))),vh.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,Ku,"m",_h).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!==Hl&&d!==Jl||!this.isRestartOnError||i(this,Ku,"m",ah).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!==yc&&i(this,fh,"f").call(this),"completed"===m){this.storeLastAuthenticatedUser&&Nd(Object.assign(Object.assign({},b),{lastUsedPerScreen:Dd()})),Fd(this.loggerWrapper);const t=Object.assign({},w);return e.data.output&&Object.keys(e.data.output).length>0&&(t.flowOutput=e.data.output),this.setValidationTrackingExecution(e.data.executionId),((e,t)=>{Vc(e,t)})(this.projectId,this.flowId),void i(this,Ku,"m",_h).call(this,"success",t)}this.storeLastAuthenticatedUser&&Nd(b,!0),k&&window.open(k,"_blank");const{executionId:I,stepId:S,stepName:C,screen:E,redirect:O,webauthn:A,error:x,samlIdpResponse:j,wsFedIdpResponse:R,nativeResponse:T}=e.data,W=Date.now();y!==yc?(this.loggerWrapper.info(`Step "${C||`#${S}`}" is ${m}`,"",{screen:E,status:m,stepId:S,stepName:C,action:y,error:x}),(null===(g=E.state)||void 0===g?void 0:g.clientScripts)&&o(this,Zu,this.loadSdkScripts(E.state.clientScripts),"f"),this.flowState.update({stepId:S,stepName:C,executionId:I,action:y,redirectTo:null==O?void 0:O.url,redirectIsPopup:null==O?void 0:O.isPopup,screenId:null==E?void 0:E.id,screenState:null==E?void 0:E.state,webauthnTransactionId:null==A?void 0:A.transactionId,webauthnOptions:null==A?void 0:A.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:W})):this.flowState.update({action:y,reqTimestamp:W})})),mh.set(this,od((()=>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)}}))))),kh.set(this,void 0),Ih.set(this,void 0),xh.set(this,null),Wh.set(this,ud(((e,t,o)=>n(this,void 0,void 0,(function*(){var n;if("true"!==e.getAttribute("loading")&&"true"!==e.getAttribute("disabled")){if("true"===e.getAttribute("formnovalidate")||i(this,Ku,"m",Oh).call(this)){const r=null==e?void 0:e.getAttribute("id");i(this,Ku,"m",Ph).call(this,e,r,o);const s=i(this,Ku,"m",jh).call(this,e);try{const o=yield i(this,Ku,"m",Ah).call(this),s=(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 a=Object.assign(Object.assign(Object.assign({},s),o),{origin:i(this,Ku,"a",Eh)}),l=yield t(r,a);this.nextRequestStatus.update({isLoading:!1}),this.captureLastSubmittedLoginId(o,null===(n=null==l?void 0:l.data)||void 0===n?void 0:n.executionId),this.storeCredentials(o)}catch(e){throw s(),e}}}else this.loggerWrapper.debug("Submit already in flight, ignoring")}))))),this.flowState=e,this.setValidationTrackingSender(((e,t)=>n(this,[e,t],void 0,(function*({executionId:e,events:t},{keepalive:n}){const i=yield this.sdk.flow.event(e,t,n);return{ok:i.ok,retryable:i.code>=500||429===i.code}}))))}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(Zl),e=(null===(o=i.searchParams)||void 0===o?void 0:o.get(Ql))||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(Gl).split("_").pop();i(this,fh,"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:{[vd(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.21",`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 o=this.nextRequestStatus.subscribe((()=>{var n;this.loggerWrapper.debug("Stopping script",e.id),(null===(n=i.stop)||void 0===n?void 0:n.call(i))&&(this.nextRequestStatus.unsubscribe(o),this.loggerWrapper.debug("Removing script",e.id),this.shadowRoot.removeChild(t))}));"function"==typeof i.present&&n(e.id)}}catch(e){i(e)}}))})))));let o;const r=new Promise((e=>{o=setTimeout((()=>{this.loggerWrapper.warn("SDK scripts loading timeout"),e(!0)}),5e3)}));return Promise.race([i,r]).finally((()=>clearTimeout(o)))}get isDismissScreenErrorOnInput(){return"true"===this.getAttribute("dismiss-screen-error-on-input")}init(){var e,t;if(!window.descopeBridge)return this._init();this.lazyInit=this._init,o(this,eh,null===(t=null===(e=null===window||void 0===window?void 0:window.descopeBridge)||void 0===e?void 0:e.registerFlow)||void 0===t?void 0:t.call(e,this),"f")}_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,Ku,"m",rh).call(this),window.addEventListener("visibilitychange",i(this,Xu,"f").visibilitychange)),yield null===(n=e.init)||void 0===n?void 0:n.call(this)}))}disconnectedCallback(){var e,t,n;super.disconnectedCallback(),this.teardownValidationTracking(),i(this,eh,"f")&&(null===(t=null===(e=window.descopeBridge)||void 0===e?void 0:e.unregisterFlow)||void 0===t||t.call(e,i(this,eh,"f")),o(this,eh,void 0,"f")),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),i(this,fh,"f").call(this),null===(n=i(this,Gu,"f"))||void 0===n||n.abort(),o(this,Gu,null,"f"),window.removeEventListener("visibilitychange",i(this,Xu,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return n(this,void 0,void 0,(function*(){let n;const i=m(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:v,redirectTo:w,redirectIsPopup:b,redirectUrl:y,token:k,code:I,isPopup:S,exchangeError:C,webauthnTransactionId:E,webauthnOptions:O,redirectAuthCodeChallenge:A,redirectAuthCallbackUrl:x,redirectAuthBackupCallbackUri:j,redirectAuthInitiator:R,locale:T,samlIdpResponseUrl:W,samlIdpResponseSamlResponse:M,samlIdpResponseRelayState:U,wsFedIdpResponseUrl:P,wsFedIdpResponseWresult:L,wsFedIdpResponseWctx:$,nativeResponseType:_,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 B=(()=>{const e=Pd(Ld);if(!e){const e=Math.floor(100*Math.random()+1);return Ud(Ld,e.toString()),e}return Number(e)})(),{outboundAppId:H,outboundAppScopes:J}=this,K=this.sdk.getLastUserLoginId();s("flowId")&&this.setValidationTrackingEnabled(!1);const Y=yield this.getFlowConfig();i(this,Ku,"m",Sh).call(this,Y,p,s);const G=yield this.getProjectConfig(),Z=Object.entries(G.flows||{}).reduce(((e,[t,n])=>(e[t]=n.version,e)),{}),X=x&&A?{callbackUrl:x,codeChallenge:A,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){Fd(this.loggerWrapper);const e=[...Y.clientScripts||[],...Y.sdkScripts||[]];if(Y.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=$d[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:I,token:k,abTestingKey:B,lastAuth:_d(K,this.loggerWrapper)},Y.conditions)),e.push(...t||[])}else Y.condition?({startScreenId:q,startScreenName:z,conditionInteractionId:V}=((e,t)=>{var n;const i=null===(n=$d[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}})(Y.condition,{loginId:K,code:I,token:k,abTestingKey:B,lastAuth:_d(K,this.loggerWrapper)})):(z=Y.startScreenName,q=Y.startScreenId);if(o(this,kh,q,"f"),o(this,Ih,z,"f"),o(this,Zu,this.loadSdkScripts(e),"f"),Y.fingerprintEnabled&&Y.fingerprintKey?yield Fs(Y.fingerprintKey,this.baseUrl):vs(Ns),!ad(q,F)){const e=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:X},F),{client:this.client}),y&&{redirectUrl:y}),{lastAuth:_d(K,this.loggerWrapper),abTestingKey:B,locale:m(T).locale,nativeOptions:Q,outboundAppId:H,outboundAppScopes:J}),V,"",G.componentsVersion,Z,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:i(this,Ku,"a",Eh)},this.formConfigValues),I?{exchangeCode:I,idpInitiated:!0}:{}),F.descopeIdpInitiated&&{idpInitiated:!0}),k?{token:k}:{}),F.oidcLoginHint?{externalId:F.oidcLoginHint}:{}));return i(this,vh,"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:S,code:I,exchangeError:C,isCodeChanged:s("code"),isExchangeErrorChanged:s("exchangeError")})),S&&(s("code")&&I||s("exchangeError")&&C))return void i(this,Ku,"m",Nh).call(this,p,I,C);if(p&&(s("token")&&k||s("code")&&I||s("exchangeError")&&C)){const e=yield this.sdk.flow.next(p,h,Ec,Y.version,G.componentsVersion,{token:k,exchangeCode:I,exchangeError:C,origin:i(this,Ku,"a",Eh)});return i(this,vh,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(f===Cc&&W&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>s(e)))){if(!M)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.appendChild(ld("SAMLResponse",t,"saml-response")),o.appendChild(ld("RelayState",n,"saml-relay-state")),document.body.appendChild(o),i(o)})(W,M,U||"",cd)}if(f===Cc&&P&&["wsFedIdpResponseUrl","wsFedIdpResponseWresult","wsFedIdpResponseWctx"].some((e=>s(e)))){if(!L)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,o.appendChild(ld("wa","wsignin1.0")),o.appendChild(ld("wresult",t)),o.appendChild(ld("wctx",n)),document.body.appendChild(o),i(o)})(P,L,$||"",cd)}if(f===bc&&(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"));let n=!1;const o=e=>{this.loggerWrapper.debug("Received popup message",JSON.stringify(e.data));const i=t?this.popupOrigin:window.location.origin;if(e.origin!==i)return void this.loggerWrapper.debug(`Ignoring message from unexpected origin. received: "${e.origin}", expected: "${i}"`);const{action:o,data:r}=e.data||{};"code"===o&&(n=!0,this.flowState.update({code:r.code,exchangeError:r.exchangeError}))};let r;this.loggerWrapper.debug("Starting popup closed detection");const s=setInterval((()=>{e.closed&&(this.loggerWrapper.debug("Popup closed, dispatching popupclosed event"),clearInterval(s),i(this,Ku,"m",_h).call(this,"popupclosed",{abandoned:!n}),this.loggerWrapper.debug("Cleaning up popup listeners"),null==r||r())}),1e3);if(t)window.addEventListener("message",o),r=()=>{this.loggerWrapper.debug("Cleaning up popup postMessage listener"),window.removeEventListener("message",o)};else{this.loggerWrapper.debug("Creating broadcast channel");const e=new BroadcastChannel(p);e.onmessage=o,r=()=>{this.loggerWrapper.debug("Closing channel"),e.close()}}}else this.handleRedirect(w),this.flowState.update({redirectTo:"no-op"}),i(this,Ku,"m",_h).call(this,"popupclosed",{});return}if(f===kc||f===Ic){if(!E||!O)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");null===(l=i(this,Gu,"f"))||void 0===l||l.abort(),o(this,Gu,null,"f");const e=yield i(this,Ku,"m",dh).call(this,f,O),t=yield this.sdk.flow.next(p,h,Ec,Y.version,G.componentsVersion,Object.assign({transactionId:E},e));i(this,vh,"f").call(this,t)}if(f===Sc)return this.nativeCallbacks.complete=e=>n(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,h,Ec,Y.version,G.componentsVersion,e);i(this,vh,"f").call(this,t)})),i(this,Ku,"m",ih).call(this,_,N),void setTimeout((()=>{this.dispatchEvent(new Event("popupclosed"))}),500);if((s("action")||s("deferredPolling"))&&i(this,ph,"f").call(this,p,h,Y.version,G.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:Kc(h,r.stepId),screenState:Object.assign(Object.assign({},v),{form:Object.assign(Object.assign({},this.formConfigValues),null==v?void 0:v.form),lastAuth:{loginId:K,name:this.sdk.getLastUserDisplayName()||K},componentsConfig:Object.assign(Object.assign(Object.assign({},Y.componentsConfig),ee),null==v?void 0:v.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:m(T).locale},ce=_d(K,this.loggerWrapper);ad(q,F)?le.next=(e,t)=>n(this,void 0,void 0,(function*(){const n=(null==Y?void 0:Y.clientScripts)||[];yield i(this,Ku,"m",Mh).call(this,n);const o=yield this.sdk.flow.start(d,Object.assign(Object.assign(Object.assign(Object.assign({tenant:u,redirectAuth:X},F),{lastAuth:ce,preview:this.preview,abTestingKey:B,client:this.client}),y&&{redirectUrl:y}),{locale:m(T).locale,nativeOptions:Q,outboundAppId:H,outboundAppScopes:J}),V,e,G.componentsVersion,Z,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),this.getComponentsContext()),gd(t)),I&&{exchangeCode:I,idpInitiated:!0}),F.descopeIdpInitiated&&{idpInitiated:!0}),k&&{token:k}),le.next.isCustomScreen);return i(this,vh,"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==v?void 0:v.clientScripts)||[];yield i(this,Ku,"m",Mh).call(this,n);const o=yield this.sdk.flow.next(p,h,e,Y.version,G.componentsVersion,Object.assign(Object.assign({},this.getComponentsContext()),gd(t)),le.next.isCustomScreen);return i(this,vh,"f").call(this,o),o}))),this.loggerWrapper.debug("Got a screen with id",le.screenId),yield i(this,Ku,"m",ch).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"),this.updateScreenUser(null==u?void 0:u.user);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,Ku,"m",bh).call(this,f,d):(e=>{e.querySelectorAll(`descope-button[${wc}="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),Td(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)=>{Rd(e,"descope-totp-image",t)})(r,null===(n=null==u?void 0:u.totp)||void 0===n?void 0:n.image),((e,t)=>{Rd(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,Ku,"m",Rh).call(this),this.updateUsernameAnchor(),this.validateOnBlur&&((e,t)=>{e.querySelectorAll("*[name]").forEach((n=>{n.addEventListener("blur",(()=>{var i;if(Wc(n,e))return;const o=()=>{var e;const i=n.focus;n.focus=()=>{};const o=null===(e=n.reportValidity)||void 0===e?void 0:e.call(n);t&&!1===o&&t(n),setTimeout((()=>{n.focus=i}))};if("true"===n.getAttribute("invalid")||(null===(i=n.value)||void 0===i?void 0:i.length))return void o();const r={timer:void 0},s=e=>{"true"===e.target.getAttribute("formnovalidate")&&(clearTimeout(r.timer),r.timer=void 0)};r.timer=setTimeout((()=>{e.removeEventListener("click",s),o(),r.timer=void 0}),150),e.addEventListener("click",s,{once:!0})}))}))})(r,(e=>this.trackValidationErrors([e],i(this,Ku,"a",Ch)))),((e,t)=>{Od(e,null==t?void 0:t.inputs),Od(e,null==t?void 0:t.form)})(r,u),this.initRealtimeConditions(r,u),i(this,Ku,"m",yh).call(this,{isFirstScreen:s,isCustomScreen:!1,stepName:e.stepName}),rd(r,this.autoFocus,s),i(this,Ku,"m",Lh).call(this,h)})),i(this,Ku,"m",$h).call(this,d,h),r.querySelector(`[${wc}="polling"]`)&&d(Oc,{})}));c?i(this,Ku,"m",hh).call(this,m):m()}))}getInputs(){return Array.from(this.shadowRoot.querySelectorAll(`*:not(slot)[name]:not([${ec}])`))}shouldUsePopupPostMessage(){if(!this.popupOrigin)return!1;try{new URL(this.popupOrigin)}catch(e){return!1}return!0}}Yu=new WeakMap,Gu=new WeakMap,Zu=new WeakMap,Xu=new WeakMap,eh=new WeakMap,lh=new WeakMap,uh=new WeakMap,ph=new WeakMap,fh=new WeakMap,gh=new WeakMap,vh=new WeakMap,mh=new WeakMap,kh=new WeakMap,Ih=new WeakMap,xh=new WeakMap,Wh=new WeakMap,Ku=new WeakSet,Qu=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1,deferredPolling:!1})}),300)},th=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,Ku,"m",ih).call(this,"beforeScreen",{screen:e,context:t})}))}))},nh=function(e){var t;(null===(t=this.nativeOptions)||void 0===t?void 0:t.bridgeVersion)>=2&&i(this,Ku,"m",ih).call(this,"afterScreen",{screen:e})},ih=function(e,t){i(this,Ku,"m",_h).call(this,"bridge",{type:e,payload:t})},oh=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(`[${wc}="${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()},rh=function(){var e,n,o,r;null===(e=this.stepState)||void 0===e||e.subscribe(this.onStepChange.bind(this),(e=>{var n=e.screenState,i=void 0===n?{}:n,{errorText:o,errorType:r}=i,s=t(i,["errorText","errorType"]),a=t(e,["screenState"]);return Object.assign(Object.assign({},a),{screenState:s})})),null===(n=this.stepState)||void 0===n||n.subscribe(i(this,Ku,"m",oh).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,Ku,"m",sh).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===(r=this.flowState)||void 0===r||r.subscribe((({screenId:e,executionId:t})=>{var n;try{this.updateTelemetryContext({screenId:e,executionId:t})}catch(e){null===(n=this.logger)||void 0===n||n.error("Error updating telemetry screenId:",e)}}),(e=>({screenId:e.screenId,executionId:e.executionId})))},sh=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=""}))})),rd(this.contentRootElement,this.autoFocus,!1))},ah=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")}))},ch=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=>{const t=(n=e.screenState,i=(e,t)=>jc.includes(t)||t.startsWith("_"),Object.fromEntries(Object.entries(n).filter((([e,t])=>!i(0,e)))));var n,i;const{screenState:{errorText:o,errorType:r}}=e;(o||r)&&(t.error={text:o,type:r}),e.action&&(t.action=e.action);const s=(e=>{if(!e)return;const t={};return fd.forEach((({key:n,from:i})=>{const o=i(e);void 0!==o&&(t[n]=o)})),Object.keys(t).length?t:void 0})(e.screenState);return s&&(t.data=s),t})(t(r,["next","stepName"]));let c=yield i(this,Ku,"m",th).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,uh,"f").call(this,c),s&&(s.isCustomScreen=c),i(this,lh,"f")!==c){const[e,t]=["flow","custom"].sort((()=>c?-1:1));this.loggerWrapper.debug(`Switching from ${t} screen to ${e} screen`),o(this,lh,c,"f"),c?this.stepState.unsubscribeAll():i(this,Ku,"m",rh).call(this)}c?(this.loggerWrapper.debug("Showing a custom screen"),i(this,Ku,"m",yh).call(this,{isFirstScreen:d,isCustomScreen:c,stepName:e.stepName}),this.disableKeyPressHandler()):this.handleKeyPress(),this.stepState.forceUpdate=c}))},dh=function(e,t){return n(this,void 0,void 0,(function*(){const n=new AbortController;try{const i=e===kc?this.sdk.webauthn.helpers.create(t,n):this.sdk.webauthn.helpers.get(t,n),o=yield sd(9e4,i,Dh);return o!==Dh?{response:o}:(n.abort(),this.loggerWrapper.warn("WebAuthn operation timed out after 90000ms"),{failure:"AbortError",failureReason:"aborted",failureMessage:"Passkey operation timed out"})}catch(e){return"InvalidStateError"===e.name?this.loggerWrapper.warn("WebAuthn operation failed",e.message):"NotAllowedError"!==e.name&&this.loggerWrapper.error(e.message),{failure:e.name,failureReason:e.reason,failureMessage:e.message}}}))},hh=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")},wh=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)}))}},bh=function(e,t){return n(this,void 0,void 0,(function*(){var r;null===(r=i(this,Gu,"f"))||void 0===r||r.abort();const s=e.querySelector('*[autocomplete="webauthn"]');if(s&&(yield Wd())){const{options:e,transactionId:r}=(yield i(this,mh,"f").call(this))||{};e&&r&&(i(this,Ku,"m",wh).call(this,s),o(this,Gu,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(e,i(this,Gu,"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)})))}}))},yh=function({isFirstScreen:e,isCustomScreen:t,stepName:n}){e&&i(this,Ku,"m",_h).call(this,"ready",{}),t||i(this,Ku,"m",nh).call(this,n),i(this,Ku,"m",_h).call(this,"page-updated",{screenName:n}),i(this,Ku,"m",_h).call(this,"screen-updated",{screenName:n})},Sh=function(e,t,n){this.setValidationTrackingEnabled(!!e.clientValidationTrackingEnabled),t&&n("executionId")&&this.setValidationTrackingExecution(t)},Ch=function(){var e,t,n,o,r,s,a;const l=null===(e=this.flowState)||void 0===e?void 0:e.current;return(null==l?void 0:l.executionId)?{executionId:l.executionId,screenId:l.screenId,screenName:(null===(a=null===(s=this.stepState)||void 0===s?void 0:s.current)||void 0===a?void 0:a.stepName)||l.stepName}:{executionId:void 0,screenId:null!==(t=i(this,kh,"f"))&&void 0!==t?t:null==l?void 0:l.screenId,screenName:null!==(n=i(this,Ih,"f"))&&void 0!==n?n:(null===(r=null===(o=this.stepState)||void 0===o?void 0:o.current)||void 0===r?void 0:r.stepName)||(null==l?void 0:l.stepName)}},Eh=function(){var e;return(null===(e=this.nativeOptions)||void 0===e?void 0:e.origin)||window.location.origin},Oh=function(){let e=!0;const t=[];return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((n=>{var i,o,r;"slot"===n.localName||Wc(n,this.contentRootElement)||(null===(i=n.reportValidity)||void 0===i||i.call(n),n.validity&&!n.validity.valid&&t.push(n),e&&(e=null===(r=null===(o=n.checkValidity)||void 0===o?void 0:o.call(n))||void 0===r||r))})),t.length&&this.trackValidationErrors(t,i(this,Ku,"a",Ch)),e},Ah=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})),{})}))},jh=function(e){var t,r;const s=Array.from(this.contentRootElement.querySelectorAll(':not([disabled]), [disabled="false"]')).filter((t=>t!==e)),a=(null===(r=null===(t=this.flowState.current)||void 0===t?void 0:t.screenState)||void 0===r?void 0:r.clientScripts)||[];e.setAttribute("loading","true"),s.forEach((e=>e.setAttribute("disabled","true")));const l=()=>{e.removeAttribute("loading"),s.forEach((e=>{e.removeAttribute("disabled")}))},c=e=>n(this,void 0,void 0,(function*(){var t;if(this.loggerWrapper.debug("Restoring components state"),this.removeEventListener("popupclosed",c),!0===(null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.abandoned)&&a.length)return o(this,Zu,(()=>n(this,void 0,void 0,(function*(){try{yield this.loadSdkScripts(a)}catch(e){this.loggerWrapper.warn("Failed to refresh client scripts on popup close",null==e?void 0:e.message)}})))(),"f"),void l();l();const i=yield this.getFlowConfig(),r=[...i.clientScripts||[],...i.sdkScripts||[]];this.loadSdkScripts(r)})),d=()=>{var e;window.removeEventListener("pageshow",i(this,xh,"f")),o(this,xh,(e=>{e.persisted&&(this.logger.debug("Page was loaded from cache, restoring components state"),c())}),"f"),window.addEventListener("pageshow",i(this,xh,"f"),{once:!0});const t=null===(e=this.stepState)||void 0===e?void 0:e.subscribe(((e,n)=>{e===n&&c(),this.removeEventListener("popupclosed",c),this.stepState.unsubscribe(t)}),(e=>e.screenId),{forceUpdate:!0})},u=this.nextRequestStatus.subscribe((({isLoading:e})=>{e?this.addEventListener("popupclosed",c,{once:!0}):(this.nextRequestStatus.unsubscribe(u),"success"===this.flowStatus?(this.removeEventListener("popupclosed",c),l()):d())}));return l},Rh=function(){document.querySelectorAll('[data-hidden-input="true"]').forEach((e=>e.remove())),this.contentRootElement.querySelectorAll('[external-input="true"]').forEach((e=>i(this,Ku,"m",Th).call(this,e)))},Th=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)}))},Mh=function(e){return n(this,void 0,void 0,(function*(){if(i(this,Zu,"f")){this.loggerWrapper.debug("Waiting for sdk scripts to load");const e=Date.now();yield i(this,Zu,"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 sd(5e3,Promise.all(o),null)}catch(e){this.loggerWrapper.error("Failed to refresh script module",e.message)}}))},Uh=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,Wh,"f").call(this,n,e,t)}))}))},Ph=function(e,t,n){t&&n&&"true"===e.getAttribute("data-opt-in-last-used-auth")&&function(e,t,n){try{const n=Dd();n[e]=t,Ud(xc,JSON.stringify(n))}catch(e){null==n||n.warn("[Descope] Failed to update in-flight last auth storage",String(e))}}(n,t,this.loggerWrapper)},Lh=function(e){var t;const n=null===(t=_d(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))},$h=function(e,t){this.contentRootElement.querySelectorAll(`descope-button:not([${tc}]), [data-type="button"]:not([${tc}]`).forEach((n=>{n.onclick=()=>{i(this,Wh,"f").call(this,n,e,t)}})),i(this,Ku,"m",Uh).call(this,e,t),this.isDismissScreenErrorOnInput&&this.contentRootElement.querySelectorAll(`*[name]:not([${ec}])`).forEach((e=>{e.addEventListener("input",(()=>{this.stepState.update((e=>Object.assign(Object.assign({},e),{screenState:Object.assign(Object.assign({},e.screenState),{errorText:"",errorType:""})})))}))}))},_h=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},Nh=function(e,t,n){var i;const[o,r]=(null===(i=window.name)||void 0===i?void 0:i.split("|"))||[],s="descope-wc"===o&&!!r,a=s?function(e){const t=Zc(e);if(t)return t===window.location.origin||Zc(function(){const e=new URLSearchParams(window.location.search).getAll("popup_opener_origin");return 1===e.length?e[0]:void 0}())===t?t:void 0}(r):void 0;s&&!a&&this.loggerWrapper.warn("Popup opener origin is not approved for this project, add it to the approved domains to send the OAuth result to it",r);const l={data:{code:t,exchangeError:n},action:"code"};if(a){this.loggerWrapper.debug("Using postMessage fallback to notify opener in origin",a);try{window.opener.postMessage(l,a)}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(l),t.close()}try{window.close()}catch(e){}},Fh.bridgeVersion=3,customElements.get("descope-wc")?console.log("descope-wc is already defined"):customElements.define("descope-wc",Fh);var qh=Object.freeze({__proto__:null,default:Fh});customElements.define("descope-user-profile-widget",zl);const zh=(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 Vh,Bh,Hh,Jh,Kh,Yh,Gh,Zh,Xh,Qh;const ep=document.createElement("template");ep.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 tp=r(J)(HTMLElement);class np extends tp{constructor(){var e;super(),Vh.add(this),Bh.set(this,new g({messages:[]})),Hh.set(this,void 0),Jh.set(this,void 0),Kh.set(this,void 0),Yh.set(this,{resize:i(this,Vh,"m",Qh).bind(this)}),this.attachShadow({mode:"open"}),null===(e=this.shadowRoot)||void 0===e||e.appendChild(ep.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,Hh,this.shadowRoot.querySelector(".debugger"),"f"),i(this,Hh,"f").style.top="32px",i(this,Hh,"f").style.left=window.innerWidth-300-32+"px",o(this,Jh,i(this,Hh,"f").querySelector(".content"),"f"),o(this,Kh,i(this,Hh,"f").querySelector(".header"),"f")}updateData(e){i(this,Bh,"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]=zh(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,Hh,"f"),i(this,Kh,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",i(this,Yh,"f").resize),(e=i(this,Hh,"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,Hh,"f").onresize=i(this,Vh,"m",Xh).bind(this),i(this,Bh,"f").subscribe(i(this,Vh,"m",Gh).bind(this))}disconnectedCallback(){i(this,Bh,"f").unsubscribeAll(),window.removeEventListener("resize",i(this,Yh,"f").resize)}}Bh=new WeakMap,Hh=new WeakMap,Jh=new WeakMap,Kh=new WeakMap,Yh=new WeakMap,Vh=new WeakSet,Gh=function(e){i(this,Vh,"m",Zh).call(this,e),i(this,Vh,"m",Xh).call(this)},Zh=function(e){i(this,Jh,"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 ${v(e.title)}\n </div>\n <div class="msg_desc">\n ${v(e.description)}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},Xh=function(){i(this,Jh,"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)}))},Qh=function(){const[e,t]=zh(i(this,Hh,"f"),Number.parseInt(i(this,Hh,"f").style.left,10),Number.parseInt(i(this,Hh,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});i(this,Hh,"f").style.top=`${t}px`,i(this,Hh,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",np);var ip=Object.freeze({__proto__:null});const op=(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))]},rp=(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]=op(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 sp,ap,lp,cp,dp,up,hp,pp,fp,gp,vp;const mp=document.createElement("template");mp.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 wp=r(J)(HTMLElement);class bp extends wp{constructor(){super(),sp.add(this),ap.set(this,new Id({messages:[]})),lp.set(this,void 0),cp.set(this,void 0),dp.set(this,void 0),up.set(this,{resize:i(this,sp,"m",vp).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(mp.content.cloneNode(!0)),o(this,lp,this.shadowRoot.querySelector(".debugger"),"f"),o(this,cp,i(this,lp,"f").querySelector(".content"),"f"),o(this,dp,i(this,lp,"f").querySelector(".header"),"f"),i(this,sp,"m",hp).call(this)}updateData(e){i(this,ap,"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),rp(i(this,lp,"f"),i(this,dp,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",i(this,up,"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,lp,"f")),i(this,lp,"f").onresize=i(this,sp,"m",gp).bind(this),i(this,ap,"f").subscribe(i(this,sp,"m",pp).bind(this))}))}disconnectedCallback(){i(this,ap,"f").unsubscribeAll(),window.removeEventListener("resize",i(this,up,"f").resize)}}ap=new WeakMap,lp=new WeakMap,cp=new WeakMap,dp=new WeakMap,up=new WeakMap,sp=new WeakSet,hp=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,lp,"f").style.top="32px",i(this,lp,"f").style.left=window.innerWidth-300-32+"px"},pp=function(e){i(this,sp,"m",fp).call(this,e),i(this,sp,"m",gp).call(this)},fp=function(e){i(this,cp,"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 ${v(e.title)}\n </div>\n <div class="msg_desc">\n ${v(e.description)}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},gp=function(){i(this,cp,"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)}))},vp=function(){const[e,t]=op(i(this,lp,"f"),Number.parseInt(i(this,lp,"f").style.left,10),Number.parseInt(i(this,lp,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});i(this,lp,"f").style.top=`${t}px`,i(this,lp,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",bp);var yp=Object.freeze({__proto__:null,default:bp});return zl}();
7
7
  //# sourceMappingURL=index.js.map